ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_ble.c File Reference

HCI transport seam (host-side) – in-memory loopback backend. More...

#include "ra8_ble.h"
#include <stddef.h>
#include <stdint.h>
#include "ra8_attributes.h"
#include "ra8_ble_internal.h"
#include "ra8_check.h"
#include "ra8_err.h"
#include "ra8_log.h"
Include dependency graph for ra8_ble.c:

Go to the source code of this file.

Data Structures

struct  ra8_ble_state_t

Enumerations

enum  ra8_ble_internal_t : uint32_t { k_ra8_ble_dispatch_budget = 64U }
enum  ra8_ble_param_limits_t : uint16_t {
  k_ra8_ble_tx_capture_bytes = 1024U ,
  k_ra8_ble_rx_inject_bytes = 1024U ,
  k_ra8_ble_scan_min = 0x0004U ,
  k_ra8_ble_scan_max = 0x4000U
}
enum  ra8_ble_byte_const_t : uint8_t {
  k_ra8_ble_byte_shift = 8U ,
  k_ra8_ble_byte_mask = 0xFFU
}
enum  ra8_ble_hci_opcode_t : uint16_t {
  k_ra8_ble_op_le_set_random_address = 0x2005U ,
  k_ra8_ble_op_le_set_adv_data = 0x2008U ,
  k_ra8_ble_op_le_set_adv_enable = 0x200AU ,
  k_ra8_ble_op_le_set_scan_params = 0x200BU ,
  k_ra8_ble_op_le_set_scan_enable = 0x200CU
}
 HCI LE command opcodes used by the convenience wrappers (Bluetooth Core 5.3 Vol 4 Part E 7.8). More...
enum  ra8_ble_scan_const_t : uint8_t {
  k_ra8_ble_scan_param_bytes = 7U ,
  k_ra8_ble_scan_own_pub = 0U ,
  k_ra8_ble_scan_filt_basic = 0U ,
  k_ra8_ble_scan_off_type = 0U ,
  k_ra8_ble_scan_off_interval_lo = 1U ,
  k_ra8_ble_scan_off_interval_hi = 2U ,
  k_ra8_ble_scan_off_window_lo = 3U ,
  k_ra8_ble_scan_off_window_hi = 4U ,
  k_ra8_ble_scan_off_own_addr = 5U ,
  k_ra8_ble_scan_off_filter = 6U ,
  k_ra8_ble_scan_enable_bytes = 2U
}

Functions

static void internal_byte_copy (uint8_t *dst, const uint8_t *src, uint16_t n)
 Bytewise copy.
static void internal_tx_byte (uint8_t b)
 Push one byte down the transport and capture it.
static uint8_t internal_rx_byte (uint8_t *out)
 Pull one byte from the injected RX buffer.
ra8_err_t ra8_ble_open (const ra8_ble_config_t *cfg)
 Power up the BLE controller and open the HCI mailbox.
ra8_err_t ra8_ble_close (void)
 Close the HCI mailbox and put the controller back in reset.
ra8_err_t ra8_ble_hci_send_command (uint16_t opcode, const uint8_t *params, uint8_t params_len)
 Emit an HCI command packet.
ra8_err_t ra8_ble_hci_send_acl_data (uint16_t handle, const uint8_t *payload, uint16_t len)
 Emit an HCI ACL data packet.
ra8_err_t ra8_ble_attach_event_handler (ra8_ble_event_fn_t fn, void *ctx)
 Register a handler for inbound HCI events.
ra8_err_t ra8_ble_attach_acl_handler (ra8_ble_acl_fn_t fn, void *ctx)
 Register a handler for inbound HCI ACL data.
static ra8_err_t internal_dispatch_event (void)
 Drain and dispatch one HCI event from the injected RX stream.
static ra8_err_t internal_dispatch_acl (void)
 Drain and dispatch one HCI ACL data packet.
ra8_err_t ra8_ble_dispatch (void)
 Pump the HCI receive path – call from ISR or main loop.
ra8_err_t ra8_ble_set_random_address (const uint8_t addr[k_ra8_ble_addr_bytes])
 Send LE_Set_Random_Address (opcode 0x2005).
ra8_err_t ra8_ble_set_advertising_data (const uint8_t *data, uint8_t len)
 Send LE_Set_Advertising_Data (opcode 0x2008).
ra8_err_t ra8_ble_set_advertising_enable (uint8_t enable)
 Send LE_Set_Advertising_Enable (opcode 0x200A).
ra8_err_t ra8_ble_scan_start (uint8_t active, uint16_t interval, uint16_t window)
 Send LE_Set_Scan_Parameters then LE_Set_Scan_Enable.
void ra8_ble_test_reset_capture (void)
 Reset the BLE loopback capture and injection cursors.
void ra8_ble_test_inject_rx (const uint8_t *bytes, uint16_t len)
 Replace the synthetic BLE receive input with bounded caller bytes.
const uint8_t * ra8_ble_test_tx_capture (uint16_t *out_len)
 Borrow the BLE transmit capture and optionally report its length.

Variables

static const char * s_tag = "BLE"
static ra8_ble_state_t s_state = {}

Detailed Description

HCI transport seam (host-side) – in-memory loopback backend.

Tag
[Ring 3 / HAL] {World: NS}

Implements the HCI transport interface declared in ra8_ble.h: H4-style command / event / ACL framing per Bluetooth Core 5.3 Vol 4 Part A 2 ("HCI Transport Layer"), plus the send / dispatch / callback machinery the NimBLE host stack (via port/nimble) drives.

There is deliberately no register access here. The RA8D2 has no on-chip Bluetooth radio (the datasheet lists no BLE/2.4 GHz block), so the former on-chip-controller backend – and its invented register map, patch loader, and firmware blob – were removed. What remains is the transport seam and a pure in-memory loopback: TX frames are captured into a buffer and RX frames are taken from an injected buffer. Host-stack unit tests use that loopback (ra8_ble_test_tx_capture / ra8_ble_test_inject_rx) to verify framing and event dispatch with no hardware.

Note
The production backend is an ESP32-C6 companion IC: the C6 runs the BLE controller (below HCI) and the RA8 runs this host-side transport, carrying HCI packets over the companion link (see esp-hosted). The send / dispatch bodies below are where that link's I/O attaches; the host stack above the seam is unchanged.

Definition in file ra8_ble.c.

Enumeration Type Documentation

◆ ra8_ble_byte_const_t

enum ra8_ble_byte_const_t : uint8_t
Enumerator
k_ra8_ble_byte_shift 

Bit shift between LE16 halves.

k_ra8_ble_byte_mask 

RA8 BLE byte mask.

Definition at line 86 of file ra8_ble.c.

◆ ra8_ble_hci_opcode_t

enum ra8_ble_hci_opcode_t : uint16_t

HCI LE command opcodes used by the convenience wrappers (Bluetooth Core 5.3 Vol 4 Part E 7.8).

Protocol constants, not registers.

Enumerator
k_ra8_ble_op_le_set_random_address 

7.8.4 LE_Set_Random_Address.

k_ra8_ble_op_le_set_adv_data 

7.8.7 LE_Set_Advertising_Data.

k_ra8_ble_op_le_set_adv_enable 

7.8.9 LE_Set_Advertising_Enable.

k_ra8_ble_op_le_set_scan_params 

7.8.10 LE_Set_Scan_Parameters.

k_ra8_ble_op_le_set_scan_enable 

7.8.11 LE_Set_Scan_Enable.

Definition at line 96 of file ra8_ble.c.

◆ ra8_ble_internal_t

enum ra8_ble_internal_t : uint32_t
Enumerator
k_ra8_ble_dispatch_budget 

Max packets drained per dispatch.

Definition at line 75 of file ra8_ble.c.

◆ ra8_ble_param_limits_t

enum ra8_ble_param_limits_t : uint16_t
Enumerator
k_ra8_ble_tx_capture_bytes 

Bytes of TX capture for unit tests.

k_ra8_ble_rx_inject_bytes 

Bytes of RX injection for tests.

k_ra8_ble_scan_min 

7.8.10 LE_Set_Scan_Parameters.

k_ra8_ble_scan_max 

7.8.10 LE_Set_Scan_Parameters.

Definition at line 79 of file ra8_ble.c.

◆ ra8_ble_scan_const_t

enum ra8_ble_scan_const_t : uint8_t
Enumerator
k_ra8_ble_scan_param_bytes 

7.8.10 parameter packet bytes.

k_ra8_ble_scan_own_pub 

Public device address.

k_ra8_ble_scan_filt_basic 

Basic unfiltered policy.

k_ra8_ble_scan_off_type 

Param byte index: scan type.

k_ra8_ble_scan_off_interval_lo 

Param byte index: interval LO.

k_ra8_ble_scan_off_interval_hi 

Param byte index: interval HI.

k_ra8_ble_scan_off_window_lo 

Param byte index: window LO.

k_ra8_ble_scan_off_window_hi 

Param byte index: window HI.

k_ra8_ble_scan_off_own_addr 

Param byte index: own_addr.

k_ra8_ble_scan_off_filter 

Param byte index: filter pol.

k_ra8_ble_scan_enable_bytes 

7.8.11 enable param bytes.

Definition at line 104 of file ra8_ble.c.

Function Documentation

◆ internal_byte_copy()

void internal_byte_copy ( uint8_t * dst,
const uint8_t * src,
uint16_t n )
inlinestatic

Bytewise copy.

Replaces memcpy so clang-tidy's clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling check stays happy. Same pattern as internal_byte_copy in ra8_eth.c.

See implementation.

Parameters
[in]dstSee implementation.
[in]srcSee implementation.
[in]nSee implementation.
Precondition
Module state is consistent.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
Caller-visible state matches the documented contract.
Note
Not thread-safe unless documented otherwise.
Since
0.1.0

Definition at line 61 of file ra8_ble.c.

References RA8_INTERNAL.

Referenced by ra8_ble_set_advertising_data(), and ra8_ble_test_inject_rx().

◆ internal_dispatch_acl()

ra8_err_t internal_dispatch_acl ( void )
static

Drain and dispatch one HCI ACL data packet.

See implementation.

Returns
Result code.
Return values
k_ra8_okOperation succeeded.
Precondition
Module state is consistent.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
Caller-visible state matches the documented contract.
Note
Not thread-safe unless documented otherwise.
Since
0.1.0

Definition at line 334 of file ra8_ble.c.

References internal_rx_byte(), k_ra8_ble_byte_shift, k_ra8_ble_max_acl_payload, k_ra8_err_invalid_arg, k_ra8_ok, RA8_INTERNAL, and s_state.

Referenced by ra8_ble_dispatch().

◆ internal_dispatch_event()

ra8_err_t internal_dispatch_event ( void )
static

Drain and dispatch one HCI event from the injected RX stream.

See implementation.

Returns
Result code.
Return values
k_ra8_okOperation succeeded.
Precondition
Module state is consistent.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
Caller-visible state matches the documented contract.
Note
Not thread-safe unless documented otherwise.
Since
0.1.0

Definition at line 301 of file ra8_ble.c.

References internal_rx_byte(), k_ra8_ble_max_evt_params, k_ra8_err_invalid_arg, k_ra8_ok, RA8_INTERNAL, and s_state.

Referenced by ra8_ble_dispatch().

◆ internal_rx_byte()

uint8_t internal_rx_byte ( uint8_t * out)
static

Pull one byte from the injected RX buffer.

Returns
1 on success, 0 if the injected stream is empty.

See implementation.

Parameters
[in]outSee implementation.
Return values
k_ra8_okOperation succeeded.
Precondition
Module state is consistent.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
Caller-visible state matches the documented contract.
Note
Not thread-safe unless documented otherwise.
Since
0.1.0

Definition at line 182 of file ra8_ble.c.

References RA8_INTERNAL, and s_state.

Referenced by internal_dispatch_acl(), internal_dispatch_event(), and ra8_ble_dispatch().

◆ internal_tx_byte()

void internal_tx_byte ( uint8_t b)
static

Push one byte down the transport and capture it.

On the loopback backend the byte is only captured (for the framing unit tests); the production backend also writes it to the companion-link TX path.

Parameters
[in]bByte to emit.
Precondition
Module state is consistent.
Module state is consistent.
Postcondition
Caller-visible state matches the documented contract.
Caller-visible state matches the documented contract.
Note
Not thread-safe unless documented otherwise.
Since
0.1.0

Definition at line 159 of file ra8_ble.c.

References k_ra8_ble_tx_capture_bytes, RA8_INTERNAL, and s_state.

Referenced by ra8_ble_hci_send_acl_data(), and ra8_ble_hci_send_command().

◆ ra8_ble_attach_acl_handler()

ra8_err_t ra8_ble_attach_acl_handler ( ra8_ble_acl_fn_t fn,
void * ctx )
nodiscard

Register a handler for inbound HCI ACL data.

Parameters
[in]fnCallback. Pass NULL to detach.
[in]ctxOpaque user context, passed back on each ACL packet.
Returns
k_ra8_ok always.
Since
0.1.0

Definition at line 281 of file ra8_ble.c.

References k_ra8_ok, and s_state.

Referenced by ble_hci_ra8_ble_deinit(), and ble_hci_ra8_ble_init().

◆ ra8_ble_attach_event_handler()

ra8_err_t ra8_ble_attach_event_handler ( ra8_ble_event_fn_t fn,
void * ctx )
nodiscard

Register a handler for inbound HCI events.

Parameters
[in]fnCallback. Pass NULL to detach.
[in]ctxOpaque user context, passed back on each event.
Returns
k_ra8_ok always.
Since
0.1.0

Definition at line 274 of file ra8_ble.c.

References k_ra8_ok, and s_state.

Referenced by ble_hci_ra8_ble_deinit(), and ble_hci_ra8_ble_init().

◆ ra8_ble_close()

ra8_err_t ra8_ble_close ( void )
nodiscard

Close the HCI mailbox and put the controller back in reset.

Returns
k_ra8_err_invalid_arg if controller is not open.
k_ra8_ok on success.
Since
0.1.0

Definition at line 211 of file ra8_ble.c.

References k_ra8_err_invalid_arg, k_ra8_ok, ra8_log_info, s_state, and s_tag.

◆ ra8_ble_dispatch()

ra8_err_t ra8_ble_dispatch ( void )
nodiscard

Pump the HCI receive path – call from ISR or main loop.

Drains both the event FIFO and the ACL RX FIFO, dispatching each frame through the registered callbacks. Bounded by a static loop cap so it never blocks indefinitely.

Returns
k_ra8_err_not_initialized if controller is not open.
k_ra8_ok on success.
Since
0.1.0

Definition at line 362 of file ra8_ble.c.

References internal_dispatch_acl(), internal_dispatch_event(), internal_rx_byte(), k_ra8_ble_dispatch_budget, k_ra8_ble_pkt_acl_data, k_ra8_ble_pkt_event, k_ra8_err_invalid_arg, k_ra8_err_not_initialized, k_ra8_ok, and s_state.

Referenced by internal_demo_thread_entry().

◆ ra8_ble_hci_send_acl_data()

ra8_err_t ra8_ble_hci_send_acl_data ( uint16_t handle,
const uint8_t * payload,
uint16_t len )
nodiscard

Emit an HCI ACL data packet.

Frames [0x02][handle_lo][handle_hi][len_lo][len_hi][payload] and pushes it into the HCI ACL TX FIFO. The handle field carries the 12-bit connection handle plus PB/BC flags as one LE16 word; callers are expected to merge those fields beforehand.

Parameters
[in]handleConnection handle + PB/BC flags (LE16, 16 bits).
[in]payloadPayload bytes. May be NULL iff len == 0.
[in]lenPayload byte count (0..k_ra8_ble_max_acl_payload).
Returns
k_ra8_err_not_initialized if controller is not open.
k_ra8_err_null_ptr if payload == NULL && len > 0.
k_ra8_err_invalid_arg if len > k_ra8_ble_max_acl_payload.
k_ra8_ok on success.
Since
0.1.0

Definition at line 246 of file ra8_ble.c.

References internal_tx_byte(), k_ra8_ble_byte_mask, k_ra8_ble_byte_shift, k_ra8_ble_max_acl_payload, k_ra8_ble_pkt_acl_data, k_ra8_err_invalid_arg, k_ra8_err_not_initialized, k_ra8_err_null_ptr, k_ra8_ok, and s_state.

Referenced by ble_transport_to_ll_acl_impl().

◆ ra8_ble_hci_send_command()

ra8_err_t ra8_ble_hci_send_command ( uint16_t opcode,
const uint8_t * params,
uint8_t params_len )
nodiscard

Emit an HCI command packet.

Frames [0x01][opcode_lo][opcode_hi][params_len][params...] and pushes it into the HCI command FIFO. Returns immediately; the matching Command Complete or Command Status event arrives via the event callback.

Parameters
[in]opcode16-bit HCI opcode (Bluetooth Core 5.3 Vol 4 Part E 5.4.1).
[in]paramsParameter bytes. May be NULL iff params_len == 0.
[in]params_lenParameter byte count (0..255).
Returns
k_ra8_err_not_initialized if controller is not open.
k_ra8_err_null_ptr if params == NULL && params_len > 0.
k_ra8_err_invalid_arg if params_len > k_ra8_ble_max_cmd_params.
k_ra8_ok on success.
Since
0.1.0

Definition at line 226 of file ra8_ble.c.

References internal_tx_byte(), k_ra8_ble_byte_mask, k_ra8_ble_byte_shift, k_ra8_ble_pkt_cmd, k_ra8_err_not_initialized, k_ra8_err_null_ptr, k_ra8_ok, and s_state.

Referenced by ble_transport_to_ll_cmd_impl(), ra8_ble_scan_start(), ra8_ble_set_advertising_data(), ra8_ble_set_advertising_enable(), and ra8_ble_set_random_address().

◆ ra8_ble_open()

ra8_err_t ra8_ble_open ( const ra8_ble_config_t * cfg)
nodiscard

Power up the BLE controller and open the HCI mailbox.

Steps (mirrors FSP r_ble open + the production patch-load helper):

  1. Drop the controller out of reset (CTRL.reset = 1, then 0).
  2. Programme OSCCTL per cfg->use_external_osc.
  3. Stub the patch-load loop (PATCHADDR/PATCHDATA writes).
  4. Set CTRL.enable | CTRL.hci_enable.
  5. Spin-wait for STATUS.ready.
Parameters
[in]cfgDriver configuration. Must not be NULL.
Returns
k_ra8_err_null_ptr if cfg == NULL.
k_ra8_err_invalid_arg if controller is already open.
k_ra8_ok on success.
Precondition
Caller has clocked the BLE block (MSTPCRC bit, HUM Ch 11).
No other thread holds the HCI mailbox.
Postcondition
STATUS.ready reads back as 1.
Subsequent ra8_ble_hci_send_command calls are accepted.
Note
Not thread-safe.
Warning
Real silicon needs the Renesas-supplied BLE firmware patch image; the patch-load loop is currently stubbed.
Since
0.1.0

Definition at line 197 of file ra8_ble.c.

References k_ra8_err_invalid_arg, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_log_info, s_state, and s_tag.

Referenced by internal_demo_ble_or_halt().

◆ ra8_ble_scan_start()

ra8_err_t ra8_ble_scan_start ( uint8_t active,
uint16_t interval,
uint16_t window )
nodiscard

Send LE_Set_Scan_Parameters then LE_Set_Scan_Enable.

Bluetooth Core 5.3 Vol 4 Part E 7.8.10 / 7.8.11. Two HCI commands fly back-to-back; the controller answers with two Command Complete events, both delivered through the registered event handler.

Parameters
[in]active1 = active scanning (with SCAN_REQ), 0 = passive.
[in]intervalScan interval in 0.625 ms units (0x0004..0x4000).
[in]windowScan window in 0.625 ms units (0x0004..0x4000), <= interval.
Returns
k_ra8_err_invalid_arg if window > interval or values out of range.
k_ra8_err_not_initialized if controller is not open.
k_ra8_ok on success.
Since
0.1.0

Definition at line 426 of file ra8_ble.c.

References k_ra8_ble_byte_mask, k_ra8_ble_byte_shift, k_ra8_ble_op_le_set_scan_enable, k_ra8_ble_op_le_set_scan_params, k_ra8_ble_scan_enable_bytes, k_ra8_ble_scan_filt_basic, k_ra8_ble_scan_max, k_ra8_ble_scan_min, k_ra8_ble_scan_off_filter, k_ra8_ble_scan_off_interval_hi, k_ra8_ble_scan_off_interval_lo, k_ra8_ble_scan_off_own_addr, k_ra8_ble_scan_off_type, k_ra8_ble_scan_off_window_hi, k_ra8_ble_scan_off_window_lo, k_ra8_ble_scan_own_pub, k_ra8_ble_scan_param_bytes, k_ra8_err_invalid_arg, k_ra8_err_not_initialized, k_ra8_ok, ra8_ble_hci_send_command(), and s_state.

◆ ra8_ble_set_advertising_data()

ra8_err_t ra8_ble_set_advertising_data ( const uint8_t * data,
uint8_t len )
nodiscard

Send LE_Set_Advertising_Data (opcode 0x2008).

Parameters
[in]dataAdvertising-data bytes.
[in]lenByte count (0..k_ra8_ble_adv_data_max).
Returns
k_ra8_err_invalid_arg if len > k_ra8_ble_adv_data_max.
k_ra8_err_null_ptr if data == NULL && len > 0.
k_ra8_err_not_initialized if controller is not open.
k_ra8_ok on success.
Since
0.1.0

Definition at line 400 of file ra8_ble.c.

References internal_byte_copy(), k_ra8_ble_adv_data_max, k_ra8_ble_op_le_set_adv_data, k_ra8_err_invalid_arg, k_ra8_err_null_ptr, and ra8_ble_hci_send_command().

◆ ra8_ble_set_advertising_enable()

ra8_err_t ra8_ble_set_advertising_enable ( uint8_t enable)
nodiscard

Send LE_Set_Advertising_Enable (opcode 0x200A).

Parameters
[in]enable0 = disable advertising, 1 = enable.
Returns
k_ra8_err_not_initialized if controller is not open.
k_ra8_ok on success.
Since
0.1.0

Definition at line 420 of file ra8_ble.c.

References k_ra8_ble_op_le_set_adv_enable, and ra8_ble_hci_send_command().

◆ ra8_ble_set_random_address()

ra8_err_t ra8_ble_set_random_address ( const uint8_t addr[k_ra8_ble_addr_bytes])
nodiscard

Send LE_Set_Random_Address (opcode 0x2005).

Parameters
[in]addr6-byte random Bluetooth address (LSB first per spec).
Returns
k_ra8_err_null_ptr if addr == NULL.
k_ra8_err_not_initialized if controller is not open.
k_ra8_ok on success.
Since
0.1.0

Definition at line 394 of file ra8_ble.c.

References k_ra8_ble_addr_bytes, k_ra8_ble_op_le_set_random_address, ra8_ble_hci_send_command(), RA8_CHECK_NULL_PTR, and s_tag.

◆ ra8_ble_test_inject_rx()

void ra8_ble_test_inject_rx ( const uint8_t * bytes,
uint16_t len )

Replace the synthetic BLE receive input with bounded caller bytes.

Rejects a null source or zero length without changing state. A longer source is truncated to k_ra8_ble_rx_inject_bytes, copied into module-owned storage, and made readable from position zero.

Parameters
[in]bytesSource bytes, or nullptr for the rejected-input vector.
[in]lenReadable source extent in bytes; values above the injection capacity are truncated.
Precondition
When non-null, bytes addresses at least len readable bytes.
No concurrent BLE operation is reading or modifying loopback state.
Postcondition
Rejected input leaves the existing receive injection state unchanged.
Accepted input replaces the receive bytes, publishes the bounded length, and resets the read position to zero.
Note
Test-only hook; it copies input and retains no caller-owned pointer.
MC/DC:
The (bytes == nullptr) || (len == 0) guard uses three vectors: non-null and nonzero continues, null and nonzero returns, and non-null and zero returns. These demonstrate each condition's independent influence.
Since
Version 0.1.0

Definition at line 479 of file ra8_ble.c.

References internal_byte_copy(), k_ra8_ble_rx_inject_bytes, RA8_TEST_HELPER, and s_state.

◆ ra8_ble_test_reset_capture()

void ra8_ble_test_reset_capture ( void )

Reset the BLE loopback capture and injection cursors.

Clears the recorded transmit length and discards every unread byte in the synthetic receive buffer without changing open state or registered callbacks.

Precondition
The linked BLE implementation provides its loopback test hooks.
No concurrent BLE operation is reading or modifying loopback state.
Postcondition
The transmit capture length is zero.
The receive injection length and read position are zero.
Note
Test-only hook; not thread-safe with any other BLE operation.
MC/DC:
This decision-free reset supplies the known-empty control state used by the HCI framing and injection vectors.
Since
Version 0.1.0

Definition at line 472 of file ra8_ble.c.

References RA8_TEST_HELPER, and s_state.

◆ ra8_ble_test_tx_capture()

const uint8_t * ra8_ble_test_tx_capture ( uint16_t * out_len)

Borrow the BLE transmit capture and optionally report its length.

Returns the stable module-owned capture base and writes the number of valid leading bytes only when out_len is non-null.

Parameters
[out]out_lenOptional destination for the captured byte count.
Returns
Read-only pointer to the module-owned transmit capture.
Return values
non-nullThe fixed capture buffer base; ownership remains internal.
Precondition
When non-null, out_len addresses writable uint16_t storage.
No concurrent BLE operation is appending to the capture.
Postcondition
A non-null out_len contains the current capture length.
The capture bytes and all BLE module state remain unchanged.
Note
Test-only borrowed view; valid for the module lifetime and mutable by later BLE transmit or reset operations.
MC/DC:
Tests call with a writable length pointer and with nullptr to cover both outcomes of the optional-output decision.
Since
Version 0.1.0

Definition at line 492 of file ra8_ble.c.

References RA8_TEST_HELPER, and s_state.

Variable Documentation

◆ s_state

ra8_ble_state_t s_state = {}
static

Definition at line 138 of file ra8_ble.c.

◆ s_tag

const char* s_tag = "BLE"
static

Definition at line 68 of file ra8_ble.c.