LED: Refactor halt function from CPLD update to core API.
Also call if CPLD load fails.
This commit is contained in:
@ -906,3 +906,18 @@ void led_toggle(const led_t led) {
|
|||||||
void hw_sync_enable(const hw_sync_mode_t hw_sync_mode){
|
void hw_sync_enable(const hw_sync_mode_t hw_sync_mode){
|
||||||
gpio_write(&gpio_hw_sync_enable, hw_sync_mode==1);
|
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);
|
||||||
|
}
|
||||||
|
}
|
@ -315,6 +315,7 @@ void led_toggle(const led_t led);
|
|||||||
|
|
||||||
void hw_sync_enable(const hw_sync_mode_t hw_sync_mode);
|
void hw_sync_enable(const hw_sync_mode_t hw_sync_mode);
|
||||||
|
|
||||||
|
void halt_and_flash(const uint32_t duration);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ int main(void) {
|
|||||||
cpu_clock_init();
|
cpu_clock_init();
|
||||||
|
|
||||||
if( !cpld_jtag_sram_load(&jtag_cpld) ) {
|
if( !cpld_jtag_sram_load(&jtag_cpld) ) {
|
||||||
// TODO: Fail, do not continue booting.
|
halt_and_flash(6000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DFU_MODE
|
#ifndef DFU_MODE
|
||||||
|
@ -61,8 +61,6 @@ static void refill_cpld_buffer(void)
|
|||||||
|
|
||||||
void cpld_update(void)
|
void cpld_update(void)
|
||||||
{
|
{
|
||||||
#define WAIT_LOOP_DELAY (6000000)
|
|
||||||
int i;
|
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
usb_queue_flush_endpoint(&usb_endpoint_bulk_in);
|
usb_queue_flush_endpoint(&usb_endpoint_bulk_in);
|
||||||
@ -75,20 +73,7 @@ void cpld_update(void)
|
|||||||
refill_cpld_buffer);
|
refill_cpld_buffer);
|
||||||
if(error == 0)
|
if(error == 0)
|
||||||
{
|
{
|
||||||
/* blink LED1, LED2, and LED3 on success */
|
halt_and_flash(6000000);
|
||||||
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");
|
|
||||||
}
|
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
/* LED3 (Red) steady on error */
|
/* LED3 (Red) steady on error */
|
||||||
|
Reference in New Issue
Block a user