18
18
* See the License for the specific language governing permissions and
19
19
* limitations under the License.
20
20
*/
21
-
21
+
22
22
#include "sam3u2c.h"
23
23
#include "DAP_config.h"
24
24
#include "target_config.h"
@@ -37,6 +37,7 @@ const char *board_id_nrf52840_dk = "1102";
37
37
extern target_cfg_t target_device_nrf52 ;
38
38
extern target_cfg_t target_device_nrf52840 ;
39
39
static uint8_t device_type ;
40
+
40
41
static void set_target_device (uint32_t device )
41
42
{
42
43
device_type = device ;
@@ -52,27 +53,27 @@ static void set_target_device(uint32_t device)
52
53
}
53
54
54
55
55
- static void prerun_board_config (void )
56
+ static void nrf_prerun_board_config (void )
56
57
{
57
58
// Work around for setting the correct board id based on GPIOs
58
59
uint8_t bit1 ;
59
60
uint8_t bit2 ;
60
61
uint8_t bit3 ;
61
-
62
+
62
63
PIOB -> PIO_PER = (1 << 1 ); // Enable PIO pin PB1
63
64
PIOB -> PIO_PER = (1 << 2 ); // Enable PIO pin PB2
64
65
PIOB -> PIO_PER = (1 << 3 ); // Enable PIO pin PB3
65
66
PIOB -> PIO_ODR = (1 << 1 ); // Disabe output
66
67
PIOB -> PIO_ODR = (1 << 2 ); // Disabe output
67
68
PIOB -> PIO_ODR = (1 << 3 ); // Disabe output
68
- PIOB -> PIO_PUER = (1 << 1 ); // Enable pull-up
69
+ PIOB -> PIO_PUER = (1 << 1 ); // Enable pull-up
69
70
PIOB -> PIO_PUER = (1 << 2 ); // Enable pull-up
70
71
PIOB -> PIO_PUER = (1 << 3 ); // Enable pull-up
71
-
72
+
72
73
bit1 = (PIOB -> PIO_PDSR >> 1 ) & 1 ; // Read PB1
73
74
bit2 = (PIOB -> PIO_PDSR >> 2 ) & 1 ; // Read PB2
74
75
bit3 = (PIOB -> PIO_PDSR >> 3 ) & 1 ; // Read PB3
75
-
76
+
76
77
/* pins translate to board-ids as follow
77
78
*
78
79
* PB3|PB2|PB1|BOARD ID| BOARD
@@ -87,7 +88,7 @@ static void prerun_board_config(void)
87
88
* 1 | 1 | 0 | undefined
88
89
*/
89
90
90
-
91
+
91
92
if (bit3 ) {
92
93
set_target_device (0 );
93
94
target_device .rt_family_id = kNordic_Nrf51_FamilyID ;
@@ -115,13 +116,13 @@ static void prerun_board_config(void)
115
116
target_device .rt_board_id = board_id_nrf52840_dk ; // 1102
116
117
}
117
118
}
118
-
119
- PIOB -> PIO_PUDR = (1 << 1 ); // Disable pull-up
119
+
120
+ PIOB -> PIO_PUDR = (1 << 1 ); // Disable pull-up
120
121
PIOB -> PIO_PUDR = (1 << 2 ); // Disable pull-up
121
122
PIOB -> PIO_PUDR = (1 << 3 ); // Disable pull-up
122
123
}
123
124
124
- static void swd_set_target_reset (uint8_t asserted ){
125
+ static void nrf_swd_set_target_reset (uint8_t asserted ){
125
126
if (asserted && device_type == 0 ) {
126
127
PIOA -> PIO_OER = PIN_SWDIO ;
127
128
PIOA -> PIO_OER = PIN_SWCLK ;
@@ -133,7 +134,7 @@ static void swd_set_target_reset(uint8_t asserted){
133
134
const board_info_t g_board_info = {
134
135
.infoVersion = 0x0 ,
135
136
.flags = kEnablePageErase ,
136
- .prerun_board_config = prerun_board_config ,
137
- .swd_set_target_reset = swd_set_target_reset ,
137
+ .prerun_board_config = nrf_prerun_board_config ,
138
+ .swd_set_target_reset = nrf_swd_set_target_reset ,
138
139
.target_cfg = & target_device ,
139
140
};
0 commit comments