fix spi and ble on zephyt

tychovrahe/T3W1/devkit1_with_zephyr
tychovrahe 2 weeks ago
parent 6fd550c27d
commit 8354eab2a9

@ -26,20 +26,19 @@
};
};
spi0_default: spi0_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 14)>,
<NRF_PSEL(SPIM_MOSI, 0, 16)>,
<NRF_PSEL(SPIM_MISO, 0, 15)>;
psels = <NRF_PSEL(SPIM_SCK, 1, 5)>,
<NRF_PSEL(SPIM_MOSI, 0, 19)>,
<NRF_PSEL(SPIM_MISO, 1, 3)>;
};
};
spi0_sleep: spi0_sleep {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 14)>,
<NRF_PSEL(SPIM_MOSI, 0, 16)>,
<NRF_PSEL(SPIM_MISO, 0, 15)>;
psels = <NRF_PSEL(SPIM_SCK, 1, 5)>,
<NRF_PSEL(SPIM_MOSI, 0, 19)>,
<NRF_PSEL(SPIM_MISO, 1, 3)>;
low-power-enable;
};
};

@ -102,7 +102,7 @@
pinctrl-0 = <&spi0_default>;
pinctrl-1 = <&spi0_sleep>;
pinctrl-names = "default", "sleep";
cs-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
cs-gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
reg_my_spi_master: spi-dev-a@0 {
reg = <0>;
};

@ -37,8 +37,10 @@ CONFIG_BT_SMP_SC_ONLY=y
CONFIG_BT_FILTER_ACCEPT_LIST=y
CONFIG_BT_BONDING_REQUIRED=y
CONFIG_BT_PRIVACY=y
#CONFIG_BT_TINYCRYPT_ECC=y
#CONFIG_BT_LL_SW_SPLIT=y
CONFIG_BT_TINYCRYPT_ECC=y
CONFIG_BT_LL_SW_SPLIT=y
#CONFIG_BT_DEBUG_SMP=y
#PHY update needed for updating PHY request
CONFIG_BT_USER_PHY_UPDATE=y

@ -178,3 +178,8 @@ void pairing_failed(struct bt_conn *conn, enum bt_security_err reason)
LOG_INF("Pairing failed conn: %s, reason %d", addr, reason);
}
struct bt_conn * conn_get_current(void){
return current_conn;
}

@ -27,3 +27,4 @@ void pairing_complete(struct bt_conn *conn, bool bonded);
void pairing_failed(struct bt_conn *conn, enum bt_security_err reason);
void num_comp_reply(bool accept);
struct bt_conn * conn_get_current(void);

@ -236,8 +236,8 @@ void ble_write_thread(void)
/* Wait indefinitely for data to be sent over bluetooth */
uart_data_t *buf = uart_get_data_ext();
if (bt_nus_send(NULL, buf->data, buf->len)) {
LOG_WRN("Failed to send data over BLE connection");
if (bt_nus_send(conn_get_current(), buf->data, buf->len)) {
LOG_WRN("Failed to send data over BLE connection: %d", buf->len);
}
k_free(buf);

@ -33,8 +33,9 @@ static K_FIFO_DEFINE(fifo_pb_tx_in); // data to send to trezor
static K_FIFO_DEFINE(fifo_pb_tx_out); // data to send to host
void prepare_response_wait() {
void prepare_response_wait() {
k_sem_reset(&pb_wait_for_ack);
uart_data_pb_flush();
}

@ -311,6 +311,10 @@ uart_data_t *uart_get_data_pb(void)
return k_fifo_get(&fifo_uart_rx_data_pb, K_MSEC(100));
}
void uart_data_pb_flush(void){
while(uart_get_data_pb() != NULL);
}
void uart_send(uart_data_t *tx)
{
int err = uart_tx(uart, tx->data, tx->len, SYS_FOREVER_MS);

@ -14,6 +14,8 @@ int uart_init(void);
uart_data_t * uart_get_data_ext(void);
uart_data_t * uart_get_data_int(void);
uart_data_t * uart_get_data_pb(void);
void uart_data_pb_flush(void);
void uart_send(uart_data_t *data);
void uart_send_ext(uart_data_t *tx);

Loading…
Cancel
Save