Skip to content

PEND: drivers: basic_radio: add basic radio API and TI CC23x0 backend - #255

Open
DavidFoscaTI wants to merge 8 commits into
TexasInstruments:v4.4.0-ti-nextfrom
DavidFoscaTI:basic_radio_ti_next
Open

DavidFoscaTI wants to merge 8 commits into
TexasInstruments:v4.4.0-ti-nextfrom
DavidFoscaTI:basic_radio_ti_next

Conversation

@DavidFoscaTI

@DavidFoscaTI DavidFoscaTI commented Dec 2, 2026 •

Copy link
Copy Markdown

Add a vendor-neutral driver API for packet radios below the link layer, for applications that run their own protocol on a radio with no protocol-specific Zephyr API.

A PHY is as an opaque pointer and must only go to a radio of the backend that defined it. Frequency, sync word, TX power and maximum payload length are applied on top of the PHY; flags select the fields to apply, so any value, including 0, can be set. TX, RX and tone operations are asynchronous, take per-operation overrides and can be scheduled on the radio time base. get_caps() reports the optional operations and the frequency and power ranges of the active PHY; ext_ctl() carries vendor commands. Devicetree describes the radio hardware only.

The CC23x0 backend drives the on-chip radio through the Radio Control Layer (RCL) of hal_ti. A CC23x0 PHY names an LRF_Config generated by SysConfig, the phyFeatures word selecting its sub-PHY, its characterized frequency range and the default frequency, sync word and TX power applied when it is selected. The frame header layout and TX power range are read from the register list of the LRF_Config, so PHYs with different layouts can be switched at runtime. Only generic PBE configurations are accepted. The certified PHYs of the CC2340R5 are provided in a C catalog, whose default PHY is applied at init unless CONFIG_BASIC_RADIO_CC23X0_DEFAULT_PHY is disabled.

Signed-off-by: David Fosca Gamarra d-foscagamarra@ti.com

DO NOT MERGE

@DavidFoscaTI
DavidFoscaTI requested a review from a team December 2, 2026 15:49
@qodo-code-review

qodo-code-review Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

drivers: basic_radio: add basic radio API and TI CC23x0 backend

✨ Enhancement 🕐 40+ Minutes

Grey Divider

AI Description

• Adds a vendor-neutral basic_radio API for packet radios below the link layer: TX, RX, tone,
 stop, time, caps, ext_ctl.
• Adds a TI CC23x0 backend over hal_ti's RCL, with PHYs as opaque pointers to SysConfig LRF_Config
 exports.
• Ships a CC2340R5 certified PHY catalog, a devicetree binding, Kconfig options, three samples, and
 a hal_ti revision bump.
Merge Risk 🟡 Medium

Blast radius 🟡 Medium 💥 4 capabilities

  • 4 affected capabilities within one bounded functional scope: basic_radio_cc23x0_integration.
  • Configuration, PHY catalog lookup, RCL initialization, and runtime parameter application all control the same CC23x0 radio instance consumed by TX, RX, and tone operations; they are one bounded integration.
  • The send API, TX buffer, RCL command, callback, and TX sample jointly implement the packet-transmission outcome within the same CC23x0 integration.
  • The RX command, reusable buffers, callback reporting, immediate recycling, application queue, metadata, and RX sample restart implement one packet-reception outcome within the same CC23x0 Basic Radio integration.
  • The tone API, RCL test command, duration and stop logic, callback, and CW sample implement one continuous-wave outcome within the CC23x0 integration.
Sources

samples/drivers/basic_radio/radio_rx/src/main.c[167-194]

		while (k_msgq_get(&rx_queue, &pkt, K_NO_WAIT) == 0) {
			cnt++;
			rx_pkt_print(&pkt, cnt);
			gpio_pin_toggle_dt(&led);
		}

		atomic_val_t dropped = atomic_clear(&rx_dropped);

		if (dropped != 0) {
			LOG_WRN("%ld packets dropped: queue full", (long)dropped);
		}

		if (!atomic_cas(&rx_done, 1, 0)) {
			continue;
		}

		/* Continuous reception ends only on stop or error: restart it */
		if (rx_done_status == -ENOBUFS) {
			LOG_WRN("RX ran out of buffers, restarting");
		} else {
			LOG_INF("RX done: %d, restarting", rx_done_status);
		}

		ret = basic_radio_recv_async(rf_dev, NULL, rx_cb, NULL);
		if (ret != 0) {
			LOG_ERR("recv_async failed: %d", ret);
			return ret;
		}
Behavioral complexity 🔴 High 🧩 Concurrent ordering, Interacting branches

  • Before: no CC23x0 packet TX path existed.
  • After: one shared TX buffer and command are protected by radio state ownership while per-packet validation, scheduling, payload copying, submission, and callback completion interact.
  • New correctness conditions are that copied data remains valid through RCL completion, immediate failures restore IDLE, and callbacks correspond to the operation owning the shared command.
Potential damage 🟡 Medium 🩹 Temporary loss

  • A configuration or PHY-selection regression can leave the enabled CC23x0 radio unusable or without an active PHY; callers can retry configuration or restart the device.
  • No application data is persisted by this path.
  • A code revert restores future configuration attempts, but a failed or partially completed PHY transition may require a successful reconfiguration or device restart before operations resume.
Sources

drivers/basic_radio/backends/ti/cc23x0/basic_radio_cc23x0.c[1326-1348]

	RCL_init();

	/* Default PHY and its default runtime parameters */
	if (default_phy != NULL) {
		struct basic_radio_cc23x0_hdr hdr;
		struct basic_radio_cc23x0_power_range power;
		int ret = phy_info_get(default_phy, &hdr, &power);

		if (ret == 0) {
			ret = phy_select(data, default_phy, &hdr, &power);
		}

		if (ret != 0) {
			LOG_ERR("default PHY %p failed: %d", (const void *)default_phy, ret);

			return ret;
		}

		rf_params_set(data, default_phy->frequency, default_phy->sync_word,
			      default_phy->tx_power, max_len_get(&hdr));
	} else {
		rf_params_set(data, 0U, 0U, 0, MAX_PACKET_LEN);
	}
Assessed commit e85c7d6
Diagram

graph TD
  App["Application"] --> API["basic_radio API"] --> Backend["CC23x0 backend"] --> RCL["RCL (hal_ti)"] --> Radio[("CC23x0 radio")]
  Catalog["CC2340R5 PHY catalog"] --> Backend
  DT["Devicetree node"] --> Backend
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. PHY selection through devicetree properties
  • ➕ Declarative, fixed at build time
  • ➕ Matches other Zephyr hardware descriptions
  • ➖ Cannot express a full SysConfig register list
  • ➖ Switching PHYs at runtime would need a reboot or overlay
2. Per-PHY ops tables in the API
  • ➕ Type-safe per-backend dispatch
  • ➖ Leaks vendor concepts into the public API
  • ➖ Harder to keep portable across vendors

Recommendation: The PR's split is sound: a runtime opaque PHY pointer, defined per backend, keeps the vendor-neutral API free of vendor types and lets applications switch PHYs without rebuilding the devicetree. Devicetree-described PHYs were considered and rejected because the PHY is a large vendor register list that does not fit devicetree properties. Reusing an existing Zephyr radio API was considered and rejected because none exists below the link layer.

Files changed (30) +2785 / -1

Enhancement (13) +2542 / -0
basic_radio_cc23x0.cImplement CC23x0 basic_radio driver over RCL +1281/-0

Implement CC23x0 basic_radio driver over RCL

• Implements config, TX, RX, tone, stop, time, caps and ext_ctl on RCL. Parses LRF_Config register lists for frame header layout and TX power range, handles scheduling, RX buffer recycling, and a 64-bit time base extended from the 32-bit SYSTIM counter.

drivers/basic_radio/backends/ti/cc23x0/basic_radio_cc23x0.c

basic_radio_cc23x0.hAdd private CC23x0 backend types +87/-0

Add private CC23x0 backend types

• Defines header layout, power range, state enum and the per-device driver data struct.

drivers/basic_radio/backends/ti/cc23x0/basic_radio_cc23x0.h

basic_radio_cc23x0_phy_catalog_cc2340r5.cAdd CC2340R5 certified PHY catalog +67/-0

Add CC2340R5 certified PHY catalog

• Defines BLE 1M/2M/coded, IEEE 802.15.4 and two proprietary PHYs, and selects BLE 1M as the default.

drivers/basic_radio/backends/ti/cc23x0/basic_radio_cc23x0_phy_catalog_cc2340r5.c

basic-radio-base.yamlAdd base basic_radio binding +14/-0

Add base basic_radio binding

• Include-only base binding describing radio hardware; PHYs are not in devicetree.

dts/bindings/basic_radio/basic-radio-base.yaml

ti,cc23x0-basic-radio.yamlAdd TI CC23x0 basic_radio binding +23/-0

Add TI CC23x0 basic_radio binding

• Defines compatible ti,cc23x0-basic-radio including the base binding, with an example node.

dts/bindings/basic_radio/ti,cc23x0-basic-radio.yaml

basic_radio.hAdd public basic_radio driver API +540/-0

Add public basic_radio driver API

• Defines opaque PHY type, config/TX/RX/tone parameter structs, flags, events, callback, caps, and inline wrappers over the driver API.

include/zephyr/drivers/basic_radio.h

ti_cc23x0.hAdd CC23x0 PHY and vendor command header +199/-0

Add CC23x0 PHY and vendor command header

• Defines the CC23x0 PHY struct and DEFINE/PHY macros, certified PHY externs, and the TI_CC23X0_EXT_GET_STATS command.

include/zephyr/drivers/basic_radio/ti_cc23x0.h

CMakeLists.txtAdd RX sample build file +8/-0

Add RX sample build file

• Standard sample CMake project building src/main.c.

samples/drivers/basic_radio/radio_rx/CMakeLists.txt

main.cAdd continuous RX sample +115/-0

Add continuous RX sample

• Starts continuous reception and logs each packet, toggling an LED from the callback.

samples/drivers/basic_radio/radio_rx/src/main.c

CMakeLists.txtAdd CW sample build file +8/-0

Add CW sample build file

• Standard sample CMake project building src/main.c.

samples/drivers/basic_radio/radio_test_cw/CMakeLists.txt

main.cAdd continuous wave tone sample +75/-0

Add continuous wave tone sample

• Emits a 5 s tone on the default PHY and waits for TONE_DONE.

samples/drivers/basic_radio/radio_test_cw/src/main.c

CMakeLists.txtAdd TX sample build file +8/-0

Add TX sample build file

• Standard sample CMake project building src/main.c.

samples/drivers/basic_radio/radio_tx/CMakeLists.txt

main.cAdd periodic TX sample +117/-0

Add periodic TX sample

• Sends a fixed payload every 2 s and blinks an LED on success.

samples/drivers/basic_radio/radio_tx/src/main.c

Tests (3) +51 / -0
tests.yamlAdd RX sample test entry +17/-0

Add RX sample test entry

• Runs the RX sample on lp_em_cc2340r5 and matches a console banner.

samples/drivers/basic_radio/radio_rx/tests.yaml

tests.yamlAdd CW sample test entry +17/-0

Add CW sample test entry

• Runs the CW sample on lp_em_cc2340r5 and matches a completion banner.

samples/drivers/basic_radio/radio_test_cw/tests.yaml

tests.yamlAdd TX sample test entry +17/-0

Add TX sample test entry

• Runs the TX sample on lp_em_cc2340r5 and matches a sent-bytes banner.

samples/drivers/basic_radio/radio_tx/tests.yaml

Other (14) +192 / -1
CMakeLists.txtRegister basic_radio subdirectory +1/-0

Register basic_radio subdirectory

• Adds add_subdirectory_ifdef(CONFIG_BASIC_RADIO basic_radio).

drivers/CMakeLists.txt

KconfigSource basic_radio Kconfig +1/-0

Source basic_radio Kconfig

• Sources drivers/basic_radio/Kconfig into the driver menu.

drivers/Kconfig

CMakeLists.txtAdd basic_radio build entry +5/-0

Add basic_radio build entry

• Adds the CC23x0 backend subdirectory when its Kconfig is enabled.

drivers/basic_radio/CMakeLists.txt

KconfigAdd BASIC_RADIO Kconfig options +50/-0

Add BASIC_RADIO Kconfig options

• Defines the experimental BASIC_RADIO menu, init priority, max packet length, and RX/TX buffer counts.

drivers/basic_radio/Kconfig

CMakeLists.txtBuild CC23x0 backend and CC2340R5 catalog +12/-0

Build CC23x0 backend and CC2340R5 catalog

• Compiles the backend and adds the CC2340R5 PHY catalog only for that SoC.

drivers/basic_radio/backends/ti/cc23x0/CMakeLists.txt

KconfigAdd CC23x0 backend Kconfig +54/-0

Add CC23x0 backend Kconfig

• Adds backend enable (depends on RCL), RX buffer size, max header length, catalog, and default-PHY options.

drivers/basic_radio/backends/ti/cc23x0/Kconfig

Kconfig.simplelinkAdd SIMPLELINK_F3_RADIO_PHYS option +8/-0

Add SIMPLELINK_F3_RADIO_PHYS option

• Adds a hidden option that builds the hal_ti certified PHY settings.

modules/Kconfig.simplelink

lp_em_cc2340r5.overlayAdd RX sample overlay for LP-EM-CC2340R5 +16/-0

Add RX sample overlay for LP-EM-CC2340R5

• Enables the CC23x0 basic_radio node on the LaunchPad.

samples/drivers/basic_radio/radio_rx/boards/lp_em_cc2340r5.overlay

prj.confAdd RX sample config +4/-0

Add RX sample config

• Enables BASIC_RADIO, GPIO and logging.

samples/drivers/basic_radio/radio_rx/prj.conf

lp_em_cc2340r5.overlayAdd CW sample overlay for LP-EM-CC2340R5 +16/-0

Add CW sample overlay for LP-EM-CC2340R5

• Enables the CC23x0 basic_radio node on the LaunchPad.

samples/drivers/basic_radio/radio_test_cw/boards/lp_em_cc2340r5.overlay

prj.confAdd CW sample config +4/-0

Add CW sample config

• Enables BASIC_RADIO, GPIO and logging.

samples/drivers/basic_radio/radio_test_cw/prj.conf

lp_em_cc2340r5.overlayAdd TX sample overlay for LP-EM-CC2340R5 +16/-0

Add TX sample overlay for LP-EM-CC2340R5

• Enables the CC23x0 basic_radio node on the LaunchPad.

samples/drivers/basic_radio/radio_tx/boards/lp_em_cc2340r5.overlay

prj.confAdd TX sample config +4/-0

Add TX sample config

• Enables BASIC_RADIO, GPIO and logging.

samples/drivers/basic_radio/radio_tx/prj.conf

west.ymlBump hal_ti revision +1/-1

Bump hal_ti revision

• Updates hal_ti to commit 2f10346, which provides the RCL and radio PHY exports used by the backend.

west.yml

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hal_ti TexasInstruments/hal_ti@603fdd6 (v4.4.0-ti-01.01.00.01) ❌ Impostor SHA: TexasInstruments/hal_ti@2f10346 TexasInstruments/hal_ti@603fdd64..2f103467

⛔ DNM label due to: 1 impostor SHA

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

⏩ Board tests skipped

Commit e85c7d6a100a

Board tests were not run because other checks on this commit failed: PR Metadata Check, Prevent Merging. Fix those first; the boards will run on the next push.

Workflow run

@qodo-code-review

qodo-code-review Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Code Review by Qodo


View medium (1)
Remediation recommended
1. Overflow totals stay hidden from callers 🐞 ⭐
Description
rx_callback() increments rx_overflow_count, but TI_CC23X0_EXT_GET_STATS does not copy that
counter into the public statistics structure. Applications can see an individual reception end with
-ENOBUFS, but cannot retrieve the cumulative overflow count alongside the other radio counters.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new `rx_overflow_count` is incremented but never returned by the vendor statistics command, so callers cannot retrieve its cumulative value.
## Fix Focus Areas
- drivers/basic_radio/backends/ti/cc23x0/basic_radio_cc23x0.c[609-611]
- drivers/basic_radio/backends/ti/cc23x0/basic_radio_cc23x0.c[1298-1310]
- include/zephyr/drivers/basic_radio/ti_cc23x0.h[189-200]
## Recommended Fix
Add an RX overflow field to the public statistics structure and populate it in the interrupt-protected `TI_CC23X0_EXT_GET_STATS` snapshot. Update the command documentation to describe what the counter includes.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


@vmyklebust

Copy link
Copy Markdown

This needs to be split up into several commits: at least one commit to update west.yml, and probably one commit per sample you add. For the rest I am not 100% sure what is best, but each commit should ideally change less files and be more self-contained

Update hal_ti to a revision that provides the certified CC23x0R5 PHY
settings used by the basic_radio CC23x0 backend.

The revision is from TexasInstruments/hal_ti pull request 15 and is to
be replaced by the merged revision.

Signed-off-by: David Fosca Gamarra <d-foscagamarra@ti.com>
Add SIMPLELINK_F3_RADIO_DRIVER, which builds the Radio Control Layer
(RCL), the LRF driver and the RF patches from hal_ti, and
SIMPLELINK_F3_RADIO_PHYS, which builds the certified PHY settings.
Drivers that use the radio select them.

Signed-off-by: David Fosca Gamarra <d-foscagamarra@ti.com>
Add a vendor-neutral driver API for packet radios below the link layer,
for applications that run their own protocol on a radio with no
protocol-specific Zephyr API. The API is described in
zephyrproject-rtos/zephyr issue 119337.

A PHY is a backend-defined object, passed to basic_radio_config() as an
opaque struct basic_radio_phy pointer. A PHY must be passed only to a
radio of the backend that defined it. basic_radio_phy_get_std() returns
the backend's PHY for a standard 2-GFSK profile whose frame format is
defined by the API, so radios of different vendors can interoperate.

Frequency, sync word, TX power and maximum payload length are applied
on top of the PHY; flags select the fields to apply, so any value,
including 0, can be set. TX, RX and tone operations are asynchronous,
take per-operation overrides and can be scheduled on a 64-bit
microsecond radio time base. Events carry a sync word timestamp and,
for received packets, the RSSI. get_caps() reports the optional
operations and the frequency and power ranges of the active PHY;
ext_ctl() carries vendor commands. Devicetree describes the radio
hardware only.

Signed-off-by: David Fosca Gamarra <d-foscagamarra@ti.com>
Add a basic_radio backend for the CC23x0 on-chip radio, on top of the
Radio Control Layer (RCL) of hal_ti.

A CC23x0 PHY names an LRF_Config generated by SysConfig, the
phyFeatures word selecting its sub-PHY, its characterized frequency
range and the default frequency, sync word and TX power applied when it
is selected. The frame header layout and TX power range are read from
the register list of the LRF_Config, so PHYs with different layouts can
be switched at runtime. Only generic PBE configurations are accepted.

The certified PHYs of the CC2340R5 are provided in a per-SoC catalog,
built when BASIC_RADIO_CC23X0_PHY_CATALOG is set. Its default PHY is
applied at init unless BASIC_RADIO_CC23X0_DEFAULT_PHY is disabled. The
catalog has no PHY for the standard profiles yet, so
basic_radio_phy_get_std() returns -ENOTSUP.

RCL keeps the RSSI and timestamp of the last received packet only: when
several packets are reported at once, the earlier ones report them as
unknown. Each operation takes the radio before it reads the active PHY,
so a concurrent basic_radio_config() cannot change the PHY between the
checks and the submission. TI_CC23X0_EXT_GET_STATS returns the RX and
scheduler counters.

Signed-off-by: David Fosca Gamarra <d-foscagamarra@ti.com>
Add a sample that transmits a packet every two seconds through the
basic_radio API, on the default PHY of the radio. It runs on
lp_em_cc2340r5.

Signed-off-by: David Fosca Gamarra <d-foscagamarra@ti.com>
Add a sample that receives packets continuously through the basic_radio
API, on the default PHY of the radio, and logs their length, timestamp,
RSSI and payload. It runs on lp_em_cc2340r5.

Signed-off-by: David Fosca Gamarra <d-foscagamarra@ti.com>
Add a sample that transmits a continuous wave for five seconds through
the basic_radio API, at the frequency and TX power of the default PHY.
It runs on lp_em_cc2340r5.

Signed-off-by: David Fosca Gamarra <d-foscagamarra@ti.com>
Temporary commit for hardware testing, to be folded into the API,
CC23x0 backend and radio_rx sample commits.

- cc23x0: hand each drained RX buffer back to RCL right after its
  last entry is reported instead of after the whole drain, so long
  drains do not starve RCL of buffers.
- cc23x0: report RX buffer exhaustion / RX FIFO overflow as -ENOBUFS
  instead of -EIO and count it in rx_overflow_count.
- api: document that callbacks must be short and the RX_DONE status
  values, including -ENOBUFS.
- radio_rx: only copy packets into a k_msgq in the callback, log from
  main() and restart reception when it ends.
Comment on lines +609 to +611
if (status_to_errno(cmd->status) == -ENOBUFS) {
data->rx_overflow_count++;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. Overflow totals stay hidden from callers 🐞 Bug ◔ Observability

rx_callback() increments rx_overflow_count, but TI_CC23X0_EXT_GET_STATS does not copy that
counter into the public statistics structure. Applications can see an individual reception end with
-ENOBUFS, but cannot retrieve the cumulative overflow count alongside the other radio counters.
Agent Prompt
## Issue description
The new `rx_overflow_count` is incremented but never returned by the vendor statistics command, so callers cannot retrieve its cumulative value.
## Fix Focus Areas
- drivers/basic_radio/backends/ti/cc23x0/basic_radio_cc23x0.c[609-611]
- drivers/basic_radio/backends/ti/cc23x0/basic_radio_cc23x0.c[1298-1310]
- include/zephyr/drivers/basic_radio/ti_cc23x0.h[189-200]
## Recommended Fix
Add an RX overflow field to the public statistics structure and populate it in the interrupt-protected `TI_CC23X0_EXT_GET_STATS` snapshot. Update the command documentation to describe what the counter includes.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants