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

NimBLE Native Porting Layer mapping onto Eclipse ThreadX. More...

#include <stdint.h>
#include "nimble/nimble_npl.h"
Include dependency graph for nimble_npl_threadx.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  ble_npl_threadx_limits_t : uint16_t {
  k_ble_npl_threadx_wait_forever = 0xFFFFU ,
  k_ble_npl_threadx_eventq_depth = 16U ,
  k_ble_npl_threadx_eventq_slot_bytes = 4U ,
  k_ble_npl_threadx_sem_max = 0xFFFFU
}
 Sizing constants for the ThreadX-backed NPL. More...

Functions

void nimble_port_init (void)
 Bring the NimBLE host port up.
void nimble_port_run (void)
 Pump the NimBLE host event loop forever.
struct ble_npl_eventqnimble_port_get_dflt_eventq (void)
 Return the host's default eventq pointer.

Detailed Description

NimBLE Native Porting Layer mapping onto Eclipse ThreadX.

Tag
[Ring 4 / PORT] {World: S}

Apache NimBLE expects a small set of OS primitives – mutex, semaphore, event-queue, callout (one-shot timer that posts an event), tick counter, critical section – collectively the "Native Porting Layer" (NPL). Upstream ships canned ports for FreeRTOS, Mynewt, Linux, NuttX, RIOT and "dummy". We provide a ThreadX-backed implementation here so NimBLE's host stack runs on the same kernel that powers threadx_blink and threadx_fs_demo.

Mapping:

NimBLE primitive ThreadX primitive
ble_npl_mutex TX_MUTEX
ble_npl_sem TX_SEMAPHORE
ble_npl_eventq TX_QUEUE
ble_npl_callout TX_TIMER
ble_npl_time_t ULONG (ticks)
critical section TX interrupt mask

Tick rate matches the project tx_user.h (TX_TIMER_TICKS_PER_SECOND = 1000), so 1 NPL tick == 1 ms.

Warning
UNVALIDATED SCAFFOLD (issue #286): this NimBLE port and its ThreadX Native Porting Layer link and pass the static gates, but have NEVER been hardware-validated and are NOT emulator-gated – ra8_emulator models no RA8D2 BLE controller / HCI mailbox, and the underlying ra8_ble transport is itself unproven on this board (see #86, #91). Treat every symbol here as a link-only stub, not a working BLE stack. Consumers stay under examples/_unsupported/ until a NimBLE app is driven to real hardware validation and promoted out of that tier.

Definition in file nimble_npl_threadx.h.

Enumeration Type Documentation

◆ ble_npl_threadx_limits_t

enum ble_npl_threadx_limits_t : uint16_t

Sizing constants for the ThreadX-backed NPL.

Enumerator
k_ble_npl_threadx_wait_forever 

Wait forever – maps onto TX_WAIT_FOREVER.

k_ble_npl_threadx_eventq_depth 

Default eventq depth (number of pointer slots).

k_ble_npl_threadx_eventq_slot_bytes 

Bytes of storage per eventq slot (one pointer on M85).

k_ble_npl_threadx_sem_max 

Default sem max value – effectively unbounded for our use case.

Definition at line 127 of file nimble_npl_threadx.h.

Function Documentation

◆ nimble_port_get_dflt_eventq()

struct ble_npl_eventq * nimble_port_get_dflt_eventq ( void )

Return the host's default eventq pointer.

Returns
Pointer to the default struct ble_npl_eventq (never NULL after nimble_port_init).
Precondition
nimble_port_init has been called.
Since
0.1.0

Return the host's default eventq pointer.

Returns
Pointer to the default ble_npl_eventq (never NULL).
Precondition
nimble_port_init has been called.
Postcondition
Caller can pass the returned pointer to ble_npl_eventq_put.
Since
0.1.0

< S dflt eventq.

Definition at line 530 of file nimble_npl_threadx.c.

References s_dflt_eventq.

◆ nimble_port_init()

void nimble_port_init ( void )

Bring the NimBLE host port up.

Initialises the default eventq used by the host stack. The adapter implementation lives in nimble_npl_threadx.c and is marked weak so the upstream NimBLE host TUs can supersede it once they are wired into the build.

Precondition
ThreadX kernel is running (tx_kernel_enter returned).
Postcondition
nimble_port_get_dflt_eventq returns a usable queue.
Since
0.1.0
Precondition
Module has been initialized.
Postcondition
Side effects bounded to documented state.
Note
Not thread-safe unless documented otherwise.

Definition at line 512 of file nimble_npl_threadx.c.

References ble_npl_eventq_init(), s_dflt_eventq, and s_dflt_eventq_ready.

Referenced by internal_demo_ble_or_halt().

◆ nimble_port_run()

void nimble_port_run ( void )

Pump the NimBLE host event loop forever.

Pulls events out of the default eventq and calls ble_npl_event_run on each. Never returns.

Precondition
nimble_port_init has been called.
Postcondition
Calling thread runs the host loop until shutdown.
Since
0.1.0
Precondition
Module has been initialized.
Postcondition
Side effects bounded to documented state.
Note
Not thread-safe unless documented otherwise.

Pump the NimBLE host event loop forever.

Pumps events out of the default eventq; never returns under normal operation.

Precondition
nimble_port_init has been called.
Postcondition
Calling thread runs the host loop until shutdown.
Since
0.1.0
Precondition
Module has been initialized.
Postcondition
Side effects bounded to documented state.
Note
Not thread-safe unless documented otherwise.

Definition at line 550 of file nimble_npl_threadx.c.

References ble_npl_event_run(), ble_npl_eventq_get(), k_ble_npl_threadx_wait_forever, and s_dflt_eventq.