Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
395 changes: 395 additions & 0 deletions mcu_client/nrf5340_ble_simulator/CHANGELOG.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions mcu_client/nrf5340_ble_simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ include(nanopb)

# Custom driver module picked up via ZEPHYR_EXTRA_MODULES (module.yml)
add_subdirectory(src/mos_components/mos_pdm)
add_subdirectory(src/mos_components/mos_interrupt)
add_subdirectory(src/mos_components/mos_cvt2135)
add_subdirectory(src/mos_driver)

target_sources(app PRIVATE
Expand All @@ -30,6 +32,9 @@ target_sources(app PRIVATE
src/bsp_log_control.c
src/shell_log_control.c
src/shell_display_control.c
src/shell_gx8002_control.c
src/shell_spt513n_control.c
src/shell_cvt213x_control.c
src/mos_components/mos_sysport/src/bal_os.c
src/mos_components/mos_lvgl_display/src/mos_lvgl_display.c
src/mos_components/mos_lvgl_display/src/display_config.c
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
/ {
chosen {
zephyr,display = &hls12vga; // Switch to HLS12VGA projector for testing
nordic-nus-uart = &uart0;
zephyr,console = &cdc_acm_uart0; // USB CDC ACM for console/logging output
zephyr,shell-uart = &cdc_acm_uart0; // Shell on USB CDC ACM
nordic-nus-uart = &uart0; // BLE NUS on UART0
};
zephyr,user{
gx8002_power-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>; /* P0.04 controls GX8002 power */
gx8002_vad_int-gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>; /* P0.12 VAD interrupt (falling edge) */
vad_init_logic-gpios = <&gpio0 27 GPIO_ACTIVE_HIGH>; /* P0.27 Logic IO: HIGH during VAD initialization */
i2s_active_logic-gpios = <&gpio0 26 GPIO_ACTIVE_HIGH>; /* P0.26 Logic IO: HIGH during I2S active */
vad_voice_detect-gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>; /* P0.25 Voice detection: LOW=voice present, HIGH=no voice */
spt513n_reset-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>; /* P0.02 SPT513N reset pin (GPIO01, falling edge active: 下降沿有效, shared with I2C SDA) */
spt513n_sda-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>; /* P0.02 SPT513N I2C SDA (software I2C) */
spt513n_scl-gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>; /* P0.03 SPT513N I2C SCL (software I2C) */

cvt213x_int-gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>;
};
};

Expand All @@ -22,7 +36,7 @@
low-power-enable;
};
};

pwm1_default: pwm1_default {
group1 {
psels = <NRF_PSEL(PWM_OUT0, 0, 13)>; /* P0.13 */
Expand All @@ -34,14 +48,14 @@
low-power-enable;
};
};

pdm0_default: pdm0_default {
group1 {
psels = <NRF_PSEL(PDM_CLK, 1, 12)>,
<NRF_PSEL(PDM_DIN, 1, 11)>;
};
};

i2c2_default: i2c2_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 1, 14)>,
Expand All @@ -55,6 +69,52 @@
low-power-enable;
};
};
i2c3_default: i2c3_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 1, 13)>,
<NRF_PSEL(TWIM_SCL, 1, 7)>;
bias-pull-up;
};
};
i2c3_sleep: i2c3_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 1, 13)>,
<NRF_PSEL(TWIM_SCL, 1, 7)>;
low-power-enable;
};
};
i2c1_default: i2c1_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 1, 2)>,
<NRF_PSEL(TWIM_SCL, 1, 3)>;
bias-pull-up;
};
};
i2c1_sleep: i2c1_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 1, 2)>,
<NRF_PSEL(TWIM_SCL, 1, 3)>;
low-power-enable;
};
};
i2s0_default: i2s0_default {
group1 {
psels = <NRF_PSEL(I2S_SDIN, 1, 9)>, /* P1.09: Serial Data Input (from I2S microphones) */
<NRF_PSEL(I2S_SDOUT, 1, 10)>, /* P1.10: Serial Data Output (to I2S headphones) */
<NRF_PSEL(I2S_SCK_M, 1, 8)>, /* P1.08: Bit Clock Output (Master) */
<NRF_PSEL(I2S_LRCK_M, 1, 6)>; /* P1.06: Word Select Output (Master) */
};
};

i2s0_sleep: i2s0_sleep {
group1 {
psels = <NRF_PSEL(I2S_SDIN, 1, 9)>, /* P1.09: Serial Data Input */
<NRF_PSEL(I2S_SDOUT, 1, 10)>, /* P1.10: Serial Data Output */
<NRF_PSEL(I2S_SCK_M, 1, 8)>, /* P1.08: Bit Clock Output */
<NRF_PSEL(I2S_LRCK_M, 1, 6)>; /* P1.06: Word Select Output */
low-power-enable;
};
};
};

/* Disable SPI3 (8MHz limited) */
Expand All @@ -77,14 +137,14 @@
spi-max-frequency = <32000000>;

/* CS pins moved to P1.04 and P1.05 to avoid Arduino connector conflicts */
left_cs-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; /* P1.04 - avoid conflicts */
left_cs-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; /* P1.04 - avoid conflicts */
right_cs-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>; /* P1.05 - avoid conflicts */

/* Power enables and reset */
v0_9-gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>; /* P0.05 */
v1_8-gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>; /* P0.06 */
vcom-gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>; /* P0.07 */
reset-gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>; /* P1.01 */
v0_9-gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>; /* P0.05 */
v1_8-gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>; /* P0.06 */
vcom-gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>; /* P0.07 */
reset-gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>; /* P1.01 */

width = <640>;
height = <480>;
Expand Down Expand Up @@ -117,10 +177,10 @@
pinctrl-names = "default", "sleep";
clock-frequency = <I2C_BITRATE_FAST_PLUS>;
zephyr,concat-buf-size = <4096>;

ssd1306: ssd1306@3c {
compatible = "solomon,ssd1306fb";
reg = <0x3c>;
compatible = "solomon,ssd1306fb";
reg = <0x3c>;
width = <128>;
height = <64>;
segment-offset = <0>;
Expand All @@ -132,4 +192,64 @@
segment-remap;
status = "disabled"; // Disable SSD1306 for HLS12VGA testing
};
};
};

/* I2S Master Configuration - nRF5340 as master, generating clocks for I2S microphones */
&i2s0 {
compatible = "nordic,nrf-i2s";
status = "okay";
pinctrl-0 = <&i2s0_default>;
pinctrl-1 = <&i2s0_sleep>;
pinctrl-names = "default", "sleep";
};

zephyr_udc0: &usbd {
compatible = "nordic,nrf-usbd";
status = "okay";

cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
};
};

/* I2C1 for GX8002 communication (P1.02 SDA, P1.03 SCL) */
&i2c1 {
compatible = "nordic,nrf-twim";
status = "okay";
pinctrl-0 = <&i2c1_default>;
pinctrl-1 = <&i2c1_sleep>;
pinctrl-names = "default", "sleep";
};
&i2c3 {
compatible = "nordic,nrf-twim";
status = "okay";
pinctrl-0 = <&i2c3_default>;
pinctrl-1 = <&i2c3_sleep>;
pinctrl-names = "default", "sleep";
};
&uart0_sleep {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 20)>,
<NRF_PSEL(UART_RX, 0, 22)>,
<NRF_PSEL(UART_RTS, 0, 19)>;
};
};


&led0 {
status = "disabled";
};

&led1 {
status = "disabled";
};
&led2 {
status = "disabled";
};

&led3 {
status = "disabled";
};
// &uicr {
// nfct-pins-as-gpios;
// };
32 changes: 19 additions & 13 deletions mcu_client/nrf5340_ble_simulator/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,21 @@ CONFIG_PWM=y
CONFIG_PWM_LOG_LEVEL_DBG=y

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_MAIN_STACK_SIZE=4096

# Config logger
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=n
CONFIG_LOG_BACKEND_RTT=n
CONFIG_USE_SEGGER_RTT=y
# CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_PRINTK=n
CONFIG_LOG_PRINTK=y
# CONFIG_LOG_DEFAULT_LEVEL=0
# Configure log filtering - ensure printk goes to console
CONFIG_LOG_RUNTIME_FILTERING=y
# CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=4096
CONFIG_LOG_BUFFER_SIZE=8192
CONFIG_LOG_MODE_IMMEDIATE=n
CONFIG_LOG_MODE_DEFERRED=y

CONFIG_ASSERT=y

Expand Down Expand Up @@ -125,7 +131,7 @@ CONFIG_LV_FONT_FMT_TXT_LARGE=y
CONFIG_LV_TXT_ENC_UTF8=y

# Enable only essential Chinese CJK font (14px sufficient for SSD1306)
CONFIG_LV_FONT_SIMSUN_14_CJK=y
# CONFIG_LV_FONT_SIMSUN_14_CJK=y
# CONFIG_LV_FONT_SIMSUN_16_CJK=y # Disabled to save ~70KB

# International fonts disabled to save memory
Expand Down Expand Up @@ -162,13 +168,6 @@ CONFIG_USER_STEREO_1RX_L_1RX_R=y
CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_USER_DATA_LEN_UPDATE=y

# CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=4096
CONFIG_LOG_BUFFER_SIZE=8192
CONFIG_LOG_MODE_IMMEDIATE=n
CONFIG_LOG_MODE_DEFERRED=y



CONFIG_SSD1306=y
CONFIG_I2C=y
# Additional I2C and SSD1306 support
Expand All @@ -186,8 +185,15 @@ CONFIG_TFM_LOG_LEVEL_SILENCE=y
CONFIG_SHELL=y
CONFIG_LOG_CMDS=y
CONFIG_SHELL_BACKEND_SERIAL=y
CONFIG_SHELL_BACKEND_RTT=y
CONFIG_SHELL_PROMPT_UART="nrf5340:~$ "
CONFIG_SHELL_PROMPT_RTT="nrf5340:~$ "
CONFIG_SHELL_CMD_BUFF_SIZE=256
CONFIG_SHELL_PRINTF_BUFF_SIZE=64
CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE=4096
CONFIG_SHELL_STACK_SIZE=8192
CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE=512
CONFIG_SHELL_STACK_SIZE=8192
CONFIG_SHELL_BACKEND_SERIAL_LOG_MESSAGE_QUEUE_SIZE=2048


CONFIG_I2C_SHELL=y
CONFIG_SENSOR_SHELL=y
Loading