Compare commits

...

7 Commits

Author SHA1 Message Date
Roy_01 617d82b787 organize the code and fix the data issue 2023-11-03 11:21:54 +08:00
Roy 528b1f9c5e [update] update GAP_LINK_TERMINATED_EVENT msg 2023-07-17 17:35:48 +08:00
Roy 72288be1c0 [update] remove unknow msg 2023-07-17 16:56:49 +08:00
Roy 2becce9678 [update] update message of check_mem_survivr & write response & connected 2023-07-17 16:35:06 +08:00
Roy 3d2c0fdced [update] update gatt_msg_rsp code 2023-07-17 16:26:52 +08:00
Roy 16d0018a01 [update] reset_status_register 0x41 2023-07-17 16:20:40 +08:00
Roy 45767f0a03 [revert] revert to "rename parameter" 2023-07-17 16:13:37 +08:00
9 changed files with 1041 additions and 1488 deletions
@@ -36,11 +36,10 @@
* CC2650 Booster Pack.
*/
/*
* ====================== Includes ============================================
*/
// clang-format off
#include <xdc/std.h>
#include <xdc/runtime/System.h>
@@ -57,46 +56,16 @@
#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__)
@@ -104,22 +73,20 @@
#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 PINCC26XX_HWAttrs PINCC26XX_hwAttrs = {
//
.intPriority = ~0,
.swiPriority = 0
//
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
};
/*============================================================================*/
/*
@@ -129,14 +96,13 @@ 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 ====================================
@@ -177,15 +143,14 @@ const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[BOOSTXL_CC2650MA_UARTCOUNT] = {
};
/* 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 =====================================
*/
@@ -207,27 +172,22 @@ 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 =====================================
*/
@@ -248,65 +208,41 @@ const UDMACC26XX_Config UDMACC26XX_config[] = { //
SPICC26XXDMA_Object spiCC26XXDMAObjects[BOOSTXL_CC2650MA_SPICOUNT];
/* SPI configuration structure, describing which pins are to be used */
const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[BOOSTXL_CC2650MA_SPICOUNT] = {
//
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 = PIN_UNASSIGNED
//
.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
},
#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[] = { //
const SPI_Config SPI_config[] = {
{
//
.fxnTablePtr = &SPICC26XXDMA_fxnTable,
.object = &spiCC26XXDMAObjects[0],
.hwAttrs = &spiCC26XXDMAHWAttrs[0]
//
.fxnTablePtr = &SPICC26XXDMA_fxnTable,
.object = &spiCC26XXDMAObjects[0],
.hwAttrs = &spiCC26XXDMAHWAttrs[0]
},
#ifdef HEADSTAGE_MA_USE_SPI2
{
//
.fxnTablePtr = &SPICC26XXDMA_fxnTable,
.object = &spiCC26XXDMAObjects[1],
.hwAttrs = &spiCC26XXDMAHWAttrs[1]
//
.fxnTablePtr = &SPICC26XXDMA_fxnTable,
.object = &spiCC26XXDMAObjects[1],
.hwAttrs = &spiCC26XXDMAHWAttrs[1]
},
#endif
{NULL, NULL, NULL}};
{NULL, NULL, NULL}
};
/*
* ========================== SPI DMA end =====================================
*/
*/
/*
* ========================== Crypto begin ====================================
@@ -326,28 +262,28 @@ const SPI_Config SPI_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 ==================================
*/
@@ -389,21 +325,20 @@ 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 ====================================
@@ -421,62 +356,14 @@ 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..) */
@@ -484,15 +371,14 @@ 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 },
};
/*
@@ -510,15 +396,14 @@ 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 */
@@ -528,300 +413,18 @@ 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 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
#define Board_BP_Pin_J1_2 PIN_UNASSIGNED //ori: DIO7
#define Board_BP_Pin_J1_3 PIN_UNASSIGNED //ori: DIO0
#define Board_BP_Pin_J1_4 PIN_UNASSIGNED //ori: DIO1
#define Board_BP_Pin_J1_5 PIN_UNASSIGNED //ori: DIO2
#define Board_BP_Pin_J1_6 PIN_UNASSIGNED //ori: DIO3
#define Board_BP_Pin_J1_7 PIN_UNASSIGNED //ori: DIO10
#define Board_BP_Pin_J1_8 PIN_UNASSIGNED //ori: DIO4
#define Board_BP_Pin_J1_9 PIN_UNASSIGNED //ori: DIO5
#define Board_BP_Pin_J1_10 PIN_UNASSIGNED //ori: DIO6
/* Connector J2 */
#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 */
#define Board_BP_Pin_J2_19 PIN_UNASSIGNED //ori: DIO8
#define Board_BP_Pin_J2_18 PIN_UNASSIGNED //ori: DIO9 /* CS */
#define Board_BP_Pin_J2_17 PIN_UNASSIGNED //ori: IOID_UNUSED /* NC */
#define Board_BP_Pin_J2_15 PIN_UNASSIGNED //ori: DIO11 /* MOSI */
#define Board_BP_Pin_J2_14 PIN_UNASSIGNED //ori: DIO12 /* MISO */
#define Board_BP_Pin_J2_13 PIN_UNASSIGNED //ori: DIO13
#define Board_BP_Pin_J2_12 PIN_UNASSIGNED //ori: DIO14
#define Board_BP_Pin_J2_11 PIN_UNASSIGNED //ori: IOID_UNUSED /* NC */
/* Mapping of BoosterPack Connector Pins to BoosterPack Standard Functions (reflecting the BoosterPack Standard)
*/
@@ -133,74 +133,27 @@ 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 */
/* On-board LEDs */
#define Board_GLED PIN_UNASSIGNED //ori: DIO2 /* Green LED */
#define Board_RLED PIN_UNASSIGNED //ori: DIO4 /* Red LED */
/*
* interface with control box
*/
#if defined(MODA_MEMORY_BOARD)
/* UART Board */
#define Board_UART_TX DIO1 //ori: Board_BP_UART_Rx /* RXD */
#define Board_UART_RX DIO0 //ori: Board_BP_UART_Tx /* TXD */
/* SPI 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 */
#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
/*
* 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
#define Board_SPI0_CS PIN_UNASSIGNED
/* Power Management Board */
#define Board_SRDY PIN_UNASSIGNED
#define Board_MRDY PIN_UNASSIGNED
#define Board_SRDY Board_BP_Pin_J2_19
#define Board_MRDY Board_BP_Pin_J1_2
/* PWM outputs */
#define Board_PWMPIN0 PIN_UNASSIGNED
@@ -212,24 +165,15 @@ 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
@@ -239,17 +183,6 @@ 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
@@ -264,16 +197,6 @@ 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
@@ -292,10 +215,6 @@ typedef enum BOOSTXL_CC2650MA_CryptoName {
typedef enum BOOSTXL_CC2650MA_SPIName {
BOOSTXL_CC2650MA_SPI0 = 0,
#ifdef HEADSTAGE_MA_USE_SPI2
BOOSTXL_CC2650MA_SPI1 ,
#endif
BOOSTXL_CC2650MA_SPICOUNT
} BOOSTXL_CC2650MA_SPIName;
@@ -375,35 +294,6 @@ 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,19 +78,16 @@ 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
uint8_t keysPressed;
static uint8_t keysPressed;
// Key debounce clock
Clock_Struct keyChangeClock;
static Clock_Struct keyChangeClock;
// Pointer to application callback
keysPressedCB_t appKeyChangeHandler = NULL;
@@ -104,30 +101,18 @@ 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
};
extern uint16_t EventMask;
PIN_State keyPins;
PIN_Handle hKeyPins;
/*********************************************************************
* PUBLIC FUNCTIONS
@@ -143,21 +128,39 @@ extern uint16_t EventMask;
*/
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 (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);
#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);
#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
#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);
#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;
@@ -174,24 +177,47 @@ void Board_initKeys(keysPressedCB_t appKeyCB)
*/
static void Board_keyCallback(PIN_Handle hPin, PIN_Id pinId)
{
keysPressed = 0;
#if defined (BOOSTXL_CC2650MA)
// if (PIN_getInputValue(PIN_MEM_REQ) == 0 && !procedureInProgress) {
// keysPressed |= KEY_REQ;
// flag_enable(EVT_PIN_REQST);
// }
keysPressed = 0;
#elif defined (CC2650_LAUNCHXL) || defined (CC1350_LAUNCHXL)
if (PIN_getInputValue(Board_BTN1) == 0) {
keysPressed |= KEY_LEFT;
}
#if defined (CC2650_LAUNCHXL) || defined (CC1350_LAUNCHXL)
if ( PIN_getInputValue(Board_BTN1) == 0 )
{
keysPressed |= KEY_LEFT;
}
if (PIN_getInputValue(Board_BTN2) == 0) {
keysPressed |= KEY_RIGHT;
}
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;
}
#endif
Util_startClock(&keyChangeClock);
Util_startClock(&keyChangeClock);
}
/*********************************************************************
@@ -55,10 +55,11 @@ extern "C" {
/*********************************************************************
* INCLUDES
*/
/*********************************************************************
* EXTERNAL VARIABLES
*/
extern uint8_t KEY_INSTEAD_UART;
/*********************************************************************
* CONSTANTS
*/
@@ -67,11 +68,9 @@ extern uint8_t KEY_INSTEAD_UART;
#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 0
#define KEY_DEBOUNCE_TIMEOUT 200
/*********************************************************************
* TYPEDEFS
@@ -56,7 +56,6 @@
#include "icall.h"
#include "hal_assert.h"
#include "board.h"
#include "central.h"
#include "simple_central.h"
@@ -73,7 +72,7 @@ bleUserCfg_t user0Cfg = BLE_USER_CFG;
#endif // USE_DEFAULT_USER_CFG
#include <ti/mw/display/Display.h>
// #include <ti/mw/display/Display.h>
#ifdef USE_FPGA
#include <inc/hw_prcm.h>
@@ -114,7 +113,7 @@ bleUserCfg_t user0Cfg = BLE_USER_CFG;
extern void AssertHandler(uint8 assertCause, uint8 assertSubcause);
extern Display_Handle dispHandle;
// extern Display_Handle dispHandle;
/*******************************************************************************
* @fn Main
@@ -219,47 +218,47 @@ int main()
*/
void AssertHandler(uint8 assertCause, uint8 assertSubcause)
{
// Open the display if the app has not already done so
if ( !dispHandle )
{
dispHandle = Display_open(Display_Type_LCD, NULL);
}
// // Open the display if the app has not already done so
// if ( !dispHandle )
// {
// dispHandle = Display_open(Display_Type_LCD, NULL);
// }
Display_print0(dispHandle, 0, 0, ">>>STACK ASSERT");
// Display_print0(dispHandle, 0, 0, ">>>STACK ASSERT");
// check the assert cause
switch (assertCause)
{
case HAL_ASSERT_CAUSE_OUT_OF_MEMORY:
Display_print0(dispHandle, 0, 0, "***ERROR***");
Display_print0(dispHandle, 2, 0, ">> OUT OF MEMORY!");
break;
// // check the assert cause
// switch (assertCause)
// {
// case HAL_ASSERT_CAUSE_OUT_OF_MEMORY:
// Display_print0(dispHandle, 0, 0, "***ERROR***");
// Display_print0(dispHandle, 2, 0, ">> OUT OF MEMORY!");
// break;
case HAL_ASSERT_CAUSE_INTERNAL_ERROR:
// check the subcause
if (assertSubcause == HAL_ASSERT_SUBCAUSE_FW_INERNAL_ERROR)
{
Display_print0(dispHandle, 0, 0, "***ERROR***");
Display_print0(dispHandle, 2, 0, ">> INTERNAL FW ERROR!");
}
else
{
Display_print0(dispHandle, 0, 0, "***ERROR***");
Display_print0(dispHandle, 2, 0, ">> INTERNAL ERROR!");
}
break;
// case HAL_ASSERT_CAUSE_INTERNAL_ERROR:
// // check the subcause
// if (assertSubcause == HAL_ASSERT_SUBCAUSE_FW_INERNAL_ERROR)
// {
// Display_print0(dispHandle, 0, 0, "***ERROR***");
// Display_print0(dispHandle, 2, 0, ">> INTERNAL FW ERROR!");
// }
// else
// {
// Display_print0(dispHandle, 0, 0, "***ERROR***");
// Display_print0(dispHandle, 2, 0, ">> INTERNAL ERROR!");
// }
// break;
case HAL_ASSERT_CAUSE_ICALL_ABORT:
Display_print0(dispHandle, 0, 0, "***ERROR***");
Display_print0(dispHandle, 2, 0, ">> ICALL ABORT!");
HAL_ASSERT_SPINLOCK;
break;
// case HAL_ASSERT_CAUSE_ICALL_ABORT:
// Display_print0(dispHandle, 0, 0, "***ERROR***");
// Display_print0(dispHandle, 2, 0, ">> ICALL ABORT!");
// HAL_ASSERT_SPINLOCK;
// break;
default:
Display_print0(dispHandle, 0, 0, "***ERROR***");
Display_print0(dispHandle, 2, 0, ">> DEFAULT SPINLOCK!");
HAL_ASSERT_SPINLOCK;
}
// default:
// Display_print0(dispHandle, 0, 0, "***ERROR***");
// Display_print0(dispHandle, 2, 0, ">> DEFAULT SPINLOCK!");
// HAL_ASSERT_SPINLOCK;
// }
return;
}
@@ -176,8 +176,6 @@ static void mem_connect_device(uint8_t addrType, uint8_t *peerAddr) {
Addr[5-i] = *(peerAddr+i);
}
// UART_write(uart_handle, Addr, 6);
state = BLE_STATE_CONNECTING;
Util_startClock(&connectingClock);
@@ -211,8 +209,6 @@ static void write_gatt_msg(uint16_t handle, uint8_t *value){
req.len = 2;
}
else{
uint8_t error_handle[13] = "error handle";
UART_write(uart_handle, error_handle, 13);
status = bleMemAllocError;
return;
}
@@ -239,15 +235,6 @@ static void write_gatt_msg(uint16_t handle, uint8_t *value){
}
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;
}
@@ -2,22 +2,50 @@
#ifndef MEM_CENTRAL_PIN
#define MEM_CENTRAL_PIN
//extern PIN_State keyPins;
extern PIN_Handle hKeyPins;
#include <Board.h>
#include <ti/drivers/pin/PINCC26XX.h>
static PIN_Handle Central_pin_handle;
static PIN_State Central_pin_state;
#define central_pin_output(pin, value) PIN_setOutputValue(Central_pin_handle, PIN_ID(pin), (value))
#define central_pin_input(pin) PIN_getInputValue(PIN_ID(pin))
#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 */
#define PIN_MULTIPLEXER_CS DIO9
const PIN_Config central_io[] = {
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_MEM_TEST | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,
PIN_RAM_SEL | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
PIN_MULTIPLEXER_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,
PIN_TERMINATE
};
uint8_t gpio_create(void)
{
Central_pin_handle = PIN_open(&Central_pin_state, central_io);
if (Central_pin_handle == NULL)
return 1;
return 0;
}
#define central_pin_output(pin, value) PIN_setOutputValue(hKeyPins, PIN_ID(pin), (value))
#define central_pin_input(pin) PIN_getInputValue(PIN_ID(pin))
void ram_select(bool value)
{
ram_sel_signal = value;
central_pin_output(PIN_RAM_SEL, (ram_sel_signal) ? 1 : 0);
central_pin_output(PIN_RAM_SEL, ram_sel_signal);
central_pin_output(PIN_MEM_TEST, ram_sel_signal);
if (ram_sel_signal) {
central_pin_output(PIN_MEM_TEST, 1);
} else {
central_pin_output(PIN_MEM_TEST, 0);
}
}
#endif
@@ -28,18 +28,18 @@ void mem_spi_init() {
central_spi_transaction.txBuf = data; \
central_spi_transaction.rxBuf = NULL; \
central_spi_transaction.count = (len); \
central_pin_output(Board_SPI_CS, 0); \
central_pin_output(PIN_MULTIPLEXER_CS, 0); \
SPI_transfer(central_spi_handle, &central_spi_transaction); \
central_pin_output(Board_SPI_CS, 1); \
central_pin_output(PIN_MULTIPLEXER_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); \
central_pin_output(PIN_MULTIPLEXER_CS, 0); \
SPI_transfer(central_spi_handle, &central_spi_transaction); \
central_pin_output(Board_SPI_CS, 1); \
central_pin_output(PIN_MULTIPLEXER_CS, 1); \
} while (0)
#endif // CENTRAL_SPI_H
File diff suppressed because it is too large Load Diff