wireless/cc1101: migrate to wlioc_rx_hdr_s and add operation modes

This commit refactors the CC1101 driver's read interface to comply with
the standard NuttX wireless character driver API and introduces extended
hardware operation modes.

- Migrate `cc1101_file_read` to accept and populate the standard
  `struct wlioc_rx_hdr_s` instead of returning raw byte arrays.
- Implement `cc1101_calc_rssi_dbm_x100` to preserve the hardware's
  0.5 dBm RSSI precision when scaling to 1/100 dBm units, eliminating
  the integer truncation loss present in the legacy calculation.
- Add `CC1101IOC_SETOPMODE` and `CC1101IOC_GETOPMODE` IOCTLs.
- Introduce four RF operation modes (`enum cc1101_opmode_e`):
  1. NORMAL: Standard packet mode with hardware filtering.
  2. PROMISCUOUS: Packet mode bypassing address filtering and retaining
     packets with CRC errors.
  3. SYNC_SERIAL: Bypasses FIFO, routes clock and data to GDO0/GDO2.
  4. ASYNC_SERIAL: Bypasses FIFO, routes async data to GDO2.
- Fix the `GS2200M_FIRST` IOCTL block offset in `wireless/ioctl.h` and
  allocate a dedicated IOCTL block for CC1101.

Signed-off-by: Chip L. <chplee@gmail.com>
This commit is contained in:
Chip L.
2026-03-09 10:23:12 +08:00
committed by Xiang Xiao
parent 72be575b1a
commit 075215cd5b
3 changed files with 236 additions and 5 deletions
+31 -1
View File
@@ -37,6 +37,7 @@
#include <nuttx/mutex.h>
#include <nuttx/semaphore.h>
#include <nuttx/spi/spi.h>
#include <nuttx/wireless/ioctl.h>
/****************************************************************************
* Pre-Processor Declarations
@@ -236,6 +237,11 @@
#define CC1101_GDO_CLK_XOSC128 0x3e
#define CC1101_GDO_CLK_XOSC192 0x3f
#define CC1101_FIRST (GS2200M_FIRST + GS2200M_NCMDS)
#define CC1101IOC_SETOPMODE _WLCIOC(CC1101_FIRST + 0)
#define CC1101IOC_GETOPMODE _WLCIOC(CC1101_FIRST + 1)
/****************************************************************************
* Public Data Types
****************************************************************************/
@@ -271,6 +277,16 @@ enum cc1101_status
CC1101_SXOFF
};
/* CC1101 Operation Mode Enumeration */
enum cc1101_opmode_e
{
CC1101_OPMODE_NORMAL = 0, /* Default: Packet mode, enable address and CRC filtering */
CC1101_OPMODE_PROMISCUOUS, /* Promiscuous: Packet mode, disable filtering, discard bad packets */
CC1101_OPMODE_SYNC_SERIAL, /* Synchronous serial: Bypass FIFO, GDO0 outputs clock, GDO2 outputs data */
CC1101_OPMODE_ASYNC_SERIAL /* Asynchronous serial: Bypass FIFO, GDO2 outputs async data */
};
struct cc1101_dev_s
{
const struct c1101_rfsettings_s *rfsettings;
@@ -294,7 +310,14 @@ struct cc1101_dev_s
mutex_t lock_rx_buffer; /* Protect access to rx fifo */
sem_t sem_rx; /* Wait for availability of received data */
sem_t sem_tx; /* Wait for availability of send data */
FAR struct pollfd *pfd; /* Polled file descr (or NULL if any) */
/* Polled file descr (or NULL if any) */
FAR struct pollfd *pfd;
/* Record the current operation mode */
enum cc1101_opmode_e opmode;
};
/* The RF Settings includes only those fields required to configure
@@ -535,6 +558,13 @@ uint8_t cc1101_setpower(FAR struct cc1101_dev_s *dev, uint8_t power);
int cc1101_calc_rssi_dbm(int rssi);
/****************************************************************************
* Convert RSSI as obtained from CC1101 to [dBm] x 100
*
****************************************************************************/
int cc1101_calc_rssi_dbm_x100(int rssi);
/****************************************************************************
* Enter receive mode and wait for a packet.
* If transmission is in progress, receive mode is entered upon its
+6 -1
View File
@@ -281,9 +281,14 @@
/* See include/nuttx/wireless/gs2200m.h */
#define GS2200M_FIRST (SX127X_FIRST + SX127X_NCMDS)
#define GS2200M_FIRST (SX126X_FIRST + SX126X_NCMDS)
#define GS2200M_NCMDS 9
/* See include/nuttx/wireless/cc1101.h */
#define CC1101_FIRST (GS2200M_FIRST + GS2200M_NCMDS)
#define CC1101_NCMDS 2
/****************************************************************************
* Public Types
****************************************************************************/