123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731 |
- #ifndef LL_DEF_H_
- #define LL_DEF_H_
- #include "types.h"
- #include "comdef.h"
- #include "ll_buf.h"
- #include "ll.h"
- #define MAX_NUM_LL_CONN 1
- #define LL_PKT_PREAMBLE_LEN 1
- #define LL_PKT_SYNCH_LEN 4
- #define LL_PKT_LLID_LEN 1
- #define LL_PKT_HDR_LEN 2
- #define LL_PKT_MIC_LEN 4
- #define LL_PKT_CRC_LEN 3
- #define LL_DATA_PDU_HDR_LLID_RESERVED 0
- #define LL_DATA_PDU_HDR_LLID_DATA_PKT_NEXT 1
- #define LL_DATA_PDU_HDR_LLID_DATA_PKT_FIRST 2
- #define LL_DATA_PDU_HDR_LLID_CONTROL_PKT 3
- #define PDU_TYPE_SHIFT 0
- #define PDU_TYPE_MASK 0xf
- #define TX_ADD_SHIFT 6
- #define TX_ADD_MASK 0x40
- #define RX_ADD_SHIFT 7
- #define RX_ADD_MASK 0x80
- #define LENGTH_SHIFT 8
- #define LENGTH_MASK 0x3f00
- #define SET_BITS(p,f,l,m) p=(f<<l) | (p & (~m))
- #define GET_BITS(p,l,m) (p&m)>>l
- #define LL_RX_FLOW_CONTROL_DISABLED 0
- #define LL_RX_FLOW_CONTROL_ENABLED 1
- #define ADV_IND 0
- #define ADV_DIRECT_IND 1
- #define ADV_NONCONN_IND 2
- #define ADV_SCAN_REQ 3
- #define ADV_SCAN_RSP 4
- #define ADV_CONN_REQ 5
- #define ADV_SCAN_IND 6
- #define LL_STATE_IDLE 0x00
- #define LL_STATE_ADV_UNDIRECTED 0x01
- #define LL_STATE_ADV_DIRECTED 0x02
- #define LL_STATE_ADV_SCAN 0x03
- #define LL_STATE_ADV_NONCONN 0x04
- #define LL_STATE_SCAN 0x05
- #define LL_STATE_INIT 0x06
- #define LL_STATE_CONN_SLAVE 0x07
- #define LL_STATE_CONN_MASTER 0x08
- #define LL_STATE_DIRECT_TEST_MODE_TX 0x09
- #define LL_STATE_DIRECT_TEST_MODE_RX 0x0A
- #define LL_STATE_MODEM_TEST_TX 0x0B
- #define LL_STATE_MODEM_TEST_RX 0x0C
- #define LL_STATE_MODEM_TEST_TX_FREQ_HOPPING 0x0D
- #define LL_SEC_STATE_IDLE 0x00
- #define LL_SEC_STATE_SCAN 0x01
- #define LL_SEC_STATE_ADV 0x02
- #define LL_SEC_STATE_SCAN_PENDING 0x03
- #define LL_SEC_STATE_ADV_PENDING 0x04
- #define LL_SEC_STATE_IDLE_PENDING 0x05
- #define LL_CONNECTION_UPDATE_REQ 0
- #define LL_CHANNEL_MAP_REQ 1
- #define LL_TERMINATE_IND 2
- #define LL_ENC_REQ 3
- #define LL_ENC_RSP 4
- #define LL_START_ENC_REQ 5
- #define LL_START_ENC_RSP 6
- #define LL_UNKNOWN_RSP 7
- #define LL_FEATURE_REQ 8
- #define LL_FEATURE_RSP 9
- #define LL_PAUSE_ENC_REQ 10
- #define LL_PAUSE_ENC_RSP 11
- #define LL_VERSION_IND 12
- #define LL_REJECT_IND 13
- #define LL_SLAVE_FEATURE_REQ 14
- #define LL_CONNECTION_PARAM_REQ 15
- #define LL_CONNECTION_PARAM_RSP 16
- #define LL_REJECT_IND_EXT 17
- #define LL_PING_REQ 18
- #define LL_PING_RSP 19
- #define LL_LENGTH_REQ 20
- #define LL_LENGTH_RSP 21
- #define LL_PHY_REQ 22
- #define LL_PHY_RSP 23
- #define LL_PHY_UPDATE_IND 24
- #define LL_CONNECT_REQ_PAYLOAD_LEN 18
- #define LL_CONN_UPDATE_REQ_PAYLOAD_LEN 12
- #define LL_CHAN_MAP_REQ_PAYLOAD_LEN 8
- #define LL_TERM_IND_PAYLOAD_LEN 2
- #define LL_ENC_REQ_PAYLOAD_LEN 23
- #define LL_ENC_RSP_PAYLOAD_LEN 13
- #define LL_START_ENC_REQ_PAYLOAD_LEN 1
- #define LL_START_ENC_RSP_PAYLOAD_LEN 1
- #define LL_PAUSE_ENC_REQ_PAYLOAD_LEN 1
- #define LL_PAUSE_ENC_RSP_PAYLOAD_LEN 1
- #define LL_REJECT_IND_PAYLOAD_LEN 2
- #define LL_REJECT_EXT_IND_PAYLOAD_LEN 3
- #define LL_FEATURE_REQ_PAYLOAD_LEN 9
- #define LL_FEATURE_RSP_PAYLOAD_LEN 9
- #define LL_VERSION_IND_PAYLOAD_LEN 6
- #define LL_UNKNOWN_RSP_PAYLOAD_LEN 2
- #define LL_LENGTH_REQ_PAYLOAD_LEN 9
- #define LL_LENGTH_RSP_PAYLOAD_LEN 9
- #define LL_PHY_REQ_PAYLOAD_LEN 3
- #define LL_PHY_RSP_PAYLOAD_LEN 3
- #define LL_PHY_UPDATE_IND_PAYLOAD_LEN 5
- #define LL_MAX_NUM_CTRL_PROC_PKTS 4
- #define LL_CTRL_UNDEFINED_PKT 0xFF
- #define LL_EVT_POST_PROCESS_NR 0x0001
- #define LL_EVT_DIRECTED_ADV_FAILED 0x0002
- #define LL_EVT_SLAVE_CONN_CREATED 0x0004
- #define LL_EVT_NEXT_INTERVAL 0x0008
- #define LL_EVT_MASTER_CONN_CANCELLED 0x0010
- #define LL_EVT_TASK_TIMER_FENCE_EXPIRED 0x0020
- #define LL_EVT_SLAVE_CONN_CREATED_BAD_PARAM 0x0040
- #define LL_EVT_START_32KHZ_XOSC_DELAY 0x0080
- #define LL_EVT_32KHZ_XOSC_DELAY 0x0100
- #define LL_EVT_RESET_SYSTEM_HARD 0x0200
- #define LL_EVT_RESET_SYSTEM_SOFT 0x0400
- #define LL_EVT_MASTER_CONN_CREATED 0x0800
- #define LL_EVT_SECONDARY_SCAN 0x1000
- #define LL_EVT_SECONDARY_ADV 0x2000
- #define LL_ADV_NONCONN_STATE 0x00
- #define LL_ADV_DISCOV_STATE 0x01
- #define LL_ADV_UNDIRECT_STATE 0x02
- #define LL_ADV_HDC_DIRECT_STATE 0x03
- #define LL_SCAN_PASSIVE_STATE 0x04
- #define LL_SCAN_ACTIVE_STATE 0x05
- #define LL_INIT_STATE 0x06
- #define LL_SLAVE_STATE 0x07
- #define LL_ADV_NONCONN_SCAN_PASSIVE_STATE 0x10
- #define LL_ADV_DISCOV_SCAN_PASSIVE_STATE 0x11
- #define LL_ADV_UNDIRECT_SCAN_PASSIVE_STATE 0x12
- #define LL_ADV_HDC_DIRECT_SCAN_PASSIVE_STATE 0x13
- #define LL_ADV_NONCONN_SCAN_ACTIVE_STATE 0x14
- #define LL_ADV_DISCOV_SCAN_ACTIVE_STATE 0x15
- #define LL_ADV_UNDIRECT_SCAN_ACTIVE_STATE 0x16
- #define LL_ADV_HDC_DIRECT_SCAN_ACTIVE_STATE 0x17
- #define LL_ADV_NONCONN_INIT_STATE 0x20
- #define LL_ADV_DISCOV_INIT_STATE 0x21
- #define LL_ADV_NONCONN_MASTER_STATE 0x22
- #define LL_ADV_DISCOV_MASTER_STATE 0x23
- #define LL_ADV_NONCONN_SLAVE_STATE 0x24
- #define LL_ADV_DISCOV_SLAVE_STATE 0x25
- #define LL_SCAN_PASSIVE_INIT_STATE 0x26
- #define LL_SCAN_ACTIVE_INIT_STATE 0x27
- #define LL_SCAN_PASSIVE_MASTER_STATE 0x30
- #define LL_SCAN_ACTIVE_MASTER_STATE 0x31
- #define LL_SCAN_PASSIVE_SLAVE_STATE 0x32
- #define LL_SCAN_ACTIVE_SLAVE_STATE 0x33
- #define LL_INIT_MASTER_STATE 0x34
- #define LL_ADV_LDC_DIRECT_STATE 0x35
- #define LL_ADV_LDC_DIRECT_SCAN_PASSIVE_STATE 0x36
- #define LL_ADV_LDC_DIRECT_SCAN_ACTIVE_STATE 0x37
- #define HCI_RX_PKT_HDR_SIZE 5
- #define LL_NUM_BYTES_FOR_CHAN_MAP 5
- #define LL_CTRL_PROC_STATUS_SUCCESS 0
- #define LL_CTRL_PROC_STATUS_TERMINATE 1
- #define LL_TX_DATA_CONTEXT_POST_PROCESSING 2
- #define LL_TX_DATA_CONTEXT_SEND_DATA 0
- #define LL_LINK_SETUP_TIMEOUT 5
- #define LL_SETUP_NEXT_LINK_STATUS_SUCCESS 0
- #define LL_SETUP_NEXT_LINK_STATUS_TERMINATE 1
- #define LL_CTRL_CONNECTION_UPDATE_REQ 0
- #define LL_CTRL_CHANNEL_MAP_REQ 1
- #define LL_CTRL_TERMINATE_IND 2
- #define LL_CTRL_ENC_REQ 3
- #define LL_CTRL_ENC_RSP 4
- #define LL_CTRL_START_ENC_REQ 5
- #define LL_CTRL_START_ENC_RSP 6
- #define LL_CTRL_UNKNOWN_RSP 7
- #define LL_CTRL_FEATURE_REQ 8
- #define LL_CTRL_FEATURE_RSP 9
- #define LL_CTRL_PAUSE_ENC_REQ 10
- #define LL_CTRL_PAUSE_ENC_RSP 11
- #define LL_CTRL_VERSION_IND 12
- #define LL_CTRL_REJECT_IND 13
- #define LL_CTRL_SLAVE_FEATURE_REQ 14
- #define LL_CTRL_CONNECTION_PARAM_REQ 15
- #define LL_CTRL_CONNECTION_PARAM_RSP 16
- #define LL_CTRL_REJECT_EXT_IND 17
- #define LL_CTRL_PING_REQ 18
- #define LL_CTRL_PING_RSP 19
- #define LL_CTRL_LENGTH_REQ 20
- #define LL_CTRL_LENGTH_RSP 21
- #define LL_CTRL_PHY_REQ 22
- #define LL_CTRL_PHY_RSP 23
- #define LL_CTRL_PHY_UPDATE_IND 24
- #define LL_CTRL_MIN_USED_CHANNELS_IND 25
- #define LL_CTRL_TERMINATE_RX_WAIT_FOR_TX_ACK 26
- #define LL_MAX_CTRL_PROC_TIMEOUT 64000
-
- #define LL_ENC_RAND_LEN 8
- #define LL_ENC_EDIV_LEN 2
- #define LL_ENC_LTK_LEN 16
- #define LL_ENC_IV_M_LEN 4
- #define LL_ENC_IV_S_LEN 4
- #define LL_ENC_IV_LINK_LEN 4
- #define LL_ENC_IV_LEN (LL_ENC_IV_M_LEN + LL_ENC_IV_S_LEN)
- #define LL_ENC_SKD_M_LEN 8
- #define LL_ENC_SKD_S_LEN 8
- #define LL_ENC_SKD_LINK_LEN 8
- #define LL_ENC_SKD_LEN (LL_ENC_SKD_M_LEN + LL_ENC_SKD_S_LEN)
- #define LL_ENC_SK_LEN 16
- #define LL_ENC_NONCE_LEN 13
- #define LL_END_NONCE_IV_OFFSET 5
- #define LL_ENC_MIC_LEN LL_PKT_MIC_LEN
- #define LL_ENC_IV_M_OFFSET LL_ENC_IV_S_LEN
- #define LL_ENC_IV_S_OFFSET 0
- #define LL_ENC_SKD_M_OFFSET LL_ENC_SKD_S_LEN
- #define LL_ENC_SKD_S_OFFSET 0
- #define LL_ENC_BLOCK_LEN 16
- #define LL_ENC_CCM_BLOCK_LEN LL_ENC_BLOCK_LEN
- #define LL_ENC_BLOCK_B0_FLAGS 0x49
- #define LL_ENC_BLOCK_A0_FLAGS 0x01
- #define LL_SCAN_ADV_CHAN_37 37
- #define LL_SCAN_ADV_CHAN_38 38
- #define LL_SCAN_ADV_CHAN_39 39
- struct bd_addr{
- uint8_t addr[6];
- };
- typedef struct
- {
- uint8_t peerAddrType;
- uint8_t peerAddr[ 6 ];
- } peerInfo_t;
- typedef struct
- {
- uint8_t active;
-
- uint16_t advInterval;
-
- uint16_t advMode;
-
- uint8_t ownAddrType;
- uint8_t ownAddr[LL_DEVICE_ADDR_LEN];
-
- uint8_t advChanMap;
-
- uint8_t advEvtType;
-
- uint8_t wlPolicy;
- uint16_t scaValue;
- uint8_t advDataLen;
-
-
- uint8_t scanRspLen;
-
-
- uint8 advNextChan;
-
- }advInfo_t;
- typedef struct
- {
- uint8 ownAddrType;
- uint8 ownAddr[ LL_DEVICE_ADDR_LEN ];
- uint8 initPending;
- uint8 scanMode;
- uint8 scanType;
- uint16 scanInterval;
- uint16 scanWindow;
- uint8 wlPolicy;
- uint8 filterReports;
- uint16 scanBackoffUL;
- uint8 nextScanChan;
- uint8 numSuccess;
- uint8 numFailure;
- uint16 currentBackoff;
- } scanInfo_t;
- typedef struct
- {
- uint8 ownAddrType;
- uint8 ownAddr[ LL_DEVICE_ADDR_LEN ];
-
- uint8 initPending;
- uint8 scanMode;
- uint16 scanInterval;
- uint16 scanWindow;
- uint8 nextScanChan;
- uint8 wlPolicy;
- uint8 connId;
- uint8 scaValue;
- } initInfo_t;
- typedef struct
- {
- uint8_t winSize;
- uint16_t winOffset;
- uint16_t connInterval;
- uint16_t slaveLatency;
- uint16_t connTimeout;
- } connParam_t;
- typedef struct
- {
- uint8_t verNum;
- uint16_t comId;
- uint16_t subverNum;
- } verInfo_t;
- typedef struct
- {
- uint8_t connId;
- uint8_t termIndRcvd;
- uint8_t reason;
- } termInfo_t;
- typedef struct txData_t
- {
- struct txData_t *pNext;
- } txData_t;
- typedef struct
- {
- txData_t *head;
- txData_t *tail;
- } llDataQ_t;
- typedef struct
- {
- uint8_t peerInfoValid;
- uint8_t hostRequest;
- uint8_t verInfoSent;
- } verExchange_t;
- typedef struct
- {
- uint8_t featureRspRcved;
- uint8_t featureSet[ 8 ];
- } featureSet_t;
- typedef struct
- {
- uint8_t chanMap[ 5 ];
- } chanMap_t;
- typedef struct
- {
- uint8_t ctrlPktActive;
- uint8_t ctrlPkts[ LL_MAX_NUM_CTRL_PROC_PKTS ];
- uint8_t ctrlPktCount;
- uint16_t ctrlTimeoutVal;
- uint16_t ctrlTimeout;
- } ctrlPktInfo_t;
- typedef struct
- {
- uint32 coarse;
- uint16 fine;
- } sysTime_t;
- typedef struct
- {
-
-
-
- uint8 IV[ LL_ENC_IV_LEN ];
- uint8 SKD [ LL_ENC_SKD_LEN ];
- uint8 RAND[ LL_ENC_RAND_LEN ];
- uint8 EDIV[ LL_ENC_EDIV_LEN ];
- uint8 nonce[ LL_ENC_NONCE_LEN ];
- uint8 SK[ LL_ENC_SK_LEN ];
- uint8 LTK[ LL_ENC_LTK_LEN ];
- uint8 SKValid;
- uint8 LTKValid;
- uint32 txPktCount;
- uint32 rxPktCount;
- uint8 encRestart;
- uint8 encRejectErrCode;
-
-
- uint8 startEncRspRcved;
- uint8 pauseEncRspRcved;
- uint8 encReqRcved;
- uint8 startEncReqRcved;
- uint8 rejectIndRcved;
- } encInfo_t;
- typedef struct
- {
- uint16 numPkts;
- uint16 numCrcErr;
- uint16 numEvents;
- uint16 numMissedEvts;
- } perInfo_t;
- typedef struct
- {
- uint8_t rx_timeout;
- uint8_t rx_crcok;
- uint8_t active;
- uint8_t connId;
- uint8_t firstPacket;
-
- uint16_t currentEvent;
- uint16_t nextEvent;
- uint16_t lastCurrentEvent;
- uint16_t expirationEvent;
- uint16_t expirationValue;
-
-
- uint16_t scaFactor;
- uint32_t timerDrift;
- uint32_t accuTimerDrift;
-
- uint32_t lastTimeToNextEvt;
- uint8_t slaveLatencyAllowed;
- uint16_t slaveLatency;
- uint8_t lastSlaveLatency;
- uint16_t slaveLatencyValue;
-
- uint32_t accessAddr;
- uint32_t initCRC;
-
- uint8_t sleepClkAccuracy;
- connParam_t curParam;
-
-
- uint8_t nextChan;
- uint8_t currentChan;
-
- uint8_t numUsedChans;
-
- uint8_t chanMapTable[LL_MAX_NUM_DATA_CHAN];
- uint8_t chanMap[5];
-
- uint8_t hop;
-
-
- uint8_t txDataEnabled;
- llDataQ_t txDataQ;
-
- uint8_t rxDataEnabled;
- uint8_t lastRssi;
-
- uint16_t foff;
- uint8_t carrSens;
-
- ctrlPktInfo_t ctrlPktInfo;
-
- uint8_t pendingParamUpdate;
- uint16_t paramUpdateEvent;
- connParam_t paramUpdate;
-
- uint8_t pendingChanUpdate;
- uint16 chanMapUpdateEvent;
-
- uint8 encEnabled;
- encInfo_t encInfo;
-
- featureSet_t featureSetInfo;
-
- verExchange_t verExchange;
- verInfo_t verInfo;
-
- termInfo_t termInfo;
-
- uint8 unknownCtrlType;
-
- perInfo_t perInfo;
- uint8_t isCollision;
- uint8_t rejectOpCode;
-
- ll_phy_update_ind_t phyUpdateInfo;
-
- uint8_t pendingPhyModeUpdate;
- uint16_t phyModeUpdateEvent;
-
- uint8_t sn_nesn;
-
-
- uint8_t llMode;
-
- int anchor_point_base_time;
- int anchor_point_fine_time;
-
- int next_event_base_time;
- int next_event_fine_time;
- } llConnState_t;
- typedef struct
- {
-
- int ll_send_undirect_adv_cnt;
- int ll_send_nonconn_adv_cnt;
- int ll_send_scan_adv_cnt;
- int ll_send_hdc_dir_adv_cnt;
- int ll_send_ldc_dir_adv_cnt;
-
- int ll_send_conn_adv_cnt;
- int ll_conn_adv_pending_cnt;
-
- int ll_conn_scan_pending_cnt;
-
- int ll_recv_scan_req_cnt;
- int ll_send_scan_rsp_cnt;
- int ll_recv_conn_req_cnt;
-
-
- int ll_filter_scan_req_cnt;
- int ll_filter_conn_req_cnt;
-
- int ll_recv_adv_pkt_cnt;
- int ll_recv_scan_rsp_cnt;
-
-
- int ll_conn_succ_cnt;
-
- int ll_link_lost_cnt;
- int ll_link_estab_fail_cnt;
-
- int ll_recv_ctrl_pkt_cnt;
- int ll_recv_data_pkt_cnt;
- int ll_recv_invalid_pkt_cnt;
-
- int ll_recv_abnormal_cnt;
-
- int ll_send_data_pkt_cnt;
-
- int ll_conn_event_cnt;
- int ll_recv_crcerr_event_cnt;
- int ll_conn_event_timeout_cnt;
- int ll_rx_peer_cnt;
-
- int ll_to_hci_pkt_cnt;
- int ll_hci_to_ll_pkt_cnt;
-
- int ll_hci_buffer_alloc_err_cnt;
-
- int ll_trigger_err;
- int ll_rfifo_rst_err;
- int ll_rfifo_rst_cnt;
- int ll_rfifo_read_err;
-
-
- int ll_tbd_cnt1;
- int ll_tbd_cnt2;
- int ll_tbd_cnt3;
- int ll_tbd_cnt4;
-
- } llGlobalStatistics_t;
-
- typedef struct
- {
- uint8 numTxDone;
- uint8 numTxAck;
- uint8 numTxCtrlAck;
- uint8 numTxCtrl;
- uint8 numTxRetrans;
- uint8 numTx;
- uint8 numRxOk;
- uint8 numRxCtrl;
- uint8 numRxNotOk;
- uint8 numRxIgnored;
- uint8 numRxEmpty;
- uint8 numRxFifoFull;
- } rfCounters_t;
- extern uint8_t LL_TaskID;
- extern uint8_t llState;
- extern uint8_t connId;
- extern peerInfo_t peerInfo;
- extern advInfo_t adv_param;
- extern scanInfo_t scanInfo;
- extern initInfo_t initInfo;
- extern llConnState_t conn_param[];
- extern chanMap_t chanMapUpdate;
- extern featureSet_t deviceFeatureSet;
- extern uint8 numComplPkts;
- extern uint8 numComplPktsLimit;
- extern verInfo_t verInfo;
- extern rfCounters_t rfCounters;
- extern llLinkBuf_t ll_buf;
- extern llGlobalStatistics_t g_pmCounters;
- extern llPduLenManagment_t g_llPduLen;
- extern llPhyModeManagment_t g_llPhyModeCtrl;
- #endif
|