Skip to content
Snippets Groups Projects
Commit 82b5b21f authored by schneider's avatar schneider Committed by rahix
Browse files

feat(bootloader): Reset when system says done

parent a43065c5
No related branches found
No related tags found
No related merge requests found
...@@ -114,11 +114,17 @@ void delay_us(unsigned int usec) ...@@ -114,11 +114,17 @@ void delay_us(unsigned int usec)
mxc_delay(usec); mxc_delay(usec);
} }
void bootloader_stop(void)
{
card10_reset();
}
void bootloader_dirty(void) void bootloader_dirty(void)
{ {
Paint_DrawString_EN(0, 16 * 3, "Writing.", &Font16, 0x0000, 0xf000); Paint_DrawString_EN(0, 16 * 3, "Writing.", &Font16, 0x0000, 0xf000);
LCD_Update(); LCD_Update();
} }
void bootloader_clean(void) void bootloader_clean(void)
{ {
Paint_DrawString_EN(0, 16 * 3, "Ready. ", &Font16, 0x0000, 0xffff); Paint_DrawString_EN(0, 16 * 3, "Ready. ", &Font16, 0x0000, 0xffff);
......
...@@ -210,15 +210,7 @@ static inline void boot(const void *vtable) ...@@ -210,15 +210,7 @@ static inline void boot(const void *vtable)
static void pmic_button(bool falling) static void pmic_button(bool falling)
{ {
if (falling) { if (falling) {
printf("Resetting ...\n"); card10_reset();
/*
* Give the UART fifo time to clear.
* TODO: Do this properly
*/
for (int i = 0; i < 0x1000000; i++) {
__asm volatile("nop");
}
MXC_GCR->rstr0 = MXC_F_GCR_RSTR0_SYSTEM;
} }
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <stdio.h> #include <stdio.h>
#include "mx25lba.h" #include "mx25lba.h"
void bootloader_stop(void);
void bootloader_dirty(void); void bootloader_dirty(void);
void bootloader_clean(void); void bootloader_clean(void);
...@@ -50,7 +51,9 @@ int mscmem_start() ...@@ -50,7 +51,9 @@ int mscmem_start()
int mscmem_stop() int mscmem_stop()
{ {
printf("%s\n", __func__); printf("%s\n", __func__);
return mx25_stop(); int ret = mx25_stop();
bootloader_stop();
return ret;
} }
/******************************************************************************/ /******************************************************************************/
......
...@@ -216,6 +216,19 @@ void card10_poll(void) ...@@ -216,6 +216,19 @@ void card10_poll(void)
pmic_poll(); pmic_poll();
} }
void card10_reset(void)
{
printf("Resetting ...\n");
/*
* Give the UART fifo time to clear.
* TODO: Do this properly
*/
for (int i = 0; i < 0x1000000; i++) {
__asm volatile("nop");
}
MXC_GCR->rstr0 = MXC_F_GCR_RSTR0_SYSTEM;
}
void GPIO0_IRQHandler(void) void GPIO0_IRQHandler(void)
{ {
GPIO_Handler(PORT_0); GPIO_Handler(PORT_0);
......
...@@ -13,4 +13,5 @@ void core1_start(void); ...@@ -13,4 +13,5 @@ void core1_start(void);
void core1_stop(void); void core1_stop(void);
void card10_poll(void); void card10_poll(void);
void card10_reset(void);
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment