atsamd: Reduce memory for have_run_init in spi/i2c

Some of the samd21 chips have limited memory - change the code to
reduce the size of global variables.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-03-01 19:31:18 -05:00
parent 946eb6b7ae
commit 309a47c781
2 changed files with 6 additions and 6 deletions

View File

@ -16,10 +16,10 @@
static void static void
i2c_init(uint32_t bus, SercomI2cm *si) i2c_init(uint32_t bus, SercomI2cm *si)
{ {
static int have_run_init[8]; static uint8_t have_run_init;
if (have_run_init[bus]) if (have_run_init & (1<<bus))
return; return;
have_run_init[bus] = 1; have_run_init |= 1<<bus;
// Configure i2c // Configure i2c
si->CTRLA.reg = 0; si->CTRLA.reg = 0;

View File

@ -13,10 +13,10 @@
void void
spi_init(uint32_t bus, SercomSpi *ss, uint32_t ctrla, uint32_t baud) spi_init(uint32_t bus, SercomSpi *ss, uint32_t ctrla, uint32_t baud)
{ {
static int have_run_init[8]; static uint8_t have_run_init;
if (have_run_init[bus]) if (have_run_init & (1<<bus))
return; return;
have_run_init[bus] = 1; have_run_init |= 1<<bus;
ss->CTRLA.reg = 0; ss->CTRLA.reg = 0;
ss->CTRLA.reg = ctrla & ~SERCOM_SPI_CTRLA_ENABLE; ss->CTRLA.reg = ctrla & ~SERCOM_SPI_CTRLA_ENABLE;