Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 617d82b787 | |||
| 528b1f9c5e | |||
| 72288be1c0 | |||
| 2becce9678 | |||
| 3d2c0fdced | |||
| 16d0018a01 | |||
| 45767f0a03 | |||
| b649c22231 | |||
| f0f36b3259 | |||
| aacc263447 | |||
| 99f502f5ca | |||
| f54dbd330f | |||
| 54ab777871 | |||
| 047acb1e99 | |||
| 1b842a5cd9 | |||
| 0161fe1868 | |||
| 9e285b43fb |
|
After Width: | Height: | Size: 144 KiB |
|
After Width: | Height: | Size: 128 KiB |
|
After Width: | Height: | Size: 152 KiB |
|
After Width: | Height: | Size: 173 KiB |
|
After Width: | Height: | Size: 203 KiB |
|
After Width: | Height: | Size: 149 KiB |
|
After Width: | Height: | Size: 127 KiB |
|
After Width: | Height: | Size: 112 KiB |
|
After Width: | Height: | Size: 174 KiB |
|
After Width: | Height: | Size: 208 KiB |
|
After Width: | Height: | Size: 155 KiB |
|
After Width: | Height: | Size: 133 KiB |
|
After Width: | Height: | Size: 154 KiB |
|
After Width: | Height: | Size: 171 KiB |
|
After Width: | Height: | Size: 212 KiB |
|
After Width: | Height: | Size: 152 KiB |
|
After Width: | Height: | Size: 135 KiB |
|
After Width: | Height: | Size: 107 KiB |
|
After Width: | Height: | Size: 169 KiB |
|
After Width: | Height: | Size: 203 KiB |
@@ -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,52 +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;
|
||||
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)
|
||||
PIN_State keyPins;
|
||||
PIN_Handle hKeyPins;
|
||||
|
||||
/*********************************************************************
|
||||
* PUBLIC FUNCTIONS
|
||||
@@ -165,21 +128,39 @@ extern void ext_call_sem();
|
||||
*/
|
||||
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;
|
||||
@@ -196,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_notify(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
|
||||
|
||||
@@ -1,46 +1,71 @@
|
||||
/* Copyright (c) 2021. WiseTop. Scientific.
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Texas Instruments Incorporated
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of Texas Instruments Incorporated nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#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>
|
||||
#include <ti/sysbios/BIOS.h>
|
||||
#include "board.h"
|
||||
#include "mem_board_central.h"
|
||||
|
||||
static GPTimerCC26XX_Handle gptimer_handle;
|
||||
#define CLOCK_FREQ 4800 // clock freq = 0.1 ms(4800)
|
||||
|
||||
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
|
||||
static void __timerCallback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask)
|
||||
{
|
||||
uint32_t gp_timer_now;
|
||||
uint32_t gp_timer_last;
|
||||
uint8_t gp_timer_delta;
|
||||
uint32_t gp_timer_switch_ram;
|
||||
};
|
||||
// interrupt callback code goes here. Minimize processing in interrupt.
|
||||
elite_100us_task();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#endif // CENTRAL_GPTIMER_H
|
||||
void elite_gptimer_open(void)
|
||||
{
|
||||
GPTimerCC26XX_Handle hTimer;
|
||||
GPTimerCC26XX_Params params;
|
||||
GPTimerCC26XX_Params_init(¶ms);
|
||||
params.width = GPT_CONFIG_16BIT;
|
||||
params.mode = GPT_MODE_PERIODIC_UP;
|
||||
params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
|
||||
hTimer = GPTimerCC26XX_open(Board_GPTIMER0A, ¶ms);
|
||||
if (hTimer == NULL) {
|
||||
Task_exit();
|
||||
}
|
||||
|
||||
Types_FreqHz freq;
|
||||
BIOS_getCpuFreq(&freq);
|
||||
//GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; //47999 = 1ms
|
||||
GPTimerCC26XX_Value loadVal = CLOCK_FREQ; //0.1ms
|
||||
GPTimerCC26XX_setLoadValue(hTimer, loadVal);
|
||||
GPTimerCC26XX_registerInterrupt(hTimer, __timerCallback, GPT_INT_TIMEOUT);
|
||||
GPTimerCC26XX_start(hTimer);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,421 +1,13 @@
|
||||
#ifndef __MEM_BOARD_CENTAL_H
|
||||
#define __MEM_BOARD_CENTAL_H
|
||||
|
||||
/*
|
||||
* 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(){
|
||||
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void elite_100us_task(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,323 @@
|
||||
|
||||
/*
|
||||
* 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>
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
||||
|
||||
#define PIN_HIGH (5)
|
||||
#define PIN_LOW (-5)
|
||||
|
||||
struct gp_timer_t gpt = {0};
|
||||
|
||||
#include "mem_central_handle_notify.h"
|
||||
#define BLE_CHAR3_HANDLE 0x0024 // send instruction
|
||||
#define BLE_CHAR4_CONFIG_HANDLE 0x0028 // notify enable: 0100=enable; 0000=disable
|
||||
|
||||
#define CIS_DATA_LEN 50
|
||||
static uint16_t recv_regular_data_len = 0;
|
||||
static char recv_regular_data[CIS_DATA_LEN];
|
||||
|
||||
static void mem_event_callback();
|
||||
static void mem_connect_device(uint8_t addrType, uint8_t *peerAddr);
|
||||
static void write_gatt_msg(uint16_t hadnle, uint8_t *value);
|
||||
static void read_gatt_msg(uint8_t handle);
|
||||
|
||||
static void mem_board_init(void){
|
||||
mem_sel_signal = central_pin_input(PIN_MEM_SEL);
|
||||
mem_req_signal = central_pin_input(PIN_MEM_REQ);
|
||||
|
||||
elite_gptimer_open();
|
||||
|
||||
mem_uart_init();
|
||||
mem_spi_init();
|
||||
|
||||
ram_select(0);
|
||||
reset_status_register();
|
||||
ram_select(1);
|
||||
reset_status_register();
|
||||
|
||||
ram_select(0);
|
||||
|
||||
flag_enable(EVT_MEM_UART_ROUTINE);
|
||||
}
|
||||
|
||||
static EventTableEntry EVENT_TABLE[] = { //
|
||||
{EVT_ALL, &mem_event_callback},
|
||||
|
||||
// terminated
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static void gatt_msg_rsp()
|
||||
{
|
||||
/*
|
||||
* 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
|
||||
* +---+---+------------+------------------+
|
||||
*
|
||||
*/
|
||||
|
||||
#define MSG_RSP_LEN (recv_regular_data_len+3)
|
||||
char msg_rsp[CIS_DATA_LEN] = {0};
|
||||
|
||||
msg_rsp[0] = 4;
|
||||
msg_rsp[1] = 0;
|
||||
msg_rsp[2] = recv_regular_data_len;
|
||||
memcpy(msg_rsp+3, recv_regular_data, recv_regular_data_len);
|
||||
UART_write(uart_handle, msg_rsp, MSG_RSP_LEN);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mem_event_callback() {
|
||||
if(flag_mask(EVT_MEM_NOTIFY_HANDLE)){
|
||||
flag_disable(EVT_MEM_NOTIFY_HANDLE);
|
||||
central_handle_notify();
|
||||
}
|
||||
|
||||
if(flag_mask(EVT_MEM_UART_ROUTINE)){
|
||||
flag_disable(EVT_MEM_UART_ROUTINE);
|
||||
int rxBytes = UART_read(uart_handle, UART_rxBuf, 1);
|
||||
}
|
||||
|
||||
if(flag_mask(EVT_MEM_INS_CHECK_SURVIVE)){
|
||||
flag_disable(EVT_MEM_INS_CHECK_SURVIVE);
|
||||
|
||||
char ACK[4] = {4,0,1,3}; //ack success
|
||||
UART_write(uart_handle, ACK, sizeof(ACK)/sizeof(ACK[0]));
|
||||
}
|
||||
|
||||
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"
|
||||
write_gatt_msg(store_rxBuf[2], store_rxBuf+3);
|
||||
}
|
||||
}
|
||||
|
||||
if(flag_mask(EVT_MEM_INS_READ)){
|
||||
flag_disable(EVT_MEM_INS_READ);
|
||||
if(state == BLE_STATE_CONNECTED){
|
||||
read_gatt_msg(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);
|
||||
gatt_msg_rsp();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
state = BLE_STATE_CONNECTING;
|
||||
|
||||
Util_startClock(&connectingClock);
|
||||
|
||||
GAPCentralRole_EstablishLink(DEFAULT_LINK_HIGH_DUTY_CYCLE,
|
||||
DEFAULT_LINK_WHITE_LIST,
|
||||
addrType, Addr);
|
||||
}
|
||||
|
||||
static void write_gatt_msg(uint16_t handle, uint8_t *value){
|
||||
|
||||
if (state == BLE_STATE_CONNECTED &&
|
||||
charHdl != 0 &&
|
||||
procedureInProgress == FALSE)
|
||||
{
|
||||
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{
|
||||
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
|
||||
{
|
||||
status = bleMemAllocError;
|
||||
}
|
||||
|
||||
if (status == SUCCESS)
|
||||
{
|
||||
procedureInProgress = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void read_gatt_msg(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void elite_100us_task(void)
|
||||
{
|
||||
//read signal
|
||||
static int mem_sel_times = 0;
|
||||
static int mem_req_times = 0;
|
||||
|
||||
gpt.gp_timer_now++;
|
||||
events |= SBC_PERIODIC_EVT;
|
||||
|
||||
mem_sel_times += central_pin_input(PIN_MEM_SEL) ? 1 : -1;
|
||||
if (mem_sel_times >= PIN_HIGH) {
|
||||
mem_sel_times = PIN_HIGH;
|
||||
mem_sel_signal = TRUE;
|
||||
mem_req_times = 0;
|
||||
} else if (mem_sel_times <= PIN_LOW) {
|
||||
mem_sel_times = PIN_LOW;
|
||||
mem_sel_signal = FALSE;
|
||||
}
|
||||
|
||||
if (mem_sel_signal == FALSE) {
|
||||
mem_req_times += central_pin_input(PIN_MEM_REQ) ? 1 : -1;
|
||||
if (mem_req_times >= PIN_HIGH) {
|
||||
mem_req_times = PIN_HIGH;
|
||||
mem_req_signal = TRUE;
|
||||
} else if (mem_req_times <= PIN_LOW) {
|
||||
mem_req_times = PIN_LOW;
|
||||
mem_req_signal = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
Semaphore_post(sem);
|
||||
}
|
||||
|
||||
void periodic_evevnt()
|
||||
{
|
||||
static bool ram_event = FALSE;
|
||||
gpt.gp_timer_delta = gpt.gp_timer_now - gpt.gp_timer_last;
|
||||
gpt.gp_timer_last = gpt.gp_timer_now;
|
||||
|
||||
if (!ram_event && mem_sel_signal == FALSE) {
|
||||
if (mem_req_signal != ram_sel_signal) {
|
||||
ram_event = TRUE;
|
||||
gpt.gp_timer_switch_ram = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (ram_event) {
|
||||
gpt.gp_timer_switch_ram++;
|
||||
if (gpt.gp_timer_switch_ram >= 1000) {
|
||||
gpt.gp_timer_switch_ram = 0;
|
||||
ram_event = FALSE;
|
||||
write_green_data_and_switch_ram();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -2,77 +2,38 @@
|
||||
#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"
|
||||
#define MEM_BUFFER_SIZE 250
|
||||
static uint16_t elite_pkg_length = 0;
|
||||
static uint8_t recv_elite_data[MEM_BUFFER_SIZE] = {0}; // recv data from elite
|
||||
|
||||
/*========================
|
||||
==== notify variable ====
|
||||
=======================*/
|
||||
void write_green_data_and_switch_ram();
|
||||
|
||||
#define MEM_BUFFER_SIZE SPI_TX_BUFFER_SIZE // 250
|
||||
//#define MEM_SWITCH_THRESHOLD 7000 //max:7K bytes
|
||||
|
||||
#define MSM_REG_WRITE 0x01
|
||||
#define MEM_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_HDR_LEN 3
|
||||
#define ELITE_PKG_LEN 40
|
||||
#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_RED_DATA_LEN (RAM_RED_HDR_LEN + ELITE_PKG_LEN + RAM_RED_TAILER_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)
|
||||
#define RAM_GREEN_DATA_LEN 12
|
||||
#define RAM_GREEN_CTX_LEN (RAM_INS_LEN + RAM_GREEN_DATA_LEN)
|
||||
|
||||
static uint16_t write_ram_addr = RAM_GREEN_DATA_LEN; // writing pointer, where to write on RAM
|
||||
static uint8_t green_wrong = 0;
|
||||
static uint8_t green_retry_cnt = 0;
|
||||
|
||||
static void reset_status_register()
|
||||
{
|
||||
uint8_t status_register_buf[2] = {MEM_REG_WRITE, 0b01000001};
|
||||
central_spi_send(status_register_buf, 2);
|
||||
}
|
||||
|
||||
uint8_t check_sum(uint8_t message[], int nBytes)
|
||||
{
|
||||
uint8_t sum = 0;
|
||||
@@ -87,229 +48,103 @@ uint8_t check_sum(uint8_t message[], int nBytes)
|
||||
|
||||
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;
|
||||
int index = 0;
|
||||
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
|
||||
static uint8_t red_wrong = 0;
|
||||
static uint8_t red_retry_cnt = 0;
|
||||
static uint8_t mem_pkg_sequence = 0; // increase when receiving data from elite
|
||||
uint8_t write_ins[RAM_INS_LEN] = {MEM_INS_WRITE, (uint8_t)(write_ram_addr >> 8), (uint8_t)(write_ram_addr)};
|
||||
uint8_t red_hdr[RAM_RED_HDR_LEN] = {0xFF, mem_pkg_sequence, elite_pkg_length};
|
||||
uint8_t red_tailer[RAM_RED_TAILER_LEN] = {red_wrong, red_retry_cnt, green_wrong, green_retry_cnt, ram_sel_signal};
|
||||
uint8_t write_ram_ins[RAM_RED_CTX_LEN] = {0};
|
||||
uint8_t read_ram_ins[RAM_RED_CTX_LEN] = {MEM_INS_READ, (uint8_t)(write_ram_addr >> 8), (uint8_t)(write_ram_addr)};
|
||||
uint8_t read_ram_buf[RAM_RED_CTX_LEN] = {0};
|
||||
|
||||
memcpy(write_ram_ins, write_ins, RAM_INS_LEN);
|
||||
index += RAM_INS_LEN;
|
||||
memcpy(write_ram_ins+index, red_hdr, RAM_RED_HDR_LEN);
|
||||
index += RAM_RED_HDR_LEN;
|
||||
memcpy(write_ram_ins+index, recv_elite_data, ELITE_PKG_LEN);
|
||||
index += ELITE_PKG_LEN;
|
||||
memcpy(write_ram_ins+index, red_tailer, RAM_RED_TAILER_LEN);
|
||||
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);
|
||||
write_ram_ins[index] = check_sum(write_ram_ins+RAM_INS_LEN, RAM_RED_HDR_LEN+ELITE_PKG_LEN+RAM_RED_TAILER_LEN);
|
||||
|
||||
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 = false;
|
||||
central_spi_send(write_ram_ins, RAM_RED_CTX_LEN);
|
||||
central_spi_recv(read_ram_ins, read_ram_buf);
|
||||
|
||||
// compare check_sum
|
||||
if (read_ram_buf[RAM_RED_CTX_LEN-1] != write_ram_ins[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++;
|
||||
red_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;
|
||||
reset_status_register();
|
||||
}
|
||||
|
||||
if (!write_again)
|
||||
break;
|
||||
|
||||
if (write_limit >= 5) {
|
||||
red_wrong++;
|
||||
reset_status_register();
|
||||
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);
|
||||
// }
|
||||
|
||||
if (write_ram_addr > 7500)
|
||||
write_ram_addr = write_ram_addr;
|
||||
else
|
||||
write_ram_addr += RAM_RED_DATA_LEN;
|
||||
|
||||
mem_pkg_sequence++;
|
||||
}
|
||||
|
||||
void master_switch_memory()
|
||||
void write_green_data_and_switch_ram()
|
||||
{
|
||||
uint8_t read_ram_ins[RAM_GREEN_CTX_LEN] = {0};
|
||||
uint8_t write_ram_ins[RAM_GREEN_CTX_LEN] = {
|
||||
MEM_INS_WRITE, 0, 0,
|
||||
(uint8_t)(write_ram_addr >> 8), (uint8_t)(write_ram_addr), 0xA5, 0x5A,
|
||||
(uint8_t)(write_ram_addr >> 8), (uint8_t)(write_ram_addr), 0xA5, 0x5A,
|
||||
(uint8_t)(write_ram_addr >> 8), (uint8_t)(write_ram_addr), 0xA5, 0x5A};
|
||||
uint8_t read_ram_ins[RAM_GREEN_CTX_LEN] = {MEM_INS_READ, 0, 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);
|
||||
bool write_again = false;
|
||||
|
||||
while (1) {
|
||||
write_again = false;
|
||||
central_spi_send(write_ram_ins, RAM_GREEN_CTX_LEN);
|
||||
central_spi_recv(read_ram_ins, read_ram_buf);
|
||||
|
||||
// compare data
|
||||
for (i=3; i<RAM_GREEN_CTX_LEN; i++) {
|
||||
if (p[i] != read_ram_buf[i]) {
|
||||
for (int i=3; i<RAM_GREEN_CTX_LEN; i++) {
|
||||
if (write_ram_ins[i] != read_ram_buf[i]) {
|
||||
write_again = true;
|
||||
green_retry_cnt++;
|
||||
write_limit++;
|
||||
reset_status_register();
|
||||
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_again)
|
||||
break;
|
||||
|
||||
if (write_limit >= 5) {
|
||||
green_wrong++;
|
||||
reset_status_register();
|
||||
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);
|
||||
|
||||
// switch RAM
|
||||
ram_select(!ram_sel_signal);
|
||||
CPUdelay(10 * 16); // 10us
|
||||
|
||||
write_ram_addr = RAM_GREEN_DATA_LEN; //reset ram_addr
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,12 +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>
|
||||
|
||||
#define central_pin_output(pin, value) PIN_setOutputValue(hKeyPins, PIN_ID(pin), (value))
|
||||
#define central_pin_input(pin) PIN_getInputValue(PIN_ID(pin))
|
||||
static PIN_Handle Central_pin_handle;
|
||||
static PIN_State Central_pin_state;
|
||||
|
||||
#define central_ram_select(value) central_pin_output(PIN_RAM_SEL, (value) ? 1 : 0)
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
void ram_select(bool value)
|
||||
{
|
||||
ram_sel_signal = value;
|
||||
central_pin_output(PIN_RAM_SEL, ram_sel_signal);
|
||||
central_pin_output(PIN_MEM_TEST, ram_sel_signal);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,42 +7,20 @@
|
||||
#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);
|
||||
void mem_spi_init() {
|
||||
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);
|
||||
}
|
||||
|
||||
#define central_spi_send(data, len) \
|
||||
@@ -50,18 +28,18 @@ static void SPI_reopen(){
|
||||
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, ¢ral_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, ¢ral_spi_transaction); \
|
||||
central_pin_output(Board_SPI_CS, 1); \
|
||||
central_pin_output(PIN_MULTIPLEXER_CS, 1); \
|
||||
} while (0)
|
||||
|
||||
#endif // CENTRAL_SPI_H
|
||||
|
||||
@@ -7,16 +7,6 @@
|
||||
*/
|
||||
#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].
|
||||
*/
|
||||
@@ -28,9 +18,9 @@
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* fire a event with [flag].
|
||||
* enable event [flag].
|
||||
*/
|
||||
#define flag_notify(flag) \
|
||||
#define flag_enable(flag) \
|
||||
do { \
|
||||
uint8 __key = Hwi_disable(); \
|
||||
EventMask |= (uint16_t)(flag); \
|
||||
@@ -38,17 +28,6 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,16 +10,13 @@
|
||||
|
||||
#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{
|
||||
@@ -36,14 +33,11 @@ typedef enum{
|
||||
INS_CHECK_SURVIVE
|
||||
} Control_Ins;
|
||||
|
||||
static Control_Ins ins = INS_IDLE;
|
||||
|
||||
/** 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
|
||||
@@ -61,12 +55,9 @@ typedef enum{
|
||||
(_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)
|
||||
static void uart_recv_callback(UART_Handle handle, void *rxBuf, size_t size)
|
||||
{
|
||||
uint8_t *uart_rxBuf = (uint8_t *)rxBuf;
|
||||
static int index = 0;
|
||||
@@ -97,52 +88,50 @@ static void readCallback(UART_Handle handle, void *rxBuf, size_t size)
|
||||
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);
|
||||
flag_enable(EVT_MEM_INS_SCAN);
|
||||
flag_enable(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);
|
||||
flag_enable(EVT_MEM_INS_CONNECT);
|
||||
flag_enable(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);
|
||||
flag_enable(EVT_MEM_INS_WRITE);
|
||||
flag_enable(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);
|
||||
flag_enable(EVT_MEM_INS_READ);
|
||||
flag_enable(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);
|
||||
flag_enable(EVT_MEM_INS_DISCONNECT);
|
||||
flag_enable(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);
|
||||
flag_enable(EVT_MEM_INS_CHECK_SURVIVE);
|
||||
flag_enable(EVT_MEM_UART_ROUTINE);
|
||||
rx_fi = true;
|
||||
return;
|
||||
}
|
||||
flag_notify(EVT_MEM_UART_ROUTINE);
|
||||
flag_enable(EVT_MEM_UART_ROUTINE);
|
||||
}
|
||||
|
||||
static void mem_UART_init(){
|
||||
|
||||
// uint32_t timeoutUs = 5000; // 5ms timeout, default timeout is no timeout (BIOS_WAIT_FOREVER)
|
||||
static void mem_uart_init(){
|
||||
|
||||
// Init UART and specify non-default parameters
|
||||
UART_Params_init(¶ms);
|
||||
@@ -150,54 +139,11 @@ static void mem_UART_init(){
|
||||
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;
|
||||
params.readCallback = uart_recv_callback;
|
||||
|
||||
// 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
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
|
||||
#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
|
||||