10000 Add time out mechanism to reset Nordic chip when boot · sgbihu/corelibs-arduino101@7d049ee · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d049ee

Browse files
committed
Add time out mechanism to reset Nordic chip when boot
1 parent 936a638 commit 7d049ee

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

system/libarc32_arduino101/framework/src/services/ble_service/ble_service.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "rpc.h"
5252

5353
#include "util/misc.h"
54+
#include "infra/time.h"
5455

5556
struct _ble_service_cb _ble_cb = { 0 };
5657
volatile uint8_t ble_inited = false;
@@ -269,6 +270,7 @@ void ble_bt_rdy(int err)
269270

270271
void ble_cfw_service_init(int service_id, T_QUEUE queue)
271272
{
273+
uint32_t time_stamp_last = 0;
272274
_ble_cb.queue = queue;
273275
_ble_cb.ble_state = BLE_ST_NOT_READY;
274276

@@ -277,9 +279,20 @@ void ble_cfw_service_init(int service_id, T_QUEUE queue)
277279
#endif
278280

279281
ble_inited = false;
280-
282+
time_stamp_last = get_uptime_ms();
283+
281284
bt_enable(ble_bt_rdy);
282-
do{}
285+
do{
286+
287+
uint32_t time_stamp_current = get_uptime_ms();
288+
if (time_stamp_current - time_stamp_last > 2000)
289+
{
290+
nble_driver_hw_reset();
291+
//pr_warning(LOG_MODULE_BLE, "time_stamp_current %d", time_stamp_current);
292+
293+
time_stamp_last = time_stamp_current;
294+
}
295+
}
283296
while (ble_inited == false);
284297
}
285298

system/libarc32_arduino101/framework/src/services/ble_service/nble_driver.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -297,21 +297,10 @@ void rpc_transmit_cb(uint8_t *p_buf, uint16_t length)
297297
* other constraints: therefore, this reset might not work everytime, especially after
298298
* flashing or debugging.
299299
*/
300-
void nble_driver_init(void)
300+
void nble_driver_hw_reset(void)
301301
{
302302
uint32_t delay_until;
303-
304-
nble_interface_init();
305-
/* Setup UART0 for BLE communication, HW flow control required */
306-
SET_PIN_MODE(18, QRK_PMUX_SEL_MODEA); /* UART0_RXD */
307-
SET_PIN_MODE(19, QRK_PMUX_SEL_MODEA); /* UART0_TXD */
308-
SET_PIN_MODE(40, QRK_PMUX_SEL_MODEB); /* UART0_CTS_B */
309-
SET_PIN_MODE(41, QRK_PMUX_SEL_MODEB); /* UART0_RTS_B */
310-
311-
ipc_uart_init(0);
312-
313-
//while (1)
314-
//{}
303+
315304
/* RESET_PIN depends on the board and the local configuration: check top of file */
316305
gpio_cfg_data_t pin_cfg = { .gpio_type = GPIO_OUTPUT };
317306

@@ -336,6 +325,23 @@ void nble_driver_init(void)
336325
soc_gpio_set_config(SOC_GPIO_32, RESET_PIN, &pin_cfg);
337326
}
338327

328+
void nble_driver_init(void)
329+
{
330+
331+
nble_interface_init();
332+
/* Setup UART0 for BLE communication, HW flow control required */
333+
SET_PIN_MODE(18, QRK_PMUX_SEL_MODEA); /* UART0_RXD */
334+
SET_PIN_MODE(19, QRK_PMUX_SEL_MODEA); /* UART0_TXD */
335+
SET_PIN_MODE(40, QRK_PMUX_SEL_MODEB); /* UART0_CTS_B */
336+
SET_PIN_MODE(41, QRK_PMUX_SEL_MODEB); /* UART0_RTS_B */
337+
338+
ipc_uart_init(0);
339+
340+
//while (1)
341+
//{}
342+
nble_driver_hw_reset();
343+
}
344+
339345

340346
void nble_driver_configure(T_QUEUE queue, void (*handler)(struct message*, void*))
341347
{

system/libarc32_arduino101/framework/src/services/ble_service/nble_driver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct ble_rpc_callin {
4747
* mechanism is up and running.
4848
*/
4949
void nble_driver_init(void);
50+
void nble_driver_hw_reset(void);
5051

5152
void nble_driver_configure(T_QUEUE queue, void (*handler)(struct message*, void*));
5253

0 commit comments

Comments
 (0)
0