diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2019-03-01 19:31:18 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2019-03-01 19:31:18 -0500 |
commit | 309a47c7810bf55d993210c2da014ede7dae8a87 (patch) | |
tree | ee054976fc1f80672030234bfb34548628011767 | |
parent | 946eb6b7ae9e44e984ca1377ae9de5d7a36f2a44 (diff) | |
download | kutter-309a47c7810bf55d993210c2da014ede7dae8a87.tar.gz kutter-309a47c7810bf55d993210c2da014ede7dae8a87.tar.xz kutter-309a47c7810bf55d993210c2da014ede7dae8a87.zip |
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>
-rw-r--r-- | src/atsamd/i2c.c | 6 | ||||
-rw-r--r-- | 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<<bus)) return; - have_run_init[bus] = 1; + have_run_init |= 1<<bus; // Configure i2c si->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<<bus)) return; - have_run_init[bus] = 1; + have_run_init |= 1<<bus; ss->CTRLA.reg = 0; ss->CTRLA.reg = ctrla & ~SERCOM_SPI_CTRLA_ENABLE; |