Skip to content

File syn_ble_hci.c

FileList > ble > syn_ble_hci.c

Go to the source code of this file

Zero-Heap Host Controller Interface (HCI) Driver implementation.

  • #include "syn_ble_hci.h"
  • #include <string.h>

Public Functions

Type Name
SYN_Status syn_ble_hci_encode_acl (uint16_t conn_handle, uint8_t pb_flags, uint8_t bc_flags, const uint8_t * data, uint16_t len, uint8_t * tx_buf, uint16_t * tx_len)
Encode HCI ACL Data Packet.
SYN_Status syn_ble_hci_encode_command (uint16_t opcode, const uint8_t * params, uint8_t param_len, uint8_t * tx_buf, uint16_t * tx_len)
Send HCI Command Packet.
SYN_Status syn_ble_hci_init (SYN_BLE_HCI * hci, const SYN_BLE_HCI_Config * cfg)
Initialize HCI Driver Context.
SYN_Status syn_ble_hci_rx_buf (SYN_BLE_HCI * hci, const uint8_t * buf, uint16_t len)
Feed raw buffer into HCI receiver state machine.
SYN_Status syn_ble_hci_rx_byte (SYN_BLE_HCI * hci, uint8_t byte)
Feed raw bytes from UART/SPI into HCI receiver state machine.

Public Static Functions

Type Name
void parse_and_dispatch (SYN_BLE_HCI * hci)
Internal parse and dispatch helper.

Macros

Type Name
define SYN_BLE_HCI_RX_STATE_HDR 1U
define SYN_BLE_HCI_RX_STATE_PAYLOAD 2U
define SYN_BLE_HCI_RX_STATE_TYPE 0U

Public Functions Documentation

function syn_ble_hci_encode_acl

Encode HCI ACL Data Packet.

SYN_Status syn_ble_hci_encode_acl (
    uint16_t conn_handle,
    uint8_t pb_flags,
    uint8_t bc_flags,
    const uint8_t * data,
    uint16_t len,
    uint8_t * tx_buf,
    uint16_t * tx_len
) 

Parameters:

  • conn_handle 12-bit Connection Handle.
  • pb_flags Packet Boundary flags (2 bits).
  • bc_flags Broadcast flags (2 bits).
  • data Data payload bytes.
  • len Data payload length in bytes.
  • tx_buf Buffer to store framed ACL packet (minimum 5 + len bytes).
  • tx_len Pointer to store resulting framed size.

Returns:

SYN_OK on success.


function syn_ble_hci_encode_command

Send HCI Command Packet.

SYN_Status syn_ble_hci_encode_command (
    uint16_t opcode,
    const uint8_t * params,
    uint8_t param_len,
    uint8_t * tx_buf,
    uint16_t * tx_len
) 

Parameters:

  • opcode 16-bit HCI Command Opcode.
  • params Pointer to parameter payload (or NULL if len is 0).
  • param_len Parameter payload length in bytes.
  • tx_buf Buffer to store framed HCI packet (minimum 4 + param_len bytes).
  • tx_len Pointer to store resulting framed size.

Returns:

SYN_OK on success.


function syn_ble_hci_init

Initialize HCI Driver Context.

SYN_Status syn_ble_hci_init (
    SYN_BLE_HCI * hci,
    const SYN_BLE_HCI_Config * cfg
) 

Parameters:

  • hci Driver handle pointer.
  • cfg Driver configuration struct.

Returns:

SYN_OK on success, SYN_INVALID_PARAM if null.


function syn_ble_hci_rx_buf

Feed raw buffer into HCI receiver state machine.

SYN_Status syn_ble_hci_rx_buf (
    SYN_BLE_HCI * hci,
    const uint8_t * buf,
    uint16_t len
) 

Parameters:

  • hci Driver handle pointer.
  • buf Data buffer pointer.
  • len Data buffer length.

Returns:

SYN_OK on success.


function syn_ble_hci_rx_byte

Feed raw bytes from UART/SPI into HCI receiver state machine.

SYN_Status syn_ble_hci_rx_byte (
    SYN_BLE_HCI * hci,
    uint8_t byte
) 

Parameters:

  • hci Driver handle pointer.
  • byte Single received byte from H:4 transport.

Returns:

SYN_OK on success.


Public Static Functions Documentation

function parse_and_dispatch

Internal parse and dispatch helper.

static void parse_and_dispatch (
    SYN_BLE_HCI * hci
) 

Parameters:

  • hci HCI driver handle.

Macro Definition Documentation

define SYN_BLE_HCI_RX_STATE_HDR

#define SYN_BLE_HCI_RX_STATE_HDR `1U`

RX State: Header


define SYN_BLE_HCI_RX_STATE_PAYLOAD

#define SYN_BLE_HCI_RX_STATE_PAYLOAD `2U`

RX State: Payload


define SYN_BLE_HCI_RX_STATE_TYPE

#define SYN_BLE_HCI_RX_STATE_TYPE `0U`

RX State: Packet Type



The documentation for this class was generated from the following file src/syntropic/ble/syn_ble_hci.c