7489 Commits

Author SHA1 Message Date
Max Kriegleder eb92f0f8c8 drivers/timers: avoid 32-bit overflow in arch_timer current_usec
current_usec() returns a uint64_t, but it used TICK2USEC(timebase)
to convert scheduler ticks to microseconds. On 32-bit clock_t builds,
TICK2USEC() performs the multiplication in 32-bit arithmetic before the
result is widened.

With CONFIG_USEC_PER_TICK=10000, this wraps after about 71.6 minutes:

  UINT32_MAX / 1000000 ~= 4294 seconds

After the wrap, up_timer_gettick() can report time near zero again. This
can leave absolute watchdog timeouts, such as those used by usleep() /
clock_nanosleep(), waiting for a tick value that will not be reached until
the 32-bit scheduler counter wraps.

Cast timebase to uint64_t before multiplying by USEC_PER_TICK so
current_usec() remains monotonic across the 32-bit microsecond boundary.

Signed-off-by: Max Kriegleder <max.kriegleder@gmail.com>
2026-05-06 08:49:52 +02:00
daniellizewski fe67544d5f drivers/usbhost/usbhost_cdcecm.c: Converted CDC-ECM to lower half
Converted USB Host CDC-ECM to a lower half driver.
Removed existing full network driver callbacks and replaced with lower
half.

Signed-off-by: daniellizewski <daniellizewski@geotab.com>
2026-05-06 06:20:03 +08:00
daniellizewski 9b18160893 drivers/usbhost/usbhost_cdcecm.c: Added support for Host CDC-ECM
Added support for USB host to use an USB CDC-ECM device.
This class is used for usb-ethernet adapters as well as many modems.

Signed-off-by: daniellizewski <daniellizewski@geotab.com>
2026-05-06 06:20:03 +08:00
daniellizewski 761c17f1e0 drivers/usbhost/usbhost_enumerate.c: Allow selecting USB configuration
Added support for selecting a different USB configuration.
Certain USB devices offer different classes using different
configurations. This allows a board file to provide a callback
to select the proper configuration for a given USB device.

Signed-off-by: daniellizewski <daniellizewski@geotab.com>
2026-05-06 06:20:03 +08:00
Alan Carvalho de Assis a1d6016962 drivers/sensors: Add support to MT6816
This commit adds support to MagTek MT6816 sensor

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-05-03 07:56:38 -03:00
Alan Carvalho de Assis 2b8be4a3da drivers/fb: Fix a symbol missing CONFIG_
This was a mistake that was preveting the boot logo to stay visible
for more time.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-05-02 15:26:10 -03:00
Matteo Golin 48db502daf !boards: Remove NSH_ARCHINIT and board_app_initialize
BREAKING: In an effort to simplify NuttX initialization, NSH_ARCHINIT is
removed. board_app_initialize is also removed. BOARD_LATE_INITIALIZE now
performs all board initialization logic, and is by default enabled. All
references to these symbols are removed. BOARDIOC_INIT remains, but will
result in -ENOTTY when called. It is to be removed in a later commit.

Quick fix: Boards relying on NSH_ARCHINIT should now enable
CONFIG_BOARD_LATE_INITIALIZE instead. If the application needs
fine-grained control over board initialization from userspace, the logic
performed by BOARDIOC_INIT may be copied to the board_finalinitialize
function and used instead via BOARDIOC_FINALINIT. All
board_app_initialize logic provided by NuttX is now moved to
board_late_initialize, and the same should be done for out-of-tree
boards.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-05-02 18:36:46 +08:00
raiden00pl 18716159c9 sensors/bmi270_uorb: support for fixed-point data
support for fixed-point data for bmi270_uorb

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-02 00:56:42 +08:00
raiden00pl c3190cd04b sensors/bmm150_uorb: support for fixed-point data
support for fixed-point data for bmm150_uorb

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-02 00:56:42 +08:00
raiden00pl cf9aaba449 sensors/bh1749nuc_uorb: support for fixed-point data
support for fixed-point data for bh1749nuc_uorb

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-02 00:56:42 +08:00
raiden00pl 192719aa82 sensors/adxl372_uorb: support for fixed-point data
support for fixed-point data for adxl372_uorb

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-02 00:56:42 +08:00
raiden00pl a5d9f14215 sensors/adxl362_uorb: support for fixed-point data
support for fixed-point data for adxl362_uorb

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-02 00:56:42 +08:00
raiden00pl 25ddf14cf5 sensors/hyt271_uorb: support for fixed-point data
support for fixed-point data for hyt271_uorb

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-02 00:56:42 +08:00
raiden00pl 5c3c369dbd sensors/bmp180_uorb: support for fixed-point data
support for fixed-point data for bmp180_uorb

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-02 00:56:42 +08:00
raiden00pl 37981b2b2f sensors/bmp280_uorb: support for fixed-point data
support for fixed-point data for bmp280_uorb

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-02 00:56:42 +08:00
raiden00pl 39378e1d46 drivers/sensors: add initial support for fixed-point data for sensors
new sensor framework can now select between float data type and
fixed-point data type

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-02 00:56:42 +08:00
Jukka Laitinen b810cbe4d3 drivers/timers: Add common include files, definitions and upper-half for DSHOT
DShot is a packet based serial protocol, used for controlling motor controllers
(ESCs), typically for drones.

This adds an upper-half driver for dshot protocol, along with common
configuration options and definitions definitions.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-04-30 12:24:47 +08:00
Alexey Matveev 369755d00b drivers/can: Fix close drain, write-only reader lifecycle, and STM32 RX header
Always allocate per-file can_reader on open so write-only descriptors get msgalign / ioctl state; free that context on close when it was never linked into cd_readers (fixes leak).

Cap each drain loop (20×500 ms) so close() cannot block forever when bxCAN retries without ACK or dev_txempty never clears.

Fix stm32can_vputreg debug log to print the written value (correct parameter name).

Signed-off-by: Alexey Matveev <tippet@yandex.ru>
2026-04-28 10:32:56 -03:00
Alan Carvalho de Assis 90ab0a8ae1 drivers/mpr121: Add support to MPR121 Capacitive Keypad
This driver adds support to MPR121 Capacitive Keypad usually found
at Aliexpress. The MPR121 is a touch sensor chip from Freescale/NXP
that supports up to 12 sensor electrodes and 1 proximity electrode.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-04-23 15:56:32 -03:00
Julian Oes 2fd76ea150 drivers/mtd/w25n: address review comments
- Replace syslog() with finfo()/fwarn() to follow the NuttX subsystem
  debug convention.
- Merge adjacent early-continue `if` branches in w25n_pick_free_spare
  and w25n_scan_factory_bad.
- Add Input Parameters / Returned Value sections to the BBM helper
  headers.
- Clarify why only -EIO triggers a remap retry in w25n_erase and
  w25n_bwrite (block-level E-FAIL/P-FAIL vs. transient bus faults).

Signed-off-by: Julian Oes <julian@oes.ch>
2026-04-23 16:26:44 +02:00
Julian Oes 0c287d6f45 drivers/mtd/w25n: implement bad block management
Use the chip's built-in 20-entry non-volatile Bad Block Management
Look-Up Table (datasheet section 8.2.7) to transparently route around
bad blocks.

Init:
- Reserve the top 24 blocks of the array as a spare pool
- Clamp the MTD geometry to W25N_USER_BLOCKS = 1000 so upper layers
  never see the spare area (125 MB usable instead of 128 MB)
- Force BUF=1 alongside enabling ECC. The W25N01GVxxIT variant
  power-ups with BUF=0 (Continuous Read mode), in which Read Data
  ignores the column address and always starts at byte 0 - which
  silently broke any read targeting a non-zero column (OOB markers,
  sub-page reads in w25n_read).
- Scan all 1024 blocks for factory bad markers (non-FFh at byte 0 of
  the spare area of page 0) and remap any user-area bad blocks via the
  A1h BBM command. Idempotent across reboots: blocks already present
  in the LUT are skipped, so repeated scans don't consume LUT slots.

Runtime:
- On E-FAIL from w25n_block_erase or P-FAIL from w25n_program_execute,
  allocate a spare and issue A1h, then retry the operation once. The
  chip routes the retry to the spare PBA transparently. Data buffer is
  reloaded on program retry.
- Uncorrectable read ECC is left as -EIO (soft errors shouldn't trigger
  permanent remap, and remapping discards data we may still recover).

Safeguards against burning LUT slots on bogus bad blocks:
- w25n_pick_free_spare erases each candidate spare as an active proof
  of life before returning it - the factory OOB marker alone isn't
  trusted.
- w25n_bbm_swap rejects A1h with LBA outside the user area or PBA
  outside the spare pool.

Stack discipline for the logger-thread hot path:
- The 20-entry cached LUT lives in the device struct, not on the stack.
- w25n_read_bbm_lut decodes 4 bytes at a time instead of reading the
  full 80-byte LUT dump into a local buffer.

Boot diagnostics are emitted via syslog so they appear unconditionally:
- [w25n] BBM scan summary (new/remapped/unremapped/previously-remapped/
  LUT slots used)
- [w25n] W25N01GV ready line with user blocks, spare count, geometry,
  and actual SPI frequency
- [w25n] per-remap info and warnings on runtime E-FAIL/P-FAIL paths

Note: existing littlefs filesystems become unmountable because the
block count shrinks from 1024 to 1000; both PX4 board init.c paths
already mount with autoformat so they reformat on first boot after
this change.

Signed-off-by: Julian Oes <julian@oes.ch>
2026-04-23 16:26:44 +02:00
simbit18 3349a40e9a sensors/Make.defs: Aligned Make with Cmake
This sensor was not present in the Make.defs file

     AMG88xx Infrared Array Sensor
     https://github.com/apache/nuttx/pull/12829

Moved:
    These drivers can be used with sensor connected over SPI or I2C bus
         Bosch Sensortec BMI160
         Bosch Sensortec BMI088

Signed-off-by: simbit18 <simbit18@gmail.com>
2026-04-22 06:22:55 +08:00
daniellizewski 1632beaede arch/arm/src/stm32h5/stm32_usbdrdhost.c: Fixed Hub support
Fixed a few bugs in the initial stm32_usbdrdhost.c implementation
when using a USB hub. Fixed fault when freeing control endpoints.
Fixed crash when disconnecting devices from hubs due ot use after free.

Signed-off-by: daniellizewski <daniellizewski@geotab.com>
2026-04-19 14:24:40 +08:00
likun17 2e27767b0c drivers/sensors: fix misplaced endif in bmi160_base.c
Move the #endif preprocessor guard to after bmi160_transferspi()
so that both bmi160_configspi() and bmi160_transferspi() are
properly enclosed within the SPI conditional compilation block.

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-04-15 17:47:46 +02:00
zhanxiaoqi 249df8c1d9 video/fb: guarantee fb read-write integrity to prevent display tearing
Serialization has been added to the paths of fb_read/fb_write, as well as
partial reading of plane/video information, updatearea, pandisplay, etc.
This covers the scenario where "one thread draws/switches via the character
device interface while another thread reads the framebuffer via the
character device interface", ensuring that the read framebuffer data
is complete and preventing screen tearing.

Signed-off-by: zhanxiaoqi <zhanxiaoqi@bytedance.com>
2026-04-15 10:18:16 -03:00
wangjianyu3 bebfaf8bb4 video/gc0308: implement V4L2 horizontal flip control
Implement get_supported_value, get_value and set_value callbacks
for IMGSENSOR_ID_HFLIP_VIDEO / IMGSENSOR_ID_HFLIP_STILL.  This
allows applications to mirror the camera preview horizontally at
runtime via VIDIOC_S_CTRL + V4L2_CID_HFLIP.

The hardware mirror is controlled by register 0x14 (CISCTL_MODE1)
bit[0], which reverses the pixel readout order with zero CPU cost.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-04-10 10:47:07 +02:00
wangjianyu3 e6ad9d25d7 video/gc0308: report V4L2_PIX_FMT_RGB565X for 8-bit DVP output
GC0308 register 0x24 bits[3:0] = 0x06 selects RGB565 output per
datasheet.  On an 8-bit DVP bus the high byte is clocked out first,
so the pixel data arrives in memory in big-endian order (RGB565X).

Report V4L2_PIX_FMT_RGB565X so that userspace can detect this and
byte-swap if needed for a little-endian display path.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-04-10 10:47:07 +02:00
Carlos Sanchez 81d57ad5d5 drivers/mtd/mx25rxx.c: use 4 byte address for large flash memories.
On power-up, MX25L25673G uses 3-byte addresses, so only the lower
128Mb (half the memory) can be accessed. This change ensures 4-byte
addresses are used so the whole memory can be used.

Co-Authored-By: Randy Rossi <randyrossi@geotab.com>
Signed-off-by: Carlos Sanchez <carlossanchez@geotab.com>
2026-04-08 09:52:57 +08:00
Piyush Patle 13d0e64ee6 style: fix checkpatch issues after debug.h move
Build Documentation / build-html (push) Has been cancelled
Fixed copespell errors, for CI sucess!

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
2026-04-07 07:50:06 -03:00
Piyush Patle 0dccc8ba21 include/debug.h: Move to include/nuttx/debug.h
debug.h is a NuttX-specific, non-POSIX header. Placing it in the
top-level include/ directory creates naming conflicts with external
projects that define their own debug.h.
This commit moves the canonical header to include/nuttx/debug.h,
following the NuttX convention for non-POSIX/non-standard headers,
and updates all in-tree references.

A backward-compatibility shim is left at include/debug.h that
emits a deprecation #warning and re-includes <nuttx/debug.h>,
allowing out-of-tree code to continue building while migrating.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
2026-04-07 07:50:06 -03:00
Piyush Patle 140f2c1c78 docs/rc: document RC/LIRC drivers and remove empty drivers/rmt files
Add documentation for the RC/LIRC character driver subsystem covering
device registration, the LIRC interface, and usage from user space.

Remove placeholder empty files under drivers/rmt that were left over
from the rmtchar era and are no longer referenced.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
2026-04-04 11:18:32 -03:00
Piyush Patle 7b590f9c43 espressif/rmt: replace rmtchar with arch-specific lirc adapter
Replace the ESP-specific rmtchar upper-half with arch-local esp_lirc
adapters for Xtensa and RISC-V.

 This moves the RMT upper-half out of drivers/rmt, registers LIRC
 devices from the ESP board bring-up paths, and removes the old common
 rmtchar driver and headers.

 Also update the ESP Kconfig and build wiring to build esp_lirc when
 ESP_RMT and DRIVERS_RC are enabled.

 Fixes discovered during hardware validation:
  - register TX as /dev/lirc1 so RX and TX do not collide
  - parse the RX worker thread argument from the correct argv slot
  - keep RX devices from advertising TX capability

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
2026-04-04 11:18:32 -03:00
wangjianyu3 5ba0d062b1 audio: add ES7210 4-ch ADC codec driver
Add ES7210 audio ADC driver for NuttX implementing the audio
lower-half interface. Supports 4-channel recording via I2S with
configurable sample rate, bit depth, and mic gain.

- drivers/audio/es7210.c: Codec driver using LPWORK for async buffer
  management, I2C register access, and NuttX audio buffer management
- drivers/audio/es7210.h: Internal register definitions and macros
- include/nuttx/audio/es7210.h: Public header with platform config
  structure and es7210_initialize() API
- drivers/audio/Kconfig, Make.defs, CMakeLists.txt: Build system
  integration for CONFIG_AUDIO_ES7210

Key implementation details:
- ES7210_SDP_NORMAL (normal I2S) instead of TDM, matching NuttX
  I2S standard Philips mode
- ES7210_ADC_PGA_POWER_ON bit in gain registers REG43-46, required
  for analog front-end amplifier power-on
- 50ms startup delay in es7210_start for codec clock stabilization
- I2S_IOCTL(AUDIOIOC_STOP) in es7210_stop to notify I2S layer,
  preventing DMA from running without buffers after stop

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-04-03 13:34:36 +08:00
Peter Barada efdbdfe409 arch/arm/stm32*: Use PRIx32 format specifier where appropriate
Replace 'x' printf format specifier with PRIx32 where
corresponding value is uint32_t type.

Signed-off-by Peter Barada <peter.barada@gmail.com>
2026-04-01 13:48:58 +08:00
wangjianyu3 4775b36316 drivers/usbdev: add UVC gadget class driver
Add USB Video Class 1.1 gadget driver supporting Bulk transport
with uncompressed YUY2 video streaming. Resolution and frame
interval are negotiated dynamically via PROBE/COMMIT control.

- uvc.h: protocol constants, streaming control struct, public API
- uvc.c: class driver with PROBE/COMMIT, bulk EP, /dev/uvc0 chardev
- Kconfig/Make.defs: USBUVC config and build rules
- boardctl.c: BOARDIOC_USBDEV_UVC standalone init path

Hardened against host disconnect:
- Removed nxmutex_lock from USB interrupt context paths
- Added 30s semaphore timeout in uvc_write with EP_CANCEL fallback
- Drain stale wrsem counts in VS_COMMIT before new stream
- Guard uvc_streaming_stop() against double EP_CANCEL race
- Handle EP_SUBMIT returning -ESHUTDOWN gracefully

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-03-29 12:35:22 -03:00
wangjianyu3 99afb5ee34 drivers/video/gc0308: add YUYV output format support
GC0308 sensor supports multiple output formats via register 0x24.
Add YUYV (YCbCr422) alongside existing RGB565 in fmtdescs and
configure the output format register dynamically in start_capture()
based on the requested pixel format.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-03-29 12:35:22 -03:00
Shunchao Hu 7b60f6dfec drivers/net/telnet: Fix typo.
This commit fixed code comment typo in telnet.c.

Signed-off-by: Shunchao Hu <ankohuu@gmail.com>
2026-03-25 20:49:43 +08:00
Shunchao Hu b86b309eea drivers/net/telnet: Ignore unsupported subnegotiation data.
Ignore unsupported telnet subnegotiation payload until `IAC SE` so
option bytes do not leak into the first NSH command.

Keep existing NAWS handling intact and also treat `IAC IAC` inside
subnegotiation payload as an escaped `0xFF` data byte rather than a
subnegotiation terminator.

This makes subnegotiation parsing RFC-compliant for both unsupported
options and NAWS payload processing.

Signed-off-by: Shunchao Hu <ankohuu@gmail.com>
2026-03-25 19:21:30 +08:00
buxiasen 9feaa4d841 mmcsd: fix MMC bus width switch using wrong condition and add 8-bit support
The MMC CMD6 bus width switch was gated on priv->buswidth which is
derived from the SD SCR register. For MMC cards this field is never
set (unless SDIO_CAPS_4BIT_ONLY), so the CMD6 was skipped while the
host PROCTL DTW was still changed - causing a bus width mismatch and
data transfer timeouts.

Fix by checking priv->caps instead of priv->buswidth for MMC cards.
Also select EXT_CSD_BUS_WIDTH_8 when host reports SDIO_CAPS_8BIT.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2026-03-24 15:39:07 +08:00
Huang Qi e09048cc88 style: Fix "is is" typo across the codebase.
Correct duplicate "is is" word found in 181 files throughout the
codebase.
In most cases "is is" was changed to "is", but in contexts like
"MCU is is sleep mode" it was corrected to "MCU in sleep mode".

Also fixes a "the the" typo in net/inet/inet_sockif.c.

This is a pure style/documentation fix that improves code readability.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-03-24 09:39:26 +08:00
simbit18 3d555976bb drivers: Fix Make style
- Remove spaces from make file

Signed-off-by: simbit18 <simbit18@gmail.com>
2026-03-23 18:16:46 -04:00
Huang Qi e3eeaefd6d style: Fix "the the" typo across the codebase.
Fix 269 occurrences of duplicate "the" word typo found in 209 files
across source code, header files, and configuration.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-03-23 11:07:49 +01:00
Michal Lenc 014f22b1c2 drivers/mtd/w25.c: ensure the device is not in power down mode
If power down mode is set, trying to read ID ends in an infinite loop
because w25_waitwritecomplete never returns as status register never
signalizes write complete. Therefore ensure the device is not in a
power down mode before trying to read from it.

This can be an issue if the board is trying to check for more NOR
memories on one SPI bus and one chip select. For example GD25 driver
returns the memory to power down state after read id is finished,
therefore board initialization is stuck in an infinite loop if it first
checks for GD25 and then fallbacks to W25.

The commit fixes the possible issue by ensuring W25 is brought back
to normal operation mode before trying to obtain the manufacturer ID.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2026-03-19 16:23:45 -04:00
Michal Lenc 600d0e413a ioexpander/iso1i813t: add option to check errors during read
This commit adds the possibility to check for expander errors when
reading the data. This is optional if glerr_check or interr_check
fields in configuration are not zero.

If not zero, read operation also reads ISO1I813T_GLERR and
ISO1I813T_INTERR register and returns error if there is some error.
The user can control which errors he wants to check with
glerr_check and interr_check masks.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2026-03-18 15:00:48 -03:00
Neil Berkman c1c6e26395 drivers/mtd/ftl: bypass rwbuffer when O_DIRECT is set
ftl_write() unconditionally routes writes through rwb_write() when
FTL_HAVE_RWBUFFER is defined, ignoring the O_DIRECT flag stored in
dev->oflags. This means callers that open with O_DIRECT expecting
unbuffered writes still get their data buffered in RAM.

The O_DIRECT flag is already checked in ftl_flush() to select
between direct and read-modify-write paths, but the buffering
decision in ftl_write() never consults it.

Add O_DIRECT checks in both ftl_write() and ftl_read() to bypass
rwbuffer entirely when the flag is set. For writes, go directly to
ftl_flush() and normalize the return value to match the block
driver convention (nsectors on success). For reads, go directly to
ftl_reload(), bypassing any read-ahead cache.

This gives O_DIRECT callers a complete bypass of the rwbuffer layer
for both reads and writes, matching the documented contract.

Signed-off-by: Neil Berkman <neil@xuku.com>
2026-03-18 13:05:20 +01:00
wangjianyu3 fadfa85296 drivers/video: add GC0308 VGA CMOS image sensor driver
Add support for the GalaxyCore GC0308 VGA CMOS image sensor.
The driver implements the NuttX imgsensor interface and supports
VGA (640x480), QVGA (320x240), and QQVGA (160x120) resolutions
via Kconfig selection. Output format is RGB565X (big-endian).

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-03-16 17:26:27 -03:00
wangjianyu3 a07a6a00f4 video: add V4L2_PIX_FMT_RGB565X pixel format support
Add big-endian RGB565 (RGB565X) pixel format throughout the V4L2
video pipeline:
- IMGDATA_PIX_FMT_RGB565X in imgdata.h
- IMGSENSOR_PIX_FMT_RGB565X in imgsensor.h
- Format conversion and buffer size handling in v4l2_cap.c

This is needed by 8-bit DVP camera sensors that output RGB565 in
big-endian byte order (high byte first on the data bus).

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-03-16 17:26:27 -03:00
Chip L. 4aca170070 wireless/cc1101: Make SPI burst and single frequencies configurable
This patch introduces CONFIG_CC1101_SPIFREQ_BURST and
CONFIG_CC1101_SPIFREQ_SINGLE to Kconfig, allowing users to override
the default SPI frequencies for the CC1101 wireless driver.

Previously, these values were hardcoded to 6.5 MHz and 9.0 MHz
respectively. While these are safe defaults for many setups, specific
hardware designs, high routing capacitance, or platforms utilizing
internal GPIO switching matrices (such as the ESP32) can suffer from
signal integrity degradation at these speeds. By exposing these to
Kconfig, users can easily adjust the clock speeds to match their
hardware capabilities without modifying the core driver source.

Impact:
- Build: Adds two new Kconfig options under WL_CC1101.
- Runtime: Retains 6.5 MHz / 9.0 MHz defaults. Behavior only changes
  if overridden via menuconfig.

Testing:
- Built with default values and custom Kconfig overrides.
- Hardware Testing: Tested on a sub-optimal platform utilizing an
  internal GPIO matrix (ESP32). The CC1101 failed to load at the
  default 6.5/9.0 MHz due to signal integrity issues. Downclocking
  the frequencies to 4.0 MHz via Kconfig successfully restored
  signal integrity and allowed the driver to initialize and operate
  normally.

Signed-off-by: Chip L. <chplee@gmail.com>
2026-03-12 14:23:35 +01:00
Chip L. 7bfd6ee33e wireless/cc1101: Add MSK/4-FSK, dynamic PATABLE ramping, and fix IOCTL safety
This commit overhauls the CC1101 RF driver to address physical hardware
constraints, prevent register wrap-around overflows, and support accurate
dBm power scaling via the standard IOCTL interface.

What this change does:
1. Adds WLIOC_MSK and WLIOC_4FSK modulation support in `ioctl.h` and driver.
2. Replaces static PATABLE initialization with a dynamic Ramp-up curve
   generator `cc1101_ioctl_apply_power()` based on lab calibration data.
3. Modifies WLIOC_SETTXPOWER and WLIOC_GETTXPOWER to process actual dBm
   values with a nearest-match algorithm instead of raw array indices.
4. Removes DEBUGASSERT on user-space IOCTL pointers and replaces them
   with strict -EFAULT checks.
5. Implements saturation clamping (e.g., mantissa to 256-511) to prevent
   bitrate and frequency deviation calculation overflows.
6. Rebuilds volatile PATABLE memory upon SLEEP mode wake-up.

Why it is necessary & what it fixes:
- Fixes severe OOK modulation distortion and FSK spectral splatter caused
  by statically assigned PATABLE indices.
- Fixes potential kernel panic in flat builds when IOCTL receives a NULL
  pointer from user space.
- Fixes register wrap-around (silent failures) when users pass
  out-of-bounds baud rate or FDEV values.
- Prevents RF silence after SLEEP mode due to PATABLE volatility.
- Resolves inaccurate power output when changing frequencies dynamically.

Impact:
Changes the behavior of CC1101 TX power and modulation IOCTLs to strictly
comply with standard `wlioc` definitions. Improves overall driver stability
and hardware safety.

Signed-off-by: Chip L. <chplee@gmail.com>
2026-03-11 16:05:19 +01:00
Chip L. 075215cd5b 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>
2026-03-11 02:25:50 +08:00