v0.5.1
- в модулях Wire, SPI, Serial приведена в соответствие нумерация используемых экземпляров и периферии микроконтроллера. - в функции analogWrite() перед запуском ШИМ проверяется, не запущен ли уже указанный канал. - добавлена возможность переопределения функции main() в скетчах. - при старте программы задается граница кэшируемой области SPIFI в соответствии с размером текущего исполняемого кода. - исправление выявленных ошибок. Co-authored-by: KLASSENTS <klassen@elron.tech> Co-committed-by: KLASSENTS <klassen@elron.tech>
This commit was merged in pull request #25.
This commit is contained in:
1 parent
f1e091bf77
commit
eb9b1aa0c9
37 files changed
+248
-156
No files matched your search
@@ -81,6 +81,7 @@ void additionalPinsDeinit(uint32_t PinNumber);
|
||||
// UART
|
||||
// available uarts quantity
|
||||
#define SERIAL_PORT_QTY 2
|
||||
#define DEFAULT_SERIAL Serial0
|
||||
|
||||
// ADC
|
||||
#define MCU_ADC_RESOLUTION 12 // bits
|
||||
@@ -97,7 +98,7 @@ static inline __attribute__((always_inline)) bool digitalPinHasPWM(uint8_t p)
|
||||
return false;
|
||||
}
|
||||
// return true if digitalPin configured as pwm
|
||||
bool digitalPinPwmIsOn(uint8_t digitalPin);
|
||||
int8_t digitalPinPwmIsOn(uint8_t digitalPin);
|
||||
// determines which timer the pin belongs to
|
||||
TIMER32_TypeDef* pwmPinToTimer(uint32_t digPinNumber);
|
||||
// determines which timer channel the pin belongs to
|
||||
@@ -105,6 +106,7 @@ HAL_TIMER32_CHANNEL_IndexTypeDef pwmPinToTimerChannel(uint32_t digPinNumber);
|
||||
|
||||
// SPI
|
||||
#define SPI_COMMON_QTY 2
|
||||
#define DEFAULT_SPI SPI1
|
||||
|
||||
#define PIN_SPI_SS 10
|
||||
#define PIN_SPI_MOSI 11
|
||||
@@ -116,14 +118,14 @@ static const uint8_t MISO = PIN_SPI_MISO;
|
||||
static const uint8_t SCK = PIN_SPI_SCK;
|
||||
|
||||
|
||||
#define PIN_SPI1_SS 9
|
||||
#define PIN_SPI1_MOSI 5
|
||||
#define PIN_SPI1_MISO 3
|
||||
#define PIN_SPI1_SCK 6
|
||||
static const uint8_t SS1 = PIN_SPI1_SS;
|
||||
static const uint8_t MOSI1 = PIN_SPI1_MOSI;
|
||||
static const uint8_t MISO1 = PIN_SPI1_MISO;
|
||||
static const uint8_t SCK1 = PIN_SPI1_SCK;
|
||||
#define PIN_SPI0_SS 9
|
||||
#define PIN_SPI0_MOSI 5
|
||||
#define PIN_SPI0_MISO 3
|
||||
#define PIN_SPI0_SCK 6
|
||||
static const uint8_t SS0 = PIN_SPI0_SS;
|
||||
static const uint8_t MOSI0 = PIN_SPI0_MOSI;
|
||||
static const uint8_t MISO0 = PIN_SPI0_MISO;
|
||||
static const uint8_t SCK0 = PIN_SPI0_SCK;
|
||||
|
||||
// config SEL_NSS1 to replace D10 to different controller pin,
|
||||
// because NSS which is D9/D10 by default is needed to spi
|
||||
@@ -131,9 +133,10 @@ void spi_onBegin(uint8_t spiNum);
|
||||
void spi_onEnd(uint8_t spiNum);
|
||||
|
||||
// I2C
|
||||
#define I2C_COMMON_QTY 1
|
||||
#define DEFAULT_WIRE Wire1 // use I2C1 by default
|
||||
#define PIN_WIRE_SDA 18
|
||||
#define PIN_WIRE_SCL 19
|
||||
#define I2C_COMMON_QTY 1
|
||||
static const uint8_t SDA = PIN_WIRE_SDA;
|
||||
static const uint8_t SCL = PIN_WIRE_SCL;
|
||||
// available frequencies
|
||||
|
||||
@@ -204,27 +204,27 @@ uint32_t analogInputToChannelNumber(uint32_t PinNumber)
|
||||
}
|
||||
|
||||
// ---------------------- PWM ---------------------- //
|
||||
// use only if digitalPinHasPWM() == true
|
||||
#define PWM_PIN_TO_PORT_NUMBER(pin) (((pin==10)||(pin==11)||(pin==12)||(pin==13)) ? 1:0)
|
||||
|
||||
// use only if digitalPinHasPWM() == true
|
||||
// return true if digitalPin configured as pwm
|
||||
__attribute__((noinline, section(".ram_text"))) bool digitalPinPwmIsOn(uint8_t digitalPin)
|
||||
// return 1 if digitalPin configured as pwm and enabled,
|
||||
// 0 if pwm on pin is disabled,
|
||||
// -1 if pin doesn't support pwm
|
||||
__attribute__((noinline, section(".ram_text"))) int8_t digitalPinPwmIsOn(uint8_t digitalPin)
|
||||
{
|
||||
if (digitalPinHasPWM(digitalPin))
|
||||
{
|
||||
uint8_t config = 0;
|
||||
uint8_t pinShift = PIN_MASK_TO_PIN_NUMBER(digitalPinToBitMask(digitalPin));
|
||||
|
||||
if (PWM_PIN_TO_PORT_NUMBER(digitalPin) == 0)
|
||||
config = PIN_GET_PAD_CONFIG(PORT_0_CFG, pinShift);
|
||||
else
|
||||
if ((digitalPin==10)||(digitalPin==11)||(digitalPin==12)||(digitalPin==13))
|
||||
config = PIN_GET_PAD_CONFIG(PORT_1_CFG, pinShift);
|
||||
else
|
||||
config = PIN_GET_PAD_CONFIG(PORT_0_CFG, pinShift);
|
||||
|
||||
if (config == 2)
|
||||
return true;
|
||||
return 1; // pwm is on
|
||||
else
|
||||
return 0; // pwm is off
|
||||
}
|
||||
return false;
|
||||
return -1; // pin doesn't support pwm
|
||||
}
|
||||
|
||||
// function is used only if digitalPinHasPWM() is true
|
||||
|
||||
Reference in new issue
Block a user