Stair56E UART project

This commit is contained in:
2026-08-05 19:07:52 +08:00
parent 7ca1af130d
commit f5654b70cc
2500 changed files with 619007 additions and 282610 deletions
+286 -286
View File
@@ -1,286 +1,286 @@
/**
****************************************************************************************
*
* @file em_map_bt.h
*
* @brief Mapping of the different descriptors in the exchange memory
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef EM_MAP_BT_H_
#define EM_MAP_BT_H_
/**
****************************************************************************************
* @addtogroup EM Exchange Memory
* @ingroup CONTROLLER
* @brief Mapping of the different descriptors in the exchange memory
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h"
#include <stdint.h> // integer
#include "_reg_em_bt_cs.h"
#include "_reg_em_bt_rxdesc.h"
#include "_reg_em_bt_txdesc.h"
/// Null pointer in EM offset space
#define EM_PTR_NULL (0x0000)
/*
* CONTROL STRUCTURES
****************************************************************************************
*/
/**
* Control Structures area definition
*
* - ACL (N)
* - INQ
* - ISCAN
* - Active slave broadcast
* - Sync train
* - Sync scan
* - Connectionless slave broadcast TX
* - Connectionless slave broadcast RX
*/
#define EM_BT_CS_OFFSET (CO_ALIGN4_HI(EM_BT_OFFSET))
#define EM_BT_CS_NB (MAX_NB_ACTIVE_ACL+5+2*CSB_SUPPORT)
#define EM_BT_CS_END (EM_BT_CS_OFFSET + EM_BT_CS_NB * REG_EM_BT_CS_SIZE)
/**
* Control Structures indexes definition
*/
#define EM_BT_CS_ACL_INDEX(acl) (acl)
#define EM_BT_CS_IDX_TO_LID(idx) (idx)
#define EM_BT_CS_INQ_INDEX (MAX_NB_ACTIVE_ACL)
#define EM_BT_CS_ISCAN_INDEX (EM_BT_CS_INQ_INDEX + 1)
#define EM_BT_CS_ACT_BCST_INDEX (EM_BT_CS_ISCAN_INDEX + 1)
#define EM_BT_CS_STRAIN_INDEX (EM_BT_CS_ACT_BCST_INDEX + 1)
#define EM_BT_CS_SSCAN_INDEX (EM_BT_CS_STRAIN_INDEX + 1)
#define EM_BT_CS_CSB_TX_INDEX (EM_BT_CS_SSCAN_INDEX + 1)
#define EM_BT_CS_CSB_RX_INDEX (EM_BT_CS_CSB_TX_INDEX + 1)
#define EM_BT_CS_INDEX_MAX (EM_BT_CS_CSB_RX_INDEX + 1)
/**
* Frame Format
* Bluetooth state and device activity used for frequency selection and TDD frame format. See section 3.5 for further details
* Note this field is automatically updated by the RW-BT Core when changing from Page to Master Page Response mode.
* - 0000x: Do not use. -
* - 00010: Master connect. Master device
* - 00011: Slave connect. Slave device
* - 00100: Page. Initiator device
* - 00101: Page scan. Responder device
* - 00110: Master page response. -
* - 00111: Slave page response. -
* - 01000: Inquiry. Initiator device
* - 01001: Inquiry response Responder device
* - 01010: Do not use. -
* - 01011: Do not use. -
* - 011xx: Do not use. -
* - 10xxx: Do not use. -
* - 11000: Master Broadcast Master device
* - 11001: Broadcast Scan Slave device
* - 11010: Master Access window. Master device
* - 11011: Slave Access window 1. Slave device
* - 11100: Slave Access window 2. Slave device
* - 11101: Do not use. -
* - 1111x: Do not use -
*/
#define EM_BT_CS_FMT_MST_CONNECT 0x02
#define EM_BT_CS_FMT_SLV_CONNECT 0x03
#define EM_BT_CS_FMT_PAGE 0x04
#define EM_BT_CS_FMT_PAGE_SCAN 0x05
#define EM_BT_CS_FMT_MST_PAGE_RSP 0x06
#define EM_BT_CS_FMT_SLV_PAGE_RSP 0x07
#define EM_BT_CS_FMT_INQUIRY 0x08
#define EM_BT_CS_FMT_INQ_RSP 0x09
#define EM_BT_CS_FMT_MST_BCST 0x18
#define EM_BT_CS_FMT_BCST_SCAN 0x19
#define EM_BT_CS_FMT_MST_ACC_WIN 0x1A
#define EM_BT_CS_FMT_SLV_ACC_WIN1 0x1B
#define EM_BT_CS_FMT_SLV_ACC_WIN2 0x1C
/// Maximum value of RXWINSZ field (8191)
#define EM_BT_CS_RXWINSZ_MAX ((1 << 13)-1)
/// Maximum value of MAXFRMTIME field (8191)
#define EM_BT_CS_MAXFRMTIME_MAX ((1 << 13)-1)
/*
* RX DESCRIPTORS
****************************************************************************************
*/
/**
* RX Descriptors area definition
*/
#define EM_BT_RXDESC_OFFSET (CO_ALIGN4_HI(EM_BT_CS_END))
#define EM_BT_RXDESC_NB (BT_RXDESC_NB)
#define EM_BT_RXDESC_END (EM_BT_RXDESC_OFFSET + EM_BT_RXDESC_NB * REG_EM_BT_RXDESC_SIZE)
/*
* TX DESCRIPTORS
****************************************************************************************
*/
/**
* TX Descriptors area definition
*
* - ACL (2xN)
* - Active slave broadcast
* - FHS
* - EIR
* - Sync train packet
* - Connectionless slave broadcast
*/
#define EM_BT_TXDESC_OFFSET (CO_ALIGN4_HI(EM_BT_RXDESC_END))
#define EM_BT_TXDESC_NB (2*MAX_NB_ACTIVE_ACL + 4 + CSB_SUPPORT)
#define EM_BT_TXDESC_END (EM_BT_TXDESC_OFFSET + EM_BT_TXDESC_NB * REG_EM_BT_TXDESC_SIZE)
#define EM_BT_TXDESC_ACL_INDEX(acl, tog) (2*acl + tog)
#define EM_BT_TXDESC_ACT_BCST_INDEX (2*MAX_NB_ACTIVE_ACL)
#define EM_BT_TXDESC_ISCANFHS_INDEX (EM_BT_TXDESC_ACT_BCST_INDEX + 1)
#define EM_BT_TXDESC_EIR_INDEX (EM_BT_TXDESC_ISCANFHS_INDEX + 1)
#define EM_BT_TXDESC_STP_INDEX (EM_BT_TXDESC_EIR_INDEX + 1)
#define EM_BT_TXDESC_CSB_INDEX (EM_BT_TXDESC_STP_INDEX + 1)
/*
* LMP RX BUFFERS
****************************************************************************************
*/
/// LMP RX buffers area definition
#define EM_BT_LMPRXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_TXDESC_END))
#define EM_BT_LMPRXBUF_NB (EM_BT_RXDESC_NB)
#define EM_BT_LMPRXBUF_SIZE (20)
#define EM_BT_LMPRXBUF_END (EM_BT_LMPRXBUF_OFFSET + EM_BT_LMPRXBUF_NB * EM_BT_LMPRXBUF_SIZE)
/*
* LMP TX BUFFERS
****************************************************************************************
*/
/// LMP TX buffers area definition
#define EM_BT_LMPTXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_LMPRXBUF_END))
#define EM_BT_LMPTXBUF_NB (BT_LMP_BUF_NB_TX)
#define EM_BT_LMPTXBUF_SIZE (24)
#define EM_BT_LMPTXBUF_END (EM_BT_LMPTXBUF_OFFSET + EM_BT_LMPTXBUF_NB * EM_BT_LMPTXBUF_SIZE)
/*
* ISCAN FHS TX BUFFER
****************************************************************************************
*/
/// ISCAN FHS TX buffer area definition
#define EM_BT_ISCANFHSTXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_LMPTXBUF_END))
#define EM_BT_ISCANFHSTXBUF_SIZE (20)
#define EM_BT_ISCANFHSTXBUF_END (EM_BT_ISCANFHSTXBUF_OFFSET + EM_BT_ISCANFHSTXBUF_SIZE)
/*
* PAGE FHS TX BUFFER
****************************************************************************************
*/
/// PAGE FHS TX buffer area definition
#define EM_BT_PAGEFHSTXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_ISCANFHSTXBUF_END))
#define EM_BT_PAGEFHSTXBUF_SIZE (20)
#define EM_BT_PAGEFHSTXBUF_END (EM_BT_PAGEFHSTXBUF_OFFSET + EM_BT_PAGEFHSTXBUF_SIZE)
/*
* EIR TX BUFFER
****************************************************************************************
*/
/// EIR TX buffer area definition
#define EM_BT_EIRTXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_PAGEFHSTXBUF_END))
#define EM_BT_EIRTXBUF_SIZE (240)
#define EM_BT_EIRTXBUF_END (EM_BT_EIRTXBUF_OFFSET + EM_BT_EIRTXBUF_SIZE)
/*
* SAM SUBMAP BUFFER
****************************************************************************************
*/
/// SAM SUBMAP (Local) buffer area definition
#define EM_BT_LOCAL_SAM_SUBMAP_OFFSET (CO_ALIGN4_HI(EM_BT_EIRTXBUF_END))
#define EM_BT_LOCAL_SAM_SUBMAP_SIZE (SAM_TYPE0_SUBMAP_LEN)
#define EM_BT_LOCAL_SAM_SUBMAP_END (EM_BT_LOCAL_SAM_SUBMAP_OFFSET + EM_BT_LOCAL_SAM_SUBMAP_SIZE)
/// SAM MAP (Peer) buffer area definition
#define EM_BT_PEER_SAM_MAP_OFFSET (CO_ALIGN4_HI(EM_BT_LOCAL_SAM_SUBMAP_END))
#define EM_BT_PEER_SAM_MAP_OFF(acl) (EM_BT_PEER_SAM_MAP_OFFSET + (acl * RW_PEER_SAM_MAP_MAX_LEN))
#define EM_BT_PEER_SAM_MAP_SIZE (MAX_NB_ACTIVE_ACL * RW_PEER_SAM_MAP_MAX_LEN) // HW restriction
#define EM_BT_PEER_SAM_MAP_END (EM_BT_PEER_SAM_MAP_OFFSET + EM_BT_PEER_SAM_MAP_SIZE)
/*
* STP TX BUFFER
****************************************************************************************
*/
/// Sync Train Packet TX buffer area definition
#define EM_BT_STPTXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_PEER_SAM_MAP_END))
#define EM_BT_STPTXBUF_SIZE (28)
#define EM_BT_STPTXBUF_END (EM_BT_STPTXBUF_OFFSET + EM_BT_STPTXBUF_SIZE)
/*
* ACL RX BUFFERS
****************************************************************************************
*/
/// ACL RX buffers area definition
#define EM_BT_ACLRXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_STPTXBUF_END))
#define EM_BT_ACLRXBUF_NB (ACL_DATA_BUF_NB_RX)
#define EM_BT_ACLRXBUF_SIZE (1028)
#define EM_BT_ACLRXBUF_END (EM_BT_ACLRXBUF_OFFSET + EM_BT_ACLRXBUF_NB * EM_BT_ACLRXBUF_SIZE)
/*
* ACL TX BUFFERS
****************************************************************************************
*/
/// ACL TX buffers area definition
#define EM_BT_ACLTXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_ACLRXBUF_END))
#define EM_BT_ACLTXBUF_NB (ACL_DATA_BUF_NB_TX)
#define EM_BT_ACLTXBUF_SIZE (1028)
#define EM_BT_ACLTXBUF_END (EM_BT_ACLTXBUF_OFFSET + EM_BT_ACLTXBUF_NB * EM_BT_ACLTXBUF_SIZE)
/*
* AUDIO RX BUFFERS
****************************************************************************************
*/
/// AUDIO buffers area definition
#define EM_BT_AUDIOBUF_OFFSET (CO_ALIGN4_HI(EM_BT_ACLTXBUF_END))
#define EM_BT_AUDIOBUF_NB (MAX_NB_SYNC)
#define EM_BT_AUDIOBUF_SIZE (2*1080) // (4*1080) !!! Maximum configuration (2 x eSCO-3EV5) not possible on Bubble
#define EM_BT_AUDIOBUF_END (EM_BT_AUDIOBUF_OFFSET + EM_BT_AUDIOBUF_NB * EM_BT_AUDIOBUF_SIZE)
#define EM_BT_AUDIOBUF_OFF(sco) (EM_BT_AUDIOBUF_OFFSET + (sco * EM_BT_AUDIOBUF_SIZE))
/*
* END
****************************************************************************************
*/
#define EM_BT_END (EM_BT_AUDIOBUF_END)
/// @} EM
#endif // EM_MAP_BT_H_
/**
****************************************************************************************
*
* @file em_map_bt.h
*
* @brief Mapping of the different descriptors in the exchange memory
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef EM_MAP_BT_H_
#define EM_MAP_BT_H_
/**
****************************************************************************************
* @addtogroup EM Exchange Memory
* @ingroup CONTROLLER
* @brief Mapping of the different descriptors in the exchange memory
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h"
#include <stdint.h> // integer
#include "_reg_em_bt_cs.h"
#include "_reg_em_bt_rxdesc.h"
#include "_reg_em_bt_txdesc.h"
/// Null pointer in EM offset space
#define EM_PTR_NULL (0x0000)
/*
* CONTROL STRUCTURES
****************************************************************************************
*/
/**
* Control Structures area definition
*
* - ACL (N)
* - INQ
* - ISCAN
* - Active slave broadcast
* - Sync train
* - Sync scan
* - Connectionless slave broadcast TX
* - Connectionless slave broadcast RX
*/
#define EM_BT_CS_OFFSET (CO_ALIGN4_HI(EM_BT_OFFSET))
#define EM_BT_CS_NB (MAX_NB_ACTIVE_ACL+5+2*CSB_SUPPORT)
#define EM_BT_CS_END (EM_BT_CS_OFFSET + EM_BT_CS_NB * REG_EM_BT_CS_SIZE)
/**
* Control Structures indexes definition
*/
#define EM_BT_CS_ACL_INDEX(acl) (acl)
#define EM_BT_CS_IDX_TO_LID(idx) (idx)
#define EM_BT_CS_INQ_INDEX (MAX_NB_ACTIVE_ACL)
#define EM_BT_CS_ISCAN_INDEX (EM_BT_CS_INQ_INDEX + 1)
#define EM_BT_CS_ACT_BCST_INDEX (EM_BT_CS_ISCAN_INDEX + 1)
#define EM_BT_CS_STRAIN_INDEX (EM_BT_CS_ACT_BCST_INDEX + 1)
#define EM_BT_CS_SSCAN_INDEX (EM_BT_CS_STRAIN_INDEX + 1)
#define EM_BT_CS_CSB_TX_INDEX (EM_BT_CS_SSCAN_INDEX + 1)
#define EM_BT_CS_CSB_RX_INDEX (EM_BT_CS_CSB_TX_INDEX + 1)
#define EM_BT_CS_INDEX_MAX (EM_BT_CS_CSB_RX_INDEX + 1)
/**
* Frame Format
* Bluetooth state and device activity used for frequency selection and TDD frame format. See section 3.5 for further details
* Note this field is automatically updated by the RW-BT Core when changing from Page to Master Page Response mode.
* - 0000x: Do not use. -
* - 00010: Master connect. Master device
* - 00011: Slave connect. Slave device
* - 00100: Page. Initiator device
* - 00101: Page scan. Responder device
* - 00110: Master page response. -
* - 00111: Slave page response. -
* - 01000: Inquiry. Initiator device
* - 01001: Inquiry response Responder device
* - 01010: Do not use. -
* - 01011: Do not use. -
* - 011xx: Do not use. -
* - 10xxx: Do not use. -
* - 11000: Master Broadcast Master device
* - 11001: Broadcast Scan Slave device
* - 11010: Master Access window. Master device
* - 11011: Slave Access window 1. Slave device
* - 11100: Slave Access window 2. Slave device
* - 11101: Do not use. -
* - 1111x: Do not use -
*/
#define EM_BT_CS_FMT_MST_CONNECT 0x02
#define EM_BT_CS_FMT_SLV_CONNECT 0x03
#define EM_BT_CS_FMT_PAGE 0x04
#define EM_BT_CS_FMT_PAGE_SCAN 0x05
#define EM_BT_CS_FMT_MST_PAGE_RSP 0x06
#define EM_BT_CS_FMT_SLV_PAGE_RSP 0x07
#define EM_BT_CS_FMT_INQUIRY 0x08
#define EM_BT_CS_FMT_INQ_RSP 0x09
#define EM_BT_CS_FMT_MST_BCST 0x18
#define EM_BT_CS_FMT_BCST_SCAN 0x19
#define EM_BT_CS_FMT_MST_ACC_WIN 0x1A
#define EM_BT_CS_FMT_SLV_ACC_WIN1 0x1B
#define EM_BT_CS_FMT_SLV_ACC_WIN2 0x1C
/// Maximum value of RXWINSZ field (8191)
#define EM_BT_CS_RXWINSZ_MAX ((1 << 13)-1)
/// Maximum value of MAXFRMTIME field (8191)
#define EM_BT_CS_MAXFRMTIME_MAX ((1 << 13)-1)
/*
* RX DESCRIPTORS
****************************************************************************************
*/
/**
* RX Descriptors area definition
*/
#define EM_BT_RXDESC_OFFSET (CO_ALIGN4_HI(EM_BT_CS_END))
#define EM_BT_RXDESC_NB (BT_RXDESC_NB)
#define EM_BT_RXDESC_END (EM_BT_RXDESC_OFFSET + EM_BT_RXDESC_NB * REG_EM_BT_RXDESC_SIZE)
/*
* TX DESCRIPTORS
****************************************************************************************
*/
/**
* TX Descriptors area definition
*
* - ACL (2xN)
* - Active slave broadcast
* - FHS
* - EIR
* - Sync train packet
* - Connectionless slave broadcast
*/
#define EM_BT_TXDESC_OFFSET (CO_ALIGN4_HI(EM_BT_RXDESC_END))
#define EM_BT_TXDESC_NB (2*MAX_NB_ACTIVE_ACL + 4 + CSB_SUPPORT)
#define EM_BT_TXDESC_END (EM_BT_TXDESC_OFFSET + EM_BT_TXDESC_NB * REG_EM_BT_TXDESC_SIZE)
#define EM_BT_TXDESC_ACL_INDEX(acl, tog) (2*acl + tog)
#define EM_BT_TXDESC_ACT_BCST_INDEX (2*MAX_NB_ACTIVE_ACL)
#define EM_BT_TXDESC_ISCANFHS_INDEX (EM_BT_TXDESC_ACT_BCST_INDEX + 1)
#define EM_BT_TXDESC_EIR_INDEX (EM_BT_TXDESC_ISCANFHS_INDEX + 1)
#define EM_BT_TXDESC_STP_INDEX (EM_BT_TXDESC_EIR_INDEX + 1)
#define EM_BT_TXDESC_CSB_INDEX (EM_BT_TXDESC_STP_INDEX + 1)
/*
* LMP RX BUFFERS
****************************************************************************************
*/
/// LMP RX buffers area definition
#define EM_BT_LMPRXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_TXDESC_END))
#define EM_BT_LMPRXBUF_NB (EM_BT_RXDESC_NB)
#define EM_BT_LMPRXBUF_SIZE (20)
#define EM_BT_LMPRXBUF_END (EM_BT_LMPRXBUF_OFFSET + EM_BT_LMPRXBUF_NB * EM_BT_LMPRXBUF_SIZE)
/*
* LMP TX BUFFERS
****************************************************************************************
*/
/// LMP TX buffers area definition
#define EM_BT_LMPTXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_LMPRXBUF_END))
#define EM_BT_LMPTXBUF_NB (BT_LMP_BUF_NB_TX)
#define EM_BT_LMPTXBUF_SIZE (24)
#define EM_BT_LMPTXBUF_END (EM_BT_LMPTXBUF_OFFSET + EM_BT_LMPTXBUF_NB * EM_BT_LMPTXBUF_SIZE)
/*
* ISCAN FHS TX BUFFER
****************************************************************************************
*/
/// ISCAN FHS TX buffer area definition
#define EM_BT_ISCANFHSTXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_LMPTXBUF_END))
#define EM_BT_ISCANFHSTXBUF_SIZE (20)
#define EM_BT_ISCANFHSTXBUF_END (EM_BT_ISCANFHSTXBUF_OFFSET + EM_BT_ISCANFHSTXBUF_SIZE)
/*
* PAGE FHS TX BUFFER
****************************************************************************************
*/
/// PAGE FHS TX buffer area definition
#define EM_BT_PAGEFHSTXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_ISCANFHSTXBUF_END))
#define EM_BT_PAGEFHSTXBUF_SIZE (20)
#define EM_BT_PAGEFHSTXBUF_END (EM_BT_PAGEFHSTXBUF_OFFSET + EM_BT_PAGEFHSTXBUF_SIZE)
/*
* EIR TX BUFFER
****************************************************************************************
*/
/// EIR TX buffer area definition
#define EM_BT_EIRTXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_PAGEFHSTXBUF_END))
#define EM_BT_EIRTXBUF_SIZE (240)
#define EM_BT_EIRTXBUF_END (EM_BT_EIRTXBUF_OFFSET + EM_BT_EIRTXBUF_SIZE)
/*
* SAM SUBMAP BUFFER
****************************************************************************************
*/
/// SAM SUBMAP (Local) buffer area definition
#define EM_BT_LOCAL_SAM_SUBMAP_OFFSET (CO_ALIGN4_HI(EM_BT_EIRTXBUF_END))
#define EM_BT_LOCAL_SAM_SUBMAP_SIZE (SAM_TYPE0_SUBMAP_LEN)
#define EM_BT_LOCAL_SAM_SUBMAP_END (EM_BT_LOCAL_SAM_SUBMAP_OFFSET + EM_BT_LOCAL_SAM_SUBMAP_SIZE)
/// SAM MAP (Peer) buffer area definition
#define EM_BT_PEER_SAM_MAP_OFFSET (CO_ALIGN4_HI(EM_BT_LOCAL_SAM_SUBMAP_END))
#define EM_BT_PEER_SAM_MAP_OFF(acl) (EM_BT_PEER_SAM_MAP_OFFSET + (acl * RW_PEER_SAM_MAP_MAX_LEN))
#define EM_BT_PEER_SAM_MAP_SIZE (MAX_NB_ACTIVE_ACL * RW_PEER_SAM_MAP_MAX_LEN) // HW restriction
#define EM_BT_PEER_SAM_MAP_END (EM_BT_PEER_SAM_MAP_OFFSET + EM_BT_PEER_SAM_MAP_SIZE)
/*
* STP TX BUFFER
****************************************************************************************
*/
/// Sync Train Packet TX buffer area definition
#define EM_BT_STPTXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_PEER_SAM_MAP_END))
#define EM_BT_STPTXBUF_SIZE (28)
#define EM_BT_STPTXBUF_END (EM_BT_STPTXBUF_OFFSET + EM_BT_STPTXBUF_SIZE)
/*
* ACL RX BUFFERS
****************************************************************************************
*/
/// ACL RX buffers area definition
#define EM_BT_ACLRXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_STPTXBUF_END))
#define EM_BT_ACLRXBUF_NB (ACL_DATA_BUF_NB_RX)
#define EM_BT_ACLRXBUF_SIZE (1028)
#define EM_BT_ACLRXBUF_END (EM_BT_ACLRXBUF_OFFSET + EM_BT_ACLRXBUF_NB * EM_BT_ACLRXBUF_SIZE)
/*
* ACL TX BUFFERS
****************************************************************************************
*/
/// ACL TX buffers area definition
#define EM_BT_ACLTXBUF_OFFSET (CO_ALIGN4_HI(EM_BT_ACLRXBUF_END))
#define EM_BT_ACLTXBUF_NB (ACL_DATA_BUF_NB_TX)
#define EM_BT_ACLTXBUF_SIZE (1028)
#define EM_BT_ACLTXBUF_END (EM_BT_ACLTXBUF_OFFSET + EM_BT_ACLTXBUF_NB * EM_BT_ACLTXBUF_SIZE)
/*
* AUDIO RX BUFFERS
****************************************************************************************
*/
/// AUDIO buffers area definition
#define EM_BT_AUDIOBUF_OFFSET (CO_ALIGN4_HI(EM_BT_ACLTXBUF_END))
#define EM_BT_AUDIOBUF_NB (MAX_NB_SYNC)
#define EM_BT_AUDIOBUF_SIZE (2*1080) // (4*1080) !!! Maximum configuration (2 x eSCO-3EV5) not possible on Bubble
#define EM_BT_AUDIOBUF_END (EM_BT_AUDIOBUF_OFFSET + EM_BT_AUDIOBUF_NB * EM_BT_AUDIOBUF_SIZE)
#define EM_BT_AUDIOBUF_OFF(sco) (EM_BT_AUDIOBUF_OFFSET + (sco * EM_BT_AUDIOBUF_SIZE))
/*
* END
****************************************************************************************
*/
#define EM_BT_END (EM_BT_AUDIOBUF_END)
/// @} EM
#endif // EM_MAP_BT_H_
+70 -70
View File
@@ -1,70 +1,70 @@
/**
****************************************************************************************
*
* @file rwbt.h
*
* @brief RWBT interrupt definitions
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef _RW_BT_H_
#define _RW_BT_H_
/**
****************************************************************************************
* @addtogroup ROOT
* @brief Entry points of the BT stack
*
* This module contains the primitives that allow an application accessing and running the
* BT protocol stack.
*
*
* @{
****************************************************************************************
*/
#include <stdint.h> // standard integer definitions
#include <stdbool.h> // standard boolean definitions
#include "rwip_config.h" // stack configuration
#include "arch.h"
/*
* FUNCTION DECLARATION
*****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initializes the RW BT SW.
*
****************************************************************************************
*/
void rwbt_init(void);
/**
****************************************************************************************
* @brief Reset the RW BT SW.
*
****************************************************************************************
*/
void rwbt_reset(void);
/**
****************************************************************************************
* @brief The RWBT core interrupt handler.
*
* Handles both the clock interrupt and the Rx Packet interrupt (when activated)
* In the case of a clock interrupt, check if there are active links and which one
* has the highest priority.
*
****************************************************************************************
*/
__BTIRQ void rwbt_isr(void);
///@} ROOT
#endif // _RW_BT_H_
/**
****************************************************************************************
*
* @file rwbt.h
*
* @brief RWBT interrupt definitions
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef _RW_BT_H_
#define _RW_BT_H_
/**
****************************************************************************************
* @addtogroup ROOT
* @brief Entry points of the BT stack
*
* This module contains the primitives that allow an application accessing and running the
* BT protocol stack.
*
*
* @{
****************************************************************************************
*/
#include <stdint.h> // standard integer definitions
#include <stdbool.h> // standard boolean definitions
#include "rwip_config.h" // stack configuration
#include "arch.h"
/*
* FUNCTION DECLARATION
*****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initializes the RW BT SW.
*
****************************************************************************************
*/
void rwbt_init(void);
/**
****************************************************************************************
* @brief Reset the RW BT SW.
*
****************************************************************************************
*/
void rwbt_reset(void);
/**
****************************************************************************************
* @brief The RWBT core interrupt handler.
*
* Handles both the clock interrupt and the Rx Packet interrupt (when activated)
* In the case of a clock interrupt, check if there are active links and which one
* has the highest priority.
*
****************************************************************************************
*/
__BTIRQ void rwbt_isr(void);
///@} ROOT
#endif // _RW_BT_H_
+245 -245
View File
@@ -1,245 +1,245 @@
/**
****************************************************************************************
*
* @file rwbt_config.h
*
* @brief Configuration of the BT protocol stack (max number of supported connections,
* type of partitioning, etc.)
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef RWBT_CONFIG_H_
#define RWBT_CONFIG_H_
/**
****************************************************************************************
* @addtogroup ROOT
* @{
*
* @name RWBT Stack Configuration
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
/*
* DEFINES
****************************************************************************************
*/
/******************************************************************************************/
/* -------------------------- GENERAL SETUP --------------------------------------*/
/******************************************************************************************/
/// Maximum number of ACL links
#define MAX_NB_ACTIVE_ACL CFG_CON_ACL
/// BT Heap size
#define BT_HEAP_MSG_SIZE (256 + 256 * MAX_NB_ACTIVE_ACL)
#define BT_HEAP_ENV_SIZE (1024 + 1024 * MAX_NB_ACTIVE_ACL)
/// Number of BT tasks
#define BT_TASK_SIZE 4
/// Number of RX descriptors
#define BT_RXDESC_NB (4)
/// Number of RX/TX ACL data buffers
#define ACL_DATA_BUF_NB_RX (BT_RXDESC_NB + 2)
#define ACL_DATA_BUF_NB_TX (MAX_NB_ACTIVE_ACL + 2)
/// Guard space reserved for HCI header in ACL RX buffers
#define ACL_RX_BUF_HEADER_SPACE (HCI_ACL_HDR_LEN + 1)
/// Number of TX LMP buffers
#if (MAX_NB_ACTIVE_ACL > 3)
#define BT_LMP_BUF_NB_TX (2*MAX_NB_ACTIVE_ACL)
#else // (MAX_NB_ACTIVE_ACL > 3)
#define BT_LMP_BUF_NB_TX (7)
#endif // (MAX_NB_ACTIVE_ACL > 3)
/// Maximum ACL Data Packet Size
#define ACL_DATA_BUF_SIZE DH5_3_PACKET_SIZE
/// Normal Rx window size
#define NORMAL_WIN_SIZE 26
/// Range of key size supported by the FW
#define ENC_KEY_SIZE_MAX 16
#define ENC_KEY_SIZE_MIN 7
#define ENC_KEY_SIZE_MASK 0xFFFF
/// Inquiry response TX power (the value code depends on radio used)
#define INQ_RSP_TX_PWR rwip_rf.txpwr_max
/// Size of the inquiry result filtering list
#define INQ_FILT_LEN 10
/******************************************************************************************/
/* -------------------------- SYNC SETUP ------------------------------------------*/
/******************************************************************************************/
/// Maximum number of Synchronous connections (0 to 2)
#define MAX_NB_SYNC CFG_CON_SCO
/// Flag indicating if debug mode is activated or not
#if defined (CFG_VOHCI) && (MAX_NB_SYNC > 0)
#define VOICE_OVER_HCI 1
#else
#define VOICE_OVER_HCI 0
#endif // defined (CFG_VOHCI) && (MAX_NB_SYNC > 0)
#if VOICE_OVER_HCI
/// Number of Synchronous TX buffers used for one VoHCI link
#define SYNC_TX_BUF_NB 4
/// Number of Synchronous RX buffers used for one VoHCI link
#define SYNC_RX_BUF_NB 3
/// Guard space reserved for HCI header in Sync RX buffers
#define SYNC_RX_BUF_HEADER_SPACE (HCI_SYNC_HDR_LEN + 1)
#endif //(VOICE_OVER_HCI)
/// Synchronous link negotiation number of retries
#define SYNC_NEGO_TRY 1
/******************************************************************************************/
/* ------------------------- FIRMWARE SETUP ---------------------------------------*/
/******************************************************************************************/
///Number of HCI Event filter
#define HCI_FILTER_NB 0x5
/*
* Test mode option to be able to enter test mode as defined
* in part I1: BT Test Mode, of the BT specification.
*/
/// Test mode support
#define TEST_MODE 1
/******************************************************************************************/
/* ------------------------- COEXISTENCE SETUP ------------------------------------*/
/******************************************************************************************/
/// WLAN Coexistence
#define RW_BT_WLAN_COEX RW_WLAN_COEX
///WLAN test mode
#define RW_BT_WLAN_COEX_TEST RW_WLAN_COEX_TEST
/// MWS Coexistence
#define RW_BT_MWS_COEX RW_MWS_COEX
///WLAN test mode
#define RW_BT_MWS_COEX_TEST RW_MWS_COEX_TEST
///To let the HW using the default values set in the registers
#define RW_BT_PTI_PRIO_AUTO 31
/// Coexistence Packet traffic information - Index Definitions
enum rwbt_pti_config_idx
{
BT_PTI_PAGERES_IDX ,
BT_PTI_MCONPEND_IDX ,
BT_PTI_PSCANRES_IDX ,
BT_PTI_SCONPEND_IDX ,
BT_PTI_MSSWITCH_IDX ,
BT_PTI_SNIFFANC_IDX ,
BT_PTI_BEACON_IDX ,
BT_PTI_SNIFFATT_IDX ,
BT_PTI_ACCWIN_IDX ,
BT_PTI_POLLINT_IDX ,
BT_PTI_PAGE_IDX ,
BT_PTI_PSCAN_IDX ,
BT_PTI_INQ_IDX ,
BT_PTI_INQSCAN_IDX ,
BT_PTI_INQRES_IDX ,
BT_PTI_SCORSVD_IDX ,
BT_PTI_SCORETX_IDX ,
BT_PTI_ACLTX_IDX ,
BT_PTI_ACLRETX_IDX ,
BT_PTI_LMPTX_IDX ,
BT_PTI_BCAST_IDX ,
BT_PTI_CONNECT_IDX ,
BT_PTI_IDX_MAX
};
/******************************************************************************************/
/* ------------------------- AFH SETUP ------------------------------------*/
/******************************************************************************************/
/// Minimum classification interval requested to slave devices (in slots) (2 secs)
#define BT_AFH_CH_CLASS_INT_MIN 0x0C80
/// Maximum classification interval requested to slave devices (in slots) (4 secs)
#define BT_AFH_CH_CLASS_INT_MAX 0x1900
/// AFH update period (in sec)
#define BT_AFH_UPDATE_PERIOD 4
/// Maximum duration without receiving a packet before considering a channel quality unknown (in slots) (2 secs)
#define BT_AFH_ASSESS_VALID_TO 0x1900
/// Maximum duration without receiving a packet before reintroducing a channel to the map (in slots) (20 secs)
#define BT_AFH_REASSESS_TO 0x7D00
/// Maximum counter value for channel assessment
#define BT_AFH_ASSESS_COUNT_MAX 4
/// Counter threshold to consider a channel good
#define BT_AFH_ASSESS_COUNT_THR_GOOD 2
/// Counter threshold to consider a channel bad
#define BT_AFH_ASSESS_COUNT_THR_BAD -2
/// Minimum counter value for channel assessment
#define BT_AFH_ASSESS_COUNT_MIN -4
/******************************************************************************************/
/* -------------------------- CSB SETUP ----------------------------------------*/
/******************************************************************************************/
/// Support of Connectionless Slave Broadcast
#if defined (CFG_CSB)
#define CSB_SUPPORT 1
#else
#define CSB_SUPPORT 0
#endif // defined (CFG_CSB)
/******************************************************************************************/
/* -------------------------- PCA SETUP ----------------------------------------*/
/******************************************************************************************/
/// Support of Piconet Clock Adjust
#if defined (CFG_PCA)
#define PCA_SUPPORT 1
#else
#define PCA_SUPPORT 0
#endif // defined (CFG_PCA)
/// PCA update period (in sec)
#define BT_PCA_UPDATE_PERIOD 30
/// PCA request clk_adj_slots in addition to clk_adj_us: enable=1, disable=0
#define BT_PCA_CLK_ADJ_SLOTS 0 // No mandate to request a clk_adj_slots currently - for test only
/******************************************************************************************/
/* ------------------------ CONNECTION HANDLE ----------------------------------------*/
/******************************************************************************************/
/// Bit set for BT ACL connection handles
#define BT_ACL_CONHDL_BIT (0x80)
#define BT_ACL_CONHDL_MIN (BT_ACL_CONHDL_BIT)
#define BT_ACL_CONHDL_MAX (BT_ACL_CONHDL_BIT + MAX_NB_ACTIVE_ACL - 1)
/// Bit set for BT SCO connection handles
#define BT_SYNC_CONHDL_OFF (8)
#define BT_SYNC_CONHDL_MSK (((1 << MAX_NB_SYNC) - 1) << BT_SYNC_CONHDL_OFF)
#define BT_SYNC_CONHDL_BIT(sco_link_id) ((sco_link_id + 1) << BT_SYNC_CONHDL_OFF)
#define BT_SYNC_CONHDL_LID(sco_conhdl) ((sco_conhdl >> BT_SYNC_CONHDL_OFF) - 1)
#define BT_SYNC_CONHDL(link_id, sco_link_id) (BT_ACL_CONHDL_MIN + link_id + BT_SYNC_CONHDL_BIT(sco_link_id))
/// @} BT Stack Configuration
/// @} ROOT
#endif //RWBT_CONFIG_H_
/**
****************************************************************************************
*
* @file rwbt_config.h
*
* @brief Configuration of the BT protocol stack (max number of supported connections,
* type of partitioning, etc.)
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef RWBT_CONFIG_H_
#define RWBT_CONFIG_H_
/**
****************************************************************************************
* @addtogroup ROOT
* @{
*
* @name RWBT Stack Configuration
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
/*
* DEFINES
****************************************************************************************
*/
/******************************************************************************************/
/* -------------------------- GENERAL SETUP --------------------------------------*/
/******************************************************************************************/
/// Maximum number of ACL links
#define MAX_NB_ACTIVE_ACL CFG_CON_ACL
/// BT Heap size
#define BT_HEAP_MSG_SIZE (256 + 256 * MAX_NB_ACTIVE_ACL)
#define BT_HEAP_ENV_SIZE (1024 + 1024 * MAX_NB_ACTIVE_ACL)
/// Number of BT tasks
#define BT_TASK_SIZE 4
/// Number of RX descriptors
#define BT_RXDESC_NB (4)
/// Number of RX/TX ACL data buffers
#define ACL_DATA_BUF_NB_RX (BT_RXDESC_NB + 2)
#define ACL_DATA_BUF_NB_TX (MAX_NB_ACTIVE_ACL + 2)
/// Guard space reserved for HCI header in ACL RX buffers
#define ACL_RX_BUF_HEADER_SPACE (HCI_ACL_HDR_LEN + 1)
/// Number of TX LMP buffers
#if (MAX_NB_ACTIVE_ACL > 3)
#define BT_LMP_BUF_NB_TX (2*MAX_NB_ACTIVE_ACL)
#else // (MAX_NB_ACTIVE_ACL > 3)
#define BT_LMP_BUF_NB_TX (7)
#endif // (MAX_NB_ACTIVE_ACL > 3)
/// Maximum ACL Data Packet Size
#define ACL_DATA_BUF_SIZE DH5_3_PACKET_SIZE
/// Normal Rx window size
#define NORMAL_WIN_SIZE 26
/// Range of key size supported by the FW
#define ENC_KEY_SIZE_MAX 16
#define ENC_KEY_SIZE_MIN 7
#define ENC_KEY_SIZE_MASK 0xFFFF
/// Inquiry response TX power (the value code depends on radio used)
#define INQ_RSP_TX_PWR rwip_rf.txpwr_max
/// Size of the inquiry result filtering list
#define INQ_FILT_LEN 10
/******************************************************************************************/
/* -------------------------- SYNC SETUP ------------------------------------------*/
/******************************************************************************************/
/// Maximum number of Synchronous connections (0 to 2)
#define MAX_NB_SYNC CFG_CON_SCO
/// Flag indicating if debug mode is activated or not
#if defined (CFG_VOHCI) && (MAX_NB_SYNC > 0)
#define VOICE_OVER_HCI 1
#else
#define VOICE_OVER_HCI 0
#endif // defined (CFG_VOHCI) && (MAX_NB_SYNC > 0)
#if VOICE_OVER_HCI
/// Number of Synchronous TX buffers used for one VoHCI link
#define SYNC_TX_BUF_NB 4
/// Number of Synchronous RX buffers used for one VoHCI link
#define SYNC_RX_BUF_NB 3
/// Guard space reserved for HCI header in Sync RX buffers
#define SYNC_RX_BUF_HEADER_SPACE (HCI_SYNC_HDR_LEN + 1)
#endif //(VOICE_OVER_HCI)
/// Synchronous link negotiation number of retries
#define SYNC_NEGO_TRY 1
/******************************************************************************************/
/* ------------------------- FIRMWARE SETUP ---------------------------------------*/
/******************************************************************************************/
///Number of HCI Event filter
#define HCI_FILTER_NB 0x5
/*
* Test mode option to be able to enter test mode as defined
* in part I1: BT Test Mode, of the BT specification.
*/
/// Test mode support
#define TEST_MODE 1
/******************************************************************************************/
/* ------------------------- COEXISTENCE SETUP ------------------------------------*/
/******************************************************************************************/
/// WLAN Coexistence
#define RW_BT_WLAN_COEX RW_WLAN_COEX
///WLAN test mode
#define RW_BT_WLAN_COEX_TEST RW_WLAN_COEX_TEST
/// MWS Coexistence
#define RW_BT_MWS_COEX RW_MWS_COEX
///WLAN test mode
#define RW_BT_MWS_COEX_TEST RW_MWS_COEX_TEST
///To let the HW using the default values set in the registers
#define RW_BT_PTI_PRIO_AUTO 31
/// Coexistence Packet traffic information - Index Definitions
enum rwbt_pti_config_idx
{
BT_PTI_PAGERES_IDX ,
BT_PTI_MCONPEND_IDX ,
BT_PTI_PSCANRES_IDX ,
BT_PTI_SCONPEND_IDX ,
BT_PTI_MSSWITCH_IDX ,
BT_PTI_SNIFFANC_IDX ,
BT_PTI_BEACON_IDX ,
BT_PTI_SNIFFATT_IDX ,
BT_PTI_ACCWIN_IDX ,
BT_PTI_POLLINT_IDX ,
BT_PTI_PAGE_IDX ,
BT_PTI_PSCAN_IDX ,
BT_PTI_INQ_IDX ,
BT_PTI_INQSCAN_IDX ,
BT_PTI_INQRES_IDX ,
BT_PTI_SCORSVD_IDX ,
BT_PTI_SCORETX_IDX ,
BT_PTI_ACLTX_IDX ,
BT_PTI_ACLRETX_IDX ,
BT_PTI_LMPTX_IDX ,
BT_PTI_BCAST_IDX ,
BT_PTI_CONNECT_IDX ,
BT_PTI_IDX_MAX
};
/******************************************************************************************/
/* ------------------------- AFH SETUP ------------------------------------*/
/******************************************************************************************/
/// Minimum classification interval requested to slave devices (in slots) (2 secs)
#define BT_AFH_CH_CLASS_INT_MIN 0x0C80
/// Maximum classification interval requested to slave devices (in slots) (4 secs)
#define BT_AFH_CH_CLASS_INT_MAX 0x1900
/// AFH update period (in sec)
#define BT_AFH_UPDATE_PERIOD 4
/// Maximum duration without receiving a packet before considering a channel quality unknown (in slots) (2 secs)
#define BT_AFH_ASSESS_VALID_TO 0x1900
/// Maximum duration without receiving a packet before reintroducing a channel to the map (in slots) (20 secs)
#define BT_AFH_REASSESS_TO 0x7D00
/// Maximum counter value for channel assessment
#define BT_AFH_ASSESS_COUNT_MAX 4
/// Counter threshold to consider a channel good
#define BT_AFH_ASSESS_COUNT_THR_GOOD 2
/// Counter threshold to consider a channel bad
#define BT_AFH_ASSESS_COUNT_THR_BAD -2
/// Minimum counter value for channel assessment
#define BT_AFH_ASSESS_COUNT_MIN -4
/******************************************************************************************/
/* -------------------------- CSB SETUP ----------------------------------------*/
/******************************************************************************************/
/// Support of Connectionless Slave Broadcast
#if defined (CFG_CSB)
#define CSB_SUPPORT 1
#else
#define CSB_SUPPORT 0
#endif // defined (CFG_CSB)
/******************************************************************************************/
/* -------------------------- PCA SETUP ----------------------------------------*/
/******************************************************************************************/
/// Support of Piconet Clock Adjust
#if defined (CFG_PCA)
#define PCA_SUPPORT 1
#else
#define PCA_SUPPORT 0
#endif // defined (CFG_PCA)
/// PCA update period (in sec)
#define BT_PCA_UPDATE_PERIOD 30
/// PCA request clk_adj_slots in addition to clk_adj_us: enable=1, disable=0
#define BT_PCA_CLK_ADJ_SLOTS 0 // No mandate to request a clk_adj_slots currently - for test only
/******************************************************************************************/
/* ------------------------ CONNECTION HANDLE ----------------------------------------*/
/******************************************************************************************/
/// Bit set for BT ACL connection handles
#define BT_ACL_CONHDL_BIT (0x80)
#define BT_ACL_CONHDL_MIN (BT_ACL_CONHDL_BIT)
#define BT_ACL_CONHDL_MAX (BT_ACL_CONHDL_BIT + MAX_NB_ACTIVE_ACL - 1)
/// Bit set for BT SCO connection handles
#define BT_SYNC_CONHDL_OFF (8)
#define BT_SYNC_CONHDL_MSK (((1 << MAX_NB_SYNC) - 1) << BT_SYNC_CONHDL_OFF)
#define BT_SYNC_CONHDL_BIT(sco_link_id) ((sco_link_id + 1) << BT_SYNC_CONHDL_OFF)
#define BT_SYNC_CONHDL_LID(sco_conhdl) ((sco_conhdl >> BT_SYNC_CONHDL_OFF) - 1)
#define BT_SYNC_CONHDL(link_id, sco_link_id) (BT_ACL_CONHDL_MIN + link_id + BT_SYNC_CONHDL_BIT(sco_link_id))
/// @} BT Stack Configuration
/// @} ROOT
#endif //RWBT_CONFIG_H_
+263 -263
View File
@@ -1,263 +1,263 @@
/**
****************************************************************************************
*
* @file bt_util_buf.h
*
* @brief Main API file for the BT EM buffer management system
*
* Copyright (C) RivieraWaves 2009-2015
*
****************************************************************************************
*/
#ifndef BT_UTIL_BUF_H_
#define BT_UTIL_BUF_H_
/**
****************************************************************************************
* @defgroup BT_UTIL_BUF BT EM buffer management system
* @ingroup ROOT
* @brief BT EM buffer management system
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // standard integer
#include "co_list.h" // common list definition
/*
* DEFINES
****************************************************************************************
*/
/// ACL data: handle and data length decoding
#define BT_EM_ACL_DATA_LEN_LSB (0)
#define BT_EM_ACL_DATA_LEN_MASK (0x03FF)
/// Packet boundary flag
#define BT_EM_ACL_PBF_LSB (12)
#define BT_EM_ACL_PBF_MASK (0x3000)
/// Broadcast flag
#define BT_EM_ACL_BF_LSB (14)
#define BT_EM_ACL_BF_MASK (0xC000)
/*
* STRUCTURE DEFINITION
****************************************************************************************
*/
/// EM LMP buffer element
struct bt_em_lmp_buf_elt
{
/// List header
struct co_list_hdr hdr;
/// EM buffer pointer
uint16_t buf_ptr;
/// Data length
uint8_t length;
};
/// EM ACL buffer element
struct bt_em_acl_buf_elt
{
/// List header
struct co_list_hdr hdr;
/// L2CAP packet start timestamp (in BT half-slots)
uint32_t l2cap_start_ts;
/// EM buffer pointer
uint16_t buf_ptr;
/// Data length + Data Flags (PBF + BF)
uint16_t data_len_flags;
};
#if VOICE_OVER_HCI
/// EM Sync buffer element
struct bt_em_sync_buf_elt
{
/// List header
struct co_list_hdr hdr;
/// EM buffer pointer
uint16_t buf_ptr;
/// Data length
uint8_t data_len;
/// Packet status flags
uint8_t packet_status_flag;
/// Synchronous link identifier
uint8_t sync_link_id;
};
#endif // VOICE_OVER_HCI
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialize BT EM buffers management system
*
* @param[in] reset True: reset during operations | False: power-on reset
****************************************************************************************
*/
void bt_util_buf_init(bool reset);
/**
****************************************************************************************
* @brief Allocate a LMP TX buffer
*
* @return Pointer to LMP TX buffer, NULL if no buffer available
****************************************************************************************
*/
struct bt_em_lmp_buf_elt* bt_util_buf_lmp_tx_alloc(void);
/**
****************************************************************************************
* @brief Free a LMP TX buffer
*
* @param[in] buf Pointer to LMP TX buffer
****************************************************************************************
*/
void bt_util_buf_lmp_tx_free(uint16_t buf);
/**
****************************************************************************************
* @brief Allocate a ACL RX buffer
*
* @return Pointer to ACL RX buffer, NULL if no buffer available
****************************************************************************************
*/
struct bt_em_acl_buf_elt* bt_util_buf_acl_rx_alloc(void);
/**
****************************************************************************************
* @brief Free a ACL RX buffer
*
* @param[in] buf Pointer to ACL RX buffer
****************************************************************************************
*/
void bt_util_buf_acl_rx_free(uint16_t buf);
/**
****************************************************************************************
* @brief Allocate a ACL TX buffer
*
* @return Pointer to ACL TX buffer, NULL if no buffer available
****************************************************************************************
*/
uint16_t bt_util_buf_acl_tx_alloc(void);
/**
****************************************************************************************
* @brief Retrieve TX buffer Element
*
* @return Pointer to ACL TX buffer element
****************************************************************************************
*/
struct bt_em_acl_buf_elt* bt_util_buf_acl_tx_elt_get(uint16_t buf);
/**
****************************************************************************************
* @brief Free a ACL TX buffer
*
* @param[in] buf Pointer to ACL TX buffer
****************************************************************************************
*/
void bt_util_buf_acl_tx_free(uint16_t buf);
#if VOICE_OVER_HCI
/**
****************************************************************************************
* @brief Initialize synchronous buffer allocation system
*
* @param[in] sync_id Synchronous link identifier
* @param[in] tx_buf_nb Number of synchronous TX buffers
* @param[in] tx_buf_size Size of synchronous TX buffers (data payload only)
* @param[in] rx_buf_nb Number of synchronous RX buffers
* @param[in] rx_buf_size Size of synchronous RX buffers (including HCI header and data payload)
*
* @return Pointer to Sync RX buffer, NULL if no buffer available
****************************************************************************************
*/
void bt_util_buf_sync_init(uint8_t sync_id, uint8_t tx_buf_nb, uint8_t tx_buf_size, uint8_t rx_buf_nb, uint8_t rx_buf_size);
/**
****************************************************************************************
* @brief Clear synchronous buffer allocation system
*
* @param[in] sync_id Synchronous link identifier
*
* @return Pointer to Sync RX buffer, NULL if no buffer available
****************************************************************************************
*/
void bt_util_buf_sync_clear(uint8_t sync_id);
/**
****************************************************************************************
* @brief Allocate a Sync TX buffer
*
* @param[in] sync_id Synchronous link identifier
* @param[in] size Size of the buffer
*
* @return Pointer to Sync TX buffer, NULL if no buffer available
****************************************************************************************
*/
uint16_t bt_util_buf_sync_tx_alloc(uint8_t sync_id, uint8_t size);
/**
****************************************************************************************
* @brief Retrieve TX buffer Element
*
* @param[in] sync_id Synchronous link identifier
*
* @return Pointer to Sync TX buffer element
****************************************************************************************
*/
struct bt_em_sync_buf_elt* bt_util_buf_sync_tx_elt_get(uint8_t sync_id, uint16_t buf);
/**
****************************************************************************************
* @brief Free a Sync TX buffer
*
* @param[in] sync_id Synchronous link identifier
* @param[in] buf Pointer to Sync TX buffer
****************************************************************************************
*/
void bt_util_buf_sync_tx_free(uint8_t sync_id, uint16_t buf);
/**
****************************************************************************************
* @brief Allocate a Sync RX buffer
*
* @param[in] sync_id Synchronous link identifier
* @param[in] size Size of the buffer
*
* @return Pointer to Sync RX buffer, NULL if no buffer available
****************************************************************************************
*/
struct bt_em_sync_buf_elt* bt_util_buf_sync_rx_alloc(uint8_t sync_id, uint8_t size);
/**
****************************************************************************************
* @brief Free a Sync RX buffer
*
* @param[in] sync_id Synchronous link identifier
* @param[in] buf Pointer to Sync RX buffer
****************************************************************************************
*/
void bt_util_buf_sync_rx_free(uint8_t sync_id, uint16_t buf);
#endif // VOICE_OVER_HCI
/// @} BT_UTIL_BUF
#endif // BT_UTIL_BUF_H_
/**
****************************************************************************************
*
* @file bt_util_buf.h
*
* @brief Main API file for the BT EM buffer management system
*
* Copyright (C) RivieraWaves 2009-2015
*
****************************************************************************************
*/
#ifndef BT_UTIL_BUF_H_
#define BT_UTIL_BUF_H_
/**
****************************************************************************************
* @defgroup BT_UTIL_BUF BT EM buffer management system
* @ingroup ROOT
* @brief BT EM buffer management system
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // standard integer
#include "co_list.h" // common list definition
/*
* DEFINES
****************************************************************************************
*/
/// ACL data: handle and data length decoding
#define BT_EM_ACL_DATA_LEN_LSB (0)
#define BT_EM_ACL_DATA_LEN_MASK (0x03FF)
/// Packet boundary flag
#define BT_EM_ACL_PBF_LSB (12)
#define BT_EM_ACL_PBF_MASK (0x3000)
/// Broadcast flag
#define BT_EM_ACL_BF_LSB (14)
#define BT_EM_ACL_BF_MASK (0xC000)
/*
* STRUCTURE DEFINITION
****************************************************************************************
*/
/// EM LMP buffer element
struct bt_em_lmp_buf_elt
{
/// List header
struct co_list_hdr hdr;
/// EM buffer pointer
uint16_t buf_ptr;
/// Data length
uint8_t length;
};
/// EM ACL buffer element
struct bt_em_acl_buf_elt
{
/// List header
struct co_list_hdr hdr;
/// L2CAP packet start timestamp (in BT half-slots)
uint32_t l2cap_start_ts;
/// EM buffer pointer
uint16_t buf_ptr;
/// Data length + Data Flags (PBF + BF)
uint16_t data_len_flags;
};
#if VOICE_OVER_HCI
/// EM Sync buffer element
struct bt_em_sync_buf_elt
{
/// List header
struct co_list_hdr hdr;
/// EM buffer pointer
uint16_t buf_ptr;
/// Data length
uint8_t data_len;
/// Packet status flags
uint8_t packet_status_flag;
/// Synchronous link identifier
uint8_t sync_link_id;
};
#endif // VOICE_OVER_HCI
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialize BT EM buffers management system
*
* @param[in] reset True: reset during operations | False: power-on reset
****************************************************************************************
*/
void bt_util_buf_init(bool reset);
/**
****************************************************************************************
* @brief Allocate a LMP TX buffer
*
* @return Pointer to LMP TX buffer, NULL if no buffer available
****************************************************************************************
*/
struct bt_em_lmp_buf_elt* bt_util_buf_lmp_tx_alloc(void);
/**
****************************************************************************************
* @brief Free a LMP TX buffer
*
* @param[in] buf Pointer to LMP TX buffer
****************************************************************************************
*/
void bt_util_buf_lmp_tx_free(uint16_t buf);
/**
****************************************************************************************
* @brief Allocate a ACL RX buffer
*
* @return Pointer to ACL RX buffer, NULL if no buffer available
****************************************************************************************
*/
struct bt_em_acl_buf_elt* bt_util_buf_acl_rx_alloc(void);
/**
****************************************************************************************
* @brief Free a ACL RX buffer
*
* @param[in] buf Pointer to ACL RX buffer
****************************************************************************************
*/
void bt_util_buf_acl_rx_free(uint16_t buf);
/**
****************************************************************************************
* @brief Allocate a ACL TX buffer
*
* @return Pointer to ACL TX buffer, NULL if no buffer available
****************************************************************************************
*/
uint16_t bt_util_buf_acl_tx_alloc(void);
/**
****************************************************************************************
* @brief Retrieve TX buffer Element
*
* @return Pointer to ACL TX buffer element
****************************************************************************************
*/
struct bt_em_acl_buf_elt* bt_util_buf_acl_tx_elt_get(uint16_t buf);
/**
****************************************************************************************
* @brief Free a ACL TX buffer
*
* @param[in] buf Pointer to ACL TX buffer
****************************************************************************************
*/
void bt_util_buf_acl_tx_free(uint16_t buf);
#if VOICE_OVER_HCI
/**
****************************************************************************************
* @brief Initialize synchronous buffer allocation system
*
* @param[in] sync_id Synchronous link identifier
* @param[in] tx_buf_nb Number of synchronous TX buffers
* @param[in] tx_buf_size Size of synchronous TX buffers (data payload only)
* @param[in] rx_buf_nb Number of synchronous RX buffers
* @param[in] rx_buf_size Size of synchronous RX buffers (including HCI header and data payload)
*
* @return Pointer to Sync RX buffer, NULL if no buffer available
****************************************************************************************
*/
void bt_util_buf_sync_init(uint8_t sync_id, uint8_t tx_buf_nb, uint8_t tx_buf_size, uint8_t rx_buf_nb, uint8_t rx_buf_size);
/**
****************************************************************************************
* @brief Clear synchronous buffer allocation system
*
* @param[in] sync_id Synchronous link identifier
*
* @return Pointer to Sync RX buffer, NULL if no buffer available
****************************************************************************************
*/
void bt_util_buf_sync_clear(uint8_t sync_id);
/**
****************************************************************************************
* @brief Allocate a Sync TX buffer
*
* @param[in] sync_id Synchronous link identifier
* @param[in] size Size of the buffer
*
* @return Pointer to Sync TX buffer, NULL if no buffer available
****************************************************************************************
*/
uint16_t bt_util_buf_sync_tx_alloc(uint8_t sync_id, uint8_t size);
/**
****************************************************************************************
* @brief Retrieve TX buffer Element
*
* @param[in] sync_id Synchronous link identifier
*
* @return Pointer to Sync TX buffer element
****************************************************************************************
*/
struct bt_em_sync_buf_elt* bt_util_buf_sync_tx_elt_get(uint8_t sync_id, uint16_t buf);
/**
****************************************************************************************
* @brief Free a Sync TX buffer
*
* @param[in] sync_id Synchronous link identifier
* @param[in] buf Pointer to Sync TX buffer
****************************************************************************************
*/
void bt_util_buf_sync_tx_free(uint8_t sync_id, uint16_t buf);
/**
****************************************************************************************
* @brief Allocate a Sync RX buffer
*
* @param[in] sync_id Synchronous link identifier
* @param[in] size Size of the buffer
*
* @return Pointer to Sync RX buffer, NULL if no buffer available
****************************************************************************************
*/
struct bt_em_sync_buf_elt* bt_util_buf_sync_rx_alloc(uint8_t sync_id, uint8_t size);
/**
****************************************************************************************
* @brief Free a Sync RX buffer
*
* @param[in] sync_id Synchronous link identifier
* @param[in] buf Pointer to Sync RX buffer
****************************************************************************************
*/
void bt_util_buf_sync_rx_free(uint8_t sync_id, uint16_t buf);
#endif // VOICE_OVER_HCI
/// @} BT_UTIL_BUF
#endif // BT_UTIL_BUF_H_
+124 -124
View File
@@ -1,124 +1,124 @@
/**
****************************************************************************************
*
* @file bt_util_key.h
*
* @brief link manager key management
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef BT_UTIL_KEY_H_
#define BT_UTIL_KEY_H_
/**
****************************************************************************************
* @defgroup LMKEY Link Keys
* @ingroup LM
* @brief LM module for link key management.
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "co_bt.h" // BT standard definitions
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Processes E1 algorithm for Authentication
*
* @param[in] Key Key Vector[16]
* @param[in] BdAddr BdAddr[6]
* @param[in] Random Random Vector[16]
* @param[out] Sres SRES Vector[4]
* @param[out] Aco ACIO Vector[12]
*
****************************************************************************************
*/
void E1(struct ltk Key, struct bd_addr BdAddr, struct ltk Random, struct sres_nb *Sres, struct aco *Aco);
/**
****************************************************************************************
* @brief Processes E21 algorithm for Authentication
*
* @param[in] Random Random Vector[16]
* @param[in] BdAddr BdAddr[6]
* @param[out] Key Result Vector[16]
*
****************************************************************************************
*/
void E21(struct ltk Random, struct bd_addr BdAddr, struct ltk *Key);
/**
****************************************************************************************
* @brief Processes E22 algorithm for Authentication
*
* @param[in] Random Random Vector[16]
* @param[in] BdAddr BdAddr[6]
* @param[in] Pin PIN Vector[1..16]
* @param[in] PinLen PIN length (1..16)
* @param[out] KeyOut Result Vector[16]
*
****************************************************************************************
*/
void E22(struct ltk Random, struct bd_addr BdAddr, struct pin_code Pin, uint8_t PinLen, struct ltk *KeyOut);
/**
****************************************************************************************
* @brief Processes E3 algorithm for Authentication
*
* @param[in] Key Key Vector[16]
* @param[in] Cof COF[12]
* @param[in] Random Random Vector[16]
* @param[out] KeyOut Result Vector[16]
*
****************************************************************************************
*/
void E3(struct ltk Key, struct aco Cof, struct ltk Random, struct ltk *KeyOut);
/**
****************************************************************************************
* @brief Encryption : Processes K'c Key for encryption
*
* @param[in] Random Random Vector[16]
* @param[in] BdAddr BdAddr[6]
* @param[out] KPrimC K'c Vector (Result)
*
****************************************************************************************
*/
void KPrimC(struct ltk Kc, uint8_t length, struct ltk *KPrimC);
/**
****************************************************************************************
* @brief Xor of 2 Vectors
*
* @param[in] VectorIn1 Input Vector1 [16]
* @param[in] VectorIn2 Input Vector2 [16]
* @param[out] VectorOut Result Vector[16]
*
****************************************************************************************
*/
void XorKey(struct ltk VectorIn1, struct ltk VectorIn2, struct ltk *VectorOut);
/**
****************************************************************************************
* @brief This function is used to get a random vector.
*
* @param[out] Vector Random Vector
*
****************************************************************************************
*/
void LM_MakeRandVec(struct ltk *Vector);
///@} LMKEY
#endif // BT_UTIL_KEY_H_
/**
****************************************************************************************
*
* @file bt_util_key.h
*
* @brief link manager key management
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef BT_UTIL_KEY_H_
#define BT_UTIL_KEY_H_
/**
****************************************************************************************
* @defgroup LMKEY Link Keys
* @ingroup LM
* @brief LM module for link key management.
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "co_bt.h" // BT standard definitions
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Processes E1 algorithm for Authentication
*
* @param[in] Key Key Vector[16]
* @param[in] BdAddr BdAddr[6]
* @param[in] Random Random Vector[16]
* @param[out] Sres SRES Vector[4]
* @param[out] Aco ACIO Vector[12]
*
****************************************************************************************
*/
void E1(struct ltk Key, struct bd_addr BdAddr, struct ltk Random, struct sres_nb *Sres, struct aco *Aco);
/**
****************************************************************************************
* @brief Processes E21 algorithm for Authentication
*
* @param[in] Random Random Vector[16]
* @param[in] BdAddr BdAddr[6]
* @param[out] Key Result Vector[16]
*
****************************************************************************************
*/
void E21(struct ltk Random, struct bd_addr BdAddr, struct ltk *Key);
/**
****************************************************************************************
* @brief Processes E22 algorithm for Authentication
*
* @param[in] Random Random Vector[16]
* @param[in] BdAddr BdAddr[6]
* @param[in] Pin PIN Vector[1..16]
* @param[in] PinLen PIN length (1..16)
* @param[out] KeyOut Result Vector[16]
*
****************************************************************************************
*/
void E22(struct ltk Random, struct bd_addr BdAddr, struct pin_code Pin, uint8_t PinLen, struct ltk *KeyOut);
/**
****************************************************************************************
* @brief Processes E3 algorithm for Authentication
*
* @param[in] Key Key Vector[16]
* @param[in] Cof COF[12]
* @param[in] Random Random Vector[16]
* @param[out] KeyOut Result Vector[16]
*
****************************************************************************************
*/
void E3(struct ltk Key, struct aco Cof, struct ltk Random, struct ltk *KeyOut);
/**
****************************************************************************************
* @brief Encryption : Processes K'c Key for encryption
*
* @param[in] Random Random Vector[16]
* @param[in] BdAddr BdAddr[6]
* @param[out] KPrimC K'c Vector (Result)
*
****************************************************************************************
*/
void KPrimC(struct ltk Kc, uint8_t length, struct ltk *KPrimC);
/**
****************************************************************************************
* @brief Xor of 2 Vectors
*
* @param[in] VectorIn1 Input Vector1 [16]
* @param[in] VectorIn2 Input Vector2 [16]
* @param[out] VectorOut Result Vector[16]
*
****************************************************************************************
*/
void XorKey(struct ltk VectorIn1, struct ltk VectorIn2, struct ltk *VectorOut);
/**
****************************************************************************************
* @brief This function is used to get a random vector.
*
* @param[out] Vector Random Vector
*
****************************************************************************************
*/
void LM_MakeRandVec(struct ltk *Vector);
///@} LMKEY
#endif // BT_UTIL_KEY_H_
+103 -103
View File
@@ -1,103 +1,103 @@
/**
****************************************************************************************
*
* @file bt_util_lmp.h
*
* @brief Main API file for the Link Manager Protocol
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef BT_UTIL_LMP_H_
#define BT_UTIL_LMP_H_
/**
****************************************************************************************
* @defgroup BT_UTIL_LMP Link Manager Protocol
* @ingroup ROOT
* @brief Link Manager Protocol
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // standard integer
/*
* DEFINES
****************************************************************************************
*/
/// Maximum size of LMP unpacked parameters
#define LMP_MAX_UNPACKED_SIZE (LMP_MAX_PDU_SIZE+10)
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Status returned by generic packer-unpacker
enum LMP_PACK_STATUS
{
LMP_PACK_OK,
LMP_PACK_OVERFLOW,
LMP_PACK_WRONG_FORMAT,
LMP_PACK_INVALID_SIZE,
LMP_PACK_UNKNOWN,
};
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Check if LMP packet is allowed at connection establishment
*
* @param[in] opcode LMP opcode
* @param[in] ext_opcode LMP extended opcode (if applicable)
*
* @return True if allowed, false otherwise
****************************************************************************************
*/
bool lmp_estab_allowed(uint8_t opcode, uint8_t ext_opcode);
/**
****************************************************************************************
* @brief Pack LMP packet
*
* @param[inout] buf Buffer containing parameters
* @param[inout] p_len Pointer on parameters length
*
* @return Status of the packing operation
****************************************************************************************
*/
uint8_t lmp_pack(uint8_t* buf, uint8_t* p_len);
/**
****************************************************************************************
* @brief Unpack LMP packet
*
* @param[in] in Buffer containing packed parameters
* @param[out] out Buffer containing unpacked parameters
* @param[inout] p_len Pointer on parameters length
*
* @return Status of the unpacking operation
****************************************************************************************
*/
uint8_t lmp_unpack(uint8_t* out, uint8_t* in, uint8_t* p_len);
/// @} BT_UTIL_LMP
#endif // BT_UTIL_LMP_H_
/**
****************************************************************************************
*
* @file bt_util_lmp.h
*
* @brief Main API file for the Link Manager Protocol
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef BT_UTIL_LMP_H_
#define BT_UTIL_LMP_H_
/**
****************************************************************************************
* @defgroup BT_UTIL_LMP Link Manager Protocol
* @ingroup ROOT
* @brief Link Manager Protocol
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // standard integer
/*
* DEFINES
****************************************************************************************
*/
/// Maximum size of LMP unpacked parameters
#define LMP_MAX_UNPACKED_SIZE (LMP_MAX_PDU_SIZE+10)
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Status returned by generic packer-unpacker
enum LMP_PACK_STATUS
{
LMP_PACK_OK,
LMP_PACK_OVERFLOW,
LMP_PACK_WRONG_FORMAT,
LMP_PACK_INVALID_SIZE,
LMP_PACK_UNKNOWN,
};
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Check if LMP packet is allowed at connection establishment
*
* @param[in] opcode LMP opcode
* @param[in] ext_opcode LMP extended opcode (if applicable)
*
* @return True if allowed, false otherwise
****************************************************************************************
*/
bool lmp_estab_allowed(uint8_t opcode, uint8_t ext_opcode);
/**
****************************************************************************************
* @brief Pack LMP packet
*
* @param[inout] buf Buffer containing parameters
* @param[inout] p_len Pointer on parameters length
*
* @return Status of the packing operation
****************************************************************************************
*/
uint8_t lmp_pack(uint8_t* buf, uint8_t* p_len);
/**
****************************************************************************************
* @brief Unpack LMP packet
*
* @param[in] in Buffer containing packed parameters
* @param[out] out Buffer containing unpacked parameters
* @param[inout] p_len Pointer on parameters length
*
* @return Status of the unpacking operation
****************************************************************************************
*/
uint8_t lmp_unpack(uint8_t* out, uint8_t* in, uint8_t* p_len);
/// @} BT_UTIL_LMP
#endif // BT_UTIL_LMP_H_
File diff suppressed because it is too large Load Diff
+355 -355
View File
@@ -1,355 +1,355 @@
/**
****************************************************************************************
*
* @file lb.h
*
* @brief Main API file for the Link Broadcaster
*
* Copyright (C) RivieraWaves 2009-2015
*
****************************************************************************************
*/
#ifndef LB_H_
#define LB_H_
/**
****************************************************************************************
* @defgroup LB Link Broadcaster
* @ingroup ROOT
* @brief BT Lower Layers
*
* The CONTROLLER contains the modules allowing the physical link establishment,
* maintenance and management.
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_task.h" // Task definitions
#include "ke_task.h" // kernel task definitions
/*
* MESSAGES
****************************************************************************************
*/
/// Message API of the LB task
/*@TRACE*/
enum lb_msg_id
{
LB_MSG_ID_FIRST = TASK_FIRST_MSG(TASK_ID_LB),
/*
* ************** Msg LC -> LB****************
*/
LB_MST_KEY_CFM,
LB_ENC_RESTART_CFM,
LB_ENC_START_IND,
LB_ENC_STOP_IND,
/*
* ************** Msg LD -> LB****************
*/
LB_ACL_TX_CFM,
LB_CSB_TX_END_IND,
LB_CSB_RX_IND,
LB_CSB_RX_END_IND,
LB_AFH_UPDATE_IND,
LB_AFH_REPORT_TO,
LB_SSCAN_END_IND,
LB_STRAIN_END_IND,
#if PCA_SUPPORT
LB_LOCAL_PCA_REQ,
LB_PCA_END_IND,
LB_PCA_SSCAN_START_REQ,
#if RW_BT_MWS_COEX
LB_PCA_MONITOR_INTV_TO,
#endif //RW_BT_MWS_COEX
/*
* ************** Msg LB->LB****************
*/
LB_PCA_TX_INTV_TO,
#endif //PCA_SUPPORT
};
/// LB master key confirmation
/*@TRACE*/
struct lb_mst_key_cfm
{
///Status
uint8_t status;
///Encryption mode
uint8_t enc_mode;
///Key size mask
uint16_t key_sz_msk;
};
/// LB encryption restart confirmation
/*@TRACE*/
struct lb_enc_restart_cfm
{
///Status
uint8_t status;
};
/// LB encryption start indication
/*@TRACE*/
struct lb_enc_start_ind
{
///Key flag
uint8_t key_flag;
};
/// LB ACL transmission confirmation structure
/*@TRACE*/
struct lb_acl_tx_cfm
{
/// EM buffer containing PDU
uint16_t em_buf;
};
/// LB CSB TX end indication
/*@TRACE*/
struct lb_csb_tx_end_ind
{
/// BD_ADDR
struct bd_addr bd_addr;
/// LT_ADDR
uint8_t lt_addr;
};
/// LB CST RX indication
/*@TRACE*/
struct lb_csb_rx_ind
{
/// CLK when CSB data was received
uint32_t clk;
/// (CLKNslave - CLK) modulo 2^28
uint32_t offset;
/// BD_ADDR
struct bd_addr bd_addr;
/// LT_ADDR
uint8_t lt_addr;
/// receive status
uint8_t rx_status;
/// PDU length
uint16_t length;
/// PDU (packed)
uint8_t pdu[__ARRAY_EMPTY];
};
/// LB CSB RX end indication
/*@TRACE*/
struct lb_csb_rx_end_ind
{
/// BD_ADDR
struct bd_addr bd_addr;
/// LT_ADDR
uint8_t lt_addr;
};
/// LB CSB AFH update indication
/*@TRACE*/
struct lb_afh_update_ind
{
/// AFH_Channel_Map
struct chnl_map afh_ch_map;
};
/// LB CSB AFH report timeout
/*@TRACE*/
struct lb_afh_report_to
{
/// BD_ADDR
struct bd_addr bd_addr;
};
#if PCA_SUPPORT
/// LB PCA local adjustment request structure
/*@TRACE*/
struct lb_local_pca_req
{
/// Clock adjusted us
int16_t clk_adj_us;
/// Clock adjusted slots
uint8_t clk_adj_slots;
/// Clock adjusted period (slots)
uint8_t clk_adj_period;
};
/// LM PCA adjustment complete indication structure
/*@TRACE*/
struct lb_pca_end_ind
{
/// Status
uint8_t status;
};
/// LB Sync Scan start request for PCA recovery mode
/*@TRACE*/
struct lb_pca_sscan_start_req
{
/// Link identifier
uint8_t link_id;
/// Status
uint8_t status;
};
#endif //PCA_SUPPORT
/// LB Sync Scan end indication
/*@TRACE*/
struct lb_sscan_end_ind
{
/// Status
uint8_t status;
/// BD_ADDR
struct bd_addr bd_addr;
/// Clock_Offset (28 bits) - (CLKNslave - CLK) modulo 2^28
uint32_t clock_offset;
#if PCA_SUPPORT
/// Bit offset (CLKNslave - CLK) modulo 2^28
int16_t bit_offset;
#endif // PCA_SUPPORT
/// AFH_Channel_Map
struct chnl_map afh_ch_map;
/// LT_ADDR
uint8_t lt_addr;
/// Next_Broadcast_Instant (28 bits)
uint32_t next_bcst_instant;
/// Connectionless_Slave_Broadcast_Interval (in slots)
uint16_t csb_int;
/// Service_Data
uint8_t service_data;
///Coarse clock adjust use
bool coarse_clk_adj;
};
/// LB Sync Train end indication
/*@TRACE*/
struct lb_strain_end_ind
{
///Status
uint8_t status;
///Coarse clock adjust use
bool coarse_clk_adj;
};
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialization of the BT LB task
*
* This function initializes the the LB task, as well as the environment of the LB
****************************************************************************************
*/
void lb_init(void);
/**
****************************************************************************************
* @brief Reset the BT LB task
****************************************************************************************
*/
void lb_reset(void);
/**
****************************************************************************************
* @brief Get num broadcast retransmissions
****************************************************************************************
*/
uint8_t lb_util_get_nb_broadcast(void);
/**
****************************************************************************************
* @brief Set num broadcast retransmissions
****************************************************************************************
*/
void lb_util_set_nb_broadcast(uint8_t num_bcst_ret);
/**
****************************************************************************************
* @brief Get reserved lt_addr
****************************************************************************************
*/
uint8_t lb_util_get_res_lt_addr(void);
/**
****************************************************************************************
* @brief Get CSB mode (active/inactive)
****************************************************************************************
*/
bool lb_util_get_csb_mode(void);
#if PCA_SUPPORT
/**
****************************************************************************************
* @brief Generic handler for a PCA request on a Master device
*
* @param[in] clk_adj_us. Request intraslot adjustment
* @param[in] clk_adj_slots. Request interslot adjustment
* @param[in] clk_adj_period. Period associated with interslot adjustment
* @param[in] tr_id. Transaction ID of the request.
* @return status as a result of processing the request.
****************************************************************************************
*/
uint8_t lb_master_clk_adj_req_handler(int16_t clk_adj_us, uint8_t clk_adj_slots, uint8_t clk_adj_period, uint8_t tr_id);
/**
****************************************************************************************
* @brief This function is used to clear a PCA clk_adj_ack pending flag/count.
*
****************************************************************************************
*/
void lb_clk_adj_ack(uint8_t clk_adj_id, uint8_t link_id);
#endif //PCA_SUPPORT
/**
****************************************************************************************
* @brief This function read the current master key.
*
* @param[out] MasterKey Master key with LTK size
****************************************************************************************
*/
void LM_GetMasterKey(struct ltk *MasterKey);
/**
****************************************************************************************
* @brief This function read the current master key random.
*
* @param[out] MasterRand Master key random
****************************************************************************************
*/
void LM_GetMasterKeyRand(struct ltk *MasterRand);
/**
****************************************************************************************
* @brief This function read the current Random vector for broadcast encryption.
*
* @param[out] MasterRand Random Vector
****************************************************************************************
*/
void LM_GetMasterEncRand(struct ltk *MasterRand);
/**
****************************************************************************************
* @brief This function read Broadcast Encryption Key Size.
*
* @return Encryption Key Size
****************************************************************************************
*/
uint8_t LM_GetMasterEncKeySize(void);
/// @} LB
#endif // LB_H_
/**
****************************************************************************************
*
* @file lb.h
*
* @brief Main API file for the Link Broadcaster
*
* Copyright (C) RivieraWaves 2009-2015
*
****************************************************************************************
*/
#ifndef LB_H_
#define LB_H_
/**
****************************************************************************************
* @defgroup LB Link Broadcaster
* @ingroup ROOT
* @brief BT Lower Layers
*
* The CONTROLLER contains the modules allowing the physical link establishment,
* maintenance and management.
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_task.h" // Task definitions
#include "ke_task.h" // kernel task definitions
/*
* MESSAGES
****************************************************************************************
*/
/// Message API of the LB task
/*@TRACE*/
enum lb_msg_id
{
LB_MSG_ID_FIRST = TASK_FIRST_MSG(TASK_ID_LB),
/*
* ************** Msg LC -> LB****************
*/
LB_MST_KEY_CFM,
LB_ENC_RESTART_CFM,
LB_ENC_START_IND,
LB_ENC_STOP_IND,
/*
* ************** Msg LD -> LB****************
*/
LB_ACL_TX_CFM,
LB_CSB_TX_END_IND,
LB_CSB_RX_IND,
LB_CSB_RX_END_IND,
LB_AFH_UPDATE_IND,
LB_AFH_REPORT_TO,
LB_SSCAN_END_IND,
LB_STRAIN_END_IND,
#if PCA_SUPPORT
LB_LOCAL_PCA_REQ,
LB_PCA_END_IND,
LB_PCA_SSCAN_START_REQ,
#if RW_BT_MWS_COEX
LB_PCA_MONITOR_INTV_TO,
#endif //RW_BT_MWS_COEX
/*
* ************** Msg LB->LB****************
*/
LB_PCA_TX_INTV_TO,
#endif //PCA_SUPPORT
};
/// LB master key confirmation
/*@TRACE*/
struct lb_mst_key_cfm
{
///Status
uint8_t status;
///Encryption mode
uint8_t enc_mode;
///Key size mask
uint16_t key_sz_msk;
};
/// LB encryption restart confirmation
/*@TRACE*/
struct lb_enc_restart_cfm
{
///Status
uint8_t status;
};
/// LB encryption start indication
/*@TRACE*/
struct lb_enc_start_ind
{
///Key flag
uint8_t key_flag;
};
/// LB ACL transmission confirmation structure
/*@TRACE*/
struct lb_acl_tx_cfm
{
/// EM buffer containing PDU
uint16_t em_buf;
};
/// LB CSB TX end indication
/*@TRACE*/
struct lb_csb_tx_end_ind
{
/// BD_ADDR
struct bd_addr bd_addr;
/// LT_ADDR
uint8_t lt_addr;
};
/// LB CST RX indication
/*@TRACE*/
struct lb_csb_rx_ind
{
/// CLK when CSB data was received
uint32_t clk;
/// (CLKNslave - CLK) modulo 2^28
uint32_t offset;
/// BD_ADDR
struct bd_addr bd_addr;
/// LT_ADDR
uint8_t lt_addr;
/// receive status
uint8_t rx_status;
/// PDU length
uint16_t length;
/// PDU (packed)
uint8_t pdu[__ARRAY_EMPTY];
};
/// LB CSB RX end indication
/*@TRACE*/
struct lb_csb_rx_end_ind
{
/// BD_ADDR
struct bd_addr bd_addr;
/// LT_ADDR
uint8_t lt_addr;
};
/// LB CSB AFH update indication
/*@TRACE*/
struct lb_afh_update_ind
{
/// AFH_Channel_Map
struct chnl_map afh_ch_map;
};
/// LB CSB AFH report timeout
/*@TRACE*/
struct lb_afh_report_to
{
/// BD_ADDR
struct bd_addr bd_addr;
};
#if PCA_SUPPORT
/// LB PCA local adjustment request structure
/*@TRACE*/
struct lb_local_pca_req
{
/// Clock adjusted us
int16_t clk_adj_us;
/// Clock adjusted slots
uint8_t clk_adj_slots;
/// Clock adjusted period (slots)
uint8_t clk_adj_period;
};
/// LM PCA adjustment complete indication structure
/*@TRACE*/
struct lb_pca_end_ind
{
/// Status
uint8_t status;
};
/// LB Sync Scan start request for PCA recovery mode
/*@TRACE*/
struct lb_pca_sscan_start_req
{
/// Link identifier
uint8_t link_id;
/// Status
uint8_t status;
};
#endif //PCA_SUPPORT
/// LB Sync Scan end indication
/*@TRACE*/
struct lb_sscan_end_ind
{
/// Status
uint8_t status;
/// BD_ADDR
struct bd_addr bd_addr;
/// Clock_Offset (28 bits) - (CLKNslave - CLK) modulo 2^28
uint32_t clock_offset;
#if PCA_SUPPORT
/// Bit offset (CLKNslave - CLK) modulo 2^28
int16_t bit_offset;
#endif // PCA_SUPPORT
/// AFH_Channel_Map
struct chnl_map afh_ch_map;
/// LT_ADDR
uint8_t lt_addr;
/// Next_Broadcast_Instant (28 bits)
uint32_t next_bcst_instant;
/// Connectionless_Slave_Broadcast_Interval (in slots)
uint16_t csb_int;
/// Service_Data
uint8_t service_data;
///Coarse clock adjust use
bool coarse_clk_adj;
};
/// LB Sync Train end indication
/*@TRACE*/
struct lb_strain_end_ind
{
///Status
uint8_t status;
///Coarse clock adjust use
bool coarse_clk_adj;
};
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialization of the BT LB task
*
* This function initializes the the LB task, as well as the environment of the LB
****************************************************************************************
*/
void lb_init(void);
/**
****************************************************************************************
* @brief Reset the BT LB task
****************************************************************************************
*/
void lb_reset(void);
/**
****************************************************************************************
* @brief Get num broadcast retransmissions
****************************************************************************************
*/
uint8_t lb_util_get_nb_broadcast(void);
/**
****************************************************************************************
* @brief Set num broadcast retransmissions
****************************************************************************************
*/
void lb_util_set_nb_broadcast(uint8_t num_bcst_ret);
/**
****************************************************************************************
* @brief Get reserved lt_addr
****************************************************************************************
*/
uint8_t lb_util_get_res_lt_addr(void);
/**
****************************************************************************************
* @brief Get CSB mode (active/inactive)
****************************************************************************************
*/
bool lb_util_get_csb_mode(void);
#if PCA_SUPPORT
/**
****************************************************************************************
* @brief Generic handler for a PCA request on a Master device
*
* @param[in] clk_adj_us. Request intraslot adjustment
* @param[in] clk_adj_slots. Request interslot adjustment
* @param[in] clk_adj_period. Period associated with interslot adjustment
* @param[in] tr_id. Transaction ID of the request.
* @return status as a result of processing the request.
****************************************************************************************
*/
uint8_t lb_master_clk_adj_req_handler(int16_t clk_adj_us, uint8_t clk_adj_slots, uint8_t clk_adj_period, uint8_t tr_id);
/**
****************************************************************************************
* @brief This function is used to clear a PCA clk_adj_ack pending flag/count.
*
****************************************************************************************
*/
void lb_clk_adj_ack(uint8_t clk_adj_id, uint8_t link_id);
#endif //PCA_SUPPORT
/**
****************************************************************************************
* @brief This function read the current master key.
*
* @param[out] MasterKey Master key with LTK size
****************************************************************************************
*/
void LM_GetMasterKey(struct ltk *MasterKey);
/**
****************************************************************************************
* @brief This function read the current master key random.
*
* @param[out] MasterRand Master key random
****************************************************************************************
*/
void LM_GetMasterKeyRand(struct ltk *MasterRand);
/**
****************************************************************************************
* @brief This function read the current Random vector for broadcast encryption.
*
* @param[out] MasterRand Random Vector
****************************************************************************************
*/
void LM_GetMasterEncRand(struct ltk *MasterRand);
/**
****************************************************************************************
* @brief This function read Broadcast Encryption Key Size.
*
* @return Encryption Key Size
****************************************************************************************
*/
uint8_t LM_GetMasterEncKeySize(void);
/// @} LB
#endif // LB_H_
+286 -286
View File
@@ -1,286 +1,286 @@
/**
****************************************************************************************
*
* @file lb.h
*
* @brief Link Broadcaster internal definition
*
* Copyright (C) RivieraWaves 2009-2015
*
****************************************************************************************
*/
#ifndef LB_INT_H_
#define LB_INT_H_
#include "rwbt_config.h"
/**
****************************************************************************************
* @addtogroup LB Link Broadcaster
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // standard integer
#include <stdbool.h> // standard boolean
/*
* DEFINES
****************************************************************************************
*/
/// Maximum number of instances of the LB task
#define LB_IDX_MAX 1
/// Default number broadcast retransmissions
#define LB_DEFAULT_NBC 2
/// As default CSB lt_addr is not reserved - invalid value 0 denotes this
#define LB_CSB_LT_ADDR_NOT_RESERVED 0
/// LMP message instant offset, where a specific clock instant is required (in slots)
#define LB_CLK_ADJ_CLK_TX_INSTANT_OFFSET 10
/// Minimum offset to perform a coarse clock adjust
#define LB_PCA_MIN_CC_ADJ_US 40
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Possible states of the LB task
enum LB_STATE
{
/// FREE state
LB_IDLE,
/// WAIT MASTER KEY CFM state message handlers.
LB_WAIT_MASTER_KEY_CFM,
/// WAIT RESTART ENC CFM state message handlers.
LB_WAIT_RESTART_ENC_CFM,
// Number of states.
LB_STATE_MAX
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
#if PCA_SUPPORT
/// LC PCA coase clock adjustment Structure
struct lb_pca_tag
{
/// transaction ID
uint8_t tr_id;
/// aggregate coarse clock adjustment period
uint8_t frame_period;
/// coarse clock adjustment event id
uint8_t clk_adj_id;
/// coarse clock adjustment instant (in 625us BT slots)
uint32_t clk_adj_instant;
/// coarse clock adjustment us offset
int16_t clk_adj_us;
/// coarse clock adjustment slot offset
uint8_t clk_adj_slots;
/// coarse clock adjustment mode
uint8_t clk_adj_mode;
/// coarse clock adjustment PDU instant
uint32_t clk_adj_clk;
/// clock_adj instant pending
bool instant_pending;
/// number of pending LMP_clk_adj_ack responses
uint8_t pending_clk_adj_acks;
/// clk_adj_ack idx flags - one per slave
uint16_t clk_adj_ack_flags;
/// link id recovery with sscan
uint8_t sscan_link_id;
};
#endif // PCA_SUPPORT
///LB master key environment structure
struct master_key
{
/// encryption key size mask
uint16_t enc_key_size_msk;
/// encryption mode
uint8_t enc_mode;
/// status
uint8_t status;
/// in use boolean
bool in_use;
};
/// LB environment structure
struct lb_env_tag
{
#if CSB_SUPPORT
/// reserved lt_addr for CSB
uint8_t res_lt_addr;
/// max packet size for CSB data
uint16_t csb_max_pkt_size;
/// CSB mode active flag
bool csb_mode_enabled;
/// CSB interval (in half-slots)
uint16_t csb_interval;
/// CSB offset (in half-slots)
uint16_t csb_offset;
/// CSB buffer pointer
uint16_t buf_ptr;
/// CSB buffer size
uint16_t csb_buf_data_len;
/// Sync Train service data
uint8_t service_data;
#endif // CSB_SUPPORT
#if CSB_SUPPORT || PCA_SUPPORT
/// Sync Train timeout
uint32_t sync_train_to;
/// Sync Train interval
uint32_t sync_train_intv;
/// Synchronization_scanTO (in slots)
uint16_t sync_scan_to;
/// Sync_Scan_Window (in slots)
uint16_t sync_scan_win;
/// Sync_Scan_Interval (in slots)
uint16_t sync_scan_int;
#endif // CSB_SUPPORT || PCA_SUPPORT
/// Active channel Map for CSB
struct chnl_map ch_map;
/// nb of piconet broadcast acl
uint16_t nb_pic_acl;
/// connection handle
uint16_t conhdl;
/// act handle
uint16_t act_hdl;
/// piconet handle
uint16_t pic_hdl;
/// process id count
uint16_t pid_lc_cnt;
/// nb broadcast retransmissions
uint8_t num_bcst_ret;
#if PCA_SUPPORT
/// Piconet clock adjust data structure
struct lb_pca_tag pca;
#endif // PCA_SUPPORT
/// master key
struct master_key mstkey[MAX_NB_ACTIVE_ACL];
/// bd address
uint8_t lid;
/// new key flag
uint8_t new_key_flag;
/// master key request flag
bool mst_key_req;
/// encryption broadcast
bool enc_brcst;
/// master key
struct ltk LM_MasterKey;
/// master random key
struct ltk LM_MasterKeyRand;
/// master encryption key
struct ltk LM_MasterEncRand;
/// master encryption key size
uint8_t LM_MasterEncKeySize;
};
/*
* GLOBAL VARIABLE DEFINITION
*****************************************************************************************
*/
/// LB task descriptor
extern const struct ke_task_desc TASK_DESC_LB;
/// LB task message handlers table
extern const struct ke_state_handler lb_default_handler;
/// LB task state
extern ke_state_t lb_state[LB_IDX_MAX];
/// LB environment variable
extern struct lb_env_tag lb_env;
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Handle the master key creation.
*
* This function create the master key and send the request over every pid LC
****************************************************************************************
*/
void lb_mst_key(void);
/**
****************************************************************************************
* @brief Handle the master key creation completion.
*
* This function create the master key and send the request over every pid LC
****************************************************************************************
*/
void lb_mst_key_cmp(uint8_t status, uint16_t conhdl, uint8_t new_key_flag);
/**
****************************************************************************************
* @brief Restart encryption
*
* @param[in] conhdl Connection handle
****************************************************************************************
*/
void lb_mst_key_restart_enc(uint16_t conhdl);
/**
****************************************************************************************
* @brief This function start Active Broadcast Encryption link.
****************************************************************************************
*/
void lb_mst_start_act_bcst_enc(void);
/**
****************************************************************************************
* @brief This function Stop Active Broadcast Encryption.
****************************************************************************************
*/
void lb_mst_stop_act_bcst_enc(void);
#if PCA_SUPPORT
/**
****************************************************************************************
* @brief Functions dedicated to send broadcast LMP
*
* @param[in] clk_adj_instant Instant.
* @param[in] clk_adj_id Clock Adjust ID.
* @param[in] clk_adj_us Adjustment us
* @param[in] clk_adj_slots Adjustment slots
* @param[in] clk_adj_mode Mode.
* @param[in] clk_adj_clk Current clock
* @param[in] tr_id Transaction ID
* *****************************************************************************************
*/
void lb_send_pdu_clk_adj(uint32_t clk_adj_instant, uint8_t clk_adj_id, int16_t clk_adj_us, uint8_t clk_adj_slots, uint8_t clk_adj_mode, uint32_t clk_adj_clk, uint8_t tr_id);
#endif //PCA_SUPPORT
/// @} LB
#endif // LB_INT_H_
/**
****************************************************************************************
*
* @file lb.h
*
* @brief Link Broadcaster internal definition
*
* Copyright (C) RivieraWaves 2009-2015
*
****************************************************************************************
*/
#ifndef LB_INT_H_
#define LB_INT_H_
#include "rwbt_config.h"
/**
****************************************************************************************
* @addtogroup LB Link Broadcaster
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // standard integer
#include <stdbool.h> // standard boolean
/*
* DEFINES
****************************************************************************************
*/
/// Maximum number of instances of the LB task
#define LB_IDX_MAX 1
/// Default number broadcast retransmissions
#define LB_DEFAULT_NBC 2
/// As default CSB lt_addr is not reserved - invalid value 0 denotes this
#define LB_CSB_LT_ADDR_NOT_RESERVED 0
/// LMP message instant offset, where a specific clock instant is required (in slots)
#define LB_CLK_ADJ_CLK_TX_INSTANT_OFFSET 10
/// Minimum offset to perform a coarse clock adjust
#define LB_PCA_MIN_CC_ADJ_US 40
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Possible states of the LB task
enum LB_STATE
{
/// FREE state
LB_IDLE,
/// WAIT MASTER KEY CFM state message handlers.
LB_WAIT_MASTER_KEY_CFM,
/// WAIT RESTART ENC CFM state message handlers.
LB_WAIT_RESTART_ENC_CFM,
// Number of states.
LB_STATE_MAX
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
#if PCA_SUPPORT
/// LC PCA coase clock adjustment Structure
struct lb_pca_tag
{
/// transaction ID
uint8_t tr_id;
/// aggregate coarse clock adjustment period
uint8_t frame_period;
/// coarse clock adjustment event id
uint8_t clk_adj_id;
/// coarse clock adjustment instant (in 625us BT slots)
uint32_t clk_adj_instant;
/// coarse clock adjustment us offset
int16_t clk_adj_us;
/// coarse clock adjustment slot offset
uint8_t clk_adj_slots;
/// coarse clock adjustment mode
uint8_t clk_adj_mode;
/// coarse clock adjustment PDU instant
uint32_t clk_adj_clk;
/// clock_adj instant pending
bool instant_pending;
/// number of pending LMP_clk_adj_ack responses
uint8_t pending_clk_adj_acks;
/// clk_adj_ack idx flags - one per slave
uint16_t clk_adj_ack_flags;
/// link id recovery with sscan
uint8_t sscan_link_id;
};
#endif // PCA_SUPPORT
///LB master key environment structure
struct master_key
{
/// encryption key size mask
uint16_t enc_key_size_msk;
/// encryption mode
uint8_t enc_mode;
/// status
uint8_t status;
/// in use boolean
bool in_use;
};
/// LB environment structure
struct lb_env_tag
{
#if CSB_SUPPORT
/// reserved lt_addr for CSB
uint8_t res_lt_addr;
/// max packet size for CSB data
uint16_t csb_max_pkt_size;
/// CSB mode active flag
bool csb_mode_enabled;
/// CSB interval (in half-slots)
uint16_t csb_interval;
/// CSB offset (in half-slots)
uint16_t csb_offset;
/// CSB buffer pointer
uint16_t buf_ptr;
/// CSB buffer size
uint16_t csb_buf_data_len;
/// Sync Train service data
uint8_t service_data;
#endif // CSB_SUPPORT
#if CSB_SUPPORT || PCA_SUPPORT
/// Sync Train timeout
uint32_t sync_train_to;
/// Sync Train interval
uint32_t sync_train_intv;
/// Synchronization_scanTO (in slots)
uint16_t sync_scan_to;
/// Sync_Scan_Window (in slots)
uint16_t sync_scan_win;
/// Sync_Scan_Interval (in slots)
uint16_t sync_scan_int;
#endif // CSB_SUPPORT || PCA_SUPPORT
/// Active channel Map for CSB
struct chnl_map ch_map;
/// nb of piconet broadcast acl
uint16_t nb_pic_acl;
/// connection handle
uint16_t conhdl;
/// act handle
uint16_t act_hdl;
/// piconet handle
uint16_t pic_hdl;
/// process id count
uint16_t pid_lc_cnt;
/// nb broadcast retransmissions
uint8_t num_bcst_ret;
#if PCA_SUPPORT
/// Piconet clock adjust data structure
struct lb_pca_tag pca;
#endif // PCA_SUPPORT
/// master key
struct master_key mstkey[MAX_NB_ACTIVE_ACL];
/// bd address
uint8_t lid;
/// new key flag
uint8_t new_key_flag;
/// master key request flag
bool mst_key_req;
/// encryption broadcast
bool enc_brcst;
/// master key
struct ltk LM_MasterKey;
/// master random key
struct ltk LM_MasterKeyRand;
/// master encryption key
struct ltk LM_MasterEncRand;
/// master encryption key size
uint8_t LM_MasterEncKeySize;
};
/*
* GLOBAL VARIABLE DEFINITION
*****************************************************************************************
*/
/// LB task descriptor
extern const struct ke_task_desc TASK_DESC_LB;
/// LB task message handlers table
extern const struct ke_state_handler lb_default_handler;
/// LB task state
extern ke_state_t lb_state[LB_IDX_MAX];
/// LB environment variable
extern struct lb_env_tag lb_env;
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Handle the master key creation.
*
* This function create the master key and send the request over every pid LC
****************************************************************************************
*/
void lb_mst_key(void);
/**
****************************************************************************************
* @brief Handle the master key creation completion.
*
* This function create the master key and send the request over every pid LC
****************************************************************************************
*/
void lb_mst_key_cmp(uint8_t status, uint16_t conhdl, uint8_t new_key_flag);
/**
****************************************************************************************
* @brief Restart encryption
*
* @param[in] conhdl Connection handle
****************************************************************************************
*/
void lb_mst_key_restart_enc(uint16_t conhdl);
/**
****************************************************************************************
* @brief This function start Active Broadcast Encryption link.
****************************************************************************************
*/
void lb_mst_start_act_bcst_enc(void);
/**
****************************************************************************************
* @brief This function Stop Active Broadcast Encryption.
****************************************************************************************
*/
void lb_mst_stop_act_bcst_enc(void);
#if PCA_SUPPORT
/**
****************************************************************************************
* @brief Functions dedicated to send broadcast LMP
*
* @param[in] clk_adj_instant Instant.
* @param[in] clk_adj_id Clock Adjust ID.
* @param[in] clk_adj_us Adjustment us
* @param[in] clk_adj_slots Adjustment slots
* @param[in] clk_adj_mode Mode.
* @param[in] clk_adj_clk Current clock
* @param[in] tr_id Transaction ID
* *****************************************************************************************
*/
void lb_send_pdu_clk_adj(uint32_t clk_adj_instant, uint8_t clk_adj_id, int16_t clk_adj_us, uint8_t clk_adj_slots, uint8_t clk_adj_mode, uint32_t clk_adj_clk, uint8_t tr_id);
#endif //PCA_SUPPORT
/// @} LB
#endif // LB_INT_H_
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+90 -90
View File
@@ -1,90 +1,90 @@
/**
****************************************************************************************
*
* @file lc_lmppdu.h
*
* @brief LM LMP PDU packing and unpacking utilities header file.
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef LM_LMPPDU_H_
#define LM_LMPPDU_H_
/**
****************************************************************************************
* @defgroup LMLMPPDU LMP PDUs
* @ingroup LM
* @brief LM module for LMP PDU packing and unpacking.
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
* ***************************************************************************************
*/
/**
******************************************************************************************
* @brief Function called to pack and send an LMP PDU.
*
* @param param Pointer to the param part of the ke_msg used to create the PDU structure
* and packet.
*
* @return Length of PDU.
******************************************************************************************
*/
void lc_send_lmp(uint8_t link_id, void *param);
//Functions dedicated to send a LMP
void lc_send_pdu_acc(uint8_t lid,uint8_t opcode,uint8_t tr_id);
void lc_send_pdu_acc_ext4(uint8_t lid,uint8_t opcode,uint8_t tr_id);
void lc_send_pdu_not_acc(uint8_t lid,uint8_t opcode,uint8_t reason,uint8_t tr_id);
void lc_send_pdu_not_acc_ext4(uint8_t lid,uint8_t opcode,uint8_t reason,uint8_t tr_id);
void lc_send_pdu_au_rand(uint8_t lid,struct ltk* random,uint8_t tr_id);
void lc_send_pdu_in_rand(uint8_t lid,struct ltk* random,uint8_t tr_id);
void lc_send_pdu_comb_key(uint8_t lid,struct ltk* random,uint8_t tr_id);
void lc_send_pdu_max_slot(uint8_t lid,uint8_t max_slot,uint8_t tr_id);
void lc_send_pdu_max_slot_req(uint8_t lid,uint8_t max_slot,uint8_t tr_id);
void lc_send_pdu_encaps_payl(uint8_t lid,struct byte16* data,uint8_t tr_id);
void lc_send_pdu_encaps_head(uint8_t idx, uint8_t tr_id, uint8_t maj_type, uint8_t min_type, uint8_t payl_len);
void lc_send_pdu_clk_adj_ack(uint8_t idx, uint8_t clk_adj_id, uint8_t tr_id);
void lc_send_pdu_clk_adj_req(uint8_t idx, uint16_t clk_adj_us, uint8_t clk_adj_slots, uint8_t clk_adj_period, uint8_t tr_id);
void lc_send_pdu_sam_define_map(uint8_t idx, uint8_t sam_index, uint8_t t_sam_sm, uint8_t n_sam_sm, const uint8_t* p_submaps, uint8_t tr_id);
void lc_send_pdu_sam_set_type0(uint8_t idx, uint8_t update_mode, const uint8_t* p_submap, uint8_t tr_id);
void lc_send_pdu_sam_switch(uint8_t idx, uint8_t sam_index, uint8_t flags, uint8_t d_sam, uint32_t instant, uint8_t tr_id);
void lc_send_pdu_ptt_req(uint8_t lid,uint8_t ptt,uint8_t tr_id);
void lc_send_pdu_sp_nb(uint8_t lid,struct byte16* data,uint8_t tr_id);
void lc_send_pdu_sp_cfm(uint8_t lid,struct byte16* data,uint8_t tr_id);
void lc_send_pdu_sres(uint8_t lid,struct sres_nb* data,uint8_t tr_id);
void lc_send_pdu_sco_lk_req(uint8_t lid);
void lc_send_pdu_sco_lk_rem_req(uint8_t lid, uint8_t handle, uint8_t reason,uint8_t tr_id);
void lc_send_pdu_esco_lk_req(uint8_t lid);
void lc_send_pdu_esco_lk_rem_req(uint8_t lid, uint8_t handle, uint8_t reason,uint8_t tr_id);
void lc_send_pdu_auto_rate(uint8_t lid,uint8_t tr_id);
void lc_send_pdu_lsto(uint8_t lid,uint16_t timeout,uint8_t role);
void lc_send_pdu_enc_key_sz_req(uint8_t lid,uint8_t key_size,uint8_t tr_id);
void lc_send_pdu_feats_ext_req(uint8_t lid, uint8_t page, uint8_t tr_id);
void lc_send_pdu_io_cap_res(uint8_t lid);
void lc_send_pdu_num_comp_fail(uint8_t lid,uint8_t tr_id);
void lc_send_pdu_pause_enc_aes_req(uint8_t idx, uint8_t tr_id, struct byte16* random);
void lc_send_pdu_paus_enc_req(uint8_t lid,uint8_t tr_id);
void lc_send_pdu_resu_enc_req(uint8_t lid,uint8_t tr_id);
void lc_send_pdu_setup_cmp(uint8_t lid,uint8_t tr_id);
void lc_send_pdu_qos_req(uint8_t lid,uint8_t nb_bcst, uint16_t poll_int,uint8_t tr_id);
void lc_send_pdu_slot_off(uint8_t lid, uint16_t slot_off,uint8_t tr_id);
void lc_send_pdu_vers_req(uint8_t lid, uint8_t role);
void lc_send_pdu_dhkey_chk(uint8_t lid,struct ltk* dhkey,uint8_t tr_id);
void lc_send_pdu_feats_res(uint8_t lid,uint8_t tr_id);
void lc_send_pdu_set_afh(uint8_t lid,uint32_t instant,uint8_t mode,uint8_t tr_id);
void lc_send_pdu_tim_acc(uint8_t idx,uint8_t tr_id);
/// @} LMLMPPDU
#endif //LM_LMPPDU_H_
/**
****************************************************************************************
*
* @file lc_lmppdu.h
*
* @brief LM LMP PDU packing and unpacking utilities header file.
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef LM_LMPPDU_H_
#define LM_LMPPDU_H_
/**
****************************************************************************************
* @defgroup LMLMPPDU LMP PDUs
* @ingroup LM
* @brief LM module for LMP PDU packing and unpacking.
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
* ***************************************************************************************
*/
/**
******************************************************************************************
* @brief Function called to pack and send an LMP PDU.
*
* @param param Pointer to the param part of the ke_msg used to create the PDU structure
* and packet.
*
* @return Length of PDU.
******************************************************************************************
*/
void lc_send_lmp(uint8_t link_id, void *param);
//Functions dedicated to send a LMP
void lc_send_pdu_acc(uint8_t lid,uint8_t opcode,uint8_t tr_id);
void lc_send_pdu_acc_ext4(uint8_t lid,uint8_t opcode,uint8_t tr_id);
void lc_send_pdu_not_acc(uint8_t lid,uint8_t opcode,uint8_t reason,uint8_t tr_id);
void lc_send_pdu_not_acc_ext4(uint8_t lid,uint8_t opcode,uint8_t reason,uint8_t tr_id);
void lc_send_pdu_au_rand(uint8_t lid,struct ltk* random,uint8_t tr_id);
void lc_send_pdu_in_rand(uint8_t lid,struct ltk* random,uint8_t tr_id);
void lc_send_pdu_comb_key(uint8_t lid,struct ltk* random,uint8_t tr_id);
void lc_send_pdu_max_slot(uint8_t lid,uint8_t max_slot,uint8_t tr_id);
void lc_send_pdu_max_slot_req(uint8_t lid,uint8_t max_slot,uint8_t tr_id);
void lc_send_pdu_encaps_payl(uint8_t lid,struct byte16* data,uint8_t tr_id);
void lc_send_pdu_encaps_head(uint8_t idx, uint8_t tr_id, uint8_t maj_type, uint8_t min_type, uint8_t payl_len);
void lc_send_pdu_clk_adj_ack(uint8_t idx, uint8_t clk_adj_id, uint8_t tr_id);
void lc_send_pdu_clk_adj_req(uint8_t idx, uint16_t clk_adj_us, uint8_t clk_adj_slots, uint8_t clk_adj_period, uint8_t tr_id);
void lc_send_pdu_sam_define_map(uint8_t idx, uint8_t sam_index, uint8_t t_sam_sm, uint8_t n_sam_sm, const uint8_t* p_submaps, uint8_t tr_id);
void lc_send_pdu_sam_set_type0(uint8_t idx, uint8_t update_mode, const uint8_t* p_submap, uint8_t tr_id);
void lc_send_pdu_sam_switch(uint8_t idx, uint8_t sam_index, uint8_t flags, uint8_t d_sam, uint32_t instant, uint8_t tr_id);
void lc_send_pdu_ptt_req(uint8_t lid,uint8_t ptt,uint8_t tr_id);
void lc_send_pdu_sp_nb(uint8_t lid,struct byte16* data,uint8_t tr_id);
void lc_send_pdu_sp_cfm(uint8_t lid,struct byte16* data,uint8_t tr_id);
void lc_send_pdu_sres(uint8_t lid,struct sres_nb* data,uint8_t tr_id);
void lc_send_pdu_sco_lk_req(uint8_t lid);
void lc_send_pdu_sco_lk_rem_req(uint8_t lid, uint8_t handle, uint8_t reason,uint8_t tr_id);
void lc_send_pdu_esco_lk_req(uint8_t lid);
void lc_send_pdu_esco_lk_rem_req(uint8_t lid, uint8_t handle, uint8_t reason,uint8_t tr_id);
void lc_send_pdu_auto_rate(uint8_t lid,uint8_t tr_id);
void lc_send_pdu_lsto(uint8_t lid,uint16_t timeout,uint8_t role);
void lc_send_pdu_enc_key_sz_req(uint8_t lid,uint8_t key_size,uint8_t tr_id);
void lc_send_pdu_feats_ext_req(uint8_t lid, uint8_t page, uint8_t tr_id);
void lc_send_pdu_io_cap_res(uint8_t lid);
void lc_send_pdu_num_comp_fail(uint8_t lid,uint8_t tr_id);
void lc_send_pdu_pause_enc_aes_req(uint8_t idx, uint8_t tr_id, struct byte16* random);
void lc_send_pdu_paus_enc_req(uint8_t lid,uint8_t tr_id);
void lc_send_pdu_resu_enc_req(uint8_t lid,uint8_t tr_id);
void lc_send_pdu_setup_cmp(uint8_t lid,uint8_t tr_id);
void lc_send_pdu_qos_req(uint8_t lid,uint8_t nb_bcst, uint16_t poll_int,uint8_t tr_id);
void lc_send_pdu_slot_off(uint8_t lid, uint16_t slot_off,uint8_t tr_id);
void lc_send_pdu_vers_req(uint8_t lid, uint8_t role);
void lc_send_pdu_dhkey_chk(uint8_t lid,struct ltk* dhkey,uint8_t tr_id);
void lc_send_pdu_feats_res(uint8_t lid,uint8_t tr_id);
void lc_send_pdu_set_afh(uint8_t lid,uint32_t instant,uint8_t mode,uint8_t tr_id);
void lc_send_pdu_tim_acc(uint8_t idx,uint8_t tr_id);
/// @} LMLMPPDU
#endif //LM_LMPPDU_H_
+194 -194
View File
@@ -1,194 +1,194 @@
/**
****************************************************************************************
*
* @file lc_sco.h
*
* @brief Definitions for LC SCO procedures
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef LC_SCO_H_
#define LC_SCO_H_
/**
****************************************************************************************
* @defgroup LCSCO Synchronous Connection Oriented connection
* @ingroup LC
* @brief Responsible for handling SCO procedures.
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // stack configuration
#if (MAX_NB_SYNC > 0)
#include <stdint.h> // integer
#include <stdbool.h> // boolean
#include "ke_task.h" // kernel task
/*
* CONSTANT DEFINITIONS
****************************************************************************************
*/
/*
* STRUCTURE DEFINITIONS
****************************************************************************************
*/
/// Structure for (e)SCO parameters
struct lc_sco_air_params_tag
{
///Transaction ID
uint8_t tr_id;
/// eSCO handle
uint8_t esco_hdl;
/// eSCo LT Address
uint8_t esco_lt_addr;
/// Timing control flags
uint8_t flags;
/// Dsco or Desco (in slots)
uint8_t d_esco;
/// Interval (in slots)
uint8_t t_esco;
/// Retransmission window size (in slots)
uint8_t w_esco;
/// Packet M->S type
uint8_t m2s_pkt_type;
/// Packet S->M type
uint8_t s2m_pkt_type;
/// Packet M->S length for eSCO link (in bytes)
uint16_t m2s_pkt_len;
/// Packet S->M length for eSCO link (in bytes)
uint16_t s2m_pkt_len;
/// Air Mode
uint8_t air_mode;
/// Negotiation state
uint8_t nego_state;
};
/// Structure for Host synchronous parameters
struct lc_sco_host_params_tag
{
uint32_t tx_bw; // Transmit Bandwidth (in B/sec)
uint32_t rx_bw; // Receive Bandwidth (in B/sec)
uint8_t tx_cod_fmt[5]; // Transmit Coding Format
uint8_t rx_cod_fmt[5]; // Receive Coding Format
uint16_t tx_cod_fr_sz; // Transmit Codec Frame Size (in B)
uint16_t rx_cod_fr_sz; // Receive Codec Frame Size (in B)
uint32_t in_bw; // Input Bandwidth (in B/sec)
uint32_t out_bw; // Output Bandwidth (in B/sec)
uint8_t in_cod_fmt[5]; // Input Coding Format
uint8_t out_cod_fmt[5]; // Output Coding Format
uint16_t in_cod_data_sz; // Input Coded Data Size (in bits)
uint16_t out_cod_data_sz; // Output Coded Data Size (in bits)
uint8_t in_data_fmt; // Input PCM Data Format
uint8_t out_data_fmt; // Output PCM Data Format
uint8_t in_msb_pos; // Input PCM Sample Payload MSB Position (in bits)
uint8_t out_msb_pos; // Output PCM Sample Payload MSB Position (in bits)
uint8_t in_data_path; // Input Data Path (VoHCI / PCM / Other ...)
uint8_t out_data_path; // Output Data Path
uint8_t in_tr_unit_sz; // Input Transport Unit Size (in bits)
uint8_t out_tr_unit_sz; // Output Transport Unit Size (in bits)
uint16_t max_lat; // Max Latency (in ms)
uint16_t packet_type; // Packet Type (HV1 / HV2 / HV3 / EV3 / EV4 / EV5 / 2EV3 / 3EV3 / 2EV5 / 3EV5)
uint8_t retx_eff; // Retransmission Effort (No, opt power, opt quality, don't care)
};
/*
* FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialize the LC_SCO module
****************************************************************************************
*/
void lc_sco_init(void);
/**
****************************************************************************************
* @brief Reset LC_SCO module
****************************************************************************************
*/
void lc_sco_reset(void);
/**
****************************************************************************************
* @brief Detach all SCO connections on a ACL link
*
* This function starts the disconnection of all SCO links on a ACL connection.
*
* When the full disconnection procedure is requested, each disconnection procedure
* loops to this function to restart the next disconnection until no more SCO on the ACL
* is present.
*
* Host is NOT notified for each SCO link disconnection.
*
* param[in] pid Process identifier (task / instance)
* param[in] reason Detach reason (error code)
*
* return status
****************************************************************************************
*/
uint8_t lc_sco_detach(ke_task_id_t pid, uint8_t reason);
/**
****************************************************************************************
* @brief Release all SCO connections on a ACL link
*
* This function releases all SCO links on a ACL connection, without notification to the
* peer device. However, Host is notified for each SCO link disconnection.
*
* param[in] pid Process identifier (task / instance)
* param[in] reason Detach reason (error code)
****************************************************************************************
*/
void lc_sco_release(ke_task_id_t pid, uint8_t reason);
uint8_t lc_sco_host_request(ke_task_id_t pid, bool old_style, bool host_initiated, uint16_t conhdl, struct lc_sco_host_params_tag * p_host_params);
uint8_t lc_sco_host_accept(ke_task_id_t pid, bool old_style, bool very_old_style, struct lc_sco_host_params_tag * p_host_params);
void lc_sco_host_reject(ke_task_id_t pid, bool very_old_style, uint8_t status);
uint8_t lc_sco_host_request_disc(ke_task_id_t pid, uint16_t conhdl, uint8_t reason);
void lc_sco_peer_request(ke_task_id_t pid, uint8_t req_type, struct lc_sco_air_params_tag * p_peer_params);
void lc_sco_peer_accept(ke_task_id_t pid);
void lc_sco_peer_reject(ke_task_id_t pid, uint8_t reason);
void lc_sco_peer_request_disc(ke_task_id_t pid, uint8_t req_type, uint8_t scohdl, uint8_t reason);
void lc_sco_peer_accept_disc(ke_task_id_t pid);
void lc_sco_peer_reject_disc(ke_task_id_t pid, uint8_t reason);
void lc_sco_baseband_ack(ke_task_id_t pid, uint8_t lmp_opcode);
void lc_sco_timeout(ke_task_id_t pid);
/**
****************************************************************************************
* @brief This function is used to update the SCO offset.
*
* @param[in] sync_linkid SCO link ID
* @param[in] sco_offset SCO offset in slots
*
* @return True if SCO link present
****************************************************************************************
*/
void lc_sco_offset_update(uint8_t sync_linkid, uint16_t sco_offset);
#endif // (MAX_NB_SYNC > 0)
/// @} LCSCO
#endif // LC_SCO_H_
/**
****************************************************************************************
*
* @file lc_sco.h
*
* @brief Definitions for LC SCO procedures
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef LC_SCO_H_
#define LC_SCO_H_
/**
****************************************************************************************
* @defgroup LCSCO Synchronous Connection Oriented connection
* @ingroup LC
* @brief Responsible for handling SCO procedures.
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // stack configuration
#if (MAX_NB_SYNC > 0)
#include <stdint.h> // integer
#include <stdbool.h> // boolean
#include "ke_task.h" // kernel task
/*
* CONSTANT DEFINITIONS
****************************************************************************************
*/
/*
* STRUCTURE DEFINITIONS
****************************************************************************************
*/
/// Structure for (e)SCO parameters
struct lc_sco_air_params_tag
{
///Transaction ID
uint8_t tr_id;
/// eSCO handle
uint8_t esco_hdl;
/// eSCo LT Address
uint8_t esco_lt_addr;
/// Timing control flags
uint8_t flags;
/// Dsco or Desco (in slots)
uint8_t d_esco;
/// Interval (in slots)
uint8_t t_esco;
/// Retransmission window size (in slots)
uint8_t w_esco;
/// Packet M->S type
uint8_t m2s_pkt_type;
/// Packet S->M type
uint8_t s2m_pkt_type;
/// Packet M->S length for eSCO link (in bytes)
uint16_t m2s_pkt_len;
/// Packet S->M length for eSCO link (in bytes)
uint16_t s2m_pkt_len;
/// Air Mode
uint8_t air_mode;
/// Negotiation state
uint8_t nego_state;
};
/// Structure for Host synchronous parameters
struct lc_sco_host_params_tag
{
uint32_t tx_bw; // Transmit Bandwidth (in B/sec)
uint32_t rx_bw; // Receive Bandwidth (in B/sec)
uint8_t tx_cod_fmt[5]; // Transmit Coding Format
uint8_t rx_cod_fmt[5]; // Receive Coding Format
uint16_t tx_cod_fr_sz; // Transmit Codec Frame Size (in B)
uint16_t rx_cod_fr_sz; // Receive Codec Frame Size (in B)
uint32_t in_bw; // Input Bandwidth (in B/sec)
uint32_t out_bw; // Output Bandwidth (in B/sec)
uint8_t in_cod_fmt[5]; // Input Coding Format
uint8_t out_cod_fmt[5]; // Output Coding Format
uint16_t in_cod_data_sz; // Input Coded Data Size (in bits)
uint16_t out_cod_data_sz; // Output Coded Data Size (in bits)
uint8_t in_data_fmt; // Input PCM Data Format
uint8_t out_data_fmt; // Output PCM Data Format
uint8_t in_msb_pos; // Input PCM Sample Payload MSB Position (in bits)
uint8_t out_msb_pos; // Output PCM Sample Payload MSB Position (in bits)
uint8_t in_data_path; // Input Data Path (VoHCI / PCM / Other ...)
uint8_t out_data_path; // Output Data Path
uint8_t in_tr_unit_sz; // Input Transport Unit Size (in bits)
uint8_t out_tr_unit_sz; // Output Transport Unit Size (in bits)
uint16_t max_lat; // Max Latency (in ms)
uint16_t packet_type; // Packet Type (HV1 / HV2 / HV3 / EV3 / EV4 / EV5 / 2EV3 / 3EV3 / 2EV5 / 3EV5)
uint8_t retx_eff; // Retransmission Effort (No, opt power, opt quality, don't care)
};
/*
* FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialize the LC_SCO module
****************************************************************************************
*/
void lc_sco_init(void);
/**
****************************************************************************************
* @brief Reset LC_SCO module
****************************************************************************************
*/
void lc_sco_reset(void);
/**
****************************************************************************************
* @brief Detach all SCO connections on a ACL link
*
* This function starts the disconnection of all SCO links on a ACL connection.
*
* When the full disconnection procedure is requested, each disconnection procedure
* loops to this function to restart the next disconnection until no more SCO on the ACL
* is present.
*
* Host is NOT notified for each SCO link disconnection.
*
* param[in] pid Process identifier (task / instance)
* param[in] reason Detach reason (error code)
*
* return status
****************************************************************************************
*/
uint8_t lc_sco_detach(ke_task_id_t pid, uint8_t reason);
/**
****************************************************************************************
* @brief Release all SCO connections on a ACL link
*
* This function releases all SCO links on a ACL connection, without notification to the
* peer device. However, Host is notified for each SCO link disconnection.
*
* param[in] pid Process identifier (task / instance)
* param[in] reason Detach reason (error code)
****************************************************************************************
*/
void lc_sco_release(ke_task_id_t pid, uint8_t reason);
uint8_t lc_sco_host_request(ke_task_id_t pid, bool old_style, bool host_initiated, uint16_t conhdl, struct lc_sco_host_params_tag * p_host_params);
uint8_t lc_sco_host_accept(ke_task_id_t pid, bool old_style, bool very_old_style, struct lc_sco_host_params_tag * p_host_params);
void lc_sco_host_reject(ke_task_id_t pid, bool very_old_style, uint8_t status);
uint8_t lc_sco_host_request_disc(ke_task_id_t pid, uint16_t conhdl, uint8_t reason);
void lc_sco_peer_request(ke_task_id_t pid, uint8_t req_type, struct lc_sco_air_params_tag * p_peer_params);
void lc_sco_peer_accept(ke_task_id_t pid);
void lc_sco_peer_reject(ke_task_id_t pid, uint8_t reason);
void lc_sco_peer_request_disc(ke_task_id_t pid, uint8_t req_type, uint8_t scohdl, uint8_t reason);
void lc_sco_peer_accept_disc(ke_task_id_t pid);
void lc_sco_peer_reject_disc(ke_task_id_t pid, uint8_t reason);
void lc_sco_baseband_ack(ke_task_id_t pid, uint8_t lmp_opcode);
void lc_sco_timeout(ke_task_id_t pid);
/**
****************************************************************************************
* @brief This function is used to update the SCO offset.
*
* @param[in] sync_linkid SCO link ID
* @param[in] sco_offset SCO offset in slots
*
* @return True if SCO link present
****************************************************************************************
*/
void lc_sco_offset_update(uint8_t sync_linkid, uint16_t sco_offset);
#endif // (MAX_NB_SYNC > 0)
/// @} LCSCO
#endif // LC_SCO_H_
+111 -111
View File
@@ -1,111 +1,111 @@
/**
****************************************************************************************
*
* @file lm_lowpow.h
*
* @brief Link Manager Utilities functions
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef LM_LOWPOW_H_
#define LM_LOWPOW_H_
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // stack configuration
#include <stdint.h> // integer
#include <stdbool.h> // boolean
/**
****************************************************************************************
* @defgroup LMLOWPOW Low Power Functions
* @ingroup LM
* @brief LM module for low power mode management (sniff, hold, park).
* @{
****************************************************************************************
*/
/// Commands for Sniff
#define SNIFF_HL_REQ 0
#define SNIFF_PEER_REQ 1
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initializes Sniff block.
****************************************************************************************
*/
void lc_sniff_init(bool reset);
/**
****************************************************************************************
* @brief Clear sniff parameters of a specific link
****************************************************************************************
*/
void lc_sniff_clear(uint8_t link_id);
/**
****************************************************************************************
* @brief Get sniff interval and subrate
* @param[in] link_id Link identifier
* @param[out] interval Sniff interval (in slots)
* @param[out] max_subrate Maximum sniff subrate (in number of sniff events, 0 if no subrating)
****************************************************************************************
*/
void lc_sniff_interval_get(uint8_t link_id, uint16_t * interval, uint8_t * max_subrate);
/**
****************************************************************************************
* @brief This function is used to update the sniff offset
*
* @param[in] link_id Link identifier
* @param[in] sniff_offset Sniff offset in half-slots
****************************************************************************************
*/
void lc_sniff_offset_update(uint8_t link_id, uint16_t sniff_offset);
void lc_sniff_host_request(ke_task_id_t pid, uint16_t max_int, uint16_t min_int, uint16_t attempt, uint16_t timeout);
void lc_sniff_peer_request(ke_task_id_t pid, uint8_t flags, uint16_t d_sniff, uint16_t t_sniff, uint16_t sniff_attempt, uint16_t sniff_to);
void lc_sniff_peer_accept(ke_task_id_t pid);
void lc_sniff_peer_reject(ke_task_id_t pid, uint8_t reason);
void lc_sniff_baseband_ack(ke_task_id_t pid, uint8_t lmp_opcode);
void lc_sniff_timeout(ke_task_id_t pid);
/**
****************************************************************************************
* @brief Unsniff link
*
* This function initiating an unsniff LMP procedure.
*
* param[in] pid Process identifier (task / instance)
****************************************************************************************
*/
void lc_sniff_unsniff(ke_task_id_t pid);
void lc_sniff_unsniff_peer_request(ke_task_id_t pid);
void lc_sniff_unsniff_peer_accept(ke_task_id_t pid);
void lc_sniff_unsniff_peer_reject(ke_task_id_t pid, uint8_t reason);
void lc_sniff_ssr_nego(ke_task_id_t pid);
void lc_sniff_ssr_host_request(ke_task_id_t pid, uint16_t max_lat, uint16_t min_rem_to, uint16_t min_loc_to);
void lc_sniff_ssr_peer_request(ke_task_id_t pid, uint8_t max_subrate, uint16_t min_to, uint32_t instant);
void lc_sniff_ssr_peer_response(ke_task_id_t pid, uint8_t max_subrate, uint16_t min_to, uint32_t instant);
void lc_sniff_ssr_peer_reject(ke_task_id_t pid, uint8_t reason);
void lc_sniff_ssr_baseband_ack(ke_task_id_t pid);
void lc_sniff_ssr_instant(ke_task_id_t pid);
///@} LMLOWPOW
#endif // LM_LMLOWPOW_H_
/**
****************************************************************************************
*
* @file lm_lowpow.h
*
* @brief Link Manager Utilities functions
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef LM_LOWPOW_H_
#define LM_LOWPOW_H_
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // stack configuration
#include <stdint.h> // integer
#include <stdbool.h> // boolean
/**
****************************************************************************************
* @defgroup LMLOWPOW Low Power Functions
* @ingroup LM
* @brief LM module for low power mode management (sniff, hold, park).
* @{
****************************************************************************************
*/
/// Commands for Sniff
#define SNIFF_HL_REQ 0
#define SNIFF_PEER_REQ 1
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initializes Sniff block.
****************************************************************************************
*/
void lc_sniff_init(bool reset);
/**
****************************************************************************************
* @brief Clear sniff parameters of a specific link
****************************************************************************************
*/
void lc_sniff_clear(uint8_t link_id);
/**
****************************************************************************************
* @brief Get sniff interval and subrate
* @param[in] link_id Link identifier
* @param[out] interval Sniff interval (in slots)
* @param[out] max_subrate Maximum sniff subrate (in number of sniff events, 0 if no subrating)
****************************************************************************************
*/
void lc_sniff_interval_get(uint8_t link_id, uint16_t * interval, uint8_t * max_subrate);
/**
****************************************************************************************
* @brief This function is used to update the sniff offset
*
* @param[in] link_id Link identifier
* @param[in] sniff_offset Sniff offset in half-slots
****************************************************************************************
*/
void lc_sniff_offset_update(uint8_t link_id, uint16_t sniff_offset);
void lc_sniff_host_request(ke_task_id_t pid, uint16_t max_int, uint16_t min_int, uint16_t attempt, uint16_t timeout);
void lc_sniff_peer_request(ke_task_id_t pid, uint8_t flags, uint16_t d_sniff, uint16_t t_sniff, uint16_t sniff_attempt, uint16_t sniff_to);
void lc_sniff_peer_accept(ke_task_id_t pid);
void lc_sniff_peer_reject(ke_task_id_t pid, uint8_t reason);
void lc_sniff_baseband_ack(ke_task_id_t pid, uint8_t lmp_opcode);
void lc_sniff_timeout(ke_task_id_t pid);
/**
****************************************************************************************
* @brief Unsniff link
*
* This function initiating an unsniff LMP procedure.
*
* param[in] pid Process identifier (task / instance)
****************************************************************************************
*/
void lc_sniff_unsniff(ke_task_id_t pid);
void lc_sniff_unsniff_peer_request(ke_task_id_t pid);
void lc_sniff_unsniff_peer_accept(ke_task_id_t pid);
void lc_sniff_unsniff_peer_reject(ke_task_id_t pid, uint8_t reason);
void lc_sniff_ssr_nego(ke_task_id_t pid);
void lc_sniff_ssr_host_request(ke_task_id_t pid, uint16_t max_lat, uint16_t min_rem_to, uint16_t min_loc_to);
void lc_sniff_ssr_peer_request(ke_task_id_t pid, uint8_t max_subrate, uint16_t min_to, uint32_t instant);
void lc_sniff_ssr_peer_response(ke_task_id_t pid, uint8_t max_subrate, uint16_t min_to, uint32_t instant);
void lc_sniff_ssr_peer_reject(ke_task_id_t pid, uint8_t reason);
void lc_sniff_ssr_baseband_ack(ke_task_id_t pid);
void lc_sniff_ssr_instant(ke_task_id_t pid);
///@} LMLOWPOW
#endif // LM_LMLOWPOW_H_
+229 -229
View File
@@ -1,229 +1,229 @@
/**
****************************************************************************************
*
* @file lc_util.h
*
* @brief LC Util API
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef LC_UTIL_H_
#define LC_UTIL_H_
/**
****************************************************************************************
* @addtogroup LCUTIL Link Controller
* @ingroup CONTROLLER
* @brief Link Layer Controller utility
*
* Declaration of the API functions to be called by other layers
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // integer
#include <stdbool.h> // bool
#include "co_bt.h"
#include "ke_msg.h" // kernel timer definition
/*
* DEFINES
****************************************************************************************
*/
/*
* CONSTANT DEFINITIONS
****************************************************************************************
*/
#define QOS_HL_REQ 0
#define QOS_PEER_REQ 1
#define QOS_PEER_FORCE 2
#define QOS_PEER_REJECT 3
/*
* MACRO DEFINITIONS
****************************************************************************************
*/
/*
* STRUCTURE DEFINITIONS
****************************************************************************************
*/
/*
* FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief This function is used to compute the resulting ACL packet types.
*
* @param[in] PreferredPacketType Preferred packet type
* @param[in] CurrentPacketType Current packet type in use
* @param[in] KeepCurrent Boolean to keep the current packet type
*
* @return PacketType
****************************************************************************************
*/
uint16_t LM_ComputePacketType(uint16_t PreferredPacketType, uint16_t CurrentPacketType, bool KeepCurrent);
/**
****************************************************************************************
* @brief This function is used to check which ACL packet types are allowed.
*
* @param[in] PacketType ACL packet type
* @param[in] RemoteCapability Remote device capability
*
* @return PacketType
****************************************************************************************
*/
uint16_t LM_UpdateAclPacketType(uint16_t PacketType, uint8_t RemoteCapability);
/**
****************************************************************************************
* @brief This function is used to check which EDR ACL packet types are allowed.
*
* @param[in] PacketType Requested Packet type
* @param[in] RemoteCapabilityByte3 Capability of Remote device
* @param[in] RemoteCapabilityByte4 Capability of Remote device
* @param[in] RemoteCapabilityByte5 Capability of Remote device
*
* @return PossiblePacketType
****************************************************************************************
*/
uint16_t LM_UpdateAclEdrPacketType(uint16_t PacketType,
uint8_t RemoteCapabilityByte3,
uint8_t RemoteCapabilityByte4,
uint8_t RemoteCapabilityByte5);
/**
****************************************************************************************
* @brief This function is used to removed ACL packet type.
*
* @param[out] ReqPacketType Possible packet type
* @param[in] Slot Packet slot (1, 3, 5)
****************************************************************************************
*/
void LM_SuppressAclPacket(uint16_t *ReqPacketType, uint8_t Slot);
/**
****************************************************************************************
* @brief This function is used to retrieve the Quality of Service information
* linked with the connection handle.
*
* @param[in] Role Device role connection
* @param[out] ServiceType Type of service
* @param[out] TokenRate Token rate
* @param[out] PeakBandwidth Bandwidth peak
* @param[out] Latency Latency
* @param[out] DelayVariation Variation
* @param[out] PollInterval Polling interval. Should be even value.
* @param[in] PacketType Type of packet
* @param[in] Request Request type (HL, PEER, FORCE, REJECT)
*
* @return Status
****************************************************************************************
*/
uint8_t LM_GetQoSParam(uint8_t Role, uint8_t *ServiceType,
uint32_t *TokenRate, uint32_t *PeakBandwidth, uint32_t *Latency,
uint32_t *DelayVariation, uint16_t *PollInterval,
uint16_t PacketType, uint8_t Request);
/**
****************************************************************************************
* @brief This function make a COF from a BD_ADDR.
*
* @param[in] BdAddr BD Address
* @param[out] Aco ACO value
****************************************************************************************
*/
void LM_MakeCof(struct bd_addr BdAddr, struct aco *Aco);
/**
****************************************************************************************
* @brief This function is used to check all the EDR features available.
*
* @param[in] RequestFeatures Feature table
*
* @return True if found, False otherwise.
****************************************************************************************
*/
bool LM_CheckEdrFeatureRequest(uint16_t RequestFeatures);
/**
****************************************************************************************
* @brief This function is used to get a feature.
*
* @param[in] FeaturesPtr Feature table
* @param[in] Feature Feature to extract
*
* @return 0 (not found) or 1 (found)
****************************************************************************************
*/
uint16_t LM_GetFeature(struct features *FeaturesPtr, uint8_t Feature);
/**
****************************************************************************************
* @brief This function is used to check if a link key is stored.
*
* @param[in] p_bd_addr BD Address to search
* @param[out] Key Link key
*
* @return Boolean, True if key found, False otherwise
****************************************************************************************
*/
bool lm_look_for_stored_link_key(struct bd_addr *p_bd_addr, struct ltk *Key);
/**
****************************************************************************************
* @brief Converts the Preferred Rate into TX packet type for
* the corresponding link ID.
*
* @param[in] PreferredRate Preferred Rate for the link
* @param[in] pkt_type_table 0: 1MBPS / 1: 2-3MBPS
*
* @return Preferred Packet types
****************************************************************************************
*/
uint16_t lc_util_convert_pref_rate_to_packet_type(uint8_t PreferredRate, uint8_t pkt_type_table);
/**
****************************************************************************************
* @brief Converts the maxslot into TX packet type
*
* @param[in] maxslot Maximum number of slots
*
* @return Possible Packet types
****************************************************************************************
*/
uint16_t lc_util_convert_maxslot_to_packet_type(uint8_t maxslot);
#if MAX_NB_SYNC
/**
****************************************************************************************
* @brief This function is used to get the common packet types
*
* @param[in] SyncPacketType Original packets type (SCO and/or eSCO)
* @param[in] *RemoteFeaturesPtr Pointer on Remote features
*
* @return Common packet types (bit mask)
****************************************************************************************
*/
uint16_t lm_get_common_pkt_types(uint16_t SyncPacketType, struct features *RemoteFeaturesPtr);
#endif // MAX_NB_SYNC
/// @} LC
#endif // LC_UTIL_H_
/**
****************************************************************************************
*
* @file lc_util.h
*
* @brief LC Util API
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef LC_UTIL_H_
#define LC_UTIL_H_
/**
****************************************************************************************
* @addtogroup LCUTIL Link Controller
* @ingroup CONTROLLER
* @brief Link Layer Controller utility
*
* Declaration of the API functions to be called by other layers
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // integer
#include <stdbool.h> // bool
#include "co_bt.h"
#include "ke_msg.h" // kernel timer definition
/*
* DEFINES
****************************************************************************************
*/
/*
* CONSTANT DEFINITIONS
****************************************************************************************
*/
#define QOS_HL_REQ 0
#define QOS_PEER_REQ 1
#define QOS_PEER_FORCE 2
#define QOS_PEER_REJECT 3
/*
* MACRO DEFINITIONS
****************************************************************************************
*/
/*
* STRUCTURE DEFINITIONS
****************************************************************************************
*/
/*
* FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief This function is used to compute the resulting ACL packet types.
*
* @param[in] PreferredPacketType Preferred packet type
* @param[in] CurrentPacketType Current packet type in use
* @param[in] KeepCurrent Boolean to keep the current packet type
*
* @return PacketType
****************************************************************************************
*/
uint16_t LM_ComputePacketType(uint16_t PreferredPacketType, uint16_t CurrentPacketType, bool KeepCurrent);
/**
****************************************************************************************
* @brief This function is used to check which ACL packet types are allowed.
*
* @param[in] PacketType ACL packet type
* @param[in] RemoteCapability Remote device capability
*
* @return PacketType
****************************************************************************************
*/
uint16_t LM_UpdateAclPacketType(uint16_t PacketType, uint8_t RemoteCapability);
/**
****************************************************************************************
* @brief This function is used to check which EDR ACL packet types are allowed.
*
* @param[in] PacketType Requested Packet type
* @param[in] RemoteCapabilityByte3 Capability of Remote device
* @param[in] RemoteCapabilityByte4 Capability of Remote device
* @param[in] RemoteCapabilityByte5 Capability of Remote device
*
* @return PossiblePacketType
****************************************************************************************
*/
uint16_t LM_UpdateAclEdrPacketType(uint16_t PacketType,
uint8_t RemoteCapabilityByte3,
uint8_t RemoteCapabilityByte4,
uint8_t RemoteCapabilityByte5);
/**
****************************************************************************************
* @brief This function is used to removed ACL packet type.
*
* @param[out] ReqPacketType Possible packet type
* @param[in] Slot Packet slot (1, 3, 5)
****************************************************************************************
*/
void LM_SuppressAclPacket(uint16_t *ReqPacketType, uint8_t Slot);
/**
****************************************************************************************
* @brief This function is used to retrieve the Quality of Service information
* linked with the connection handle.
*
* @param[in] Role Device role connection
* @param[out] ServiceType Type of service
* @param[out] TokenRate Token rate
* @param[out] PeakBandwidth Bandwidth peak
* @param[out] Latency Latency
* @param[out] DelayVariation Variation
* @param[out] PollInterval Polling interval. Should be even value.
* @param[in] PacketType Type of packet
* @param[in] Request Request type (HL, PEER, FORCE, REJECT)
*
* @return Status
****************************************************************************************
*/
uint8_t LM_GetQoSParam(uint8_t Role, uint8_t *ServiceType,
uint32_t *TokenRate, uint32_t *PeakBandwidth, uint32_t *Latency,
uint32_t *DelayVariation, uint16_t *PollInterval,
uint16_t PacketType, uint8_t Request);
/**
****************************************************************************************
* @brief This function make a COF from a BD_ADDR.
*
* @param[in] BdAddr BD Address
* @param[out] Aco ACO value
****************************************************************************************
*/
void LM_MakeCof(struct bd_addr BdAddr, struct aco *Aco);
/**
****************************************************************************************
* @brief This function is used to check all the EDR features available.
*
* @param[in] RequestFeatures Feature table
*
* @return True if found, False otherwise.
****************************************************************************************
*/
bool LM_CheckEdrFeatureRequest(uint16_t RequestFeatures);
/**
****************************************************************************************
* @brief This function is used to get a feature.
*
* @param[in] FeaturesPtr Feature table
* @param[in] Feature Feature to extract
*
* @return 0 (not found) or 1 (found)
****************************************************************************************
*/
uint16_t LM_GetFeature(struct features *FeaturesPtr, uint8_t Feature);
/**
****************************************************************************************
* @brief This function is used to check if a link key is stored.
*
* @param[in] p_bd_addr BD Address to search
* @param[out] Key Link key
*
* @return Boolean, True if key found, False otherwise
****************************************************************************************
*/
bool lm_look_for_stored_link_key(struct bd_addr *p_bd_addr, struct ltk *Key);
/**
****************************************************************************************
* @brief Converts the Preferred Rate into TX packet type for
* the corresponding link ID.
*
* @param[in] PreferredRate Preferred Rate for the link
* @param[in] pkt_type_table 0: 1MBPS / 1: 2-3MBPS
*
* @return Preferred Packet types
****************************************************************************************
*/
uint16_t lc_util_convert_pref_rate_to_packet_type(uint8_t PreferredRate, uint8_t pkt_type_table);
/**
****************************************************************************************
* @brief Converts the maxslot into TX packet type
*
* @param[in] maxslot Maximum number of slots
*
* @return Possible Packet types
****************************************************************************************
*/
uint16_t lc_util_convert_maxslot_to_packet_type(uint8_t maxslot);
#if MAX_NB_SYNC
/**
****************************************************************************************
* @brief This function is used to get the common packet types
*
* @param[in] SyncPacketType Original packets type (SCO and/or eSCO)
* @param[in] *RemoteFeaturesPtr Pointer on Remote features
*
* @return Common packet types (bit mask)
****************************************************************************************
*/
uint16_t lm_get_common_pkt_types(uint16_t SyncPacketType, struct features *RemoteFeaturesPtr);
#endif // MAX_NB_SYNC
/// @} LC
#endif // LC_UTIL_H_
+194 -194
View File
@@ -1,194 +1,194 @@
/**
****************************************************************************************
*
* @file lm_sco.h
*
* @brief Link Manager synchronous link functions
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef LM_SCO_H_
#define LM_SCO_H_
/**
****************************************************************************************
* @defgroup LMSCO SCO Functions
* @ingroup LM
* @brief LM module for synchronous functions.
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // stack configuration
#if (MAX_NB_SYNC > 0)
#include "lc_sco.h"
/*
* DEFINITION
* ***************************************************************************************
*/
/// Commands for synchronous link
#define SYNC_HL_REQ 0
#define SYNC_PEER_REQ 1
#define SYNC_HL_RSP 2
#define SYNC_PEER_RSP 3
#define SYNC_HL_MODIF 4
#define SYNC_PEER_MODIF 5
#define SYNC_UPDATE 6
/*
* FUNCTION DECLARATIONS
* ***************************************************************************************
*/
/**
****************************************************************************************
* @brief This function is used to initialize LM Sco Data.
****************************************************************************************
*/
void lm_init_sync(void);
/**
****************************************************************************************
* @brief This function is used to reset LM Sco Data.
****************************************************************************************
*/
void lm_reset_sync(void);
/**
****************************************************************************************
* @brief This function is used to check and store informations about a SCO link.
*
* @param[in] sco_link_id Synchronous link ID
* @param[in] RemoteFeatures Remote device features
* @param[in] Role Master or Slave
* @param[in] SyncType SCO or eSCO
* @param[in] SyncLtAddr Synchronous link LT address
* @param[out] *SyncHdl Synchronous link handle
* @param[in] SyncTxBw TX bandwidth
* @param[in] SyncRxBw RX bandwidth
* @param[in] SyncLat Maximum allowed Latency
* @param[in] SyncVoice Voice settings
* @param[in] SyncAirMode Air Mode
* @param[in] SyncReTx Retransmission effort
* @param[in] SyncPacketType Allowed packet types
* @param[out] sco_params SCO parameters
* @param[in] Request Request originator
*
* @return Status
****************************************************************************************
*/
uint8_t lm_add_sync(uint8_t sco_link_id, struct features *RemoteFeatures,
uint8_t LinkId, uint8_t Role, uint8_t *SyncType,
uint32_t SyncTxBw, uint32_t SyncRxBw, uint16_t SyncLat, uint16_t VoiceSetting,
uint8_t SyncReTx, uint16_t SyncPacketType,
struct lc_sco_air_params_tag * sco_params, uint8_t Request);
/**
****************************************************************************************
* @brief This function is used to check if a Sync link can be modified.
*
* @param[in] sco_link_id Synchronous link ID
* @param[in] SyncType SCO or eSCO
* @param[in] SyncTxBw TX bandwidth
* @param[in] SyncRxBw RX bandwidth
* @param[in] SyncLat Maximum allowed Latency
* @param[in] SyncVoice Voice settings
* @param[in] SyncReTx Retransmission effort
* @param[in] SyncPacketType Allowed packet types
* @param[out] sco_params SCO parameters
* @param[in] Request Request type
*
* @return Status
*
****************************************************************************************
*/
uint8_t lm_modif_sync(uint8_t sco_link_id, uint8_t SyncType,
uint32_t SyncTxBw, uint32_t SyncRxBw, uint16_t SyncLat,
uint16_t SyncVoice, uint8_t SyncReTx, uint16_t SyncPacketType,
struct lc_sco_air_params_tag * sco_params, uint8_t Request);
/**
****************************************************************************************
* @brief This function is used to check the Accept Sync connection parameters.
*
* @param[in] sco_link_id Synchronous link ID
* @param[in] SyncTxBw TX bandwidth
* @param[in] SyncRxBw RX bandwidth
* @param[in] SyncLat Maximum allowed Latency
* @param[in] SyncVoice Voice settings
* @param[in] SyncReTx Retransmission effort
* @param[in] SyncPacketType Allowed packet types
* @param[out] sco_params SCO parameters
*
* @return Status
*
****************************************************************************************
*/
uint8_t lm_check_sync_hl_rsp(uint8_t sco_link_id, uint32_t SyncTxBw, uint32_t SyncRxBw,
uint16_t SyncLat, uint16_t SyncVoice, uint8_t SyncReTx, uint16_t SyncPacketType,
struct lc_sco_air_params_tag * sco_params);
/**
****************************************************************************************
* @brief This function is used to remove stored synchronous link information.
*
* @param[in] sco_link_id Synchronous link ID
****************************************************************************************
*/
void lm_remove_sync(uint8_t sco_link_id);
/**
****************************************************************************************
* @brief This function is used to Restore parameters for a synchronous link.
*
* @param[in] sco_link_id Synchronous link ID
* @param[out] sco_params SCO parameters
* @param[in] Request Request type
*
* @return Status
****************************************************************************************
*/
uint8_t lm_get_sync_param(uint8_t sco_link_id, struct lc_sco_air_params_tag * sco_params, uint8_t Request);
/**
****************************************************************************************
* @brief This function is used to get the Sync Handle of a Sync link.
*
* @param[in] sco_link_id Synchronous link ID
*
* @return Synchronous link handle
****************************************************************************************
*/
uint8_t lm_get_synchdl(uint8_t sco_link_id);
/**
****************************************************************************************
* @brief This function is used to check if an ACL link has at least 1 synchronous link.
*
* @param[in] sco_link_id Synchronous link ID
* @param[in] type Check SCO or eSCO specifically (ACL_TYPE if the type does not matter)
*
* @return True if SCO link present
****************************************************************************************
*/
bool lm_look_for_sync(uint8_t link_id, uint8_t type);
/**************************************************************************************
* @brief Indicate the end of a SCO negotiation
**************************************************************************************/
void lm_sco_nego_end(void);
#endif //(MAX_NB_SYNC > 0)
///@} LMSCO
#endif // LM_SCO_H_
/**
****************************************************************************************
*
* @file lm_sco.h
*
* @brief Link Manager synchronous link functions
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef LM_SCO_H_
#define LM_SCO_H_
/**
****************************************************************************************
* @defgroup LMSCO SCO Functions
* @ingroup LM
* @brief LM module for synchronous functions.
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // stack configuration
#if (MAX_NB_SYNC > 0)
#include "lc_sco.h"
/*
* DEFINITION
* ***************************************************************************************
*/
/// Commands for synchronous link
#define SYNC_HL_REQ 0
#define SYNC_PEER_REQ 1
#define SYNC_HL_RSP 2
#define SYNC_PEER_RSP 3
#define SYNC_HL_MODIF 4
#define SYNC_PEER_MODIF 5
#define SYNC_UPDATE 6
/*
* FUNCTION DECLARATIONS
* ***************************************************************************************
*/
/**
****************************************************************************************
* @brief This function is used to initialize LM Sco Data.
****************************************************************************************
*/
void lm_init_sync(void);
/**
****************************************************************************************
* @brief This function is used to reset LM Sco Data.
****************************************************************************************
*/
void lm_reset_sync(void);
/**
****************************************************************************************
* @brief This function is used to check and store informations about a SCO link.
*
* @param[in] sco_link_id Synchronous link ID
* @param[in] RemoteFeatures Remote device features
* @param[in] Role Master or Slave
* @param[in] SyncType SCO or eSCO
* @param[in] SyncLtAddr Synchronous link LT address
* @param[out] *SyncHdl Synchronous link handle
* @param[in] SyncTxBw TX bandwidth
* @param[in] SyncRxBw RX bandwidth
* @param[in] SyncLat Maximum allowed Latency
* @param[in] SyncVoice Voice settings
* @param[in] SyncAirMode Air Mode
* @param[in] SyncReTx Retransmission effort
* @param[in] SyncPacketType Allowed packet types
* @param[out] sco_params SCO parameters
* @param[in] Request Request originator
*
* @return Status
****************************************************************************************
*/
uint8_t lm_add_sync(uint8_t sco_link_id, struct features *RemoteFeatures,
uint8_t LinkId, uint8_t Role, uint8_t *SyncType,
uint32_t SyncTxBw, uint32_t SyncRxBw, uint16_t SyncLat, uint16_t VoiceSetting,
uint8_t SyncReTx, uint16_t SyncPacketType,
struct lc_sco_air_params_tag * sco_params, uint8_t Request);
/**
****************************************************************************************
* @brief This function is used to check if a Sync link can be modified.
*
* @param[in] sco_link_id Synchronous link ID
* @param[in] SyncType SCO or eSCO
* @param[in] SyncTxBw TX bandwidth
* @param[in] SyncRxBw RX bandwidth
* @param[in] SyncLat Maximum allowed Latency
* @param[in] SyncVoice Voice settings
* @param[in] SyncReTx Retransmission effort
* @param[in] SyncPacketType Allowed packet types
* @param[out] sco_params SCO parameters
* @param[in] Request Request type
*
* @return Status
*
****************************************************************************************
*/
uint8_t lm_modif_sync(uint8_t sco_link_id, uint8_t SyncType,
uint32_t SyncTxBw, uint32_t SyncRxBw, uint16_t SyncLat,
uint16_t SyncVoice, uint8_t SyncReTx, uint16_t SyncPacketType,
struct lc_sco_air_params_tag * sco_params, uint8_t Request);
/**
****************************************************************************************
* @brief This function is used to check the Accept Sync connection parameters.
*
* @param[in] sco_link_id Synchronous link ID
* @param[in] SyncTxBw TX bandwidth
* @param[in] SyncRxBw RX bandwidth
* @param[in] SyncLat Maximum allowed Latency
* @param[in] SyncVoice Voice settings
* @param[in] SyncReTx Retransmission effort
* @param[in] SyncPacketType Allowed packet types
* @param[out] sco_params SCO parameters
*
* @return Status
*
****************************************************************************************
*/
uint8_t lm_check_sync_hl_rsp(uint8_t sco_link_id, uint32_t SyncTxBw, uint32_t SyncRxBw,
uint16_t SyncLat, uint16_t SyncVoice, uint8_t SyncReTx, uint16_t SyncPacketType,
struct lc_sco_air_params_tag * sco_params);
/**
****************************************************************************************
* @brief This function is used to remove stored synchronous link information.
*
* @param[in] sco_link_id Synchronous link ID
****************************************************************************************
*/
void lm_remove_sync(uint8_t sco_link_id);
/**
****************************************************************************************
* @brief This function is used to Restore parameters for a synchronous link.
*
* @param[in] sco_link_id Synchronous link ID
* @param[out] sco_params SCO parameters
* @param[in] Request Request type
*
* @return Status
****************************************************************************************
*/
uint8_t lm_get_sync_param(uint8_t sco_link_id, struct lc_sco_air_params_tag * sco_params, uint8_t Request);
/**
****************************************************************************************
* @brief This function is used to get the Sync Handle of a Sync link.
*
* @param[in] sco_link_id Synchronous link ID
*
* @return Synchronous link handle
****************************************************************************************
*/
uint8_t lm_get_synchdl(uint8_t sco_link_id);
/**
****************************************************************************************
* @brief This function is used to check if an ACL link has at least 1 synchronous link.
*
* @param[in] sco_link_id Synchronous link ID
* @param[in] type Check SCO or eSCO specifically (ACL_TYPE if the type does not matter)
*
* @return True if SCO link present
****************************************************************************************
*/
bool lm_look_for_sync(uint8_t link_id, uint8_t type);
/**************************************************************************************
* @brief Indicate the end of a SCO negotiation
**************************************************************************************/
void lm_sco_nego_end(void);
#endif //(MAX_NB_SYNC > 0)
///@} LMSCO
#endif // LM_SCO_H_
+1580 -1580
View File
File diff suppressed because it is too large Load Diff
+328 -328
View File
@@ -1,328 +1,328 @@
/**
****************************************************************************************
*
* @file ld_int.h
*
* @brief LD Internal API
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef LD_INT_H_
#define LD_INT_H_
/**
****************************************************************************************
* @addtogroup LD
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // stack configuration
#include <stdint.h> // integer
#include <stdbool.h> // boolean
#include "ld.h"
/*
* CONSTANT DEFINITIONS
****************************************************************************************
*/
/// BCH size
#define LD_BCH_SIZE 8
/// Set an ACL link as active
#define LD_ACT_ACL_SET(field, link_id) (field |= (1<<(link_id)))
/// Clear an ACL link from active links
#define LD_ACT_ACL_CLEAR(field, link_id) (field &= ~(1<<(link_id)))
/// Set a SCO link as active
#define LD_ACT_SCO_SET(field, sco_link_id, link_id) \
field = (((field) & ~(0xFF << (8*(sco_link_id+1)))) | (0x80 + link_id) << (8*(sco_link_id+1)));
/// Clear a SCO link from active links
#define LD_ACT_SCO_CLEAR(field, sco_link_id) (field &= ~(0xFF << (8*(sco_link_id+1))))
/// Allocate an event with an associated data structure
#define LD_ALLOC_EVT(data_struct) (struct data_struct *) ke_malloc(sizeof(struct data_struct), KE_MEM_ENV);
/// Initialize memory of an event and an associated data structure
#define LD_INIT_EVT(evt, data_struct) memset(evt , 0, sizeof(struct data_struct));
/// Index for DM1 packet type (used in both BR and EDR)
#define DM1_IDX 0
/// Basic Rate packet types indexes (classified by packet size)
#define DH1_IDX 1
#define DM3_IDX 2
#define DH3_IDX 3
#define DM5_IDX 4
#define DH5_IDX 5
#define BR_IDX_MAX 6
/// Enhanced Data Rate packet types indexes (classified by packet size)
#define DH1_2_IDX 1
#define DH1_3_IDX 2
#define DH3_2_IDX 3
#define DH3_3_IDX 4
#define DH5_2_IDX 5
#define DH5_3_IDX 6
#define EDR_IDX_MAX 7
/*
* ENUMERATION DEFINITIONS
****************************************************************************************
*/
/// Activity type
enum LD_ACT_TYPE
{
LD_ACT_TYPE_ACL,
LD_ACT_TYPE_SCO,
};
/// Active mode
enum LD_ACT_MODE
{
LD_ACT_MODE_OFF,
LD_ACT_MODE_ON,
};
/*
* STRUCTURE DEFINITIONS
****************************************************************************************
*/
/// LD environment structure
struct ld_env_tag
{
/// Local BD_ADDR
struct bd_addr local_bd_addr;
/**
* Class of Device
*
* 0xXXXXXX Class of Device for the device.
*/
struct devclass class_of_dev;
/// Channel assessment data
struct ld_afh_ch_assess_data afh_ch_assess;
#if MAX_NB_SYNC
/// Bit field for PCM setting (used when creating an audio link)
uint8_t pcm_settings[8];
#endif //MAX_NB_SYNC
/// Bit field indicating the active links
///
/// 34 30 ... 24 23 22 ... 16 15 14 ... 8 7 6 ... 0
/// +----+-----------------------+----+-----------------------+----+-----------------------+----+---------------------------+
/// | 0/1| link_id for SCO2 | 0/1| link_id for SCO1 | 0/1| link_id for SCO0 | | ACL[i] is active |
/// +----+-----------------------+----+-----------------------+----+-----------------------+----+---------------------------+
///
uint32_t active_links;
/// Local BCH
uint8_t local_bch[LD_BCH_SIZE];
/// Current RX descriptor index [0:N-1]
uint8_t curr_rxdesc_index;
/// Tx path delay
uint8_t tx_path_delay;
/// Rx path delay
uint8_t rx_path_delay;
/// Expected sync position in us, which incorporates the Rx path delay
uint8_t exp_sync_pos;
/// Maximum value of the local clock drift
uint8_t local_drift;
/// Maximum value of the local clock jitter
uint8_t local_jitter;
/// Maximum value of the local active clock drift
uint8_t local_drift_active;
#if (RW_BT_MWS_COEX)
/// MWS external frame duration (us)
uint16_t mws_ext_fr_duration;
/// MWS external frame sync assert offset (us)
int16_t mws_ext_fr_offset;
/// active MWS pattern index [0-2, 0xFF=disabled]
uint8_t mws_index;
#endif //RW_BT_MWS_COEX
};
#if RW_BT_MWS_COEX
/// MWS pattern update information
typedef struct
{
/// MWS pattern index (0-2, 0xFF=disabled)
uint8_t pattern_index;
/// slot offset (activation time) (slots)
uint8_t slot_offset;
} ld_mwsifstat_t;
#endif //RW_BT_MWS_COEX
/*
* VARIABLE DECLARATION
*****************************************************************************************
*/
/// Basic Rate packet types table (classified by packet size)
extern const uint8_t ld_acl_br_types[BR_IDX_MAX];
/// Basic Rate packet sizes table (classified by packet size)
extern const uint16_t ld_acl_br_sizes[BR_IDX_MAX];
/// Enhanced Data Rate packet types table (classified by packet size)
extern const uint8_t ld_acl_edr_types[EDR_IDX_MAX];
/// Enhanced Data Rate packet sizes table (classified by packet size)
extern const uint16_t ld_acl_edr_sizes[EDR_IDX_MAX];
/// LD environment variable
extern struct ld_env_tag ld_env;
/*
* FUNCTIONS DECLARATION
****************************************************************************************
*/
#if RW_BT_MWS_COEX
/**
****************************************************************************************
* @brief Get the active MWS index
*
* @return Pattern index (0-2, 0xFF=disabled) and activation offset (@see ld_mwsifstat_t)
*
*****************************************************************************************
*/
ld_mwsifstat_t ld_mws_pattern_index_get(void);
/**
****************************************************************************************
* @brief Get the inactivity MWS duration
*
* @return uint8_t Inactivity duration (0:none, 1-30: val*5ms, 31:infinite)
*
*****************************************************************************************
*/
uint8_t ld_mws_inactivity_duration_get(void);
/**
****************************************************************************************
* @brief Build Xi scan mask for MWS COEX generically based on the specified uap_lap.
*
* @param[in] mwscoex_xi_scan_mask Xi mask to build.
* @param[in] uap_lap UAP/LAP for building Xi mask.
* ****************************************************************************************
*/
void ld_mwscoex_xi_scan_mask_build(uint32_t *mwscoex_xi_scan_mask, uint32_t uap_lap);
#endif // RW_BT_MWS_COEX
/**
****************************************************************************************
* @brief Assess a RF channel
*
* @param[in] channel Channel index
* @param[in] rx_ok True: reception is correct | False: reception is corrupted
* @param[in] timestamp Timestamp of the assessment (in half-slots)
*
* @return status 0: success | 1-255: error
****************************************************************************************
*/
void ld_channel_assess(uint8_t channel, bool rx_ok, uint32_t timestamp);
/**
****************************************************************************************
* @brief Free current RX descriptor
****************************************************************************************
*/
void ld_rxdesc_free(void);
/**
****************************************************************************************
* @brief Check if the current RX descriptor is consumed by a given activity
*
* @param[in] label representing the activity (as indicated in the CS)
*
* @return True if current RX descriptor is consumed by the activity identified by label
****************************************************************************************
*/
bool ld_rxdesc_check(uint8_t label);
/**
****************************************************************************************
* @brief Indicate active mode
*
* @param[in] type 0:ACL | 1:SCO
* @param[in] link_id ACL link ID
* @param[in] sco_link_id SCO link ID
* @param[in] mode 0: inactive | 1: active
****************************************************************************************
*/
void ld_active_mode_set(uint8_t type, uint8_t link_id, uint8_t sco_link_id, uint8_t mode);
/**
****************************************************************************************
* @brief Check if an ACL link is active, or a SCO is present on this ACL
*
* @param[in] link_id ACL link ID
*
* @return True if ACL link is active, or a SCO is present on this ACL
****************************************************************************************
*/
bool ld_active_link_check(uint8_t link_id);
void ld_inq_init(void);
void ld_inq_reset(void);
void ld_iscan_init(void);
void ld_iscan_reset(void);
void ld_page_init(void);
void ld_page_reset(void);
void ld_pscan_init(void);
void ld_pscan_reset(void);
void ld_acl_init(void);
void ld_acl_reset(void);
void ld_bcst_acl_init(void);
void ld_bcst_acl_reset(void);
#if CSB_SUPPORT || PCA_SUPPORT
void ld_sscan_init(void);
void ld_sscan_reset(void);
void ld_strain_init(void);
void ld_strain_reset(void);
#endif // CSB_SUPPORT || PCA_SUPPORT
#if CSB_SUPPORT
void ld_csb_tx_init(void);
void ld_csb_tx_reset(void);
void ld_csb_rx_init(void);
void ld_csb_rx_reset(void);
#endif // CSB_SUPPORT
#if PCA_SUPPORT
void ld_pca_init(void);
void ld_pca_reset(void);
#endif // PCA_SUPPORT
/// @} LD
#endif // LD_INT_H_
/**
****************************************************************************************
*
* @file ld_int.h
*
* @brief LD Internal API
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef LD_INT_H_
#define LD_INT_H_
/**
****************************************************************************************
* @addtogroup LD
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // stack configuration
#include <stdint.h> // integer
#include <stdbool.h> // boolean
#include "ld.h"
/*
* CONSTANT DEFINITIONS
****************************************************************************************
*/
/// BCH size
#define LD_BCH_SIZE 8
/// Set an ACL link as active
#define LD_ACT_ACL_SET(field, link_id) (field |= (1<<(link_id)))
/// Clear an ACL link from active links
#define LD_ACT_ACL_CLEAR(field, link_id) (field &= ~(1<<(link_id)))
/// Set a SCO link as active
#define LD_ACT_SCO_SET(field, sco_link_id, link_id) \
field = (((field) & ~(0xFF << (8*(sco_link_id+1)))) | (0x80 + link_id) << (8*(sco_link_id+1)));
/// Clear a SCO link from active links
#define LD_ACT_SCO_CLEAR(field, sco_link_id) (field &= ~(0xFF << (8*(sco_link_id+1))))
/// Allocate an event with an associated data structure
#define LD_ALLOC_EVT(data_struct) (struct data_struct *) ke_malloc(sizeof(struct data_struct), KE_MEM_ENV);
/// Initialize memory of an event and an associated data structure
#define LD_INIT_EVT(evt, data_struct) memset(evt , 0, sizeof(struct data_struct));
/// Index for DM1 packet type (used in both BR and EDR)
#define DM1_IDX 0
/// Basic Rate packet types indexes (classified by packet size)
#define DH1_IDX 1
#define DM3_IDX 2
#define DH3_IDX 3
#define DM5_IDX 4
#define DH5_IDX 5
#define BR_IDX_MAX 6
/// Enhanced Data Rate packet types indexes (classified by packet size)
#define DH1_2_IDX 1
#define DH1_3_IDX 2
#define DH3_2_IDX 3
#define DH3_3_IDX 4
#define DH5_2_IDX 5
#define DH5_3_IDX 6
#define EDR_IDX_MAX 7
/*
* ENUMERATION DEFINITIONS
****************************************************************************************
*/
/// Activity type
enum LD_ACT_TYPE
{
LD_ACT_TYPE_ACL,
LD_ACT_TYPE_SCO,
};
/// Active mode
enum LD_ACT_MODE
{
LD_ACT_MODE_OFF,
LD_ACT_MODE_ON,
};
/*
* STRUCTURE DEFINITIONS
****************************************************************************************
*/
/// LD environment structure
struct ld_env_tag
{
/// Local BD_ADDR
struct bd_addr local_bd_addr;
/**
* Class of Device
*
* 0xXXXXXX Class of Device for the device.
*/
struct devclass class_of_dev;
/// Channel assessment data
struct ld_afh_ch_assess_data afh_ch_assess;
#if MAX_NB_SYNC
/// Bit field for PCM setting (used when creating an audio link)
uint8_t pcm_settings[8];
#endif //MAX_NB_SYNC
/// Bit field indicating the active links
///
/// 34 30 ... 24 23 22 ... 16 15 14 ... 8 7 6 ... 0
/// +----+-----------------------+----+-----------------------+----+-----------------------+----+---------------------------+
/// | 0/1| link_id for SCO2 | 0/1| link_id for SCO1 | 0/1| link_id for SCO0 | | ACL[i] is active |
/// +----+-----------------------+----+-----------------------+----+-----------------------+----+---------------------------+
///
uint32_t active_links;
/// Local BCH
uint8_t local_bch[LD_BCH_SIZE];
/// Current RX descriptor index [0:N-1]
uint8_t curr_rxdesc_index;
/// Tx path delay
uint8_t tx_path_delay;
/// Rx path delay
uint8_t rx_path_delay;
/// Expected sync position in us, which incorporates the Rx path delay
uint8_t exp_sync_pos;
/// Maximum value of the local clock drift
uint8_t local_drift;
/// Maximum value of the local clock jitter
uint8_t local_jitter;
/// Maximum value of the local active clock drift
uint8_t local_drift_active;
#if (RW_BT_MWS_COEX)
/// MWS external frame duration (us)
uint16_t mws_ext_fr_duration;
/// MWS external frame sync assert offset (us)
int16_t mws_ext_fr_offset;
/// active MWS pattern index [0-2, 0xFF=disabled]
uint8_t mws_index;
#endif //RW_BT_MWS_COEX
};
#if RW_BT_MWS_COEX
/// MWS pattern update information
typedef struct
{
/// MWS pattern index (0-2, 0xFF=disabled)
uint8_t pattern_index;
/// slot offset (activation time) (slots)
uint8_t slot_offset;
} ld_mwsifstat_t;
#endif //RW_BT_MWS_COEX
/*
* VARIABLE DECLARATION
*****************************************************************************************
*/
/// Basic Rate packet types table (classified by packet size)
extern const uint8_t ld_acl_br_types[BR_IDX_MAX];
/// Basic Rate packet sizes table (classified by packet size)
extern const uint16_t ld_acl_br_sizes[BR_IDX_MAX];
/// Enhanced Data Rate packet types table (classified by packet size)
extern const uint8_t ld_acl_edr_types[EDR_IDX_MAX];
/// Enhanced Data Rate packet sizes table (classified by packet size)
extern const uint16_t ld_acl_edr_sizes[EDR_IDX_MAX];
/// LD environment variable
extern struct ld_env_tag ld_env;
/*
* FUNCTIONS DECLARATION
****************************************************************************************
*/
#if RW_BT_MWS_COEX
/**
****************************************************************************************
* @brief Get the active MWS index
*
* @return Pattern index (0-2, 0xFF=disabled) and activation offset (@see ld_mwsifstat_t)
*
*****************************************************************************************
*/
ld_mwsifstat_t ld_mws_pattern_index_get(void);
/**
****************************************************************************************
* @brief Get the inactivity MWS duration
*
* @return uint8_t Inactivity duration (0:none, 1-30: val*5ms, 31:infinite)
*
*****************************************************************************************
*/
uint8_t ld_mws_inactivity_duration_get(void);
/**
****************************************************************************************
* @brief Build Xi scan mask for MWS COEX generically based on the specified uap_lap.
*
* @param[in] mwscoex_xi_scan_mask Xi mask to build.
* @param[in] uap_lap UAP/LAP for building Xi mask.
* ****************************************************************************************
*/
void ld_mwscoex_xi_scan_mask_build(uint32_t *mwscoex_xi_scan_mask, uint32_t uap_lap);
#endif // RW_BT_MWS_COEX
/**
****************************************************************************************
* @brief Assess a RF channel
*
* @param[in] channel Channel index
* @param[in] rx_ok True: reception is correct | False: reception is corrupted
* @param[in] timestamp Timestamp of the assessment (in half-slots)
*
* @return status 0: success | 1-255: error
****************************************************************************************
*/
void ld_channel_assess(uint8_t channel, bool rx_ok, uint32_t timestamp);
/**
****************************************************************************************
* @brief Free current RX descriptor
****************************************************************************************
*/
void ld_rxdesc_free(void);
/**
****************************************************************************************
* @brief Check if the current RX descriptor is consumed by a given activity
*
* @param[in] label representing the activity (as indicated in the CS)
*
* @return True if current RX descriptor is consumed by the activity identified by label
****************************************************************************************
*/
bool ld_rxdesc_check(uint8_t label);
/**
****************************************************************************************
* @brief Indicate active mode
*
* @param[in] type 0:ACL | 1:SCO
* @param[in] link_id ACL link ID
* @param[in] sco_link_id SCO link ID
* @param[in] mode 0: inactive | 1: active
****************************************************************************************
*/
void ld_active_mode_set(uint8_t type, uint8_t link_id, uint8_t sco_link_id, uint8_t mode);
/**
****************************************************************************************
* @brief Check if an ACL link is active, or a SCO is present on this ACL
*
* @param[in] link_id ACL link ID
*
* @return True if ACL link is active, or a SCO is present on this ACL
****************************************************************************************
*/
bool ld_active_link_check(uint8_t link_id);
void ld_inq_init(void);
void ld_inq_reset(void);
void ld_iscan_init(void);
void ld_iscan_reset(void);
void ld_page_init(void);
void ld_page_reset(void);
void ld_pscan_init(void);
void ld_pscan_reset(void);
void ld_acl_init(void);
void ld_acl_reset(void);
void ld_bcst_acl_init(void);
void ld_bcst_acl_reset(void);
#if CSB_SUPPORT || PCA_SUPPORT
void ld_sscan_init(void);
void ld_sscan_reset(void);
void ld_strain_init(void);
void ld_strain_reset(void);
#endif // CSB_SUPPORT || PCA_SUPPORT
#if CSB_SUPPORT
void ld_csb_tx_init(void);
void ld_csb_tx_reset(void);
void ld_csb_rx_init(void);
void ld_csb_rx_reset(void);
#endif // CSB_SUPPORT
#if PCA_SUPPORT
void ld_pca_init(void);
void ld_pca_reset(void);
#endif // PCA_SUPPORT
/// @} LD
#endif // LD_INT_H_
+219 -219
View File
@@ -1,219 +1,219 @@
/**
****************************************************************************************
*
* @file ld_util.h
*
* @brief LD Util API
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef LD_UTIL_H_
#define LD_UTIL_H_
/**
****************************************************************************************
* @addtogroup LD
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // stack configuration
#include <stdint.h> // integer
#include "co_bt.h" // BT standard definitions
/*
* CONSTANT DEFINITIONS
****************************************************************************************
*/
/// Undefined BT clock value
#define LD_CLOCK_UNDEF 0xFFFFFFFF
/**
* Margin between 2 ACL frames (in us)
*
* The chosen value is based on the packets duration and the time needed by the system to close and start a frame.
*
* Remaining guard band after Poll/Null : 499us
* Remaining guard band after max DM1 packet : 199us
*
* Time used by system after frame (Power Down / CS+Desc update) : 50
* Time used by system after frame (Power Up / CS+Desc fetch) : 50
*/
#define LD_ACL_INTERFRAME_MARGIN (120)
/**
* Margin after eSCO frame (in us)
*/
#define LD_SCO_INTERFRAME_MARGIN (80)
/**
* Margin after inquiry frames (in us)
*
* The chosen value is based on last frame duration and the time needed by the system to close and start a frame.
*
* Remaining guard band after last ID packet missed reception : 250us
*
* Time used by system after frame (Power Down / CS+Desc update) : 50
* Time used by system after frame (Power Up / CS+Desc fetch) : 50
*/
#define LD_INQ_INTERFRAME_MARGIN (200)
#define LD_PAGE_INTERFRAME_MARGIN (200)
/**
* Margin after scan frames (in us)
*
* The chosen value is based on last frame duration and the time needed by the anticipated prefetch abort mechanism
* to abort the scan. The prefetch abort delay is configured to the register.
*
* Just consider half-slot for enabling interlacing acitivites with high bit offset
*/
#define LD_SCAN_INTERFRAME_MARGIN (SLOT_SIZE - LD_ACL_INTERFRAME_MARGIN + 1)
/*
* MACRO DEFINITIONS
****************************************************************************************
*/
/*
* STRUCTURE DEFINITIONS
****************************************************************************************
*/
/*
* VARIABLE DEFINITIONS
****************************************************************************************
*/
/// Table for synchronization train channels
extern const uint8_t ld_sync_train_channels[SYNC_TRAIN_CHANNEL_NB];
/*
* FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Unpack FHS packet
*
* @param[in] fhs_buf_ptr Pointer to the FHS payload buffer (in EM)
* @param[out] bch_ptr Pointer to BCH
* @param[out] bd_addr BD Address
* @param[out] class_dev Class Of Device
* @param[out] lt_addr LT Address
* @param[out] clk_frm Clock (in 1.25ms BT frame)
* @param[out] page_scan_rep_mode Page Scan Repetition Mode (R0, R1, R2)
****************************************************************************************
*/
void ld_util_fhs_unpk(uint16_t fhs_buf_ptr, uint8_t* bch_ptr, struct bd_addr* bd_addr, struct devclass* class_of_dev, uint8_t* lt_addr, uint32_t* clk_frm, uint8_t* page_scan_rep_mode);
/**
****************************************************************************************
* @brief Generate a BCH code from LAP.
*
* The lap pointer must point on a table :
* Msb Lsb
* lap[0] = a7..a0
* lap[1] = a15..a7
* lap[2] = a23..a16
* The bch result is stored in :
* Msb Lsb
* bch[0] = a7..a0
* bch[1] = a15..a8
* bch[2] = a23..a16
* bch[3] = a31..a24
* bch[4] = a39..a32
* bch[5] = a47..a40
* bch[6] = a55..a48
* bch[7] = a63..a56
*
* @param[in] lap Input LAP Vector[3]
* @param[out] bch Output BCH [8]
*
****************************************************************************************
*/
void ld_util_bch_create(uint8_t *lap, uint8_t *bch);
/**
****************************************************************************************
* @brief Pack FHS packet
*
* @param[in] fhs_buf_ptr Pointer to the FHS payload buffer (in EM)
* @param[in] bch_ptr Pointer to BCH
* @param[in] eir Value indicating whether EIR is available or not
* @param[in] sr Scan repetition
* @param[in] bd_addr BD Address
* @param[in] class_of_dev Class Of Device
* @param[in] lt_addr LT Address
* @param[in] page_scan_mode Page scan mode
****************************************************************************************
*/
void ld_util_fhs_pk(uint16_t fhs_buf_ptr, uint8_t* bch_ptr, uint8_t eir, uint8_t sr, struct bd_addr* bd_addr, struct devclass* class_of_dev, uint8_t lt_addr, uint8_t page_scan_mode);
/**
****************************************************************************************
* @brief Set the active AFH Map
*
* @param[in] chnl_map AFH map
****************************************************************************************
*/
void ld_util_active_master_afh_map_set(struct chnl_map* ch_map);
/**
****************************************************************************************
* @brief Get the active AFH Map
*
* @param[out] chnl_map AFH map
****************************************************************************************
*/
struct chnl_map* ld_util_active_master_afh_map_get(void);
/**
****************************************************************************************
* @brief Unpack sync train packet
*
* @param[in] buf_ptr Pointer to the STP payload buffer (in EM)
* @param[out] clk_hs Current piconet clock (CLK) (in half slots)
* @param[out] future_csb_inst Future Connectionless Slave Broadcast Instant
* @param[out] afh_ch_map The current AFH_Channel_Map used for the PBD logical link
* @param[out] mst_bd_addr Master BD Address
* @param[out] csb_intv CSB interval (in slots)
* @param[out] csb_lt_addr The LT_ADDR reserved for the CSB logical transport
* @param[out] svc_data Defined by the service using the Connectionless Slave Broadcast feature
****************************************************************************************
*/
void ld_util_stp_unpk(uint16_t buf_ptr, uint32_t* clk_hs, uint32_t* future_csb_inst, struct chnl_map* afh_ch_map, struct bd_addr* mst_bd_addr, uint16_t* csb_intv, uint8_t* csb_lt_addr, uint8_t* svc_data);
/**
****************************************************************************************
* @brief Pack sync train packet
*
* @param[in] buf_ptr Pointer to the STP payload buffer (in EM)
* @param[out] clk_hs Current piconet clock (CLK) (in half slots)
* @param[out] future_csb_inst Future Connectionless Slave Broadcast Instant (in slots)
* @param[out] afh_ch_map The current AFH_Channel_Map used for the PBD logical link
* @param[out] mst_bd_addr Master BD Address
* @param[out] csb_intv CSB interval (in slots)
* @param[out] csb_lt_addr The LT_ADDR reserved for the CSB logical transport
* @param[out] svc_data Defined by the service using the Connectionless Slave Broadcast feature
****************************************************************************************
*/
void ld_util_stp_pk(uint16_t buf_ptr, uint32_t clk_hs, uint32_t future_csb_inst, struct chnl_map* afh_ch_map, struct bd_addr* mst_bd_addr, uint16_t csb_intv, uint8_t csb_lt_addr, uint8_t svc_data);
/// @} LD
#endif // LD_UTIL_H_
/**
****************************************************************************************
*
* @file ld_util.h
*
* @brief LD Util API
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef LD_UTIL_H_
#define LD_UTIL_H_
/**
****************************************************************************************
* @addtogroup LD
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // stack configuration
#include <stdint.h> // integer
#include "co_bt.h" // BT standard definitions
/*
* CONSTANT DEFINITIONS
****************************************************************************************
*/
/// Undefined BT clock value
#define LD_CLOCK_UNDEF 0xFFFFFFFF
/**
* Margin between 2 ACL frames (in us)
*
* The chosen value is based on the packets duration and the time needed by the system to close and start a frame.
*
* Remaining guard band after Poll/Null : 499us
* Remaining guard band after max DM1 packet : 199us
*
* Time used by system after frame (Power Down / CS+Desc update) : 50
* Time used by system after frame (Power Up / CS+Desc fetch) : 50
*/
#define LD_ACL_INTERFRAME_MARGIN (120)
/**
* Margin after eSCO frame (in us)
*/
#define LD_SCO_INTERFRAME_MARGIN (80)
/**
* Margin after inquiry frames (in us)
*
* The chosen value is based on last frame duration and the time needed by the system to close and start a frame.
*
* Remaining guard band after last ID packet missed reception : 250us
*
* Time used by system after frame (Power Down / CS+Desc update) : 50
* Time used by system after frame (Power Up / CS+Desc fetch) : 50
*/
#define LD_INQ_INTERFRAME_MARGIN (200)
#define LD_PAGE_INTERFRAME_MARGIN (200)
/**
* Margin after scan frames (in us)
*
* The chosen value is based on last frame duration and the time needed by the anticipated prefetch abort mechanism
* to abort the scan. The prefetch abort delay is configured to the register.
*
* Just consider half-slot for enabling interlacing acitivites with high bit offset
*/
#define LD_SCAN_INTERFRAME_MARGIN (SLOT_SIZE - LD_ACL_INTERFRAME_MARGIN + 1)
/*
* MACRO DEFINITIONS
****************************************************************************************
*/
/*
* STRUCTURE DEFINITIONS
****************************************************************************************
*/
/*
* VARIABLE DEFINITIONS
****************************************************************************************
*/
/// Table for synchronization train channels
extern const uint8_t ld_sync_train_channels[SYNC_TRAIN_CHANNEL_NB];
/*
* FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Unpack FHS packet
*
* @param[in] fhs_buf_ptr Pointer to the FHS payload buffer (in EM)
* @param[out] bch_ptr Pointer to BCH
* @param[out] bd_addr BD Address
* @param[out] class_dev Class Of Device
* @param[out] lt_addr LT Address
* @param[out] clk_frm Clock (in 1.25ms BT frame)
* @param[out] page_scan_rep_mode Page Scan Repetition Mode (R0, R1, R2)
****************************************************************************************
*/
void ld_util_fhs_unpk(uint16_t fhs_buf_ptr, uint8_t* bch_ptr, struct bd_addr* bd_addr, struct devclass* class_of_dev, uint8_t* lt_addr, uint32_t* clk_frm, uint8_t* page_scan_rep_mode);
/**
****************************************************************************************
* @brief Generate a BCH code from LAP.
*
* The lap pointer must point on a table :
* Msb Lsb
* lap[0] = a7..a0
* lap[1] = a15..a7
* lap[2] = a23..a16
* The bch result is stored in :
* Msb Lsb
* bch[0] = a7..a0
* bch[1] = a15..a8
* bch[2] = a23..a16
* bch[3] = a31..a24
* bch[4] = a39..a32
* bch[5] = a47..a40
* bch[6] = a55..a48
* bch[7] = a63..a56
*
* @param[in] lap Input LAP Vector[3]
* @param[out] bch Output BCH [8]
*
****************************************************************************************
*/
void ld_util_bch_create(uint8_t *lap, uint8_t *bch);
/**
****************************************************************************************
* @brief Pack FHS packet
*
* @param[in] fhs_buf_ptr Pointer to the FHS payload buffer (in EM)
* @param[in] bch_ptr Pointer to BCH
* @param[in] eir Value indicating whether EIR is available or not
* @param[in] sr Scan repetition
* @param[in] bd_addr BD Address
* @param[in] class_of_dev Class Of Device
* @param[in] lt_addr LT Address
* @param[in] page_scan_mode Page scan mode
****************************************************************************************
*/
void ld_util_fhs_pk(uint16_t fhs_buf_ptr, uint8_t* bch_ptr, uint8_t eir, uint8_t sr, struct bd_addr* bd_addr, struct devclass* class_of_dev, uint8_t lt_addr, uint8_t page_scan_mode);
/**
****************************************************************************************
* @brief Set the active AFH Map
*
* @param[in] chnl_map AFH map
****************************************************************************************
*/
void ld_util_active_master_afh_map_set(struct chnl_map* ch_map);
/**
****************************************************************************************
* @brief Get the active AFH Map
*
* @param[out] chnl_map AFH map
****************************************************************************************
*/
struct chnl_map* ld_util_active_master_afh_map_get(void);
/**
****************************************************************************************
* @brief Unpack sync train packet
*
* @param[in] buf_ptr Pointer to the STP payload buffer (in EM)
* @param[out] clk_hs Current piconet clock (CLK) (in half slots)
* @param[out] future_csb_inst Future Connectionless Slave Broadcast Instant
* @param[out] afh_ch_map The current AFH_Channel_Map used for the PBD logical link
* @param[out] mst_bd_addr Master BD Address
* @param[out] csb_intv CSB interval (in slots)
* @param[out] csb_lt_addr The LT_ADDR reserved for the CSB logical transport
* @param[out] svc_data Defined by the service using the Connectionless Slave Broadcast feature
****************************************************************************************
*/
void ld_util_stp_unpk(uint16_t buf_ptr, uint32_t* clk_hs, uint32_t* future_csb_inst, struct chnl_map* afh_ch_map, struct bd_addr* mst_bd_addr, uint16_t* csb_intv, uint8_t* csb_lt_addr, uint8_t* svc_data);
/**
****************************************************************************************
* @brief Pack sync train packet
*
* @param[in] buf_ptr Pointer to the STP payload buffer (in EM)
* @param[out] clk_hs Current piconet clock (CLK) (in half slots)
* @param[out] future_csb_inst Future Connectionless Slave Broadcast Instant (in slots)
* @param[out] afh_ch_map The current AFH_Channel_Map used for the PBD logical link
* @param[out] mst_bd_addr Master BD Address
* @param[out] csb_intv CSB interval (in slots)
* @param[out] csb_lt_addr The LT_ADDR reserved for the CSB logical transport
* @param[out] svc_data Defined by the service using the Connectionless Slave Broadcast feature
****************************************************************************************
*/
void ld_util_stp_pk(uint16_t buf_ptr, uint32_t clk_hs, uint32_t future_csb_inst, struct chnl_map* afh_ch_map, struct bd_addr* mst_bd_addr, uint16_t csb_intv, uint8_t csb_lt_addr, uint8_t svc_data);
/// @} LD
#endif // LD_UTIL_H_
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff