File tree Expand file tree Collapse file tree 4 files changed +54
-4
lines changed Expand file tree Collapse file tree 4 files changed +54
-4
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,8 @@ bool button_pressed(uint32_t pin)
63
63
}
64
64
65
65
// This is declared so that a board specific init can be called from here.
66
- void __attribute__((weak )) board_init_extra (void ) { }
66
+ void __attribute__((weak )) board_init2 (void ) { }
67
+
67
68
void board_init (void )
68
69
{
69
70
// stop LF clock just in case we jump from application without reset
@@ -96,7 +97,7 @@ void board_init(void)
96
97
NRF_POWER -> DCDCEN = 1 ;
97
98
#endif
98
99
// Make sure any custom inits are performed
99
- board_init_extra ();
100
+ board_init2 ();
100
101
101
102
// When board is supplied on VDDH (and not VDD), this specifies what voltage the GPIO should run at
102
103
// and what voltage is output at VDD. The default (0xffffffff) is 1.8V; typically you'll want
@@ -129,6 +130,9 @@ void board_init(void)
129
130
SysTick_Config (SystemCoreClock /1000 );
130
131
}
131
132
133
+ // Actions at the end of board_teardown.
134
+ void __attribute__((weak )) board_teardown2 (void ) { }
135
+
132
136
void board_teardown (void )
133
137
{
134
138
// Disable systick, turn off LEDs
@@ -159,6 +163,9 @@ void board_teardown(void)
159
163
{
160
164
nrf_gpio_cfg_default (i );
161
165
}
166
+
167
+ // board specific teardown actions
168
+ board_teardown2 ();
162
169
}
163
170
164
171
static uint32_t _systick_count = 0 ;
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ const uint32_t bootloaderConfig[] =
19
19
/* CF2 END */
20
20
};
21
21
22
- void board_init_extra (void )
22
+ void board_init2 (void )
23
23
{
24
24
// Turn LDO on
25
25
nrf_gpio_cfg_output (LDO_CONTROL_PIN );
Original file line number Diff line number Diff line change 43
43
*------------------------------------------------------------------*/
44
44
#define BUTTONS_NUMBER 2
45
45
#define BUTTON_1 _PINNUM(0, 27)
46
- #define BUTTON_2 _PINNUM(1, 7)
46
+ #define BUTTON_2 _PINNUM(0, 19) // ESC
47
47
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
48
48
49
+ /*------------------------------------------------------------------*/
50
+ /* On board regulator control
51
+ *------------------------------------------------------------------*/
52
+ #define LDO_CONTROL_PIN _PINNUM(0, 28) // Enables external pwr
53
+
49
54
//--------------------------------------------------------------------+
50
55
// BLE OTA
51
56
//--------------------------------------------------------------------+
Original file line number Diff line number Diff line change 1
1
#include "boards.h"
2
+ #include "board.h"
2
3
#include "uf2/configkeys.h"
3
4
4
5
__attribute__((used , section (".bootloaderConfig" )))
@@ -17,3 +18,40 @@ const uint32_t bootloaderConfig[] =
17
18
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
18
19
/* CF2 END */
19
20
};
21
+
22
+ static void power_on (void )
23
+ {
24
+ // Turn on the regulator
25
+ nrf_gpio_cfg_output (LDO_CONTROL_PIN );
26
+ nrf_gpio_pin_write (LDO_CONTROL_PIN , 1 );
27
+ }
28
+
29
+ void board_init2 (void )
30
+ {
31
+ power_on ();
32
+
33
+ // configure P0.05 for ESC/BUTTON_2
34
+ // P0.05 --- |<- --- / --- P0.19
35
+ // diode sw(esc)
36
+ // mode: output, push-pull, low
37
+ nrf_gpio_cfg (
38
+ _PINNUM (0 , 5 ),
39
+ NRF_GPIO_PIN_DIR_OUTPUT ,
40
+ NRF_GPIO_PIN_INPUT_DISCONNECT ,
41
+ NRF_GPIO_PIN_NOPULL ,
42
+ NRF_GPIO_PIN_H0D1 ,
43
+ NRF_GPIO_PIN_NOSENSE
44
+ );
45
+ nrf_gpio_pin_write (_PINNUM (0 , 5 ), 0 );
46
+
47
+ // Wait the buttons stable.
48
+ // This is mandatory, or the keyboard will enter bootloader whenever
49
+ // booted by pressing the button at back (same with BUTTON_1)
50
+ NRFX_DELAY_MS (300 );
51
+ }
52
+
53
+ void board_teardown2 (void )
54
+ {
55
+ // re-enable the battery
56
+ power_on ();
57
+ }
You can’t perform that action at this time.
0 commit comments