mirror of https://github.com/ARMmbed/mbed-os.git
commit
5af16c9546
|
|
@ -1522,7 +1522,8 @@
|
|||
"template": ["uvision5_arm_beetle_soc.uvproj.tmpl"]
|
||||
}
|
||||
},
|
||||
"device_has": ["ANALOGIN", "CLCD", "I2C", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "SERIAL", "SPI"]
|
||||
"device_has": ["ANALOGIN", "CLCD", "I2C", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "SERIAL", "SPI"],
|
||||
"features": ["BLE"]
|
||||
},
|
||||
"RZ_A1H": {
|
||||
"supported_form_factors": ["ARDUINO"],
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ LR_IROM1 0x00000000 0x00040000 { ; load region size_region
|
|||
*.o (RESET, +FIRST)
|
||||
*(InRoot$$Sections)
|
||||
.ANY (+RO)
|
||||
CORDIO_RO_2.1.o (*)
|
||||
}
|
||||
; Total: 80 vectors = 320 bytes (0x140) to be reserved in RAM
|
||||
RW_IRAM1 (0x20000000+0x140) (0x20000-0x140) { ; RW data
|
||||
|
|
|
|||
|
|
@ -70,6 +70,12 @@ SECTIONS
|
|||
. = ALIGN(4);
|
||||
} > VECTORS
|
||||
|
||||
.cordio :
|
||||
{
|
||||
*CORDIO_RO_2.1.o
|
||||
*TRIM_2.1.o
|
||||
} > FLASH
|
||||
|
||||
.text :
|
||||
{
|
||||
*(.text*)
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ int EFlash_IdCheck()
|
|||
{
|
||||
unsigned int eflash_id;
|
||||
|
||||
eflash_id = readl(SYS_EFLASH_PIDR2) & (EFLASH_DES_1 | EFLASH_JEDEC);
|
||||
eflash_id = EFlash_Readl(SYS_EFLASH_PIDR2) & (EFLASH_DES_1 | EFLASH_JEDEC);
|
||||
|
||||
if (readl(SYS_EFLASH_PIDR0) != FLS_PID0
|
||||
|| readl(SYS_EFLASH_PIDR1) != FLS_PID1
|
||||
if (EFlash_Readl(SYS_EFLASH_PIDR0) != FLS_PID0
|
||||
|| EFlash_Readl(SYS_EFLASH_PIDR1) != FLS_PID1
|
||||
|| eflash_id != FLS_PID2)
|
||||
/* port ID and ARM ID does not match */
|
||||
return 1;
|
||||
|
|
@ -52,7 +52,7 @@ int EFlash_ReturnBank1BaseAddress()
|
|||
unsigned int hwparams0;
|
||||
int baseaddr;
|
||||
|
||||
hwparams0 = readl(SYS_EFLASH_HWPARAMS0) & EFLASH_FLASHSIZE;
|
||||
hwparams0 = EFlash_Readl(SYS_EFLASH_HWPARAMS0) & EFLASH_FLASHSIZE;
|
||||
|
||||
switch(hwparams0)
|
||||
{
|
||||
|
|
@ -73,31 +73,35 @@ int EFlash_ReturnBank1BaseAddress()
|
|||
return baseaddr;
|
||||
}
|
||||
|
||||
/* EFlash_Initialize: eFlash Initialize function */
|
||||
void EFlash_Initialize()
|
||||
/* EFlash_DriverInitialize: eFlash Driver Initialize function */
|
||||
void EFlash_DriverInitialize()
|
||||
{
|
||||
/* Find the start address of banks */
|
||||
eflash.basebank0 = 0x0;
|
||||
eflash.basebank0_me = 0x40000000;
|
||||
eflash.basebank1 = EFlash_ReturnBank1BaseAddress();
|
||||
eflash.basebank1_me = 0x80000000;
|
||||
}
|
||||
|
||||
/* EFlash_ClockConfig: eFlash Clock Configuration */
|
||||
void EFlash_ClockConfig()
|
||||
{
|
||||
/* Wait until eFlash controller gets unlocked */
|
||||
while ((readl(SYS_EFLASH_STATUS) & EFLASH_LOCK_MASK) == EFLASH_LOCK);
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS) & EFLASH_LOCK_MASK) == EFLASH_LOCK);
|
||||
|
||||
/*
|
||||
* Configure to use external clock
|
||||
* EXTCL = 31250 ns ->
|
||||
* 1 ms = 32 clock count 32khz ext_clk -> ER_CLK_COUNT = 32
|
||||
* 1 us = 84 clock count system_clk -> WR_CLK_COUNT = 84
|
||||
* EXT_CLK_CONF = 0x1 [Erase] External clock used for erase counters (>1ms)
|
||||
* HCLK used for write counters
|
||||
* RD_CLK_COUNT = 0x3
|
||||
*/
|
||||
writel(SYS_EFLASH_CONFIG0, 0x00200B43);
|
||||
* Configure to use external clock
|
||||
* EXTCL = 31250 ns ->
|
||||
* 1 ms = 32 clock count 32khz ext_clk -> ER_CLK_COUNT = 32
|
||||
* 1 us = 84 clock count system_clk -> WR_CLK_COUNT = 84
|
||||
* EXT_CLK_CONF = 0x1 [Erase] External clock used for erase counters (>1ms)
|
||||
* HCLK used for write counters
|
||||
* RD_CLK_COUNT = 0x3
|
||||
*/
|
||||
EFlash_Writel(SYS_EFLASH_CONFIG0, 0x00200B43);
|
||||
|
||||
/* Wait until eFlash controller gets unlocked */
|
||||
while ((readl(SYS_EFLASH_STATUS) & EFLASH_BUSY_MASK) == EFLASH_BUSY);
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS) & EFLASH_BUSY_MASK) == EFLASH_BUSY);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -116,87 +120,87 @@ void EFlash_Erase(int mode)
|
|||
{
|
||||
case 0:
|
||||
/* Wait until eFlash controller gets unlocked */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_LOCK_MASK) == EFLASH_LOCK);
|
||||
/* Erase Block #0 */
|
||||
writel(SYS_EFLASH_WADDR, eflash.basebank0);
|
||||
writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank0);
|
||||
EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
/* Wait until eFlash controller is not busy */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_BUSY_MASK) == EFLASH_BUSY);
|
||||
break;
|
||||
case 1:
|
||||
/* Wait until eFlash controller gets unlocked */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_LOCK_MASK) == EFLASH_LOCK);
|
||||
/* Erase Block #1 */
|
||||
writel(SYS_EFLASH_WADDR, eflash.basebank1);
|
||||
writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank1);
|
||||
EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
/* Wait until eFlash controller is not busy */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_BUSY_MASK) == EFLASH_BUSY);
|
||||
break;
|
||||
case 2:
|
||||
/* Wait until eFlash controller gets unlocked */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_LOCK_MASK) == EFLASH_LOCK);
|
||||
/* Erase Block #0 + info pages */
|
||||
writel(SYS_EFLASH_WADDR, eflash.basebank0_me);
|
||||
writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank0_me);
|
||||
EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
/* Wait until eFlash controller is not busy */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_BUSY_MASK) == EFLASH_BUSY);
|
||||
break;
|
||||
case 3:
|
||||
/* Wait until eFlash controller gets unlocked */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_LOCK_MASK) == EFLASH_LOCK);
|
||||
/* Erase Block #1 + info pages */
|
||||
writel(SYS_EFLASH_WADDR, eflash.basebank1_me);
|
||||
writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank1_me);
|
||||
EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
/* Wait until eFlash controller is not busy */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_BUSY_MASK) == EFLASH_BUSY);
|
||||
break;
|
||||
case 4:
|
||||
/* Wait until eFlash controller gets unlocked */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_LOCK_MASK) == EFLASH_LOCK);
|
||||
/* Erase Block #0 */
|
||||
writel(SYS_EFLASH_WADDR, eflash.basebank0);
|
||||
writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank0);
|
||||
EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
/* Wait until eFlash controller is not busy */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_BUSY_MASK) == EFLASH_BUSY);
|
||||
/* Wait until eFlash controller gets unlocked */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_LOCK_MASK) == EFLASH_LOCK);
|
||||
/* Erase Block #1 */
|
||||
writel(SYS_EFLASH_WADDR, eflash.basebank1);
|
||||
writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank1);
|
||||
EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
/* Wait until eFlash controller gets unlocked */
|
||||
/* Wait until eFlash controller is not busy */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_BUSY_MASK) == EFLASH_BUSY);
|
||||
break;
|
||||
case 5:
|
||||
/* Wait until eFlash controller gets unlocked */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_LOCK_MASK) == EFLASH_LOCK);
|
||||
/* Erase Block #0 + info pages */
|
||||
writel(SYS_EFLASH_WADDR, eflash.basebank0_me);
|
||||
writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank0_me);
|
||||
EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
/* Wait until eFlash controller is not busy */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_BUSY_MASK) == EFLASH_BUSY);
|
||||
/* Wait until eFlash controller gets unlocked */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_LOCK_MASK) == EFLASH_LOCK);
|
||||
/* Erase Block #1 + info pages */
|
||||
writel(SYS_EFLASH_WADDR, eflash.basebank1_me);
|
||||
writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank1_me);
|
||||
EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
|
||||
/* Wait until eFlash controller is not busy */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_BUSY_MASK) == EFLASH_BUSY);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -208,10 +212,10 @@ void EFlash_Erase(int mode)
|
|||
void EFlash_ErasePage(unsigned int waddr)
|
||||
{
|
||||
/* Erase the page starting a waddr */
|
||||
writel(SYS_EFLASH_WADDR, waddr);
|
||||
writel(SYS_EFLASH_CTRL, EFLASH_ERASE);
|
||||
EFlash_Writel(SYS_EFLASH_WADDR, waddr);
|
||||
EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_ERASE);
|
||||
/* Wait until eFlash controller gets unlocked */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_BUSY_MASK) == EFLASH_BUSY);
|
||||
}
|
||||
|
||||
|
|
@ -224,13 +228,13 @@ void EFlash_ErasePage(unsigned int waddr)
|
|||
void EFlash_Write(unsigned int waddr, unsigned int data)
|
||||
{
|
||||
/* Set Write Data Register */
|
||||
writel(SYS_EFLASH_WDATA, data);
|
||||
EFlash_Writel(SYS_EFLASH_WDATA, data);
|
||||
/* Set Write Address Register */
|
||||
writel(SYS_EFLASH_WADDR, waddr);
|
||||
EFlash_Writel(SYS_EFLASH_WADDR, waddr);
|
||||
/* Start Write Operation through CTRL register */
|
||||
writel(SYS_EFLASH_CTRL, EFLASH_WRITE);
|
||||
EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_WRITE);
|
||||
/* Wait until eFlash controller gets unlocked */
|
||||
while ((readl(SYS_EFLASH_STATUS)
|
||||
while ((EFlash_Readl(SYS_EFLASH_STATUS)
|
||||
& EFLASH_BUSY_MASK) == EFLASH_BUSY);
|
||||
|
||||
/* Flash Cache invalidate if FCache enabled */
|
||||
|
|
@ -275,7 +279,7 @@ int EFlash_WritePage(unsigned int waddr, unsigned int page_size,
|
|||
*/
|
||||
unsigned int EFlash_Read(unsigned int waddr)
|
||||
{
|
||||
unsigned int eflash_read = readl(waddr);
|
||||
unsigned int eflash_read = EFlash_Readl(waddr);
|
||||
return eflash_read;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ extern "C" {
|
|||
#define EFLASH_REVISION 0xF0 /* Revision number */
|
||||
|
||||
/* Macros */
|
||||
#define readl(reg) *(volatile unsigned int *)reg
|
||||
#define writel(reg, val) *(unsigned int *)reg = val;
|
||||
#define EFlash_Readl(reg) *(volatile unsigned int *)reg
|
||||
#define EFlash_Writel(reg, val) *(volatile unsigned int *)reg = val;
|
||||
|
||||
/* peripheral and component ID values */
|
||||
#define FLS_PID4 0x14
|
||||
|
|
@ -80,8 +80,12 @@ extern "C" {
|
|||
#define FLS_CID3 0xB1
|
||||
|
||||
/* Functions */
|
||||
/* EFlash_Initialize: eFlash Initialize function */
|
||||
void EFlash_Initialize(void);
|
||||
/* EFlash_DriverInitialize: eFlash Driver Initialize function */
|
||||
void EFlash_DriverInitialize(void);
|
||||
|
||||
/* EFlash_ClockConfig: eFlash Clock Configuration */
|
||||
void EFlash_ClockConfig(void);
|
||||
|
||||
/*
|
||||
* EFlash_Erase: Erases flash banks
|
||||
* Mode:
|
||||
|
|
|
|||
|
|
@ -21,22 +21,22 @@ static unsigned int fcache_mode;
|
|||
/* Functions */
|
||||
|
||||
/*
|
||||
* FCache_Initialize: flash cache initialize funtion
|
||||
* FCache_DriverInitialize: flash cache driver initialize funtion
|
||||
*/
|
||||
void FCache_Initialize()
|
||||
void FCache_DriverInitialize()
|
||||
{
|
||||
unsigned int irqstat;
|
||||
|
||||
/* Clear interrupt status register */
|
||||
irqstat = readl(SYS_FCACHE_IRQSTAT) & (FCACHE_POW_ERR | FCACHE_MAN_INV_ERR);
|
||||
writel(SYS_FCACHE_IRQSTAT, irqstat);
|
||||
irqstat = FCache_Readl(SYS_FCACHE_IRQSTAT) & (FCACHE_POW_ERR | FCACHE_MAN_INV_ERR);
|
||||
FCache_Writel(SYS_FCACHE_IRQSTAT, irqstat);
|
||||
|
||||
/* Cache Disabled: Set enabled to 0 */
|
||||
enabled = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* FCache_Enable: Enables the flash cache
|
||||
* FCache_Enable: Enables the flash cache mode
|
||||
* mode: supported modes:
|
||||
* 0 - auto-power auto-invalidate
|
||||
* 1 - manual-power, manual-invalidate
|
||||
|
|
@ -52,9 +52,9 @@ void FCache_Enable(int mode)
|
|||
/* Statistic counters enabled, Cache enable,
|
||||
* auto-inval, auto-power control
|
||||
*/
|
||||
writel(SYS_FCACHE_CCR, (FCACHE_EN | FCACHE_STATISTIC_EN));
|
||||
FCache_Writel(SYS_FCACHE_CCR, (FCACHE_EN | FCACHE_STATISTIC_EN));
|
||||
/* Wait until the cache is enabled */
|
||||
while ((readl(SYS_FCACHE_SR) & FCACHE_CS) != FCACHE_CS_ENABLED);
|
||||
while ((FCache_Readl(SYS_FCACHE_SR) & FCACHE_CS) != FCACHE_CS_ENABLED);
|
||||
/* Cache Enabled: Set enabled to 1 */
|
||||
enabled = 1;
|
||||
break;
|
||||
|
|
@ -64,33 +64,33 @@ void FCache_Enable(int mode)
|
|||
* Manual power request (Setting: Power CTRL:
|
||||
* Manual, Invalidate: Manual)
|
||||
*/
|
||||
writel(SYS_FCACHE_CCR, (FCACHE_POW_REQ
|
||||
FCache_Writel(SYS_FCACHE_CCR, (FCACHE_POW_REQ
|
||||
| FCACHE_SET_MAN_POW
|
||||
| FCACHE_SET_MAN_INV
|
||||
| FCACHE_STATISTIC_EN));
|
||||
/* Wait until the cache rams are powered */
|
||||
while ((readl(SYS_FCACHE_SR) & FCACHE_POW_STAT) != FCACHE_POW_STAT);
|
||||
while ((FCache_Readl(SYS_FCACHE_SR) & FCACHE_POW_STAT) != FCACHE_POW_STAT);
|
||||
/* Statistic counters enabled, Cache enabled
|
||||
* Manual invalidate request (Setting: Power CTRL:
|
||||
* Manual, Invalidate: Manual)
|
||||
*/
|
||||
writel(SYS_FCACHE_CCR, (FCACHE_INV_REQ
|
||||
FCache_Writel(SYS_FCACHE_CCR, (FCACHE_INV_REQ
|
||||
| FCACHE_POW_REQ
|
||||
| FCACHE_SET_MAN_POW
|
||||
| FCACHE_SET_MAN_INV
|
||||
| FCACHE_STATISTIC_EN));
|
||||
/* Wait until the cache is invalidated */
|
||||
while ((readl(SYS_FCACHE_SR) & FCACHE_INV_STAT) == FCACHE_INV_STAT);
|
||||
while ((FCache_Readl(SYS_FCACHE_SR) & FCACHE_INV_STAT) == FCACHE_INV_STAT);
|
||||
/* Statistic counters enabled, Cache enable,
|
||||
* manual-inval, manual-power control
|
||||
*/
|
||||
writel(SYS_FCACHE_CCR, (FCACHE_EN
|
||||
FCache_Writel(SYS_FCACHE_CCR, (FCACHE_EN
|
||||
| FCACHE_POW_REQ
|
||||
| FCACHE_SET_MAN_POW
|
||||
| FCACHE_SET_MAN_INV
|
||||
| FCACHE_STATISTIC_EN));
|
||||
/* Wait until the cache is enabled */
|
||||
while ((readl(SYS_FCACHE_SR) & FCACHE_CS) != FCACHE_CS_ENABLED);
|
||||
while ((FCache_Readl(SYS_FCACHE_SR) & FCACHE_CS) != FCACHE_CS_ENABLED);
|
||||
/* Cache Enabled: Set enabled to 1 */
|
||||
enabled = 1;
|
||||
break;
|
||||
|
|
@ -100,7 +100,7 @@ void FCache_Enable(int mode)
|
|||
}
|
||||
|
||||
/*
|
||||
* FCache_Disable: Disables the cache
|
||||
* FCache_Disable: Disables the flash cache mode previously enabled
|
||||
*/
|
||||
void FCache_Disable()
|
||||
{
|
||||
|
|
@ -110,9 +110,9 @@ void FCache_Disable()
|
|||
/* Statistic counters enabled, Cache disable,
|
||||
* auto-inval, auto-power control
|
||||
*/
|
||||
writel(SYS_FCACHE_CCR, FCACHE_STATISTIC_EN);
|
||||
FCache_Writel(SYS_FCACHE_CCR, FCACHE_STATISTIC_EN);
|
||||
/* Wait until the cache is disabled */
|
||||
while ((readl(SYS_FCACHE_SR) & FCACHE_CS) != FCACHE_CS_DISABLED);
|
||||
while ((FCache_Readl(SYS_FCACHE_SR) & FCACHE_CS) != FCACHE_CS_DISABLED);
|
||||
/* Cache Enabled: Set enabled to 0 */
|
||||
enabled = 0;
|
||||
break;
|
||||
|
|
@ -120,12 +120,12 @@ void FCache_Disable()
|
|||
/* Statistic counters enabled, Cache disable,
|
||||
* manual-inval, manual-power control
|
||||
*/
|
||||
writel(SYS_FCACHE_CCR, (FCACHE_POW_REQ
|
||||
FCache_Writel(SYS_FCACHE_CCR, (FCACHE_POW_REQ
|
||||
| FCACHE_SET_MAN_POW
|
||||
| FCACHE_SET_MAN_INV
|
||||
| FCACHE_STATISTIC_EN));
|
||||
/* Wait until the cache is disabled */
|
||||
while ((readl(SYS_FCACHE_SR) & FCACHE_CS) != FCACHE_CS_DISABLED);
|
||||
while ((FCache_Readl(SYS_FCACHE_SR) & FCACHE_CS) != FCACHE_CS_DISABLED);
|
||||
/* Cache Enabled: Set enabled to 0 */
|
||||
enabled = 0;
|
||||
break;
|
||||
|
|
@ -151,18 +151,18 @@ int FCache_Invalidate()
|
|||
goto error;
|
||||
|
||||
/* Trigger INV_REQ */
|
||||
writel(SYS_FCACHE_CCR, (FCACHE_INV_REQ
|
||||
FCache_Writel(SYS_FCACHE_CCR, (FCACHE_INV_REQ
|
||||
| FCACHE_POW_REQ
|
||||
| FCACHE_SET_MAN_POW
|
||||
| FCACHE_SET_MAN_INV
|
||||
| FCACHE_STATISTIC_EN));
|
||||
|
||||
/* Wait until INV_REQ is finished */
|
||||
while ((readl(SYS_FCACHE_SR) & FCACHE_CS) != FCACHE_CS_DISABLED);
|
||||
while ((FCache_Readl(SYS_FCACHE_SR) & FCACHE_CS) != FCACHE_CS_DISABLED);
|
||||
|
||||
/* Clear Stats */
|
||||
writel(SYS_FCACHE_CSHR, 0);
|
||||
writel(SYS_FCACHE_CSMR, 0);
|
||||
FCache_Writel(SYS_FCACHE_CSHR, 0);
|
||||
FCache_Writel(SYS_FCACHE_CSMR, 0);
|
||||
|
||||
/* Enable Flash Cache */
|
||||
if (enabled == 0)
|
||||
|
|
@ -183,9 +183,9 @@ unsigned int * FCache_GetStats()
|
|||
static unsigned int stats[2];
|
||||
|
||||
/* Cache Statistics HIT Register */
|
||||
stats[0] = readl(SYS_FCACHE_CSHR);
|
||||
stats[0] = FCache_Readl(SYS_FCACHE_CSHR);
|
||||
/* Cache Statistics MISS Register */
|
||||
stats[1] = readl(SYS_FCACHE_CSMR);
|
||||
stats[1] = FCache_Readl(SYS_FCACHE_CSMR);
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
|
@ -197,4 +197,3 @@ unsigned int FCache_isEnabled()
|
|||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,18 +60,18 @@ extern "C" {
|
|||
#define FCACHE_MAN_INV_ERR (1 << 1) /* Manual Invalidation error status */
|
||||
|
||||
/* Macros */
|
||||
#define readl(reg) *(volatile unsigned int *)reg
|
||||
#define writel(reg, val) *(unsigned int *)reg = val;
|
||||
#define FCache_Readl(reg) *(volatile unsigned int *)reg
|
||||
#define FCache_Writel(reg, val) *(volatile unsigned int *)reg = val;
|
||||
|
||||
/* Functions */
|
||||
|
||||
/*
|
||||
* FCache_Initialize: flash cache initialize funtion
|
||||
* FCache_DriverInitialize: flash cache driver initialize funtion
|
||||
*/
|
||||
void FCache_Initialize(void);
|
||||
void FCache_DriverInitialize(void);
|
||||
|
||||
/*
|
||||
* FCache_Enable: Enables the flash cache
|
||||
* FCache_Enable: Enables the flash cache mode
|
||||
* mode: supported modes:
|
||||
* 0 - auto-power auto-invalidate
|
||||
* 1 - manual-power, manual-invalidate
|
||||
|
|
@ -79,7 +79,7 @@ void FCache_Initialize(void);
|
|||
void FCache_Enable(int mode);
|
||||
|
||||
/*
|
||||
* FCache_Disable: Disables the cache
|
||||
* FCache_Disable: Disables the flash cache mode previously enabled
|
||||
*/
|
||||
void FCache_Disable(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -119,3 +119,36 @@ void SystemPowerResume(power_mode_t mode)
|
|||
__DSB();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* System config data storage functions
|
||||
* Reserved as the data is not strictly persistent
|
||||
*/
|
||||
|
||||
/*
|
||||
* __System_Config_GetBDAddr(): Address for the BLE device on the air.
|
||||
*/
|
||||
void __System_Config_GetBDAddr(uint8_t *addr, uint8_t byte_len)
|
||||
{
|
||||
SystemCoreConfigData *p;
|
||||
int bank1addr = EFlash_ReturnBank1BaseAddress();
|
||||
|
||||
if (byte_len > 6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (bank1addr < 0)
|
||||
{
|
||||
memset(addr, 0xFF, byte_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 2x bank1 address is the top as banks have to be symmetric sizes */
|
||||
/* The data is stored at the end.*/
|
||||
p = (SystemCoreConfigData *) ((2 * bank1addr) - SYSTEM_CORE_CONFIG_DATA_SIZE);
|
||||
|
||||
memcpy(addr, p->BD_ADDR, byte_len);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,29 @@ void SystemPowerSuspend(power_mode_t mode);
|
|||
*/
|
||||
void SystemPowerResume(power_mode_t mode);
|
||||
|
||||
/*
|
||||
* Definitions for storing static configuration data in Beetle
|
||||
* This is not strictly persistent data as it will get wiped out on chip erase.
|
||||
*
|
||||
* There are only read functions provided.
|
||||
* No Write function to prevent accidental writes resulting in
|
||||
* the system being non responsive.
|
||||
* Use the Flash manual before trying to write anything in the last 4k.
|
||||
*/
|
||||
#define SYSTEM_CORE_CONFIG_DATA_SIZE (0x200) /* 512 bytes*/
|
||||
|
||||
typedef struct {
|
||||
uint32_t BD_ADDR[2];
|
||||
|
||||
/*rest reserved*/
|
||||
uint32_t reserved[SYSTEM_CORE_CONFIG_DATA_SIZE - 2];
|
||||
} SystemCoreConfigData;
|
||||
|
||||
/*
|
||||
* __System_Config_GetBDAddr(): Address for the BLE device on the air.
|
||||
*/
|
||||
void __System_Config_GetBDAddr(uint8_t *addr, uint8_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
4
hal/targets/hal/TARGET_ARM_SSG/TARGET_BEETLE/TOOLCHAIN_ARM_STD/.gitattributes
vendored
Normal file
4
hal/targets/hal/TARGET_ARM_SSG/TARGET_BEETLE/TOOLCHAIN_ARM_STD/.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
*.o binary
|
||||
*.lib binary
|
||||
*.a binary
|
||||
*.ar binary
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
Permissive Binary License
|
||||
|
||||
Version 1.0, September 2015
|
||||
|
||||
Redistribution. Redistribution and use in binary form, without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1) Redistributions must reproduce the above copyright notice and the
|
||||
following disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
2) Unless to the extent explicitly permitted by law, no reverse
|
||||
engineering, decompilation, or disassembly of this software is
|
||||
permitted.
|
||||
|
||||
3) Redistribution as part of a software development kit must include the
|
||||
accompanying file named “DEPENDENCIES” and any dependencies listed in
|
||||
that file.
|
||||
|
||||
4) Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
Limited patent license. The copyright holders (and contributors) grant a
|
||||
worldwide, non-exclusive, no-charge, royalty-free patent license to
|
||||
make, have made, use, offer to sell, sell, import, and otherwise
|
||||
transfer this software, where such license applies only to those patent
|
||||
claims licensable by the copyright holders (and contributors) that are
|
||||
necessarily infringed by this software. This patent license shall not
|
||||
apply to any combinations that include this software. No hardware is
|
||||
licensed hereunder.
|
||||
|
||||
If you institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the software
|
||||
itself infringes your patent(s), then your rights granted under this
|
||||
license shall terminate as of the date such litigation is filed.
|
||||
|
||||
DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
|
||||
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
The binary files (cordio.0.0.1.ar and cordio_platform.0.0.1.ar) in this directory are licensed under the
|
||||
Permissive Binary License1.0 (PBL-1.0) as can be found in: LICENSE-permissive-binary-license-1.0.txt
|
||||
Binary file not shown.
Binary file not shown.
4
hal/targets/hal/TARGET_ARM_SSG/TARGET_BEETLE/TOOLCHAIN_GCC_ARM/.gitattributes
vendored
Normal file
4
hal/targets/hal/TARGET_ARM_SSG/TARGET_BEETLE/TOOLCHAIN_GCC_ARM/.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
*.o binary
|
||||
*.lib binary
|
||||
*.a binary
|
||||
*.ar binary
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
Permissive Binary License
|
||||
|
||||
Version 1.0, September 2015
|
||||
|
||||
Redistribution. Redistribution and use in binary form, without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1) Redistributions must reproduce the above copyright notice and the
|
||||
following disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
2) Unless to the extent explicitly permitted by law, no reverse
|
||||
engineering, decompilation, or disassembly of this software is
|
||||
permitted.
|
||||
|
||||
3) Redistribution as part of a software development kit must include the
|
||||
accompanying file named “DEPENDENCIES” and any dependencies listed in
|
||||
that file.
|
||||
|
||||
4) Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
Limited patent license. The copyright holders (and contributors) grant a
|
||||
worldwide, non-exclusive, no-charge, royalty-free patent license to
|
||||
make, have made, use, offer to sell, sell, import, and otherwise
|
||||
transfer this software, where such license applies only to those patent
|
||||
claims licensable by the copyright holders (and contributors) that are
|
||||
necessarily infringed by this software. This patent license shall not
|
||||
apply to any combinations that include this software. No hardware is
|
||||
licensed hereunder.
|
||||
|
||||
If you institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the software
|
||||
itself infringes your patent(s), then your rights granted under this
|
||||
license shall terminate as of the date such litigation is filed.
|
||||
|
||||
DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
|
||||
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
The binary files (libcordio.0.0.1.a and libcordio_platform.0.0.1.a) in this directory are licensed under the
|
||||
Permissive Binary License1.0 (PBL-1.0) as can be found in: LICENSE-permissive-binary-license-1.0.txt
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,49 @@
|
|||
Permissive Binary License
|
||||
|
||||
Version 1.0, September 2015
|
||||
|
||||
Redistribution. Redistribution and use in binary form, without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1) Redistributions must reproduce the above copyright notice and the
|
||||
following disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
2) Unless to the extent explicitly permitted by law, no reverse
|
||||
engineering, decompilation, or disassembly of this software is
|
||||
permitted.
|
||||
|
||||
3) Redistribution as part of a software development kit must include the
|
||||
accompanying file named “DEPENDENCIES” and any dependencies listed in
|
||||
that file.
|
||||
|
||||
4) Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
Limited patent license. The copyright holders (and contributors) grant a
|
||||
worldwide, non-exclusive, no-charge, royalty-free patent license to
|
||||
make, have made, use, offer to sell, sell, import, and otherwise
|
||||
transfer this software, where such license applies only to those patent
|
||||
claims licensable by the copyright holders (and contributors) that are
|
||||
necessarily infringed by this software. This patent license shall not
|
||||
apply to any combinations that include this software. No hardware is
|
||||
licensed hereunder.
|
||||
|
||||
If you institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the software
|
||||
itself infringes your patent(s), then your rights granted under this
|
||||
license shall terminate as of the date such litigation is filed.
|
||||
|
||||
DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
|
||||
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
*.o binary
|
||||
*.lib binary
|
||||
*.a binary
|
||||
*.ar binary
|
||||
Binary file not shown.
|
|
@ -0,0 +1,49 @@
|
|||
Permissive Binary License
|
||||
|
||||
Version 1.0, September 2015
|
||||
|
||||
Redistribution. Redistribution and use in binary form, without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1) Redistributions must reproduce the above copyright notice and the
|
||||
following disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
2) Unless to the extent explicitly permitted by law, no reverse
|
||||
engineering, decompilation, or disassembly of this software is
|
||||
permitted.
|
||||
|
||||
3) Redistribution as part of a software development kit must include the
|
||||
accompanying file named “DEPENDENCIES” and any dependencies listed in
|
||||
that file.
|
||||
|
||||
4) Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
Limited patent license. The copyright holders (and contributors) grant a
|
||||
worldwide, non-exclusive, no-charge, royalty-free patent license to
|
||||
make, have made, use, offer to sell, sell, import, and otherwise
|
||||
transfer this software, where such license applies only to those patent
|
||||
claims licensable by the copyright holders (and contributors) that are
|
||||
necessarily infringed by this software. This patent license shall not
|
||||
apply to any combinations that include this software. No hardware is
|
||||
licensed hereunder.
|
||||
|
||||
If you institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the software
|
||||
itself infringes your patent(s), then your rights granted under this
|
||||
license shall terminate as of the date such litigation is filed.
|
||||
|
||||
DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
|
||||
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
The binary files (CORDIO_RO_2.1.o and TRIM_2.1.o) in this directory are licensed under the
|
||||
Permissive Binary License1.0 (PBL-1.0) as can be found in: LICENSE-permissive-binary-license-1.0.txt
|
||||
Binary file not shown.
|
|
@ -0,0 +1,125 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file board.h
|
||||
*
|
||||
* \brief Board-specific include file for BT4 module board.
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
|
||||
#ifndef BOARD_H
|
||||
#define BOARD_H
|
||||
|
||||
|
||||
|
||||
/***************************************************************************************************
|
||||
** DEVICE
|
||||
***************************************************************************************************/
|
||||
|
||||
/* install defines and installs for device ARM_BEETLE_SOC */
|
||||
#define ARM_BEETLE_SOC (1U)
|
||||
|
||||
/***************************************************************************************************
|
||||
** UART & CONSOLE
|
||||
***************************************************************************************************/
|
||||
#include <drv_uart.h>
|
||||
extern const struct drv_uart Drv_UART0;
|
||||
#define BOARD_HAS_UART0
|
||||
|
||||
#include <drv_console.h>
|
||||
extern const struct drv_console Drv_Console0;
|
||||
|
||||
#define BOARD_UART Drv_UART0
|
||||
#define BOARD_CONSOLE Drv_Console0
|
||||
#define BOARD_CONSOLE_NUM 0
|
||||
#define BOARD_CONSOLE_BAUD 9600u
|
||||
|
||||
#define BOARD_HCIPASSTHRU_CONSOLE Drv_Console0
|
||||
#define BOARD_HCIPASSTHRU_NUM 0
|
||||
#define BOARD_HCIPASSTHRU_BAUD 9600u
|
||||
|
||||
#if BOARD_CONSOLE_NUM == BOARD_HCIPASSTHRU_NUM
|
||||
# if BOARD_CONSOLE_BAUD != BOARD_HCIPASSTHRU_BAUD
|
||||
# error CONSOLE and HCIPASSTHRU use the same UART, but the bauds are configured different
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define BOARD_TERMINAL_CONSOLE Drv_Console0
|
||||
#define BOARD_TERMINAL_NUM 0
|
||||
#define BOARD_TERMINAL_BAUD 9600u
|
||||
|
||||
/***************************************************************************************************
|
||||
** GPIO
|
||||
***************************************************************************************************/
|
||||
#define BOARD_GPIO_OUTPUT_QUANTITY 1u
|
||||
#define BOARD_GPIO_OUTPUT_0 GPIO_GPIO3
|
||||
#define BOARD_GPIO_OUTPUTS {BOARD_GPIO_OUTPUT_0}
|
||||
#define BOARD_GPIO_OUTPUTS_MASK (BOARD_GPIO_OUTPUT_0)
|
||||
|
||||
/* gpio inputs */
|
||||
#define BOARD_HAS_WAKEUP
|
||||
|
||||
/***************************************************************************************************
|
||||
** SPI
|
||||
***************************************************************************************************/
|
||||
#ifndef ARM_BEETLE_SOC
|
||||
|
||||
#define BOARD_SPIFLASH_MAIN_IMAGE_OFFSET 0u
|
||||
#define BOARD_SPIFLASH_MAIN_IMAGE_LIMIT (BOARD_SPIFLASH_NVDATA_OFFSET - 1u)
|
||||
#define BOARD_SPIFLASH_NVDATA_LEN (4u * 1024u)
|
||||
#define BOARD_SPIFLASH_NVDATA_OFFSET (1020u * 1024u)
|
||||
#define BOARD_SPIFLASH_NVDATA_LIMIT (BOARD_SPIFLASH_NVDATA_OFFSET + BOARD_SPIFLASH_NVDATA_LEN - 1u)
|
||||
|
||||
#else
|
||||
/* USING ON CHIP FLASH FROM UPPER UPPER BANK, LINKED THROUGH *.o and SCATTER */
|
||||
extern unsigned char _binary_ASIC_2_1_img_start;
|
||||
extern unsigned char _binary_ASIC_2_1_img_end;
|
||||
extern unsigned char _binary_ASIC_2_1_img_size;
|
||||
|
||||
#define BOARD_HAS_FLASH_STORAGE
|
||||
|
||||
#define FLASH_ELF_HDR_JMP_OFFSET (52U)
|
||||
#define BOARD_FLASH_STORAGE_MAIN_IMAGE_OFFSET (0U) //jump over the ELF HEADER OF OBJECT
|
||||
#define BOARD_FLASH_STORAGE_MAIN_IMAGE_LIMIT (((74U) * (1024U)) - 1u) //64K FLASH STORAGE BLOCK
|
||||
|
||||
#define BOARD_FLASH_STORAGE_NVDATA_OFFSET (0U)
|
||||
#define BOARD_FLASH_STORAGE_NVDATA_LEN ((4U) * (1024U)) //4K NVM BLOCK SIZE
|
||||
#define BOARD_FLASH_STORAGE_NVDATA_LIMIT (BOARD_FLASH_STORAGE_NVDATA_OFFSET + BOARD_FLASH_STORAGE_NVDATA_LEN - 1u)
|
||||
|
||||
#define BOARD_FLASH_STORAGE_DATA_LEN_MASK (0xFFFU); //Length mask of 4K
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/***************************************************************************************************
|
||||
** LLCC
|
||||
***************************************************************************************************/
|
||||
|
||||
#include <drv_llcc.h>
|
||||
extern const struct drv_llcc Drv_LLCC;
|
||||
|
||||
/***************************************************************************************************
|
||||
** IDs
|
||||
***************************************************************************************************/
|
||||
|
||||
#define BOARD_MANUFACTURER "ARM, Ltd."
|
||||
#define BOARD_NAME "BEETLE"
|
||||
#define BOARD_NAME_SHORT "BT4"
|
||||
#define BOARD_HW_REVISION "B"
|
||||
#define BOARD_COMPANY_ID 0x01AFu
|
||||
|
||||
#endif /* BOARD_H */
|
||||
|
|
@ -0,0 +1,361 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file main_board.h
|
||||
*
|
||||
* \brief Board services.
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
|
||||
#ifndef __MAIN_BOARD_H
|
||||
#define __MAIN_BOARD_H
|
||||
|
||||
/***************************************************************************************************
|
||||
** INCLUDES
|
||||
***************************************************************************************************/
|
||||
|
||||
#include "chip.h"
|
||||
#include "board.h"
|
||||
|
||||
#include "wsf_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************************************************************************************
|
||||
** TYPES
|
||||
***************************************************************************************************/
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** enum main_board_mode
|
||||
**
|
||||
** DESCRIPTION: Mode of application on board, if detectable at run-time.
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
enum main_board_mode {
|
||||
MAIN_BOARD_MODE_DTM = 0,
|
||||
MAIN_BOARD_MODE_BEACON = 1,
|
||||
MAIN_BOARD_MODE_SENSOR = 2,
|
||||
MAIN_BOARD_MODE_BEACON_NONCONNECTABLE = 3
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** enum main_board_settings
|
||||
**
|
||||
** DESCRIPTION: Settings for board, stored in NV data. These values should not be changed once
|
||||
** used.
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
enum main_board_settings {
|
||||
/* Major number (for beacon) [2 bytes] */
|
||||
MAIN_BOARD_SETTING_MAJOR = 0,
|
||||
/* Minor number (for beacon) [2 bytes] */
|
||||
MAIN_BOARD_SETTING_MINOR = 1,
|
||||
/* RSSI reference (for beacon) [2 bytes] */
|
||||
MAIN_BOARD_SETTING_RSSI_REFERENCE = 2,
|
||||
/* HCI logging level [1 byte] */
|
||||
MAIN_BOARD_SETTING_HCI_LOGGING_LEVEL = 3,
|
||||
/* Lock state (for UriBeacon) [1 byte] */
|
||||
MAIN_BOARD_SETTING_LOCK_STATE = 4,
|
||||
/* URI data (for UriBeacon) [18 bytes] */
|
||||
MAIN_BOARD_SETTING_URI_DATA = 5,
|
||||
/* URI flags (for UriBeacon) [1 byte] */
|
||||
MAIN_BOARD_SETTING_URI_FLAGS = 6,
|
||||
/* Advertised tx power levels (for UriBeacon) [4 bytes] */
|
||||
MAIN_BOARD_SETTING_ADVERTISED_TX_POWER_LEVELS = 7,
|
||||
/* Tx power mode (for UriBeacon) [1 byte] */
|
||||
MAIN_BOARD_SETTING_TX_POWER_MODE = 8,
|
||||
/* Beacon period (for beacon) [2 bytes] */
|
||||
MAIN_BOARD_SETTING_BEACON_PERIOD = 9,
|
||||
/* Lock [16 bytes] */
|
||||
MAIN_BOARD_SETTING_LOCK = 10,
|
||||
/* PIN [3 bytes] */
|
||||
MAIN_BOARD_SETTING_PIN = 11,
|
||||
/* Beacon type [1 byte] */
|
||||
MAIN_BOARD_SETTING_BEACON_TYPE = 12,
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** enum main_board_muxmode
|
||||
**
|
||||
** DESCRIPTION: Settings for MUX mode of MCU.
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
enum main_board_muxmode {
|
||||
MAIN_BOARD_MUXMODE_NORMAL = 0,
|
||||
MAIN_BOARD_MUXMODE_DIGITAL_TEST = 1,
|
||||
};
|
||||
|
||||
/***************************************************************************************************
|
||||
** FUNCTIONS
|
||||
***************************************************************************************************/
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardInit()
|
||||
**
|
||||
** DESCRIPTION: Initialize board.
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
void Main_BoardInit(void);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardI2cInit()
|
||||
**
|
||||
** DESCRIPTION: Initialize I2C devices on board.
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
#ifdef BOARD_HAS_I2C
|
||||
void Main_BoardI2cInit(void);
|
||||
#endif
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardGetMode()
|
||||
**
|
||||
** DESCRIPTION: Get board mode.
|
||||
**
|
||||
** RETURNS: Board mode.
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
enum main_board_mode Main_BoardGetMode(void);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardNvGetSize()
|
||||
**
|
||||
** DESCRIPTION: Called to get size of NV memory.
|
||||
**
|
||||
** RETURNS: Size of NV memory
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
#ifdef BOARD_HAS_SPIFLASH
|
||||
size_t Main_BoardNvGetSize(void);
|
||||
#endif /* BOARD_HAS_SPIFLASH */
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardNvRead()
|
||||
**
|
||||
** DESCRIPTION: Called to read NV data.
|
||||
**
|
||||
** PARAMETERS: addr Address from which to read
|
||||
** buf Pointer to buffer to receive data
|
||||
** length Number of bytes to read
|
||||
**
|
||||
** RETURNS: Number of bytes read
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
#ifdef BOARD_HAS_SPIFLASH
|
||||
size_t Main_BoardNvRead(size_t addr, uint8_t *buf, size_t length);
|
||||
#endif /* BOARD_HAS_SPIFLASH */
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardNvWrite()
|
||||
**
|
||||
** DESCRIPTION: Called to write NV data.
|
||||
**
|
||||
** PARAMETERS: addr Address at which to write
|
||||
** buf Pointer to buffer with data to write
|
||||
** length Number of bytes to write
|
||||
**
|
||||
** RETURNS: Number of bytes written
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
#ifdef BOARD_HAS_SPIFLASH
|
||||
size_t Main_BoardNvWrite(size_t addr, const uint8_t *buf, size_t length);
|
||||
#endif /* BOARD_HAS_SPIFLASH */
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardNvErase()
|
||||
**
|
||||
** DESCRIPTION: Called to erase NV data.
|
||||
**
|
||||
** RETURNS: 0 or error (if not 0)
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
#ifdef BOARD_HAS_SPIFLASH
|
||||
int32_t Main_BoardNvErase(void);
|
||||
#endif /* BOARD_HAS_SPIFLASH */
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardSettingsInit()
|
||||
**
|
||||
** DESCRIPTION: Initialize settings stored in a host blob in the NV data.
|
||||
**
|
||||
** RETURNS: 0 or error (if not 0)
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
#ifdef BOARD_HAS_SPIFLASH
|
||||
int32_t Main_BoardSettingsInit(void);
|
||||
#endif /* BOARD_HAS_SPIFLASH */
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardSettingsClear()
|
||||
**
|
||||
** DESCRIPTION: Clear settings stored in a host blob in the NV data.
|
||||
**
|
||||
** RETURNS: 0 or error (if not 0)
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
#ifdef BOARD_HAS_SPIFLASH
|
||||
int32_t Main_BoardSettingsClear(void);
|
||||
#endif /* BOARD_HAS_SPIFLASH */
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardSettingRead()
|
||||
**
|
||||
** DESCRIPTION: Read a setting stored in a host blob in the NV data.
|
||||
**
|
||||
** PARAMETERS: id ID of the setting
|
||||
** buf Pointer to buffer that will receive setting value
|
||||
** length Length of the buffer; if setting is longer, only this many bytes will be
|
||||
** stored
|
||||
**
|
||||
** RETURNS: length of the setting or error (if less than or equal to zero)
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
#ifdef BOARD_HAS_SPIFLASH
|
||||
int32_t Main_BoardSettingRead(uint8_t id, uint8_t *buf, uint8_t length);
|
||||
#endif /* BOARD_HAS_SPIFLASH */
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardSettingWrite()
|
||||
**
|
||||
** DESCRIPTION: Write a setting stored in a host blob in the NV data.
|
||||
**
|
||||
** PARAMETERS: id ID of the setting
|
||||
** buf Pointer to buffer with setting value
|
||||
** length Length of the buffer; if setting is longer, only this many bytes will be
|
||||
** read
|
||||
**
|
||||
** RETURNS: length of the setting or error (if less than or equal to zero)
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
#ifdef BOARD_HAS_SPIFLASH
|
||||
int32_t Main_BoardSettingWrite(uint8_t id, const uint8_t *buf, uint8_t length);
|
||||
#endif /* BOARD_HAS_SPIFLASH */
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardSetPmuFeature()
|
||||
**
|
||||
** DESCRIPTION: Set PMU feature of MCU.
|
||||
**
|
||||
** PARAMETERS: req Requested feature(s).
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
void Main_BoardSetPmuFeature(uint8_t req);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardGetPmuFeature()
|
||||
**
|
||||
** DESCRIPTION: Get PMU feature of MCU.
|
||||
**
|
||||
** RETURNS: Requested feature(s).
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
uint8_t Main_BoardGetPmuFeature(void);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardSetMuxMode()
|
||||
**
|
||||
** DESCRIPTION: Set MUX mode of MCU.
|
||||
**
|
||||
** PARAMETERS: mode Mode to set
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
void Main_BoardSetMuxMode(uint8_t mode);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardWakeLockInc()
|
||||
**
|
||||
** DESCRIPTION: Increment counter to keep MCU from entering deep sleep.
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
void Main_BoardWakeLockInc(void);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardWakeLockDec()
|
||||
**
|
||||
** DESCRIPTION: Decrement counter to allow MCU to enter deep sleep.
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
void Main_BoardWakeLockDec(void);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_Board32kTimerSleep()
|
||||
**
|
||||
** DESCRIPTION: Deep sleep for a certain number of ticks of the 32k timer.
|
||||
**
|
||||
** PARAMETERS: ticks Number of ticks to sleep; 0 to sleep forever
|
||||
** deep TRUE if sleep should be deep sleep
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
void Main_Board32kTimerSleep(uint32_t ticks, bool_t deep);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_Board32kTimerRead()
|
||||
**
|
||||
** DESCRIPTION: Read the 32k timer.
|
||||
**
|
||||
** Returns: The timer value
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
uint32_t Main_Board32kTimerRead(void);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardSetWakeupCallback()
|
||||
**
|
||||
** DESCRIPTION: Set callback for wakeup interrupt.
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
#ifdef BOARD_HAS_WAKEUP
|
||||
void Main_BoardSetWakeupCback(void (*wakeupCback)(void));
|
||||
#endif
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardWatchdogTimeout()
|
||||
**
|
||||
** DESCRIPTION: Set watchdog to expire in certain number of milliseconds, after which the processor
|
||||
** will reset.
|
||||
**
|
||||
** PARAMETERS: to_ms Milliseconds before timeout; 0 to timeout immediately
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
void Main_BoardWatchdogTimeout(uint16_t to_ms);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardWatchdogCancel()
|
||||
**
|
||||
** DESCRIPTION: Cancel watchdog timeout, so that the processor will not reset if it expires.
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
void Main_BoardWatchdogCancel(void);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardGpioSet()
|
||||
**
|
||||
** DESCRIPTION: Set GPIO output.
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
#ifdef BOARD_HAS_GPIO_OUTPUTS
|
||||
void Main_BoardGpioSet(uint8_t num);
|
||||
#endif
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardGpioClr()
|
||||
**
|
||||
** DESCRIPTION: Clear GPIO output.
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
#ifdef BOARD_HAS_GPIO_OUTPUTS
|
||||
void Main_BoardGpioClr(uint8_t num);
|
||||
#endif
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardGpioToggle()
|
||||
**
|
||||
** DESCRIPTION: Toggle GPIO output.
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
#ifdef BOARD_HAS_GPIO_OUTPUTS
|
||||
void Main_BoardGpioToggle(uint8_t num);
|
||||
#endif
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Main_BoardDelayUsec()
|
||||
**
|
||||
** DESCRIPTION: Delay for a certain time, in microseconds.
|
||||
**
|
||||
** PARAMETERS: delay_us Microseconds to delay.
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
void Main_BoardDelayUsec(uint32_t delay_us);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __MAIN_BOARD_H */
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file chip.h
|
||||
*
|
||||
* \brief Include file for SMD TC2.
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
|
||||
#ifndef CHIP_H
|
||||
#define CHIP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <CMSDK_BEETLE.h>
|
||||
|
||||
#include "chip_hw.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CHIP_H */
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file chip_hw.h
|
||||
*
|
||||
* \brief Low-level chip defines for SMD TC2.
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
|
||||
#ifndef CHIP_HW_H
|
||||
#define CHIP_HW_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MCU_SRAM_BASE (0x20000000)
|
||||
#define MCU_SRAM_SIZE (128*1024)
|
||||
#define MCU_STACK_SIZE (1024)
|
||||
#define MCU_MIN_HEAP (1024)
|
||||
#define MCU_ROM_BASE (0x00000000)
|
||||
#define MCU_ROM_SIZE (8*1024)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CHIP_HW_H */
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file ble_init.c
|
||||
*
|
||||
* \brief BLE initialization.
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
|
||||
#ifndef BLE_INIT_H
|
||||
#define BLE_INIT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn BleInitStart
|
||||
*
|
||||
* \brief Set BLE initialization.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void BleInitStart(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLE_INIT_H */
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file cordio_tc2_defs.h
|
||||
*
|
||||
* \brief Cordio TC2 defines.
|
||||
*
|
||||
* $Date: 2015-09-28 16:07:14 -0400 (Mon, 28 Sep 2015) $
|
||||
* $Revision: 4037 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
|
||||
#ifndef CORDIO_TC2_DEFS_H
|
||||
#define CORDIO_TC2_DEFS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! \brief Expected cookie value for TC2 images. */
|
||||
#define CORDIO_TC2_HEADER_COOKIE 0x30444D53
|
||||
|
||||
/*! \brief Length of header. */
|
||||
#define CORDIO_TC2_HEADER_LEN 24
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! \brief Header for images sought by ROM bootloader. */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t cookie; /*!< Cookie value. */
|
||||
uint8_t hdrLen; /*!< Header length, in octets (must be 24). */
|
||||
uint8_t type; /*!< Type of image. */
|
||||
uint8_t revMajor; /*!< Major image revision. */
|
||||
uint8_t revMinor; /*!< Minor image revision. */
|
||||
uint32_t dataLen; /*!< Length of data, with image flags. */
|
||||
uint32_t offset; /*!< Offset to which image should be copied. */
|
||||
uint32_t entry; /*!< Entry point. */
|
||||
uint32_t crc; /*!< Checksum over header and data. */
|
||||
} CordioTc2ImgHdr_t;
|
||||
|
||||
/*! \brief Image types. */
|
||||
enum
|
||||
{
|
||||
CORDIO_TC2_IMG_TYPE_HOST_FW = 0, /*!< Host firmware. */
|
||||
CORDIO_TC2_IMG_TYPE_BT4_FW = 1, /*!< BT4 firmware. */
|
||||
CORDIO_TC2_IMG_TYPE_BT4_PATCH = 2, /*!< BT4 patch. */
|
||||
CORDIO_TC2_IMG_TYPE_BT4_TRIM = 3, /*!< BT4 trim. */
|
||||
CORDIO_TC2_IMG_TYPE_HOST_CFG = 4 /*!< Host configuration. */
|
||||
};
|
||||
|
||||
/*! \brief Data length bits and fields. */
|
||||
enum
|
||||
{
|
||||
CORDIO_TC2_DATA_LEN_MASK = 0x00FFFFFF, /*!< Data length mask. */
|
||||
CORDIO_TC2_DATA_LEN_FLAG_ENCRYPTED = (1 << 30) /*!< Data encrypted flag. */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CORDIO_TC2_DEFS_H */
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file cordio_sdk_version.h
|
||||
*
|
||||
* \brief Cordio SDK version.
|
||||
*
|
||||
* $Date: 2015-10-22 18:45:26 -0400 (Thu, 22 Oct 2015) $
|
||||
* $Revision: 4273 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
|
||||
#ifndef CORDIO_SDK_VERSION_H
|
||||
#define CORDIO_SDK_VERSION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*! \brief Cordio SDK version string. */
|
||||
#define CORDIO_SDK_VERSION "20151023-r4279"
|
||||
|
||||
/*! \brief Cordio SDK major version. */
|
||||
#define CORDIO_SDK_VERSION_MAJOR 1
|
||||
|
||||
/*! \brief Cordio SDK minor version. */
|
||||
#define CORDIO_SDK_VERSION_MINOR 1.4
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CORDIO_SDK_VERSION_H */
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file drv_console.h
|
||||
*
|
||||
* \brief Upper-layer UART driver.
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
|
||||
#ifndef __DRV_CONSOLE_H
|
||||
#define __DRV_CONSOLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************************************************************************************
|
||||
** INCLUDES
|
||||
***************************************************************************************************/
|
||||
|
||||
#include "chip.h"
|
||||
#include "board.h"
|
||||
|
||||
/***************************************************************************************************
|
||||
** DEFINES
|
||||
***************************************************************************************************/
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** ENABLE/DISABLE, ON/OFF DEFINES
|
||||
**
|
||||
** DESCRIPTION: For clarity in enable parameters.
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef DRV_ENABLE
|
||||
#define DRV_ENABLE 1
|
||||
#endif
|
||||
|
||||
#ifndef DRV_DISABLE
|
||||
#define DRV_DISABLE 0
|
||||
#endif
|
||||
|
||||
#ifndef DRV_ON
|
||||
#define DRV_ON 1
|
||||
#endif
|
||||
|
||||
#ifndef DRV_OFF
|
||||
#define DRV_OFF 0
|
||||
#endif
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** TX/RX DEFINES
|
||||
**
|
||||
** DESCRIPTION: For tx/rx argument of driver functions.
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
#define DRV_CONSOLE_TX (1u << 0)
|
||||
#define DRV_CONSOLE_RX (1u << 1)
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** DRV_CONSOLE_BUF_LEN
|
||||
**
|
||||
** DESCRIPTION: The maximum length of printed strings.
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
#define DRV_CONSOLE_BUF_LEN 128u
|
||||
|
||||
/***************************************************************************************************
|
||||
** TYPES
|
||||
***************************************************************************************************/
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** DRV_CONSOLE_RX_CALLBACK_t()
|
||||
**
|
||||
** DESCRIPTION: Callback for received byte.
|
||||
**
|
||||
** PARAMETERS: c Received byte
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
|
||||
typedef void (*DRV_CONSOLE_RX_CALLBACK_t)(uint8_t c);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** DRV_CONSOLE_TX_COMPLETE_CALLBACK_t()
|
||||
**
|
||||
** DESCRIPTION: Callback for transmission completion.
|
||||
**
|
||||
** PARAMETERS: buf Pointer to buffer that was transmitted
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
|
||||
typedef void (*DRV_CONSOLE_TX_COMPLETE_CALLBACK_t)(const uint8_t *buf);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** struct drv_console
|
||||
**
|
||||
** DESCRIPTION: Access structure of driver.
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
struct drv_console {
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** Initialize()
|
||||
**
|
||||
** DESCRIPTION: Initialize console.
|
||||
**
|
||||
** PARAMETERS: baud Baud rate
|
||||
** rx_tx Indicates allowed modes of driver (DRV_CONSOLE_RX &/| DRV_CONSOLE_TX).
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
void (*Initialize)(uint32_t baud, uint32_t rx_tx);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** Receive()
|
||||
**
|
||||
** DESCRIPTION: Receive data.
|
||||
**
|
||||
** PARAMETERS: buf Pointer to buffer that will receive data
|
||||
** len Number of data bytes to data
|
||||
**
|
||||
** RETURNS: Number of bytes received
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
int32_t (*Receive)(uint8_t *buf, uint32_t len);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** ReceiveAsyncStart()
|
||||
**
|
||||
** DESCRIPTION: Start receiving data asynchronously.
|
||||
**
|
||||
** PARAMETERS: cb Callback for receive events
|
||||
**
|
||||
** RETURNS: 0 or error (if not zero)
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
int32_t (*ReceiveAsyncStart)(DRV_UART_RX_CALLBACK_t cb);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** ReceiveAsyncStart()
|
||||
**
|
||||
** DESCRIPTION: Stop receiving data asynchronously.
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
void (*ReceiveAsyncStop)(void);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** Transmit()
|
||||
**
|
||||
** DESCRIPTION: Transmit buffer synchronously, waiting for any active transmission to finish.
|
||||
**
|
||||
** PARAMETERS: buf Pointer to buffer of data to transmit
|
||||
** len Number of data bytes to transmit
|
||||
**
|
||||
** RETURNS: Number of bytes transmitted
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
int32_t (*Transmit)(const uint8_t *buf, uint32_t len);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** TransmitAsync()
|
||||
**
|
||||
** DESCRIPTION: Transmit buffer asynchronously, waiting for any active transmission to finish.
|
||||
**
|
||||
** PARAMETERS: buf Pointer to buffer of data to transmit
|
||||
** len Number of data bytes to transmit
|
||||
** cb Pointer to completion callback
|
||||
**
|
||||
** RETURNS: 0 or error (if not zero)
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
int32_t (*TransmitAsync)(const uint8_t *buf, uint32_t len, DRV_CONSOLE_TX_COMPLETE_CALLBACK_t cb);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** GetUART()
|
||||
**
|
||||
** DESCRIPTION: Get UART associated with this console.
|
||||
**
|
||||
** RETURNS: Pointer to UART
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
const struct drv_uart *(*GetUART)(void);
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DRV_CONSOLE_H */
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file drv_llcc.h
|
||||
*
|
||||
* \brief LLCC driver.
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
|
||||
#ifndef __DRV_LLCC_H
|
||||
#define __DRV_LLCC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************************************************************************************
|
||||
** INCLUDES
|
||||
***************************************************************************************************/
|
||||
|
||||
#include "chip.h"
|
||||
#include "board.h"
|
||||
|
||||
/***************************************************************************************************
|
||||
** CONSTANTS
|
||||
***************************************************************************************************/
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** ENABLE/DISABLE, ON/OFF DEFINES
|
||||
**
|
||||
** DESCRIPTION: For clarity in enable parameters.
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef DRV_ENABLE
|
||||
#define DRV_ENABLE 1
|
||||
#endif
|
||||
|
||||
#ifndef DRV_DISABLE
|
||||
#define DRV_DISABLE 0
|
||||
#endif
|
||||
|
||||
#ifndef DRV_ON
|
||||
#define DRV_ON 1
|
||||
#endif
|
||||
|
||||
#ifndef DRV_OFF
|
||||
#define DRV_OFF 0
|
||||
#endif
|
||||
|
||||
/***************************************************************************************************
|
||||
** TYPES
|
||||
***************************************************************************************************/
|
||||
|
||||
typedef void (*DRV_LLCC_WD_CALLBACK_t) (uint8_t type, uint8_t *pData, void *pContext, int32_t error);
|
||||
typedef void (*DRV_LLCC_RD_CALLBACK_t) (uint8_t type, uint8_t *pData, uint8_t align, uint16_t len);
|
||||
typedef void * (*DRV_LLCC_ALLOC_CALLBACK_t) (uint16_t len);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** struct drv_llcc
|
||||
**
|
||||
** DESCRIPTION: Access structure of driver.
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
struct drv_llcc {
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** Initialize()
|
||||
**
|
||||
** DESCRIPTION: Initialize ESS IPCC interface
|
||||
** RETURNS: 0 or error (if not 0)
|
||||
---------------------------------------------------------------------------------------------*/
|
||||
int32_t (*Initialize)(void);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** Reset()
|
||||
**
|
||||
** DESCRIPTION: Take the ESS IPCC into or out of reset.
|
||||
** PARAMETERS: on If not 0, take the ESS IPCC out of reset
|
||||
---------------------------------------------------------------------------------------------*/
|
||||
void (*Reset)(int32_t on);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** SetTxHandler()
|
||||
**
|
||||
** DESCRIPTION: Set handler for transmit events
|
||||
** PARAMETERS: cb Pointer to callback; if NULL, the default handler is set
|
||||
---------------------------------------------------------------------------------------------*/
|
||||
void (*SetTxHandler)(DRV_LLCC_WD_CALLBACK_t cb);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** SetRxHandler()
|
||||
**
|
||||
** DESCRIPTION: Set handler for receive events
|
||||
** PARAMETERS: cb Pointer to callback; if NULL, the default handler is set
|
||||
---------------------------------------------------------------------------------------------*/
|
||||
void (*SetRxHandler)(DRV_LLCC_RD_CALLBACK_t cb);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** SetAllocHandler()
|
||||
**
|
||||
** DESCRIPTION: Set handler for allocate requests
|
||||
** PARAMETERS: cb Pointer to callback; if NULL, the default handler is set
|
||||
---------------------------------------------------------------------------------------------*/
|
||||
void (*SetAllocHandler)(DRV_LLCC_ALLOC_CALLBACK_t cb);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** Write()
|
||||
**
|
||||
** DESCRIPTION: Write to write channel
|
||||
** PARAMETERS: cmd Command to send
|
||||
** data Pointer to buffer with data to send
|
||||
** num Number of bytes to write
|
||||
** context Context associated with this write
|
||||
** RETURNS: Number of bytes written or error (if less than 0)
|
||||
---------------------------------------------------------------------------------------------*/
|
||||
int32_t (*Write)(uint32_t cmd, const uint8_t *data, uint16_t num, void *context);
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DRV_LLCC_H */
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file drv_uart.h
|
||||
*
|
||||
* \brief UART driver.
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
|
||||
#ifndef __DRV_UART_H
|
||||
#define __DRV_UART_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************************************************************************************
|
||||
** INCLUDES
|
||||
***************************************************************************************************/
|
||||
|
||||
#include "chip.h"
|
||||
#include "board.h"
|
||||
|
||||
/***************************************************************************************************
|
||||
** DEFINES
|
||||
***************************************************************************************************/
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** ENABLE/DISABLE, ON/OFF DEFINES
|
||||
**
|
||||
** DESCRIPTION: For clarity in enable parameters.
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef DRV_ENABLE
|
||||
#define DRV_ENABLE 1
|
||||
#endif
|
||||
|
||||
#ifndef DRV_DISABLE
|
||||
#define DRV_DISABLE 0
|
||||
#endif
|
||||
|
||||
#ifndef DRV_ON
|
||||
#define DRV_ON 1
|
||||
#endif
|
||||
|
||||
#ifndef DRV_OFF
|
||||
#define DRV_OFF 0
|
||||
#endif
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** TX/RX DEFINES
|
||||
**
|
||||
** DESCRIPTION: For tx/rx argument of driver functions.
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
#define DRV_UART_TX (1u << 0)
|
||||
#define DRV_UART_RX (1u << 1)
|
||||
|
||||
/***************************************************************************************************
|
||||
** TYPES
|
||||
***************************************************************************************************/
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** DRV_UART_RX_CALLBACK_t()
|
||||
**
|
||||
** DESCRIPTION: Callback for received byte.
|
||||
**
|
||||
** PARAMETERS: c Received byte
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
|
||||
typedef void (*DRV_UART_RX_CALLBACK_t)(uint8_t c);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** DRV_UART_TX_COMPLETE_t()
|
||||
**
|
||||
** DESCRIPTION: Callback for transmit interrupt.
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
|
||||
typedef void (*DRV_UART_TX_CALLBACK_t)(void);
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** DRV_UART_BUF_LEN
|
||||
**
|
||||
** DESCRIPTION: The maximum length of printed strings.
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
#define DRV_UART_BUF_LEN 128u
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** struct drv_console
|
||||
**
|
||||
** DESCRIPTION: Access structure of driver.
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
struct drv_uart {
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** Initialize()
|
||||
**
|
||||
** DESCRIPTION: Initialize UART.
|
||||
**
|
||||
** PARAMETERS: baud Baud rate
|
||||
** rx_tx Indicates allowed modes of driver (DRV_UART_RX &/| DRV_UART_TX).
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
void (*Initialize)(uint32_t baud, uint32_t rx_tx);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** Sleep()
|
||||
**
|
||||
** DESCRIPTION: Allow UART settings to be saved before processor enters deep sleep.
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
void (*Sleep)(void);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** Wake()
|
||||
**
|
||||
** DESCRIPTION: Allow UART settings to be restored after processor exits deep sleep.
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
void (*Wake)(void);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** Receive()
|
||||
**
|
||||
** DESCRIPTION: Receive data.
|
||||
**
|
||||
** PARAMETERS: buf Pointer to buffer that will receive data
|
||||
** len Number of data bytes to data
|
||||
**
|
||||
** RETURNS: Number of bytes receuved
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
int32_t (*Receive)(uint8_t *buf, uint32_t len);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** Transmit()
|
||||
**
|
||||
** DESCRIPTION: Transmit data.
|
||||
**
|
||||
** PARAMETERS: buf Pointer to buffer of data to transmit
|
||||
** len Number of data bytes to transmit
|
||||
**
|
||||
** RETURNS: Number of bytes transmitted
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
int32_t (*Transmit)(const uint8_t *buf, uint32_t len);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** SetReceiveHandler()
|
||||
**
|
||||
** DESCRIPTION: Set receive handler.
|
||||
**
|
||||
** PARAMETERS: cb Pointer to callbak
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
void (*SetReceiveHandler)(DRV_UART_RX_CALLBACK_t cb);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** SetTransmitHandler()
|
||||
**
|
||||
** DESCRIPTION: Set transmit handler.
|
||||
**
|
||||
** PARAMETERS: cb Pointer to callbak
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
void (*SetTransmitHandler)(DRV_UART_TX_CALLBACK_t cb);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------
|
||||
** EnableInterrupt()
|
||||
**
|
||||
** DESCRIPTION: Enable or disable an interrupt.
|
||||
**
|
||||
** PARAMETERS: rx_tx Select between receive (DRV_UART_RX) or transmit (DRV_UART_TX) interrupt.
|
||||
** enable Indicates whether interrupt should be enable (not 0) or disabled (0).
|
||||
**--------------------------------------------------------------------------------------------*/
|
||||
void (*EnableInterrupt)(uint32_t rx_tx, int32_t enable);
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DRV_UART_H */
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file hci_core_ps.h
|
||||
*
|
||||
* \brief HCI core platform-specific interfaces for dual-chip.
|
||||
*
|
||||
* $Date: 2015-06-12 07:19:18 -0400 (Fri, 12 Jun 2015) $
|
||||
* $Revision: 3061 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef HCI_CORE_PS_H
|
||||
#define HCI_CORE_PS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
void hciCoreResetSequence(uint8_t *pMsg);
|
||||
void hciCoreNumCmplPkts(uint8_t *pMsg);
|
||||
void hciCoreRecv(uint8_t msgType, uint8_t *pCoreRecvMsg);
|
||||
uint8_t hciCoreVsCmdCmplRcvd(uint16_t opcode, uint8_t *pMsg, uint8_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* HCI_CORE_PS_H */
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file hci_core.h
|
||||
*
|
||||
* \brief HCI core interfaces.
|
||||
*
|
||||
* $Date: 2015-06-12 07:19:18 -0400 (Fri, 12 Jun 2015) $
|
||||
* $Revision: 3061 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef HCI_CORE_H
|
||||
#define HCI_CORE_H
|
||||
|
||||
#include "hci_core_ps.h"
|
||||
#include "wsf_queue.h"
|
||||
#include "wsf_os.h"
|
||||
#include "hci_api.h"
|
||||
#include "cfg_stack.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/* Per-connection structure for ACL packet accounting */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *pTxAclPkt; /* Fragmenting TX ACL packet pointer */
|
||||
uint8_t *pNextTxFrag; /* Next TX ACL packet fragment */
|
||||
uint8_t *pRxAclPkt; /* RX ACL packet pointer */
|
||||
uint8_t *pNextRxFrag; /* Next RX ACL packet fragment */
|
||||
uint16_t handle; /* Connection handle */
|
||||
uint16_t txAclRemLen; /* Fragmenting TX ACL packet remaining length */
|
||||
uint16_t rxAclRemLen; /* Fragmented RX ACL packet remaining length */
|
||||
bool_t fragmenting; /* TRUE if fragmenting a TX ACL packet */
|
||||
bool_t flowDisabled; /* TRUE if data flow disabled */
|
||||
uint8_t queuedBufs; /* Queued ACL buffers on this connection */
|
||||
uint8_t outBufs; /* Outstanding ACL buffers sent to controller */
|
||||
} hciCoreConn_t;
|
||||
|
||||
/* Main control block for dual-chip implementation */
|
||||
typedef struct
|
||||
{
|
||||
hciCoreConn_t conn[DM_CONN_MAX]; /* Connection structures */
|
||||
uint8_t leStates[HCI_LE_STATES_LEN]; /* Controller LE supported states */
|
||||
bdAddr_t bdAddr; /* Bluetooth device address */
|
||||
wsfQueue_t aclQueue; /* HCI ACL TX queue */
|
||||
hciCoreConn_t *pConnRx; /* Connection struct for current transport RX packet */
|
||||
uint16_t maxRxAclLen; /* Maximum reassembled RX ACL packet length */
|
||||
uint16_t bufSize; /* Controller ACL data buffer size */
|
||||
uint8_t aclQueueHi; /* Disable flow when this many ACL buffers queued */
|
||||
uint8_t aclQueueLo; /* Enable flow when this many ACL buffers queued */
|
||||
uint8_t availBufs; /* Current avail ACL data buffers */
|
||||
uint8_t numBufs; /* Controller number of ACL data buffers */
|
||||
uint8_t whiteListSize; /* Controller white list size */
|
||||
uint8_t numCmdPkts; /* Controller command packed count */
|
||||
uint8_t leSupFeat; /* Controller LE supported features */
|
||||
int8_t advTxPwr; /* Controller advertising TX power */
|
||||
} hciCoreCb_t;
|
||||
|
||||
/**************************************************************************************************
|
||||
Global Variables
|
||||
**************************************************************************************************/
|
||||
|
||||
/* Control block */
|
||||
extern hciCoreCb_t hciCoreCb;
|
||||
|
||||
/* LE event mask */
|
||||
extern const uint8_t hciLeEventMask[HCI_LE_EVT_MASK_LEN];
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
void hciCoreInit(void);
|
||||
void hciCoreResetStart(void);
|
||||
void hciCoreConnOpen(uint16_t handle);
|
||||
void hciCoreConnClose(uint16_t handle);
|
||||
hciCoreConn_t *hciCoreConnByHandle(uint16_t handle);
|
||||
void hciCoreSendAclData(hciCoreConn_t *pConn, uint8_t *pData);
|
||||
void hciCoreTxReady(uint8_t bufs);
|
||||
void hciCoreTxAclStart(hciCoreConn_t *pConn, uint16_t len, uint8_t *pData);
|
||||
bool_t hciCoreTxAclContinue(hciCoreConn_t *pConn);
|
||||
void hciCoreTxAclComplete(hciCoreConn_t *pConn, uint8_t *pData);
|
||||
uint8_t *hciCoreAclReassembly(uint8_t *pData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* HCI_CORE_H */
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file hci_drv.h
|
||||
*
|
||||
* \brief HCI driver interface.
|
||||
*
|
||||
* $Date: 2013-01-03 01:19:17 -0500 (Thu, 03 Jan 2013) $
|
||||
* $Revision: 405 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef HCI_DRV_H
|
||||
#define HCI_DRV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn hciDrvWrite
|
||||
*
|
||||
* \brief Write data the driver.
|
||||
*
|
||||
* \param type HCI packet type
|
||||
* \param len Number of bytes to write.
|
||||
* \param pData Byte array to write.
|
||||
*
|
||||
* \return Return actual number of data bytes written.
|
||||
*
|
||||
* \note The type parameter allows the driver layer to prepend the data with a header on the
|
||||
* same write transaction.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint16_t hciDrvWrite(uint8_t type, uint16_t len, uint8_t *pData);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn hciDrvRead
|
||||
*
|
||||
* \brief Read data bytes from the driver.
|
||||
*
|
||||
* \param len Number of bytes to read.
|
||||
* \param pData Byte array to store data.
|
||||
*
|
||||
* \return Return actual number of data bytes read.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint16_t hciDrvRead(uint16_t len, uint8_t *pData);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn hciDrvReadyToSleep
|
||||
*
|
||||
* \brief Returns TRUE if driver allows MCU to enter low power sleep mode.
|
||||
*
|
||||
* \return TRUE if ready to sleep, FALSE otherwise.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
bool_t hciDrvReadyToSleep(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* HCI_DRV_H */
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file hci_tr.h
|
||||
*
|
||||
* \brief HCI transport interface.
|
||||
*
|
||||
* $Date: 2015-06-12 07:19:18 -0400 (Fri, 12 Jun 2015) $
|
||||
* $Revision: 3061 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef HCI_TR_H
|
||||
#define HCI_TR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
void hciTrSendAclData(void *pContext, uint8_t *pAclData);
|
||||
void hciTrSendCmd(uint8_t *pCmdData);
|
||||
bool_t hciTrInit(uint8_t port, uint32_t baudRate, bool_t flowControl);
|
||||
void hciTrShutdown(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* HCI_TR_H */
|
||||
|
|
@ -0,0 +1,362 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file hpal_blep.h
|
||||
*
|
||||
* \brief HPAL BLEP initialization.
|
||||
*
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* \endinternal
|
||||
*
|
||||
* __USAGE NOTE__
|
||||
*
|
||||
* main() will usually start Cordio initialization:
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* int main()
|
||||
* {
|
||||
* wsfHandlerId_t handlerId;
|
||||
*
|
||||
* // ... initialize platform ...
|
||||
*
|
||||
* handlerId = WsfOsSetNextHandler(HpalBlepHandler);
|
||||
* HpalBlepInit(handlerId);
|
||||
*
|
||||
* // ... add other handlers ...
|
||||
*
|
||||
* HpalBlepSetStartupCback(mainBlepStartCallback);
|
||||
* HpalBlepStart(&myBlobCbacks, (void *)&myContext);
|
||||
*
|
||||
* // ... dispatcher loop ...
|
||||
*
|
||||
* }
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* The startup callback will receive a pass/fail indication after startup complees. The application
|
||||
* can then assign callbacks for the HCI interface and "take up" the HCI to begin sending commands
|
||||
* and receiving events.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* static void mainBlepStartCallback(bool_t ok)
|
||||
* {
|
||||
* // ... start BLE stack initialization ...
|
||||
*
|
||||
* HpalHciSetCbacks(&myHciCbacks);
|
||||
* HpalHciTakeUp();
|
||||
*
|
||||
* // ... more BLE stack initialization ...
|
||||
*
|
||||
* // ... start using BLE ...
|
||||
* }
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* __STARTUP PROCESS__
|
||||
*
|
||||
* Setup of the BLEP begins with a @ref STARTUP "VS_Startup event" sent from Cordio.
|
||||
* The Startup_Flags parameter indicates whether the currently-executing firmware (here the
|
||||
* bootloader) requires a firmware update to perform Bluetooth LE operations if bit 0x02 is set.
|
||||
*
|
||||
* If firmware must be updated, the firmware should be retrieved from storage, and a description
|
||||
* provided to Cordio in a @ref FW_LOAD "VS_Firmware_Load command". The Status and Extended_Status
|
||||
* should be checked in the Command_Complete event returned in response. The firmware data should
|
||||
* then be supplied with a series of @ref FW_DATA "VS_Firmware_Data commands". Again, from each
|
||||
* Command_Complete event returned in response, the Status and Extended_Status should be checked.
|
||||
* After the Command_Complete event following the final VS_FW_Data command, Cordio will reset and
|
||||
* the new firmware will begin executing. Another @ref STARTUP "VS_Startup event" will be sent
|
||||
* from Cordio.
|
||||
*
|
||||
* The Startup_Flags parameter from the VS_Startup event will also indicate whether Cordio needs
|
||||
* a trim update to operate if bit 0x01 is set. If trim must be updated, the trim should be
|
||||
* retrieved from storage, and a description provided to Cordio in a @ref TRIM_LOAD "VS_Trim_Load command".
|
||||
* The Status and Extended_Status should be checked in the Command_Complete event returned in
|
||||
* response. The trim data should then be supplied with a series of @ref TRIM_DATA "VS_Trim_Data commands".
|
||||
* Again, from each Command_Complete event returned in response, the Status and Extended_Status
|
||||
* should be checked. Multiple trim blobs may be uploaded sequentially.
|
||||
*
|
||||
* After the firmware update and trim update (if necessary), Cordio should be ready to process
|
||||
* standard Bluetooth LE commands. The Startup_Flags from the last VS_Startup event should
|
||||
* confirm this by setting bit 0x04.
|
||||
*
|
||||
* \dot
|
||||
* digraph G {
|
||||
* node [shape="oval", color="darkorange", width=2, height=0.6, fixedsize=true];
|
||||
* edge [color="darkorange"];
|
||||
*
|
||||
* WAIT_FOR_STARTUP [label="Wait for STARTUP\n from bootloader"];
|
||||
* START_FW_LOAD [label="Start firmware load"];
|
||||
* DO_FW_LOAD [label="Load firmware"];
|
||||
* WAIT_FOR_FW_STARTUP [label="Wait for STARTUP\n from firmware"];
|
||||
* START_TRIM_LOAD [label="Start trim load"];
|
||||
* DO_TRIM_LOAD [label="Load a trim blob"];
|
||||
* DONE_FAILURE [label="Done with error"];
|
||||
* DONE_SUCCESS [label="Done with success"];
|
||||
*
|
||||
* WAIT_FOR_STARTUP -> START_FW_LOAD;
|
||||
*
|
||||
* START_FW_LOAD -> START_TRIM_LOAD [label="doesn't\n need fw"];
|
||||
* START_FW_LOAD -> DO_FW_LOAD;
|
||||
* DO_FW_LOAD -> DO_FW_LOAD [label="more data"];
|
||||
* DO_FW_LOAD -> WAIT_FOR_FW_STARTUP [label="no more\n data"];
|
||||
*
|
||||
* WAIT_FOR_FW_STARTUP -> START_TRIM_LOAD;
|
||||
*
|
||||
* START_TRIM_LOAD -> DONE_SUCCESS [label="doesn't\n need trim"];
|
||||
* START_TRIM_LOAD -> DO_TRIM_LOAD [label="another\n trim blob"];
|
||||
* START_TRIM_LOAD -> DONE_SUCCESS [label="no more\n trim blobs"];
|
||||
* DO_TRIM_LOAD -> DO_TRIM_LOAD [label="more data"];
|
||||
* DO_TRIM_LOAD -> START_TRIM_LOAD [label="no more\n data"];
|
||||
*
|
||||
* WAIT_FOR_STARTUP -> DONE_FAILURE [label="timeout\n or error"];
|
||||
* START_FW_LOAD -> DONE_FAILURE [label="timeout\n or error"];
|
||||
* DO_FW_LOAD -> DONE_FAILURE [label="timeout\n or error"];
|
||||
* WAIT_FOR_FW_STARTUP -> DONE_FAILURE [label="timeout\n or error"];
|
||||
* START_TRIM_LOAD -> DONE_FAILURE [label="timeout\n or error"];
|
||||
* DO_TRIM_LOAD -> DONE_FAILURE [label="timeout\n or error"];
|
||||
* }
|
||||
* \enddot
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
|
||||
#ifndef HPAL_BLEP_H
|
||||
#define HPAL_BLEP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "cordio_bt4_defs.h"
|
||||
|
||||
#include "wsf_types.h"
|
||||
#include "wsf_os.h"
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \brief Header preceding each blob of data.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
typedef CordioTc2ImgHdr_t hpalBlepBlobHeader_t;
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \brief Callback for BLEP startup status.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
typedef void (*hpalBlepStartupCback_t)(bool_t ok);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \brief Storage callbacks invoked during startup to read patch and trim data.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
/***********************************************************************************************/
|
||||
/*!
|
||||
* \brief Setup device for reading from beginning of blob storage.
|
||||
*
|
||||
* \param pContext Context given to HpalBlepStart()
|
||||
*
|
||||
* \return TRUE if successful
|
||||
*/
|
||||
/***********************************************************************************************/
|
||||
bool_t (*StartStorage)(void *pContext);
|
||||
|
||||
/***********************************************************************************************/
|
||||
/*!
|
||||
* \brief Storage device is no longer needed, so it can be powered down.
|
||||
*
|
||||
* \param pContext Context given to HpalBlepStart()
|
||||
*
|
||||
* \return TRUE if successful
|
||||
*/
|
||||
/***********************************************************************************************/
|
||||
bool_t (*EndStorage)(void *pContext);
|
||||
|
||||
/***********************************************************************************************/
|
||||
/*!
|
||||
* \brief Read next blob header from storage device.
|
||||
*
|
||||
* \param pContext Context given to HpalBlepStart()
|
||||
* \param pHdr Pointer to structure that will receive header
|
||||
*
|
||||
* \return TRUE if successful
|
||||
*/
|
||||
/***********************************************************************************************/
|
||||
bool_t (*ReadNextBlobHeader)(void *pContext, hpalBlepBlobHeader_t *pHdr);
|
||||
|
||||
/***********************************************************************************************/
|
||||
/*!
|
||||
* \brief Read more data from current blob at current offset. Reading data advances the
|
||||
* offset.
|
||||
*
|
||||
* \param pContext Context given to HpalBlep_Startup()
|
||||
* \param pData Storage for data
|
||||
* \param length Number of bytes to read
|
||||
*
|
||||
* \return TRUE if successful
|
||||
*/
|
||||
/***********************************************************************************************/
|
||||
bool_t (*ReadMoreBlobData)(void *pContext, uint8_t *pData, uint32_t length);
|
||||
|
||||
/***********************************************************************************************/
|
||||
/*!
|
||||
* \brief Advance the offset of the current blob.
|
||||
*
|
||||
* \param pContext Context given to HpalBlep_Startup()
|
||||
* \param length Number of bytes to skip
|
||||
*
|
||||
* \return TRUE if successful
|
||||
*/
|
||||
/***********************************************************************************************/
|
||||
bool_t (*SkipBlobData)(void *pContext, uint32_t length);
|
||||
} hpalBlepStorageCbacks_t;
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \brief Initialize the BLEP startup.
|
||||
*
|
||||
* \param handlerId Handler ID for HpalBlepHandler().
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void HpalBlepInit(wsfHandlerId_t handlerId);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \brief Begin BLEP startup.
|
||||
*
|
||||
* \param pCbacks Storage callbacks.
|
||||
* \param pCbackContext Storage callback context.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void HpalBlepStart(const hpalBlepStorageCbacks_t *pCbacks, void *pCbackContext);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \brief Set callback that will indicate startup status.
|
||||
*
|
||||
* \param cback Application callback.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void HpalBlepSetStartupCback(hpalBlepStartupCback_t cback);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \brief Handler for BLEP startup messages.
|
||||
*
|
||||
* \param event WSF event mask.
|
||||
* \param pMsg WSF message.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void HpalBlepHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* @mainpage Host Software Architecture
|
||||
*
|
||||
* __OVERVIEW__
|
||||
*
|
||||
* The architecture of a typical host's software can be divided into four basic components: the
|
||||
* application, a host BLE stack, an RTOS or bare-metal event framework, and the CORDIO Host
|
||||
* Peripheral Access Library (HPAL).
|
||||
*
|
||||
* The host BLE stack will provide some API, generally proprietary, for managing connections to
|
||||
* devices (advertising, scanning, connecting, etc.) and organizing attributes into services and
|
||||
* accessing the attribute values.
|
||||
*
|
||||
* The CORDIO HPAL provides to the stack an interface for writing to the standard Bluetooth Host
|
||||
* Controller Interface (HCI) or receiving alerts when new messages have been received, as well as
|
||||
* CORDIO-specific startup routines the application (perhaps through the stack) must call before
|
||||
* HCI transactions begin. The provided HPAL implementation is independent of host MCU, BLE stack,
|
||||
* and any (if any) RTOS. However, the provided startup code does submit and service messages on
|
||||
* the WSF event-driven OS framework.
|
||||
*
|
||||
* \dot
|
||||
* graph G {
|
||||
* node [shape="polygon", sides=4 color="darkorange", width=2.5 fixedsize=true];
|
||||
* edge [color="darkorange"];
|
||||
* splines="ortho";
|
||||
*
|
||||
* subgraph cluster0 {
|
||||
* app -- host;
|
||||
* host -- hpal [label="HCI messages", color="darkorange"];
|
||||
* hpal -- peripheral [label="LLCC Bus", color="darkorange"];
|
||||
* color=white;
|
||||
* ratio=fill;
|
||||
* edge [style="invis"];
|
||||
* }
|
||||
* rtos -- wsf [constraint=false];
|
||||
* app -- wsf [constraint=false];
|
||||
* host -- wsf [constraint=false headport="s", tailport="e"];
|
||||
* hpal -- wsf [constraint=false headport="s", tailport="e"];
|
||||
*
|
||||
* app [label="Application Profiles\n or Services"];
|
||||
* host [label="Host\n BLE Stack"];
|
||||
* hpal [label="CORDIO HPAL"];
|
||||
* peripheral [label="CORDIO Peripheral"];
|
||||
*
|
||||
* rtos [label="RTOS or\n Bare-Metal\n Event Framework", width=1.5 height=1.0];
|
||||
* wsf [label="WSF", width=1.5, height=0.5];
|
||||
* }
|
||||
* \enddot
|
||||
*
|
||||
* __CORDIO HPAL__
|
||||
*
|
||||
* The CORDIO peripheral has two operational modes. It enters _statup mode_ after reset, when
|
||||
* the host software must load firmware and trim patches. If that sequence is successful, the
|
||||
* peripheral will enter _HCI mode_, during which the standard HCI interface expected by the host
|
||||
* BLE stack will be alive.
|
||||
*
|
||||
* The passage from startup to HCI modes is guided by the module _hpal_blep_ and kicked off with
|
||||
* a call of the API function \ref HpalBlepStart(). During this process, a series of
|
||||
* vendor-specific HCI commands and events are exchanged across the LLCC bus. When startup has
|
||||
* completed, the startup callback (set with \ref HpalBlepSetStartupCback()) will return
|
||||
* a status indication; in the event of an error, the LLCC bus will be disabled and the HCI
|
||||
* interface will be locked to prevent inadvertent access.
|
||||
*
|
||||
* After a successful startup, the HCI can be accessed directly with the functions in the module
|
||||
* _hpal_hci_. Management functions can "take up" (\ref HpalHciTakeUp()) or "take down" (\ref
|
||||
* HpalHciTakeDown()) the interface. Writes are performed directly (@\refHpalHci_Write()) and
|
||||
* completed reads or writes indicated through callbacks (\ref HpalHciSetCbacks()). A basic
|
||||
* logging facility will, optionally, dump packet information or contents to a console for
|
||||
* debugging.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* HPAL_BLEP_H */
|
||||
|
|
@ -0,0 +1,238 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file hpal_hci.h
|
||||
*
|
||||
* \brief HPAL HCI abstraction.
|
||||
*
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* \endinternal
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
|
||||
#ifndef HPAL_HCI_H
|
||||
#define HPAL_HCI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "wsf_types.h"
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \struct hpalHciCbacks_t
|
||||
*
|
||||
* \brief Callbacks for allocating buffers and handling read and write completion.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
/*********************************************************************************************/
|
||||
/*!
|
||||
* \brief Allocate a buffer for a received message.
|
||||
*
|
||||
* This function is called from an interrupt context.
|
||||
*
|
||||
* \param len Length of buffer
|
||||
*
|
||||
* \return Pointer to buffer or NULL if buffer could not be allocated
|
||||
*/
|
||||
/*********************************************************************************************/
|
||||
uint8_t *(*BufAlloc) (uint16_t len);
|
||||
|
||||
/*********************************************************************************************/
|
||||
/*!
|
||||
* \brief Free a buffer previously allocated with `BufAlloc()`.
|
||||
*
|
||||
* \param buf Pointer to buffer
|
||||
*/
|
||||
/*********************************************************************************************/
|
||||
void (*BufFree) (uint8_t *buf);
|
||||
|
||||
/*********************************************************************************************/
|
||||
/*!
|
||||
* \brief Handle read completion.
|
||||
*
|
||||
* This function is called from an interrupt context.
|
||||
*
|
||||
* \param type Packet type
|
||||
* \param pData Packet data, which was allocated with `BufAlloc()`. The caller must free
|
||||
* this buffer
|
||||
* \param len Length of packet data, in bytes
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*********************************************************************************************/
|
||||
void (*ReadDone) (uint8_t type, uint8_t *pData, uint16_t len);
|
||||
|
||||
/*********************************************************************************************/
|
||||
/*!
|
||||
* \brief Handle write completion.
|
||||
*
|
||||
* This function is called from an interrupt context.
|
||||
*
|
||||
* \parma type Packet type.
|
||||
* \param pData Pointer to buffer that held written data, which was passed to
|
||||
* `HpalHciWrite()`
|
||||
* \param err Indicates success (0) or error (one of the `HPAL_HCI_ERROR_####` codes)
|
||||
* \param pContext Context pointer passed to `HpalHciWrite()`
|
||||
*
|
||||
* \return None.
|
||||
*
|
||||
* \ref ERROR_CODES "error codes"
|
||||
*/
|
||||
/*********************************************************************************************/
|
||||
void (*WriteDone)(uint8_t type, uint8_t *pData, int32_t err, void *pContext);
|
||||
} hpalHciCbacks_t;
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \name Logging levels
|
||||
* \anchor LOGGING_LEVELS
|
||||
* \brief Level of logging information printed about HCI packets received and transmitted.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
/*! \{ */
|
||||
enum
|
||||
{
|
||||
HPAL_HCI_LOGGING_LEVEL_OFF = 0, /*!< No information will be logged. */
|
||||
HPAL_HCI_LOGGING_LEVEL_INFO = 1, /*!< Basic details about packets will be interpreted. */
|
||||
HPAL_HCI_LOGGING_LEVEL_VERBOSE = 2 /*!< The full byte contents of packets will be logged. */
|
||||
};
|
||||
/*! \} */
|
||||
|
||||
/*! \brief The default log level. */
|
||||
#define HPAL_HCI_LOGGING_LEVEL_DEFAULT HPAL_HCI_LOGGING_LEVEL_OFF
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \name Error codes
|
||||
* \anchor ERROR_CODES
|
||||
* \brief An error code returned in the `WriteDone()` callback.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
/*! \{ */
|
||||
enum
|
||||
{
|
||||
HPAL_HCI_ERROR_OK = 0, /*!< No error; the operation succeeded. */
|
||||
HPAL_HCI_ERROR_BAD_ACK = -1, /*!< The write failed because a bad ACK was received. */
|
||||
HPAL_HCI_ERROR_ABORTED = -2, /*!< The write was aborted. */
|
||||
HPAL_HCI_ERROR_ALLOC = -3, /*!< Allocation failed. */
|
||||
};
|
||||
/*! \} */
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \brief Initialize the HCI and prepare software for reading and writing.
|
||||
*
|
||||
* \return None.
|
||||
*
|
||||
* This function is called by `HpalBlepInit()` and generally should not be called by the
|
||||
* application.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void HpalHciInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \brief Set callbacks for HCI notifications and buffer allocations.
|
||||
*
|
||||
* \param pCbacks Pointer to callbacks. If NULL, the reference to the existing callbacks will be
|
||||
* cleared.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void HpalHciSetCbacks(const hpalHciCbacks_t *pCbacks);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \brief Take up the interface (i.e., start receiving messages and be able to transmit).
|
||||
*
|
||||
* \return None.
|
||||
*
|
||||
* HCI messages will be received and transmissions will be allowed. The HCI callbacks should have
|
||||
* been set before the interface is taken up.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void HpalHciTakeUp(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \brief Take down the interface (i.e., stop receiving messages and block transmissions).
|
||||
*
|
||||
* \return None.
|
||||
*
|
||||
* HCI messages will no longer be received and transmissions (i.e., calls to `HpalHciWrite()`) will
|
||||
* be blocked. The HCI callbacks can only safely be cleared after the interface is taken down.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void HpalHciTakeDown(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \brief Fully disable the interface.
|
||||
*
|
||||
* \return None.
|
||||
*
|
||||
* Disabling the interface may be necessary upon an unexpected event, such as a BLEP-specific
|
||||
* command received after startup is complete.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void HpalHciDisable(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \brief Enable or disable logging for HCI packets.
|
||||
*
|
||||
* \param level logging level
|
||||
*
|
||||
* \return None.
|
||||
*
|
||||
* \see \ref LOGGING_LEVELS "logging levels"
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void HpalHciSetLoggingLevel(uint8_t level);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \brief Write packet to HCI.
|
||||
*
|
||||
* \param type Packet type.
|
||||
* \param pData Packet data.
|
||||
* \param len Packet length, in bytes
|
||||
* \param pContext Context pointer that will be returned in the `WriteDone()` callback
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void HpalHciWrite(uint8_t type, const uint8_t *pData, uint16_t len, void *pContext);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* HPAL_HCI_H */
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file cfg_stack.h
|
||||
*
|
||||
* \brief Stack configuration.
|
||||
*
|
||||
* $Date: 2015-06-12 07:19:18 -0400 (Fri, 12 Jun 2015) $
|
||||
* $Revision: 3061 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef CFG_STACK_H
|
||||
#define CFG_STACK_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
HCI
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Vendor specific targets */
|
||||
#define HCI_VS_GENERIC 0
|
||||
#define HCI_VS_EMM 1
|
||||
|
||||
/*! Vendor specific target configuration */
|
||||
#ifndef HCI_VS_TARGET
|
||||
#define HCI_VS_TARGET HCI_VS_GENERIC
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
DM
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Maximum number of connections */
|
||||
#ifndef DM_CONN_MAX
|
||||
#define DM_CONN_MAX 3
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
L2C
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Maximum number of connection oriented channels */
|
||||
#ifndef L2C_COC_CHAN_MAX
|
||||
#define L2C_COC_CHAN_MAX 8
|
||||
#endif
|
||||
|
||||
/*! Maximum number of connection oriented channel registered clients */
|
||||
#ifndef L2C_COC_REG_MAX
|
||||
#define L2C_COC_REG_MAX 4
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
ATT
|
||||
**************************************************************************************************/
|
||||
|
||||
/**************************************************************************************************
|
||||
SMP
|
||||
**************************************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* CFG_STACK_H */
|
||||
|
|
@ -0,0 +1,945 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file att_api.h
|
||||
*
|
||||
* \brief Attribute protocol client and server API.
|
||||
*
|
||||
* $Date: 2015-06-12 18:20:34 -0400 (Fri, 12 Jun 2015) $
|
||||
* $Revision: 3075 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef ATT_API_H
|
||||
#define ATT_API_H
|
||||
|
||||
#include "wsf_timer.h"
|
||||
#include "att_defs.h"
|
||||
#include "att_uuid.h"
|
||||
#include "dm_api.h"
|
||||
#include "cfg_stack.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! ATT server attribute settings */
|
||||
#define ATTS_SET_UUID_128 0x01 /*! Set if the UUID is 128 bits in length */
|
||||
#define ATTS_SET_WRITE_CBACK 0x02 /*! Set if the group callback is executed when
|
||||
this attribute is written by a client device */
|
||||
#define ATTS_SET_READ_CBACK 0x04 /*! Set if the group callback is executed when
|
||||
this attribute is read by a client device */
|
||||
#define ATTS_SET_VARIABLE_LEN 0x08 /*! Set if the attribute has a variable length */
|
||||
#define ATTS_SET_ALLOW_OFFSET 0x10 /*! Set if writes are allowed with an offset */
|
||||
#define ATTS_SET_CCC 0x20 /*! Set if the attribute is a client characteristic
|
||||
configuration descriptor */
|
||||
#define ATTS_SET_ALLOW_SIGNED 0x40 /*! Set if signed writes are allowed */
|
||||
#define ATTS_SET_REQ_SIGNED 0x80 /*! Set if signed writes are required if link
|
||||
is not encrypted */
|
||||
|
||||
/*! ATT server attribute permissions */
|
||||
#define ATTS_PERMIT_READ 0x01 /*! Set if attribute can be read */
|
||||
#define ATTS_PERMIT_READ_AUTH 0x02 /*! Set if attribute read requires authentication */
|
||||
#define ATTS_PERMIT_READ_AUTHORIZ 0x04 /*! Set if attribute read requires authorization */
|
||||
#define ATTS_PERMIT_READ_ENC 0x08 /*! Set if attribute read requires encryption */
|
||||
#define ATTS_PERMIT_WRITE 0x10 /*! Set if attribute can be written */
|
||||
#define ATTS_PERMIT_WRITE_AUTH 0x20 /*! Set if attribute write requires authentication */
|
||||
#define ATTS_PERMIT_WRITE_AUTHORIZ 0x40 /*! Set if attribute write requires authorization */
|
||||
#define ATTS_PERMIT_WRITE_ENC 0x80 /*! Set if attribute write requires encryption */
|
||||
|
||||
/*! ATT client characteristic discovery and configuration settings */
|
||||
#define ATTC_SET_UUID_128 0x01 /*! Set if the UUID is 128 bits in length */
|
||||
#define ATTC_SET_REQUIRED 0x02 /*! Set if characteristic must be discovered */
|
||||
#define ATTC_SET_DESCRIPTOR 0x04 /*! Set if this is a characteristic descriptor */
|
||||
|
||||
/*! ATT callback events */
|
||||
#define ATT_CBACK_START 0x02 /*! ATT callback event starting value */
|
||||
enum /*! Internal note: event values match method values */
|
||||
{
|
||||
/*! ATT client callback events */
|
||||
ATTC_FIND_INFO_RSP = ATT_CBACK_START, /*! Find information response */
|
||||
ATTC_FIND_BY_TYPE_VALUE_RSP, /*! Find by type value response */
|
||||
ATTC_READ_BY_TYPE_RSP, /*! Read by type value response */
|
||||
ATTC_READ_RSP, /*! Read response */
|
||||
ATTC_READ_LONG_RSP, /*! Read long response */
|
||||
ATTC_READ_MULTIPLE_RSP, /*! Read multiple response */
|
||||
ATTC_READ_BY_GROUP_TYPE_RSP, /*! Read group type response */
|
||||
ATTC_WRITE_RSP, /*! Write response */
|
||||
ATTC_WRITE_CMD_RSP, /*! Write command response */
|
||||
ATTC_PREPARE_WRITE_RSP, /*! Prepare write response */
|
||||
ATTC_EXECUTE_WRITE_RSP, /*! Execute write response */
|
||||
ATTC_HANDLE_VALUE_NTF, /*! Handle value notification */
|
||||
ATTC_HANDLE_VALUE_IND, /*! Handle value indication */
|
||||
/*! ATT server callback events */
|
||||
ATTS_HANDLE_VALUE_CNF, /*! Handle value confirmation */
|
||||
ATTS_CCC_STATE_IND /*! Client chracteristic configuration state change */
|
||||
};
|
||||
|
||||
/*! ATT callback events */
|
||||
#define ATT_CBACK_END ATTS_CCC_STATE_IND /*! ATT callback event ending value */
|
||||
|
||||
/*! Base value for HCI error status values passed through ATT */
|
||||
#define ATT_HCI_ERR_BASE 0x20
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Configurable parameters */
|
||||
typedef struct
|
||||
{
|
||||
wsfTimerTicks_t discIdleTimeout; /*! ATT server service discovery connection idle timeout in seconds */
|
||||
uint16_t mtu; /*! desired ATT MTU */
|
||||
uint8_t transTimeout; /*! transcation timeout in seconds */
|
||||
uint8_t numPrepWrites; /*! number of queued prepare writes supported by server */
|
||||
} attCfg_t;
|
||||
|
||||
/*!
|
||||
* Attribute server data types
|
||||
*/
|
||||
|
||||
/*! Attribute structure */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t const *pUuid; /*! Pointer to the attribute’s UUID */
|
||||
uint8_t *pValue; /*! Pointer to the attribute’s value */
|
||||
uint16_t *pLen; /*! Pointer to the length of the attribute’s value */
|
||||
uint16_t maxLen; /*! Maximum length of attribute’s value */
|
||||
uint8_t settings; /*! Attribute settings */
|
||||
uint8_t permissions; /*! Attribute permissions */
|
||||
} attsAttr_t;
|
||||
|
||||
/*! Attribute group read callback */
|
||||
typedef uint8_t (*attsReadCback_t)(dmConnId_t connId, uint16_t handle, uint8_t operation,
|
||||
uint16_t offset, attsAttr_t *pAttr);
|
||||
|
||||
/*! Attribute group write callback */
|
||||
typedef uint8_t (*attsWriteCback_t)(dmConnId_t connId, uint16_t handle, uint8_t operation,
|
||||
uint16_t offset, uint16_t len, uint8_t *pValue,
|
||||
attsAttr_t *pAttr);
|
||||
|
||||
/*! Attribute group */
|
||||
typedef struct attsGroup_tag
|
||||
{
|
||||
struct attsGroup_tag *pNext; /*! For internal use only */
|
||||
attsAttr_t *pAttr; /*! Pointer to attribute list for this group */
|
||||
attsReadCback_t readCback; /*! Read callback function */
|
||||
attsWriteCback_t writeCback; /*! Write callback function */
|
||||
uint16_t startHandle; /*! The handle of the first attribute in this group */
|
||||
uint16_t endHandle; /*! The handle of the last attribute in this group */
|
||||
} attsGroup_t;
|
||||
|
||||
/*! Client characteristc configuration settings */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /*! Client characteristc configuration descriptor handle */
|
||||
uint16_t valueRange; /*! Acceptable value range of the descriptor value */
|
||||
uint8_t secLevel; /*! Security level of characteristic value */
|
||||
} attsCccSet_t;
|
||||
|
||||
/*! ATT client structure for characteristic and descriptor discovery */
|
||||
typedef struct attcDiscChar_tag
|
||||
{
|
||||
uint8_t const *pUuid; /*! Pointer to UUID */
|
||||
uint8_t settings; /*! Characteristic discovery settings */
|
||||
} attcDiscChar_t;
|
||||
|
||||
/*! ATT client structure for characteristic and descriptor configuration */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t const *pValue; /*! Pointer to default value or NULL */
|
||||
uint8_t valueLen; /*! Default value length */
|
||||
uint8_t hdlIdx; /*! Index of its handle in handle list */
|
||||
} attcDiscCfg_t;
|
||||
|
||||
/*! ATT client discovery control block */
|
||||
typedef struct
|
||||
{
|
||||
attcDiscChar_t **pCharList; /*! Characterisic list for discovery */
|
||||
uint16_t *pHdlList; /*! Characteristic handle list */
|
||||
attcDiscCfg_t *pCfgList; /*! Characterisic list for configuration */
|
||||
uint8_t charListLen; /*! Characteristic and handle list length */
|
||||
uint8_t cfgListLen; /*! Configuration list length */
|
||||
|
||||
/* the following are for internal use only */
|
||||
uint16_t svcStartHdl;
|
||||
uint16_t svcEndHdl;
|
||||
uint8_t charListIdx;
|
||||
uint8_t endHdlIdx;
|
||||
} attcDiscCb_t;
|
||||
|
||||
/*!
|
||||
* ATT callback parameters:
|
||||
*
|
||||
* \param hdr.event Callback event
|
||||
* \param hdr.param DM connection ID
|
||||
* \param hdr.status Event status: ATT_SUCCESS or error status
|
||||
* \param pValue Pointer to value data, valid if valueLen > 0
|
||||
* \param valueLen Length of value data
|
||||
* \param handle Attribute handle
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr; /*! Header structure */
|
||||
uint8_t *pValue; /*! Value */
|
||||
uint16_t valueLen; /*! Value length */
|
||||
uint16_t handle; /*! Attribute handle */
|
||||
bool_t continuing; /*! TRUE if more response packets expected */
|
||||
} attEvt_t;
|
||||
|
||||
/*! ATTS client characteristic configuration callback structure */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr; /*! Header structure */
|
||||
uint16_t handle; /*! CCCD handle */
|
||||
uint16_t value; /*! CCCD value */
|
||||
uint8_t idx; /*! CCCD settings index */
|
||||
} attsCccEvt_t;
|
||||
|
||||
/*! ATT callback type */
|
||||
typedef void (*attCback_t)(attEvt_t *pEvt);
|
||||
|
||||
/*! ATTS authorization callback type */
|
||||
typedef uint8_t (*attsAuthorCback_t)(dmConnId_t connId, uint8_t permit, uint16_t handle);
|
||||
|
||||
/*! ATTS client characteristic configuration callback */
|
||||
typedef void (*attsCccCback_t)(attsCccEvt_t *pEvt);
|
||||
|
||||
/**************************************************************************************************
|
||||
Global Variables
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Configuration pointer */
|
||||
extern attCfg_t *pAttCfg;
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttRegister
|
||||
*
|
||||
* \brief Register a callback with ATT.
|
||||
*
|
||||
* \param cback Client callback function.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttRegister(attCback_t cback);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttConnRegister
|
||||
*
|
||||
* \brief Register a connection callback with ATT. The callback is typically used to
|
||||
* manage the attribute server database.
|
||||
*
|
||||
* \param cback Client callback function.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttConnRegister(dmCback_t cback);
|
||||
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttGetMtu
|
||||
*
|
||||
* \brief Get the attribute protocol MTU of a connection.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
*
|
||||
* \return MTU of the connection.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint16_t AttGetMtu(dmConnId_t connId);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsInit
|
||||
*
|
||||
* \brief Initialize ATT server.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttsInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsIndInit
|
||||
*
|
||||
* \brief Initialize ATT server for indications/notifications.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttsIndInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsSignInit
|
||||
*
|
||||
* \brief Initialize ATT server for data signing.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttsSignInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsAuthorRegister
|
||||
*
|
||||
* \brief Register an authorization callback with the attribute server.
|
||||
*
|
||||
* \param cback Client callback function.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttsAuthorRegister(attsAuthorCback_t cback);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsAddGroup
|
||||
*
|
||||
* \brief Add an attribute group to the attribute server.
|
||||
*
|
||||
* \param pGroup Pointer to an attribute group structure.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttsAddGroup(attsGroup_t *pGroup);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsRemoveGroup
|
||||
*
|
||||
* \brief Remove an attribute group from the attribute server.
|
||||
*
|
||||
* \param startHandle Start handle of attribute group to be removed.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttsRemoveGroup(uint16_t startHandle);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsSetAttr
|
||||
*
|
||||
* \brief Set an attribute value in the attribute server.
|
||||
*
|
||||
* \param handle Attribute handle.
|
||||
* \param valueLen Attribute length.
|
||||
* \param pValue Attribute value.
|
||||
*
|
||||
* \return ATT_SUCCESS if successful otherwise error.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint8_t AttsSetAttr(uint16_t handle, uint16_t valueLen, uint8_t *pValue);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsGetAttr
|
||||
*
|
||||
* \brief Get an attribute value in the attribute server.
|
||||
*
|
||||
* \param handle Attribute handle.
|
||||
* \param pLen Returned attribute length pointer.
|
||||
* \param pValue Returned attribute value pointer.
|
||||
*
|
||||
* \return ATT_SUCCESS if successful otherwise error.
|
||||
* \return This function returns the attribute length in pLen and a pointer to the attribute
|
||||
* value in pValue.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint8_t AttsGetAttr(uint16_t handle, uint16_t *pLen, uint8_t **pValue);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsHandleValueInd
|
||||
*
|
||||
* \brief Send an attribute protocol Handle Value Indication.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param handle Attribute handle.
|
||||
* \param valueLen Length of value data.
|
||||
* \param pValue Pointer to value data.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttsHandleValueInd(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsHandleValueNtf
|
||||
*
|
||||
* \brief Send an attribute protocol Handle Value Notification.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param handle Attribute handle.
|
||||
* \param valueLen Length of value data.
|
||||
* \param pValue Pointer to value data.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttsHandleValueNtf(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsCccRegister
|
||||
*
|
||||
* \brief Register the utility service for managing client characteristic
|
||||
* configuration descriptors. This function is typically called once on
|
||||
* system initialization.
|
||||
*
|
||||
* \param setLen Length of settings array.
|
||||
* \param pSet Array of CCC descriptor settings.
|
||||
* \param cback Client callback function.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttsCccRegister(uint8_t setLen, attsCccSet_t *pSet, attsCccCback_t cback);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsCccInitTable
|
||||
*
|
||||
* \brief Initialize the client characteristic configuration descriptor value table for a
|
||||
* connection. The table is initialized with the values from pCccTbl. If pCccTbl
|
||||
* is NULL the table will be initialized to zero.
|
||||
*
|
||||
* This function must be called when a connection is established or when a
|
||||
* device is bonded.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param pCccTbl Pointer to the descriptor value array. The length of the array
|
||||
* must equal the value of setLen passed to AttsCccRegister().
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttsCccInitTable(dmConnId_t connId, uint16_t *pCccTbl);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsCccClearTable
|
||||
*
|
||||
* \brief Clear and deallocate the client characteristic configuration descriptor value
|
||||
* table for a connection. This function must be called when a connection is closed.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttsCccClearTable(dmConnId_t connId);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsCccGet
|
||||
*
|
||||
* \brief Get the value of a client characteristic configuration descriptor by its index.
|
||||
* If not found, return zero.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param idx Index of descriptor in CCC descriptor handle table.
|
||||
*
|
||||
* \return Value of the descriptor.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint16_t AttsCccGet(dmConnId_t connId, uint8_t idx);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsCccSet
|
||||
*
|
||||
* \brief Set the value of a client characteristic configuration descriptor by its index.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param idx Index of descriptor in CCC descriptor handle table.
|
||||
* \param value Value of the descriptor.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttsCccSet(dmConnId_t connId, uint8_t idx, uint16_t value);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsCccEnabled
|
||||
*
|
||||
* \brief Check if a client characteristic configuration descriptor is enabled and if
|
||||
* the characteristic's security level has been met.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param idx Index of descriptor in CCC descriptor handle table.
|
||||
*
|
||||
* \return Value of the descriptor if security level is met, otherwise zero.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint16_t AttsCccEnabled(dmConnId_t connId, uint8_t idx);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsSetCsrk
|
||||
*
|
||||
* \brief Set the peer's data signing key on this connection. This function
|
||||
* is typically called from the ATT connection callback when the connection is
|
||||
* established. The caller is responsible for maintaining the memory that
|
||||
* contains the key.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param pCsrk Pointer to data signing key (CSRK).
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttsSetCsrk(dmConnId_t connId, uint8_t *pCsrk);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsSetSignCounter
|
||||
*
|
||||
* \brief Set the peer's sign counter on this connection. This function
|
||||
* is typically called from the ATT connection callback when the connection is
|
||||
* established. ATT maintains the value of the sign counter internally and
|
||||
* sets the value when a signed packet is successfully received.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param signCounter Sign counter.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttsSetSignCounter(dmConnId_t connId, uint32_t signCounter);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsGetSignCounter
|
||||
*
|
||||
* \brief Get the current value peer's sign counter on this connection. This function
|
||||
* is typically called from the ATT connection callback when the connection is
|
||||
* closed so the application can store the sign counter for use on future
|
||||
* connections.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
*
|
||||
* \return Sign counter.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint32_t AttsGetSignCounter(dmConnId_t connId);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcInit
|
||||
*
|
||||
* \brief Initialize ATT client.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcSignInit
|
||||
*
|
||||
* \brief Initialize ATT client for data signing.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcSignInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcFindInfoReq
|
||||
*
|
||||
* \brief Initiate an attribute protocol Find Information Request.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param startHandle Attribute start handle.
|
||||
* \param endHandle Attribute end handle.
|
||||
* \param continuing TRUE if ATTC continues sending requests until complete.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcFindInfoReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle, bool_t continuing);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcFindByTypeValueReq
|
||||
*
|
||||
* \brief Initiate an attribute protocol Find By Type Value Request.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param startHandle Attribute start handle.
|
||||
* \param endHandle Attribute end handle.
|
||||
* \param uuid16 16-bit UUID to find.
|
||||
* \param valueLen Length of value data.
|
||||
* \param pValue Pointer to value data.
|
||||
* \param continuing TRUE if ATTC continues sending requests until complete.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcFindByTypeValueReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle,
|
||||
uint16_t uuid16, uint16_t valueLen, uint8_t *pValue, bool_t continuing);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcReadByTypeReq
|
||||
*
|
||||
* \brief Initiate an attribute protocol Read By Type Request.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param startHandle Attribute start handle.
|
||||
* \param endHandle Attribute end handle.
|
||||
* \param uuidLen Length of UUID (2 or 16).
|
||||
* \param pUuid Pointer to UUID data.
|
||||
* \param continuing TRUE if ATTC continues sending requests until complete.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcReadByTypeReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle,
|
||||
uint8_t uuidLen, uint8_t *pUuid, bool_t continuing);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcReadReq
|
||||
*
|
||||
* \brief Initiate an attribute protocol Read Request.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param handle Attribute handle.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcReadReq(dmConnId_t connId, uint16_t handle);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcReadLongReq
|
||||
*
|
||||
* \brief Initiate an attribute protocol Read Long Request.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param handle Attribute handle.
|
||||
* \param offset Read attribute data starting at this offset.
|
||||
* \param continuing TRUE if ATTC continues sending requests until complete.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcReadLongReq(dmConnId_t connId, uint16_t handle, uint16_t offset, bool_t continuing);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcReadMultipleReq
|
||||
*
|
||||
* \brief Initiate an attribute protocol Read Multiple Request.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param numHandles Number of handles in attribute handle list.
|
||||
* \param pHandles List of attribute handles.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcReadMultipleReq(dmConnId_t connId, uint8_t numHandles, uint16_t *pHandles);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcReadByGroupTypeReq
|
||||
*
|
||||
* \brief Initiate an attribute protocol Read By Group Type Request.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param startHandle Attribute start handle.
|
||||
* \param endHandle Attribute end handle.
|
||||
* \param uuidLen Length of UUID (2 or 16).
|
||||
* \param pUuid Pointer to UUID data.
|
||||
* \param continuing TRUE if ATTC continues sending requests until complete.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcReadByGroupTypeReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle,
|
||||
uint8_t uuidLen, uint8_t *pUuid, bool_t continuing);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcWriteReq
|
||||
*
|
||||
* \brief Initiate an attribute protocol Write Request.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param handle Attribute handle.
|
||||
* \param valueLen Length of value data.
|
||||
* \param pValue Pointer to value data.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcWriteReq(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcWriteCmd
|
||||
*
|
||||
* \brief Initiate an attribute protocol Write Command.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param handle Attribute handle.
|
||||
* \param valueLen Length of value data.
|
||||
* \param pValue Pointer to value data.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcWriteCmd(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcSignedWriteCmd
|
||||
*
|
||||
* \brief Initiate an attribute protocol signed Write Command.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param handle Attribute handle.
|
||||
* \param signCounter Value of the sign counter.
|
||||
* \param valueLen Length of value data.
|
||||
* \param pValue Pointer to value data.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcSignedWriteCmd(dmConnId_t connId, uint16_t handle, uint32_t signCounter,
|
||||
uint16_t valueLen, uint8_t *pValue);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcPrepareWriteReq
|
||||
*
|
||||
* \brief Initiate an attribute protocol Prepare Write Request.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param handle Attribute handle.
|
||||
* \param offset Write attribute data starting at this offset.
|
||||
* \param valueLen Length of value data.
|
||||
* \param pValue Pointer to value data.
|
||||
* \param valueByRef TRUE if pValue data is accessed by reference rather than copied.
|
||||
* \param continuing TRUE if ATTC continues sending requests until complete.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcPrepareWriteReq(dmConnId_t connId, uint16_t handle, uint16_t offset, uint16_t valueLen,
|
||||
uint8_t *pValue, bool_t valueByRef, bool_t continuing);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcExecuteWriteReq
|
||||
*
|
||||
* \brief Initiate an attribute protocol Execute Write Request.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param writeAll TRUE to write all queued writes, FALSE to cancel all queued writes.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcExecuteWriteReq(dmConnId_t connId, bool_t writeAll);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcCancelReq
|
||||
*
|
||||
* \brief Cancel an attribute protocol request in progress.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcCancelReq(dmConnId_t connId);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcDiscService
|
||||
*
|
||||
* \brief This utility function discovers the given service on a peer device. Function
|
||||
* AttcFindByTypeValueReq() is called to initiate the discovery procedure.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param pCb Pointer to discovery control block.
|
||||
* \param uuidLen Length of service UUID (2 or 16).
|
||||
* \param pUuid Pointer to service UUID.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcDiscService(dmConnId_t connId, attcDiscCb_t *pCb, uint8_t uuidLen, uint8_t *pUuid);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcDiscServiceCmpl
|
||||
*
|
||||
* \brief This utility function processes a service discovery result. It should be called
|
||||
* when an ATTC_FIND_BY_TYPE_VALUE_RSP callback event is received after service
|
||||
* discovery is initiated by calling AttcDiscService().
|
||||
*
|
||||
* \param pCb Pointer to discovery control block.
|
||||
* \param pMsg ATT callback event message.
|
||||
*
|
||||
* \return ATT_SUCCESS if successful otherwise error.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint8_t AttcDiscServiceCmpl(attcDiscCb_t *pCb, attEvt_t *pMsg);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcDiscCharStart
|
||||
*
|
||||
* \brief This utility function starts characteristic and characteristic descriptor
|
||||
* discovery for a service on a peer device. The service must have been previously
|
||||
* discovered by calling AttcDiscService() and AttcDiscServiceCmpl().
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param pCb Pointer to discovery control block.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcDiscCharStart(dmConnId_t connId, attcDiscCb_t *pCb);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcDiscCharCmpl
|
||||
*
|
||||
* \brief This utility function processes a characteristic discovery result. It should be
|
||||
* called when an ATTC_READ_BY_TYPE_RSP or ATTC_FIND_INFO_RSP callback event is
|
||||
* received after characteristic discovery is initiated by calling AttcDiscCharStart().
|
||||
*
|
||||
* \param pCb Pointer to discovery control block.
|
||||
* \param pMsg ATT callback event message.
|
||||
*
|
||||
* \return ATT_CONTINUING if successful and the discovery procedure is continuing.
|
||||
* ATT_SUCCESS if the discovery procedure completed successfully.
|
||||
* Otherwise the discovery procedure failed.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint8_t AttcDiscCharCmpl(attcDiscCb_t *pCb, attEvt_t *pMsg);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcDiscConfigStart
|
||||
*
|
||||
* \brief This utility function starts characteristic configuration for characteristics on a
|
||||
* peer device. The characteristics must have been previously discovered by calling
|
||||
* AttcDiscCharStart() and AttcDiscCharCmpl().
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param pCb Pointer to discovery control block.
|
||||
*
|
||||
* \return ATT_CONTINUING if successful and configuration procedure is continuing.
|
||||
* ATT_SUCCESS if nothing to configure.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint8_t AttcDiscConfigStart(dmConnId_t connId, attcDiscCb_t *pCb);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcDiscConfigCmpl
|
||||
*
|
||||
* \brief This utility function initiates the next characteristic configuration procedure.
|
||||
* It should be called when an ATTC_READ_RSP or ATTC_WRITE_RSP callback event is received
|
||||
* after characteristic configuration is initiated by calling AttcDiscConfigStart().
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param pCb Pointer to discovery control block.
|
||||
*
|
||||
* \return ATT_CONTINUING if successful and configuration procedure is continuing.
|
||||
* ATT_SUCCESS if configuration procedure completed successfully.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint8_t AttcDiscConfigCmpl(dmConnId_t connId, attcDiscCb_t *pCb);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcDiscConfigResume
|
||||
*
|
||||
* \brief This utility function resumes the characteristic configuration procedure. It can
|
||||
* be called when an ATTC_READ_RSP or ATTC_WRITE_RSP callback event is received
|
||||
* with failure status to attempt the read or write procedure again.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param pCb Pointer to discovery control block.
|
||||
*
|
||||
* \return ATT_CONTINUING if successful and configuration procedure is continuing.
|
||||
* ATT_SUCCESS if configuration procedure completed successfully.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint8_t AttcDiscConfigResume(dmConnId_t connId, attcDiscCb_t *pCb);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttcMtuReq
|
||||
*
|
||||
* \brief For internal use only.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param mtu Attribute protocol MTU.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttcMtuReq(dmConnId_t connId, uint16_t mtu);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttsErrorTest
|
||||
*
|
||||
* \brief For testing purposes only.
|
||||
*
|
||||
* \param status ATT status
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttsErrorTest(uint8_t status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* ATT_API_H */
|
||||
|
|
@ -0,0 +1,225 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file att_defs.h
|
||||
*
|
||||
* \brief Attribute protocol constants and definitions from the Bluetooth specification.
|
||||
*
|
||||
* $Date: 2015-09-10 17:58:31 -0400 (Thu, 10 Sep 2015) $
|
||||
* $Revision: 3838 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef ATT_DEFS_H
|
||||
#define ATT_DEFS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Attribute PDU format */
|
||||
#define ATT_HDR_LEN 1 /*! Attribute PDU header length */
|
||||
#define ATT_AUTH_SIG_LEN 12 /*! Authentication signature length */
|
||||
#define ATT_DEFAULT_MTU 23 /*! Default value of ATT_MTU */
|
||||
#define ATT_MAX_MTU 517 /*! Maximum value of ATT_MTU */
|
||||
#define ATT_DEFAULT_PAYLOAD_LEN 20 /*! Default maximum payload length for most PDUs */
|
||||
|
||||
/*! Attribute value parameters */
|
||||
#define ATT_VALUE_MAX_LEN 512 /*! Maximum attribute value length */
|
||||
#define ATT_VALUE_MAX_OFFSET 511 /*! Maximum attribute value offset */
|
||||
|
||||
/*! Transaction timeout */
|
||||
#define ATT_MAX_TRANS_TIMEOUT 30 /*! Maximum transaction timeout in seconds */
|
||||
|
||||
/*! Error codes */
|
||||
#define ATT_SUCCESS 0x00 /*! Operation successful */
|
||||
#define ATT_ERR_HANDLE 0x01 /*! Invalid handle */
|
||||
#define ATT_ERR_READ 0x02 /*! Read not permitted */
|
||||
#define ATT_ERR_WRITE 0x03 /*! Write not permitted */
|
||||
#define ATT_ERR_INVALID_PDU 0x04 /*! Invalid pdu */
|
||||
#define ATT_ERR_AUTH 0x05 /*! Insufficient authentication */
|
||||
#define ATT_ERR_NOT_SUP 0x06 /*! Request not supported */
|
||||
#define ATT_ERR_OFFSET 0x07 /*! Invalid offset */
|
||||
#define ATT_ERR_AUTHOR 0x08 /*! Insufficient authorization */
|
||||
#define ATT_ERR_QUEUE_FULL 0x09 /*! Prepare queue full */
|
||||
#define ATT_ERR_NOT_FOUND 0x0A /*! Attribute not found */
|
||||
#define ATT_ERR_NOT_LONG 0x0B /*! Attribute not long */
|
||||
#define ATT_ERR_KEY_SIZE 0x0C /*! Insufficient encryption key size */
|
||||
#define ATT_ERR_LENGTH 0x0D /*! Invalid attribute value length */
|
||||
#define ATT_ERR_UNLIKELY 0x0E /*! Other unlikely error */
|
||||
#define ATT_ERR_ENC 0x0F /*! Insufficient encryption */
|
||||
#define ATT_ERR_GROUP_TYPE 0x10 /*! Unsupported group type */
|
||||
#define ATT_ERR_RESOURCES 0x11 /*! Insufficient resources */
|
||||
#define ATT_ERR_CCCD 0xFD /*! CCCD improperly configured */
|
||||
#define ATT_ERR_IN_PROGRESS 0xFE /*! Procedure already in progress */
|
||||
#define ATT_ERR_RANGE 0xFF /*! Value out of range */
|
||||
|
||||
/*! Proprietary internal error codes */
|
||||
#define ATT_ERR_MEMORY 0x70 /*! Out of memory */
|
||||
#define ATT_ERR_TIMEOUT 0x71 /*! Transaction timeout */
|
||||
#define ATT_ERR_OVERFLOW 0x72 /*! Transaction overflow */
|
||||
#define ATT_ERR_INVALID_RSP 0x73 /*! Invalid response PDU */
|
||||
#define ATT_ERR_CANCELLED 0x74 /*! Request cancelled */
|
||||
#define ATT_ERR_UNDEFINED 0x75 /*! Other undefined error */
|
||||
#define ATT_ERR_REQ_NOT_FOUND 0x76 /*! Required characteristic not found */
|
||||
#define ATT_ERR_MTU_EXCEEDED 0x77 /*! Attribute PDU length exceeded MTU size */
|
||||
#define ATT_CONTINUING 0x78 /*! Procedure continuing */
|
||||
|
||||
/*! Application error codes */
|
||||
#define ATT_ERR_VALUE_RANGE 0x80 /*! Value out of range */
|
||||
|
||||
/*! PDU types */
|
||||
#define ATT_PDU_ERR_RSP 0x01 /*! Error response */
|
||||
#define ATT_PDU_MTU_REQ 0x02 /*! Exchange mtu request */
|
||||
#define ATT_PDU_MTU_RSP 0x03 /*! Exchange mtu response */
|
||||
#define ATT_PDU_FIND_INFO_REQ 0x04 /*! Find information request */
|
||||
#define ATT_PDU_FIND_INFO_RSP 0x05 /*! Find information response */
|
||||
#define ATT_PDU_FIND_TYPE_REQ 0x06 /*! Find by type value request */
|
||||
#define ATT_PDU_FIND_TYPE_RSP 0x07 /*! Find by type value response */
|
||||
#define ATT_PDU_READ_TYPE_REQ 0x08 /*! Read by type request */
|
||||
#define ATT_PDU_READ_TYPE_RSP 0x09 /*! Read by type response */
|
||||
#define ATT_PDU_READ_REQ 0x0A /*! Read request */
|
||||
#define ATT_PDU_READ_RSP 0x0B /*! Read response */
|
||||
#define ATT_PDU_READ_BLOB_REQ 0x0C /*! Read blob request */
|
||||
#define ATT_PDU_READ_BLOB_RSP 0x0D /*! Read blob response */
|
||||
#define ATT_PDU_READ_MULT_REQ 0x0E /*! Read multiple request */
|
||||
#define ATT_PDU_READ_MULT_RSP 0x0F /*! Read multiple response */
|
||||
#define ATT_PDU_READ_GROUP_TYPE_REQ 0x10 /*! Read by group type request */
|
||||
#define ATT_PDU_READ_GROUP_TYPE_RSP 0x11 /*! Read by group type response */
|
||||
#define ATT_PDU_WRITE_REQ 0x12 /*! Write request */
|
||||
#define ATT_PDU_WRITE_RSP 0x13 /*! Write response */
|
||||
#define ATT_PDU_WRITE_CMD 0x52 /*! Write command */
|
||||
#define ATT_PDU_SIGNED_WRITE_CMD 0xD2 /*! Signed write command */
|
||||
#define ATT_PDU_PREP_WRITE_REQ 0x16 /*! Prepare write request */
|
||||
#define ATT_PDU_PREP_WRITE_RSP 0x17 /*! Prepare write response */
|
||||
#define ATT_PDU_EXEC_WRITE_REQ 0x18 /*! Execute write request */
|
||||
#define ATT_PDU_EXEC_WRITE_RSP 0x19 /*! Execute write response */
|
||||
#define ATT_PDU_VALUE_NTF 0x1B /*! Handle value notification */
|
||||
#define ATT_PDU_VALUE_IND 0x1D /*! Handle value indication */
|
||||
#define ATT_PDU_VALUE_CNF 0x1E /*! Handle value confirmation */
|
||||
#define ATT_PDU_MAX 0x1F /*! PDU Maximum */
|
||||
|
||||
/*! Length of PDU fixed length fields */
|
||||
#define ATT_ERR_RSP_LEN 5
|
||||
#define ATT_MTU_REQ_LEN 3
|
||||
#define ATT_MTU_RSP_LEN 3
|
||||
#define ATT_FIND_INFO_REQ_LEN 5
|
||||
#define ATT_FIND_INFO_RSP_LEN 2
|
||||
#define ATT_FIND_TYPE_REQ_LEN 7
|
||||
#define ATT_FIND_TYPE_RSP_LEN 1
|
||||
#define ATT_READ_TYPE_REQ_LEN 5
|
||||
#define ATT_READ_TYPE_RSP_LEN 2
|
||||
#define ATT_READ_REQ_LEN 3
|
||||
#define ATT_READ_RSP_LEN 1
|
||||
#define ATT_READ_BLOB_REQ_LEN 5
|
||||
#define ATT_READ_BLOB_RSP_LEN 1
|
||||
#define ATT_READ_MULT_REQ_LEN 1
|
||||
#define ATT_READ_MULT_RSP_LEN 1
|
||||
#define ATT_READ_GROUP_TYPE_REQ_LEN 5
|
||||
#define ATT_READ_GROUP_TYPE_RSP_LEN 2
|
||||
#define ATT_WRITE_REQ_LEN 3
|
||||
#define ATT_WRITE_RSP_LEN 1
|
||||
#define ATT_WRITE_CMD_LEN 3
|
||||
#define ATT_SIGNED_WRITE_CMD_LEN (ATT_WRITE_CMD_LEN + ATT_AUTH_SIG_LEN)
|
||||
#define ATT_PREP_WRITE_REQ_LEN 5
|
||||
#define ATT_PREP_WRITE_RSP_LEN 5
|
||||
#define ATT_EXEC_WRITE_REQ_LEN 2
|
||||
#define ATT_EXEC_WRITE_RSP_LEN 1
|
||||
#define ATT_VALUE_NTF_LEN 3
|
||||
#define ATT_VALUE_IND_LEN 3
|
||||
#define ATT_VALUE_CNF_LEN 1
|
||||
|
||||
/*! Find information response format */
|
||||
#define ATT_FIND_HANDLE_16_UUID 0x01 /*! Handle and 16 bit UUID */
|
||||
#define ATT_FIND_HANDLE_128_UUID 0x02 /*! Handle and 128 bit UUID */
|
||||
|
||||
/*! Execute write request flags */
|
||||
#define ATT_EXEC_WRITE_CANCEL 0x00 /*! Cancel all prepared writes */
|
||||
#define ATT_EXEC_WRITE_ALL 0x01 /*! Write all pending prepared writes */
|
||||
|
||||
/*! PDU masks */
|
||||
#define ATT_PDU_MASK_SERVER 0x01 /*! Server bit mask */
|
||||
#define ATT_PDU_MASK_COMMAND 0x40 /*! Command bit mask */
|
||||
#define ATT_PDU_MASK_SIGNED 0x80 /*! Auth signature bit mask */
|
||||
|
||||
/*! Handles */
|
||||
#define ATT_HANDLE_NONE 0x0000
|
||||
#define ATT_HANDLE_START 0x0001
|
||||
#define ATT_HANDLE_MAX 0xFFFF
|
||||
|
||||
/*! UUID lengths */
|
||||
#define ATT_NO_UUID_LEN 0 /*! Length when no UUID is present ;-) */
|
||||
#define ATT_16_UUID_LEN 2 /*! Length in bytes of a 16 bit UUID */
|
||||
#define ATT_128_UUID_LEN 16 /*! Length in bytes of a 128 bit UUID */
|
||||
|
||||
/*! GATT characteristic properties */
|
||||
#define ATT_PROP_BROADCAST 0x01 /*! Permit broadcasts */
|
||||
#define ATT_PROP_READ 0x02 /*! Permit reads */
|
||||
#define ATT_PROP_WRITE_NO_RSP 0x04 /*! Permit writes without response */
|
||||
#define ATT_PROP_WRITE 0x08 /*! Permit writes with response */
|
||||
#define ATT_PROP_NOTIFY 0x10 /*! Permit notifications */
|
||||
#define ATT_PROP_INDICATE 0x20 /*! Permit indications */
|
||||
#define ATT_PROP_AUTHENTICATED 0x40 /*! Permit signed writes */
|
||||
#define ATT_PROP_EXTENDED 0x80 /*! More properties defined in extended properties */
|
||||
|
||||
/*! GATT characteristic extended properties */
|
||||
#define ATT_EXT_PROP_RELIABLE_WRITE 0x0001 /*! Permit reliable writes */
|
||||
#define ATT_EXT_PROP_WRITEABLE_AUX 0x0002 /*! Permit write to characteristic descriptor */
|
||||
|
||||
/*! GATT client characteristic configuration */
|
||||
#define ATT_CLIENT_CFG_NOTIFY 0x0001 /*! Notify the value */
|
||||
#define ATT_CLIENT_CFG_INDICATE 0x0002 /*! Indicate the value */
|
||||
|
||||
/*! GATT server characteristic configuration */
|
||||
#define ATT_SERVER_CFG_BROADCAST 0x0001 /*! Broadcast the value */
|
||||
|
||||
/*! GATT characteristic format */
|
||||
#define ATT_FORMAT_BOOLEAN 0x01 /*! Boolean */
|
||||
#define ATT_FORMAT_2BIT 0x02 /*! Unsigned 2 bit integer */
|
||||
#define ATT_FORMAT_NIBBLE 0x03 /*! Unsigned 4 bit integer */
|
||||
#define ATT_FORMAT_UINT8 0x04 /*! Unsigned 8 bit integer */
|
||||
#define ATT_FORMAT_UINT12 0x05 /*! Unsigned 12 bit integer */
|
||||
#define ATT_FORMAT_UINT16 0x06 /*! Unsigned 16 bit integer */
|
||||
#define ATT_FORMAT_UINT24 0x07 /*! Unsigned 24 bit integer */
|
||||
#define ATT_FORMAT_UINT32 0x08 /*! Unsigned 32 bit integer */
|
||||
#define ATT_FORMAT_UINT48 0x09 /*! Unsigned 48 bit integer */
|
||||
#define ATT_FORMAT_UINT64 0x0A /*! Unsigned 64 bit integer */
|
||||
#define ATT_FORMAT_UINT128 0x0B /*! Unsigned 128 bit integer */
|
||||
#define ATT_FORMAT_SINT8 0x0C /*! Signed 8 bit integer */
|
||||
#define ATT_FORMAT_SINT12 0x0D /*! Signed 12 bit integer */
|
||||
#define ATT_FORMAT_SINT16 0x0E /*! Signed 16 bit integer */
|
||||
#define ATT_FORMAT_SINT24 0x0F /*! Signed 24 bit integer */
|
||||
#define ATT_FORMAT_SINT32 0x10 /*! Signed 32 bit integer */
|
||||
#define ATT_FORMAT_SINT48 0x11 /*! Signed 48 bit integer */
|
||||
#define ATT_FORMAT_SINT64 0x12 /*! Signed 64 bit integer */
|
||||
#define ATT_FORMAT_SINT128 0x13 /*! Signed 128 bit integer */
|
||||
#define ATT_FORMAT_FLOAT32 0x14 /*! IEEE-754 32 bit floating point */
|
||||
#define ATT_FORMAT_FLOAT64 0x15 /*! IEEE-754 64 bit floating point */
|
||||
#define ATT_FORMAT_SFLOAT 0x16 /*! IEEE-11073 16 bit SFLOAT */
|
||||
#define ATT_FORMAT_FLOAT 0x17 /*! IEEE-11073 32 bit FLOAT */
|
||||
#define ATT_FORMAT_DUINT16 0x18 /*! IEEE-20601 format */
|
||||
#define ATT_FORMAT_UTF8 0x19 /*! UTF-8 string */
|
||||
#define ATT_FORMAT_UTF16 0x1A /*! UTF-16 string */
|
||||
#define ATT_FORMAT_STRUCT 0x1B /*! Opaque structure */
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* ATT_DEFS_H */
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file att_handler.h
|
||||
*
|
||||
* \brief Interface to ATT event handler.
|
||||
*
|
||||
* $Date: 2012-03-29 16:24:04 -0400 (Thu, 29 Mar 2012) $
|
||||
* $Revision: 287 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef ATT_HANDLER_H
|
||||
#define ATT_HANDLER_H
|
||||
|
||||
#include "wsf_os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttHandlerInit
|
||||
*
|
||||
* \brief ATT handler init function called during system initialization.
|
||||
*
|
||||
* \param handlerID WSF handler ID for ATT.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttHandlerInit(wsfHandlerId_t handlerId);
|
||||
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn AttHandler
|
||||
*
|
||||
* \brief WSF event handler for ATT.
|
||||
*
|
||||
* \param event WSF event mask.
|
||||
* \param pMsg WSF message.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void AttHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* ATT_HANDLER_H */
|
||||
|
|
@ -0,0 +1,437 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file att_uuid.h
|
||||
*
|
||||
* \brief Attribute protocol UUIDs from the Bluetooth specification.
|
||||
*
|
||||
* $Date: 2015-09-20 14:19:39 -0400 (Sun, 20 Sep 2015) $
|
||||
* $Revision: 3979 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef ATT_UUID_H
|
||||
#define ATT_UUID_H
|
||||
|
||||
#include "att_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Service UUIDs */
|
||||
#define ATT_UUID_GAP_SERVICE 0x1800 /*! Generic Access Profile Service */
|
||||
#define ATT_UUID_GATT_SERVICE 0x1801 /*! Generic Attribute Profile Service */
|
||||
#define ATT_UUID_IMMEDIATE_ALERT_SERVICE 0x1802 /*! Immediate Alert Service */
|
||||
#define ATT_UUID_LINK_LOSS_SERVICE 0x1803 /*! Link Loss Service */
|
||||
#define ATT_UUID_TX_POWER_SERVICE 0x1804 /*! Tx Power Service */
|
||||
#define ATT_UUID_CURRENT_TIME_SERVICE 0x1805 /*! Current Time Service */
|
||||
#define ATT_UUID_REF_TIME_UPDATE_SERVICE 0x1806 /*! Reference Time Update Service */
|
||||
#define ATT_UUID_DST_CHANGE_SERVICE 0x1807 /*! Next DST Change Service */
|
||||
#define ATT_UUID_GLUCOSE_SERVICE 0x1808 /*! Glucose Service */
|
||||
#define ATT_UUID_HEALTH_THERM_SERVICE 0x1809 /*! Health Thermometer Service */
|
||||
#define ATT_UUID_DEVICE_INFO_SERVICE 0x180A /*! Device Information Service */
|
||||
#define ATT_UUID_NETWORK_AVAIL_SERVICE 0x180B /*! Network Availability Service */
|
||||
#define ATT_UUID_WATCHDOG_SERVICE 0x180C /*! Watchdog Service */
|
||||
#define ATT_UUID_HEART_RATE_SERVICE 0x180D /*! Heart Rate Service */
|
||||
#define ATT_UUID_PHONE_ALERT_SERVICE 0x180E /*! Phone Alert Status Service */
|
||||
#define ATT_UUID_BATTERY_SERVICE 0x180F /*! Battery Service */
|
||||
#define ATT_UUID_BLOOD_PRESSURE_SERVICE 0x1810 /*! Blood Pressure Service */
|
||||
#define ATT_UUID_ALERT_NOTIF_SERVICE 0x1811 /*! Alert Notification Service */
|
||||
#define ATT_UUID_HID_SERVICE 0x1812 /*! Human Interface Device Service */
|
||||
#define ATT_UUID_SCAN_PARAM_SERVICE 0x1813 /*! Scan Parameter Service */
|
||||
|
||||
/*! GATT UUIDs */
|
||||
#define ATT_UUID_PRIMARY_SERVICE 0x2800 /*! Primary Service */
|
||||
#define ATT_UUID_SECONDARY_SERVICE 0x2801 /*! Secondary Service */
|
||||
#define ATT_UUID_INCLUDE 0x2802 /*! Include */
|
||||
#define ATT_UUID_CHARACTERISTIC 0x2803 /*! Characteristic */
|
||||
|
||||
/*! Descriptor UUIDs */
|
||||
#define ATT_UUID_CHARACTERISTIC_EXT 0x2900 /*! Characteristic Extended Properties */
|
||||
#define ATT_UUID_CHAR_USER_DESC 0x2901 /*! Characteristic User Description */
|
||||
#define ATT_UUID_CLIENT_CHAR_CONFIG 0x2902 /*! Client Characteristic Configuration */
|
||||
#define ATT_UUID_SERVER_CHAR_CONFIG 0x2903 /*! Server Characteristic Configuration */
|
||||
#define ATT_UUID_CHAR_PRES_FORMAT 0x2904 /*! Characteristic Presentation Format */
|
||||
#define ATT_UUID_AGGREGATE_FORMAT 0x2905 /*! Characteristic Aggregate Format */
|
||||
#define ATT_UUID_VALID_RANGE 0x2906 /*! Valid Range */
|
||||
#define ATT_UUID_HID_EXT_REPORT_MAPPING 0x2907 /*! HID External Report ID Mapping */
|
||||
#define ATT_UUID_HID_REPORT_ID_MAPPING 0x2908 /*! HID Report ID Mapping */
|
||||
|
||||
/*! Characteristic UUIDs */
|
||||
#define ATT_UUID_DEVICE_NAME 0x2A00 /*! Device Name */
|
||||
#define ATT_UUID_APPEARANCE 0x2A01 /*! Appearance */
|
||||
#define ATT_UUID_PERIPH_PRIVACY_FLAG 0x2A02 /*! Peripheral Privacy Flag */
|
||||
#define ATT_UUID_RECONN_ADDR 0x2A03 /*! Reconnection Address */
|
||||
#define ATT_UUID_PREF_CONN_PARAM 0x2A04 /*! Peripheral Preferred Connection Parameters */
|
||||
#define ATT_UUID_SERVICE_CHANGED 0x2A05 /*! Service Changed */
|
||||
#define ATT_UUID_ALERT_LEVEL 0x2A06 /*! Alert Level */
|
||||
#define ATT_UUID_TX_POWER_LEVEL 0x2A07 /*! Tx Power Level */
|
||||
#define ATT_UUID_DATE_TIME 0x2A08 /*! Date Time */
|
||||
#define ATT_UUID_DAY_OF_WEEK 0x2A09 /*! Day of Week */
|
||||
#define ATT_UUID_DAY_DATE_TIME 0x2A0A /*! Day Date Time */
|
||||
#define ATT_UUID_EXACT_TIME_100 0x2A0B /*! Exact Time 100 */
|
||||
#define ATT_UUID_EXACT_TIME_256 0x2A0C /*! Exact Time 256 */
|
||||
#define ATT_UUID_DST_OFFSET 0x2A0D /*! DST Offset */
|
||||
#define ATT_UUID_TIME_ZONE 0x2A0E /*! Time Zone */
|
||||
#define ATT_UUID_LOCAL_TIME_INFO 0x2A0F /*! Local Time Information */
|
||||
#define ATT_UUID_SECONDARY_TIME_ZONE 0x2A10 /*! Secondary Time Zone */
|
||||
#define ATT_UUID_TIME_WITH_DST 0x2A11 /*! Time with DST */
|
||||
#define ATT_UUID_TIME_ACCURACY 0x2A12 /*! Time Accuracy */
|
||||
#define ATT_UUID_TIME_SOURCE 0x2A13 /*! Time Source */
|
||||
#define ATT_UUID_REFERENCE_TIME_INFO 0x2A14 /*! Reference Time Information */
|
||||
#define ATT_UUID_TIME_BROADCAST 0x2A15 /*! Time Broadcast */
|
||||
#define ATT_UUID_TIME_UPDATE_CP 0x2A16 /*! Time Update Control Point */
|
||||
#define ATT_UUID_TIME_UPDATE_STATE 0x2A17 /*! Time Update State */
|
||||
#define ATT_UUID_GLUCOSE_MEAS 0x2A18 /*! Glucose Measurement */
|
||||
#define ATT_UUID_BATTERY_LEVEL 0x2A19 /*! Battery Level */
|
||||
#define ATT_UUID_BATTERY_POWER_STATE 0x2A1A /*! Battery Power State */
|
||||
#define ATT_UUID_BATTERY_LEVEL_STATE 0x2A1B /*! Battery Level State */
|
||||
#define ATT_UUID_TEMP_MEAS 0x2A1C /*! Temperature Measurement */
|
||||
#define ATT_UUID_TEMP_TYPE 0x2A1D /*! Temperature Type */
|
||||
#define ATT_UUID_INTERMEDIATE_TEMP 0x2A1E /*! Intermediate Temperature */
|
||||
#define ATT_UUID_TEMP_C 0x2A1F /*! Temperature Celsius */
|
||||
#define ATT_UUID_TEMP_F 0x2A20 /*! Temperature Fahrenheit */
|
||||
#define ATT_UUID_MEAS_INTERVAL 0x2A21 /*! Measurement Interval */
|
||||
#define ATT_UUID_HID_BOOT_KEYBOARD_IN 0x2A22 /*! HID Boot Keyboard In */
|
||||
#define ATT_UUID_SYSTEM_ID 0x2A23 /*! System ID */
|
||||
#define ATT_UUID_MODEL_NUMBER 0x2A24 /*! Model Number String */
|
||||
#define ATT_UUID_SERIAL_NUMBER 0x2A25 /*! Serial Number String */
|
||||
#define ATT_UUID_FIRMWARE_REV 0x2A26 /*! Firmware Revision String */
|
||||
#define ATT_UUID_HARDWARE_REV 0x2A27 /*! Hardware Revision String */
|
||||
#define ATT_UUID_SOFTWARE_REV 0x2A28 /*! Software Revision String */
|
||||
#define ATT_UUID_MANUFACTURER_NAME 0x2A29 /*! Manufacturer Name String */
|
||||
#define ATT_UUID_11073_CERT_DATA 0x2A2A /*! IEEE 11073-20601 Regulatory Certification Data List */
|
||||
#define ATT_UUID_CURRENT_TIME 0x2A2B /*! Current Time */
|
||||
#define ATT_UUID_ELEVATION 0x2A2C /*! Elevation */
|
||||
#define ATT_UUID_LATITUDE 0x2A2D /*! Latitude */
|
||||
#define ATT_UUID_LONGITUDE 0x2A2E /*! Longitude */
|
||||
#define ATT_UUID_POSITION_2D 0x2A2F /*! Position 2D */
|
||||
#define ATT_UUID_POSITION_3D 0x2A30 /*! Position 3D */
|
||||
#define ATT_UUID_VENDOR_ID 0x2A31 /*! Vendor ID */
|
||||
#define ATT_UUID_HID_BOOT_KEYBOARD_OUT 0x2A32 /*! HID Boot Keyboard Out */
|
||||
#define ATT_UUID_HID_BOOT_MOUSE_IN 0x2A33 /*! HID Boot Mouse In */
|
||||
#define ATT_UUID_GLUCOSE_MEAS_CONTEXT 0x2A34 /*! Glucose Measurement Context */
|
||||
#define ATT_UUID_BP_MEAS 0x2A35 /*! Blood Pressure Measurement */
|
||||
#define ATT_UUID_INTERMEDIATE_BP 0x2A36 /*! Intermediate Cuff Pressure */
|
||||
#define ATT_UUID_HR_MEAS 0x2A37 /*! Heart Rate Measurement */
|
||||
#define ATT_UUID_HR_SENSOR_LOC 0x2A38 /*! Body Sensor Location */
|
||||
#define ATT_UUID_HR_CP 0x2A39 /*! Heart Rate Control Point */
|
||||
#define ATT_UUID_REMOVABLE 0x2A3A /*! Removable */
|
||||
#define ATT_UUID_SERVICE_REQ 0x2A3B /*! Service Required */
|
||||
#define ATT_UUID_SCI_TEMP_C 0x2A3C /*! Scientific Temperature in Celsius */
|
||||
#define ATT_UUID_STRING 0x2A3D /*! String */
|
||||
#define ATT_UUID_NETWORK_AVAIL 0x2A3E /*! Network Availability */
|
||||
#define ATT_UUID_ALERT_STATUS 0x2A3F /*! Alert Status */
|
||||
#define ATT_UUID_RINGER_CP 0x2A40 /*! Ringer Control Point */
|
||||
#define ATT_UUID_RINGER_SETTING 0x2A41 /*! Ringer Setting */
|
||||
#define ATT_UUID_ALERT_CAT_ID_MASK 0x2A42 /*! Alert Category ID Bit Mask */
|
||||
#define ATT_UUID_ALERT_CAT_ID 0x2A43 /*! Alert Category ID */
|
||||
#define ATT_UUID_ALERT_NOTIF_CP 0x2A44 /*! Alert Notification Control Point */
|
||||
#define ATT_UUID_UNREAD_ALERT_STATUS 0x2A45 /*! Unread Alert Status */
|
||||
#define ATT_UUID_NEW_ALERT 0x2A46 /*! New Alert */
|
||||
#define ATT_UUID_SUP_NEW_ALERT_CAT 0x2A47 /*! Supported New Alert Category */
|
||||
#define ATT_UUID_SUP_UNREAD_ALERT_CAT 0x2A48 /*! Supported Unread Alert Category */
|
||||
#define ATT_UUID_BP_FEATURE 0x2A49 /*! Blood Pressure Feature */
|
||||
#define ATT_UUID_HID_INFORMATION 0x2A4A /*! HID Information */
|
||||
#define ATT_UUID_HID_REPORT_MAP 0x2A4B /*! HID Report Map */
|
||||
#define ATT_UUID_HID_CONTROL_POINT 0x2A4C /*! HID Control Point */
|
||||
#define ATT_UUID_HID_REPORT 0x2A4D /*! HID Report */
|
||||
#define ATT_UUID_HID_PROTOCOL_MODE 0x2A4E /*! HID Protocol Mode */
|
||||
#define ATT_UUID_SCAN_INT_WIND 0x2A4F /*! Scan Interval Window */
|
||||
#define ATT_UUID_PNP_ID 0x2A50 /*! PnP ID */
|
||||
#define ATT_UUID_GLUCOSE_FEATURE 0x2A51 /*! Glucose Feature */
|
||||
#define ATT_UUID_RACP 0x2A52 /*! Record Access Control Point */
|
||||
|
||||
/* remove when adopted */
|
||||
#define ATT_UUID_GENERIC_CTRL_SERVICE 0xF011
|
||||
#define ATT_UUID_COMMAND_ENUM 0xE010 /*! Command Enumeration */
|
||||
#define ATT_UUID_GENERIC_COMMAND_CP 0xE011 /*! Generic Command Control Point */
|
||||
#define ATT_UUID_WEIGHT_SCALE_SERVICE 0x181D /*! Weight Scale Service */
|
||||
#define ATT_UUID_WEIGHT_MEAS 0x2A9D /*! Weight Measurement */
|
||||
#define ATT_UUID_WEIGHT_SCALE_FEATURE 0x2A9E /*! Weight Scale Feature */
|
||||
|
||||
/*! Unit UUIDs */
|
||||
#define ATT_UUID_UNITLESS 0x2700 /*! unitless */
|
||||
#define ATT_UUID_LENGTH_M 0x2701 /*! length metre */
|
||||
#define ATT_UUID_MASS_KG 0x2702 /*! mass kilogram */
|
||||
#define ATT_UUID_TIME_SEC 0x2703 /*! time second */
|
||||
#define ATT_UUID_ELECTRIC_CURRENT_AMP 0x2704 /*! electric current ampere */
|
||||
#define ATT_UUID_THERMO_TEMP_K 0x2705 /*! thermodynamic temperature kelvin */
|
||||
#define ATT_UUID_AMOUNT_OF_SUBSTANCE_MOLE 0x2706 /*! amount of substance mole */
|
||||
#define ATT_UUID_LUMINOUS_INTENSITY_CAND 0x2707 /*! luminous intensity candela */
|
||||
#define ATT_UUID_AREA_SQ_M 0x2710 /*! area square metres */
|
||||
#define ATT_UUID_VOLUME_CU_M 0x2711 /*! volume cubic metres */
|
||||
#define ATT_UUID_VELOCITY_MPS 0x2712 /*! velocity metres per second */
|
||||
#define ATT_UUID_ACCELERATION_MPS_SQ 0x2713 /*! acceleration metres per second squared */
|
||||
#define ATT_UUID_WAVENUMBER_RECIPROCAL_M 0x2714 /*! wavenumber reciprocal metre */
|
||||
#define ATT_UUID_DENSITY_KG_PER_CU_M 0x2715 /*! density kilogram per cubic metre */
|
||||
#define ATT_UUID_SURFACE_DENS_KG_PER_SQ_M 0x2716 /*! surface density kilogram per square metre */
|
||||
#define ATT_UUID_SPECIFIC_VOL_CU_M_PER_KG 0x2717 /*! specific volume cubic metre per kilogram */
|
||||
#define ATT_UUID_CURRENT_DENS_AMP_PER_SQ_M 0x2718 /*! current density ampere per square metre */
|
||||
#define ATT_UUID_MAG_FIELD_STR_AMP_PER_M 0x2719 /*! magnetic field strength ampere per metre */
|
||||
#define ATT_UUID_AMOUNT_CONC_MOLE_PER_CU_M 0x271A /*! amount concentration mole per cubic metre */
|
||||
#define ATT_UUID_MASS_CONC_KG_PER_CU_M 0x271B /*! mass concentration kilogram per cubic metre */
|
||||
#define ATT_UUID_LUM_CAND_PER_SQ_M 0x271C /*! luminance candela per square metre */
|
||||
#define ATT_UUID_REFRACTIVE_INDEX 0x271D /*! refractive index */
|
||||
#define ATT_UUID_RELATIVE_PERMEABILITY 0x271E /*! relative permeability */
|
||||
#define ATT_UUID_PLANE_ANGLE_R 0x2720 /*! plane angle radian */
|
||||
#define ATT_UUID_SOLID_ANGLE_STER 0x2721 /*! solid angle steradian */
|
||||
#define ATT_UUID_FREQUENCY_HERTZ 0x2722 /*! frequency hertz */
|
||||
#define ATT_UUID_FORCE_NEWT 0x2723 /*! force newton */
|
||||
#define ATT_UUID_PRESSURE_PASCAL 0x2724 /*! pressure pascal */
|
||||
#define ATT_UUID_ENERGY_J 0x2725 /*! energy joule */
|
||||
#define ATT_UUID_POWER_W 0x2726 /*! power watt */
|
||||
#define ATT_UUID_ELECTRIC_CHG_C 0x2727 /*! electric charge coulomb */
|
||||
#define ATT_UUID_ELECTRIC_POTENTIAL_VOLT 0x2728 /*! electric potential difference volt */
|
||||
#define ATT_UUID_CAPACITANCE_F 0x2729 /*! capacitance farad */
|
||||
#define ATT_UUID_ELECTRIC_RESISTANCE_OHM 0x272A /*! electric resistance ohm */
|
||||
#define ATT_UUID_ELECTRIC_COND_SIEMENS 0x272B /*! electric conductance siemens */
|
||||
#define ATT_UUID_MAGNETIC_FLEX_WEBER 0x272C /*! magnetic flex weber */
|
||||
#define ATT_UUID_MAGNETIC_FLEX_DENS_TESLA 0x272D /*! magnetic flex density tesla */
|
||||
#define ATT_UUID_INDUCTANCE_H 0x272E /*! inductance henry */
|
||||
#define ATT_UUID_C_TEMP_DEG_C 0x272F /*! Celsius temperature degree Celsius */
|
||||
#define ATT_UUID_LUMINOUS_FLUX_LUMEN 0x2730 /*! luminous flux lumen */
|
||||
#define ATT_UUID_ILLUMINANCE_LUX 0x2731 /*! illuminance lux */
|
||||
#define ATT_UUID_RADIONUCLIDE_BECQUEREL 0x2732 /*! activity referred to a radionuclide becquerel */
|
||||
#define ATT_UUID_ABSORBED_DOSE_GRAY 0x2733 /*! absorbed dose gray */
|
||||
#define ATT_UUID_DOSE_EQUIVALENT_SIEVERT 0x2734 /*! dose equivalent sievert */
|
||||
#define ATT_UUID_CATALYTIC_ACTIVITY_KATAL 0x2735 /*! catalytic activity katal */
|
||||
#define ATT_UUID_DYNAMIC_VISC_PASCAL_SEC 0x2740 /*! dynamic viscosity pascal second */
|
||||
#define ATT_UUID_MOMENT_OF_FORCE_NEWT_M 0x2741 /*! moment of force newton metre */
|
||||
#define ATT_UUID_SURFACE_TENSION_NEWT_PER_M 0x2742 /*! surface tension newton per metre */
|
||||
#define ATT_UUID_ANG_VELOCITY_R_PER_SEC 0x2743 /*! angular velocity radian per second */
|
||||
#define ATT_UUID_ANG_ACCEL_R_PER_SEC_SQD 0x2744 /*! angular acceleration radian per second squared */
|
||||
#define ATT_UUID_HEAT_FLUX_DEN_W_PER_SQ_M 0x2745 /*! heat flux density watt per square metre */
|
||||
#define ATT_UUID_HEAT_CAP_J_PER_K 0x2746 /*! heat capacity joule per kelvin */
|
||||
#define ATT_UUID_SPEC_HEAT_CAP_J_PER_KG_K 0x2747 /*! specific heat capacity joule per kilogram kelvin */
|
||||
#define ATT_UUID_SPEC_ENERGY_J_PER_KG 0x2748 /*! specific energy joule per kilogram */
|
||||
#define ATT_UUID_THERMAL_COND_W_PER_M_K 0x2749 /*! thermal conductivity watt per metre kelvin */
|
||||
#define ATT_UUID_ENERGY_DENSITY_J_PER_CU_M 0x274A /*! energy density joule per cubic metre */
|
||||
#define ATT_UUID_ELEC_FIELD_STR_VOLT_PER_M 0x274B /*! electric field strength volt per metre */
|
||||
#define ATT_UUID_ELEC_CHG_DENS_C_PER_CU_M 0x274C /*! electric charge density coulomb per cubic metre */
|
||||
#define ATT_UUID_SURF_CHG_DENS_C_PER_SQ_M 0x274D /*! surface charge density coulomb per square metre */
|
||||
#define ATT_UUID_ELEC_FLUX_DENS_C_PER_SQ_M 0x274E /*! electric flux density coulomb per square metre */
|
||||
#define ATT_UUID_PERMITTIVITY_F_PER_M 0x274F /*! permittivity farad per metre */
|
||||
#define ATT_UUID_PERMEABILITY_H_PER_M 0x2750 /*! permeability henry per metre */
|
||||
#define ATT_UUID_MOLAR_ENERGY_J_PER_MOLE 0x2751 /*! molar energy joule per mole */
|
||||
#define ATT_UUID_MOLAR_ENTROPY_J_PER_MOLE_K 0x2752 /*! molar entropy joule per mole kelvin */
|
||||
#define ATT_UUID_EXPOSURE_C_PER_KG 0x2753 /*! exposure coulomb per kilogram */
|
||||
#define ATT_UUID_DOSE_RATE_GRAY_PER_SEC 0x2754 /*! absorbed dose rate gray per second */
|
||||
#define ATT_UUID_RT_INTENSITY_W_PER_STER 0x2755 /*! radiant intensity watt per steradian */
|
||||
#define ATT_UUID_RCE_W_PER_SQ_METER_STER 0x2756 /*! radiance watt per square meter steradian */
|
||||
#define ATT_UUID_CATALYTIC_KATAL_PER_CU_M 0x2757 /*! catalytic activity concentration katal per cubic metre */
|
||||
#define ATT_UUID_TIME_MIN 0x2760 /*! time minute */
|
||||
#define ATT_UUID_TIME_HR 0x2761 /*! time hour */
|
||||
#define ATT_UUID_TIME_DAY 0x2762 /*! time day */
|
||||
#define ATT_UUID_PLANE_ANGLE_DEG 0x2763 /*! plane angle degree */
|
||||
#define ATT_UUID_PLANE_ANGLE_MIN 0x2764 /*! plane angle minute */
|
||||
#define ATT_UUID_PLANE_ANGLE_SEC 0x2765 /*! plane angle second */
|
||||
#define ATT_UUID_AREA_HECTARE 0x2766 /*! area hectare */
|
||||
#define ATT_UUID_VOLUME_L 0x2767 /*! volume litre */
|
||||
#define ATT_UUID_MASS_TONNE 0x2768 /*! mass tonne */
|
||||
#define ATT_UUID_PRESSURE_BAR 0x2780 /*! pressure bar */
|
||||
#define ATT_UUID_PRESSURE_MM 0x2781 /*! pressure millimetre of mercury */
|
||||
#define ATT_UUID_LENGTH_ANGSTROM 0x2782 /*! length angstrom */
|
||||
#define ATT_UUID_LENGTH_NAUTICAL_MILE 0x2783 /*! length nautical mile */
|
||||
#define ATT_UUID_AREA_BARN 0x2784 /*! area barn */
|
||||
#define ATT_UUID_VELOCITY_KNOT 0x2785 /*! velocity knot */
|
||||
#define ATT_UUID_LOG_RADIO_QUANT_NEPER 0x2786 /*! logarithmic radio quantity neper */
|
||||
#define ATT_UUID_LOG_RADIO_QUANT_BEL 0x2787 /*! logarithmic radio quantity bel */
|
||||
#define ATT_UUID_LOG_RADIO_QUANT_DB 0x2788 /*! logarithmic radio quantity decibel */
|
||||
#define ATT_UUID_LENGTH_YARD 0x27A0 /*! length yard */
|
||||
#define ATT_UUID_LENGTH_PARSEC 0x27A1 /*! length parsec */
|
||||
#define ATT_UUID_LENGTH_IN 0x27A2 /*! length inch */
|
||||
#define ATT_UUID_LENGTH_FOOT 0x27A3 /*! length foot */
|
||||
#define ATT_UUID_LENGTH_MILE 0x27A4 /*! length mile */
|
||||
#define ATT_UUID_PRESSURE_POUND_PER_SQ_IN 0x27A5 /*! pressure pound-force per square inch */
|
||||
#define ATT_UUID_VELOCITY_KPH 0x27A6 /*! velocity kilometre per hour */
|
||||
#define ATT_UUID_VELOCITY_MPH 0x27A7 /*! velocity mile per hour */
|
||||
#define ATT_UUID_ANG_VELOCITY_RPM 0x27A8 /*! angular velocity revolution per minute */
|
||||
#define ATT_UUID_ENERGY_GRAM_CALORIE 0x27A9 /*! energy gram calorie */
|
||||
#define ATT_UUID_ENERGY_KG_CALORIE 0x27AA /*! energy kilogram calorie */
|
||||
#define ATT_UUID_ENERGY_KILOWATT_HR 0x27AB /*! energy kilowatt hour */
|
||||
#define ATT_UUID_THERM_TEMP_F 0x27AC /*! thermodynamic temperature degree Fahrenheit */
|
||||
#define ATT_UUID_PERCENTAGE 0x27AD /*! percentage */
|
||||
#define ATT_UUID_PER_MILLE 0x27AE /*! per mille */
|
||||
#define ATT_UUID_PERIOD_BEATS_PER_MIN 0x27AF /*! period beats per minute */
|
||||
#define ATT_UUID_ELECTRIC_CHG_AMP_HRS 0x27B0 /*! electric charge ampere hours */
|
||||
#define ATT_UUID_MASS_DENSITY_MG_PER_DL 0x27B1 /*! mass density milligram per decilitre */
|
||||
#define ATT_UUID_MASS_DENSITY_MMOLE_PER_L 0x27B2 /*! mass density millimole per litre */
|
||||
#define ATT_UUID_TIME_YEAR 0x27B3 /*! time year */
|
||||
#define ATT_UUID_TIME_MONTH 0x27B4 /*! time month */
|
||||
|
||||
/*! Wicentric proprietary UUIDs */
|
||||
|
||||
/*! Base UUID: E0262760-08C2-11E1-9073-0E8AC72EXXXX */
|
||||
#define ATT_UUID_WICENTRIC_BASE 0x2E, 0xC7, 0x8A, 0x0E, 0x73, 0x90, \
|
||||
0xE1, 0x11, 0xC2, 0x08, 0x60, 0x27, 0x26, 0xE0
|
||||
|
||||
/*! Macro for building Wicentric UUIDs */
|
||||
#define ATT_UUID_WICENTRIC_BUILD(part) UINT16_TO_BYTES(part), ATT_UUID_WICENTRIC_BASE
|
||||
|
||||
/*! Partial proprietary service UUIDs */
|
||||
#define ATT_UUID_P1_SERVICE_PART 0x1001 /*! Proprietary service P1 */
|
||||
|
||||
/*! Partial proprietary characteristic UUIDs */
|
||||
#define ATT_UUID_D1_DATA_PART 0x0001 /*! Proprietary data D1 */
|
||||
|
||||
/* Proprietary services */
|
||||
#define ATT_UUID_P1_SERVICE ATT_UUID_WICENTRIC_BUILD(ATT_UUID_P1_SERVICE_PART)
|
||||
|
||||
/* Proprietary characteristics */
|
||||
#define ATT_UUID_D1_DATA ATT_UUID_WICENTRIC_BUILD(ATT_UUID_D1_DATA_PART)
|
||||
|
||||
/**************************************************************************************************
|
||||
Global Variables
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Service UUIDs */
|
||||
extern const uint8_t attGapSvcUuid[ATT_16_UUID_LEN]; /*! Generic Access Profile Service */
|
||||
extern const uint8_t attGattSvcUuid[ATT_16_UUID_LEN]; /*! Generic Attribute Profile Service */
|
||||
extern const uint8_t attIasSvcUuid[ATT_16_UUID_LEN]; /*! Immediate Alert Service */
|
||||
extern const uint8_t attLlsSvcUuid[ATT_16_UUID_LEN]; /*! Link Loss Service */
|
||||
extern const uint8_t attTpsSvcUuid[ATT_16_UUID_LEN]; /*! Tx Power Service */
|
||||
extern const uint8_t attCtsSvcUuid[ATT_16_UUID_LEN]; /*! Current Time Service */
|
||||
extern const uint8_t attRtusSvcUuid[ATT_16_UUID_LEN]; /*! Reference Time Update Service */
|
||||
extern const uint8_t attNdcsSvcUuid[ATT_16_UUID_LEN]; /*! Next DST Change Service */
|
||||
extern const uint8_t attGlsSvcUuid[ATT_16_UUID_LEN]; /*! Glucose Service */
|
||||
extern const uint8_t attHtsSvcUuid[ATT_16_UUID_LEN]; /*! Health Thermometer Service */
|
||||
extern const uint8_t attDisSvcUuid[ATT_16_UUID_LEN]; /*! Device Information Service */
|
||||
extern const uint8_t attNwaSvcUuid[ATT_16_UUID_LEN]; /*! Network Availability Service */
|
||||
extern const uint8_t attWdsSvcUuid[ATT_16_UUID_LEN]; /*! Watchdog Service */
|
||||
extern const uint8_t attHrsSvcUuid[ATT_16_UUID_LEN]; /*! Heart Rate Service */
|
||||
extern const uint8_t attPassSvcUuid[ATT_16_UUID_LEN]; /*! Phone Alert Status Service */
|
||||
extern const uint8_t attBasSvcUuid[ATT_16_UUID_LEN]; /*! Battery Service */
|
||||
extern const uint8_t attBpsSvcUuid[ATT_16_UUID_LEN]; /*! Blood Pressure Service */
|
||||
extern const uint8_t attAnsSvcUuid[ATT_16_UUID_LEN]; /*! Alert Notification Service */
|
||||
extern const uint8_t attHidSvcUuid[ATT_16_UUID_LEN]; /*! Human Interface Device Service */
|
||||
extern const uint8_t attSpsSvcUuid[ATT_16_UUID_LEN]; /*! Scan Parameter Service */
|
||||
|
||||
/*! GATT UUIDs */
|
||||
extern const uint8_t attPrimSvcUuid[ATT_16_UUID_LEN]; /*! Primary Service */
|
||||
extern const uint8_t attSecSvcUuid[ATT_16_UUID_LEN]; /*! Secondary Service */
|
||||
extern const uint8_t attIncUuid[ATT_16_UUID_LEN]; /*! Include */
|
||||
extern const uint8_t attChUuid[ATT_16_UUID_LEN]; /*! Characteristic */
|
||||
|
||||
/*! Descriptor UUIDs */
|
||||
extern const uint8_t attChExtUuid[ATT_16_UUID_LEN]; /*! Characteristic Extended Properties */
|
||||
extern const uint8_t attChUserDescUuid[ATT_16_UUID_LEN]; /*! Characteristic User Description */
|
||||
extern const uint8_t attCliChCfgUuid[ATT_16_UUID_LEN]; /*! Client Characteristic Configuration */
|
||||
extern const uint8_t attSrvChCfgUuid[ATT_16_UUID_LEN]; /*! Server Characteristic Configuration */
|
||||
extern const uint8_t attChPresFmtUuid[ATT_16_UUID_LEN]; /*! Characteristic Presentation Format */
|
||||
extern const uint8_t attAggFmtUuid[ATT_16_UUID_LEN]; /*! Characteristic Aggregate Format */
|
||||
extern const uint8_t attHidErmUuid[ATT_16_UUID_LEN]; /*! HID External Report Reference */
|
||||
extern const uint8_t attHidRimUuid[ATT_16_UUID_LEN]; /*! HID Report ID Mapping */
|
||||
extern const uint8_t attValRangeUuid[ATT_16_UUID_LEN]; /*! Valid Range */
|
||||
|
||||
/*! Characteristic UUIDs */
|
||||
extern const uint8_t attDnChUuid[ATT_16_UUID_LEN]; /*! Device Name */
|
||||
extern const uint8_t attApChUuid[ATT_16_UUID_LEN]; /*! Appearance */
|
||||
extern const uint8_t attPpfChUuid[ATT_16_UUID_LEN]; /*! Peripheral Privacy Flag */
|
||||
extern const uint8_t attRaChUuid[ATT_16_UUID_LEN]; /*! Reconnection Address */
|
||||
extern const uint8_t attPpcpChUuid[ATT_16_UUID_LEN]; /*! Peripheral Preferred Connection Parameters */
|
||||
extern const uint8_t attScChUuid[ATT_16_UUID_LEN]; /*! Service Changed */
|
||||
extern const uint8_t attAlChUuid[ATT_16_UUID_LEN]; /*! Alert Level */
|
||||
extern const uint8_t attTxpChUuid[ATT_16_UUID_LEN]; /*! Tx Power Level */
|
||||
extern const uint8_t attDtChUuid[ATT_16_UUID_LEN]; /*! Date Time */
|
||||
extern const uint8_t attDwChUuid[ATT_16_UUID_LEN]; /*! Day of Week */
|
||||
extern const uint8_t attDdtChUuid[ATT_16_UUID_LEN]; /*! Day Date Time */
|
||||
extern const uint8_t attEt100ChUuid[ATT_16_UUID_LEN]; /*! Exact Time 100 */
|
||||
extern const uint8_t attEt256ChUuid[ATT_16_UUID_LEN]; /*! Exact Time 256 */
|
||||
extern const uint8_t attDstoChUuid[ATT_16_UUID_LEN]; /*! DST Offset */
|
||||
extern const uint8_t attTzChUuid[ATT_16_UUID_LEN]; /*! Time Zone */
|
||||
extern const uint8_t attLtiChUuid[ATT_16_UUID_LEN]; /*! Local Time Information */
|
||||
extern const uint8_t attStzChUuid[ATT_16_UUID_LEN]; /*! Secondary Time Zone */
|
||||
extern const uint8_t attTdstChUuid[ATT_16_UUID_LEN]; /*! Time with DST */
|
||||
extern const uint8_t attTaChUuid[ATT_16_UUID_LEN]; /*! Time Accuracy */
|
||||
extern const uint8_t attTsChUuid[ATT_16_UUID_LEN]; /*! Time Source */
|
||||
extern const uint8_t attRtiChUuid[ATT_16_UUID_LEN]; /*! Reference Time Information */
|
||||
extern const uint8_t attTbChUuid[ATT_16_UUID_LEN]; /*! Time Broadcast */
|
||||
extern const uint8_t attTucpChUuid[ATT_16_UUID_LEN]; /*! Time Update Control Point */
|
||||
extern const uint8_t attTusChUuid[ATT_16_UUID_LEN]; /*! Time Update State */
|
||||
extern const uint8_t attGlmChUuid[ATT_16_UUID_LEN]; /*! Glucose Measurement */
|
||||
extern const uint8_t attBlChUuid[ATT_16_UUID_LEN]; /*! Battery Level */
|
||||
extern const uint8_t attBpsChUuid[ATT_16_UUID_LEN]; /*! Battery Power State */
|
||||
extern const uint8_t attBlsChUuid[ATT_16_UUID_LEN]; /*! Battery Level State */
|
||||
extern const uint8_t attTmChUuid[ATT_16_UUID_LEN]; /*! Temperature Measurement */
|
||||
extern const uint8_t attTtChUuid[ATT_16_UUID_LEN]; /*! Temperature Type */
|
||||
extern const uint8_t attItChUuid[ATT_16_UUID_LEN]; /*! Intermediate Temperature */
|
||||
extern const uint8_t attTcelChUuid[ATT_16_UUID_LEN]; /*! Temperature Celsius */
|
||||
extern const uint8_t attTfahChUuid[ATT_16_UUID_LEN]; /*! Temperature Fahrenheit */
|
||||
extern const uint8_t attSidChUuid[ATT_16_UUID_LEN]; /*! System ID */
|
||||
extern const uint8_t attMnsChUuid[ATT_16_UUID_LEN]; /*! Model Number String */
|
||||
extern const uint8_t attSnsChUuid[ATT_16_UUID_LEN]; /*! Serial Number String */
|
||||
extern const uint8_t attFrsChUuid[ATT_16_UUID_LEN]; /*! Firmware Revision String */
|
||||
extern const uint8_t attHrsChUuid[ATT_16_UUID_LEN]; /*! Hardware Revision String */
|
||||
extern const uint8_t attSrsChUuid[ATT_16_UUID_LEN]; /*! Software Revision String */
|
||||
extern const uint8_t attMfnsChUuid[ATT_16_UUID_LEN]; /*! Manufacturer Name String */
|
||||
extern const uint8_t attIeeeChUuid[ATT_16_UUID_LEN]; /*! IEEE 11073-20601 Regulatory Certification Data List */
|
||||
extern const uint8_t attCtChUuid[ATT_16_UUID_LEN]; /*! Current Time */
|
||||
extern const uint8_t attElChUuid[ATT_16_UUID_LEN]; /*! Elevation */
|
||||
extern const uint8_t attLatChUuid[ATT_16_UUID_LEN]; /*! Latitude */
|
||||
extern const uint8_t attLongChUuid[ATT_16_UUID_LEN]; /*! Longitude */
|
||||
extern const uint8_t attP2dChUuid[ATT_16_UUID_LEN]; /*! Position 2D */
|
||||
extern const uint8_t attP3dChUuid[ATT_16_UUID_LEN]; /*! Position 3D */
|
||||
extern const uint8_t attVidChUuid[ATT_16_UUID_LEN]; /*! Vendor ID */
|
||||
extern const uint8_t attGlmcChUuid[ATT_16_UUID_LEN]; /*! Glucose Measurement Context */
|
||||
extern const uint8_t attBpmChUuid[ATT_16_UUID_LEN]; /*! Blood Pressure Measurement */
|
||||
extern const uint8_t attIcpChUuid[ATT_16_UUID_LEN]; /*! Intermediate Cuff Pressure */
|
||||
extern const uint8_t attHrmChUuid[ATT_16_UUID_LEN]; /*! Heart Rate Measurement */
|
||||
extern const uint8_t attBslChUuid[ATT_16_UUID_LEN]; /*! Body Sensor Location */
|
||||
extern const uint8_t attHrcpChUuid[ATT_16_UUID_LEN]; /*! Heart Rate Control Point */
|
||||
extern const uint8_t attRemChUuid[ATT_16_UUID_LEN]; /*! Removable */
|
||||
extern const uint8_t attSrChUuid[ATT_16_UUID_LEN]; /*! Service Required */
|
||||
extern const uint8_t attStcChUuid[ATT_16_UUID_LEN]; /*! Scientific Temperature in Celsius */
|
||||
extern const uint8_t attStrChUuid[ATT_16_UUID_LEN]; /*! String */
|
||||
extern const uint8_t attNwaChUuid[ATT_16_UUID_LEN]; /*! Network Availability */
|
||||
extern const uint8_t attAsChUuid[ATT_16_UUID_LEN]; /*! Alert Status */
|
||||
extern const uint8_t attRcpChUuid[ATT_16_UUID_LEN]; /*! Ringer Control Point */
|
||||
extern const uint8_t attRsChUuid[ATT_16_UUID_LEN]; /*! Ringer Setting */
|
||||
extern const uint8_t attAcbmChUuid[ATT_16_UUID_LEN]; /*! Alert Category ID Bit Mask */
|
||||
extern const uint8_t attAcChUuid[ATT_16_UUID_LEN]; /*! Alert Category ID */
|
||||
extern const uint8_t attAncpChUuid[ATT_16_UUID_LEN]; /*! Alert Notification Control Point */
|
||||
extern const uint8_t attUasChUuid[ATT_16_UUID_LEN]; /*! Unread Alert Status */
|
||||
extern const uint8_t attNaChUuid[ATT_16_UUID_LEN]; /*! New Alert */
|
||||
extern const uint8_t attSnacChUuid[ATT_16_UUID_LEN]; /*! Supported New Alert Category */
|
||||
extern const uint8_t attSuacChUuid[ATT_16_UUID_LEN]; /*! Supported Unread Alert Category */
|
||||
extern const uint8_t attBpfChUuid[ATT_16_UUID_LEN]; /*! Blood Pressure Feature */
|
||||
extern const uint8_t attHidBmiChUuid[ATT_16_UUID_LEN]; /*! HID Information */
|
||||
extern const uint8_t attHidBkiChUuid[ATT_16_UUID_LEN]; /*! HID Information */
|
||||
extern const uint8_t attHidBkoChUuid[ATT_16_UUID_LEN]; /*! HID Information */
|
||||
extern const uint8_t attHidiChUuid[ATT_16_UUID_LEN]; /*! HID Information */
|
||||
extern const uint8_t attHidRmChUuid[ATT_16_UUID_LEN]; /*! Report Map */
|
||||
extern const uint8_t attHidcpChUuid[ATT_16_UUID_LEN]; /*! HID Control Point */
|
||||
extern const uint8_t attHidRepChUuid[ATT_16_UUID_LEN]; /*! Report */
|
||||
extern const uint8_t attHidPmChUuid[ATT_16_UUID_LEN]; /*! Protocol Mode */
|
||||
extern const uint8_t attSiwChUuid[ATT_16_UUID_LEN]; /*! Scan Interval Window */
|
||||
extern const uint8_t attPnpChUuid[ATT_16_UUID_LEN]; /*! PnP ID */
|
||||
extern const uint8_t attGlfChUuid[ATT_16_UUID_LEN]; /*! Glucose Feature */
|
||||
extern const uint8_t attRacpChUuid[ATT_16_UUID_LEN]; /*! Record Access Control Point */
|
||||
|
||||
/* remove when adopted */
|
||||
extern const uint8_t attWssSvcUuid[ATT_16_UUID_LEN]; /*! Weight scale service */
|
||||
extern const uint8_t attWmChUuid[ATT_16_UUID_LEN]; /*! Weight measurement */
|
||||
extern const uint8_t attWsfChUuid[ATT_16_UUID_LEN]; /*! Weight scale feature */
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* ATT_UUID_H */
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,70 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file dm_handler.h
|
||||
*
|
||||
* \brief Interface to DM event handler.
|
||||
*
|
||||
* $Date: 2012-03-29 16:24:04 -0400 (Thu, 29 Mar 2012) $
|
||||
* $Revision: 287 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef DM_HANDLER_H
|
||||
#define DM_HANDLER_H
|
||||
|
||||
#include "wsf_os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn DmHandlerInit
|
||||
*
|
||||
* \brief DM handler init function called during system initialization.
|
||||
*
|
||||
* \param handlerID WSF handler ID for DM.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void DmHandlerInit(wsfHandlerId_t handlerId);
|
||||
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn DmHandler
|
||||
*
|
||||
* \brief WSF event handler for DM.
|
||||
*
|
||||
* \param event WSF event mask.
|
||||
* \param pMsg WSF message.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void DmHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* DM_HANDLER_H */
|
||||
|
|
@ -0,0 +1,383 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file hci_api.h
|
||||
*
|
||||
* \brief HCI subsystem API.
|
||||
*
|
||||
* $Date: 2015-10-20 16:44:24 -0400 (Tue, 20 Oct 2015) $
|
||||
* $Revision: 4255 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef HCI_API_H
|
||||
#define HCI_API_H
|
||||
|
||||
#include "wsf_types.h"
|
||||
#include "hci_defs.h"
|
||||
#include "wsf_os.h"
|
||||
#include "bda.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Internal event values for the HCI event and sec callbacks */
|
||||
#define HCI_RESET_SEQ_CMPL_CBACK_EVT 0 /*! Reset sequence complete */
|
||||
#define HCI_LE_CONN_CMPL_CBACK_EVT 1 /*! LE connection complete */
|
||||
#define HCI_DISCONNECT_CMPL_CBACK_EVT 2 /*! LE disconnect complete */
|
||||
#define HCI_LE_CONN_UPDATE_CMPL_CBACK_EVT 3 /*! LE connection update complete */
|
||||
#define HCI_LE_CREATE_CONN_CANCEL_CMD_CMPL_CBACK_EVT 4 /*! LE create connection cancel command complete */
|
||||
#define HCI_LE_ADV_REPORT_CBACK_EVT 5 /*! LE advertising report */
|
||||
#define HCI_READ_RSSI_CMD_CMPL_CBACK_EVT 6 /*! Read RSSI command complete */
|
||||
#define HCI_LE_READ_CHAN_MAP_CMD_CMPL_CBACK_EVT 7 /*! LE Read channel map command complete */
|
||||
#define HCI_READ_TX_PWR_LVL_CMD_CMPL_CBACK_EVT 8 /*! Read transmit power level command complete */
|
||||
#define HCI_READ_REMOTE_VER_INFO_CMPL_CBACK_EVT 9 /*! Read remote version information complete */
|
||||
#define HCI_LE_READ_REMOTE_FEAT_CMPL_CBACK_EVT 10 /*! LE read remote features complete */
|
||||
#define HCI_LE_LTK_REQ_REPL_CMD_CMPL_CBACK_EVT 11 /*! LE LTK request reply command complete */
|
||||
#define HCI_LE_LTK_REQ_NEG_REPL_CMD_CMPL_CBACK_EVT 12 /*! LE LTK request negative reply command complete */
|
||||
#define HCI_ENC_KEY_REFRESH_CMPL_CBACK_EVT 13 /*! Encryption key refresh complete */
|
||||
#define HCI_ENC_CHANGE_CBACK_EVT 14 /*! Encryption change */
|
||||
#define HCI_LE_LTK_REQ_CBACK_EVT 15 /*! LE LTK request */
|
||||
#define HCI_VENDOR_SPEC_CMD_STATUS_CBACK_EVT 16 /*! Vendor specific command status */
|
||||
#define HCI_VENDOR_SPEC_CMD_CMPL_CBACK_EVT 17 /*! Vendor specific command complete */
|
||||
#define HCI_VENDOR_SPEC_CBACK_EVT 18 /*! Vendor specific */
|
||||
#define HCI_HW_ERROR_CBACK_EVT 19 /*! Hardware error */
|
||||
#define HCI_LE_ENCRYPT_CMD_CMPL_CBACK_EVT 20 /*! LE encrypt command complete */
|
||||
#define HCI_LE_RAND_CMD_CMPL_CBACK_EVT 21 /*! LE rand command complete */
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Connection specification type */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t connIntervalMin;
|
||||
uint16_t connIntervalMax;
|
||||
uint16_t connLatency;
|
||||
uint16_t supTimeout;
|
||||
uint16_t minCeLen;
|
||||
uint16_t maxCeLen;
|
||||
} hciConnSpec_t;
|
||||
|
||||
/*! LE connection complete event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t status;
|
||||
uint16_t handle;
|
||||
uint8_t role;
|
||||
uint8_t addrType;
|
||||
bdAddr_t peerAddr;
|
||||
uint16_t connInterval;
|
||||
uint16_t connLatency;
|
||||
uint16_t supTimeout;
|
||||
uint8_t clockAccuracy;
|
||||
} hciLeConnCmplEvt_t;
|
||||
|
||||
/*! Disconnect complete event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t status;
|
||||
uint16_t handle;
|
||||
uint8_t reason;
|
||||
} hciDisconnectCmplEvt_t;
|
||||
|
||||
/*! LE connection update complete event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t status;
|
||||
uint16_t handle;
|
||||
uint16_t connInterval;
|
||||
uint16_t connLatency;
|
||||
uint16_t supTimeout;
|
||||
} hciLeConnUpdateCmplEvt_t;
|
||||
|
||||
/*! LE create connection cancel command complete event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t status;
|
||||
} hciLeCreateConnCancelCmdCmplEvt_t;
|
||||
|
||||
/*! LE advertising report event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t *pData;
|
||||
uint8_t len;
|
||||
int8_t rssi;
|
||||
uint8_t eventType;
|
||||
uint8_t addrType;
|
||||
bdAddr_t addr;
|
||||
} hciLeAdvReportEvt_t;
|
||||
|
||||
/*! Read RSSI command complete event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t status;
|
||||
uint16_t handle;
|
||||
int8_t rssi;
|
||||
} hciReadRssiCmdCmplEvt_t;
|
||||
|
||||
/*! LE Read channel map command complete event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t status;
|
||||
uint16_t handle;
|
||||
uint8_t chanMap[HCI_CHAN_MAP_LEN];
|
||||
} hciReadChanMapCmdCmplEvt_t;
|
||||
|
||||
/*! Read transmit power level command complete event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t status;
|
||||
uint8_t handle;
|
||||
int8_t pwrLvl;
|
||||
} hciReadTxPwrLvlCmdCmplEvt_t;
|
||||
|
||||
/*! Read remote version information complete event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t status;
|
||||
uint16_t handle;
|
||||
uint8_t version;
|
||||
uint16_t mfrName;
|
||||
uint16_t subversion;
|
||||
} hciReadRemoteVerInfoCmplEvt_t;
|
||||
|
||||
/*! LE read remote features complete event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t status;
|
||||
uint16_t handle;
|
||||
uint8_t features[HCI_FEAT_LEN];
|
||||
} hciLeReadRemoteFeatCmplEvt_t;
|
||||
|
||||
/*! LE LTK request reply command complete event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t status;
|
||||
uint16_t handle;
|
||||
} hciLeLtkReqReplCmdCmplEvt_t;
|
||||
|
||||
/*! LE LTK request negative reply command complete event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t status;
|
||||
uint16_t handle;
|
||||
} hciLeLtkReqNegReplCmdCmplEvt_t;
|
||||
|
||||
/*! Encryption key refresh complete event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t status;
|
||||
uint16_t handle;
|
||||
} hciEncKeyRefreshCmpl_t;
|
||||
|
||||
/*! Encryption change event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t status;
|
||||
uint16_t handle;
|
||||
uint8_t enabled;
|
||||
} hciEncChangeEvt_t;
|
||||
|
||||
/*! LE LTK request event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint16_t handle;
|
||||
uint8_t randNum[HCI_RAND_LEN];
|
||||
uint16_t encDiversifier;
|
||||
} hciLeLtkReqEvt_t;
|
||||
|
||||
/*! Vendor specific command status event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint16_t opcode;
|
||||
} hciVendorSpecCmdStatusEvt_t;
|
||||
|
||||
/*! Vendor specific command complete event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint16_t opcode;
|
||||
uint8_t param[1];
|
||||
} hciVendorSpecCmdCmplEvt_t;
|
||||
|
||||
/*! Vendor specific event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t param[1];
|
||||
} hciVendorSpecEvt_t;
|
||||
|
||||
/*! Hardware error event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t code;
|
||||
} hciHwErrorEvt_t;
|
||||
|
||||
/*! LE encrypt command complete event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t status;
|
||||
uint8_t data[HCI_ENCRYPT_DATA_LEN];
|
||||
} hciLeEncryptCmdCmplEvt_t;
|
||||
|
||||
/*! LE rand command complete event */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t status;
|
||||
uint8_t randNum[HCI_RAND_LEN];
|
||||
} hciLeRandCmdCmplEvt_t;
|
||||
|
||||
|
||||
/*! Union of all event types */
|
||||
typedef union
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
wsfMsgHdr_t resetSeqCmpl;
|
||||
hciLeConnCmplEvt_t leConnCmpl;
|
||||
hciDisconnectCmplEvt_t disconnectCmpl;
|
||||
hciLeConnUpdateCmplEvt_t leConnUpdateCmpl;
|
||||
hciLeCreateConnCancelCmdCmplEvt_t leCreateConnCancelCmdCmpl;
|
||||
hciLeAdvReportEvt_t leAdvReport;
|
||||
hciReadRssiCmdCmplEvt_t readRssiCmdCmpl;
|
||||
hciReadChanMapCmdCmplEvt_t readChanMapCmdCmpl;
|
||||
hciReadTxPwrLvlCmdCmplEvt_t readTxPwrLvlCmdCmpl;
|
||||
hciReadRemoteVerInfoCmplEvt_t readRemoteVerInfoCmpl;
|
||||
hciLeReadRemoteFeatCmplEvt_t leReadRemoteFeatCmpl;
|
||||
hciLeLtkReqReplCmdCmplEvt_t leLtkReqReplCmdCmpl;
|
||||
hciLeLtkReqNegReplCmdCmplEvt_t leLtkReqNegReplCmdCmpl;
|
||||
hciEncKeyRefreshCmpl_t encKeyRefreshCmpl;
|
||||
hciEncChangeEvt_t encChange;
|
||||
hciLeLtkReqEvt_t leLtkReq;
|
||||
hciVendorSpecCmdStatusEvt_t vendorSpecCmdStatus;
|
||||
hciVendorSpecCmdCmplEvt_t vendorSpecCmdCmpl;
|
||||
hciVendorSpecEvt_t vendorSpec;
|
||||
hciHwErrorEvt_t hwError;
|
||||
hciLeEncryptCmdCmplEvt_t leEncryptCmdCmpl;
|
||||
hciLeRandCmdCmplEvt_t leRandCmdCmpl;
|
||||
} hciEvt_t;
|
||||
|
||||
/**************************************************************************************************
|
||||
Callback Function Types
|
||||
**************************************************************************************************/
|
||||
|
||||
typedef void (*hciEvtCback_t)(hciEvt_t *pEvent);
|
||||
typedef void (*hciSecCback_t)(hciEvt_t *pEvent);
|
||||
typedef void (*hciAclCback_t)(uint8_t *pData);
|
||||
typedef void (*hciFlowCback_t)(uint16_t handle, bool_t flowDisabled);
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Initialization, registration, and reset */
|
||||
void HciEvtRegister(hciEvtCback_t evtCback);
|
||||
void HciSecRegister(hciSecCback_t secCback);
|
||||
void HciAclRegister(hciAclCback_t aclCback, hciFlowCback_t flowCback);
|
||||
void HciResetSequence(void);
|
||||
void HciVsInit(uint8_t param);
|
||||
void HciCoreInit(void);
|
||||
void HciCoreHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
|
||||
void HciSetMaxRxAclLen(uint16_t len);
|
||||
void HciSetAclQueueWatermarks(uint8_t queueHi, uint8_t queueLo);
|
||||
|
||||
/*! Optimization interface */
|
||||
uint8_t *HciGetBdAddr(void);
|
||||
uint8_t HciGetWhiteListSize(void);
|
||||
int8_t HciGetAdvTxPwr(void);
|
||||
uint16_t HciGetBufSize(void);
|
||||
uint8_t HciGetNumBufs(void);
|
||||
uint8_t *HciGetSupStates(void);
|
||||
uint8_t HciGetLeSupFeat(void);
|
||||
uint16_t HciGetMaxRxAclLen(void);
|
||||
|
||||
/*! ACL data interface */
|
||||
void HciSendAclData(uint8_t *pAclData);
|
||||
|
||||
/*! Command interface */
|
||||
void HciDisconnectCmd(uint16_t handle, uint8_t reason);
|
||||
void HciLeAddDevWhiteListCmd(uint8_t addrType, uint8_t *pAddr);
|
||||
void HciLeClearWhiteListCmd(void);
|
||||
void HciLeConnUpdateCmd(uint16_t handle, hciConnSpec_t *pConnSpec);
|
||||
void HciLeCreateConnCmd(uint16_t scanInterval, uint16_t scanWindow, uint8_t filterPolicy,
|
||||
uint8_t peerAddrType, uint8_t *pPeerAddr, uint8_t ownAddrType,
|
||||
hciConnSpec_t *pConnSpec);
|
||||
void HciLeCreateConnCancelCmd(void);
|
||||
void HciLeEncryptCmd(uint8_t *pKey, uint8_t *pData);
|
||||
void HciLeLtkReqNegReplCmd(uint16_t handle);
|
||||
void HciLeLtkReqReplCmd(uint16_t handle, uint8_t *pKey);
|
||||
void HciLeRandCmd(void);
|
||||
void HciLeReadAdvTXPowerCmd(void);
|
||||
void HciLeReadBufSizeCmd(void);
|
||||
void HciLeReadChanMapCmd(uint16_t handle);
|
||||
void HciLeReadLocalSupFeatCmd(void);
|
||||
void HciLeReadRemoteFeatCmd(uint16_t handle);
|
||||
void HciLeReadSupStatesCmd(void);
|
||||
void HciLeReadWhiteListSizeCmd(void);
|
||||
void HciLeRemoveDevWhiteListCmd(uint8_t addrType, uint8_t *pAddr);
|
||||
void HciLeSetAdvEnableCmd(uint8_t enable);
|
||||
void HciLeSetAdvDataCmd(uint8_t len, uint8_t *pData);
|
||||
void HciLeSetAdvParamCmd(uint16_t advIntervalMin, uint16_t advIntervalMax, uint8_t advType,
|
||||
uint8_t ownAddrType, uint8_t peerAddrType, uint8_t *pPeerAddr,
|
||||
uint8_t advChanMap, uint8_t advFiltPolicy);
|
||||
void HciLeSetEventMaskCmd(uint8_t *pLeEventMask);
|
||||
void HciLeSetHostChanClassCmd(uint8_t *pChanMap);
|
||||
void HciLeSetRandAddrCmd(uint8_t *pAddr);
|
||||
void HciLeSetScanEnableCmd(uint8_t enable, uint8_t filterDup);
|
||||
void HciLeSetScanParamCmd(uint8_t scanType, uint16_t scanInterval, uint16_t scanWindow,
|
||||
uint8_t ownAddrType, uint8_t scanFiltPolicy);
|
||||
void HciLeSetScanRespDataCmd(uint8_t len, uint8_t *pData);
|
||||
void HciLeStartEncryptionCmd(uint16_t handle, uint8_t *pRand, uint16_t diversifier, uint8_t *pKey);
|
||||
void HciReadBdAddrCmd(void);
|
||||
void HciReadBufSizeCmd(void);
|
||||
void HciReadLocalSupFeatCmd(void);
|
||||
void HciReadLocalVerInfoCmd(void);
|
||||
void HciReadRemoteVerInfoCmd(uint16_t handle);
|
||||
void HciReadRssiCmd(uint16_t handle);
|
||||
void HciReadTxPwrLvlCmd(uint16_t handle, uint8_t type);
|
||||
void HciResetCmd(void);
|
||||
void HciSetEventMaskCmd(uint8_t *pEventMask);
|
||||
void HciVendorSpecificCmd(uint16_t opcode, uint8_t len, uint8_t *pData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* HCI_API_H */
|
||||
|
|
@ -0,0 +1,467 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file hci_defs.h
|
||||
*
|
||||
* \brief HCI constants and definitions from the Bluetooth specification.
|
||||
*
|
||||
* $Date: 2015-06-12 07:19:18 -0400 (Fri, 12 Jun 2015) $
|
||||
* $Revision: 3061 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef HCI_DEFS_H
|
||||
#define HCI_DEFS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*! Packet definitions */
|
||||
#define HCI_CMD_HDR_LEN 3 /*! Command packet header length */
|
||||
#define HCI_ACL_HDR_LEN 4 /*! ACL packet header length */
|
||||
#define HCI_EVT_HDR_LEN 2 /*! Event packet header length */
|
||||
#define HCI_EVT_PARAM_MAX_LEN 255 /*! Maximum length of event packet parameters */
|
||||
#define HCI_ACL_DEFAULT_LEN 27 /*! Default maximum ACL packet length */
|
||||
#define HCI_PB_FLAG_MASK 0x3000 /*! ACL packet boundary flag mask */
|
||||
#define HCI_PB_START_H2C 0x0000 /*! Packet boundary flag, start, host-to-controller */
|
||||
#define HCI_PB_CONTINUE 0x1000 /*! Packet boundary flag, continue */
|
||||
#define HCI_PB_START_C2H 0x2000 /*! Packet boundary flag, start, controller-to-host */
|
||||
#define HCI_HANDLE_MASK 0x0FFF /*! Mask for handle bits in ACL packet */
|
||||
#define HCI_HANDLE_NONE 0xFFFF /*! Value for invalid handle */
|
||||
|
||||
/*! Packet types */
|
||||
#define HCI_CMD_TYPE 1 /*! HCI command packet */
|
||||
#define HCI_ACL_TYPE 2 /*! HCI ACL data packet */
|
||||
#define HCI_EVT_TYPE 4 /*! HCI event packet */
|
||||
|
||||
/*! Error codes */
|
||||
#define HCI_SUCCESS 0x00 /*! Success */
|
||||
#define HCI_ERR_UNKNOWN_CMD 0x01 /*! Unknown HCI command */
|
||||
#define HCI_ERR_UNKNOWN_HANDLE 0x02 /*! Unknown connection identifier */
|
||||
#define HCI_ERR_HARDWARE_FAILURE 0x03 /*! Hardware failure */
|
||||
#define HCI_ERR_PAGE_TIMEOUT 0x04 /*! Page timeout */
|
||||
#define HCI_ERR_AUTH_FAILURE 0x05 /*! Authentication failure */
|
||||
#define HCI_ERR_KEY_MISSING 0x06 /*! PIN or key missing */
|
||||
#define HCI_ERR_MEMORY_EXCEEDED 0x07 /*! Memory capacity exceeded */
|
||||
#define HCI_ERR_CONN_TIMEOUT 0x08 /*! Connection timeout */
|
||||
#define HCI_ERR_CONN_LIMIT 0x09 /*! Connection limit exceeded */
|
||||
#define HCI_ERR_SYNCH_CONN_LIMIT 0x0A /*! Synchronous connection limit exceeded */
|
||||
#define HCI_ERR_ACL_CONN_EXISTS 0x0B /*! ACL connection already exists */
|
||||
#define HCI_ERR_CMD_DISALLOWED 0x0C /*! Command disallowed */
|
||||
#define HCI_ERR_REJ_RESOURCES 0x0D /*! Connection rejected limited resources */
|
||||
#define HCI_ERR_REJ_SECURITY 0x0E /*! Connection rejected security reasons */
|
||||
#define HCI_ERR_REJ_BD_ADDR 0x0F /*! Connection rejected unacceptable BD_ADDR */
|
||||
#define HCI_ERR_ACCEPT_TIMEOUT 0x10 /*! Connection accept timeout exceeded */
|
||||
#define HCI_ERR_UNSUP_FEAT 0x11 /*! Unsupported feature or parameter value */
|
||||
#define HCI_ERR_INVALID_PARAM 0x12 /*! Invalid HCI command parameters */
|
||||
#define HCI_ERR_REMOTE_TERMINATED 0x13 /*! Remote user terminated connection */
|
||||
#define HCI_ERR_REMOTE_RESOURCES 0x14 /*! Remote device low resources */
|
||||
#define HCI_ERR_REMOTE_POWER_OFF 0x15 /*! Remote device power off */
|
||||
#define HCI_ERR_LOCAL_TERMINATED 0x16 /*! Connection terminated by local host */
|
||||
#define HCI_ERR_REPEATED_ATTEMPTS 0x17 /*! Repeated attempts */
|
||||
#define HCI_ERR_PAIRING_NOT_ALLOWED 0x18 /*! Pairing not allowed */
|
||||
#define HCI_ERR_UNKNOWN_LMP_PDU 0x19 /*! Unknown LMP PDU */
|
||||
#define HCI_ERR_UNSUP_REMOTE_FEAT 0x1A /*! Unsupported remote feature */
|
||||
#define HCI_ERR_SCO_OFFSET 0x1B /*! SCO offset rejected */
|
||||
#define HCI_ERR_SCO_INTERVAL 0x1C /*! SCO interval rejected */
|
||||
#define HCI_ERR_SCO_MODE 0x1D /*! SCO air mode rejected */
|
||||
#define HCI_ERR_LMP_PARAM 0x1E /*! Invalid LMP parameters */
|
||||
#define HCI_ERR_UNSPECIFIED 0x1F /*! Unspecified error */
|
||||
#define HCI_ERR_UNSUP_LMP_PARAM 0x20 /*! Unsupported LMP parameter value */
|
||||
#define HCI_ERR_ROLE_CHANGE 0x21 /*! Role change not allowed */
|
||||
#define HCI_ERR_LL_RESP_TIMEOUT 0x22 /*! LL response timeout */
|
||||
#define HCI_ERR_LMP_COLLISION 0x23 /*! LMP error transaction collision */
|
||||
#define HCI_ERR_LMP_PDU 0x24 /*! LMP pdu not allowed */
|
||||
#define HCI_ERR_ENCRYPT_MODE 0x25 /*! Encryption mode not acceptable */
|
||||
#define HCI_ERR_LINK_KEY 0x26 /*! Link key can not be changed */
|
||||
#define HCI_ERR_UNSUP_QOS 0x27 /*! Requested qos not supported */
|
||||
#define HCI_ERR_INSTANT_PASSED 0x28 /*! Instant passed */
|
||||
#define HCI_ERR_UNSUP_UNIT_KEY 0x29 /*! Pairing with unit key not supported */
|
||||
#define HCI_ERR_TRANSACT_COLLISION 0x2A /*! Different transaction collision */
|
||||
#define HCI_ERR_CHANNEL_CLASS 0x2E /*! Channel classification not supported */
|
||||
#define HCI_ERR_MEMORY 0x2F /*! Insufficient security */
|
||||
#define HCI_ERR_PARAMETER_RANGE 0x30 /*! Parameter out of mandatory range */
|
||||
#define HCI_ERR_ROLE_SWITCH_PEND 0x32 /*! Role switch pending */
|
||||
#define HCI_ERR_RESERVED_SLOT 0x34 /*! Reserved slot violation */
|
||||
#define HCI_ERR_ROLE_SWITCH 0x35 /*! Role switch failed */
|
||||
#define HCI_ERR_INQ_TOO_LARGE 0x36 /*! Extended inquiry response too large */
|
||||
#define HCI_ERR_UNSUP_SSP 0x37 /*! Secure simple pairing not supported by host */
|
||||
#define HCI_ERR_HOST_BUSY_PAIRING 0x38 /*! Host busy - pairing */
|
||||
#define HCI_ERR_NO_CHANNEL 0x39 /*! Connection rejected no suitable channel */
|
||||
#define HCI_ERR_CONTROLLER_BUSY 0x3A /*! Controller busy */
|
||||
#define HCI_ERR_CONN_INTERVAL 0x3B /*! Unacceptable connection interval */
|
||||
#define HCI_ERR_ADV_TIMEOUT 0x3C /*! Directed advertising timeout */
|
||||
#define HCI_ERR_MIC_FAILURE 0x3D /*! Connection terminated due to MIC failure */
|
||||
#define HCI_ERR_CONN_FAIL 0x3E /*! Connection failed to be established */
|
||||
#define HCI_ERR_MAC_CONN_FAIL 0x3F /*! MAC connection failed */
|
||||
|
||||
/*! Command groups */
|
||||
#define HCI_OGF_NOP 0x00 /*! No operation */
|
||||
#define HCI_OGF_LINK_CONTROL 0x01 /*! Link control */
|
||||
#define HCI_OGF_LINK_POLICY 0x02 /*! Link policy */
|
||||
#define HCI_OGF_CONTROLLER 0x03 /*! Controller and baseband */
|
||||
#define HCI_OGF_INFORMATIONAL 0x04 /*! Informational parameters */
|
||||
#define HCI_OGF_STATUS 0x05 /*! Status parameters */
|
||||
#define HCI_OGF_TESTING 0x06 /*! Testing */
|
||||
#define HCI_OGF_LE_CONTROLLER 0x08 /*! LE controller */
|
||||
#define HCI_OGF_VENDOR_SPEC 0x3F /*! Vendor specific */
|
||||
|
||||
/*! NOP command */
|
||||
#define HCI_OCF_NOP 0x00
|
||||
|
||||
/*! Link control commands */
|
||||
#define HCI_OCF_DISCONNECT 0x06
|
||||
#define HCI_OCF_READ_REMOTE_VER_INFO 0x1D
|
||||
|
||||
/*! Link policy commands (none used for LE) */
|
||||
|
||||
/*! Controller and baseband commands */
|
||||
#define HCI_OCF_SET_EVENT_MASK 0x01
|
||||
#define HCI_OCF_RESET 0x03
|
||||
#define HCI_OCF_READ_TX_PWR_LVL 0x2D
|
||||
#define HCI_OCF_SET_CONTROLLER_TO_HOST_FC 0x31
|
||||
#define HCI_OCF_HOST_BUFFER_SIZE 0x33
|
||||
#define HCI_OCF_HOST_NUM_CMPL_PKTS 0x35
|
||||
|
||||
/*! Informational commands */
|
||||
#define HCI_OCF_READ_LOCAL_VER_INFO 0x01
|
||||
#define HCI_OCF_READ_LOCAL_SUP_CMDS 0x02
|
||||
#define HCI_OCF_READ_LOCAL_SUP_FEAT 0x03
|
||||
#define HCI_OCF_READ_BUF_SIZE 0x05
|
||||
#define HCI_OCF_READ_BD_ADDR 0x09
|
||||
|
||||
/*! Status commands */
|
||||
#define HCI_OCF_READ_RSSI 0x05
|
||||
|
||||
/*! LE controller commands */
|
||||
#define HCI_OCF_LE_SET_EVENT_MASK 0x01
|
||||
#define HCI_OCF_LE_READ_BUF_SIZE 0x02
|
||||
#define HCI_OCF_LE_READ_LOCAL_SUP_FEAT 0x03
|
||||
#define HCI_OCF_LE_SET_RAND_ADDR 0x05
|
||||
#define HCI_OCF_LE_SET_ADV_PARAM 0x06
|
||||
#define HCI_OCF_LE_READ_ADV_TX_POWER 0x07
|
||||
#define HCI_OCF_LE_SET_ADV_DATA 0x08
|
||||
#define HCI_OCF_LE_SET_SCAN_RESP_DATA 0x09
|
||||
#define HCI_OCF_LE_SET_ADV_ENABLE 0x0A
|
||||
#define HCI_OCF_LE_SET_SCAN_PARAM 0x0B
|
||||
#define HCI_OCF_LE_SET_SCAN_ENABLE 0x0C
|
||||
#define HCI_OCF_LE_CREATE_CONN 0x0D
|
||||
#define HCI_OCF_LE_CREATE_CONN_CANCEL 0x0E
|
||||
#define HCI_OCF_LE_READ_WHITE_LIST_SIZE 0x0F
|
||||
#define HCI_OCF_LE_CLEAR_WHITE_LIST 0x10
|
||||
#define HCI_OCF_LE_ADD_DEV_WHITE_LIST 0x11
|
||||
#define HCI_OCF_LE_REMOVE_DEV_WHITE_LIST 0x12
|
||||
#define HCI_OCF_LE_CONN_UPDATE 0x13
|
||||
#define HCI_OCF_LE_SET_HOST_CHAN_CLASS 0x14
|
||||
#define HCI_OCF_LE_READ_CHAN_MAP 0x15
|
||||
#define HCI_OCF_LE_READ_REMOTE_FEAT 0x16
|
||||
#define HCI_OCF_LE_ENCRYPT 0x17
|
||||
#define HCI_OCF_LE_RAND 0x18
|
||||
#define HCI_OCF_LE_START_ENCRYPTION 0x19
|
||||
#define HCI_OCF_LE_LTK_REQ_REPL 0x1A
|
||||
#define HCI_OCF_LE_LTK_REQ_NEG_REPL 0x1B
|
||||
#define HCI_OCF_LE_READ_SUP_STATES 0x1C
|
||||
#define HCI_OCF_LE_RECEIVER_TEST 0x1D
|
||||
#define HCI_OCF_LE_TRANSMITTER_TEST 0x1E
|
||||
#define HCI_OCF_LE_TEST_END 0x1F
|
||||
|
||||
/*! Opcode manipulation macros */
|
||||
#define HCI_OPCODE(ogf, ocf) (((ogf) << 10) + (ocf))
|
||||
#define HCI_OGF(opcode) ((opcode) >> 10)
|
||||
#define HCI_OCF(opcode) ((opcode) & 0x03FF)
|
||||
|
||||
/*! Command opcodes */
|
||||
#define HCI_OPCODE_NOP HCI_OPCODE(HCI_OGF_NOP, HCI_OCF_NOP)
|
||||
|
||||
#define HCI_OPCODE_DISCONNECT HCI_OPCODE(HCI_OGF_LINK_CONTROL, HCI_OCF_DISCONNECT)
|
||||
#define HCI_OPCODE_READ_REMOTE_VER_INFO HCI_OPCODE(HCI_OGF_LINK_CONTROL, HCI_OCF_READ_REMOTE_VER_INFO)
|
||||
|
||||
#define HCI_OPCODE_SET_EVENT_MASK HCI_OPCODE(HCI_OGF_CONTROLLER, HCI_OCF_SET_EVENT_MASK)
|
||||
#define HCI_OPCODE_RESET HCI_OPCODE(HCI_OGF_CONTROLLER, HCI_OCF_RESET)
|
||||
#define HCI_OPCODE_READ_TX_PWR_LVL HCI_OPCODE(HCI_OGF_CONTROLLER, HCI_OCF_READ_TX_PWR_LVL)
|
||||
#define HCI_OPCODE_SET_CONTROLLER_TO_HOST_FC HCI_OPCODE(HCI_OGF_CONTROLLER, HCI_OCF_SET_CONTROLLER_TO_HOST_FC)
|
||||
#define HCI_OPCODE_HOST_BUFFER_SIZE HCI_OPCODE(HCI_OGF_CONTROLLER, HCI_OCF_HOST_BUFFER_SIZE)
|
||||
#define HCI_OPCODE_HOST_NUM_CMPL_PKTS HCI_OPCODE(HCI_OGF_CONTROLLER, HCI_OCF_HOST_NUM_CMPL_PKTS)
|
||||
|
||||
#define HCI_OPCODE_READ_LOCAL_VER_INFO HCI_OPCODE(HCI_OGF_INFORMATIONAL, HCI_OCF_READ_LOCAL_VER_INFO)
|
||||
#define HCI_OPCODE_READ_LOCAL_SUP_CMDS HCI_OPCODE(HCI_OGF_INFORMATIONAL, HCI_OCF_READ_LOCAL_SUP_CMDS)
|
||||
#define HCI_OPCODE_READ_LOCAL_SUP_FEAT HCI_OPCODE(HCI_OGF_INFORMATIONAL, HCI_OCF_READ_LOCAL_SUP_FEAT)
|
||||
#define HCI_OPCODE_READ_BUF_SIZE HCI_OPCODE(HCI_OGF_INFORMATIONAL, HCI_OCF_READ_BUF_SIZE)
|
||||
#define HCI_OPCODE_READ_BD_ADDR HCI_OPCODE(HCI_OGF_INFORMATIONAL, HCI_OCF_READ_BD_ADDR)
|
||||
|
||||
#define HCI_OPCODE_READ_RSSI HCI_OPCODE(HCI_OGF_STATUS, HCI_OCF_READ_RSSI)
|
||||
|
||||
#define HCI_OPCODE_LE_SET_EVENT_MASK HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_EVENT_MASK)
|
||||
#define HCI_OPCODE_LE_READ_BUF_SIZE HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_BUF_SIZE)
|
||||
#define HCI_OPCODE_LE_READ_LOCAL_SUP_FEAT HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_LOCAL_SUP_FEAT)
|
||||
#define HCI_OPCODE_LE_SET_RAND_ADDR HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_RAND_ADDR)
|
||||
#define HCI_OPCODE_LE_SET_ADV_PARAM HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_ADV_PARAM)
|
||||
#define HCI_OPCODE_LE_READ_ADV_TX_POWER HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_ADV_TX_POWER)
|
||||
#define HCI_OPCODE_LE_SET_ADV_DATA HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_ADV_DATA)
|
||||
#define HCI_OPCODE_LE_SET_SCAN_RESP_DATA HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_SCAN_RESP_DATA)
|
||||
#define HCI_OPCODE_LE_SET_ADV_ENABLE HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_ADV_ENABLE)
|
||||
#define HCI_OPCODE_LE_SET_SCAN_PARAM HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_SCAN_PARAM)
|
||||
#define HCI_OPCODE_LE_SET_SCAN_ENABLE HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_SCAN_ENABLE)
|
||||
#define HCI_OPCODE_LE_CREATE_CONN HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_CREATE_CONN)
|
||||
#define HCI_OPCODE_LE_CREATE_CONN_CANCEL HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_CREATE_CONN_CANCEL)
|
||||
#define HCI_OPCODE_LE_READ_WHITE_LIST_SIZE HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_WHITE_LIST_SIZE)
|
||||
#define HCI_OPCODE_LE_CLEAR_WHITE_LIST HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_CLEAR_WHITE_LIST)
|
||||
#define HCI_OPCODE_LE_ADD_DEV_WHITE_LIST HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_ADD_DEV_WHITE_LIST)
|
||||
#define HCI_OPCODE_LE_REMOVE_DEV_WHITE_LIST HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_REMOVE_DEV_WHITE_LIST)
|
||||
#define HCI_OPCODE_LE_CONN_UPDATE HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_CONN_UPDATE)
|
||||
#define HCI_OPCODE_LE_SET_HOST_CHAN_CLASS HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_HOST_CHAN_CLASS)
|
||||
#define HCI_OPCODE_LE_READ_CHAN_MAP HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_CHAN_MAP)
|
||||
#define HCI_OPCODE_LE_READ_REMOTE_FEAT HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_REMOTE_FEAT)
|
||||
#define HCI_OPCODE_LE_ENCRYPT HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_ENCRYPT)
|
||||
#define HCI_OPCODE_LE_RAND HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_RAND)
|
||||
#define HCI_OPCODE_LE_START_ENCRYPTION HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_START_ENCRYPTION)
|
||||
#define HCI_OPCODE_LE_LTK_REQ_REPL HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_LTK_REQ_REPL)
|
||||
#define HCI_OPCODE_LE_LTK_REQ_NEG_REPL HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_LTK_REQ_NEG_REPL)
|
||||
#define HCI_OPCODE_LE_READ_SUP_STATES HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_SUP_STATES)
|
||||
#define HCI_OPCODE_LE_RECEIVER_TEST HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_RECEIVER_TEST)
|
||||
#define HCI_OPCODE_LE_TRANSMITTER_TEST HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_TRANSMITTER_TEST)
|
||||
#define HCI_OPCODE_LE_TEST_END HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_TEST_END)
|
||||
|
||||
/*! Command parameter lengths */
|
||||
#define HCI_LEN_NOP 0
|
||||
|
||||
#define HCI_LEN_DISCONNECT 3
|
||||
#define HCI_LEN_READ_REMOTE_VER_INFO 2
|
||||
|
||||
#define HCI_LEN_SET_EVENT_MASK 8
|
||||
#define HCI_LEN_RESET 0
|
||||
#define HCI_LEN_READ_TX_PWR_LVL 3
|
||||
#define HCI_LEN_SET_CONTROLLER_TO_HOST_FC 1
|
||||
#define HCI_LEN_HOST_BUFFER_SIZE 8
|
||||
#define HCI_LEN_HOST_NUM_CMPL_PKTS 1
|
||||
|
||||
#define HCI_LEN_READ_LOCAL_VER_INFO 0
|
||||
#define HCI_LEN_READ_LOCAL_SUP_CMDS 0
|
||||
#define HCI_LEN_READ_LOCAL_SUP_FEAT 0
|
||||
#define HCI_LEN_READ_BUF_SIZE 0
|
||||
#define HCI_LEN_READ_BD_ADDR 0
|
||||
|
||||
#define HCI_LEN_READ_RSSI 2
|
||||
|
||||
#define HCI_LEN_LE_SET_EVENT_MASK 8
|
||||
#define HCI_LEN_LE_READ_BUF_SIZE 0
|
||||
#define HCI_LEN_LE_READ_LOCAL_SUP_FEAT 0
|
||||
#define HCI_LEN_LE_SET_RAND_ADDR 6
|
||||
#define HCI_LEN_LE_SET_ADV_PARAM 15
|
||||
#define HCI_LEN_LE_READ_ADV_TX_POWER 0
|
||||
#define HCI_LEN_LE_SET_ADV_DATA 32
|
||||
#define HCI_LEN_LE_SET_SCAN_RESP_DATA 32
|
||||
#define HCI_LEN_LE_SET_ADV_ENABLE 1
|
||||
#define HCI_LEN_LE_SET_SCAN_PARAM 7
|
||||
#define HCI_LEN_LE_SET_SCAN_ENABLE 2
|
||||
#define HCI_LEN_LE_CREATE_CONN 25
|
||||
#define HCI_LEN_LE_CREATE_CONN_CANCEL 0
|
||||
#define HCI_LEN_LE_READ_WHITE_LIST_SIZE 0
|
||||
#define HCI_LEN_LE_CLEAR_WHITE_LIST 0
|
||||
#define HCI_LEN_LE_ADD_DEV_WHITE_LIST 7
|
||||
#define HCI_LEN_LE_REMOVE_DEV_WHITE_LIST 7
|
||||
#define HCI_LEN_LE_CONN_UPDATE 14
|
||||
#define HCI_LEN_LE_SET_HOST_CHAN_CLASS 5
|
||||
#define HCI_LEN_LE_READ_CHAN_MAP 2
|
||||
#define HCI_LEN_LE_READ_REMOTE_FEAT 2
|
||||
#define HCI_LEN_LE_ENCRYPT 32
|
||||
#define HCI_LEN_LE_RAND 0
|
||||
#define HCI_LEN_LE_START_ENCRYPTION 28
|
||||
#define HCI_LEN_LE_LTK_REQ_REPL 18
|
||||
#define HCI_LEN_LE_LTK_REQ_NEG_REPL 2
|
||||
#define HCI_LEN_LE_READ_SUP_STATES 0
|
||||
#define HCI_LEN_LE_RECEIVER_TEST 1
|
||||
#define HCI_LEN_LE_TRANSMITTER_TEST 3
|
||||
#define HCI_LEN_LE_TEST_END 0
|
||||
|
||||
/*! Events */
|
||||
#define HCI_DISCONNECT_CMPL_EVT 0x05
|
||||
#define HCI_ENC_CHANGE_EVT 0x08
|
||||
#define HCI_READ_REMOTE_VER_INFO_CMPL_EVT 0x0C
|
||||
#define HCI_CMD_CMPL_EVT 0x0E
|
||||
#define HCI_CMD_STATUS_EVT 0x0F
|
||||
#define HCI_HW_ERROR_EVT 0x10
|
||||
#define HCI_NUM_CMPL_PKTS_EVT 0x13
|
||||
#define HCI_DATA_BUF_OVERFLOW_EVT 0x1A
|
||||
#define HCI_ENC_KEY_REFRESH_CMPL_EVT 0x30
|
||||
#define HCI_LE_META_EVT 0x3E
|
||||
#define HCI_VENDOR_SPEC_EVT 0xFF
|
||||
|
||||
/*! LE Subevents */
|
||||
#define HCI_LE_CONN_CMPL_EVT 0x01
|
||||
#define HCI_LE_ADV_REPORT_EVT 0x02
|
||||
#define HCI_LE_CONN_UPDATE_CMPL_EVT 0x03
|
||||
#define HCI_LE_READ_REMOTE_FEAT_CMPL_EVT 0x04
|
||||
#define HCI_LE_LTK_REQ_EVT 0x05
|
||||
|
||||
/*! Event parameter lengths */
|
||||
#define HCI_LEN_DISCONNECT_CMPL 4
|
||||
#define HCI_LEN_ENC_CHANGE 5
|
||||
#define HCI_LEN_LE_CONN_CMPL 19
|
||||
#define HCI_LEN_LE_CONN_UPDATE_CMPL 9
|
||||
#define HCI_LEN_LE_READ_REMOTE_FEAT_CMPL 12
|
||||
#define HCI_LEN_LE_LTK_REQ 13
|
||||
|
||||
/*! Supported commands */
|
||||
#define HCI_SUP_DISCONNECT 0x20 /*! Byte 0 */
|
||||
#define HCI_SUP_READ_REMOTE_VER_INFO 0x80 /*! Byte 2 */
|
||||
#define HCI_SUP_SET_EVENT_MASK 0x40 /*! Byte 5 */
|
||||
#define HCI_SUP_RESET 0x80 /*! Byte 5 */
|
||||
#define HCI_SUP_READ_TX_PWR_LVL 0x04 /*! Byte 10 */
|
||||
#define HCI_SUP_SET_CONTROLLER_TO_HOST_FC 0x20 /*! Byte 10 */
|
||||
#define HCI_SUP_HOST_BUFFER_SIZE 0x40 /*! Byte 10 */
|
||||
#define HCI_SUP_HOST_NUM_CMPL_PKTS 0x80 /*! Byte 10 */
|
||||
#define HCI_SUP_READ_LOCAL_VER_INFO 0x08 /*! Byte 14 */
|
||||
#define HCI_SUP_READ_LOCAL_SUP_FEAT 0x20 /*! Byte 14 */
|
||||
#define HCI_SUP_READ_BD_ADDR 0x02 /*! Byte 15 */
|
||||
#define HCI_SUP_READ_RSSI 0x20 /*! Byte 15 */
|
||||
#define HCI_SUP_LE_SET_EVENT_MASK 0x01 /*! Byte 25 */
|
||||
#define HCI_SUP_LE_READ_BUF_SIZE 0x02 /*! Byte 25 */
|
||||
#define HCI_SUP_LE_READ_LOCAL_SUP_FEAT 0x04 /*! Byte 25 */
|
||||
#define HCI_SUP_LE_SET_RAND_ADDR 0x10 /*! Byte 25 */
|
||||
#define HCI_SUP_LE_SET_ADV_PARAM 0x20 /*! Byte 25 */
|
||||
#define HCI_SUP_LE_READ_ADV_TX_POWER 0x40 /*! Byte 25 */
|
||||
#define HCI_SUP_LE_SET_ADV_DATA 0x80 /*! Byte 25 */
|
||||
#define HCI_SUP_LE_SET_SCAN_RESP_DATA 0x01 /*! Byte 26 */
|
||||
#define HCI_SUP_LE_SET_ADV_ENABLE 0x02 /*! Byte 26 */
|
||||
#define HCI_SUP_LE_SET_SCAN_PARAM 0x04 /*! Byte 26 */
|
||||
#define HCI_SUP_LE_SET_SCAN_ENABLE 0x08 /*! Byte 26 */
|
||||
#define HCI_SUP_LE_CREATE_CONN 0x10 /*! Byte 26 */
|
||||
#define HCI_SUP_LE_CREATE_CONN_CANCEL 0x20 /*! Byte 26 */
|
||||
#define HCI_SUP_LE_READ_WHITE_LIST_SIZE 0x40 /*! Byte 26 */
|
||||
#define HCI_SUP_LE_CLEAR_WHITE_LIST 0x80 /*! Byte 26 */
|
||||
#define HCI_SUP_LE_ADD_DEV_WHITE_LIST 0x01 /*! Byte 27 */
|
||||
#define HCI_SUP_LE_REMOVE_DEV_WHITE_LIST 0x02 /*! Byte 27 */
|
||||
#define HCI_SUP_LE_CONN_UPDATE 0x04 /*! Byte 27 */
|
||||
#define HCI_SUP_LE_SET_HOST_CHAN_CLASS 0x08 /*! Byte 27 */
|
||||
#define HCI_SUP_LE_READ_CHAN_MAP 0x10 /*! Byte 27 */
|
||||
#define HCI_SUP_LE_READ_REMOTE_FEAT 0x20 /*! Byte 27 */
|
||||
#define HCI_SUP_LE_ENCRYPT 0x40 /*! Byte 27 */
|
||||
#define HCI_SUP_LE_RAND 0x80 /*! Byte 27 */
|
||||
#define HCI_SUP_LE_START_ENCRYPTION 0x01 /*! Byte 28 */
|
||||
#define HCI_SUP_LE_LTK_REQ_REPL 0x02 /*! Byte 28 */
|
||||
#define HCI_SUP_LE_LTK_REQ_NEG_REPL 0x04 /*! Byte 28 */
|
||||
#define HCI_SUP_LE_READ_SUP_STATES 0x08 /*! Byte 28 */
|
||||
#define HCI_SUP_LE_RECEIVER_TEST 0x10 /*! Byte 28 */
|
||||
#define HCI_SUP_LE_TRANSMITTER_TEST 0x20 /*! Byte 28 */
|
||||
#define HCI_SUP_LE_TEST_END 0x40 /*! Byte 28 */
|
||||
|
||||
/*! Event mask */
|
||||
#define HCI_EVT_MASK_DISCONNECT_CMPL 0x10 /*! Byte 0 */
|
||||
#define HCI_EVT_MASK_ENC_CHANGE 0x80 /*! Byte 0 */
|
||||
#define HCI_EVT_MASK_READ_REMOTE_VER_INFO_CMPL 0x08 /*! Byte 1 */
|
||||
#define HCI_EVT_MASK_HW_ERROR 0x80 /*! Byte 1 */
|
||||
#define HCI_EVT_MASK_DATA_BUF_OVERFLOW 0x02 /*! Byte 3 */
|
||||
#define HCI_EVT_MASK_ENC_KEY_REFRESH_CMPL 0x80 /*! Byte 5 */
|
||||
#define HCI_EVT_MASK_LE_META 0x20 /*! Byte 7 */
|
||||
|
||||
/*! LE event mask */
|
||||
#define HCI_EVT_MASK_LE_CONN_CMPL_EVT 0x01 /*! Byte 0 */
|
||||
#define HCI_EVT_MASK_LE_ADV_REPORT_EVT 0x02 /*! Byte 0 */
|
||||
#define HCI_EVT_MASK_LE_CONN_UPDATE_CMPL_EVT 0x04 /*! Byte 0 */
|
||||
#define HCI_EVT_MASK_LE_READ_REMOTE_FEAT_CMPL_EVT 0x08 /*! Byte 0 */
|
||||
#define HCI_EVT_MASK_LE_LTK_REQ_EVT 0x10 /*! Byte 0 */
|
||||
|
||||
/*! LE supported features */
|
||||
#define HCI_LE_SUP_FEAT_ENCRYPTION 0x01
|
||||
|
||||
/*! Advertising command parameters */
|
||||
#define HCI_ADV_MIN_INTERVAL 0x0020 /*! Minimum advertising interval */
|
||||
#define HCI_ADV_NONCONN_MIN_INTERVAL 0x00A0 /*! Minimum nonconnectable adv. interval */
|
||||
#define HCI_ADV_MAX_INTERVAL 0x4000 /*! Maximum advertising interval */
|
||||
#define HCI_ADV_TYPE_CONN_UNDIRECT 0x00 /*! Connectable undirected advertising */
|
||||
#define HCI_ADV_TYPE_CONN_DIRECT 0x01 /*! Connectable directed advertising */
|
||||
#define HCI_ADV_TYPE_DISC_UNDIRECT 0x02 /*! Discoverable undirected advertising */
|
||||
#define HCI_ADV_TYPE_NONCONN_UNDIRECT 0x03 /*! Nonconnectable undirected advertising */
|
||||
#define HCI_ADV_CHAN_37 0x01 /*! Advertising channel 37 */
|
||||
#define HCI_ADV_CHAN_38 0x02 /*! Advertising channel 38 */
|
||||
#define HCI_ADV_CHAN_39 0x04 /*! Advertising channel 39 */
|
||||
#define HCI_ADV_FILT_NONE 0x00 /*! No scan request or connection filtering */
|
||||
#define HCI_ADV_FILT_SCAN 0x01 /*! White list filters scan requests */
|
||||
#define HCI_ADV_FILT_CONN 0x02 /*! White list filters connections */
|
||||
#define HCI_ADV_FILT_ALL 0x03 /*! White list filters scan req. and conn. */
|
||||
|
||||
/*! Scan command parameters */
|
||||
#define HCI_SCAN_TYPE_PASSIVE 0 /*! Passive scan */
|
||||
#define HCI_SCAN_TYPE_ACTIVE 1 /*! Active scan */
|
||||
#define HCI_SCAN_INTERVAL_MIN 0x0004 /*! Minimum scan interval */
|
||||
#define HCI_SCAN_INTERVAL_MAX 0x4000 /*! Maximum scan interval */
|
||||
#define HCI_SCAN_INTERVAL_DEFAULT 0x0010 /*! Default scan interval */
|
||||
#define HCI_SCAN_WINDOW_MIN 0x0004 /*! Minimum scan window */
|
||||
#define HCI_SCAN_WINDOW_MAX 0x4000 /*! Maximum scan window */
|
||||
#define HCI_SCAN_WINDOW_DEFAULT 0x0010 /*! Default scan window */
|
||||
|
||||
/*! Connection command parameters */
|
||||
#define HCI_CONN_INTERVAL_MIN 0x0006 /*! Minimum connection interval */
|
||||
#define HCI_CONN_INTERVAL_MAX 0x0C80 /*! Maximum connection interval */
|
||||
#define HCI_CONN_LATENCY_MAX 0x01F3 /*! Maximum connection latency */
|
||||
#define HCI_SUP_TIMEOUT_MIN 0x000A /*! Minimum supervision timeout */
|
||||
#define HCI_SUP_TIMEOUT_MAX 0x0C80 /*! Maximum supervision timeout */
|
||||
|
||||
/*! Connection event parameters */
|
||||
#define HCI_ROLE_MASTER 0 /*! Role is master */
|
||||
#define HCI_ROLE_SLAVE 1 /*! Role is slave */
|
||||
#define HCI_CLOCK_500PPM 0x00 /*! 500 ppm clock accuracy */
|
||||
#define HCI_CLOCK_250PPM 0x01 /*! 250 ppm clock accuracy */
|
||||
#define HCI_CLOCK_150PPM 0x02 /*! 150 ppm clock accuracy */
|
||||
#define HCI_CLOCK_100PPM 0x03 /*! 100 ppm clock accuracy */
|
||||
#define HCI_CLOCK_75PPM 0x04 /*! 75 ppm clock accuracy */
|
||||
#define HCI_CLOCK_50PPM 0x05 /*! 50 ppm clock accuracy */
|
||||
#define HCI_CLOCK_30PPM 0x06 /*! 30 ppm clock accuracy */
|
||||
#define HCI_CLOCK_20PPM 0x07 /*! 20 ppm clock accuracy */
|
||||
|
||||
/*! Advertising report event parameters */
|
||||
#define HCI_ADV_CONN_UNDIRECT 0x00 /*! Connectable undirected advertising */
|
||||
#define HCI_ADV_CONN_DIRECT 0x01 /*! Connectable directed advertising */
|
||||
#define HCI_ADV_DISC_UNDIRECT 0x02 /*! Discoverable undirected advertising */
|
||||
#define HCI_ADV_NONCONN_UNDIRECT 0x03 /*! Non-connectable undirected advertising */
|
||||
#define HCI_ADV_SCAN_RESPONSE 0x04 /*! Scan response */
|
||||
|
||||
/*! Misc command parameters */
|
||||
#define HCI_READ_TX_PWR_CURRENT 0 /*! Read current tx power */
|
||||
#define HCI_READ_TX_PWR_MAX 1 /*! Read maximum tx power */
|
||||
#define HCI_TX_PWR_MIN -30 /*! Minimum tx power dBm */
|
||||
#define HCI_TX_PWR_MAX 20 /*! Maximum tx power dBm */
|
||||
#define HCI_VERSION 6 /*! HCI specification version */
|
||||
#define HCI_RSSI_MIN -127 /*! Minimum RSSI dBm */
|
||||
#define HCI_RSSI_MAX 20 /*! Maximum RSSI dBm */
|
||||
#define HCI_ADDR_TYPE_PUBLIC 0 /*! Public device address */
|
||||
#define HCI_ADDR_TYPE_RANDOM 1 /*! Random device address */
|
||||
#define HCI_FILT_NONE 0 /*! No white list filtering */
|
||||
#define HCI_FILT_WHITE_LIST 1 /*! White list filtering */
|
||||
#define HCI_ROLE_MASTER 0 /*! Role is master */
|
||||
#define HCI_ROLE_SLAVE 1 /*! Role is slave */
|
||||
|
||||
/*! Parameter lengths */
|
||||
#define HCI_EVT_MASK_LEN 8 /*! Length of event mask byte array */
|
||||
#define HCI_LE_EVT_MASK_LEN 8 /*! Length of LE event mask byte array */
|
||||
#define HCI_FEAT_LEN 8 /*! Length of features byte array */
|
||||
#define HCI_ADV_DATA_LEN 31 /*! Length of advertising data */
|
||||
#define HCI_SCAN_DATA_LEN 31 /*! Length of scan response data */
|
||||
#define HCI_CHAN_MAP_LEN 5 /*! Length of channel map byte array */
|
||||
#define HCI_KEY_LEN 16 /*! Length of encryption key */
|
||||
#define HCI_ENCRYPT_DATA_LEN 16 /*! Length of data used in encryption */
|
||||
#define HCI_RAND_LEN 8 /*! Length of random number */
|
||||
#define HCI_LE_STATES_LEN 8 /*! Length of LE states byte array */
|
||||
|
||||
/*! Wicentric company ID */
|
||||
#define HCI_ID_WICENTRIC 0x005F
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* HCI_DEFS_H */
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file hci_handler.h
|
||||
*
|
||||
* \brief Interface to HCI event handler.
|
||||
*
|
||||
* $Date: 2012-03-29 16:24:04 -0400 (Thu, 29 Mar 2012) $
|
||||
* $Revision: 287 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef HCI_HANDLER_H
|
||||
#define HCI_HANDLER_H
|
||||
|
||||
#include "wsf_os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn HciHandlerInit
|
||||
*
|
||||
* \brief HCI handler init function called during system initialization.
|
||||
*
|
||||
* \param handlerID WSF handler ID for HCI.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void HciHandlerInit(wsfHandlerId_t handlerId);
|
||||
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn HciHandler
|
||||
*
|
||||
* \brief WSF event handler for HCI.
|
||||
*
|
||||
* \param event WSF event mask.
|
||||
* \param pMsg WSF message.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void HciHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* HCI_HANDLER_H */
|
||||
|
|
@ -0,0 +1,442 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file l2c_api.h
|
||||
*
|
||||
* \brief L2CAP subsystem API.
|
||||
*
|
||||
* $Date: 2015-10-09 12:08:23 -0400 (Fri, 09 Oct 2015) $
|
||||
* $Revision: 4164 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef L2C_API_H
|
||||
#define L2C_API_H
|
||||
|
||||
#include "dm_api.h"
|
||||
#include "l2c_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Control callback message events */
|
||||
#define L2C_CTRL_FLOW_ENABLE_IND 0 /*! Data flow enabled */
|
||||
#define L2C_CTRL_FLOW_DISABLE_IND 1 /*! Data flow disabled */
|
||||
|
||||
/*! Invalid channel registration ID for connection oriented channels */
|
||||
#define L2C_COC_REG_ID_NONE 0
|
||||
|
||||
/*! Invalid channel ID for connection oriented channels */
|
||||
#define L2C_COC_CID_NONE 0
|
||||
|
||||
/*! Connection oriented channel initiator/acceptor role */
|
||||
#define L2C_COC_ROLE_NONE 0x00 /*! No role (unallocated) */
|
||||
#define L2C_COC_ROLE_INITIATOR 0x01 /*! Channel initiator */
|
||||
#define L2C_COC_ROLE_ACCEPTOR 0x02 /*! Channel acceptor */
|
||||
|
||||
/*! Connection oriented channel data confirm status values */
|
||||
#define L2C_COC_DATA_SUCCESS 0 /*! Data request successful */
|
||||
#define L2C_COC_DATA_ERR_MEMORY 1 /*! Out of memory */
|
||||
#define L2C_COC_DATA_ERR_OVERFLOW 2 /*! Transaction overflow */
|
||||
|
||||
/*! Connection oriented channel callback events */
|
||||
#define L2C_COC_CBACK_START 0x40 /*! L2C callback event starting value */
|
||||
enum
|
||||
{
|
||||
L2C_COC_CONNECT_IND = L2C_COC_CBACK_START, /*! Channel connect indication */
|
||||
L2C_COC_DISCONNECT_IND, /*! Channel disconnect indication */
|
||||
L2C_COC_DATA_IND, /*! Received data indication */
|
||||
L2C_COC_DATA_CNF /*! Transmit data confirm */
|
||||
};
|
||||
|
||||
#define L2C_COC_CBACK_CBACK_END L2C_COC_DATA_CNF /*! L2C callback event ending value */
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Connection oriented channel registration ID */
|
||||
typedef uint16_t l2cCocRegId_t;
|
||||
|
||||
/*! Connection oriented channel registration structure */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t psm; /*! Protocol service multiplexer */
|
||||
uint16_t mps; /*! Maximum receive PDU fragment size */
|
||||
uint16_t mtu; /*! Maximum receive data packet size */
|
||||
uint16_t credits; /*! Data packet receive credits for this channel */
|
||||
bool_t authoriz; /*! TRUE if authorization is required */
|
||||
uint8_t secLevel; /*! Channel minimum security level requirements */
|
||||
uint8_t role; /*! Channel initiator/acceptor role */
|
||||
} l2cCocReg_t;
|
||||
|
||||
/* Connection oriented channel connect indication structure */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr; /*! Header structure */
|
||||
uint16_t cid; /*! Local channel ID */
|
||||
uint16_t peerMtu; /*! Data packet MTU peer can receive */
|
||||
uint16_t psm; /*! Connected PSM */
|
||||
} l2cCocConnectInd_t;
|
||||
|
||||
/* Connection oriented channel disconnect indication structure */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr; /*! Header structure */
|
||||
uint16_t cid; /*! Local channel ID */
|
||||
uint16_t result; /*! Connection failure result code */
|
||||
} l2cCocDisconnectInd_t;
|
||||
|
||||
/* Connection oriented channel data indication structure */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr; /*! Header structure */
|
||||
uint16_t cid; /*! Local channel ID */
|
||||
uint8_t *pData; /*! Pointer to packet data */
|
||||
uint16_t dataLen; /*! packet data length */
|
||||
} l2cCocDataInd_t;
|
||||
|
||||
/* Connection oriented channel disconnect indication structure */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr; /*! Header structure */
|
||||
uint16_t cid; /*! Local channel ID */
|
||||
} l2cCocDataCnf_t;
|
||||
|
||||
/*!
|
||||
* Connection oriented channel event structure
|
||||
*
|
||||
* Connection oriented channel callback header parameters:
|
||||
*
|
||||
* \param hdr.event Callback event
|
||||
* \param hdr.param DM connection ID
|
||||
* \param hdr.status Event status (L2C_COC_DATA_CNF only)
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
wsfMsgHdr_t hdr; /*! Header structure */
|
||||
l2cCocConnectInd_t connectInd; /*! Channel connect indication */
|
||||
l2cCocDisconnectInd_t disconnectInd; /*! Channel disconnect indication */
|
||||
l2cCocDataInd_t dataInd; /*! Received data indication */
|
||||
l2cCocDataCnf_t dataCnf; /*! Transmit data confirm */
|
||||
} l2cCocEvt_t;
|
||||
|
||||
/*! Configurable parameters */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t reqTimeout; /*! Request timeout in seconds */
|
||||
} l2cCfg_t;
|
||||
|
||||
/**************************************************************************************************
|
||||
Global Variables;
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Configuration pointer */
|
||||
extern l2cCfg_t *pL2cCfg;
|
||||
|
||||
/**************************************************************************************************
|
||||
Callback Function Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn l2cDataCback_t
|
||||
*
|
||||
* \brief This callback function sends a received L2CAP packet to the client.
|
||||
*
|
||||
* \param handle The connection handle.
|
||||
* \param len The length of the L2CAP payload data in pPacket.
|
||||
* \param pPacket A buffer containing the packet.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
typedef void (*l2cDataCback_t)(uint16_t handle, uint16_t len, uint8_t *pPacket);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn l2cCtrlCback_t
|
||||
*
|
||||
* \brief This callback function sends control messages to the client.
|
||||
*
|
||||
* \param pMsg Pointer to message structure.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
typedef void (*l2cCtrlCback_t)(wsfMsgHdr_t *pMsg);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn l2cCocCback_t
|
||||
*
|
||||
* \brief This callback function sends data and other events to connection oriented
|
||||
* channels clients.
|
||||
*
|
||||
* \param pMsg Pointer to message structure.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
typedef void (*l2cCocCback_t)(l2cCocEvt_t *pMsg);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn l2cCocAuthorCback_t
|
||||
*
|
||||
* \brief This callback function is used for authoriztion of connection oriented channels.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param regId The registration instance requiring authorization.
|
||||
* \param psm The PSM of the registration instance.
|
||||
*
|
||||
* \return L2C_CONN_SUCCESS if authorization is successful, any other value for failure.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
typedef uint16_t (*l2cCocAuthorCback_t)(dmConnId_t connId, l2cCocRegId_t regId, uint16_t psm);
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cInit
|
||||
*
|
||||
* \brief Initialize L2C subsystem.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cMasterInit
|
||||
*
|
||||
* \brief Initialize L2C for operation as a Bluetooth LE master.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cMasterInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cSlaveInit
|
||||
*
|
||||
* \brief Initialize L2C for operation as a Bluetooth LE slave.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cSlaveInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cSlaveInit
|
||||
*
|
||||
* \brief Initialize L2C for operation with connection-oriented channels.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cCocInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cRegister
|
||||
*
|
||||
* \brief called by the L2C client, such as ATT or SMP, to register for the given CID.
|
||||
*
|
||||
* \param cid channel identifier.
|
||||
* \param dataCback Callback function for L2CAP data received for this CID.
|
||||
* \param ctrlCback Callback function for control events for this CID.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cRegister(uint16_t cid, l2cDataCback_t dataCback, l2cCtrlCback_t ctrlCback);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cDataReq
|
||||
*
|
||||
* \brief Send an L2CAP data packet on the given CID.
|
||||
*
|
||||
* \param cid The channel identifier.
|
||||
* \param handle The connection handle. The client receives this handle from DM.
|
||||
* \param len The length of the payload data in pPacket.
|
||||
* \param pPacket A buffer containing the packet.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cDataReq(uint16_t cid, uint16_t handle, uint16_t len, uint8_t *pL2cPacket);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cCocInit
|
||||
*
|
||||
* \brief Initialize L2C connection oriented channel subsystem.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cCocInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cCocRegister
|
||||
*
|
||||
* \brief Register to use a connection oriented channel, as either a channel acceptor,
|
||||
* initiator, or both. If registering as channel acceptor then the PSM is specified.
|
||||
* After registering a connection can be established by the client using this
|
||||
* registration instance.
|
||||
*
|
||||
* \param cback Client callback function.
|
||||
* \param pReg Registration parameter structure.
|
||||
*
|
||||
* \return Registration instance ID or L2C_COC_REG_ID_NONE if registration failed.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
l2cCocRegId_t L2cCocRegister(l2cCocCback_t cback, l2cCocReg_t *pReg);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cCocDeregister
|
||||
*
|
||||
* \brief Deregister and deallocate a connection oriented channel registration instance.
|
||||
* This function should only be called if there are no active channels using this
|
||||
* registration instance.
|
||||
*
|
||||
* \param regId Registration instance ID.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cCocDeregister(l2cCocRegId_t regId);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cCocConnectReq
|
||||
*
|
||||
* \brief Initiate a connection to the given peer PSM.
|
||||
*
|
||||
* \param connId DM connection ID.
|
||||
* \param regId The associated registration instance.
|
||||
* \param psm Peer PSM.
|
||||
*
|
||||
* \return Local CID or L2C_COC_CID_NONE none if failure.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint16_t L2cCocConnectReq(dmConnId_t connId, l2cCocRegId_t regId, uint16_t psm);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cCocDisconnectReq
|
||||
*
|
||||
* \brief Disconnect the channel for the given CID.
|
||||
*
|
||||
* \param cid Channel ID.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cCocDisconnectReq(uint16_t cid);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cCocDataReq
|
||||
*
|
||||
* \brief Send an L2CAP data packet on the given connection oriented CID.
|
||||
*
|
||||
* \param cid The local channel identifier.
|
||||
* \param len The length of the payload data in pPacket.
|
||||
* \param pPacket Packet payload data.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cCocDataReq(uint16_t cid, uint16_t len, uint8_t *pPayload);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cCocErrorTest
|
||||
*
|
||||
* \brief For testing purposes only.
|
||||
*
|
||||
* \param result Result code
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cCocErrorTest(uint16_t result);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cCocCreditSendTest
|
||||
*
|
||||
* \brief For testing purposes only.
|
||||
*
|
||||
* \param cid The local channel identifier.
|
||||
* \param credits Credits to send.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cCocCreditSendTest(uint16_t cid, uint16_t credits);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cDmConnUpdateReq
|
||||
*
|
||||
* \brief For internal use only. This function is called by DM to send an L2CAP
|
||||
* connection update request.
|
||||
*
|
||||
* \param handle The connection handle.
|
||||
* \param pConnSpec Pointer to the connection specification structure.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cDmConnUpdateReq(uint16_t handle, hciConnSpec_t *pConnSpec);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cDmConnUpdateRsp
|
||||
*
|
||||
* \brief For internal use only. This function is called by DM to send an L2CAP
|
||||
* connection update response.
|
||||
*
|
||||
* \param identifier Identifier value previously passed from L2C to DM.
|
||||
* \param handle The connection handle.
|
||||
* \param result Connection update response result.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cDmConnUpdateRsp(uint8_t identifier, uint16_t handle, uint16_t result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* L2C_API_H */
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file l2c_defs.h
|
||||
*
|
||||
* \brief L2CAP constants and definitions from the Bluetooth specification.
|
||||
*
|
||||
* $Date: 2015-06-12 07:19:18 -0400 (Fri, 12 Jun 2015) $
|
||||
* $Revision: 3061 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef L2C_DEFS_H
|
||||
#define L2C_DEFS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Packet definitions */
|
||||
#define L2C_HDR_LEN 4 /*! L2CAP packet header length */
|
||||
#define L2C_MIN_MTU 23 /*! Minimum packet payload MTU for LE */
|
||||
#define L2C_SIG_HDR_LEN 4 /*! L2CAP signaling command header length */
|
||||
#define L2C_LE_SDU_HDR_LEN 2 /*! L2CAP LE SDU data header length */
|
||||
|
||||
/*! Start of L2CAP payload in an HCI ACL packet buffer */
|
||||
#define L2C_PAYLOAD_START (HCI_ACL_HDR_LEN + L2C_HDR_LEN)
|
||||
|
||||
/*! L2CAP signaling packet base length, including HCI header */
|
||||
#define L2C_SIG_PKT_BASE_LEN (HCI_ACL_HDR_LEN + L2C_HDR_LEN + L2C_SIG_HDR_LEN)
|
||||
|
||||
/*! L2CAP LE SDU packet base length, including HCI header */
|
||||
#define L2C_LE_SDU_PKT_BASE_LEN (HCI_ACL_HDR_LEN + L2C_HDR_LEN + L2C_LE_SDU_HDR_LEN)
|
||||
|
||||
/*! Signaling packet parameter lengths */
|
||||
#define L2C_SIG_CONN_UPDATE_REQ_LEN 8
|
||||
#define L2C_SIG_CONN_UPDATE_RSP_LEN 2
|
||||
#define L2C_SIG_CMD_REJ_LEN 2
|
||||
#define L2C_SIG_DISCONN_REQ_LEN 4
|
||||
#define L2C_SIG_DISCONN_RSP_LEN 4
|
||||
#define L2C_SIG_LE_CONN_REQ_LEN 10
|
||||
#define L2C_SIG_LE_CONN_RSP_LEN 10
|
||||
#define L2C_SIG_FLOW_CTRL_CREDIT_LEN 4
|
||||
|
||||
/*! Connection identifiers */
|
||||
#define L2C_CID_ATT 0x0004 /*! CID for attribute protocol */
|
||||
#define L2C_CID_LE_SIGNALING 0x0005 /*! CID for LE signaling */
|
||||
#define L2C_CID_SMP 0x0006 /*! CID for security manager protocol */
|
||||
|
||||
/*! Signaling codes */
|
||||
#define L2C_SIG_CMD_REJ 0x01 /*! Comand reject */
|
||||
#define L2C_SIG_DISCONNECT_REQ 0x06 /*! Disconnect request */
|
||||
#define L2C_SIG_DISCONNECT_RSP 0x07 /*! Disconnect response */
|
||||
#define L2C_SIG_CONN_UPDATE_REQ 0x12 /*! Connection parameter update request */
|
||||
#define L2C_SIG_CONN_UPDATE_RSP 0x13 /*! Connection parameter update response */
|
||||
#define L2C_SIG_LE_CONNECT_REQ 0x14 /*! LE credit based connection request */
|
||||
#define L2C_SIG_LE_CONNECT_RSP 0x15 /*! LE credit based connection response */
|
||||
#define L2C_SIG_FLOW_CTRL_CREDIT 0x16 /*! LE flow control credit */
|
||||
|
||||
/*! Signaling response code flag */
|
||||
#define L2C_SIG_RSP_FLAG 0x01
|
||||
|
||||
/*! Command reject reason codes */
|
||||
#define L2C_REJ_NOT_UNDERSTOOD 0x0000 /*! Command not understood */
|
||||
#define L2C_REJ_MTU_EXCEEDED 0x0001 /*! Signaling MTU exceeded */
|
||||
#define L2C_REJ_INVALID_CID 0x0002 /*! Invalid CID in request */
|
||||
|
||||
/*! Connection parameter update result */
|
||||
#define L2C_CONN_PARAM_ACCEPTED 0x0000 /*! Connection parameters accepted */
|
||||
#define L2C_CONN_PARAM_REJECTED 0x0001 /*! Connection parameters rejected */
|
||||
|
||||
/*! LE connection result */
|
||||
#define L2C_CONN_SUCCESS 0x0000 /*! Connection successful */
|
||||
#define L2C_CONN_NONE 0x0001 /*! No connection result value available */
|
||||
#define L2C_CONN_FAIL_PSM 0x0002 /*! Connection refused LE_PSM not supported */
|
||||
#define L2C_CONN_FAIL_RES 0x0004 /*! Connection refused no resources available */
|
||||
#define L2C_CONN_FAIL_AUTH 0x0005 /*! Connection refused insufficient authentication */
|
||||
#define L2C_CONN_FAIL_AUTHORIZ 0x0006 /*! Connection refused insufficient authorization */
|
||||
#define L2C_CONN_FAIL_KEY_SIZE 0x0007 /*! Connection refused insufficient encryption key size */
|
||||
#define L2C_CONN_FAIL_ENC 0x0008 /*! Connection Refused insufficient encryption */
|
||||
|
||||
/*! LE connection result proprietary codes */
|
||||
#define L2C_CONN_FAIL_TIMEOUT 0xF000 /*! Request timeout */
|
||||
|
||||
/*! Signaling parameter value ranges */
|
||||
#define L2C_PSM_MIN 0x0001
|
||||
#define L2C_PSM_MAX 0x00FF
|
||||
#define L2C_CID_DYN_MIN 0x0040
|
||||
#define L2C_CID_DYN_MAX 0x007F
|
||||
#define L2C_MTU_MIN 0x0017
|
||||
#define L2C_MPS_MIN 0x0017
|
||||
#define L2C_MPS_MAX 0xFFFD
|
||||
#define L2C_CREDITS_MAX 0xFFFF
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* L2C_DEFS_H */
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file l2c_handler.h
|
||||
*
|
||||
* \brief L2CAP handler interface.
|
||||
*
|
||||
* $Date $
|
||||
* $Revision $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef L2C_HANDLER_H
|
||||
#define L2C_HANDLER_H
|
||||
|
||||
#include "wsf_os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cSlaveHandlerInit
|
||||
*
|
||||
* \brief Event handler initialization function for L2C when operating as a slave.
|
||||
*
|
||||
* \param handlerId ID for this event handler.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cSlaveHandlerInit(wsfHandlerId_t handlerId);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cSlaveHandler
|
||||
*
|
||||
* \brief The WSF event handler for L2C when operating as a slave.
|
||||
*
|
||||
* \param event Event mask.
|
||||
* \param pMsg Pointer to message.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cSlaveHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cCocHandlerInit
|
||||
*
|
||||
* \brief Event handler initialization function for L2C with connection oriented channels.
|
||||
*
|
||||
* \param handlerId ID for this event handler.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cCocHandlerInit(wsfHandlerId_t handlerId);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn L2cCocHandler
|
||||
*
|
||||
* \brief The WSF event handler for L2C with connection oriented channels.
|
||||
*
|
||||
* \param event Event mask.
|
||||
* \param pMsg Pointer to message.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void L2cCocHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* L2C_HANDLER_H */
|
||||
|
|
@ -0,0 +1,241 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file smp_api.h
|
||||
*
|
||||
* \brief SMP subsystem API.
|
||||
*
|
||||
* $Date: 2015-06-12 07:19:18 -0400 (Fri, 12 Jun 2015) $
|
||||
* $Revision: 3061 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef SMP_API_H
|
||||
#define SMP_API_H
|
||||
|
||||
#include "wsf_os.h"
|
||||
#include "smp_defs.h"
|
||||
#include "dm_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Event handler messages for SMP state machines */
|
||||
enum
|
||||
{
|
||||
SMP_MSG_API_PAIR_REQ = 1, /*! API pairing request */
|
||||
SMP_MSG_API_PAIR_RSP, /*! API pairing response */
|
||||
SMP_MSG_API_CANCEL_REQ, /*! API cancel request */
|
||||
SMP_MSG_API_AUTH_RSP, /*! API pin response */
|
||||
SMP_MSG_API_SECURITY_REQ, /*! API security request */
|
||||
SMP_MSG_CMD_PKT, /*! SMP command packet received */
|
||||
SMP_MSG_CMD_PAIRING_FAILED, /*! SMP pairing failed packet received */
|
||||
SMP_MSG_DM_ENCRYPT_CMPL, /*! Link encrypted */
|
||||
SMP_MSG_DM_ENCRYPT_FAILED, /*! Link encryption failed */
|
||||
SMP_MSG_DM_CONN_CLOSE, /*! Connection closed */
|
||||
SMP_MSG_WSF_AES_CMPL, /*! AES calculation complete */
|
||||
SMP_MSG_INT_SEND_NEXT_KEY, /*! Send next key to be distributed */
|
||||
SMP_MSG_INT_MAX_ATTEMPTS, /*! Maximum pairing attempts reached */
|
||||
SMP_MSG_INT_PAIRING_CMPL, /*! Pairing complete */
|
||||
SMP_MSG_INT_TIMEOUT, /*! Pairing protocol timeout */
|
||||
SMP_MSG_INT_LESC, /*! Pair with Secure Connections */
|
||||
SMP_MSG_INT_LEGACY, /*! Pair with Legacy Security */
|
||||
SMP_MSG_INT_JW_NC, /*! LESC Just-Works/Numeric Comparison pairing */
|
||||
SMP_MSG_INT_PASSKEY, /*! LESC Passkey pairing */
|
||||
SMP_MSG_INT_OOB, /*! LESC Out-of-Band Pairing */
|
||||
SMP_MSG_API_USER_CONFIRM, /*! User confirms valid numeric comparison */
|
||||
SMP_MSG_API_USER_KEYPRESS, /*! User keypress in passkey pairing */
|
||||
SMP_MSG_API_KEYPRESS_CMPL, /*! User keypress complete in passkey pairing */
|
||||
SMP_MSG_WSF_ECC_CMPL, /*! WSF ECC operation complete */
|
||||
SMP_MSG_INT_PK_NEXT, /*! Continue to next passkey bit */
|
||||
SMP_MSG_INT_PK_CMPL, /*! Passkey operation complete */
|
||||
SMP_MSG_WSF_CMAC_CMPL, /*! WSF CMAC operation complete */
|
||||
SMP_MSG_DH_CHECK_FAILURE, /*! WSF CMAC operation complete */
|
||||
SMP_NUM_MSGS
|
||||
};
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Configurable parameters */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t attemptTimeout; /*! 'Repeated attempts' timeout in msec */
|
||||
uint8_t ioCap; /*! I/O Capability */
|
||||
uint8_t minKeyLen; /*! Minimum encryption key length */
|
||||
uint8_t maxKeyLen; /*! Maximum encryption key length */
|
||||
uint8_t maxAttempts; /*! Attempts to trigger 'repeated attempts' timeout */
|
||||
uint8_t auth; /*! Device authentication requirements */
|
||||
} smpCfg_t;
|
||||
|
||||
/*! Data type for SMP_MSG_API_PAIR_REQ and SMP_MSG_API_PAIR_RSP */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t oob;
|
||||
uint8_t auth;
|
||||
uint8_t iKeyDist;
|
||||
uint8_t rKeyDist;
|
||||
} smpDmPair_t;
|
||||
|
||||
/*! Data type for SMP_MSG_API_AUTH_RSP */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t authData[SMP_OOB_LEN];
|
||||
uint8_t authDataLen;
|
||||
} smpDmAuthRsp_t;
|
||||
|
||||
/*! Data type for SMP_MSG_API_USER_KEYPRESS */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t keypress;
|
||||
} smpDmKeypress_t;
|
||||
|
||||
/*! Data type for SMP_MSG_API_SECURITY_REQ */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
uint8_t auth;
|
||||
} smpDmSecurityReq_t;
|
||||
|
||||
/*! Union SMP DM message data types */
|
||||
typedef union
|
||||
{
|
||||
wsfMsgHdr_t hdr;
|
||||
smpDmPair_t pair;
|
||||
smpDmAuthRsp_t authRsp;
|
||||
smpDmSecurityReq_t securityReq;
|
||||
smpDmKeypress_t keypress;
|
||||
} smpDmMsg_t;
|
||||
|
||||
/**************************************************************************************************
|
||||
Global Variables;
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Configuration pointer */
|
||||
extern smpCfg_t *pSmpCfg;
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn SmpiInit
|
||||
*
|
||||
* \brief Initialize SMP initiator role.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void SmpiInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn SmprInit
|
||||
*
|
||||
* \brief Initialize SMP responder role.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void SmprInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn SmpiScInit
|
||||
*
|
||||
* \brief Initialize SMP initiator role utilizing BTLE Secure Connections.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void SmpiScInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn SmprScInit
|
||||
*
|
||||
* \brief Initialize SMP responder role utilizing BTLE Secure Connections.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void SmprScInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn SmpNonInit
|
||||
*
|
||||
* \brief Use this SMP init function when SMP is not supported.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void SmpNonInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn SmpDmMsgSend
|
||||
*
|
||||
* \brief This function is called by DM to send a message to SMP.
|
||||
*
|
||||
* \param pMsg Pointer to message structure.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void SmpDmMsgSend(smpDmMsg_t *pMsg);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn SmpDmEncryptInd
|
||||
*
|
||||
* \brief This function is called by DM to notify SMP of encrypted link status.
|
||||
*
|
||||
* \param pMsg Pointer to HCI message structure.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void SmpDmEncryptInd(wsfMsgHdr_t *pMsg);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn SmpDmGetStk
|
||||
*
|
||||
* \brief Return the STK for the given connection.
|
||||
*
|
||||
* \param connId Connection identifier.
|
||||
* \param pSecLevel Returns the security level of pairing when STK was created.
|
||||
*
|
||||
* \return Pointer to STK or NULL if not available.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint8_t *SmpDmGetStk(dmConnId_t connId, uint8_t *pSecLevel);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* SMP_API_H */
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file smp_defs.h
|
||||
*
|
||||
* \brief Security manager constants and definitions from the Bluetooth specification.
|
||||
*
|
||||
* $Date: 2015-10-15 13:06:43 -0400 (Thu, 15 Oct 2015) $
|
||||
* $Revision: 4216 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef SMP_DEFS_H
|
||||
#define SMP_DEFS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! PDU format */
|
||||
#define SMP_HDR_LEN 1 /*! Attribute PDU header length */
|
||||
|
||||
/*! Protocol timeout */
|
||||
#define SMP_TIMEOUT 30 /*! Protocol timeout in seconds */
|
||||
|
||||
/*! Encryption key size */
|
||||
#define SMP_KEY_SIZE_MAX 16 /*! Maximum encryption key size */
|
||||
#define SMP_KEY_SIZE_MIN 7 /*! Minimum encryption key size */
|
||||
|
||||
/*! OOB and PIN data lengths in bytes */
|
||||
#define SMP_OOB_LEN 16
|
||||
#define SMP_PIN_LEN 3
|
||||
|
||||
/*! Error codes */
|
||||
#define SMP_ERR_PASSKEY_ENTRY 0x01 /*! User input of passkey failed */
|
||||
#define SMP_ERR_OOB 0x02 /*! OOB data is not available */
|
||||
#define SMP_ERR_AUTH_REQ 0x03 /*! Authentication requirements cannot be met */
|
||||
#define SMP_ERR_CONFIRM_VALUE 0x04 /*! Confirm value does not match */
|
||||
#define SMP_ERR_PAIRING_NOT_SUP 0x05 /*! Pairing is not supported by the device */
|
||||
#define SMP_ERR_ENC_KEY_SIZE 0x06 /*! Insufficient encryption key size */
|
||||
#define SMP_ERR_COMMAND_NOT_SUP 0x07 /*! Command not supported */
|
||||
#define SMP_ERR_UNSPECIFIED 0x08 /*! Unspecified reason */
|
||||
#define SMP_ERR_ATTEMPTS 0x09 /*! Repeated attempts */
|
||||
#define SMP_ERR_INVALID_PARAM 0x0A /*! Invalid parameter or command length */
|
||||
#define SMP_ERR_DH_KEY_CHECK 0x0B /*! DH Key check did not match */
|
||||
#define SMP_ERR_NUMERIC_COMPARISON 0x0C /*! Numeric comparison did not match */
|
||||
#define SMP_ERR_BR_EDR_IN_PROGRESS 0x0D /*! BR/EDR in progress */
|
||||
#define SMP_ERR_CROSS_TRANSPORT 0x0E /*! BR/EDR Cross transport key generation not allowed */
|
||||
|
||||
/*! Proprietary internal error codes */
|
||||
#define SMP_ERR_MEMORY 0xE0 /*! Out of memory */
|
||||
#define SMP_ERR_TIMEOUT 0xE1 /*! Transaction timeout */
|
||||
|
||||
/*! Command codes */
|
||||
#define SMP_CMD_PAIR_REQ 0x01 /*! Pairing Request */
|
||||
#define SMP_CMD_PAIR_RSP 0x02 /*! Pairing Response */
|
||||
#define SMP_CMD_PAIR_CNF 0x03 /*! Pairing Confirm */
|
||||
#define SMP_CMD_PAIR_RAND 0x04 /*! Pairing Random */
|
||||
#define SMP_CMD_PAIR_FAIL 0x05 /*! Pairing Failed */
|
||||
#define SMP_CMD_ENC_INFO 0x06 /*! Encryption Information */
|
||||
#define SMP_CMD_MASTER_ID 0x07 /*! Master Identification */
|
||||
#define SMP_CMD_ID_INFO 0x08 /*! Identity Information */
|
||||
#define SMP_CMD_ID_ADDR_INFO 0x09 /*! Identity Address Information */
|
||||
#define SMP_CMD_SIGN_INFO 0x0A /*! Signing Information */
|
||||
#define SMP_CMD_SECURITY_REQ 0x0B /*! Security Request */
|
||||
#define SMP_CMD_PUBLIC_KEY 0x0C /*! Public Key */
|
||||
#define SMP_CMD_DHKEY_CHECK 0x0D /*! DH Key Check */
|
||||
#define SMP_CMD_KEYPRESS 0x0E /*! User Key Press */
|
||||
#define SMP_CMD_MAX 0x0F /*! Command code maximum */
|
||||
|
||||
/*! Command packet lengths */
|
||||
#define SMP_PAIR_REQ_LEN 7
|
||||
#define SMP_PAIR_RSP_LEN 7
|
||||
#define SMP_PAIR_CNF_LEN 17
|
||||
#define SMP_PAIR_RAND_LEN 17
|
||||
#define SMP_PAIR_FAIL_LEN 2
|
||||
#define SMP_ENC_INFO_LEN 17
|
||||
#define SMP_MASTER_ID_LEN 11
|
||||
#define SMP_ID_INFO_LEN 17
|
||||
#define SMP_ID_ADDR_INFO_LEN 8
|
||||
#define SMP_SIGN_INFO_LEN 17
|
||||
#define SMP_SECURITY_REQ_LEN 2
|
||||
#define SMP_PUB_KEY_MSG_LEN (1 + 2*SMP_PUB_KEY_LEN)
|
||||
#define SMP_DHKEY_CHECK_MSG_LEN (1 + SMP_DHKEY_CHECK_LEN)
|
||||
#define SMP_KEYPRESS_MSG_LEN 2
|
||||
|
||||
/*! I/O capabilities */
|
||||
#define SMP_IO_DISP_ONLY 0x00 /*! DisplayOnly */
|
||||
#define SMP_IO_DISP_YES_NO 0x01 /*! DisplayYesNo */
|
||||
#define SMP_IO_KEY_ONLY 0x02 /*! KeyboardOnly */
|
||||
#define SMP_IO_NO_IN_NO_OUT 0x03 /*! NoInputNoOutput */
|
||||
#define SMP_IO_KEY_DISP 0x04 /*! KeyboardDisplay */
|
||||
|
||||
/*! OOB data present */
|
||||
#define SMP_OOB_DATA_NONE 0x00
|
||||
#define SMP_OOB_DATA_PRESENT 0x01
|
||||
|
||||
/*! Authentication/security properties bit mask */
|
||||
#define SMP_AUTH_BOND_MASK 0x03 /*! Mask for bonding bits */
|
||||
#define SMP_AUTH_BOND_FLAG 0x01 /*! Bonding requested */
|
||||
#define SMP_AUTH_MITM_FLAG 0x04 /*! MITM (authenticated pairing) requested */
|
||||
#define SMP_AUTH_SC_FLAG 0x08 /*! LE Secure Connections requested */
|
||||
#define SMP_AUTH_KP_FLAG 0x10 /*! Keypress notifications requested */
|
||||
|
||||
/*! Key distribution bit mask */
|
||||
#define SMP_KEY_DIST_ENC 0x01 /*! Distribute LTK */
|
||||
#define SMP_KEY_DIST_ID 0x02 /*! Distribute IRK */
|
||||
#define SMP_KEY_DIST_SIGN 0x04 /*! Distribute CSRK */
|
||||
#define SMP_KEY_DIST_MASK (SMP_KEY_DIST_ENC | SMP_KEY_DIST_ID | SMP_KEY_DIST_SIGN)
|
||||
|
||||
/*! LESC Passkey keypress types */
|
||||
#define SMP_PASSKEY_ENTRY_STARTED 0x00 /*! Passkey entry started keypress type */
|
||||
#define SMP_PASSKEY_DIGIT_ENTERED 0x01 /*! Passkey digit entered keypress type */
|
||||
#define SMP_PASSKEY_DIGIT_ERASED 0x02 /*! Passkey digit erased keypress type */
|
||||
#define SMP_PASSKEY_CLEARED 0x03 /*! Passkey cleared keypress type */
|
||||
#define SMP_PASSKEY_ENTRY_COMPLETED 0x04 /*! Passkey entry complete keypress type */
|
||||
|
||||
/*! Various parameter lengths */
|
||||
#define SMP_RAND_LEN 16
|
||||
#define SMP_CONFIRM_LEN 16
|
||||
#define SMP_KEY_LEN 16
|
||||
#define SMP_RAND8_LEN 8
|
||||
#define SMP_PRIVATE_KEY_LEN 32
|
||||
#define SMP_PUB_KEY_LEN 32
|
||||
#define SMP_DHKEY_LEN 32
|
||||
#define SMP_DHKEY_CHECK_LEN 16
|
||||
|
||||
/* CMAC Input Lengths */
|
||||
#define SMP_F4_TEXT_LEN (SMP_PUB_KEY_LEN * 2 + 1)
|
||||
#define SMP_G2_TEXT_LEN (SMP_PUB_KEY_LEN * 2 + SMP_RAND_LEN)
|
||||
#define SMP_F5_TKEY_TEXT_LEN (SMP_DHKEY_LEN)
|
||||
#define SMP_F5_TEXT_LEN (9 + 2*BDA_ADDR_LEN + 2*SMP_RAND_LEN)
|
||||
#define SMP_F6_TEXT_LEN (2*BDA_ADDR_LEN + 3*SMP_RAND_LEN + 5)
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* SMP_DEFS_H */
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file smp_handler.h
|
||||
*
|
||||
* \brief Interface to SMP event handler.
|
||||
*
|
||||
* $Date: 2012-03-29 16:24:04 -0400 (Thu, 29 Mar 2012) $
|
||||
* $Revision: 287 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef SMP_HANDLER_H
|
||||
#define SMP_HANDLER_H
|
||||
|
||||
#include "wsf_os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn SmpHandlerInit
|
||||
*
|
||||
* \brief SMP handler init function called during system initialization.
|
||||
*
|
||||
* \param handlerID WSF handler ID for SMP.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void SmpHandlerInit(wsfHandlerId_t handlerId);
|
||||
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn SmpHandler
|
||||
*
|
||||
* \brief WSF event handler for SMP.
|
||||
*
|
||||
* \param event WSF event mask.
|
||||
* \param pMsg WSF message.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void SmpHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* SMP_HANDLER_H */
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file bda.h
|
||||
*
|
||||
* \brief Bluetooth device address utilities.
|
||||
*
|
||||
* $Date: 2015-09-26 13:06:16 -0400 (Sat, 26 Sep 2015) $
|
||||
* $Revision: 4027 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef BDA_H
|
||||
#define BDA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! BD address length */
|
||||
#define BDA_ADDR_LEN 6
|
||||
|
||||
/*! BD address string length */
|
||||
#define BDA_ADDR_STR_LEN (BDA_ADDR_LEN * 2)
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! BD address data type */
|
||||
typedef uint8_t bdAddr_t[BDA_ADDR_LEN];
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn BdaCpy
|
||||
*
|
||||
* \brief Copy a BD address from source to destination.
|
||||
*
|
||||
* \param pDst Pointer to destination.
|
||||
* \param pSrc Pointer to source.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void BdaCpy(uint8_t *pDst, const uint8_t *pSrc);
|
||||
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn BdaCmp
|
||||
*
|
||||
* \brief Compare two BD addresses.
|
||||
*
|
||||
* \param pAddr1 First address.
|
||||
* \param pAddr2 Second address.
|
||||
*
|
||||
* \return TRUE if addresses match, FALSE otherwise.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
bool_t BdaCmp(const uint8_t *pAddr1, const uint8_t *pAddr2);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn BdaClr
|
||||
*
|
||||
* \brief Set a BD address to all zeros.
|
||||
*
|
||||
* \param pDst Pointer to destination.
|
||||
*
|
||||
* \return pDst + BDA_ADDR_LEN
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint8_t *BdaClr(uint8_t *pDst);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn Bda2Str
|
||||
*
|
||||
* \brief Convert a BD address to a string.
|
||||
*
|
||||
* \param pAddr Pointer to BD address.
|
||||
*
|
||||
* \return Pointer to string.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
char *Bda2Str(const uint8_t *pAddr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* BDA_H */
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file bstream.h
|
||||
*
|
||||
* \brief Byte stream to integer conversion macros.
|
||||
*
|
||||
* $Date: 2015-10-17 10:29:30 -0400 (Sat, 17 Oct 2015) $
|
||||
* $Revision: 4235 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef BSTREAM_H
|
||||
#define BSTREAM_H
|
||||
|
||||
#include "bda.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*!
|
||||
* Macros for converting a little endian byte buffer to integers.
|
||||
*/
|
||||
#define BYTES_TO_UINT16(n, p) {n = ((uint16_t)(p)[0] + ((uint16_t)(p)[1] << 8));}
|
||||
|
||||
#define BYTES_TO_UINT24(n, p) {n = ((uint16_t)(p)[0] + ((uint16_t)(p)[1] << 8) + \
|
||||
((uint16_t)(p)[2] << 16));}
|
||||
|
||||
#define BYTES_TO_UINT32(n, p) {n = ((uint32_t)(p)[0] + ((uint32_t)(p)[1] << 8) + \
|
||||
((uint32_t)(p)[2] << 16) + ((uint32_t)(p)[3] << 24));}
|
||||
|
||||
#define BYTES_TO_UINT40(n, p) {n = ((uint64_t)(p)[0] + ((uint64_t)(p)[1] << 8) + \
|
||||
((uint64_t)(p)[2] << 16) + ((uint64_t)(p)[3] << 24) + \
|
||||
((uint64_t)(p)[4] << 32));}
|
||||
|
||||
#define BYTES_TO_UINT64(n, p) {n = ((uint64_t)(p)[0] + ((uint64_t)(p)[1] << 8) + \
|
||||
((uint64_t)(p)[2] << 16) + ((uint64_t)(p)[3] << 24) + \
|
||||
((uint64_t)(p)[4] << 32) + ((uint64_t)(p)[5] << 40) + \
|
||||
((uint64_t)(p)[6] << 48) + ((uint64_t)(p)[7] << 56));}
|
||||
|
||||
/*!
|
||||
* Macros for converting little endian integers to array of bytes
|
||||
*/
|
||||
#define UINT16_TO_BYTES(n) ((uint8_t) (n)), ((uint8_t)((n) >> 8))
|
||||
|
||||
/*!
|
||||
* Macros for converting little endian integers to single bytes
|
||||
*/
|
||||
#define UINT16_TO_BYTE0(n) ((uint8_t) (n))
|
||||
#define UINT16_TO_BYTE1(n) ((uint8_t) ((n) >> 8))
|
||||
|
||||
#define UINT32_TO_BYTE0(n) ((uint8_t) (n))
|
||||
#define UINT32_TO_BYTE1(n) ((uint8_t) ((n) >> 8))
|
||||
#define UINT32_TO_BYTE2(n) ((uint8_t) ((n) >> 16))
|
||||
#define UINT32_TO_BYTE3(n) ((uint8_t) ((n) >> 24))
|
||||
|
||||
/*!
|
||||
* Macros for converting a little endian byte stream to integers, with increment.
|
||||
*/
|
||||
#define BSTREAM_TO_INT8(n, p) {n = (int8_t)(*(p)++);}
|
||||
#define BSTREAM_TO_UINT8(n, p) {n = (uint8_t)(*(p)++);}
|
||||
#define BSTREAM_TO_UINT16(n, p) {BYTES_TO_UINT16(n, p); p += 2;}
|
||||
#define BSTREAM_TO_UINT24(n, p) {BYTES_TO_UINT24(n, p); p += 3;}
|
||||
#define BSTREAM_TO_UINT32(n, p) {BYTES_TO_UINT32(n, p); p += 4;}
|
||||
#define BSTREAM_TO_UINT40(n, p) {BYTES_TO_UINT40(n, p); p += 5;}
|
||||
#define BSTREAM_TO_UINT64(n, p) {n = BstreamToUint64(p); p += 8;}
|
||||
#define BSTREAM_TO_BDA(bda, p) {BdaCpy(bda, p); p += BDA_ADDR_LEN;}
|
||||
#define BSTREAM_TO_BDA64(bda, p) {bda = BstreamToBda64(p); p += BDA_ADDR_LEN;}
|
||||
|
||||
/*!
|
||||
* Macros for converting integers to a little endian byte stream, with increment.
|
||||
*/
|
||||
#define UINT8_TO_BSTREAM(p, n) {*(p)++ = (uint8_t)(n);}
|
||||
#define UINT16_TO_BSTREAM(p, n) {*(p)++ = (uint8_t)(n); *(p)++ = (uint8_t)((n) >> 8);}
|
||||
#define UINT24_TO_BSTREAM(p, n) {*(p)++ = (uint8_t)(n); *(p)++ = (uint8_t)((n) >> 8); \
|
||||
*(p)++ = (uint8_t)((n) >> 16);}
|
||||
#define UINT32_TO_BSTREAM(p, n) {*(p)++ = (uint8_t)(n); *(p)++ = (uint8_t)((n) >> 8); \
|
||||
*(p)++ = (uint8_t)((n) >> 16); *(p)++ = (uint8_t)((n) >> 24);}
|
||||
#define UINT40_TO_BSTREAM(p, n) {*(p)++ = (uint8_t)(n); *(p)++ = (uint8_t)((n) >> 8); \
|
||||
*(p)++ = (uint8_t)((n) >> 16); *(p)++ = (uint8_t)((n) >> 24); \
|
||||
*(p)++ = (uint8_t)((n) >> 32);}
|
||||
#define UINT64_TO_BSTREAM(p, n) {Uint64ToBstream(p, n); p += sizeof(uint64_t);}
|
||||
#define BDA_TO_BSTREAM(p, bda) {BdaCpy(p, bda); p += BDA_ADDR_LEN;}
|
||||
#define BDA64_TO_BSTREAM(p, bda) {Bda64ToBstream(p, bda); p += BDA_ADDR_LEN;}
|
||||
|
||||
/*!
|
||||
* Macros for converting integers to a little endian byte stream, without increment.
|
||||
*/
|
||||
#define UINT16_TO_BUF(p, n) {(p)[0] = (uint8_t)(n); (p)[1] = (uint8_t)((n) >> 8);}
|
||||
#define UINT32_TO_BUF(p, n) {(p)[0] = (uint8_t)(n); (p)[1] = (uint8_t)((n) >> 8); \
|
||||
(p)[2] = (uint8_t)((n) >> 16); (p)[3] = (uint8_t)((n) >> 24);}
|
||||
|
||||
/*!
|
||||
* Macros for comparing a little endian byte buffer to integers.
|
||||
*/
|
||||
#define BYTES_UINT16_CMP(p, n) ((p)[1] == UINT16_TO_BYTE1(n) && (p)[0] == UINT16_TO_BYTE0(n))
|
||||
|
||||
/*!
|
||||
* Macros for IEEE FLOAT type: exponent = byte 3, mantissa = bytes 2-0
|
||||
*/
|
||||
#define FLT_TO_UINT32(m, e) ((m) | ((int32_t)(e) << 24))
|
||||
#define UINT32_TO_FLT(m, e, n) {m = UINT32_TO_FLT_M(n); e = UINT32_TO_FLT_E(n);}
|
||||
#define UINT32_TO_FLT_M(n) ((((n) & 0x00FFFFFF) >= 0x00800000) ? \
|
||||
((int32_t)(((n) | 0xFF000000))) : ((int32_t)((n) & 0x00FFFFFF)))
|
||||
#define UINT32_TO_FLT_E(n) ((int8_t)(n >> 24))
|
||||
/*!
|
||||
* Macros for IEEE SFLOAT type: exponent = bits 15-12, mantissa = bits 11-0
|
||||
*/
|
||||
#define SFLT_TO_UINT16(m, e) ((m) | ((int16_t)(e) << 12))
|
||||
#define UINT16_TO_SFLT(m, e, n) {m = UINT16_TO_SFLT_M(n); e = UINT16_TO_SFLT_E(n);}
|
||||
#define UINT16_TO_SFLT_M(n) ((((n) & 0x0FFF) >= 0x0800) ? \
|
||||
((int16_t)(((n) | 0xF000))) : ((int16_t)((n) & 0x0FFF)))
|
||||
#define UINT16_TO_SFLT_E(n) (((n >> 12) >= 0x0008) ? \
|
||||
((int8_t)(((n >> 12) | 0xF0))) : ((int8_t)(n >> 12)))
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
uint64_t BstreamToBda64(const uint8_t *p);
|
||||
uint64_t BstreamToUint64(const uint8_t *p);
|
||||
void Bda64ToBstream(uint8_t *p, uint64_t bda);
|
||||
void Uint64ToBstream(uint8_t *p, uint64_t n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* BSTREAM_H */
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file utils.h
|
||||
*
|
||||
* \brief Utility functions.
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
|
||||
#ifndef __UTILS_H
|
||||
#define __UTILS_H
|
||||
|
||||
/***************************************************************************************************
|
||||
** INCLUDES
|
||||
***************************************************************************************************/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "wsf_types.h"
|
||||
|
||||
#if defined(__GNUC__) || defined(__CC_ARM)
|
||||
#define PRINTF_ATTRIBUTE(a, b) __attribute__((format(printf, a, b)))
|
||||
#else
|
||||
#define PRINTF_ATTRIBUTE(a, b)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************************************************************************************
|
||||
** DEFINES
|
||||
***************************************************************************************************/
|
||||
|
||||
#define UTIL_MAC_ADDR_LEN 6
|
||||
|
||||
/*------------------------------------------------------------------------------------------------*/
|
||||
|
||||
#define UTIL_IS_DIGIT(c) ((c >= '0') && (c <= '9'))
|
||||
#define UTIL_IS_XDIGIT(c) (((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) || \
|
||||
((c >= 'A') && (c <= 'F')))
|
||||
|
||||
/*------------------------------------------------------------------------------------------------*/
|
||||
|
||||
#define UTIL_DIGIT_TO_INT(c) (((c >= '0') && (c <= '9')) ? (uint8_t)(c - '0') : 0u)
|
||||
#define UTIL_XDIGIT_TO_INT(c) (((c >= '0') && (c <= '9')) ? (uint8_t)(c - '0') : \
|
||||
((c >= 'a') && (c <= 'f')) ? (uint8_t)(c - 'a' + 10u) : \
|
||||
((c >= 'A') && (c <= 'F')) ? (uint8_t)(c - 'A' + 10u) : 0u)
|
||||
|
||||
/***************************************************************************************************
|
||||
** FUNCTIONS
|
||||
***************************************************************************************************/
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Util_VSNPrintf()
|
||||
**
|
||||
** DESCRIPTION: Print formatted output to string.
|
||||
**
|
||||
** PARAMETERS: s Pointer to string that will receive outoput
|
||||
** size Maximum number of characters to store in s
|
||||
** format Pointer to format string
|
||||
** ap Variable arguments
|
||||
**
|
||||
** RETURNS: Number of characters stored in s
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
int Util_VSNPrintf(char *s, size_t size, const char *format, va_list ap) PRINTF_ATTRIBUTE(3, 0);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Util_SNPrintf()
|
||||
**
|
||||
** DESCRIPTION: Print formatted output to string.
|
||||
**
|
||||
** PARAMETERS: s Pointer to string that will receive outoput
|
||||
** size Maximum number of characters to store in s
|
||||
** format Pointer to format string
|
||||
** ap Variable arguments
|
||||
**
|
||||
** RETURNS: Number of characters stored in s
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
int Util_SNPrintf (char *s, size_t size, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Util_ParseMacAddr()
|
||||
**
|
||||
** DESCRIPTION: Parse MAC address from string.
|
||||
**
|
||||
** PARAMETERS: s Pointer to string to parse
|
||||
** addr Pointer to buffer that will receive MAC address
|
||||
**
|
||||
** RETURNS: Number of characters consumed from string
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
int32_t Util_ParseMacAddr(const char *s, uint8_t (*addr)[UTIL_MAC_ADDR_LEN]);
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------
|
||||
** Util_ParseUInt()
|
||||
**
|
||||
** DESCRIPTION: Parse unsigned integer from string.
|
||||
**
|
||||
** PARAMETERS: s Pointer to string to parse
|
||||
** u Pointer to variable that will receive integer
|
||||
** base Base of integer (between 2 and 36, inclusive) or 0, for automatic detection
|
||||
**
|
||||
** RETURNS: Number of characters consumed from string
|
||||
**------------------------------------------------------------------------------------------------*/
|
||||
int32_t Util_ParseUInt(const char *s, uint32_t *u, uint32_t base);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __UTILS_H */
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file wsf_assert.h
|
||||
*
|
||||
* \brief Assert macro.
|
||||
*
|
||||
* $Date: 2015-10-05 12:54:16 -0400 (Mon, 05 Oct 2015) $
|
||||
* $Revision: 4112 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef WSF_ASSERT_H
|
||||
#define WSF_ASSERT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Prototypes
|
||||
**************************************************************************************************/
|
||||
|
||||
#if WSF_TOKEN_ENABLED == TRUE
|
||||
void WsfAssert(uint16_t modId, uint16_t line);
|
||||
#else
|
||||
void WsfAssert(const char *pFile, uint16_t line);
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \def WSF_ASSERT
|
||||
*
|
||||
* \brief Run-time assert macro. The assert executes when the expression is FALSE.
|
||||
*
|
||||
* \param expr Boolean expression to be tested.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#if WSF_ASSERT_ENABLED == TRUE
|
||||
#if WSF_TOKEN_ENABLED == TRUE
|
||||
#define WSF_ASSERT(expr) if (!(expr)) {WsfAssert(MODULE_ID, (uint16_t) __LINE__);}
|
||||
#else
|
||||
#define WSF_ASSERT(expr) if (!(expr)) {WsfAssert(__FILE__, (uint16_t) __LINE__);}
|
||||
#endif
|
||||
#else
|
||||
#define WSF_ASSERT(expr)
|
||||
#endif
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \def WSF_CT_ASSERT
|
||||
*
|
||||
* \brief Compile-time assert macro. This macro causes a compiler error when the
|
||||
* expression is FALSE. Note that this macro is generally used at file scope to
|
||||
* test constant expressions. Errors may result of it is used in executing code.
|
||||
*
|
||||
* \param expr Boolean expression to be tested.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#define WSF_CT_ASSERT(expr) extern char wsf_ct_assert[(expr) ? 1 : -1]
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* WSF_ASSERT_H */
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file wsf_os_int.h
|
||||
*
|
||||
* \brief Software foundation OS platform-specific interface file.
|
||||
*
|
||||
* $Date: 2012-10-01 16:53:07 -0400 (Mon, 01 Oct 2012) $
|
||||
* $Revision: 357 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef WSF_OS_INT_H
|
||||
#define WSF_OS_INT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/* Task events */
|
||||
#define WSF_MSG_QUEUE_EVENT 0x01 /* Message queued for event handler */
|
||||
#define WSF_TIMER_EVENT 0x02 /* Timer expired for event handler */
|
||||
#define WSF_HANDLER_EVENT 0x04 /* Event set for event handler */
|
||||
|
||||
/* Derive task from handler ID */
|
||||
#define WSF_TASK_FROM_ID(handlerID) (((handlerID) >> 4) & 0x0F)
|
||||
|
||||
/* Derive handler from handler ID */
|
||||
#define WSF_HANDLER_FROM_ID(handlerID) ((handlerID) & 0x0F)
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/* Event handler ID data type */
|
||||
typedef uint8_t wsfHandlerId_t;
|
||||
|
||||
/* Event handler event mask data type */
|
||||
typedef uint8_t wsfEventMask_t;
|
||||
|
||||
/* Task ID data type */
|
||||
typedef wsfHandlerId_t wsfTaskId_t;
|
||||
|
||||
/* Task event mask data type */
|
||||
typedef uint8_t wsfTaskEvent_t;
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn wsfOsReadyToSleep
|
||||
*
|
||||
* \brief Check if WSF is ready to sleep.
|
||||
*
|
||||
* \param None.
|
||||
*
|
||||
* \return Return TRUE if there are no pending WSF task events set, FALSE otherwise.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
bool_t wsfOsReadyToSleep(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn wsfOsDispatcher
|
||||
*
|
||||
* \brief Event dispatched. Designed to be called repeatedly from infinite loop.
|
||||
*
|
||||
* \param None.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void wsfOsDispatcher(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfOsShutdown
|
||||
*
|
||||
* \brief Shutdown OS.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfOsShutdown(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* WSF_OS_INT_H */
|
||||
|
|
@ -0,0 +1,219 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file wsf_trace.h
|
||||
*
|
||||
* \brief Trace message interface.
|
||||
*
|
||||
* $Date: 2015-10-02 20:12:32 -0400 (Fri, 02 Oct 2015) $
|
||||
* $Revision: 4099 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef WSF_TRACE_H
|
||||
#define WSF_TRACE_H
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! \brief Token event handler. */
|
||||
typedef void (*WsfTokenHandler_t)(void);
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Prototypes
|
||||
**************************************************************************************************/
|
||||
|
||||
void WsfTrace(const char *pStr, ...);
|
||||
void WsfToken(uint32_t tok, uint32_t var);
|
||||
|
||||
/* Token management. */
|
||||
bool_t WsfTokenService(void);
|
||||
uint8_t WsfTokenIOWrite(uint8_t *pBuf, uint8_t len);
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
#ifdef TOKEN_GENERATION
|
||||
|
||||
#define WSF_TOKEN(subsys, stat, msg) \
|
||||
__WSF_TOKEN_DEFINE__( \
|
||||
/* token: */ MODULE_ID, __LINE__, \
|
||||
/* origin: */ __FILE__, subsys, \
|
||||
/* message: */ stat, msg)
|
||||
|
||||
#define WSF_TRACE0(subsys, stat, msg) WSF_TOKEN(subsys, stat, msg)
|
||||
#define WSF_TRACE1(subsys, stat, msg, var1) WSF_TOKEN(subsys, stat, msg)
|
||||
#define WSF_TRACE2(subsys, stat, msg, var1, var2) WSF_TOKEN(subsys, stat, msg)
|
||||
#define WSF_TRACE3(subsys, stat, msg, var1, var2, var3) WSF_TOKEN(subsys, stat, msg)
|
||||
|
||||
#elif WSF_TRACE_ENABLED == TRUE
|
||||
|
||||
#define WSF_TRACE0(subsys, stat, msg) WsfTrace(msg)
|
||||
#define WSF_TRACE1(subsys, stat, msg, var1) WsfTrace(msg, var1)
|
||||
#define WSF_TRACE2(subsys, stat, msg, var1, var2) WsfTrace(msg, var1, var2)
|
||||
#define WSF_TRACE3(subsys, stat, msg, var1, var2, var3) WsfTrace(msg, var1, var2, var3)
|
||||
|
||||
#elif WSF_TOKEN_ENABLED == TRUE
|
||||
|
||||
#define WSF_TRACE0(subsys, stat, msg) \
|
||||
WsfToken(((__LINE__ & 0xFFF) << 16) | MODULE_ID, 0)
|
||||
#define WSF_TRACE1(subsys, stat, msg, var1) \
|
||||
WsfToken(((__LINE__ & 0xFFF) << 16) | MODULE_ID, (uint32_t)(var1))
|
||||
#define WSF_TRACE2(subsys, stat, msg, var1, var2) \
|
||||
WsfToken(((__LINE__ & 0xFFF) << 16) | MODULE_ID, (uint32_t)(((var2) << 16) | ((var1) & 0xFFFF)))
|
||||
#define WSF_TRACE3(subsys, stat, msg, var1, var2, var3) \
|
||||
WsfToken(((__LINE__ & 0xFFF) << 16) | MODULE_ID, (uint32_t)((((var3) & 0xFFFF) << 16) | (((var2) & 0xFF) << 8) | ((var1) & 0xFF)))
|
||||
|
||||
#else
|
||||
|
||||
#define WSF_TRACE0(subsys, stat, msg)
|
||||
#define WSF_TRACE1(subsys, stat, msg, var1)
|
||||
#define WSF_TRACE2(subsys, stat, msg, var1, var2)
|
||||
#define WSF_TRACE3(subsys, stat, msg, var1, var2, var3)
|
||||
|
||||
#endif
|
||||
|
||||
#define WSF_TRACE_INFO0(msg)
|
||||
#define WSF_TRACE_INFO1(msg, var1)
|
||||
#define WSF_TRACE_INFO2(msg, var1, var2)
|
||||
#define WSF_TRACE_INFO3(msg, var1, var2, var3)
|
||||
#define WSF_TRACE_WARN0(msg) WSF_TRACE0("WSF", "WARN", msg)
|
||||
#define WSF_TRACE_WARN1(msg, var1) WSF_TRACE1("WSF", "WARN", msg, var1)
|
||||
#define WSF_TRACE_WARN2(msg, var1, var2) WSF_TRACE2("WSF", "WARN", msg, var1, var2)
|
||||
#define WSF_TRACE_WARN3(msg, var1, var2, var3) WSF_TRACE3("WSF", "WARN", msg, var1, var2, var3)
|
||||
#define WSF_TRACE_ERR0(msg) WSF_TRACE0("WSF", "ERR", msg)
|
||||
#define WSF_TRACE_ERR1(msg, var1) WSF_TRACE1("WSF", "ERR", msg, var1)
|
||||
#define WSF_TRACE_ERR2(msg, var1, var2) WSF_TRACE2("WSF", "ERR", msg, var1, var2)
|
||||
#define WSF_TRACE_ERR3(msg, var1, var2, var3) WSF_TRACE3("WSF", "ERR", msg, var1, var2, var3)
|
||||
#define WSF_TRACE_ALLOC0(msg)
|
||||
#define WSF_TRACE_ALLOC1(msg, var1)
|
||||
#define WSF_TRACE_ALLOC2(msg, var1, var2)
|
||||
#define WSF_TRACE_ALLOC3(msg, var1, var2, var3)
|
||||
#define WSF_TRACE_FREE0(msg)
|
||||
#define WSF_TRACE_FREE1(msg, var1)
|
||||
#define WSF_TRACE_FREE2(msg, var1, var2)
|
||||
#define WSF_TRACE_FREE3(msg, var1, var2, var3)
|
||||
#define WSF_TRACE_MSG0(msg)
|
||||
#define WSF_TRACE_MSG1(msg, var1)
|
||||
#define WSF_TRACE_MSG2(msg, var1, var2)
|
||||
#define WSF_TRACE_MSG3(msg, var1, var2, var3)
|
||||
|
||||
#define HCI_TRACE_INFO0(msg) WSF_TRACE0("HCI", "INFO", msg)
|
||||
#define HCI_TRACE_INFO1(msg, var1) WSF_TRACE1("HCI", "INFO", msg, var1)
|
||||
#define HCI_TRACE_INFO2(msg, var1, var2) WSF_TRACE2("HCI", "INFO", msg, var1, var2)
|
||||
#define HCI_TRACE_INFO3(msg, var1, var2, var3) WSF_TRACE3("HCI", "INFO", msg, var1, var2, var3)
|
||||
#define HCI_TRACE_WARN0(msg) WSF_TRACE0("HCI", "WARN", msg)
|
||||
#define HCI_TRACE_WARN1(msg, var1) WSF_TRACE1("HCI", "WARN", msg, var1)
|
||||
#define HCI_TRACE_WARN2(msg, var1, var2) WSF_TRACE2("HCI", "WARN", msg, var1, var2)
|
||||
#define HCI_TRACE_WARN3(msg, var1, var2, var3) WSF_TRACE3("HCI", "WARN", msg, var1, var2, var3)
|
||||
#define HCI_TRACE_ERR0(msg) WSF_TRACE0("HCI", "ERR", msg)
|
||||
#define HCI_TRACE_ERR1(msg, var1) WSF_TRACE1("HCI", "ERR", msg, var1)
|
||||
#define HCI_TRACE_ERR2(msg, var1, var2) WSF_TRACE2("HCI", "ERR", msg, var1, var2)
|
||||
#define HCI_TRACE_ERR3(msg, var1, var2, var3) WSF_TRACE3("HCI", "ERR", msg, var1, var2, var3)
|
||||
|
||||
#define HCI_PDUMP_CMD(len, pBuf)
|
||||
#define HCI_PDUMP_EVT(len, pBuf)
|
||||
#define HCI_PDUMP_TX_ACL(len, pBuf)
|
||||
#define HCI_PDUMP_RX_ACL(len, pBuf)
|
||||
|
||||
#define DM_TRACE_INFO0(msg) WSF_TRACE0("DM", "INFO", msg)
|
||||
#define DM_TRACE_INFO1(msg, var1) WSF_TRACE1("DM", "INFO", msg, var1)
|
||||
#define DM_TRACE_INFO2(msg, var1, var2) WSF_TRACE2("DM", "INFO", msg, var1, var2)
|
||||
#define DM_TRACE_INFO3(msg, var1, var2, var3) WSF_TRACE3("DM", "INFO", msg, var1, var2, var3)
|
||||
#define DM_TRACE_WARN0(msg) WSF_TRACE0("DM", "WARN", msg)
|
||||
#define DM_TRACE_WARN1(msg, var1) WSF_TRACE1("DM", "WARN", msg, var1)
|
||||
#define DM_TRACE_WARN2(msg, var1, var2) WSF_TRACE2("DM", "WARN", msg, var1, var2)
|
||||
#define DM_TRACE_WARN3(msg, var1, var2, var3) WSF_TRACE3("DM", "WARN", msg, var1, var2, var3)
|
||||
#define DM_TRACE_ERR0(msg) WSF_TRACE0("DM", "ERR", msg)
|
||||
#define DM_TRACE_ERR1(msg, var1) WSF_TRACE1("DM", "ERR", msg, var1)
|
||||
#define DM_TRACE_ERR2(msg, var1, var2) WSF_TRACE2("DM", "ERR", msg, var1, var2)
|
||||
#define DM_TRACE_ERR3(msg, var1, var2, var3) WSF_TRACE3("DM", "ERR", msg, var1, var2, var3)
|
||||
#define DM_TRACE_ALLOC0(msg) WSF_TRACE0("DM", "ALLOC", msg)
|
||||
#define DM_TRACE_ALLOC1(msg, var1) WSF_TRACE1("DM", "ALLOC", msg, var1)
|
||||
#define DM_TRACE_ALLOC2(msg, var1, var2) WSF_TRACE2("DM", "ALLOC", msg, var1, var2)
|
||||
#define DM_TRACE_ALLOC3(msg, var1, var2, var3) WSF_TRACE3("DM", "ALLOC", msg, var1, var2, var3)
|
||||
#define DM_TRACE_FREE0(msg) WSF_TRACE0("DM", "FREE", msg)
|
||||
#define DM_TRACE_FREE1(msg, var1) WSF_TRACE1("DM", "FREE", msg, var1)
|
||||
#define DM_TRACE_FREE2(msg, var1, var2) WSF_TRACE2("DM", "FREE", msg, var1, var2)
|
||||
#define DM_TRACE_FREE3(msg, var1, var2, var3) WSF_TRACE3("DM", "FREE", msg, var1, var2, var3)
|
||||
|
||||
#define L2C_TRACE_INFO0(msg) WSF_TRACE0("L2C", "INFO", msg)
|
||||
#define L2C_TRACE_INFO1(msg, var1) WSF_TRACE1("L2C", "INFO", msg, var1)
|
||||
#define L2C_TRACE_INFO2(msg, var1, var2) WSF_TRACE2("L2C", "INFO", msg, var1, var2)
|
||||
#define L2C_TRACE_INFO3(msg, var1, var2, var3) WSF_TRACE3("L2C", "INFO", msg, var1, var2, var3)
|
||||
#define L2C_TRACE_WARN0(msg) WSF_TRACE0("L2C", "WARN", msg)
|
||||
#define L2C_TRACE_WARN1(msg, var1) WSF_TRACE1("L2C", "WARN", msg, var1)
|
||||
#define L2C_TRACE_WARN2(msg, var1, var2) WSF_TRACE2("L2C", "WARN", msg, var1, var2)
|
||||
#define L2C_TRACE_WARN3(msg, var1, var2, var3) WSF_TRACE3("L2C", "WARN", msg, var1, var2, var3)
|
||||
#define L2C_TRACE_ERR0(msg) WSF_TRACE0("L2C", "ERR", msg)
|
||||
#define L2C_TRACE_ERR1(msg, var1) WSF_TRACE1("L2C", "ERR", msg, var1)
|
||||
#define L2C_TRACE_ERR2(msg, var1, var2) WSF_TRACE2("L2C", "ERR", msg, var1, var2)
|
||||
#define L2C_TRACE_ERR3(msg, var1, var2, var3) WSF_TRACE3("L2C", "ERR", msg, var1, var2, var3)
|
||||
|
||||
#define ATT_TRACE_INFO0(msg) WSF_TRACE0("ATT", "INFO", msg)
|
||||
#define ATT_TRACE_INFO1(msg, var1) WSF_TRACE1("ATT", "INFO", msg, var1)
|
||||
#define ATT_TRACE_INFO2(msg, var1, var2) WSF_TRACE2("ATT", "INFO", msg, var1, var2)
|
||||
#define ATT_TRACE_INFO3(msg, var1, var2, var3) WSF_TRACE3("ATT", "INFO", msg, var1, var2, var3)
|
||||
#define ATT_TRACE_WARN0(msg) WSF_TRACE0("ATT", "WARN", msg)
|
||||
#define ATT_TRACE_WARN1(msg, var1) WSF_TRACE1("ATT", "WARN", msg, var1)
|
||||
#define ATT_TRACE_WARN2(msg, var1, var2) WSF_TRACE2("ATT", "WARN", msg, var1, var2)
|
||||
#define ATT_TRACE_WARN3(msg, var1, var2, var3) WSF_TRACE3("ATT", "WARN", msg, var1, var2, var3)
|
||||
#define ATT_TRACE_ERR0(msg) WSF_TRACE0("ATT", "ERR", msg)
|
||||
#define ATT_TRACE_ERR1(msg, var1) WSF_TRACE1("ATT", "ERR", msg, var1)
|
||||
#define ATT_TRACE_ERR2(msg, var1, var2) WSF_TRACE2("ATT", "ERR", msg, var1, var2)
|
||||
#define ATT_TRACE_ERR3(msg, var1, var2, var3) WSF_TRACE3("ATT", "ERR", msg, var1, var2, var3)
|
||||
|
||||
#define SMP_TRACE_INFO0(msg) WSF_TRACE0("SMP", "INFO", msg)
|
||||
#define SMP_TRACE_INFO1(msg, var1) WSF_TRACE1("SMP", "INFO", msg, var1)
|
||||
#define SMP_TRACE_INFO2(msg, var1, var2) WSF_TRACE2("SMP", "INFO", msg, var1, var2)
|
||||
#define SMP_TRACE_INFO3(msg, var1, var2, var3) WSF_TRACE3("SMP", "INFO", msg, var1, var2, var3)
|
||||
#define SMP_TRACE_WARN0(msg) WSF_TRACE0("SMP", "WARN", msg)
|
||||
#define SMP_TRACE_WARN1(msg, var1) WSF_TRACE1("SMP", "WARN", msg, var1)
|
||||
#define SMP_TRACE_WARN2(msg, var1, var2) WSF_TRACE2("SMP", "WARN", msg, var1, var2)
|
||||
#define SMP_TRACE_WARN3(msg, var1, var2, var3) WSF_TRACE3("SMP", "WARN", msg, var1, var2, var3)
|
||||
#define SMP_TRACE_ERR0(msg) WSF_TRACE0("SMP", "ERR", msg)
|
||||
#define SMP_TRACE_ERR1(msg, var1) WSF_TRACE1("SMP", "ERR", msg, var1)
|
||||
#define SMP_TRACE_ERR2(msg, var1, var2) WSF_TRACE2("SMP", "ERR", msg, var1, var2)
|
||||
#define SMP_TRACE_ERR3(msg, var1, var2, var3) WSF_TRACE3("SMP", "ERR", msg, var1, var2, var3)
|
||||
|
||||
#define APP_TRACE_INFO0(msg) WSF_TRACE0("APP", "INFO", msg)
|
||||
#define APP_TRACE_INFO1(msg, var1) WSF_TRACE1("APP", "INFO", msg, var1)
|
||||
#define APP_TRACE_INFO2(msg, var1, var2) WSF_TRACE2("APP", "INFO", msg, var1, var2)
|
||||
#define APP_TRACE_INFO3(msg, var1, var2, var3) WSF_TRACE3("APP", "INFO", msg, var1, var2, var3)
|
||||
#define APP_TRACE_WARN0(msg) WSF_TRACE0("APP", "WARN", msg)
|
||||
#define APP_TRACE_WARN1(msg, var1) WSF_TRACE1("APP", "WARN", msg, var1)
|
||||
#define APP_TRACE_WARN2(msg, var1, var2) WSF_TRACE2("APP", "WARN", msg, var1, var2)
|
||||
#define APP_TRACE_WARN3(msg, var1, var2, var3) WSF_TRACE3("APP", "WARN", msg, var1, var2, var3)
|
||||
#define APP_TRACE_ERR0(msg) WSF_TRACE0("APP", "ERR", msg)
|
||||
#define APP_TRACE_ERR1(msg, var1) WSF_TRACE1("APP", "ERR", msg, var1)
|
||||
#define APP_TRACE_ERR2(msg, var1, var2) WSF_TRACE2("APP", "ERR", msg, var1, var2)
|
||||
#define APP_TRACE_ERR3(msg, var1, var2, var3) WSF_TRACE3("APP", "ERR", msg, var1, var2, var3)
|
||||
|
||||
#define LL_TRACE_INFO0(msg) WSF_TRACE0("LL", "INFO", msg)
|
||||
#define LL_TRACE_INFO1(msg, var1) WSF_TRACE1("LL", "INFO", msg, var1)
|
||||
#define LL_TRACE_INFO2(msg, var1, var2) WSF_TRACE2("LL", "INFO", msg, var1, var2)
|
||||
#define LL_TRACE_INFO3(msg, var1, var2, var3) WSF_TRACE3("LL", "INFO", msg, var1, var2, var3)
|
||||
#define LL_TRACE_WARN0(msg) WSF_TRACE0("LL", "WARN", msg)
|
||||
#define LL_TRACE_WARN1(msg, var1) WSF_TRACE1("LL", "WARN", msg, var1)
|
||||
#define LL_TRACE_WARN2(msg, var1, var2) WSF_TRACE2("LL", "WARN", msg, var1, var2)
|
||||
#define LL_TRACE_WARN3(msg, var1, var2, var3) WSF_TRACE3("LL", "WARN", msg, var1, var2, var3)
|
||||
#define LL_TRACE_ERR0(msg) WSF_TRACE0("LL", "ERR", msg)
|
||||
#define LL_TRACE_ERR1(msg, var1) WSF_TRACE1("LL", "ERR", msg, var1)
|
||||
#define LL_TRACE_ERR2(msg, var1, var2) WSF_TRACE2("LL", "ERR", msg, var1, var2)
|
||||
#define LL_TRACE_ERR3(msg, var1, var2, var3) WSF_TRACE3("LL", "ERR", msg, var1, var2, var3)
|
||||
|
||||
#endif /* WSF_TRACE_H */
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file wsf_types.h
|
||||
*
|
||||
* \brief Platform-independent data types.
|
||||
*
|
||||
* $Date: 2015-05-14 17:58:23 -0400 (Thu, 14 May 2015) $
|
||||
* $Revision: 2837 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef WSF_TYPES_H
|
||||
#define WSF_TYPES_H
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/* Integer data types */
|
||||
#if ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) && \
|
||||
(!defined(__ICC8051__) || (__ICC8051__ == 0)))
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#if 0
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed long int32_t;
|
||||
typedef unsigned long uint32_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
/* Boolean data type */
|
||||
typedef uint8_t bool_t;
|
||||
|
||||
#endif /* WSF_TYPES_H */
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file wsf_buf.h
|
||||
*
|
||||
* \brief Buffer pool service.
|
||||
*
|
||||
* $Date: 2015-09-05 12:01:07 -0400 (Sat, 05 Sep 2015) $
|
||||
* $Revision: 3793 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef WSF_BUF_H
|
||||
#define WSF_BUF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Length of the buffer statistics array */
|
||||
#define WSF_BUF_STATS_MAX_LEN 128
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Buffer pool descriptor structure */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t len; /*! length of buffers in pool */
|
||||
uint8_t num; /*! number of buffers in pool */
|
||||
} wsfBufPoolDesc_t;
|
||||
|
||||
/*! Pool statistics */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bufSize; /*!< Pool buffer size. */
|
||||
uint8_t numBuf; /*!< Total number of buffers. */
|
||||
uint8_t numAlloc; /*!< Number of outstanding allocations. */
|
||||
uint8_t maxAlloc; /*!< High allocation watermark. */
|
||||
} WsfBufPoolStat_t;
|
||||
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfBufInit
|
||||
*
|
||||
* \brief Initialize the buffer pool service. This function should only be called once
|
||||
* upon system initialization.
|
||||
*
|
||||
* \param bufMemLen Length in bytes of memory pointed to by pBufMem.
|
||||
* \param pBufMem Memory in which to store the pools used by the buffer pool service.
|
||||
* \param numPools Number of buffer pools.
|
||||
* \param pDesc Array of buffer pool descriptors, one for each pool.
|
||||
*
|
||||
* \return Amount of pBufMem used or 0 for failures.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint16_t WsfBufInit(uint16_t bufMemLen, uint8_t *pBufMem, uint8_t numPools, wsfBufPoolDesc_t *pDesc);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfBufAlloc
|
||||
*
|
||||
* \brief Allocate a buffer.
|
||||
*
|
||||
* \param len Length of buffer to allocate.
|
||||
*
|
||||
* \return Pointer to allocated buffer or NULL if allocation fails.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void *WsfBufAlloc(uint16_t len);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfBufFree
|
||||
*
|
||||
* \brief Free a buffer.
|
||||
*
|
||||
* \param pBuf Buffer to free.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfBufFree(void *pBuf);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfBufGetMaxAlloc
|
||||
*
|
||||
* \brief Diagnostic function to get maximum allocated buffers from a pool.
|
||||
*
|
||||
* \param pool Buffer pool number.
|
||||
*
|
||||
* \return Number of allocated buffers.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint8_t WsfBufGetMaxAlloc(uint8_t pool);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfBufGetNumAlloc
|
||||
*
|
||||
* \brief Diagnostic function to get the number of currently allocated buffers in a pool.
|
||||
*
|
||||
* \param pool Buffer pool number.
|
||||
*
|
||||
* \return Number of allocated buffers.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint8_t WsfBufGetNumAlloc(uint8_t pool);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfBufGetAllocStats
|
||||
*
|
||||
* \brief Diagnostic function to get the buffer allocation statistics.
|
||||
*
|
||||
* \return Buffer allocation statistics array.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint8_t *WsfBufGetAllocStats(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfBufGetPoolStats
|
||||
*
|
||||
* \brief Get statistics for each pool.
|
||||
*
|
||||
* \param pStat Buffer to store the statistics.
|
||||
* \param numPool Number of pool elements.
|
||||
*
|
||||
* \return Pool statistics.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfBufGetPoolStats(WsfBufPoolStat_t *pStat, uint8_t numPool);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* WSF_BUF_H */
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file wsf_math.h
|
||||
*
|
||||
* \brief Common math utilities.
|
||||
*
|
||||
* $Date: 2015-08-27 08:31:35 -0400 (Thu, 27 Aug 2015) $
|
||||
* $Revision: 3731 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef WSF_MATH_H
|
||||
#define WSF_MATH_H
|
||||
|
||||
#include "wsf_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! \brief Returns the minimum of two values. */
|
||||
#define WSF_MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
/*! \brief Returns the maximum of two values. */
|
||||
#define WSF_MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
/*! \brief Binary divide with 1,000 divisor. */
|
||||
#define WSF_MATH_DIV_10E3(n) (((n) * UINT32_C(1048)) >> 20)
|
||||
|
||||
/*! \brief Binary divide with 1,000,000 divisor. */
|
||||
#define WSF_MATH_DIV_10E6(n) ((uint32_t)(((uint64_t)(n) * UINT64_C(4295)) >> 32))
|
||||
|
||||
/*! \brief Binary divide with 10 divisor. */
|
||||
#define WSF_MATH_DIV_10(n) ((uint32_t)(((uint64_t)(n) * UINT64_C(419431)) >> 22))
|
||||
|
||||
/*! \brief Binary divide with 37 divisor. */
|
||||
#define WSF_MATH_DIV_37(n) (((n) * UINT32_C(56680)) >> 21)
|
||||
|
||||
/*! \brief Binary modulo 37. */
|
||||
#define WSF_MATH_MOD_37(n) ((n) - (WSF_MATH_DIV_37(n) * 37))
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
void WsfMathInit(void);
|
||||
uint32_t WsfRandNum(void);
|
||||
void WsfAesEcb(const uint8_t *pKey, uint8_t *pOut, const uint8_t *pIn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* WSF_MATH_H */
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file wsf_msg.h
|
||||
*
|
||||
* \brief Message passing service.
|
||||
*
|
||||
* $Date: 2013-07-02 18:08:09 -0400 (Tue, 02 Jul 2013) $
|
||||
* $Revision: 779 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef WSF_MSG_H
|
||||
#define WSF_MSG_H
|
||||
|
||||
#include "wsf_queue.h"
|
||||
#include "wsf_os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfMsgAlloc
|
||||
*
|
||||
* \brief Allocate a message buffer to be sent with WsfMsgSend().
|
||||
*
|
||||
* \param len Message length in bytes.
|
||||
*
|
||||
* \return Pointer to message buffer or NULL if allocation failed.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void *WsfMsgAlloc(uint16_t len);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfMsgFree
|
||||
*
|
||||
* \brief Free a message buffer allocated with WsfMsgAlloc().
|
||||
*
|
||||
* \param pMsg Pointer to message buffer.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfMsgFree(void *pMsg);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfMsgSend
|
||||
*
|
||||
* \brief Send a message to an event handler.
|
||||
*
|
||||
* \param handlerId Event handler ID.
|
||||
* \param pMsg Pointer to message buffer.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfMsgSend(wsfHandlerId_t handlerId, void *pMsg);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfMsgEnq
|
||||
*
|
||||
* \brief Enqueue a message.
|
||||
*
|
||||
* \param pQueue Pointer to queue.
|
||||
* \param handerId Set message handler ID to this value.
|
||||
* \param pElem Pointer to message buffer.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfMsgEnq(wsfQueue_t *pQueue, wsfHandlerId_t handlerId, void *pMsg);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfMsgDeq
|
||||
*
|
||||
* \brief Dequeue a message.
|
||||
*
|
||||
* \param pQueue Pointer to queue.
|
||||
* \param pHandlerId Handler ID of returned message; this is a return parameter.
|
||||
*
|
||||
* \return Pointer to message that has been dequeued or NULL if queue is empty.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void *WsfMsgDeq(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfMsgPeek
|
||||
*
|
||||
* \brief Get the next message without removing it from the queue.
|
||||
*
|
||||
* \param pQueue Pointer to queue.
|
||||
* \param pHandlerId Handler ID of returned message; this is a return parameter.
|
||||
*
|
||||
* \return Pointer to the next message on the queue or NULL if queue is empty.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void *WsfMsgPeek(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* WSF_MSG_H */
|
||||
|
|
@ -0,0 +1,150 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file wsf_os.h
|
||||
*
|
||||
* \brief Software foundation OS API.
|
||||
*
|
||||
* $Date: 2014-08-08 09:30:50 -0400 (Fri, 08 Aug 2014) $
|
||||
* $Revision: 1725 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef WSF_OS_H
|
||||
#define WSF_OS_H
|
||||
|
||||
#include "wsf_os_int.h"
|
||||
#include "wsf_queue.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Common message structure passed to event handler */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t param; /*! General purpose parameter passed to event handler */
|
||||
uint8_t event; /*! General purpose event value passed to event handler */
|
||||
uint8_t status; /*! General purpose status value passed to event handler */
|
||||
} wsfMsgHdr_t;
|
||||
|
||||
/**************************************************************************************************
|
||||
Callback Function Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn wsfEventHandler_t
|
||||
*
|
||||
* \brief Event handler callback function.
|
||||
*
|
||||
* \param event Mask of events set for the event handler.
|
||||
* \param pMsg Pointer to message for the event handler.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
typedef void (*wsfEventHandler_t)(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfSetEvent
|
||||
*
|
||||
* \brief Set an event for an event handler.
|
||||
*
|
||||
* \param handlerId Handler ID.
|
||||
* \param event Event or events to set.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfSetEvent(wsfHandlerId_t handlerId, wsfEventMask_t event);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfTaskLock
|
||||
*
|
||||
* \brief Lock task scheduling.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfTaskLock(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfTaskUnlock
|
||||
*
|
||||
* \brief Unlock task scheduling.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfTaskUnlock(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfTaskSetReady
|
||||
*
|
||||
* \brief Set the task used by the given handler as ready to run.
|
||||
*
|
||||
* \param handlerId Event handler ID.
|
||||
* \param event Task event mask.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfTaskSetReady(wsfHandlerId_t handlerId, wsfTaskEvent_t event);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfTaskMsgQueue
|
||||
*
|
||||
* \brief Return the task message queue used by the given handler.
|
||||
*
|
||||
* \param handlerId Event handler ID.
|
||||
*
|
||||
* \return Task message queue.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
wsfQueue_t *WsfTaskMsgQueue(wsfHandlerId_t handlerId);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfOsSetNextHandler
|
||||
*
|
||||
* \brief Set the next WSF handler function in the WSF OS handler array. This function
|
||||
* should only be called as part of the OS initialization procedure.
|
||||
*
|
||||
* \param handler WSF handler function.
|
||||
*
|
||||
* \return WSF handler ID for this handler.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
wsfHandlerId_t WsfOsSetNextHandler(wsfEventHandler_t handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* WSF_OS_H */
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file wsf_queue.h
|
||||
*
|
||||
* \brief General purpose queue service.
|
||||
*
|
||||
* $Date: 2011-10-15 00:35:03 -0400 (Sat, 15 Oct 2011) $
|
||||
* $Revision: 191 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef WSF_QUEUE_H
|
||||
#define WSF_QUEUE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Initialize a queue */
|
||||
#define WSF_QUEUE_INIT(pQueue) {(pQueue)->pHead = NULL; (pQueue)->pTail = NULL;}
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Queue structure */
|
||||
typedef struct
|
||||
{
|
||||
void *pHead; /*! head of queue */
|
||||
void *pTail; /*! tail of queue */
|
||||
} wsfQueue_t;
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfQueueEnq
|
||||
*
|
||||
* \brief Enqueue an element to the tail of a queue.
|
||||
*
|
||||
* \param pQueue Pointer to queue.
|
||||
* \param pElem Pointer to element.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfQueueEnq(wsfQueue_t *pQueue, void *pElem);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfQueueDeq
|
||||
*
|
||||
* \brief Dequeue an element from the head of a queue.
|
||||
*
|
||||
* \param pQueue Pointer to queue.
|
||||
*
|
||||
* \return Pointer to element that has been dequeued or NULL if queue is empty.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void *WsfQueueDeq(wsfQueue_t *pQueue);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfQueuePush
|
||||
*
|
||||
* \brief Push an element to the head of a queue.
|
||||
*
|
||||
* \param pQueue Pointer to queue.
|
||||
* \param pElem Pointer to element.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfQueuePush(wsfQueue_t *pQueue, void *pElem);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfQueueInsert
|
||||
*
|
||||
* \brief Insert an element into a queue. This function is typically used when iterating
|
||||
* over a queue.
|
||||
*
|
||||
* \param pQueue Pointer to queue.
|
||||
* \param pElem Pointer to element to be inserted.
|
||||
* \param pPrev Pointer to previous element in the queue before element to be inserted.
|
||||
* Note: set pPrev to NULL if pElem is first element in queue.
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfQueueInsert(wsfQueue_t *pQueue, void *pElem, void *pPrev);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfQueueRemove
|
||||
*
|
||||
* \brief Remove an element from a queue. This function is typically used when iterating
|
||||
* over a queue.
|
||||
*
|
||||
* \param pQueue Pointer to queue.
|
||||
* \param pElem Pointer to element to be removed.
|
||||
* \param pPrev Pointer to previous element in the queue before element to be removed.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfQueueRemove(wsfQueue_t *pQueue, void *pElem, void *pPrev);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfQueueCount
|
||||
*
|
||||
* \brief Count the number of elements in a queue.
|
||||
*
|
||||
* \param pQueue Pointer to queue.
|
||||
*
|
||||
* \return Number of elements in queue.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint16_t WsfQueueCount(wsfQueue_t *pQueue);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfQueueEmpty
|
||||
*
|
||||
* \brief Return TRUE if queue is empty.
|
||||
*
|
||||
* \param pQueue Pointer to queue.
|
||||
*
|
||||
* \return TRUE if queue is empty, FALSE otherwise.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
bool_t WsfQueueEmpty(wsfQueue_t *pQueue);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* WSF_QUEUE_H */
|
||||
|
|
@ -0,0 +1,246 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file wsf_sec.h
|
||||
*
|
||||
* \brief AES and random number security service API.
|
||||
*
|
||||
* $Date: 2015-10-15 14:57:57 -0400 (Thu, 15 Oct 2015) $
|
||||
* $Revision: 4218 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef WSF_SEC_H
|
||||
#define WSF_SEC_H
|
||||
|
||||
#include "wsf_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! CMAC algorithm key length */
|
||||
#define WSF_CMAC_KEY_LEN 16
|
||||
|
||||
/*! CMAC algorithm result length */
|
||||
#define WSF_CMAC_HASH_LEN 16
|
||||
|
||||
/*! ECC algorithm key length */
|
||||
#define WSF_ECC_KEY_LEN 32
|
||||
|
||||
/*! Invalid AES Token */
|
||||
#define WSF_TOKEN_INVALID 0xFF
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
/*! AES Security callback parameters structure */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr; /*! header */
|
||||
uint8_t *pCiphertext; /*! pointer to 16 bytes of ciphertext data */
|
||||
} wsfSecMsg_t;
|
||||
|
||||
/*! AES Security callback are the same as wsfSecMsg_t */
|
||||
typedef wsfSecMsg_t wsfSecAes_t;
|
||||
|
||||
/*! CMAC Security callback are the same as wsfSecMsg_t */
|
||||
typedef wsfSecMsg_t wsfSecCmacMsg_t;
|
||||
|
||||
/*! ECC Security public/private key pair */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t pubKey_x[WSF_ECC_KEY_LEN]; /*! x component of ecc public key */
|
||||
uint8_t pubKey_y[WSF_ECC_KEY_LEN]; /*! y component of ecc public key */
|
||||
uint8_t privKey[WSF_ECC_KEY_LEN]; /*! ecc private key */
|
||||
} wsfSecEccKey_t;
|
||||
|
||||
/*! ECC security DH Key shared secret */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t secret[WSF_ECC_KEY_LEN]; /*! DH Key Shared secret */
|
||||
} wsfSecEccSharedSec_t;
|
||||
|
||||
|
||||
/*! ECC Security callback parameters structure */
|
||||
typedef struct
|
||||
{
|
||||
wsfMsgHdr_t hdr; /*! header */
|
||||
union
|
||||
{
|
||||
wsfSecEccSharedSec_t sharedSecret; /*! shared secret */
|
||||
wsfSecEccKey_t key; /*! ecc public/private key pair */
|
||||
} data;
|
||||
} wsfSecEccMsg_t;
|
||||
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfSecInit
|
||||
*
|
||||
* \brief Initialize the security service. This function should only be called once
|
||||
* upon system initialization.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfSecInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfSecRandInit
|
||||
*
|
||||
* \brief Initialize the random number service. This function should only be called once
|
||||
* upon system initialization.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfSecRandInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfSecAesInit
|
||||
*
|
||||
* \brief Initialize the AES service. This function should only be called once
|
||||
* upon system initialization.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfSecAesInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfSecCmacInit
|
||||
*
|
||||
* \brief Called to initialize CMAC security. This function should only be called once
|
||||
* upon system initialization.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfSecCmacInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfSecEccInit
|
||||
*
|
||||
* \brief Called to initialize ECC security. This function should only be called once
|
||||
* upon system initialization.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfSecEccInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfSecAes
|
||||
*
|
||||
* \brief Execute an AES calculation. When the calculation completes, a WSF message will be
|
||||
* sent to the specified handler. This function returns a token value that
|
||||
* the client can use to match calls to this function with messages.
|
||||
*
|
||||
* \param pKey Pointer to 16 byte key.
|
||||
* \param pPlaintext Pointer to 16 byte plaintext.
|
||||
* \param handlerId WSF handler ID.
|
||||
* \param param Client-defined parameter returned in message.
|
||||
* \param event Event for client's WSF handler.
|
||||
*
|
||||
* \return Token value.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
uint8_t WsfSecAes(uint8_t *pKey, uint8_t *pPlaintext, wsfHandlerId_t handlerId,
|
||||
uint16_t param, uint8_t event);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfSecAesCmac
|
||||
*
|
||||
* \brief Execute the CMAC algorithm.
|
||||
*
|
||||
* \param pKey Key used in CMAC operation.
|
||||
* \param pPlaintext Data to perform CMAC operation over
|
||||
* \param len Size of pPlaintext in bytes.
|
||||
* \param handlerId WSF handler ID for client.
|
||||
* \param param Optional parameter sent to client's WSF handler.
|
||||
* \param event Event for client's WSF handler.
|
||||
*
|
||||
* \return TRUE if successful, else FALSE.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
bool_t WsfSecCmac(const uint8_t *pKey, uint8_t *pPlaintext, uint8_t textLen, wsfHandlerId_t handlerId,
|
||||
uint16_t param, uint8_t event);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfSecEccGenKey
|
||||
*
|
||||
* \brief Generate an ECC key.
|
||||
*
|
||||
* \param handlerId WSF handler ID for client.
|
||||
* \param param Optional parameter sent to client's WSF handler.
|
||||
* \param event Event for client's WSF handler.
|
||||
*
|
||||
* \return TRUE if successful, else FALSE.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
bool_t WsfSecEccGenKey(wsfHandlerId_t handlerId, uint16_t param, uint8_t event);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfSecEccGenSharedSecret
|
||||
*
|
||||
* \brief Generate an ECC key.
|
||||
*
|
||||
* \param pKey ECC Key structure.
|
||||
* \param handlerId WSF handler ID for client.
|
||||
* \param param Optional parameter sent to client's WSF handler.
|
||||
* \param event Event for client's WSF handler.
|
||||
*
|
||||
* \return TRUE if successful, else FALSE.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
bool_t WsfSecEccGenSharedSecret(wsfSecEccKey_t *pKey, wsfHandlerId_t handlerId, uint16_t param, uint8_t event);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfSecRand
|
||||
*
|
||||
* \brief This function returns up to 16 bytes of random data to a buffer provided by the
|
||||
* client.
|
||||
*
|
||||
* \param pRand Pointer to returned random data.
|
||||
* \param randLen Length of random data.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfSecRand(uint8_t *pRand, uint8_t randLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* WSF_SEC_H */
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file wsf_sec_int.h
|
||||
*
|
||||
* \brief Internal security service structures.
|
||||
*
|
||||
* $Date: 2015-09-05 12:01:07 -0400 (Sat, 05 Sep 2015) $
|
||||
* $Revision: 3793 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef WSF_SEC_INT_H
|
||||
#define WSF_SEC_INT_H
|
||||
|
||||
#include "hci_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
|
||||
/*! AES, CMAC and HCI algorithm block length */
|
||||
#define WSF_SEC_BLOCK_LEN 16
|
||||
|
||||
/* CMAC constant Rb */
|
||||
#define WSF_SEC_CMAC_RB 0x87
|
||||
|
||||
/*! Multiple of HCI_RAND_LEN to keep in the wsfSecCb_t rand data buffer */
|
||||
#define WSF_HCI_RAND_MULT (32 / HCI_RAND_LEN)
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Enumeration of security operation types */
|
||||
enum
|
||||
{
|
||||
WSF_SEC_TYPE_AES,
|
||||
WSF_SEC_TYPE_CMAC,
|
||||
WSF_SEC_TYPE_DH,
|
||||
WSF_SEC_NUM_TYPES
|
||||
};
|
||||
|
||||
/*! Security queue element for CMAC operations */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *pPlainText;
|
||||
uint8_t key[WSF_CMAC_KEY_LEN];
|
||||
uint8_t subkey[WSF_CMAC_KEY_LEN];
|
||||
uint16_t position;
|
||||
uint16_t len;
|
||||
wsfHandlerId_t handlerId;
|
||||
uint8_t state;
|
||||
} wsfSecCmacSecCb_t;
|
||||
|
||||
/*! Security queue element */
|
||||
typedef struct
|
||||
{
|
||||
wsfSecMsg_t msg;
|
||||
uint8_t ciphertext[WSF_SEC_BLOCK_LEN];
|
||||
uint8_t reserved[WSF_SEC_BLOCK_LEN];
|
||||
void *pCb;
|
||||
uint8_t type;
|
||||
} wsfSecQueueBuf_t;
|
||||
|
||||
typedef void wsfSecHciCback_t(wsfSecQueueBuf_t *pBuf, hciEvt_t *pEvent, wsfHandlerId_t handlerId);
|
||||
typedef wsfSecHciCback_t *pWsfSecHciCback_t;
|
||||
|
||||
/* Control block */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t rand[HCI_RAND_LEN*WSF_HCI_RAND_MULT]; /* Random data buffer */
|
||||
wsfQueue_t queue; /* Queue for AES requests */
|
||||
uint8_t token; /* Token value */
|
||||
pWsfSecHciCback_t hciCbackTbl[WSF_SEC_NUM_TYPES];
|
||||
} wsfSecCb_t;
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* WSF_SEC_H */
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file wsf_timer.h
|
||||
*
|
||||
* \brief Timer service.
|
||||
*
|
||||
* $Date: 2015-09-11 17:14:44 -0400 (Fri, 11 Sep 2015) $
|
||||
* $Revision: 3856 $
|
||||
*
|
||||
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef WSF_TIMER_H
|
||||
#define WSF_TIMER_H
|
||||
|
||||
#include "wsf_os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Macros
|
||||
**************************************************************************************************/
|
||||
|
||||
#ifndef WSF_MS_PER_TICK
|
||||
/*! Default milliseconds per tick rate */
|
||||
#define WSF_MS_PER_TICK 10
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
Data Types
|
||||
**************************************************************************************************/
|
||||
|
||||
/*! Timer ticks data type */
|
||||
typedef uint32_t wsfTimerTicks_t;
|
||||
|
||||
/*! Timer structure */
|
||||
typedef struct wsfTimer_tag
|
||||
{
|
||||
struct wsfTimer_tag *pNext; /*! pointer to next timer in queue */
|
||||
wsfTimerTicks_t ticks; /*! number of ticks until expiration */
|
||||
wsfHandlerId_t handlerId; /*! event handler for this timer */
|
||||
bool_t isStarted; /*! TRUE if timer has been started */
|
||||
wsfMsgHdr_t msg; /*! application-defined timer event parameters */
|
||||
} wsfTimer_t;
|
||||
|
||||
|
||||
/**************************************************************************************************
|
||||
Function Declarations
|
||||
**************************************************************************************************/
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfTimerInit
|
||||
*
|
||||
* \brief Initialize the timer service. This function should only be called once
|
||||
* upon system initialization.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfTimerInit(void);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfTimerStartSec
|
||||
*
|
||||
* \brief Start a timer in units of seconds. Before this function is called parameter
|
||||
* pTimer->handlerId must be set to the event handler for this timer and parameter
|
||||
* pTimer->msg must be set to any application-defined timer event parameters.
|
||||
*
|
||||
* \param pTimer Pointer to timer.
|
||||
* \param sec Seconds until expiration.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfTimerStartSec(wsfTimer_t *pTimer, wsfTimerTicks_t sec);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfTimerStartMs
|
||||
*
|
||||
* \brief Start a timer in units of milliseconds.
|
||||
*
|
||||
* \param pTimer Pointer to timer.
|
||||
* \param ms Milliseconds until expiration.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfTimerStartMs(wsfTimer_t *pTimer, wsfTimerTicks_t ms);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfTimerStop
|
||||
*
|
||||
* \brief Stop a timer.
|
||||
*
|
||||
* \param pTimer Pointer to timer.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfTimerStop(wsfTimer_t *pTimer);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfTimerUpdate
|
||||
*
|
||||
* \brief Update the timer service with the number of elapsed ticks. This function is
|
||||
* typically called only from timer porting code.
|
||||
*
|
||||
* \param ticks Number of ticks since last update.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
void WsfTimerUpdate(wsfTimerTicks_t ticks);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfTimerNextExpiration
|
||||
*
|
||||
* \brief Return the number of ticks until the next timer expiration. Note that this
|
||||
* function can return zero even if a timer is running, indicating the timer
|
||||
* has expired but has not yet been serviced.
|
||||
*
|
||||
* \param pTimerRunning Returns TRUE if a timer is running, FALSE if no timers running.
|
||||
*
|
||||
* \return The number of ticks until the next timer expiration.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
wsfTimerTicks_t WsfTimerNextExpiration(bool_t *pTimerRunning);
|
||||
|
||||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \fn WsfTimerServiceExpired
|
||||
*
|
||||
* \brief Service expired timers for the given task. This function is typically called only
|
||||
* WSF OS porting code.
|
||||
*
|
||||
* \param taskId OS Task ID of task servicing timers.
|
||||
*
|
||||
* \return Pointer to next expired timer or NULL if there are no expired timers.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
wsfTimer_t *WsfTimerServiceExpired(wsfTaskId_t taskId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* WSF_TIMER_H */
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*************************************************************************************************/
|
||||
/*!
|
||||
* \file wsf_mbed_os.h
|
||||
*
|
||||
* \brief Mbed OS specific callback.
|
||||
*
|
||||
* $Date: 2016-06-24 12:54:16 -0400 (Mon, 05 Oct 2015) $
|
||||
* $Revision: 1 $
|
||||
*
|
||||
* Copyright (c) 2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: LicenseRef-PBL
|
||||
*
|
||||
* This file and the related binary are licensed under the
|
||||
* Permissive Binary License, Version 1.0 (the "License");
|
||||
* you may not use these files except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License here:
|
||||
* LICENSE-permissive-binary-license-1.0.txt and at
|
||||
* https://www.mbed.com/licenses/PBL-1.0
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*************************************************************************************************/
|
||||
#ifndef WSF_MBED_OS_H
|
||||
#define WSF_MBED_OS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Register MBED OS SignalEvent */
|
||||
void mbedOSRegisterSignalEventCallback(uint32_t (*fnSignalEventInput)(void));
|
||||
|
||||
/*
|
||||
* Call Mbed OS SignalEvent
|
||||
* This function is called to signal to the user code when a wsf task is ready
|
||||
*/
|
||||
void mbedOSSignalEventCallback(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* WSF_MBED_OS_H */
|
||||
|
|
@ -20,10 +20,11 @@ void mbed_sdk_init(void) {
|
|||
SystemPowerConfig();
|
||||
|
||||
/* Config EFlash Controller Clock */
|
||||
EFlash_Initialize();
|
||||
EFlash_DriverInitialize();
|
||||
EFlash_ClockConfig();
|
||||
|
||||
/* Initialize Flash Cache */
|
||||
FCache_Initialize();
|
||||
/* Enable Flash Cache Stats */
|
||||
FCache_DriverInitialize();
|
||||
FCache_Enable(1);
|
||||
FCache_Invalidate();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue