Skip to content

Commit

Permalink
somewhat working version
Browse files Browse the repository at this point in the history
  • Loading branch information
TychoVrahe committed Nov 1, 2024
1 parent ee3118c commit e1e57d3
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 33 deletions.
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
# This CMake file is picked by the Zephyr build system because it is defined
# as the module CMake entry point (see zephyr/module.yml).

# This is needed so that custom driver classes using system calls are taken into
# account
zephyr_syscall_include_directories(include)

zephyr_include_directories(include)

add_subdirectory(drivers)
add_subdirectory(lib)
20 changes: 20 additions & 0 deletions app/boards/t3w1_nrf52833.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_BT_CTLR=y
CONFIG_BT_LL_SW_SPLIT=y

# Enable Direction Finding Feature including AoA and AoD
CONFIG_BT_CTLR_DF=y

CONFIG_BT_CTLR_DF_CTE_RX=y
CONFIG_BT_CTLR_DF_CONN_CTE_RX=y
CONFIG_BT_CTLR_DF_ANT_SWITCH_RX=y
CONFIG_BT_CTLR_DF_CONN_CTE_REQ=y

# Ensure that there are enough control procedure contexts to queue and execute all procedures
CONFIG_BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM=6
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
33 changes: 33 additions & 0 deletions app/boards/t3w1_nrf52833.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
/ {
chosen {
nordic,nus-uart = &uart0;
};
};

&radio {
status = "okay";
/* This is the number of antennas that are available on the antenna matrix
* designed by Nordic Semiconductor. For more information see README.rst.
*/
dfe-antenna-num = <12>;
/* This is a setting that enables antenna 0 (in antenna matrix designed
* by Nordic Semiconductor) for Rx PDU. For more information see README.rst.
*/
dfe-pdu-antenna = <0x0>;

/* These are GPIO pin numbers that are provided to
* Radio peripheral. The pins will be acquired by Radio to
* drive antenna switching when AoA is enabled.
* Pin numbers are selected to drive switches on antenna matrix
* desinged by Nordic Semiconductor. For more information see README.rst.
*/
dfegpio0-gpios = <&gpio0 3 0>;
dfegpio1-gpios = <&gpio0 4 0>;
dfegpio2-gpios = <&gpio0 28 0>;
dfegpio3-gpios = <&gpio0 29 0>;
};
3 changes: 1 addition & 2 deletions app/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ CONFIG_UART_ASYNC_API=y
CONFIG_NRFX_UARTE0=y
CONFIG_SERIAL=y

CONFIG_NANOPB=y

# Enable the SPI driver
CONFIG_SPI=y
CONFIG_NRFX_SPIM0=y
Expand Down Expand Up @@ -96,4 +94,5 @@ CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_PRINTK=n

CONFIG_NANOPB=n
CONFIG_ASSERT=y
5 changes: 0 additions & 5 deletions app/src/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include "int_comm.h"
#include "oob.h"

#define CON_STATUS_LED DK_LED2

#define LOG_MODULE_NAME fw_int_connection
LOG_MODULE_REGISTER(LOG_MODULE_NAME);

Expand Down Expand Up @@ -47,8 +45,6 @@ void connected(struct bt_conn *conn, uint8_t err)
LOG_ERR("Phy update request failed: %d", err);
}

dk_set_led_on(CON_STATUS_LED);

send_status_event();
}

Expand All @@ -68,7 +64,6 @@ void disconnected(struct bt_conn *conn, uint8_t reason)
if (current_conn) {
bt_conn_unref(current_conn);
current_conn = NULL;
dk_set_led_off(CON_STATUS_LED);
}

send_status_event();
Expand Down
30 changes: 24 additions & 6 deletions app/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#define RUN_LED_BLINK_INTERVAL 1000

#define FW_RUNNING_SIG DK_LED3
#define CON_STATUS_LED DK_LED2


static K_SEM_DEFINE(ble_init_ok, 0, 1);
Expand Down Expand Up @@ -251,14 +252,31 @@ void ble_write_thread(void)

void led_thread(void)
{
int blink_status = 0;
/* Don't go any further until BLE is initialized */
k_sem_take(&led_init_ok, K_FOREVER);
bool connected = false;
int blink_status = 0;
/* Don't go any further until BLE is initialized */
k_sem_take(&led_init_ok, K_FOREVER);

for (;;) {
blink_status++;
dk_set_led(RUN_STATUS_LED, (blink_status) % 2);

connected = is_connected();

if (connected) {
dk_set_led_on(CON_STATUS_LED);
} else {

if (is_advertising() && !is_advertising_whitelist()) {
dk_set_led(CON_STATUS_LED, (blink_status) % 2);
} else {
dk_set_led_off(CON_STATUS_LED);
}
}


for (;;) {
dk_set_led(RUN_STATUS_LED, (++blink_status) % 2);
k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));
}
}
}


Expand Down
12 changes: 6 additions & 6 deletions app/src/trz_nus.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@
extern "C" {
#endif

/** @brief UUID of the NUS Service. **/
/** @brief UUID of the NUS Service. **/
#define BT_UUID_NUS_VAL \
BT_UUID_128_ENCODE(0x6e400001, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)
BT_UUID_128_ENCODE(0x8c000001, 0xa59b, 0x4d58, 0xa9ad, 0x073df69fa1b1)

/** @brief UUID of the TX Characteristic. **/
/** @brief UUID of the TX Characteristic. **/
#define BT_UUID_NUS_TX_VAL \
BT_UUID_128_ENCODE(0x6e400003, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)
BT_UUID_128_ENCODE(0x8c000003, 0xa59b, 0x4d58, 0xa9ad, 0x073df69fa1b1)

/** @brief UUID of the RX Characteristic. **/
/** @brief UUID of the RX Characteristic. **/
#define BT_UUID_NUS_RX_VAL \
BT_UUID_128_ENCODE(0x6e400002, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)
BT_UUID_128_ENCODE(0x8c000002, 0xa59b, 0x4d58, 0xa9ad, 0x073df69fa1b1)

#define BT_UUID_NUS_SERVICE BT_UUID_DECLARE_128(BT_UUID_NUS_VAL)
#define BT_UUID_NUS_RX BT_UUID_DECLARE_128(BT_UUID_NUS_RX_VAL)
Expand Down
12 changes: 6 additions & 6 deletions app/src/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void uart_cb(const struct device *dev, struct uart_event *evt, void *user
}

if (evt->data.tx.len == 0) {
buf = CONTAINER_OF(evt->data.tx.buf, uart_data_t, data);
buf = CONTAINER_OF(evt->data.tx.buf, uart_data_t, data[0]);

LOG_DBG("Free uart data");
k_free(buf);
Expand All @@ -69,12 +69,12 @@ static void uart_cb(const struct device *dev, struct uart_event *evt, void *user

if (aborted_buf) {
buf = CONTAINER_OF(aborted_buf, uart_data_t,
data);
data[0]);
aborted_buf = NULL;
aborted_len = 0;
} else {
buf = CONTAINER_OF(evt->data.tx.buf, uart_data_t,
data);
data[0]);
}

LOG_DBG("Free uart data");
Expand All @@ -93,7 +93,7 @@ static void uart_cb(const struct device *dev, struct uart_event *evt, void *user

case UART_RX_RDY:
// LOG_WRN("UART_RX_RDY");
buf = CONTAINER_OF(evt->data.rx.buf, uart_data_t, data);
buf = CONTAINER_OF(evt->data.rx.buf, uart_data_t, data[0]);
buf->len += evt->data.rx.len;

switch(rx_phase) {
Expand Down Expand Up @@ -221,7 +221,7 @@ static void uart_cb(const struct device *dev, struct uart_event *evt, void *user
case UART_RX_BUF_RELEASED:
LOG_DBG("UART_RX_BUF_RELEASED");
buf = CONTAINER_OF(evt->data.rx_buf.buf, uart_data_t,
data);
data[0]);

if (rx_phase == 3 && buf->len > 0) {
buf->len -= COMM_FOOTER_SIZE;
Expand Down Expand Up @@ -251,7 +251,7 @@ static void uart_cb(const struct device *dev, struct uart_event *evt, void *user

aborted_len += evt->data.tx.len;
buf = CONTAINER_OF(aborted_buf, uart_data_t,
data);
data[0]);

uart_tx(uart, &buf->data[aborted_len],
buf->len - aborted_len, SYS_FOREVER_MS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
# SPDX-License-Identifier: Apache-2.0

config BOARD_T3W1_NRF52833
select SOC_NRF52833_QIAA
bool "T3W1 NRF52833"
depends on SOC_NRF52833_QIAA
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@
&uart0 {
compatible = "nordic,nrf-uarte";
status = "okay";
current-speed = <115200>;
current-speed = <1000000>;
pinctrl-0 = <&uart0_default>;
pinctrl-1 = <&uart0_sleep>;
pinctrl-names = "default", "sleep";
hw-flow-control;
};

&spi0 {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ manifest:
- name: nrf
remote: ncs
repo-path: sdk-nrf
revision: main
revision: v2.6.2
import: true
- name: mcuboot
url: https://github.com/hiviah/mcuboot
Expand Down

0 comments on commit e1e57d3

Please sign in to comment.