From a6e157b61a9176eb64280e50f3f26d9e6914b1f2 Mon Sep 17 00:00:00 2001 From: Carles Cufi Date: Fri, 21 Apr 2017 13:18:52 +0200 Subject: [PATCH] Bluetooth: Controller: Fix alignment issues from new integer types The switch from C99 integer types to u16_t, etc. caused misalignment in structs and function definitions with multi-line parameter lists. Change-Id: I1448b159ab1afe50ff88b7a6bd1b254c44858d4c Signed-off-by: Carles Cufi --- subsys/bluetooth/controller/hal/ccm.h | 8 +- subsys/bluetooth/controller/hal/ecb.h | 24 +- subsys/bluetooth/controller/hal/nrf5/ecb.c | 22 +- subsys/bluetooth/controller/hal/nrf5/radio.c | 5 +- subsys/bluetooth/controller/hal/radio.h | 5 +- subsys/bluetooth/controller/hci/hci.c | 8 +- subsys/bluetooth/controller/include/ll.h | 18 +- subsys/bluetooth/controller/ll_sw/ctrl.c | 259 ++++++++---------- subsys/bluetooth/controller/ll_sw/ctrl.h | 42 +-- .../controller/ll_sw/ctrl_internal.h | 98 +++---- subsys/bluetooth/controller/ll_sw/ll.c | 70 ++--- subsys/bluetooth/controller/ll_sw/pdu.h | 26 +- subsys/bluetooth/controller/ticker/ticker.c | 132 ++++----- subsys/bluetooth/controller/ticker/ticker.h | 43 ++- subsys/bluetooth/controller/util/mayfly.h | 5 +- subsys/bluetooth/controller/util/mem.c | 16 +- subsys/bluetooth/controller/util/mem.h | 3 +- 17 files changed, 362 insertions(+), 422 deletions(-) diff --git a/subsys/bluetooth/controller/hal/ccm.h b/subsys/bluetooth/controller/hal/ccm.h index 54abc4fab32..c3b3949e37d 100644 --- a/subsys/bluetooth/controller/hal/ccm.h +++ b/subsys/bluetooth/controller/hal/ccm.h @@ -9,11 +9,11 @@ #define _CCM_H_ struct ccm { - u8_t key[16]; + u8_t key[16]; u64_t counter; - u8_t direction:1; - u8_t resv1:7; - u8_t iv[8]; + u8_t direction:1; + u8_t resv1:7; + u8_t iv[8]; } __packed; #endif /* _CCM_H_ */ diff --git a/subsys/bluetooth/controller/hal/ecb.h b/subsys/bluetooth/controller/hal/ecb.h index 522fd177199..92e47267e3b 100644 --- a/subsys/bluetooth/controller/hal/ecb.h +++ b/subsys/bluetooth/controller/hal/ecb.h @@ -8,28 +8,24 @@ #ifndef _ECB_H_ #define _ECB_H_ -typedef void (*ecb_fp) (u32_t status, u8_t *cipher_be, - void *context); +typedef void (*ecb_fp) (u32_t status, u8_t *cipher_be, void *context); struct ecb { - u8_t in_key_be[16]; - u8_t in_clear_text_be[16]; - u8_t out_cipher_text_be[16]; + u8_t in_key_be[16]; + u8_t in_clear_text_be[16]; + u8_t out_cipher_text_be[16]; /* if not null reverse copy into in_key_be */ - u8_t *in_key_le; + u8_t *in_key_le; /* if not null reverse copy into in_clear_text_be */ - u8_t *in_clear_text_le; + u8_t *in_clear_text_le; ecb_fp fp_ecb; - void *context; + void *context; }; -void ecb_encrypt_be(u8_t const *const key_be, - u8_t const *const clear_text_be, +void ecb_encrypt_be(u8_t const *const key_be, u8_t const *const clear_text_be, u8_t * const cipher_text_be); -void ecb_encrypt(u8_t const *const key_le, - u8_t const *const clear_text_le, - u8_t * const cipher_text_le, - u8_t * const cipher_text_be); +void ecb_encrypt(u8_t const *const key_le, u8_t const *const clear_text_le, + u8_t * const cipher_text_le, u8_t * const cipher_text_be); u32_t ecb_encrypt_nonblocking(struct ecb *ecb); void isr_ecb(void *param); diff --git a/subsys/bluetooth/controller/hal/nrf5/ecb.c b/subsys/bluetooth/controller/hal/nrf5/ecb.c index ddf5fd3d09c..2717feeea02 100644 --- a/subsys/bluetooth/controller/hal/nrf5/ecb.c +++ b/subsys/bluetooth/controller/hal/nrf5/ecb.c @@ -40,8 +40,7 @@ static void do_ecb(struct ecb_param *ecb) NRF_ECB->ECBDATAPTR = 0; } -void ecb_encrypt_be(u8_t const *const key_be, - u8_t const *const clear_text_be, +void ecb_encrypt_be(u8_t const *const key_be, u8_t const *const clear_text_be, u8_t * const cipher_text_be) { struct ecb_param ecb; @@ -54,10 +53,8 @@ void ecb_encrypt_be(u8_t const *const key_be, memcpy(cipher_text_be, &ecb.cipher_text[0], sizeof(ecb.cipher_text)); } -void ecb_encrypt(u8_t const *const key_le, - u8_t const *const clear_text_le, - u8_t * const cipher_text_le, - u8_t * const cipher_text_be) +void ecb_encrypt(u8_t const *const key_le, u8_t const *const clear_text_le, + u8_t * const cipher_text_le, u8_t * const cipher_text_be) { struct ecb_param ecb; @@ -144,7 +141,7 @@ void isr_ecb(void *param) struct ecb_ut_context { u32_t volatile done; u32_t status; - u8_t cipher_text[16]; + u8_t cipher_text[16]; }; static void ecb_cb(u32_t status, u8_t *cipher_be, void *context) @@ -162,12 +159,11 @@ static void ecb_cb(u32_t status, u8_t *cipher_be, void *context) u32_t ecb_ut(void) { - u8_t key[16] = { - 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, - 0x11, 0x22, 0x33, 0x44, 0x55 }; - u8_t clear_text[16] = { - 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, - 0x11, 0x22, 0x33, 0x44, 0x55 }; + u8_t key[16] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, + 0x99, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }; + u8_t clear_text[16] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44, + 0x55 }; u8_t cipher_text[16]; u32_t status = 0; struct ecb ecb; diff --git a/subsys/bluetooth/controller/hal/nrf5/radio.c b/subsys/bluetooth/controller/hal/nrf5/radio.c index c203fa59a89..b4fa3e1ce83 100644 --- a/subsys/bluetooth/controller/hal/nrf5/radio.c +++ b/subsys/bluetooth/controller/hal/nrf5/radio.c @@ -261,9 +261,8 @@ u32_t radio_rssi_is_ready(void) return NRF_RADIO->EVENTS_RSSIEND; } -void radio_filter_configure(u8_t bitmask_enable, - u8_t bitmask_addr_type, - u8_t *bdaddr) +void radio_filter_configure(u8_t bitmask_enable, u8_t bitmask_addr_type, + u8_t *bdaddr) { u8_t index; diff --git a/subsys/bluetooth/controller/hal/radio.h b/subsys/bluetooth/controller/hal/radio.h index afe3d63c702..95e416dceb7 100644 --- a/subsys/bluetooth/controller/hal/radio.h +++ b/subsys/bluetooth/controller/hal/radio.h @@ -59,9 +59,8 @@ u32_t radio_rssi_get(void); void radio_rssi_status_reset(void); u32_t radio_rssi_is_ready(void); -void radio_filter_configure(u8_t bitmask_enable, - u8_t bitmask_addr_type, - u8_t *bdaddr); +void radio_filter_configure(u8_t bitmask_enable, u8_t bitmask_addr_type, + u8_t *bdaddr); void radio_filter_disable(void); void radio_filter_status_reset(void); u32_t radio_filter_has_match(void); diff --git a/subsys/bluetooth/controller/hci/hci.c b/subsys/bluetooth/controller/hci/hci.c index aea30c9c6d2..c3a89457898 100644 --- a/subsys/bluetooth/controller/hci/hci.c +++ b/subsys/bluetooth/controller/hci/hci.c @@ -38,8 +38,8 @@ static u16_t _opcode; #if CONFIG_BLUETOOTH_CONTROLLER_DUP_FILTER_LEN > 0 /* Scan duplicate filter */ struct dup { - u8_t mask; - bt_addr_le_t addr; + u8_t mask; + bt_addr_le_t addr; }; static struct dup dup_filter[CONFIG_BLUETOOTH_CONTROLLER_DUP_FILTER_LEN]; static s32_t dup_count; @@ -1003,7 +1003,7 @@ static void le_advertising_report(struct pdu_data *pdu_data, u8_t *b, struct net_buf *buf) { const u8_t c_adv_type[] = { 0x00, 0x01, 0x03, 0xff, 0x04, - 0xff, 0x02 }; + 0xff, 0x02 }; struct bt_hci_ev_le_advertising_report *sep; struct pdu_adv *adv = (struct pdu_adv *)pdu_data; struct bt_hci_ev_le_advertising_info *adv_info; @@ -1275,7 +1275,7 @@ static void encode_control(struct radio_pdu_node_rx *node_rx, } static void le_ltk_request(struct pdu_data *pdu_data, u16_t handle, - struct net_buf *buf) + struct net_buf *buf) { struct bt_hci_evt_le_ltk_request *sep; diff --git a/subsys/bluetooth/controller/include/ll.h b/subsys/bluetooth/controller/include/ll.h index 6d7e3e932da..b1bf0584dc3 100644 --- a/subsys/bluetooth/controller/include/ll.h +++ b/subsys/bluetooth/controller/include/ll.h @@ -29,20 +29,20 @@ u32_t ll_filter_remove(u8_t addr_type, u8_t *addr); void ll_irk_clear(void); u32_t ll_irk_add(u8_t *irk); u32_t ll_create_connection(u16_t scan_interval, u16_t scan_window, - u8_t filter_policy, u8_t peer_addr_type, - u8_t *p_peer_addr, u8_t own_addr_type, - u16_t interval, u16_t latency, - u16_t timeout); + u8_t filter_policy, u8_t peer_addr_type, + u8_t *p_peer_addr, u8_t own_addr_type, + u16_t interval, u16_t latency, + u16_t timeout); u32_t ll_connect_disable(void); u32_t ll_conn_update(u16_t handle, u8_t cmd, u8_t status, - u16_t interval, u16_t latency, - u16_t timeout); + u16_t interval, u16_t latency, + u16_t timeout); u32_t ll_chm_update(u8_t *chm); u32_t ll_chm_get(u16_t handle, u8_t *chm); u32_t ll_enc_req_send(u16_t handle, u8_t *rand, u8_t *ediv, - u8_t *ltk); + u8_t *ltk); u32_t ll_start_enc_req_send(u16_t handle, u8_t err_code, - u8_t const *const ltk); + u8_t const *const ltk); u32_t ll_feature_req_send(u16_t handle); u32_t ll_version_ind_send(u16_t handle); u32_t ll_terminate_ind_send(u16_t handle, u8_t reason); @@ -52,7 +52,7 @@ u32_t ll_length_req_send(u16_t handle, u16_t tx_octets); void ll_length_default_get(u16_t *max_tx_octets, u16_t *max_tx_time); u32_t ll_length_default_set(u16_t max_tx_octets, u16_t max_tx_time); void ll_length_max_get(u16_t *max_tx_octets, u16_t *max_tx_time, - u16_t *max_rx_octets, u16_t *max_rx_time); + u16_t *max_rx_octets, u16_t *max_rx_time); #endif /* CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH */ #endif /* _LL_H_ */ diff --git a/subsys/bluetooth/controller/ll_sw/ctrl.c b/subsys/bluetooth/controller/ll_sw/ctrl.c index e622360b2df..8770dbade8e 100644 --- a/subsys/bluetooth/controller/ll_sw/ctrl.c +++ b/subsys/bluetooth/controller/ll_sw/ctrl.c @@ -97,20 +97,20 @@ struct advertiser { struct observer { struct shdr hdr; - u8_t scan_type:1; - u8_t scan_state:1; - u8_t scan_chan:2; - u8_t filter_policy:2; - u8_t adv_addr_type:1; - u8_t init_addr_type:1; + u8_t scan_type:1; + u8_t scan_state:1; + u8_t scan_chan:2; + u8_t filter_policy:2; + u8_t adv_addr_type:1; + u8_t init_addr_type:1; - u8_t adv_addr[BDADDR_SIZE]; - u8_t init_addr[BDADDR_SIZE]; + u8_t adv_addr[BDADDR_SIZE]; + u8_t init_addr[BDADDR_SIZE]; u32_t ticks_window; - u8_t filter_enable_bitmask; - u8_t filter_addr_type_bitmask; - u8_t filter_bdaddr[8][BDADDR_SIZE]; + u8_t filter_enable_bitmask; + u8_t filter_addr_type_bitmask; + u8_t filter_bdaddr[8][BDADDR_SIZE]; u16_t conn_interval; u16_t conn_latency; @@ -127,34 +127,34 @@ static struct { u32_t ticks_anchor; u32_t remainder_anchor; - u8_t volatile ticker_id_prepare; - u8_t volatile ticker_id_event; - u8_t volatile ticker_id_stop; + u8_t volatile ticker_id_prepare; + u8_t volatile ticker_id_event; + u8_t volatile ticker_id_stop; - enum role volatile role; - enum state state; + enum role volatile role; + enum state state; - u8_t filter_enable_bitmask; - u8_t filter_addr_type_bitmask; - u8_t filter_bdaddr[8][BDADDR_SIZE]; + u8_t filter_enable_bitmask; + u8_t filter_addr_type_bitmask; + u8_t filter_bdaddr[8][BDADDR_SIZE]; - u8_t nirk; - u8_t irk[RADIO_IRK_COUNT_MAX][16]; + u8_t nirk; + u8_t irk[RADIO_IRK_COUNT_MAX][16]; struct advertiser advertiser; struct observer observer; - void *conn_pool; - void *conn_free; - u8_t connection_count; + void *conn_pool; + void *conn_free; + u8_t connection_count; struct connection *conn_curr; - u8_t packet_counter; - u8_t crc_expire; + u8_t packet_counter; + u8_t crc_expire; - u8_t data_chan_map[5]; - u8_t data_chan_count; - u8_t sca; + u8_t data_chan_map[5]; + u8_t data_chan_count; + u8_t sca; #if defined(CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH) /* DLE global settings */ @@ -166,46 +166,46 @@ static struct { * Rx-es. */ /* Advertiser, Observer, and Connections Rx data pool */ - void *pkt_rx_data_pool; - void *pkt_rx_data_free; + void *pkt_rx_data_pool; + void *pkt_rx_data_free; u16_t packet_data_octets_max; u16_t packet_rx_data_pool_size; u16_t packet_rx_data_size; - u8_t packet_rx_data_count; + u8_t packet_rx_data_count; /* Free queue Rx data buffers */ struct radio_pdu_node_rx **packet_rx; - u8_t packet_rx_count; - u8_t volatile packet_rx_last; - u8_t packet_rx_acquire; + u8_t packet_rx_count; + u8_t volatile packet_rx_last; + u8_t packet_rx_acquire; /* Controller to Host event-cum-data queue */ - void *link_rx_pool; - void *link_rx_free; - void *link_rx_head; + void *link_rx_pool; + void *link_rx_free; + void *link_rx_head; - void *volatile link_rx_tail; - u8_t link_rx_data_quota; + void *volatile link_rx_tail; + u8_t link_rx_data_quota; /* Connections common Tx ctrl and data pool */ - void *pkt_tx_ctrl_pool; - void *pkt_tx_ctrl_free; - void *pkt_tx_data_pool; - void *pkt_tx_data_free; + void *pkt_tx_ctrl_pool; + void *pkt_tx_ctrl_free; + void *pkt_tx_data_pool; + void *pkt_tx_data_free; u16_t packet_tx_data_size; /* Host to Controller Tx, and Controller to Host Num complete queue */ struct pdu_data_q_tx *pkt_tx; struct pdu_data_q_tx *pkt_release; - u8_t packet_tx_count; - u8_t volatile packet_tx_first; - u8_t packet_tx_last; - u8_t packet_release_first; - u8_t volatile packet_release_last; + u8_t packet_tx_count; + u8_t volatile packet_tx_first; + u8_t packet_tx_last; + u8_t packet_release_first; + u8_t volatile packet_release_last; u16_t fc_handle[TRIPLE_BUFFER_SIZE]; - u8_t volatile fc_req; - u8_t fc_ack; - u8_t fc_ena; + u8_t volatile fc_req; + u8_t fc_ack; + u8_t fc_ena; u32_t ticks_active_to_start; @@ -229,24 +229,22 @@ static void chan_sel_2_ut(void); #endif /* CONFIG_BLUETOOTH_CONTROLLER_CHAN_SEL_2 */ static void adv_setup(void); -static void event_adv(u32_t ticks_at_expire, u32_t remainder, - u16_t lazy, void *context); -static void event_obs(u32_t ticks_at_expire, u32_t remainder, - u16_t lazy, void *context); -static void event_slave_prepare(u32_t ticks_at_expire, - u32_t remainder, u16_t lazy, - void *context); -static void event_slave(u32_t ticks_at_expire, u32_t remainder, - u16_t lazy, void *context); -static void event_master_prepare(u32_t ticks_at_expire, - u32_t remainder, u16_t lazy, - void *context); -static void event_master(u32_t ticks_at_expire, u32_t remainder, - u16_t lazy, void *context); +static void event_adv(u32_t ticks_at_expire, u32_t remainder, u16_t lazy, + void *context); +static void event_obs(u32_t ticks_at_expire, u32_t remainder, u16_t lazy, + void *context); +static void event_slave_prepare(u32_t ticks_at_expire, u32_t remainder, + u16_t lazy, void *context); +static void event_slave(u32_t ticks_at_expire, u32_t remainder, u16_t lazy, + void *context); +static void event_master_prepare(u32_t ticks_at_expire, u32_t remainder, + u16_t lazy, void *context); +static void event_master(u32_t ticks_at_expire, u32_t remainder, u16_t lazy, + void *context); static void rx_packet_set(struct connection *conn, struct pdu_data *pdu_data_rx); static void tx_packet_set(struct connection *conn, - struct pdu_data *pdu_data_tx); + struct pdu_data *pdu_data_tx); static void prepare_pdu_data_tx(struct connection *conn, struct pdu_data **pdu_data_tx); static void packet_rx_allocate(u8_t max); @@ -264,12 +262,11 @@ static void ctrl_tx_enqueue(struct connection *conn, static void pdu_node_tx_release(u16_t handle, struct radio_pdu_node_tx *node_tx); static void connection_release(struct connection *conn); -static u32_t conn_update(struct connection *conn, - struct pdu_data *pdu_data_rx); +static u32_t conn_update(struct connection *conn, struct pdu_data *pdu_data_rx); static u32_t is_peer_compatible(struct connection *conn); static u32_t conn_update_req(struct connection *conn); static u32_t chan_map_update(struct connection *conn, - struct pdu_data *pdu_data_rx); + struct pdu_data *pdu_data_rx); static void enc_req_reused_send(struct connection *conn, struct radio_pdu_node_tx *node_tx); static void terminate_ind_rx_enqueue(struct connection *conn, u8_t reason); @@ -285,28 +282,25 @@ static void version_ind_send(struct connection *conn); static void ping_resp_send(struct connection *conn); #endif /* CONFIG_BLUETOOTH_CONTROLLER_LE_PING */ -static void reject_ind_ext_send(struct connection *conn, - u8_t reject_opcode, +static void reject_ind_ext_send(struct connection *conn, u8_t reject_opcode, u8_t error_code); #if defined(CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH) -static void length_resp_send(struct connection *conn, - u16_t eff_rx_octets, - u16_t eff_tx_octets); +static void length_resp_send(struct connection *conn, u16_t eff_rx_octets, + u16_t eff_tx_octets); #endif /* CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH */ -static u32_t role_disable(u8_t ticker_id_primary, - u8_t ticker_id_stop); +static u32_t role_disable(u8_t ticker_id_primary, u8_t ticker_id_stop); static void rx_fc_lock(u16_t handle); /***************************************************************************** *RADIO ****************************************************************************/ u32_t radio_init(void *hf_clock, u8_t sca, u8_t connection_count_max, - u8_t rx_count_max, u8_t tx_count_max, - u16_t packet_data_octets_max, - u16_t packet_tx_data_size, u8_t *mem_radio, - u16_t mem_size) + u8_t rx_count_max, u8_t tx_count_max, + u16_t packet_data_octets_max, + u16_t packet_tx_data_size, u8_t *mem_radio, + u16_t mem_size) { u32_t retcode; u8_t *mem_radio_end; @@ -583,7 +577,7 @@ static inline void isr_radio_state_tx(void) } static inline u32_t isr_rx_adv(u8_t devmatch_ok, u8_t irkmatch_ok, - u8_t irkmatch_id, u8_t rssi_ready) + u8_t irkmatch_id, u8_t rssi_ready) { struct pdu_adv *pdu_adv, *_pdu_adv; struct radio_pdu_node_rx *radio_pdu_node_rx; @@ -1173,7 +1167,7 @@ static inline u32_t isr_rx_obs(u8_t irkmatch_id, u8_t rssi_ready) } static inline u8_t isr_rx_conn_pkt_ack(struct pdu_data *pdu_data_tx, - struct radio_pdu_node_tx **node_tx) + struct radio_pdu_node_tx **node_tx) { u8_t terminate = 0; @@ -1394,7 +1388,7 @@ isr_rx_conn_pkt_ctrl_rej(struct radio_pdu_node_rx *radio_pdu_node_rx, #if defined(CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH) static inline u8_t isr_rx_conn_pkt_ctrl_dle(struct pdu_data *pdu_data_rx, - u8_t *rx_enqueue) + u8_t *rx_enqueue) { u16_t eff_rx_octets; u16_t eff_tx_octets; @@ -2433,8 +2427,7 @@ static inline u32_t isr_close_adv(void) radio_filter_disable(); - pdu_adv = - (struct pdu_adv *) + pdu_adv = (struct pdu_adv *) &_radio.advertiser.adv_data.data[_radio.advertiser.adv_data.first][0]; if ((_radio.state == STATE_CLOSE) && (pdu_adv->type != PDU_ADV_TYPE_DIRECT_IND)) { @@ -3101,7 +3094,7 @@ static void mayfly_xtal_start(void *params) } static void event_xtal(u32_t ticks_at_expire, u32_t remainder, - u16_t lazy, void *context) + u16_t lazy, void *context) { static void *s_link[2]; static struct mayfly s_mfy_xtal_start = {0, 0, s_link, NULL, @@ -3210,9 +3203,8 @@ static void prepare_normal(u32_t status, void *op_context) } } -static void prepare_normal_set(struct shdr *hdr, - u8_t ticker_user_id, - u8_t ticker_id) +static void prepare_normal_set(struct shdr *hdr, u8_t ticker_user_id, + u8_t ticker_id) { if (hdr->ticks_xtal_to_start & ((u32_t)1 << 31)) { u32_t ticker_status; @@ -3237,7 +3229,7 @@ static void prepare_normal_set(struct shdr *hdr, #if (RADIO_TICKER_PREEMPT_PART_US <= RADIO_TICKER_PREEMPT_PART_MIN_US) static u32_t preempt_calc(struct shdr *hdr, u8_t ticker_id, - u32_t ticks_at_expire) + u32_t ticks_at_expire) { u32_t diff = ticker_ticks_diff_get(ticker_ticks_now_get(), ticks_at_expire); @@ -3581,11 +3573,11 @@ static void mayfly_sched_win_offset_use(void *params) } static void sched_free_win_offset_calc(struct connection *conn_curr, - u8_t is_select, - u32_t *ticks_to_offset_next, - u16_t conn_interval, - u8_t *offset_max, - u8_t *win_offset) + u8_t is_select, + u32_t *ticks_to_offset_next, + u16_t conn_interval, + u8_t *offset_max, + u8_t *win_offset) { u32_t ticks_prepare_reduced = 0; u32_t ticks_anchor; @@ -4082,9 +4074,8 @@ static u8_t chan_sel_remap(u8_t *chan_map, u8_t chan_index) return chan_next; } -static u8_t chan_sel_1(u8_t *chan_use, u8_t hop, - u16_t latency, u8_t *chan_map, - u8_t chan_count) +static u8_t chan_sel_1(u8_t *chan_use, u8_t hop, u16_t latency, u8_t *chan_map, + u8_t chan_count) { u8_t chan_next; @@ -4147,8 +4138,8 @@ static u16_t chan_prn(u16_t counter, u16_t chan_id) return prn_e; } -static u8_t chan_sel_2(u16_t counter, u16_t chan_id, - u8_t *chan_map, u8_t chan_count) +static u8_t chan_sel_2(u16_t counter, u16_t chan_id, u8_t *chan_map, + u8_t chan_count) { u8_t chan_next; u16_t prn_e; @@ -4443,8 +4434,8 @@ static void event_adv(u32_t ticks_at_expire, u32_t remainder, DEBUG_RADIO_START_A(0); } -void event_adv_stop(u32_t ticks_at_expire, u32_t remainder, - u16_t lazy, void *context) +void event_adv_stop(u32_t ticks_at_expire, u32_t remainder, u16_t lazy, + void *context) { u32_t ticker_status; struct radio_pdu_node_rx *radio_pdu_node_rx; @@ -4553,8 +4544,8 @@ static void event_obs_prepare(u32_t ticks_at_expire, u32_t remainder, DEBUG_RADIO_PREPARE_O(0); } -static void event_obs(u32_t ticks_at_expire, u32_t remainder, - u16_t lazy, void *context) +static void event_obs(u32_t ticks_at_expire, u32_t remainder, u16_t lazy, + void *context) { u32_t ticker_status; @@ -4836,8 +4827,8 @@ static inline void event_conn_update_st_rsp(struct connection *conn, } static inline u32_t event_conn_update_prep(struct connection *conn, - u16_t event_counter, - u32_t ticks_at_expire) + u16_t event_counter, + u32_t ticks_at_expire) { struct connection *conn_upd; u16_t instant_latency; @@ -5843,8 +5834,8 @@ static void event_slave_prepare(u32_t ticks_at_expire, u32_t remainder, DEBUG_RADIO_PREPARE_S(0); } -static void event_slave(u32_t ticks_at_expire, u32_t remainder, - u16_t lazy, void *context) +static void event_slave(u32_t ticks_at_expire, u32_t remainder, u16_t lazy, + void *context) { u8_t data_chan_use = 0; struct connection *conn; @@ -5973,8 +5964,8 @@ static void event_master_prepare(u32_t ticks_at_expire, u32_t remainder, DEBUG_RADIO_PREPARE_M(0); } -static void event_master(u32_t ticks_at_expire, u32_t remainder, - u16_t lazy, void *context) +static void event_master(u32_t ticks_at_expire, u32_t remainder, u16_t lazy, + void *context) { u8_t data_chan_use = 0; struct pdu_data *pdu_data_tx; @@ -6132,8 +6123,7 @@ static void rx_packet_set(struct connection *conn, struct pdu_data *pdu_data_rx) } } -static void tx_packet_set(struct connection *conn, - struct pdu_data *pdu_data_tx) +static void tx_packet_set(struct connection *conn, struct pdu_data *pdu_data_tx) { u8_t phy; u16_t max_tx_octets; @@ -6658,8 +6648,7 @@ static void terminate_ind_rx_enqueue(struct connection *conn, u8_t reason) packet_rx_callback(); } -static u32_t conn_update(struct connection *conn, - struct pdu_data *pdu_data_rx) +static u32_t conn_update(struct connection *conn, struct pdu_data *pdu_data_rx) { if (((pdu_data_rx->payload.llctrl.ctrldata.conn_update_ind.instant - conn->event_counter) & 0xFFFF) > 0x7FFF) { @@ -6740,7 +6729,7 @@ static u32_t conn_update_req(struct connection *conn) } static u32_t chan_map_update(struct connection *conn, - struct pdu_data *pdu_data_rx) + struct pdu_data *pdu_data_rx) { if (((pdu_data_rx->payload.llctrl.ctrldata.chan_map_ind.instant - conn->event_counter) & 0xffff) > 0x7fff) { @@ -7236,8 +7225,7 @@ static inline void role_active_disable(u8_t ticker_id_stop, } } -static u32_t role_disable(u8_t ticker_id_primary, - u8_t ticker_id_stop) +static u32_t role_disable(u8_t ticker_id_primary, u8_t ticker_id_stop) { u32_t volatile ret_cb = TICKER_STATUS_BUSY; u32_t ticks_active_to_start = 0; @@ -7324,8 +7312,7 @@ role_disable_cleanup: return ret_cb; } -u32_t radio_adv_enable(u16_t interval, u8_t chl_map, - u8_t filter_policy) +u32_t radio_adv_enable(u16_t interval, u8_t chl_map, u8_t filter_policy) { u32_t volatile ret_cb = TICKER_STATUS_BUSY; u32_t ticks_slot_offset; @@ -7543,9 +7530,8 @@ u32_t radio_adv_disable(void) return status; } -u32_t radio_scan_enable(u8_t scan_type, u8_t init_addr_type, - u8_t *init_addr, u16_t interval, - u16_t window, u8_t filter_policy) +u32_t radio_scan_enable(u8_t scan_type, u8_t init_addr_type, u8_t *init_addr, + u16_t interval, u16_t window, u8_t filter_policy) { u32_t volatile ret_cb = TICKER_STATUS_BUSY; u32_t ticks_slot_offset; @@ -7652,9 +7638,8 @@ u32_t radio_scan_disable(void) return status; } -u32_t radio_connect_enable(u8_t adv_addr_type, u8_t *adv_addr, - u16_t interval, u16_t latency, - u16_t timeout) +u32_t radio_connect_enable(u8_t adv_addr_type, u8_t *adv_addr, u16_t interval, + u16_t latency, u16_t timeout) { void *link; struct connection *conn; @@ -7791,9 +7776,8 @@ u32_t ll_connect_disable(void) return status; } -u32_t ll_conn_update(u16_t handle, u8_t cmd, u8_t status, - u16_t interval, u16_t latency, - u16_t timeout) +u32_t ll_conn_update(u16_t handle, u8_t cmd, u8_t status, u16_t interval, + u16_t latency, u16_t timeout) { struct connection *conn; @@ -7878,8 +7862,7 @@ u32_t ll_chm_get(u16_t handle, u8_t *chm) return 0; } -u32_t ll_enc_req_send(u16_t handle, u8_t *rand, u8_t *ediv, - u8_t *ltk) +u32_t ll_enc_req_send(u16_t handle, u8_t *rand, u8_t *ediv, u8_t *ltk) { struct connection *conn; struct radio_pdu_node_tx *node_tx; @@ -7954,7 +7937,7 @@ u32_t ll_enc_req_send(u16_t handle, u8_t *rand, u8_t *ediv, } u32_t ll_start_enc_req_send(u16_t handle, u8_t error_code, - u8_t const *const ltk) + u8_t const *const ltk) { struct connection *conn; @@ -8148,8 +8131,7 @@ static u8_t tx_cmplt_get(u16_t *handle, u8_t *first, u8_t last) return cmplt; } -u8_t radio_rx_get(struct radio_pdu_node_rx **radio_pdu_node_rx, - u16_t *handle) +u8_t radio_rx_get(struct radio_pdu_node_rx **radio_pdu_node_rx, u16_t *handle) { u8_t cmplt; @@ -8316,8 +8298,7 @@ static void rx_fc_lock(u16_t handle) } } -u8_t do_radio_rx_fc_set(u16_t handle, u8_t req, - u8_t ack) +u8_t do_radio_rx_fc_set(u16_t handle, u8_t req, u8_t ack) { if (req == ack) { if (_radio.link_rx_head == _radio.link_rx_tail) { @@ -8397,8 +8378,7 @@ void radio_tx_mem_release(struct radio_pdu_node_tx *node_tx) mem_release(node_tx, &_radio.pkt_tx_data_free); } -static void ticker_op_latency_cancelled(u32_t ticker_status, - void *params) +static void ticker_op_latency_cancelled(u32_t ticker_status, void *params) { struct connection *conn; @@ -8408,8 +8388,7 @@ static void ticker_op_latency_cancelled(u32_t ticker_status, conn->role.slave.latency_cancel = 0; } -u32_t radio_tx_mem_enqueue(u16_t handle, - struct radio_pdu_node_tx *node_tx) +u32_t radio_tx_mem_enqueue(u16_t handle, struct radio_pdu_node_tx *node_tx) { u8_t last; struct connection *conn; diff --git a/subsys/bluetooth/controller/ll_sw/ctrl.h b/subsys/bluetooth/controller/ll_sw/ctrl.h index c8080b3e0b0..c6fdb374285 100644 --- a/subsys/bluetooth/controller/ll_sw/ctrl.h +++ b/subsys/bluetooth/controller/ll_sw/ctrl.h @@ -224,21 +224,21 @@ enum radio_pdu_node_rx_type { }; struct radio_le_conn_cmplt { - u8_t status; - u8_t role; - u8_t peer_addr_type; - u8_t peer_addr[BDADDR_SIZE]; - u8_t own_addr_type; - u8_t own_addr[BDADDR_SIZE]; - u8_t peer_irk_index; + u8_t status; + u8_t role; + u8_t peer_addr_type; + u8_t peer_addr[BDADDR_SIZE]; + u8_t own_addr_type; + u8_t own_addr[BDADDR_SIZE]; + u8_t peer_irk_index; u16_t interval; u16_t latency; u16_t timeout; - u8_t mca; + u8_t mca; } __packed; struct radio_le_conn_update_cmplt { - u8_t status; + u8_t status; u16_t interval; u16_t latency; u16_t timeout; @@ -261,7 +261,7 @@ struct radio_pdu_node_rx_hdr { struct radio_pdu_node_rx { struct radio_pdu_node_rx_hdr hdr; - u8_t pdu_data[1]; + u8_t pdu_data[1]; }; /***************************************************************************** @@ -269,27 +269,27 @@ struct radio_pdu_node_rx { ****************************************************************************/ /* Downstream */ u32_t radio_init(void *hf_clock, u8_t sca, u8_t connection_count_max, - u8_t rx_count_max, u8_t tx_count_max, - u16_t packet_data_octets_max, - u16_t packet_tx_data_size, u8_t *mem_radio, - u16_t mem_size); + u8_t rx_count_max, u8_t tx_count_max, + u16_t packet_data_octets_max, + u16_t packet_tx_data_size, u8_t *mem_radio, + u16_t mem_size); void radio_ticks_active_to_start_set(u32_t ticks_active_to_start); struct radio_adv_data *radio_adv_data_get(void); struct radio_adv_data *radio_scan_data_get(void); u32_t radio_adv_enable(u16_t interval, u8_t chl_map, - u8_t filter_policy); + u8_t filter_policy); u32_t radio_adv_disable(void); u32_t radio_scan_enable(u8_t scan_type, u8_t init_addr_type, - u8_t *init_addr, u16_t interval, - u16_t window, u8_t filter_policy); + u8_t *init_addr, u16_t interval, + u16_t window, u8_t filter_policy); u32_t radio_scan_disable(void); u32_t radio_connect_enable(u8_t adv_addr_type, u8_t *adv_addr, - u16_t interval, u16_t latency, - u16_t timeout); + u16_t interval, u16_t latency, + u16_t timeout); /* Upstream */ u8_t radio_rx_get(struct radio_pdu_node_rx **radio_pdu_node_rx, - u16_t *handle); + u16_t *handle); void radio_rx_dequeue(void); void radio_rx_mem_release(struct radio_pdu_node_rx **radio_pdu_node_rx); u8_t radio_rx_fc_set(u16_t handle, u8_t fc); @@ -297,7 +297,7 @@ u8_t radio_rx_fc_get(u16_t *handle); struct radio_pdu_node_tx *radio_tx_mem_acquire(void); void radio_tx_mem_release(struct radio_pdu_node_tx *pdu_data_node_tx); u32_t radio_tx_mem_enqueue(u16_t handle, - struct radio_pdu_node_tx *pdu_data_node_tx); + struct radio_pdu_node_tx *pdu_data_node_tx); /* Callbacks */ extern void radio_active_callback(u8_t active); extern void radio_event_callback(void); diff --git a/subsys/bluetooth/controller/ll_sw/ctrl_internal.h b/subsys/bluetooth/controller/ll_sw/ctrl_internal.h index 613154d73ea..838c2f35edb 100644 --- a/subsys/bluetooth/controller/ll_sw/ctrl_internal.h +++ b/subsys/bluetooth/controller/ll_sw/ctrl_internal.h @@ -30,13 +30,13 @@ struct shdr { struct connection { struct shdr hdr; - u8_t access_addr[4]; - u8_t crc_init[3]; - u8_t data_chan_map[5]; + u8_t access_addr[4]; + u8_t crc_init[3]; + u8_t data_chan_map[5]; - u8_t data_chan_count:6; - u8_t data_chan_sel:1; - u8_t rfu:1; + u8_t data_chan_count:6; + u8_t data_chan_sel:1; + u8_t rfu:1; union { struct { @@ -74,13 +74,13 @@ struct connection { union { struct { - u8_t role:1; - u8_t connect_expire; + u8_t role:1; + u8_t connect_expire; } master; struct { - u8_t role:1; - u8_t sca:3; - u8_t latency_cancel:1; + u8_t role:1; + u8_t sca:3; + u8_t latency_cancel:1; u32_t window_widening_periodic_us; u32_t window_widening_max_us; u32_t window_widening_prepare_us; @@ -92,15 +92,15 @@ struct connection { } slave; } role; - u8_t llcp_req; - u8_t llcp_ack; - enum llcp llcp_type; + u8_t llcp_req; + u8_t llcp_ack; + enum llcp llcp_type; union { struct { u16_t interval; u16_t latency; u16_t timeout; - u8_t preferred_periodicity; + u8_t preferred_periodicity; u16_t instant; u16_t offset0; u16_t offset1; @@ -112,8 +112,8 @@ struct connection { u32_t ticks_to_offset_next; u32_t win_offset_us; u16_t *pdu_win_offset; - u8_t win_size; - u8_t state:3; + u8_t win_size; + u8_t state:3; #define LLCP_CONN_STATE_INPROG 0 /* master + slave proc in progress * until instant */ @@ -124,37 +124,37 @@ struct connection { #define LLCP_CONN_STATE_RSP_WAIT 5 /* master rsp or slave conn_update * or rej */ - u8_t is_internal:2; + u8_t is_internal:2; } connection_update; struct { - u8_t initiate; - u8_t chm[5]; + u8_t initiate; + u8_t chm[5]; u16_t instant; } chan_map; struct { - u8_t error_code; - u8_t rand[8]; - u8_t ediv[2]; - u8_t ltk[16]; - u8_t skd[16]; + u8_t error_code; + u8_t rand[8]; + u8_t ediv[2]; + u8_t ltk[16]; + u8_t skd[16]; } encryption; } llcp; u32_t llcp_features; struct { - u8_t tx:1; - u8_t rx:1; - u8_t version_number; + u8_t tx:1; + u8_t rx:1; + u8_t version_number; u16_t company_id; u16_t sub_version_number; } llcp_version; struct { - u8_t req; - u8_t ack; - u8_t reason_own; - u8_t reason_peer; + u8_t req; + u8_t ack; + u8_t reason_own; + u8_t reason_peer; struct { struct radio_pdu_node_rx_hdr hdr; u8_t reason; @@ -163,9 +163,9 @@ struct connection { #if defined(CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH) struct { - u8_t req; - u8_t ack; - u8_t state:2; + u8_t req; + u8_t ack; + u8_t state:2; #define LLCP_LENGTH_STATE_REQ 0 #define LLCP_LENGTH_STATE_ACK_WAIT 1 #define LLCP_LENGTH_STATE_RSP_WAIT 2 @@ -175,14 +175,14 @@ struct connection { } llcp_length; #endif /* CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH */ - u8_t sn:1; - u8_t nesn:1; - u8_t pause_rx:1; - u8_t pause_tx:1; - u8_t enc_rx:1; - u8_t enc_tx:1; - u8_t refresh:1; - u8_t empty:1; + u8_t sn:1; + u8_t nesn:1; + u8_t pause_rx:1; + u8_t pause_tx:1; + u8_t enc_rx:1; + u8_t enc_tx:1; + u8_t refresh:1; + u8_t empty:1; struct ccm ccm_rx; struct ccm ccm_tx; @@ -191,19 +191,19 @@ struct connection { struct radio_pdu_node_tx *pkt_tx_ctrl; struct radio_pdu_node_tx *pkt_tx_data; struct radio_pdu_node_tx *pkt_tx_last; - u8_t packet_tx_head_len; - u8_t packet_tx_head_offset; + u8_t packet_tx_head_len; + u8_t packet_tx_head_offset; #if defined(CONFIG_BLUETOOTH_CONTROLLER_CONN_RSSI) - u8_t rssi_latest; - u8_t rssi_reported; - u8_t rssi_sample_count; + u8_t rssi_latest; + u8_t rssi_reported; + u8_t rssi_sample_count; #endif /* CONFIG_BLUETOOTH_CONTROLLER_CONN_RSSI */ }; #define CONNECTION_T_SIZE MROUND(sizeof(struct connection)) struct pdu_data_q_tx { - u16_t handle; + u16_t handle; struct radio_pdu_node_tx *node_tx; }; diff --git a/subsys/bluetooth/controller/ll_sw/ll.c b/subsys/bluetooth/controller/ll_sw/ll.c index a06bc947e37..085ec17ffa1 100644 --- a/subsys/bluetooth/controller/ll_sw/ll.c +++ b/subsys/bluetooth/controller/ll_sw/ll.c @@ -54,21 +54,21 @@ static struct { static struct { u16_t interval; - u8_t adv_type:4; - u8_t tx_addr:1; - u8_t rx_addr:1; - u8_t filter_policy:2; - u8_t chl_map:3; - u8_t adv_addr[BDADDR_SIZE]; - u8_t direct_addr[BDADDR_SIZE]; + u8_t adv_type:4; + u8_t tx_addr:1; + u8_t rx_addr:1; + u8_t filter_policy:2; + u8_t chl_map:3; + u8_t adv_addr[BDADDR_SIZE]; + u8_t direct_addr[BDADDR_SIZE]; } _ll_adv_params; static struct { u16_t interval; u16_t window; - u8_t scan_type:1; - u8_t tx_addr:1; - u8_t filter_policy:1; + u8_t scan_type:1; + u8_t tx_addr:1; + u8_t filter_policy:1; } _ll_scan_params; void mayfly_enable_cb(u8_t caller_id, u8_t callee_id, u8_t enable) @@ -405,8 +405,8 @@ void ll_scan_data_set(u8_t len, u8_t const *const data) pdu->tx_addr = _ll_adv_params.tx_addr; pdu->rx_addr = 0; pdu->len = BDADDR_SIZE + len; - memcpy(&pdu->payload.scan_rsp.addr[0], - &_ll_adv_params.adv_addr[0], BDADDR_SIZE); + memcpy(&pdu->payload.scan_rsp.addr[0], &_ll_adv_params.adv_addr[0], + BDADDR_SIZE); memcpy(&pdu->payload.scan_rsp.data[0], data, len); pdu->resv = 0; @@ -440,23 +440,23 @@ u32_t ll_adv_enable(u8_t enable) [radio_scan_data->last][0]; if (_ll_adv_params.tx_addr) { memcpy(&_ll_adv_params.adv_addr[0], - &_ll_context.rnd_addr[0], BDADDR_SIZE); + &_ll_context.rnd_addr[0], BDADDR_SIZE); memcpy(&pdu_adv->payload.adv_ind.addr[0], - &_ll_context.rnd_addr[0], BDADDR_SIZE); + &_ll_context.rnd_addr[0], BDADDR_SIZE); memcpy(&pdu_scan->payload.scan_rsp.addr[0], - &_ll_context.rnd_addr[0], BDADDR_SIZE); + &_ll_context.rnd_addr[0], BDADDR_SIZE); } else { memcpy(&_ll_adv_params.adv_addr[0], - &_ll_context.pub_addr[0], BDADDR_SIZE); + &_ll_context.pub_addr[0], BDADDR_SIZE); memcpy(&pdu_adv->payload.adv_ind.addr[0], - &_ll_context.pub_addr[0], BDADDR_SIZE); + &_ll_context.pub_addr[0], BDADDR_SIZE); memcpy(&pdu_scan->payload.scan_rsp.addr[0], - &_ll_context.pub_addr[0], BDADDR_SIZE); + &_ll_context.pub_addr[0], BDADDR_SIZE); } status = radio_adv_enable(_ll_adv_params.interval, - _ll_adv_params.chl_map, - _ll_adv_params.filter_policy); + _ll_adv_params.chl_map, + _ll_adv_params.filter_policy); } else { status = radio_adv_disable(); } @@ -480,13 +480,13 @@ u32_t ll_scan_enable(u8_t enable) if (enable) { status = radio_scan_enable(_ll_scan_params.scan_type, - _ll_scan_params.tx_addr, - (_ll_scan_params.tx_addr) ? - &_ll_context.rnd_addr[0] : - &_ll_context.pub_addr[0], - _ll_scan_params.interval, - _ll_scan_params.window, - _ll_scan_params.filter_policy); + _ll_scan_params.tx_addr, + (_ll_scan_params.tx_addr) ? + &_ll_context.rnd_addr[0] : + &_ll_context.pub_addr[0], + _ll_scan_params.interval, + _ll_scan_params.window, + _ll_scan_params.filter_policy); } else { status = radio_scan_disable(); } @@ -495,22 +495,22 @@ u32_t ll_scan_enable(u8_t enable) } u32_t ll_create_connection(u16_t scan_interval, u16_t scan_window, - u8_t filter_policy, u8_t peer_addr_type, - u8_t *peer_addr, u8_t own_addr_type, - u16_t interval, u16_t latency, - u16_t timeout) + u8_t filter_policy, u8_t peer_addr_type, + u8_t *peer_addr, u8_t own_addr_type, + u16_t interval, u16_t latency, + u16_t timeout) { u32_t status; status = radio_connect_enable(peer_addr_type, peer_addr, interval, - latency, timeout); + latency, timeout); if (status) { return status; } return radio_scan_enable(0, own_addr_type, (own_addr_type) ? - &_ll_context.rnd_addr[0] : - &_ll_context.pub_addr[0], - scan_interval, scan_window, filter_policy); + &_ll_context.rnd_addr[0] : + &_ll_context.pub_addr[0], + scan_interval, scan_window, filter_policy); } diff --git a/subsys/bluetooth/controller/ll_sw/pdu.h b/subsys/bluetooth/controller/ll_sw/pdu.h index 6fa51ed2e32..86e6eef57bd 100644 --- a/subsys/bluetooth/controller/ll_sw/pdu.h +++ b/subsys/bluetooth/controller/ll_sw/pdu.h @@ -39,16 +39,16 @@ struct pdu_adv_payload_connect_ind { u8_t init_addr[BDADDR_SIZE]; u8_t adv_addr[BDADDR_SIZE]; struct { - u8_t access_addr[4]; - u8_t crc_init[3]; - u8_t win_size; + u8_t access_addr[4]; + u8_t crc_init[3]; + u8_t win_size; u16_t win_offset; u16_t interval; u16_t latency; u16_t timeout; - u8_t chan_map[5]; - u8_t hop:5; - u8_t sca:3; + u8_t chan_map[5]; + u8_t hop:5; + u8_t sca:3; } __packed lldata; } __packed; @@ -127,7 +127,7 @@ enum pdu_data_llctrl_type { }; struct pdu_data_llctrl_conn_update_ind { - u8_t win_size; + u8_t win_size; u16_t win_offset; u16_t interval; u16_t latency; @@ -136,7 +136,7 @@ struct pdu_data_llctrl_conn_update_ind { } __packed; struct pdu_data_llctrl_chan_map_ind { - u8_t chm[5]; + u8_t chm[5]; u16_t instant; } __packed; @@ -169,7 +169,7 @@ struct pdu_data_llctrl_feature_rsp { } __packed; struct pdu_data_llctrl_version_ind { - u8_t version_number; + u8_t version_number; u16_t company_id; u16_t sub_version_number; } __packed; @@ -183,7 +183,7 @@ struct pdu_data_llctrl_conn_param_req { u16_t interval_max; u16_t latency; u16_t timeout; - u8_t preferred_periodicity; + u8_t preferred_periodicity; u16_t reference_conn_event_count; u16_t offset0; u16_t offset1; @@ -198,7 +198,7 @@ struct pdu_data_llctrl_conn_param_rsp { u16_t interval_max; u16_t latency; u16_t timeout; - u8_t preferred_periodicity; + u8_t preferred_periodicity; u16_t reference_conn_event_count; u16_t offset0; u16_t offset1; @@ -226,8 +226,8 @@ struct pdu_data_llctrl_phy_req_rsp { } __packed; struct pdu_data_llctrl_phy_update_ind { - u8_t m_to_s_phy; - u8_t s_to_m_phy; + u8_t m_to_s_phy; + u8_t s_to_m_phy; u16_t instant; } __packed; diff --git a/subsys/bluetooth/controller/ticker/ticker.c b/subsys/bluetooth/controller/ticker/ticker.c index 203be66f3ee..2097b7ed23b 100644 --- a/subsys/bluetooth/controller/ticker/ticker.c +++ b/subsys/bluetooth/controller/ticker/ticker.c @@ -29,15 +29,15 @@ * Types ****************************************************************************/ struct ticker_node { - u8_t next; + u8_t next; - u8_t req; - u8_t ack; - u8_t force; + u8_t req; + u8_t ack; + u8_t force; u32_t ticks_periodic; u32_t ticks_to_expire; ticker_timeout_func timeout_func; - void *context; + void *context; u16_t ticks_to_expire_minus; u16_t ticks_slot; @@ -64,7 +64,7 @@ struct ticker_user_op_start { u16_t lazy; u16_t ticks_slot; ticker_timeout_func fp_timeout_func; - void *context; + void *context; }; struct ticker_user_op_update { @@ -73,11 +73,11 @@ struct ticker_user_op_update { u16_t ticks_slot_plus; u16_t ticks_slot_minus; u16_t lazy; - u8_t force; + u8_t force; }; struct ticker_user_op_slot_get { - u8_t *ticker_id; + u8_t *ticker_id; u32_t *ticks_current; u32_t *ticks_to_expire; }; @@ -92,7 +92,7 @@ struct ticker_user_op { } params; u32_t status; ticker_op_func fp_op_func; - void *op_context; + void *op_context; }; struct ticker_user { @@ -106,20 +106,20 @@ struct ticker_user { struct ticker_instance { struct ticker_node *node; struct ticker_user *user; - u8_t count_node; - u8_t count_user; - u8_t ticks_elapsed_first; - u8_t ticks_elapsed_last; + u8_t count_node; + u8_t count_user; + u8_t ticks_elapsed_first; + u8_t ticks_elapsed_last; u32_t ticks_elapsed[DOUBLE_BUFFER_SIZE]; u32_t ticks_current; - u8_t ticker_id_head; - u8_t ticker_id_slot_previous; + u8_t ticker_id_head; + u8_t ticker_id_slot_previous; u16_t ticks_slot_previous; - u8_t job_guard; - u8_t worker_trigger; - u8_t (*fp_caller_id_get)(u8_t user_id); - void (*fp_sched)(u8_t caller_id, u8_t callee_id, u8_t chain); - void (*fp_cmp_set)(u32_t value); + u8_t job_guard; + u8_t worker_trigger; + u8_t (*fp_caller_id_get)(u8_t user_id); + void (*fp_sched)(u8_t caller_id, u8_t callee_id, u8_t chain); + void (*fp_cmp_set)(u32_t value); }; /***************************************************************************** @@ -130,9 +130,8 @@ static struct ticker_instance _instance[2]; /***************************************************************************** * Static Functions ****************************************************************************/ -static u8_t ticker_by_slot_get(struct ticker_node *node, - u8_t ticker_id_head, - u32_t ticks_slot) +static u8_t ticker_by_slot_get(struct ticker_node *node, u8_t ticker_id_head, + u32_t ticks_slot) { while (ticker_id_head != TICKER_NULL) { struct ticker_node *ticker; @@ -157,9 +156,8 @@ static u8_t ticker_by_slot_get(struct ticker_node *node, } static void ticker_by_next_slot_get(struct ticker_instance *instance, - u8_t *ticker_id_head, - u32_t *ticks_current, - u32_t *ticks_to_expire) + u8_t *ticker_id_head, u32_t *ticks_current, + u32_t *ticks_to_expire) { struct ticker_node *node; u8_t _ticker_id_head; @@ -195,8 +193,7 @@ static void ticker_by_next_slot_get(struct ticker_instance *instance, *ticks_to_expire = _ticks_to_expire; } -static u8_t ticker_enqueue(struct ticker_instance *instance, - u8_t id) +static u8_t ticker_enqueue(struct ticker_instance *instance, u8_t id) { struct ticker_node *node; struct ticker_node *ticker_new; @@ -269,8 +266,7 @@ static u8_t ticker_enqueue(struct ticker_instance *instance, return id; } -static u32_t ticker_dequeue(struct ticker_instance *instance, - u8_t id) +static u32_t ticker_dequeue(struct ticker_instance *instance, u8_t id) { struct ticker_node *ticker_current; struct ticker_node *node; @@ -418,8 +414,7 @@ static inline void ticker_worker(struct ticker_instance *instance) } static void prepare_ticks_to_expire(struct ticker_node *ticker, - u32_t ticks_current, - u32_t ticks_at_start) + u32_t ticks_current, u32_t ticks_at_start) { u32_t ticks_to_expire = ticker->ticks_to_expire; u16_t ticks_to_expire_minus = ticker->ticks_to_expire_minus; @@ -481,10 +476,10 @@ static u8_t ticker_remainder_decrement(struct ticker_node *ticker) } static inline void ticker_job_node_update(struct ticker_node *ticker, - struct ticker_user_op *user_op, - u32_t ticks_current, - u32_t ticks_elapsed, - u8_t *insert_head) + struct ticker_user_op *user_op, + u32_t ticks_current, + u32_t ticks_elapsed, + u8_t *insert_head) { u32_t ticks_now; u32_t ticks_to_expire = ticker->ticks_to_expire; @@ -545,10 +540,9 @@ static inline void ticker_job_node_update(struct ticker_node *ticker, *insert_head = user_op->id; } -static inline u8_t ticker_job_list_manage( - struct ticker_instance *instance, - u32_t ticks_elapsed, - u8_t *insert_head) +static inline u8_t ticker_job_list_manage(struct ticker_instance *instance, + u32_t ticks_elapsed, + u8_t *insert_head) { u8_t pending; struct ticker_node *node; @@ -778,9 +772,8 @@ static inline void ticker_job_worker_bottom_half( } } -static inline void ticker_job_list_insert( - struct ticker_instance *instance, - u8_t insert_head) +static inline void ticker_job_list_insert(struct ticker_instance *instance, + u8_t insert_head) { struct ticker_node *node; struct ticker_user *users; @@ -936,8 +929,7 @@ static inline void ticker_job_list_insert( } } -static inline void ticker_job_list_inquire( - struct ticker_instance *instance) +static inline void ticker_job_list_inquire(struct ticker_instance *instance) { struct ticker_user *users; u8_t count_user; @@ -1002,9 +994,8 @@ static inline void ticker_job_list_inquire( } } -static inline void ticker_job_compare_update( - struct ticker_instance *instance, - u8_t ticker_id_old_head) +static inline void ticker_job_compare_update(struct ticker_instance *instance, + u8_t ticker_id_old_head) { struct ticker_node *ticker; struct ticker_node *node; @@ -1218,8 +1209,7 @@ static u8_t ticker_instance1_caller_id_get(u8_t user_id) return 0; } -static void ticker_instance0_sched(u8_t caller_id, u8_t callee_id, - u8_t chain) +static void ticker_instance0_sched(u8_t caller_id, u8_t callee_id, u8_t chain) { /* return value not checked as we allow multiple calls to schedule * before being actually needing the work to complete before new @@ -1345,8 +1335,7 @@ static void ticker_instance0_sched(u8_t caller_id, u8_t callee_id, } } -static void ticker_instance1_sched(u8_t caller_id, u8_t callee_id, - u8_t chain) +static void ticker_instance1_sched(u8_t caller_id, u8_t callee_id, u8_t chain) { /* return value not checked as we allow multiple calls to schedule * before being actually needing the work to complete before new @@ -1486,8 +1475,7 @@ static void ticker_instance1_cmp_set(u32_t value) * Public Interface ****************************************************************************/ u32_t ticker_init(u8_t instance_index, u8_t count_node, void *node, - u8_t count_user, void *user, u8_t count_op, - void *user_op) + u8_t count_user, void *user, u8_t count_op, void *user_op) { struct ticker_instance *instance = &_instance[instance_index]; struct ticker_user *users; @@ -1559,13 +1547,11 @@ void ticker_trigger(u8_t instance_index) DEBUG_TICKER_ISR(0); } -u32_t ticker_start(u8_t instance_index, u8_t user_id, - u8_t _ticker_id, u32_t ticks_anchor, - u32_t ticks_first, u32_t ticks_periodic, - u32_t remainder_periodic, u16_t lazy, - u16_t ticks_slot, - ticker_timeout_func ticker_timeout_func, void *context, - ticker_op_func fp_op_func, void *op_context) +u32_t ticker_start(u8_t instance_index, u8_t user_id, u8_t _ticker_id, + u32_t ticks_anchor, u32_t ticks_first, u32_t ticks_periodic, + u32_t remainder_periodic, u16_t lazy, u16_t ticks_slot, + ticker_timeout_func ticker_timeout_func, void *context, + ticker_op_func fp_op_func, void *op_context) { u8_t last; struct ticker_instance *instance = &_instance[instance_index]; @@ -1605,11 +1591,10 @@ u32_t ticker_start(u8_t instance_index, u8_t user_id, return user_op->status; } -u32_t ticker_update(u8_t instance_index, u8_t user_id, - u8_t _ticker_id, u16_t ticks_drift_plus, - u16_t ticks_drift_minus, u16_t ticks_slot_plus, - u16_t ticks_slot_minus, u16_t lazy, u8_t force, - ticker_op_func fp_op_func, void *op_context) +u32_t ticker_update(u8_t instance_index, u8_t user_id, u8_t _ticker_id, + u16_t ticks_drift_plus, u16_t ticks_drift_minus, + u16_t ticks_slot_plus, u16_t ticks_slot_minus, u16_t lazy, + u8_t force, ticker_op_func fp_op_func, void *op_context) { struct ticker_instance *instance = &_instance[instance_index]; u8_t last; @@ -1647,9 +1632,8 @@ u32_t ticker_update(u8_t instance_index, u8_t user_id, return user_op->status; } -u32_t ticker_stop(u8_t instance_index, u8_t user_id, - u8_t _ticker_id, ticker_op_func fp_op_func, - void *op_context) +u32_t ticker_stop(u8_t instance_index, u8_t user_id, u8_t _ticker_id, + ticker_op_func fp_op_func, void *op_context) { struct ticker_instance *instance = &_instance[instance_index]; u8_t last; @@ -1681,11 +1665,9 @@ u32_t ticker_stop(u8_t instance_index, u8_t user_id, return user_op->status; } -u32_t ticker_next_slot_get(u8_t instance_index, u8_t user_id, - u8_t *_ticker_id, - u32_t *ticks_current, - u32_t *ticks_to_expire, - ticker_op_func fp_op_func, void *op_context) +u32_t ticker_next_slot_get(u8_t instance_index, u8_t user_id, u8_t *_ticker_id, + u32_t *ticks_current, u32_t *ticks_to_expire, + ticker_op_func fp_op_func, void *op_context) { struct ticker_instance *instance = &_instance[instance_index]; u8_t last; @@ -1721,7 +1703,7 @@ u32_t ticker_next_slot_get(u8_t instance_index, u8_t user_id, } u32_t ticker_job_idle_get(u8_t instance_index, u8_t user_id, - ticker_op_func fp_op_func, void *op_context) + ticker_op_func fp_op_func, void *op_context) { struct ticker_instance *instance = &_instance[instance_index]; u8_t last; diff --git a/subsys/bluetooth/controller/ticker/ticker.h b/subsys/bluetooth/controller/ticker/ticker.h index 299abe73f5f..00d1ccb4b24 100644 --- a/subsys/bluetooth/controller/ticker/ticker.h +++ b/subsys/bluetooth/controller/ticker/ticker.h @@ -76,9 +76,8 @@ /** \brief Timer timeout function type. */ -typedef void (*ticker_timeout_func) (u32_t ticks_at_expire, - u32_t remainder, u16_t lazy, - void *context); +typedef void (*ticker_timeout_func) (u32_t ticks_at_expire, u32_t remainder, + u16_t lazy, void *context); /** \brief Timer operation complete function type. */ @@ -96,31 +95,25 @@ typedef void (*ticker_op_func) (u32_t status, void *op_context); * \param[in] user_op */ u32_t ticker_init(u8_t instance_index, u8_t count_node, void *node, - u8_t count_user, void *user, u8_t count_op, - void *user_op); + u8_t count_user, void *user, u8_t count_op, void *user_op); void ticker_trigger(u8_t instance_index); -u32_t ticker_start(u8_t instance_index, u8_t user_id, - u8_t ticker_id, u32_t ticks_anchor, - u32_t ticks_first, u32_t ticks_periodic, - u32_t remainder_periodic, u16_t lazy, - u16_t ticks_slot, - ticker_timeout_func ticker_timeout_func, void *context, - ticker_op_func fp_op_func, void *op_context); -u32_t ticker_update(u8_t instance_index, u8_t user_id, - u8_t ticker_id, u16_t ticks_drift_plus, - u16_t ticks_drift_minus, u16_t ticks_slot_plus, - u16_t ticks_slot_minus, u16_t lazy, u8_t force, - ticker_op_func fp_op_func, void *op_context); -u32_t ticker_stop(u8_t instance_index, u8_t user_id, - u8_t ticker_id, ticker_op_func fp_op_func, - void *op_context); +u32_t ticker_start(u8_t instance_index, u8_t user_id, u8_t ticker_id, + u32_t ticks_anchor, u32_t ticks_first, u32_t ticks_periodic, + u32_t remainder_periodic, u16_t lazy, u16_t ticks_slot, + ticker_timeout_func ticker_timeout_func, void *context, + ticker_op_func fp_op_func, void *op_context); +u32_t ticker_update(u8_t instance_index, u8_t user_id, u8_t ticker_id, + u16_t ticks_drift_plus, u16_t ticks_drift_minus, + u16_t ticks_slot_plus, u16_t ticks_slot_minus, u16_t lazy, + u8_t force, ticker_op_func fp_op_func, void *op_context); +u32_t ticker_stop(u8_t instance_index, u8_t user_id, u8_t ticker_id, + ticker_op_func fp_op_func, void *op_context); u32_t ticker_next_slot_get(u8_t instance_index, u8_t user_id, - u8_t *ticker_id_head, - u32_t *ticks_current, - u32_t *ticks_to_expire, - ticker_op_func fp_op_func, void *op_context); + u8_t *ticker_id_head, u32_t *ticks_current, + u32_t *ticks_to_expire, + ticker_op_func fp_op_func, void *op_context); u32_t ticker_job_idle_get(u8_t instance_index, u8_t user_id, - ticker_op_func fp_op_func, void *op_context); + ticker_op_func fp_op_func, void *op_context); void ticker_job_sched(u8_t instance_index, u8_t user_id); u32_t ticker_ticks_now_get(void); u32_t ticker_ticks_diff_get(u32_t ticks_now, u32_t ticks_old); diff --git a/subsys/bluetooth/controller/util/mayfly.h b/subsys/bluetooth/controller/util/mayfly.h index 301dee38379..f11bfaefe2f 100644 --- a/subsys/bluetooth/controller/util/mayfly.h +++ b/subsys/bluetooth/controller/util/mayfly.h @@ -26,11 +26,10 @@ struct mayfly { void mayfly_init(void); void mayfly_enable(u8_t caller_id, u8_t callee_id, u8_t enable); u32_t mayfly_enqueue(u8_t caller_id, u8_t callee_id, u8_t chain, - struct mayfly *m); + struct mayfly *m); void mayfly_run(u8_t callee_id); -extern void mayfly_enable_cb(u8_t caller_id, u8_t callee_id, - u8_t enable); +extern void mayfly_enable_cb(u8_t caller_id, u8_t callee_id, u8_t enable); extern u32_t mayfly_is_enabled(u8_t caller_id, u8_t callee_id); extern u32_t mayfly_prio_is_equal(u8_t caller_id, u8_t callee_id); extern void mayfly_pend(u8_t caller_id, u8_t callee_id); diff --git a/subsys/bluetooth/controller/util/mem.c b/subsys/bluetooth/controller/util/mem.c index e62f67d41cf..3b5183733a4 100644 --- a/subsys/bluetooth/controller/util/mem.c +++ b/subsys/bluetooth/controller/util/mem.c @@ -20,8 +20,7 @@ void mem_init(void *mem_pool, u16_t mem_size, u16_t mem_count, /* Store free mem_count after the list's next pointer at an aligned * memory location to ensure atomic read/write (in ARM for now). */ - *((u16_t *)MROUND((u8_t *)mem_pool + sizeof(mem_pool))) = - mem_count; + *((u16_t *)MROUND((u8_t *)mem_pool + sizeof(mem_pool))) = mem_count; /* Initialize next pointers to form a free list, * next pointer is stored in the first 32-bit of each block @@ -32,9 +31,9 @@ void mem_init(void *mem_pool, u16_t mem_size, u16_t mem_count, u32_t next; next = (u32_t)((u8_t *) mem_pool + - (mem_size * (mem_count + 1))); + (mem_size * (mem_count + 1))); memcpy(((u8_t *)mem_pool + (mem_size * mem_count)), - (void *)&next, sizeof(next)); + (void *)&next, sizeof(next)); } } @@ -47,7 +46,7 @@ void *mem_acquire(void **mem_head) /* Get the free count from the list and decrement it */ free_count = *((u16_t *)MROUND((u8_t *)*mem_head + - sizeof(mem_head))); + sizeof(mem_head))); free_count--; mem = *mem_head; @@ -73,7 +72,7 @@ void mem_release(void *mem, void **mem_head) /* Get the free count from the list and increment it */ if (*mem_head) { free_count = *((u16_t *)MROUND((u8_t *)*mem_head + - sizeof(mem_head))); + sizeof(mem_head))); } free_count++; @@ -92,7 +91,7 @@ u16_t mem_free_count_get(void *mem_head) /* Get the free count from the list */ if (mem_head) { free_count = *((u16_t *)MROUND((u8_t *)mem_head + - sizeof(mem_head))); + sizeof(mem_head))); } return free_count; @@ -105,8 +104,7 @@ void *mem_get(void *mem_pool, u16_t mem_size, u16_t index) u16_t mem_index_get(void *mem, void *mem_pool, u16_t mem_size) { - return ((u16_t)((u8_t *)mem - (u8_t *)mem_pool) / - mem_size); + return ((u16_t)((u8_t *)mem - (u8_t *)mem_pool) / mem_size); } void mem_rcopy(u8_t *dst, u8_t const *src, u16_t len) diff --git a/subsys/bluetooth/controller/util/mem.h b/subsys/bluetooth/controller/util/mem.h index 443a26b1e62..f86672a64f7 100644 --- a/subsys/bluetooth/controller/util/mem.h +++ b/subsys/bluetooth/controller/util/mem.h @@ -16,8 +16,7 @@ #define MROUND(x) (((u32_t)(x)+3) & (~((u32_t)3))) #endif -void mem_init(void *mem_pool, u16_t mem_size, u16_t mem_count, - void **mem_head); +void mem_init(void *mem_pool, u16_t mem_size, u16_t mem_count, void **mem_head); void *mem_acquire(void **mem_head); void mem_release(void *mem, void **mem_head);