Dev nexfirmware i2s input#2014
Draft
yagarwal1307 wants to merge 9 commits intodev-nexfirmware-evt1from
Draft
Conversation
…rade support + nRF5340 I2S slave mode configuration
Main Features:
1. I2C Communication Interface Configuration
- Configure I2C1 interface for GX8002 communication (SDA: P1.02, SCL: P1.03)
- Support dual address mode: command address 0x2F, data address 0x36 (hardware-fixed OTA upgrade address)
- I2C1 pull-up configuration (via device tree pinctrl)
- Improved I2C error handling: automatically wait for bus recovery on consecutive errors
2. VAD Initialization Logic GPIO Monitoring
- Implement P0.27 GPIO for VAD initialization status monitoring
- HIGH state indicates VAD initialization in progress, LOW indicates initialization complete
- Initialization duration is extremely short, cannot be precisely measured (timestamp debugging code removed)
3. I2S Active Status Logic GPIO
- Implement P0.26 GPIO for I2S active status (start/stop) indication
- HIGH indicates I2S reception active, LOW indicates I2S stopped
4. VAD Voice Detection GPIO Control
- Implement P0.25 GPIO (GX8002-GPIO02) for voice detection status reading
- LOW indicates voice detected, HIGH indicates no voice
- After timer timeout, check P0.25: if LOW, extend timer by 5 seconds and continue detection; if HIGH, immediately stop I2S (master+slave)
5. OTA Firmware Upgrade Support
- Implement Shell command `gx8002 update <version>` for firmware upgrade
- Temporarily embed v07, v08 versions in firmware for testing
- Automatically disable VAD interrupt and stop I2S before upgrade to avoid I2C bus conflicts
- Automatically re-enable VAD interrupt after upgrade
- Improved handshake retry logic with I2C bus recovery support
- Future plan: Use LittleFS to store 8002 OTA firmware
6. USB CDC + RTT Logging Support
- Add usb_cdc.conf configuration file, enable USB CDC ACM as console
- Enable SEGGER RTT support (CONFIG_USE_SEGGER_RTT=y)
- Configure Shell to support both USB CDC and RTT backends
- Logs can be output via USB CDC (RTT log backend can be enabled as needed)
7. Firmware Size Optimization
- Temporarily disable CONFIG_LV_FONT_SIMSUN_14_CJK to reduce firmware size
- Keep other necessary font configurations
8. I2C Shell Support
- Add CONFIG_I2C_SHELL=y and CONFIG_SENSOR_SHELL=y
- Support I2C communication debugging via Shell commands
9. Interrupt Handling Framework Refactoring
- Implement generic interrupt handling framework (interrupt_handler.c)
- Separate VAD interrupt handling logic into independent module (vad_interrupt_handler.c)
- Unified VAD interrupt enable/disable API (bsp_gx8002_vad_int_disable/re_enable)
- Improved interrupt handling flow to prevent re-entry and I2C conflicts
10. I2S Audio Stream Processing Optimization
- Implement I2S slave mode reception (nRF5340 as slave device)
- Stereo to mono conversion (using average method, suitable for ASR and translation applications)
- Optimize audio buffer management
- Support independent I2S stop (does not affect LC3 encoding and BLE transmission)
11. GX8002 Power Control GPIO
- Implement P0.04 GPIO for GX8002 chip power control
- HIGH indicates power on, LOW indicates power off
- Set to HIGH (power on) during initialization
- Used for firmware reset: power off for 2 seconds then power on (power cycle reset)
- Shell command `gx8002 reset` uses this GPIO for power cycle reset
12. VAD Interrupt GPIO
- Implement P0.12 GPIO for receiving GX8002 VAD (Voice Activity Detection) interrupt signal
- Configured as input mode with internal pull-up resistor
- Falling edge triggered interrupt (GPIO_INT_EDGE_FALLING)
- When GX8002 detects voice, generates falling edge interrupt on this pin
- After interrupt trigger, automatically starts GX8002 I2S output and nRF5340 I2S slave mode reception
- Support interrupt enable/disable API for avoiding I2C bus conflicts during OTA upgrade
13. Device Tree Configuration Updates
- Add I2C1 pinctrl configuration (i2c1_default, i2c1_sleep)
- Add I2S0 pinctrl configuration (i2s0_default, i2s0_sleep)
- Configure USB CDC ACM device (cdc_acm_uart0)
- Define all GPIOs (P0.04 power control, P0.12 VAD interrupt, P0.25 voice detection, P0.26 I2S active, P0.27 VAD initialization)
Technical Details:
- Use Zephyr GPIO API for all GPIO operations
- Use Zephyr I2C API for GX8002 communication
- Use Zephyr I2S API for audio reception
- Use Zephyr Shell subsystem for firmware upgrade commands
- All hardware configurations managed through Device Tree
File Changes:
- New: mos_components/mos_interrupt/ (interrupt handling framework)
- New: mos_driver/src/gx8002_update.c (OTA upgrade implementation)
- New: shell_gx8002_control.c (Shell command implementation)
- New: usb_cdc.conf (USB CDC configuration)
- Modified: bsp_gx8002.c (I2C communication, GPIO control, interrupt management)
- Modified: vad_interrupt_handler.c (VAD business logic, GPIO control)
- Modified: pdm_audio_stream.c (I2S reception, stereo to mono conversion)
- Modified: Device tree overlay (I2C1, I2S0, USB CDC, GPIO configuration)
- Modified: prj.conf (RTT logging, I2C Shell, font configuration)
…n support New Features: - Implement STP513N driver core functionality (software I2C, hardware reset, EEPROM configuration management) - Add Shell command interface for testing and debugging (11 commands) - Support touch configuration parameter read/write and update - Configure I2S0 as Master mode, supporting external I2S microphone input and headphone output New Files: - src/mos_driver/include/stp513n.h - src/mos_driver/src/stp513n.c - src/shell_stp513n_control.c Modified Files: - boards/nrf5340dk_nrf5340_cpuapp_ns.overlay: * Add STP513N GPIO configuration (P0.02/P0.03) * Configure I2S0 as Master mode (P1.06/P1.08/P1.09/P1.10) - src/main.c: Add STP513N driver initialization - src/mos_driver/src/bspal_audio_i2s.c: Configure I2S as Master mode - src/pdm_audio_stream.c: Support I2S input and headphone output - src/pdm_audio_stream.h: Update I2S related interfaces - CMakeLists.txt: Add new files to build list Technical Features: - STP513N: Software I2C implementation (GPIO emulation, P0.02 SDA, P0.03 SCL) - STP513N: Hardware reset sequence (P0.02, falling edge active, 20ms LOW + 10ms HIGH) - STP513N: Complete reset and connection within 100ms window - STP513N: EEPROM configuration management (64 bytes) - I2S Master: nRF5340 acts as master device, generating clocks for external I2S microphones - I2S Master: Support stereo input (dual microphones) and output (headphones) - I2S Master: 16kHz sample rate, 16-bit, stereo Hardware Connections: STP513N: - Reset/SDA: P0.02 (shared pin) - SCL: P0.03 - I2C Address: 0x60 I2S Master: - SCK (Bit Clock): P1.08 (output, Master) - LRCK (Word Select): P1.06 (output, Master) - SDIN (Serial Data In): P1.09 (input, from I2S microphones) - SDOUT (Serial Data Out): P1.10 (output, to I2S headphones)
- Remove all #region agent log debug instrumentation - Clean up temporary debugging code added during development - Part of STP513N and I2S Master configuration cleanup
Major changes: - Add CVT213X touch sensor driver and application layer code - Add app_cvt213x component (main controller, porting layer, library files) - Implement I2C communication, interrupt handling and gesture recognition - Integrate vendor SDK library (cva_tws) - Hardware configuration updates - Add I2C3 bus configuration (P1.13/P1.7) - Configure CVT213X interrupt pin (P0.29) - Disable onboard LEDs to avoid pin conflicts - Adjust device tree overlay configuration - Driver integration - Add cvt213x.c/h driver files - Implement I2C initialization and verification functions - Add Shell commands for debugging and testing - Main program updates - Initialize CVT213X system in main.c - Call touch processing thread in main loop - Temporarily disable LED blinking to reduce interference - Build system - Update CMakeLists.txt to add new component - Link CVT213X related source files Test status: Requires hardware verification of I2C communication and touch detection functionality
✨ New Features: - Add `cvt213x sleep` shell command for sleep mode testing - Add `cvt213x wakeup` shell command for wakeup testing - Invoke app_cvt213x_sleep() and app_cvt213x_wakeup() APIs 🔧 Configuration Adjustments: - DOZE_SCAN period: 0x0005 → 0x0019 (~10ms → ~50ms) - Optimize scan frequency in doze mode for power/responsiveness balance 📝 Modified Files: - mcu_client/nrf5340_ble_simulator/src/shell_cvt213x_control.c (+28 lines) * Include app_cvt213x_main.h header * Implement cmd_cvt213x_sleep() and cmd_cvt213x_wakeup() handlers * Update help menu with new commands * Register sleep/wakeup to shell subcommand set - mcu_client/.../cva_tws_config.h (+1 line) * DOZE_SCAN: 0x0005 → 0x0019 (10ms → 50ms) 🧪 Testing: uart:~$ cvt213x sleep # Enter sleep mode uart:~$ cvt213x wakeup # Wake up device
…ear detection [Key Features] 1️⃣ Debounce Timer Implementation (shim layer) - recheck_timer (50ms): Re-check after INT pin falling edge to ensure debouncing - inear_debounce_timer (50ms): Called by IED process, supports restart/stop interface - Timer callbacks trigger polling flags and drive scheduler events 2️⃣ IED Gesture Detection Integration (cva_tws_gesture.c) - Call restart() during ON/OFF debounce phases to restart timer - Call stop() when debounce counter reaches threshold - Support both normal mode and calibration mode paths 3️⃣ Platform Adaptation Layer Refactoring - Add I2C HAL interfaces to cvt213x.c (cvt213x_i2c_init/verify) - Unify I2C initialization in driver layer (i2c3 dedicated) - Standardize app_cvt213x_* alias forwarding 4️⃣ Code Cleanup - Remove app_cvt213x_log.h and bsp_i2c.h - Remove app_cvt213x_thread() polling in main.c - porting.c: Remove periodic timer and worker thread - Migrate scheduler to shim layer (app_hal_cvt213x_scheduler_init)
…d future implementation
Overview: Uniformly change the naming of the touch chip from "STP513N" to "SPT513N", simultaneously update the driver/header files, Shell commands, device tree properties and CMake references; no functional changes involved. Specific modifications: Build files: Update the referenced source files and Shell control files CMakeLists.txt Device tree: Rename the zephyr and user node attributes from stp513n_* to spt513n_* (reset/sda/scl) nrf5340dk_nrf5340_cpuapp_ns.overlay Main program: Header file inclusion and prompt text are changed to "spt513n", and initialization call is changed to "spt513n_init()" main.c Driver interface: Rename the header/source files, unify the macros and API prefixes from stp513n_* to spt513n_*; STP513N_I2C_ADDR → SPT513N_I2C_ADDR spt513n.h,spt513n.c Shell command: Module name, command registration and help text changed to spt513n, SHELL_CMD_REGISTER(spt513n, ...) shell_spt513n_control.c Impact and Compatibility: The shell interactive commands have been changed from stp513n to spt513n (please update usage habits accordingly) The device tree attribute names have been changed to spt513n_* and the code has been adjusted accordingly There are no functional changes; mainly, the naming consistency has been corrected
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.