43 #include "dev/flash.h" 44 #include "dev/watchdog.h" 50 #ifndef COFFEE_CONF_CUSTOM_PORT 52 #if !COFFEE_SECTOR_SIZE || COFFEE_SECTOR_SIZE % FLASH_PAGE_SIZE 53 #error COFFEE_SECTOR_SIZE must be a non-zero multiple of the flash page size 55 #if !COFFEE_PAGE_SIZE || COFFEE_SECTOR_SIZE % COFFEE_PAGE_SIZE 56 #error COFFEE_PAGE_SIZE must be a divisor of COFFEE_SECTOR_SIZE 58 #if COFFEE_PAGE_SIZE % FLASH_WORD_SIZE 59 #error COFFEE_PAGE_SIZE must be a multiple of the flash word size 61 #if COFFEE_START % FLASH_PAGE_SIZE 62 #error COFFEE_START must be aligned with a flash page boundary 64 #if COFFEE_SIZE % COFFEE_SECTOR_SIZE 65 #error COFFEE_SIZE must be a multiple of COFFEE_SECTOR_SIZE 67 #if COFFEE_SIZE / COFFEE_PAGE_SIZE > INT16_MAX 68 #error Too many Coffee pages for coffee_page_t 70 #if COFFEE_START < CC2538_DEV_FLASH_ADDR || \ 71 COFFEE_START + COFFEE_SIZE > FLASH_CCA_ADDR 72 #error Coffee does not fit in flash 88 const uint32_t *src = buf;
95 if(size && (align = flash_addr & (FLASH_WORD_SIZE - 1))) {
96 len = MIN(FLASH_WORD_SIZE - align, size);
97 word = ~((*src & ((1 << (len << 3)) - 1)) << (align << 3));
100 rom_util_program_flash(&word, flash_addr & ~(FLASH_WORD_SIZE - 1),
103 *(
const uint8_t **)&src += len;
108 while(size >= FLASH_WORD_SIZE) {
110 for(i = 0; i < len / FLASH_WORD_SIZE; i++) {
111 page_buf[i] = ~*src++;
115 rom_util_program_flash(page_buf, flash_addr, len);
122 word = ~(*src & ((1 << (size << 3)) - 1));
125 rom_util_program_flash(&word, flash_addr, FLASH_WORD_SIZE);
137 for(src = (
const void *)(
COFFEE_START + offset), dst = buf; size; size--) {
void cfs_coffee_arch_read(void *buf, unsigned int size, cfs_offset_t offset)
Reads from the device to a buffer.
void cfs_coffee_arch_erase(uint16_t sector)
Erases a device sector.
#define INTERRUPTS_DISABLE()
Disables all CPU interrupts.
Header for the Coffee file system.
#define INTERRUPTS_ENABLE()
Enables all CPU interrupts.
void cfs_coffee_arch_write(const void *buf, unsigned int size, cfs_offset_t offset)
Writes a buffer to the device.
Header file with prototypes for interrupt control on the cc2538 Cortex-M3 micro.
Header file for the cc2538 devices definitions.
#define COFFEE_START
Start offset of the file system.
Header file for the cc2538 ROM utility function library driver.
#define COFFEE_SECTOR_SIZE
Logical sector size.
Header file for the cc2538 Coffee port module.
void watchdog_periodic(void)
Writes the WDT clear sequence.
Default definitions of C compiler quirk work-arounds.
#define COFFEE_PAGE_SIZE
Logical page size.