wireless/cc1101: Add standard RF IOCTL support#18472
Merged
acassis merged 1 commit intoapache:masterfrom Mar 4, 2026
Merged
Conversation
Implement `cc1101_file_ioctl` to map common NuttX wireless IOCTL commands to CC1101 hardware registers. This allows dynamic configuration of radio parameters from user-space applications. * Map `WLIOC_SETRADIOFREQ` and `GETRADIOFREQ` to `FREQ[2:0]`. * Map `WLIOC_SETADDR` and `GETADDR` to `ADDR`. * Map `WLIOC_SETTXPOWER` and `GETTXPOWER` to internal PATABLE indexing. * Map `WLIOC_SETMODU` and `GETMODU` to `MDMCFG2`. * Map `WLIOC_FSK_SETBITRATE` and `GETBITRATE` to `MDMCFG4` and `MDMCFG3`. * Map `WLIOC_FSK_SETFDEV` and `GETFDEV` to `DEVIATN`. * Normalize positive SPI status byte returns from `cc1101_access` to `OK` (0) to ensure POSIX compliance and prevent silently skipped register writes. Signed-off-by: Chip L. <chplee@gmail.com>
jerpelea
approved these changes
Mar 4, 2026
xiaoxiang781216
approved these changes
Mar 4, 2026
acassis
approved these changes
Mar 4, 2026
Contributor
|
Nice work @AuroraRAS ! Thank you!!! |
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.
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_ioctlfunction to map abstractWLIOC_*commands to specific CC1101 hardware registers.WLIOC_SETRADIOFREQ): Calculates the 24-bit frequency word and applies it toFREQ[2:0], while zeroingCHANNRto prevent offset calculation errors.WLIOC_SETADDR): Maps to the single-byte hardwareADDRregister.WLIOC_SETTXPOWER): Maps absolute dBm index values to the internalPATABLEvia existingcc1101_setpowerAPI.WLIOC_SETMODU): Applies bitmasks toMDMCFG2to support FSK, GFSK, and OOK, while actively rejecting unsupported formats like LoRa with-ENOTSUP.WLIOC_FSK_SETBITRATE): Calculates the required exponent and mantissa, updatingMDMCFG4andMDMCFG3without overwriting receiver bandwidth configurations.WLIOC_FSK_SETFDEV): Computes and applies the frequency deviation exponent and mantissa to theDEVIATNregister.Additionally, this implementation normalizes positive SPI status bytes returned by
cc1101_accesstoOK(0), ensuring POSIX compliance and preventing silent bypasses of subsequent register writes.Impact
ioctl()calls using the<nuttx/wireless/ioctl.h>interface.-ENOSYSor-ENOTSUP.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 sequentialWLIOC_SET*andWLIOC_GET*operations, comparing the targeted integer values against the actual values calculated and read back from the hardware registers.Runtime Logs: