Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 334a68c6fe | |||
| 627b5f0b59 | |||
| 94e82768d2 | |||
| 4957142e08 | |||
| 08490df886 | |||
| ac0662bc9d |
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
@@ -36,10 +36,11 @@
|
||||
* CC2650 Booster Pack.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* ====================== Includes ============================================
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
#include <xdc/std.h>
|
||||
#include <xdc/runtime/System.h>
|
||||
|
||||
@@ -56,16 +57,46 @@
|
||||
#include <inc/hw_ints.h>
|
||||
#include <driverlib/ioc.h>
|
||||
#include <driverlib/udma.h>
|
||||
// clang-format on
|
||||
|
||||
#include "Board.h"
|
||||
|
||||
///*
|
||||
// * ========================= IO driver initialization =========================
|
||||
// * From main, PIN_init(BoardGpioInitTable) should be called to setup safe
|
||||
// * settings for this board.
|
||||
// * When a pin is allocated and then de-allocated, it will revert to the state
|
||||
// * configured in this table.
|
||||
// */
|
||||
//
|
||||
///* Place into subsections to allow the TI linker to remove items properly */
|
||||
//#if defined(__TI_COMPILER_VERSION__)
|
||||
//#pragma DATA_SECTION(BoardGpioInitTable, ".const:BoardGpioInitTable")
|
||||
//#pragma DATA_SECTION(PINCC26XX_hwAttrs, ".const:PINCC26XX_hwAttrs")
|
||||
//#endif
|
||||
//
|
||||
//PIN_Config BoardGpioInitTable[] = { //
|
||||
// PIN_MEM_INS | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS,
|
||||
// PIN_MEM_REQ | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS,
|
||||
// PIN_MEM_BZY | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS,
|
||||
// PIN_MEM_SEL | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
// PIN_MEM_TEST | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
|
||||
// PIN_TERMINATE};
|
||||
//
|
||||
//const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = {
|
||||
// //
|
||||
// .intPriority = ~0,
|
||||
// .swiPriority = 0
|
||||
// //
|
||||
//};
|
||||
|
||||
/*
|
||||
* ========================= IO driver initialization =========================
|
||||
* From main, PIN_init(BoardGpioInitTable) should be called to setup safe
|
||||
* settings for this board.
|
||||
* When a pin is allocated and then de-allocated, it will revert to the state
|
||||
* configured in this table.
|
||||
*/
|
||||
*/
|
||||
|
||||
/* Place into subsections to allow the TI linker to remove items properly */
|
||||
#if defined(__TI_COMPILER_VERSION__)
|
||||
@@ -73,20 +104,22 @@
|
||||
#pragma DATA_SECTION(PINCC26XX_hwAttrs, ".const:PINCC26XX_hwAttrs")
|
||||
#endif
|
||||
|
||||
const PIN_Config BoardGpioInitTable[] = {
|
||||
Board_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
|
||||
Board_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
|
||||
Board_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX */
|
||||
Board_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX */
|
||||
Board_SRDY | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* SRDY */
|
||||
Board_MRDY | PIN_INPUT_EN | PIN_PULLDOWN, /* MRDY */
|
||||
PIN_TERMINATE
|
||||
};
|
||||
const PIN_Config BoardGpioInitTable[] = { //
|
||||
Board_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
|
||||
Board_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
|
||||
Board_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX */
|
||||
Board_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX */
|
||||
Board_SRDY | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* SRDY */
|
||||
Board_MRDY | PIN_INPUT_EN | PIN_PULLDOWN, /* MRDY */
|
||||
PIN_TERMINATE};
|
||||
|
||||
const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = {
|
||||
//
|
||||
.intPriority = ~0,
|
||||
.swiPriority = 0
|
||||
//
|
||||
};
|
||||
|
||||
/*============================================================================*/
|
||||
|
||||
/*
|
||||
@@ -96,13 +129,14 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = {
|
||||
#if defined(__TI_COMPILER_VERSION__)
|
||||
#pragma DATA_SECTION(PowerCC26XX_config, ".const:PowerCC26XX_config")
|
||||
#endif
|
||||
|
||||
const PowerCC26XX_Config PowerCC26XX_config = {
|
||||
.policyInitFxn = NULL,
|
||||
.policyFxn = &PowerCC26XX_standbyPolicy,
|
||||
.calibrateFxn = &PowerCC26XX_calibrate,
|
||||
.enablePolicy = TRUE,
|
||||
.calibrateRCOSC_LF = TRUE,
|
||||
.calibrateRCOSC_HF = TRUE,
|
||||
.policyInitFxn = NULL,
|
||||
.policyFxn = &PowerCC26XX_standbyPolicy,
|
||||
.calibrateFxn = &PowerCC26XX_calibrate,
|
||||
.enablePolicy = TRUE,
|
||||
.calibrateRCOSC_LF = TRUE,
|
||||
.calibrateRCOSC_HF = TRUE,
|
||||
};
|
||||
/*
|
||||
* ============================= Power end ====================================
|
||||
@@ -126,28 +160,32 @@ UARTCC26XX_Object uartCC26XXObjects[BOOSTXL_CC2650MA_UARTCOUNT];
|
||||
|
||||
/* UART hardware parameter structure, also used to assign UART pins */
|
||||
const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[BOOSTXL_CC2650MA_UARTCOUNT] = {
|
||||
//
|
||||
{
|
||||
.baseAddr = UART0_BASE,
|
||||
.powerMngrId = PowerCC26XX_PERIPH_UART0,
|
||||
.intNum = INT_UART0_COMB,
|
||||
.intPriority = ~0,
|
||||
.swiPriority = 0,
|
||||
.txPin = Board_UART_TX,
|
||||
.rxPin = Board_UART_RX,
|
||||
.ctsPin = PIN_UNASSIGNED,
|
||||
.rtsPin = PIN_UNASSIGNED
|
||||
.baseAddr = UART0_BASE,
|
||||
.powerMngrId = PowerCC26XX_PERIPH_UART0,
|
||||
.intNum = INT_UART0_COMB,
|
||||
.intPriority = ~0,
|
||||
.swiPriority = 0,
|
||||
.txPin = Board_UART_TX,
|
||||
.rxPin = Board_UART_RX,
|
||||
.ctsPin = PIN_UNASSIGNED,
|
||||
.rtsPin = PIN_UNASSIGNED
|
||||
//
|
||||
}
|
||||
//
|
||||
};
|
||||
|
||||
/* UART configuration structure */
|
||||
const UART_Config UART_config[] = {
|
||||
const UART_Config UART_config[] = { //
|
||||
{
|
||||
//
|
||||
.fxnTablePtr = &UARTCC26XX_fxnTable,
|
||||
.object = &uartCC26XXObjects[0],
|
||||
.hwAttrs = &uartCC26XXHWAttrs[0]
|
||||
//
|
||||
},
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
{NULL, NULL, NULL}};
|
||||
/*
|
||||
* ============================= UART end =====================================
|
||||
*/
|
||||
@@ -169,22 +207,27 @@ UDMACC26XX_Object udmaObjects[BOOSTXL_CC2650MA_UDMACOUNT];
|
||||
|
||||
/* UDMA configuration structure */
|
||||
const UDMACC26XX_HWAttrs udmaHWAttrs[BOOSTXL_CC2650MA_UDMACOUNT] = {
|
||||
//
|
||||
{
|
||||
//
|
||||
.baseAddr = UDMA0_BASE,
|
||||
.powerMngrId = PowerCC26XX_PERIPH_UDMA,
|
||||
.intNum = INT_DMA_ERR,
|
||||
.intPriority = ~0
|
||||
//
|
||||
}
|
||||
//
|
||||
};
|
||||
|
||||
/* UDMA configuration structure */
|
||||
const UDMACC26XX_Config UDMACC26XX_config[] = {
|
||||
const UDMACC26XX_Config UDMACC26XX_config[] = { //
|
||||
{
|
||||
.object = &udmaObjects[0],
|
||||
.hwAttrs = &udmaHWAttrs[0]
|
||||
//
|
||||
.object = &udmaObjects[0],
|
||||
.hwAttrs = &udmaHWAttrs[0]
|
||||
//
|
||||
},
|
||||
{NULL, NULL}
|
||||
};
|
||||
{NULL, NULL}};
|
||||
/*
|
||||
* ============================= UDMA end =====================================
|
||||
*/
|
||||
@@ -193,53 +236,77 @@ const UDMACC26XX_Config UDMACC26XX_config[] = {
|
||||
* ========================== SPI DMA begin ===================================
|
||||
*/
|
||||
/* Place into subsections to allow the TI linker to remove items properly */
|
||||
// #if defined(__TI_COMPILER_VERSION__)
|
||||
// #pragma DATA_SECTION(SPI_config, ".const:SPI_config")
|
||||
// #pragma DATA_SECTION(spiCC26XXDMAHWAttrs, ".const:spiCC26XXDMAHWAttrs")
|
||||
// #endif
|
||||
#if defined(__TI_COMPILER_VERSION__)
|
||||
#pragma DATA_SECTION(SPI_config, ".const:SPI_config")
|
||||
#pragma DATA_SECTION(spiCC26XXDMAHWAttrs, ".const:spiCC26XXDMAHWAttrs")
|
||||
#endif
|
||||
|
||||
// /* Include drivers */
|
||||
// #include <ti/drivers/spi/SPICC26XXDMA.h>
|
||||
/* Include drivers */
|
||||
#include <ti/drivers/spi/SPICC26XXDMA.h>
|
||||
|
||||
// /* SPI objects */
|
||||
// SPICC26XXDMA_Object spiCC26XXDMAObjects[BOOSTXL_CC2650MA_SPICOUNT];
|
||||
/* SPI objects */
|
||||
SPICC26XXDMA_Object spiCC26XXDMAObjects[BOOSTXL_CC2650MA_SPICOUNT];
|
||||
|
||||
// /* SPI configuration structure, describing which pins are to be used */
|
||||
// const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[BOOSTXL_CC2650MA_UDMACOUNT] = {
|
||||
// {
|
||||
// .baseAddr = SSI0_BASE,
|
||||
// .intNum = INT_SSI0_COMB,
|
||||
// .intPriority = ~0,
|
||||
// .swiPriority = 0,
|
||||
// .powerMngrId = PowerCC26XX_PERIPH_SSI0,
|
||||
// .defaultTxBufValue = 0,
|
||||
// .rxChannelBitMask = 1<<UDMA_CHAN_SSI0_RX,
|
||||
// .txChannelBitMask = 1<<UDMA_CHAN_SSI0_TX,
|
||||
// .mosiPin = Board_SPI0_MOSI,
|
||||
// .misoPin = Board_SPI0_MISO,
|
||||
// .clkPin = Board_SPI0_CLK,
|
||||
// .csnPin = Board_SPI0_CS
|
||||
// },
|
||||
// };
|
||||
/* SPI configuration structure, describing which pins are to be used */
|
||||
const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[BOOSTXL_CC2650MA_SPICOUNT] = {
|
||||
//
|
||||
{
|
||||
//
|
||||
.baseAddr = SSI0_BASE,
|
||||
.intNum = INT_SSI0_COMB,
|
||||
.intPriority = ~0,
|
||||
.swiPriority = 0,
|
||||
.powerMngrId = PowerCC26XX_PERIPH_SSI0,
|
||||
.defaultTxBufValue = 0,
|
||||
.rxChannelBitMask = 1 << UDMA_CHAN_SSI0_RX,
|
||||
.txChannelBitMask = 1 << UDMA_CHAN_SSI0_TX,
|
||||
.mosiPin = Board_SPI0_MOSI,
|
||||
.misoPin = Board_SPI0_MISO,
|
||||
.clkPin = Board_SPI0_CLK,
|
||||
.csnPin = PIN_UNASSIGNED
|
||||
//
|
||||
},
|
||||
#ifdef HEADSTAGE_MA_USE_SPI2
|
||||
{
|
||||
//
|
||||
.baseAddr = SSI1_BASE,
|
||||
.intNum = INT_SSI1_COMB,
|
||||
.intPriority = ~0,
|
||||
.swiPriority = 0,
|
||||
.powerMngrId = PowerCC26XX_PERIPH_SSI1,
|
||||
.defaultTxBufValue = 0,
|
||||
.rxChannelBitMask = 1 << UDMA_CHAN_SSI1_RX,
|
||||
.txChannelBitMask = 1 << UDMA_CHAN_SSI1_TX,
|
||||
.mosiPin = Board_SPI1_MOSI,
|
||||
.misoPin = Board_SPI1_MISO,
|
||||
.clkPin = Board_SPI1_CLK,
|
||||
.csnPin = Board_SPI1_CS //
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
// /* SPI configuration structure */
|
||||
// const SPI_Config SPI_config[] = {
|
||||
// {
|
||||
// .fxnTablePtr = &SPICC26XXDMA_fxnTable,
|
||||
// .object = &spiCC26XXDMAObjects[0],
|
||||
// .hwAttrs = &spiCC26XXDMAHWAttrs[0]
|
||||
// },
|
||||
// {
|
||||
// .fxnTablePtr = &SPICC26XXDMA_fxnTable,
|
||||
// .object = &spiCC26XXDMAObjects[1],
|
||||
// .hwAttrs = &spiCC26XXDMAHWAttrs[1]
|
||||
// },
|
||||
// {NULL, NULL, NULL}
|
||||
// };
|
||||
/* SPI configuration structure */
|
||||
const SPI_Config SPI_config[] = { //
|
||||
{
|
||||
//
|
||||
.fxnTablePtr = &SPICC26XXDMA_fxnTable,
|
||||
.object = &spiCC26XXDMAObjects[0],
|
||||
.hwAttrs = &spiCC26XXDMAHWAttrs[0]
|
||||
//
|
||||
},
|
||||
#ifdef HEADSTAGE_MA_USE_SPI2
|
||||
{
|
||||
//
|
||||
.fxnTablePtr = &SPICC26XXDMA_fxnTable,
|
||||
.object = &spiCC26XXDMAObjects[1],
|
||||
.hwAttrs = &spiCC26XXDMAHWAttrs[1]
|
||||
//
|
||||
},
|
||||
#endif
|
||||
{NULL, NULL, NULL}};
|
||||
/*
|
||||
* ========================== SPI DMA end =====================================
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* ========================== Crypto begin ====================================
|
||||
@@ -259,28 +326,28 @@ const UDMACC26XX_Config UDMACC26XX_config[] = {
|
||||
CryptoCC26XX_Object cryptoCC26XXObjects[BOOSTXL_CC2650MA_CRYPTOCOUNT];
|
||||
|
||||
/* Crypto configuration structure, describing which pins are to be used */
|
||||
const CryptoCC26XX_HWAttrs cryptoCC26XXHWAttrs[BOOSTXL_CC2650MA_CRYPTOCOUNT] = {
|
||||
{
|
||||
.baseAddr = CRYPTO_BASE,
|
||||
.powerMngrId = PowerCC26XX_PERIPH_CRYPTO,
|
||||
.intNum = INT_CRYPTO_RESULT_AVAIL_IRQ,
|
||||
.intPriority = ~0,
|
||||
}
|
||||
};
|
||||
const CryptoCC26XX_HWAttrs cryptoCC26XXHWAttrs[BOOSTXL_CC2650MA_CRYPTOCOUNT] = {{
|
||||
//
|
||||
.baseAddr = CRYPTO_BASE,
|
||||
.powerMngrId = PowerCC26XX_PERIPH_CRYPTO,
|
||||
.intNum = INT_CRYPTO_RESULT_AVAIL_IRQ,
|
||||
.intPriority = ~0,
|
||||
//
|
||||
}};
|
||||
|
||||
/* Crypto configuration structure */
|
||||
const CryptoCC26XX_Config CryptoCC26XX_config[] = {
|
||||
const CryptoCC26XX_Config CryptoCC26XX_config[] = { //
|
||||
{
|
||||
.object = &cryptoCC26XXObjects[0],
|
||||
.hwAttrs = &cryptoCC26XXHWAttrs[0]
|
||||
//
|
||||
.object = &cryptoCC26XXObjects[0],
|
||||
.hwAttrs = &cryptoCC26XXHWAttrs[0]
|
||||
//
|
||||
},
|
||||
{NULL, NULL}
|
||||
};
|
||||
{NULL, NULL}};
|
||||
/*
|
||||
* ========================== Crypto end ======================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* ========================= RF driver begin ==================================
|
||||
*/
|
||||
@@ -294,10 +361,12 @@ const CryptoCC26XX_Config CryptoCC26XX_config[] = {
|
||||
|
||||
/* RF hwi and swi priority */
|
||||
const RFCC26XX_HWAttrs RFCC26XX_hwAttrs = {
|
||||
//
|
||||
.hwiCpe0Priority = ~0,
|
||||
.hwiHwPriority = ~0,
|
||||
.swiCpe0Priority = 5,
|
||||
.swiHwPriority = 5,
|
||||
.swiCpe0Priority = 5,
|
||||
.swiHwPriority = 5,
|
||||
//
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -320,20 +389,21 @@ const RFCC26XX_HWAttrs RFCC26XX_hwAttrs = {
|
||||
TRNGCC26XX_Object trngCC26XXObjects[BOOSTXL_CC2650MA_TRNGCOUNT];
|
||||
|
||||
/* TRNG configuration structure, describing which pins are to be used */
|
||||
const TRNGCC26XX_HWAttrs TRNGCC26XXHWAttrs[BOOSTXL_CC2650MA_TRNGCOUNT] = {
|
||||
{
|
||||
.powerMngrId = PowerCC26XX_PERIPH_TRNG,
|
||||
}
|
||||
};
|
||||
const TRNGCC26XX_HWAttrs TRNGCC26XXHWAttrs[BOOSTXL_CC2650MA_TRNGCOUNT] = {{
|
||||
//
|
||||
.powerMngrId = PowerCC26XX_PERIPH_TRNG,
|
||||
//
|
||||
}};
|
||||
|
||||
/* TRNG configuration structure */
|
||||
const TRNGCC26XX_Config TRNGCC26XX_config[] = {
|
||||
const TRNGCC26XX_Config TRNGCC26XX_config[] = { //
|
||||
{
|
||||
.object = &trngCC26XXObjects[0],
|
||||
.hwAttrs = &TRNGCC26XXHWAttrs[0]
|
||||
//
|
||||
.object = &trngCC26XXObjects[0],
|
||||
.hwAttrs = &TRNGCC26XXHWAttrs[0]
|
||||
//
|
||||
},
|
||||
{NULL, NULL}
|
||||
};
|
||||
{NULL, NULL}};
|
||||
|
||||
/*
|
||||
* ========================= TRNG end ====================================
|
||||
@@ -351,14 +421,62 @@ const TRNGCC26XX_Config TRNGCC26XX_config[] = {
|
||||
|
||||
/* GPTimer hardware attributes, one per timer part (Timer 0A, 0B, 1A, 1B..) */
|
||||
const GPTimerCC26XX_HWAttrs gptimerCC26xxHWAttrs[BOOSTXL_CC2650MA_GPTIMERPARTSCOUNT] = {
|
||||
{ .baseAddr = GPT0_BASE, .intNum = INT_GPT0A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT0, .pinMux = GPT_PIN_0A, },
|
||||
{ .baseAddr = GPT0_BASE, .intNum = INT_GPT0B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT0, .pinMux = GPT_PIN_0B, },
|
||||
{ .baseAddr = GPT1_BASE, .intNum = INT_GPT1A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT1, .pinMux = GPT_PIN_1A, },
|
||||
{ .baseAddr = GPT1_BASE, .intNum = INT_GPT1B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT1, .pinMux = GPT_PIN_1B, },
|
||||
{ .baseAddr = GPT2_BASE, .intNum = INT_GPT2A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT2, .pinMux = GPT_PIN_2A, },
|
||||
{ .baseAddr = GPT2_BASE, .intNum = INT_GPT2B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT2, .pinMux = GPT_PIN_2B, },
|
||||
{ .baseAddr = GPT3_BASE, .intNum = INT_GPT3A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT3, .pinMux = GPT_PIN_3A, },
|
||||
{ .baseAddr = GPT3_BASE, .intNum = INT_GPT3B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT3, .pinMux = GPT_PIN_3B, },
|
||||
{
|
||||
.baseAddr = GPT0_BASE,
|
||||
.intNum = INT_GPT0A,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT0,
|
||||
.pinMux = GPT_PIN_0A,
|
||||
},
|
||||
{
|
||||
.baseAddr = GPT0_BASE,
|
||||
.intNum = INT_GPT0B,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT0,
|
||||
.pinMux = GPT_PIN_0B,
|
||||
},
|
||||
{
|
||||
.baseAddr = GPT1_BASE,
|
||||
.intNum = INT_GPT1A,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT1,
|
||||
.pinMux = GPT_PIN_1A,
|
||||
},
|
||||
{
|
||||
.baseAddr = GPT1_BASE,
|
||||
.intNum = INT_GPT1B,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT1,
|
||||
.pinMux = GPT_PIN_1B,
|
||||
},
|
||||
{
|
||||
.baseAddr = GPT2_BASE,
|
||||
.intNum = INT_GPT2A,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT2,
|
||||
.pinMux = GPT_PIN_2A,
|
||||
},
|
||||
{
|
||||
.baseAddr = GPT2_BASE,
|
||||
.intNum = INT_GPT2B,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT2,
|
||||
.pinMux = GPT_PIN_2B,
|
||||
},
|
||||
{
|
||||
.baseAddr = GPT3_BASE,
|
||||
.intNum = INT_GPT3A,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT3,
|
||||
.pinMux = GPT_PIN_3A,
|
||||
},
|
||||
{
|
||||
.baseAddr = GPT3_BASE,
|
||||
.intNum = INT_GPT3B,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT3,
|
||||
.pinMux = GPT_PIN_3B,
|
||||
},
|
||||
};
|
||||
|
||||
/* GPTimer objects, one per full-width timer (A+B) (Timer 0, Timer 1..) */
|
||||
@@ -366,14 +484,15 @@ GPTimerCC26XX_Object gptimerCC26XXObjects[BOOSTXL_CC2650MA_GPTIMERCOUNT];
|
||||
|
||||
/* GPTimer configuration (used as GPTimer_Handle by driver and application) */
|
||||
const GPTimerCC26XX_Config GPTimerCC26XX_config[BOOSTXL_CC2650MA_GPTIMERPARTSCOUNT] = {
|
||||
{ &gptimerCC26XXObjects[0], &gptimerCC26xxHWAttrs[0], GPT_A },
|
||||
{ &gptimerCC26XXObjects[0], &gptimerCC26xxHWAttrs[1], GPT_B },
|
||||
{ &gptimerCC26XXObjects[1], &gptimerCC26xxHWAttrs[2], GPT_A },
|
||||
{ &gptimerCC26XXObjects[1], &gptimerCC26xxHWAttrs[3], GPT_B },
|
||||
{ &gptimerCC26XXObjects[2], &gptimerCC26xxHWAttrs[4], GPT_A },
|
||||
{ &gptimerCC26XXObjects[2], &gptimerCC26xxHWAttrs[5], GPT_B },
|
||||
{ &gptimerCC26XXObjects[3], &gptimerCC26xxHWAttrs[6], GPT_A },
|
||||
{ &gptimerCC26XXObjects[3], &gptimerCC26xxHWAttrs[7], GPT_B },
|
||||
//
|
||||
{&gptimerCC26XXObjects[0], &gptimerCC26xxHWAttrs[0], GPT_A},
|
||||
{&gptimerCC26XXObjects[0], &gptimerCC26xxHWAttrs[1], GPT_B},
|
||||
{&gptimerCC26XXObjects[1], &gptimerCC26xxHWAttrs[2], GPT_A},
|
||||
{&gptimerCC26XXObjects[1], &gptimerCC26xxHWAttrs[3], GPT_B},
|
||||
{&gptimerCC26XXObjects[2], &gptimerCC26xxHWAttrs[4], GPT_A},
|
||||
{&gptimerCC26XXObjects[2], &gptimerCC26xxHWAttrs[5], GPT_B},
|
||||
{&gptimerCC26XXObjects[3], &gptimerCC26xxHWAttrs[6], GPT_A},
|
||||
{&gptimerCC26XXObjects[3], &gptimerCC26xxHWAttrs[7], GPT_B},
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -391,14 +510,15 @@ const GPTimerCC26XX_Config GPTimerCC26XX_config[BOOSTXL_CC2650MA_GPTIMERPARTSCOU
|
||||
#endif
|
||||
/* PWM configuration, one per PWM output. */
|
||||
PWMTimerCC26XX_HwAttrs pwmtimerCC26xxHWAttrs[BOOSTXL_CC2650MA_PWMCOUNT] = {
|
||||
{ .pwmPin = Board_PWMPIN0, .gpTimerUnit = Board_GPTIMER0A },
|
||||
{ .pwmPin = Board_PWMPIN1, .gpTimerUnit = Board_GPTIMER0B },
|
||||
{ .pwmPin = Board_PWMPIN2, .gpTimerUnit = Board_GPTIMER1A },
|
||||
{ .pwmPin = Board_PWMPIN3, .gpTimerUnit = Board_GPTIMER1B },
|
||||
{ .pwmPin = Board_PWMPIN4, .gpTimerUnit = Board_GPTIMER2A },
|
||||
{ .pwmPin = Board_PWMPIN5, .gpTimerUnit = Board_GPTIMER2B },
|
||||
{ .pwmPin = Board_PWMPIN6, .gpTimerUnit = Board_GPTIMER3A },
|
||||
{ .pwmPin = Board_PWMPIN7, .gpTimerUnit = Board_GPTIMER3B },
|
||||
//
|
||||
{.pwmPin = Board_PWMPIN0, .gpTimerUnit = Board_GPTIMER0A},
|
||||
{.pwmPin = Board_PWMPIN1, .gpTimerUnit = Board_GPTIMER0B},
|
||||
{.pwmPin = Board_PWMPIN2, .gpTimerUnit = Board_GPTIMER1A},
|
||||
{.pwmPin = Board_PWMPIN3, .gpTimerUnit = Board_GPTIMER1B},
|
||||
{.pwmPin = Board_PWMPIN4, .gpTimerUnit = Board_GPTIMER2A},
|
||||
{.pwmPin = Board_PWMPIN5, .gpTimerUnit = Board_GPTIMER2B},
|
||||
{.pwmPin = Board_PWMPIN6, .gpTimerUnit = Board_GPTIMER3A},
|
||||
{.pwmPin = Board_PWMPIN7, .gpTimerUnit = Board_GPTIMER3B},
|
||||
};
|
||||
|
||||
/* PWM object, one per PWM output */
|
||||
@@ -408,18 +528,300 @@ extern const PWM_FxnTable PWMTimerCC26XX_fxnTable;
|
||||
|
||||
/* PWM configuration (used as PWM_Handle by driver and application) */
|
||||
const PWM_Config PWM_config[BOOSTXL_CC2650MA_PWMCOUNT + 1] = {
|
||||
{ &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[0], &pwmtimerCC26xxHWAttrs[0] },
|
||||
{ &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[1], &pwmtimerCC26xxHWAttrs[1] },
|
||||
{ &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[2], &pwmtimerCC26xxHWAttrs[2] },
|
||||
{ &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[3], &pwmtimerCC26xxHWAttrs[3] },
|
||||
{ &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[4], &pwmtimerCC26xxHWAttrs[4] },
|
||||
{ &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[5], &pwmtimerCC26xxHWAttrs[5] },
|
||||
{ &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[6], &pwmtimerCC26xxHWAttrs[6] },
|
||||
{ &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[7], &pwmtimerCC26xxHWAttrs[7] },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
//
|
||||
{&PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[0], &pwmtimerCC26xxHWAttrs[0]},
|
||||
{&PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[1], &pwmtimerCC26xxHWAttrs[1]},
|
||||
{&PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[2], &pwmtimerCC26xxHWAttrs[2]},
|
||||
{&PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[3], &pwmtimerCC26xxHWAttrs[3]},
|
||||
{&PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[4], &pwmtimerCC26xxHWAttrs[4]},
|
||||
{&PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[5], &pwmtimerCC26xxHWAttrs[5]},
|
||||
{&PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[6], &pwmtimerCC26xxHWAttrs[6]},
|
||||
{&PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[7], &pwmtimerCC26xxHWAttrs[7]},
|
||||
{NULL, NULL, NULL}};
|
||||
|
||||
/*
|
||||
* ============================= PWM end ======================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* ============================= I2C Begin=====================================
|
||||
*/
|
||||
|
||||
#ifdef HEADSTAGE_LED_USE_I2C
|
||||
|
||||
#define Board_I2C0_SCL0 IOID_10
|
||||
#define Board_I2C0_SDA0 IOID_11
|
||||
|
||||
/* Place into subsections to allow the TI linker to remove items properly */
|
||||
#if defined(__TI_COMPILER_VERSION__)
|
||||
#pragma DATA_SECTION(I2C_config, ".const:I2C_config")
|
||||
#pragma DATA_SECTION(i2cCC26xxHWAttrs, ".const:i2cCC26xxHWAttrs")
|
||||
#endif
|
||||
|
||||
/* Include drivers */
|
||||
#include <ti/drivers/i2c/I2CCC26XX.h>
|
||||
|
||||
/* I2C objects */
|
||||
I2CCC26XX_Object i2cCC26xxObjects[BOOSTXL_CC2650MA_I2CCOUNT];
|
||||
|
||||
/* I2C configuration structure, describing which pins are to be used */
|
||||
const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[BOOSTXL_CC2650MA_I2CCOUNT] = {
|
||||
{
|
||||
.baseAddr = I2C0_BASE,
|
||||
.powerMngrId = PowerCC26XX_PERIPH_I2C0,
|
||||
.intNum = INT_I2C_IRQ,
|
||||
.intPriority = ~0,
|
||||
.swiPriority = 0,
|
||||
.sdaPin = Board_I2C0_SDA0,
|
||||
.sclPin = Board_I2C0_SCL0,
|
||||
}
|
||||
};
|
||||
|
||||
/* I2C configuration structure */
|
||||
const I2C_Config I2C_config[] = {
|
||||
{
|
||||
.fxnTablePtr = &I2CCC26XX_fxnTable,
|
||||
.object = &i2cCC26xxObjects[0],
|
||||
.hwAttrs = &i2cCC26xxHWAttrs[0]
|
||||
},
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
#endif
|
||||
/*
|
||||
* ========================== I2C end =========================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* ========================= Display begin ====================================
|
||||
*/
|
||||
/* Place into subsections to allow the TI linker to remove items properly */
|
||||
#if defined(__TI_COMPILER_VERSION__)
|
||||
#pragma DATA_SECTION(Display_config, ".const:Display_config")
|
||||
#pragma DATA_SECTION(displaySharpHWattrs, ".const:displaySharpHWattrs")
|
||||
#pragma DATA_SECTION(displayUartHWAttrs, ".const:displayUartHWAttrs")
|
||||
#endif
|
||||
|
||||
#include <ti/mw/display/Display.h>
|
||||
#include <ti/mw/display/DisplaySharp.h>
|
||||
#include <ti/mw/display/DisplayUart.h>
|
||||
|
||||
/* Structures for UartPlain Blocking */
|
||||
DisplayUart_Object displayUartObject;
|
||||
|
||||
#ifndef BOARD_DISPLAY_UART_STRBUF_SIZE
|
||||
#define BOARD_DISPLAY_UART_STRBUF_SIZE 128
|
||||
#endif
|
||||
static char uartStringBuf[BOARD_DISPLAY_UART_STRBUF_SIZE];
|
||||
|
||||
const DisplayUart_HWAttrs displayUartHWAttrs = {
|
||||
.uartIdx = Board_UART,
|
||||
.baudRate = 115200,
|
||||
.mutexTimeout = BIOS_WAIT_FOREVER,
|
||||
.strBuf = uartStringBuf,
|
||||
.strBufLen = BOARD_DISPLAY_UART_STRBUF_SIZE,
|
||||
};
|
||||
|
||||
/* Structures for SHARP */
|
||||
DisplaySharp_Object displaySharpObject;
|
||||
|
||||
#ifndef BOARD_DISPLAY_SHARP_SIZE
|
||||
#define BOARD_DISPLAY_SHARP_SIZE 96 // 96->96x96 is the most common board, alternative is 128->128x128.
|
||||
#endif
|
||||
static uint8_t sharpDisplayBuf[BOARD_DISPLAY_SHARP_SIZE * BOARD_DISPLAY_SHARP_SIZE / 8];
|
||||
|
||||
const DisplaySharp_HWAttrs displaySharpHWattrs = {
|
||||
.spiIndex = Board_SPI0,
|
||||
.csPin = Board_LCD_CS,
|
||||
.extcominPin = Board_LCD_EXTCOMIN,
|
||||
.powerPin = Board_LCD_POWER,
|
||||
.enablePin = Board_LCD_ENABLE,
|
||||
.pixelWidth = BOARD_DISPLAY_SHARP_SIZE,
|
||||
.pixelHeight = BOARD_DISPLAY_SHARP_SIZE,
|
||||
.displayBuf = sharpDisplayBuf,
|
||||
};
|
||||
|
||||
/* Array of displays */
|
||||
const Display_Config Display_config[] = {
|
||||
#if !defined(BOARD_DISPLAY_EXCLUDE_UART)
|
||||
{
|
||||
.fxnTablePtr = &DisplayUart_fxnTable,
|
||||
.object = &displayUartObject,
|
||||
.hwAttrs = &displayUartHWAttrs,
|
||||
},
|
||||
#endif
|
||||
#if !defined(BOARD_DISPLAY_EXCLUDE_LCD)
|
||||
{
|
||||
.fxnTablePtr = &DisplaySharp_fxnTable,
|
||||
.object = &displaySharpObject,
|
||||
.hwAttrs = &displaySharpHWattrs
|
||||
},
|
||||
#endif
|
||||
{ NULL, NULL, NULL } // Terminator
|
||||
};
|
||||
|
||||
/*
|
||||
* ========================= Display end ======================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* ============================= Watchdog begin =====================================
|
||||
*/
|
||||
|
||||
/* Place into subsections to allow the TI linker to remove items properly */
|
||||
#if defined(__TI_COMPILER_VERSION__)
|
||||
#pragma DATA_SECTION(Watchdog_config, ".const:Watchdog_config")
|
||||
#pragma DATA_SECTION(wdCC26XXHWAttrs, ".const:wdCC26XXHWAttrs")
|
||||
#endif
|
||||
|
||||
#include <ti/drivers/watchdog/WatchdogCC26XX.h>
|
||||
WatchdogCC26XX_Object wdCC26XXObject[BOOSTXL_CC2650MA_WATCHDOGCOUNT];
|
||||
|
||||
const WatchdogCC26XX_HWAttrs wdCC26XXHWAttrs[] = {
|
||||
{
|
||||
.baseAddr = WDT_BASE,
|
||||
.intNum = INT_WDT_IRQ,
|
||||
.reloadValue = 100
|
||||
}
|
||||
};
|
||||
|
||||
/* I2S configuration structure */
|
||||
const Watchdog_Config Watchdog_config[] = {
|
||||
{
|
||||
.fxnTablePtr = &WatchdogCC26XX_fxnTable,
|
||||
.object = &wdCC26XXObject[0],
|
||||
.hwAttrs = &wdCC26XXHWAttrs[0]
|
||||
},
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/*
|
||||
* ============================= Watchdog end =====================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* ================================ ADC begin ======================================
|
||||
*/
|
||||
#ifdef HEADSTAGE_RECORD_BATTERY
|
||||
|
||||
/* Place into subsections to allow the TI linker to remove items properly */
|
||||
#if defined(__TI_COMPILER_VERSION__)
|
||||
#pragma DATA_SECTION(ADC_config, ".const:ADC_config")
|
||||
#pragma DATA_SECTION(adcCC26xxHWAttrs, ".const:adcCC26xxHWAttrs")
|
||||
#endif
|
||||
|
||||
#include <ti/drivers/ADC.h>
|
||||
#include <ti/drivers/adc/ADCCC26XX.h>
|
||||
|
||||
/* ADC objects */
|
||||
ADCCC26XX_Object adcCC26xxObjects[BOOSTXL_CC2650MA_ADCCOUNT];
|
||||
|
||||
const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[BOOSTXL_CC2650MA_ADCCOUNT] = {
|
||||
{
|
||||
.adcDIO = Board_DIO0_ANALOG,
|
||||
.adcCompBInput = ADC_COMPB_IN_AUXIO7,
|
||||
.refSource = ADCCC26XX_FIXED_REFERENCE,
|
||||
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
|
||||
.inputScalingEnabled = true,
|
||||
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
|
||||
},
|
||||
{
|
||||
.adcDIO = Board_DIO1_ANALOG,
|
||||
.adcCompBInput = ADC_COMPB_IN_AUXIO6,
|
||||
.refSource = ADCCC26XX_FIXED_REFERENCE,
|
||||
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
|
||||
.inputScalingEnabled = true,
|
||||
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
|
||||
},
|
||||
{
|
||||
.adcDIO = Board_DIO2_ANALOG,
|
||||
.adcCompBInput = ADC_COMPB_IN_AUXIO5,
|
||||
.refSource = ADCCC26XX_FIXED_REFERENCE,
|
||||
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
|
||||
.inputScalingEnabled = true,
|
||||
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
|
||||
},
|
||||
{
|
||||
.adcDIO = Board_DIO3_ANALOG,
|
||||
.adcCompBInput = ADC_COMPB_IN_AUXIO4,
|
||||
.refSource = ADCCC26XX_FIXED_REFERENCE,
|
||||
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
|
||||
.inputScalingEnabled = true,
|
||||
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
|
||||
},
|
||||
{
|
||||
.adcDIO = Board_DIO4_ANALOG,
|
||||
.adcCompBInput = ADC_COMPB_IN_AUXIO3,
|
||||
.refSource = ADCCC26XX_FIXED_REFERENCE,
|
||||
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
|
||||
.inputScalingEnabled = true,
|
||||
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
|
||||
},
|
||||
{
|
||||
.adcDIO = Board_DIO5_ANALOG,
|
||||
.adcCompBInput = ADC_COMPB_IN_AUXIO2,
|
||||
.refSource = ADCCC26XX_FIXED_REFERENCE,
|
||||
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
|
||||
.inputScalingEnabled = true,
|
||||
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
|
||||
},
|
||||
{
|
||||
.adcDIO = Board_DIO6_ANALOG,
|
||||
.adcCompBInput = ADC_COMPB_IN_AUXIO1,
|
||||
.refSource = ADCCC26XX_FIXED_REFERENCE,
|
||||
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
|
||||
.inputScalingEnabled = true,
|
||||
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
|
||||
},
|
||||
{
|
||||
.adcDIO = Board_DIO7_ANALOG,
|
||||
.adcCompBInput = ADC_COMPB_IN_AUXIO0,
|
||||
.refSource = ADCCC26XX_FIXED_REFERENCE,
|
||||
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_10P9_MS,
|
||||
.inputScalingEnabled = true,
|
||||
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
|
||||
},
|
||||
{
|
||||
.adcDIO = PIN_UNASSIGNED,
|
||||
.adcCompBInput = ADC_COMPB_IN_DCOUPL,
|
||||
.refSource = ADCCC26XX_FIXED_REFERENCE,
|
||||
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
|
||||
.inputScalingEnabled = true,
|
||||
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
|
||||
},
|
||||
{
|
||||
.adcDIO = PIN_UNASSIGNED,
|
||||
.adcCompBInput = ADC_COMPB_IN_VSS,
|
||||
.refSource = ADCCC26XX_FIXED_REFERENCE,
|
||||
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
|
||||
.inputScalingEnabled = true,
|
||||
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
|
||||
},
|
||||
{
|
||||
.adcDIO = PIN_UNASSIGNED,
|
||||
.adcCompBInput = ADC_COMPB_IN_VDDS,
|
||||
.refSource = ADCCC26XX_FIXED_REFERENCE,
|
||||
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
|
||||
.inputScalingEnabled = true,
|
||||
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
|
||||
}
|
||||
};
|
||||
|
||||
const ADC_Config ADC_config[] = {
|
||||
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[0], &adcCC26xxHWAttrs[0]},
|
||||
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[1], &adcCC26xxHWAttrs[1]},
|
||||
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[2], &adcCC26xxHWAttrs[2]},
|
||||
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[3], &adcCC26xxHWAttrs[3]},
|
||||
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[4], &adcCC26xxHWAttrs[4]},
|
||||
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[5], &adcCC26xxHWAttrs[5]},
|
||||
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[6], &adcCC26xxHWAttrs[6]},
|
||||
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[7], &adcCC26xxHWAttrs[7]},
|
||||
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[8], &adcCC26xxHWAttrs[8]},
|
||||
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[9], &adcCC26xxHWAttrs[9]},
|
||||
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[10], &adcCC26xxHWAttrs[10]},
|
||||
{NULL, NULL, NULL},
|
||||
};
|
||||
|
||||
/*
|
||||
* ================================ ADC end ========================================
|
||||
*/
|
||||
#endif
|
||||
|
||||
@@ -89,25 +89,25 @@ extern const PIN_Config BoardGpioInitTable[];
|
||||
*/
|
||||
|
||||
/* Connector J1 */
|
||||
#define Board_BP_Pin_J1_2 DIO7
|
||||
#define Board_BP_Pin_J1_3 DIO0
|
||||
#define Board_BP_Pin_J1_4 DIO1
|
||||
#define Board_BP_Pin_J1_5 DIO2
|
||||
#define Board_BP_Pin_J1_6 DIO3
|
||||
#define Board_BP_Pin_J1_7 DIO10
|
||||
#define Board_BP_Pin_J1_8 DIO4
|
||||
#define Board_BP_Pin_J1_9 DIO5
|
||||
#define Board_BP_Pin_J1_10 DIO6
|
||||
#define Board_BP_Pin_J1_2 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_3 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_4 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_5 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_6 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_7 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_8 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_9 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_10 IOID_UNUSED
|
||||
|
||||
/* Connector J2 */
|
||||
#define Board_BP_Pin_J2_19 DIO8
|
||||
#define Board_BP_Pin_J2_18 DIO9 /* CS */
|
||||
#define Board_BP_Pin_J2_17 IOID_UNUSED /* NC */
|
||||
#define Board_BP_Pin_J2_15 DIO11 /* MOSI */
|
||||
#define Board_BP_Pin_J2_14 DIO12 /* MISO */
|
||||
#define Board_BP_Pin_J2_13 DIO13
|
||||
#define Board_BP_Pin_J2_12 DIO14
|
||||
#define Board_BP_Pin_J2_11 IOID_UNUSED /* NC */
|
||||
#define Board_BP_Pin_J2_19 IOID_UNUSED
|
||||
#define Board_BP_Pin_J2_18 IOID_UNUSED /* CS */
|
||||
#define Board_BP_Pin_J2_17 IOID_UNUSED /* NC */
|
||||
#define Board_BP_Pin_J2_15 IOID_UNUSED /* MOSI */
|
||||
#define Board_BP_Pin_J2_14 IOID_UNUSED /* MISO */
|
||||
#define Board_BP_Pin_J2_13 IOID_UNUSED
|
||||
#define Board_BP_Pin_J2_12 IOID_UNUSED
|
||||
#define Board_BP_Pin_J2_11 IOID_UNUSED /* NC */
|
||||
|
||||
/* Mapping of BoosterPack Connector Pins to BoosterPack Standard Functions (reflecting the BoosterPack Standard)
|
||||
*/
|
||||
@@ -133,27 +133,74 @@ extern const PIN_Config BoardGpioInitTable[];
|
||||
#define Board_BP_SPI_CS_Other Board_BP_Pin_J2_12
|
||||
#define Board_BP_GPIO_2 Board_BP_Pin_J2_11
|
||||
|
||||
|
||||
/* Mapping of application specific functionality of the BoosterPack to BoosterPack Pins (application dependent)
|
||||
*/
|
||||
|
||||
/* UART Board */
|
||||
#define Board_UART_TX DIO1 /* RXD */
|
||||
#define Board_UART_RX DIO0 /* TXD */
|
||||
|
||||
/*
|
||||
* interface with control box
|
||||
*/
|
||||
#if defined(MODA_MEMORY_BOARD)
|
||||
#define Board_SPI0_MISO DIO12
|
||||
#define Board_SPI0_MOSI DIO11
|
||||
#define Board_SPI0_CLK DIO10
|
||||
#define Board_SPI_CS DIO9
|
||||
|
||||
#define PIN_RAM_SEL DIO8 /* layout: MEM_SEL */
|
||||
#define PIN_MEM_SEL DIO4 /* layout: MEM_RST */
|
||||
#define PIN_MEM_BZY DIO13 /* layout: MEM_BZY */
|
||||
#define PIN_MEM_REQ DIO14 /* layout: MEM_REQ */
|
||||
#define PIN_MEM_TEST DIO7 /* layout: SPARE */
|
||||
|
||||
/* On-board LEDs */
|
||||
#define Board_GLED PIN_UNASSIGNED /* Green LED */
|
||||
#define Board_RLED PIN_UNASSIGNED /* Red LED */
|
||||
|
||||
#elif defined(MODA_BOOSTER_PACK)
|
||||
#define Board_SPI0_MISO DIO7
|
||||
#define Board_SPI0_MOSI DIO8
|
||||
#define Board_SPI0_CLK DIO9
|
||||
#define Board_SPI_CS DIO10
|
||||
|
||||
#define PIN_MEM_INS DIO1
|
||||
#define PIN_MEM_SEL DIO2
|
||||
#define PIN_MEM_BZY DIO12
|
||||
#define PIN_MEM_REQ DIO0
|
||||
#define PIN_MEM_TEST DIO4
|
||||
|
||||
/* On-board LEDs */
|
||||
#define Board_GLED DIO2 /* Green LED */
|
||||
#define Board_RLED DIO4 /* Red LED */
|
||||
|
||||
/* UART Board */
|
||||
#define Board_UART_TX Board_BP_UART_Rx /* RXD */
|
||||
#define Board_UART_RX Board_BP_UART_Tx /* TXD */
|
||||
#else
|
||||
#error "please define BOOSTXL_CC2650MA on BoosterPack or MemoryBoard"
|
||||
#endif
|
||||
//#define PIN_MEM_INS PIN_UNASSIGNED
|
||||
//#define PIN_MEM_BZY PIN_UNASSIGNED
|
||||
//#define PIN_MEM_REQ PIN_UNASSIGNED
|
||||
//#define PIN_MEM_SEL DIO4
|
||||
//#define PIN_MEM_TEST DIO2
|
||||
|
||||
// /* SPI Board */
|
||||
// #define Board_SPI0_MISO Board_BP_SPI_MISO
|
||||
// #define Board_SPI0_MOSI Board_BP_SPI_MOSI
|
||||
// #define Board_SPI0_CLK Board_BP_SPI_CLK
|
||||
// #define Board_SPI0_CS Board_BP_SPI_CS_Wireless
|
||||
/*
|
||||
* unused SPI
|
||||
*/
|
||||
|
||||
#define Board_SPI1_MISO PIN_UNASSIGNED
|
||||
#define Board_SPI1_MOSI PIN_UNASSIGNED
|
||||
#define Board_SPI1_CLK PIN_UNASSIGNED
|
||||
#define Board_SPI1_CS PIN_UNASSIGNED
|
||||
|
||||
#define Board_LCD_CS PIN_UNASSIGNED
|
||||
#define Board_LCD_EXTCOMIN PIN_UNASSIGNED
|
||||
#define Board_LCD_POWER PIN_UNASSIGNED
|
||||
#define Board_LCD_ENABLE PIN_UNASSIGNED
|
||||
|
||||
/* Power Management Board */
|
||||
#define Board_SRDY Board_BP_Pin_J2_19
|
||||
#define Board_MRDY Board_BP_Pin_J1_2
|
||||
#define Board_SRDY PIN_UNASSIGNED
|
||||
#define Board_MRDY PIN_UNASSIGNED
|
||||
|
||||
/* PWM outputs */
|
||||
#define Board_PWMPIN0 PIN_UNASSIGNED
|
||||
@@ -165,16 +212,24 @@ extern const PIN_Config BoardGpioInitTable[];
|
||||
#define Board_PWMPIN6 PIN_UNASSIGNED
|
||||
#define Board_PWMPIN7 PIN_UNASSIGNED
|
||||
|
||||
|
||||
/** ============================================================================
|
||||
* Instance identifiers
|
||||
* ==========================================================================*/
|
||||
|
||||
/* Generic SPI instance identifiers */
|
||||
#define Board_SPI0 BOOSTXL_CC2650MA_SPI0
|
||||
|
||||
#ifdef HEADSTAGE_MA_USE_SPI2
|
||||
#define Board_SPI1 BOOSTXL_CC2650MA_SPI1
|
||||
#endif
|
||||
|
||||
/* Generic UART instance identifiers */
|
||||
#define Board_UART BOOSTXL_CC2650MA_UART0
|
||||
|
||||
/* Generic TRNG instance identiifer */
|
||||
#define Board_TRNG BOOSTXL_CC2650MA_TRNG0
|
||||
|
||||
/* Generic GPTimer instance identifiers */
|
||||
#define Board_GPTIMER0A BOOSTXL_CC2650MA_GPTIMER0A
|
||||
#define Board_GPTIMER0B BOOSTXL_CC2650MA_GPTIMER0B
|
||||
@@ -184,6 +239,17 @@ extern const PIN_Config BoardGpioInitTable[];
|
||||
#define Board_GPTIMER2B BOOSTXL_CC2650MA_GPTIMER2B
|
||||
#define Board_GPTIMER3A BOOSTXL_CC2650MA_GPTIMER3A
|
||||
#define Board_GPTIMER3B BOOSTXL_CC2650MA_GPTIMER3B
|
||||
|
||||
/* Generic ADC instance identifiers */
|
||||
#define Board_DIO0_ANALOG PIN_UNASSIGNED
|
||||
#define Board_DIO1_ANALOG PIN_UNASSIGNED
|
||||
#define Board_DIO2_ANALOG PIN_UNASSIGNED
|
||||
#define Board_DIO3_ANALOG PIN_UNASSIGNED
|
||||
#define Board_DIO4_ANALOG PIN_UNASSIGNED
|
||||
#define Board_DIO5_ANALOG PIN_UNASSIGNED
|
||||
#define Board_DIO6_ANALOG PIN_UNASSIGNED
|
||||
#define Board_DIO7_ANALOG PIN_UNASSIGNED
|
||||
|
||||
/* Generic PWM instance identifiers */
|
||||
#define Board_PWM0 BOOSTXL_CC2650MA_PWM0
|
||||
#define Board_PWM1 BOOSTXL_CC2650MA_PWM1
|
||||
@@ -198,6 +264,16 @@ extern const PIN_Config BoardGpioInitTable[];
|
||||
* Number of peripherals and their names
|
||||
* ==========================================================================*/
|
||||
|
||||
/*
|
||||
* @def BOOSTXL_CC2650MA_I2C
|
||||
* @brief Enum of I2C names on the cc2650 dev board
|
||||
*/
|
||||
typedef enum BOOSTXL_CC2650MA_I2CName{
|
||||
BOOSTXL_CC2650MA_I2C0 = 0,
|
||||
|
||||
BOOSTXL_CC2650MA_I2CCOUNT
|
||||
} BOOSTXL_CC2650MA_I2CName;
|
||||
|
||||
/*!
|
||||
* @def BOOSTXL_CC2650MA_CryptoName
|
||||
* @brief Enum of Crypto names on the CC2650 Booster Pack
|
||||
@@ -209,15 +285,19 @@ typedef enum BOOSTXL_CC2650MA_CryptoName {
|
||||
} BOOSTXL_CC2650MA_CryptoName;
|
||||
|
||||
|
||||
// /*!
|
||||
// * @def BOOSTXL_CC2650MA_SPIName
|
||||
// * @brief Enum of SPI names on the CC2650 Booster Pack
|
||||
// */
|
||||
// typedef enum BOOSTXL_CC2650MA_SPIName {
|
||||
// BOOSTXL_CC2650MA_SPI0 = 0,
|
||||
/*!
|
||||
* @def BOOSTXL_CC2650MA_SPIName
|
||||
* @brief Enum of SPI names on the CC2650 Booster Pack
|
||||
*/
|
||||
typedef enum BOOSTXL_CC2650MA_SPIName {
|
||||
BOOSTXL_CC2650MA_SPI0 = 0,
|
||||
|
||||
// BOOSTXL_CC2650MA_SPICOUNT
|
||||
// } BOOSTXL_CC2650MA_SPIName;
|
||||
#ifdef HEADSTAGE_MA_USE_SPI2
|
||||
BOOSTXL_CC2650MA_SPI1 ,
|
||||
#endif
|
||||
|
||||
BOOSTXL_CC2650MA_SPICOUNT
|
||||
} BOOSTXL_CC2650MA_SPIName;
|
||||
|
||||
/*!
|
||||
* @def BOOSTXL_CC2650MA_TRNGName
|
||||
@@ -295,6 +375,35 @@ typedef enum BOOSTXL_CC2650MA_PWM
|
||||
BOOSTXL_CC2650MA_PWMCOUNT
|
||||
} BOOSTXL_CC2650MA_PWM;
|
||||
|
||||
typedef enum BOOSTXL_CC2650MA_WATCHDOG
|
||||
{
|
||||
BOOSTXL_CC2650MA_WATCHDOG0 = 0,
|
||||
BOOSTXL_CC2650MA_WATCHDOGCOUNT
|
||||
} BOOSTXL_CC2650MA_WATCHDOG;
|
||||
|
||||
#ifdef HEADSTAGE_MA_USE_ADC
|
||||
|
||||
/*!
|
||||
* @def BOOSTXL_CC2650MA_ADCName
|
||||
* @brief Enum of ADCs
|
||||
*/
|
||||
typedef enum BOOSTXL_CC2650MA_ADCName {
|
||||
BOOSTXL_CC2650MA_ADC0 = 0,
|
||||
BOOSTXL_CC2650MA_ADC1,
|
||||
BOOSTXL_CC2650MA_ADC2,
|
||||
BOOSTXL_CC2650MA_ADC3,
|
||||
BOOSTXL_CC2650MA_ADC4,
|
||||
BOOSTXL_CC2650MA_ADC5,
|
||||
BOOSTXL_CC2650MA_ADC6,
|
||||
BOOSTXL_CC2650MA_ADC7,
|
||||
BOOSTXL_CC2650MA_ADCDCOUPL,
|
||||
BOOSTXL_CC2650MA_ADCVSS,
|
||||
BOOSTXL_CC2650MA_ADCVDDS,
|
||||
BOOSTXL_CC2650MA_ADCCOUNT
|
||||
} BOOSTXL_CC2650MA_ADCName;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -78,16 +78,19 @@ static void Board_keyCallback(PIN_Handle hPin, PIN_Id pinId);
|
||||
/*******************************************************************************
|
||||
* EXTERNAL VARIABLES
|
||||
*/
|
||||
|
||||
extern bool procedureInProgress;
|
||||
/*********************************************************************
|
||||
* LOCAL VARIABLES
|
||||
*/
|
||||
PIN_State keyPins;
|
||||
PIN_Handle hKeyPins;
|
||||
|
||||
// Value of keys Pressed
|
||||
static uint8_t keysPressed;
|
||||
uint8_t keysPressed;
|
||||
|
||||
// Key debounce clock
|
||||
static Clock_Struct keyChangeClock;
|
||||
Clock_Struct keyChangeClock;
|
||||
|
||||
|
||||
// Pointer to application callback
|
||||
keysPressedCB_t appKeyChangeHandler = NULL;
|
||||
@@ -101,18 +104,52 @@ PIN_Config keyPinsCfg[] =
|
||||
#if defined (CC2650_LAUNCHXL) || defined (CC1350_LAUNCHXL)
|
||||
Board_BTN1 | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
Board_BTN2 | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
Board_UART_RX_IRQ | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLDOWN,
|
||||
#elif defined (CC2650DK_7ID) || defined (CC1350DK_7XD)
|
||||
Board_KEY_SELECT | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
Board_KEY_UP | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
Board_KEY_DOWN | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
Board_KEY_LEFT | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
Board_KEY_RIGHT | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
#elif defined(BOOSTXL_CC2650MA)
|
||||
PIN_MEM_SEL | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
PIN_MEM_REQ | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
PIN_MEM_BZY | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
PIN_RAM_SEL | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
Board_SPI_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,
|
||||
PIN_MEM_TEST | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,
|
||||
#if defined(MODA_BOOSTER_PACK)
|
||||
Board_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
Board_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
#endif
|
||||
|
||||
#endif
|
||||
PIN_TERMINATE
|
||||
};
|
||||
|
||||
PIN_State keyPins;
|
||||
PIN_Handle hKeyPins;
|
||||
extern uint16_t EventMask;
|
||||
extern void ext_call_sem();
|
||||
|
||||
/** event */
|
||||
#define EVT_ALL 0xFFFF
|
||||
#define EVT_MEM_LED 0x0001 /**< set led event */
|
||||
#define EVT_MEM_LED_OFF 0x0002
|
||||
#define EVT_MEM_DECODE_INS 0x0004
|
||||
//#define EVT_PIN_REQST 0x0008
|
||||
#define EVT_MEM_RETURN_DATA 0x0010
|
||||
#define EVT_MEM_CONN_TIMEOUT 0x0020
|
||||
#define EVT_MEM_NOTIFY_HANDLE 0x0040
|
||||
#define EVT_MEM_UART_ROUTINE 0x0080
|
||||
/**
|
||||
* fire a event with [flag].
|
||||
*/
|
||||
#define flag_notify(flag) \
|
||||
do { \
|
||||
uint8 __key = Hwi_disable(); \
|
||||
EventMask |= (uint16_t)(flag); \
|
||||
Hwi_restore(__key); \
|
||||
ext_call_sem(); \
|
||||
} while (0)
|
||||
|
||||
/*********************************************************************
|
||||
* PUBLIC FUNCTIONS
|
||||
@@ -128,38 +165,21 @@ PIN_Handle hKeyPins;
|
||||
*/
|
||||
void Board_initKeys(keysPressedCB_t appKeyCB)
|
||||
{
|
||||
// Initialize KEY pins. Enable int after callback registered
|
||||
hKeyPins = PIN_open(&keyPins, keyPinsCfg);
|
||||
PIN_registerIntCb(hKeyPins, Board_keyCallback);
|
||||
// Initialize KEY pins. Enable int after callback registered
|
||||
hKeyPins = PIN_open(&keyPins, keyPinsCfg);
|
||||
PIN_registerIntCb(hKeyPins, Board_keyCallback);
|
||||
|
||||
#if defined (CC2650_LAUNCHXL) || defined (CC1350_LAUNCHXL)
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_BTN1 | PIN_IRQ_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_BTN2 | PIN_IRQ_NEGEDGE);
|
||||
#elif defined (CC2650DK_7ID) || defined (CC1350DK_7XD)
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_SELECT | PIN_IRQ_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_UP | PIN_IRQ_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_DOWN | PIN_IRQ_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_LEFT | PIN_IRQ_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_RIGHT | PIN_IRQ_NEGEDGE);
|
||||
#endif
|
||||
#if defined (BOOSTXL_CC2650MA)
|
||||
// PIN_setConfig(hKeyPins, PIN_BM_IRQ, PIN_MEM_SEL | PIN_IRQ_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, PIN_MEM_REQ | PIN_IRQ_NEGEDGE);
|
||||
|
||||
#ifdef POWER_SAVING
|
||||
//Enable wakeup
|
||||
#if defined (CC2650_LAUNCHXL) || defined (CC1350_LAUNCHXL)
|
||||
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_BTN1 | PINCC26XX_WAKEUP_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_BTN2 | PINCC26XX_WAKEUP_NEGEDGE);
|
||||
#elif defined (CC2650DK_7ID) || defined (CC1350DK_7XD)
|
||||
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_SELECT | PINCC26XX_WAKEUP_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_UP | PINCC26XX_WAKEUP_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_DOWN | PINCC26XX_WAKEUP_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_LEFT | PINCC26XX_WAKEUP_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_RIGHT | PINCC26XX_WAKEUP_NEGEDGE);
|
||||
#elif defined (CC2650_LAUNCHXL) || defined (CC1350_LAUNCHXL)
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_BTN1 | PIN_IRQ_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_BTN2 | PIN_IRQ_NEGEDGE);
|
||||
#endif
|
||||
#endif //POWER_SAVING
|
||||
|
||||
// Setup keycallback for keys
|
||||
Util_constructClock(&keyChangeClock, Board_keyChangeHandler,
|
||||
KEY_DEBOUNCE_TIMEOUT, 0, false, 0);
|
||||
Util_constructClock(&keyChangeClock, Board_keyChangeHandler, KEY_DEBOUNCE_TIMEOUT, 0, false, 0);
|
||||
|
||||
// Set the application callback
|
||||
appKeyChangeHandler = appKeyCB;
|
||||
@@ -176,47 +196,24 @@ void Board_initKeys(keysPressedCB_t appKeyCB)
|
||||
*/
|
||||
static void Board_keyCallback(PIN_Handle hPin, PIN_Id pinId)
|
||||
{
|
||||
keysPressed = 0;
|
||||
keysPressed = 0;
|
||||
#if defined (BOOSTXL_CC2650MA)
|
||||
// if (PIN_getInputValue(PIN_MEM_REQ) == 0 && !procedureInProgress) {
|
||||
// keysPressed |= KEY_REQ;
|
||||
// flag_notify(EVT_PIN_REQST);
|
||||
// }
|
||||
|
||||
#if defined (CC2650_LAUNCHXL) || defined (CC1350_LAUNCHXL)
|
||||
if ( PIN_getInputValue(Board_BTN1) == 0 )
|
||||
{
|
||||
keysPressed |= KEY_LEFT;
|
||||
}
|
||||
#elif defined (CC2650_LAUNCHXL) || defined (CC1350_LAUNCHXL)
|
||||
if (PIN_getInputValue(Board_BTN1) == 0) {
|
||||
keysPressed |= KEY_LEFT;
|
||||
}
|
||||
|
||||
if ( PIN_getInputValue(Board_BTN2) == 0 )
|
||||
{
|
||||
keysPressed |= KEY_RIGHT;
|
||||
}
|
||||
|
||||
#elif defined (CC2650DK_7ID) || defined (CC1350DK_7XD)
|
||||
if ( PIN_getInputValue(Board_KEY_SELECT) == 0 )
|
||||
{
|
||||
keysPressed |= KEY_SELECT;
|
||||
}
|
||||
|
||||
if ( PIN_getInputValue(Board_KEY_UP) == 0 )
|
||||
{
|
||||
keysPressed |= KEY_UP;
|
||||
}
|
||||
|
||||
if ( PIN_getInputValue(Board_KEY_DOWN) == 0 )
|
||||
{
|
||||
keysPressed |= KEY_DOWN;
|
||||
}
|
||||
|
||||
if ( PIN_getInputValue(Board_KEY_LEFT) == 0 )
|
||||
{
|
||||
keysPressed |= KEY_LEFT;
|
||||
}
|
||||
|
||||
if ( PIN_getInputValue(Board_KEY_RIGHT) == 0 )
|
||||
{
|
||||
keysPressed |= KEY_RIGHT;
|
||||
}
|
||||
if (PIN_getInputValue(Board_BTN2) == 0) {
|
||||
keysPressed |= KEY_RIGHT;
|
||||
}
|
||||
#endif
|
||||
|
||||
Util_startClock(&keyChangeClock);
|
||||
Util_startClock(&keyChangeClock);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
||||
@@ -55,11 +55,10 @@ extern "C" {
|
||||
/*********************************************************************
|
||||
* INCLUDES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL VARIABLES
|
||||
*/
|
||||
|
||||
extern uint8_t KEY_INSTEAD_UART;
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
@@ -68,9 +67,11 @@ extern "C" {
|
||||
#define KEY_DOWN 0x0004
|
||||
#define KEY_LEFT 0x0008
|
||||
#define KEY_RIGHT 0x0010
|
||||
#define KEY_UART_EN 0x0020
|
||||
#define KEY_REQ 0x0040
|
||||
|
||||
// Debounce timeout in milliseconds
|
||||
#define KEY_DEBOUNCE_TIMEOUT 200
|
||||
#define KEY_DEBOUNCE_TIMEOUT 0
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/* Copyright (c) 2021. WiseTop. Scientific.
|
||||
*/
|
||||
#ifndef CENTRAL_GPTIMER_H
|
||||
#define CENTRAL_GPTIMER_H
|
||||
|
||||
//#include <Board.h>
|
||||
#include <ti/drivers/timer/GPTimerCC26XX.h>
|
||||
#include <ti/sysbios/BIOS.h>
|
||||
#include <xdc/runtime/Types.h>
|
||||
|
||||
static GPTimerCC26XX_Handle gptimer_handle;
|
||||
|
||||
static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask);
|
||||
|
||||
#define elite_gptimer_start() GPTimerCC26XX_start(gptimer_handle)
|
||||
#define elite_gptimer_stop() GPTimerCC26XX_stop(gptimer_handle)
|
||||
#define elite_gptimer_close() GPTimerCC26XX_close(gptimer_handle)
|
||||
#define CLOCK_FREQ 4800 // clock freq = 0.1 ms(4800), Measured(4769)
|
||||
|
||||
#define elite_gptimer_open() \
|
||||
do { \
|
||||
GPTimerCC26XX_Params params; \
|
||||
GPTimerCC26XX_Params_init(¶ms); \
|
||||
params.width = GPT_CONFIG_16BIT; \
|
||||
params.mode = GPT_MODE_PERIODIC_UP; \
|
||||
params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF; \
|
||||
gptimer_handle = GPTimerCC26XX_open(Board_GPTIMER0A, ¶ms); \
|
||||
Types_FreqHz freq; \
|
||||
BIOS_getCpuFreq(&freq); \
|
||||
GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; /*47999*/ \
|
||||
GPTimerCC26XX_setLoadValue(gptimer_handle, loadVal); \
|
||||
GPTimerCC26XX_setLoadValue(gptimer_handle, CLOCK_FREQ); /* 0.1 ms*/ \
|
||||
GPTimerCC26XX_registerInterrupt(gptimer_handle, elite_gptimer_callback, GPT_INT_TIMEOUT); \
|
||||
} while (0)
|
||||
|
||||
// GPT counter
|
||||
struct gp_timer_t
|
||||
{
|
||||
uint32_t gp_timer_now;
|
||||
uint32_t gp_timer_last;
|
||||
uint8_t gp_timer_delta;
|
||||
uint32_t gp_timer_switch_ram;
|
||||
};
|
||||
|
||||
|
||||
#endif // CENTRAL_GPTIMER_H
|
||||
@@ -56,6 +56,7 @@
|
||||
|
||||
#include "icall.h"
|
||||
#include "hal_assert.h"
|
||||
#include "board.h"
|
||||
#include "central.h"
|
||||
#include "simple_central.h"
|
||||
|
||||
|
||||
+421
@@ -0,0 +1,421 @@
|
||||
|
||||
/*
|
||||
* Reference web page https://github.com/ti-simplelink/ble_examples/tree/ble_examples-2.2
|
||||
* http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/tirtos/2_20_00_06/
|
||||
* exports/tirtos_full_2_20_00_06/products/tidrivers_cc13xx_cc26xx_2_20_00_08/docs/
|
||||
* doxygen/html/_u_a_r_t_c_c26_x_x_8h.html
|
||||
*/
|
||||
|
||||
#ifndef MEM_BOARD_CENTRAL
|
||||
#define MEM_BOARD_CENTRAL
|
||||
|
||||
#include <ti/sysbios/knl/Clock.h>
|
||||
#include "mem_central_pin.h"
|
||||
#include "mem_uart.h"
|
||||
#include "mem_central_handle_notify.h"
|
||||
#include "mem_uart_routine.h"
|
||||
|
||||
//#include "uart_printf.h"
|
||||
//#include <xdc/runtime/System.h>
|
||||
|
||||
#define BLE_CDR_SAMLL_SIZE 10
|
||||
#define BLE_CHAR2_HANDLE 0x0021 // read CIS return data
|
||||
#define BLE_CHAR3_HANDLE 0x0024 // send instruction
|
||||
#define BLE_CHAR4_CONFIG_HANDLE 0x0028 // notify enable: 0100=enable; 0000=disable
|
||||
|
||||
#define RET_INFO_BUF_SIZE 52
|
||||
|
||||
#define CIS_BUFF_PREFIX 3
|
||||
#define CIS_BUFF_SUFFIX 2
|
||||
#define CIS_DATA_LEN 50
|
||||
static uint16_t CIS_length = 10;
|
||||
static char CIS_data[CIS_DATA_LEN];
|
||||
|
||||
static void mem_central_event();
|
||||
static void mem_recv_ins();
|
||||
static void mem_connect_device(uint8_t addrType, uint8_t *peerAddr);
|
||||
static void mem_send_ins(uint16_t hadnle, uint8_t *value);
|
||||
static void mem_read_data_and_return();
|
||||
static void mem_central_get_cis(uint8_t handle);
|
||||
static void mem_connection_timeout();
|
||||
|
||||
static void MemBoard_init(void){
|
||||
mem_UART_init();
|
||||
master_spi_open();
|
||||
central_ram_init();
|
||||
central_reset();
|
||||
|
||||
flag_enable(EVT_MEM_UART_ROUTINE);
|
||||
|
||||
// uint8_t txBuf[] = "Simple Central memory board MA\n\r"; // Transmit buffer
|
||||
// UART_txBuf = txBuf;
|
||||
// UART_write(uart_handle, txBuf, sizeof(txBuf));
|
||||
|
||||
|
||||
// mem_UART_display(txBuf);
|
||||
}
|
||||
|
||||
static EventTableEntry EVENT_TABLE[] = { //
|
||||
{EVT_ALL, &mem_central_event},
|
||||
|
||||
// terminated
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
/**
|
||||
* system event handle. It go through [EVENT_TABLE] and invoke event callback
|
||||
* if event_mask bits set.
|
||||
*/
|
||||
static void mem_event_handle() {
|
||||
for (EventTableEntry *entry = EVENT_TABLE; EventMask && entry->event_mask; entry++) {
|
||||
if (entry->event_callback && flag_mask(entry->event_mask)) {
|
||||
entry->event_callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef enum{
|
||||
LED_OFF,
|
||||
LED_ON
|
||||
} LED_Status;
|
||||
|
||||
typedef enum{
|
||||
UART_NO_DATA,
|
||||
UART_RECEIVED_DATA
|
||||
} UART_DATA_Status;
|
||||
|
||||
static LED_Status GLEDStatus = LED_OFF;
|
||||
static UART_DATA_Status UARTStatus = UART_NO_DATA;
|
||||
|
||||
static void mem_central_event() {
|
||||
if(flag_mask(EVT_MEM_NOTIFY_HANDLE)){
|
||||
flag_disable(EVT_MEM_NOTIFY_HANDLE);
|
||||
// notify_handle_done = false;
|
||||
central_handle_notify();
|
||||
}
|
||||
|
||||
// if (flag_mask(EVT_PIN_REQST)){
|
||||
// flag_disable(EVT_PIN_REQST);
|
||||
//
|
||||
// // spi idle
|
||||
// if (notify_handle_done){
|
||||
// master_switch_memory();
|
||||
// }
|
||||
// // spi busy
|
||||
// else{
|
||||
// ram_sw = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
if(flag_mask(EVT_MEM_UART_ROUTINE)){
|
||||
flag_disable(EVT_MEM_UART_ROUTINE);
|
||||
mem_uart_routine();
|
||||
}
|
||||
|
||||
// if (flag_mask(EVT_MEM_LED)) {
|
||||
// flag_disable(EVT_MEM_LED);
|
||||
// GLEDStatus = LED_ON;
|
||||
//// SetMemOutputPIN(Board_GLED, 1);
|
||||
// }
|
||||
//
|
||||
// if(flag_mask(EVT_MEM_LED_OFF)){
|
||||
// flag_disable(EVT_MEM_LED_OFF);
|
||||
// GLEDStatus = LED_OFF;
|
||||
//// SetMemOutputPIN(Board_GLED, 0);
|
||||
// }
|
||||
|
||||
|
||||
if(flag_mask(EVT_MEM_INS_CHECK_SURVIVE)){
|
||||
flag_disable(EVT_MEM_INS_CHECK_SURVIVE);
|
||||
|
||||
char ACK[15] = {4,0,1,3}; //ack success
|
||||
UART_write(uart_handle, ACK, 4);
|
||||
}
|
||||
|
||||
if(flag_mask(EVT_MEM_INS_SCAN)){
|
||||
flag_disable(EVT_MEM_INS_SCAN);
|
||||
SimpleBLECentral_discoverDevices();
|
||||
}
|
||||
|
||||
if(flag_mask(EVT_MEM_INS_CONNECT)){
|
||||
flag_disable(EVT_MEM_INS_CONNECT);
|
||||
mem_connect_device(store_rxBuf[2], store_rxBuf+3);
|
||||
}
|
||||
|
||||
if(flag_mask(EVT_MEM_INS_WRITE)){
|
||||
flag_disable(EVT_MEM_INS_WRITE);
|
||||
if(state == BLE_STATE_CONNECTED){
|
||||
// This is done by SimpleBLECentral_processRoleEvent() in the case "GAP_LINK_ESTABLISHED_EVENT"
|
||||
mem_send_ins(store_rxBuf[2], store_rxBuf+3);
|
||||
}
|
||||
}
|
||||
|
||||
if(flag_mask(EVT_MEM_INS_READ)){
|
||||
flag_disable(EVT_MEM_INS_READ);
|
||||
if(state == BLE_STATE_CONNECTED){
|
||||
mem_central_get_cis(store_rxBuf[2]);
|
||||
}
|
||||
}
|
||||
|
||||
if(flag_mask(EVT_MEM_INS_DISCONNECT)){
|
||||
flag_disable(EVT_MEM_INS_DISCONNECT);
|
||||
GAPCentralRole_TerminateLink(connHandle);
|
||||
state = BLE_STATE_DISCONNECTING;
|
||||
}
|
||||
|
||||
if(flag_mask(EVT_MEM_RETURN_DATA)){
|
||||
flag_disable(EVT_MEM_RETURN_DATA);
|
||||
mem_read_data_and_return();
|
||||
}
|
||||
|
||||
if(flag_mask(EVT_MEM_CONN_TIMEOUT)){
|
||||
flag_disable(EVT_MEM_CONN_TIMEOUT);
|
||||
mem_connection_timeout();
|
||||
}
|
||||
}
|
||||
|
||||
static Control_Ins ins = INS_IDLE;
|
||||
|
||||
static void mem_recv_ins(){
|
||||
extern uint8_t keysPressed;
|
||||
extern Clock_Struct keyChangeClock;
|
||||
|
||||
switch(UART_rxBuf[0]){
|
||||
case INS_IDLE:{
|
||||
break;
|
||||
}
|
||||
|
||||
case INS_RESET:{
|
||||
state = BLE_STATE_IDLE;
|
||||
connHandle = GAP_CONNHANDLE_INIT;
|
||||
discState = BLE_DISC_STATE_IDLE;
|
||||
break;
|
||||
}
|
||||
|
||||
case INS_KEY:{
|
||||
if(UART_rxBuf[2] == 1){
|
||||
keysPressed = KEY_LEFT;
|
||||
Util_startClock(&keyChangeClock);
|
||||
}
|
||||
else if(UART_rxBuf[2] == 2){
|
||||
keysPressed = KEY_RIGHT;
|
||||
Util_startClock(&keyChangeClock);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case INS_SCAN:{
|
||||
SimpleBLECentral_discoverDevices();
|
||||
break;
|
||||
}
|
||||
|
||||
// instruction format:
|
||||
// ins[0]: INS_SCAN_RESPONSE = 0x04
|
||||
// ins[1]: scan_response (device number)=0, a certain device = device_id
|
||||
// ins[2]: attr_length=0, e.g. len(addr)=6, len(company_code)=4, len(localName)=20
|
||||
// addr=1, localName=2, company_code=3, version_info=4, battery_info=5
|
||||
|
||||
case INS_CONNECT:{
|
||||
mem_connect_device(UART_rxBuf[2], UART_rxBuf+3);
|
||||
break;
|
||||
}
|
||||
|
||||
case INS_WRITE:{
|
||||
if(state == BLE_STATE_CONNECTED){
|
||||
// This is done by SimpleBLECentral_processRoleEvent() in the case "GAP_LINK_ESTABLISHED_EVENT"
|
||||
mem_send_ins(UART_rxBuf[2], UART_rxBuf+3);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case INS_READ:{
|
||||
if(state == BLE_STATE_CONNECTED){
|
||||
mem_central_get_cis(UART_rxBuf[2]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case INS_DISCONNECT:{
|
||||
// clear scan result
|
||||
GAPCentralRole_TerminateLink(connHandle);
|
||||
state = BLE_STATE_DISCONNECTING;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:{
|
||||
uint8_t error_msg[35] = "error";
|
||||
error_msg[6] = state;
|
||||
error_msg[7] = 0xFF;
|
||||
for(int i = 0 ; i < UART_BUFF_SIZE ; i++){
|
||||
error_msg[8+i] = UART_rxBuf[i];
|
||||
}
|
||||
UART_write(uart_handle, error_msg, 35);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mem_connect_device(uint8_t addrType, uint8_t *peerAddr) {
|
||||
|
||||
uint8_t Addr[B_ADDR_LEN];
|
||||
|
||||
for(int i=0 ; i<B_ADDR_LEN ; i++){
|
||||
Addr[5-i] = *(peerAddr+i);
|
||||
}
|
||||
|
||||
// UART_write(uart_handle, Addr, 6);
|
||||
|
||||
state = BLE_STATE_CONNECTING;
|
||||
|
||||
Util_startClock(&connectingClock);
|
||||
|
||||
GAPCentralRole_EstablishLink(DEFAULT_LINK_HIGH_DUTY_CYCLE,
|
||||
DEFAULT_LINK_WHITE_LIST,
|
||||
addrType, Addr);
|
||||
}
|
||||
|
||||
static void mem_send_ins(uint16_t handle, uint8_t *value){
|
||||
|
||||
if (state == BLE_STATE_CONNECTED &&
|
||||
charHdl != 0 &&
|
||||
procedureInProgress == FALSE)
|
||||
{
|
||||
uint8_t ACK[15] = {0}; //ack success
|
||||
ACK[1] = handle;
|
||||
ACK[2] = value[0];
|
||||
ACK[3] = value[1];
|
||||
UART_write(uart_handle, ACK, 4);
|
||||
uint8_t status;
|
||||
|
||||
// Do a read or write as long as no other read or write is in progress
|
||||
// Do a write
|
||||
attWriteReq_t req;
|
||||
|
||||
// enable notify
|
||||
req.handle = handle;
|
||||
req.len = 19;
|
||||
if(handle == BLE_CHAR3_HANDLE){
|
||||
// RIS, VIS, CIS instruction
|
||||
req.len = 19;
|
||||
}
|
||||
else if(handle == BLE_CHAR4_CONFIG_HANDLE){
|
||||
// notify enable
|
||||
req.len = 2;
|
||||
}
|
||||
else{
|
||||
uint8_t error_handle[13] = "error handle";
|
||||
UART_write(uart_handle, error_handle, 13);
|
||||
status = bleMemAllocError;
|
||||
return;
|
||||
}
|
||||
|
||||
req.pValue = GATT_bm_alloc(connHandle, ATT_WRITE_REQ, req.len, NULL);
|
||||
if ( req.pValue != NULL )
|
||||
{
|
||||
// send instruction
|
||||
for(int i=0 ; i < req.len ; i++){
|
||||
req.pValue[i] = *(value+i);
|
||||
}
|
||||
req.sig = 0;
|
||||
req.cmd = 0;
|
||||
status = GATT_WriteCharValue(connHandle, &req, selfEntity);
|
||||
|
||||
// uncomment GATT_WriteLongCharValue if we need a long instruction;
|
||||
// However, there are some error to fix when using GATT_WriteLongCharValue
|
||||
// status = GATT_WriteLongCharValue(connHandle, &req, selfEntity);
|
||||
|
||||
if ( status != SUCCESS )
|
||||
{
|
||||
GATT_bm_free((gattMsg_t *)&req, ATT_WRITE_REQ);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t error_msg[10] = "err";
|
||||
error_msg[3] = req.handle;
|
||||
error_msg[4] = *value;
|
||||
error_msg[5] = *(value+1);
|
||||
error_msg[6] = *(value+2);
|
||||
error_msg[7] = *(value+3);
|
||||
error_msg[8] = *(value+4);
|
||||
error_msg[9] = *(value+5);
|
||||
UART_write(uart_handle, error_msg, 10);
|
||||
status = bleMemAllocError;
|
||||
}
|
||||
|
||||
if (status == SUCCESS)
|
||||
{
|
||||
procedureInProgress = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mem_central_get_cis(uint8_t handle){
|
||||
// get the actual CIS data from simple_central.c > SimpleBLECentral_processGATTMsg()
|
||||
if (state == BLE_STATE_CONNECTED &&
|
||||
charHdl != 0 &&
|
||||
procedureInProgress == FALSE)
|
||||
{
|
||||
uint8_t status;
|
||||
|
||||
// send read command
|
||||
attReadReq_t read_cis_req;
|
||||
read_cis_req.handle = handle;
|
||||
status = GATT_ReadCharValue(connHandle, &read_cis_req, selfEntity);
|
||||
|
||||
if (status == SUCCESS)
|
||||
{
|
||||
procedureInProgress = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mem_read_data_and_return(){
|
||||
/*
|
||||
* CIS data formate:
|
||||
* Elite send to central:
|
||||
* +------------+------------------+
|
||||
* | Header(1B) | Payload(nB) |
|
||||
* +------------+------------------+
|
||||
* |d0(recv_len)| d1, d2, d3, ... |
|
||||
* +------------+------------------+
|
||||
* ex: | 0x03 | 0x10,0xC0,0x01 | <--- barrery data
|
||||
* +------------+------------------+
|
||||
*
|
||||
* central send to controller:
|
||||
* +--------------------+------------------+
|
||||
* | Header(3B) | Payload |
|
||||
* +---+---+------------+------------------+
|
||||
* | 4 | 0 | ret_length | d1, d2, d3, ... |
|
||||
* +---+---+------------+------------------+
|
||||
* ex: | 4 | 0 | 0x14 | 0x10,0xC0,0x01 | <--- barrery data
|
||||
* +---+---+------------+------------------+
|
||||
*
|
||||
*/
|
||||
|
||||
// add prefix and suffix to sync communication
|
||||
uint16_t ret_length;
|
||||
|
||||
if (CIS_length < 22) {
|
||||
ret_length = 20;
|
||||
} else {
|
||||
ret_length = CIS_length - CIS_BUFF_PREFIX;
|
||||
}
|
||||
|
||||
CIS_data[0] = 4;
|
||||
CIS_data[1] = 0;
|
||||
CIS_data[2] = ret_length;
|
||||
CIS_data[CIS_length++] = 0;
|
||||
CIS_data[CIS_length++] = 0;
|
||||
|
||||
UART_write(uart_handle, CIS_data, ret_length + CIS_BUFF_PREFIX);
|
||||
|
||||
memset(CIS_data, 0, CIS_DATA_LEN);
|
||||
}
|
||||
|
||||
static void mem_connection_timeout(){
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
+315
@@ -0,0 +1,315 @@
|
||||
|
||||
#ifndef CENTRAL_NOTIFY
|
||||
#define CENTRAL_NOTIFY
|
||||
|
||||
#include "mem_event.h"
|
||||
#include "mem_uart.h"
|
||||
#include "mem_central_pin.h"
|
||||
#include "mem_central_spi.h"
|
||||
#include "mem_board_central.h"
|
||||
|
||||
/*========================
|
||||
==== notify variable ====
|
||||
=======================*/
|
||||
|
||||
#define MEM_BUFFER_SIZE SPI_TX_BUFFER_SIZE // 250
|
||||
//#define MEM_SWITCH_THRESHOLD 7000 //max:7K bytes
|
||||
|
||||
#define MSM_REG_WRITE 0x01
|
||||
#define MEM_INS_WRITE 0x02
|
||||
#define MEM_INS_READ 0x03
|
||||
#define MEM_REG_READ 0x05
|
||||
|
||||
#define MEM_META_LENGTH 12
|
||||
|
||||
#define central_ram_init() \
|
||||
do { \
|
||||
master_tx_buffer[0] = MSM_REG_WRITE; \
|
||||
master_tx_buffer[1] = 0b01000011; \
|
||||
central_ram_select(1); \
|
||||
central_spi_send(master_tx_buffer, 2); \
|
||||
central_ram_select(0); \
|
||||
central_spi_send(master_tx_buffer, 2); \
|
||||
} while (0)
|
||||
|
||||
|
||||
static uint16_t not_counter = 0; // writing counter, increase when notify
|
||||
static uint16_t not_offset = 0; // writing pointer, where to write on RAM
|
||||
|
||||
static uint16_t notify_length = 0;
|
||||
static uint8_t notify_value[MEM_BUFFER_SIZE] = {0}; // recv data from elite
|
||||
|
||||
void master_switch_memory();
|
||||
|
||||
static void central_reset()
|
||||
{
|
||||
not_counter = 0;
|
||||
not_offset = MEM_META_LENGTH;
|
||||
ram_sel_signal = false;
|
||||
central_ram_select(ram_sel_signal);
|
||||
|
||||
}
|
||||
|
||||
static void reset_status_register()
|
||||
{
|
||||
uint8_t status_register_buf[2];
|
||||
status_register_buf[0] = MSM_REG_WRITE;
|
||||
status_register_buf[1] = 0b01000011;
|
||||
central_spi_send(status_register_buf, 2);
|
||||
|
||||
}
|
||||
|
||||
#define RAM_INS_LEN 3
|
||||
|
||||
#define RAM_RED_HEADER_LEN 3
|
||||
#define RAM_RED_TAILER_LEN 5
|
||||
#define ELITE_NOTIFY_LEN 40
|
||||
#define RAM_RED_CHECK_SUM_LEN 1
|
||||
#define RAM_RED_DATA_LEN (RAM_RED_HEADER_LEN + RAM_RED_TAILER_LEN + ELITE_NOTIFY_LEN + RAM_RED_CHECK_SUM_LEN)
|
||||
#define RAM_RED_CTX_LEN (RAM_INS_LEN + RAM_RED_DATA_LEN)
|
||||
|
||||
#define RAM_GREEN_CTX_LEN (MEM_META_LENGTH + RAM_INS_LEN)
|
||||
|
||||
static uint8_t green_wrong = 0;
|
||||
static uint8_t green_retry_cnt = 0;
|
||||
|
||||
uint8_t check_sum(uint8_t message[], int nBytes)
|
||||
{
|
||||
uint8_t sum = 0;
|
||||
|
||||
while (nBytes-- > 0) {
|
||||
sum += *(message++);
|
||||
}
|
||||
|
||||
return sum;
|
||||
|
||||
}
|
||||
|
||||
static void central_handle_notify()
|
||||
{
|
||||
uint8_t spi_buffer0[MEM_BUFFER_SIZE] = {0};
|
||||
uint8_t spi_buffer1[MEM_BUFFER_SIZE] = {0};
|
||||
uint8_t read_ram_ins[RAM_RED_CTX_LEN] = {0};
|
||||
uint8_t read_ram_buf[RAM_RED_CTX_LEN] = {0};
|
||||
uint8_t tailer[RAM_RED_TAILER_LEN] = {0};
|
||||
static bool spi_buffer_index = true;
|
||||
static uint8_t wrong = 0;
|
||||
static uint8_t retry_cnt = 0;
|
||||
bool wrong_flag = false;
|
||||
bool write_again = false;
|
||||
uint8_t write_limit = 0;
|
||||
uint8_t check_number = 0;
|
||||
uint8_t pkg_cnt;
|
||||
uint8_t *p;
|
||||
int index;
|
||||
int i;
|
||||
|
||||
// localize current buffer
|
||||
if (spi_buffer_index) {
|
||||
spi_buffer_index = false;
|
||||
p = spi_buffer0;
|
||||
} else {
|
||||
spi_buffer_index = true;
|
||||
p = spi_buffer1;
|
||||
}
|
||||
|
||||
memset(p, 0, MEM_BUFFER_SIZE);
|
||||
pkg_cnt = not_counter;
|
||||
not_counter = not_counter + 1;
|
||||
|
||||
// update offset
|
||||
uint32_t cnt_offset = not_offset;
|
||||
if (not_offset > 7500) {
|
||||
not_offset = not_offset;
|
||||
} else {
|
||||
not_offset = not_offset + RAM_RED_DATA_LEN;
|
||||
}
|
||||
|
||||
tailer[0] = wrong;
|
||||
tailer[1] = retry_cnt;
|
||||
tailer[2] = green_wrong;
|
||||
tailer[3] = green_retry_cnt;
|
||||
tailer[4] = ram_sel_signal;
|
||||
|
||||
p[0] = MEM_INS_WRITE; // instruction
|
||||
p[1] = (uint8_t)((cnt_offset >> 8) & 0xFF); // address
|
||||
p[2] = (uint8_t)(cnt_offset & 0xFF); // address
|
||||
p[3] = 0xFF; // RAM_RED_HEADER_LEN: data header
|
||||
p[4] = pkg_cnt; // RAM_RED_HEADER_LEN: data counter
|
||||
p[5] = notify_length; // RAM_RED_HEADER_LEN: data content length
|
||||
|
||||
index = RAM_INS_LEN + RAM_RED_HEADER_LEN;
|
||||
memcpy(p + index, notify_value, ELITE_NOTIFY_LEN); // ELITE_NOTIFY_LEN: data content
|
||||
|
||||
index += ELITE_NOTIFY_LEN;
|
||||
memcpy(p + index, tailer, RAM_RED_TAILER_LEN); // RAM_RED_TAILER_LEN: tailer content
|
||||
|
||||
index += RAM_RED_TAILER_LEN;
|
||||
p[index] = check_sum(p+3, RAM_RED_DATA_LEN - RAM_RED_CHECK_SUM_LEN); // RAM_RED_CHECK_SUM_LEN
|
||||
|
||||
central_spi_send(p, RAM_RED_CTX_LEN);
|
||||
|
||||
// read RAM
|
||||
read_ram_ins[0] = 0x03; //read RAM
|
||||
read_ram_ins[1] = (uint8_t)((cnt_offset >> 8) & 0xFF); // address
|
||||
read_ram_ins[2] = (uint8_t)(cnt_offset & 0xFF); // address
|
||||
central_spi_recv(read_ram_ins, read_ram_buf);
|
||||
|
||||
while (1) {
|
||||
// compare data
|
||||
check_number = check_sum(p+3, RAM_RED_DATA_LEN - RAM_RED_CHECK_SUM_LEN);
|
||||
if (check_number != p[RAM_RED_CTX_LEN-1]) {
|
||||
write_again = true;
|
||||
memset(p+3, 255, RAM_RED_DATA_LEN - RAM_RED_CHECK_SUM_LEN);
|
||||
p[RAM_RED_CTX_LEN-1] = check_sum(p+3, RAM_RED_DATA_LEN - RAM_RED_CHECK_SUM_LEN);
|
||||
|
||||
} else {
|
||||
check_number = check_sum(read_ram_buf+3, RAM_RED_DATA_LEN - RAM_RED_CHECK_SUM_LEN);
|
||||
if (check_number != read_ram_buf[RAM_RED_CTX_LEN-1]) {
|
||||
write_again = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (write_again == false) {
|
||||
for (i=3; i<RAM_RED_CTX_LEN; i++) {
|
||||
if (p[i]!=read_ram_buf[i]) {
|
||||
write_again = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (write_again) {
|
||||
reset_status_register();
|
||||
CPUdelay(10 * 16); // 10us
|
||||
|
||||
write_again = false;
|
||||
retry_cnt++;
|
||||
write_limit++;
|
||||
|
||||
//write RAM
|
||||
central_spi_send(p, RAM_RED_CTX_LEN);
|
||||
|
||||
// read RAM
|
||||
read_ram_ins[0] = 0x03; //read RAM
|
||||
read_ram_ins[1] = (uint8_t)((cnt_offset >> 8) & 0xFF); // address
|
||||
read_ram_ins[2] = (uint8_t)(cnt_offset & 0xFF); // address
|
||||
central_spi_recv(read_ram_ins, read_ram_buf);
|
||||
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
if (write_limit >= 5) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (i=3; i<RAM_RED_CTX_LEN; i++) {
|
||||
if (p[i] != read_ram_buf[i]) {
|
||||
wrong_flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (wrong_flag) {
|
||||
wrong++;
|
||||
reset_status_register();
|
||||
CPUdelay(10 * 16); // 10us
|
||||
}
|
||||
|
||||
// if (ram_sel_signal) {
|
||||
// central_pin_output(PIN_MEM_TEST, 1);
|
||||
// } else {
|
||||
// central_pin_output(PIN_MEM_TEST, 0);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
void master_switch_memory()
|
||||
{
|
||||
uint8_t read_ram_ins[RAM_GREEN_CTX_LEN] = {0};
|
||||
uint8_t read_ram_buf[RAM_GREEN_CTX_LEN] = {0};
|
||||
uint8_t *p = master_tx_buffer; // localize current buffer
|
||||
bool wrong_flag = false;
|
||||
bool write_again = false;
|
||||
uint8_t write_limit = 0;
|
||||
uint16_t cnt_offset;
|
||||
int i;
|
||||
|
||||
cnt_offset = not_offset;
|
||||
not_offset = MEM_META_LENGTH;
|
||||
|
||||
memset(p, 0, sizeof(master_tx_buffer)/sizeof(master_tx_buffer[0]));
|
||||
p[0] = MEM_INS_WRITE; // instruction
|
||||
p[1] = 0;
|
||||
p[2] = 0;
|
||||
p[3] = (uint8_t)((cnt_offset >> 8) & 0xFF); // data: notify data length
|
||||
p[4] = (uint8_t)(cnt_offset & 0xFF); // data: notify data length
|
||||
p[5] = 0xA5;
|
||||
p[6] = 0x5A;
|
||||
memcpy(p + 7, p + 3, 4);
|
||||
memcpy(p + 11, p + 3, 4);
|
||||
central_spi_send(p, RAM_GREEN_CTX_LEN);
|
||||
|
||||
// read RAM
|
||||
read_ram_ins[0] = MEM_INS_READ; //read RAM
|
||||
read_ram_ins[1] = 0; // address
|
||||
read_ram_ins[2] = 0; // address
|
||||
central_spi_recv(read_ram_ins, read_ram_buf);
|
||||
|
||||
while (1) {
|
||||
// compare data
|
||||
for (i=3; i<RAM_GREEN_CTX_LEN; i++) {
|
||||
if (p[i] != read_ram_buf[i]) {
|
||||
write_again = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (write_again) {
|
||||
write_again = false;
|
||||
green_retry_cnt++;
|
||||
write_limit++;
|
||||
reset_status_register();
|
||||
CPUdelay(10 * 16); // 10us
|
||||
|
||||
//write RAM
|
||||
central_spi_send(p, RAM_GREEN_CTX_LEN);
|
||||
|
||||
// read RAM
|
||||
read_ram_ins[0] = MEM_INS_READ; //read RAM
|
||||
read_ram_ins[1] = 0; // address
|
||||
read_ram_ins[2] = 0; // address
|
||||
central_spi_recv(read_ram_ins, read_ram_buf);
|
||||
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
if (write_limit >= 5) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (i=3; i<RAM_GREEN_CTX_LEN; i++) {
|
||||
if (p[i] != read_ram_buf[i]) {
|
||||
wrong_flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (wrong_flag) {
|
||||
green_wrong++;
|
||||
}
|
||||
|
||||
// switch memory
|
||||
ram_sel_signal = !ram_sel_signal;
|
||||
central_ram_select(ram_sel_signal);
|
||||
|
||||
CPUdelay(10 * 16); // 10us
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
|
||||
#ifndef MEM_CENTRAL_PIN
|
||||
#define MEM_CENTRAL_PIN
|
||||
|
||||
//extern PIN_State keyPins;
|
||||
extern PIN_Handle hKeyPins;
|
||||
|
||||
#define central_pin_output(pin, value) PIN_setOutputValue(hKeyPins, PIN_ID(pin), (value))
|
||||
#define central_pin_input(pin) PIN_getInputValue(PIN_ID(pin))
|
||||
|
||||
#define central_ram_select(value) central_pin_output(PIN_RAM_SEL, (value) ? 1 : 0)
|
||||
|
||||
#endif
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
#ifndef CENTRAL_SPI_H
|
||||
#define CENTRAL_SPI_H
|
||||
|
||||
// clang-format off
|
||||
#include <ti/drivers/SPI.h>
|
||||
#include <ti/drivers/dma/UDMACC26XX.h>
|
||||
#include <ti/drivers/spi/SPICC26XXDMA.h>
|
||||
// clang-format on
|
||||
|
||||
#include "mem_central_pin.h"
|
||||
|
||||
#define SPI_TX_BUFFER_SIZE 250
|
||||
|
||||
static uint8_t master_tx_buffer[SPI_TX_BUFFER_SIZE] = {0};
|
||||
|
||||
static SPI_Handle central_spi_handle;
|
||||
static SPI_Transaction central_spi_transaction;
|
||||
|
||||
#define master_spi_open() \
|
||||
do { \
|
||||
SPI_init(); \
|
||||
SPI_Params spi_parameter; \
|
||||
SPI_Params_init(&spi_parameter); \
|
||||
spi_parameter.transferMode = SPI_MODE_BLOCKING; \
|
||||
spi_parameter.mode = SPI_MASTER; \
|
||||
spi_parameter.bitRate = 12000000; \
|
||||
spi_parameter.transferTimeout = 1000; \
|
||||
spi_parameter.dataSize = 8; \
|
||||
spi_parameter.frameFormat = SPI_POL0_PHA0; \
|
||||
central_spi_handle = SPI_open(Board_SPI0, &spi_parameter); \
|
||||
} while (0)
|
||||
|
||||
#define SPI_close() SPI_close(central_spi_handle)
|
||||
|
||||
static void SPI_reopen(){
|
||||
SPI_init();
|
||||
SPI_Params spi_parameter;
|
||||
SPI_Params_init(&spi_parameter);
|
||||
spi_parameter.transferMode = SPI_MODE_BLOCKING;
|
||||
spi_parameter.mode = SPI_MASTER;
|
||||
spi_parameter.bitRate = 8000000;
|
||||
spi_parameter.transferTimeout = 1000;
|
||||
spi_parameter.dataSize = 8;
|
||||
spi_parameter.frameFormat = SPI_POL0_PHA0;
|
||||
central_spi_handle = SPI_open(Board_SPI0, &spi_parameter);
|
||||
}
|
||||
|
||||
#define central_spi_send(data, len) \
|
||||
do { \
|
||||
central_spi_transaction.txBuf = data; \
|
||||
central_spi_transaction.rxBuf = NULL; \
|
||||
central_spi_transaction.count = (len); \
|
||||
central_pin_output(Board_SPI_CS, 0); \
|
||||
SPI_transfer(central_spi_handle, ¢ral_spi_transaction); \
|
||||
central_pin_output(Board_SPI_CS, 1); \
|
||||
} while (0)
|
||||
|
||||
#define central_spi_recv(ins, data) \
|
||||
do { \
|
||||
central_spi_transaction.txBuf = ins; \
|
||||
central_spi_transaction.rxBuf = data; \
|
||||
central_pin_output(Board_SPI_CS, 0); \
|
||||
SPI_transfer(central_spi_handle, ¢ral_spi_transaction); \
|
||||
central_pin_output(Board_SPI_CS, 1); \
|
||||
} while (0)
|
||||
|
||||
#endif // CENTRAL_SPI_H
|
||||
@@ -0,0 +1,71 @@
|
||||
|
||||
#ifndef MEM_EVENT_H
|
||||
#define MEM_EVENT_H
|
||||
|
||||
/**
|
||||
* test event [flag] has been enabled.
|
||||
*/
|
||||
#define flag_mask(flag) ((EventMask & (flag)) != 0)
|
||||
|
||||
/**
|
||||
* enable event [flag].
|
||||
*/
|
||||
#define flag_enable(flag) \
|
||||
do { \
|
||||
uint8 __key = Hwi_disable(); \
|
||||
EventMask |= (uint16_t)(flag); \
|
||||
Hwi_restore(__key); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* disable event [flag].
|
||||
*/
|
||||
#define flag_disable(flag) \
|
||||
do { \
|
||||
uint8 __key = Hwi_disable(); \
|
||||
EventMask &= ~((uint16_t)(flag)); \
|
||||
Hwi_restore(__key); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* fire a event with [flag].
|
||||
*/
|
||||
#define flag_notify(flag) \
|
||||
do { \
|
||||
uint8 __key = Hwi_disable(); \
|
||||
EventMask |= (uint16_t)(flag); \
|
||||
Hwi_restore(__key); \
|
||||
Semaphore_post(sem); \
|
||||
} while (0)
|
||||
|
||||
/** event */
|
||||
#define EVT_ALL 0xFFFF
|
||||
#define EVT_MEM_LED 0x0001 /**< set led event */
|
||||
#define EVT_MEM_LED_OFF 0x0002
|
||||
#define EVT_MEM_DECODE_INS 0x0004
|
||||
//#define EVT_PIN_REQST 0x0008
|
||||
#define EVT_MEM_RETURN_DATA 0x0010
|
||||
#define EVT_MEM_CONN_TIMEOUT 0x0020
|
||||
#define EVT_MEM_NOTIFY_HANDLE 0x0040
|
||||
#define EVT_MEM_UART_ROUTINE 0x0080
|
||||
|
||||
uint16_t EventMask = 0;
|
||||
|
||||
/**
|
||||
* event table entry.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* event mask.
|
||||
*/
|
||||
uint16_t event_mask;
|
||||
|
||||
/**
|
||||
* event callback. invoked by system when system [EVENT_MASK] set with
|
||||
* [event_mask] bits.
|
||||
*/
|
||||
void (*event_callback)();
|
||||
} EventTableEntry;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,203 @@
|
||||
|
||||
#ifndef MEM_UART
|
||||
#define MEM_UART
|
||||
|
||||
/*
|
||||
* http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/tirtos/
|
||||
* 2_20_00_06/exports/tirtos_full_2_20_00_06/products/tidrivers_cc13xx_cc26xx_2_20_00_08/
|
||||
* docs/doxygen/html/_u_a_r_t_c_c26_x_x_8h.html
|
||||
*/
|
||||
|
||||
#include <ti/drivers/UART.h>
|
||||
#include <ti/drivers/uart/UARTCC26XX.h>
|
||||
#include "mem_event.h"
|
||||
|
||||
#define UART_BUFF_SIZE 25
|
||||
|
||||
static UART_Handle uart_handle;
|
||||
static UART_Params params;
|
||||
|
||||
static uint8_t UART_txBuf[UART_BUFF_SIZE];
|
||||
static uint8_t UART_rxBuf[UART_BUFF_SIZE];
|
||||
|
||||
static uint8_t store_rxBuf[UART_BUFF_SIZE];
|
||||
|
||||
typedef enum{
|
||||
INS_IDLE,
|
||||
INS_RESET,
|
||||
INS_KEY,
|
||||
INS_SCAN,
|
||||
INS_SCAN_RESPONSE,
|
||||
INS_CONNECT,
|
||||
INS_WRITE,
|
||||
INS_READ,
|
||||
INS_DISCONNECT,
|
||||
INS_PREPARE_CONNECT,
|
||||
INS_CHECK_SURVIVE
|
||||
} Control_Ins;
|
||||
|
||||
/** event */
|
||||
#define EVT_ALL 0xFFFF
|
||||
#define EVT_MEM_LED 0x0001 /**< set led event */
|
||||
#define EVT_MEM_LED_OFF 0x0002
|
||||
#define EVT_MEM_DECODE_INS 0x0004
|
||||
//#define EVT_PIN_REQST 0x0008
|
||||
#define EVT_MEM_RETURN_DATA 0x0010
|
||||
#define EVT_MEM_CONN_TIMEOUT 0x0020
|
||||
#define EVT_MEM_NOTIFY_HANDLE 0x0040
|
||||
#define EVT_MEM_UART_ROUTINE 0x0080
|
||||
#define EVT_MEM_INS_SCAN 0x0100
|
||||
#define EVT_MEM_INS_CONNECT 0x0200
|
||||
#define EVT_MEM_INS_WRITE 0x0400
|
||||
#define EVT_MEM_INS_READ 0x0800
|
||||
#define EVT_MEM_INS_DISCONNECT 0x1000
|
||||
#define EVT_MEM_INS_CHECK_SURVIVE 0x2000
|
||||
|
||||
|
||||
#define IS_EVT_MEM_DECODE_INS(_b) ((_b)[0] == INS_SCAN || \
|
||||
(_b)[0] == INS_CONNECT || \
|
||||
(_b)[0] == INS_WRITE || \
|
||||
(_b)[0] == INS_READ || \
|
||||
(_b)[0] == INS_DISCONNECT || \
|
||||
(_b)[0] == INS_CHECK_SURVIVE)
|
||||
|
||||
#define IS_FINAL_RX_BYTE(_i, _l) (((_i) == (_l) + 1) && (store_rxBuf[(_l) + 1] == 0xF1))
|
||||
|
||||
static void mem_recv_uart();
|
||||
|
||||
// Callback function
|
||||
static void readCallback(UART_Handle handle, void *rxBuf, size_t size)
|
||||
{
|
||||
uint8_t *uart_rxBuf = (uint8_t *)rxBuf;
|
||||
static int index = 0;
|
||||
static int length = 0;
|
||||
static bool rx_fi = false;
|
||||
|
||||
if (rx_fi) {
|
||||
memset(store_rxBuf, 0, UART_BUFF_SIZE);
|
||||
rx_fi = false;
|
||||
}
|
||||
|
||||
if (IS_EVT_MEM_DECODE_INS(uart_rxBuf) && index == 0) {
|
||||
store_rxBuf[0] = uart_rxBuf[0];
|
||||
index++;
|
||||
} else if (IS_EVT_MEM_DECODE_INS(store_rxBuf) && index == 1) {
|
||||
store_rxBuf[1] = uart_rxBuf[0];
|
||||
length = uart_rxBuf[0];
|
||||
index++;
|
||||
} else if (IS_EVT_MEM_DECODE_INS(store_rxBuf) && index > 1) {
|
||||
store_rxBuf[index] = uart_rxBuf[0];
|
||||
if (index >= length + 2) { //num = 0 when over length
|
||||
store_rxBuf[index] = 0;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
//0xF1 = 241
|
||||
if(index > 1 && store_rxBuf[0] == INS_SCAN && store_rxBuf[length + 1] == 0xF1 ) {
|
||||
index = 0;
|
||||
length = 0;
|
||||
flag_notify(EVT_MEM_INS_SCAN);
|
||||
flag_notify(EVT_MEM_UART_ROUTINE);
|
||||
rx_fi = true;
|
||||
return;
|
||||
} else if (index > 1 && store_rxBuf[0] == INS_CONNECT && store_rxBuf[length + 1] == 0xF1) {
|
||||
index = 0;
|
||||
length = 0;
|
||||
flag_notify(EVT_MEM_INS_CONNECT);
|
||||
flag_notify(EVT_MEM_UART_ROUTINE);
|
||||
rx_fi = true;
|
||||
return;
|
||||
} else if (index > 1 && store_rxBuf[0] == INS_WRITE && store_rxBuf[length + 1] == 0xF1) {
|
||||
index = 0;
|
||||
length = 0;
|
||||
flag_notify(EVT_MEM_INS_WRITE);
|
||||
flag_notify(EVT_MEM_UART_ROUTINE);
|
||||
rx_fi = true;
|
||||
return;
|
||||
} else if (index > 1 && store_rxBuf[0] == INS_READ && store_rxBuf[length + 1] == 0xF1) {
|
||||
index = 0;
|
||||
length = 0;
|
||||
flag_notify(EVT_MEM_INS_READ);
|
||||
flag_notify(EVT_MEM_UART_ROUTINE);
|
||||
rx_fi = true;
|
||||
return;
|
||||
} else if (index > 1 && store_rxBuf[0] == INS_DISCONNECT && store_rxBuf[length + 1] == 0xF1) {
|
||||
flag_notify(EVT_MEM_INS_DISCONNECT);
|
||||
index = 0;
|
||||
length = 0;
|
||||
flag_notify(EVT_MEM_UART_ROUTINE);
|
||||
rx_fi = true;
|
||||
return;
|
||||
} else if (index > 1 && store_rxBuf[0] == INS_CHECK_SURVIVE && store_rxBuf[length + 1] == 0xF1) {
|
||||
flag_notify(EVT_MEM_INS_CHECK_SURVIVE);
|
||||
index = 0;
|
||||
length = 0;
|
||||
flag_notify(EVT_MEM_UART_ROUTINE);
|
||||
rx_fi = true;
|
||||
return;
|
||||
}
|
||||
flag_notify(EVT_MEM_UART_ROUTINE);
|
||||
}
|
||||
|
||||
static void mem_UART_init(){
|
||||
|
||||
// uint32_t timeoutUs = 5000; // 5ms timeout, default timeout is no timeout (BIOS_WAIT_FOREVER)
|
||||
|
||||
// Init UART and specify non-default parameters
|
||||
UART_Params_init(¶ms);
|
||||
params.baudRate = 115200;
|
||||
params.writeDataMode = UART_DATA_BINARY;
|
||||
params.readMode = UART_MODE_CALLBACK;
|
||||
params.readDataMode = UART_DATA_BINARY;
|
||||
params.readCallback = readCallback;
|
||||
// params.readTimeout = timeoutUs / Clock_tickPeriod; // Default tick period is 10us
|
||||
// params.readTimeout = ti_sysbios_BIOS_WAIT_FOREVER;
|
||||
|
||||
// Open the UART and do the read
|
||||
uart_handle = UART_open(Board_UART, ¶ms);
|
||||
// int rxBytes = UART_read(uart_handle, rxBuf, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
static void mem_UART_display(char *str){
|
||||
|
||||
// calculate string size
|
||||
uint8_t str_size;
|
||||
for(str_size=0 ; *(str+str_size)!='\0' && str_size < 10; str_size++){
|
||||
// do nothing
|
||||
}
|
||||
str_size ++;
|
||||
|
||||
char *out_str = malloc((str_size) * sizeof(char));
|
||||
|
||||
// char *out_str = str;
|
||||
for(int i=0 ; i<str_size ; i++){
|
||||
*(out_str+i) = *(str+i);
|
||||
}
|
||||
|
||||
UART_write(uart_handle, out_str, str_size);
|
||||
free(out_str);
|
||||
out_str = NULL;
|
||||
}
|
||||
|
||||
static void mem_UART_clear_screen(){
|
||||
uint8_t cls[] = "\033[2J";
|
||||
|
||||
UART_write(uart_handle, cls, sizeof(cls));
|
||||
}
|
||||
|
||||
static void mem_UART_newline(){
|
||||
char out_str[2] = {'\n', '\r'};
|
||||
UART_write(uart_handle, out_str, 2);
|
||||
}
|
||||
|
||||
static void mem_recv_uart(){
|
||||
UART_read(uart_handle, UART_rxBuf, 10);
|
||||
}
|
||||
|
||||
static void mem_send_recv_uart(){
|
||||
UART_write(uart_handle, UART_rxBuf, 10);
|
||||
}
|
||||
|
||||
#endif
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
|
||||
#ifndef MEM_UART_ROUTINE_H
|
||||
#define MEM_UART_ROUTINE_H
|
||||
|
||||
#include "mem_uart.h"
|
||||
#include "mem_event.h"
|
||||
|
||||
static void mem_uart_routine(){
|
||||
if (uartProcedureInProgress == FALSE) {
|
||||
// uartProcedureInProgress = TRUE;
|
||||
int rxBytes = UART_read(uart_handle, UART_rxBuf, 1);
|
||||
} else {
|
||||
flag_notify(EVT_MEM_UART_ROUTINE);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
+1032
-1004
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -24,7 +24,7 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In
|
||||
GPTimerCC26XX_Params params; \
|
||||
GPTimerCC26XX_Params_init(¶ms); \
|
||||
params.width = GPT_CONFIG_16BIT; \
|
||||
params.mode = GPT_MODE_PERIODIC_DOWN; \
|
||||
params.mode = GPT_MODE_PERIODIC_UP; \
|
||||
params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF; \
|
||||
gptimer_handle = GPTimerCC26XX_open(Board_GPTIMER0A, ¶ms); \
|
||||
Types_FreqHz freq; \
|
||||
|
||||
+232
-411
@@ -50,6 +50,7 @@
|
||||
*/
|
||||
#include <string.h>
|
||||
|
||||
// clang-format off
|
||||
#include "bcomdef.h"
|
||||
#include "osal.h"
|
||||
#include "linkdb.h"
|
||||
@@ -58,61 +59,21 @@
|
||||
#include "gatt_uuid.h"
|
||||
#include "gattservapp.h"
|
||||
#include "gapbondmgr.h"
|
||||
// clang-format on
|
||||
|
||||
#include "simple_gatt_profile.h"
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
#define _UUID(_uuid) \
|
||||
{ LO_UINT16(_uuid), HI_UINT16(_uuid) }
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
CONST uint8 simpleProfileServUUID[ATT_BT_UUID_SIZE] = _UUID(SIMPLEPROFILE_SERV_UUID); // Simple GATT Profile Service UUID: 0xFFF0
|
||||
CONST uint8 simpleProfilechar1UUID[ATT_BT_UUID_SIZE] = _UUID(SIMPLEPROFILE_CHAR1_UUID); // Characteristic 1 UUID: 0xFFF1
|
||||
CONST uint8 simpleProfilechar2UUID[ATT_BT_UUID_SIZE] = _UUID(SIMPLEPROFILE_CHAR2_UUID); // Characteristic 2 UUID: 0xFFF2
|
||||
CONST uint8 simpleProfilechar3UUID[ATT_BT_UUID_SIZE] = _UUID(SIMPLEPROFILE_CHAR3_UUID); // Characteristic 3 UUID: 0xFFF3
|
||||
CONST uint8 simpleProfilechar4UUID[ATT_BT_UUID_SIZE] = _UUID(SIMPLEPROFILE_CHAR4_UUID); // Characteristic 4 UUID: 0xFFF4
|
||||
CONST uint8 simpleProfilechar5UUID[ATT_BT_UUID_SIZE] = _UUID(SIMPLEPROFILE_CHAR5_UUID); // Characteristic 5 UUID: 0xFFF5
|
||||
|
||||
#define SERVAPP_NUM_ATTR_SUPPORTED 17
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
*/
|
||||
// Simple GATT Profile Service UUID: 0xFFF0
|
||||
CONST uint8 simpleProfileServUUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(SIMPLEPROFILE_SERV_UUID), HI_UINT16(SIMPLEPROFILE_SERV_UUID)
|
||||
};
|
||||
|
||||
// Characteristic 1 UUID: 0xFFF1
|
||||
CONST uint8 simpleProfilechar1UUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(SIMPLEPROFILE_CHAR1_UUID), HI_UINT16(SIMPLEPROFILE_CHAR1_UUID)
|
||||
};
|
||||
|
||||
// Characteristic 2 UUID: 0xFFF2
|
||||
CONST uint8 simpleProfilechar2UUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(SIMPLEPROFILE_CHAR2_UUID), HI_UINT16(SIMPLEPROFILE_CHAR2_UUID)
|
||||
};
|
||||
|
||||
// Characteristic 3 UUID: 0xFFF3
|
||||
CONST uint8 simpleProfilechar3UUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(SIMPLEPROFILE_CHAR3_UUID), HI_UINT16(SIMPLEPROFILE_CHAR3_UUID)
|
||||
};
|
||||
|
||||
// Characteristic 4 UUID: 0xFFF4
|
||||
CONST uint8 simpleProfilechar4UUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(SIMPLEPROFILE_CHAR4_UUID), HI_UINT16(SIMPLEPROFILE_CHAR4_UUID)
|
||||
};
|
||||
|
||||
// Characteristic 5 UUID: 0xFFF5
|
||||
CONST uint8 simpleProfilechar5UUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(SIMPLEPROFILE_CHAR5_UUID), HI_UINT16(SIMPLEPROFILE_CHAR5_UUID)
|
||||
};
|
||||
#undef _UUID
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL VARIABLES
|
||||
@@ -133,50 +94,30 @@ static simpleProfileCBs_t *simpleProfile_AppCBs = NULL;
|
||||
*/
|
||||
|
||||
// Simple Profile Service attribute
|
||||
static CONST gattAttrType_t simpleProfileService = { ATT_BT_UUID_SIZE, simpleProfileServUUID };
|
||||
static CONST gattAttrType_t simpleProfileService = {ATT_BT_UUID_SIZE, simpleProfileServUUID};
|
||||
|
||||
// Simple Profile Characteristic 1 Properties
|
||||
// static uint8 simpleProfileChar1Props = GATT_PROP_READ | GATT_PROP_WRITE;
|
||||
/*user insert*/
|
||||
static uint8 simpleProfileChar1Props = GATT_PROP_READ;
|
||||
|
||||
// Characteristic 1 Value
|
||||
// static uint8 simpleProfileChar1 = 0;
|
||||
/*user insert*/
|
||||
#define SIMPLEPROFILE_CHAR1_LEN 20
|
||||
static uint8 simpleProfileChar1[SIMPLEPROFILE_CHAR1_LEN] = {0};
|
||||
|
||||
// Simple Profile Characteristic 1 User Description
|
||||
static uint8 simpleProfileChar1UserDesp[17] = "Characteristic 1";
|
||||
|
||||
// Simple Profile Characteristic 2 Properties
|
||||
static uint8 simpleProfileChar2Props = GATT_PROP_READ;
|
||||
|
||||
// Characteristic 2 Value
|
||||
// static uint8 simpleProfileChar2 = 0;
|
||||
/*user insert*/
|
||||
static uint8 simpleProfileChar2[SIMPLEPROFILE_CHAR2_LEN] = {0};
|
||||
|
||||
// Simple Profile Characteristic 2 User Description
|
||||
static uint8 simpleProfileChar2UserDesp[17] = "Characteristic 2";
|
||||
|
||||
// Simple Profile Characteristic 3 Properties
|
||||
static uint8 simpleProfileChar3Props = GATT_PROP_WRITE;
|
||||
|
||||
// Characteristic 3 Value
|
||||
// static uint8 simpleProfileChar3 = 0;
|
||||
/*user insert*/
|
||||
static uint8 simpleProfileChar3[SIMPLEPROFILE_CHAR3_LEN] = {0};
|
||||
|
||||
// Simple Profile Characteristic 3 User Description
|
||||
static uint8 simpleProfileChar3UserDesp[17] = "Characteristic 3";
|
||||
|
||||
// Simple Profile Characteristic 4 Properties
|
||||
static uint8 simpleProfileChar4Props = GATT_PROP_NOTIFY;
|
||||
|
||||
// Characteristic 4 Value
|
||||
// static uint8 simpleProfileChar4 = 0;
|
||||
/*user insert*/
|
||||
static uint8 simpleProfileChar4[SIMPLEPROFILE_CHAR4_LEN] = {0};
|
||||
|
||||
// Simple Profile Characteristic 4 Configuration Each client has its own
|
||||
@@ -185,175 +126,89 @@ static uint8 simpleProfileChar4[SIMPLEPROFILE_CHAR4_LEN] = {0};
|
||||
// that client and writes only affect the configuration of that client.
|
||||
static gattCharCfg_t *simpleProfileChar4Config;
|
||||
|
||||
// Simple Profile Characteristic 4 User Description
|
||||
static uint8 simpleProfileChar4UserDesp[17] = "Characteristic 4";
|
||||
|
||||
// Simple Profile Characteristic 5 Properties
|
||||
static uint8 simpleProfileChar5Props = GATT_PROP_READ;
|
||||
static uint8 simpleProfileChar5Props = GATT_PROP_READ | GATT_PROP_WRITE;
|
||||
|
||||
// Characteristic 5 Value
|
||||
static uint8 simpleProfileChar5[SIMPLEPROFILE_CHAR5_LEN] = { 0, 0, 0, 0, 0 };
|
||||
|
||||
// Simple Profile Characteristic 5 User Description
|
||||
static uint8 simpleProfileChar5UserDesp[17] = "Characteristic 5";
|
||||
static uint8 simpleProfileChar5[SIMPLEPROFILE_CHAR5_LEN] = {0};
|
||||
|
||||
/*********************************************************************
|
||||
* Profile Attributes - Table
|
||||
*/
|
||||
|
||||
static gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] =
|
||||
{
|
||||
// Simple Profile Service
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
|
||||
GATT_PERMIT_READ, /* permissions */
|
||||
0, /* handle */
|
||||
(uint8 *)&simpleProfileService /* pValue */
|
||||
},
|
||||
#define SERVAPP_NUM_ATTR_SUPPORTED 17
|
||||
|
||||
static gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] = {
|
||||
// Simple Profile Service
|
||||
{{ATT_BT_UUID_SIZE, primaryServiceUUID}, GATT_PERMIT_READ, 0, (uint8 *)&simpleProfileService},
|
||||
|
||||
// Characteristic 1 Declaration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, characterUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&simpleProfileChar1Props
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, characterUUID}, GATT_PERMIT_READ, 0, &simpleProfileChar1Props},
|
||||
|
||||
// Characteristic Value 1
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, simpleProfilechar1UUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar1
|
||||
},
|
||||
// Characteristic Value 1
|
||||
{{ATT_BT_UUID_SIZE, simpleProfilechar1UUID}, GATT_PERMIT_READ, 0, simpleProfileChar1},
|
||||
|
||||
// Characteristic 1 User Description
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, charUserDescUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar1UserDesp
|
||||
},
|
||||
// Characteristic 1 User Description
|
||||
{{ATT_BT_UUID_SIZE, charUserDescUUID}, GATT_PERMIT_READ, 0, "FS"},
|
||||
|
||||
// Characteristic 2 Declaration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, characterUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&simpleProfileChar2Props
|
||||
},
|
||||
|
||||
// Characteristic Value 2
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, simpleProfilechar2UUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar2
|
||||
},
|
||||
|
||||
// Characteristic 2 User Description
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, charUserDescUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar2UserDesp
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, characterUUID}, GATT_PERMIT_READ, 0, &simpleProfileChar2Props},
|
||||
|
||||
// Characteristic Value 2
|
||||
{{ATT_BT_UUID_SIZE, simpleProfilechar2UUID}, GATT_PERMIT_READ, 0, simpleProfileChar2},
|
||||
|
||||
// Characteristic 2 User Description
|
||||
{{ATT_BT_UUID_SIZE, charUserDescUUID}, GATT_PERMIT_READ, 0, "CR"},
|
||||
|
||||
// Characteristic 3 Declaration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, characterUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&simpleProfileChar3Props
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, characterUUID}, GATT_PERMIT_READ, 0, &simpleProfileChar3Props},
|
||||
|
||||
// Characteristic Value 3
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, simpleProfilechar3UUID },
|
||||
GATT_PERMIT_WRITE,
|
||||
0,
|
||||
simpleProfileChar3
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, simpleProfilechar3UUID}, GATT_PERMIT_WRITE, 0, simpleProfileChar3},
|
||||
|
||||
// Characteristic 3 User Description
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, charUserDescUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar3UserDesp
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, charUserDescUUID}, GATT_PERMIT_READ, 0, "IS"},
|
||||
|
||||
// Characteristic 4 Declaration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, characterUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&simpleProfileChar4Props
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, characterUUID}, GATT_PERMIT_READ, 0, &simpleProfileChar4Props},
|
||||
|
||||
// Characteristic Value 4
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, simpleProfilechar4UUID },
|
||||
0,
|
||||
0,
|
||||
simpleProfileChar4
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, simpleProfilechar4UUID}, 0, 0, simpleProfileChar4},
|
||||
|
||||
// Characteristic 4 configuration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
|
||||
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
|
||||
0,
|
||||
(uint8 *)&simpleProfileChar4Config
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, clientCharCfgUUID}, GATT_PERMIT_READ | GATT_PERMIT_WRITE, 0, (uint8 *)&simpleProfileChar4Config},
|
||||
|
||||
// Characteristic 4 User Description
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, charUserDescUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar4UserDesp
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, charUserDescUUID}, GATT_PERMIT_READ, 0, "Nt"},
|
||||
|
||||
// Characteristic 5 Declaration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, characterUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&simpleProfileChar5Props
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, characterUUID}, GATT_PERMIT_READ, 0, &simpleProfileChar5Props},
|
||||
|
||||
// Characteristic Value 5
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, simpleProfilechar5UUID },
|
||||
GATT_PERMIT_AUTHEN_READ,
|
||||
0,
|
||||
simpleProfileChar5
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, simpleProfilechar5UUID}, GATT_PERMIT_READ | GATT_PERMIT_WRITE, 0, simpleProfileChar5},
|
||||
// GATT_PERMIT_AUTHEN_READ,
|
||||
|
||||
// Characteristic 5 User Description
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, charUserDescUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar5UserDesp
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, charUserDescUUID}, GATT_PERMIT_READ, 0, "Dg"},
|
||||
};
|
||||
|
||||
/*********************************************************************
|
||||
* LOCAL FUNCTIONS
|
||||
*/
|
||||
static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle,
|
||||
gattAttribute_t *pAttr,
|
||||
uint8_t *pValue, uint16_t *pLen,
|
||||
uint16_t offset, uint16_t maxLen,
|
||||
uint8_t method);
|
||||
static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle,
|
||||
gattAttribute_t *pAttr,
|
||||
uint8_t *pValue, uint16_t len,
|
||||
uint16_t offset, uint8_t method);
|
||||
static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, //
|
||||
gattAttribute_t *pAttr,
|
||||
uint8_t * pValue,
|
||||
uint16_t * pLen,
|
||||
uint16_t offset,
|
||||
uint16_t maxLen,
|
||||
uint8_t method);
|
||||
|
||||
static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle, //
|
||||
gattAttribute_t *pAttr,
|
||||
uint8_t * pValue,
|
||||
uint16_t len,
|
||||
uint16_t offset,
|
||||
uint8_t method);
|
||||
|
||||
/*********************************************************************
|
||||
* PROFILE CALLBACKS
|
||||
@@ -367,11 +222,10 @@ static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle,
|
||||
// pfnAuthorizeAttrCB to check a client's authorization prior to calling
|
||||
// pfnReadAttrCB or pfnWriteAttrCB, so no checks for authorization need to be
|
||||
// made within these functions.
|
||||
CONST gattServiceCBs_t simpleProfileCBs =
|
||||
{
|
||||
simpleProfile_ReadAttrCB, // Read callback function pointer
|
||||
simpleProfile_WriteAttrCB, // Write callback function pointer
|
||||
NULL // Authorization callback function pointer
|
||||
CONST gattServiceCBs_t simpleProfileCBs = {
|
||||
simpleProfile_ReadAttrCB, // Read callback function pointer
|
||||
simpleProfile_WriteAttrCB, // Write callback function pointer
|
||||
NULL // Authorization callback function pointer
|
||||
};
|
||||
|
||||
/*********************************************************************
|
||||
@@ -389,35 +243,29 @@ CONST gattServiceCBs_t simpleProfileCBs =
|
||||
*
|
||||
* @return Success or Failure
|
||||
*/
|
||||
bStatus_t SimpleProfile_AddService( uint32 services )
|
||||
{
|
||||
uint8 status;
|
||||
bStatus_t SimpleProfile_AddService(uint32 services) {
|
||||
uint8 status;
|
||||
|
||||
// Allocate Client Characteristic Configuration table
|
||||
simpleProfileChar4Config = (gattCharCfg_t *)ICall_malloc( sizeof(gattCharCfg_t) *
|
||||
linkDBNumConns );
|
||||
if ( simpleProfileChar4Config == NULL )
|
||||
{
|
||||
return ( bleMemAllocError );
|
||||
}
|
||||
// Allocate Client Characteristic Configuration table
|
||||
simpleProfileChar4Config = (gattCharCfg_t *)ICall_malloc(sizeof(gattCharCfg_t) * linkDBNumConns);
|
||||
if (simpleProfileChar4Config == NULL) {
|
||||
return (bleMemAllocError);
|
||||
}
|
||||
|
||||
// Initialize Client Characteristic Configuration attributes
|
||||
GATTServApp_InitCharCfg( INVALID_CONNHANDLE, simpleProfileChar4Config );
|
||||
// Initialize Client Characteristic Configuration attributes
|
||||
GATTServApp_InitCharCfg(INVALID_CONNHANDLE, simpleProfileChar4Config);
|
||||
|
||||
if ( services & SIMPLEPROFILE_SERVICE )
|
||||
{
|
||||
// Register GATT attribute list and CBs with GATT Server App
|
||||
status = GATTServApp_RegisterService( simpleProfileAttrTbl,
|
||||
GATT_NUM_ATTRS( simpleProfileAttrTbl ),
|
||||
GATT_MAX_ENCRYPT_KEY_SIZE,
|
||||
&simpleProfileCBs );
|
||||
}
|
||||
else
|
||||
{
|
||||
status = SUCCESS;
|
||||
}
|
||||
if (services & SIMPLEPROFILE_SERVICE) {
|
||||
// Register GATT attribute list and CBs with GATT Server App
|
||||
status = GATTServApp_RegisterService(simpleProfileAttrTbl, //
|
||||
GATT_NUM_ATTRS(simpleProfileAttrTbl),
|
||||
GATT_MAX_ENCRYPT_KEY_SIZE,
|
||||
&simpleProfileCBs);
|
||||
} else {
|
||||
status = SUCCESS;
|
||||
}
|
||||
|
||||
return ( status );
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
@@ -430,18 +278,14 @@ bStatus_t SimpleProfile_AddService( uint32 services )
|
||||
*
|
||||
* @return SUCCESS or bleAlreadyInRequestedMode
|
||||
*/
|
||||
bStatus_t SimpleProfile_RegisterAppCBs( simpleProfileCBs_t *appCallbacks )
|
||||
{
|
||||
if ( appCallbacks )
|
||||
{
|
||||
simpleProfile_AppCBs = appCallbacks;
|
||||
bStatus_t SimpleProfile_RegisterAppCBs(simpleProfileCBs_t *appCallbacks) {
|
||||
if (appCallbacks) {
|
||||
simpleProfile_AppCBs = appCallbacks;
|
||||
|
||||
return ( SUCCESS );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( bleAlreadyInRequestedMode );
|
||||
}
|
||||
return (SUCCESS);
|
||||
} else {
|
||||
return (bleAlreadyInRequestedMode);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
@@ -458,76 +302,60 @@ bStatus_t SimpleProfile_RegisterAppCBs( simpleProfileCBs_t *appCallbacks )
|
||||
*
|
||||
* @return bStatus_t
|
||||
*/
|
||||
bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value )
|
||||
{
|
||||
bStatus_t ret = SUCCESS;
|
||||
switch ( param )
|
||||
{
|
||||
case SIMPLEPROFILE_CHAR1:
|
||||
if ( len <= SIMPLEPROFILE_CHAR1_LEN )
|
||||
{
|
||||
memcpy(simpleProfileChar1, value, len);
|
||||
// simpleProfileChar1 = *((uint8*)value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = bleInvalidRange;
|
||||
}
|
||||
break;
|
||||
bStatus_t SimpleProfile_SetParameter(uint8 param, uint8 len, void *value) {
|
||||
switch (param) {
|
||||
case SIMPLEPROFILE_CHAR1:
|
||||
if (len <= SIMPLEPROFILE_CHAR1_LEN) {
|
||||
memcpy(simpleProfileChar1, value, len);
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return bleInvalidRange;
|
||||
}
|
||||
|
||||
case SIMPLEPROFILE_CHAR2:
|
||||
if (len <= SIMPLEPROFILE_CHAR2_LEN)
|
||||
{
|
||||
memcpy(simpleProfileChar2, value, len);
|
||||
// simpleProfileChar2 = *((uint8*)value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = bleInvalidRange;
|
||||
}
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR2:
|
||||
if (len <= SIMPLEPROFILE_CHAR2_LEN) {
|
||||
memcpy(simpleProfileChar2, value, len);
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return bleInvalidRange;
|
||||
}
|
||||
|
||||
case SIMPLEPROFILE_CHAR3:
|
||||
if (len <= SIMPLEPROFILE_CHAR3_LEN)
|
||||
{
|
||||
memcpy(simpleProfileChar3, value, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = bleInvalidRange;
|
||||
}
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR3:
|
||||
if (len <= SIMPLEPROFILE_CHAR3_LEN) {
|
||||
memcpy(simpleProfileChar3, value, len);
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return bleInvalidRange;
|
||||
}
|
||||
|
||||
case SIMPLEPROFILE_CHAR4:
|
||||
if (len <= SIMPLEPROFILE_CHAR4_LEN)
|
||||
{
|
||||
memcpy(simpleProfileChar4, value, len);
|
||||
case SIMPLEPROFILE_CHAR4:
|
||||
if (len <= SIMPLEPROFILE_CHAR4_LEN) {
|
||||
memcpy(simpleProfileChar4, value, len);
|
||||
|
||||
// See if Notification has been enabled
|
||||
GATTServApp_ProcessCharCfg(simpleProfileChar4Config, simpleProfileChar4, FALSE, simpleProfileAttrTbl, GATT_NUM_ATTRS(simpleProfileAttrTbl), INVALID_TASK_ID, simpleProfile_ReadAttrCB);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = bleInvalidRange;
|
||||
}
|
||||
break;
|
||||
// See if Notification has been enabled
|
||||
GATTServApp_ProcessCharCfg(simpleProfileChar4Config, //
|
||||
simpleProfileChar4,
|
||||
FALSE,
|
||||
simpleProfileAttrTbl,
|
||||
GATT_NUM_ATTRS(simpleProfileAttrTbl),
|
||||
INVALID_TASK_ID,
|
||||
simpleProfile_ReadAttrCB);
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return bleInvalidRange;
|
||||
}
|
||||
|
||||
case SIMPLEPROFILE_CHAR5:
|
||||
if (len == SIMPLEPROFILE_CHAR5_LEN) {
|
||||
VOID memcpy(simpleProfileChar5, value, SIMPLEPROFILE_CHAR5_LEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = bleInvalidRange;
|
||||
}
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR5:
|
||||
if (len <= SIMPLEPROFILE_CHAR5_LEN) {
|
||||
memcpy(simpleProfileChar5, value, len);
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return bleInvalidRange;
|
||||
}
|
||||
|
||||
default:
|
||||
ret = INVALIDPARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
return ( ret );
|
||||
default:
|
||||
return INVALIDPARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
@@ -544,36 +372,32 @@ bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value )
|
||||
* @return bStatus_t
|
||||
*/
|
||||
bStatus_t SimpleProfile_GetParameter(uint8 param, void *value) {
|
||||
bStatus_t ret = SUCCESS;
|
||||
switch (param) {
|
||||
case SIMPLEPROFILE_CHAR1:
|
||||
memcpy(value, simpleProfileChar1, SIMPLEPROFILE_CHAR1_LEN);
|
||||
// *((uint8*)value) = simpleProfileChar1;
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR1:
|
||||
memcpy(value, simpleProfileChar1, SIMPLEPROFILE_CHAR1_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR2:
|
||||
memcpy(value, simpleProfileChar2, SIMPLEPROFILE_CHAR2_LEN);
|
||||
// *((uint8*)value) = simpleProfileChar2;
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR2:
|
||||
memcpy(value, simpleProfileChar2, SIMPLEPROFILE_CHAR2_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR3:
|
||||
memcpy(value, simpleProfileChar3, SIMPLEPROFILE_CHAR3_LEN);
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR3:
|
||||
memcpy(value, simpleProfileChar3, SIMPLEPROFILE_CHAR3_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR4:
|
||||
memcpy(value, simpleProfileChar4, SIMPLEPROFILE_CHAR4_LEN);
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR4:
|
||||
memcpy(value, simpleProfileChar4, SIMPLEPROFILE_CHAR4_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR5:
|
||||
VOID memcpy(value, simpleProfileChar5, SIMPLEPROFILE_CHAR5_LEN);
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR5:
|
||||
memcpy(value, simpleProfileChar5, SIMPLEPROFILE_CHAR5_LEN);
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = INVALIDPARAMETER;
|
||||
break;
|
||||
default:
|
||||
return INVALIDPARAMETER;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
@@ -591,7 +415,13 @@ bStatus_t SimpleProfile_GetParameter(uint8 param, void *value) {
|
||||
*
|
||||
* @return SUCCESS, blePending or Failure
|
||||
*/
|
||||
static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, gattAttribute_t *pAttr, uint8_t *pValue, uint16_t *pLen, uint16_t offset, uint16_t maxLen, uint8_t method) {
|
||||
static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, //
|
||||
gattAttribute_t *pAttr,
|
||||
uint8_t * pValue,
|
||||
uint16_t * pLen,
|
||||
uint16_t offset,
|
||||
uint16_t maxLen,
|
||||
uint8_t method) {
|
||||
bStatus_t status = SUCCESS;
|
||||
|
||||
// Make sure it's not a blob operation (no attributes in the profile are long)
|
||||
@@ -603,42 +433,31 @@ static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, gattAttribute_t *
|
||||
// 16-bit UUID
|
||||
uint16 uuid = BUILD_UINT16(pAttr->type.uuid[0], pAttr->type.uuid[1]);
|
||||
switch (uuid) {
|
||||
// No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
|
||||
// gattserverapp handles those reads
|
||||
case SIMPLEPROFILE_CHAR1_UUID:
|
||||
*pLen = SIMPLEPROFILE_CHAR1_LEN;
|
||||
memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR1_LEN);
|
||||
break;
|
||||
|
||||
// characteristics 1 and 2 have read permissions
|
||||
// characteritisc 3 does not have read permissions; therefore it is not
|
||||
// included here
|
||||
// characteristic 4 does not have read permissions, but because it
|
||||
// can be sent as a notification, it is included here
|
||||
case SIMPLEPROFILE_CHAR1_UUID:
|
||||
*pLen = SIMPLEPROFILE_CHAR1_LEN;
|
||||
VOID memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR1_LEN);
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR2_UUID:
|
||||
*pLen = SIMPLEPROFILE_CHAR2_LEN;
|
||||
memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR2_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR2_UUID:
|
||||
// *pLen = 1;
|
||||
// pValue[0] = *pAttr->pValue;
|
||||
case SIMPLEPROFILE_CHAR4_UUID:
|
||||
*pLen = SIMPLEPROFILE_CHAR4_LEN;
|
||||
memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR4_LEN);
|
||||
break;
|
||||
|
||||
*pLen = SIMPLEPROFILE_CHAR2_LEN;
|
||||
VOID memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR2_LEN);
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR5_UUID:
|
||||
*pLen = SIMPLEPROFILE_CHAR5_LEN;
|
||||
memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR5_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR4_UUID:
|
||||
*pLen = SIMPLEPROFILE_CHAR4_LEN;
|
||||
VOID memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR4_LEN);
|
||||
break;
|
||||
// case SIMPLEPROFILE_CHAR5_UUID:
|
||||
|
||||
// *pLen = SIMPLEPROFILE_CHAR5_LEN;
|
||||
// VOID memcpy( pValue, pAttr->pValue, SIMPLEPROFILE_CHAR5_LEN );
|
||||
// break;
|
||||
|
||||
default:
|
||||
// Should never get here! (characteristics 3 and 4 do not have read permissions)
|
||||
*pLen = 0;
|
||||
status = ATT_ERR_ATTR_NOT_FOUND;
|
||||
break;
|
||||
default:
|
||||
// Should never get here! (characteristics 3 and 4 do not have read permissions)
|
||||
*pLen = 0;
|
||||
status = ATT_ERR_ATTR_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// 128-bit UUID
|
||||
@@ -663,71 +482,73 @@ static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, gattAttribute_t *
|
||||
*
|
||||
* @return SUCCESS, blePending or Failure
|
||||
*/
|
||||
static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle, gattAttribute_t *pAttr, uint8_t *pValue, uint16_t len, uint16_t offset, uint8_t method) {
|
||||
static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle, //
|
||||
gattAttribute_t *pAttr,
|
||||
uint8_t * pValue,
|
||||
uint16_t len,
|
||||
uint16_t offset,
|
||||
uint8_t method) {
|
||||
bStatus_t status = SUCCESS;
|
||||
uint8 notifyApp = 0xFF;
|
||||
|
||||
if (pAttr->type.len == ATT_BT_UUID_SIZE) {
|
||||
// 16-bit UUID
|
||||
uint16 uuid = BUILD_UINT16(pAttr->type.uuid[0], pAttr->type.uuid[1]);
|
||||
|
||||
switch (uuid) {
|
||||
// Validate the value
|
||||
// Make sure it's not a blob oper
|
||||
/*
|
||||
if ( offset == 0 )
|
||||
{
|
||||
if ( len != 1 )
|
||||
{
|
||||
status = ATT_ERR_INVALID_VALUE_SIZE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = ATT_ERR_ATTR_NOT_LONG;
|
||||
}
|
||||
case SIMPLEPROFILE_CHAR3_UUID:
|
||||
|
||||
//Write the value
|
||||
if ( status == SUCCESS )
|
||||
{
|
||||
uint8 *pCurValue = (uint8 *)pAttr->pValue;
|
||||
*pCurValue = pValue[0];
|
||||
|
||||
if( pAttr->pValue == &simpleProfileChar1 )
|
||||
{
|
||||
notifyApp = SIMPLEPROFILE_CHAR1;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
*/
|
||||
case SIMPLEPROFILE_CHAR3_UUID:
|
||||
if (offset == 0) {
|
||||
if (len > SIMPLEPROFILE_CHAR3_LEN) {
|
||||
status = ATT_ERR_INVALID_VALUE_SIZE;
|
||||
// Validate the value
|
||||
// Make sure it's not a blob oper
|
||||
if (offset == 0) {
|
||||
if (len >= SIMPLEPROFILE_CHAR3_LEN) {
|
||||
status = ATT_ERR_INVALID_VALUE_SIZE;
|
||||
}
|
||||
} else {
|
||||
status = ATT_ERR_ATTR_NOT_LONG;
|
||||
}
|
||||
} else {
|
||||
status = ATT_ERR_ATTR_NOT_LONG;
|
||||
}
|
||||
|
||||
// Write the value
|
||||
if (status == SUCCESS) {
|
||||
// Copy pValue into the variable we point to from the attribute table.
|
||||
memcpy(pAttr->pValue + offset, pValue, len);
|
||||
memset(pAttr->pValue + len, 0, SIMPLEPROFILE_CHAR3_LEN - len);
|
||||
// Write the value
|
||||
if (status == SUCCESS) {
|
||||
// Copy pValue into the variable we point to from the attribute table.
|
||||
memcpy(pAttr->pValue + offset, pValue, len);
|
||||
memset(pAttr->pValue + len, 0, SIMPLEPROFILE_CHAR3_LEN - len);
|
||||
|
||||
if (pAttr->pValue == simpleProfileChar3) {
|
||||
notifyApp = SIMPLEPROFILE_CHAR3;
|
||||
if (pAttr->pValue == simpleProfileChar3) {
|
||||
notifyApp = SIMPLEPROFILE_CHAR3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case GATT_CLIENT_CHAR_CFG_UUID:
|
||||
status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len, offset, GATT_CLIENT_CFG_NOTIFY);
|
||||
break;
|
||||
default:
|
||||
// Should never get here! (characteristics 2 and 4 do not have write permissions)
|
||||
status = ATT_ERR_ATTR_NOT_FOUND;
|
||||
break;
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR5_UUID:
|
||||
if (offset == 0) {
|
||||
if (len >= SIMPLEPROFILE_CHAR5_LEN) {
|
||||
status = ATT_ERR_INVALID_VALUE_SIZE;
|
||||
}
|
||||
} else {
|
||||
status = ATT_ERR_ATTR_NOT_LONG;
|
||||
}
|
||||
|
||||
// Write the value
|
||||
if (status == SUCCESS) {
|
||||
// Copy pValue into the variable we point to from the attribute table.
|
||||
memcpy(pAttr->pValue + offset, pValue, len);
|
||||
memset(pAttr->pValue + len, 0, SIMPLEPROFILE_CHAR5_LEN - len);
|
||||
|
||||
if (pAttr->pValue == simpleProfileChar5) {
|
||||
notifyApp = SIMPLEPROFILE_CHAR5;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case GATT_CLIENT_CHAR_CFG_UUID:
|
||||
status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len, offset, GATT_CLIENT_CFG_NOTIFY);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Should never get here! (characteristics 2 and 4 do not have write permissions)
|
||||
status = ATT_ERR_ATTR_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// 128-bit UUID
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
Target Device: CC2650, CC2640
|
||||
|
||||
******************************************************************************
|
||||
|
||||
|
||||
Copyright (c) 2010-2018, Texas Instruments Incorporated
|
||||
All rights reserved.
|
||||
|
||||
@@ -49,8 +49,7 @@
|
||||
#define SIMPLEGATTPROFILE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
@@ -62,36 +61,37 @@ extern "C"
|
||||
*/
|
||||
|
||||
// Profile Parameters
|
||||
#define SIMPLEPROFILE_CHAR1 0 // RW uint8 - Profile Characteristic 1 value
|
||||
#define SIMPLEPROFILE_CHAR2 1 // RW uint8 - Profile Characteristic 2 value
|
||||
#define SIMPLEPROFILE_CHAR3 2 // RW uint8 - Profile Characteristic 3 value
|
||||
#define SIMPLEPROFILE_CHAR4 3 // RW uint8 - Profile Characteristic 4 value
|
||||
#define SIMPLEPROFILE_CHAR5 4 // RW uint8 - Profile Characteristic 4 value
|
||||
#define SIMPLEPROFILE_CHAR1 0 // RW uint8 - Profile Characteristic 1 value
|
||||
#define SIMPLEPROFILE_CHAR2 1 // RW uint8 - Profile Characteristic 2 value
|
||||
#define SIMPLEPROFILE_CHAR3 2 // RW uint8 - Profile Characteristic 3 value
|
||||
#define SIMPLEPROFILE_CHAR4 3 // RW uint8 - Profile Characteristic 4 value
|
||||
#define SIMPLEPROFILE_CHAR5 4 // RW uint8 - Profile Characteristic 4 value
|
||||
|
||||
// Simple Profile Service UUID
|
||||
#define SIMPLEPROFILE_SERV_UUID 0xFFF0
|
||||
#define SIMPLEPROFILE_SERV_UUID 0xFFF0
|
||||
|
||||
// Key Pressed UUID
|
||||
#define SIMPLEPROFILE_CHAR1_UUID 0xFFF1
|
||||
#define SIMPLEPROFILE_CHAR2_UUID 0xFFF2
|
||||
#define SIMPLEPROFILE_CHAR3_UUID 0xFFF3
|
||||
#define SIMPLEPROFILE_CHAR4_UUID 0xFFF4
|
||||
#define SIMPLEPROFILE_CHAR5_UUID 0xFFF5
|
||||
#define SIMPLEPROFILE_CHAR1_UUID 0xFFF1
|
||||
#define SIMPLEPROFILE_CHAR2_UUID 0xFFF2
|
||||
#define SIMPLEPROFILE_CHAR3_UUID 0xFFF3
|
||||
#define SIMPLEPROFILE_CHAR4_UUID 0xFFF4
|
||||
#define SIMPLEPROFILE_CHAR5_UUID 0xFFF5
|
||||
|
||||
// Simple Keys Profile Services bit fields
|
||||
#define SIMPLEPROFILE_SERVICE 0x00000001
|
||||
#define SIMPLEPROFILE_SERVICE 0x00000001
|
||||
|
||||
// Length of Characteristic 5 in bytes
|
||||
#define SIMPLEPROFILE_CHAR5_LEN 5
|
||||
/*user insert*/
|
||||
#define SIMPLEPROFILE_CHAR4_LEN 40
|
||||
#define SIMPLEPROFILE_CHAR3_LEN 20
|
||||
#define SIMPLEPROFILE_CHAR2_LEN 20
|
||||
#define SIMPLEPROFILE_CHAR1_LEN 2
|
||||
#define SIMPLEPROFILE_CHAR2_LEN 10
|
||||
#define SIMPLEPROFILE_CHAR3_LEN 20
|
||||
#define SIMPLEPROFILE_CHAR4_LEN 200
|
||||
//#define SIMPLEPROFILE_CHAR4_LEN 20
|
||||
#define SIMPLEPROFILE_CHAR5_LEN 20
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
@@ -101,20 +101,16 @@ extern "C"
|
||||
*/
|
||||
|
||||
// Callback when a characteristic value has changed
|
||||
typedef void (*simpleProfileChange_t)( uint8 paramID );
|
||||
typedef void (*simpleProfileChange_t)(uint8 paramID);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
simpleProfileChange_t pfnSimpleProfileChange; // Called when characteristic value changes
|
||||
typedef struct {
|
||||
simpleProfileChange_t pfnSimpleProfileChange; // Called when characteristic value changes
|
||||
} simpleProfileCBs_t;
|
||||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* API FUNCTIONS
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* SimpleProfile_AddService- Initializes the Simple GATT Profile service by registering
|
||||
* GATT attributes with the GATT server.
|
||||
@@ -123,7 +119,7 @@ typedef struct
|
||||
* contain more than one service.
|
||||
*/
|
||||
|
||||
extern bStatus_t SimpleProfile_AddService( uint32 services );
|
||||
extern bStatus_t SimpleProfile_AddService(uint32 services);
|
||||
|
||||
/*
|
||||
* SimpleProfile_RegisterAppCBs - Registers the application callback function.
|
||||
@@ -131,7 +127,7 @@ extern bStatus_t SimpleProfile_AddService( uint32 services );
|
||||
*
|
||||
* appCallbacks - pointer to application callbacks.
|
||||
*/
|
||||
extern bStatus_t SimpleProfile_RegisterAppCBs( simpleProfileCBs_t *appCallbacks );
|
||||
extern bStatus_t SimpleProfile_RegisterAppCBs(simpleProfileCBs_t *appCallbacks);
|
||||
|
||||
/*
|
||||
* SimpleProfile_SetParameter - Set a Simple GATT Profile parameter.
|
||||
@@ -143,7 +139,7 @@ extern bStatus_t SimpleProfile_RegisterAppCBs( simpleProfileCBs_t *appCallbacks
|
||||
* data type (example: data type of uint16 will be cast to
|
||||
* uint16 pointer).
|
||||
*/
|
||||
extern bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value );
|
||||
extern bStatus_t SimpleProfile_SetParameter(uint8 param, uint8 len, void *value);
|
||||
|
||||
/*
|
||||
* SimpleProfile_GetParameter - Get a Simple GATT Profile parameter.
|
||||
@@ -154,8 +150,7 @@ extern bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value
|
||||
* data type (example: data type of uint16 will be cast to
|
||||
* uint16 pointer).
|
||||
*/
|
||||
extern bStatus_t SimpleProfile_GetParameter( uint8 param, void *value );
|
||||
|
||||
extern bStatus_t SimpleProfile_GetParameter(uint8 param, void *value);
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user