From 309a47c7810bf55d993210c2da014ede7dae8a87 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 1 Mar 2019 19:31:18 -0500 Subject: [PATCH] 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 --- src/atsamd/i2c.c | 6 +++--- src/atsamd/spi.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/atsamd/i2c.c b/src/atsamd/i2c.c index 89b190fa..e5e0a379 100644 --- a/src/atsamd/i2c.c +++ b/src/atsamd/i2c.c @@ -16,10 +16,10 @@ static void i2c_init(uint32_t bus, SercomI2cm *si) { - static int have_run_init[8]; - if (have_run_init[bus]) + static uint8_t have_run_init; + if (have_run_init & (1<CTRLA.reg = 0; diff --git a/src/atsamd/spi.c b/src/atsamd/spi.c index 4bf281bc..96125d5b 100644 --- a/src/atsamd/spi.c +++ b/src/atsamd/spi.c @@ -13,10 +13,10 @@ void spi_init(uint32_t bus, SercomSpi *ss, uint32_t ctrla, uint32_t baud) { - static int have_run_init[8]; - if (have_run_init[bus]) + static uint8_t have_run_init; + if (have_run_init & (1<CTRLA.reg = 0; ss->CTRLA.reg = ctrla & ~SERCOM_SPI_CTRLA_ENABLE;