добавлена поддержка еще одного прерывания и еще двух выводов для ШИМ для
платы Elbear. добавлены флаги компиляции, необходимые для работы в ArduinoIDE v1.8.19
This commit is contained in:
1 parent
f06650400b
commit
a32d749c60
19 files changed
+172
-116
No files matched your search
@@ -32,49 +32,51 @@ extern "C" {
|
||||
#include "mik32_hal_gpio.h"
|
||||
#include "mik32_hal_timer32.h"
|
||||
|
||||
#define PORT_PIN_MASK 0xF
|
||||
|
||||
// digital pins
|
||||
#define P0_0 0
|
||||
#define P0_1 1
|
||||
#define P0_2 2
|
||||
#define P0_3 3
|
||||
#define P0_4 4
|
||||
#define P0_5 5
|
||||
#define P0_6 6
|
||||
#define P0_7 7
|
||||
#define P0_8 8
|
||||
#define P0_9 9
|
||||
#define P0_10 10
|
||||
#define P0_11 11
|
||||
#define P0_12 12
|
||||
#define P0_13 13
|
||||
#define P0_14 14
|
||||
#define P0_15 15
|
||||
#define P1_0 16
|
||||
#define P1_1 17
|
||||
#define P1_2 18
|
||||
#define P1_3 19
|
||||
#define P1_4 20
|
||||
#define P1_5 21
|
||||
#define P1_6 22
|
||||
#define P1_7 23
|
||||
#define P1_8 24
|
||||
#define P1_9 25
|
||||
#define P1_10 26
|
||||
#define P1_11 27
|
||||
#define P1_12 28
|
||||
#define P1_13 29
|
||||
#define P1_14 30
|
||||
#define P1_15 31
|
||||
#define P2_0 32
|
||||
#define P2_1 33
|
||||
#define P2_2 34
|
||||
#define P2_3 35
|
||||
#define P2_4 36
|
||||
#define P2_5 37
|
||||
#define P2_6 38
|
||||
#define P2_7 39
|
||||
typedef enum
|
||||
{
|
||||
P0_0 = 0, // 0
|
||||
P0_1, // 1
|
||||
P0_2, // 2
|
||||
P0_3, // 3
|
||||
P0_4, // 4
|
||||
P0_5, // 5
|
||||
P0_6, // 6
|
||||
P0_7, // 7
|
||||
P0_8, // 8
|
||||
P0_9, // 9
|
||||
P0_10, // 10
|
||||
P0_11, // 11
|
||||
P0_12, // 12
|
||||
P0_13, // 13
|
||||
P0_14, // 14
|
||||
P0_15, // 15
|
||||
P1_0, // 16
|
||||
P1_1, // 17
|
||||
P1_2, // 18
|
||||
P1_3, // 19
|
||||
P1_4, // 20
|
||||
P1_5, // 21
|
||||
P1_6, // 22
|
||||
P1_7, // 23
|
||||
P1_8, // 24
|
||||
P1_9, // 25
|
||||
P1_10, // 26
|
||||
P1_11, // 27
|
||||
P1_12, // 28
|
||||
P1_13, // 29
|
||||
P1_14, // 30
|
||||
P1_15, // 31
|
||||
P2_0, // 32
|
||||
P2_1, // 33
|
||||
P2_2, // 34
|
||||
P2_3, // 35
|
||||
P2_4, // 36
|
||||
P2_5, // 37
|
||||
P2_6, // 38
|
||||
P2_7, // 39
|
||||
PINS_COMMON_QTY, // 40
|
||||
} DigitalPinsTypeDef;
|
||||
|
||||
// analog pins
|
||||
#define PIN_A0 (P1_5)
|
||||
@@ -105,9 +107,15 @@ static const uint8_t A7 = PIN_A7;
|
||||
// determines the address of the port by the board pin number to which this pin belongs on the MCU
|
||||
GPIO_TypeDef* digitalPinToPort(uint32_t digPinNumber);
|
||||
// determines the pin address inside the port by the board pin number
|
||||
HAL_PinsTypeDef digitalPinToBitMask(uint32_t digPinNumber);
|
||||
static inline HAL_PinsTypeDef digitalPinToBitMask(uint32_t digitalPinNumber)
|
||||
{
|
||||
return (HAL_PinsTypeDef)(1 << (digitalPinNumber & 0xF));
|
||||
}
|
||||
// total number of pins available for initialization
|
||||
uint16_t pinCommonQty(void);
|
||||
static inline uint16_t pinCommonQty(void)
|
||||
{
|
||||
return (uint16_t)PINS_COMMON_QTY;
|
||||
}
|
||||
// the function returns a reference to the OUTPUT address of the GPIO register
|
||||
volatile uint32_t* portOutputRegister(GPIO_TypeDef* GPIO_x);
|
||||
// the function returns a reference to the STATE address of the GPIO register
|
||||
|
||||
@@ -41,17 +41,6 @@ GPIO_TypeDef *digitalPinToPort(uint32_t digitalPinNumber)
|
||||
}
|
||||
}
|
||||
|
||||
// determines the pin address inside the port by the board pin number
|
||||
HAL_PinsTypeDef digitalPinToBitMask(uint32_t digitalPinNumber)
|
||||
{
|
||||
return 1 << (digitalPinNumber & 0xF);
|
||||
}
|
||||
|
||||
uint16_t pinCommonQty(void)
|
||||
{
|
||||
return (uint16_t)40;
|
||||
}
|
||||
|
||||
// the function returns a reference to the OUTPUT address of the GPIO register
|
||||
volatile uint32_t *portOutputRegister(GPIO_TypeDef *GPIO_x)
|
||||
{
|
||||
@@ -105,17 +94,13 @@ uint32_t analogInputToChannelNumber(uint32_t PinNumber)
|
||||
// ---------------------- PWM ---------------------- //
|
||||
// use only if digitalPinHasPWM() == true
|
||||
#define PWM_PIN_TO_PORT_NUMBER(pin) (((pin) & 16) ? 1 : 0)
|
||||
// use only if digitalPinHasPWM() == true
|
||||
static inline uint8_t pwmPinToGpioPinShift(uint8_t digitalPin)
|
||||
{
|
||||
return digitalPin & 3;
|
||||
}
|
||||
|
||||
// use only if digitalPinHasPWM() == true
|
||||
// return true if digitalPin configured as pwm
|
||||
bool digitalPinPwmIsOn(uint8_t digitalPin)
|
||||
{
|
||||
uint8_t config = 0;
|
||||
uint8_t pinShift = pwmPinToGpioPinShift(digitalPin);
|
||||
uint8_t pinShift = digitalPin & 3;
|
||||
|
||||
if (PWM_PIN_TO_PORT_NUMBER(digitalPin) == 0)
|
||||
config = PIN_GET_PAD_CONFIG(PORT_0_CFG, pinShift);
|
||||
|
||||
Reference in new issue
Block a user