mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-29 18:27:20 +02:00
Merge branch 'feat/optimize_hci_data_recv_process_v5.2' into 'release/v5.2'
Feat/optimize hci data recv process (v5.2) See merge request espressif/esp-idf!37832
This commit is contained in:
@ -90,7 +90,7 @@ menu "HCI Config"
|
||||
config BT_LE_HCI_TRANS_TASK_STACK_SIZE
|
||||
int "HCI transport task stack size"
|
||||
depends on !BT_LE_HCI_INTERFACE_USE_RAM
|
||||
default 1024
|
||||
default 2048
|
||||
help
|
||||
This configures stack size of hci transport task
|
||||
endmenu
|
||||
@ -424,7 +424,7 @@ config BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
config BT_LE_WHITELIST_SIZE
|
||||
int "BLE white list size"
|
||||
range 1 15
|
||||
range 1 31
|
||||
default 12
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
|
||||
|
@ -108,7 +108,7 @@ menu "HCI Config"
|
||||
config BT_LE_HCI_TRANS_TASK_STACK_SIZE
|
||||
int "HCI transport task stack size"
|
||||
depends on !BT_LE_HCI_INTERFACE_USE_RAM
|
||||
default 1024
|
||||
default 2048
|
||||
help
|
||||
This configures stack size of hci transport task
|
||||
|
||||
@ -491,7 +491,7 @@ config BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
config BT_LE_WHITELIST_SIZE
|
||||
int "BLE white list size"
|
||||
range 1 15
|
||||
range 1 31
|
||||
default 12
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
|
||||
|
@ -108,7 +108,7 @@ menu "HCI Config"
|
||||
config BT_LE_HCI_TRANS_TASK_STACK_SIZE
|
||||
int "HCI transport task stack size"
|
||||
depends on !BT_LE_HCI_INTERFACE_USE_RAM
|
||||
default 1024
|
||||
default 2048
|
||||
help
|
||||
This configures stack size of hci transport task
|
||||
|
||||
@ -482,7 +482,7 @@ config BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
config BT_LE_WHITELIST_SIZE
|
||||
int "BLE white list size"
|
||||
range 1 15
|
||||
range 1 31
|
||||
default 12
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
|
||||
|
@ -720,10 +720,11 @@ endif
|
||||
config BT_NIMBLE_WHITELIST_SIZE
|
||||
int "BLE white list size"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
range 1 31 if SOC_ESP_NIMBLE_CONTROLLER
|
||||
range 1 15
|
||||
default 12
|
||||
help
|
||||
BLE list size
|
||||
BLE list size
|
||||
|
||||
config BT_NIMBLE_TEST_THROUGHPUT_TEST
|
||||
bool "Throughput Test Mode enable"
|
||||
|
@ -1,315 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef H_HCI_TRANSPORT_
|
||||
#define H_HCI_TRANSPORT_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "os/os_mempool.h"
|
||||
|
||||
#define BLE_HCI_TRANS_CMD_SZ 260
|
||||
/*** Type of buffers for holding commands and events. */
|
||||
/**
|
||||
* Controller-to-host event buffers. Events have one of two priorities:
|
||||
* o Low-priority (BLE_HCI_TRANS_BUF_EVT_LO)
|
||||
* o High-priority (BLE_HCI_TRANS_BUF_EVT_HI)
|
||||
*
|
||||
* Low-priority event buffers are only used for advertising reports. If there
|
||||
* are no free low-priority event buffers, then an incoming advertising report
|
||||
* will get dropped.
|
||||
*
|
||||
* High-priority event buffers are for everything except advertising reports.
|
||||
* If there are no free high-priority event buffers, a request to allocate one
|
||||
* will try to allocate a low-priority buffer instead.
|
||||
*
|
||||
* If you want all events to be given equal treatment, then you should allocate
|
||||
* low-priority events only.
|
||||
*
|
||||
* Event priorities solve the problem of critical events getting dropped due to
|
||||
* a flood of advertising reports. This solution is likely temporary: when
|
||||
* HCI flow control is added, event priorities may become obsolete.
|
||||
*
|
||||
* Not all transports distinguish between low and high priority events. If the
|
||||
* transport does not have separate settings for low and high buffer counts,
|
||||
* then it treats all events with equal priority.
|
||||
*/
|
||||
#define BLE_HCI_TRANS_BUF_EVT_LO 1
|
||||
#define BLE_HCI_TRANS_BUF_EVT_HI 2
|
||||
|
||||
/* Host-to-controller command. */
|
||||
#define BLE_HCI_TRANS_BUF_CMD 3
|
||||
|
||||
/** Callback function types; executed when HCI packets are received. */
|
||||
typedef int ble_hci_trans_rx_cmd_fn(uint8_t *cmd, void *arg);
|
||||
typedef int ble_hci_trans_rx_acl_fn(struct os_mbuf *om, void *arg);
|
||||
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED
|
||||
#define ble_transport_alloc_cmd() ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_CMD)
|
||||
#define ble_transport_alloc_event(X) ble_hci_trans_buf_alloc(X ? BLE_HCI_TRANS_BUF_EVT_LO : BLE_HCI_TRANS_BUF_EVT_HI)
|
||||
#define ble_transport_free ble_hci_trans_buf_free
|
||||
|
||||
struct ble_hci_trans_funcs_t {
|
||||
int(*_ble_hci_trans_hs_acl_tx)(struct os_mbuf *om);
|
||||
int(*_ble_hci_trans_hs_cmd_tx)(uint8_t *cmd);
|
||||
int(*_ble_hci_trans_ll_acl_tx)(struct os_mbuf *om);
|
||||
int(*_ble_hci_trans_ll_evt_tx)(uint8_t *hci_ev);
|
||||
int(*_ble_hci_trans_reset)(void);
|
||||
int(*_ble_hci_trans_set_acl_free_cb)(os_mempool_put_fn *cb, void *arg);
|
||||
};
|
||||
|
||||
extern struct ble_hci_trans_funcs_t *ble_hci_trans_funcs_ptr;
|
||||
|
||||
/**
|
||||
* Sends an HCI event from the controller to the host.
|
||||
*
|
||||
* @param cmd The HCI event to send. This buffer must be
|
||||
* allocated via ble_hci_trans_buf_alloc().
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
extern int r_ble_hci_trans_ll_evt_tx(uint8_t *hci_ev);
|
||||
#define ble_hci_trans_ll_evt_tx ble_hci_trans_funcs_ptr->_ble_hci_trans_ll_evt_tx
|
||||
|
||||
/**
|
||||
* Sends ACL data from controller to host.
|
||||
*
|
||||
* @param om The ACL data packet to send.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
extern int r_ble_hci_trans_ll_acl_tx(struct os_mbuf *om);
|
||||
#define ble_hci_trans_ll_acl_tx ble_hci_trans_funcs_ptr->_ble_hci_trans_ll_acl_tx
|
||||
|
||||
/**
|
||||
* Sends an HCI command from the host to the controller.
|
||||
*
|
||||
* @param cmd The HCI command to send. This buffer must be
|
||||
* allocated via ble_hci_trans_buf_alloc().
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
extern int r_ble_hci_trans_hs_cmd_tx(uint8_t *cmd);
|
||||
#define ble_hci_trans_hs_cmd_tx ble_hci_trans_funcs_ptr->_ble_hci_trans_hs_cmd_tx
|
||||
|
||||
/**
|
||||
* Sends ACL data from host to controller.
|
||||
*
|
||||
* @param om The ACL data packet to send.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
extern int r_ble_hci_trans_hs_acl_tx(struct os_mbuf *om);
|
||||
#define ble_hci_trans_hs_acl_tx ble_hci_trans_funcs_ptr->_ble_hci_trans_hs_acl_tx
|
||||
|
||||
/**
|
||||
* Allocates a flat buffer of the specified type.
|
||||
*
|
||||
* @param type The type of buffer to allocate; one of the
|
||||
* BLE_HCI_TRANS_BUF_[...] constants.
|
||||
*
|
||||
* @return The allocated buffer on success;
|
||||
* NULL on buffer exhaustion.
|
||||
*/
|
||||
extern uint8_t *r_ble_hci_trans_buf_alloc(int type);
|
||||
#define ble_hci_trans_buf_alloc r_ble_hci_trans_buf_alloc
|
||||
|
||||
/**
|
||||
* Frees the specified flat buffer. The buffer must have been allocated via
|
||||
* ble_hci_trans_buf_alloc().
|
||||
*
|
||||
* @param buf The buffer to free.
|
||||
*/
|
||||
extern void r_ble_hci_trans_buf_free(uint8_t *buf);
|
||||
#define ble_hci_trans_buf_free r_ble_hci_trans_buf_free
|
||||
|
||||
/**
|
||||
* Configures a callback to get executed whenever an ACL data packet is freed.
|
||||
* The function is called immediately before the free occurs.
|
||||
*
|
||||
* @param cb The callback to configure.
|
||||
* @param arg An optional argument to pass to the callback.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* BLE_ERR_UNSUPPORTED if the transport does not
|
||||
* support this operation.
|
||||
*/
|
||||
extern int r_ble_hci_trans_set_acl_free_cb(os_mempool_put_fn *cb, void *arg);
|
||||
#define ble_hci_trans_set_acl_free_cb ble_hci_trans_funcs_ptr->_ble_hci_trans_set_acl_free_cb
|
||||
|
||||
/**
|
||||
* Configures the HCI transport to operate with a controller. The transport
|
||||
* will execute specified callbacks upon receiving HCI packets from the host.
|
||||
*
|
||||
* @param cmd_cb The callback to execute upon receiving an HCI
|
||||
* command.
|
||||
* @param cmd_arg Optional argument to pass to the command
|
||||
* callback.
|
||||
* @param acl_cb The callback to execute upon receiving ACL
|
||||
* data.
|
||||
* @param acl_arg Optional argument to pass to the ACL
|
||||
* callback.
|
||||
*/
|
||||
extern void r_ble_hci_trans_cfg_ll(ble_hci_trans_rx_cmd_fn *cmd_cb,
|
||||
void *cmd_arg,
|
||||
ble_hci_trans_rx_acl_fn *acl_cb,
|
||||
void *acl_arg);
|
||||
#define ble_hci_trans_cfg_ll r_ble_hci_trans_cfg_ll
|
||||
|
||||
/**
|
||||
* Configures the HCI transport to operate with a host. The transport will
|
||||
* execute specified callbacks upon receiving HCI packets from the controller.
|
||||
*
|
||||
* @param evt_cb The callback to execute upon receiving an HCI
|
||||
* event.
|
||||
* @param evt_arg Optional argument to pass to the event
|
||||
* callback.
|
||||
* @param acl_cb The callback to execute upon receiving ACL
|
||||
* data.
|
||||
* @param acl_arg Optional argument to pass to the ACL
|
||||
* callback.
|
||||
*/
|
||||
extern void r_ble_hci_trans_cfg_hs(ble_hci_trans_rx_cmd_fn *evt_cb,
|
||||
void *evt_arg,
|
||||
ble_hci_trans_rx_acl_fn *acl_cb,
|
||||
void *acl_arg);
|
||||
#define ble_hci_trans_cfg_hs r_ble_hci_trans_cfg_hs
|
||||
|
||||
/**
|
||||
* Resets the HCI module to a clean state. Frees all buffers and reinitializes
|
||||
* the underlying transport.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
extern int r_ble_hci_trans_reset(void);
|
||||
#define ble_hci_trans_reset ble_hci_trans_funcs_ptr->_ble_hci_trans_reset
|
||||
|
||||
void esp_ble_hci_trans_init(uint8_t);
|
||||
|
||||
#else
|
||||
/**
|
||||
* Sends an HCI event from the controller to the host.
|
||||
*
|
||||
* @param cmd The HCI event to send. This buffer must be
|
||||
* allocated via ble_hci_trans_buf_alloc().
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
int ble_hci_trans_ll_evt_tx(uint8_t *hci_ev);
|
||||
|
||||
/**
|
||||
* Sends ACL data from controller to host.
|
||||
*
|
||||
* @param om The ACL data packet to send.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
int ble_hci_trans_ll_acl_tx(struct os_mbuf *om);
|
||||
|
||||
/**
|
||||
* Sends an HCI command from the host to the controller.
|
||||
*
|
||||
* @param cmd The HCI command to send. This buffer must be
|
||||
* allocated via ble_hci_trans_buf_alloc().
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
int ble_hci_trans_hs_cmd_tx(uint8_t *cmd);
|
||||
|
||||
/**
|
||||
* Sends ACL data from host to controller.
|
||||
*
|
||||
* @param om The ACL data packet to send.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
int ble_hci_trans_hs_acl_tx(struct os_mbuf *om);
|
||||
|
||||
/**
|
||||
* Allocates a flat buffer of the specified type.
|
||||
*
|
||||
* @param type The type of buffer to allocate; one of the
|
||||
* BLE_HCI_TRANS_BUF_[...] constants.
|
||||
*
|
||||
* @return The allocated buffer on success;
|
||||
* NULL on buffer exhaustion.
|
||||
*/
|
||||
int esp_ble_hci_trans_hs_cmd_tx(uint8_t *cmd);
|
||||
|
||||
/**
|
||||
* Sends ACL data from host to controller.
|
||||
*
|
||||
* @param om The ACL data packet to send.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
int esp_ble_hci_trans_hs_acl_tx(struct os_mbuf *om);
|
||||
|
||||
/**
|
||||
* Allocates a flat buffer of the specified type.
|
||||
*
|
||||
* @param type The type of buffer to allocate; one of the
|
||||
* BLE_HCI_TRANS_BUF_[...] constants.
|
||||
*
|
||||
* @return The allocated buffer on success;
|
||||
* NULL on buffer exhaustion.
|
||||
*/
|
||||
uint8_t *esp_ble_hci_trans_buf_alloc(int type);
|
||||
|
||||
/**
|
||||
* Frees the specified flat buffer. The buffer must have been allocated via
|
||||
* ble_hci_trans_buf_alloc().
|
||||
*
|
||||
* @param buf The buffer to free.
|
||||
*/
|
||||
void esp_ble_hci_trans_buf_free(uint8_t *buf);
|
||||
|
||||
/**
|
||||
* Configures the HCI transport to operate with a host. The transport will
|
||||
* execute specified callbacks upon receiving HCI packets from the controller.
|
||||
*
|
||||
* @param evt_cb The callback to execute upon receiving an HCI
|
||||
* event.
|
||||
* @param evt_arg Optional argument to pass to the event
|
||||
* callback.
|
||||
* @param acl_cb The callback to execute upon receiving ACL
|
||||
* data.
|
||||
* @param acl_arg Optional argument to pass to the ACL
|
||||
* callback.
|
||||
*/
|
||||
void esp_ble_hci_trans_cfg_hs(ble_hci_trans_rx_cmd_fn *evt_cb,
|
||||
void *evt_arg,
|
||||
ble_hci_trans_rx_acl_fn *acl_cb,
|
||||
void *acl_arg);
|
||||
|
||||
/**
|
||||
* Resets the HCI module to a clean state. Frees all buffers and reinitializes
|
||||
* the underlying transport.
|
||||
*
|
||||
* @return 0 on success;
|
||||
* A BLE_ERR_[...] error code on failure.
|
||||
*/
|
||||
int esp_ble_hci_trans_reset(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* H_HCI_TRANSPORT_ */
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -27,7 +27,9 @@
|
||||
#include <string.h>
|
||||
#include <os/os.h>
|
||||
#include <os/os_mbuf.h>
|
||||
#include "esp_hci_driver.h"
|
||||
#include "common/hci_driver_h4.h"
|
||||
#include "common/hci_driver_util.h"
|
||||
|
||||
#ifndef min
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
@ -62,9 +64,11 @@ hci_h4_frame_start(struct hci_h4_sm *rxs, uint8_t pkt_type)
|
||||
case HCI_H4_ISO:
|
||||
rxs->min_len = 4;
|
||||
break;
|
||||
#if (!CONFIG_BT_CONTROLLER_ENABLED)
|
||||
case HCI_H4_EVT:
|
||||
rxs->min_len = 2;
|
||||
break;
|
||||
#endif // (!CONFIG_BT_CONTROLLER_ENABLED)
|
||||
default:
|
||||
/* !TODO: Sync loss. Need to wait for reset. */
|
||||
return -1;
|
||||
@ -76,7 +80,7 @@ hci_h4_frame_start(struct hci_h4_sm *rxs, uint8_t pkt_type)
|
||||
static int
|
||||
hci_h4_ib_consume(struct hci_h4_input_buffer *ib, uint16_t len)
|
||||
{
|
||||
assert(ib->len >= len);
|
||||
HCI_TRANS_ASSERT((ib->len >= len), ib->len, len);
|
||||
|
||||
ib->buf += len;
|
||||
ib->len -= len;
|
||||
@ -113,7 +117,7 @@ hci_h4_sm_w4_header(struct hci_h4_sm *h4sm, struct hci_h4_input_buffer *ib)
|
||||
|
||||
switch (h4sm->pkt_type) {
|
||||
case HCI_H4_CMD:
|
||||
assert(h4sm->allocs && h4sm->allocs->cmd);
|
||||
HCI_TRANS_ASSERT(h4sm->allocs && h4sm->allocs->cmd, 0, 0);
|
||||
h4sm->buf = h4sm->allocs->cmd();
|
||||
if (!h4sm->buf) {
|
||||
return -1;
|
||||
@ -124,7 +128,7 @@ hci_h4_sm_w4_header(struct hci_h4_sm *h4sm, struct hci_h4_input_buffer *ib)
|
||||
|
||||
break;
|
||||
case HCI_H4_ACL:
|
||||
assert(h4sm->allocs && h4sm->allocs->acl);
|
||||
HCI_TRANS_ASSERT(h4sm->allocs && h4sm->allocs->acl, 0, 0);
|
||||
h4sm->om = h4sm->allocs->acl();
|
||||
if (!h4sm->om) {
|
||||
return -1;
|
||||
@ -145,7 +149,7 @@ hci_h4_sm_w4_header(struct hci_h4_sm *h4sm, struct hci_h4_input_buffer *ib)
|
||||
}
|
||||
}
|
||||
|
||||
assert(h4sm->allocs && h4sm->allocs->evt);
|
||||
HCI_TRANS_ASSERT(h4sm->allocs && h4sm->allocs->evt, 0, 0);
|
||||
|
||||
/* We can drop legacy advertising events if there's no free buffer in
|
||||
* discardable pool.
|
||||
@ -167,7 +171,7 @@ hci_h4_sm_w4_header(struct hci_h4_sm *h4sm, struct hci_h4_input_buffer *ib)
|
||||
break;
|
||||
#endif // !CONFIG_BT_CONTROLLER_ENABLED
|
||||
case HCI_H4_ISO:
|
||||
assert(h4sm->allocs && h4sm->allocs->iso);
|
||||
HCI_TRANS_ASSERT(h4sm->allocs && h4sm->allocs->iso, 0, 0);
|
||||
h4sm->om = h4sm->allocs->iso();
|
||||
if (!h4sm->om) {
|
||||
return -1;
|
||||
@ -177,8 +181,7 @@ hci_h4_sm_w4_header(struct hci_h4_sm *h4sm, struct hci_h4_input_buffer *ib)
|
||||
h4sm->exp_len = (get_le16(&h4sm->hdr[2]) & 0x7fff) + 4;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
return -2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -193,19 +196,18 @@ hci_h4_sm_w4_payload(struct hci_h4_sm *h4sm,
|
||||
int rc;
|
||||
|
||||
len = min(ib->len, h4sm->exp_len - h4sm->len);
|
||||
|
||||
|
||||
switch (h4sm->pkt_type) {
|
||||
case HCI_H4_CMD:
|
||||
#if (!CONFIG_BT_CONTROLLER_ENABLED)
|
||||
case HCI_H4_EVT:
|
||||
#endif // (!CONFIG_BT_CONTROLLER_ENABLED)
|
||||
if (h4sm->buf) {
|
||||
memcpy(&h4sm->buf[h4sm->len], ib->buf, len);
|
||||
}
|
||||
break;
|
||||
case HCI_H4_ACL:
|
||||
case HCI_H4_ISO:
|
||||
assert(h4sm->om);
|
||||
|
||||
HCI_TRANS_ASSERT(h4sm->om, h4sm->pkt_type, len);
|
||||
mbuf_len = OS_MBUF_PKTLEN(h4sm->om);
|
||||
rc = os_mbuf_append(h4sm->om, ib->buf, len);
|
||||
if (rc) {
|
||||
@ -215,13 +217,11 @@ hci_h4_sm_w4_payload(struct hci_h4_sm *h4sm,
|
||||
len = OS_MBUF_PKTLEN(h4sm->om) - mbuf_len;
|
||||
h4sm->len += len;
|
||||
hci_h4_ib_consume(ib, len);
|
||||
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
return -2;
|
||||
}
|
||||
|
||||
h4sm->len += len;
|
||||
@ -240,51 +240,110 @@ hci_h4_sm_completed(struct hci_h4_sm *h4sm)
|
||||
#if CONFIG_BT_CONTROLLER_ENABLED
|
||||
case HCI_H4_CMD:
|
||||
if (h4sm->buf) {
|
||||
assert(h4sm->frame_cb);
|
||||
HCI_TRANS_ASSERT(h4sm->frame_cb, 0, 0);
|
||||
rc = h4sm->frame_cb(h4sm->pkt_type, h4sm->buf);
|
||||
assert(rc == 0);
|
||||
HCI_TRANS_ASSERT(rc == 0, rc, 0);
|
||||
h4sm->buf = NULL;
|
||||
}
|
||||
break;
|
||||
case HCI_H4_ACL:
|
||||
case HCI_H4_ISO:
|
||||
if (h4sm->om) {
|
||||
assert(h4sm->frame_cb);
|
||||
HCI_TRANS_ASSERT(h4sm->frame_cb, 0, 0);
|
||||
rc = h4sm->frame_cb(h4sm->pkt_type, h4sm->om);
|
||||
assert(rc == 0);
|
||||
HCI_TRANS_ASSERT(rc == 0, rc, 0);
|
||||
h4sm->om = NULL;
|
||||
}
|
||||
break;
|
||||
#else
|
||||
case HCI_H4_CMD:
|
||||
case HCI_H4_EVT:
|
||||
if (h4sm->buf) {
|
||||
assert(h4sm->frame_cb);
|
||||
HCI_TRANS_ASSERT(h4sm->frame_cb, 0, 0);
|
||||
rc = h4sm->frame_cb(h4sm->pkt_type, h4sm->buf);
|
||||
if (rc != 0) {
|
||||
ble_transport_free(h4sm->buf);
|
||||
HCI_TRANS_ASSERT(h4sm->frees && h4sm->frees->cmd, rc, (uint32_t)h4sm->frees);
|
||||
h4sm->frees->cmd(h4sm->buf);
|
||||
}
|
||||
h4sm->buf = NULL;
|
||||
}
|
||||
break;
|
||||
case HCI_H4_EVT:
|
||||
if (h4sm->buf) {
|
||||
HCI_TRANS_ASSERT(h4sm->frame_cb, 0, 0);
|
||||
rc = h4sm->frame_cb(h4sm->pkt_type, h4sm->buf);
|
||||
if (rc != 0) {
|
||||
HCI_TRANS_ASSERT(h4sm->frees && h4sm->frees->evt, rc, (uint32_t)h4sm->frees);
|
||||
h4sm->frees->evt(h4sm->buf);
|
||||
}
|
||||
h4sm->buf = NULL;
|
||||
}
|
||||
break;
|
||||
case HCI_H4_ACL:
|
||||
case HCI_H4_ISO:
|
||||
if (h4sm->om) {
|
||||
assert(h4sm->frame_cb);
|
||||
HCI_TRANS_ASSERT(h4sm->frame_cb, 0, 0);
|
||||
rc = h4sm->frame_cb(h4sm->pkt_type, h4sm->om);
|
||||
if (rc != 0) {
|
||||
os_mbuf_free_chain(h4sm->om);
|
||||
HCI_TRANS_ASSERT(h4sm->frees && h4sm->frees->acl, rc, (uint32_t)h4sm->frees);
|
||||
h4sm->frees->acl(h4sm->om);
|
||||
}
|
||||
h4sm->om = NULL;
|
||||
}
|
||||
break;
|
||||
case HCI_H4_ISO:
|
||||
if (h4sm->om) {
|
||||
HCI_TRANS_ASSERT(h4sm->frame_cb, 0, 0);
|
||||
rc = h4sm->frame_cb(h4sm->pkt_type, h4sm->om);
|
||||
if (rc != 0) {
|
||||
HCI_TRANS_ASSERT(h4sm->frees && h4sm->frees->iso, rc, (uint32_t)h4sm->frees);
|
||||
h4sm->frees->iso(h4sm->om);
|
||||
}
|
||||
h4sm->om = NULL;
|
||||
}
|
||||
break;
|
||||
#endif // CONFIG_BT_CONTROLLER_ENABLED
|
||||
default:
|
||||
assert(0);
|
||||
HCI_TRANS_ASSERT(0, h4sm->pkt_type, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
hci_h4_sm_free_buf(struct hci_h4_sm *h4sm)
|
||||
{
|
||||
switch (h4sm->pkt_type) {
|
||||
case HCI_H4_CMD:
|
||||
if (h4sm->buf) {
|
||||
h4sm->frees->cmd(h4sm->buf);
|
||||
h4sm->buf = NULL;
|
||||
}
|
||||
break;
|
||||
#if (!CONFIG_BT_CONTROLLER_ENABLED)
|
||||
case HCI_H4_EVT:
|
||||
if (h4sm->buf) {
|
||||
h4sm->frees->evt(h4sm->buf);
|
||||
h4sm->buf = NULL;
|
||||
}
|
||||
break;
|
||||
#endif // (!CONFIG_BT_CONTROLLER_ENABLED)
|
||||
case HCI_H4_ACL:
|
||||
if (h4sm->om) {
|
||||
h4sm->frees->acl(h4sm->om);
|
||||
h4sm->om = NULL;
|
||||
}
|
||||
break;
|
||||
case HCI_H4_ISO:
|
||||
if (h4sm->om) {
|
||||
h4sm->frees->iso(h4sm->om);
|
||||
h4sm->om = NULL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
hci_h4_sm_rx(struct hci_h4_sm *h4sm, const uint8_t *buf, uint16_t len)
|
||||
{
|
||||
@ -307,18 +366,18 @@ hci_h4_sm_rx(struct hci_h4_sm *h4sm, const uint8_t *buf, uint16_t len)
|
||||
/* no break */
|
||||
case HCI_H4_SM_W4_HEADER:
|
||||
rc = hci_h4_sm_w4_header(h4sm, &ib);
|
||||
assert(rc >= 0);
|
||||
if (rc) {
|
||||
break;
|
||||
}
|
||||
|
||||
h4sm->state = HCI_H4_SM_W4_PAYLOAD;
|
||||
/* no break */
|
||||
case HCI_H4_SM_W4_PAYLOAD:
|
||||
rc = hci_h4_sm_w4_payload(h4sm, &ib);
|
||||
assert(rc >= 0);
|
||||
if (rc) {
|
||||
break;
|
||||
}
|
||||
|
||||
h4sm->state = HCI_H4_SM_COMPLETED;
|
||||
/* no break */
|
||||
case HCI_H4_SM_COMPLETED:
|
||||
@ -330,6 +389,11 @@ hci_h4_sm_rx(struct hci_h4_sm *h4sm, const uint8_t *buf, uint16_t len)
|
||||
}
|
||||
}
|
||||
|
||||
if (rc < 0) {
|
||||
hci_h4_sm_free_buf(h4sm);
|
||||
h4sm->state = HCI_H4_SM_W4_PKT_TYPE;
|
||||
return -1;
|
||||
}
|
||||
/* Calculate consumed bytes
|
||||
*
|
||||
* Note: we should always consume some bytes unless there is an oom error.
|
||||
@ -339,7 +403,7 @@ hci_h4_sm_rx(struct hci_h4_sm *h4sm, const uint8_t *buf, uint16_t len)
|
||||
*/
|
||||
len = len - ib.len;
|
||||
if (len == 0) {
|
||||
assert(rc < 0);
|
||||
HCI_TRANS_ASSERT((rc < 0), rc, ib.len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -347,10 +411,11 @@ hci_h4_sm_rx(struct hci_h4_sm *h4sm, const uint8_t *buf, uint16_t len)
|
||||
}
|
||||
|
||||
void
|
||||
hci_h4_sm_init(struct hci_h4_sm *h4sm, const struct hci_h4_allocators *allocs,
|
||||
hci_h4_sm_init(struct hci_h4_sm *h4sm, const struct hci_h4_allocators *allocs, const struct hci_h4_frees *frees,
|
||||
hci_h4_frame_cb *frame_cb)
|
||||
{
|
||||
memset(h4sm, 0, sizeof(*h4sm));
|
||||
h4sm->allocs = allocs;
|
||||
h4sm->frees = frees;
|
||||
h4sm->frame_cb = frame_cb;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -53,3 +53,10 @@ const struct hci_h4_allocators s_hci_driver_mem_alloc = {
|
||||
.acl = hci_driver_mem_acl_alloc,
|
||||
.iso = hci_driver_mem_iso_alloc,
|
||||
};
|
||||
|
||||
const struct hci_h4_frees s_hci_driver_mem_free = {
|
||||
.cmd = r_ble_hci_trans_buf_free,
|
||||
.evt = r_ble_hci_trans_buf_free,
|
||||
.acl = os_mbuf_free_chain,
|
||||
.iso = os_mbuf_free_chain,
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -96,7 +96,7 @@ hci_driver_util_tx_list_enqueue(hci_driver_data_type_t type, uint8_t *data, uint
|
||||
hci_driver_util_tx_entry_t *tx_entry;
|
||||
|
||||
tx_entry = os_memblock_get(s_hci_driver_util_env.tx_entry_pool);
|
||||
assert(tx_entry != NULL);
|
||||
HCI_TRANS_ASSERT((tx_entry != NULL), 0, 0);
|
||||
tx_entry->data_type = type;
|
||||
tx_entry->data = data;
|
||||
tx_entry->length = len;
|
||||
@ -149,7 +149,7 @@ hci_driver_util_tx_list_dequeue(uint32_t max_tx_len, void **tx_data, bool *last_
|
||||
*tx_data = &tx_entry->data[s_hci_driver_util_env.cur_tx_off];
|
||||
}
|
||||
} else {
|
||||
assert(0);
|
||||
HCI_TRANS_ASSERT(0, tx_entry->data_type, data_len);
|
||||
}
|
||||
/* If this is the last frame, inform the invoker not to call this API until the current data
|
||||
* has been completely sent.
|
||||
@ -223,3 +223,10 @@ hci_driver_util_deinit(void)
|
||||
|
||||
memset(&s_hci_driver_util_env, 0, sizeof(hci_driver_util_env_t));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
hci_driver_util_assert_check(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2)
|
||||
{
|
||||
ESP_LOGE(TAG, "hci driver assert: line %d in function %s, param: 0x%x, 0x%x", ln, fn, param1, param2);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -37,7 +37,6 @@ typedef struct {
|
||||
static hci_driver_uart_env_t s_hci_driver_uart_env;
|
||||
static struct hci_h4_sm s_hci_driver_uart_h4_sm;
|
||||
static uint8_t s_hci_driver_uart_rx_data[CONFIG_BT_LE_HCI_RX_PROC_DATA_LEN];
|
||||
static hci_driver_uart_params_config_t hci_driver_uart_params = BT_HCI_DRIVER_UART_CONFIG_DEFAULT();
|
||||
|
||||
static int
|
||||
hci_driver_uart_tx(hci_driver_data_type_t data_type, uint8_t *data, uint32_t length,
|
||||
@ -111,6 +110,7 @@ hci_driver_uart_rx_task(void *p)
|
||||
ESP_LOG_BUFFER_HEXDUMP(TAG, data, read_len, ESP_LOG_DEBUG);
|
||||
ret = hci_h4_sm_rx(s_hci_driver_uart_env.h4_sm, data, read_len);
|
||||
if (ret < 0) {
|
||||
ESP_LOGE(TAG, "parse rx data error! sm_state:%d\n", s_hci_driver_uart_env.h4_sm->state);
|
||||
r_ble_ll_hci_ev_hw_err(ESP_HCI_SYNC_LOSS_ERR);
|
||||
}
|
||||
}
|
||||
@ -175,7 +175,7 @@ hci_driver_uart_init(hci_driver_forward_fn *cb)
|
||||
memset(&s_hci_driver_uart_env, 0, sizeof(hci_driver_uart_env_t));
|
||||
|
||||
s_hci_driver_uart_env.h4_sm = &s_hci_driver_uart_h4_sm;
|
||||
hci_h4_sm_init(s_hci_driver_uart_env.h4_sm, &s_hci_driver_mem_alloc, hci_driver_uart_h4_frame_cb);
|
||||
hci_h4_sm_init(s_hci_driver_uart_env.h4_sm, &s_hci_driver_mem_alloc, &s_hci_driver_mem_free, hci_driver_uart_h4_frame_cb);
|
||||
|
||||
rc = hci_driver_util_init();
|
||||
if (rc) {
|
||||
@ -189,8 +189,8 @@ hci_driver_uart_init(hci_driver_forward_fn *cb)
|
||||
|
||||
s_hci_driver_uart_env.rx_data = s_hci_driver_uart_rx_data;
|
||||
s_hci_driver_uart_env.forward_cb = cb;
|
||||
s_hci_driver_uart_env.hci_uart_params = &hci_driver_uart_params;
|
||||
hci_driver_uart_config(&hci_driver_uart_params);
|
||||
s_hci_driver_uart_env.hci_uart_params = hci_driver_uart_config_param_get();
|
||||
hci_driver_uart_config(s_hci_driver_uart_env.hci_uart_params);
|
||||
/* Currently, the queue size is set to 1. It will be considered as semaphore. */
|
||||
ESP_ERROR_CHECK(uart_driver_install(s_hci_driver_uart_env.hci_uart_params->hci_uart_port,
|
||||
CONFIG_BT_LE_HCI_UART_RX_BUFFER_SIZE,
|
||||
@ -214,14 +214,9 @@ int
|
||||
hci_driver_uart_reconfig_pin(int tx_pin, int rx_pin, int cts_pin, int rts_pin)
|
||||
{
|
||||
int rc;
|
||||
hci_driver_uart_params_config_t *uart_param = s_hci_driver_uart_env.hci_uart_params;
|
||||
|
||||
hci_driver_uart_task_delete();
|
||||
uart_param->hci_uart_tx_pin = tx_pin;
|
||||
uart_param->hci_uart_rx_pin = rx_pin;
|
||||
uart_param->hci_uart_rts_pin = rts_pin;
|
||||
uart_param->hci_uart_cts_pin = cts_pin;
|
||||
hci_driver_uart_config(uart_param);
|
||||
hci_driver_uart_pin_update(tx_pin, rx_pin, cts_pin, rts_pin);
|
||||
/* Currently, the queue size is set to 1. It will be considered as semaphore. */
|
||||
ESP_ERROR_CHECK(uart_driver_install(s_hci_driver_uart_env.hci_uart_params->hci_uart_port,
|
||||
CONFIG_BT_LE_HCI_UART_RX_BUFFER_SIZE,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -60,6 +60,28 @@ typedef struct hci_driver_uart_params_config
|
||||
*/
|
||||
int hci_driver_uart_config(hci_driver_uart_params_config_t *uart_config);
|
||||
|
||||
/**
|
||||
* @brief Update the UART pin configuration for the HCI driver.
|
||||
*
|
||||
* This function updates the TX, RX, CTS, and RTS pin assignments for the HCI driver operating over UART.
|
||||
* It allows dynamic reconfiguration of UART pins as needed.
|
||||
*
|
||||
* @param tx_pin The GPIO number assigned to the UART TX pin.
|
||||
* @param rx_pin The GPIO number assigned to the UART RX pin.
|
||||
* @param cts_pin The GPIO number assigned to the UART CTS pin.
|
||||
* @param rts_pin The GPIO number assigned to the UART RTS pin.
|
||||
*
|
||||
* @return 0 on success, or a negative error code on failure.
|
||||
*/
|
||||
int hci_driver_uart_pin_update(int tx_pin, int rx_pin, int cts_pin, int rts_pin);
|
||||
|
||||
/**
|
||||
* @brief Retrieves the current UART configuration parameters for the HCI driver.
|
||||
*
|
||||
* @return hci_driver_uart_params_config_t* Pointer to the structure with UART configuration parameters.
|
||||
*/
|
||||
hci_driver_uart_params_config_t * hci_driver_uart_config_param_get(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -10,9 +10,9 @@
|
||||
#include "driver/uart.h"
|
||||
#include "hci_driver_uart.h"
|
||||
|
||||
|
||||
static const char *TAG = "hci_uart_config";
|
||||
static uart_config_t s_uart_cfg;
|
||||
static hci_driver_uart_params_config_t s_hci_driver_uart_params = BT_HCI_DRIVER_UART_CONFIG_DEFAULT();
|
||||
|
||||
int hci_driver_uart_config(hci_driver_uart_params_config_t *uart_config)
|
||||
{
|
||||
@ -26,7 +26,6 @@ int hci_driver_uart_config(hci_driver_uart_params_config_t *uart_config)
|
||||
uart_cfg->source_clk= UART_SCLK_DEFAULT;
|
||||
uart_cfg->rx_flow_ctrl_thresh = UART_HW_FIFO_LEN(uart_config->hci_uart_port) - 1;
|
||||
|
||||
|
||||
ESP_LOGI(TAG,"set uart pin tx:%d, rx:%d.\n", uart_config->hci_uart_tx_pin, uart_config->hci_uart_rx_pin);
|
||||
ESP_LOGI(TAG,"set rts:%d, cts:%d.\n", uart_config->hci_uart_rts_pin, uart_config->hci_uart_cts_pin);
|
||||
ESP_LOGI(TAG,"set baud_rate:%d.\n", uart_config->hci_uart_baud);
|
||||
@ -38,3 +37,20 @@ int hci_driver_uart_config(hci_driver_uart_params_config_t *uart_config)
|
||||
uart_config->hci_uart_rts_pin, uart_config->hci_uart_cts_pin));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
hci_driver_uart_pin_update(int tx_pin, int rx_pin, int cts_pin, int rts_pin)
|
||||
{
|
||||
hci_driver_uart_params_config_t *uart_param = &s_hci_driver_uart_params;
|
||||
uart_param->hci_uart_tx_pin = tx_pin;
|
||||
uart_param->hci_uart_rx_pin = rx_pin;
|
||||
uart_param->hci_uart_rts_pin = rts_pin;
|
||||
uart_param->hci_uart_cts_pin = cts_pin;
|
||||
return hci_driver_uart_config(uart_param);
|
||||
}
|
||||
|
||||
hci_driver_uart_params_config_t *
|
||||
hci_driver_uart_config_param_get(void)
|
||||
{
|
||||
return &s_hci_driver_uart_params;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -19,7 +19,6 @@
|
||||
#include "common/hci_driver_mem.h"
|
||||
#include "hci_driver_uart.h"
|
||||
|
||||
#include "ble_hci_trans.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_private/gdma.h"
|
||||
#include "hal/uhci_ll.h"
|
||||
@ -81,7 +80,7 @@ typedef struct {
|
||||
/* The number of lldescs pool */
|
||||
#define HCI_LLDESCS_POOL_NUM (CONFIG_BT_LE_HCI_LLDESCS_POOL_NUM)
|
||||
/* Default block size for HCI RX data */
|
||||
#define HCI_RX_DATA_BLOCK_SIZE (DEFAULT_BT_LE_ACL_BUF_SIZE + BLE_HCI_TRANS_CMD_SZ)
|
||||
#define HCI_RX_DATA_BLOCK_SIZE (DEFAULT_BT_LE_ACL_BUF_SIZE + HCI_TRANSPORT_CMD_SZ)
|
||||
#define HCI_RX_DATA_POOL_NUM (CONFIG_BT_LE_HCI_TRANS_RX_MEM_NUM)
|
||||
#define HCI_RX_INFO_POOL_NUM (CONFIG_BT_LE_HCI_TRANS_RX_MEM_NUM + 1)
|
||||
|
||||
@ -114,7 +113,6 @@ int hci_driver_uart_dma_tx_start(esp_bt_hci_tl_callback_t callback, void *arg);
|
||||
static const char *TAG = "uart_dma";
|
||||
static hci_driver_uart_dma_env_t s_hci_driver_uart_dma_env;
|
||||
static struct hci_h4_sm s_hci_driver_uart_h4_sm;
|
||||
static hci_driver_uart_params_config_t hci_driver_uart_dma_params = BT_HCI_DRIVER_UART_CONFIG_DEFAULT();
|
||||
|
||||
/* The list for hci_rx_data */
|
||||
STAILQ_HEAD(g_hci_rxinfo_list, hci_message);
|
||||
@ -609,7 +607,7 @@ hci_driver_uart_dma_init(hci_driver_forward_fn *cb)
|
||||
memset(&s_hci_driver_uart_dma_env, 0, sizeof(hci_driver_uart_dma_env_t));
|
||||
|
||||
s_hci_driver_uart_dma_env.h4_sm = &s_hci_driver_uart_h4_sm;
|
||||
hci_h4_sm_init(s_hci_driver_uart_dma_env.h4_sm, &s_hci_driver_mem_alloc, hci_driver_uart_dma_h4_frame_cb);
|
||||
hci_h4_sm_init(s_hci_driver_uart_dma_env.h4_sm, &s_hci_driver_mem_alloc, &s_hci_driver_mem_free, hci_driver_uart_dma_h4_frame_cb);
|
||||
|
||||
rc = hci_driver_util_init();
|
||||
if (rc) {
|
||||
@ -627,8 +625,8 @@ hci_driver_uart_dma_init(hci_driver_forward_fn *cb)
|
||||
}
|
||||
|
||||
s_hci_driver_uart_dma_env.forward_cb = cb;
|
||||
s_hci_driver_uart_dma_env.hci_uart_params = &hci_driver_uart_dma_params;
|
||||
hci_driver_uart_config(&hci_driver_uart_dma_params);
|
||||
s_hci_driver_uart_dma_env.hci_uart_params = hci_driver_uart_config_param_get();
|
||||
hci_driver_uart_config(s_hci_driver_uart_dma_env.hci_uart_params);
|
||||
|
||||
ESP_LOGI(TAG, "uart attach uhci!");
|
||||
hci_driver_uart_dma_install();
|
||||
@ -655,12 +653,7 @@ error:
|
||||
int
|
||||
hci_driver_uart_dma_reconfig_pin(int tx_pin, int rx_pin, int cts_pin, int rts_pin)
|
||||
{
|
||||
hci_driver_uart_params_config_t *uart_param = s_hci_driver_uart_dma_env.hci_uart_params;
|
||||
uart_param->hci_uart_tx_pin = tx_pin;
|
||||
uart_param->hci_uart_rx_pin = rx_pin;
|
||||
uart_param->hci_uart_rts_pin = rts_pin;
|
||||
uart_param->hci_uart_cts_pin = cts_pin;
|
||||
return hci_driver_uart_config(uart_param);
|
||||
return hci_driver_uart_pin_update(tx_pin, rx_pin, cts_pin, rts_pin);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -48,6 +48,17 @@ struct hci_h4_allocators {
|
||||
extern const struct hci_h4_allocators hci_h4_allocs_from_ll;
|
||||
extern const struct hci_h4_allocators hci_h4_allocs_from_hs;
|
||||
|
||||
typedef void (hci_h4_free_cmd)(uint8_t *buf);
|
||||
typedef void (hci_h4_free_evt)(uint8_t *buf);
|
||||
typedef int (hci_h4_free_acl)(struct os_mbuf *om);
|
||||
typedef int (hci_h4_free_iso)(struct os_mbuf *om);
|
||||
struct hci_h4_frees {
|
||||
hci_h4_free_cmd *cmd;
|
||||
hci_h4_free_acl *acl;
|
||||
hci_h4_free_evt *evt;
|
||||
hci_h4_free_iso *iso;
|
||||
};
|
||||
|
||||
typedef int (hci_h4_frame_cb)(uint8_t pkt_type, void *data);
|
||||
|
||||
struct hci_h4_sm {
|
||||
@ -63,11 +74,13 @@ struct hci_h4_sm {
|
||||
};
|
||||
|
||||
const struct hci_h4_allocators *allocs;
|
||||
const struct hci_h4_frees *frees;
|
||||
hci_h4_frame_cb *frame_cb;
|
||||
};
|
||||
|
||||
void hci_h4_sm_init(struct hci_h4_sm *h4sm,
|
||||
const struct hci_h4_allocators *allocs,
|
||||
const struct hci_h4_frees *frees,
|
||||
hci_h4_frame_cb *frame_cb);
|
||||
|
||||
int hci_h4_sm_rx(struct hci_h4_sm *h4sm, const uint8_t *buf, uint16_t len);
|
||||
|
@ -21,5 +21,5 @@ struct os_mbuf *hci_driver_mem_iso_alloc(void);
|
||||
struct os_mbuf *hci_driver_mem_iso_len_alloc(uint32_t len);
|
||||
|
||||
extern const struct hci_h4_allocators s_hci_driver_mem_alloc;
|
||||
|
||||
extern const struct hci_h4_frees s_hci_driver_mem_free;
|
||||
#endif // _H_HCI_DRIVER_MEM_
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -15,4 +15,9 @@ void hci_driver_util_tx_list_enqueue(hci_driver_data_type_t type, uint8_t *data,
|
||||
|
||||
uint32_t hci_driver_util_tx_list_dequeue(uint32_t max_tx_len, void **tx_data, bool *last_frame);
|
||||
|
||||
void hci_driver_util_assert_check(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2);
|
||||
#define HCI_TRANS_ASSERT(cond, p1, p2) \
|
||||
if (!(cond)) { \
|
||||
hci_driver_util_assert_check(__LINE__, __func__, p1, p2); \
|
||||
}
|
||||
#endif // _H_HCI_DRIVER_UTIL_
|
||||
|
@ -38,7 +38,7 @@ typedef enum {
|
||||
} hci_trans_mode_t;
|
||||
|
||||
typedef int hci_transport_host_recv_fn(hci_trans_pkt_ind_t type, uint8_t *data, uint16_t len);
|
||||
|
||||
#define HCI_TRANSPORT_CMD_SZ (260)
|
||||
/**
|
||||
* @brief Initialize the HCI transport layer.
|
||||
* It should be called before using any other functions in the transport layer.
|
||||
|
Reference in New Issue
Block a user