LED: Refactor halt function from CPLD update to core API.

Also call if CPLD load fails.
This commit is contained in:
Jared Boone
2019-02-28 21:32:03 -08:00
parent afb55e18dd
commit 75adda314e
4 changed files with 18 additions and 17 deletions

View File

@ -906,3 +906,18 @@ void led_toggle(const led_t led) {
void hw_sync_enable(const hw_sync_mode_t hw_sync_mode){
gpio_write(&gpio_hw_sync_enable, hw_sync_mode==1);
}
void halt_and_flash(const uint32_t duration) {
/* blink LED1, LED2, and LED3 */
while (1)
{
led_on(LED1);
led_on(LED2);
led_on(LED3);
delay(duration);
led_off(LED1);
led_off(LED2);
led_off(LED3);
delay(duration);
}
}

View File

@ -315,6 +315,7 @@ void led_toggle(const led_t led);
void hw_sync_enable(const hw_sync_mode_t hw_sync_mode);
void halt_and_flash(const uint32_t duration);
#ifdef __cplusplus
}

View File

@ -230,7 +230,7 @@ int main(void) {
cpu_clock_init();
if( !cpld_jtag_sram_load(&jtag_cpld) ) {
// TODO: Fail, do not continue booting.
halt_and_flash(6000000);
}
#ifndef DFU_MODE

View File

@ -61,8 +61,6 @@ static void refill_cpld_buffer(void)
void cpld_update(void)
{
#define WAIT_LOOP_DELAY (6000000)
int i;
int error;
usb_queue_flush_endpoint(&usb_endpoint_bulk_in);
@ -75,20 +73,7 @@ void cpld_update(void)
refill_cpld_buffer);
if(error == 0)
{
/* blink LED1, LED2, and LED3 on success */
while (1)
{
led_on(LED1);
led_on(LED2);
led_on(LED3);
for (i = 0; i < WAIT_LOOP_DELAY; i++) /* Wait a bit. */
__asm__("nop");
led_off(LED1);
led_off(LED2);
led_off(LED3);
for (i = 0; i < WAIT_LOOP_DELAY; i++) /* Wait a bit. */
__asm__("nop");
}
halt_and_flash(6000000);
}else
{
/* LED3 (Red) steady on error */