Skip to content

Commit b59e48f

Browse files
authored
Add support the nfsw control for omi v03 (#2429)
1 parent ad88fde commit b59e48f

File tree

5 files changed

+47
-24
lines changed

5 files changed

+47
-24
lines changed

omi/firmware/omi/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,10 @@ config OMI_ENABLE_HAPTIC
5555
"Enable the haptic support."
5656
default n
5757

58+
config OMI_ENABLE_RFSW_CTRL
59+
bool "Enable RFSwitch Control"
60+
help
61+
"Enable RFSwitch Control support."
62+
default y
63+
5864
endmenu

omi/firmware/omi/omi.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ CONFIG_BT_DIS_MODEL="Omi CV 1"
181181
CONFIG_BT_DIS_MANUF="Based Hardware"
182182
CONFIG_BT_DIS_FW_REV=y
183183
CONFIG_BT_DIS_HW_REV=y
184-
CONFIG_BT_DIS_FW_REV_STR="3.0.4"
184+
CONFIG_BT_DIS_FW_REV_STR="3.0.5"
185185
CONFIG_BT_DIS_HW_REV_STR="Based Hardware Omi"
186186

187187
#
@@ -362,3 +362,4 @@ CONFIG_OMI_ENABLE_SPEAKER=n
362362
CONFIG_OMI_ENABLE_BATTERY=y
363363
CONFIG_OMI_ENABLE_USB=n
364364
CONFIG_OMI_ENABLE_HAPTIC=y
365+
CONFIG_OMI_ENABLE_RFSW_CTRL=y

omi/firmware/omi/src/lib/dk2/button.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ void check_button_level(struct k_work *work_item)
225225

226226
// // Enter the low power mode
227227
is_off = true;
228-
bt_off();
228+
transport_off();
229229
turnoff_all();
230230
}
231231

omi/firmware/omi/src/lib/dk2/transport.c

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include <zephyr/logging/log.h>
1212
#include <zephyr/sys/atomic.h>
1313
#include <zephyr/sys/ring_buffer.h>
14+
#include <zephyr/drivers/gpio.h>
15+
#include <zephyr/dt-bindings/gpio/nordic-nrf-gpio.h>
1416
#include <hal/nrf_power.h>
1517
#include "transport.h"
1618
#include "config.h"
@@ -24,6 +26,10 @@
2426
#include <math.h> // For float conversion in logs
2527
LOG_MODULE_REGISTER(transport, CONFIG_LOG_DEFAULT_LEVEL);
2628

29+
#ifdef CONFIG_OMI_ENABLE_RFSW_CTRL
30+
static const struct gpio_dt_spec rfsw_en = GPIO_DT_SPEC_GET_OR(DT_NODELABEL(rfsw_en_pin), gpios, {0});
31+
#endif
32+
2733
// Counters for tracking function calls
2834
extern uint32_t gatt_notify_count;
2935
extern uint32_t write_to_tx_queue_count;
@@ -243,7 +249,6 @@ void broadcast_battery_level(struct k_work *work_item) {
243249

244250
LOG_PRINTK("Battery at %d mV (capacity %d%%)\n", battery_millivolt, battery_percentage);
245251

246-
247252
// Use the Zephyr BAS function to set (and notify) the battery level
248253
int err = bt_bas_set_battery_level(battery_percentage);
249254
if (err) {
@@ -774,10 +779,7 @@ void pusher(void)
774779
}
775780
}
776781

777-
//
778-
// Public functions
779-
//
780-
int bt_off()
782+
int transport_off()
781783
{
782784
// First disconnect any active connections
783785
if (current_connection != NULL) {
@@ -800,6 +802,15 @@ int bt_off()
800802
LOG_ERR("Failed to disable Bluetooth %d", err);
801803
}
802804

805+
// Pull the rfsw control low
806+
#ifdef CONFIG_OMI_ENABLE_RFSW_CTRL
807+
err = gpio_pin_set_dt(&rfsw_en, 0);
808+
if (err)
809+
{
810+
LOG_ERR("Failed to pull the rfsw control low %d", err);
811+
}
812+
#endif
813+
803814
// Turn off other peripherals
804815
#ifdef CONFIG_OMI_ENABLE_OFFLINE_STORAGE
805816
k_mutex_lock(&write_sdcard_mutex, K_FOREVER);
@@ -820,29 +831,35 @@ int bt_off()
820831
return 0;
821832
}
822833

823-
int bt_on()
824-
{
825-
int err = bt_enable(NULL);
826-
bt_le_adv_start(BT_LE_ADV_CONN, bt_ad, ARRAY_SIZE(bt_ad), bt_sd, ARRAY_SIZE(bt_sd));
827-
#ifdef CONFIG_OMI_ENABLE_OFFLINE_STORAGE
828-
bt_gatt_service_register(&storage_service);
829-
#endif
830-
sd_on();
831-
mic_on();
832-
833-
return 0;
834-
}
835-
836-
//periodic advertising
834+
// periodic advertising
837835
int transport_start()
838836
{
839837
k_mutex_init(&write_sdcard_mutex);
840838

839+
int err = 0;
840+
841+
// Pull the nfsw control high
842+
#ifdef CONFIG_OMI_ENABLE_RFSW_CTRL
843+
err = gpio_pin_configure_dt(&rfsw_en, (GPIO_OUTPUT | NRF_GPIO_DRIVE_S0H1));
844+
if (err)
845+
{
846+
LOG_ERR("Failed to get the rfsw pin config (err %d)", err);
847+
}
848+
else
849+
{
850+
err = gpio_pin_set_dt(&rfsw_en, 1);
851+
if (err)
852+
{
853+
LOG_ERR("Failed to pull the rfsw pin control high (err %d)", err);
854+
}
855+
}
856+
#endif
857+
841858
// Configure callbacks
842859
bt_conn_cb_register(&_callback_references);
843860

844861
// Enable Bluetooth
845-
int err = bt_enable(NULL);
862+
err = bt_enable(NULL);
846863
if (err)
847864
{
848865
LOG_ERR("Transport bluetooth init failed (err %d)", err);

omi/firmware/omi/src/lib/dk2/transport.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
* @return 0 if successful, negative errno code if error
1111
*/
1212
int transport_start();
13+
int transport_off();
1314
int broadcast_audio_packets(uint8_t *buffer, size_t size);
1415
struct bt_conn *get_current_connection();
15-
int bt_on();
16-
int bt_off();
1716
#endif

0 commit comments

Comments
 (0)