Skip to content

Commit

Permalink
working uart
Browse files Browse the repository at this point in the history
  • Loading branch information
TychoVrahe committed Nov 21, 2024
1 parent eefc8fc commit f07cebd
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 34 deletions.
1 change: 0 additions & 1 deletion app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ target_sources(app PRIVATE
src/uart.c
src/spi.c
src/int_comm.c
src/oob.c
src/trz_nus.c
)

Expand Down
15 changes: 1 addition & 14 deletions app/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,7 @@ CONFIG_MAIN_STACK_SIZE=1152
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096

# NFC
CONFIG_NFC_T4T_NRFXLIB=y

CONFIG_NFC_NDEF=y
CONFIG_NFC_NDEF_MSG=y
CONFIG_NFC_NDEF_RECORD=y
CONFIG_NFC_NDEF_LE_OOB_REC=y
CONFIG_NFC_NDEF_CH_MSG=y

CONFIG_NFC_NDEF_TNEP_RECORD=y
CONFIG_NFC_TNEP_TAG=y
CONFIG_NFC_NDEF_PARSER=y
CONFIG_NFC_NDEF_CH_PARSER=y
CONFIG_NFC_NDEF_LE_OOB_REC_PARSER=y
CONFIG_NFC_TNEP_CH=y
CONFIG_NFCT_PINS_AS_GPIOS=y

CONFIG_POLL=y

Expand Down
3 changes: 1 addition & 2 deletions app/src/advertising.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "int_comm.h"
#include "connection.h"
#include "oob.h"
#include "trz_nus.h"


Expand Down Expand Up @@ -109,7 +108,7 @@ void advertising_start(bool wl){
advertising_wl = wl;


oob_fetch_addr();
// oob_fetch_addr();

send_status_event();
}
Expand Down
13 changes: 6 additions & 7 deletions app/src/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "connection.h"
#include "advertising.h"
#include "int_comm.h"
#include "oob.h"

#define LOG_MODULE_NAME fw_int_connection
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
Expand Down Expand Up @@ -160,9 +159,9 @@ void pairing_complete(struct bt_conn *conn, bool bonded)

bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

oob_signal();
bt_le_oob_set_sc_flag(false);
bt_le_oob_set_legacy_flag(false);
// oob_signal();
// bt_le_oob_set_sc_flag(false);
// bt_le_oob_set_legacy_flag(false);

if (bonded) {
advertising_setup_wl();
Expand All @@ -178,9 +177,9 @@ void pairing_failed(struct bt_conn *conn, enum bt_security_err reason)

bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

oob_signal();
bt_le_oob_set_sc_flag(false);
bt_le_oob_set_legacy_flag(false);
// oob_signal();
// bt_le_oob_set_sc_flag(false);
// bt_le_oob_set_legacy_flag(false);

LOG_INF("Pairing failed conn: %s, reason %d", addr, reason);
}
Expand Down
3 changes: 1 addition & 2 deletions app/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <zephyr/types.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/uart.h>
#include <zephyr/drivers/gpio.h>

#include <zephyr/device.h>
#include <zephyr/devicetree.h>
Expand All @@ -35,7 +36,6 @@
#include "int_comm.h"
#include "advertising.h"
#include "trz_nus.h"
#include "oob.h"
#include "events.h"

#define LOG_MODULE_NAME fw
Expand Down Expand Up @@ -94,7 +94,6 @@ static struct bt_conn_auth_cb conn_auth_callbacks = {
// .pairing_accept = pairing_accept,
.passkey_display = auth_passkey_display,
.passkey_confirm = auth_passkey_confirm,
.oob_data_request = auth_oob_data_request,
.cancel = auth_cancel,
};

Expand Down
9 changes: 9 additions & 0 deletions app/src/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ static void uart_cb(const struct device *dev, struct uart_event *evt, void *user
k_free(buf);
}
break;
case UART_RX_STOPPED:
LOG_DBG("UART_RX_STOPPED");
g_uart_rx_running = false;
rx_data_len= 0;
rx_len = 0;
rx_msg_type = 0;
rx_phase = 0;
k_work_reschedule(&uart_work, UART_WAIT_FOR_BUF_DELAY);
break;

case UART_TX_ABORTED:
LOG_DBG("UART_TX_ABORTED");
Expand Down
16 changes: 8 additions & 8 deletions boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
&pinctrl {
uart0_default: uart0_default {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 9)>,
<NRF_PSEL(UART_RTS, 0, 8)>;
psels = <NRF_PSEL(UART_TX, 0, 6)>,
<NRF_PSEL(UART_RTS, 0, 7)>;
};
group2 {
psels = <NRF_PSEL(UART_RX, 0, 6)>,
<NRF_PSEL(UART_CTS, 0, 7)>;
psels = <NRF_PSEL(UART_RX, 0, 9)>,
<NRF_PSEL(UART_CTS, 0, 8)>;
bias-pull-up;
};
};

uart0_sleep: uart0_sleep {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 9)>,
<NRF_PSEL(UART_RX, 0, 6)>,
<NRF_PSEL(UART_RTS, 0, 8)>,
<NRF_PSEL(UART_CTS, 0, 7)>;
psels = <NRF_PSEL(UART_TX, 0, 6)>,
<NRF_PSEL(UART_RX, 0, 9)>,
<NRF_PSEL(UART_RTS, 0, 7)>,
<NRF_PSEL(UART_CTS, 0, 8)>;
low-power-enable;
};
};
Expand Down

0 comments on commit f07cebd

Please sign in to comment.