Проверка в analogWrite(), добавление экземпляров для Wire, SPI, Serial #21

Merged
klassents merged 12 commits from v0.5.1_editing into v0.5.1 2025-05-27 12:35:38 +03:00
6 changed files with 44 additions and 36 deletions
Showing only changes of commit 90b42b9fac - Show all commits

View File

@ -1,9 +1,11 @@
#include "SPI.h"
SPIClass SPI(1);
SPIClass SPI1(1);
#if SPI_COMMON_QTY > 1
SPIClass SPI1(0);
SPIClass SPI0(0);
#endif
// default interface
SPIClass& SPI = DEFAULT_SPI;
static uint8_t reverse_bits(uint8_t byte);

View File

@ -127,9 +127,11 @@ public:
void setClockDivider(uint8_t clockDiv);
};
extern SPIClass SPI;
#if SPI_COMMON_QTY > 1
extern SPIClass SPI1;
#if SPI_COMMON_QTY > 1
extern SPIClass SPI0;
#endif
// default interface
extern SPIClass& SPI;
#endif

View File

@ -106,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
@ -117,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

View File

@ -101,6 +101,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
@ -111,14 +112,14 @@ static const uint8_t MOSI = PIN_SPI_MOSI;
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 SS1 = PIN_SPI0_SS;
static const uint8_t MOSI1 = PIN_SPI0_MOSI;
static const uint8_t MISO1 = PIN_SPI0_MISO;
static const uint8_t SCK1 = 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

View File

@ -131,6 +131,7 @@ HAL_TIMER32_CHANNEL_IndexTypeDef pwmPinToTimerChannel(uint32_t digPinNumber);
// SPI
#define SPI_COMMON_QTY 2
#define DEFAULT_SPI SPI1
#define PIN_SPI_SS P1_3
#define PIN_SPI_MOSI P1_1
@ -141,14 +142,14 @@ static const uint8_t MOSI = PIN_SPI_MOSI;
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK = PIN_SPI_SCK;
#define PIN_SPI1_SS P0_3
#define PIN_SPI1_MOSI P0_1
#define PIN_SPI1_MISO P0_0
#define PIN_SPI1_SCK P0_2
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 P0_3
#define PIN_SPI0_MOSI P0_1
#define PIN_SPI0_MISO P0_0
#define PIN_SPI0_SCK P0_2
static const uint8_t SS1 = PIN_SPI0_SS;
static const uint8_t MOSI1 = PIN_SPI0_MOSI;
static const uint8_t MISO1 = PIN_SPI0_MISO;
static const uint8_t SCK1 = PIN_SPI0_SCK;
// check if pwm is used on spi pins
void spi_onBegin(uint8_t spiNum);

View File

@ -144,6 +144,7 @@ HAL_TIMER32_CHANNEL_IndexTypeDef pwmPinToTimerChannel(uint32_t digPinNumber);
// SPI
#define SPI_COMMON_QTY 2
#define DEFAULT_SPI SPI1
#define PIN_SPI_SS P1_3
#define PIN_SPI_MOSI P1_1
@ -154,14 +155,14 @@ static const uint8_t MOSI = PIN_SPI_MOSI;
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK = PIN_SPI_SCK;
#define PIN_SPI1_SS P0_3
#define PIN_SPI1_MOSI P0_1
#define PIN_SPI1_MISO P0_0
#define PIN_SPI1_SCK P0_2
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 P0_3
#define PIN_SPI0_MOSI P0_1
#define PIN_SPI0_MISO P0_0
#define PIN_SPI0_SCK P0_2
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;
// check if pwm is used on spi pins
void spi_onBegin(uint8_t spiNum);