Compare commits

...

28 Commits

Author SHA1 Message Date
alan 15cb7a0c62 Merge remote-tracking branch 'origin/Elite_LaunchPadTest' into Elite_LaunchPadTest 2019-05-30 17:40:31 +08:00
alan b0627e51e8 elite launch pad 2019-05-30 17:38:34 +08:00
YiChin fe279301d1 bug fix 2019-05-30 17:23:21 +08:00
YiChin 66e0c62750 bug fix 2019-05-30 16:46:01 +08:00
alan 98e48df14f elite launch pad 2019-05-30 16:32:20 +08:00
alan f814e12e56 elite launch pad 2019-05-30 16:31:26 +08:00
YiChin cb3bebca36 bug fix 2019-05-30 16:20:39 +08:00
alan 512d95b9ee elite launch pad 2019-05-30 16:11:01 +08:00
alan 74293a7d28 elite launch pad 2019-05-30 16:06:06 +08:00
YiChin 3f54899136 bug fix 2019-05-30 16:03:51 +08:00
alan 6ad3b562b7 elite launch pad 2019-05-30 15:56:57 +08:00
alan 19b83b69b2 elite launch pad 2019-05-30 15:49:35 +08:00
alan ac89659c77 elite launch pad 2019-05-30 15:39:38 +08:00
alan 463afb5d30 elite launch pad 2019-05-30 15:34:28 +08:00
alan 3fee0a3cbd elite launch pad 2019-05-30 15:30:50 +08:00
alan 04cee1794c elite launch pad 2019-05-30 15:14:41 +08:00
alan 606423928b elite launch pad 2019-05-30 15:06:21 +08:00
alan ace41c9edf elite launch pad 2019-05-30 15:03:40 +08:00
alan 94fce346e4 elite launch pad 2019-05-30 14:55:10 +08:00
alan 9f156469c1 elite launch pad 2019-05-30 14:34:36 +08:00
alan 5b9dccc66e elite launch pad 2019-05-30 14:33:02 +08:00
alan 823d5ee9c9 elite launch pad 2019-05-30 14:23:47 +08:00
alan a65e4d41f0 elite launch pad 2019-05-30 12:23:29 +08:00
YiChin 50505d8e4d bug fix 2019-05-30 12:13:35 +08:00
alan fc398f078f elite launch pad 2019-05-30 11:55:24 +08:00
alan f34ae830db elite launch pad 2019-05-30 11:49:20 +08:00
alan a72ab9d0d0 elite launch pad 2019-05-30 11:46:41 +08:00
alan 69bfaf060e elite launch pad 2019-05-30 10:45:47 +08:00
21 changed files with 565 additions and 827 deletions
@@ -16,7 +16,7 @@
# sources were generated) is:
# C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\config\src
#
GEN_SRC_DIR ?= ../../config/src
GEN_SRC_DIR ?= ../../../../../ti/simplelink/ble_sdk_2_02_02_25/examples/cc2650em/simple_peripheral/ccs/config/src
ifeq (,$(wildcard $(GEN_SRC_DIR)))
$(error "ERROR: GEN_SRC_DIR must be set to the directory containing the generated sources")
@@ -1,12 +1,12 @@
XOPTS = -I"C:/ti/xdctools_3_32_02_25_core/packages/" -Dxdc_target_types__=C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/targets/arm/elf/std.h -Dxdc_target_name__=M3
XOPTS = -I"C:/ti/xdctools_3_32_00_06_core/packages/" -Dxdc_target_types__=C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/targets/arm/elf/std.h -Dxdc_target_name__=M3
vpath % C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/sysbios/
vpath %.c C:/ti/xdctools_3_32_02_25_core/packages/
vpath %.c C:/ti/xdctools_3_32_00_06_core/packages/
CCOPTS = --endian=little -mv7M3 --abi=eabi -q -ms --opt_for_speed=0 --program_level_compile -o3 -g --optimize_with_debug -Dti_sysbios_knl_Task_minimizeLatency__D=FALSE -Dti_sysbios_family_arm_cc26xx_Boot_driverlibVersion=2 -Dti_sysbios_knl_Clock_stopCheckNext__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_enableException__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_disablePriority__D=32U -Dti_sysbios_family_arm_m3_Hwi_numSparseInterrupts__D=0U
XDC_ROOT = C:/ti/xdctools_3_32_02_25_core/packages/
XDC_ROOT = C:/ti/xdctools_3_32_00_06_core/packages/
BIOS_ROOT = C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/sysbios/
@@ -22,8 +22,8 @@ CC = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/bin/armcl -c $(CCOPTS) -I
ASM = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/include
AR = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/bin/armar rq
DEL = C:/ti/xdctools_3_32_02_25_core/packages/../bin/rm -f
CP = C:/ti/xdctools_3_32_02_25_core/packages/../bin/cp -f
DEL = C:/ti/xdctools_3_32_00_06_core/packages/../bin/rm -f
CP = C:/ti/xdctools_3_32_00_06_core/packages/../bin/cp -f
define RM
$(if $(wildcard $1),$(DEL) $1,:)
@@ -1,9 +1,10 @@
/*
** Stack Frontier Generator 1.1.0 (2016-03-28 14:11:07.308000)
** Stack Frontier Generator 1.1.0 (2019-05-30 16:41:28.535000)
**
** WARNING - Auto-generated file. Modifications could be lost!
*/
--define=ICALL_STACK0_ADDR=0xe001
--define=ICALL_STACK0_START=0xe000
--define=ICALL_RAM0_START=0x20004368
--define=ICALL_STACK0_ADDR=0xf001
--define=ICALL_STACK0_START=0xf000
--define=ICALL_RAM0_START=0x20004320
@@ -1,9 +1,10 @@
/*
** Stack Frontier Generator 1.1.0 (2016-03-28 14:11:07.308000)
** Stack Frontier Generator 1.1.0 (2019-05-30 16:41:28.535000)
**
** WARNING - Auto-generated file. Modifications could be lost!
*/
--define=ICALL_RAM0_START=0x20004368
--define=ICALL_STACK0_START=0xe000
--define=ICALL_STACK0_ADDR=0xe001
--define=ICALL_RAM0_START=0x20004320
--define=ICALL_STACK0_START=0xf000
--define=ICALL_STACK0_ADDR=0xf001
@@ -4,5 +4,5 @@
*/
"C:\ti\simplelink\ble_sdk_2_02_02_25\blelib\host\host_pxxx.a"
"C:\ti\simplelink\ble_sdk_2_02_02_25\blelib\ctrl\cc2640\cc2640_ctrl_pxxx_ext.a"
"C:\ti\simplelink\ble_sdk_2_02_02_25\blelib\hci_tl\cc26xx\cc26xx_hci_tl_none_v41_v42.a"
"C:\ti\simplelink\ble_sdk_2_02_02_25\blelib\ctrl\cc2640\cc2640_ctrl_pxxx.a"
"C:\ti\simplelink\ble_sdk_2_02_02_25\blelib\hci_tl\cc26xx\cc26xx_hci_tl_none.a"
@@ -16,7 +16,7 @@
# sources were generated) is:
# C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650lp\simple_peripheral\ccs\config\src
#
GEN_SRC_DIR ?= ../../config/src
GEN_SRC_DIR ?= ../../../../../ti/simplelink/ble_sdk_2_02_02_25/examples/cc2650lp/simple_peripheral/ccs/config/src
ifeq (,$(wildcard $(GEN_SRC_DIR)))
$(error "ERROR: GEN_SRC_DIR must be set to the directory containing the generated sources")
@@ -16,11 +16,11 @@ BIOS_INC = -I"C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/pa
TARGET_INC = -I"C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/"
INCS = $(BIOS_INC) $(TARGET_INC) --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/icall/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/dev_info" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/heapmgr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/controller/cc26xx/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/target" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/osal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/sdata" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/saddr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/icall/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/rom" --include_path="C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/cc26xxware_2_24_03_17272" -IC:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/
INCS = $(BIOS_INC) $(TARGET_INC) --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/include" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/npi" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/icall/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/dev_info" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/heapmgr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/controller/cc26xx/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/target" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/osal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/sdata" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/saddr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/icall/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/rom" --include_path="C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/cc26xxware_2_24_03_17272" -IC:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/
CC = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include
ASM = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include
AR = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armar rq
CC = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/include
ASM = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/include
AR = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/bin/armar rq
DEL = C:/ti/xdctools_3_32_00_06_core/packages/../bin/rm -f
CP = C:/ti/xdctools_3_32_00_06_core/packages/../bin/cp -f
@@ -81,9 +81,14 @@ const PIN_Config BoardGpioInitTable[] = {
Board_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */
Board_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */
Board_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */
Board_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */
Board_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */
Board_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */
Board_SPI0_MOSI | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN,
Board_SPI0_CLK | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_SPI0_CSN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
// Board_PWMPIN2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
PIN_TERMINATE
};
@@ -84,10 +84,11 @@ extern const PIN_Config BoardGpioInitTable[];
#define Board_UART_RTS IOID_18 /* RTS */
/* SPI Board */
#define Board_SPI0_MISO IOID_0 /* RF1.20 */
#define Board_SPI0_MOSI IOID_1 /* RF1.18 */
#define Board_SPI0_CLK IOID_3 /* RF1.16 */
#define Board_SPI0_CSN PIN_UNASSIGNED
#define Board_SPI0_MISO IOID_9 /* RF1.20 */
#define Board_SPI0_MOSI IOID_8 /* RF1.18 */
#define Board_SPI0_CLK IOID_10 /* RF1.16 */
#define Board_SPI0_CSN IOID_23
#define Board_SPI1_MISO PIN_UNASSIGNED
#define Board_SPI1_MOSI IOID_8 /* LED_MOSI */
#define Board_SPI1_CLK IOID_9 /* LED_CLK */
@@ -60,8 +60,13 @@ static uint8_t spi_ADC_rxbuf[SPI_ADC_SIZE] = {0};
//#define PIN_ADC_CS IOID_12
//#define PIN_DAC_CS IOID_9
PIN_Handle pin_handle;
static PIN_State ZM_rst;
static SPI_Handle spiHandle0 = NULL; // SPI0 is for ADC and DAC
static SPI_Params spiParams0;
static SPI_Transaction ZM_transaction;
#define SPI_DAC 0
#define SPI_ADC 1
static uint8_t SPI_mode;
static void ZM_update_instruction_callback(uint8_t ins_type, uint8_t chip_ID, uint8_t *ins);
@@ -69,15 +74,6 @@ static void ZM_update_instruction_callback(uint8_t ins_type, uint8_t chip_ID, ui
========== ramp generating ============
=====================================*/
static uint16_t ramp_counter = 0;
static void create_ramp(uint8_t *buff) {
buff[1] = (uint8_t)(ramp_counter >> 8);
buff[2] = (uint8_t)(ramp_counter);
ramp_counter += 1;
}
static uint8_t switch_on_key = 1;
/*
static void switch_on_callback(PIN_Handle handle, PIN_Id pin) {
if (pin == switch_on) {
@@ -86,27 +82,17 @@ static void switch_on_callback(PIN_Handle handle, PIN_Id pin) {
}
}
*/
static void ZM_init() {
set_update_instruction_callback(ZM_update_instruction_callback);
// initialize
pin_handle = PIN_open(&ZM_rst, BLE_IO);
PIN_setOutputValue(pin_handle, shutdown_6994, 1); // OFF = 1 => turn off 6994
PIN_setOutputValue(pin_handle, enable_10v, 0); // enable 10V
PIN_setOutputValue(pin_handle, ADC_CS, 1); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, DAC_CS, 1); // DAC_CS HIGH
ZM_spi_init();
// PIN_registerIntCb(pin_handle, switch_on_callback);
// PIN_setInterrupt(pin_handle, switch_on | PIN_IRQ_POSEDGE);
}
static void LTC_6994_init() {
LED_color(0xf0,0x00, 0x00, 0xff);
CPUdelay(0x03FFFFFF); // 0.5 sec
PIN_setOutputValue(pin_handle, shutdown_6994, 0); // OFF = 0 => turn on 6994
}
/*** register of ADC ***/
static void update_ADC_control_register() {
@@ -163,10 +149,10 @@ static void ADC_write(uint8_t ADCin) {
spi_ADC_txbuf[i] = 0;
}
PIN_setOutputValue(pin_handle, DAC_CS, 1); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, ADC_CS, 0); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, Board_SPI0_CSN, 1); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, Board_SPI0_CSN, 0); // ADC_CS HIGH
ZM_spi_transaction(2, spi_ADC_txbuf, spi_ADC_rxbuf);
PIN_setOutputValue(pin_handle, ADC_CS, 1); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, Board_SPI0_CSN, 1); // ADC_CS HIGH
}
static void ADC_read(){
@@ -181,10 +167,10 @@ static void ADC_read(){
spi_ADC_rxbuf[i] = 0;
}
PIN_setOutputValue(pin_handle, DAC_CS, 1); // DAC_CS HIGH
PIN_setOutputValue(pin_handle, ADC_CS, 0); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, Board_SPI0_CSN, 1); // DAC_CS HIGH
PIN_setOutputValue(pin_handle, Board_SPI0_CSN, 0); // ADC_CS HIGH
ZM_spi_transaction(SPI_ADC_SIZE, spi_ADC_txbuf, spi_ADC_rxbuf);
PIN_setOutputValue(pin_handle, ADC_CS, 1); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, Board_SPI0_CSN, 1); // ADC_CS HIGH
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, SPI_ADC_SIZE, spi_ADC_rxbuf);
SimpleProfile_SetParameter(BLE_DAT_BUFF_CHAR, SPI_ADC_SIZE, spi_ADC_rxbuf);
@@ -208,10 +194,10 @@ static void DAC_outputV(uint8_t command, uint8_t v1, uint8_t v2) {
ZM_spi_init();
}
PIN_setOutputValue(pin_handle, ADC_CS, 1); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, DAC_CS, 0); // DAC_CS LOW
PIN_setOutputValue(pin_handle, Board_SPI0_CSN, 1); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, Board_SPI0_CSN, 0); // DAC_CS LOW
ZM_spi_transaction(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
PIN_setOutputValue(pin_handle, DAC_CS, 1); // DAC_CS HIGH
PIN_setOutputValue(pin_handle, Board_SPI0_CSN, 1); // DAC_CS HIGH
}
static void VoltScan(){
@@ -219,7 +205,7 @@ static void VoltScan(){
uint8_t ramp0 = (uint8_t) (VoltOrigin & 0x00FF);
uint8_t ramp1 = (uint8_t) ((VoltOrigin>>8) & 0x00FF);
DAC_outputV(0x30, ramp1, ramp0);
PeriodicEvent = false;
// PeriodicEvent = false;
}
else if(VoltOrigin < VoltFinal){
IVCurve_T();
@@ -230,12 +216,9 @@ static void VoltScan(){
}
static void cyclic_Voltammetry(){
DAC_outputV(0x30, 0x7F, 0xF0);
ADC_write(0x00);
ADC_read();
}
static void fxn_Gen() {}
@@ -283,20 +266,6 @@ static void ramp_test(){
}
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[18] = 0xffff;
spi_LEDtxbuf[19] = 0xffff;
LED_ADC_SPI(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf);
}
static void SimpleBLEPeripheral_clockHandler(UArg arg) {
// Store the event.
// events |= SBP_PERIODIC_EVT;
@@ -400,8 +369,8 @@ static void IVCurve_T(){
// check if we reach the final volt
ramp = ( (uint16_t) (ramp1)<<8 ) | ( (uint16_t) (ramp0) );
if ( ramp >= VoltFinal) {
PeriodicEvent = false;
reset = true;
// PeriodicEvent = false;
// reset = true;
// reset all the parameter
VoltOrigin = 0x7FF0;
@@ -447,8 +416,8 @@ static void IVCurve_T2(){
// check if we reach the final volt
ramp = ( (uint16_t) (ramp1)<<8 ) | ( (uint16_t) (ramp0) );
if ( ramp <= VoltFinal) {
PeriodicEvent = false;
reset = true;
// PeriodicEvent = false;
// reset = true;
// reset all the parameter
VoltOrigin = 0x7FF0;
@@ -477,99 +446,99 @@ static void IVCurve_T2(){
static void WorkModeLED(){
switch(INSTRUCTION.eliteFxn){
case IVCurve:{
LED_color(0xE1, 0xF4, 0x00, 0x00);
break;
}
case cyclicVoltammetry:{
LED_color(0xE1, 0xF4, 0x00, 0x00);
break;
}
case fxnGen:{
LED_color(0xE1, 0xF4, 0x00, 0x00);
break;
}
case ZTCurve:{
LED_color(0xE1, 0x00, 0x00, 0xF4);
break;
}
case VTCurve:{
LED_color(0xE1, 0xF4, 0x00, 0x00);
break;
}
case ITCurve:{
LED_color(0xE1, 0xF4, 0x00, 0xF4);
break;
}
case VIS_RST:{
LEDPowerON();
break;
}
case RAMP_GENERATE:{
LED_color(0xE1, 0xF4, 0x00, 0x00);
break;
}
case ADCTEST:{
LEDPowerON();
break;
}
default:{
LEDPowerON();
break;
}
}
}
static void KeyWorkModeLED(){
switch(INSTRUCTION.eliteFxn){
case IVCurve:{
LED_color(0xEF, 0xF4, 0x00, 0x00);
break;
}
case cyclicVoltammetry:{
LED_color(0xEF, 0xF4, 0x00, 0x00);
break;
}
case fxnGen:{
LED_color(0xEF, 0xF4, 0x00, 0x00);
break;
}
case ZTCurve:{
LED_color(0xEF, 0x00, 0x00, 0xF4);
break;
}
case VTCurve:{
LED_color(0xEF, 0xF4, 0x00, 0x00);
break;
}
case ITCurve:{
LED_color(0xEF, 0xF4, 0x00, 0x00);
break;
}
case VIS_RST:{
LED_color(0xEF, 0x00, 0xFA, 0x00);
break;
}
case RAMP_GENERATE:{
LED_color(0xEF, 0xF4, 0x00, 0x00);
break;
}
case ADCTEST:{
LED_color(0xEF, 0x00, 0xF4, 0x00);
break;
}
default:{
LED_color(0xEF, 0x00, 0xFA, 0x00);
break;
}
}
}
//static void WorkModeLED(){
// switch(INSTRUCTION.eliteFxn){
// case IVCurve:{
// LED_color(0xE1, 0xF4, 0x00, 0x00);
// break;
// }
// case cyclicVoltammetry:{
// LED_color(0xE1, 0xF4, 0x00, 0x00);
// break;
// }
// case fxnGen:{
// LED_color(0xE1, 0xF4, 0x00, 0x00);
// break;
// }
// case ZTCurve:{
// LED_color(0xE1, 0x00, 0x00, 0xF4);
// break;
// }
// case VTCurve:{
// LED_color(0xE1, 0xF4, 0x00, 0x00);
// break;
// }
// case ITCurve:{
// LED_color(0xE1, 0xF4, 0x00, 0xF4);
// break;
// }
//
// case VIS_RST:{
// LEDPowerON();
// break;
// }
// case RAMP_GENERATE:{
// LED_color(0xE1, 0xF4, 0x00, 0x00);
// break;
// }
// case ADCTEST:{
// LEDPowerON();
// break;
// }
//
// default:{
// LEDPowerON();
// break;
// }
// }
//}
//
//static void KeyWorkModeLED(){
// switch(INSTRUCTION.eliteFxn){
// case IVCurve:{
// LED_color(0xEF, 0xF4, 0x00, 0x00);
// break;
// }
// case cyclicVoltammetry:{
// LED_color(0xEF, 0xF4, 0x00, 0x00);
// break;
// }
// case fxnGen:{
// LED_color(0xEF, 0xF4, 0x00, 0x00);
// break;
// }
// case ZTCurve:{
// LED_color(0xEF, 0x00, 0x00, 0xF4);
// break;
// }
// case VTCurve:{
// LED_color(0xEF, 0xF4, 0x00, 0x00);
// break;
// }
// case ITCurve:{
// LED_color(0xEF, 0xF4, 0x00, 0x00);
// break;
// }
//
// case VIS_RST:{
// LED_color(0xEF, 0x00, 0xFA, 0x00);
// break;
// }
// case RAMP_GENERATE:{
// LED_color(0xEF, 0xF4, 0x00, 0x00);
// break;
// }
// case ADCTEST:{
// LED_color(0xEF, 0x00, 0xF4, 0x00);
// break;
// }
//
// default:{
// LED_color(0xEF, 0x00, 0xFA, 0x00);
// break;
// }
// }
//}
static void EliteKeyPress(uint8_t key){
static uint8_t ShutDownCounter = 0;
@@ -578,11 +547,11 @@ static void EliteKeyPress(uint8_t key){
if(key == 0){
// key = 0 if press
// press key => bight LED
KeyWorkModeLED();
// KeyWorkModeLED();
// press 3~4 sec, shutdown 2650
if(ShutDownCounter >= 35){
PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V
// PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V
}
else{
ShutDownCounter ++;
@@ -593,7 +562,7 @@ static void EliteKeyPress(uint8_t key){
if(OriginEliteFxn == INSTRUCTION.eliteFxn){
if(ShutDownCounter != 0){
// dark LED
WorkModeLED();
// WorkModeLED();
ShutDownCounter = 0;
}
}
@@ -603,7 +572,7 @@ static void EliteKeyPress(uint8_t key){
ShutDownCounter = 0;
}
// dark mode LED
WorkModeLED();
// WorkModeLED();
}
}
}
@@ -615,8 +584,8 @@ static bool TurnOnElite(uint8_t key){
// press 1 sec, power on LED
if(TurnOnCounter >= 15){
// PIN_setOutputValue(pin_handle, enable_10v, 1); // enable 10V
PIN_setOutputValue(pin_handle, enable_5v, 1); // enable 5V
LEDPowerON();
// PIN_setOutputValue(pin_handle, enable_5v, 1); // enable 5V
// LEDPowerON();
return true;
}
else{
@@ -626,21 +595,21 @@ static bool TurnOnElite(uint8_t key){
}
else{
TurnOnCounter = 0;
PIN_setOutputValue(pin_handle, enable_5v, 0); // enable 5V
// PIN_setOutputValue(pin_handle, enable_5v, 0); // enable 5V
return false;
}
}
static void reset(){;
PeriodicEvent = false;
static void reset(){
// PeriodicEvent = false;
VoltOrigin = 0;
VoltFinal = 0;
Step = 10; // 10 = 0x0A ~= 3.05 mv ~= 3 mv
StepTime = 24; // 0x30 = 2'd48 ~= 2 second, 24 = 0x18
PeriodicCounter = 0;
LEDPowerON();
// LEDPowerON();
for(int i=0 ; i<BLE_INS_BUFF_SIZE ; i++){
ins_buf[i] = 0;
}
@@ -664,8 +633,8 @@ static void reset(){;
ZM_spi_init();
DAC_init();
PIN_setOutputValue(pin_handle, ADC_CS, 1); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, DAC_CS, 1); // DAC_CS HIGH
PIN_setOutputValue(pin_handle, Board_SPI0_CSN, 1); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, Board_SPI0_CSN, 1); // DAC_CS HIGH
}
/*
@@ -691,7 +660,42 @@ static void SendNotify(){
not_buf[18] = (not_time_stamp >> 16) & 0xff;
not_buf[19] = (not_time_stamp >> 24) & 0xff;
SimpleProfile_SetParameter(BLE_DAT_BUFF_CHAR, BLE_DAT_BUFF_SIZE, not_buf);
// SimpleProfile_SetParameter(BLE_DAT_BUFF_CHAR, BLE_DAT_BUFF_SIZE, not_buf);
}
static void ZM_spi_init() {
SPI_init();
SPI_Params_init(&spiParams0);
spiParams0.bitRate = 1200000; // 1.2M
spiParams0.mode = SPI_MASTER;
spiParams0.dataSize = 8;
spiParams0.frameFormat = SPI_POL0_PHA0;
spiHandle0 = SPI_open(Board_SPI0, &spiParams0); // ADC and DAC
SPI_mode = SPI_DAC;
}
static void ADC_spi_init(){
SPI_init();
SPI_Params_init(&spiParams0);
spiParams0.bitRate = 1200000; // 1.2M
spiParams0.mode = SPI_MASTER;
spiParams0.dataSize = 8;
spiParams0.frameFormat = SPI_POL0_PHA1;
spiHandle0 = SPI_open(Board_SPI0, &spiParams0); // ADC and DAC
SPI_mode = SPI_ADC;
}
// for DAC / ADC
static void ZM_spi_transaction(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
ZM_transaction.count = length;
ZM_transaction.txBuf = spi_txbuf;
ZM_transaction.rxBuf = spi_rxbuf;
SPI_transfer(spiHandle0, &ZM_transaction);
}
#endif /* IMPEDANCE_METER_H_ */
@@ -548,18 +548,10 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
headstage_init_device_info();
// headstage_gptimer_init();
LED_spi_init();
ZM_spi_init();
ZM_init();
DAC_init();
uint8_t key = 0;
uint8_t counter6994 = 0;
bool EliteOn = 0;
bool Wake6994 = true;
Util_constructClock(&periodicClock, SimpleBLEPeripheral_clockHandler, SBP_PERIODIC_EVT_PERIOD, 0, false, SBP_PERIODIC_EVT);
Util_startClock(&periodicClock);
// Util_startClock(&periodicClock);
// Application main loops
for (;;) {
@@ -611,36 +603,6 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
}
}
if(!PeriodicEvent){
Util_startClock(&periodicClock);
key = PIN_getInputValue(switch_on);
if(EliteOn){
if(Wake6994 < 35){
counter6994 ++;
}
else if(Wake6994 == 35){
PIN_setOutputValue(pin_handle, shutdown_6994, 0); // OFF = 1 => turn off 6994
Wake6994 ++;
}
EliteKeyPress(key);
}
else{
EliteOn = TurnOnElite(key);
}
}
else{
Util_startClock(&periodicClock);
if(PeriodicCounter >= StepTime){
SimpleBLEPeripheral_performPeriodicTask();
PeriodicCounter = 0;
}
key = PIN_getInputValue(switch_on);
EliteKeyPress(key);
PeriodicCounter ++;
}
}
@@ -832,9 +794,9 @@ static void SimpleBLEPeripheral_processAppMsg(sbpEvt_t *pMsg) {
break;
case SBP_CHAR_CHANGE_EVT:
// headstage_instruction_update_handle(pMsg->hdr.state);
headstage_instruction_update_handle(pMsg->hdr.state);
// LED_color(0xE6, 0xFF, 0xFA, 0x0A);
ZM_instruction_update_handle(pMsg->hdr.state);
// ZM_instruction_update_handle(pMsg->hdr.state);
break;