Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b649c22231 | |||
| f0f36b3259 | |||
| aacc263447 | |||
| 99f502f5ca | |||
| f54dbd330f | |||
| 54ab777871 | |||
| 047acb1e99 | |||
| 1b842a5cd9 | |||
| 0161fe1868 | |||
| 9e285b43fb | |||
| 334a68c6fe | |||
| 627b5f0b59 | |||
| 94e82768d2 | |||
| 4957142e08 | |||
| 08490df886 | |||
| ac0662bc9d |
|
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 |
|
After Width: | Height: | Size: 54 KiB |
@@ -36,10 +36,11 @@
|
||||
* CC2650 Booster Pack.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* ====================== Includes ============================================
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
#include <xdc/std.h>
|
||||
#include <xdc/runtime/System.h>
|
||||
|
||||
@@ -56,16 +57,46 @@
|
||||
#include <inc/hw_ints.h>
|
||||
#include <driverlib/ioc.h>
|
||||
#include <driverlib/udma.h>
|
||||
// clang-format on
|
||||
|
||||
#include "Board.h"
|
||||
|
||||
///*
|
||||
// * ========================= IO driver initialization =========================
|
||||
// * From main, PIN_init(BoardGpioInitTable) should be called to setup safe
|
||||
// * settings for this board.
|
||||
// * When a pin is allocated and then de-allocated, it will revert to the state
|
||||
// * configured in this table.
|
||||
// */
|
||||
//
|
||||
///* Place into subsections to allow the TI linker to remove items properly */
|
||||
//#if defined(__TI_COMPILER_VERSION__)
|
||||
//#pragma DATA_SECTION(BoardGpioInitTable, ".const:BoardGpioInitTable")
|
||||
//#pragma DATA_SECTION(PINCC26XX_hwAttrs, ".const:PINCC26XX_hwAttrs")
|
||||
//#endif
|
||||
//
|
||||
//PIN_Config BoardGpioInitTable[] = { //
|
||||
// PIN_MEM_INS | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS,
|
||||
// PIN_MEM_REQ | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS,
|
||||
// PIN_MEM_BZY | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS,
|
||||
// PIN_MEM_SEL | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
// PIN_MEM_TEST | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
|
||||
// PIN_TERMINATE};
|
||||
//
|
||||
//const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = {
|
||||
// //
|
||||
// .intPriority = ~0,
|
||||
// .swiPriority = 0
|
||||
// //
|
||||
//};
|
||||
|
||||
/*
|
||||
* ========================= IO driver initialization =========================
|
||||
* From main, PIN_init(BoardGpioInitTable) should be called to setup safe
|
||||
* settings for this board.
|
||||
* When a pin is allocated and then de-allocated, it will revert to the state
|
||||
* configured in this table.
|
||||
*/
|
||||
*/
|
||||
|
||||
/* Place into subsections to allow the TI linker to remove items properly */
|
||||
#if defined(__TI_COMPILER_VERSION__)
|
||||
@@ -73,20 +104,22 @@
|
||||
#pragma DATA_SECTION(PINCC26XX_hwAttrs, ".const:PINCC26XX_hwAttrs")
|
||||
#endif
|
||||
|
||||
const PIN_Config BoardGpioInitTable[] = {
|
||||
Board_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
|
||||
Board_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
|
||||
Board_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX */
|
||||
Board_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX */
|
||||
Board_SRDY | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* SRDY */
|
||||
Board_MRDY | PIN_INPUT_EN | PIN_PULLDOWN, /* MRDY */
|
||||
PIN_TERMINATE
|
||||
};
|
||||
const PIN_Config BoardGpioInitTable[] = { //
|
||||
Board_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
|
||||
Board_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
|
||||
Board_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX */
|
||||
Board_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX */
|
||||
Board_SRDY | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* SRDY */
|
||||
Board_MRDY | PIN_INPUT_EN | PIN_PULLDOWN, /* MRDY */
|
||||
PIN_TERMINATE};
|
||||
|
||||
const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = {
|
||||
//
|
||||
.intPriority = ~0,
|
||||
.swiPriority = 0
|
||||
//
|
||||
};
|
||||
|
||||
/*============================================================================*/
|
||||
|
||||
/*
|
||||
@@ -96,13 +129,14 @@ const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = {
|
||||
#if defined(__TI_COMPILER_VERSION__)
|
||||
#pragma DATA_SECTION(PowerCC26XX_config, ".const:PowerCC26XX_config")
|
||||
#endif
|
||||
|
||||
const PowerCC26XX_Config PowerCC26XX_config = {
|
||||
.policyInitFxn = NULL,
|
||||
.policyFxn = &PowerCC26XX_standbyPolicy,
|
||||
.calibrateFxn = &PowerCC26XX_calibrate,
|
||||
.enablePolicy = TRUE,
|
||||
.calibrateRCOSC_LF = TRUE,
|
||||
.calibrateRCOSC_HF = TRUE,
|
||||
.policyInitFxn = NULL,
|
||||
.policyFxn = &PowerCC26XX_standbyPolicy,
|
||||
.calibrateFxn = &PowerCC26XX_calibrate,
|
||||
.enablePolicy = TRUE,
|
||||
.calibrateRCOSC_LF = TRUE,
|
||||
.calibrateRCOSC_HF = TRUE,
|
||||
};
|
||||
/*
|
||||
* ============================= Power end ====================================
|
||||
@@ -126,28 +160,32 @@ UARTCC26XX_Object uartCC26XXObjects[BOOSTXL_CC2650MA_UARTCOUNT];
|
||||
|
||||
/* UART hardware parameter structure, also used to assign UART pins */
|
||||
const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[BOOSTXL_CC2650MA_UARTCOUNT] = {
|
||||
//
|
||||
{
|
||||
.baseAddr = UART0_BASE,
|
||||
.powerMngrId = PowerCC26XX_PERIPH_UART0,
|
||||
.intNum = INT_UART0_COMB,
|
||||
.intPriority = ~0,
|
||||
.swiPriority = 0,
|
||||
.txPin = Board_UART_TX,
|
||||
.rxPin = Board_UART_RX,
|
||||
.ctsPin = PIN_UNASSIGNED,
|
||||
.rtsPin = PIN_UNASSIGNED
|
||||
.baseAddr = UART0_BASE,
|
||||
.powerMngrId = PowerCC26XX_PERIPH_UART0,
|
||||
.intNum = INT_UART0_COMB,
|
||||
.intPriority = ~0,
|
||||
.swiPriority = 0,
|
||||
.txPin = Board_UART_TX,
|
||||
.rxPin = Board_UART_RX,
|
||||
.ctsPin = PIN_UNASSIGNED,
|
||||
.rtsPin = PIN_UNASSIGNED
|
||||
//
|
||||
}
|
||||
//
|
||||
};
|
||||
|
||||
/* UART configuration structure */
|
||||
const UART_Config UART_config[] = {
|
||||
const UART_Config UART_config[] = { //
|
||||
{
|
||||
//
|
||||
.fxnTablePtr = &UARTCC26XX_fxnTable,
|
||||
.object = &uartCC26XXObjects[0],
|
||||
.hwAttrs = &uartCC26XXHWAttrs[0]
|
||||
//
|
||||
},
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
{NULL, NULL, NULL}};
|
||||
/*
|
||||
* ============================= UART end =====================================
|
||||
*/
|
||||
@@ -169,22 +207,27 @@ UDMACC26XX_Object udmaObjects[BOOSTXL_CC2650MA_UDMACOUNT];
|
||||
|
||||
/* UDMA configuration structure */
|
||||
const UDMACC26XX_HWAttrs udmaHWAttrs[BOOSTXL_CC2650MA_UDMACOUNT] = {
|
||||
//
|
||||
{
|
||||
//
|
||||
.baseAddr = UDMA0_BASE,
|
||||
.powerMngrId = PowerCC26XX_PERIPH_UDMA,
|
||||
.intNum = INT_DMA_ERR,
|
||||
.intPriority = ~0
|
||||
//
|
||||
}
|
||||
//
|
||||
};
|
||||
|
||||
/* UDMA configuration structure */
|
||||
const UDMACC26XX_Config UDMACC26XX_config[] = {
|
||||
const UDMACC26XX_Config UDMACC26XX_config[] = { //
|
||||
{
|
||||
.object = &udmaObjects[0],
|
||||
.hwAttrs = &udmaHWAttrs[0]
|
||||
//
|
||||
.object = &udmaObjects[0],
|
||||
.hwAttrs = &udmaHWAttrs[0]
|
||||
//
|
||||
},
|
||||
{NULL, NULL}
|
||||
};
|
||||
{NULL, NULL}};
|
||||
/*
|
||||
* ============================= UDMA end =====================================
|
||||
*/
|
||||
@@ -206,54 +249,64 @@ SPICC26XXDMA_Object spiCC26XXDMAObjects[BOOSTXL_CC2650MA_SPICOUNT];
|
||||
|
||||
/* SPI configuration structure, describing which pins are to be used */
|
||||
const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[BOOSTXL_CC2650MA_SPICOUNT] = {
|
||||
//
|
||||
{
|
||||
.baseAddr = SSI0_BASE,
|
||||
.intNum = INT_SSI0_COMB,
|
||||
.intPriority = ~0,
|
||||
.swiPriority = 0,
|
||||
.powerMngrId = PowerCC26XX_PERIPH_SSI0,
|
||||
.defaultTxBufValue = 0,
|
||||
.rxChannelBitMask = 1<<UDMA_CHAN_SSI0_RX,
|
||||
.txChannelBitMask = 1<<UDMA_CHAN_SSI0_TX,
|
||||
.mosiPin = Board_SPI0_MOSI,
|
||||
.misoPin = Board_SPI0_MISO,
|
||||
.clkPin = Board_SPI0_CLK,
|
||||
.csnPin = Board_SPI0_CS
|
||||
//
|
||||
.baseAddr = SSI0_BASE,
|
||||
.intNum = INT_SSI0_COMB,
|
||||
.intPriority = ~0,
|
||||
.swiPriority = 0,
|
||||
.powerMngrId = PowerCC26XX_PERIPH_SSI0,
|
||||
.defaultTxBufValue = 0,
|
||||
.rxChannelBitMask = 1 << UDMA_CHAN_SSI0_RX,
|
||||
.txChannelBitMask = 1 << UDMA_CHAN_SSI0_TX,
|
||||
.mosiPin = Board_SPI0_MOSI,
|
||||
.misoPin = Board_SPI0_MISO,
|
||||
.clkPin = Board_SPI0_CLK,
|
||||
.csnPin = PIN_UNASSIGNED
|
||||
//
|
||||
},
|
||||
#ifdef HEADSTAGE_MA_USE_SPI2
|
||||
{
|
||||
.baseAddr = SSI1_BASE,
|
||||
.intNum = INT_SSI1_COMB,
|
||||
.intPriority = ~0,
|
||||
.swiPriority = 0,
|
||||
.powerMngrId = PowerCC26XX_PERIPH_SSI1,
|
||||
.defaultTxBufValue = 0,
|
||||
.rxChannelBitMask = 1<<UDMA_CHAN_SSI1_RX,
|
||||
.txChannelBitMask = 1<<UDMA_CHAN_SSI1_TX,
|
||||
.mosiPin = Board_SPI1_MOSI,
|
||||
.misoPin = Board_SPI1_MISO,
|
||||
.clkPin = Board_SPI1_CLK,
|
||||
.csnPin = Board_SPI1_CS
|
||||
},
|
||||
//
|
||||
.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]
|
||||
//
|
||||
},
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
#endif
|
||||
{NULL, NULL, NULL}};
|
||||
/*
|
||||
* ========================== SPI DMA end =====================================
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* ========================== Crypto begin ====================================
|
||||
@@ -273,28 +326,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 ==================================
|
||||
*/
|
||||
@@ -308,10 +361,12 @@ const CryptoCC26XX_Config CryptoCC26XX_config[] = {
|
||||
|
||||
/* RF hwi and swi priority */
|
||||
const RFCC26XX_HWAttrs RFCC26XX_hwAttrs = {
|
||||
//
|
||||
.hwiCpe0Priority = ~0,
|
||||
.hwiHwPriority = ~0,
|
||||
.swiCpe0Priority = 5,
|
||||
.swiHwPriority = 5,
|
||||
.swiCpe0Priority = 5,
|
||||
.swiHwPriority = 5,
|
||||
//
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -334,20 +389,21 @@ const RFCC26XX_HWAttrs RFCC26XX_hwAttrs = {
|
||||
TRNGCC26XX_Object trngCC26XXObjects[BOOSTXL_CC2650MA_TRNGCOUNT];
|
||||
|
||||
/* TRNG configuration structure, describing which pins are to be used */
|
||||
const TRNGCC26XX_HWAttrs TRNGCC26XXHWAttrs[BOOSTXL_CC2650MA_TRNGCOUNT] = {
|
||||
{
|
||||
.powerMngrId = PowerCC26XX_PERIPH_TRNG,
|
||||
}
|
||||
};
|
||||
const TRNGCC26XX_HWAttrs TRNGCC26XXHWAttrs[BOOSTXL_CC2650MA_TRNGCOUNT] = {{
|
||||
//
|
||||
.powerMngrId = PowerCC26XX_PERIPH_TRNG,
|
||||
//
|
||||
}};
|
||||
|
||||
/* TRNG configuration structure */
|
||||
const TRNGCC26XX_Config TRNGCC26XX_config[] = {
|
||||
const TRNGCC26XX_Config TRNGCC26XX_config[] = { //
|
||||
{
|
||||
.object = &trngCC26XXObjects[0],
|
||||
.hwAttrs = &TRNGCC26XXHWAttrs[0]
|
||||
//
|
||||
.object = &trngCC26XXObjects[0],
|
||||
.hwAttrs = &TRNGCC26XXHWAttrs[0]
|
||||
//
|
||||
},
|
||||
{NULL, NULL}
|
||||
};
|
||||
{NULL, NULL}};
|
||||
|
||||
/*
|
||||
* ========================= TRNG end ====================================
|
||||
@@ -365,14 +421,62 @@ const TRNGCC26XX_Config TRNGCC26XX_config[] = {
|
||||
|
||||
/* GPTimer hardware attributes, one per timer part (Timer 0A, 0B, 1A, 1B..) */
|
||||
const GPTimerCC26XX_HWAttrs gptimerCC26xxHWAttrs[BOOSTXL_CC2650MA_GPTIMERPARTSCOUNT] = {
|
||||
{ .baseAddr = GPT0_BASE, .intNum = INT_GPT0A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT0, .pinMux = GPT_PIN_0A, },
|
||||
{ .baseAddr = GPT0_BASE, .intNum = INT_GPT0B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT0, .pinMux = GPT_PIN_0B, },
|
||||
{ .baseAddr = GPT1_BASE, .intNum = INT_GPT1A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT1, .pinMux = GPT_PIN_1A, },
|
||||
{ .baseAddr = GPT1_BASE, .intNum = INT_GPT1B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT1, .pinMux = GPT_PIN_1B, },
|
||||
{ .baseAddr = GPT2_BASE, .intNum = INT_GPT2A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT2, .pinMux = GPT_PIN_2A, },
|
||||
{ .baseAddr = GPT2_BASE, .intNum = INT_GPT2B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT2, .pinMux = GPT_PIN_2B, },
|
||||
{ .baseAddr = GPT3_BASE, .intNum = INT_GPT3A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT3, .pinMux = GPT_PIN_3A, },
|
||||
{ .baseAddr = GPT3_BASE, .intNum = INT_GPT3B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT3, .pinMux = GPT_PIN_3B, },
|
||||
{
|
||||
.baseAddr = GPT0_BASE,
|
||||
.intNum = INT_GPT0A,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT0,
|
||||
.pinMux = GPT_PIN_0A,
|
||||
},
|
||||
{
|
||||
.baseAddr = GPT0_BASE,
|
||||
.intNum = INT_GPT0B,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT0,
|
||||
.pinMux = GPT_PIN_0B,
|
||||
},
|
||||
{
|
||||
.baseAddr = GPT1_BASE,
|
||||
.intNum = INT_GPT1A,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT1,
|
||||
.pinMux = GPT_PIN_1A,
|
||||
},
|
||||
{
|
||||
.baseAddr = GPT1_BASE,
|
||||
.intNum = INT_GPT1B,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT1,
|
||||
.pinMux = GPT_PIN_1B,
|
||||
},
|
||||
{
|
||||
.baseAddr = GPT2_BASE,
|
||||
.intNum = INT_GPT2A,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT2,
|
||||
.pinMux = GPT_PIN_2A,
|
||||
},
|
||||
{
|
||||
.baseAddr = GPT2_BASE,
|
||||
.intNum = INT_GPT2B,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT2,
|
||||
.pinMux = GPT_PIN_2B,
|
||||
},
|
||||
{
|
||||
.baseAddr = GPT3_BASE,
|
||||
.intNum = INT_GPT3A,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT3,
|
||||
.pinMux = GPT_PIN_3A,
|
||||
},
|
||||
{
|
||||
.baseAddr = GPT3_BASE,
|
||||
.intNum = INT_GPT3B,
|
||||
.intPriority = (~0),
|
||||
.powerMngrId = PowerCC26XX_PERIPH_GPT3,
|
||||
.pinMux = GPT_PIN_3B,
|
||||
},
|
||||
};
|
||||
|
||||
/* GPTimer objects, one per full-width timer (A+B) (Timer 0, Timer 1..) */
|
||||
@@ -380,14 +484,15 @@ GPTimerCC26XX_Object gptimerCC26XXObjects[BOOSTXL_CC2650MA_GPTIMERCOUNT];
|
||||
|
||||
/* GPTimer configuration (used as GPTimer_Handle by driver and application) */
|
||||
const GPTimerCC26XX_Config GPTimerCC26XX_config[BOOSTXL_CC2650MA_GPTIMERPARTSCOUNT] = {
|
||||
{ &gptimerCC26XXObjects[0], &gptimerCC26xxHWAttrs[0], GPT_A },
|
||||
{ &gptimerCC26XXObjects[0], &gptimerCC26xxHWAttrs[1], GPT_B },
|
||||
{ &gptimerCC26XXObjects[1], &gptimerCC26xxHWAttrs[2], GPT_A },
|
||||
{ &gptimerCC26XXObjects[1], &gptimerCC26xxHWAttrs[3], GPT_B },
|
||||
{ &gptimerCC26XXObjects[2], &gptimerCC26xxHWAttrs[4], GPT_A },
|
||||
{ &gptimerCC26XXObjects[2], &gptimerCC26xxHWAttrs[5], GPT_B },
|
||||
{ &gptimerCC26XXObjects[3], &gptimerCC26xxHWAttrs[6], GPT_A },
|
||||
{ &gptimerCC26XXObjects[3], &gptimerCC26xxHWAttrs[7], GPT_B },
|
||||
//
|
||||
{&gptimerCC26XXObjects[0], &gptimerCC26xxHWAttrs[0], GPT_A},
|
||||
{&gptimerCC26XXObjects[0], &gptimerCC26xxHWAttrs[1], GPT_B},
|
||||
{&gptimerCC26XXObjects[1], &gptimerCC26xxHWAttrs[2], GPT_A},
|
||||
{&gptimerCC26XXObjects[1], &gptimerCC26xxHWAttrs[3], GPT_B},
|
||||
{&gptimerCC26XXObjects[2], &gptimerCC26xxHWAttrs[4], GPT_A},
|
||||
{&gptimerCC26XXObjects[2], &gptimerCC26xxHWAttrs[5], GPT_B},
|
||||
{&gptimerCC26XXObjects[3], &gptimerCC26xxHWAttrs[6], GPT_A},
|
||||
{&gptimerCC26XXObjects[3], &gptimerCC26xxHWAttrs[7], GPT_B},
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -405,14 +510,15 @@ const GPTimerCC26XX_Config GPTimerCC26XX_config[BOOSTXL_CC2650MA_GPTIMERPARTSCOU
|
||||
#endif
|
||||
/* PWM configuration, one per PWM output. */
|
||||
PWMTimerCC26XX_HwAttrs pwmtimerCC26xxHWAttrs[BOOSTXL_CC2650MA_PWMCOUNT] = {
|
||||
{ .pwmPin = Board_PWMPIN0, .gpTimerUnit = Board_GPTIMER0A },
|
||||
{ .pwmPin = Board_PWMPIN1, .gpTimerUnit = Board_GPTIMER0B },
|
||||
{ .pwmPin = Board_PWMPIN2, .gpTimerUnit = Board_GPTIMER1A },
|
||||
{ .pwmPin = Board_PWMPIN3, .gpTimerUnit = Board_GPTIMER1B },
|
||||
{ .pwmPin = Board_PWMPIN4, .gpTimerUnit = Board_GPTIMER2A },
|
||||
{ .pwmPin = Board_PWMPIN5, .gpTimerUnit = Board_GPTIMER2B },
|
||||
{ .pwmPin = Board_PWMPIN6, .gpTimerUnit = Board_GPTIMER3A },
|
||||
{ .pwmPin = Board_PWMPIN7, .gpTimerUnit = Board_GPTIMER3B },
|
||||
//
|
||||
{.pwmPin = Board_PWMPIN0, .gpTimerUnit = Board_GPTIMER0A},
|
||||
{.pwmPin = Board_PWMPIN1, .gpTimerUnit = Board_GPTIMER0B},
|
||||
{.pwmPin = Board_PWMPIN2, .gpTimerUnit = Board_GPTIMER1A},
|
||||
{.pwmPin = Board_PWMPIN3, .gpTimerUnit = Board_GPTIMER1B},
|
||||
{.pwmPin = Board_PWMPIN4, .gpTimerUnit = Board_GPTIMER2A},
|
||||
{.pwmPin = Board_PWMPIN5, .gpTimerUnit = Board_GPTIMER2B},
|
||||
{.pwmPin = Board_PWMPIN6, .gpTimerUnit = Board_GPTIMER3A},
|
||||
{.pwmPin = Board_PWMPIN7, .gpTimerUnit = Board_GPTIMER3B},
|
||||
};
|
||||
|
||||
/* PWM object, one per PWM output */
|
||||
@@ -422,17 +528,16 @@ 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 ======================================
|
||||
@@ -440,7 +545,13 @@ const PWM_Config PWM_config[BOOSTXL_CC2650MA_PWMCOUNT + 1] = {
|
||||
|
||||
/*
|
||||
* ============================= 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")
|
||||
@@ -475,6 +586,242 @@ const I2C_Config I2C_config[] = {
|
||||
},
|
||||
{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
|
||||
|
||||
@@ -50,7 +50,6 @@ extern "C" {
|
||||
* ==========================================================================*/
|
||||
#include <ti/drivers/PIN.h>
|
||||
#include <driverlib/ioc.h>
|
||||
#include "boards_config/elite_boards_select.h"
|
||||
|
||||
/** ============================================================================
|
||||
* Externs
|
||||
@@ -90,25 +89,25 @@ extern const PIN_Config BoardGpioInitTable[];
|
||||
*/
|
||||
|
||||
/* Connector J1 */
|
||||
#define Board_BP_Pin_J1_2 DIO7
|
||||
#define Board_BP_Pin_J1_3 DIO0
|
||||
#define Board_BP_Pin_J1_4 DIO1
|
||||
#define Board_BP_Pin_J1_5 DIO2
|
||||
#define Board_BP_Pin_J1_6 DIO3
|
||||
#define Board_BP_Pin_J1_7 DIO10
|
||||
#define Board_BP_Pin_J1_8 DIO4
|
||||
#define Board_BP_Pin_J1_9 DIO5
|
||||
#define Board_BP_Pin_J1_10 DIO6
|
||||
#define Board_BP_Pin_J1_2 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_3 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_4 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_5 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_6 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_7 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_8 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_9 IOID_UNUSED
|
||||
#define Board_BP_Pin_J1_10 IOID_UNUSED
|
||||
|
||||
/* Connector J2 */
|
||||
#define Board_BP_Pin_J2_19 DIO8
|
||||
#define Board_BP_Pin_J2_18 DIO9 /* CS */
|
||||
#define Board_BP_Pin_J2_17 IOID_UNUSED /* NC */
|
||||
#define Board_BP_Pin_J2_15 DIO11 /* MOSI */
|
||||
#define Board_BP_Pin_J2_14 DIO12 /* MISO */
|
||||
#define Board_BP_Pin_J2_13 DIO13
|
||||
#define Board_BP_Pin_J2_12 DIO14
|
||||
#define Board_BP_Pin_J2_11 IOID_UNUSED /* NC */
|
||||
#define Board_BP_Pin_J2_19 IOID_UNUSED
|
||||
#define Board_BP_Pin_J2_18 IOID_UNUSED /* CS */
|
||||
#define Board_BP_Pin_J2_17 IOID_UNUSED /* NC */
|
||||
#define Board_BP_Pin_J2_15 IOID_UNUSED /* MOSI */
|
||||
#define Board_BP_Pin_J2_14 IOID_UNUSED /* MISO */
|
||||
#define Board_BP_Pin_J2_13 IOID_UNUSED
|
||||
#define Board_BP_Pin_J2_12 IOID_UNUSED
|
||||
#define Board_BP_Pin_J2_11 IOID_UNUSED /* NC */
|
||||
|
||||
/* Mapping of BoosterPack Connector Pins to BoosterPack Standard Functions (reflecting the BoosterPack Standard)
|
||||
*/
|
||||
@@ -134,27 +133,74 @@ extern const PIN_Config BoardGpioInitTable[];
|
||||
#define Board_BP_SPI_CS_Other Board_BP_Pin_J2_12
|
||||
#define Board_BP_GPIO_2 Board_BP_Pin_J2_11
|
||||
|
||||
|
||||
/* Mapping of application specific functionality of the BoosterPack to BoosterPack Pins (application dependent)
|
||||
*/
|
||||
|
||||
/* UART Board */
|
||||
#define Board_UART_TX DIO1 /* RXD */
|
||||
#define Board_UART_RX DIO0 /* TXD */
|
||||
|
||||
/*
|
||||
* interface with control box
|
||||
*/
|
||||
#if defined(MODA_MEMORY_BOARD)
|
||||
#define Board_SPI0_MISO DIO12
|
||||
#define Board_SPI0_MOSI DIO11
|
||||
#define Board_SPI0_CLK DIO10
|
||||
#define Board_SPI_CS DIO9
|
||||
|
||||
#define PIN_RAM_SEL DIO8 /* layout: MEM_SEL */
|
||||
#define PIN_MEM_SEL DIO4 /* layout: MEM_RST */
|
||||
#define PIN_MEM_BZY DIO13 /* layout: MEM_BZY */
|
||||
#define PIN_MEM_REQ DIO14 /* layout: MEM_REQ */
|
||||
#define PIN_MEM_TEST DIO7 /* layout: SPARE */
|
||||
|
||||
/* On-board LEDs */
|
||||
#define Board_GLED PIN_UNASSIGNED /* Green LED */
|
||||
#define Board_RLED PIN_UNASSIGNED /* Red LED */
|
||||
|
||||
#elif defined(MODA_BOOSTER_PACK)
|
||||
#define Board_SPI0_MISO DIO7
|
||||
#define Board_SPI0_MOSI DIO8
|
||||
#define Board_SPI0_CLK DIO9
|
||||
#define Board_SPI_CS DIO10
|
||||
|
||||
#define PIN_MEM_INS DIO1
|
||||
#define PIN_MEM_SEL DIO2
|
||||
#define PIN_MEM_BZY DIO12
|
||||
#define PIN_MEM_REQ DIO0
|
||||
#define PIN_MEM_TEST DIO4
|
||||
|
||||
/* On-board LEDs */
|
||||
#define Board_GLED DIO2 /* Green LED */
|
||||
#define Board_RLED DIO4 /* Red LED */
|
||||
|
||||
/* UART Board */
|
||||
#define Board_UART_TX Board_BP_UART_Rx /* RXD */
|
||||
#define Board_UART_RX Board_BP_UART_Tx /* TXD */
|
||||
#else
|
||||
#error "please define BOOSTXL_CC2650MA on BoosterPack or MemoryBoard"
|
||||
#endif
|
||||
//#define PIN_MEM_INS PIN_UNASSIGNED
|
||||
//#define PIN_MEM_BZY PIN_UNASSIGNED
|
||||
//#define PIN_MEM_REQ PIN_UNASSIGNED
|
||||
//#define PIN_MEM_SEL DIO4
|
||||
//#define PIN_MEM_TEST DIO2
|
||||
|
||||
// /* SPI Board */
|
||||
// #define Board_SPI0_MISO Board_BP_SPI_MISO
|
||||
// #define Board_SPI0_MOSI Board_BP_SPI_MOSI
|
||||
// #define Board_SPI0_CLK Board_BP_SPI_CLK
|
||||
// #define Board_SPI0_CS Board_BP_SPI_CS_Wireless
|
||||
/*
|
||||
* unused SPI
|
||||
*/
|
||||
|
||||
#define Board_SPI1_MISO PIN_UNASSIGNED
|
||||
#define Board_SPI1_MOSI PIN_UNASSIGNED
|
||||
#define Board_SPI1_CLK PIN_UNASSIGNED
|
||||
#define Board_SPI1_CS PIN_UNASSIGNED
|
||||
|
||||
#define Board_LCD_CS PIN_UNASSIGNED
|
||||
#define Board_LCD_EXTCOMIN PIN_UNASSIGNED
|
||||
#define Board_LCD_POWER PIN_UNASSIGNED
|
||||
#define Board_LCD_ENABLE PIN_UNASSIGNED
|
||||
|
||||
/* Power Management Board */
|
||||
#define Board_SRDY Board_BP_Pin_J2_19
|
||||
#define Board_MRDY Board_BP_Pin_J1_2
|
||||
#define Board_SRDY PIN_UNASSIGNED
|
||||
#define Board_MRDY PIN_UNASSIGNED
|
||||
|
||||
/* PWM outputs */
|
||||
#define Board_PWMPIN0 PIN_UNASSIGNED
|
||||
@@ -166,18 +212,24 @@ extern const PIN_Config BoardGpioInitTable[];
|
||||
#define Board_PWMPIN6 PIN_UNASSIGNED
|
||||
#define Board_PWMPIN7 PIN_UNASSIGNED
|
||||
|
||||
|
||||
/** ============================================================================
|
||||
* Instance identifiers
|
||||
* ==========================================================================*/
|
||||
|
||||
/* Generic SPI instance identifiers */
|
||||
#define Board_SPI0 BOOSTXL_CC2650MA_SPI0
|
||||
|
||||
#ifdef HEADSTAGE_MA_USE_SPI2
|
||||
#define Board_SPI1 BOOSTXL_CC2650MA_SPI1
|
||||
/* Generic I2C instance identifiers */
|
||||
#define Board_I2C0 BOOSTXL_CC2650MA_I2C0
|
||||
#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
|
||||
@@ -187,6 +239,17 @@ extern const PIN_Config BoardGpioInitTable[];
|
||||
#define Board_GPTIMER2B BOOSTXL_CC2650MA_GPTIMER2B
|
||||
#define Board_GPTIMER3A BOOSTXL_CC2650MA_GPTIMER3A
|
||||
#define Board_GPTIMER3B BOOSTXL_CC2650MA_GPTIMER3B
|
||||
|
||||
/* Generic ADC instance identifiers */
|
||||
#define Board_DIO0_ANALOG PIN_UNASSIGNED
|
||||
#define Board_DIO1_ANALOG PIN_UNASSIGNED
|
||||
#define Board_DIO2_ANALOG PIN_UNASSIGNED
|
||||
#define Board_DIO3_ANALOG PIN_UNASSIGNED
|
||||
#define Board_DIO4_ANALOG PIN_UNASSIGNED
|
||||
#define Board_DIO5_ANALOG PIN_UNASSIGNED
|
||||
#define Board_DIO6_ANALOG PIN_UNASSIGNED
|
||||
#define Board_DIO7_ANALOG PIN_UNASSIGNED
|
||||
|
||||
/* Generic PWM instance identifiers */
|
||||
#define Board_PWM0 BOOSTXL_CC2650MA_PWM0
|
||||
#define Board_PWM1 BOOSTXL_CC2650MA_PWM1
|
||||
@@ -201,6 +264,16 @@ extern const PIN_Config BoardGpioInitTable[];
|
||||
* Number of peripherals and their names
|
||||
* ==========================================================================*/
|
||||
|
||||
/*
|
||||
* @def BOOSTXL_CC2650MA_I2C
|
||||
* @brief Enum of I2C names on the cc2650 dev board
|
||||
*/
|
||||
typedef enum BOOSTXL_CC2650MA_I2CName{
|
||||
BOOSTXL_CC2650MA_I2C0 = 0,
|
||||
|
||||
BOOSTXL_CC2650MA_I2CCOUNT
|
||||
} BOOSTXL_CC2650MA_I2CName;
|
||||
|
||||
/*!
|
||||
* @def BOOSTXL_CC2650MA_CryptoName
|
||||
* @brief Enum of Crypto names on the CC2650 Booster Pack
|
||||
@@ -218,7 +291,10 @@ typedef enum BOOSTXL_CC2650MA_CryptoName {
|
||||
*/
|
||||
typedef enum BOOSTXL_CC2650MA_SPIName {
|
||||
BOOSTXL_CC2650MA_SPI0 = 0,
|
||||
BOOSTXL_CC2650MA_SPI1 = 1,
|
||||
|
||||
#ifdef HEADSTAGE_MA_USE_SPI2
|
||||
BOOSTXL_CC2650MA_SPI1 ,
|
||||
#endif
|
||||
|
||||
BOOSTXL_CC2650MA_SPICOUNT
|
||||
} BOOSTXL_CC2650MA_SPIName;
|
||||
@@ -299,15 +375,34 @@ typedef enum BOOSTXL_CC2650MA_PWM
|
||||
BOOSTXL_CC2650MA_PWMCOUNT
|
||||
} BOOSTXL_CC2650MA_PWM;
|
||||
|
||||
/*!
|
||||
* @def BOOSTXL_CC2650MA_I2CName
|
||||
* @brief Enum of I2C names on the CC2650 Booster Pack
|
||||
*/
|
||||
typedef enum BOOSTXL_CC2650MA_I2CName {
|
||||
BOOSTXL_CC2650MA_I2C0 = 0,
|
||||
typedef enum BOOSTXL_CC2650MA_WATCHDOG
|
||||
{
|
||||
BOOSTXL_CC2650MA_WATCHDOG0 = 0,
|
||||
BOOSTXL_CC2650MA_WATCHDOGCOUNT
|
||||
} BOOSTXL_CC2650MA_WATCHDOG;
|
||||
|
||||
BOOSTXL_CC2650MA_I2CCOUNT
|
||||
} BOOSTXL_CC2650MA_I2CName;
|
||||
#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
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ extern "C" {
|
||||
#define Board_initGPIO()
|
||||
#define Board_initPWM() PWM_init()
|
||||
#define Board_initSPI() SPI_init()
|
||||
#define Board_initI2C() I2C_init()
|
||||
#define Board_initUART() UART_init()
|
||||
#define Board_initWatchdog() Watchdog_init()
|
||||
#define GPIO_toggle(n)
|
||||
|
||||
@@ -78,16 +78,19 @@ static void Board_keyCallback(PIN_Handle hPin, PIN_Id pinId);
|
||||
/*******************************************************************************
|
||||
* EXTERNAL VARIABLES
|
||||
*/
|
||||
|
||||
extern bool procedureInProgress;
|
||||
/*********************************************************************
|
||||
* LOCAL VARIABLES
|
||||
*/
|
||||
PIN_State keyPins;
|
||||
PIN_Handle hKeyPins;
|
||||
|
||||
// Value of keys Pressed
|
||||
static uint8_t keysPressed;
|
||||
uint8_t keysPressed;
|
||||
|
||||
// Key debounce clock
|
||||
static Clock_Struct keyChangeClock;
|
||||
Clock_Struct keyChangeClock;
|
||||
|
||||
|
||||
// Pointer to application callback
|
||||
keysPressedCB_t appKeyChangeHandler = NULL;
|
||||
@@ -101,18 +104,30 @@ PIN_Config keyPinsCfg[] =
|
||||
#if defined (CC2650_LAUNCHXL) || defined (CC1350_LAUNCHXL)
|
||||
Board_BTN1 | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
Board_BTN2 | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
Board_UART_RX_IRQ | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLDOWN,
|
||||
#elif defined (CC2650DK_7ID) || defined (CC1350DK_7XD)
|
||||
Board_KEY_SELECT | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
Board_KEY_UP | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
Board_KEY_DOWN | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
Board_KEY_LEFT | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
Board_KEY_RIGHT | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
#elif defined(BOOSTXL_CC2650MA)
|
||||
PIN_MEM_SEL | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
PIN_MEM_REQ | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
|
||||
PIN_MEM_BZY | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
PIN_RAM_SEL | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
Board_SPI_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,
|
||||
PIN_MEM_TEST | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,
|
||||
#if defined(MODA_BOOSTER_PACK)
|
||||
Board_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
Board_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
#endif
|
||||
|
||||
#endif
|
||||
PIN_TERMINATE
|
||||
};
|
||||
|
||||
PIN_State keyPins;
|
||||
PIN_Handle hKeyPins;
|
||||
extern uint16_t EventMask;
|
||||
|
||||
/*********************************************************************
|
||||
* PUBLIC FUNCTIONS
|
||||
@@ -128,38 +143,21 @@ PIN_Handle hKeyPins;
|
||||
*/
|
||||
void Board_initKeys(keysPressedCB_t appKeyCB)
|
||||
{
|
||||
// Initialize KEY pins. Enable int after callback registered
|
||||
hKeyPins = PIN_open(&keyPins, keyPinsCfg);
|
||||
PIN_registerIntCb(hKeyPins, Board_keyCallback);
|
||||
// Initialize KEY pins. Enable int after callback registered
|
||||
hKeyPins = PIN_open(&keyPins, keyPinsCfg);
|
||||
PIN_registerIntCb(hKeyPins, Board_keyCallback);
|
||||
|
||||
#if defined (CC2650_LAUNCHXL) || defined (CC1350_LAUNCHXL)
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_BTN1 | PIN_IRQ_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_BTN2 | PIN_IRQ_NEGEDGE);
|
||||
#elif defined (CC2650DK_7ID) || defined (CC1350DK_7XD)
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_SELECT | PIN_IRQ_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_UP | PIN_IRQ_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_DOWN | PIN_IRQ_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_LEFT | PIN_IRQ_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_RIGHT | PIN_IRQ_NEGEDGE);
|
||||
#endif
|
||||
#if defined (BOOSTXL_CC2650MA)
|
||||
// PIN_setConfig(hKeyPins, PIN_BM_IRQ, PIN_MEM_SEL | PIN_IRQ_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, PIN_MEM_REQ | PIN_IRQ_NEGEDGE);
|
||||
|
||||
#ifdef POWER_SAVING
|
||||
//Enable wakeup
|
||||
#if defined (CC2650_LAUNCHXL) || defined (CC1350_LAUNCHXL)
|
||||
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_BTN1 | PINCC26XX_WAKEUP_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_BTN2 | PINCC26XX_WAKEUP_NEGEDGE);
|
||||
#elif defined (CC2650DK_7ID) || defined (CC1350DK_7XD)
|
||||
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_SELECT | PINCC26XX_WAKEUP_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_UP | PINCC26XX_WAKEUP_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_DOWN | PINCC26XX_WAKEUP_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_LEFT | PINCC26XX_WAKEUP_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_RIGHT | PINCC26XX_WAKEUP_NEGEDGE);
|
||||
#elif defined (CC2650_LAUNCHXL) || defined (CC1350_LAUNCHXL)
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_BTN1 | PIN_IRQ_NEGEDGE);
|
||||
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_BTN2 | PIN_IRQ_NEGEDGE);
|
||||
#endif
|
||||
#endif //POWER_SAVING
|
||||
|
||||
// Setup keycallback for keys
|
||||
Util_constructClock(&keyChangeClock, Board_keyChangeHandler,
|
||||
KEY_DEBOUNCE_TIMEOUT, 0, false, 0);
|
||||
Util_constructClock(&keyChangeClock, Board_keyChangeHandler, KEY_DEBOUNCE_TIMEOUT, 0, false, 0);
|
||||
|
||||
// Set the application callback
|
||||
appKeyChangeHandler = appKeyCB;
|
||||
@@ -176,47 +174,24 @@ void Board_initKeys(keysPressedCB_t appKeyCB)
|
||||
*/
|
||||
static void Board_keyCallback(PIN_Handle hPin, PIN_Id pinId)
|
||||
{
|
||||
keysPressed = 0;
|
||||
keysPressed = 0;
|
||||
#if defined (BOOSTXL_CC2650MA)
|
||||
// if (PIN_getInputValue(PIN_MEM_REQ) == 0 && !procedureInProgress) {
|
||||
// keysPressed |= KEY_REQ;
|
||||
// flag_enable(EVT_PIN_REQST);
|
||||
// }
|
||||
|
||||
#if defined (CC2650_LAUNCHXL) || defined (CC1350_LAUNCHXL)
|
||||
if ( PIN_getInputValue(Board_BTN1) == 0 )
|
||||
{
|
||||
keysPressed |= KEY_LEFT;
|
||||
}
|
||||
#elif defined (CC2650_LAUNCHXL) || defined (CC1350_LAUNCHXL)
|
||||
if (PIN_getInputValue(Board_BTN1) == 0) {
|
||||
keysPressed |= KEY_LEFT;
|
||||
}
|
||||
|
||||
if ( PIN_getInputValue(Board_BTN2) == 0 )
|
||||
{
|
||||
keysPressed |= KEY_RIGHT;
|
||||
}
|
||||
|
||||
#elif defined (CC2650DK_7ID) || defined (CC1350DK_7XD)
|
||||
if ( PIN_getInputValue(Board_KEY_SELECT) == 0 )
|
||||
{
|
||||
keysPressed |= KEY_SELECT;
|
||||
}
|
||||
|
||||
if ( PIN_getInputValue(Board_KEY_UP) == 0 )
|
||||
{
|
||||
keysPressed |= KEY_UP;
|
||||
}
|
||||
|
||||
if ( PIN_getInputValue(Board_KEY_DOWN) == 0 )
|
||||
{
|
||||
keysPressed |= KEY_DOWN;
|
||||
}
|
||||
|
||||
if ( PIN_getInputValue(Board_KEY_LEFT) == 0 )
|
||||
{
|
||||
keysPressed |= KEY_LEFT;
|
||||
}
|
||||
|
||||
if ( PIN_getInputValue(Board_KEY_RIGHT) == 0 )
|
||||
{
|
||||
keysPressed |= KEY_RIGHT;
|
||||
}
|
||||
if (PIN_getInputValue(Board_BTN2) == 0) {
|
||||
keysPressed |= KEY_RIGHT;
|
||||
}
|
||||
#endif
|
||||
|
||||
Util_startClock(&keyChangeClock);
|
||||
Util_startClock(&keyChangeClock);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
||||
@@ -55,11 +55,10 @@ extern "C" {
|
||||
/*********************************************************************
|
||||
* INCLUDES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL VARIABLES
|
||||
*/
|
||||
|
||||
extern uint8_t KEY_INSTEAD_UART;
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
@@ -68,9 +67,11 @@ extern "C" {
|
||||
#define KEY_DOWN 0x0004
|
||||
#define KEY_LEFT 0x0008
|
||||
#define KEY_RIGHT 0x0010
|
||||
#define KEY_UART_EN 0x0020
|
||||
#define KEY_REQ 0x0040
|
||||
|
||||
// Debounce timeout in milliseconds
|
||||
#define KEY_DEBOUNCE_TIMEOUT 200
|
||||
#define KEY_DEBOUNCE_TIMEOUT 0
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <ti/drivers/timer/GPTimerCC26XX.h>
|
||||
#include <xdc/runtime/Types.h>
|
||||
#include <ti/sysbios/BIOS.h>
|
||||
#include "board.h"
|
||||
#include "mem_board_central.h"
|
||||
|
||||
#define CLOCK_FREQ 4800 // clock freq = 0.1 ms(4800)
|
||||
|
||||
static void __timerCallback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask)
|
||||
{
|
||||
// interrupt callback code goes here. Minimize processing in interrupt.
|
||||
elite_100us_task();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
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,6 +56,7 @@
|
||||
|
||||
#include "icall.h"
|
||||
#include "hal_assert.h"
|
||||
#include "board.h"
|
||||
#include "central.h"
|
||||
#include "simple_central.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef __MEM_BOARD_CENTAL_H
|
||||
#define __MEM_BOARD_CENTAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void elite_100us_task(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,336 @@
|
||||
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
// 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 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{
|
||||
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 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
|
||||
@@ -0,0 +1,150 @@
|
||||
|
||||
#ifndef CENTRAL_NOTIFY
|
||||
#define CENTRAL_NOTIFY
|
||||
|
||||
#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
|
||||
|
||||
void write_green_data_and_switch_ram();
|
||||
|
||||
#define MEM_REG_WRITE 0x01
|
||||
#define MEM_INS_WRITE 0x02
|
||||
#define MEM_INS_READ 0x03
|
||||
|
||||
#define RAM_INS_LEN 3
|
||||
|
||||
#define RAM_RED_HDR_LEN 3
|
||||
#define ELITE_PKG_LEN 40
|
||||
#define RAM_RED_TAILER_LEN 5
|
||||
#define RAM_RED_CHECK_SUM_LEN 1
|
||||
#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_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;
|
||||
|
||||
while (nBytes-- > 0) {
|
||||
sum += *(message++);
|
||||
}
|
||||
|
||||
return sum;
|
||||
|
||||
}
|
||||
|
||||
static void central_handle_notify()
|
||||
{
|
||||
int index = 0;
|
||||
bool write_again = false;
|
||||
uint8_t write_limit = 0;
|
||||
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;
|
||||
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) {
|
||||
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;
|
||||
red_retry_cnt++;
|
||||
write_limit++;
|
||||
reset_status_register();
|
||||
}
|
||||
|
||||
if (!write_again)
|
||||
break;
|
||||
|
||||
if (write_limit >= 5) {
|
||||
red_wrong++;
|
||||
reset_status_register();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (write_ram_addr > 7500)
|
||||
write_ram_addr = write_ram_addr;
|
||||
else
|
||||
write_ram_addr += RAM_RED_DATA_LEN;
|
||||
|
||||
mem_pkg_sequence++;
|
||||
}
|
||||
|
||||
void write_green_data_and_switch_ram()
|
||||
{
|
||||
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 write_limit = 0;
|
||||
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 (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)
|
||||
break;
|
||||
|
||||
if (write_limit >= 5) {
|
||||
green_wrong++;
|
||||
reset_status_register();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// switch RAM
|
||||
ram_select(!ram_sel_signal);
|
||||
CPUdelay(10 * 16); // 10us
|
||||
|
||||
write_ram_addr = RAM_GREEN_DATA_LEN; //reset ram_addr
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
#ifndef MEM_CENTRAL_PIN
|
||||
#define MEM_CENTRAL_PIN
|
||||
|
||||
//extern PIN_State keyPins;
|
||||
extern PIN_Handle hKeyPins;
|
||||
|
||||
#define central_pin_output(pin, value) PIN_setOutputValue(hKeyPins, PIN_ID(pin), (value))
|
||||
#define central_pin_input(pin) PIN_getInputValue(PIN_ID(pin))
|
||||
|
||||
void ram_select(bool value)
|
||||
{
|
||||
ram_sel_signal = value;
|
||||
central_pin_output(PIN_RAM_SEL, (ram_sel_signal) ? 1 : 0);
|
||||
|
||||
if (ram_sel_signal) {
|
||||
central_pin_output(PIN_MEM_TEST, 1);
|
||||
} else {
|
||||
central_pin_output(PIN_MEM_TEST, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef CENTRAL_SPI_H
|
||||
#define CENTRAL_SPI_H
|
||||
|
||||
// clang-format off
|
||||
#include <ti/drivers/SPI.h>
|
||||
#include <ti/drivers/dma/UDMACC26XX.h>
|
||||
#include <ti/drivers/spi/SPICC26XXDMA.h>
|
||||
// clang-format on
|
||||
|
||||
static SPI_Handle central_spi_handle;
|
||||
static SPI_Transaction central_spi_transaction;
|
||||
|
||||
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) \
|
||||
do { \
|
||||
central_spi_transaction.txBuf = data; \
|
||||
central_spi_transaction.rxBuf = NULL; \
|
||||
central_spi_transaction.count = (len); \
|
||||
central_pin_output(Board_SPI_CS, 0); \
|
||||
SPI_transfer(central_spi_handle, ¢ral_spi_transaction); \
|
||||
central_pin_output(Board_SPI_CS, 1); \
|
||||
} while (0)
|
||||
|
||||
#define central_spi_recv(ins, data) \
|
||||
do { \
|
||||
central_spi_transaction.txBuf = ins; \
|
||||
central_spi_transaction.rxBuf = data; \
|
||||
central_pin_output(Board_SPI_CS, 0); \
|
||||
SPI_transfer(central_spi_handle, ¢ral_spi_transaction); \
|
||||
central_pin_output(Board_SPI_CS, 1); \
|
||||
} while (0)
|
||||
|
||||
#endif // CENTRAL_SPI_H
|
||||
@@ -0,0 +1,50 @@
|
||||
|
||||
#ifndef MEM_EVENT_H
|
||||
#define MEM_EVENT_H
|
||||
|
||||
/**
|
||||
* test event [flag] has been enabled.
|
||||
*/
|
||||
#define flag_mask(flag) ((EventMask & (flag)) != 0)
|
||||
|
||||
/**
|
||||
* disable event [flag].
|
||||
*/
|
||||
#define flag_disable(flag) \
|
||||
do { \
|
||||
uint8 __key = Hwi_disable(); \
|
||||
EventMask &= ~((uint16_t)(flag)); \
|
||||
Hwi_restore(__key); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* enable event [flag].
|
||||
*/
|
||||
#define flag_enable(flag) \
|
||||
do { \
|
||||
uint8 __key = Hwi_disable(); \
|
||||
EventMask |= (uint16_t)(flag); \
|
||||
Hwi_restore(__key); \
|
||||
Semaphore_post(sem); \
|
||||
} while (0)
|
||||
|
||||
uint16_t EventMask = 0;
|
||||
|
||||
/**
|
||||
* event table entry.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* event mask.
|
||||
*/
|
||||
uint16_t event_mask;
|
||||
|
||||
/**
|
||||
* event callback. invoked by system when system [EVENT_MASK] set with
|
||||
* [event_mask] bits.
|
||||
*/
|
||||
void (*event_callback)();
|
||||
} EventTableEntry;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,149 @@
|
||||
|
||||
#ifndef MEM_UART
|
||||
#define MEM_UART
|
||||
|
||||
/*
|
||||
* http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/tirtos/
|
||||
* 2_20_00_06/exports/tirtos_full_2_20_00_06/products/tidrivers_cc13xx_cc26xx_2_20_00_08/
|
||||
* docs/doxygen/html/_u_a_r_t_c_c26_x_x_8h.html
|
||||
*/
|
||||
|
||||
#include <ti/drivers/UART.h>
|
||||
#include <ti/drivers/uart/UARTCC26XX.h>
|
||||
|
||||
#define UART_BUFF_SIZE 25
|
||||
|
||||
static UART_Handle uart_handle;
|
||||
static UART_Params params;
|
||||
|
||||
static uint8_t UART_rxBuf[UART_BUFF_SIZE];
|
||||
static uint8_t store_rxBuf[UART_BUFF_SIZE];
|
||||
|
||||
typedef enum{
|
||||
INS_IDLE,
|
||||
INS_RESET,
|
||||
INS_KEY,
|
||||
INS_SCAN,
|
||||
INS_SCAN_RESPONSE,
|
||||
INS_CONNECT,
|
||||
INS_WRITE,
|
||||
INS_READ,
|
||||
INS_DISCONNECT,
|
||||
INS_PREPARE_CONNECT,
|
||||
INS_CHECK_SURVIVE
|
||||
} Control_Ins;
|
||||
|
||||
static Control_Ins ins = INS_IDLE;
|
||||
|
||||
/** event */
|
||||
#define EVT_ALL 0xFFFF
|
||||
#define EVT_MEM_RETURN_DATA 0x0010
|
||||
#define EVT_MEM_NOTIFY_HANDLE 0x0040
|
||||
#define EVT_MEM_UART_ROUTINE 0x0080
|
||||
#define EVT_MEM_INS_SCAN 0x0100
|
||||
#define EVT_MEM_INS_CONNECT 0x0200
|
||||
#define EVT_MEM_INS_WRITE 0x0400
|
||||
#define EVT_MEM_INS_READ 0x0800
|
||||
#define EVT_MEM_INS_DISCONNECT 0x1000
|
||||
#define EVT_MEM_INS_CHECK_SURVIVE 0x2000
|
||||
|
||||
|
||||
#define IS_EVT_MEM_DECODE_INS(_b) ((_b)[0] == INS_SCAN || \
|
||||
(_b)[0] == INS_CONNECT || \
|
||||
(_b)[0] == INS_WRITE || \
|
||||
(_b)[0] == INS_READ || \
|
||||
(_b)[0] == INS_DISCONNECT || \
|
||||
(_b)[0] == INS_CHECK_SURVIVE)
|
||||
|
||||
|
||||
// Callback function
|
||||
static void uart_recv_callback(UART_Handle handle, void *rxBuf, size_t size)
|
||||
{
|
||||
uint8_t *uart_rxBuf = (uint8_t *)rxBuf;
|
||||
static int index = 0;
|
||||
static int length = 0;
|
||||
static bool rx_fi = false;
|
||||
|
||||
if (rx_fi) {
|
||||
memset(store_rxBuf, 0, UART_BUFF_SIZE);
|
||||
rx_fi = false;
|
||||
}
|
||||
|
||||
if (IS_EVT_MEM_DECODE_INS(uart_rxBuf) && index == 0) {
|
||||
store_rxBuf[0] = uart_rxBuf[0];
|
||||
index++;
|
||||
} else if (IS_EVT_MEM_DECODE_INS(store_rxBuf) && index == 1) {
|
||||
store_rxBuf[1] = uart_rxBuf[0];
|
||||
length = uart_rxBuf[0];
|
||||
index++;
|
||||
} else if (IS_EVT_MEM_DECODE_INS(store_rxBuf) && index > 1) {
|
||||
store_rxBuf[index] = uart_rxBuf[0];
|
||||
if (index >= length + 2) { //num = 0 when over length
|
||||
store_rxBuf[index] = 0;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
//0xF1 = 241
|
||||
if(index > 1 && store_rxBuf[0] == INS_SCAN && store_rxBuf[length + 1] == 0xF1 ) {
|
||||
index = 0;
|
||||
length = 0;
|
||||
flag_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_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_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_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) {
|
||||
index = 0;
|
||||
length = 0;
|
||||
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) {
|
||||
index = 0;
|
||||
length = 0;
|
||||
flag_enable(EVT_MEM_INS_CHECK_SURVIVE);
|
||||
flag_enable(EVT_MEM_UART_ROUTINE);
|
||||
rx_fi = true;
|
||||
return;
|
||||
}
|
||||
flag_enable(EVT_MEM_UART_ROUTINE);
|
||||
}
|
||||
|
||||
static void mem_uart_init(){
|
||||
|
||||
// Init UART and specify non-default parameters
|
||||
UART_Params_init(¶ms);
|
||||
params.baudRate = 115200;
|
||||
params.writeDataMode = UART_DATA_BINARY;
|
||||
params.readMode = UART_MODE_CALLBACK;
|
||||
params.readDataMode = UART_DATA_BINARY;
|
||||
params.readCallback = uart_recv_callback;
|
||||
|
||||
// Open the UART and do the read
|
||||
uart_handle = UART_open(Board_UART, ¶ms);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,141 +0,0 @@
|
||||
#ifndef ELITE_BOARDS_SELECT_H
|
||||
#define ELITE_BOARDS_SELECT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
*
|
||||
* product number: MAJOR_PRODUCT_NUMBER, MINOR_PRODUCT_NUMBER, MAJOR_VERSION_NUMBER, MINOR_VERSION_NUMBER
|
||||
* MAJOR_PRODUCT_NUMBER -> 0:Elite, 1:other serial
|
||||
* Elite:
|
||||
* MINOR_PRODUCT_NUMBER -> 1:legacy, 2:EDC, 3:BAT, 4:EIS, 5:TRIG, 6:MEGAFLY
|
||||
*
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* | model name | hw upper board | hw lower board | product number | device name | data server lib name | UI |
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* | DEF_ELITE_EDC_1_4 | Elite1.4-re Jun.2019 | Elite1.4-re Jun. 2019 | 0, 2, 1, 5 | "Elite-EDC" | Elite_EDC_1.4 | null |
|
||||
* | DEF_ELITE_EDC_1_5 | Elite1.5 Dec. 2019 | Elite1.5 Dec. 2019 | 0, 2, 1, 6 | "Elite-EDC" | Elite_EDC_1.5 | EliteEDC |
|
||||
* | DEF_ELITE_EDC_1_5_RE | Elite1.5 Dec. 2019 | Elite1.5-re Jan. 2021 | 0, 2, 1, 7 | "Elite-EDC" | Elite_EDC_1.5re | EliteEDC |
|
||||
* | DEF_ELITE_EDC_1_5_R2 | Elite1.5 Dec. 2019 | Elite1.5-r2 May. 2022 | 0, 2, 1, 8 | "Elite-EDC" | Elite_EDC_1.5r2 | EliteEDC |
|
||||
* | DEF_ELITE_BAT_1_0 | Elite2.0 Feb. 2022 | 0, 3, 1, 0 | "Elite-BAT" | Elite_BAT_1.0 | EliteEDC |
|
||||
* | DEF_ELITE_EIS_1_0 | Elite1.5 Dec. 2019 | Elite EIS1.0 Aug. 2020 | 0, 4, 1, 0 | "Elite-EIS" | Elite_EIS_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_1_1 | Elite1.5 Dec. 2019 | Elite EIS1.1 Feb. 2022 | 0, 4, 1, 1 | "Elite-EIS" | Elite_EIS_1.1 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_MINI_1_0 | EIS MINI May. 2022 | 0, 4, 1, 2 | "Elite-EIS-MINI" | Elite_EIS_MINI_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_TRIG_0_1 | Elite TRIG01 Jan. 2021 | 0, 5, 1, 0 | "Elite-TRIG" | Elite_TRIG_0.1 | null |
|
||||
* | DEF_ELITE_MEGAFLY_0_1 | Elite1.5 Dec. 2019 | Elite Megafly Sep. 2020 | 0, 6, 1, 0 | "Elite-MEGAFLY" | Elite_MEGAFLY_0.1 | null |
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* ps.
|
||||
* model name is FW engineer defined
|
||||
* device name is used for controller
|
||||
*/
|
||||
|
||||
|
||||
#define DEF_ELITE_EDC_1_4 0
|
||||
#define DEF_ELITE_EDC_1_5 1
|
||||
#define DEF_ELITE_EDC_1_5_RE 2
|
||||
#define DEF_ELITE_EDC_1_5_R2 3
|
||||
#define DEF_ELITE_BAT_1_0 4
|
||||
#define DEF_ELITE_EIS_1_0 5
|
||||
#define DEF_ELITE_EIS_1_1 6
|
||||
#define DEF_ELITE_EIS_MINI_1_0 7
|
||||
#define DEF_ELITE_TRIG_0_1 8
|
||||
#define DEF_ELITE_MEGAFLY_0_1 9
|
||||
#define DEF_ELITE_MAX 10
|
||||
|
||||
#define DEF_ELITE_MODEL DEF_ELITE_EDC_1_5_RE
|
||||
#ifndef DEF_ELITE_MODEL
|
||||
#error "DEF_ELITE_MODEL not defined"
|
||||
#endif
|
||||
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_4)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_RE)
|
||||
#include "boards_config/pin_def_edc15re.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_R2)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_0)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_1)
|
||||
#include "boards_config/pin_def_eis11.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_1_0)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_0_1)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_0_1)
|
||||
#error "code no support" // need fix
|
||||
#else
|
||||
#error "no this model"
|
||||
#endif
|
||||
|
||||
|
||||
// model information
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_4)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 5
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 6
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_RE)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 7
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_R2)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 8
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_1_0)
|
||||
#define DEVICE_NAME "Elite-BAT"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 3
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_0)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_1)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 1
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_MINI_1_0)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 2
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_0_1)
|
||||
#define DEVICE_NAME "Elite-TRIG"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 5
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_0_1)
|
||||
#define DEVICE_NAME "Elite-MEGAFLY"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 6
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // ELITE_BOARDS_SELECT_H
|
||||
@@ -1,63 +0,0 @@
|
||||
#ifndef PIN_DEF_EDC15RE_H
|
||||
#define PIN_DEF_EDC15RE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* +------------------------------+
|
||||
* | CC2650moda |
|
||||
* +-------------+----------------+
|
||||
* | MISO | DIO1 |
|
||||
* | D0 | DIO3 |
|
||||
* | D1 | DIO4 |
|
||||
* | D2/JTAG_TDO | DIO5/JTAG_TDO |
|
||||
* | D3/JTAG_TDI | DIO6/JTAG_TDI |
|
||||
* | D4 | DIO7 |
|
||||
* | D5 | DIO8 |
|
||||
* | D6 | DIO9 |
|
||||
* | D7 | DIO10 |
|
||||
* | LOAD2 | DIO11 |
|
||||
* | LOAD1 | DIO12 |
|
||||
* | LOAD0 | DIO13 |
|
||||
* | SHUT_DOWN | DIO14 |
|
||||
* +-------------+----------------+
|
||||
*/
|
||||
|
||||
|
||||
/* CC2650moda */
|
||||
#define E_PIN_MISO DIO1
|
||||
#define E_PIN_D0 DIO3
|
||||
#define E_PIN_D1 DIO4
|
||||
#define E_PIN_D2 DIO5
|
||||
#define E_PIN_D3 DIO6
|
||||
#define E_PIN_D4 DIO7
|
||||
#define E_PIN_D5 DIO8
|
||||
#define E_PIN_D6 DIO9
|
||||
#define E_PIN_D7 DIO10
|
||||
|
||||
#define E_PIN_LOAD2 DIO11
|
||||
#define E_PIN_LOAD1 DIO12
|
||||
#define E_PIN_LOAD0 DIO13
|
||||
#define E_PIN_SHUT_DOWN DIO14 // to sense switch
|
||||
|
||||
/* SPI Board */
|
||||
#define Board_SPI0_MISO PIN_UNASSIGNED
|
||||
#define Board_SPI0_MOSI E_PIN_D1
|
||||
#define Board_SPI0_CLK E_PIN_D0
|
||||
#define Board_SPI0_CS PIN_UNASSIGNED
|
||||
|
||||
#define Board_SPI1_MISO E_PIN_MISO
|
||||
#define Board_SPI1_MOSI E_PIN_D3
|
||||
#define Board_SPI1_CLK E_PIN_D2
|
||||
#define Board_SPI1_CS PIN_UNASSIGNED
|
||||
|
||||
/* I2C */
|
||||
#define Board_I2C0_SCL0 PIN_UNASSIGNED
|
||||
#define Board_I2C0_SDA0 PIN_UNASSIGNED
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // PIN_DEF_EDC15RE_H
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef GPIO_EDC15RE_H
|
||||
#define GPIO_EDC15RE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint8_t gpio_create(void);
|
||||
uint8_t add_pin_d0_d3(void);
|
||||
uint8_t remove_pin_d0_d3(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // GPIO_EDC15RE_H
|
||||
@@ -1,89 +0,0 @@
|
||||
#include <Board.h>
|
||||
#include <ti/drivers/pin/PINCC26XX.h>
|
||||
#include "driver/gpio_edc15re.h"
|
||||
|
||||
static PIN_Handle PinHandle;
|
||||
static PIN_State PinStatus;
|
||||
|
||||
const PIN_Config BLE_IO[] = {
|
||||
E_PIN_D0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_D1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_D2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_D3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_D4 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_D5 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_D6 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_D7 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_LOAD0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_LOAD1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_LOAD2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
|
||||
E_PIN_SHUT_DOWN | PIN_INPUT_EN | PIN_PULLDOWN,
|
||||
|
||||
PIN_TERMINATE
|
||||
};
|
||||
|
||||
static PIN_Handle __get_gpio_handle(void)
|
||||
{
|
||||
return PinHandle;
|
||||
}
|
||||
|
||||
static void __set_gpio_handle(PIN_Handle handle)
|
||||
{
|
||||
PinHandle = handle;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t gpio_create(void)
|
||||
{
|
||||
PIN_Handle h;
|
||||
|
||||
h = PIN_open(&PinStatus, BLE_IO);
|
||||
__set_gpio_handle(h);
|
||||
|
||||
if (h == NULL)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t add_pin_d0_d3(void)
|
||||
{
|
||||
PIN_Handle h = __get_gpio_handle();
|
||||
|
||||
PIN_add(h, E_PIN_D0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(h, E_PIN_D1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(h, E_PIN_D2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(h, E_PIN_D3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t remove_pin_d0_d3(void)
|
||||
{
|
||||
PIN_Handle h = __get_gpio_handle();
|
||||
|
||||
PIN_remove(h, E_PIN_D0);
|
||||
PIN_remove(h, E_PIN_D1);
|
||||
PIN_remove(h, E_PIN_D2);
|
||||
PIN_remove(h, E_PIN_D3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t pin_set(uint8_t pin, uint8_t set_value)
|
||||
{
|
||||
/*
|
||||
* if status = 0: success
|
||||
* else: fail
|
||||
*/
|
||||
uint8_t p = pin;
|
||||
uint8_t v = set_value;
|
||||
PIN_Status status;
|
||||
PIN_Handle h = __get_gpio_handle();
|
||||
|
||||
status = PIN_setOutputValue(h, p, v);
|
||||
|
||||
return (uint8_t)status;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
#ifndef SPI_CTRL_H
|
||||
#define SPI_CTRL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define POL0 0
|
||||
#define POL1 1
|
||||
#define PHA0 0
|
||||
#define PHA1 1
|
||||
|
||||
#define SPI_CLK_1M 1000000
|
||||
#define SPI_CLK_4M 4000000
|
||||
|
||||
uint8_t spi0_open(uint32_t bitRate, uint8_t polarity, uint8_t phase);
|
||||
uint8_t spi0_close(void);
|
||||
uint8_t spi0_write(uint8_t *rxBuf, uint8_t *txBuf, uint8_t len);
|
||||
|
||||
uint8_t spi1_open(uint32_t bitRate, uint8_t polarity, uint8_t phase);
|
||||
uint8_t spi1_close(void);
|
||||
uint8_t spi1_write(uint8_t *rxBuf, uint8_t *txBuf, uint8_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // SPI_CTRL_H
|
||||
@@ -1,208 +0,0 @@
|
||||
#include <Board.h>
|
||||
#include <ti/drivers/SPI.h>
|
||||
#include "driver/spi_ctrl.h"
|
||||
|
||||
#define CC2650_SPI_BITRATE_MAX 4000000 //4M
|
||||
|
||||
static SPI_Handle SpiHandle0 = NULL;
|
||||
static SPI_Params SpiParams0;
|
||||
|
||||
static SPI_Handle SpiHandle1 = NULL;
|
||||
static SPI_Params SpiParams1;
|
||||
|
||||
static SPI_Handle __get_spi_handle(uint8_t spi_channel)
|
||||
{
|
||||
uint8_t c = spi_channel;
|
||||
|
||||
if (c >= BOOSTXL_CC2650MA_SPICOUNT)
|
||||
return NULL;
|
||||
|
||||
if (c == Board_SPI0)
|
||||
return SpiHandle0;
|
||||
|
||||
if (c == Board_SPI1)
|
||||
return SpiHandle1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __set_spi_handle(uint8_t spi_channel, SPI_Handle handle)
|
||||
{
|
||||
uint8_t c = spi_channel;
|
||||
|
||||
if (c == Board_SPI0)
|
||||
SpiHandle0 = handle;
|
||||
else if (c == Board_SPI1)
|
||||
SpiHandle1 = handle;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static SPI_FrameFormat __get_spi_mode(uint8_t polarity, uint8_t phase)
|
||||
{
|
||||
uint8_t pol = polarity;
|
||||
uint8_t pha = phase;
|
||||
SPI_FrameFormat mode;
|
||||
|
||||
if (pol == 0 && pha == 0)
|
||||
mode = SPI_POL0_PHA0;
|
||||
else if (pol == 0 && pha == 1)
|
||||
mode = SPI_POL0_PHA1;
|
||||
else if (pol == 1 && pha == 0)
|
||||
mode = SPI_POL1_PHA0;
|
||||
else if (pol == 1 && pha == 1)
|
||||
mode = SPI_POL1_PHA1;
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
uint8_t spi0_open(uint32_t bitRate, uint8_t polarity, uint8_t phase)
|
||||
{
|
||||
uint32_t rate = bitRate;
|
||||
uint8_t pol = polarity;
|
||||
uint8_t pha = phase;
|
||||
SPI_Handle h = __get_spi_handle(Board_SPI0);
|
||||
SPI_Params *para = &SpiParams0;
|
||||
|
||||
if (rate > CC2650_SPI_BITRATE_MAX)
|
||||
return 1;
|
||||
|
||||
if (pol > 1 || pha > 1)
|
||||
return 2;
|
||||
|
||||
if (h != NULL)
|
||||
return 3;
|
||||
|
||||
SPI_Params_init(para);
|
||||
para->bitRate = rate;
|
||||
para->mode = SPI_MASTER;
|
||||
para->dataSize = 8;
|
||||
para->frameFormat = __get_spi_mode(pol, pha);
|
||||
|
||||
h = SPI_open(Board_SPI0, para);
|
||||
__set_spi_handle(Board_SPI0, h);
|
||||
|
||||
if (h == NULL)
|
||||
return 4;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t spi0_close(void)
|
||||
{
|
||||
SPI_Handle h = __get_spi_handle(Board_SPI0);
|
||||
|
||||
if (h == NULL)
|
||||
return 1;
|
||||
|
||||
SPI_close(h);
|
||||
__set_spi_handle(Board_SPI0, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t spi0_write(uint8_t *rxBuf, uint8_t *txBuf, uint8_t len)
|
||||
{
|
||||
SPI_Handle h = __get_spi_handle(Board_SPI0);
|
||||
SPI_Transaction spi0_tran;
|
||||
uint8_t ret;
|
||||
|
||||
if (h == NULL)
|
||||
return 1;
|
||||
|
||||
spi0_tran.count = len;
|
||||
spi0_tran.txBuf = txBuf;
|
||||
spi0_tran.arg = NULL;
|
||||
spi0_tran.rxBuf = NULL;
|
||||
ret = SPI_transfer(h, &spi0_tran);
|
||||
|
||||
if (ret == false)
|
||||
return 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t spi1_open(uint32_t bitRate, uint8_t polarity, uint8_t phase)
|
||||
{
|
||||
uint32_t rate = bitRate;
|
||||
uint8_t pol = polarity;
|
||||
uint8_t pha = phase;
|
||||
SPI_Handle h = __get_spi_handle(Board_SPI1);
|
||||
SPI_Params *para = &SpiParams1;
|
||||
|
||||
if (rate > CC2650_SPI_BITRATE_MAX)
|
||||
return 1;
|
||||
|
||||
if (pol > 1 || pha > 1)
|
||||
return 2;
|
||||
|
||||
if (h != NULL)
|
||||
return 3;
|
||||
|
||||
SPI_Params_init(para);
|
||||
para->bitRate = rate;
|
||||
para->mode = SPI_MASTER;
|
||||
para->dataSize = 8;
|
||||
para->frameFormat = __get_spi_mode(pol, pha);
|
||||
|
||||
h = SPI_open(Board_SPI1, para);
|
||||
__set_spi_handle(Board_SPI1, h);
|
||||
|
||||
if (h == NULL)
|
||||
return 4;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t spi1_close(void)
|
||||
{
|
||||
SPI_Handle h = __get_spi_handle(Board_SPI1);
|
||||
if (h == NULL)
|
||||
return 1;
|
||||
|
||||
SPI_close(h);
|
||||
__set_spi_handle(Board_SPI1, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t spi1_write(uint8_t *rxBuf, uint8_t *txBuf, uint8_t len)
|
||||
{
|
||||
SPI_Handle h = __get_spi_handle(Board_SPI1);
|
||||
SPI_Transaction spi1_tran;
|
||||
uint8_t ret;
|
||||
|
||||
if (h == NULL)
|
||||
return 1;
|
||||
|
||||
spi1_tran.count = len;
|
||||
spi1_tran.txBuf = txBuf;
|
||||
spi1_tran.arg = NULL;
|
||||
spi1_tran.rxBuf = rxBuf;
|
||||
ret = SPI_transfer(h, &spi1_tran);
|
||||
|
||||
if (ret == false)
|
||||
return 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* utils.c.h */
|
||||
/*
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
static void ___print_hex(uint8_t* p, int len)
|
||||
{
|
||||
// ___print_hex((uint8_t *)p, sizeof(struct led_series_data_t));
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
printf("0x%x, ", *p++);
|
||||
}
|
||||
printf("\n\n");
|
||||
|
||||
return;
|
||||
}
|
||||
*/
|
||||
@@ -1,40 +0,0 @@
|
||||
#ifndef TIMERS_H
|
||||
#define TIMERS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//timer
|
||||
enum gptimer0_ctrl_e {
|
||||
GPT_CTRL_START = 0,
|
||||
GPT_CTRL_STOP,
|
||||
GPT_CTRL_CLOSE,
|
||||
|
||||
GPT_CTRL_MAX,
|
||||
};
|
||||
|
||||
void elite_gptimer_open();
|
||||
uint8_t gptimer0_ctrl(enum gptimer0_ctrl_e gpt_ctrl);
|
||||
|
||||
|
||||
//clock
|
||||
/***************************************************
|
||||
* Q: Why define CPU_1us = 16?
|
||||
* A:
|
||||
* 3 cycles per loop: 16 loops @ 48 Mhz ~= 1 us
|
||||
* 3 cycles * X loops / 48Mhz = 1us(ideal value)
|
||||
* 3 cycles * X loops / 48us = 1us(ideal value)
|
||||
* X = 48 / 3 => X = 16 loops
|
||||
***************************************************/
|
||||
#define CPU_1us 16
|
||||
#define CPU_1ms 16000
|
||||
|
||||
void CPUdelay_us(uint32_t delay_t);
|
||||
void CPUdelay_ms(uint32_t delay_t);
|
||||
void GPT_timerIncrement();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // TIMERS_H
|
||||
@@ -1,90 +0,0 @@
|
||||
#include <Board.h>
|
||||
#include <ti/drivers/timer/GPTimerCC26XX.h>
|
||||
#include <xdc/runtime/Types.h>
|
||||
#include <ti/sysbios/BIOS.h>
|
||||
#include "driver/timers.h"
|
||||
#include "simple_peripheral.h"
|
||||
|
||||
static GPTimerCC26XX_Handle gptimer_handle; // was defined static
|
||||
|
||||
#define CLOCK_FREQ 4769 // clock freq = 0.1 ms(4800), Measured(4769)
|
||||
|
||||
static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) {
|
||||
elite_gptimer_task();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void elite_gptimer_open()
|
||||
{
|
||||
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);
|
||||
if (gptimer_handle == NULL) {
|
||||
Task_exit();
|
||||
}
|
||||
|
||||
Types_FreqHz freq;
|
||||
BIOS_getCpuFreq(&freq);
|
||||
GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; //47999 = 1ms
|
||||
loadVal = CLOCK_FREQ; //0.1ms
|
||||
GPTimerCC26XX_setLoadValue(gptimer_handle, loadVal);
|
||||
GPTimerCC26XX_registerInterrupt(gptimer_handle, elite_gptimer_callback, GPT_INT_TIMEOUT);
|
||||
|
||||
GPTimerCC26XX_start(gptimer_handle);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t gptimer0_ctrl(enum gptimer0_ctrl_e gpt_ctrl)
|
||||
{
|
||||
enum gptimer0_ctrl_e gc = gpt_ctrl;
|
||||
|
||||
if (gc > GPT_CTRL_MAX)
|
||||
return 1;
|
||||
|
||||
switch (gc) {
|
||||
case GPT_CTRL_START:
|
||||
GPTimerCC26XX_start(gptimer_handle);
|
||||
break;
|
||||
|
||||
case GPT_CTRL_STOP:
|
||||
GPTimerCC26XX_stop(gptimer_handle);
|
||||
break;
|
||||
|
||||
case GPT_CTRL_CLOSE:
|
||||
GPTimerCC26XX_close(gptimer_handle);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************************/
|
||||
//clock
|
||||
void CPUdelay_us(uint32_t delay_t)
|
||||
{
|
||||
uint32_t t = delay_t;
|
||||
|
||||
CPUdelay(t * CPU_1us);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void CPUdelay_ms(uint32_t delay_t)
|
||||
{
|
||||
uint32_t t = delay_t;
|
||||
|
||||
CPUdelay(t * CPU_1ms);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void GPT_timerIncrement() {
|
||||
GPT.cnt_gpt_delta = GPT.cnt_gpt - GPT.cnt_gpt0;
|
||||
GPT.cnt_gpt0 = GPT.cnt_gpt;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#ifndef ELITE_GPTIMER_H
|
||||
#define ELITE_GPTIMER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct gptimer0_t{
|
||||
uint32_t cnt_gpt;
|
||||
uint32_t cnt_gpt0;
|
||||
uint8_t cnt_gpt_delta;
|
||||
uint32_t cnt_adc_rate;
|
||||
uint32_t cnt_notify_rate;
|
||||
uint32_t cnt_v_scan_rate;
|
||||
uint32_t cnt_lead_time;
|
||||
uint32_t BatteryADCCounter;
|
||||
uint32_t BatteryCheckCounter;
|
||||
uint32_t GptimerMultiple;
|
||||
};
|
||||
|
||||
void InitGPT();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // ELITE_GPTIMER_H
|
||||
@@ -1,16 +0,0 @@
|
||||
#include "elite_task/elite_GPtimer.h"
|
||||
|
||||
void InitGPT()
|
||||
{
|
||||
GPT.cnt_gpt = 0;
|
||||
GPT.cnt_gpt0 = 0;
|
||||
GPT.cnt_gpt_delta = 0;
|
||||
GPT.cnt_adc_rate = 0;
|
||||
GPT.cnt_notify_rate = 0;
|
||||
GPT.cnt_v_scan_rate = 0;
|
||||
GPT.cnt_lead_time = 0;
|
||||
GPT.BatteryADCCounter = 0;
|
||||
GPT.BatteryCheckCounter = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
#ifndef ELITE_LATCH_H
|
||||
#define ELITE_LATCH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LOAD0 0
|
||||
#define LOAD1 1
|
||||
#define LOAD2 2
|
||||
#define LOAD_MAX 3
|
||||
|
||||
#define D0 0
|
||||
#define D1 1
|
||||
#define D2 2
|
||||
#define D3 3
|
||||
#define D4 4
|
||||
#define D5 5
|
||||
#define D6 6
|
||||
#define D7 7
|
||||
#define D_MAX 8
|
||||
|
||||
// latch 1 control
|
||||
// #define E_LATCH_LED_SCLK_A LOAD0, D0 // not gpio
|
||||
// #define E_LATCH_LED_MOSI_A LOAD0, D1 // not gpio
|
||||
// #define E_LATCH_SCLK LOAD0, D2 // not gpio
|
||||
// #define E_LATCH_MOSI LOAD0, D3 // not gpio
|
||||
#define E_LATCH_HIGH_Z LOAD0, D4
|
||||
#define E_LATCH_CS_MEM LOAD0, D5
|
||||
#define E_LATCH_CS_ADC LOAD0, D6
|
||||
#define E_LATCH_CS_DAC LOAD0, D7
|
||||
|
||||
// latch 2 control
|
||||
#define E_LATCH_MEM_HOLD LOAD1, D0
|
||||
#define E_LATCH_10V_ENABLE LOAD1, D5
|
||||
#define E_LATCH_5V_ENABLE LOAD1, D6
|
||||
|
||||
// latch 3 control
|
||||
#define E_LATCH_I_MID_ON LOAD2, D0
|
||||
#define E_LATCH_I_LARGE_ON LOAD2, D1
|
||||
#define E_LATCH_V_SMALL_ON LOAD2, D2
|
||||
#define E_LATCH_V_MID_ON LOAD2, D3
|
||||
#define E_LATCH_I_SMALL_ON LOAD2, D4
|
||||
#define E_LATCH_OFF LOAD2, D6
|
||||
#define E_LATCH_VOUT_SMALL_ON LOAD2, D7
|
||||
|
||||
uint8_t update_latch_stat(uint8_t latch, uint8_t dio, uint8_t value);
|
||||
uint8_t latch_single_ctrl(uint8_t latch, uint8_t dio, uint8_t value);
|
||||
uint8_t latch_multi_ctrl(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // ELITE_LATCH_H
|
||||
@@ -1,352 +0,0 @@
|
||||
#include "elite_task/elite_latch.h"
|
||||
#include "driver/gpio_edc15re.h"
|
||||
#include "driver/spi_ctrl.h"
|
||||
|
||||
enum pin_ctrl_e {
|
||||
PC_LOAD0_CLR = 0,
|
||||
PC_LOAD0_SET,
|
||||
PC_LOAD1_CLR,
|
||||
PC_LOAD1_SET,
|
||||
PC_LOAD2_CLR,
|
||||
PC_LOAD2_SET,
|
||||
PC_D0_CLR,
|
||||
PC_D0_SET,
|
||||
PC_D1_CLR,
|
||||
PC_D1_SET,
|
||||
PC_D2_CLR,
|
||||
PC_D2_SET,
|
||||
PC_D3_CLR,
|
||||
PC_D3_SET,
|
||||
PC_D4_CLR,
|
||||
PC_D4_SET,
|
||||
PC_D5_CLR,
|
||||
PC_D5_SET,
|
||||
PC_D6_CLR,
|
||||
PC_D6_SET,
|
||||
PC_D7_CLR,
|
||||
PC_D7_SET,
|
||||
PC_MAX,
|
||||
};
|
||||
|
||||
//d0.d1.d2.d3.d4.d5.d6.d7
|
||||
struct latch_t {
|
||||
uint8_t d7: 1,
|
||||
d6: 1,
|
||||
d5: 1,
|
||||
d4: 1,
|
||||
d3: 1,
|
||||
d2: 1,
|
||||
d1: 1,
|
||||
d0: 1;
|
||||
};
|
||||
|
||||
static struct latch_t LH0 = {0};
|
||||
static struct latch_t LH1 = {0};
|
||||
static struct latch_t LH2 = {0};
|
||||
|
||||
static uint8_t __pin_ctrl(uint8_t pin_control)
|
||||
{
|
||||
uint8_t pc = pin_control;
|
||||
int8_t st;
|
||||
|
||||
if (pc >= PC_MAX)
|
||||
return 1;
|
||||
|
||||
switch (pc) {
|
||||
case PC_LOAD0_CLR:
|
||||
st = pin_set(E_PIN_LOAD0, 0);
|
||||
break;
|
||||
|
||||
case PC_LOAD0_SET:
|
||||
st = pin_set(E_PIN_LOAD0, 1);
|
||||
break;
|
||||
|
||||
case PC_LOAD1_CLR:
|
||||
st = pin_set(E_PIN_LOAD1, 0);
|
||||
break;
|
||||
|
||||
case PC_LOAD1_SET:
|
||||
st = pin_set(E_PIN_LOAD1, 1);
|
||||
break;
|
||||
|
||||
case PC_LOAD2_CLR:
|
||||
st = pin_set(E_PIN_LOAD2, 0);
|
||||
break;
|
||||
|
||||
case PC_LOAD2_SET:
|
||||
st = pin_set(E_PIN_LOAD2, 1);
|
||||
break;
|
||||
|
||||
case PC_D0_CLR:
|
||||
st = pin_set(E_PIN_D0, 0);
|
||||
break;
|
||||
|
||||
case PC_D0_SET:
|
||||
st = pin_set(E_PIN_D0, 1);
|
||||
break;
|
||||
|
||||
case PC_D1_CLR:
|
||||
st = pin_set(E_PIN_D1, 0);
|
||||
break;
|
||||
|
||||
case PC_D1_SET:
|
||||
st = pin_set(E_PIN_D1, 1);
|
||||
break;
|
||||
|
||||
case PC_D2_CLR:
|
||||
st = pin_set(E_PIN_D2, 0);
|
||||
break;
|
||||
|
||||
case PC_D2_SET:
|
||||
st = pin_set(E_PIN_D2, 1);
|
||||
break;
|
||||
|
||||
case PC_D3_CLR:
|
||||
st = pin_set(E_PIN_D3, 0);
|
||||
break;
|
||||
|
||||
case PC_D3_SET:
|
||||
st = pin_set(E_PIN_D3, 1);
|
||||
break;
|
||||
|
||||
case PC_D4_CLR:
|
||||
st = pin_set(E_PIN_D4, 0);
|
||||
break;
|
||||
|
||||
case PC_D4_SET:
|
||||
st = pin_set(E_PIN_D4, 1);
|
||||
break;
|
||||
|
||||
case PC_D5_CLR:
|
||||
st = pin_set(E_PIN_D5, 0);
|
||||
break;
|
||||
|
||||
case PC_D5_SET:
|
||||
st = pin_set(E_PIN_D5, 1);
|
||||
break;
|
||||
|
||||
case PC_D6_CLR:
|
||||
st = pin_set(E_PIN_D6, 0);
|
||||
break;
|
||||
|
||||
case PC_D6_SET:
|
||||
st = pin_set(E_PIN_D6, 1);
|
||||
break;
|
||||
|
||||
case PC_D7_CLR:
|
||||
st = pin_set(E_PIN_D7, 0);
|
||||
break;
|
||||
|
||||
case PC_D7_SET:
|
||||
st = pin_set(E_PIN_D7, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (st)
|
||||
return 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct latch_t *__get_lh_stat(uint8_t latch)
|
||||
{
|
||||
uint8_t lh = latch;
|
||||
|
||||
if (lh == LOAD0)
|
||||
return &LH0;
|
||||
|
||||
if (lh == LOAD1)
|
||||
return &LH1;
|
||||
|
||||
if (lh == LOAD2)
|
||||
return &LH2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __latch0_set(void)
|
||||
{
|
||||
struct latch_t *lh_p = __get_lh_stat(LOAD0);
|
||||
|
||||
pin_set(E_PIN_D4, lh_p->d4);
|
||||
pin_set(E_PIN_D5, lh_p->d5);
|
||||
pin_set(E_PIN_D6, lh_p->d6);
|
||||
pin_set(E_PIN_D7, lh_p->d7);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __latch1_set(void)
|
||||
{
|
||||
struct latch_t *lh_p = __get_lh_stat(LOAD1);
|
||||
|
||||
pin_set(E_PIN_D0, lh_p->d0);
|
||||
pin_set(E_PIN_D5, lh_p->d5);
|
||||
pin_set(E_PIN_D6, lh_p->d6);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __latch2_set(void)
|
||||
{
|
||||
struct latch_t *lh_p = __get_lh_stat(LOAD2);
|
||||
|
||||
pin_set(E_PIN_D0, lh_p->d0);
|
||||
pin_set(E_PIN_D1, lh_p->d1);
|
||||
pin_set(E_PIN_D2, lh_p->d2);
|
||||
pin_set(E_PIN_D3, lh_p->d3);
|
||||
pin_set(E_PIN_D4, lh_p->d4);
|
||||
pin_set(E_PIN_D6, lh_p->d6);
|
||||
pin_set(E_PIN_D7, lh_p->d7);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static uint8_t __latch0_as_gpio(void)
|
||||
{
|
||||
__pin_ctrl(PC_LOAD0_CLR);
|
||||
|
||||
spi0_close();
|
||||
spi1_close();
|
||||
|
||||
add_pin_d0_d3();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t __latch0_as_spi(void)
|
||||
{
|
||||
remove_pin_d0_d3();
|
||||
|
||||
Board_initSPI();
|
||||
spi0_open(SPI_CLK_1M, POL0, PHA1); //SPI 1M: LED
|
||||
spi1_open(SPI_CLK_4M, POL0, PHA1); //SPI 4M: ADC、DAC
|
||||
|
||||
__latch0_set();
|
||||
__pin_ctrl(PC_LOAD0_SET);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t update_latch_stat(uint8_t latch, uint8_t dio, uint8_t value)
|
||||
{
|
||||
uint8_t lh = latch;
|
||||
uint8_t d = dio;
|
||||
uint8_t val = value;
|
||||
struct latch_t *lh_p;
|
||||
|
||||
if (lh >= LOAD_MAX)
|
||||
return 1;
|
||||
|
||||
if (d >= D_MAX)
|
||||
return 2;
|
||||
|
||||
if (val != 1 && value != 0)
|
||||
return 3;
|
||||
|
||||
lh_p = __get_lh_stat(lh);
|
||||
|
||||
switch (d) {
|
||||
case D0:
|
||||
lh_p->d0 = val;
|
||||
break;
|
||||
|
||||
case D1:
|
||||
lh_p->d1 = val;
|
||||
break;
|
||||
|
||||
case D2:
|
||||
lh_p->d2 = val;
|
||||
break;
|
||||
|
||||
case D3:
|
||||
lh_p->d3 = val;
|
||||
break;
|
||||
|
||||
case D4:
|
||||
lh_p->d4 = val;
|
||||
break;
|
||||
|
||||
case D5:
|
||||
lh_p->d5 = val;
|
||||
break;
|
||||
|
||||
case D6:
|
||||
lh_p->d6 = val;
|
||||
break;
|
||||
|
||||
case D7:
|
||||
lh_p->d7 = val;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t latch_single_ctrl(uint8_t latch, uint8_t dio, uint8_t value)
|
||||
{
|
||||
// control one latch pin -> update_latch_stat -> what latch to update? -> latch?_ctrl
|
||||
uint8_t lh = latch;
|
||||
uint8_t d = dio;
|
||||
uint8_t val = value;
|
||||
|
||||
if (lh >= LOAD_MAX)
|
||||
return 1;
|
||||
|
||||
if (d >= D_MAX)
|
||||
return 2;
|
||||
|
||||
if (val != 1 && value != 0)
|
||||
return 3;
|
||||
|
||||
update_latch_stat(lh, d, val);
|
||||
|
||||
switch (lh) {
|
||||
case LOAD0:
|
||||
__latch0_set();
|
||||
break;
|
||||
|
||||
case LOAD1:
|
||||
__latch0_as_gpio();
|
||||
|
||||
__latch1_set();
|
||||
__pin_ctrl(PC_LOAD1_SET);
|
||||
__pin_ctrl(PC_LOAD1_CLR);
|
||||
|
||||
__latch0_as_spi();
|
||||
break;
|
||||
|
||||
case LOAD2:
|
||||
__latch0_as_gpio();
|
||||
|
||||
__latch2_set();
|
||||
__pin_ctrl(PC_LOAD2_SET);
|
||||
__pin_ctrl(PC_LOAD2_CLR);
|
||||
|
||||
__latch0_as_spi();
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t latch_multi_ctrl(void)
|
||||
{
|
||||
// control many latch pin -> update_latch_stat -> update_latch_stat -> ... -> latch_ctrl 0.1.2
|
||||
__latch0_set();
|
||||
__pin_ctrl(PC_LOAD0_SET);
|
||||
|
||||
__latch0_as_gpio();
|
||||
|
||||
__latch1_set();
|
||||
__pin_ctrl(PC_LOAD1_SET);
|
||||
__pin_ctrl(PC_LOAD1_CLR);
|
||||
|
||||
__latch2_set();
|
||||
__pin_ctrl(PC_LOAD2_SET);
|
||||
__pin_ctrl(PC_LOAD2_CLR);
|
||||
|
||||
__latch0_as_spi();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
#ifndef DAC_MAX5136_H
|
||||
#define DAC_MAX5136_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "driver/spi_ctrl.h"
|
||||
|
||||
#define CTRL_B_LDAC 0x01
|
||||
#define CTRL_B_CLR 0x02
|
||||
#define CTRL_B_POW_CTRL 0x03
|
||||
#define CTRL_B_LINEARITY 0x05
|
||||
#define CTRL_B_WRT(_d0, _d1) (0x10 | ((_d1) << 1) | (_d0))
|
||||
#define CTRL_B_WRT_THR(_d0, _d1) (0x30 | ((_d1) << 1) | (_d0))
|
||||
|
||||
#define DATA_B_LDAC(_d0, _d1) ((_d1) << 9 | (_d0) << 8)
|
||||
#define DATA_B_POW_CT(_d0, _d1, _rd) ((_d1) << 9 | (_d0) << 8 | (_rd) << 7)
|
||||
#define DATA_B_LINE(_en) ((_en) << 9)
|
||||
|
||||
#define DAC0_EN 1
|
||||
#define DAC0_DIS 0
|
||||
#define DAC1_EN 1
|
||||
#define DAC1_DIS 0
|
||||
|
||||
#define DAC0_W_T(_v) dac_write_through_mode(DAC0_EN, DAC1_DIS, _v);
|
||||
#define DAC0_W(_v) dac_write_mode(DAC0_EN, DAC1_DIS, _v);
|
||||
#define DAC0_P_C(_rdy) dac_power_control_mode(DAC0_EN, DAC1_DIS, _rdy);
|
||||
#define DAC0_LDAC() dac_ldac_mode(DAC0_EN, DAC1_DIS);
|
||||
|
||||
|
||||
int dac_ldac_mode(uint8_t dac0_enable, uint8_t dac1_enable);
|
||||
int dac_clear_mode();
|
||||
int dac_power_control_mode(uint8_t dac0_enable, uint8_t dac1_enable, uint8_t ready_enable);
|
||||
int dac_linearity_mode(uint8_t linear_enable);
|
||||
int dac_write_mode(uint8_t dac0_enable, uint8_t dac1_enable, uint16_t volts);
|
||||
int dac_write_through_mode(uint8_t dac0_enable, uint8_t dac1_enable, uint16_t volts);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //DAC_MAX5136_H
|
||||
@@ -1,110 +0,0 @@
|
||||
#include "hardware/dac_MAX5136.h"
|
||||
|
||||
struct dac_series_data_t {
|
||||
uint8_t control_bits;
|
||||
uint16_t data_bits;
|
||||
}__attribute__((packed));
|
||||
|
||||
static struct dac_series_data_t dac_series_data_g = {0};
|
||||
|
||||
|
||||
static int __dac_transfer(struct dac_series_data_t *sd)
|
||||
{
|
||||
latch_single_ctrl(E_LATCH_CS_DAC, 0);
|
||||
|
||||
#define WRITE_TO_DAC(_d, _l) spi1_write(NULL, (uint8_t *)(_d), (_l))
|
||||
WRITE_TO_DAC(sd, sizeof(struct dac_series_data_t));
|
||||
|
||||
latch_single_ctrl(E_LATCH_CS_DAC, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dac_ldac_mode(uint8_t dac0_enable, uint8_t dac1_enable)
|
||||
{
|
||||
uint8_t d0 = dac0_enable;
|
||||
uint8_t d1 = dac1_enable;
|
||||
|
||||
struct dac_series_data_t *sd = &dac_series_data_g;
|
||||
sd->control_bits = CTRL_B_LDAC;
|
||||
sd->data_bits = REVERT_2_BYTE(DATA_B_LDAC(d0, d1));
|
||||
__dac_transfer(sd);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int dac_clear_mode()
|
||||
{
|
||||
struct dac_series_data_t *sd = &dac_series_data_g;
|
||||
sd->control_bits = CTRL_B_CLR;
|
||||
__dac_transfer(sd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int dac_power_control_mode(uint8_t dac0_enable, uint8_t dac1_enable, uint8_t ready_enable)
|
||||
{
|
||||
uint8_t d0 = dac0_enable;
|
||||
uint8_t d1 = dac1_enable;
|
||||
uint8_t rdy_en = ready_enable;
|
||||
struct dac_series_data_t *sd = &dac_series_data_g;
|
||||
|
||||
sd->control_bits = CTRL_B_POW_CTRL;
|
||||
sd->data_bits = REVERT_2_BYTE(DATA_B_POW_CT(d0, d1, rdy_en));
|
||||
|
||||
__dac_transfer(sd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int dac_linearity_mode(uint8_t linear_enable)
|
||||
{
|
||||
uint8_t lin_en = linear_enable;
|
||||
struct dac_series_data_t *sd = &dac_series_data_g;
|
||||
|
||||
sd->control_bits = CTRL_B_LINEARITY;
|
||||
sd->data_bits = REVERT_2_BYTE(DATA_B_LINE(lin_en));
|
||||
__dac_transfer(sd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int dac_write_mode(uint8_t dac0_enable, uint8_t dac1_enable, uint16_t volts)
|
||||
{
|
||||
uint8_t d0 = dac0_enable;
|
||||
uint8_t d1 = dac1_enable;
|
||||
uint16_t v = volts;
|
||||
struct dac_series_data_t *sd = &dac_series_data_g;
|
||||
|
||||
sd->control_bits = CTRL_B_WRT(d0, d1);
|
||||
sd->data_bits = REVERT_2_BYTE(v);
|
||||
__dac_transfer(sd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int dac_write_through_mode(uint8_t dac0_enable, uint8_t dac1_enable, uint16_t volts)
|
||||
{
|
||||
uint8_t d0 = dac0_enable;
|
||||
uint8_t d1 = dac1_enable;
|
||||
uint16_t v = volts;
|
||||
struct dac_series_data_t *sd = &dac_series_data_g;
|
||||
|
||||
sd->control_bits = CTRL_B_WRT_THR(d0, d1);
|
||||
sd->data_bits = REVERT_2_BYTE(v);
|
||||
__dac_transfer(sd);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
#ifndef DAC_ADS1118_H
|
||||
#define DAC_ADS1118_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "driver/spi_ctrl.h"
|
||||
|
||||
#define ADC_CH_CURR AIN0_GND
|
||||
#define ADC_CH_VIN AIN1_GND
|
||||
#define ADC_CH_VOUT AIN2_GND
|
||||
#define ADC_CH_BAT AIN3_GND
|
||||
|
||||
#define MEASURE_CURRENT() read_adc_data(ADC_CH_CURR, FSR3)
|
||||
#define MEASURE_VOLT() read_adc_data(ADC_CH_VIN, FSR3)
|
||||
#define MEASURE_DAC() read_adc_data(ADC_CH_VOUT, FSR3)
|
||||
#define MEASURE_BATTERY() read_adc_data(ADC_CH_BAT, FSR1)
|
||||
|
||||
|
||||
enum input_mux_e {
|
||||
AIN0_AIN1 = 0x00,
|
||||
AIN0_AIN3 = 0x01,
|
||||
AIN1_AIN3 = 0x02,
|
||||
AIN2_AIN3 = 0x03,
|
||||
AIN0_GND = 0x04,
|
||||
AIN1_GND = 0x05,
|
||||
AIN2_GND = 0x06,
|
||||
AIN3_GND = 0x07,
|
||||
};
|
||||
|
||||
/*
|
||||
* [Progrmmable gain amplifier configuration]
|
||||
*
|
||||
* The corresponing relationship of FSRx to volt will be the form:
|
||||
* FSRx <-> 0xXX <-> +- xV
|
||||
*
|
||||
* FSR1 <-> 0x00 <-> +-6.144V
|
||||
* FSR2 <-> 0x01 <-> +-4.096V
|
||||
* FSR3 <-> 0x02 <-> +-2.408V
|
||||
* FSR4 <-> 0x03 <-> +-1.024V
|
||||
* FSR5 <-> 0x04 <-> +-0.512V
|
||||
* FSR6 <-> 0x05 <-> +-0.256V
|
||||
* FSR7 <-> 0x06 <-> +-0.256V
|
||||
* FSR8 <-> 0x07 <-> +-0.256V
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
enum gain_amplifier_e {
|
||||
FSR1 = 0x00,
|
||||
FSR2 = 0x01,
|
||||
FSR3 = 0x02,
|
||||
FSR4 = 0X03,
|
||||
FSR5 = 0x04,
|
||||
FSR6 = 0x05,
|
||||
FSR7 = 0x06,
|
||||
FSR8 = 0x07,
|
||||
};
|
||||
|
||||
uint16_t read_adc_data(uint8_t AdcChannel, uint8_t gainAmp);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //ADC_ADS1118_H
|
||||
@@ -1,79 +0,0 @@
|
||||
#include "hardware/adc_ads1118.h"
|
||||
|
||||
static uint8_t spi_ADC_txbuf_l[2] = {0};
|
||||
static uint8_t spi_ADC_rxbuf_l[2] = {0};
|
||||
|
||||
|
||||
static void __ADC_read(uint8_t input_mux, uint8_t gAmp)
|
||||
{
|
||||
/*
|
||||
* write SPI to get ADC value
|
||||
* [7]~[0] should always be 0b11101011, data rate is 860 sps, other is default
|
||||
*
|
||||
* [15] : SS, 0 = no effect, 1 = start work, default 0b0
|
||||
* [14]~[12] : MUX[2:0], default 0b000
|
||||
*
|
||||
* [Input multiplexer configuration]
|
||||
*
|
||||
* the MUX selection will correspond to a pin pair
|
||||
* where the pair is positive and negative input
|
||||
*
|
||||
* MUX[2:0] <-> (AINp, AINn)
|
||||
*
|
||||
* 000 <-> AINp is AIN0, AINn is AIN1
|
||||
* 001 <-> AINp is AIN0, AINn is AIN3
|
||||
* 010 <-> AINp is AIN1, AINn is AIN3
|
||||
* 011 <-> AINp is AIN2, AINn is AIN3
|
||||
* 100 <-> AINp is AIN0, AINn is GND
|
||||
* 101 <-> AINp is AIN1, AINn is GND
|
||||
* 110 <-> AINp is AIN2, AINn is GND
|
||||
* 111 <-> AINp is AIN3, AINn is GND
|
||||
*
|
||||
*
|
||||
*
|
||||
* [11]~[9] : PGA[2:0], default 0b010 = FSR is ±2.048
|
||||
* [8] : mode, 0 = continuous, 1 = one shot, default 0b1 (Power-down and single-shot mode )
|
||||
*
|
||||
* [7]~[5] : data rate, default 0b100 = 128 SPS; 0b111 = 860 SPS
|
||||
* [4] : Temperature? default 0b0 = ADC mode
|
||||
* [3] : Pullup enable, default 0b1 = Pullup resistor enabled
|
||||
* [2]~[1] : NOP, default 0b01
|
||||
* [0] : reserved, default 0b1
|
||||
*
|
||||
*/
|
||||
|
||||
uint8_t *tx = spi_ADC_txbuf_l;
|
||||
uint8_t *rx = spi_ADC_rxbuf_l;
|
||||
uint8_t i_mux = input_mux;
|
||||
uint8_t ga = gAmp;
|
||||
|
||||
|
||||
tx[0] = i_mux << 4 | ga << 1 | 0b10000001;
|
||||
tx[1] = 0b11101011;
|
||||
|
||||
latch_single_ctrl(E_LATCH_CS_ADC, 0);
|
||||
spi1_write(NULL, tx, 2);
|
||||
latch_single_ctrl(E_LATCH_CS_ADC, 1);
|
||||
|
||||
memset(tx, 0, sizeof(tx));
|
||||
memset(rx, 0, sizeof(rx));
|
||||
|
||||
latch_single_ctrl(E_LATCH_CS_ADC, 0);
|
||||
spi1_write(rx, tx, 2);
|
||||
latch_single_ctrl(E_LATCH_CS_ADC, 1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t read_adc_data(uint8_t AdcChannel, uint8_t gainAmplifier)
|
||||
{
|
||||
uint8_t Adc_ch = AdcChannel;
|
||||
uint8_t gainAmp = gainAmplifier;
|
||||
uint16_t rx;
|
||||
|
||||
__ADC_read(Adc_ch, gainAmp);
|
||||
|
||||
rx = (uint16_t)spi_ADC_rxbuf_l[0] << 8 | (uint16_t)spi_ADC_rxbuf_l[1];
|
||||
|
||||
return rx;
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
#ifndef LED_APA_102_H
|
||||
#define LED_APA_102_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* APA-102-2020-256-8A-20190612: Series data structure
|
||||
* +-------------------+------------------------- ... -+-----------------+
|
||||
* | start_frame(4B) | led_frame(4B) *LED_TANDEM_N | end_frame(4B) |
|
||||
* +-------------------+------------------------- ... -+-----------------+
|
||||
* / \
|
||||
* / led_frame(4B) \
|
||||
* / \
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | 111 | bright | blue | green | red |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*/
|
||||
|
||||
#include "driver/spi_ctrl.h"
|
||||
|
||||
#define DEF_LED_TANDEN_N 12
|
||||
|
||||
#ifdef DEF_LED_TANDEN_N
|
||||
#define LED_TANDEM_N DEF_LED_TANDEN_N
|
||||
#else
|
||||
#define LED_TANDEM_N 12
|
||||
#endif
|
||||
|
||||
enum led_series_nb_e {
|
||||
LED_NB_1 = 0,
|
||||
LED_NB_2,
|
||||
LED_NB_3,
|
||||
LED_NB_4,
|
||||
LED_NB_5,
|
||||
LED_NB_6,
|
||||
LED_NB_7,
|
||||
LED_NB_8,
|
||||
LED_NB_9,
|
||||
LED_NB_10,
|
||||
LED_NB_11,
|
||||
LED_NB_12,
|
||||
|
||||
LED_NB_MAX = LED_TANDEM_N,
|
||||
};
|
||||
|
||||
enum led_bright_e {
|
||||
LED_BR_LV0 = 0x00,
|
||||
LED_BR_LV1 = 0x01,
|
||||
LED_BR_LV8 = 0x08,
|
||||
|
||||
LED_BR_MAX = 0x1F,
|
||||
};
|
||||
|
||||
enum led_color_e {
|
||||
LED_CLR_BLACK = 0,
|
||||
LED_CLR_WHITE,
|
||||
LED_CLR_RED,
|
||||
LED_CLR_ORANGE,
|
||||
LED_CLR_YELLOW,
|
||||
LED_CLR_GREEN,
|
||||
LED_CLR_CYAN,
|
||||
LED_CLR_BLUE,
|
||||
LED_CLR_PURPLE,
|
||||
LED_CLR_MAGENTA,
|
||||
LED_CLR_YELLOWGREEN,
|
||||
LED_CLR_EMERALD,
|
||||
|
||||
LED_CLR_MAX,
|
||||
};
|
||||
|
||||
struct led_color_t {
|
||||
uint8_t b;
|
||||
uint8_t g;
|
||||
uint8_t r;
|
||||
};
|
||||
|
||||
struct led_frame_t {
|
||||
uint8_t bright: 5,
|
||||
rsvd: 3;
|
||||
struct led_color_t color;
|
||||
};
|
||||
|
||||
int led_color_set(enum led_series_nb_e led_nb, enum led_bright_e bright, enum led_color_e color);
|
||||
int led_color_code_set(enum led_series_nb_e led_nb, enum led_bright_e bright, struct led_color_t *color);
|
||||
int led_rainbow(enum led_bright_e bright);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // LED_APA_102_H
|
||||
@@ -1,189 +0,0 @@
|
||||
#include "hardware/led_APA_102.h"
|
||||
|
||||
#define LED_FRME_FILL_RSVD(_f) (_f)->rsvd = 0x07 // 0x11100000 || bright
|
||||
#define LED_SERIES_D_START 0x00000000
|
||||
#define LED_SERIES_D_END 0xFFFFFFFF
|
||||
|
||||
struct led_series_data_t {
|
||||
uint32_t f_start;
|
||||
struct led_frame_t f_led[LED_TANDEM_N];
|
||||
uint32_t f_end;
|
||||
};
|
||||
|
||||
static struct led_series_data_t led_series_data_g = {0};
|
||||
|
||||
const struct led_color_t led_color_list_g[LED_CLR_MAX] = {
|
||||
// {blue, green, red}
|
||||
{0x00, 0x00, 0x00}, // LED_CLR_BLACK
|
||||
{0xFF, 0xFF, 0xCA}, // LED_CLR_WHITE
|
||||
{0x00, 0x00, 0xFF}, // LED_CLR_RED
|
||||
{0x09, 0x58, 0xFF}, // LED_CLR_ORANGE
|
||||
{0x00, 0xE1, 0xE1}, // LED_CLR_YELLOW
|
||||
{0x00, 0xFA, 0x00}, // LED_CLR_GREEN
|
||||
{0x40, 0x40, 0x00}, // LED_CLR_CYAN
|
||||
{0xAA, 0x00, 0x00}, // LED_CLR_BLUE
|
||||
{0x6F, 0x00, 0x3A}, // LED_CLR_PURPLE
|
||||
{0xFF, 0x00, 0xFF}, // LED_CLR_MAGENTA
|
||||
{0x00, 0xA6, 0x64}, // LED_CLR_YELLOWGREEN
|
||||
{0x78, 0xC8, 0x50}, // LED_CLR_EMERALD
|
||||
};
|
||||
|
||||
static int __led_single_set(struct led_series_data_t *led_s_d, struct led_frame_t *led_f, enum led_series_nb_e led_nb)
|
||||
{
|
||||
struct led_series_data_t *sd = led_s_d;
|
||||
struct led_frame_t *f = led_f;
|
||||
enum led_series_nb_e nb = led_nb;
|
||||
|
||||
memcpy(&sd->f_led[nb], f, sizeof(struct led_frame_t));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __led_multiple_set(struct led_series_data_t *led_s_d, struct led_frame_t *led_f)
|
||||
{
|
||||
struct led_series_data_t *sd = led_s_d;
|
||||
struct led_frame_t *f = led_f;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* use __led_single_set() to finish all led;
|
||||
*/
|
||||
for (i = LED_NB_1; i < LED_NB_MAX; i++) {
|
||||
__led_single_set(sd, f, (enum led_series_nb_e)i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __led_complete(struct led_series_data_t *led_s_d)
|
||||
{
|
||||
struct led_series_data_t *sd = led_s_d;
|
||||
struct led_frame_t *f = sd->f_led;
|
||||
int i;
|
||||
|
||||
for (i = LED_NB_1; i < LED_NB_MAX; i++) {
|
||||
LED_FRME_FILL_RSVD(f);
|
||||
f++;
|
||||
}
|
||||
|
||||
sd->f_start = LED_SERIES_D_START;
|
||||
sd->f_end = LED_SERIES_D_END;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __led_color_set(enum led_series_nb_e led_nb, struct led_frame_t *led_f)
|
||||
{
|
||||
enum led_series_nb_e nb = led_nb;
|
||||
struct led_frame_t *f = led_f;
|
||||
struct led_series_data_t *sd = &led_series_data_g;
|
||||
|
||||
if (f == NULL)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* nb - < LED_NB_MAX: fill one led_frame
|
||||
* == LED_NB_MAX: fill multiple led_frame
|
||||
*
|
||||
* complete: then, fill (start_frame, end_frame and the rsvd of every led_frame)
|
||||
*
|
||||
* finally, write cmd to hw by spi
|
||||
*/
|
||||
if (nb < LED_NB_MAX) {
|
||||
__led_single_set(sd, f, nb);
|
||||
} else if (nb == LED_NB_MAX) {
|
||||
__led_multiple_set(sd, f);
|
||||
} else {
|
||||
return -2;
|
||||
}
|
||||
|
||||
__led_complete(sd);
|
||||
|
||||
#define WRITE_TO_HW(_d, _l) spi0_write(NULL, (uint8_t *)(_d), (_l))
|
||||
WRITE_TO_HW(sd, sizeof(struct led_series_data_t));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int led_color_set(enum led_series_nb_e led_nb, enum led_bright_e bright, enum led_color_e color)
|
||||
{
|
||||
enum led_series_nb_e nb = led_nb;
|
||||
enum led_bright_e b = bright;
|
||||
enum led_color_e c = color;
|
||||
struct led_frame_t led_f;
|
||||
|
||||
if (nb > LED_NB_MAX)
|
||||
return -1;
|
||||
|
||||
if (c >= LED_CLR_MAX)
|
||||
return -2;
|
||||
|
||||
if (b > LED_BR_MAX)
|
||||
return -3;
|
||||
|
||||
led_f.bright = b;
|
||||
led_f.color = led_color_list_g[c];
|
||||
__led_color_set(nb, &led_f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int led_color_code_set(enum led_series_nb_e led_nb, enum led_bright_e bright, struct led_color_t *color)
|
||||
{
|
||||
enum led_series_nb_e nb = led_nb;
|
||||
enum led_bright_e b = bright;
|
||||
struct led_color_t *c = color;
|
||||
struct led_frame_t led_f;
|
||||
|
||||
// valid the input values
|
||||
if (nb > LED_NB_MAX)
|
||||
return -1;
|
||||
|
||||
if (b > LED_BR_MAX)
|
||||
return -2;
|
||||
|
||||
led_f.bright = b;
|
||||
memcpy(&led_f.color, c, sizeof(struct led_color_t));
|
||||
|
||||
__led_color_set(nb, &led_f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int led_rainbow(enum led_bright_e bright)
|
||||
{
|
||||
enum led_bright_e b = bright;
|
||||
int i;
|
||||
|
||||
if (b > LED_BR_MAX)
|
||||
return -1;
|
||||
|
||||
for(i=0; i<LED_NB_MAX; i++) {
|
||||
led_color_set((enum led_series_nb_e)i, b, (enum led_color_e)i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* example -
|
||||
* customize color:
|
||||
* struct led_color_t led_c;
|
||||
* uint8_t bri;
|
||||
* // { ins, ins, num, r, g, b, bri};
|
||||
* uint8_t ins[20] = {0x30, 0x00, LED_NB_4, 0xFF, 0x00, 0x44, 0x3};
|
||||
* led_c.r = ins[3];
|
||||
* led_c.g = ins[4];
|
||||
* led_c.b = ins[5];
|
||||
* bri = ins[6];
|
||||
* led_color_code_set(LED_NB_4, bri, &led_c);
|
||||
*
|
||||
* single led:
|
||||
* led_color_set(LED_NB_1, LED_BR_LV1, LED_CLR_WHITE);
|
||||
*
|
||||
* multiple led:
|
||||
* led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_BLUE);
|
||||
*
|
||||
* rainbow led:
|
||||
* led_rainbow(LED_BR_LV1);
|
||||
*/
|
||||
@@ -0,0 +1,179 @@
|
||||
{
|
||||
"name": "Elite-ZM",
|
||||
"version": "1.2.30",
|
||||
"match_rule": {
|
||||
"local_name_pattern": "Elite-ZM.+",
|
||||
"major_product_number": 0,
|
||||
"minor_product_number": 2,
|
||||
"major_version_number": 1,
|
||||
"minor_version_number": 2
|
||||
},
|
||||
"constant": {
|
||||
"ADC_CHANNEL_NUMBER": [
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15
|
||||
],
|
||||
"VOLT_MAX": 4095
|
||||
},
|
||||
"parameters": {
|
||||
"CHANNEL": {
|
||||
"description": "record channels",
|
||||
"record_meta": true,
|
||||
"domain": "property",
|
||||
"value": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
]
|
||||
},
|
||||
"SAMPLE_RATE": {
|
||||
"description": "data sampling rate",
|
||||
"record_meta": true,
|
||||
"domain": "constant",
|
||||
"value": 1
|
||||
},
|
||||
"AMP_GAIN": {
|
||||
"description": "amp gain",
|
||||
"record_meta": true,
|
||||
"domain": "constant",
|
||||
"value": 1
|
||||
},
|
||||
"MODE": {
|
||||
"description": "working mode",
|
||||
"value": [
|
||||
"I-V Curve",
|
||||
"Cyclic Voltammetry",
|
||||
"Function Generator",
|
||||
"Z-T Curve",
|
||||
"V-T Curve",
|
||||
"I-T Curve",
|
||||
"ADC test"
|
||||
]
|
||||
},
|
||||
"VOLT_ORIGIN": {
|
||||
"description": "Origin Voltage of Scan",
|
||||
"domain": [
|
||||
"VOLT_MAX"
|
||||
]
|
||||
},
|
||||
"VOLT_FINAL": {
|
||||
"description": "The last Voltage of Scan",
|
||||
"domain": [
|
||||
"VOLT_MAX"
|
||||
],
|
||||
"value": "1365 * VALUE"
|
||||
},
|
||||
"VOLT_STEP": {
|
||||
"description": "Voltage Step",
|
||||
"domain": [
|
||||
5
|
||||
]
|
||||
},
|
||||
"STEP_TIME": {
|
||||
"description": "How much time between two step",
|
||||
"domain": [
|
||||
4
|
||||
]
|
||||
},
|
||||
"DAC_VOLT": {
|
||||
"description": "DAC output Voltage",
|
||||
"domain": [
|
||||
"VOLT_MAX"
|
||||
]
|
||||
},
|
||||
"ADC_CHANNEL": {
|
||||
"description": "read ADC data",
|
||||
"value": [
|
||||
"ANA0",
|
||||
"ANA1",
|
||||
"ANA2",
|
||||
"ANA3"
|
||||
]
|
||||
}
|
||||
},
|
||||
"instruction": {
|
||||
"start": [
|
||||
{
|
||||
"expression": "MODE",
|
||||
"when": {
|
||||
"0": "curve_iv",
|
||||
"1": "curve_cv",
|
||||
"2": "func_gen",
|
||||
"6": "adc_test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"data_format": [
|
||||
"_data_format('TDC4VAF2')"
|
||||
],
|
||||
"curve_iv": [
|
||||
"data_format",
|
||||
"_notify(True)",
|
||||
"curve_iv0",
|
||||
"_sync(True)",
|
||||
"VIS_STI"
|
||||
],
|
||||
"curve_iv0": {
|
||||
"type": "RIS",
|
||||
"parameter": {
|
||||
"va": "(VOLT_ORIGIN + 1) * 0x0010",
|
||||
"vb": "(VOLT_FINAL + 1) * 0x0010",
|
||||
"dv": "VOLT_STEP * 0x40",
|
||||
"dt": "STEP_TIME * 0x12"
|
||||
},
|
||||
"data": [
|
||||
"1X10;2B>va;2B>vb;B>dv;B>dt"
|
||||
]
|
||||
},
|
||||
"curve_cv": [
|
||||
"data_format",
|
||||
"_notify(True)",
|
||||
"curve_cv0",
|
||||
"_sync(True)",
|
||||
"VIS_STI"
|
||||
],
|
||||
"curve_cv0": {
|
||||
"type": "RIS",
|
||||
"parameter": {
|
||||
"va": "(VOLT_ORIGIN + 1) * 0x0010",
|
||||
"vb": "(VOLT_FINAL + 1) * 0x0010",
|
||||
"dv": "VOLT_STEP * 0x40",
|
||||
"dt": "STEP_TIME * 0x12"
|
||||
},
|
||||
"data": [
|
||||
"1X20;2B>va;2B>vb;B>dv;B>dt"
|
||||
]
|
||||
},
|
||||
"func_gen": [
|
||||
"data_format",
|
||||
"func_gen0",
|
||||
"VIS_STI"
|
||||
],
|
||||
"func_gen0": {
|
||||
"type": "RIS",
|
||||
"parameter": {
|
||||
"v": "(DAC_VOLT + 1) * 0x0010"
|
||||
},
|
||||
"data": [
|
||||
"X30;X30;2B>v"
|
||||
]
|
||||
},
|
||||
"adc_test": [
|
||||
"data_format",
|
||||
"_notify(True)",
|
||||
"adc_test0",
|
||||
"_sync(True)",
|
||||
"VIS_STI"
|
||||
],
|
||||
"adc_test0": {
|
||||
"type": "RIS",
|
||||
"data": [
|
||||
"X90;B>ADC_CHANNEL"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
|
||||
#ifndef Elite15_PIN
|
||||
#define Elite_15PIN
|
||||
|
||||
#include "Elite_PIN.h"
|
||||
|
||||
static void update_latch_status (uint32_t latch_num, uint32_t elite_pin, bool highlow) {
|
||||
switch (latch_num) {
|
||||
case LOAD0: {
|
||||
switch (elite_pin) {
|
||||
case D0: {
|
||||
LH.LATCH0[0] = highlow;
|
||||
break;
|
||||
}
|
||||
case D1: {
|
||||
LH.LATCH0[1] = highlow;
|
||||
break;
|
||||
}
|
||||
case D2: {
|
||||
LH.LATCH0[2] = highlow;
|
||||
break;
|
||||
}
|
||||
case D3: {
|
||||
LH.LATCH0[3] = highlow;
|
||||
break;
|
||||
}
|
||||
case D4: {
|
||||
LH.LATCH0[4] = highlow;
|
||||
break;
|
||||
}
|
||||
case D5: {
|
||||
LH.LATCH0[5] = highlow;
|
||||
break;
|
||||
}
|
||||
case D6: {
|
||||
LH.LATCH0[6] = highlow;
|
||||
break;
|
||||
}
|
||||
case D7: {
|
||||
LH.LATCH0[7] = highlow;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LOAD1: {
|
||||
switch (elite_pin) {
|
||||
case D0: {
|
||||
LH.LATCH1[0] = highlow;
|
||||
break;
|
||||
}
|
||||
case D1: {
|
||||
LH.LATCH1[1] = highlow;
|
||||
break;
|
||||
}
|
||||
case D2: {
|
||||
LH.LATCH1[2] = highlow;
|
||||
break;
|
||||
}
|
||||
case D3: {
|
||||
LH.LATCH1[3] = highlow;
|
||||
break;
|
||||
}
|
||||
case D4: {
|
||||
LH.LATCH1[4] = highlow;
|
||||
break;
|
||||
}
|
||||
case D5: {
|
||||
LH.LATCH1[5] = highlow;
|
||||
break;
|
||||
}
|
||||
case D6: {
|
||||
LH.LATCH1[6] = highlow;
|
||||
break;
|
||||
}
|
||||
case D7: {
|
||||
LH.LATCH1[7] = highlow;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LOAD2: {
|
||||
switch (elite_pin) {
|
||||
case D0: {
|
||||
LH.LATCH2[0] = highlow;
|
||||
break;
|
||||
}
|
||||
case D1: {
|
||||
LH.LATCH2[1] = highlow;
|
||||
break;
|
||||
}
|
||||
case D2: {
|
||||
LH.LATCH2[2] = highlow;
|
||||
break;
|
||||
}
|
||||
case D3: {
|
||||
LH.LATCH2[3] = highlow;
|
||||
break;
|
||||
}
|
||||
case D4: {
|
||||
LH.LATCH2[4] = highlow;
|
||||
break;
|
||||
}
|
||||
case D5: {
|
||||
LH.LATCH2[5] = highlow;
|
||||
break;
|
||||
}
|
||||
case D6: {
|
||||
LH.LATCH2[6] = highlow;
|
||||
break;
|
||||
}
|
||||
case D7: {
|
||||
LH.LATCH2[7] = highlow;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow) {
|
||||
ELITE15_SPI_CLOSE();
|
||||
add_elite_pin();
|
||||
update_latch_status (latch_num, pin_num, highlow);
|
||||
// PIN_setOutputValue(&ZM_rst, latch_num, 1); // Turn on latch
|
||||
|
||||
switch (latch_num) {
|
||||
case LOAD0: {
|
||||
// PIN_setOutputValue(&ZM_rst, D0, LH.LATCH0[0]);
|
||||
// PIN_setOutputValue(&ZM_rst, D1, LH.LATCH0[1]);
|
||||
// PIN_setOutputValue(&ZM_rst, D2, LH.LATCH0[2]);
|
||||
// PIN_setOutputValue(&ZM_rst, D3, LH.LATCH0[3]);
|
||||
PIN_setOutputValue(pin_handle, D4, LH.LATCH0[4]);
|
||||
PIN_setOutputValue(pin_handle, D5, LH.LATCH0[5]);
|
||||
PIN_setOutputValue(pin_handle, D6, LH.LATCH0[6]);
|
||||
PIN_setOutputValue(pin_handle, D7, LH.LATCH0[7]);
|
||||
break;
|
||||
}
|
||||
case LOAD1: {
|
||||
PIN_setOutputValue(pin_handle, D0, LH.LATCH1[0]);
|
||||
PIN_setOutputValue(pin_handle, D1, LH.LATCH1[1]);
|
||||
PIN_setOutputValue(pin_handle, D2, LH.LATCH1[2]);
|
||||
PIN_setOutputValue(pin_handle, D3, LH.LATCH1[3]);
|
||||
PIN_setOutputValue(pin_handle, D4, LH.LATCH1[4]);
|
||||
PIN_setOutputValue(pin_handle, D5, LH.LATCH1[5]);
|
||||
PIN_setOutputValue(pin_handle, D6, LH.LATCH1[6]);
|
||||
PIN_setOutputValue(pin_handle, D7, LH.LATCH1[7]);
|
||||
break;
|
||||
}
|
||||
case LOAD2: {
|
||||
PIN_setOutputValue(pin_handle, D0, LH.LATCH2[0]);
|
||||
PIN_setOutputValue(pin_handle, D1, LH.LATCH2[1]);
|
||||
PIN_setOutputValue(pin_handle, D2, LH.LATCH2[2]);
|
||||
PIN_setOutputValue(pin_handle, D3, LH.LATCH2[3]);
|
||||
PIN_setOutputValue(pin_handle, D4, LH.LATCH2[4]);
|
||||
PIN_setOutputValue(pin_handle, D5, LH.LATCH2[5]);
|
||||
PIN_setOutputValue(pin_handle, D6, LH.LATCH2[6]);
|
||||
PIN_setOutputValue(pin_handle, D7, LH.LATCH2[7]);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
PIN_setOutputValue(&ZM_rst, latch_num, 1); // Turn on latch
|
||||
// CPUdelay(10);
|
||||
PIN_setOutputValue(&ZM_rst, latch_num, 0); // Turn off latch
|
||||
remove_elite_pin();
|
||||
ELITE15_SPI_HOLD();
|
||||
}
|
||||
|
||||
static void Init_Elite15_PIN () {
|
||||
InitLH();
|
||||
add_elite_pin();
|
||||
|
||||
PIN_setOutputValue(pin_handle, D0, 0);
|
||||
PIN_setOutputValue(pin_handle, D1, 0);
|
||||
PIN_setOutputValue(pin_handle, D2, 0);
|
||||
PIN_setOutputValue(pin_handle, D3, 0);
|
||||
PIN_setOutputValue(pin_handle, D4, 0);
|
||||
PIN_setOutputValue(pin_handle, D5, 0);
|
||||
PIN_setOutputValue(pin_handle, D6, 0);
|
||||
PIN_setOutputValue(pin_handle, D7, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD1, 1);
|
||||
PIN_setOutputValue(pin_handle, LOAD2, 1);
|
||||
CPUdelay(10);
|
||||
PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD2, 0);
|
||||
|
||||
|
||||
PIN_setOutputValue(pin_handle, D0, 0);
|
||||
PIN_setOutputValue(pin_handle, D1, 0);
|
||||
PIN_setOutputValue(pin_handle, D2, 0);
|
||||
PIN_setOutputValue(pin_handle, D3, 0);
|
||||
PIN_setOutputValue(pin_handle, D4, 1);
|
||||
PIN_setOutputValue(pin_handle, D5, 1);
|
||||
PIN_setOutputValue(pin_handle, D6, 1);
|
||||
PIN_setOutputValue(pin_handle, D7, 1);
|
||||
CPUdelay(10);
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 0);
|
||||
|
||||
remove_elite_pin();
|
||||
|
||||
// InitLH();
|
||||
// add_elite_pin();
|
||||
//
|
||||
// PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
// PIN_setOutputValue(pin_handle, LOAD1, 1);
|
||||
// PIN_setOutputValue(pin_handle, LOAD2, 1);
|
||||
// CPUdelay(10);
|
||||
// PIN_setOutputValue(pin_handle, D0, 0);
|
||||
// PIN_setOutputValue(pin_handle, D1, 0);
|
||||
// PIN_setOutputValue(pin_handle, D2, 0);
|
||||
// PIN_setOutputValue(pin_handle, D3, 0);
|
||||
// PIN_setOutputValue(pin_handle, D4, 0);
|
||||
// PIN_setOutputValue(pin_handle, D5, 0);
|
||||
// PIN_setOutputValue(pin_handle, D6, 0);
|
||||
// PIN_setOutputValue(pin_handle, D7, 0);
|
||||
// CPUdelay(10);
|
||||
// PIN_setOutputValue(pin_handle, LOAD0, 0);
|
||||
// PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
// PIN_setOutputValue(pin_handle, LOAD2, 0);
|
||||
//
|
||||
// remove_elite_pin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -4,6 +4,21 @@
|
||||
#ifndef EliteADC
|
||||
#define EliteADC
|
||||
|
||||
#include "Elite_PIN.h"
|
||||
#include "EliteSPI.h"
|
||||
|
||||
// ADC command, Elite will use these cmd to control ADC
|
||||
#define CMD_CURRENT_MEASURE 0xC5
|
||||
#define CMD_VOLT_MEASURE 0xD5
|
||||
#define CMD_DAC_MEASURE 0xE5
|
||||
#define CMD_BATTERY_MEASURE 0xF1
|
||||
|
||||
// controller command, these are command from control box
|
||||
#define ADC_CH_CURR 0x00
|
||||
#define ADC_CH_VIN 0x01
|
||||
#define ADC_CH_VOUT 0x02
|
||||
#define ADC_CH_BAT 0x03
|
||||
|
||||
/* for Elite1.5-re */
|
||||
// Iin theoretical boundary <2.67, 1.89~80, 63~2600, >1900 (uA)
|
||||
#define I_GAIN_SMALL_BOUNDARY 4000 // 4 uA = 4,000,000 pA
|
||||
@@ -16,7 +31,7 @@
|
||||
// Vin theoretical boundary <7, 5~200, >100 (mV)
|
||||
#define VIN_GAIN_SMALL_BOUNDARY 7000 // 7 mV = 7,000,000 nV
|
||||
#define VIN_GAIN_MID1_BOUNDARY1 5000 // 5 mV = 5,000,000 nV
|
||||
#define VIN_GAIN_MID1_BOUNDARY2 290000 // 290 mV = 290,000,000 nV
|
||||
#define VIN_GAIN_MID1_BOUNDARY2 300000 // 300 mV = 300,000,000 nV
|
||||
#define VIN_GAIN_LARGE_BOUNDARY 250000 // 250 mV = 250,000,000 nV
|
||||
|
||||
/*
|
||||
@@ -34,6 +49,7 @@
|
||||
|
||||
void IinADCGainCtrl(uint8_t IinADCLevel);
|
||||
void VinADCGainCtrl(uint8_t VinADCLevel);
|
||||
void read_adc_raw_data(uint8_t AdcChannel, uint8_t *rxbuf, uint8_t *txbuf);
|
||||
void AutoGainChangeIin(int32_t RealCurrent, uint16_t plot_type, uint16_t *no_rec_time);
|
||||
void AutoGainChangeVin(int32_t RealVin);
|
||||
|
||||
@@ -41,168 +57,300 @@ void AutoGainChangeVin(int32_t RealVin);
|
||||
= EliteADC.c =
|
||||
=============================================================================*/
|
||||
|
||||
static void __switch_lv0(uint8_t gain0_en, uint16_t plot, uint16_t *no_rec_cnt)
|
||||
static void __ADC_write(uint8_t ADCin, uint8_t *rxbuf, uint8_t *txbuf)
|
||||
{
|
||||
static int16_t gain_cnt = 0;
|
||||
/*
|
||||
* write SPI to get ADC value
|
||||
* This function can only define [15]~[8] through ADCin
|
||||
* [7]~[0] should always be 0b11101011
|
||||
*
|
||||
* [15] : SS, 0 = no effect, 1 = start work, default 0b0
|
||||
* [14]~[12] : MUX[2:0], default 0b000
|
||||
* [11]~[9] : PGA[2:0], default 0b010 = FSR is ±2.048
|
||||
* [8] : mode, 0 = continuous, 1 = one shot, default 0b1 (Power-down and single-shot mode )
|
||||
*
|
||||
* [7]~[5] : data rate, default 0b100 = 128 SPS
|
||||
* [4] : Temperature? default 0b0 = ADC mode
|
||||
* [3] : Pullup enable, default 0b1 = Pullup resistor enabled
|
||||
* [2]~[1] : NOP, default 0b01
|
||||
* [0] : reserved, default 0b1
|
||||
*
|
||||
*/
|
||||
uint8_t *rx = rxbuf;
|
||||
uint8_t *tx = txbuf;
|
||||
|
||||
// tx[0] = 0b00000101;
|
||||
for (int i=0; i<SPI_ADC_SIZE; i++) {
|
||||
tx[i] = 0;
|
||||
rx[i] = 0;
|
||||
|
||||
}
|
||||
|
||||
tx[0] = ADCin;
|
||||
tx[1] = 0b11101011;
|
||||
|
||||
ADC_SPI(2, tx, rx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __ADC_read(uint8_t *rxbuf, uint8_t *txbuf)
|
||||
{
|
||||
/*
|
||||
* read SPI to get ADC value
|
||||
*/
|
||||
uint8_t *rx = rxbuf;
|
||||
uint8_t *tx = txbuf;
|
||||
|
||||
for (int i=0; i<SPI_ADC_SIZE; i++) {
|
||||
tx[i] = 0;
|
||||
rx[i] = 0;
|
||||
|
||||
}
|
||||
|
||||
ADC_SPI(2, tx, rx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __ADC_ch_sel(uint8_t AdcChannel, uint8_t *rxbuf, uint8_t *txbuf)
|
||||
{
|
||||
/*
|
||||
* choise ADC channel to write
|
||||
*
|
||||
* set ADC parameter
|
||||
* 0xC1~F1 = reading AIN0~AIN3. Using FSR+-6V, resolution = 187.5uV
|
||||
* 0xC5~F5 = reading AIN0~AIN3. Using FSR+-2V, resolution = 62.5 uV
|
||||
*
|
||||
* ADCChannel == ADC_CH_CURR: - AINp is AIN0; AINn is GND
|
||||
* - measure AIN0, which is a current measure
|
||||
* == ADC_CH_VIN: - AINp is AIN1; AINn is GND
|
||||
* - AIN1, which is a volt measure
|
||||
* == ADC_CH_VOUT: - AINp is AIN2; AINn is GND
|
||||
* - AIN2, measure DAC voltage (Note that this is NOT DAC real output value!!)
|
||||
* == ADC_CH_BAT: - measure battery volt
|
||||
*
|
||||
*/
|
||||
|
||||
uint8_t ch = AdcChannel;
|
||||
uint8_t *rx = rxbuf;
|
||||
uint8_t *tx = txbuf;
|
||||
|
||||
switch (ch) {
|
||||
case ADC_CH_CURR:
|
||||
__ADC_write(CMD_CURRENT_MEASURE, rx, tx);
|
||||
break;
|
||||
|
||||
case ADC_CH_VIN:
|
||||
__ADC_write(CMD_VOLT_MEASURE, rx, tx);
|
||||
break;
|
||||
|
||||
|
||||
case ADC_CH_VOUT:
|
||||
__ADC_write(CMD_DAC_MEASURE, rx, tx);
|
||||
break;
|
||||
|
||||
case ADC_CH_BAT:
|
||||
__ADC_write(CMD_BATTERY_MEASURE, rx, tx);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __read_ADC_value(uint8_t AdcChannel, uint8_t *rxbuf, uint8_t *txbuf)
|
||||
{
|
||||
uint8_t ch = AdcChannel;
|
||||
uint8_t *rx = rxbuf;
|
||||
uint8_t *tx = txbuf;
|
||||
|
||||
// Read data twice since the first data we get is previous data
|
||||
__ADC_ch_sel(ch, rx, tx);
|
||||
__ADC_read(rx, tx);
|
||||
|
||||
__ADC_ch_sel(ch, rx, tx);
|
||||
__ADC_read(rx, tx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __reset_i_gain_cnt(int16_t *I_100R_cnt, int16_t *I_3K_cnt, int16_t *I_100K_cnt, int16_t *I_3M_cnt)
|
||||
{
|
||||
*I_3M_cnt = 0;
|
||||
*I_100K_cnt = 0;
|
||||
*I_3K_cnt = 0;
|
||||
*I_100R_cnt = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __switch_lv0(uint8_t gain0_en, uint16_t plot, int16_t *I_GAIN_3M_counter, uint16_t *no_rec_cnt)
|
||||
{
|
||||
int16_t *gain_cnt = I_GAIN_3M_counter;
|
||||
uint16_t *no_rec = no_rec_cnt;
|
||||
uint8_t gain_en = gain0_en;
|
||||
uint16_t pt = plot;
|
||||
|
||||
if (gain_en == 0)
|
||||
return;
|
||||
if (gain_en) {
|
||||
*gain_cnt += 1;
|
||||
|
||||
gain_cnt++;
|
||||
if (*gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_3M;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
*gain_cnt = 0;
|
||||
|
||||
if (gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_3M;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
gain_cnt = 0;
|
||||
if (pt == IIN_VIN_VOUT_PLOT) {
|
||||
*no_rec = CNT_H2L_IIN_VIN_VOUT_PLOT;
|
||||
|
||||
if (pt == IIN_VIN_VOUT_PLOT)
|
||||
*no_rec = CNT_H2L_IIN_VIN_VOUT_PLOT;
|
||||
} else if (pt == IIN_VIN_PLOT) {
|
||||
*no_rec = CNT_H2L_IIN_VIN_PLOT;
|
||||
|
||||
else if (pt == IIN_VIN_PLOT)
|
||||
*no_rec = CNT_H2L_IIN_VIN_PLOT;
|
||||
} else if (pt == IT_PLOT) {
|
||||
*no_rec = CNT_H2L_IT_PLOT;
|
||||
|
||||
else if (pt == IT_PLOT)
|
||||
*no_rec = CNT_H2L_IT_PLOT;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __switch_lv3(uint8_t gain3_en, uint16_t plot, uint16_t *no_rec_cnt)
|
||||
static void __switch_lv3(uint8_t gain3_en, uint16_t plot, int16_t *I_GAIN_100R_counter, uint16_t *no_rec_cnt)
|
||||
{
|
||||
static int16_t gain_cnt = 0;
|
||||
int16_t *gain_cnt = I_GAIN_100R_counter;
|
||||
uint16_t *no_rec = no_rec_cnt;
|
||||
uint8_t gain_en = gain3_en;
|
||||
|
||||
if (gain_en == 0)
|
||||
return;
|
||||
if (gain_en) {
|
||||
*gain_cnt += 1;
|
||||
|
||||
gain_cnt++;
|
||||
if (gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_100R;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
if (*gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_100R;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
*gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __large_switch_lv1(uint8_t gain1_en, uint16_t plot, uint16_t *no_rec_cnt)
|
||||
static void __large_switch_lv1(uint8_t gain1_en, uint16_t plot, int16_t *I_GAIN_100K_counter, uint16_t *no_rec_cnt)
|
||||
{
|
||||
static int16_t gain_cnt = 0;
|
||||
int16_t *gain_cnt = I_GAIN_100K_counter;
|
||||
uint16_t *no_rec = no_rec_cnt;
|
||||
uint8_t gain_en = gain1_en;
|
||||
uint16_t pt = plot;
|
||||
|
||||
if (gain_en == 0)
|
||||
return;
|
||||
if (gain_en) {
|
||||
*gain_cnt += 1;
|
||||
|
||||
gain_cnt++;
|
||||
if (*gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_100K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
*gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
|
||||
if (gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_100K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
if (pt == IIN_VIN_VOUT_PLOT) {
|
||||
*no_rec = CNT_H2L_IIN_VIN_VOUT_PLOT;
|
||||
|
||||
if (pt == IIN_VIN_VOUT_PLOT)
|
||||
*no_rec = CNT_H2L_IIN_VIN_VOUT_PLOT;
|
||||
} else if (pt == IIN_VIN_PLOT) {
|
||||
*no_rec = CNT_H2L_IIN_VIN_PLOT;
|
||||
|
||||
else if (pt == IIN_VIN_PLOT)
|
||||
*no_rec = CNT_H2L_IIN_VIN_PLOT;
|
||||
} else if (pt == IT_PLOT) {
|
||||
*no_rec = CNT_H2L_IT_PLOT;
|
||||
|
||||
else if (pt == IT_PLOT)
|
||||
*no_rec = CNT_H2L_IT_PLOT;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __small_switch_lv1(uint8_t gain1_en, uint16_t plot, uint16_t *no_rec_cnt)
|
||||
static void __small_switch_lv1(uint8_t gain1_en, uint16_t plot, int16_t *I_GAIN_100K_counter, uint16_t *no_rec_cnt)
|
||||
{
|
||||
static int16_t gain_cnt = 0;
|
||||
int16_t *gain_cnt = I_GAIN_100K_counter;
|
||||
uint16_t *no_rec = no_rec_cnt;
|
||||
uint8_t gain_en = gain1_en;
|
||||
uint16_t pt = plot;
|
||||
|
||||
if (gain_en == 0)
|
||||
return;
|
||||
if (gain_en) {
|
||||
*gain_cnt += 1;
|
||||
|
||||
gain_cnt++;
|
||||
if (*gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_100K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
*gain_cnt = 0;
|
||||
|
||||
if (gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_100K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
gain_cnt = 0;
|
||||
if (pt == IIN_VIN_VOUT_PLOT) {
|
||||
*no_rec = CNT_L2H_IIN_VIN_VOUT_PLOT;
|
||||
|
||||
if (pt == IIN_VIN_VOUT_PLOT)
|
||||
*no_rec = CNT_L2H_IIN_VIN_VOUT_PLOT;
|
||||
} else if (pt == IIN_VIN_PLOT) {
|
||||
*no_rec = CNT_L2H_IIN_VIN_PLOT;
|
||||
|
||||
else if (pt == IIN_VIN_PLOT)
|
||||
*no_rec = CNT_L2H_IIN_VIN_PLOT;
|
||||
|
||||
else if (pt == IT_PLOT)
|
||||
*no_rec = CNT_L2H_IT_PLOT;
|
||||
} else if (pt == IT_PLOT) {
|
||||
*no_rec = CNT_L2H_IT_PLOT;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __large_switch_lv2(uint8_t gain2_en, uint16_t plot, uint16_t *no_rec_cnt)
|
||||
static void __large_switch_lv2(uint8_t gain2_en, uint16_t plot, int16_t *I_GAIN_3K_counter, uint16_t *no_rec_cnt)
|
||||
{
|
||||
static int16_t gain_cnt = 0;
|
||||
int16_t *gain_cnt = I_GAIN_3K_counter;
|
||||
uint16_t *no_rec = no_rec_cnt;
|
||||
uint8_t gain_en = gain2_en;
|
||||
uint16_t pt = plot;
|
||||
|
||||
if (gain_en == 0)
|
||||
return;
|
||||
if (gain_en) {
|
||||
*gain_cnt += 1;
|
||||
|
||||
gain_cnt++;
|
||||
if (*gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_3K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
*gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
|
||||
if (gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_3K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
if (pt == IIN_VIN_VOUT_PLOT) {
|
||||
*no_rec = CNT_H2L_IIN_VIN_VOUT_PLOT;
|
||||
|
||||
if (pt == IIN_VIN_VOUT_PLOT)
|
||||
*no_rec = CNT_H2L_IIN_VIN_VOUT_PLOT;
|
||||
} else if (pt == IIN_VIN_PLOT) {
|
||||
*no_rec = CNT_H2L_IIN_VIN_PLOT;
|
||||
|
||||
else if (pt == IIN_VIN_PLOT)
|
||||
*no_rec = CNT_H2L_IIN_VIN_PLOT;
|
||||
|
||||
else if (pt == IT_PLOT)
|
||||
*no_rec = CNT_H2L_IT_PLOT;
|
||||
} else if (pt == IT_PLOT) {
|
||||
*no_rec = CNT_H2L_IT_PLOT;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __small_switch_lv2(uint8_t gain2_en, uint16_t plot, uint16_t *no_rec_cnt)
|
||||
static void __small_switch_lv2(uint8_t gain2_en, uint16_t plot, int16_t *I_GAIN_3K_counter, uint16_t *no_rec_cnt)
|
||||
{
|
||||
static int16_t gain_cnt = 0;
|
||||
int16_t *gain_cnt = I_GAIN_3K_counter;
|
||||
uint16_t *no_rec = no_rec_cnt;
|
||||
uint8_t gain_en = gain2_en;
|
||||
|
||||
if (gain_en == 0)
|
||||
return;
|
||||
if (gain_en) {
|
||||
*gain_cnt += 1;
|
||||
|
||||
gain_cnt++;
|
||||
if (*gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_3K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
*gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
|
||||
if (gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_3K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -210,42 +358,51 @@ static void __small_switch_lv2(uint8_t gain2_en, uint16_t plot, uint16_t *no_rec
|
||||
|
||||
void IinADCGainCtrl(uint8_t IinADCLevel)
|
||||
{
|
||||
if (IinADCLevel>= 4)
|
||||
return;
|
||||
/* hardware need open before close, so don't change position*/
|
||||
if (IinADCLevel == 0) {
|
||||
// ADC gain level = 0, using 2M resister
|
||||
update_latch_stat(E_LATCH_I_LARGE_ON, 0);
|
||||
update_latch_stat(E_LATCH_I_MID_ON, 0);
|
||||
update_latch_stat(E_LATCH_I_SMALL_ON, 0);
|
||||
latch_multi_ctrl();
|
||||
// ADC gain level = 0, using 3M resister
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 0);
|
||||
PIN15_setOutputValue(Turnon_I_MID, 0);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 0);
|
||||
|
||||
} else if (IinADCLevel == 1) {
|
||||
// ADC gain level = 1, using 91K resister
|
||||
update_latch_stat(E_LATCH_I_SMALL_ON, 1); /* need open first */
|
||||
update_latch_stat(E_LATCH_I_LARGE_ON, 0);
|
||||
update_latch_stat(E_LATCH_I_MID_ON, 0);
|
||||
latch_multi_ctrl();
|
||||
// ADC gain level = 1, using 100K resister
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 1); /* need open first */
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 0);
|
||||
PIN15_setOutputValue(Turnon_I_MID, 0);
|
||||
|
||||
} else if (IinADCLevel == 2) {
|
||||
// ADC gain level = 2, using 4.3K resister
|
||||
update_latch_stat(E_LATCH_I_MID_ON, 1); /* need open first */
|
||||
update_latch_stat(E_LATCH_I_LARGE_ON, 0);
|
||||
update_latch_stat(E_LATCH_I_SMALL_ON, 0);
|
||||
latch_multi_ctrl();
|
||||
// ADC gain level = 2, using 3K resister
|
||||
PIN15_setOutputValue(Turnon_I_MID, 1); /* need open first */
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 0);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 0);
|
||||
|
||||
} else if (IinADCLevel == 3) {
|
||||
// ADC gain level = 3, using 200R resistor
|
||||
update_latch_stat(E_LATCH_I_LARGE_ON, 1); /* need open first */
|
||||
update_latch_stat(E_LATCH_I_MID_ON, 0);
|
||||
update_latch_stat(E_LATCH_I_SMALL_ON, 0);
|
||||
latch_multi_ctrl();
|
||||
// ADC gain level = 3, using 100R resistor
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 1); /* need open first */
|
||||
PIN15_setOutputValue(Turnon_I_MID, 0);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 0);
|
||||
|
||||
} else if (IinADCLevel == 4) {
|
||||
// ADC gain level = 3, auto gain (using 100R resister)
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 1); /* need open first */
|
||||
PIN15_setOutputValue(Turnon_I_MID, 0);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 0);
|
||||
|
||||
} else {
|
||||
// default using 100R resister
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 1); /* need open first */
|
||||
PIN15_setOutputValue(Turnon_I_MID, 0);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 0);
|
||||
|
||||
}
|
||||
|
||||
if (IinADCLevel == 0 || IinADCLevel == 1 || IinADCLevel == 2 || IinADCLevel == 3) {
|
||||
lastIinADCGainLevel = IinADCLevel;
|
||||
|
||||
} else {
|
||||
lastIinADCGainLevel = 3;
|
||||
|
||||
}
|
||||
|
||||
curr_rec_en = false;
|
||||
@@ -255,32 +412,38 @@ void IinADCGainCtrl(uint8_t IinADCLevel)
|
||||
|
||||
void VinADCGainCtrl(uint8_t VinADCLevel)
|
||||
{
|
||||
if (VinADCLevel >= 3)
|
||||
return;
|
||||
|
||||
/* hardware need open before close, so don't change position*/
|
||||
if (VinADCLevel == 0) {
|
||||
// Vin ADC gain level = 0, using 1M resister
|
||||
update_latch_stat(E_LATCH_V_SMALL_ON, 0);
|
||||
update_latch_stat(E_LATCH_V_MID_ON, 0);
|
||||
latch_multi_ctrl();
|
||||
PIN15_setOutputValue(Turnon_V_SMALL, 0);
|
||||
PIN15_setOutputValue(Turnon_V_MID, 0);
|
||||
|
||||
} else if (VinADCLevel == 1) {
|
||||
// Vin ADC gain level = 1, using 30K resister
|
||||
update_latch_stat(E_LATCH_V_MID_ON, 1); /* need open first */
|
||||
update_latch_stat(E_LATCH_V_SMALL_ON, 0);
|
||||
latch_multi_ctrl();
|
||||
PIN15_setOutputValue(Turnon_V_MID, 1); /* need open first */
|
||||
PIN15_setOutputValue(Turnon_V_SMALL, 0);
|
||||
|
||||
} else if (VinADCLevel == 2) {
|
||||
// Vin ADC gain level = 2, using 1K resister
|
||||
update_latch_stat(E_LATCH_V_SMALL_ON, 1); /* need open first */
|
||||
update_latch_stat(E_LATCH_V_MID_ON, 0);
|
||||
latch_multi_ctrl();
|
||||
PIN15_setOutputValue(Turnon_V_SMALL, 1); /* need open first */
|
||||
PIN15_setOutputValue(Turnon_V_MID, 0);
|
||||
|
||||
} else if (VinADCLevel == 3) {
|
||||
// Vin ADC gain level = 3, auto gain (using 1K resister)
|
||||
PIN15_setOutputValue(Turnon_V_SMALL, 1); /* need open first */
|
||||
PIN15_setOutputValue(Turnon_V_MID, 0);
|
||||
|
||||
} else {
|
||||
// default using 1K resister
|
||||
PIN15_setOutputValue(Turnon_V_SMALL, 1); /* need open first */
|
||||
PIN15_setOutputValue(Turnon_V_MID, 0);
|
||||
|
||||
}
|
||||
|
||||
if (VinADCLevel == 0 || VinADCLevel == 1 || VinADCLevel == 2) {
|
||||
lastVinADCGainLv = VinADCLevel;
|
||||
} else {
|
||||
lastVinADCGainLv = 2;
|
||||
}
|
||||
|
||||
volt_rec_en = false;
|
||||
@@ -288,6 +451,38 @@ void VinADCGainCtrl(uint8_t VinADCLevel)
|
||||
return;
|
||||
}
|
||||
|
||||
void read_adc_raw_data(uint8_t AdcChannel, uint8_t *rxbuf, uint8_t *txbuf)
|
||||
{
|
||||
uint8_t ch = AdcChannel;
|
||||
uint8_t *rx = rxbuf;
|
||||
uint8_t *tx = txbuf;
|
||||
|
||||
if (ch == RIS_ADC_IIN) {
|
||||
__read_ADC_value(ADC_CH_CURR, rx, tx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ch == RIS_ADC_VIN) {
|
||||
__read_ADC_value(ADC_CH_VIN, rx, tx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ch == RIS_ADC_VOUT) {
|
||||
__read_ADC_value(ADC_CH_VOUT, rx, tx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ch == RIS_ADC_BAT) {
|
||||
__read_ADC_value(ADC_CH_BAT, rx, tx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void AutoGainChangeIin(int32_t RealCurrent, uint16_t plot_type, uint16_t *no_rec_time)
|
||||
{
|
||||
@@ -303,6 +498,11 @@ void AutoGainChangeIin(int32_t RealCurrent, uint16_t plot_type, uint16_t *no_rec
|
||||
uint16_t plot = plot_type;
|
||||
uint16_t *skip_time = no_rec_time;
|
||||
|
||||
static int16_t I_100R_cnt = 0;
|
||||
static int16_t I_3K_cnt = 0;
|
||||
static int16_t I_100K_cnt = 0;
|
||||
static int16_t I_3M_cnt = 0;
|
||||
|
||||
int64_t small_gain = I_GAIN_SMALL_BOUNDARY;
|
||||
int64_t mid1_gain1 = I_GAIN_MID1_BOUNDARY1;
|
||||
int64_t mid1_gain2 = I_GAIN_MID1_BOUNDARY2;
|
||||
@@ -318,15 +518,18 @@ void AutoGainChangeIin(int32_t RealCurrent, uint16_t plot_type, uint16_t *no_rec
|
||||
if (instru.IinADCGainLv == I_GAIN_100R) {
|
||||
if (curr < large_gain && curr > -1 * large_gain) {
|
||||
if (curr < mid1_gain1 && curr > -1 * mid1_gain1) {
|
||||
__switch_lv0(gain0_en, plot, skip_time);
|
||||
__switch_lv0(gain0_en, plot, &I_3M_cnt, skip_time);
|
||||
|
||||
} else if (curr < mid2_gain1 && curr > -1 * mid2_gain1) {
|
||||
__large_switch_lv1(gain1_en, plot, skip_time);
|
||||
__large_switch_lv1(gain1_en, plot, &I_100K_cnt, skip_time);
|
||||
|
||||
} else {
|
||||
__large_switch_lv2(gain2_en, plot, skip_time);
|
||||
__large_switch_lv2(gain2_en, plot, &I_3K_cnt, skip_time);
|
||||
|
||||
}
|
||||
} else {
|
||||
__reset_i_gain_cnt(&I_100R_cnt, &I_3K_cnt, &I_100K_cnt, &I_3M_cnt);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -334,16 +537,19 @@ void AutoGainChangeIin(int32_t RealCurrent, uint16_t plot_type, uint16_t *no_rec
|
||||
|
||||
if (instru.IinADCGainLv == I_GAIN_3K) {
|
||||
if (curr > mid2_gain2 || curr < -1 * mid2_gain2) {
|
||||
__switch_lv3(gain3_en, plot, skip_time);
|
||||
__switch_lv3(gain3_en, plot, &I_100R_cnt, skip_time);
|
||||
|
||||
} else if (curr < mid2_gain1 && curr > -1 * mid2_gain1) {
|
||||
if (curr < mid1_gain1 && curr > -1 * mid1_gain1) {
|
||||
__switch_lv0(gain0_en, plot, skip_time);
|
||||
__switch_lv0(gain0_en, plot, &I_3M_cnt, skip_time);
|
||||
|
||||
} else {
|
||||
__large_switch_lv1(gain1_en, plot, skip_time);
|
||||
__large_switch_lv1(gain1_en, plot, &I_100K_cnt, skip_time);
|
||||
|
||||
}
|
||||
} else {
|
||||
__reset_i_gain_cnt(&I_100R_cnt, &I_3K_cnt, &I_100K_cnt, &I_3M_cnt);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -351,16 +557,19 @@ void AutoGainChangeIin(int32_t RealCurrent, uint16_t plot_type, uint16_t *no_rec
|
||||
|
||||
if (instru.IinADCGainLv == I_GAIN_100K) {
|
||||
if (curr < mid1_gain1 && curr > -1 * mid1_gain1) {
|
||||
__switch_lv0(gain0_en, plot, skip_time);
|
||||
__switch_lv0(gain0_en, plot, &I_3M_cnt, skip_time);
|
||||
|
||||
} else if (curr > mid1_gain2 || curr < -1 * mid1_gain2) {
|
||||
if (curr > mid2_gain2 || curr < -1 * mid2_gain2) {
|
||||
__switch_lv3(gain3_en, plot, skip_time);
|
||||
__switch_lv3(gain3_en, plot, &I_100R_cnt, skip_time);
|
||||
|
||||
} else {
|
||||
__small_switch_lv2(gain2_en, plot, skip_time);
|
||||
__small_switch_lv2(gain2_en, plot, &I_3K_cnt, skip_time);
|
||||
|
||||
}
|
||||
} else {
|
||||
__reset_i_gain_cnt(&I_100R_cnt, &I_3K_cnt, &I_100K_cnt, &I_3M_cnt);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -369,15 +578,18 @@ void AutoGainChangeIin(int32_t RealCurrent, uint16_t plot_type, uint16_t *no_rec
|
||||
if (instru.IinADCGainLv == I_GAIN_3M) {
|
||||
if (curr > small_gain || curr < -1 * small_gain) {
|
||||
if (curr > mid2_gain2 || curr < -1 * mid2_gain2) {
|
||||
__switch_lv3(gain3_en, plot, skip_time);
|
||||
__switch_lv3(gain3_en, plot, &I_100R_cnt, skip_time);
|
||||
|
||||
} else if (curr > mid1_gain2 || curr < -1 * mid1_gain2) {
|
||||
__small_switch_lv2(gain2_en, plot, skip_time);
|
||||
__small_switch_lv2(gain2_en, plot, &I_3K_cnt, skip_time);
|
||||
|
||||
} else {
|
||||
__small_switch_lv1(gain1_en, plot, skip_time);
|
||||
__small_switch_lv1(gain1_en, plot, &I_100K_cnt, skip_time);
|
||||
|
||||
}
|
||||
} else {
|
||||
__reset_i_gain_cnt(&I_100R_cnt, &I_3K_cnt, &I_100K_cnt, &I_3M_cnt);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -4,29 +4,55 @@
|
||||
|
||||
static bool DACReset;
|
||||
|
||||
#ifdef ELITE_VERSION_1_4
|
||||
#define DACCLS 0x02
|
||||
#define DACOUT 0x31
|
||||
|
||||
static uint16_t DAC_outputV(uint16_t voltLV) {
|
||||
// C = command, X = don't care, D = data
|
||||
// CCCC CCCC = command
|
||||
// DDDD DDDD = v1
|
||||
// DDDD DDDD = v2
|
||||
|
||||
// command
|
||||
// 0x02 = clear
|
||||
// 0x31 = output voltage
|
||||
|
||||
uint8_t v1, v2 = 0;
|
||||
v1 = (uint8_t) ((voltLV & 0xFF00) >> 8);
|
||||
v2 = (uint8_t) (voltLV & 0x00FF);
|
||||
|
||||
spi_DACtxbuf[0] = DACOUT;
|
||||
spi_DACtxbuf[1] = v1;
|
||||
spi_DACtxbuf[2] = v2;
|
||||
|
||||
DAC_SPI(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
|
||||
|
||||
return voltLV;
|
||||
}
|
||||
|
||||
static void VoutGainControl(uint8_t VOUTLevel){
|
||||
if(VOUTLevel == 0){
|
||||
// VOUT gain level = 0, using 240K resister
|
||||
latch_single_ctrl(E_LATCH_VOUT_SMALL_ON, 0);
|
||||
PIN15_setOutputValue(Turnon_VOUT_SMALL, 0);
|
||||
}
|
||||
else if(VOUTLevel == 1){
|
||||
// VOUT gain level = 1, using 15K resister
|
||||
latch_single_ctrl(E_LATCH_VOUT_SMALL_ON, 1);
|
||||
PIN15_setOutputValue(Turnon_VOUT_SMALL, 1);
|
||||
}
|
||||
else if(VOUTLevel == 2){
|
||||
// VOUT gain level = 2, using 15K resister
|
||||
latch_single_ctrl(E_LATCH_VOUT_SMALL_ON, 1);
|
||||
PIN15_setOutputValue(Turnon_VOUT_SMALL, 1);
|
||||
}
|
||||
else{
|
||||
// default using 15K resister
|
||||
latch_single_ctrl(E_LATCH_VOUT_SMALL_ON, 1);
|
||||
PIN15_setOutputValue(Turnon_VOUT_SMALL, 1);
|
||||
}
|
||||
volt_rec_en = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int32_t User2Real(uint16_t UserCode){
|
||||
/* transfer usercode to real voltage value (mV) */
|
||||
return (int32_t)((UserCode - 25000) / 5);
|
||||
@@ -44,6 +70,11 @@ static void AutoGainChangeVout(int32_t userCode){
|
||||
// switch to 1 level volt(small) 15K
|
||||
// switch to 2 level volt(large) 240K
|
||||
|
||||
if(instru.VoutGainLv == VOUT_GAIN_AUTO){
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
}
|
||||
|
||||
if(instru.VoutGainLv == VOUT_GAIN_15K){
|
||||
if(RealVolt > DAC_VOUT_GAIN_LARGE_BOUNDARY || RealVolt < -1 * DAC_VOUT_GAIN_LARGE_BOUNDARY){
|
||||
// switch to 2 level volt(large)
|
||||
|
||||
@@ -1431,6 +1431,40 @@ struct correction_ctx_t Correction = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_F0_68
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6267,
|
||||
.ADC_volt[0].offset = (-102028002),
|
||||
|
||||
.ADC_volt[1].coeff = 215634,
|
||||
.ADC_volt[1].offset = (-3517189151),
|
||||
|
||||
.ADC_volt[2].coeff = 6281201,
|
||||
.ADC_volt[2].offset = (-102431111612),
|
||||
|
||||
.ADC_current[0].coeff = 3117736,
|
||||
.ADC_current[0].offset = (-50837353744),
|
||||
|
||||
.ADC_current[1].coeff = 71655674,
|
||||
.ADC_current[1].offset = (-1168489519122),
|
||||
|
||||
.ADC_current[2].coeff = 1454231926,
|
||||
.ADC_current[2].offset = (-23713068124450),
|
||||
|
||||
.ADC_current[3].coeff = 30667117763,
|
||||
.ADC_current[3].offset = (-500020256785398),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10547916),
|
||||
.Usercode2DAC[0].offset = 583186274643,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-179389854),
|
||||
.Usercode2DAC[1].offset = 4804853449970,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6244452),
|
||||
.ADC_Vout_volt[0].offset = 102103245637,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_E7_2D
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6293,
|
||||
@@ -1567,6 +1601,40 @@ struct correction_ctx_t Correction = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_A4_DA_32_D4_E8_0B
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6266,
|
||||
.ADC_volt[0].offset = (-102510450),
|
||||
|
||||
.ADC_volt[1].coeff = 215104,
|
||||
.ADC_volt[1].offset = (-3516281969),
|
||||
|
||||
.ADC_volt[2].coeff = 6263495,
|
||||
.ADC_volt[2].offset = (-102366794643),
|
||||
|
||||
.ADC_current[0].coeff = 3134531,
|
||||
.ADC_current[0].offset = (-51203208091),
|
||||
|
||||
.ADC_current[1].coeff = 71817037,
|
||||
.ADC_current[1].offset = (-1173217647997),
|
||||
|
||||
.ADC_current[2].coeff = 1462086757,
|
||||
.ADC_current[2].offset = (-23883222331602),
|
||||
|
||||
.ADC_current[3].coeff = 30700669121,
|
||||
.ADC_current[3].offset = (-501453504657573),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10544373),
|
||||
.Usercode2DAC[0].offset = 584350176185,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178475043),
|
||||
.Usercode2DAC[1].offset = 4783237161078,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6261766),
|
||||
.ADC_Vout_volt[0].offset = 101995687562,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_E7_6E
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6277,
|
||||
@@ -1601,6 +1669,41 @@ struct correction_ctx_t Correction = {
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BOARD_A4_DA_32_D4_E7_34
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6271,
|
||||
.ADC_volt[0].offset = (-101634397),
|
||||
|
||||
.ADC_volt[1].coeff = 215437,
|
||||
.ADC_volt[1].offset = (-3491402418),
|
||||
|
||||
.ADC_volt[2].coeff = 6274038,
|
||||
.ADC_volt[2].offset = (-101654277903),
|
||||
|
||||
.ADC_current[0].coeff = 3117355,
|
||||
.ADC_current[0].offset = (-50497924237),
|
||||
|
||||
.ADC_current[1].coeff = 71774648,
|
||||
.ADC_current[1].offset = (-1162852302911),
|
||||
|
||||
.ADC_current[2].coeff = 1452664130,
|
||||
.ADC_current[2].offset = (-23532284128026),
|
||||
|
||||
.ADC_current[3].coeff = 30668623144,
|
||||
.ADC_current[3].offset = (-496799430136624),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10573209),
|
||||
.Usercode2DAC[0].offset = 582781434937,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-179369334),
|
||||
.Usercode2DAC[1].offset = 4803319819942,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6260515),
|
||||
.ADC_Vout_volt[0].offset = 101238248026,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_1
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6315,
|
||||
@@ -1612,60 +1715,60 @@ struct correction_ctx_t Correction = {
|
||||
.ADC_volt[2].coeff = 6308429,
|
||||
.ADC_volt[2].offset = (-102635617764),
|
||||
|
||||
.ADC_current[0].coeff = 3156315,
|
||||
.ADC_current[0].offset = (-51438344681),
|
||||
.ADC_current[0].coeff = 3156898,
|
||||
.ADC_current[0].offset = (-51438927976),
|
||||
|
||||
.ADC_current[1].coeff = 72304608,
|
||||
.ADC_current[1].offset = (-1178438121249),
|
||||
.ADC_current[1].coeff = 72301623,
|
||||
.ADC_current[1].offset = (-1178167981915),
|
||||
|
||||
.ADC_current[2].coeff = 1464191587,
|
||||
.ADC_current[2].offset = (-23862163505975),
|
||||
.ADC_current[2].coeff = 1464429161,
|
||||
.ADC_current[2].offset = (-23862375612241),
|
||||
|
||||
.ADC_current[3].coeff = 30888240646,
|
||||
.ADC_current[3].offset = (-503408729801573),
|
||||
.ADC_current[3].coeff = 30894502102,
|
||||
.ADC_current[3].offset = (-503359960019922),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10538401),
|
||||
.Usercode2DAC[0].offset = 583999264775,
|
||||
.Usercode2DAC[0].coeff = (-10538970),
|
||||
.Usercode2DAC[0].offset = 583952997041,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-177550021),
|
||||
.Usercode2DAC[1].offset = 4759896184151,
|
||||
.Usercode2DAC[1].coeff = (-177570442),
|
||||
.Usercode2DAC[1].offset = 4760354859768,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6243651),
|
||||
.ADC_Vout_volt[0].offset = 102210944196,
|
||||
.ADC_Vout_volt[0].coeff = (-6241858),
|
||||
.ADC_Vout_volt[0].offset = 102166686340,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_2
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6230,
|
||||
.ADC_volt[0].offset = (-101437544),
|
||||
.ADC_volt[0].coeff = 6234,
|
||||
.ADC_volt[0].offset = (-101493321),
|
||||
|
||||
.ADC_volt[1].coeff = 213934,
|
||||
.ADC_volt[1].offset = (-3484584765),
|
||||
.ADC_volt[1].coeff = 213971,
|
||||
.ADC_volt[1].offset = (-3485112171),
|
||||
|
||||
.ADC_volt[2].coeff = 6246732,
|
||||
.ADC_volt[2].offset = (-101725090674),
|
||||
.ADC_volt[2].coeff = 6247968,
|
||||
.ADC_volt[2].offset = (-101739720097),
|
||||
|
||||
.ADC_current[0].coeff = 3112908,
|
||||
.ADC_current[0].offset = (-50655254352),
|
||||
.ADC_current[0].coeff = 3112362,
|
||||
.ADC_current[0].offset = (-50644603940),
|
||||
|
||||
.ADC_current[1].coeff = 71720599,
|
||||
.ADC_current[1].offset = (-1167260727022),
|
||||
.ADC_current[1].coeff = 71727943,
|
||||
.ADC_current[1].offset = (-1167221793306),
|
||||
|
||||
.ADC_current[2].coeff = 1453192668,
|
||||
.ADC_current[2].offset = (-23648559112492),
|
||||
.ADC_current[2].coeff = 1453074599,
|
||||
.ADC_current[2].offset = (-23645424090461),
|
||||
|
||||
.ADC_current[3].coeff = 30628424312,
|
||||
.ADC_current[3].offset = (-498473690168297),
|
||||
.ADC_current[3].coeff = 30629831832,
|
||||
.ADC_current[3].offset = (-498401716288422),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10541755),
|
||||
.Usercode2DAC[0].offset = 582943515821,
|
||||
.Usercode2DAC[0].coeff = (-10541600),
|
||||
.Usercode2DAC[0].offset = 582903765879,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178547678),
|
||||
.Usercode2DAC[1].offset = 4783742988037,
|
||||
.Usercode2DAC[1].coeff = (-178545712),
|
||||
.Usercode2DAC[1].offset = 4783666004036,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6261279),
|
||||
.ADC_Vout_volt[0].offset = 102062559721,
|
||||
.ADC_Vout_volt[0].coeff = (-6260712),
|
||||
.ADC_Vout_volt[0].offset = 102045664022,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1714,17 +1817,17 @@ struct correction_ctx_t Correction = {
|
||||
.ADC_volt[2].coeff = 6272056,
|
||||
.ADC_volt[2].offset = (-101898197885),
|
||||
|
||||
.ADC_current[0].coeff = 3122581,
|
||||
.ADC_current[0].offset = (-50990772435),
|
||||
.ADC_current[0].coeff = 3120583,
|
||||
.ADC_current[0].offset = (-50952018649),
|
||||
|
||||
.ADC_current[1].coeff = 71783278,
|
||||
.ADC_current[1].offset = (-1172259135178),
|
||||
.ADC_current[1].coeff = 71782053,
|
||||
.ADC_current[1].offset = (-1172185993613),
|
||||
|
||||
.ADC_current[2].coeff = 1458649016,
|
||||
.ADC_current[2].offset = (-23817223539623),
|
||||
.ADC_current[2].coeff = 1455794482,
|
||||
.ADC_current[2].offset = (-23771014006994),
|
||||
|
||||
.ADC_current[3].coeff = 30694489296,
|
||||
.ADC_current[3].offset = (-501242075218683),
|
||||
.ADC_current[3].coeff = 30680080834,
|
||||
.ADC_current[3].offset = (-500914481788232),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10497415),
|
||||
.Usercode2DAC[0].offset = 581646261432,
|
||||
@@ -1737,585 +1840,7 @@ struct correction_ctx_t Correction = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_5
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6237,
|
||||
.ADC_volt[0].offset = (-101855130),
|
||||
|
||||
.ADC_volt[1].coeff = 213703,
|
||||
.ADC_volt[1].offset = (-3491189842),
|
||||
|
||||
.ADC_volt[2].coeff = 6244405,
|
||||
.ADC_volt[2].offset = (-101986129186),
|
||||
|
||||
.ADC_current[0].coeff = 3130068,
|
||||
.ADC_current[0].offset = (-50984593111),
|
||||
|
||||
.ADC_current[1].coeff = 72080835,
|
||||
.ADC_current[1].offset = (-1174200131726),
|
||||
|
||||
.ADC_current[2].coeff = 1457082070,
|
||||
.ADC_current[2].offset = (-23733331223750),
|
||||
|
||||
.ADC_current[3].coeff = 30696257882,
|
||||
.ADC_current[3].offset = (-500026090255991),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10534133),
|
||||
.Usercode2DAC[0].offset = 581929808996,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178323512),
|
||||
.Usercode2DAC[1].offset = 4777303676874,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6258567),
|
||||
.ADC_Vout_volt[0].offset = 101427042471,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_6
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6313,
|
||||
.ADC_volt[0].offset = (-102797766),
|
||||
|
||||
.ADC_volt[1].coeff = 216580,
|
||||
.ADC_volt[1].offset = (-3528929783),
|
||||
|
||||
.ADC_volt[2].coeff = 6320430,
|
||||
.ADC_volt[2].offset = (-102965476465),
|
||||
|
||||
.ADC_current[0].coeff = 3107357,
|
||||
.ADC_current[0].offset = (-50583555853),
|
||||
|
||||
.ADC_current[1].coeff = 71314255,
|
||||
.ADC_current[1].offset = (-1160993950796),
|
||||
|
||||
.ADC_current[2].coeff = 1447582803,
|
||||
.ADC_current[2].offset = (-23564917012505),
|
||||
|
||||
.ADC_current[3].coeff = 30569895236,
|
||||
.ADC_current[3].offset = (-497665095915136),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10579871),
|
||||
.Usercode2DAC[0].offset = 586502855315,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178895152),
|
||||
.Usercode2DAC[1].offset = 4795005362039,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6273016),
|
||||
.ADC_Vout_volt[0].offset = 102363252317,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_7
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6261,
|
||||
.ADC_volt[0].offset = (-101829392),
|
||||
|
||||
.ADC_volt[1].coeff = 216264,
|
||||
.ADC_volt[1].offset = (-3516891018),
|
||||
|
||||
.ADC_volt[2].coeff = 6303328,
|
||||
.ADC_volt[2].offset = (-102474893054),
|
||||
|
||||
.ADC_current[0].coeff = 3116515,
|
||||
.ADC_current[0].offset = (-50706637833),
|
||||
|
||||
.ADC_current[1].coeff = 71754936,
|
||||
.ADC_current[1].offset = (-1167563957189),
|
||||
|
||||
.ADC_current[2].coeff = 1455534427,
|
||||
.ADC_current[2].offset = (-23681827162816),
|
||||
|
||||
.ADC_current[3].coeff = 30714861578,
|
||||
.ADC_current[3].offset = (-499791620533034),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10523335),
|
||||
.Usercode2DAC[0].offset = 582979514455,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178902791),
|
||||
.Usercode2DAC[1].offset = 4793071084176,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6237351),
|
||||
.ADC_Vout_volt[0].offset = 101984862423,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_8
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6263,
|
||||
.ADC_volt[0].offset = (-101682131),
|
||||
|
||||
.ADC_volt[1].coeff = 215329,
|
||||
.ADC_volt[1].offset = (-3498402458),
|
||||
|
||||
.ADC_volt[2].coeff = 6269445,
|
||||
.ADC_volt[2].offset = (-101833589970),
|
||||
|
||||
.ADC_current[0].coeff = 3131643,
|
||||
.ADC_current[0].offset = (-50940975097),
|
||||
|
||||
.ADC_current[1].coeff = 71884258,
|
||||
.ADC_current[1].offset = (-1169236286490),
|
||||
|
||||
.ADC_current[2].coeff = 1455983505,
|
||||
.ADC_current[2].offset = (-23681166075995),
|
||||
|
||||
.ADC_current[3].coeff = 30733849637,
|
||||
.ADC_current[3].offset = (-499848813950696),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10529784),
|
||||
.Usercode2DAC[0].offset = 582486528189,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-179068703),
|
||||
.Usercode2DAC[1].offset = 4796606756196,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6285173),
|
||||
.ADC_Vout_volt[0].offset = 102222446826,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_9
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6267,
|
||||
.ADC_volt[0].offset = (-102028002),
|
||||
|
||||
.ADC_volt[1].coeff = 215634,
|
||||
.ADC_volt[1].offset = (-3517189151),
|
||||
|
||||
.ADC_volt[2].coeff = 6281201,
|
||||
.ADC_volt[2].offset = (-102431111612),
|
||||
|
||||
.ADC_current[0].coeff = 3117736,
|
||||
.ADC_current[0].offset = (-50837353744),
|
||||
|
||||
.ADC_current[1].coeff = 71655674,
|
||||
.ADC_current[1].offset = (-1168489519122),
|
||||
|
||||
.ADC_current[2].coeff = 1454231926,
|
||||
.ADC_current[2].offset = (-23713068124450),
|
||||
|
||||
.ADC_current[3].coeff = 30667117763,
|
||||
.ADC_current[3].offset = (-500020256785398),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10547916),
|
||||
.Usercode2DAC[0].offset = 583186274643,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-179389854),
|
||||
.Usercode2DAC[1].offset = 4804853449970,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6244452),
|
||||
.ADC_Vout_volt[0].offset = 102103245637,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_10
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6266,
|
||||
.ADC_volt[0].offset = (-102510450),
|
||||
|
||||
.ADC_volt[1].coeff = 215104,
|
||||
.ADC_volt[1].offset = (-3516281969),
|
||||
|
||||
.ADC_volt[2].coeff = 6263495,
|
||||
.ADC_volt[2].offset = (-102366794643),
|
||||
|
||||
.ADC_current[0].coeff = 3134531,
|
||||
.ADC_current[0].offset = (-51203208091),
|
||||
|
||||
.ADC_current[1].coeff = 71817037,
|
||||
.ADC_current[1].offset = (-1173217647997),
|
||||
|
||||
.ADC_current[2].coeff = 1462086757,
|
||||
.ADC_current[2].offset = (-23883222331602),
|
||||
|
||||
.ADC_current[3].coeff = 30700669121,
|
||||
.ADC_current[3].offset = (-501453504657573),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10544373),
|
||||
.Usercode2DAC[0].offset = 584350176185,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178475043),
|
||||
.Usercode2DAC[1].offset = 4783237161078,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6261766),
|
||||
.ADC_Vout_volt[0].offset = 101995687562,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_11
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6271,
|
||||
.ADC_volt[0].offset = (-101634397),
|
||||
|
||||
.ADC_volt[1].coeff = 215437,
|
||||
.ADC_volt[1].offset = (-3491402418),
|
||||
|
||||
.ADC_volt[2].coeff = 6274038,
|
||||
.ADC_volt[2].offset = (-101654277903),
|
||||
|
||||
.ADC_current[0].coeff = 3117355,
|
||||
.ADC_current[0].offset = (-50497924237),
|
||||
|
||||
.ADC_current[1].coeff = 71774648,
|
||||
.ADC_current[1].offset = (-1162852302911),
|
||||
|
||||
.ADC_current[2].coeff = 1452664130,
|
||||
.ADC_current[2].offset = (-23532284128026),
|
||||
|
||||
.ADC_current[3].coeff = 30668623144,
|
||||
.ADC_current[3].offset = (-496799430136624),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10573209),
|
||||
.Usercode2DAC[0].offset = 582781434937,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-179369334),
|
||||
.Usercode2DAC[1].offset = 4803319819942,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6260515),
|
||||
.ADC_Vout_volt[0].offset = 101238248026,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_12
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6279,
|
||||
.ADC_volt[0].offset = (-102038347),
|
||||
|
||||
.ADC_volt[1].coeff = 215399,
|
||||
.ADC_volt[1].offset = (-3499372419),
|
||||
|
||||
.ADC_volt[2].coeff = 6271256,
|
||||
.ADC_volt[2].offset = (-101854059267),
|
||||
|
||||
.ADC_current[0].coeff = 3127579,
|
||||
.ADC_current[0].offset = (-50976515534),
|
||||
|
||||
.ADC_current[1].coeff = 71810250,
|
||||
.ADC_current[1].offset = (-1170512309345),
|
||||
|
||||
.ADC_current[2].coeff = 1459326140,
|
||||
.ADC_current[2].offset = (-23785128070449),
|
||||
|
||||
.ADC_current[3].coeff = 30698357437,
|
||||
.ADC_current[3].offset = (-500364793529135),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10515092),
|
||||
.Usercode2DAC[0].offset = 583551823033,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178895889),
|
||||
.Usercode2DAC[1].offset = 4793704222970,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6264947),
|
||||
.ADC_Vout_volt[0].offset = 101871189432,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_13
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6267,
|
||||
.ADC_volt[0].offset = (-101500321),
|
||||
|
||||
.ADC_volt[1].coeff = 214738,
|
||||
.ADC_volt[1].offset = (-3479346399),
|
||||
|
||||
.ADC_volt[2].coeff = 6266076,
|
||||
.ADC_volt[2].offset = (-101495271507),
|
||||
|
||||
.ADC_current[0].coeff = 3131355,
|
||||
.ADC_current[0].offset = (-50776447942),
|
||||
|
||||
.ADC_current[1].coeff = 71941999,
|
||||
.ADC_current[1].offset = (-1166670778645),
|
||||
|
||||
.ADC_current[2].coeff = 1459861085,
|
||||
.ADC_current[2].offset = (-23672231221240),
|
||||
|
||||
.ADC_current[3].coeff = 30713643316,
|
||||
.ADC_current[3].offset = (-498023476090336),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10534478),
|
||||
.Usercode2DAC[0].offset = 581065668584,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-177995981),
|
||||
.Usercode2DAC[1].offset = 4768228482663,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6242146),
|
||||
.ADC_Vout_volt[0].offset = 101296652593,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_14
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6233,
|
||||
.ADC_volt[0].offset = (-101600596),
|
||||
|
||||
.ADC_volt[1].coeff = 214213,
|
||||
.ADC_volt[1].offset = (-3492067604),
|
||||
|
||||
.ADC_volt[2].coeff = 6231071,
|
||||
.ADC_volt[2].offset = (-101547302286),
|
||||
|
||||
.ADC_current[0].coeff = 3127494,
|
||||
.ADC_current[0].offset = (-50791776302),
|
||||
|
||||
.ADC_current[1].coeff = 71436522,
|
||||
.ADC_current[1].offset = (-1160264778964),
|
||||
|
||||
.ADC_current[2].coeff = 1454999583,
|
||||
.ADC_current[2].offset = (-23631081707179),
|
||||
|
||||
.ADC_current[3].coeff = 30734513992,
|
||||
.ADC_current[3].offset = (-499174754129614),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10524578),
|
||||
.Usercode2DAC[0].offset = 580685281839,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178938545),
|
||||
.Usercode2DAC[1].offset = 4791672708498,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6287121),
|
||||
.ADC_Vout_volt[0].offset = 101919340594,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_15
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6278,
|
||||
.ADC_volt[0].offset = (-102374780),
|
||||
|
||||
.ADC_volt[1].coeff = 215578,
|
||||
.ADC_volt[1].offset = (-3514021066),
|
||||
|
||||
.ADC_volt[2].coeff = 6277736,
|
||||
.ADC_volt[2].offset = (-102314560841),
|
||||
|
||||
.ADC_current[0].coeff = 3121442,
|
||||
.ADC_current[0].offset = (-50925291177),
|
||||
|
||||
.ADC_current[1].coeff = 71617588,
|
||||
.ADC_current[1].offset = (-1168563472647),
|
||||
|
||||
.ADC_current[2].coeff = 1456095704,
|
||||
.ADC_current[2].offset = (-23757431937207),
|
||||
|
||||
.ADC_current[3].coeff = 30728459175,
|
||||
.ADC_current[3].offset = (-501347924376505),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10522914),
|
||||
.Usercode2DAC[0].offset = 582323677692,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178029958),
|
||||
.Usercode2DAC[1].offset = 4770650014378,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6278317),
|
||||
.ADC_Vout_volt[0].offset = 102365137425,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_16 // R2
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6276,
|
||||
.ADC_volt[0].offset = (-102671998),
|
||||
|
||||
.ADC_volt[1].coeff = 216563,
|
||||
.ADC_volt[1].offset = (-3543055230),
|
||||
|
||||
.ADC_volt[2].coeff = 6307068,
|
||||
.ADC_volt[2].offset = (-103165069679),
|
||||
|
||||
.ADC_current[0].coeff = 3128089,
|
||||
.ADC_current[0].offset = (-51016401920),
|
||||
|
||||
.ADC_current[1].coeff = 71887266,
|
||||
.ADC_current[1].offset = (-1172673156926),
|
||||
|
||||
.ADC_current[2].coeff = 1458529439,
|
||||
.ADC_current[2].offset = (-23791298278977),
|
||||
|
||||
.ADC_current[3].coeff = 30688895879,
|
||||
.ADC_current[3].offset = (-500613041520786),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10547767),
|
||||
.Usercode2DAC[0].offset = 582805793442,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-177870657),
|
||||
.Usercode2DAC[1].offset = 4766517514398,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6223522),
|
||||
.ADC_Vout_volt[0].offset = 101414758679,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_17 // R2
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6281,
|
||||
.ADC_volt[0].offset = (-102091135),
|
||||
|
||||
.ADC_volt[1].coeff = 215489,
|
||||
.ADC_volt[1].offset = (-3502773449),
|
||||
|
||||
.ADC_volt[2].coeff = 6284799,
|
||||
.ADC_volt[2].offset = (-102137567699),
|
||||
|
||||
.ADC_current[0].coeff = 3127489,
|
||||
.ADC_current[0].offset = (-50929238025),
|
||||
|
||||
.ADC_current[1].coeff = 72028152,
|
||||
.ADC_current[1].offset = (-1173190386421),
|
||||
|
||||
.ADC_current[2].coeff = 1462120904,
|
||||
.ADC_current[2].offset = (-23813658336317),
|
||||
|
||||
.ADC_current[3].coeff = 30772133023,
|
||||
.ADC_current[3].offset = (-501193399098681),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10525509),
|
||||
.Usercode2DAC[0].offset = 583168750255,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178502405),
|
||||
.Usercode2DAC[1].offset = 4783222906500,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6246238),
|
||||
.ADC_Vout_volt[0].offset = 101174300735,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_18 // R2
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6307,
|
||||
.ADC_volt[0].offset = (-102227194),
|
||||
|
||||
.ADC_volt[1].coeff = 216350,
|
||||
.ADC_volt[1].offset = (-3510441794),
|
||||
|
||||
.ADC_volt[2].coeff = 6321158,
|
||||
.ADC_volt[2].offset = (-102545234591),
|
||||
|
||||
.ADC_current[0].coeff = 3127182,
|
||||
.ADC_current[0].offset = (-50985551728),
|
||||
|
||||
.ADC_current[1].coeff = 71761497,
|
||||
.ADC_current[1].offset = (-1170210907687),
|
||||
|
||||
.ADC_current[2].coeff = 1457926498,
|
||||
.ADC_current[2].offset = (-23773550048662),
|
||||
|
||||
.ADC_current[3].coeff = 30730387774,
|
||||
.ADC_current[3].offset = (-501134113778611),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10542537),
|
||||
.Usercode2DAC[0].offset = 582354584774,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178433148),
|
||||
.Usercode2DAC[1].offset = 4780251590552,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6245655),
|
||||
.ADC_Vout_volt[0].offset = 101405660400,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_19 //R2
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6248,
|
||||
.ADC_volt[0].offset = (-101988256),
|
||||
|
||||
.ADC_volt[1].coeff = 215428,
|
||||
.ADC_volt[1].offset = (-3518184654),
|
||||
|
||||
.ADC_volt[2].coeff = 6267624,
|
||||
.ADC_volt[2].offset = (-102333798553),
|
||||
|
||||
.ADC_current[0].coeff = 3132332,
|
||||
.ADC_current[0].offset = (-50985538056),
|
||||
|
||||
.ADC_current[1].coeff = 71555053,
|
||||
.ADC_current[1].offset = (-1165030559094),
|
||||
|
||||
.ADC_current[2].coeff = 1464565286,
|
||||
.ADC_current[2].offset = (-23841501204443),
|
||||
|
||||
.ADC_current[3].coeff = 30827554942,
|
||||
.ADC_current[3].offset = (-501862954230438),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10508759),
|
||||
.Usercode2DAC[0].offset = 581937735033,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178323180),
|
||||
.Usercode2DAC[1].offset = 4777879424722,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6212067),
|
||||
.ADC_Vout_volt[0].offset = 101533593863,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_20 //R2
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6223,
|
||||
.ADC_volt[0].offset = (-100772846),
|
||||
|
||||
.ADC_volt[1].coeff = 214243,
|
||||
.ADC_volt[1].offset = (-3474181335),
|
||||
|
||||
.ADC_volt[2].coeff = 6249611,
|
||||
.ADC_volt[2].offset = (-101316282249),
|
||||
|
||||
.ADC_current[0].coeff = 3120936,
|
||||
.ADC_current[0].offset = (-50668228961),
|
||||
|
||||
.ADC_current[1].coeff = 71902191,
|
||||
.ADC_current[1].offset = (-1167587543417),
|
||||
|
||||
.ADC_current[2].coeff = 1457439423,
|
||||
.ADC_current[2].offset = (-23664301410063),
|
||||
|
||||
.ADC_current[3].coeff = 30697477675,
|
||||
.ADC_current[3].offset = (-498485527107672),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10506483),
|
||||
.Usercode2DAC[0].offset = 579666250198,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178136809),
|
||||
.Usercode2DAC[1].offset = 4771066521917,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6279145),
|
||||
.ADC_Vout_volt[0].offset = 101443137473,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_21
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6297,
|
||||
.ADC_volt[0].offset = (-102239918),
|
||||
|
||||
.ADC_volt[1].coeff = 215976,
|
||||
.ADC_volt[1].offset = (-3511853183),
|
||||
|
||||
.ADC_volt[2].coeff = 6301113,
|
||||
.ADC_volt[2].offset = (-102433011284),
|
||||
|
||||
.ADC_current[0].coeff = 3142822,
|
||||
.ADC_current[0].offset = (-51073945597),
|
||||
|
||||
.ADC_current[1].coeff = 71828674,
|
||||
.ADC_current[1].offset = (-1167357180875),
|
||||
|
||||
.ADC_current[2].coeff = 1464305335,
|
||||
.ADC_current[2].offset = (-23796552730288),
|
||||
|
||||
.ADC_current[3].coeff = 30691748879,
|
||||
.ADC_current[3].offset = (-498801800724347),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10538563),
|
||||
.Usercode2DAC[0].offset = 583007751105,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178520622),
|
||||
.Usercode2DAC[1].offset = 4783591915817,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6245655),
|
||||
.ADC_Vout_volt[0].offset = 101405660400,
|
||||
};
|
||||
#endif
|
||||
|
||||
int32_t DecodeADCValue(uint8_t adc_gain, uint8_t adc_channel, uint16_t adc_rxbuf);
|
||||
int32_t DecodeADCValue(uint8_t adc_gain, uint8_t adc_channel, uint8_t *adc_rxbuf);
|
||||
uint16_t Usercode_Correction_to_DAC(uint8_t dac_gain, uint16_t usercode);
|
||||
|
||||
/*=============================================================================
|
||||
@@ -2384,11 +1909,12 @@ static int32_t DecodeADCCurrent(uint8_t adc_gain, uint16_t adc_measure)
|
||||
return (int32_t) (curr);
|
||||
}
|
||||
|
||||
int32_t DecodeADCValue(uint8_t adc_gain, uint8_t adc_channel, uint16_t adc_rxbuf)
|
||||
int32_t DecodeADCValue(uint8_t adc_gain, uint8_t adc_channel, uint8_t *adc_rxbuf)
|
||||
{
|
||||
uint8_t gain = adc_gain;
|
||||
uint8_t ch = adc_channel;
|
||||
uint16_t adc_16b_measure = adc_rxbuf;
|
||||
uint8_t *rx = adc_rxbuf;
|
||||
uint16_t adc_16b_measure;
|
||||
int32_t ret = 0;
|
||||
|
||||
/*
|
||||
@@ -2399,6 +1925,7 @@ int32_t DecodeADCValue(uint8_t adc_gain, uint8_t adc_channel, uint16_t adc_rxbuf
|
||||
* if channel == RIS_ADC_VIN: return real battery volt
|
||||
*/
|
||||
|
||||
adc_16b_measure = (uint16_t)rx[0] << 8 | (uint16_t)rx[1];
|
||||
|
||||
if(ch == RIS_ADC_VIN){
|
||||
return DecodeADCVolt(gain, adc_16b_measure);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
#ifndef ELITE_FLAG_CT_INIT
|
||||
#define ELITE_FLAG_CT_INIT
|
||||
|
||||
// GPT counter
|
||||
struct _GPT{
|
||||
uint32_t GptimerCounter;
|
||||
uint32_t GptimerCounter0;
|
||||
uint8_t DeltaGptimerCounter;
|
||||
uint32_t SampleRateCounter;
|
||||
uint32_t NotifyCounter;
|
||||
uint32_t VscanRateCounter;
|
||||
uint32_t LeadTimeCounter;
|
||||
uint32_t BatteryADCCounter;
|
||||
uint32_t BatteryCheckCounter;
|
||||
uint32_t GptimerMultiple;
|
||||
uint32_t StiCounter;
|
||||
}GPT = {0};
|
||||
|
||||
static void InitGPT(){
|
||||
GPT.GptimerCounter = 0;
|
||||
GPT.GptimerCounter0 = 0;
|
||||
GPT.DeltaGptimerCounter = 0;
|
||||
GPT.SampleRateCounter = 0;
|
||||
GPT.NotifyCounter = 0;
|
||||
GPT.VscanRateCounter = 0;
|
||||
GPT.LeadTimeCounter = 0;
|
||||
GPT.BatteryADCCounter = 0;
|
||||
GPT.BatteryCheckCounter = 0;
|
||||
GPT.StiCounter = 0;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
/* Copyright (c) 2019. BioPro. Scientific.
|
||||
*/
|
||||
#ifndef HEADSTAGE_GPTIMER_H
|
||||
#define HEADSTAGE_GPTIMER_H
|
||||
|
||||
#include <Board.h>
|
||||
#include <ti/drivers/timer/GPTimerCC26XX.h>
|
||||
#include <ti/sysbios/BIOS.h>
|
||||
#include <xdc/runtime/Types.h>
|
||||
|
||||
#define EVT_PERIODIC_GPTIMER EVT_PERIODIC_0
|
||||
|
||||
static GPTimerCC26XX_Handle gptimer_handle;
|
||||
|
||||
static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask);
|
||||
|
||||
#define elite_gptimer_start() GPTimerCC26XX_start(gptimer_handle)
|
||||
#define elite_gptimer_stop() GPTimerCC26XX_stop(gptimer_handle)
|
||||
#define elite_gptimer_close() GPTimerCC26XX_close(gptimer_handle)
|
||||
#define CLOCK_FREQ 4769 // 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)
|
||||
|
||||
#endif // HEADSTAGE_GPTIMER_H
|
||||
@@ -0,0 +1,95 @@
|
||||
|
||||
#ifndef ELITE_I2C
|
||||
#define ELITE_I2C
|
||||
|
||||
/*
|
||||
* Read I2C example in
|
||||
* http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/tirtos/2_14_02_22/
|
||||
* exports/tirtos_full_2_14_02_22/docs/doxygen/html/_i2_c_c_c26_x_x_8h.html
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ti/drivers/I2C.h>
|
||||
#include <ti/drivers/Power.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
// I2C
|
||||
static I2C_Handle I2Chandle;
|
||||
static I2C_Params I2Cparams;
|
||||
static I2C_Transaction i2cTrans;
|
||||
|
||||
#define I2CBufSize 4
|
||||
static uint8_t I2CtxBuf[I2CBufSize]; // Transmit buffer
|
||||
static uint8_t I2CrxBuf[I2CBufSize]; // Receive buffer
|
||||
bool transferDone = false;
|
||||
|
||||
static void I2CCallbackFunction(I2C_Handle handle, I2C_Transaction *msg, bool transfer) {
|
||||
if(transfer){
|
||||
transferDone = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void I2Cinit(){
|
||||
I2C_init();
|
||||
|
||||
// Configure I2C parameters.
|
||||
I2C_Params_init(&I2Cparams);
|
||||
|
||||
I2Cparams.transferMode = I2C_MODE_CALLBACK;
|
||||
I2Cparams.transferCallbackFxn = I2CCallbackFunction;
|
||||
I2Cparams.bitRate = I2C_100kHz;
|
||||
|
||||
// Initialize master I2C transaction structure
|
||||
i2cTrans.writeCount = I2CBufSize;
|
||||
i2cTrans.writeBuf = I2CtxBuf;
|
||||
i2cTrans.readCount = I2CBufSize;
|
||||
i2cTrans.readBuf = I2CrxBuf;
|
||||
i2cTrans.slaveAddress = 0xA0;
|
||||
|
||||
for(int i=0 ; i<10 ; i++){
|
||||
I2CtxBuf[i] = 0;
|
||||
I2CrxBuf[i] = 0;
|
||||
}
|
||||
|
||||
// Open I2C
|
||||
I2Chandle = I2C_open(Board_I2C, &I2Cparams);
|
||||
|
||||
}
|
||||
#define WriteMem 0b10100001
|
||||
#define ReadMem 0b10100000
|
||||
|
||||
static void I2CWrite(uint8_t addr, uint8_t data){
|
||||
for(int i=0 ; i<I2CBufSize ; i++){
|
||||
I2CtxBuf[i] = 0;
|
||||
I2CrxBuf[i] = 0;
|
||||
}
|
||||
|
||||
I2CtxBuf[0] = WriteMem;
|
||||
I2CtxBuf[1] = addr;
|
||||
I2CtxBuf[2] = data;
|
||||
|
||||
// I2Chandle = I2C_open(Board_I2C, &I2Cparams);
|
||||
I2C_transfer(I2Chandle, &i2cTrans);
|
||||
// I2C_close(I2Chandle);
|
||||
}
|
||||
|
||||
|
||||
static void I2CRead(uint8_t addr){
|
||||
for(int i=0 ; i<I2CBufSize ; i++){
|
||||
I2CtxBuf[i] = 0;
|
||||
I2CrxBuf[i] = 0;
|
||||
}
|
||||
|
||||
I2CtxBuf[0] = ReadMem;
|
||||
I2CtxBuf[1] = addr;
|
||||
|
||||
// I2Chandle = I2C_open(Board_I2C, &I2Cparams);
|
||||
I2C_transfer(I2Chandle, &i2cTrans);
|
||||
// I2C_close(I2Chandle);
|
||||
}
|
||||
|
||||
|
||||
#endif // ELITE_I2C
|
||||
|
||||
@@ -47,8 +47,6 @@ struct HEADSTAGE_INSTRUCTION {
|
||||
uint16_t cycleNumber;
|
||||
uint8_t charge;
|
||||
int32_t constantCurrent;
|
||||
uint8_t cc_resistance;
|
||||
uint8_t cc_cp_speed;
|
||||
|
||||
// uni pulse mode
|
||||
int32_t v0;
|
||||
@@ -66,12 +64,35 @@ struct HEADSTAGE_INSTRUCTION {
|
||||
int32_t v_1;
|
||||
int32_t v_2;
|
||||
|
||||
|
||||
// pulse mode
|
||||
int32_t sti_v1;
|
||||
int32_t sti_v2;
|
||||
int32_t sti_v3;
|
||||
int32_t sti_v4;
|
||||
int32_t sti_v5;
|
||||
int32_t sti_v6;
|
||||
int32_t sti_v7;
|
||||
int32_t sti_t1;
|
||||
int32_t sti_t2;
|
||||
int32_t sti_t3;
|
||||
int32_t sti_t4;
|
||||
int32_t sti_t5;
|
||||
int32_t sti_t6;
|
||||
int32_t sti_t7;
|
||||
uint16_t sti_cy;
|
||||
uint16_t sti_loop;
|
||||
|
||||
int32_t Vout;
|
||||
|
||||
// not use
|
||||
int32_t Currentmax;
|
||||
uint8_t VoViSwitch;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} instru = {0};
|
||||
|
||||
/** Iin, Vin, Vout **/
|
||||
@@ -141,12 +162,12 @@ static void InitEliteInstruction(void)
|
||||
instru.IinADCAutoGainEn = 1;
|
||||
instru.VinADCAutoGainEn = 1;
|
||||
instru.VoutAutoGainEn = 1;
|
||||
instru.IinADCGainLv = I_GAIN_100R;
|
||||
instru.VinADCGainLv = VIN_GAIN_1K;
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
instru.IinADCGainLv = I_GAIN_AUTO;
|
||||
instru.VinADCGainLv = VIN_GAIN_AUTO;
|
||||
instru.VoutGainLv = VOUT_GAIN_AUTO;
|
||||
instru.gain_switch_on = 0b11110000; // cur auto gain switch, |lv0|lv1|lv2|lv3|none|none|none|none|
|
||||
instru.AdcChannel = 0; // RIS_ADC_IIN: 0x00, RIS_ADC_VIN: 0x01, RIS_DAC_VOUT: 0x02, RIS_HIGH_Z: 0x03
|
||||
instru.hign_z_en = 0;
|
||||
instru.hign_z_en = 1;
|
||||
|
||||
instru.cycleNumber = 1;
|
||||
instru.charge = 1; // 0:discharge, 1:charge
|
||||
@@ -184,6 +205,24 @@ static void InitEliteInstruction(void)
|
||||
instru.v_1 = 0;
|
||||
instru.v_2 = 0;
|
||||
|
||||
//pulse mode
|
||||
instru.sti_t1 = 0;
|
||||
instru.sti_t2 = 0;
|
||||
instru.sti_t3 = 0;
|
||||
instru.sti_t4 = 0;
|
||||
instru.sti_t5 = 0;
|
||||
instru.sti_t6 = 0;
|
||||
instru.sti_t7 = 0;
|
||||
instru.sti_v1 = DAC_ZERO;
|
||||
instru.sti_v2 = DAC_ZERO;
|
||||
instru.sti_v3 = DAC_ZERO;
|
||||
instru.sti_v4 = DAC_ZERO;
|
||||
instru.sti_v5 = DAC_ZERO;
|
||||
instru.sti_v6 = DAC_ZERO;
|
||||
instru.sti_v7 = DAC_ZERO;
|
||||
instru.sti_loop = 1;
|
||||
instru.sti_cy = 0;
|
||||
|
||||
instru.Vout = 0;
|
||||
|
||||
// not use
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
|
||||
#ifndef ELITEKEYDETECT
|
||||
#define ELITEKEYDETECT
|
||||
|
||||
static bool TurnOnElite(uint8_t key) {
|
||||
static uint16_t TurnOnCounter = 0;
|
||||
|
||||
if (key == 0) {
|
||||
// press 1 sec, power on LED, read bat power
|
||||
if (TurnOnCounter >= CLOCK_ONE_SECOND) {
|
||||
headstage_battery_volt();
|
||||
uint16_t bat = NotifyVoltBat;
|
||||
if( bat < 768 && bat > 20){
|
||||
PIN15_setOutputValue(enable_5v, 0);
|
||||
return false;
|
||||
}else{
|
||||
PIN15_setOutputValue(enable_5v, 1); // enable 5V
|
||||
TurnOn10V();
|
||||
ModeLED(BT_WAIT);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
TurnOnCounter++;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
TurnOnCounter = 0;
|
||||
PIN15_setOutputValue(enable_5v, 0); // disable 5V
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void EliteKeyPress(uint8_t key) {
|
||||
static uint16_t ShutDownCounter = 0;
|
||||
static uint8_t OriginEliteFxn = 0;
|
||||
|
||||
if (key == 0) {
|
||||
// key = 0 if press
|
||||
// press key => bight LED
|
||||
|
||||
if (ShutDownCounter == CLOCK_ONE_SECOND) {
|
||||
KEYLED();
|
||||
}
|
||||
|
||||
// press 3~4 sec, shutdown 2650
|
||||
else if (ShutDownCounter > (CLOCK_ONE_SECOND*3) ) {
|
||||
LED_color(DARKLED, 0xFF, 0xFF, 0x00);
|
||||
PIN15_setOutputValue(enable_5v, 0); // disable 5V
|
||||
}
|
||||
ShutDownCounter ++;
|
||||
} else {
|
||||
if (OriginEliteFxn == instru.eliteFxn) { // old function == currunt instruction
|
||||
if (ShutDownCounter != 0) {
|
||||
// dark LED
|
||||
checkFlafLED();
|
||||
ShutDownCounter = 0;
|
||||
}
|
||||
} else { // old function != currunt instruction
|
||||
OriginEliteFxn = instru.eliteFxn;
|
||||
if (ShutDownCounter != 0) {
|
||||
ShutDownCounter = 0;
|
||||
}
|
||||
checkFlafLED();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void TurnOn10V() {
|
||||
If10Von = true;
|
||||
PIN15_setOutputValue(enable_10v, 1);
|
||||
CPUdelay(8000);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -2,6 +2,9 @@
|
||||
#ifndef ELITELED
|
||||
#define ELITELED
|
||||
|
||||
#define DARKLED 0xE1
|
||||
#define LIGHTLED 0xE8
|
||||
|
||||
static bool btWaitLedFlag = 0;
|
||||
static bool noEventLedFlag = 0;
|
||||
static bool preWorkLedFlag = 0;
|
||||
@@ -10,6 +13,93 @@ static bool postWorkLedFlag = 0;
|
||||
|
||||
static void WorkModeLED();
|
||||
|
||||
static void LED_color(uint8_t bright, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
spi_LEDtxbuf[0] = 0x0000;
|
||||
spi_LEDtxbuf[1] = 0x0000;
|
||||
for (int i = 2; i < SPI_LED_SIZE - 2; i += 2) {
|
||||
spi_LEDtxbuf[i] = 0xE000 | ((uint16_t)bright << 8) | blue;
|
||||
spi_LEDtxbuf[i + 1] = ((uint16_t)green << 8) | red;
|
||||
}
|
||||
|
||||
spi_LEDtxbuf[SPI_LED_SIZE - 2] = 0xffff;
|
||||
spi_LEDtxbuf[SPI_LED_SIZE - 1] = 0xffff;
|
||||
|
||||
LED_SPI(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf);
|
||||
}
|
||||
|
||||
static void Elite_led_color(uint16_t color){
|
||||
switch (color) {
|
||||
case COLOR_RED: {
|
||||
LED_color(DARKLED, 0xFF, 0x00, 0x00);
|
||||
break;
|
||||
}
|
||||
case COLOR_ORANGE: {
|
||||
LED_color(DARKLED, 0xFF, 0x58, 0x09);
|
||||
break;
|
||||
}
|
||||
case COLOR_YELLOW: {
|
||||
LED_color(LIGHTLED, 0xFF, 0x80, 0x00);
|
||||
break;
|
||||
}
|
||||
case COLOR_GREEN: {
|
||||
LED_color(DARKLED, 0x00, 0xFA, 0x00);
|
||||
break;
|
||||
}
|
||||
case COLOR_YELLOWGREEN: {
|
||||
LED_color(DARKLED, 0x64, 0xA6, 0x00);
|
||||
break;
|
||||
}
|
||||
case COLOR_BLUE: {
|
||||
LED_color(DARKLED, 0x00, 0x00, 0xAA);
|
||||
break;
|
||||
}
|
||||
case COLOR_CYAN: {
|
||||
LED_color(DARKLED, 0x00, 0x40, 0x40);
|
||||
break;
|
||||
}
|
||||
case COLOR_MAGENTA: {
|
||||
LED_color(DARKLED, 0xFF, 0x00, 0x80);
|
||||
break;
|
||||
}
|
||||
case COLOR_PURPLE: {
|
||||
LED_color(DARKLED, 0xFF, 0x00, 0xFF);
|
||||
break;
|
||||
}
|
||||
case COLOR_WHITE: {
|
||||
LED_color(DARKLED, 0xCA, 0xFF, 0xFF);
|
||||
break;
|
||||
}
|
||||
case COLOR_BLACK: {
|
||||
LED_color(0x00, 0x00, 0x00, 0x00);
|
||||
break;
|
||||
}
|
||||
//dark LED
|
||||
case COLOR_YELLOW_DARK: {
|
||||
LED_color(DARKLED, 0xFF, 0x80, 0x00);
|
||||
break;
|
||||
}
|
||||
case COLOR_GREEN_DARK: {
|
||||
LED_color(DARKLED, 0x00, 0x33, 0x00);
|
||||
break;
|
||||
}
|
||||
case COLOR_BLUE_DARK: {
|
||||
LED_color(DARKLED, 0x00, 0x00, 0x33);
|
||||
break;
|
||||
}
|
||||
case COLOR_CYAN_DARK: {
|
||||
LED_color(DARKLED, 0x00, 0x10, 0x10);
|
||||
break;
|
||||
}
|
||||
case COLOR_PURPLE_DARK: {
|
||||
LED_color(DARKLED, 0x55, 0x00, 0x55);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ModeLED(uint16_t modeStatus) {
|
||||
btWaitLedFlag = 0;
|
||||
noEventLedFlag = 0;
|
||||
@@ -18,47 +108,53 @@ static void ModeLED(uint16_t modeStatus) {
|
||||
postWorkLedFlag = 0;
|
||||
|
||||
switch (modeStatus) {
|
||||
case BT_WAIT:
|
||||
btWaitLedFlag = 1;
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_YELLOWGREEN);
|
||||
break;
|
||||
|
||||
case NO_EVENT:
|
||||
noEventLedFlag = 1;
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_GREEN);
|
||||
break;
|
||||
|
||||
case PRE_WORK:
|
||||
preWorkLedFlag = 1;
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_BLUE);
|
||||
break;
|
||||
|
||||
case WORKING:
|
||||
workingLedFlag = 1;
|
||||
WorkModeLED();
|
||||
break;
|
||||
|
||||
case POST_WORK:
|
||||
postWorkLedFlag = 1;
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_GREEN);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
case BT_WAIT: {
|
||||
btWaitLedFlag = 1;
|
||||
BT_WAIT_LED();
|
||||
break;
|
||||
}
|
||||
case NO_EVENT: {
|
||||
noEventLedFlag = 1;
|
||||
LEDPowerON();
|
||||
break;
|
||||
}
|
||||
case PRE_WORK: {
|
||||
preWorkLedFlag = 1;
|
||||
Elite_led_color(COLOR_BLUE);
|
||||
break;
|
||||
}
|
||||
case WORKING: {
|
||||
workingLedFlag = 1;
|
||||
WorkModeLED();
|
||||
break;
|
||||
}
|
||||
case POST_WORK: {
|
||||
postWorkLedFlag = 1;
|
||||
Elite_led_color(COLOR_BLUE);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
LEDPowerON();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void checkFlafLED()
|
||||
{
|
||||
if(btWaitLedFlag == 1) {
|
||||
if(btWaitLedFlag == 1){
|
||||
ModeLED(BT_WAIT);
|
||||
} else if(noEventLedFlag == 1) {
|
||||
}
|
||||
else if(noEventLedFlag == 1){
|
||||
ModeLED(NO_EVENT);
|
||||
} else if(preWorkLedFlag == 1) {
|
||||
}
|
||||
else if(preWorkLedFlag == 1){
|
||||
ModeLED(PRE_WORK);
|
||||
} else if(workingLedFlag == 1) {
|
||||
}
|
||||
else if(workingLedFlag == 1){
|
||||
ModeLED(WORKING);
|
||||
} else if(postWorkLedFlag == 1) {
|
||||
}
|
||||
else if(postWorkLedFlag == 1){
|
||||
ModeLED(POST_WORK);
|
||||
}
|
||||
}
|
||||
@@ -77,21 +173,22 @@ static void WorkModeLED()
|
||||
case CURVE_OCP:
|
||||
case CURVE_LSV:
|
||||
case CURVE_IV_CY:
|
||||
case CURVE_PULSE:
|
||||
case CURVE_UNI_PULSE:
|
||||
case CURVE_DPV:
|
||||
case CURVE_DPV_SMPRATE:
|
||||
case CURVE_DPV_ADVANCE:
|
||||
case CURVE_DPV_ADVANCE_SMPRATE:
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_CYAN);
|
||||
WORKLED();
|
||||
break;
|
||||
|
||||
case CURVE_CALI_ADC:
|
||||
if (instru.AdcChannel == RIS_ADC_IIN) {
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_RED);
|
||||
Elite_led_color(COLOR_RED);
|
||||
} else if (instru.AdcChannel == RIS_ADC_VIN) {
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_ORANGE);
|
||||
Elite_led_color(COLOR_ORANGE);
|
||||
} else if (instru.AdcChannel == RIS_DAC_VOUT) {
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_BLUE);
|
||||
Elite_led_color(COLOR_BLUE);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
#ifndef ELITE_LATCH_INIT
|
||||
#define ELITE_LATCH_INIT
|
||||
|
||||
static void InitLH() {
|
||||
for (int i=0; i<LATCH_BUFF_SIZE; i++) {
|
||||
LH.LATCH0[i] = 0;
|
||||
LH.LATCH1[i] = 0;
|
||||
LH.LATCH2[i] = 0;
|
||||
}
|
||||
LH.LoadState = 0;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,18 +10,29 @@ static void reset() {
|
||||
initINSBuf();
|
||||
initDATBuf();
|
||||
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, 0); // HIGH Z MODE // 1: close; 0: open;
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // HIGH Z MODE // 1: close; 0: open;
|
||||
|
||||
instru.VinADCGainLv = VIN_GAIN_1K;
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
instru.IinADCGainLv = I_GAIN_100R;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
VinADCGainCtrl(VIN_GAIN_AUTO);
|
||||
IinADCGainCtrl(I_GAIN_AUTO);
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
DAC0_W_T(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
|
||||
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
|
||||
|
||||
for (int i = 0; i < SPI_LED_SIZE; i++) {
|
||||
spi_LEDtxbuf[i] = 0;
|
||||
spi_LEDrxbuf[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < SPI_DAC_SIZE; i++) {
|
||||
spi_DACtxbuf[i] = 0;
|
||||
spi_rxbuf[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < SPI_ADC_SIZE; i++) {
|
||||
spi_ADC_txbuf[i] = 0;
|
||||
spi_ADC_rxbuf[i] = 0;
|
||||
}
|
||||
|
||||
ModeLED(NO_EVENT);
|
||||
CPUdelay(1600);
|
||||
@@ -35,14 +46,27 @@ static void Eliteinterrupt() {
|
||||
initINSBuf();
|
||||
initDATBuf();
|
||||
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, 0); // HIGH Z MODE // 1: close; 0: open;
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // HIGH Z MODE // 1: close; 0: open;
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
DAC0_W_T(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
|
||||
|
||||
ADC_rxbuf = 0;
|
||||
|
||||
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
|
||||
|
||||
for (int i = 0; i < SPI_LED_SIZE; i++) {
|
||||
spi_LEDtxbuf[i] = 0;
|
||||
spi_LEDrxbuf[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < SPI_DAC_SIZE; i++) {
|
||||
spi_DACtxbuf[i] = 0;
|
||||
spi_rxbuf[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < SPI_ADC_SIZE; i++) {
|
||||
spi_ADC_txbuf[i] = 0;
|
||||
spi_ADC_rxbuf[i] = 0;
|
||||
}
|
||||
|
||||
ModeLED(NO_EVENT);
|
||||
CPUdelay(8000);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
|
||||
#ifndef ELITE_SPI
|
||||
#define ELITE_SPI
|
||||
|
||||
/*
|
||||
* Read SPI example in
|
||||
* http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/tirtos/2_14_02_22/
|
||||
* exports/tirtos_full_2_14_02_22/docs/doxygen/html/_s_p_i_c_c26_x_x_d_m_a_8h.html
|
||||
*/
|
||||
|
||||
#include <Board.h>
|
||||
#include <ti/drivers/SPI.h>
|
||||
#include <ti/drivers/dma/UDMACC26XX.h>
|
||||
#include <ti/drivers/spi/SPICC26XXDMA.h>
|
||||
#include "Elite_PIN.h"
|
||||
|
||||
/* application use SPI parameters and buffers */
|
||||
#define SPI_LED_SIZE 28
|
||||
#define SPI_DAC_SIZE 3
|
||||
#define SPI_ADC_SIZE 4
|
||||
|
||||
static uint16_t spi_LEDtxbuf[SPI_LED_SIZE] = {0};
|
||||
static uint16_t spi_LEDrxbuf[SPI_LED_SIZE] = {0};
|
||||
|
||||
static uint8_t spi_DACtxbuf[SPI_DAC_SIZE] = {0};
|
||||
static uint8_t spi_rxbuf[SPI_DAC_SIZE] = {0};
|
||||
|
||||
static uint8_t spi_ADC_txbuf[SPI_ADC_SIZE] = {0};
|
||||
static uint8_t spi_ADC_rxbuf[SPI_ADC_SIZE] = {0};
|
||||
|
||||
/* system use SPI parameters */
|
||||
static SPI_Handle spiHandle0 = NULL; // SPI0 = LED
|
||||
static SPI_Handle spiHandle1 = NULL; // SPI1 = ADC +DAC
|
||||
static SPI_Params spiParams0;
|
||||
static SPI_Params spiParams1;
|
||||
static SPI_Transaction LED_transaction;
|
||||
static SPI_Transaction ADC_DAC_transaction;
|
||||
|
||||
static void ELITE15_SPI_HOLD();
|
||||
static void ELITE15_SPI_CLOSE();
|
||||
|
||||
static void Elite_SPI_init(){
|
||||
SPI_init();
|
||||
SPI_Params_init(&spiParams0);
|
||||
spiParams0.bitRate = 10000000; // 10M
|
||||
spiParams0.mode = SPI_MASTER;
|
||||
spiParams0.dataSize = 16;
|
||||
spiParams0.frameFormat = SPI_POL0_PHA1;
|
||||
spiHandle0 = SPI_open(Board_SPI0, &spiParams0); // LED SPI
|
||||
|
||||
SPI_Params_init(&spiParams1);
|
||||
spiParams1.bitRate = 10000000; // 10M
|
||||
spiParams1.mode = SPI_MASTER;
|
||||
spiParams1.dataSize = 8;
|
||||
spiParams1.frameFormat = SPI_POL0_PHA1;
|
||||
spiHandle1 = SPI_open(Board_SPI1, &spiParams1); // ADC DAC SPI
|
||||
}
|
||||
|
||||
static void LED_SPI(uint8_t length, uint16_t *spi_txbuf, uint16_t *spi_rxbuf) {
|
||||
LED_transaction.count = length;
|
||||
LED_transaction.txBuf = spi_txbuf;
|
||||
LED_transaction.rxBuf = spi_rxbuf;
|
||||
|
||||
SPI_transfer(spiHandle0, &LED_transaction);
|
||||
}
|
||||
|
||||
static void ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
// PIN15_setOutputValue(ADC_CS, 0); // ADC_CS LOW
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
PIN_setOutputValue(pin_handle, D6, 0); // ADC_CS LOW
|
||||
|
||||
ADC_DAC_transaction.count = length;
|
||||
ADC_DAC_transaction.txBuf = spi_txbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, D6, 1); // ADC_CS HIGH
|
||||
update_latch_status (ADC_CS, 1);
|
||||
// PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
|
||||
}
|
||||
|
||||
static void DAC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
// PIN15_setOutputValue(DAC_CS, 0); // DAC_CS LOW
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
PIN_setOutputValue(pin_handle, D7, 0); // DAC_CS LOW
|
||||
|
||||
ADC_DAC_transaction.count = length;
|
||||
ADC_DAC_transaction.txBuf = spi_txbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, D7, 1); // DAC_CS HIGH
|
||||
update_latch_status (DAC_CS, 1);
|
||||
// PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
|
||||
}
|
||||
|
||||
static void ELITE15_SPI_HOLD() {
|
||||
Elite_SPI_init();
|
||||
#ifdef ELITE_PIN_1_5_RE
|
||||
PIN_setOutputValue(pin_handle, D6, LH.LATCH0[6]); // ADC_CS
|
||||
PIN_setOutputValue(pin_handle, D7, LH.LATCH0[7]); // DAC_CS
|
||||
PIN_setOutputValue(pin_handle, D4, LH.LATCH0[4]); // update HIGH_Z_MODE
|
||||
#endif
|
||||
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD2, 0);
|
||||
}
|
||||
static void ELITE15_SPI_CLOSE() {
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD2, 0);
|
||||
|
||||
SPI_close(spiHandle0);
|
||||
SPI_close(spiHandle1);
|
||||
}
|
||||
|
||||
/* Elite1.5 Calibration SPI */
|
||||
static void CAL_ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
// PIN15_setOutputValue(ADC_CS, 0); // ADC_CS LOW
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
PIN_setOutputValue(pin_handle, D6, 0); // ADC_CS LOW
|
||||
|
||||
ADC_DAC_transaction.count = length;
|
||||
ADC_DAC_transaction.txBuf = spi_txbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, D6, 1); // ADC_CS HOGH
|
||||
update_latch_status (ADC_CS, 1);
|
||||
// PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
|
||||
}
|
||||
|
||||
#endif // ELITE_SPI
|
||||
@@ -482,6 +482,48 @@ static int __ca_create(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __pulse_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_pulse_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_pulse_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vset = 0;
|
||||
p->_sti_v1 = instru.sti_v1;
|
||||
p->_sti_v2 = instru.sti_v2;
|
||||
p->_sti_v3 = instru.sti_v3;
|
||||
p->_sti_v4 = instru.sti_v4;
|
||||
p->_sti_v5 = instru.sti_v5;
|
||||
p->_sti_v6 = instru.sti_v6;
|
||||
p->_sti_v7 = instru.sti_v7;
|
||||
p->_sti_t1 = instru.sti_t1;
|
||||
p->_sti_t2 = instru.sti_t2;
|
||||
p->_sti_t3 = instru.sti_t3;
|
||||
p->_sti_t4 = instru.sti_t4;
|
||||
p->_sti_t5 = instru.sti_t5;
|
||||
p->_sti_t6 = instru.sti_t6;
|
||||
p->_sti_t7 = instru.sti_t7;
|
||||
p->_sti_t = instru.sti_t1;
|
||||
p->_sti_v = instru.sti_v1;
|
||||
p->_sti_t_flag = 1;
|
||||
p->_sti_cy = instru.sti_cy;
|
||||
p->_sti_lp = instru.sti_loop;
|
||||
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __uni_pulse_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
@@ -746,6 +788,10 @@ int wm_init(void)
|
||||
if (__ca_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_PULSE:
|
||||
if (__pulse_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_UNI_PULSE:
|
||||
if (__uni_pulse_create()) return -2;
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
|
||||
#ifndef Elite_PIN
|
||||
#define Elite_PIN
|
||||
|
||||
#include <ti/drivers/pin/PINCC26XX.h>
|
||||
#include <Board.h>
|
||||
#include <ti/drivers/PIN.h>
|
||||
|
||||
//#define ELITE_PIN_1_5
|
||||
#define ELITE_PIN_1_5_RE
|
||||
|
||||
/* SPI Board */
|
||||
#define Board_SPI0_MISO PIN_UNASSIGNED
|
||||
#define Board_SPI0_MOSI D1
|
||||
#define Board_SPI0_CLK D0
|
||||
#define Board_SPI0_CS PIN_UNASSIGNED
|
||||
|
||||
#define Board_SPI1_MISO IOID_1
|
||||
#define Board_SPI1_MOSI D3
|
||||
#define Board_SPI1_CLK D2
|
||||
#define Board_SPI1_CS PIN_UNASSIGNED
|
||||
|
||||
#define D0 IOID_3
|
||||
#define D1 IOID_4
|
||||
#define D2 IOID_5
|
||||
#define D3 IOID_6
|
||||
#define D4 IOID_7
|
||||
#define D5 IOID_8
|
||||
#define D6 IOID_9
|
||||
#define D7 IOID_10
|
||||
|
||||
#define LOAD0 IOID_13
|
||||
#define LOAD1 IOID_12
|
||||
#define LOAD2 IOID_11
|
||||
|
||||
#define ADC_CS LOAD0, D6
|
||||
#define DAC_CS LOAD0, D7
|
||||
#define ADC_DAC_SPI_MOSI LOAD0, D3
|
||||
#define ADC_DAC_SPI_CLK LOAD0, D2
|
||||
#define LED_MOSI LOAD0, D1
|
||||
#define LED_CLK LOAD0, D0
|
||||
#define MEM_CS LOAD0, D5
|
||||
|
||||
#ifdef ELITE_PIN_1_5
|
||||
#define MEM_HOLD LOAD0, D4
|
||||
#define HIGH_Z_MODE LOAD2, D5
|
||||
#endif
|
||||
#ifdef ELITE_PIN_1_5_RE
|
||||
#define MEM_HOLD LOAD1, D0
|
||||
#define HIGH_Z_MODE LOAD0, D4
|
||||
#endif
|
||||
|
||||
#define Turnon_I_MID LOAD2, D0
|
||||
#define Turnon_I_SMALL LOAD2, D4
|
||||
#define Turnon_I_LARGE LOAD2, D1
|
||||
#define Turnon_V_SMALL LOAD2, D2
|
||||
#define Turnon_V_MID LOAD2, D3
|
||||
#define Turnon_VOUT_SMALL LOAD2, D7
|
||||
#define shutdown_6994 LOAD2, D6
|
||||
|
||||
//#define Turnon10K Turnon_I_MID
|
||||
//#define Turnon200R Turnon_I_LARGE
|
||||
|
||||
/* I2C */
|
||||
#ifdef ELITE_VERSION_1_4
|
||||
#define Board_I2C0_SCL0 PIN_UNASSIGNED
|
||||
#define Board_I2C0_SDA0 PIN_UNASSIGNED
|
||||
#endif
|
||||
|
||||
#define switch_on IOID_14
|
||||
#define enable_10v LOAD1, D5
|
||||
#define enable_5v LOAD1, D6
|
||||
|
||||
PIN_Handle pin_handle;
|
||||
static PIN_State ZM_rst;
|
||||
|
||||
const PIN_Config BLE_IO[] = {
|
||||
// D0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
// D1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
// D2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
// D3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
D4 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
D5 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
D6 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
D7 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
|
||||
LOAD0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
LOAD1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
LOAD2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
|
||||
switch_on | PIN_INPUT_EN | PIN_PULLDOWN, // to sense switch
|
||||
|
||||
PIN_TERMINATE
|
||||
};
|
||||
|
||||
static void add_elite_pin() {
|
||||
// PIN_Status elite15_status;
|
||||
PIN_add(pin_handle,
|
||||
D0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(pin_handle,
|
||||
D1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(pin_handle,
|
||||
D2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(pin_handle,
|
||||
D3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
|
||||
// if(elite15_status != PIN_SUCCESS) {
|
||||
// LED_color(DARKLED, 0x0F, 0x0F, 0x0F);
|
||||
// }
|
||||
}
|
||||
|
||||
static void remove_elite_pin() {
|
||||
PIN_close(pin_handle);
|
||||
pin_handle = PIN_open(&ZM_rst, BLE_IO);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @def BOOSTXL_CC2650MA_SPIName
|
||||
* @brief Enum of SPI names on the CC2650 Booster Pack
|
||||
*/
|
||||
typedef enum BOOSTXL_CC2650MA_SPIName {
|
||||
BOOSTXL_CC2650MA_SPI0 = 0,
|
||||
BOOSTXL_CC2650MA_SPI1 = 1,
|
||||
|
||||
BOOSTXL_CC2650MA_SPICOUNT
|
||||
} BOOSTXL_CC2650MA_SPIName;
|
||||
|
||||
/*
|
||||
* ========================== SPI DMA begin ===================================
|
||||
*/
|
||||
/* Place into subsections to allow the TI linker to remove items properly */
|
||||
#if defined(__TI_COMPILER_VERSION__)
|
||||
#pragma DATA_SECTION(SPI_config, ".const:SPI_config")
|
||||
#pragma DATA_SECTION(spiCC26XXDMAHWAttrs, ".const:spiCC26XXDMAHWAttrs")
|
||||
#endif
|
||||
|
||||
/* Include drivers */
|
||||
#include <ti/drivers/spi/SPICC26XXDMA.h>
|
||||
|
||||
/* SPI objects */
|
||||
SPICC26XXDMA_Object spiCC26XXDMAObjects[BOOSTXL_CC2650MA_SPICOUNT];
|
||||
|
||||
/* SPI configuration structure, describing which pins are to be used */
|
||||
const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[BOOSTXL_CC2650MA_SPICOUNT] = {
|
||||
{
|
||||
.baseAddr = SSI0_BASE,
|
||||
.intNum = INT_SSI0_COMB,
|
||||
.intPriority = ~0,
|
||||
.swiPriority = 0,
|
||||
.powerMngrId = PowerCC26XX_PERIPH_SSI0,
|
||||
.defaultTxBufValue = 0,
|
||||
.rxChannelBitMask = 1<<UDMA_CHAN_SSI0_RX,
|
||||
.txChannelBitMask = 1<<UDMA_CHAN_SSI0_TX,
|
||||
.mosiPin = Board_SPI0_MOSI,
|
||||
.misoPin = Board_SPI0_MISO,
|
||||
.clkPin = Board_SPI0_CLK,
|
||||
.csnPin = Board_SPI0_CS
|
||||
},
|
||||
{
|
||||
.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
|
||||
},
|
||||
};
|
||||
|
||||
/* SPI configuration structure */
|
||||
const SPI_Config SPI_config[] = {
|
||||
{
|
||||
.fxnTablePtr = &SPICC26XXDMA_fxnTable,
|
||||
.object = &spiCC26XXDMAObjects[0],
|
||||
.hwAttrs = &spiCC26XXDMAHWAttrs[0]
|
||||
},
|
||||
{
|
||||
.fxnTablePtr = &SPICC26XXDMA_fxnTable,
|
||||
.object = &spiCC26XXDMAObjects[1],
|
||||
.hwAttrs = &spiCC26XXDMAHWAttrs[1]
|
||||
},
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/*
|
||||
* ========================== SPI DMA end =====================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* ============================= I2C Begin=====================================
|
||||
*/
|
||||
|
||||
#ifdef ELITE_VERSION_1_4
|
||||
|
||||
/* Generic I2C instance identifiers */
|
||||
#define Board_I2C CC2650_MA_I2C0
|
||||
/*!
|
||||
* @def CC2650_LAUNCHXL_I2CName
|
||||
* @brief Enum of I2C names on the CC2650 dev board
|
||||
*/
|
||||
typedef enum CC2650_MA_I2CName {
|
||||
CC2650_MA_I2C0 = 0,
|
||||
|
||||
CC2650_MA_I2CCOUNT
|
||||
} CC2650_MA_I2CName;
|
||||
|
||||
/* 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[CC2650_MA_I2CCOUNT];
|
||||
|
||||
/* I2C configuration structure, describing which pins are to be used */
|
||||
const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[CC2650_MA_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}
|
||||
};
|
||||
/*
|
||||
* ========================== I2C end =========================================
|
||||
*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -34,8 +34,8 @@ static uint8_t headstage_battery_percent() {
|
||||
static void headstage_battery_volt(){
|
||||
uint32_t bat_volt = 0;
|
||||
|
||||
ADC_rxbuf = MEASURE_BATTERY();
|
||||
bat_volt = (uint32_t) ADC_rxbuf;
|
||||
read_adc_raw_data(RIS_ADC_BAT, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
bat_volt = (uint32_t) (spi_ADC_rxbuf[0] << 8) | (uint32_t) (spi_ADC_rxbuf[1]);
|
||||
bat_volt = bat_volt * 12 / 125; //x * 187.5 * 1e-6 * 2 / 125 * 320 * 100 ;
|
||||
// bat_volt = (bat_volt - 1) * 187.5 * 2;
|
||||
|
||||
@@ -53,11 +53,11 @@ static bool EliteADCBattery(){
|
||||
static uint8_t ADCSwitch = 0;
|
||||
bool read_adc_flag = false;
|
||||
if(ADCSwitch == 0){ /**read V**/
|
||||
ADC_rxbuf = MEASURE_BATTERY();
|
||||
read_adc_raw_data(RIS_ADC_BAT, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADCSwitch++;
|
||||
}
|
||||
else if(ADCSwitch == 1){ /**read V**/
|
||||
ADC_rxbuf = MEASURE_BATTERY();
|
||||
read_adc_raw_data(RIS_ADC_BAT, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADCSwitch++;
|
||||
}
|
||||
else if(ADCSwitch == 2){ /**read V(buffer)**/
|
||||
@@ -92,7 +92,7 @@ static void measureBat(){
|
||||
|
||||
uint16_t bat = NotifyVoltBat;
|
||||
if( bat < 768 && bat > 20){
|
||||
latch_single_ctrl(E_LATCH_5V_ENABLE, 0);
|
||||
PIN15_setOutputValue(enable_5v, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,31 +17,33 @@
|
||||
#define VIS_SHIFT_200R 0x80
|
||||
#define VIS_DEVICE_SHINY 0x10
|
||||
#define VIS_SHINY_DIS 0x20
|
||||
#define VIS_CC_ZERO 0x40
|
||||
|
||||
// RIS (real instruction)
|
||||
enum all_mode_e {
|
||||
CURVE_IV = 0x01, // I-V Curve
|
||||
CURVE_IV_CY = 0x02, // Cycle I-V
|
||||
CURVE_VO = 0x03, // Function Generator
|
||||
CURVE_RT = 0x04, // R-T Graph
|
||||
CURVE_VT = 0x05, // V-T Graph
|
||||
CURVE_IT = 0x06, // I-T Graph
|
||||
CURVE_CC = 0x07, // Constant Current (CC)
|
||||
CURVE_IV = 0x01, // I-V Curve //0x10,
|
||||
CURVE_IV_CY = 0x02, // Cycle I-V //0x20,
|
||||
CURVE_VO = 0x03, // Function Generator //0x30,
|
||||
CURVE_RT = 0x04, // R-T Graph //0x40,
|
||||
CURVE_VT = 0x05, // V-T Graph //0x50,
|
||||
CURVE_IT = 0x06, // I-T Graph //0x60,
|
||||
CURVE_CC = 0x07, // Constant Current (CC) //0xD0,
|
||||
CURVE_OCP = 0x08, // Open Circuit Potential (OCP)
|
||||
CURVE_CV = 0x09, // Cyclic Voltammetry (CV)
|
||||
CURVE_LSV = 0x0A, // Linear Sweep Voltammetry (LSV)
|
||||
CURVE_CA = 0x0B, // Chronoamperometric Graph (CA)
|
||||
CURVE_UNI_PULSE = 0x0D, // Pulse Sensing (universal pulse)
|
||||
CURVE_DPV = 0x0E, // Differential Pulse Voltammetry (DPV)
|
||||
CURVE_CV = 0x09, // Cyclic Voltammetry (CV) //0xC0,
|
||||
CURVE_LSV = 0x0A, // Linear Sweep Voltammetry (LSV) //0x02,
|
||||
CURVE_CA = 0x0B, // Chronoamperometric Graph (CA) //0x03,
|
||||
CURVE_PULSE = 0x0C, //0x94,
|
||||
CURVE_UNI_PULSE = 0x0D, // universal pulse
|
||||
CURVE_DPV = 0x0E,
|
||||
CURVE_DPV_SMPRATE = 0x0F,
|
||||
CURVE_DPV_ADVANCE = 0x10,
|
||||
CURVE_DPV_ADVANCE_SMPRATE = 0x11,
|
||||
|
||||
CURVE_CALI_ADC = 0xF1, // Cali ADC - test
|
||||
CURVE_CALI_ADC = 0xF1, // Cali ADC - test //0x92,
|
||||
|
||||
|
||||
SET_SAMPLE_RATE = 0xE0,
|
||||
SET_ADC_DAC_GAIN = 0xE1,
|
||||
SET_SAMPLE_RATE = 0xE0, //0x70,
|
||||
SET_ADC_DAC_GAIN = 0xE1, //0x80,
|
||||
SET_PARA = 0xE2
|
||||
};
|
||||
|
||||
@@ -80,15 +82,19 @@ enum dev_para_e {
|
||||
#define COLOR_CYAN 0x06
|
||||
#define COLOR_MAGENTA 0x07
|
||||
#define COLOR_PURPLE 0x08
|
||||
#define COLOR_WHITE 0x09
|
||||
#define COLOR_WHITE 0x09
|
||||
#define COLOR_YELLOWGREEN 0x0A
|
||||
#define COLOR_EMERALD 0x0B
|
||||
#define COLOR_YELLOW_DARK 0xF3
|
||||
#define COLOR_GREEN_DARK 0xF4
|
||||
#define COLOR_BLUE_DARK 0xF5
|
||||
#define COLOR_CYAN_DARK 0xF6
|
||||
#define COLOR_PURPLE_DARK 0xF8
|
||||
|
||||
#define LEDPowerON() Elite_led_color(COLOR_GREEN)
|
||||
#define WORKLED() Elite_led_color(COLOR_CYAN)
|
||||
#define KEYLED() Elite_led_color(COLOR_YELLOW)
|
||||
#define BT_WAIT_LED() Elite_led_color(COLOR_YELLOWGREEN)
|
||||
|
||||
|
||||
#define BT_WAIT 0x01
|
||||
#define NO_EVENT 0x02
|
||||
|
||||
@@ -23,7 +23,8 @@ static void volt_out() {
|
||||
|
||||
instru.VoltConstant = instru.Vout / 40000 + 25000; //5nV=>usercode
|
||||
DACOutCode = Usercode_Correction_to_DAC(instru.VoutGainLv, instru.VoltConstant);
|
||||
DAC0_W_T(DACOutCode);
|
||||
DAC_outputV(DACOutCode);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -45,7 +46,8 @@ static void vscan_volt_out(void)
|
||||
|
||||
instru.VoltConstant = instru.Vout / 40000 + 25000;//5nV=>usercode
|
||||
DACOutCode = Usercode_Correction_to_DAC(instru.VoutGainLv, instru.VoltConstant);
|
||||
DAC0_W_T(DACOutCode);
|
||||
DAC_outputV(DACOutCode);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -125,18 +127,18 @@ static void DACenable(uint8_t afterRead){
|
||||
*/
|
||||
#define CNT_TO_I_GAIN_3M_IIN_VIN_VOUT_PLOT 7 // 7 * 12ms = 84ms
|
||||
#define CNT_TO_I_GAIN_100K_IIN_VIN_VOUT_PLOT 2 // 2 * 12ms = 24ms
|
||||
#define CNT_TO_I_GAIN_3K_IIN_VIN_VOUT_PLOT 5 // 5 * 12ms = 60ms
|
||||
#define CNT_TO_I_GAIN_100R_IIN_VIN_VOUT_PLOT 5 // 5 * 12ms = 60ms
|
||||
#define CNT_TO_I_GAIN_3K_IIN_VIN_VOUT_PLOT 1 // 1 * 12ms = 12ms
|
||||
#define CNT_TO_I_GAIN_100R_IIN_VIN_VOUT_PLOT 1 // 1 * 12ms = 12ms
|
||||
|
||||
#define CNT_TO_I_GAIN_3M_IIN_VIN_PLOT 10 // 10 * 8ms = 80ms
|
||||
#define CNT_TO_I_GAIN_100K_IIN_VIN_PLOT 3 // 3 * 8ms = 24ms
|
||||
#define CNT_TO_I_GAIN_3K_IIN_VIN_PLOT 5 // 5 * 8ms = 40ms
|
||||
#define CNT_TO_I_GAIN_100R_IIN_VIN_PLOT 5 // 5 * 8ms = 40ms
|
||||
#define CNT_TO_I_GAIN_3K_IIN_VIN_PLOT 2 // 2 * 8ms = 16ms
|
||||
#define CNT_TO_I_GAIN_100R_IIN_VIN_PLOT 2 // 2 * 8ms = 16ms
|
||||
|
||||
#define CNT_TO_I_GAIN_3M_IT_PLOT 20 // 20 * 4ms = 80ms
|
||||
#define CNT_TO_I_GAIN_100K_IT_PLOT 5 // 5 * 4ms = 20ms
|
||||
#define CNT_TO_I_GAIN_3K_IT_PLOT 5 // 5 * 4ms = 20ms
|
||||
#define CNT_TO_I_GAIN_100R_IT_PLOT 5 // 5 * 4ms = 20ms
|
||||
#define CNT_TO_I_GAIN_3K_IT_PLOT 3 // 3 * 4ms = 12ms
|
||||
#define CNT_TO_I_GAIN_100R_IT_PLOT 3 // 3 * 4ms = 12ms
|
||||
|
||||
static void read_Iin_change_gain(uint16_t plot_type)
|
||||
{
|
||||
@@ -154,8 +156,8 @@ static void read_Iin_change_gain(uint16_t plot_type)
|
||||
if (instru.IinADCAutoGainEn > 1)
|
||||
return;
|
||||
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
MEAS_CURR(wm) = DecodeADCValue(instru.IinADCGainLv, RIS_ADC_IIN, ADC_rxbuf);
|
||||
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
MEAS_CURR(wm) = DecodeADCValue(instru.IinADCGainLv, RIS_ADC_IIN, spi_ADC_rxbuf);
|
||||
|
||||
if (instru.IinADCAutoGainEn) {
|
||||
AutoGainChangeIin(MEAS_CURR(wm), plot, &no_rec_time);
|
||||
@@ -223,8 +225,8 @@ static void read_Vin_change_gain(void)
|
||||
return;
|
||||
|
||||
/* read Vin and do NOT record the Vin after changing gain twice */
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
MEAS_VIN(wm) = DecodeADCValue(instru.VinADCGainLv, RIS_ADC_VIN, ADC_rxbuf);
|
||||
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
MEAS_VIN(wm) = DecodeADCValue(instru.VinADCGainLv, RIS_ADC_VIN, spi_ADC_rxbuf);
|
||||
if (instru.VinADCAutoGainEn) {
|
||||
AutoGainChangeVin(MEAS_VIN(wm));
|
||||
} else {
|
||||
@@ -251,8 +253,8 @@ static void read_Vout_change_gain(void)
|
||||
void *wm = wm_get();
|
||||
|
||||
/* read Vout and do NOT record the Vout after changing gain twice */
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
MEAS_VOUT(wm) = DecodeADCValue(0, RIS_ADC_VOUT, ADC_rxbuf);
|
||||
read_adc_raw_data(RIS_ADC_VOUT, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
MEAS_VOUT(wm) = DecodeADCValue(0, RIS_ADC_VOUT, spi_ADC_rxbuf);
|
||||
|
||||
if (volt_rec_en == false) {
|
||||
rec_cnt++;
|
||||
@@ -429,7 +431,7 @@ static void Iin_Vin_Vout_Plot(uint32_t time)
|
||||
if (batteryCheck_flag && tempCheck_flag) {
|
||||
read_adc_flag = EliteADCBattery();
|
||||
if (!read_adc_flag) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt = 5;
|
||||
}
|
||||
|
||||
@@ -461,7 +463,7 @@ static void Iin_Vin_Vout_Plot(uint32_t time)
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 1) {
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 2) {
|
||||
@@ -470,7 +472,7 @@ static void Iin_Vin_Vout_Plot(uint32_t time)
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 3) {
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
read_adc_raw_data(RIS_ADC_VOUT, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 4) {
|
||||
@@ -479,7 +481,7 @@ static void Iin_Vin_Vout_Plot(uint32_t time)
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 5) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt = 0;
|
||||
}
|
||||
|
||||
@@ -496,7 +498,7 @@ static void Iin_Vin_Plot(void)
|
||||
if (batteryCheck_flag && tempCheck_flag) {
|
||||
read_adc_flag = EliteADCBattery();
|
||||
if (!read_adc_flag) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt = 3;
|
||||
}
|
||||
|
||||
@@ -517,7 +519,7 @@ static void Iin_Vin_Plot(void)
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 1) {
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 2) {
|
||||
@@ -526,7 +528,7 @@ static void Iin_Vin_Plot(void)
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 3) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt = 0;
|
||||
}
|
||||
|
||||
@@ -547,7 +549,7 @@ static void IT_Plot(uint32_t time)
|
||||
if (batteryCheck_flag || tempCheck_flag) {
|
||||
read_adc_flag = EliteADCBattery();
|
||||
if (!read_adc_flag) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt = 1;
|
||||
}
|
||||
|
||||
@@ -558,7 +560,7 @@ static void IT_Plot(uint32_t time)
|
||||
* 1 - read Iin and reset ADC_cnt
|
||||
*/
|
||||
if (ADC_cnt == 0) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt++;
|
||||
|
||||
return;
|
||||
@@ -590,7 +592,7 @@ static void VT_Plot(void)
|
||||
if (batteryCheck_flag && tempCheck_flag) {
|
||||
EliteADCBattery();
|
||||
if (!batteryCheck_flag) {
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt = 1;
|
||||
}
|
||||
|
||||
@@ -601,7 +603,7 @@ static void VT_Plot(void)
|
||||
* 1 - read Vin and reset ADC_cnt
|
||||
*/
|
||||
if (ADC_cnt == 0) {
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt++;
|
||||
|
||||
return;
|
||||
@@ -627,7 +629,7 @@ static void Vout_Plot(void)
|
||||
if (batteryCheck_flag && tempCheck_flag) {
|
||||
EliteADCBattery();
|
||||
if (!batteryCheck_flag) {
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
read_adc_raw_data(RIS_ADC_VOUT, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt = 1;
|
||||
}
|
||||
|
||||
@@ -638,7 +640,7 @@ static void Vout_Plot(void)
|
||||
* 1 - read Vout and reset ADC_cnt
|
||||
*/
|
||||
if (ADC_cnt == 0) {
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
read_adc_raw_data(RIS_ADC_VOUT, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt++;
|
||||
|
||||
return;
|
||||
@@ -673,8 +675,8 @@ static void cali_IT_plot(void) {
|
||||
if (instru.IinADCAutoGainEn) {
|
||||
MEAS_CURR(wm) = 0xFFFF;
|
||||
} else {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
MEAS_CURR(wm) = (int32_t) ADC_rxbuf;
|
||||
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
MEAS_CURR(wm) = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
|
||||
if (lastIinADCGainLevel != instru.IinADCGainLv) {
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
}
|
||||
@@ -727,14 +729,14 @@ static void cali_IT_plot(void) {
|
||||
}
|
||||
|
||||
if (ADC_cnt == 1) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ADC_cnt == 2) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt = 0;
|
||||
|
||||
return;
|
||||
@@ -761,8 +763,8 @@ static void cali_VT_plot(void) {
|
||||
if (instru.VinADCAutoGainEn) {
|
||||
MEAS_VIN(wm) = 0xFFFF;
|
||||
} else {
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
MEAS_VIN(wm) = (int32_t) ADC_rxbuf;
|
||||
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
MEAS_VIN(wm) = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
|
||||
if (lastVinADCGainLv != instru.VinADCGainLv) VinADCGainCtrl(instru.VinADCGainLv);
|
||||
}
|
||||
|
||||
@@ -813,14 +815,14 @@ static void cali_VT_plot(void) {
|
||||
}
|
||||
|
||||
if (ADC_cnt == 1) {
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ADC_cnt == 2) {
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt = 0;
|
||||
|
||||
return;
|
||||
@@ -844,8 +846,8 @@ static void cali_Vout_plot(void) {
|
||||
*/
|
||||
if (ADC_cnt == 0) {
|
||||
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
MEAS_VOUT(wm) = (int32_t) ADC_rxbuf;
|
||||
read_adc_raw_data(RIS_ADC_VOUT, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
MEAS_VOUT(wm) = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
|
||||
|
||||
if (volt_rec_en == false) {
|
||||
rec_cnt++;
|
||||
@@ -888,14 +890,14 @@ static void cali_Vout_plot(void) {
|
||||
}
|
||||
|
||||
if (ADC_cnt == 1) {
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
read_adc_raw_data(RIS_ADC_VOUT, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ADC_cnt == 2) {
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
read_adc_raw_data(RIS_ADC_VOUT, spi_ADC_rxbuf, spi_ADC_txbuf);
|
||||
ADC_cnt = 0;
|
||||
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef HEADSTAGE_POWER_H
|
||||
#define HEADSTAGE_POWER_H
|
||||
|
||||
#include <ti/drivers/Power.h>
|
||||
#include <ti/drivers/power/PowerCC26XX.h>
|
||||
|
||||
#define headstage_power_shutdown() Power_shutdown(NULL, 0)
|
||||
|
||||
#endif // HEADSTAGE_POWER_H
|
||||
@@ -3,10 +3,10 @@
|
||||
#define VERSION_DATE
|
||||
|
||||
#define VERSION_DATE_YEAR 22
|
||||
#define VERSION_DATE_MONTH 8
|
||||
#define VERSION_DATE_DAY 2
|
||||
#define VERSION_DATE_HOUR 11
|
||||
#define VERSION_DATE_MINUTE 33
|
||||
#define VERSION_DATE_MONTH 4
|
||||
#define VERSION_DATE_DAY 13
|
||||
#define VERSION_DATE_HOUR 14
|
||||
#define VERSION_DATE_MINUTE 16
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
|
||||
@@ -420,7 +420,38 @@ characteristic change event
|
||||
/*===================================
|
||||
==== headstage general variable ====
|
||||
==================================*/
|
||||
// Internal Events for RTOS application
|
||||
#ifndef RTOSPARA
|
||||
#define RTOSPARA
|
||||
#define SBP_STATE_CHANGE_EVT 0x0001
|
||||
#define SBP_CHAR_CHANGE_EVT 0x0002
|
||||
#define SBP_PERIODIC_EVT 0x0004
|
||||
#define SBP_CONN_EVT_END_EVT 0x0008
|
||||
#define SBP_KEY_CHANGE_EVT 0x0010
|
||||
#endif
|
||||
|
||||
/**************************
|
||||
controller version
|
||||
EliteZM02 0,2,1,5
|
||||
EliteZM15 0,2,1,6
|
||||
EliteZM_pulsefly 0,2,1,7
|
||||
**************************/
|
||||
// product information
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0 // 0:Elite, 1:Neulive
|
||||
#define MINOR_PRODUCT_NUMBER 2 // 1:Elite_legacy(Ori_Neulive) 2:Elite_zm 3:Elite_bat
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 6
|
||||
|
||||
#define ELITE_VERSION_1_4
|
||||
|
||||
// buffer size
|
||||
#define BLE_CIS_BUFF_CHAR SIMPLEPROFILE_CHAR2
|
||||
#define BLE_INS_BUFF_CHAR SIMPLEPROFILE_CHAR3
|
||||
#define BLE_DAT_BUFF_CHAR SIMPLEPROFILE_CHAR4
|
||||
#define BLE_CIS_BUFF_SIZE SIMPLEPROFILE_CHAR2_LEN
|
||||
#define BLE_INS_BUFF_SIZE SIMPLEPROFILE_CHAR3_LEN
|
||||
#define BLE_DAT_BUFF_SIZE SIMPLEPROFILE_CHAR4_LEN
|
||||
|
||||
enum send_ins_para_order_e {
|
||||
PARA_1 = 0x01,
|
||||
@@ -456,9 +487,26 @@ static uint8_t ins_buf[BLE_INS_BUFF_SIZE] = {0};
|
||||
static uint8_t not_buf[BLE_DAT_BUFF_SIZE] = {0};
|
||||
static uint8_t cis_buf[BLE_CIS_BUFF_SIZE] = {0};
|
||||
|
||||
/**
|
||||
* Latch initialize
|
||||
*/
|
||||
#define LATCH_BUFF_SIZE 8 // define latch
|
||||
struct _LH{
|
||||
bool LATCH0[LATCH_BUFF_SIZE];
|
||||
bool LATCH1[LATCH_BUFF_SIZE];
|
||||
bool LATCH2[LATCH_BUFF_SIZE];
|
||||
uint8_t LoadState;
|
||||
} LH= {0};
|
||||
static void InitLH();
|
||||
static void Init_Elite15_PIN();
|
||||
|
||||
|
||||
static Clock_Struct periodicClock;
|
||||
static bool PeriodicEvent = false;
|
||||
static bool InitPeriodicEvent = true;
|
||||
static bool megaStiEnable = false;
|
||||
static ICall_Semaphore semaphore;
|
||||
static uint16_t events;
|
||||
|
||||
/*=====================================
|
||||
==== headstage function prototype ====
|
||||
@@ -466,7 +514,7 @@ static bool megaStiEnable = false;
|
||||
/**
|
||||
* ZM function
|
||||
*/
|
||||
static void device_init(void);
|
||||
static void ZM_init();
|
||||
|
||||
/**
|
||||
* update the instruction buffer major content.
|
||||
@@ -523,16 +571,20 @@ static bool stiFirstTime;
|
||||
static uint8_t lastVinADCGainLv;
|
||||
static uint8_t lastIinADCGainLevel;
|
||||
|
||||
// static void update_latch_status (uint32_t latch_num, uint32_t elite_pin, bool highlow);
|
||||
static void update_latch_status (uint32_t latch_num, uint32_t elite_pin, bool highlow);
|
||||
|
||||
// ADC function
|
||||
static void headstage_battery_volt();
|
||||
static bool EliteADCBattery();
|
||||
static void VinADCGainCtrl(uint8_t VinADCLevel);
|
||||
static void VoutGainControl(uint8_t VOUTLevel);
|
||||
static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow);
|
||||
|
||||
// Elite key detection & turn on/ shutdown function (peripheral hardware control)
|
||||
static void Elite_led_color(uint16_t color);
|
||||
static void ModeLED(uint16_t modeStatus);
|
||||
static bool If10Von = false;
|
||||
static void TurnOn10V();
|
||||
|
||||
// periodic event control
|
||||
static void EliteADCControl(uint32_t time);
|
||||
@@ -553,18 +605,31 @@ static void pulse_vscan(void);
|
||||
|
||||
//mode (notify)
|
||||
static void initDATBuf();
|
||||
#include "EliteNotify.h"
|
||||
|
||||
#include "EliteADC.h"
|
||||
#include "EliteInstruction.h"
|
||||
#include "EliteDAC.h"
|
||||
#include "EliteSPI.h"
|
||||
#include "Elite_PIN.h"
|
||||
#include "Elite15_PIN.h"
|
||||
|
||||
#ifdef ELITE_VERSION_1_4
|
||||
#include "EliteI2C.h"
|
||||
#endif
|
||||
|
||||
#include "EliteDeviceCorrection.h"
|
||||
#include "EliteNotify.h"
|
||||
#include "EliteFlagCTInit.h"
|
||||
#include "EliteLatchInit.h"
|
||||
#include "EliteReset.h"
|
||||
#include "EliteLED.h"
|
||||
#include "EliteKeyDetect.h"
|
||||
#include "Elite_mode_ADC_DAC.h"
|
||||
#include "scan_volt.h"
|
||||
#include "impedance_meter.h"
|
||||
#include "Elite_version.h"
|
||||
#include "Elite_batt.h"
|
||||
#include "Elite_power.h"
|
||||
|
||||
// update instruction for Z meter
|
||||
static void update_ZM_instruction(uint8 *ins) {
|
||||
@@ -585,13 +650,14 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.Vmax = (int32_t)VMAX(instru.Ve1,instru.Ve2);
|
||||
instru.Vmin = (int32_t)VMIN(instru.Ve1,instru.Ve2);
|
||||
instru.directionInit = VDIRECTION(instru.Ve1,instru.Ve2);
|
||||
instru.steptime = get_step_time(ins[9]); //5000;10000;20000;
|
||||
instru.steptime = (uint32_t)(ins[9]);
|
||||
instru.steptime = OldStep2NewStepTime(instru.steptime); //5000;10000;20000;
|
||||
instru.step = ((uint32_t)(ins[7]) << 8) | (uint32_t)(ins[8]);//1~1000 = 0.1mv ~ 100mv
|
||||
instru.step = instru.step * 100000 / instru.steptime;
|
||||
STEP_TO_VSETRATE(instru.step);
|
||||
instru.VsetRate = VsetRateTable[instru.VsetRateIndex];//N
|
||||
instru.cycleNumber = 1;
|
||||
instru.hign_z_en = ins[11] & 0x0F;
|
||||
instru.hign_z_en = ~(ins[11] & 0x0F);
|
||||
instru.notifyRate = ((uint32_t)ins[12] << 8) | (uint32_t)ins[13];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
|
||||
@@ -615,13 +681,14 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.Vmax = (int32_t)VMAX(instru.Ve1,instru.Ve2);
|
||||
instru.Vmin = (int32_t)VMIN(instru.Ve1,instru.Ve2);
|
||||
instru.directionInit = VDIRECTION(instru.Ve1,instru.Ve2);
|
||||
instru.steptime = get_step_time(ins[9]); //5000;10000;20000;
|
||||
instru.steptime = (uint32_t)(ins[9]);
|
||||
instru.steptime = OldStep2NewStepTime(instru.steptime); //5000;10000;20000;
|
||||
instru.step = ((uint32_t)(ins[7]) << 8) | (uint32_t)(ins[8]);//1~1000 = 0.1mv ~ 100mv
|
||||
instru.step = instru.step * 100000 / instru.steptime;
|
||||
STEP_TO_VSETRATE(instru.step);
|
||||
instru.VsetRate = VsetRateTable[instru.VsetRateIndex];//N
|
||||
instru.cycleNumber = ((uint16_t)(ins[10]) << 8) | (uint16_t)(ins[11]);
|
||||
instru.hign_z_en = ins[13] & 0x0F;
|
||||
instru.hign_z_en = ~(ins[13] & 0x0F);
|
||||
instru.notifyRate = ((uint32_t)ins[14] << 8) | (uint32_t)ins[15];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
|
||||
@@ -638,10 +705,10 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
}
|
||||
|
||||
case CURVE_VO: {
|
||||
instru.eliteFxn = CURVE_VO; //0x3000037530000103E8
|
||||
instru.eliteFxn = CURVE_VO;
|
||||
instru.Ve1 = ((uint16_t)ins[3] << 8) | (uint16_t)ins[4];
|
||||
instru.Vinit = (int32_t)instru.Ve1;
|
||||
instru.hign_z_en = ins[6] & 0x0F;
|
||||
instru.hign_z_en = ~(ins[6] & 0x0F);
|
||||
|
||||
if(instru.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE){
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
@@ -664,7 +731,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.VsetRate = 2;
|
||||
instru.Ve1 = ((uint16_t)ins[3] << 8) | (uint16_t)ins[4];
|
||||
instru.Vinit = (int32_t)instru.Ve1;
|
||||
instru.hign_z_en = ins[6] & 0x0F;
|
||||
instru.hign_z_en = ~(ins[6] & 0x0F);
|
||||
|
||||
if(instru.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE){
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
@@ -681,7 +748,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.eliteFxn = CURVE_VT;
|
||||
instru.notifyRate = ((uint32_t)ins[5] << 8) | (uint32_t)ins[6];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.hign_z_en = ins[4] & 0x0F;
|
||||
instru.hign_z_en = ~(ins[4] & 0x0F);
|
||||
|
||||
ModeLED(WORKING);
|
||||
|
||||
@@ -694,7 +761,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.Ve1 = ((uint16_t)ins[3] << 8) | (uint16_t)ins[4];
|
||||
instru.Vinit = (int32_t)instru.Ve1;
|
||||
instru.hign_z_en = ins[6] & 0x0F;
|
||||
instru.hign_z_en = ~(ins[6] & 0x0F);
|
||||
|
||||
if(instru.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE){
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
@@ -715,9 +782,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.constantCurrent = (uint32_t)(ins[4]) << 24 | (uint32_t)(ins[5]) << 16 | (uint32_t)(ins[6]) << 8 | (uint32_t)(ins[7]);
|
||||
instru.Vmax = (uint32_t)(ins[8]) << 8 | (uint32_t)(ins[9]);
|
||||
instru.Vmin = (uint32_t)(ins[10]) << 8 | (uint32_t)(ins[11]);
|
||||
instru.hign_z_en = ins[13] & 0x0F;
|
||||
instru.cc_resistance = ins[16] & 0xF0; // 0:vout has 0R 1:vout has 100R
|
||||
instru.cc_cp_speed = ins[16] & 0x0F; // 0:low 1:normal 2:high
|
||||
instru.hign_z_en = ~(ins[13] & 0x0F);
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
|
||||
@@ -756,7 +821,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.cycleNumber = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
|
||||
instru.notifyRate = (uint32_t)(ins[8]) << 8 | (uint32_t)(ins[9]);
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.hign_z_en = ins[7] & 0x0F;
|
||||
instru.hign_z_en = ~(ins[7] & 0x0F);
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
ModeLED(WORKING);
|
||||
@@ -785,7 +850,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.eliteFxn = CURVE_LSV;
|
||||
instru.notifyRate = (uint32_t)(ins[6]) << 8 | (uint32_t)(ins[7]);
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.hign_z_en = ins[5] & 0x0F;
|
||||
instru.hign_z_en = ~(ins[5] & 0x0F);
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
|
||||
@@ -801,7 +866,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.notifyRate = (uint32_t)(ins[7]) << 8 | (uint32_t)(ins[8]);
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.VsetRate = VsetRateTable[0];
|
||||
instru.hign_z_en = ins[6] & 0x0F;
|
||||
instru.hign_z_en = ~(ins[6] & 0x0F);
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
|
||||
@@ -813,7 +878,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.eliteFxn = CURVE_OCP;
|
||||
instru.notifyRate = ((uint32_t)ins[5] << 8) | (uint32_t)ins[6];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.hign_z_en = ins[4] & 0x0F;;
|
||||
instru.hign_z_en = 0;
|
||||
|
||||
ModeLED(WORKING);
|
||||
|
||||
@@ -852,6 +917,10 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
break;
|
||||
}
|
||||
case RIS_DAC_VOUT : {
|
||||
// instru.VoutGainLv = ins[4];
|
||||
// if(instru.VoutGainLv == VOUT_GAIN_AUTO){
|
||||
// instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
// }
|
||||
instru.VoutGainLv = ins[4];
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
break;
|
||||
@@ -859,16 +928,11 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
case RIS_HIGH_Z : {
|
||||
switch(ins[4]) {
|
||||
case 0x00 : {
|
||||
if (PeriodicEvent) {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, 0); // 0 => open high_z mode
|
||||
}
|
||||
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0 => open high_z mode
|
||||
break;
|
||||
}
|
||||
case 0x01 : {
|
||||
if (PeriodicEvent) {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, 1); // 1 => close high_z mode
|
||||
}
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
break;
|
||||
}
|
||||
default : {
|
||||
@@ -905,7 +969,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.AdcChannel = RIS_DAC_VOUT;
|
||||
instru.notifyRate = 1000;
|
||||
instru.VoltConstant = ( ((uint16_t)(ins[4])) << 8) | (uint16_t)(ins[5]); // output voltage
|
||||
DAC0_W_T(instru.VoltConstant);
|
||||
DAC_outputV(instru.VoltConstant); //UserCode -> DAC code -> DAC out
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
@@ -916,6 +980,44 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_PULSE: {
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
instru.notifyRate = 100;
|
||||
if (ins[3] == PARA_1) {
|
||||
instru.sti_t1 = (int32_t)(ins[4]) << 24 | (int32_t)(ins[5]) << 16 | (int32_t)(ins[6]) << 8 | (int32_t)(ins[7]);
|
||||
instru.sti_t2 = (int32_t)(ins[8]) << 24 | (int32_t)(ins[9]) << 16 | (int32_t)(ins[10]) << 8 | (int32_t)(ins[11]);
|
||||
instru.sti_t3 = (int32_t)(ins[12]) << 24 | (int32_t)(ins[13]) << 16 | (int32_t)(ins[14]) << 8 | (int32_t)(ins[15]);
|
||||
instru.sti_t4 = (int32_t)(ins[16]) << 24 | (int32_t)(ins[17]) << 16 | (int32_t)(ins[18]) << 8 | (int32_t)(ins[19]);
|
||||
} else if (ins[3] == PARA_2) {
|
||||
instru.sti_t5 = (int32_t)(ins[4]) << 24 | (int32_t)(ins[5]) << 16 | (int32_t)(ins[6]) << 8 | (int32_t)(ins[7]);
|
||||
instru.sti_v1 = 25000; //8~11
|
||||
instru.sti_v2 = 50000; //12~15 //41406.43161.
|
||||
instru.sti_v3 = 25000; //16~19
|
||||
} else if (ins[3] == PARA_3) {
|
||||
instru.sti_v4 = 25000; //4~7
|
||||
instru.sti_v5 = 25000; //8~11
|
||||
instru.sti_cy = (uint16_t)(ins[12]); //12
|
||||
instru.sti_loop = (uint16_t)(ins[13]); //13
|
||||
} else if (ins[3] == PARA_4) {
|
||||
instru.sti_t6 = (int32_t)(ins[4]) << 24 | (int32_t)(ins[5]) << 16 | (int32_t)(ins[6]) << 8 | (int32_t)(ins[7]); //4~7
|
||||
instru.sti_t7 = (int32_t)(ins[8]) << 24 | (int32_t)(ins[9]) << 16 | (int32_t)(ins[10]) << 8 | (int32_t)(ins[11]); //8~11
|
||||
instru.sti_v6 = 25000; //12~15
|
||||
instru.sti_v7 = 25000;; //16~19
|
||||
instru.sti_t1 = VALUE_ZERO_TO_ONE(instru.sti_t1);
|
||||
instru.sti_t2 = VALUE_ZERO_TO_ONE(instru.sti_t2);
|
||||
instru.sti_t3 = VALUE_ZERO_TO_ONE(instru.sti_t3);
|
||||
instru.sti_t4 = VALUE_ZERO_TO_ONE(instru.sti_t4);
|
||||
instru.sti_t5 = VALUE_ZERO_TO_ONE(instru.sti_t5);
|
||||
instru.sti_t6 = VALUE_ZERO_TO_ONE(instru.sti_t6);
|
||||
instru.sti_t7 = VALUE_ZERO_TO_ONE(instru.sti_t7);
|
||||
megaStiEnable = true;
|
||||
} else if (ins[3] == PARA_17) {
|
||||
instru.eliteFxn = CURVE_PULSE;
|
||||
ModeLED(WORKING);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_UNI_PULSE: {
|
||||
if (ins[3] == PARA_1) {
|
||||
uint8_t seg_index = ins[12];
|
||||
@@ -956,7 +1058,6 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
|
||||
} else if (ins[3] == PARA_FINAL) {
|
||||
instru.eliteFxn = CURVE_UNI_PULSE;
|
||||
instru.hign_z_en = ins[5] & 0x0F;
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
|
||||
@@ -1021,8 +1122,6 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
dpv_curr_rec_percent_max[1] = (uint32_t)ins[11];
|
||||
|
||||
} else if (ins[3] == PARA_FINAL) {
|
||||
instru.hign_z_en = ins[5] & 0x0F;
|
||||
|
||||
dpv_e_init = UC_TO_5NV(dpv_e_init);
|
||||
dpv_e_final = UC_TO_5NV(dpv_e_final);
|
||||
dpv_amp = UC_TO_5NV(dpv_amp);
|
||||
@@ -1131,8 +1230,6 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
dpv_cycle = (uint16_t)ins[9] << 8 | (uint16_t)ins[10];
|
||||
|
||||
} else if (ins[3] == PARA_FINAL) {
|
||||
instru.hign_z_en = ins[5] & 0x0F;
|
||||
|
||||
dpv_e_init = UC_TO_5NV(dpv_e_init);
|
||||
dpv_e_final = UC_TO_5NV(dpv_e_final);
|
||||
dpv_amp = UC_TO_5NV(dpv_amp);
|
||||
@@ -1316,63 +1413,15 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
}
|
||||
|
||||
case LED_DEV_TEST: {
|
||||
led_rainbow(LED_BR_LV8);
|
||||
if (ins[4] == 0) {
|
||||
Elite_led_color(ins[5]);
|
||||
} else if (ins[4] == 1) {
|
||||
LED_color(LIGHTLED, ins[5], ins[6], ins[7]);
|
||||
} else if (ins[4] == 2) {
|
||||
LED_color(DARKLED, ins[5], ins[6], ins[7]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x50: {
|
||||
initCISBuf();
|
||||
|
||||
cis_buf[0] = 2;
|
||||
cis_buf[1] = (uint8_t) ADC_rxbuf >> 8;
|
||||
cis_buf[2] = (uint8_t) ADC_rxbuf;
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case 0x51: {
|
||||
initCISBuf();
|
||||
cis_buf[0] = 2;
|
||||
cis_buf[1] = (uint8_t) ADC_rxbuf >> 8;
|
||||
cis_buf[2] = (uint8_t) ADC_rxbuf;
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case 0x61: {
|
||||
dac_ldac_mode(ins[4], ins[5]);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x62: {
|
||||
dac_clear_mode();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x63: {
|
||||
dac_power_control_mode(ins[4], ins[5], ins[6]);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x64: {
|
||||
dac_linearity_mode(ins[4]);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x65: {
|
||||
uint16_t volts = (uint16_t)ins[6] << 8 | ins[7];
|
||||
dac_write_mode(ins[4], ins[5], volts);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x66: {
|
||||
uint16_t volts = (uint16_t)ins[6] << 8 | ins[7];
|
||||
DAC0_W_T(volts);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1410,12 +1459,12 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
PeriodicEvent = true;
|
||||
InitPeriodicEvent = true; // need to create a WorkModeData?
|
||||
mode_init = true;
|
||||
// InitGPT();
|
||||
InitGPT();
|
||||
break;
|
||||
}
|
||||
|
||||
case VIS_FUH: {
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_MAGENTA);
|
||||
LED_color(DARKLED, 0x0F, 0x00, 0x0F);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1428,19 +1477,36 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
}
|
||||
|
||||
case VIS_DEVICE_SHINY: {
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_PURPLE);
|
||||
Elite_led_color(COLOR_PURPLE);
|
||||
break;
|
||||
}
|
||||
|
||||
case VIS_SHINY_DIS: {
|
||||
if (PeriodicEvent) {
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_CYAN);
|
||||
WORKLED();
|
||||
} else if (!PeriodicEvent) {
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_GREEN);
|
||||
LEDPowerON();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VIS_CC_ZERO: {
|
||||
instru.eliteFxn = CURVE_OCP;
|
||||
instru.notifyRate = 500;
|
||||
|
||||
if (instru.notifyRate > 1000) {
|
||||
// slow notify rate, < 10sps, auto gain changer only use ADC gain level = 1.2.3.4
|
||||
instru.gain_switch_on = 0b11110000;
|
||||
|
||||
} else {
|
||||
// fast notify rate, >= 10sps, auto gain changer only use ADC gain level = 1.2.3
|
||||
instru.gain_switch_on = 0b01110000;
|
||||
}
|
||||
|
||||
ModeLED(PRE_WORK);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
@@ -1450,6 +1516,11 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
|
||||
case INS_TYPE_CIS: {
|
||||
switch (oper) {
|
||||
case 0x00: {
|
||||
I2CWrite(0x01, 0xAB);
|
||||
break;
|
||||
}
|
||||
|
||||
case CIS_VERSION: {
|
||||
initCISBuf();
|
||||
cis_buf[0] = 6; //data len
|
||||
@@ -1505,6 +1576,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
static void ZM_instruction_update_handle(uint8_t characteristic) {
|
||||
switch (characteristic) {
|
||||
case BLE_INS_BUFF_CHAR:
|
||||
// LED_color(0xf8, 0x00, 0xFF, 0xFF);
|
||||
SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR3, ins_buf);
|
||||
update_ZM_instruction(ins_buf);
|
||||
break;
|
||||
@@ -1513,85 +1585,116 @@ static void ZM_instruction_update_handle(uint8_t characteristic) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DEVICE_NAME
|
||||
#error "DEVICE_NAME not defined"
|
||||
#endif
|
||||
|
||||
#ifndef MAJOR_PRODUCT_NUMBER
|
||||
#error "MAJOR_PRODUCT_NUMBER not defined"
|
||||
#endif
|
||||
|
||||
#ifndef MINOR_PRODUCT_NUMBER
|
||||
#error "MINOR_PRODUCT_NUMBER not defined"
|
||||
#endif
|
||||
|
||||
#ifndef MAJOR_VERSION_NUMBER
|
||||
#error "MAJOR_VERSION_NUMBER not defined"
|
||||
#endif
|
||||
|
||||
#ifndef MINOR_VERSION_NUMBER
|
||||
#error "MINOR_VERSION_NUMBER not defined"
|
||||
#endif
|
||||
|
||||
#include "devinfoservice.h"
|
||||
#include "gapgattserver.h"
|
||||
#include "gattservapp.h"
|
||||
|
||||
struct date_t {
|
||||
uint8_t year;
|
||||
uint8_t month;
|
||||
uint8_t day;
|
||||
};
|
||||
static void headstage_init_device_info() {
|
||||
char * date = __DATE__;
|
||||
uint8_t year = 10 * (date[9] - '0') + (date[10] - '0');
|
||||
uint8_t month = 0;
|
||||
|
||||
struct device_info_t {
|
||||
struct date_t date;
|
||||
};
|
||||
|
||||
struct device_info_t device_info;
|
||||
|
||||
void get_date(struct date_t *date)
|
||||
{
|
||||
const char *months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
struct date_t *d = date;
|
||||
char year_s[5] = {0};
|
||||
char month_s[4] = {0};
|
||||
char day_s[3] = {0};
|
||||
int i;
|
||||
char date_now[] = __DATE__;
|
||||
|
||||
memcpy(year_s, date_now + 9, 2);
|
||||
memcpy(month_s, date_now, 3);
|
||||
memcpy(day_s, date_now + 4, 2);
|
||||
|
||||
d->year = atoi(year_s);
|
||||
d->day = atoi(day_s);
|
||||
for (i=0; i<12; i++) {
|
||||
if (!strcmp(month_s, months[i])) {
|
||||
d->month = i + 1;
|
||||
break;
|
||||
switch (date[0]) {
|
||||
case 'J':
|
||||
// Jan, January
|
||||
// Jun, June
|
||||
// Jul, July
|
||||
if (date[1] == 'a') {
|
||||
month = 1;
|
||||
} else if (date[2] == 'n') {
|
||||
month = 6;
|
||||
} else {
|
||||
month = 7;
|
||||
}
|
||||
break;
|
||||
case 'F':
|
||||
// Feb, February
|
||||
month = 2;
|
||||
break;
|
||||
case 'M':
|
||||
// Mar, March
|
||||
// May, May
|
||||
if (date[2] == 'r') {
|
||||
month = 3;
|
||||
} else {
|
||||
month = 5;
|
||||
}
|
||||
break;
|
||||
case 'A':
|
||||
// Apr, April
|
||||
// Ang, August
|
||||
if (date[1] == 'p') {
|
||||
month = 4;
|
||||
} else {
|
||||
month = 8;
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
// Sep, September
|
||||
month = 9;
|
||||
break;
|
||||
case 'O':
|
||||
// Oct, October
|
||||
month = 10;
|
||||
break;
|
||||
case 'N':
|
||||
// Nov, November
|
||||
month = 11;
|
||||
break;
|
||||
case 'D':
|
||||
// Dec, December
|
||||
month = 12;
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void headstage_init_device_info() {
|
||||
uint8_t scan_rsp_data[64] = {9};
|
||||
uint8_t *p = scan_rsp_data;
|
||||
struct device_info_t *dev = &device_info;
|
||||
int i;
|
||||
|
||||
get_date(&device_info.date);
|
||||
|
||||
*p++ = sizeof(DEVICE_NAME); // 10
|
||||
*p++ = GAP_ADTYPE_LOCAL_NAME_COMPLETE; // 09
|
||||
for (i=0; i<sizeof(DEVICE_NAME)-1; i++) {
|
||||
uint8_t scanRspData[64];
|
||||
uint8_t *p = scanRspData;
|
||||
*p++ = sizeof(DEVICE_NAME);
|
||||
*p++ = GAP_ADTYPE_LOCAL_NAME_COMPLETE;
|
||||
for (unsigned int i = 0; i < sizeof(DEVICE_NAME) - 1; i++) {
|
||||
*p++ = DEVICE_NAME[i];
|
||||
} // 69 108 105 116 101 45 69 73 83
|
||||
*p++ = 16; // 16
|
||||
*p++ = GAP_ADTYPE_MANUFACTURER_SPECIFIC; // 255
|
||||
*p++ = 'B'; // 66
|
||||
*p++ = 'P'; // 80
|
||||
*p++ = 'H'; // 72
|
||||
*p++ = 'S'; // 83
|
||||
*p++ = MAJOR_PRODUCT_NUMBER; // 0
|
||||
*p++ = MINOR_PRODUCT_NUMBER; // 4
|
||||
*p++ = MAJOR_VERSION_NUMBER; // 1
|
||||
*p++ = MINOR_VERSION_NUMBER; // 0
|
||||
*p++ = dev->date.year; // 22
|
||||
*p++ = dev->date.month; // 07
|
||||
*p++ = 'B'; // 66
|
||||
*p++ = 'A'; // 65
|
||||
*p++ = 'T'; // 84
|
||||
*p++ = (uint8_t)(NotifyVoltBat); // 44
|
||||
*p++ = (uint8_t)(NotifyVoltBat >> 8); // 33
|
||||
}
|
||||
*p++ = 16;
|
||||
*p++ = GAP_ADTYPE_MANUFACTURER_SPECIFIC;
|
||||
*p++ = 'B';
|
||||
*p++ = 'P';
|
||||
*p++ = 'H';
|
||||
*p++ = 'S';
|
||||
*p++ = MAJOR_PRODUCT_NUMBER;
|
||||
*p++ = MINOR_PRODUCT_NUMBER;
|
||||
*p++ = MAJOR_VERSION_NUMBER;
|
||||
*p++ = MINOR_VERSION_NUMBER;
|
||||
*p++ = year;
|
||||
*p++ = month;
|
||||
*p++ = 'B';
|
||||
*p++ = 'A';
|
||||
*p++ = 'T';
|
||||
*p++ = (uint8_t)(NotifyVoltBat);
|
||||
*p++ = (uint8_t)(NotifyVoltBat >> 8);
|
||||
|
||||
GGS_SetParameter(GGS_DEVICE_NAME_ATT, sizeof(DEVICE_NAME), DEVICE_NAME);
|
||||
|
||||
GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, p - scan_rsp_data, scan_rsp_data);
|
||||
GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, p - scanRspData, scanRspData);
|
||||
}
|
||||
|
||||
#endif // HEADSTAGE_H
|
||||
|
||||
@@ -0,0 +1,311 @@
|
||||
|
||||
#ifndef HEADSTAGE_H
|
||||
#error "headstage.h not include"
|
||||
#endif
|
||||
|
||||
#ifdef HEADSTAGE_H_H
|
||||
#error "headstage_*.h has be included"
|
||||
#endif
|
||||
|
||||
#ifndef HEADSTAGE_TNI_H
|
||||
#define HEADSTAGE_H_H
|
||||
#define HEADSTAGE_TNI_H
|
||||
|
||||
// product information
|
||||
#define DEVICE_NAME "Elite-v0.1"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 1
|
||||
#define MAJOR_VERSION_NUMBER 0
|
||||
#define MINOR_VERSION_NUMBER 1
|
||||
|
||||
// header
|
||||
#include <ti/drivers/PIN.h>
|
||||
#include "board.h"
|
||||
|
||||
/*============
|
||||
==== SPI ====
|
||||
===========*/
|
||||
|
||||
/* application use SPI parameters and buffers */
|
||||
|
||||
#define SPI_BUFFER_SIZE 16
|
||||
|
||||
/**
|
||||
* the pointer to point which channel is used currently.
|
||||
* -1 for not beginning.
|
||||
*/
|
||||
static int8 channel_pointer = -1;
|
||||
|
||||
static uint8_t spi_txbuf[SPI_BUFFER_SIZE] = {0};
|
||||
static uint8_t spi_rxbuf[SPI_BUFFER_SIZE] = {0};
|
||||
|
||||
/*=============================
|
||||
==== headstage variable ====
|
||||
============================*/
|
||||
|
||||
PIN_Handle pin_handle;
|
||||
static PIN_State DBS_rst;
|
||||
|
||||
// DBS reset pin
|
||||
|
||||
const PIN_Config BLE_IO[] = {
|
||||
//
|
||||
IOID_9 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
IOID_2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
IOID_3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
IOID_13 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
PIN_TERMINATE //
|
||||
};
|
||||
|
||||
/**
|
||||
* ADC clock switch signal.
|
||||
*/
|
||||
static bool adc_clock_signal = FALSE;
|
||||
|
||||
/*=======================================
|
||||
==== headstage function declaration ====
|
||||
======================================*/
|
||||
|
||||
static void headstage_tni_update_instruction_callback(uint8_t ins_type, uint8_t ins_op, uint8_t ins_len, uint8_t *ins);
|
||||
|
||||
/*=============================
|
||||
==== ramp data generating ====
|
||||
============================*/
|
||||
|
||||
static uint16_t ramp_data_counter = 0;
|
||||
|
||||
static void create_ramp(uint8_t *buff) {
|
||||
buff[0] = 0b10110000 | (0b00001111 & (uint8_t)(ramp_data_counter >> 6));
|
||||
buff[1] = (uint8_t)(ramp_data_counter << 2);
|
||||
ramp_data_counter += 1;
|
||||
}
|
||||
|
||||
/*=======================================
|
||||
==== headstage function implemented ====
|
||||
======================================*/
|
||||
|
||||
/**
|
||||
* change channel value to little endian
|
||||
*/
|
||||
static uint8 encode_channel(uint8 channel) {
|
||||
return 0x0F & (((channel & 0b1000) >> 3) | //
|
||||
((channel & 0b0100) >> 1) | //
|
||||
((channel & 0b0010) << 1) | //
|
||||
((channel & 0b0001) << 3));
|
||||
}
|
||||
|
||||
static void headstage_init() {
|
||||
set_update_instruction_callback(headstage_tni_update_instruction_callback);
|
||||
|
||||
// initialize the DBS reset pin
|
||||
pin_handle = PIN_open(&DBS_rst, BLE_IO);
|
||||
PIN_setOutputValue(pin_handle, IOID_9, 1);
|
||||
PIN_setOutputValue(pin_handle, IOID_2, 0);
|
||||
PIN_setOutputValue(pin_handle, IOID_3, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* change the recording clock bit in the instruction buffer.
|
||||
*/
|
||||
static void update_ins_rec_clock(uint8_t *buf, bool adc_clock_signal) {
|
||||
buf[3] = (buf[3] & 0b11110000) | ((adc_clock_signal) ? 0b1000 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* change the recording channel bit in the instruction buffer.
|
||||
*/
|
||||
static void update_ins_rec_channel(uint8_t *buf, uint8 channel) {
|
||||
buf[1] = (buf[1] & 0b00001111) | (encode_channel(channel) << 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* change the stimulation enable bit in the instruction buffer.
|
||||
*/
|
||||
static void update_ins_sti_enable(uint8_t *buf, bool enable) {
|
||||
buf[1] = (buf[1] & 0b11111101) | ((enable) ? 0b10 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* change the stimulating channel bit in the instruction buffer.
|
||||
*/
|
||||
static void update_ins_sti_channel(uint8_t *buf, uint8 sti_chp, uint8 sti_chn) {
|
||||
buf[2] = (buf[2] & 0b11110000) | encode_channel(sti_chp);
|
||||
buf[3] = (buf[3] & 0b00001111) | (encode_channel(sti_chn) << 4);
|
||||
}
|
||||
|
||||
static void update_ins_buffer() {
|
||||
uint8 header = 0b10100000;
|
||||
uint8 amp_gain = (instru.amp_gain & 0b11) << 3;
|
||||
uint8 amp_lbf = instru.amp_low_band_freq & 0b111;
|
||||
uint8 channel = 0; // should be call update_ins_channel to modify this value
|
||||
uint8 chopper = (instru.chopper) ? 0b00001000 : 0;
|
||||
uint8 fast_settle = (instru.fast_settle) ? 0b00000100 : 0;
|
||||
uint8 sti_enable = (instru.work_mode != STI_MODE_DISABLE) ? 0b00000010 : 0;
|
||||
uint8 sti_volt_l = (instru.sti_volt & 0b11111) >> 4;
|
||||
uint8 sti_volt_h = (instru.sti_volt & 0b01111) << 4;
|
||||
uint8 sti_chp = instru.sti_channel_pmos & 0b1111;
|
||||
uint8 sti_chn = (instru.sti_channel_nmos & 0b1111) << 4;
|
||||
uint8 clk_signal = 0; // should be call update_ins_clock to modify this value
|
||||
|
||||
spi_txbuf[0] = header | amp_gain | amp_lbf;
|
||||
spi_txbuf[1] = channel | chopper | fast_settle | sti_enable | sti_volt_l;
|
||||
spi_txbuf[2] = sti_volt_h | sti_chp;
|
||||
spi_txbuf[3] = sti_chn | clk_signal;
|
||||
}
|
||||
|
||||
static bool update_ins_rec_buffer() {
|
||||
adc_clock_signal = (adc_clock_signal) ? FALSE : TRUE; // switch adc_clock
|
||||
update_ins_rec_clock(spi_txbuf, adc_clock_signal);
|
||||
|
||||
if (adc_clock_signal) {
|
||||
// change to next channel
|
||||
|
||||
if (next_active_channel()) {
|
||||
update_ins_rec_channel(spi_txbuf, channel_pointer);
|
||||
} else {
|
||||
// no channel active
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the instruction content for SPI buffer, which is depended on the
|
||||
* work_mode. Expend the remind instruction according to the base instruction
|
||||
* which allocated at the beginning 4 bytes of the SPI buffer.
|
||||
*
|
||||
* ========= ===========
|
||||
* work_mode ins pattern
|
||||
* ========= ===========
|
||||
* POS, NEG 4 F D 0
|
||||
* P2N, N2P 4 4' F D
|
||||
* AWF not impl
|
||||
* ========= ===========
|
||||
*
|
||||
* pattern *4*
|
||||
* stimulation instruction.
|
||||
*
|
||||
* pattern *F*
|
||||
* set pmos channel to 0xF, release the remain voltage in the capacitance.
|
||||
*
|
||||
* pattern *D*
|
||||
* disable stimulation
|
||||
*
|
||||
* pattern *0*
|
||||
* nop.
|
||||
*
|
||||
* @param: buf: pointer of the SPI buffer.
|
||||
*/
|
||||
static void update_ins_sti_buffer() {
|
||||
switch (instru.work_mode) {
|
||||
case STI_MODE_POS:
|
||||
case STI_MODE_NEG:
|
||||
// copy [4:7]
|
||||
spi_txbuf[4] = spi_txbuf[0];
|
||||
spi_txbuf[5] = spi_txbuf[1];
|
||||
spi_txbuf[6] = spi_txbuf[2];
|
||||
spi_txbuf[7] = spi_txbuf[3];
|
||||
// copy [8:B]
|
||||
spi_txbuf[8] = spi_txbuf[0];
|
||||
spi_txbuf[9] = spi_txbuf[1];
|
||||
spi_txbuf[10] = spi_txbuf[2];
|
||||
spi_txbuf[11] = spi_txbuf[3];
|
||||
// reset [C:F]
|
||||
spi_txbuf[12] = 0;
|
||||
spi_txbuf[13] = 0;
|
||||
spi_txbuf[14] = 0;
|
||||
spi_txbuf[15] = 0;
|
||||
// change content
|
||||
update_ins_sti_enable(spi_txbuf, TRUE);
|
||||
// ins buf [4:7]
|
||||
update_ins_sti_enable(spi_txbuf + 4, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 4, 0xF, instru.sti_channel_pmos);
|
||||
// ins buf [8:B]
|
||||
update_ins_sti_enable(spi_txbuf + 8, FALSE);
|
||||
break;
|
||||
case STI_MODE_P2N:
|
||||
case STI_MODE_N2P:
|
||||
// copy [4:7]
|
||||
spi_txbuf[4] = spi_txbuf[0];
|
||||
spi_txbuf[5] = spi_txbuf[1];
|
||||
spi_txbuf[6] = spi_txbuf[2];
|
||||
spi_txbuf[7] = spi_txbuf[3];
|
||||
// copy [8:B]
|
||||
spi_txbuf[8] = spi_txbuf[0];
|
||||
spi_txbuf[9] = spi_txbuf[1];
|
||||
spi_txbuf[10] = spi_txbuf[2];
|
||||
spi_txbuf[11] = spi_txbuf[3];
|
||||
// copy [C:F]
|
||||
spi_txbuf[12] = spi_txbuf[0];
|
||||
spi_txbuf[13] = spi_txbuf[1];
|
||||
spi_txbuf[14] = spi_txbuf[2];
|
||||
spi_txbuf[15] = spi_txbuf[3];
|
||||
// change content
|
||||
update_ins_sti_enable(spi_txbuf + 0, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 0, instru.sti_channel_pmos, instru.sti_channel_nmos);
|
||||
// ins buf [4:7]
|
||||
update_ins_sti_enable(spi_txbuf + 4, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 4, instru.sti_channel_nmos, instru.sti_channel_pmos);
|
||||
// ins buf [8:B]
|
||||
update_ins_sti_enable(spi_txbuf + 8, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 8, 0xF, instru.sti_channel_nmos);
|
||||
// ins buf [C:F]
|
||||
update_ins_sti_enable(spi_txbuf + 12, FALSE);
|
||||
break;
|
||||
case STI_MODE_AWF:
|
||||
// XXX define the voltage change
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void headstage_tni_update_instruction_callback(uint8_t ins_type, uint8_t ins_op, uint8_t ins_len, uint8_t *ins) {
|
||||
switch (ins_type) {
|
||||
case INS_TYPE_VIS: {
|
||||
// reset
|
||||
case VIS_RST:
|
||||
// reset. reset all variable
|
||||
adc_clock_signal = FALSE;
|
||||
memset(spi_txbuf, 0, SPI_BUFFER_SIZE);
|
||||
break;
|
||||
|
||||
// interrupt
|
||||
case VIS_INT:
|
||||
// stop. reset channel table
|
||||
ramp_data_counter = 0;
|
||||
memset(spi_txbuf, 0, SPI_BUFFER_SIZE);
|
||||
break;
|
||||
}
|
||||
case INS_TYPE_RIS:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t *spi_transact_rec_instruction() {
|
||||
if (IS_REC_MODE(instru.work_mode)) {
|
||||
PIN_setOutputValue(pin_handle, IOID_13, 1); // DBS_P2S turn on
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE, spi_txbuf, spi_rxbuf);
|
||||
PIN_setOutputValue(pin_handle, IOID_13, 0); // DBS_P2S turn off
|
||||
|
||||
} else if (IS_ARM_MODE(instru.work_mode) && !adc_clock_signal) {
|
||||
create_ramp(spi_rxbuf);
|
||||
}
|
||||
|
||||
if (adc_clock_signal) {
|
||||
return NULL;
|
||||
} else {
|
||||
return spi_rxbuf;
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t *spi_transact_sti_instruction() {
|
||||
headstage_spi_transaction(16, spi_txbuf, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -17,33 +17,62 @@
|
||||
#define IMPEDANCE_METER_H_
|
||||
|
||||
// header
|
||||
#include <ti/drivers/PIN.h>
|
||||
#include "board.h"
|
||||
#include "EliteWorkData.h"
|
||||
#include <driverlib/aon_batmon.h>
|
||||
|
||||
static void SimpleBLEPeripheral_performPeriodicTask(void);
|
||||
|
||||
static void SimpleBLEPeripheral_clockHandler(UArg arg) {
|
||||
// Store the event.
|
||||
// events |= SBP_PERIODIC_EVT;
|
||||
|
||||
// Wake up the application.
|
||||
// Semaphore_post(semaphore); // send samaphore to jump out of infinite waiting(simple_peripheral.c line570)
|
||||
|
||||
}
|
||||
static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) {
|
||||
events |= SBP_PERIODIC_EVT;
|
||||
Semaphore_post(semaphore);
|
||||
GPT.GptimerCounter++;
|
||||
}
|
||||
|
||||
|
||||
static void device_init(void)
|
||||
{
|
||||
gpio_create();
|
||||
static void ZM_update_instruction_callback(uint8_t ins_type, uint8_t chip_ID, uint8_t *ins);
|
||||
|
||||
static void ZM_init() {
|
||||
set_update_instruction_callback(ZM_update_instruction_callback);
|
||||
|
||||
// initialize
|
||||
pin_handle = PIN_open(&ZM_rst, BLE_IO);
|
||||
Init_Elite15_PIN();
|
||||
ELITE15_SPI_HOLD();
|
||||
|
||||
PIN15_setOutputValue(shutdown_6994, 1); // OFF = 1 => turn off 6994
|
||||
PIN15_setOutputValue(enable_10v, 0); // enable 10V
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // HIGH Z MODE // 1: close; 0: open;
|
||||
|
||||
InitEliteInstruction();
|
||||
|
||||
update_latch_stat(E_LATCH_CS_MEM, 1);
|
||||
update_latch_stat(E_LATCH_CS_ADC, 1);
|
||||
update_latch_stat(E_LATCH_CS_DAC, 1);
|
||||
update_latch_stat(E_LATCH_OFF, 1); // E_LATCH_OFF = 1 => turn off 6994
|
||||
latch_multi_ctrl();
|
||||
// init DAC, set output ~= 0 V
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
|
||||
|
||||
/* when elite open, must change vin level,
|
||||
measure battery value will be right */
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
DAC0_W_T(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
|
||||
measure battery value will be right */
|
||||
VinADCGainCtrl(VIN_GAIN_AUTO);
|
||||
|
||||
elite_gptimer_open();
|
||||
InitGPT();
|
||||
|
||||
return;
|
||||
elite_gptimer_start();
|
||||
|
||||
// PIN_registerIntCb(pin_handle, switch_on_callback);
|
||||
// PIN_setInterrupt(pin_handle, switch_on | PIN_IRQ_POSEDGE);
|
||||
}
|
||||
|
||||
static void ZM_update_instruction_callback(uint8_t ins_type, uint8_t chip_ID, uint8_t *ins) {}
|
||||
|
||||
#define IsPeriodicMode() ( \
|
||||
(instru.eliteFxn == CURVE_IV) || \
|
||||
(instru.eliteFxn == CURVE_IV_CY) || \
|
||||
@@ -66,24 +95,145 @@ static void device_init(void)
|
||||
(instru.eliteFxn == CURVE_LSV) \
|
||||
)
|
||||
|
||||
static void pulse_mode(void)
|
||||
{
|
||||
// Default working flow is vscan -> ADC read -> send notify
|
||||
// We will need a flag to control vscan, ADC and notify
|
||||
|
||||
if(mode_init){
|
||||
GPT.SampleRateCounter = instru.sampleRate - 10;
|
||||
GPT.VscanRateCounter = instru.VsetRate - 1;
|
||||
mode_init = false;
|
||||
batteryADC_flag = false;
|
||||
volt_rec_en = true;
|
||||
curr_rec_en = true;
|
||||
firstTimeReset = true;
|
||||
notifyFirst_flag = true;
|
||||
//pulsemode variable
|
||||
stiFirstTime = true;
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
if (Ve1MatchVe2Mode()) {
|
||||
if (instru.Ve1 == instru.Ve2) {
|
||||
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLv, instru.Ve1));
|
||||
PeriodicEvent = false;
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0: open highz;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
} else if (instru.eliteFxn == CURVE_PULSE) {
|
||||
if(!megaStiEnable){
|
||||
PeriodicEvent = false;
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0: open highz;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
|
||||
if(leadTimeReset && GPT.LeadTimeCounter <= 2000){
|
||||
vscanReset = true;
|
||||
}else{
|
||||
if(notifyFirst_flag){
|
||||
GPT.NotifyCounter = instru.notifyRate - 20;
|
||||
notifyFirst_flag = false;
|
||||
}
|
||||
vscanReset = false;
|
||||
leadTimeReset = false;
|
||||
}
|
||||
|
||||
//vscan counter
|
||||
GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
|
||||
//pulse mode counter
|
||||
GPT.StiCounter = GPT.StiCounter + GPT.DeltaGptimerCounter;
|
||||
if (vscanReset) {
|
||||
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
|
||||
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
|
||||
//vscanReset = false;
|
||||
}else{
|
||||
if (megaStiEnable) {
|
||||
pulse_vscan();
|
||||
}
|
||||
}
|
||||
|
||||
//battery counter
|
||||
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
|
||||
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.BatteryCheckCounter >= 50000){
|
||||
GPT.BatteryCheckCounter -= 50000; //To get right time
|
||||
batteryCheck_flag = true;
|
||||
tempCheck_flag = true;
|
||||
|
||||
if ((instru.eliteFxn == CURVE_IV) ||
|
||||
(instru.eliteFxn == CURVE_IV_CY) ||
|
||||
(instru.eliteFxn == CURVE_CC) ||
|
||||
(instru.eliteFxn == CURVE_CV) ||
|
||||
(instru.eliteFxn == CURVE_LSV) ||
|
||||
(instru.eliteFxn == CURVE_CA) ||
|
||||
(instru.eliteFxn == CURVE_OCP) ||
|
||||
(instru.eliteFxn == CURVE_PULSE) ||
|
||||
(instru.eliteFxn == CURVE_UNI_PULSE) ||
|
||||
(instru.eliteFxn == CURVE_DPV) ||
|
||||
(instru.eliteFxn == CURVE_DPV_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_CALI_ADC)) {
|
||||
batteryCheck_flag = false;
|
||||
tempCheck_flag = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t bat = NotifyVoltBat;
|
||||
if( bat < 768 && bat > 20){
|
||||
PIN15_setOutputValue(enable_5v, 0);
|
||||
}
|
||||
|
||||
//ADC counter
|
||||
GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.SampleRateCounter >= instru.sampleRate){
|
||||
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
|
||||
EliteADCControl(0);
|
||||
}
|
||||
|
||||
//Notify counter(Notify control, check if we need to send notify)
|
||||
//please don't put Notify counter before ADC counter, maybe get wrong data
|
||||
GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.NotifyCounter >= instru.notifyRate){
|
||||
GPT.NotifyCounter -= instru.notifyRate; //To get right time
|
||||
notify_flag = true;
|
||||
if(vscanReset){
|
||||
notify_flag = false;
|
||||
}
|
||||
if(notify_flag){
|
||||
SendNotify();
|
||||
notify_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
mode_done();
|
||||
|
||||
}
|
||||
|
||||
static void peri_mode(void)
|
||||
{
|
||||
|
||||
|
||||
GPT.cnt_lead_time = GPT.cnt_lead_time + GPT.cnt_gpt_delta;
|
||||
if (leadTimeReset && GPT.cnt_lead_time <= 2000) {
|
||||
GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
|
||||
if (leadTimeReset && GPT.LeadTimeCounter <= 2000) {
|
||||
vscanReset = true;
|
||||
if (first_highz_flag && GPT.cnt_lead_time >= 1000) {
|
||||
if (first_highz_flag && GPT.LeadTimeCounter >= 1000) {
|
||||
if (instru.eliteFxn == CURVE_OCP) {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0);
|
||||
} else {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // HIGH Z MODE // 1: close; 0: open;
|
||||
}
|
||||
first_highz_flag = false;
|
||||
}
|
||||
} else {
|
||||
if (notifyFirst_flag) {
|
||||
GPT.cnt_notify_rate = instru.notifyRate - 20;
|
||||
GPT.NotifyCounter = instru.notifyRate - 20;
|
||||
notifyFirst_flag = false;
|
||||
}
|
||||
vscanReset = false;
|
||||
@@ -91,20 +241,20 @@ static void peri_mode(void)
|
||||
}
|
||||
|
||||
//vscan counter
|
||||
GPT.cnt_v_scan_rate = GPT.cnt_v_scan_rate + GPT.cnt_gpt_delta;
|
||||
if (GPT.cnt_v_scan_rate >= instru.VsetRate) {
|
||||
if (GPT.cnt_v_scan_rate >= instru.VsetRate * 2) {
|
||||
GPT.GptimerMultiple = GPT.cnt_v_scan_rate / instru.VsetRate;
|
||||
GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
|
||||
if (GPT.VscanRateCounter >= instru.VsetRate) {
|
||||
if (GPT.VscanRateCounter >= instru.VsetRate * 2) {
|
||||
GPT.GptimerMultiple = GPT.VscanRateCounter / instru.VsetRate;
|
||||
} else {
|
||||
GPT.GptimerMultiple = 1;
|
||||
}
|
||||
GPT.cnt_v_scan_rate -= instru.VsetRate * GPT.GptimerMultiple; //To get right time
|
||||
GPT.VscanRateCounter -= instru.VsetRate * GPT.GptimerMultiple; //To get right time
|
||||
vscan_ctrl(0);
|
||||
}
|
||||
|
||||
//battery counter
|
||||
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.cnt_gpt_delta;
|
||||
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.cnt_gpt_delta;
|
||||
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
|
||||
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.BatteryCheckCounter >= 50000){
|
||||
GPT.BatteryCheckCounter -= 50000; //To get right time
|
||||
batteryCheck_flag = true;
|
||||
@@ -116,6 +266,7 @@ static void peri_mode(void)
|
||||
(instru.eliteFxn == CURVE_LSV) ||
|
||||
(instru.eliteFxn == CURVE_CA) ||
|
||||
(instru.eliteFxn == CURVE_OCP) ||
|
||||
(instru.eliteFxn == CURVE_PULSE) ||
|
||||
(instru.eliteFxn == CURVE_UNI_PULSE) ||
|
||||
(instru.eliteFxn == CURVE_DPV) ||
|
||||
(instru.eliteFxn == CURVE_DPV_SMPRATE) ||
|
||||
@@ -130,27 +281,27 @@ static void peri_mode(void)
|
||||
|
||||
uint16_t bat = NotifyVoltBat;
|
||||
if( bat < 768 && bat > 20){
|
||||
// latch_single_ctrl(E_LATCH_5V_ENABLE, 0);
|
||||
// PIN15_setOutputValue(enable_5v, 0);
|
||||
}
|
||||
|
||||
//ADC counter
|
||||
GPT.cnt_adc_rate = GPT.cnt_adc_rate + GPT.cnt_gpt_delta;
|
||||
if(GPT.cnt_adc_rate >= instru.sampleRate){
|
||||
GPT.cnt_adc_rate = 0; //To get right data, ADC must be delay 1.5ms
|
||||
GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.SampleRateCounter >= instru.sampleRate){
|
||||
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
|
||||
EliteADCControl(0);
|
||||
}
|
||||
|
||||
// Over temperature protection
|
||||
uint16_t CC2650temp = NotifyTemperature;
|
||||
if(CC2650temp > 40) {
|
||||
latch_single_ctrl(E_LATCH_5V_ENABLE, 0);
|
||||
PIN15_setOutputValue(enable_5v, 0);
|
||||
}
|
||||
|
||||
//Notify counter(Notify control, check if we need to send notify)
|
||||
//please don't put Notify counter before ADC counter, maybe get wrong data
|
||||
GPT.cnt_notify_rate = GPT.cnt_notify_rate + GPT.cnt_gpt_delta;
|
||||
if(GPT.cnt_notify_rate >= instru.notifyRate){
|
||||
GPT.cnt_notify_rate -= instru.notifyRate; //To get right time
|
||||
GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.NotifyCounter >= instru.notifyRate){
|
||||
GPT.NotifyCounter -= instru.notifyRate; //To get right time
|
||||
notify_flag = true;
|
||||
if(vscanReset){
|
||||
notify_flag = false;
|
||||
@@ -175,22 +326,22 @@ static void uni_pulse_mode(void)
|
||||
// Default working flow is vscan -> ADC read -> send notify
|
||||
// We will need a flag to control vscan, ADC and notify
|
||||
|
||||
GPT.cnt_lead_time = GPT.cnt_lead_time + GPT.cnt_gpt_delta;
|
||||
if (leadTimeReset && GPT.cnt_lead_time <= 2000) {
|
||||
GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
|
||||
if (leadTimeReset && GPT.LeadTimeCounter <= 2000) {
|
||||
vscanReset = true;
|
||||
GPT.cnt_v_scan_rate = 0xFFFFFFFF;
|
||||
GPT.VscanRateCounter = 0xFFFFFFFF;
|
||||
dpv_step_cnt = 0;
|
||||
if (first_highz_flag && GPT.cnt_lead_time >= 1000) {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
|
||||
if (first_highz_flag && GPT.LeadTimeCounter >= 1000) {
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
|
||||
first_highz_flag = false;
|
||||
}
|
||||
} else {
|
||||
if (notifyFirst_flag) {
|
||||
GPT.cnt_notify_rate = instru.notifyRate - 20;
|
||||
GPT.NotifyCounter = instru.notifyRate - 20;
|
||||
notifyFirst_flag = false;
|
||||
}
|
||||
if (vscanReset) {
|
||||
GPT.cnt_v_scan_rate = 0xFFFFFFFF;
|
||||
GPT.VscanRateCounter = 0xFFFFFFFF;
|
||||
dpv_step_cnt = 0;
|
||||
}
|
||||
vscanReset = false;
|
||||
@@ -198,16 +349,16 @@ static void uni_pulse_mode(void)
|
||||
}
|
||||
|
||||
//vscan counter
|
||||
GPT.cnt_v_scan_rate = GPT.cnt_v_scan_rate + GPT.cnt_gpt_delta;
|
||||
if (GPT.cnt_v_scan_rate >= instru.period) {
|
||||
GPT.cnt_v_scan_rate -= instru.period; //To get right time
|
||||
GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
|
||||
if (GPT.VscanRateCounter >= instru.period) {
|
||||
GPT.VscanRateCounter -= instru.period; //To get right time
|
||||
dpv_step_cnt +=1;
|
||||
}
|
||||
vscan_ctrl(GPT.cnt_v_scan_rate);
|
||||
vscan_ctrl(GPT.VscanRateCounter);
|
||||
|
||||
//battery counter
|
||||
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.cnt_gpt_delta;
|
||||
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.cnt_gpt_delta;
|
||||
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
|
||||
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.BatteryCheckCounter >= 50000){
|
||||
GPT.BatteryCheckCounter -= 50000; //To get right time
|
||||
batteryCheck_flag = true;
|
||||
@@ -220,6 +371,7 @@ static void uni_pulse_mode(void)
|
||||
(instru.eliteFxn == CURVE_LSV) ||
|
||||
(instru.eliteFxn == CURVE_CA) ||
|
||||
(instru.eliteFxn == CURVE_OCP) ||
|
||||
(instru.eliteFxn == CURVE_PULSE) ||
|
||||
(instru.eliteFxn == CURVE_UNI_PULSE) ||
|
||||
(instru.eliteFxn == CURVE_DPV) ||
|
||||
(instru.eliteFxn == CURVE_DPV_SMPRATE) ||
|
||||
@@ -233,21 +385,21 @@ static void uni_pulse_mode(void)
|
||||
}
|
||||
|
||||
//ADC counter
|
||||
GPT.cnt_adc_rate = GPT.cnt_adc_rate + GPT.cnt_gpt_delta;
|
||||
if(GPT.cnt_adc_rate >= instru.sampleRate){
|
||||
GPT.cnt_adc_rate = 0; //To get right data, ADC must be delay 1.5ms
|
||||
EliteADCControl(GPT.cnt_v_scan_rate);
|
||||
GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.SampleRateCounter >= instru.sampleRate){
|
||||
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
|
||||
EliteADCControl(GPT.VscanRateCounter);
|
||||
}
|
||||
|
||||
uint16_t bat = NotifyVoltBat;
|
||||
if( bat < 768 && bat > 20){
|
||||
// latch_single_ctrl(E_LATCH_5V_ENABLE, 0);
|
||||
// PIN15_setOutputValue(enable_5v, 0);
|
||||
}
|
||||
|
||||
// Over temperature protection
|
||||
uint16_t CC2650temp = NotifyTemperature;
|
||||
if(CC2650temp > 40) {
|
||||
latch_single_ctrl(E_LATCH_5V_ENABLE, 0);
|
||||
PIN15_setOutputValue(enable_5v, 0);
|
||||
}
|
||||
|
||||
if (instru.eliteFxn == CURVE_DPV || instru.eliteFxn == CURVE_DPV_ADVANCE) {
|
||||
@@ -255,9 +407,9 @@ static void uni_pulse_mode(void)
|
||||
} else {
|
||||
//Notify counter(Notify control, check if we need to send notify)
|
||||
//please don't put Notify counter before ADC counter, maybe get wrong data
|
||||
GPT.cnt_notify_rate = GPT.cnt_notify_rate + GPT.cnt_gpt_delta;
|
||||
if(GPT.cnt_notify_rate >= instru.notifyRate){
|
||||
GPT.cnt_notify_rate -= instru.notifyRate; //To get right time
|
||||
GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.NotifyCounter >= instru.notifyRate){
|
||||
GPT.NotifyCounter -= instru.notifyRate; //To get right time
|
||||
notify_flag = true;
|
||||
if (instru.eliteFxn == CURVE_UNI_PULSE) {
|
||||
notify_flag = false;
|
||||
@@ -308,15 +460,23 @@ static void mode_init_set(void)
|
||||
instru.gain_switch_on = 0b01110000;
|
||||
}
|
||||
|
||||
if (instru.IinADCGainLv == I_GAIN_AUTO) {
|
||||
instru.IinADCGainLv = I_GAIN_100R;
|
||||
}
|
||||
|
||||
if (instru.VinADCAutoGainEn == VIN_GAIN_AUTO) {
|
||||
instru.VinADCGainLv = VIN_GAIN_1K;
|
||||
}
|
||||
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
|
||||
if (Ve1MatchVe2Mode()) {
|
||||
if (instru.Ve1 == instru.Ve2) {
|
||||
DAC0_W_T(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
|
||||
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLv, instru.Ve1));
|
||||
PeriodicEvent = false;
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, 0); // 0: open highz;
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0: open highz;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
@@ -333,17 +493,17 @@ static void mode_init_set(void)
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
static void elite_task(void)
|
||||
static void SimpleBLEPeripheral_performPeriodicTask(void)
|
||||
{
|
||||
// GPT_timerIncrement();
|
||||
GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
|
||||
GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
|
||||
if (IsPeriodicMode()) {
|
||||
if (mode_init) {
|
||||
GPT.SampleRateCounter = instru.sampleRate - 10;
|
||||
GPT.VscanRateCounter = instru.VsetRate - 1;
|
||||
mode_init = false;
|
||||
mode_init_set();
|
||||
InitGPT();
|
||||
GPT.cnt_adc_rate = instru.sampleRate - 10;
|
||||
GPT.cnt_v_scan_rate = instru.VsetRate - 1;
|
||||
}
|
||||
|
||||
peri_mode();
|
||||
@@ -355,7 +515,6 @@ static void elite_task(void)
|
||||
if (mode_init) {
|
||||
mode_init = false;
|
||||
mode_init_set();
|
||||
InitGPT();
|
||||
calc_avg_en = false;
|
||||
}
|
||||
|
||||
@@ -368,7 +527,6 @@ static void elite_task(void)
|
||||
if (mode_init) {
|
||||
mode_init = false;
|
||||
mode_init_set();
|
||||
InitGPT();
|
||||
calc_avg_en = false;
|
||||
}
|
||||
|
||||
@@ -381,7 +539,6 @@ static void elite_task(void)
|
||||
if (mode_init) {
|
||||
mode_init = false;
|
||||
mode_init_set();
|
||||
InitGPT();
|
||||
}
|
||||
|
||||
uni_pulse_mode();
|
||||
@@ -471,6 +628,18 @@ static void EliteADCControl(uint32_t time)
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_PULSE:
|
||||
Iin_Vin_Vout_Plot(t);
|
||||
if (curr_rec_en) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
}
|
||||
|
||||
if (volt_rec_en) {
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_IMPEDANCE, MEAS_VOUT(wm));
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_IT:
|
||||
Iin_Vin_Vout_Plot(t);
|
||||
if (curr_rec_en) {
|
||||
@@ -641,9 +810,11 @@ static void vscan_ctrl(uint32_t time)
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t get_step_time(uint8_t StepTime){
|
||||
static uint32_t OldStep2NewStepTime(uint32_t StepTime){
|
||||
uint8_t StepTimeLevel = 0;
|
||||
StepTimeLevel = StepTime / 0x12;
|
||||
|
||||
switch (StepTime) {
|
||||
switch (StepTimeLevel) {
|
||||
case 0: { //0.5 sec
|
||||
return STEPTIME_HALF_SEC;
|
||||
}
|
||||
|
||||
@@ -178,9 +178,7 @@ static void vo_vscan(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#define DELTAVOLTMAX 20000000 //2000000 = 10mV //10000000 = 50mV //20000000 = 100mV
|
||||
#define RESISTANCE_100R 1 // 100V/1A = 1[5nV]/50[pA]
|
||||
|
||||
#define DELTAVOLTMAX 2000000 //2000000 = 10mV
|
||||
static void cc_vscan(void)
|
||||
{
|
||||
/* Transform setting CC into IUC
|
||||
@@ -196,27 +194,20 @@ static void cc_vscan(void)
|
||||
int32_t deltaI;
|
||||
int32_t deltaV;
|
||||
int32_t Iin;
|
||||
int32_t Voutin;
|
||||
uint8_t cc_cp_speed = instru.cc_cp_speed; // 0:low 1:normal 2:high
|
||||
uint8_t cc_resistance = instru.cc_resistance; // 0:vout has 0R 1:vout has 100R
|
||||
static int32_t i_set = 0;
|
||||
int32_t Vin;
|
||||
|
||||
if (vscanReset) {
|
||||
Vset = 0;
|
||||
|
||||
if (cc->_charge == 0) {
|
||||
i_set = cc->_Iset * (-1);
|
||||
} else if(cc->_charge == 1) {
|
||||
i_set = cc->_Iset;
|
||||
cc->_Iset = instru.constantCurrent * 200 * (-1);
|
||||
//[50pA] //controller UI 15000uA => Elite 1500000 => 1500000 * 10 * 1000 / 50 [50pA];
|
||||
}
|
||||
|
||||
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
|
||||
Voutin = m->_measureVout * 200; //[5nV]
|
||||
Vin = m->_measureVin * 200; //[5nV]
|
||||
|
||||
if (cc_resistance == 1) //vout has 100R
|
||||
Vset = Voutin + (i_set * RESISTANCE_100R); //[5nV]
|
||||
else
|
||||
Vset = Voutin; //[5nV]
|
||||
Vset = Vin + cc->_Iset; //[5nV]
|
||||
|
||||
if (Vset >= 1100000000) { // 5.5V
|
||||
Vset = 1100000000;
|
||||
@@ -227,28 +218,14 @@ static void cc_vscan(void)
|
||||
|
||||
if (!vscanReset) {
|
||||
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
|
||||
deltaI = Iin - i_set;
|
||||
deltaI = Iin - cc->_Iset;
|
||||
|
||||
if (deltaI > 400000 || deltaI < -400000) { //20uA
|
||||
if (instru.cc_cp_speed == 0) { // 0:low 1:normal 2:high
|
||||
cc_cp_speed = 100;
|
||||
} else if (instru.cc_cp_speed == 1) {
|
||||
cc_cp_speed = 10;
|
||||
} else {
|
||||
cc_cp_speed = 1;
|
||||
}
|
||||
if (deltaI > 2000000 || deltaI < -2000000) { //100uA
|
||||
divisionRate = 1;
|
||||
} else {
|
||||
if (instru.cc_cp_speed == 0) { // 0:low 1:normal 2:high
|
||||
cc_cp_speed = 100;
|
||||
} else if (instru.cc_cp_speed == 1) {
|
||||
cc_cp_speed = 20;
|
||||
} else {
|
||||
cc_cp_speed = 20;
|
||||
}
|
||||
divisionRate = 20;
|
||||
}
|
||||
|
||||
divisionRate = cc_cp_speed;
|
||||
|
||||
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
|
||||
|
||||
if (deltaV > DELTAVOLTMAX) { //2000000 = 10mV
|
||||
@@ -721,6 +698,118 @@ static void dpv_advance_vscan(uint32_t time)
|
||||
return;
|
||||
}
|
||||
|
||||
static void pulse_vscan(void)
|
||||
{
|
||||
struct wm_pulse_ctx_t *pulse = (struct wm_pulse_ctx_t *)wm_get();
|
||||
static uint16_t lastVolt;
|
||||
|
||||
if (stiFirstTime) {
|
||||
stiFirstTime = false;
|
||||
lastVolt = 25000;
|
||||
pulse->_sti_t_flag = 1;
|
||||
pulse->_sti_v = pulse->_sti_v1;
|
||||
pulse->_sti_t = pulse->_sti_t1;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else if(!stiFirstTime) {
|
||||
if (GPT.StiCounter >= pulse->_sti_t) {
|
||||
GPT.StiCounter -= pulse->_sti_t; //to get right time
|
||||
|
||||
if (pulse->_sti_lp > 0) {
|
||||
if (pulse->_sti_cy > 0) {
|
||||
if (pulse->_sti_t_flag == 1) {
|
||||
pulse->_sti_t_flag = 2;
|
||||
pulse->_sti_v = pulse->_sti_v2;
|
||||
pulse->_sti_t = pulse->_sti_t2;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else if (pulse->_sti_t_flag == 2) {
|
||||
pulse->_sti_t_flag = 3;
|
||||
pulse->_sti_v = pulse->_sti_v3;
|
||||
pulse->_sti_t = pulse->_sti_t3;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else if (pulse->_sti_t_flag == 3) {
|
||||
pulse->_sti_cy -- ;
|
||||
if (pulse->_sti_cy == 0) {
|
||||
pulse->_sti_t_flag = 4;
|
||||
pulse->_sti_v = pulse->_sti_v4;
|
||||
pulse->_sti_t = pulse->_sti_t4;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else {
|
||||
pulse->_sti_t_flag = 2;
|
||||
pulse->_sti_v = pulse->_sti_v2;
|
||||
pulse->_sti_t = pulse->_sti_t2;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (pulse->_sti_cy <= 0){
|
||||
if (pulse->_sti_t_flag == 4) {
|
||||
pulse->_sti_lp -- ;
|
||||
if (pulse->_sti_lp > 0) {
|
||||
pulse->_sti_cy = instru.sti_cy;
|
||||
pulse->_sti_t_flag = 2;
|
||||
pulse->_sti_v = pulse->_sti_v2;
|
||||
pulse->_sti_t = pulse->_sti_t2;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else {
|
||||
pulse->_sti_t_flag = 5;
|
||||
pulse->_sti_v = pulse->_sti_v5;
|
||||
pulse->_sti_t = pulse->_sti_t5;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (pulse->_sti_lp <= 0) {
|
||||
if (pulse->_sti_t_flag == 5) {
|
||||
pulse->_sti_t_flag = 6;
|
||||
pulse->_sti_v = pulse->_sti_v6;
|
||||
pulse->_sti_t = pulse->_sti_t6;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else if (pulse->_sti_t_flag == 6) {
|
||||
pulse->_sti_t_flag = 7;
|
||||
pulse->_sti_v = pulse->_sti_v7;
|
||||
pulse->_sti_t = pulse->_sti_t7;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else if (pulse->_sti_t_flag == 7) {
|
||||
pulse->_sti_v = 25000;
|
||||
PeriodicEvent = false;
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0: open highz;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastVolt != pulse->_sti_v) {
|
||||
lastVolt = pulse->_sti_v;
|
||||
//if (pulse->_sti_v == 25000) {
|
||||
// PIN15_setOutputValue(HIGH_Z_MODE, 0); // 1 => close high_z mode
|
||||
//} else {
|
||||
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
//}
|
||||
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, pulse->_sti_v));
|
||||
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, pulse->_sti_v));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void chg_vo_para(uint16_t parameter, int32_t value)
|
||||
{
|
||||
uint16_t pa = parameter;
|
||||
|
||||
@@ -50,9 +50,13 @@
|
||||
|
||||
#include <xdc/runtime/Error.h>
|
||||
|
||||
|
||||
#include <ti/drivers/Power.h>
|
||||
#include <ti/drivers/power/PowerCC26XX.h>
|
||||
#include <ti/sysbios/BIOS.h>
|
||||
#include <ti/drivers/SPI.h>
|
||||
#include <ti/drivers/spi/SPICC26XXDMA.h>
|
||||
#include <ti/drivers/dma/UDMACC26XX.h>
|
||||
|
||||
#include "icall.h"
|
||||
#include "hal_assert.h"
|
||||
@@ -132,7 +136,7 @@ PIN_Handle radCtrlHandle;
|
||||
|
||||
extern void AssertHandler(uint8 assertCause, uint8 assertSubcause);
|
||||
|
||||
// extern Display_Handle dispHandle;
|
||||
//extern Display_Handle dispHandle;
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn Main
|
||||
@@ -247,49 +251,48 @@ 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);
|
||||
}
|
||||
// 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;
|
||||
|
||||
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;
|
||||
|
||||
default:
|
||||
Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
Display_print0(dispHandle, 2, 0, ">> DEFAULT SPINLOCK!");
|
||||
HAL_ASSERT_SPINLOCK;
|
||||
}
|
||||
*/
|
||||
// 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_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;
|
||||
// }
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
*/
|
||||
#include <string.h>
|
||||
|
||||
// clang-format off
|
||||
#include "bcomdef.h"
|
||||
#include "osal.h"
|
||||
#include "linkdb.h"
|
||||
@@ -58,61 +59,21 @@
|
||||
#include "gatt_uuid.h"
|
||||
#include "gattservapp.h"
|
||||
#include "gapbondmgr.h"
|
||||
// clang-format on
|
||||
|
||||
#include "simple_gatt_profile.h"
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
#define _UUID(_uuid) \
|
||||
{ LO_UINT16(_uuid), HI_UINT16(_uuid) }
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
CONST uint8 simpleProfileServUUID[ATT_BT_UUID_SIZE] = _UUID(SIMPLEPROFILE_SERV_UUID); // Simple GATT Profile Service UUID: 0xFFF0
|
||||
CONST uint8 simpleProfilechar1UUID[ATT_BT_UUID_SIZE] = _UUID(SIMPLEPROFILE_CHAR1_UUID); // Characteristic 1 UUID: 0xFFF1
|
||||
CONST uint8 simpleProfilechar2UUID[ATT_BT_UUID_SIZE] = _UUID(SIMPLEPROFILE_CHAR2_UUID); // Characteristic 2 UUID: 0xFFF2
|
||||
CONST uint8 simpleProfilechar3UUID[ATT_BT_UUID_SIZE] = _UUID(SIMPLEPROFILE_CHAR3_UUID); // Characteristic 3 UUID: 0xFFF3
|
||||
CONST uint8 simpleProfilechar4UUID[ATT_BT_UUID_SIZE] = _UUID(SIMPLEPROFILE_CHAR4_UUID); // Characteristic 4 UUID: 0xFFF4
|
||||
CONST uint8 simpleProfilechar5UUID[ATT_BT_UUID_SIZE] = _UUID(SIMPLEPROFILE_CHAR5_UUID); // Characteristic 5 UUID: 0xFFF5
|
||||
|
||||
#define SERVAPP_NUM_ATTR_SUPPORTED 17
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
*/
|
||||
// Simple GATT Profile Service UUID: 0xFFF0
|
||||
CONST uint8 simpleProfileServUUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(SIMPLEPROFILE_SERV_UUID), HI_UINT16(SIMPLEPROFILE_SERV_UUID)
|
||||
};
|
||||
|
||||
// Characteristic 1 UUID: 0xFFF1
|
||||
CONST uint8 simpleProfilechar1UUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(SIMPLEPROFILE_CHAR1_UUID), HI_UINT16(SIMPLEPROFILE_CHAR1_UUID)
|
||||
};
|
||||
|
||||
// Characteristic 2 UUID: 0xFFF2
|
||||
CONST uint8 simpleProfilechar2UUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(SIMPLEPROFILE_CHAR2_UUID), HI_UINT16(SIMPLEPROFILE_CHAR2_UUID)
|
||||
};
|
||||
|
||||
// Characteristic 3 UUID: 0xFFF3
|
||||
CONST uint8 simpleProfilechar3UUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(SIMPLEPROFILE_CHAR3_UUID), HI_UINT16(SIMPLEPROFILE_CHAR3_UUID)
|
||||
};
|
||||
|
||||
// Characteristic 4 UUID: 0xFFF4
|
||||
CONST uint8 simpleProfilechar4UUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(SIMPLEPROFILE_CHAR4_UUID), HI_UINT16(SIMPLEPROFILE_CHAR4_UUID)
|
||||
};
|
||||
|
||||
// Characteristic 5 UUID: 0xFFF5
|
||||
CONST uint8 simpleProfilechar5UUID[ATT_BT_UUID_SIZE] =
|
||||
{
|
||||
LO_UINT16(SIMPLEPROFILE_CHAR5_UUID), HI_UINT16(SIMPLEPROFILE_CHAR5_UUID)
|
||||
};
|
||||
#undef _UUID
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL VARIABLES
|
||||
@@ -133,50 +94,30 @@ static simpleProfileCBs_t *simpleProfile_AppCBs = NULL;
|
||||
*/
|
||||
|
||||
// Simple Profile Service attribute
|
||||
static CONST gattAttrType_t simpleProfileService = { ATT_BT_UUID_SIZE, simpleProfileServUUID };
|
||||
static CONST gattAttrType_t simpleProfileService = {ATT_BT_UUID_SIZE, simpleProfileServUUID};
|
||||
|
||||
// Simple Profile Characteristic 1 Properties
|
||||
// static uint8 simpleProfileChar1Props = GATT_PROP_READ | GATT_PROP_WRITE;
|
||||
/*user insert*/
|
||||
static uint8 simpleProfileChar1Props = GATT_PROP_READ;
|
||||
|
||||
// Characteristic 1 Value
|
||||
// static uint8 simpleProfileChar1 = 0;
|
||||
/*user insert*/
|
||||
#define SIMPLEPROFILE_CHAR1_LEN 20
|
||||
static uint8 simpleProfileChar1[SIMPLEPROFILE_CHAR1_LEN] = {0};
|
||||
|
||||
// Simple Profile Characteristic 1 User Description
|
||||
static uint8 simpleProfileChar1UserDesp[17] = "Characteristic 1";
|
||||
|
||||
// Simple Profile Characteristic 2 Properties
|
||||
static uint8 simpleProfileChar2Props = GATT_PROP_READ;
|
||||
|
||||
// Characteristic 2 Value
|
||||
// static uint8 simpleProfileChar2 = 0;
|
||||
/*user insert*/
|
||||
static uint8 simpleProfileChar2[SIMPLEPROFILE_CHAR2_LEN] = {0};
|
||||
|
||||
// Simple Profile Characteristic 2 User Description
|
||||
static uint8 simpleProfileChar2UserDesp[17] = "Characteristic 2";
|
||||
|
||||
// Simple Profile Characteristic 3 Properties
|
||||
static uint8 simpleProfileChar3Props = GATT_PROP_WRITE;
|
||||
|
||||
// Characteristic 3 Value
|
||||
// static uint8 simpleProfileChar3 = 0;
|
||||
/*user insert*/
|
||||
static uint8 simpleProfileChar3[SIMPLEPROFILE_CHAR3_LEN] = {0};
|
||||
|
||||
// Simple Profile Characteristic 3 User Description
|
||||
static uint8 simpleProfileChar3UserDesp[17] = "Characteristic 3";
|
||||
|
||||
// Simple Profile Characteristic 4 Properties
|
||||
static uint8 simpleProfileChar4Props = GATT_PROP_NOTIFY;
|
||||
|
||||
// Characteristic 4 Value
|
||||
// static uint8 simpleProfileChar4 = 0;
|
||||
/*user insert*/
|
||||
static uint8 simpleProfileChar4[SIMPLEPROFILE_CHAR4_LEN] = {0};
|
||||
|
||||
// Simple Profile Characteristic 4 Configuration Each client has its own
|
||||
@@ -185,175 +126,89 @@ static uint8 simpleProfileChar4[SIMPLEPROFILE_CHAR4_LEN] = {0};
|
||||
// that client and writes only affect the configuration of that client.
|
||||
static gattCharCfg_t *simpleProfileChar4Config;
|
||||
|
||||
// Simple Profile Characteristic 4 User Description
|
||||
static uint8 simpleProfileChar4UserDesp[17] = "Characteristic 4";
|
||||
|
||||
// Simple Profile Characteristic 5 Properties
|
||||
static uint8 simpleProfileChar5Props = GATT_PROP_READ;
|
||||
static uint8 simpleProfileChar5Props = GATT_PROP_READ | GATT_PROP_WRITE;
|
||||
|
||||
// Characteristic 5 Value
|
||||
static uint8 simpleProfileChar5[SIMPLEPROFILE_CHAR5_LEN] = { 0, 0, 0, 0, 0 };
|
||||
|
||||
// Simple Profile Characteristic 5 User Description
|
||||
static uint8 simpleProfileChar5UserDesp[17] = "Characteristic 5";
|
||||
static uint8 simpleProfileChar5[SIMPLEPROFILE_CHAR5_LEN] = {0};
|
||||
|
||||
/*********************************************************************
|
||||
* Profile Attributes - Table
|
||||
*/
|
||||
|
||||
static gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] =
|
||||
{
|
||||
// Simple Profile Service
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
|
||||
GATT_PERMIT_READ, /* permissions */
|
||||
0, /* handle */
|
||||
(uint8 *)&simpleProfileService /* pValue */
|
||||
},
|
||||
#define SERVAPP_NUM_ATTR_SUPPORTED 17
|
||||
|
||||
static gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] = {
|
||||
// Simple Profile Service
|
||||
{{ATT_BT_UUID_SIZE, primaryServiceUUID}, GATT_PERMIT_READ, 0, (uint8 *)&simpleProfileService},
|
||||
|
||||
// Characteristic 1 Declaration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, characterUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&simpleProfileChar1Props
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, characterUUID}, GATT_PERMIT_READ, 0, &simpleProfileChar1Props},
|
||||
|
||||
// Characteristic Value 1
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, simpleProfilechar1UUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar1
|
||||
},
|
||||
// Characteristic Value 1
|
||||
{{ATT_BT_UUID_SIZE, simpleProfilechar1UUID}, GATT_PERMIT_READ, 0, simpleProfileChar1},
|
||||
|
||||
// Characteristic 1 User Description
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, charUserDescUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar1UserDesp
|
||||
},
|
||||
// Characteristic 1 User Description
|
||||
{{ATT_BT_UUID_SIZE, charUserDescUUID}, GATT_PERMIT_READ, 0, "FS"},
|
||||
|
||||
// Characteristic 2 Declaration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, characterUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&simpleProfileChar2Props
|
||||
},
|
||||
|
||||
// Characteristic Value 2
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, simpleProfilechar2UUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar2
|
||||
},
|
||||
|
||||
// Characteristic 2 User Description
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, charUserDescUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar2UserDesp
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, characterUUID}, GATT_PERMIT_READ, 0, &simpleProfileChar2Props},
|
||||
|
||||
// Characteristic Value 2
|
||||
{{ATT_BT_UUID_SIZE, simpleProfilechar2UUID}, GATT_PERMIT_READ, 0, simpleProfileChar2},
|
||||
|
||||
// Characteristic 2 User Description
|
||||
{{ATT_BT_UUID_SIZE, charUserDescUUID}, GATT_PERMIT_READ, 0, "CR"},
|
||||
|
||||
// Characteristic 3 Declaration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, characterUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&simpleProfileChar3Props
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, characterUUID}, GATT_PERMIT_READ, 0, &simpleProfileChar3Props},
|
||||
|
||||
// Characteristic Value 3
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, simpleProfilechar3UUID },
|
||||
GATT_PERMIT_WRITE,
|
||||
0,
|
||||
simpleProfileChar3
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, simpleProfilechar3UUID}, GATT_PERMIT_WRITE, 0, simpleProfileChar3},
|
||||
|
||||
// Characteristic 3 User Description
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, charUserDescUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar3UserDesp
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, charUserDescUUID}, GATT_PERMIT_READ, 0, "IS"},
|
||||
|
||||
// Characteristic 4 Declaration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, characterUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&simpleProfileChar4Props
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, characterUUID}, GATT_PERMIT_READ, 0, &simpleProfileChar4Props},
|
||||
|
||||
// Characteristic Value 4
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, simpleProfilechar4UUID },
|
||||
0,
|
||||
0,
|
||||
simpleProfileChar4
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, simpleProfilechar4UUID}, 0, 0, simpleProfileChar4},
|
||||
|
||||
// Characteristic 4 configuration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
|
||||
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
|
||||
0,
|
||||
(uint8 *)&simpleProfileChar4Config
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, clientCharCfgUUID}, GATT_PERMIT_READ | GATT_PERMIT_WRITE, 0, (uint8 *)&simpleProfileChar4Config},
|
||||
|
||||
// Characteristic 4 User Description
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, charUserDescUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar4UserDesp
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, charUserDescUUID}, GATT_PERMIT_READ, 0, "Nt"},
|
||||
|
||||
// Characteristic 5 Declaration
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, characterUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&simpleProfileChar5Props
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, characterUUID}, GATT_PERMIT_READ, 0, &simpleProfileChar5Props},
|
||||
|
||||
// Characteristic Value 5
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, simpleProfilechar5UUID },
|
||||
GATT_PERMIT_AUTHEN_READ,
|
||||
0,
|
||||
simpleProfileChar5
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, simpleProfilechar5UUID}, GATT_PERMIT_READ | GATT_PERMIT_WRITE, 0, simpleProfileChar5},
|
||||
// GATT_PERMIT_AUTHEN_READ,
|
||||
|
||||
// Characteristic 5 User Description
|
||||
{
|
||||
{ ATT_BT_UUID_SIZE, charUserDescUUID },
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar5UserDesp
|
||||
},
|
||||
{{ATT_BT_UUID_SIZE, charUserDescUUID}, GATT_PERMIT_READ, 0, "Dg"},
|
||||
};
|
||||
|
||||
/*********************************************************************
|
||||
* LOCAL FUNCTIONS
|
||||
*/
|
||||
static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle,
|
||||
gattAttribute_t *pAttr,
|
||||
uint8_t *pValue, uint16_t *pLen,
|
||||
uint16_t offset, uint16_t maxLen,
|
||||
uint8_t method);
|
||||
static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle,
|
||||
gattAttribute_t *pAttr,
|
||||
uint8_t *pValue, uint16_t len,
|
||||
uint16_t offset, uint8_t method);
|
||||
static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, //
|
||||
gattAttribute_t *pAttr,
|
||||
uint8_t * pValue,
|
||||
uint16_t * pLen,
|
||||
uint16_t offset,
|
||||
uint16_t maxLen,
|
||||
uint8_t method);
|
||||
|
||||
static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle, //
|
||||
gattAttribute_t *pAttr,
|
||||
uint8_t * pValue,
|
||||
uint16_t len,
|
||||
uint16_t offset,
|
||||
uint8_t method);
|
||||
|
||||
/*********************************************************************
|
||||
* PROFILE CALLBACKS
|
||||
@@ -367,11 +222,10 @@ static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle,
|
||||
// pfnAuthorizeAttrCB to check a client's authorization prior to calling
|
||||
// pfnReadAttrCB or pfnWriteAttrCB, so no checks for authorization need to be
|
||||
// made within these functions.
|
||||
CONST gattServiceCBs_t simpleProfileCBs =
|
||||
{
|
||||
simpleProfile_ReadAttrCB, // Read callback function pointer
|
||||
simpleProfile_WriteAttrCB, // Write callback function pointer
|
||||
NULL // Authorization callback function pointer
|
||||
CONST gattServiceCBs_t simpleProfileCBs = {
|
||||
simpleProfile_ReadAttrCB, // Read callback function pointer
|
||||
simpleProfile_WriteAttrCB, // Write callback function pointer
|
||||
NULL // Authorization callback function pointer
|
||||
};
|
||||
|
||||
/*********************************************************************
|
||||
@@ -389,35 +243,29 @@ CONST gattServiceCBs_t simpleProfileCBs =
|
||||
*
|
||||
* @return Success or Failure
|
||||
*/
|
||||
bStatus_t SimpleProfile_AddService( uint32 services )
|
||||
{
|
||||
uint8 status;
|
||||
bStatus_t SimpleProfile_AddService(uint32 services) {
|
||||
uint8 status;
|
||||
|
||||
// Allocate Client Characteristic Configuration table
|
||||
simpleProfileChar4Config = (gattCharCfg_t *)ICall_malloc( sizeof(gattCharCfg_t) *
|
||||
linkDBNumConns );
|
||||
if ( simpleProfileChar4Config == NULL )
|
||||
{
|
||||
return ( bleMemAllocError );
|
||||
}
|
||||
// Allocate Client Characteristic Configuration table
|
||||
simpleProfileChar4Config = (gattCharCfg_t *)ICall_malloc(sizeof(gattCharCfg_t) * linkDBNumConns);
|
||||
if (simpleProfileChar4Config == NULL) {
|
||||
return (bleMemAllocError);
|
||||
}
|
||||
|
||||
// Initialize Client Characteristic Configuration attributes
|
||||
GATTServApp_InitCharCfg( INVALID_CONNHANDLE, simpleProfileChar4Config );
|
||||
// Initialize Client Characteristic Configuration attributes
|
||||
GATTServApp_InitCharCfg(INVALID_CONNHANDLE, simpleProfileChar4Config);
|
||||
|
||||
if ( services & SIMPLEPROFILE_SERVICE )
|
||||
{
|
||||
// Register GATT attribute list and CBs with GATT Server App
|
||||
status = GATTServApp_RegisterService( simpleProfileAttrTbl,
|
||||
GATT_NUM_ATTRS( simpleProfileAttrTbl ),
|
||||
GATT_MAX_ENCRYPT_KEY_SIZE,
|
||||
&simpleProfileCBs );
|
||||
}
|
||||
else
|
||||
{
|
||||
status = SUCCESS;
|
||||
}
|
||||
if (services & SIMPLEPROFILE_SERVICE) {
|
||||
// Register GATT attribute list and CBs with GATT Server App
|
||||
status = GATTServApp_RegisterService(simpleProfileAttrTbl, //
|
||||
GATT_NUM_ATTRS(simpleProfileAttrTbl),
|
||||
GATT_MAX_ENCRYPT_KEY_SIZE,
|
||||
&simpleProfileCBs);
|
||||
} else {
|
||||
status = SUCCESS;
|
||||
}
|
||||
|
||||
return ( status );
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
@@ -430,18 +278,14 @@ bStatus_t SimpleProfile_AddService( uint32 services )
|
||||
*
|
||||
* @return SUCCESS or bleAlreadyInRequestedMode
|
||||
*/
|
||||
bStatus_t SimpleProfile_RegisterAppCBs( simpleProfileCBs_t *appCallbacks )
|
||||
{
|
||||
if ( appCallbacks )
|
||||
{
|
||||
simpleProfile_AppCBs = appCallbacks;
|
||||
bStatus_t SimpleProfile_RegisterAppCBs(simpleProfileCBs_t *appCallbacks) {
|
||||
if (appCallbacks) {
|
||||
simpleProfile_AppCBs = appCallbacks;
|
||||
|
||||
return ( SUCCESS );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( bleAlreadyInRequestedMode );
|
||||
}
|
||||
return (SUCCESS);
|
||||
} else {
|
||||
return (bleAlreadyInRequestedMode);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
@@ -458,76 +302,60 @@ bStatus_t SimpleProfile_RegisterAppCBs( simpleProfileCBs_t *appCallbacks )
|
||||
*
|
||||
* @return bStatus_t
|
||||
*/
|
||||
bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value )
|
||||
{
|
||||
bStatus_t ret = SUCCESS;
|
||||
switch ( param )
|
||||
{
|
||||
case SIMPLEPROFILE_CHAR1:
|
||||
if ( len <= SIMPLEPROFILE_CHAR1_LEN )
|
||||
{
|
||||
memcpy(simpleProfileChar1, value, len);
|
||||
// simpleProfileChar1 = *((uint8*)value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = bleInvalidRange;
|
||||
}
|
||||
break;
|
||||
bStatus_t SimpleProfile_SetParameter(uint8 param, uint8 len, void *value) {
|
||||
switch (param) {
|
||||
case SIMPLEPROFILE_CHAR1:
|
||||
if (len <= SIMPLEPROFILE_CHAR1_LEN) {
|
||||
memcpy(simpleProfileChar1, value, len);
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return bleInvalidRange;
|
||||
}
|
||||
|
||||
case SIMPLEPROFILE_CHAR2:
|
||||
if (len <= SIMPLEPROFILE_CHAR2_LEN)
|
||||
{
|
||||
memcpy(simpleProfileChar2, value, len);
|
||||
// simpleProfileChar2 = *((uint8*)value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = bleInvalidRange;
|
||||
}
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR2:
|
||||
if (len <= SIMPLEPROFILE_CHAR2_LEN) {
|
||||
memcpy(simpleProfileChar2, value, len);
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return bleInvalidRange;
|
||||
}
|
||||
|
||||
case SIMPLEPROFILE_CHAR3:
|
||||
if (len <= SIMPLEPROFILE_CHAR3_LEN)
|
||||
{
|
||||
memcpy(simpleProfileChar3, value, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = bleInvalidRange;
|
||||
}
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR3:
|
||||
if (len <= SIMPLEPROFILE_CHAR3_LEN) {
|
||||
memcpy(simpleProfileChar3, value, len);
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return bleInvalidRange;
|
||||
}
|
||||
|
||||
case SIMPLEPROFILE_CHAR4:
|
||||
if (len <= SIMPLEPROFILE_CHAR4_LEN)
|
||||
{
|
||||
memcpy(simpleProfileChar4, value, len);
|
||||
case SIMPLEPROFILE_CHAR4:
|
||||
if (len <= SIMPLEPROFILE_CHAR4_LEN) {
|
||||
memcpy(simpleProfileChar4, value, len);
|
||||
|
||||
// See if Notification has been enabled
|
||||
GATTServApp_ProcessCharCfg(simpleProfileChar4Config, simpleProfileChar4, FALSE, simpleProfileAttrTbl, GATT_NUM_ATTRS(simpleProfileAttrTbl), INVALID_TASK_ID, simpleProfile_ReadAttrCB);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = bleInvalidRange;
|
||||
}
|
||||
break;
|
||||
// See if Notification has been enabled
|
||||
GATTServApp_ProcessCharCfg(simpleProfileChar4Config, //
|
||||
simpleProfileChar4,
|
||||
FALSE,
|
||||
simpleProfileAttrTbl,
|
||||
GATT_NUM_ATTRS(simpleProfileAttrTbl),
|
||||
INVALID_TASK_ID,
|
||||
simpleProfile_ReadAttrCB);
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return bleInvalidRange;
|
||||
}
|
||||
|
||||
case SIMPLEPROFILE_CHAR5:
|
||||
if (len == SIMPLEPROFILE_CHAR5_LEN) {
|
||||
VOID memcpy(simpleProfileChar5, value, SIMPLEPROFILE_CHAR5_LEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = bleInvalidRange;
|
||||
}
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR5:
|
||||
if (len <= SIMPLEPROFILE_CHAR5_LEN) {
|
||||
memcpy(simpleProfileChar5, value, len);
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return bleInvalidRange;
|
||||
}
|
||||
|
||||
default:
|
||||
ret = INVALIDPARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
return ( ret );
|
||||
default:
|
||||
return INVALIDPARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
@@ -544,36 +372,32 @@ bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value )
|
||||
* @return bStatus_t
|
||||
*/
|
||||
bStatus_t SimpleProfile_GetParameter(uint8 param, void *value) {
|
||||
bStatus_t ret = SUCCESS;
|
||||
switch (param) {
|
||||
case SIMPLEPROFILE_CHAR1:
|
||||
memcpy(value, simpleProfileChar1, SIMPLEPROFILE_CHAR1_LEN);
|
||||
// *((uint8*)value) = simpleProfileChar1;
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR1:
|
||||
memcpy(value, simpleProfileChar1, SIMPLEPROFILE_CHAR1_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR2:
|
||||
memcpy(value, simpleProfileChar2, SIMPLEPROFILE_CHAR2_LEN);
|
||||
// *((uint8*)value) = simpleProfileChar2;
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR2:
|
||||
memcpy(value, simpleProfileChar2, SIMPLEPROFILE_CHAR2_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR3:
|
||||
memcpy(value, simpleProfileChar3, SIMPLEPROFILE_CHAR3_LEN);
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR3:
|
||||
memcpy(value, simpleProfileChar3, SIMPLEPROFILE_CHAR3_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR4:
|
||||
memcpy(value, simpleProfileChar4, SIMPLEPROFILE_CHAR4_LEN);
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR4:
|
||||
memcpy(value, simpleProfileChar4, SIMPLEPROFILE_CHAR4_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR5:
|
||||
VOID memcpy(value, simpleProfileChar5, SIMPLEPROFILE_CHAR5_LEN);
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR5:
|
||||
memcpy(value, simpleProfileChar5, SIMPLEPROFILE_CHAR5_LEN);
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = INVALIDPARAMETER;
|
||||
break;
|
||||
default:
|
||||
return INVALIDPARAMETER;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
@@ -591,7 +415,13 @@ bStatus_t SimpleProfile_GetParameter(uint8 param, void *value) {
|
||||
*
|
||||
* @return SUCCESS, blePending or Failure
|
||||
*/
|
||||
static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, gattAttribute_t *pAttr, uint8_t *pValue, uint16_t *pLen, uint16_t offset, uint16_t maxLen, uint8_t method) {
|
||||
static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, //
|
||||
gattAttribute_t *pAttr,
|
||||
uint8_t * pValue,
|
||||
uint16_t * pLen,
|
||||
uint16_t offset,
|
||||
uint16_t maxLen,
|
||||
uint8_t method) {
|
||||
bStatus_t status = SUCCESS;
|
||||
|
||||
// Make sure it's not a blob operation (no attributes in the profile are long)
|
||||
@@ -603,42 +433,31 @@ static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, gattAttribute_t *
|
||||
// 16-bit UUID
|
||||
uint16 uuid = BUILD_UINT16(pAttr->type.uuid[0], pAttr->type.uuid[1]);
|
||||
switch (uuid) {
|
||||
// No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
|
||||
// gattserverapp handles those reads
|
||||
case SIMPLEPROFILE_CHAR1_UUID:
|
||||
*pLen = SIMPLEPROFILE_CHAR1_LEN;
|
||||
memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR1_LEN);
|
||||
break;
|
||||
|
||||
// characteristics 1 and 2 have read permissions
|
||||
// characteritisc 3 does not have read permissions; therefore it is not
|
||||
// included here
|
||||
// characteristic 4 does not have read permissions, but because it
|
||||
// can be sent as a notification, it is included here
|
||||
case SIMPLEPROFILE_CHAR1_UUID:
|
||||
*pLen = SIMPLEPROFILE_CHAR1_LEN;
|
||||
VOID memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR1_LEN);
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR2_UUID:
|
||||
*pLen = SIMPLEPROFILE_CHAR2_LEN;
|
||||
memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR2_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR2_UUID:
|
||||
// *pLen = 1;
|
||||
// pValue[0] = *pAttr->pValue;
|
||||
case SIMPLEPROFILE_CHAR4_UUID:
|
||||
*pLen = SIMPLEPROFILE_CHAR4_LEN;
|
||||
memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR4_LEN);
|
||||
break;
|
||||
|
||||
*pLen = SIMPLEPROFILE_CHAR2_LEN;
|
||||
VOID memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR2_LEN);
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR5_UUID:
|
||||
*pLen = SIMPLEPROFILE_CHAR5_LEN;
|
||||
memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR5_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR4_UUID:
|
||||
*pLen = SIMPLEPROFILE_CHAR4_LEN;
|
||||
VOID memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR4_LEN);
|
||||
break;
|
||||
// case SIMPLEPROFILE_CHAR5_UUID:
|
||||
|
||||
// *pLen = SIMPLEPROFILE_CHAR5_LEN;
|
||||
// VOID memcpy( pValue, pAttr->pValue, SIMPLEPROFILE_CHAR5_LEN );
|
||||
// break;
|
||||
|
||||
default:
|
||||
// Should never get here! (characteristics 3 and 4 do not have read permissions)
|
||||
*pLen = 0;
|
||||
status = ATT_ERR_ATTR_NOT_FOUND;
|
||||
break;
|
||||
default:
|
||||
// Should never get here! (characteristics 3 and 4 do not have read permissions)
|
||||
*pLen = 0;
|
||||
status = ATT_ERR_ATTR_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// 128-bit UUID
|
||||
@@ -663,71 +482,73 @@ static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, gattAttribute_t *
|
||||
*
|
||||
* @return SUCCESS, blePending or Failure
|
||||
*/
|
||||
static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle, gattAttribute_t *pAttr, uint8_t *pValue, uint16_t len, uint16_t offset, uint8_t method) {
|
||||
static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle, //
|
||||
gattAttribute_t *pAttr,
|
||||
uint8_t * pValue,
|
||||
uint16_t len,
|
||||
uint16_t offset,
|
||||
uint8_t method) {
|
||||
bStatus_t status = SUCCESS;
|
||||
uint8 notifyApp = 0xFF;
|
||||
|
||||
if (pAttr->type.len == ATT_BT_UUID_SIZE) {
|
||||
// 16-bit UUID
|
||||
uint16 uuid = BUILD_UINT16(pAttr->type.uuid[0], pAttr->type.uuid[1]);
|
||||
|
||||
switch (uuid) {
|
||||
// Validate the value
|
||||
// Make sure it's not a blob oper
|
||||
/*
|
||||
if ( offset == 0 )
|
||||
{
|
||||
if ( len != 1 )
|
||||
{
|
||||
status = ATT_ERR_INVALID_VALUE_SIZE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = ATT_ERR_ATTR_NOT_LONG;
|
||||
}
|
||||
case SIMPLEPROFILE_CHAR3_UUID:
|
||||
|
||||
//Write the value
|
||||
if ( status == SUCCESS )
|
||||
{
|
||||
uint8 *pCurValue = (uint8 *)pAttr->pValue;
|
||||
*pCurValue = pValue[0];
|
||||
|
||||
if( pAttr->pValue == &simpleProfileChar1 )
|
||||
{
|
||||
notifyApp = SIMPLEPROFILE_CHAR1;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
*/
|
||||
case SIMPLEPROFILE_CHAR3_UUID:
|
||||
if (offset == 0) {
|
||||
if (len > SIMPLEPROFILE_CHAR3_LEN) {
|
||||
status = ATT_ERR_INVALID_VALUE_SIZE;
|
||||
// Validate the value
|
||||
// Make sure it's not a blob oper
|
||||
if (offset == 0) {
|
||||
if (len >= SIMPLEPROFILE_CHAR3_LEN) {
|
||||
status = ATT_ERR_INVALID_VALUE_SIZE;
|
||||
}
|
||||
} else {
|
||||
status = ATT_ERR_ATTR_NOT_LONG;
|
||||
}
|
||||
} else {
|
||||
status = ATT_ERR_ATTR_NOT_LONG;
|
||||
}
|
||||
|
||||
// Write the value
|
||||
if (status == SUCCESS) {
|
||||
// Copy pValue into the variable we point to from the attribute table.
|
||||
memcpy(pAttr->pValue + offset, pValue, len);
|
||||
memset(pAttr->pValue + len, 0, SIMPLEPROFILE_CHAR3_LEN - len);
|
||||
// Write the value
|
||||
if (status == SUCCESS) {
|
||||
// Copy pValue into the variable we point to from the attribute table.
|
||||
memcpy(pAttr->pValue + offset, pValue, len);
|
||||
memset(pAttr->pValue + len, 0, SIMPLEPROFILE_CHAR3_LEN - len);
|
||||
|
||||
if (pAttr->pValue == simpleProfileChar3) {
|
||||
notifyApp = SIMPLEPROFILE_CHAR3;
|
||||
if (pAttr->pValue == simpleProfileChar3) {
|
||||
notifyApp = SIMPLEPROFILE_CHAR3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case GATT_CLIENT_CHAR_CFG_UUID:
|
||||
status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len, offset, GATT_CLIENT_CFG_NOTIFY);
|
||||
break;
|
||||
default:
|
||||
// Should never get here! (characteristics 2 and 4 do not have write permissions)
|
||||
status = ATT_ERR_ATTR_NOT_FOUND;
|
||||
break;
|
||||
break;
|
||||
case SIMPLEPROFILE_CHAR5_UUID:
|
||||
if (offset == 0) {
|
||||
if (len >= SIMPLEPROFILE_CHAR5_LEN) {
|
||||
status = ATT_ERR_INVALID_VALUE_SIZE;
|
||||
}
|
||||
} else {
|
||||
status = ATT_ERR_ATTR_NOT_LONG;
|
||||
}
|
||||
|
||||
// Write the value
|
||||
if (status == SUCCESS) {
|
||||
// Copy pValue into the variable we point to from the attribute table.
|
||||
memcpy(pAttr->pValue + offset, pValue, len);
|
||||
memset(pAttr->pValue + len, 0, SIMPLEPROFILE_CHAR5_LEN - len);
|
||||
|
||||
if (pAttr->pValue == simpleProfileChar5) {
|
||||
notifyApp = SIMPLEPROFILE_CHAR5;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case GATT_CLIENT_CHAR_CFG_UUID:
|
||||
status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len, offset, GATT_CLIENT_CFG_NOTIFY);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Should never get here! (characteristics 2 and 4 do not have write permissions)
|
||||
status = ATT_ERR_ATTR_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// 128-bit UUID
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
Target Device: CC2650, CC2640
|
||||
|
||||
******************************************************************************
|
||||
|
||||
|
||||
Copyright (c) 2010-2018, Texas Instruments Incorporated
|
||||
All rights reserved.
|
||||
|
||||
@@ -49,8 +49,7 @@
|
||||
#define SIMPLEGATTPROFILE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
@@ -62,36 +61,37 @@ extern "C"
|
||||
*/
|
||||
|
||||
// Profile Parameters
|
||||
#define SIMPLEPROFILE_CHAR1 0 // RW uint8 - Profile Characteristic 1 value
|
||||
#define SIMPLEPROFILE_CHAR2 1 // RW uint8 - Profile Characteristic 2 value
|
||||
#define SIMPLEPROFILE_CHAR3 2 // RW uint8 - Profile Characteristic 3 value
|
||||
#define SIMPLEPROFILE_CHAR4 3 // RW uint8 - Profile Characteristic 4 value
|
||||
#define SIMPLEPROFILE_CHAR5 4 // RW uint8 - Profile Characteristic 4 value
|
||||
#define SIMPLEPROFILE_CHAR1 0 // RW uint8 - Profile Characteristic 1 value
|
||||
#define SIMPLEPROFILE_CHAR2 1 // RW uint8 - Profile Characteristic 2 value
|
||||
#define SIMPLEPROFILE_CHAR3 2 // RW uint8 - Profile Characteristic 3 value
|
||||
#define SIMPLEPROFILE_CHAR4 3 // RW uint8 - Profile Characteristic 4 value
|
||||
#define SIMPLEPROFILE_CHAR5 4 // RW uint8 - Profile Characteristic 4 value
|
||||
|
||||
// Simple Profile Service UUID
|
||||
#define SIMPLEPROFILE_SERV_UUID 0xFFF0
|
||||
#define SIMPLEPROFILE_SERV_UUID 0xFFF0
|
||||
|
||||
// Key Pressed UUID
|
||||
#define SIMPLEPROFILE_CHAR1_UUID 0xFFF1
|
||||
#define SIMPLEPROFILE_CHAR2_UUID 0xFFF2
|
||||
#define SIMPLEPROFILE_CHAR3_UUID 0xFFF3
|
||||
#define SIMPLEPROFILE_CHAR4_UUID 0xFFF4
|
||||
#define SIMPLEPROFILE_CHAR5_UUID 0xFFF5
|
||||
#define SIMPLEPROFILE_CHAR1_UUID 0xFFF1
|
||||
#define SIMPLEPROFILE_CHAR2_UUID 0xFFF2
|
||||
#define SIMPLEPROFILE_CHAR3_UUID 0xFFF3
|
||||
#define SIMPLEPROFILE_CHAR4_UUID 0xFFF4
|
||||
#define SIMPLEPROFILE_CHAR5_UUID 0xFFF5
|
||||
|
||||
// Simple Keys Profile Services bit fields
|
||||
#define SIMPLEPROFILE_SERVICE 0x00000001
|
||||
#define SIMPLEPROFILE_SERVICE 0x00000001
|
||||
|
||||
// Length of Characteristic 5 in bytes
|
||||
#define SIMPLEPROFILE_CHAR5_LEN 5
|
||||
/*user insert*/
|
||||
#define SIMPLEPROFILE_CHAR4_LEN 40
|
||||
#define SIMPLEPROFILE_CHAR3_LEN 20
|
||||
#define SIMPLEPROFILE_CHAR2_LEN 20
|
||||
#define SIMPLEPROFILE_CHAR1_LEN 2
|
||||
#define SIMPLEPROFILE_CHAR2_LEN 10
|
||||
#define SIMPLEPROFILE_CHAR3_LEN 20
|
||||
#define SIMPLEPROFILE_CHAR4_LEN 200
|
||||
//#define SIMPLEPROFILE_CHAR4_LEN 20
|
||||
#define SIMPLEPROFILE_CHAR5_LEN 20
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
@@ -101,20 +101,16 @@ extern "C"
|
||||
*/
|
||||
|
||||
// Callback when a characteristic value has changed
|
||||
typedef void (*simpleProfileChange_t)( uint8 paramID );
|
||||
typedef void (*simpleProfileChange_t)(uint8 paramID);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
simpleProfileChange_t pfnSimpleProfileChange; // Called when characteristic value changes
|
||||
typedef struct {
|
||||
simpleProfileChange_t pfnSimpleProfileChange; // Called when characteristic value changes
|
||||
} simpleProfileCBs_t;
|
||||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* API FUNCTIONS
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* SimpleProfile_AddService- Initializes the Simple GATT Profile service by registering
|
||||
* GATT attributes with the GATT server.
|
||||
@@ -123,7 +119,7 @@ typedef struct
|
||||
* contain more than one service.
|
||||
*/
|
||||
|
||||
extern bStatus_t SimpleProfile_AddService( uint32 services );
|
||||
extern bStatus_t SimpleProfile_AddService(uint32 services);
|
||||
|
||||
/*
|
||||
* SimpleProfile_RegisterAppCBs - Registers the application callback function.
|
||||
@@ -131,7 +127,7 @@ extern bStatus_t SimpleProfile_AddService( uint32 services );
|
||||
*
|
||||
* appCallbacks - pointer to application callbacks.
|
||||
*/
|
||||
extern bStatus_t SimpleProfile_RegisterAppCBs( simpleProfileCBs_t *appCallbacks );
|
||||
extern bStatus_t SimpleProfile_RegisterAppCBs(simpleProfileCBs_t *appCallbacks);
|
||||
|
||||
/*
|
||||
* SimpleProfile_SetParameter - Set a Simple GATT Profile parameter.
|
||||
@@ -143,7 +139,7 @@ extern bStatus_t SimpleProfile_RegisterAppCBs( simpleProfileCBs_t *appCallbacks
|
||||
* data type (example: data type of uint16 will be cast to
|
||||
* uint16 pointer).
|
||||
*/
|
||||
extern bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value );
|
||||
extern bStatus_t SimpleProfile_SetParameter(uint8 param, uint8 len, void *value);
|
||||
|
||||
/*
|
||||
* SimpleProfile_GetParameter - Get a Simple GATT Profile parameter.
|
||||
@@ -154,8 +150,7 @@ extern bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value
|
||||
* data type (example: data type of uint16 will be cast to
|
||||
* uint16 pointer).
|
||||
*/
|
||||
extern bStatus_t SimpleProfile_GetParameter( uint8 param, void *value );
|
||||
|
||||
extern bStatus_t SimpleProfile_GetParameter(uint8 param, void *value);
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||