diff options
| author | iabdalkader <i.abdalkader@gmail.com> | 2023-04-11 13:06:58 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-09-15 16:47:19 +1000 |
| commit | d30f61ba0d533f5889d036b24423521e8a2b77a4 (patch) | |
| tree | 783fb29707527d4d4b0a11dd436e0f61abbb5a7a | |
| parent | 9ea9e04ef63897c8e8349813cfc65d29d7f20078 (diff) | |
drivers/ninaw10/nina_bt_hci: Make some minor fixes to HCI driver.
Fixes are:
- Reset the module first before changing GPIO1 direction.
- Skip spurious bytes received after reset.
- Use HCI UART ID and baudrate when reinitializing UART.
- Disable all printf output which causes unit-tests to fail.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
| -rw-r--r-- | drivers/ninaw10/nina_bt_hci.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/ninaw10/nina_bt_hci.c b/drivers/ninaw10/nina_bt_hci.c index 6dc320447..754e99ed7 100644 --- a/drivers/ninaw10/nina_bt_hci.c +++ b/drivers/ninaw10/nina_bt_hci.c @@ -50,7 +50,7 @@ #define OCF_SET_EVENT_MASK (0x0001) #define OCF_RESET (0x0003) -#define error_printf(...) mp_printf(&mp_plat_print, "nina_bt_hci.c: " __VA_ARGS__) +#define error_printf(...) // mp_printf(&mp_plat_print, "nina_bt_hci.c: " __VA_ARGS__) #define debug_printf(...) // mp_printf(&mp_plat_print, "nina_bt_hci.c: " __VA_ARGS__) // Provided by the port, and also possibly shared with the stack. @@ -86,7 +86,7 @@ static int nina_hci_cmd(int ogf, int ocf, size_t param_len, const uint8_t *param buf[i] = mp_bluetooth_hci_uart_readchar(); // There seems to be a sync issue with this fw/module. - if (i == 0 && buf[0] == 0xFF) { + if (i == 0 && (buf[0] == 0xFF || buf[0] == 0xFE)) { continue; } @@ -121,19 +121,19 @@ static int nina_hci_cmd(int ogf, int ocf, size_t param_len, const uint8_t *param int mp_bluetooth_hci_controller_init(void) { // This is called immediately after the UART is initialised during stack initialisation. - mp_hal_pin_output(MICROPY_HW_NINA_GPIO1); mp_hal_pin_output(MICROPY_HW_NINA_RESET); + mp_hal_pin_write(MICROPY_HW_NINA_RESET, 0); + mp_hal_pin_output(MICROPY_HW_NINA_GPIO1); mp_hal_pin_write(MICROPY_HW_NINA_GPIO1, 0); - mp_hal_pin_write(MICROPY_HW_NINA_RESET, 0); - mp_hal_delay_ms(100); + mp_hal_delay_ms(150); mp_hal_pin_write(MICROPY_HW_NINA_RESET, 1); mp_hal_delay_ms(750); - // The UART must be re-initialize here because the GPIO1/RX pin is used initially + // The UART must be re-initialized here because the GPIO1/RX pin is used initially // to reset the module in Bluetooth mode. This will change back the pin to UART RX. - mp_bluetooth_hci_uart_init(0, 0); + mp_bluetooth_hci_uart_init(MICROPY_HW_BLE_UART_ID, MICROPY_HW_BLE_UART_BAUDRATE); // Send reset command return nina_hci_cmd(OGF_HOST_CTL, OCF_RESET, 0, NULL); |
