diff options
| author | Keith Packard <keithp@keithp.com> | 2014-05-12 22:55:38 -0700 |
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2014-05-12 22:55:38 -0700 |
| commit | 530894f508874f4cb3db644ca9ca679ed704f964 (patch) | |
| tree | 6f0744a9eee34ee9028ee26a77a325ca224a6b7f /src/stm/ao_interrupt.c | |
| parent | 2c543be5548ccda6bd29a2a7659fcc287f7a9f07 (diff) | |
altos/stm: Figure out available flash space based on chip id registers
Look at the flash size and the device id registers to figure out how
much flash is available.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/stm/ao_interrupt.c')
| -rw-r--r-- | src/stm/ao_interrupt.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/stm/ao_interrupt.c b/src/stm/ao_interrupt.c index 969e6a0f..56cce0c0 100644 --- a/src/stm/ao_interrupt.c +++ b/src/stm/ao_interrupt.c @@ -39,6 +39,38 @@ void stm_ignore_isr(void) const void *stm_interrupt_vector[]; +uint32_t +stm_flash_size(void) { + uint16_t dev_id = stm_dev_id(); + uint16_t kbytes = 0; + + switch (dev_id) { + case 0x416: /* cat 1 */ + kbytes = stm_flash_size_medium.f_size; + break; + case 0x429: /* cat 2 */ + kbytes = stm_flash_size_medium.f_size & 0xff; + break; + case 0x427: /* cat 3 */ + kbytes = stm_flash_size_large.f_size; + break; + case 0x436: /* cat 4 */ + switch (stm_flash_size_large.f_size) { + case 0: + kbytes = 256; + break; + case 1: + kbytes = 384; + break; + } + break; + case 0x437: /* cat 5 */ + kbytes = stm_flash_size_large.f_size; + break; + } + return (uint32_t) kbytes * 1024; +} + void start(void) { #ifdef AO_BOOT_CHAIN |
