Skip to content

Commit f42bea8

Browse files
committed
move bootloader retrieval to common init()
1 parent 7940252 commit f42bea8

File tree

7 files changed

+20
-21
lines changed

7 files changed

+20
-21
lines changed

boards.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ metro52.build.board=METRO52
7070
metro52.build.core=nRF5
7171
metro52.build.variant=metro52
7272

73-
7473
# Debug Menu
7574
metro52.menu.debug.l0=Level 0 (Release)
7675
metro52.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0

cores/nRF5/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ static void loop_task(void* arg)
6464
int main( void )
6565
{
6666
init();
67-
6867
initVariant();
6968

7069
if (setLoopStacksize)

cores/nRF5/wiring.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ extern "C" {
2828
#define BOOTLOADER_DFU_SERIAL_MAGIC 0x4e
2929
#define BOOTLOADER_DFU_OTA_FULLRESET_MAGIC 0xA8
3030

31+
// Must match temp register in bootloader
32+
#define BOOTLOADER_VERSION_REGISTER NRF_TIMER2->CC[0]
33+
uint32_t bootloaderVersion = 0;
34+
3135
void init( void )
3236
{
3337
#if defined( USE_LFXO )
@@ -41,6 +45,16 @@ void init( void )
4145
#endif
4246

4347
NRF_CLOCK->TASKS_LFCLKSTART = 1UL;
48+
49+
// Retrieve bootloader version
50+
bootloaderVersion = BOOTLOADER_VERSION_REGISTER;
51+
52+
// RTC1 could be enabled by bootloader. Disable it
53+
NVIC_DisableIRQ(RTC1_IRQn);
54+
NRF_RTC1->EVTENCLR = RTC_EVTEN_COMPARE0_Msk;
55+
NRF_RTC1->INTENCLR = RTC_INTENSET_COMPARE0_Msk;
56+
NRF_RTC1->TASKS_STOP = 1;
57+
NRF_RTC1->TASKS_CLEAR = 1;
4458
}
4559

4660
void enterSerialDfu(void)

cores/nRF5/wiring.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ extern void init(void);
2727
extern void enterSerialDfu(void);
2828
extern void enterOTADfu(void);
2929

30+
/* Bootloader version. Assigned by init().
31+
* - value of 0x000500 is version 0.5.0
32+
*/
33+
extern uint32_t bootloaderVersion;
34+
3035
// Hint instruction to tell CPU go to low power mode
3136
#if 0
3237
#define waitForEvent() __WFE()

libraries/Bluefruit52Lib/examples/Hardware/hwinfo/hwinfo.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ typedef volatile uint32_t REG32;
1111
void setup() {
1212
Serial.begin(115200);
1313

14-
Serial.println("Bluefruit Feather 52 HW Info");
14+
Serial.println("Bluefruit 52 HW Info");
1515
Serial.println("");
1616

1717
// MAC Address

variants/feather52/variant.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,8 @@ const uint32_t g_ADigitalPinMap[] = {
6868

6969
};
7070

71-
// Must match temp register in bootloader
72-
#define BOOTLOADER_VERSION_REGISTER NRF_TIMER2->CC[0]
73-
uint32_t bootloaderVersion = 0;
74-
7571
void initVariant()
7672
{
77-
bootloaderVersion = BOOTLOADER_VERSION_REGISTER;
78-
79-
// RTC1 is already configured by bootloader. Disable it here
80-
NVIC_DisableIRQ(RTC1_IRQn);
81-
NRF_RTC1->EVTENCLR = RTC_EVTEN_COMPARE0_Msk;
82-
NRF_RTC1->INTENCLR = RTC_INTENSET_COMPARE0_Msk;
83-
NRF_RTC1->TASKS_STOP = 1;
84-
NRF_RTC1->TASKS_CLEAR = 1;
85-
8673
// LED1 & LED2
8774
pinMode(PIN_LED1, OUTPUT);
8875
ledOff(PIN_LED1);

variants/feather52/variant.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,6 @@ static const uint8_t SCK = PIN_SPI_SCK ;
116116
#define PIN_WIRE_SDA (25u)
117117
#define PIN_WIRE_SCL (26u)
118118

119-
/* Bootloader version, may move to other file. Assigned by
120-
* initVariant() upon running.
121-
* - value of 0x000500 is version 0.5.0
122-
*/
123-
extern uint32_t bootloaderVersion;
124119

125120
static inline bool isPinValid(uint32_t pin)
126121
{

0 commit comments

Comments
 (0)