AuroraRAS opened a new pull request, #18472:
URL: https://github.com/apache/nuttx/pull/18472

   ## Summary
   
   The CC1101 driver previously lacked support for standard NuttX wireless 
IOCTL commands, preventing runtime configuration of radio parameters by 
user-space applications.
   
   This change implements the `cc1101_file_ioctl` function to map abstract 
`WLIOC_*` commands to specific CC1101 hardware registers.
   
   * **Radio Frequency (`WLIOC_SETRADIOFREQ`):** Calculates the 24-bit 
frequency word and applies it to `FREQ[2:0]`, while zeroing `CHANNR` to prevent 
offset calculation errors.
   * **Address (`WLIOC_SETADDR`):** Maps to the single-byte hardware `ADDR` 
register.
   * **Output Power (`WLIOC_SETTXPOWER`):** Maps absolute dBm index values to 
the internal `PATABLE` via existing `cc1101_setpower` API.
   * **Modulation (`WLIOC_SETMODU`):** Applies bitmasks to `MDMCFG2` to support 
FSK, GFSK, and OOK, while actively rejecting unsupported formats like LoRa with 
`-ENOTSUP`.
   * **Data Rate (`WLIOC_FSK_SETBITRATE`):** Calculates the required exponent 
and mantissa, updating `MDMCFG4` and `MDMCFG3` without overwriting receiver 
bandwidth configurations.
   * **FSK Deviation (`WLIOC_FSK_SETFDEV`):** Computes and applies the 
frequency deviation exponent and mantissa to the `DEVIATN` register.
   
   Additionally, this implementation normalizes positive SPI status bytes 
returned by `cc1101_access` to `OK` (`0`), ensuring POSIX compliance and 
preventing silent bypasses of subsequent register writes.
   
   ## Impact
   
   * **Users/API:** Exposes dynamic configuration capabilities to user-space 
applications via standard POSIX `ioctl()` calls using the 
`<nuttx/wireless/ioctl.h>` interface.
   * **Hardware:** Specific to the CC1101 transceiver.
   * **Compatibility:** Fully compatible with existing RF IOCTL definitions. 
Commands not applicable to CC1101 hardware (e.g., LoRa parameters, fine power 
steps) correctly return `-ENOSYS` or `-ENOTSUP`.
   * **Build/Security:** No impact on the core build process or system security.
   
   ## Testing
   
   To verify the quantitative accuracy of the mathematical conversions (e.g., 
Hz to register words, bps to mantissa/exponent) and ensure no regressions, a 
custom user-space application (`ecrf_test`) was executed.
   
   Testing was performed on an ESP32 hardware platform interfacing with dual 
CC1101 modules (`/dev/radio0`, `/dev/radio1`) and an nRF24L01 module 
(`/dev/nrf24l01`), validating a multi-transceiver architecture similar to the 
EvilCrowRF-V2 project. The test performs sequential `WLIOC_SET*` and 
`WLIOC_GET*` operations, comparing the targeted integer values against the 
actual values calculated and read back from the hardware registers.
   
   **Runtime Logs:**
   
   ```text
   nsh> ecrf_test
   --- EvilCrowRF-V2 Hardware Validation ---
   
   Testing device: /dev/radio0
     [PASS] FD: 3
   Starting CC1101 IOCTL hardware test on /dev/radio0...
     [PASS] Frequency: Target 433000000 Hz, Actual 432999816 Hz
     [PASS] Address: Target 0x5A, Actual 0x5A
     [PASS] TX Power Index: Target 2, Actual 2
     [PASS] Modulation: Target 2, Actual 2
     [PASS] Bitrate: Target 250000 bps, Actual 249938 bps
     [PASS] FSK Deviation: Target 47000 Hz, Actual 44433 Hz
   CC1101 IOCTL hardware test completed successfully.
   
   Testing device: /dev/radio1
     [PASS] FD: 3
   Starting CC1101 IOCTL hardware test on /dev/radio1...
     [PASS] Frequency: Target 433000000 Hz, Actual 432999816 Hz
     [PASS] Address: Target 0x5A, Actual 0x5A
     [PASS] TX Power Index: Target 2, Actual 2
     [PASS] Modulation: Target 2, Actual 2
     [PASS] Bitrate: Target 250000 bps, Actual 249938 bps
     [PASS] FSK Deviation: Target 47000 Hz, Actual 44433 Hz
   CC1101 IOCTL hardware test completed successfully.
   
   Testing device: /dev/nrf24l01
     [PASS] FD: 3
   Starting nRF24L01 IOCTL tests...
     [PASS] Freq: 2450000000 Hz
     [PASS] TX Power: -6 dBm
     [PASS] Fine TX Power: 0 (0.01 dBm)
     [PASS] Modulation correctly rejected non-GFSK.
     [PASS] Address: AA:BB:CC:DD:EE
     [PASS] Retransmit Config (Delay: 5, Count: 10)
     [PASS] Data Rate: 2Mbps
     [PASS] State Transition to STANDBY
     [PASS] TX Payload NoACK: Enabled
   Testing completed. Failures: 0
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to