Skip to content
Snippets Groups Projects
Commit dd50d5c4 authored by Cristian Maglie's avatar Cristian Maglie Committed by Cristian Maglie
Browse files

Implemented 1200bps-touch to restart bootloader when connected from native port

parent b11367dc
No related branches found
No related tags found
No related merge requests found
......@@ -28,8 +28,8 @@ arduino_zero_native.pid.0=0x004d
arduino_zero_native.upload.tool=bossac
arduino_zero_native.upload.protocol=sam-ba
arduino_zero_native.upload.maximum_size=262144
arduino_zero_native.upload.use_1200bps_touch=false
arduino_zero_native.upload.wait_for_upload_port=false
arduino_zero_native.upload.use_1200bps_touch=true
arduino_zero_native.upload.wait_for_upload_port=true
arduino_zero_native.upload.native_usb=true
arduino_zero_native.build.mcu=cortex-m0plus
arduino_zero_native.build.f_cpu=48000000L
......
......@@ -23,12 +23,28 @@
extern "C" {
#endif
#define NVM_MEMORY ((volatile uint16_t *)0x000000)
#define APP_START 0x00002004
static inline bool nvmReady(void) {
return NVMCTRL->INTFLAG.reg & NVMCTRL_INTFLAG_READY;
}
__attribute__ ((long_call, section (".ramfunc")))
static void banzai() {
// Disable all interrupts
__disable_irq();
// Reset the device
// Erase application
while (!nvmReady())
;
NVMCTRL->STATUS.reg |= NVMCTRL_STATUS_MASK;
NVMCTRL->ADDR.reg = (uintptr_t)&NVM_MEMORY[APP_START / 4];
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMD_ER | NVMCTRL_CTRLA_CMDEX_KEY;
while (!nvmReady())
;
// Reset the device
NVIC_SystemReset() ;
while (true);
......
......@@ -58,10 +58,13 @@ void delay( uint32_t ms )
} while ( _ulTickCount - start <= ms ) ;
}
#include "Reset.h" // for tickReset()
void SysTick_Handler( void )
{
// Increment tick count each ms
_ulTickCount++ ;
tickReset();
}
#ifdef __cplusplus
......
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