void timer4_init(void) { // // Enable the peripherals used by this example. // SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER4); // // Configure the 32-bit periodic timer. // TimerConfigure(TIMER4_BASE, TIMER_CFG_PERIODIC); TimerLoadSet(TIMER4_BASE, TIMER_A, ui32SysClock/1000); //Clock at 120 MHz IntPrioritySet(INT_TIMER4A, 0x00); // // Setup the interrupts for the timer timeouts. // IntEnable(INT_TIMER4A); TimerIntEnable(TIMER4_BASE, TIMER_TIMA_TIMEOUT); // // Enable the timers. // TimerEnable(TIMER4_BASE, TIMER_A); } #define FLASH_EVENT_START 0x6C000 //Address of the first block of flash to be used for storing events.475136 0x6C000 // 524288-16384(boot)-16384(params)-16384(events)=475136 #define FLASH_EVENT_END 0x70000 //Address of the last block of flash to be used for storing events. #define FLASH_BLOCK_SIZE 0x4000 //Flash erases in 16k block increments. //4000 DR #define FLASH_BLOCKS_TO_ERASE 1 // Number of blocks to erase. long Event_Schedule_Save(DIGITAL_EVENT_SCHEDULE* einfo) { // Save Event Info long error = 1; tFlashProtection state; int i; FLASH_EVENT_START= ASSERT((FLASH_EVENT_START % 4) == 0); // Starting address must be a multiple of 4. ASSERT((sizeof(einfo) % 4) == 0); // Number of bytes to be programmed must be a multiple of 4. state = FlashProtectGet(FLASH_EVENT_START); // Get protection setting for block of memory to be used. if (state == FlashReadWrite) { // States are r/w, ro, xo, must r/w. error = FlashErase(FLASH_EVENT_START); // Erase flash in 16k block increments. } else error = -1; // Error if state is not r/w. if (!error) error = FlashProgram((uint32_t*) einfo, FLASH_EVENT_START, sizeof(DIGITAL_EVENT_SCHEDULE)); return (error); // -1 indicates programming error, 0 is success. } typedef struct { union { struct { EVENT_SCHEDULE_HEADER HEADER; DIGITAL_EVENT EVENTS[EVENT_COUNT]; }; unsigned char Byte[DIGITAL_EVENT_SCHEDULE_SIZE + EVENT_SCHEDULE_HEADER_SIZE]; }; } DIGITAL_EVENT_SCHEDULE;