Skip to content

Commit

Permalink
Blink the green LED when the new firmware has been programmed
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauszus committed May 14, 2017
1 parent ec0a370 commit 4c13a82
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
14 changes: 8 additions & 6 deletions boot_usb_msc.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,14 @@ int main(void)
UARTprintf("Bootloader started\n\n");
#endif

ROM_GPIOPinTypeGPIOOutput(LED_GPIO_BASE, LED_BLUE);
ROM_GPIOPinTypeGPIOOutput(LED_GPIO_BASE, LED_GREEN | LED_BLUE);
while(1) {
// Blink the blue LED so the user knows we're in a bootloader mode
ROM_GPIOPinWrite(LED_GPIO_BASE, LED_BLUE, LED_BLUE);
ROM_SysCtlDelay(ROM_SysCtlClockGet() / 4 / 2);
ROM_GPIOPinWrite(LED_GPIO_BASE, LED_BLUE, 0);
ROM_SysCtlDelay(ROM_SysCtlClockGet() / 4 / 2);
// Blink the blue LED so the user knows we are in bootloader mode
// The green LED will blink when the new firmware has been programmed
const uint32_t led = newFirmwareStartSet ? LED_GREEN : LED_BLUE; // TODO: Use different flag
ROM_GPIOPinWrite(LED_GPIO_BASE, LED_GREEN | LED_BLUE, led);
ROM_SysCtlDelay(ROM_SysCtlClockGet() / 4 / 2);
ROM_GPIOPinWrite(LED_GPIO_BASE, LED_GREEN | LED_BLUE, 0);
ROM_SysCtlDelay(ROM_SysCtlClockGet() / 4 / 2);
}
}
4 changes: 2 additions & 2 deletions ramdisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#define FIRMWARE_START_SECTOR (DATA_REGION_SECTOR + (firmware_start_cluster - 2) * SECTORS_PER_CLUSTER)

int massStorageDrive = 0;
int newFirmwareStartSet = 0;
bool newFirmwareStartSet = false;
unsigned long firmware_start_cluster = FIRMWARE_BIN_CLUSTER;

unsigned char bootSector[] = {
Expand Down Expand Up @@ -306,7 +306,7 @@ unsigned long massStorageWrite(void *drive, unsigned char *data, unsigned long b
else if (blockNumber >= FIRMWARE_START_SECTOR) {
if (isFirmwareStart(data)) { // TODO: Reset flag after when the firmware has been read
// the host tried to write actual data to the data region, we assume this is the new firmware
newFirmwareStartSet = 1;
newFirmwareStartSet = true;
firmware_start_cluster = (blockNumber - DATA_REGION_SECTOR) / SECTORS_PER_CLUSTER + 2;
#ifdef DEBUGUART
UARTprintf("New firmware start\n");
Expand Down
2 changes: 2 additions & 0 deletions ramdisk.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ extern unsigned long massStorageRead(void *drive, unsigned char *data, unsigned
extern unsigned long massStorageWrite(void *drive, unsigned char *data, unsigned long blockNumber, unsigned long numberOfBlocks);
extern unsigned long massStorageNumBlocks(void *drive);

extern bool newFirmwareStartSet;

#endif

0 comments on commit 4c13a82

Please sign in to comment.