move bootloader retrieval to common init()

This commit is contained in:
hathach committed 2017-06-29 14:44:02 +07:00
1 parent 79402524e9
commit f42bea8d8f
7 files changed
+20 -21

No files matched your search

-1
View File
@@ -70,7 +70,6 @@ metro52.build.board=METRO52
metro52.build.core=nRF5
metro52.build.variant=metro52
# Debug Menu
metro52.menu.debug.l0=Level 0 (Release)
metro52.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
-1
View File
@@ -64,7 +64,6 @@ static void loop_task(void* arg)
int main( void )
{
init();
initVariant();
if (setLoopStacksize)
+14
View File
@@ -28,6 +28,10 @@ extern "C" {
#define BOOTLOADER_DFU_SERIAL_MAGIC 0x4e
#define BOOTLOADER_DFU_OTA_FULLRESET_MAGIC 0xA8
// Must match temp register in bootloader
#define BOOTLOADER_VERSION_REGISTER NRF_TIMER2->CC[0]
uint32_t bootloaderVersion = 0;
void init( void )
{
#if defined( USE_LFXO )
@@ -41,6 +45,16 @@ void init( void )
#endif
NRF_CLOCK->TASKS_LFCLKSTART = 1UL;
// Retrieve bootloader version
bootloaderVersion = BOOTLOADER_VERSION_REGISTER;
// RTC1 could be enabled by bootloader. Disable it
NVIC_DisableIRQ(RTC1_IRQn);
NRF_RTC1->EVTENCLR = RTC_EVTEN_COMPARE0_Msk;
NRF_RTC1->INTENCLR = RTC_INTENSET_COMPARE0_Msk;
NRF_RTC1->TASKS_STOP = 1;
NRF_RTC1->TASKS_CLEAR = 1;
}
void enterSerialDfu(void)
+5
View File
@@ -27,6 +27,11 @@ extern void init(void);
extern void enterSerialDfu(void);
extern void enterOTADfu(void);
/* Bootloader version. Assigned by init().
* - value of 0x000500 is version 0.5.0
*/
extern uint32_t bootloaderVersion;
// Hint instruction to tell CPU go to low power mode
#if 0
#define waitForEvent() __WFE()
@@ -11,7 +11,7 @@ typedef volatile uint32_t REG32;
void setup() {
Serial.begin(115200);
Serial.println("Bluefruit Feather 52 HW Info");
Serial.println("Bluefruit 52 HW Info");
Serial.println("");
// MAC Address
-13
View File
@@ -68,21 +68,8 @@ const uint32_t g_ADigitalPinMap[] = {
};
// Must match temp register in bootloader
#define BOOTLOADER_VERSION_REGISTER NRF_TIMER2->CC[0]
uint32_t bootloaderVersion = 0;
void initVariant()
{
bootloaderVersion = BOOTLOADER_VERSION_REGISTER;
// RTC1 is already configured by bootloader. Disable it here
NVIC_DisableIRQ(RTC1_IRQn);
NRF_RTC1->EVTENCLR = RTC_EVTEN_COMPARE0_Msk;
NRF_RTC1->INTENCLR = RTC_INTENSET_COMPARE0_Msk;
NRF_RTC1->TASKS_STOP = 1;
NRF_RTC1->TASKS_CLEAR = 1;
// LED1 & LED2
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
-5
View File
@@ -116,11 +116,6 @@ static const uint8_t SCK = PIN_SPI_SCK ;
#define PIN_WIRE_SDA (25u)
#define PIN_WIRE_SCL (26u)
/* Bootloader version, may move to other file. Assigned by
* initVariant() upon running.
* - value of 0x000500 is version 0.5.0
*/
extern uint32_t bootloaderVersion;
static inline bool isPinValid(uint32_t pin)
{