добавлена поддержка платы Start-MIK32
This commit is contained in:
1 parent
8c82685f37
commit
f06650400b
46 files changed
+1813
-163
No files matched your search
+11
-11
@@ -21,14 +21,14 @@ void SPISettings::spiUpdateSettings(uint32_t speedMaximum, uint8_t dataOrder, ui
|
||||
// Find the fastest clock that is less than or equal to the
|
||||
// given clock rate. If nothing is slow enough - use the slowest.
|
||||
// mik32v2 has the set of deviders, that can be calculate as:
|
||||
// div = 2 << (1...7). Value in braсkets is a value for config register
|
||||
// div = 2 << (0...7). Value in braсkets is a value for config register
|
||||
uint8_t divRegVal = 0; // start from minimal divider (maximum speed)
|
||||
while(divRegVal < 7)
|
||||
while(divRegVal <= 7)
|
||||
{
|
||||
divRegVal++; // values from 1 to 7
|
||||
if ((F_CPU/(2 << divRegVal)) <= speedMaximum)
|
||||
// find suitable divider
|
||||
break;
|
||||
divRegVal++;
|
||||
}
|
||||
// if break didn't call in cycle, it will be the greatest divRegVal (and divider)
|
||||
|
||||
@@ -95,7 +95,7 @@ void SPIClass::end()
|
||||
|
||||
void SPIClass::usingInterrupt(uint8_t interruptNumber)
|
||||
{
|
||||
if(interruptNumber < EXTERNAL_NUM_INTERRUPTS)
|
||||
if(interruptNumber < EXTERNAL_INTERRUPTS_QTY)
|
||||
{
|
||||
noInterrupts(); // prevent transactionBegin
|
||||
interruptMask |= (1 << interruptNumber); // add new interrupt to mask
|
||||
@@ -107,7 +107,7 @@ void SPIClass::usingInterrupt(uint8_t interruptNumber)
|
||||
|
||||
void SPIClass::notUsingInterrupt(uint8_t interruptNumber)
|
||||
{
|
||||
if(interruptNumber < EXTERNAL_NUM_INTERRUPTS)
|
||||
if(interruptNumber < EXTERNAL_INTERRUPTS_QTY)
|
||||
{
|
||||
noInterrupts(); // prevent transactionBegin
|
||||
interruptMask &= ~(1<<interruptNumber); // delete interrupt from mask
|
||||
@@ -122,7 +122,7 @@ void SPIClass::beginTransaction(SPISettings settings)
|
||||
// disable interrupts in use if necessary
|
||||
if (spiInUse && (interruptMode > 0))
|
||||
{
|
||||
for (uint8_t i = 0; i < EXTERNAL_NUM_INTERRUPTS; i++)
|
||||
for (uint8_t i = 0; i < EXTERNAL_INTERRUPTS_QTY; i++)
|
||||
{
|
||||
if (interruptMask & (1 << i))
|
||||
// disable every interrupt by it's number
|
||||
@@ -234,7 +234,7 @@ void SPIClass::endTransaction(void)
|
||||
// enable interrupts in use
|
||||
if (spiInUse && (interruptMode > 0))
|
||||
{
|
||||
for (uint8_t i = 0; i < EXTERNAL_NUM_INTERRUPTS; i++)
|
||||
for (uint8_t i = 0; i < EXTERNAL_INTERRUPTS_QTY; i++)
|
||||
{
|
||||
if (interruptMask & (1 << i))
|
||||
// enable every interrupt in use by it's number
|
||||
@@ -270,10 +270,10 @@ void SPIClass::setClockDivider(uint8_t clockDiv)
|
||||
if (spiInUse)
|
||||
{
|
||||
// if divider is valid
|
||||
if ((clockDiv == SPI_CLOCK_DIV4) || (clockDiv == SPI_CLOCK_DIV8) ||
|
||||
(clockDiv == SPI_CLOCK_DIV16) || (clockDiv == SPI_CLOCK_DIV32) ||
|
||||
(clockDiv == SPI_CLOCK_DIV64) || (clockDiv == SPI_CLOCK_DIV128) ||
|
||||
(clockDiv == SPI_CLOCK_DIV256))
|
||||
if ((clockDiv == SPI_CLOCK_DIV2) || (clockDiv == SPI_CLOCK_DIV4) ||
|
||||
(clockDiv == SPI_CLOCK_DIV8) || (clockDiv == SPI_CLOCK_DIV16) ||
|
||||
(clockDiv == SPI_CLOCK_DIV32) || (clockDiv == SPI_CLOCK_DIV64) ||
|
||||
(clockDiv == SPI_CLOCK_DIV128) || (clockDiv == SPI_CLOCK_DIV256))
|
||||
{
|
||||
hspi.Init.BaudRateDiv = clockDiv;
|
||||
currentSpeed = F_CPU >> (clockDiv+1);
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
|
||||
// dividers for setClockDivider()
|
||||
#define SPI_CLOCK_DIV2 0x00 // 16 MHz
|
||||
#define SPI_CLOCK_DIV4 0x01 // 8 MHz
|
||||
#define SPI_CLOCK_DIV8 0x02 // 4 MHz
|
||||
#define SPI_CLOCK_DIV16 0x03 // 2 MHz
|
||||
|
||||
Reference in new issue
Block a user