fix OTA with freeRTOS
This commit is contained in:
1 parent
2022a14e34
commit
f417662b83
3 files changed
+9
-4
No files matched your search
@@ -89,7 +89,7 @@
|
||||
* See http://www.freertos.org/a00110.html.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configTICK_SOURCE FREERTOS_USE_SYSTICK // FREERTOS_USE_RTC
|
||||
#define configTICK_SOURCE FREERTOS_USE_SYSTICK
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
|
||||
@@ -207,6 +207,7 @@ standard names - or at least those used in the unmodified vector table. */
|
||||
/* Code below should be only used by the compiler, and not the assembler. */
|
||||
#if !(defined(__ASSEMBLY__) || defined(__ASSEMBLER__))
|
||||
#include "nrf.h"
|
||||
//#include "nrf_assert.h"
|
||||
|
||||
/* This part of definitions may be problematic in assembly - it uses definitions from files that are not assembly compatible. */
|
||||
/* Cortex-M specific definitions. */
|
||||
|
||||
@@ -45,7 +45,6 @@ void loop()
|
||||
{
|
||||
// Toggle both LEDs every 1 second
|
||||
digitalToggle(LED_BUILTIN);
|
||||
digitalToggle(LED_CONN);
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
@@ -127,8 +127,12 @@ static void bledfu_control_wr_authorize_cb(BLECharacteristic& chr, ble_gatts_evt
|
||||
Bluefruit.disconnect();
|
||||
Bluefruit.stopAdvertising();
|
||||
|
||||
// Disable Systick to prevent Interrupt happens after changing vector table
|
||||
bitClear(SysTick->CTRL, SysTick_CTRL_ENABLE_Pos);
|
||||
|
||||
// Set GPReset to DFU OTA
|
||||
enum { DFU_OTA_MAGIC = 0xB1 };
|
||||
sd_power_gpregret_clr(0xFF);
|
||||
VERIFY_STATUS( sd_power_gpregret_set(DFU_OTA_MAGIC), RETURN_VOID);
|
||||
VERIFY_STATUS( sd_softdevice_disable(), RETURN_VOID );
|
||||
VERIFY_STATUS( sd_softdevice_vector_table_base_set(NRF_UICR->NRFFW[0]), RETURN_VOID);
|
||||
@@ -137,14 +141,15 @@ static void bledfu_control_wr_authorize_cb(BLECharacteristic& chr, ble_gatts_evt
|
||||
peer_data->addr = Bluefruit.peerAddr();
|
||||
peer_data->crc16 = crc16((uint8_t*) peer_data, offsetof(peer_data_t, crc16));
|
||||
|
||||
NVIC_ClearPendingIRQ(SWI2_IRQn);
|
||||
NVIC_ClearPendingIRQ(SD_EVT_IRQn);
|
||||
|
||||
// Disable all interrupts
|
||||
for(int i=0; i<FPU_IRQn; i++)
|
||||
for(int i=0; i <= FPU_IRQn; i++)
|
||||
{
|
||||
NVIC_DisableIRQ( (IRQn_Type) i );
|
||||
}
|
||||
|
||||
__set_CONTROL(0); // switch to MSP, required if using FreeRTOS
|
||||
bootloader_util_app_start(NRF_UICR->NRFFW[0]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user