Removed redeclaration of peripheral bus freq
This commit is contained in:
parent
0e3f3bb2ca
commit
b5c2120efc
2 changed files with 5 additions and 7 deletions
|
@ -194,13 +194,13 @@ void spi_transfer(uint8_t bus, void *data, size_t len)
|
||||||
spi_endianness_t e = spi_get_endianness(bus);
|
spi_endianness_t e = spi_get_endianness(bus);
|
||||||
spi_set_endianness(bus, SPI_LITTLE_ENDIAN);
|
spi_set_endianness(bus, SPI_LITTLE_ENDIAN);
|
||||||
|
|
||||||
size_t counts = len / _SPI_BUF_SIZE;
|
size_t blocks = len / _SPI_BUF_SIZE;
|
||||||
for (uint8_t i = 0; i < counts; i++)
|
for (uint8_t i = 0; i < blocks; i++)
|
||||||
_spi_buf_transfer(bus, data + i * _SPI_BUF_SIZE, _SPI_BUF_SIZE);
|
_spi_buf_transfer(bus, data + i * _SPI_BUF_SIZE, _SPI_BUF_SIZE);
|
||||||
|
|
||||||
uint8_t tail = len % _SPI_BUF_SIZE;
|
uint8_t tail = len % _SPI_BUF_SIZE;
|
||||||
if (tail)
|
if (tail)
|
||||||
_spi_buf_transfer(bus, data + counts * _SPI_BUF_SIZE, tail);
|
_spi_buf_transfer(bus, data + blocks * _SPI_BUF_SIZE, tail);
|
||||||
|
|
||||||
spi_set_endianness(bus, e);
|
spi_set_endianness(bus, e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "esp/spi_regs.h"
|
#include "esp/spi_regs.h"
|
||||||
|
#include "esp/clocks.h"
|
||||||
// FIXME Better to define it somewhere else. This is not the CPU frequency!
|
|
||||||
#define SYSTEM_BUS_FREQ 80000000UL
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro for use with spi_init and spi_set_frequency_div.
|
* Macro for use with spi_init and spi_set_frequency_div.
|
||||||
|
@ -121,7 +119,7 @@ void spi_set_frequency_div(uint8_t bus, uint32_t divider);
|
||||||
*/
|
*/
|
||||||
inline uint32_t spi_get_frequency_hz(uint8_t bus)
|
inline uint32_t spi_get_frequency_hz(uint8_t bus)
|
||||||
{
|
{
|
||||||
return SYSTEM_BUS_FREQ /
|
return APB_CLK_FREQ /
|
||||||
(((SPI(bus).CLOCK >> SPI_CLOCK_DIV_PRE_S) & SPI_CLOCK_DIV_PRE_M) + 1) /
|
(((SPI(bus).CLOCK >> SPI_CLOCK_DIV_PRE_S) & SPI_CLOCK_DIV_PRE_M) + 1) /
|
||||||
(((SPI(bus).CLOCK >> SPI_CLOCK_COUNT_NUM_S) & SPI_CLOCK_COUNT_NUM_M) + 1);
|
(((SPI(bus).CLOCK >> SPI_CLOCK_COUNT_NUM_S) & SPI_CLOCK_COUNT_NUM_M) + 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue