mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-08-05 01:27:56 +00:00
Merge pull request #128 from andrzej-kaczmarek/silly-nrf51-optimize
Some optimizations
This commit is contained in:
@@ -451,6 +451,7 @@ int ble_ll_rx_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr);
|
||||
|
||||
/* Helper callback to tx mbuf using ble_phy_tx() */
|
||||
uint8_t ble_ll_tx_mbuf_pducb(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte);
|
||||
uint8_t ble_ll_tx_flat_mbuf_pducb(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte);
|
||||
|
||||
/*--- Controller API ---*/
|
||||
void ble_ll_mbuf_init(struct os_mbuf *m, uint8_t pdulen, uint8_t hdr);
|
||||
|
||||
@@ -1017,6 +1017,23 @@ ble_ll_tx_mbuf_pducb(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte)
|
||||
return ble_hdr->txinfo.pyld_len;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
ble_ll_tx_flat_mbuf_pducb(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte)
|
||||
{
|
||||
struct os_mbuf *txpdu;
|
||||
struct ble_mbuf_hdr *ble_hdr;
|
||||
|
||||
txpdu = pducb_arg;
|
||||
BLE_LL_ASSERT(txpdu);
|
||||
ble_hdr = BLE_MBUF_HDR_PTR(txpdu);
|
||||
|
||||
memcpy(dptr, txpdu->om_data, ble_hdr->txinfo.pyld_len);
|
||||
|
||||
*hdr_byte = ble_hdr->txinfo.hdr_byte;
|
||||
|
||||
return ble_hdr->txinfo.pyld_len;
|
||||
}
|
||||
|
||||
static void
|
||||
ble_ll_event_rx_pkt(struct ble_npl_event *ev)
|
||||
{
|
||||
|
||||
@@ -2868,7 +2868,7 @@ ble_ll_conn_request_send(uint8_t addr_type, uint8_t *adva, uint16_t txoffset,
|
||||
} else {
|
||||
ble_phy_set_txend_cb(ble_ll_conn_req_txend_init, NULL);
|
||||
}
|
||||
rc = ble_phy_tx(ble_ll_tx_mbuf_pducb, m, end_trans);
|
||||
rc = ble_phy_tx(ble_ll_tx_flat_mbuf_pducb, m, end_trans);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -3057,6 +3057,55 @@ ble_ll_init_rx_isr_start(uint8_t pdu_type, struct ble_mbuf_hdr *ble_hdr)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a connect request PDU
|
||||
*
|
||||
* @param connsm
|
||||
*/
|
||||
static void
|
||||
ble_ll_conn_req_pdu_make(struct ble_ll_conn_sm *connsm, uint8_t chan)
|
||||
{
|
||||
uint8_t pdu_type;
|
||||
uint8_t *dptr;
|
||||
struct os_mbuf *m;
|
||||
|
||||
m = ble_ll_scan_get_pdu();
|
||||
BLE_LL_ASSERT(m != NULL);
|
||||
|
||||
/* Construct first PDU header byte */
|
||||
pdu_type = BLE_ADV_PDU_TYPE_CONNECT_REQ;
|
||||
|
||||
#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1)
|
||||
/* We need CSA2 bit only for legacy connect */
|
||||
if (chan >= BLE_PHY_NUM_DATA_CHANS) {
|
||||
pdu_type |= BLE_ADV_PDU_HDR_CHSEL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set BLE transmit header */
|
||||
ble_ll_mbuf_init(m, BLE_CONNECT_REQ_LEN, pdu_type);
|
||||
|
||||
/* Construct the connect request */
|
||||
dptr = m->om_data;
|
||||
|
||||
/* Skip inita and adva advertiser's address as we dont know that yet */
|
||||
dptr += (2 * BLE_DEV_ADDR_LEN);
|
||||
|
||||
/* Access address */
|
||||
put_le32(dptr, connsm->access_addr);
|
||||
dptr[4] = (uint8_t)connsm->crcinit;
|
||||
dptr[5] = (uint8_t)(connsm->crcinit >> 8);
|
||||
dptr[6] = (uint8_t)(connsm->crcinit >> 16);
|
||||
dptr[7] = connsm->tx_win_size;
|
||||
put_le16(dptr + 8, connsm->tx_win_off);
|
||||
put_le16(dptr + 10, connsm->conn_itvl);
|
||||
put_le16(dptr + 12, connsm->slave_latency);
|
||||
put_le16(dptr + 14, connsm->supervision_tmo);
|
||||
memcpy(dptr + 16, &connsm->chanmap, BLE_LL_CONN_CHMAP_LEN);
|
||||
dptr[21] = connsm->hop_inc | (connsm->master_sca << 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a receive PDU has ended and we are in the initiating state.
|
||||
*
|
||||
|
||||
@@ -123,54 +123,6 @@ ble_ll_conn_hci_chk_conn_params(uint16_t itvl_min, uint16_t itvl_max,
|
||||
return BLE_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a connect request PDU
|
||||
*
|
||||
* @param connsm
|
||||
*/
|
||||
void
|
||||
ble_ll_conn_req_pdu_make(struct ble_ll_conn_sm *connsm, uint8_t chan)
|
||||
{
|
||||
uint8_t pdu_type;
|
||||
uint8_t *dptr;
|
||||
struct os_mbuf *m;
|
||||
|
||||
m = ble_ll_scan_get_pdu();
|
||||
BLE_LL_ASSERT(m != NULL);
|
||||
|
||||
/* Construct first PDU header byte */
|
||||
pdu_type = BLE_ADV_PDU_TYPE_CONNECT_REQ;
|
||||
|
||||
#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1)
|
||||
/* We need CSA2 bit only for legacy connect */
|
||||
if (chan >= BLE_PHY_NUM_DATA_CHANS) {
|
||||
pdu_type |= BLE_ADV_PDU_HDR_CHSEL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set BLE transmit header */
|
||||
ble_ll_mbuf_init(m, BLE_CONNECT_REQ_LEN, pdu_type);
|
||||
|
||||
/* Construct the connect request */
|
||||
dptr = m->om_data;
|
||||
|
||||
/* Skip inita and adva advertiser's address as we dont know that yet */
|
||||
dptr += (2 * BLE_DEV_ADDR_LEN);
|
||||
|
||||
/* Access address */
|
||||
put_le32(dptr, connsm->access_addr);
|
||||
dptr[4] = (uint8_t)connsm->crcinit;
|
||||
dptr[5] = (uint8_t)(connsm->crcinit >> 8);
|
||||
dptr[6] = (uint8_t)(connsm->crcinit >> 16);
|
||||
dptr[7] = connsm->tx_win_size;
|
||||
put_le16(dptr + 8, connsm->tx_win_off);
|
||||
put_le16(dptr + 10, connsm->conn_itvl);
|
||||
put_le16(dptr + 12, connsm->slave_latency);
|
||||
put_le16(dptr + 14, connsm->supervision_tmo);
|
||||
memcpy(dptr + 16, &connsm->chanmap, BLE_LL_CONN_CHMAP_LEN);
|
||||
dptr[21] = connsm->hop_inc | (connsm->master_sca << 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a connection complete event
|
||||
*
|
||||
|
||||
@@ -182,7 +182,6 @@ int ble_ll_hci_acl_rx(struct os_mbuf *om, void *arg);
|
||||
int ble_ll_conn_hci_le_rd_phy(uint8_t *cmdbuf, uint8_t *rsp, uint8_t *rsplen);
|
||||
int ble_ll_conn_hci_le_set_phy(uint8_t *cmdbuf);
|
||||
int ble_ll_conn_chk_phy_upd_start(struct ble_ll_conn_sm *connsm);
|
||||
void ble_ll_conn_req_pdu_make(struct ble_ll_conn_sm *connsm, uint8_t chan);
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
|
||||
int ble_ll_ext_conn_create(uint8_t *cmdbuf);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user