Compare commits

..

137 Commits

Author SHA1 Message Date
Roy c52078cc30 Refactor(#7): clean unused code
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-06-14 13:16:07 +08:00
Roy 9472ff4ce2 Merge branch 'dev/elite/trig0.1/modularize_some_function' into elite/trig0.1 2023-06-14 13:14:00 +08:00
Roy 52643ae5d7 Refactor(#7): update pr0/pr1 instruction
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-06-13 17:56:43 +08:00
Roy 09d51b5fd6 Refactor(#7): update chan_en parameter
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-06-06 16:11:08 +08:00
Roy fe13bf4f42 Refactor(#7): remove TRC
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-06-05 16:26:08 +08:00
Roy 0607d6cf9b Feat(#7): new D0/D1 as 5V function
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-06-05 14:47:37 +08:00
Roy 2361e857e9 Feat(#7): update mode_all_output_ctrl mode
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-06-02 11:01:47 +08:00
Roy 49d13b8d34 Feat(#7): optimization led code
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-06-01 15:47:52 +08:00
Roy 1462879b29 Feat(#7): ctrl pr0/d0/d1/a0/a1/a2/a3/pr1 power
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-06-01 13:42:08 +08:00
Roy 9484705b3b Feat(#7): remove spi1
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-06-01 12:40:38 +08:00
Roy 35502b18f0 Feat(#7): fix pr0/d0/d1/a0/a1/a2/pr1 power (a3 -> pr1)
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-06-01 11:25:14 +08:00
Roy 1dbffad946 Feat(#7): fix pr0/d0/d1/a0/a1/a2/a3 power
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-06-01 09:43:36 +08:00
Roy 65bb984692 Feat(#7): fix finishMode flag
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-05-31 15:26:39 +08:00
Roy 890df7ce16 Feat(#7): control pr0/d0/d1/a0/a1/a2/a3 power
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-05-31 15:12:48 +08:00
Roy 56dca39a16 Feat(#7): control pr1 power
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-05-31 13:41:36 +08:00
Roy 8162d4eca6 Feat(#7): control pr0 power
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-05-31 11:31:28 +08:00
Roy 2067de1fb6 Feat(#7): control pr0 power
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-05-30 17:13:27 +08:00
Roy 2bcccf6036 Feat(#7): control pr0 power
https://www.notion.so/439a3c3a2694457ebb9233903291d6cd?v=6f499c754ed34fc09ee1d8d7590f8478&p=c382a9f88a444185873dbb62a7deee1a&pm=s
2023-05-30 11:51:45 +08:00
Roy 31c8797a82 Feat(#7): clean code 2023-05-29 13:47:22 +08:00
Roy b359ebf5f9 Feat(#7): clean code 2023-05-29 11:45:08 +08:00
Roy 55c4df4dcb Feat(#7): clean code 2023-05-26 17:27:49 +08:00
Roy 2fbd57cfb4 Feat(#7): clean code and fix ACC mode 2023-05-26 13:55:07 +08:00
Roy 75e21615d0 Feat(#7): fix gp timer and notify buffer 2023-05-24 11:32:31 +08:00
Roy 97495ceb25 Feat(#7): clean code 2023-05-19 17:48:17 +08:00
Roy 258b8a1c02 Feat(#7): clean code 2023-05-19 17:20:10 +08:00
Roy 46ea9c7afd Feat(#7): clean code 2023-05-19 16:54:25 +08:00
Roy e188cd23c4 Feat(#7): clean code 2023-05-19 14:34:36 +08:00
Roy da720eb9f4 Feat(#7): clean code 2023-05-19 14:16:32 +08:00
Roy d342ae3e9c Feat(#7): fix led and output buf
https://www.notion.so/7-Modularize-some-function-e19a0f14fb3f494b9fbb5103d7befb7f
2023-05-18 22:56:22 +08:00
Roy a9d24ad477 Feat(#7): fix battery and temperature buf
https://www.notion.so/7-Modularize-some-function-e19a0f14fb3f494b9fbb5103d7befb7f
2023-05-18 15:47:24 +08:00
Roy 7759c9eae9 Feat(#7): remove noused function
https://www.notion.so/7-Modularize-some-function-e19a0f14fb3f494b9fbb5103d7befb7f
2023-05-18 15:18:40 +08:00
Roy 9e42593882 Feat(#7): new spi function
https://www.notion.so/7-Modularize-some-function-e19a0f14fb3f494b9fbb5103d7befb7f
2023-05-18 14:41:06 +08:00
Roy af03bc03e2 Feat(#7): new spi function
https://www.notion.so/7-Modularize-some-function-e19a0f14fb3f494b9fbb5103d7befb7f
2023-05-18 14:34:49 +08:00
Roy d096eabf47 Feat(#7): remove noused function
https://www.notion.so/7-Modularize-some-function-e19a0f14fb3f494b9fbb5103d7befb7f
2023-05-18 14:07:07 +08:00
Roy 441bd80595 Feat(#7): remove noused function
https://www.notion.so/7-Modularize-some-function-e19a0f14fb3f494b9fbb5103d7befb7f
2023-05-18 13:55:42 +08:00
Roy 3557c3d288 Feat(#7): fix led
https://www.notion.so/7-Modularize-some-function-e19a0f14fb3f494b9fbb5103d7befb7f
2023-05-18 13:26:12 +08:00
Roy 16ac2ab82d Feat(#7): modularize boot function
https://www.notion.so/7-Modularize-some-function-e19a0f14fb3f494b9fbb5103d7befb7f
2023-05-18 11:34:24 +08:00
Roy 6756a057bc Feat(#7): modularize timer function
https://www.notion.so/7-Modularize-some-function-e19a0f14fb3f494b9fbb5103d7befb7f
2023-05-18 11:09:27 +08:00
Roy 00c61096b7 Refactor: update elite version 2023-05-16 14:33:42 +08:00
Roy 119285f7c8 Feat(#6): new instruction of pin control
https://www.notion.so/6-TRIG0-1-5V-c382a9f88a444185873dbb62a7deee1a
2023-05-16 13:41:05 +08:00
Roy fce1a943e1 Feat(#6): new instruction of pin control
https://www.notion.so/6-TRIG0-1-5V-c382a9f88a444185873dbb62a7deee1a
2023-05-16 11:21:12 +08:00
Roy 30bd896d4c Feat(#6): clean code (battery&temperature) 2023-05-15 17:27:06 +08:00
Roy 5b2ccf8e7c Feat(#6): clean code (battery&temperature) 2023-05-15 16:39:52 +08:00
Roy ea24ba5406 Feat(#6): clean code 2023-05-15 16:21:13 +08:00
Roy a23083c080 Feat(#6): clean code 2023-05-12 18:12:38 +08:00
Roy 735ffa2bef Feat(#6): clean code 2023-05-10 16:36:14 +08:00
Roy 5ad2759a81 Feat(#6): clean code 2023-05-10 16:15:15 +08:00
Roy 31c990bc18 Feat(#6): clean code 2023-05-10 15:56:20 +08:00
Roy 9c839a181f Feat(#6): clean code 2023-05-10 15:48:46 +08:00
Roy a10517bf38 Feat(#6): clean code 2023-05-10 15:26:44 +08:00
Roy ac7aaad5a2 Feat(#6): clean code 2023-05-10 14:41:24 +08:00
ROY bc21e3cb27 [update] fix short instruction and LED 2023-01-09 16:27:36 +08:00
ROY 9baa4e8ae0 [update] fix product name 2023-01-09 16:20:07 +08:00
ROY 00e233cc9e [update] clear code 2023-01-09 16:01:09 +08:00
ROY 13b4e2253c [copy] copy 37157110fff478e22958661c116a49963edab874 version from BPS_bioprocc2650 project 2022-08-12 18:04:39 +08:00
ROY 9c29ad0a86 [update] new dev tool function: LED 2022-08-11 15:58:46 +08:00
ROY 6b421d73e9 [update] fix start voltage on cc/cp mode 2022-08-11 11:14:12 +08:00
ROY 34107872ec [update] rel/elite/edc1.5/v1.15.0 2022-08-10 17:16:50 +08:00
ROY f6719c3182 [update] update model name 2022-08-05 16:28:28 +08:00
ROY 79188d76b9 [update] new cp mode (cc cp separate) 2022-08-04 18:14:43 +08:00
ROY 3e5c9b9b73 [update] clean up the code 2022-08-03 17:06:08 +08:00
ROY f1fa366b8f [update] clean up the code 2022-08-03 16:22:08 +08:00
ROY 16814ad816 [cali] add BOARD_20 calibration data. 2022-08-02 16:32:08 +08:00
ROY 92ae63b7f9 [cali] add BOARD_19 calibration data. 2022-08-02 16:29:45 +08:00
ROY 1f3e7a5efe [cali] add BOARD_21 calibration data. 2022-08-02 16:03:08 +08:00
ROY c573135e98 [update] VIN_GAIN_MID1_BOUNDARY2 = 290mV 2022-08-02 11:33:04 +08:00
ROY 5d4c5b5a86 Merge branch 'dev/elite1.5re/fix_auto_gain' into elite/edc1.5re 2022-08-01 18:12:59 +08:00
ROY caf6985e66 [update] fix auto gain 2022-08-01 18:12:25 +08:00
ROY a7a1f7f2b5 [update] fix gain 2022-07-29 13:09:24 +08:00
ROY 45182935b7 [update] remove CC_ZERO mode and fix gain 2022-07-29 11:31:26 +08:00
ROY 6958c410a1 [update] move device info 2022-07-29 09:38:29 +08:00
ROY a337434903 [update] delete unused file 2022-07-28 17:55:40 +08:00
ROY 14c897c26e [update] delete unused file 2022-07-28 17:54:32 +08:00
ROY 02a6018cac [update] delete Elite.json 2022-07-28 17:53:40 +08:00
ROY 544b571f85 [note] fix mode enum 2022-07-28 17:52:41 +08:00
ROY 939de9098a [update] fix step time on IV & Cycle-IV mode 2022-07-28 16:32:55 +08:00
ROY 7441d9a5c8 [cali] add BOARD_18 calibration data. 2022-07-28 11:48:03 +08:00
ROY a680f59277 [cali] add BOARD_17 calibration data. 2022-07-28 11:45:24 +08:00
ROY b595215326 [update] limit volt = 100mV on cc mode 2022-07-28 10:57:38 +08:00
ROY 901108ea90 [update] fix main loop 2022-07-28 10:09:04 +08:00
ROY 16dc76833a [update] update device info 2022-07-27 10:16:15 +08:00
JayC319 e6993f5a4a [update] minor changes and instruction added 2022-07-22 14:39:04 +08:00
ROY a2b5a5728b [update] update adc function 2022-07-22 14:09:24 +08:00
JayC319 4d76e4585e [update] variable name changed 2022-07-22 13:14:03 +08:00
JayC319 43e72567c0 [update] ADC modulized small fix 2022-07-22 13:04:03 +08:00
ROY 311f0d1238 Merge branch 'dev/eliteedc1.5re/merge_latch_adc_dac' into elite/edc1.5re 2022-07-22 10:19:17 +08:00
ROY 7177e8549b [update] merge latch & adc & dac code 2022-07-22 10:19:01 +08:00
ROY 7106f59122 Merge branch 'dev/roy/latch' into test 2022-07-22 09:59:16 +08:00
ROY 2c203b73a1 [update] update latch process 2022-07-22 09:57:01 +08:00
JayC319 ba7552e091 [update] "latest version" 2022-07-22 09:48:14 +08:00
JayC319 4b65c8666e Merge branch 'dev/ADC_modulize' of https://gitlab.com/wisetop/microchip/application/cc2650/wtp_cc2650_development into dev/ADC_modulize 2022-07-22 09:44:09 +08:00
JayC319 5dc35425d5 [update] ADC modulized done and ADC rx buffer revised 2022-07-22 09:41:39 +08:00
JayC319 790db4bcf4 [update] DAC modulized finished and DAC rx buffer revised 2022-07-22 09:26:12 +08:00
ROY d9cc6f2ba6 [update] update latch process 2022-07-21 17:34:17 +08:00
ROY 5e04fcb7e2 [update] update latch process 2022-07-21 17:29:31 +08:00
ROY dc5cabf2ae [update] update latch process 2022-07-21 15:20:50 +08:00
ROY 7cf60e2717 [update] update latch process 2022-07-21 14:12:41 +08:00
JayC319 f1ab4be88a [update] adc modulized first version done and dac modulize revision 2022-07-19 17:47:04 +08:00
JayC319 3509b6df00 Merge branch 'dev/1.5re/DAC_modulize' into dev/elite/edc1.5re/merge_dac_and_cc_mode 2022-07-18 18:57:48 +08:00
JayC319 26b37b759f Merge branch 'dev/1.5re/DAC_modulize' into dev/elite/edc1.5re/merge_dac_and_cc_mode 2022-07-18 18:57:03 +08:00
JayC319 6321fdca51 [update] DAC_modulized function ok 2022-07-18 18:20:01 +08:00
ROY c496ccb791 [update] fix charge/discharge problem on cc mode 2022-07-15 21:48:13 +08:00
JayC319 c8aeabdfeb [update] DAC_modulized function ok 2022-07-14 18:11:22 +08:00
JayC319 9bfc251029 [update] DAC_modulized 2022-07-14 17:09:25 +08:00
JayC319 0273a9571b [update] nono 2022-07-13 19:05:06 +08:00
JayC319 5318a89132 [update] button and LED modulizing finished 2022-07-12 15:45:02 +08:00
JayC319 a4f653951e [update] finished button modulized 2022-07-12 10:46:18 +08:00
JayC319 925447817f [update] check comiler 2022-07-11 14:34:28 +08:00
JayC319 b64a3d031f [update] boardselect changed, Elite_PIN.h delete 2022-07-08 14:06:04 +08:00
JayC319 6fc7b2591f [update] gpio modulize 2022-07-07 17:58:16 +08:00
JayC319 00cc58e720 [update]modulize_LED 2022-07-06 18:06:18 +08:00
ROY fcc1477acd [cali] add BOARD_16 calibration data. 2022-07-04 17:59:09 +08:00
ROY 545fc8323c [update] remove old pulse mode 2022-07-04 10:50:02 +08:00
ROY 4c654982d2 [cali] add BOARD_15 calibration data. 2022-07-04 10:25:05 +08:00
ROY d7a4e02349 [cali] add BOARD_14 calibration data. 2022-07-04 10:22:00 +08:00
ROY ee1d052c3a [cali] add BOARD_13 calibration data. 2022-06-22 15:36:50 +08:00
ROY 7acafa81b8 [cali] add BOARD_12 calibration data. 2022-06-22 15:33:59 +08:00
ROY e97d556dd9 [cali] update BOARD_7 calibration data. 2022-06-10 18:19:46 +08:00
ROY c227d21546 [update] use red led when BT timeout 2022-06-01 10:57:35 +08:00
ROY f9e33d0ede [cali] add BOARD_11 calibration data. 2022-05-31 16:13:51 +08:00
ROY a9fd1028d1 [cali] add BOARD_8 calibration data. 2022-05-31 16:08:18 +08:00
ROY f6a20eaea5 [cali] update BOARD_2 calibration data. 2022-05-31 13:26:34 +08:00
ROY f904bbd522 [cali] update BOARD_7 calibration data. 2022-05-31 13:23:55 +08:00
ROY 6f3a1b57ae [cali] add BOARD_7 calibration data. 2022-05-26 17:31:39 +08:00
ROY b795b7eb6b [cali] update BOARD_8 & BOARD_9 & BOARD_10 calibration data. 2022-05-26 17:22:37 +08:00
ROY a1adf82f2b [update] cc & cp corrected speed 1/10/100 2022-05-23 11:00:46 +08:00
Roy 061064c27a [update] don't use GPT_MODE_PERIODIC_DOWN 2022-05-18 15:17:38 +08:00
Roy 2d1556686c [cali] update BOARD_1 calibration data. 2022-05-04 10:40:13 +08:00
Roy 0d7f334499 [cali] update BOARD_4 calibration data. 2022-05-04 10:38:25 +08:00
Roy b849231be3 [update] fix manual current stalls 2022-04-29 18:37:39 +08:00
Roy 060dde64a8 [cali] update BOARD_5 calibration data. 2022-04-29 16:48:21 +08:00
Roy 6be73528d4 [cali] update BOARD_1 calibration data. 2022-04-29 10:12:16 +08:00
Roy 7b4436920f [cali] update BOARD_2 calibration data. 2022-04-28 18:18:26 +08:00
Roy b34e947cc8 [update] fix power off led 2022-04-28 10:15:20 +08:00
Roy 8c4737e494 [cali] add BOARD_6 calibration data. 2022-04-27 16:57:55 +08:00
Roy 6f36e781b7 [cali] add BOARD_5 calibration data. 2022-04-27 16:55:25 +08:00
Roy 8403c16fa0 [update] fix highz problem 2022-04-27 13:18:24 +08:00
21 changed files with 3686 additions and 475 deletions
+55
View File
@@ -0,0 +1,55 @@
#Generated from Visual Studio settings
---
BasedOnStyle: webkit
BraceWrapping:
BeforeCatch: true
BeforeElse: true
AfterClass: true
AfterFunction: true
AfterControlStatement: true
AfterEnum: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
ColumnLimit: 0
BreakBeforeBraces: Custom
NamespaceIndentation: All
TabWidth: 4
IndentCaseLabels: true
AlignAfterOpenBracket: Align
PointerAlignment: Right
AlignOperands: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortLoopsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: false
BreakAfterJavaFieldAnnotations: true
AlignConsecutiveAssignments: true
AlignTrailingComments: true
BreakConstructorInitializers: AfterColon
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignArrayOfStructures: Right
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: true
PadOperators: true
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: true
PadOperators: true
AlignEscapedNewlines: Right
BinPackArguments: false
BinPackParameters: false
...
@@ -50,7 +50,7 @@ extern "C" {
* ==========================================================================*/
#include <ti/drivers/PIN.h>
#include <driverlib/ioc.h>
// #include "application_config/application_config.h"
#include "boards_config/elite_boards_select.h"
/** ============================================================================
* Externs
@@ -146,6 +146,12 @@ extern const PIN_Config BoardGpioInitTable[];
#define Board_UART_TX Board_BP_UART_Rx /* RXD */
#define Board_UART_RX Board_BP_UART_Tx /* TXD */
// /* 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
/* Power Management Board */
#define Board_SRDY Board_BP_Pin_J2_19
#define Board_MRDY Board_BP_Pin_J1_2
@@ -160,35 +166,6 @@ extern const PIN_Config BoardGpioInitTable[];
#define Board_PWMPIN6 PIN_UNASSIGNED
#define Board_PWMPIN7 PIN_UNASSIGNED
/* SPI & I2C Board */
#ifndef DEF_ELITE_MODEL
#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
#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_I2C0_SCL0 PIN_UNASSIGNED
#define Board_I2C0_SDA0 PIN_UNASSIGNED
#else
#define Board_SPI0_MISO E_SPI0_MISO
#define Board_SPI0_MOSI E_SPI0_MOSI
#define Board_SPI0_CLK E_SPI0_CLK
#define Board_SPI0_CS E_SPI0_CS
#define Board_SPI1_MISO E_SPI1_MISO
#define Board_SPI1_MOSI E_SPI1_MOSI
#define Board_SPI1_CLK E_SPI1_CLK
#define Board_SPI1_CS E_SPI1_CS
#define Board_I2C0_SCL0 E_I2C0_SCL0
#define Board_I2C0_SDA0 E_I2C0_SDA0
#endif
/** ============================================================================
* Instance identifiers
* ==========================================================================*/
@@ -0,0 +1,141 @@
#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_TRIG_0_1
#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)
#include "boards_config/pin_def_trig01.h"
#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
@@ -0,0 +1,93 @@
#ifndef PIN_DEF_TRIG01_H
#define PIN_DEF_TRIG01_H
#ifdef __cplusplus
extern "C"
{
#endif
/*
* +------------------------------+
* | CC2650moda |
* +-------------+----------------+
* | TRIG_0 | DIO_0 |
* | MISO | DIO_1 |
* | TRIG_1 | DIO_2 | re: short TRIG_1 & LOAD2
* | D0 | DIO_3 |
* | D1 | DIO_4 |
* | D2/JTAG_TDO | DIO_5/JTAG_TDO |
* | D3/JTAG_TDI | DIO_6/JTAG_TDI |
* | D4 | DIO_7 |
* | D5 | DIO_8 |
* | D6 | DIO_9 |
* | D7 | DIO_10 |
* | LOAD0 | DIO_11 |
* | LOAD1 | DIO_12 |
* | FLT | DIO_13 |
* | SHUT_DOWN | DIO_14 |
* +-------------+----------------+
*/
#define CC2650_TRIG_0 DIO0
#define CC2650_MISO DIO1
#define CC2650_TRIG_1 DIO2
#define CC2650_D0 DIO3
#define CC2650_D1 DIO4
#define CC2650_D2 DIO5
#define CC2650_D3 DIO6
#define CC2650_D4 DIO7
#define CC2650_D5 DIO8
#define CC2650_D6 DIO9
#define CC2650_D7 DIO10
#define CC2650_LOAD0 DIO11
#define CC2650_LOAD1 DIO12
#define CC2650_FLT DIO13
#define CC2650_SHUT_DOWN DIO14
#define CC2650_LOAD2 CC2650_TRIG_1
#define E_PIN_LED_SCLK_A CC2650_LOAD0, CC2650_D0
#define E_PIN_LED_MOSI_A CC2650_LOAD0, CC2650_D1
#define E_PIN_SCLK CC2650_LOAD0, CC2650_D2
#define E_PIN_MOSI CC2650_LOAD0, CC2650_D3
#define E_PIN_TW_SCKI_0 CC2650_LOAD0, CC2650_D4
#define E_PIN_TW_SCKI_1 CC2650_LOAD0, CC2650_D5
#define E_PIN_TW_SCKI_2 CC2650_LOAD0, CC2650_D6
#define E_PIN_TW_SCKI_3 CC2650_LOAD0, CC2650_D7
#define E_PIN_BAT_CHAR CC2650_LOAD1, CC2650_D0
#define E_PIN_BAT_OK CC2650_LOAD1, CC2650_D1
#define E_PIN_3V_PULL_UP_DOWN_0 CC2650_LOAD1, CC2650_D2
#define E_PIN_3V_PULL_UP_DOWN_1 CC2650_LOAD1, CC2650_D3
#define E_PIN_OFF CC2650_LOAD1, CC2650_D4
#define E_PIN_5V_OUT_EN_0 CC2650_LOAD1, CC2650_D5
#define E_PIN_5V_enable CC2650_LOAD1, CC2650_D6
#define E_PIN_5V_OUT_EN_1 CC2650_LOAD1, CC2650_D7
#define E_PIN_DO_MOS_0 CC2650_LOAD2, CC2650_D0
#define E_PIN_DO_MOS_1 CC2650_LOAD2, CC2650_D1
#define E_PIN_AO_MOS_0 CC2650_LOAD2, CC2650_D2
#define E_PIN_AO_MOS_1 CC2650_LOAD2, CC2650_D3
#define E_PIN_AO_MOS_2 CC2650_LOAD2, CC2650_D4
#define E_PIN_AO_MOS_3 CC2650_LOAD2, CC2650_D5
#define E_PIN_D0_PR_0 CC2650_LOAD2, CC2650_D6
#define E_PIN_D0_PR_1 CC2650_LOAD2, CC2650_D7
/* SPI Board */
#define Board_SPI0_MISO PIN_UNASSIGNED
#define Board_SPI0_MOSI CC2650_D1 // load0 need to activate
#define Board_SPI0_CLK CC2650_D0 // load0 need to activate
#define Board_SPI0_CS PIN_UNASSIGNED
#define Board_SPI1_MISO CC2650_MISO
#define Board_SPI1_MOSI CC2650_D3 // load0 need to activate
#define Board_SPI1_CLK CC2650_D2 // load0 need to activate
#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_TRIG01_H
@@ -0,0 +1,26 @@
#ifndef SPI_CTRL_H
#define SPI_CTRL_H
#ifdef __cplusplus
extern "C" {
#endif
#define SPI0 0
#define SPI1 1
#define SPI_POL0 0
#define SPI_POL1 1
#define SPI_PHA0 0
#define SPI_PHA1 1
#define SPI_RATE_1M 1000000
#define SPI_RATE_4M 4000000
#define SPI_RATE_6M 6000000
uint8_t spi_open(uint8_t spi_n, uint32_t b_rate, uint8_t pol, uint8_t pha);
uint8_t spi_close(uint8_t spi_n);
uint8_t spi_write(uint8_t spi_n, uint8_t *rxBuf, uint8_t *txBuf, uint8_t len);
#ifdef __cplusplus
}
#endif
#endif // SPI_CTRL_H
@@ -0,0 +1,143 @@
#include <ti/drivers/SPI.h>
#include "board.h"
#include "driver/spi_ctrl.h"
#define CC2650_SPI_BITRATE_MAX 6e6 // Full-duplex maximum speed = 6M
static SPI_Handle handle0 = NULL;
static SPI_Handle handle1 = NULL;
/**
* _get_spi_mode - transfer both polarity and phase to pol_pha_combine
* @pol: polarity
* @pha: phase
* Returns: spi mode
*/
static SPI_FrameFormat _get_spi_mode(uint8_t pol, uint8_t pha)
{
SPI_FrameFormat spi_mode;
if (pol == 0 && pha == 0)
spi_mode = SPI_POL0_PHA0;
else if (pol == 0 && pha == 1)
spi_mode = SPI_POL0_PHA1;
else if (pol == 1 && pha == 0)
spi_mode = SPI_POL1_PHA0;
else if (pol == 1 && pha == 1)
spi_mode = SPI_POL1_PHA1;
return spi_mode;
}
/**
* spi_open -
* @spi_n: which SPI
* @b_rate: bit rate of SPI
* @pol: polarity
* @pha: phase
* Returns: 0 on success, 1 on no this spi module, 2 on spi already open,
* 3 on unsupported bit rate, 4 on unsupported polarity and phase,
* while (1); on failure
* note: Before using PIN_open() and SPI_open(), make sure that the pins are
* not already registered, otherwise it will crash.
*/
uint8_t spi_open(uint8_t spi_n, uint32_t b_rate, uint8_t pol, uint8_t pha)
{
SPI_Params para;
if (spi_n >= 2)
return 1;
if ((spi_n == SPI0 && handle0) || (spi_n == SPI1 && handle1))
return 2;
if (b_rate > CC2650_SPI_BITRATE_MAX)
return 3;
if (pol > 1 || pha > 1)
return 4;
SPI_Params_init(&para);
para.bitRate = b_rate;
para.mode = SPI_MASTER;
para.dataSize = 8;
para.frameFormat = _get_spi_mode(pol, pha);
if (spi_n == SPI0) {
handle0 = SPI_open(Board_SPI0, &para);
if (handle0 == NULL) {
while (1);
}
} else {
handle1 = SPI_open(Board_SPI1, &para);
if (handle1 == NULL) {
while (1);
}
}
return 0;
}
/**
* spi_close -
* @spi_n: which SPI
* Returns: 0 on success, 1 on no this spi module, 2 on no instance
* note: Before using PIN_close() and SPI_close(), make sure that there is \
* an instance available, otherwise it will crash.
*/
uint8_t spi_close(uint8_t spi_n)
{
if (spi_n >= 2)
return 1;
if ((spi_n == SPI0 && !handle0) || (spi_n == SPI1 && !handle1))
return 2;
if (spi_n == SPI0) {
SPI_close(handle0);
handle0 = NULL;
} else {
SPI_close(handle1);
handle1 = NULL;
}
return 0;
}
/**
* spi_write -
* @spi_n: which SPI
* @*rxBuf: rxbuf
* @*txBuf: txbuf
* @len: what is the required length
* Returns: 0 on success, 1 on no this spi module, 2 on no instance,
* 3 on write failure
*/
uint8_t spi_write(uint8_t spi_n, uint8_t *rxBuf, uint8_t *txBuf, uint8_t len)
{
bool transferOK;
SPI_Transaction spi_tran;
if (spi_n >= 2)
return 1;
if ((spi_n == SPI0 && !handle0) || (spi_n == SPI1 && !handle1))
return 2;
spi_tran.count = len;
spi_tran.txBuf = txBuf;
spi_tran.rxBuf = rxBuf;
if (spi_n == SPI0) {
transferOK = SPI_transfer(handle0, &spi_tran);
} else {
transferOK = SPI_transfer(handle1, &spi_tran);
}
if (!transferOK) {
// Error in SPI or transfer already in progress.
return 3;
}
return 0;
}
@@ -0,0 +1,13 @@
#ifndef __TIMERS_H
#define __TIMERS_H
#ifdef __cplusplus
extern "C" {
#endif
void elite_gptimer_open(void);
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,72 @@
/*
* 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 "driver/timers.h"
#include "service/app_ser.h"
#define CLOCK_FREQ 4769 // clock freq = 0.1 ms(4800), Measured(4769)
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(&params);
params.width = GPT_CONFIG_16BIT;
params.mode = GPT_MODE_PERIODIC_UP;
params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
hTimer = GPTimerCC26XX_open(Board_GPTIMER0A, &params);
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;
}
@@ -0,0 +1,71 @@
/*=============================================================================
= EliteCorrection.h =
=============================================================================*/
#ifndef EliteCorrection
#define EliteCorrection
#define BOARD_E7A4
struct formula_ctx_t
{
long long coeff;
long long offset;
};
struct correction_ctx_t
{
struct formula_ctx_t Usercode2Aout[4];
};
#ifdef BOARD_EE59 // Elite trigger
struct correction_ctx_t Correction = {
.Usercode2Aout[0].coeff = 9544555,
.Usercode2Aout[0].offset = 624861853,
.Usercode2Aout[1].coeff = 9544555,
.Usercode2Aout[1].offset = 624861853,
.Usercode2Aout[2].coeff = 9544555,
.Usercode2Aout[2].offset = 624861853,
.Usercode2Aout[3].coeff = 9544555,
.Usercode2Aout[3].offset = 624861853,
};
#endif
#ifdef BOARD_E7A4 // Elite trigger
struct correction_ctx_t Correction = {
.Usercode2Aout[0].coeff = 9603806,
.Usercode2Aout[0].offset = 284189190,
.Usercode2Aout[1].coeff = 9716008,
.Usercode2Aout[1].offset = 231112610,
.Usercode2Aout[2].coeff = 9617383,
.Usercode2Aout[2].offset = 82131390,
.Usercode2Aout[3].coeff = 9688579,
.Usercode2Aout[3].offset = 469137665,
};
#endif
#ifdef BOARD_EEA9 // Elite trigger
struct correction_ctx_t Correction = {
.Usercode2Aout[0].coeff = 9647437,
.Usercode2Aout[0].offset = 137525701,
.Usercode2Aout[1].coeff = 9675906,
.Usercode2Aout[1].offset = 490863999,
.Usercode2Aout[2].coeff = 9668886,
.Usercode2Aout[2].offset = 94793912,
.Usercode2Aout[3].coeff = 9717771,
.Usercode2Aout[3].offset = 94763422,
};
#endif
#endif
@@ -0,0 +1,9 @@
#ifndef VERSION_DATE
#define VERSION_DATE
#define VERSION_DATE_YEAR 23
#define VERSION_DATE_MONTH 6
#define VERSION_DATE_DAY 14
#define VERSION_DATE_HOUR 13
#define VERSION_DATE_MINUTE 16
#endif
@@ -132,7 +132,7 @@ PIN_Handle radCtrlHandle;
extern void AssertHandler(uint8 assertCause, uint8 assertSubcause);
// extern Display_Handle dispHandle;
//extern Display_Handle dispHandle;
/*******************************************************************************
* @fn Main
@@ -247,49 +247,47 @@ int main()
*/
void AssertHandler(uint8 assertCause, uint8 assertSubcause)
{
/*
// Open the display if the app has not already done so
if ( !dispHandle )
{
dispHandle = Display_open(Display_Type_LCD, NULL);
}
// if ( !dispHandle )
// {
// dispHandle = Display_open(Display_Type_LCD, NULL);
// }
Display_print0(dispHandle, 0, 0, ">>>STACK ASSERT");
// Display_print0(dispHandle, 0, 0, ">>>STACK ASSERT");
// check the assert cause
switch (assertCause)
{
case HAL_ASSERT_CAUSE_OUT_OF_MEMORY:
Display_print0(dispHandle, 0, 0, "***ERROR***");
Display_print0(dispHandle, 2, 0, ">> OUT OF MEMORY!");
break;
// // check the assert cause
// switch (assertCause)
// {
// case HAL_ASSERT_CAUSE_OUT_OF_MEMORY:
// Display_print0(dispHandle, 0, 0, "***ERROR***");
// Display_print0(dispHandle, 2, 0, ">> OUT OF MEMORY!");
// break;
case HAL_ASSERT_CAUSE_INTERNAL_ERROR:
// check the subcause
if (assertSubcause == HAL_ASSERT_SUBCAUSE_FW_INERNAL_ERROR)
{
Display_print0(dispHandle, 0, 0, "***ERROR***");
Display_print0(dispHandle, 2, 0, ">> INTERNAL FW ERROR!");
}
else
{
Display_print0(dispHandle, 0, 0, "***ERROR***");
Display_print0(dispHandle, 2, 0, ">> INTERNAL ERROR!");
}
break;
// case HAL_ASSERT_CAUSE_INTERNAL_ERROR:
// // check the subcause
// if (assertSubcause == HAL_ASSERT_SUBCAUSE_FW_INERNAL_ERROR)
// {
// Display_print0(dispHandle, 0, 0, "***ERROR***");
// Display_print0(dispHandle, 2, 0, ">> INTERNAL FW ERROR!");
// }
// else
// {
// Display_print0(dispHandle, 0, 0, "***ERROR***");
// Display_print0(dispHandle, 2, 0, ">> INTERNAL ERROR!");
// }
// break;
case HAL_ASSERT_CAUSE_ICALL_ABORT:
Display_print0(dispHandle, 0, 0, "***ERROR***");
Display_print0(dispHandle, 2, 0, ">> ICALL ABORT!");
HAL_ASSERT_SPINLOCK;
break;
// case HAL_ASSERT_CAUSE_ICALL_ABORT:
// Display_print0(dispHandle, 0, 0, "***ERROR***");
// Display_print0(dispHandle, 2, 0, ">> ICALL ABORT!");
// HAL_ASSERT_SPINLOCK;
// break;
default:
Display_print0(dispHandle, 0, 0, "***ERROR***");
Display_print0(dispHandle, 2, 0, ">> DEFAULT SPINLOCK!");
HAL_ASSERT_SPINLOCK;
}
*/
// default:
// Display_print0(dispHandle, 0, 0, "***ERROR***");
// Display_print0(dispHandle, 2, 0, ">> DEFAULT SPINLOCK!");
// HAL_ASSERT_SPINLOCK;
// }
return;
}
@@ -0,0 +1,88 @@
#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 8
#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_LOW_BAT,
LED_CLR_MAX,
};
struct led_color_t {
uint8_t b;
uint8_t g;
uint8_t r;
};
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
@@ -0,0 +1,149 @@
#include <stdint.h>
#include <string.h>
#include "module/led_APA_102.h"
#define LED_FRAME_RSVD 0x07 // 0x11100000 || bright
#define LED_SERIES_D_START 0x00000000
#define LED_SERIES_D_END 0xFFFFFFFF
struct led_frame_t {
uint8_t bright: 5,
rsvd: 3;
struct led_color_t color;
};
struct led_series_data_t {
uint32_t f_start;
struct led_frame_t f_led[LED_TANDEM_N];
uint32_t f_end;
};
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
{0x05, 0x35, 0x9E}, // LED_CLR_LOW_BAT (orange)
};
static int __led_complete(struct led_series_data_t *sd)
{
for (int i = LED_NB_1; i < LED_NB_MAX; i++)
sd->f_led[i].rsvd = LED_FRAME_RSVD;
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)
{
static struct led_series_data_t led_series_data_g = {0};
struct led_series_data_t *sd = &led_series_data_g;
/*
* led_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 (led_nb < LED_NB_MAX) {
memcpy(&sd->f_led[led_nb], led_f, sizeof(struct led_frame_t));
} else if (led_nb == LED_NB_MAX) {
for (enum led_series_nb_e i = LED_NB_1; i < LED_NB_MAX; i++) {
memcpy(&sd->f_led[i], led_f, sizeof(struct led_frame_t));
}
}
__led_complete(sd);
spi_open(SPI0, SPI_RATE_1M, SPI_POL0, SPI_PHA1); //SPI 1M: LED
led_cs(1);
spi_write(SPI0, NULL, (uint8_t *)sd, sizeof(struct led_series_data_t));
led_cs(0);
spi_close(SPI0);
return 0;
}
int led_color_set(enum led_series_nb_e led_nb, enum led_bright_e bright, enum led_color_e color)
{
struct led_frame_t led_f = {0};
if (led_nb > LED_NB_MAX)
return -1;
if (bright > LED_BR_MAX)
return -2;
if (color >= LED_CLR_MAX)
return -3;
led_f.bright = bright;
led_f.color = led_color_list_g[color];
__led_color_set(led_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)
{
struct led_frame_t led_f = {0};
if (led_nb > LED_NB_MAX)
return -1;
if (bright > LED_BR_MAX)
return -2;
led_f.bright = bright;
memcpy(&led_f.color, &color, sizeof(struct led_color_t));
__led_color_set(led_nb, &led_f);
return 0;
}
int led_rainbow(enum led_bright_e bright)
{
if (bright > LED_BR_MAX)
return -1;
for(enum led_series_nb_e i=LED_NB_1; i<LED_NB_MAX; i++)
led_color_set(i, bright, (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,33 @@
# $python .\simplelink\ble_sdk_2_02_02_25\src\examples\simple_peripheral\cc26xx\app\python\update_elite_version.py
import datetime
import os
print(datetime.datetime.now())
# print(datetime.datetime.now().year)
# print(datetime.datetime.now().month)
# print(datetime.datetime.now().day)
# print(datetime.datetime.now().hour)
# print(datetime.datetime.now().minute)
# print(datetime.datetime.now().strftime("%H:%M:%S"))
y = datetime.datetime.now().year % 100
m = datetime.datetime.now().month
d = datetime.datetime.now().day
hour = datetime.datetime.now().hour
minute = datetime.datetime.now().minute
path = os.getcwd()
path += '/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h'
print('save:', path)
with open(path, 'w') as f:
f.write('#ifndef VERSION_DATE' + '\n')
f.write('#define VERSION_DATE' + '\n\n')
f.write('#define VERSION_DATE_YEAR ' + str(y) + '\n')
f.write('#define VERSION_DATE_MONTH ' + str(m) + '\n')
f.write('#define VERSION_DATE_DAY ' + str(d) + '\n')
f.write('#define VERSION_DATE_HOUR ' + str(hour) + '\n')
f.write('#define VERSION_DATE_MINUTE ' + str(minute) + '\n')
f.write('#endif' + '\n')
@@ -0,0 +1,274 @@
#ifndef APP_SER_H
#define APP_SER_H
#ifdef __cplusplus
extern "C" {
#endif
struct elite_instru_t
{
uint8_t memoryboard_id;
uint8_t elite_mode;
// time relation
uint32_t vscan_rate;
uint32_t notify_rate;
/** TRIG output channel **/
bool tri_d0_as_5v_en;
bool tri_d1_as_5v_en;
/** trigger mode enable **/
bool trig0_en;
bool trig1_en;
uint8_t trig0_edge;
uint8_t trig1_edge;
// about a0~a3
uint16_t Trig_CurCon[4];
};
#include "Elite_version.h"
#include "driver/timers.h"
#include "driver/spi_ctrl.h"
#include "module/led_APA_102.h"
#include "service/mode_all_output_ctrl.h"
// LED
#define LED_BT_WAIT 0x01
#define LED_NO_EVENT 0x02
#define LED_WORKING 0x04
static uint8_t led_status = LED_NO_EVENT;
static void update_led(uint8_t led);
/**
* Trigger channel initialize
*/
#define PIN_PR0 0
#define PIN_D0_SW 1
#define PIN_A0 2
#define PIN_A2 3
#define PIN_A3 4
#define PIN_A1 5
#define PIN_D1_SW 6
#define PIN_PR1 7
#define PIN_D0_5V 8
#define PIN_D1_5V 9
#define PIN_OUT_CH_MAX 10
bool chan_en[PIN_OUT_CH_MAX]; // [pr0_en, d0_mos_en, a0_en, a2_en, a3_en,
// a1_en, d1_mos_en, pr1_en, d0_5v_en, d1_5v_en]
/** TRIG01 trigger edge type **/
#define TRIG_POSEDGE 0x00
#define TRIG_NEGEDGE 0x01
#define TRIG_BOTHEDGE 0x02
#define TRIG_DIS 0x03
// define BT instruction
#define INS_TYPE_RIS 0x30
#define INS_TYPE_VIS 0xC0
#define INS_TYPE_CIS 0x70
// VIS (virtual instruction)
#define VIS_RST 0xF0
#define VIS_STI 0xC0
#define VIS_INT 0x60
#define VIS_DEVICE_SHINY 0x10
#define VIS_SHINY_DIS 0x20
//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
// Elite TRIG01 ADC command
#define CMD_DOUT_5V_IMON_0 0xC5
#define CMD_DOUT_5V_IMON_1 0xD5
#define Aout_CH_0 0x00
#define Aout_CH_1 0x01
#define Aout_CH_2 0x02
#define Aout_CH_3 0x03
#define LATCH_BUFF_SIZE 8 // define latch
// CIS (control instruction)
#define CIS_VERSION 0x40
#define CIS_VOLT 0x10
#define CIS_TEMPERATURE 0x80
/* TRIG01 define */
#define TRIG_PR 0x00
#define TRIG_MOS_DOUT 0x01
#define TRIG_MOS_AOUT 0x02
#define TRIG_5V_OUT 0x03
#define TRIG_input 0x04
// #define TRIG_CHAN_COUNT 10 // channel count of TRIG01
// gptimer
struct gptimer_t
{
uint32_t gpt_now;
uint32_t gpt_last;
uint8_t gpt_delta;
};
/* member of mode */
struct wm_aout_ctx_t
{
int32_t _Vset;
int32_t _Curset0;
int32_t _Curset1;
int32_t _Curset2;
int32_t _Curset3;
};
/* member of mode */
#define CH_PR0 0
#define CH_D0 1
#define CH_A0 2
#define CH_A2 3
#define CH_A3 4
#define CH_A1 5
#define CH_D1 6
#define CH_PR1 7
/**
* Latch initialize
*/
struct _LH
{
bool LATCH0[LATCH_BUFF_SIZE];
bool LATCH1[LATCH_BUFF_SIZE];
bool LATCH2[LATCH_BUFF_SIZE];
};
// RIS (real instruction)
enum all_mode_e
{
MODE_ANALOG_CURRENT_CTRL = 0x0E, // 0x0E
MODE_ALL_OUTPUT_CTRL = 0x0F, // 0x0F
DEV_TEST = 0xFF, // 0xFF,
SET_SAMPLE_RATE = 0xE0, // 0xE0,
SET_EN_CHAN = 0x81, // 0x81,
SET_PARA = 0xE2, // 0xE2,
SET_TRIG_EN = 0x41 // 0x41,
};
enum dev_para_e
{
VERSION_DEV_TEST = 0x01,
BAT_DEV_TEST = 0x02,
TEMP_DEV_TEST = 0x03,
LED_DEV_TEST = 0x04,
AOUT_DEV_TEST = 0x05,
DOUT_DEV_TEST = 0x06,
PR_DEV_TEST = 0x07,
OUT_5VEN_DEV_TEST = 0x08,
SET_EN_CHAN_DEV_TEST = 0x0F,
VIS_DEV_TRIG_EN = 0x09,
Init_DEV_Trig_flag = 0x0A
};
enum set_para_e
{
AOUT_CURRENT = 0x02,
};
struct _LH LH = { 0 };
struct elite_instru_t instru = { 0 };
struct gptimer_t gpt = {0};
static int32_t notify_ch1 = 0;
static int32_t notify_ch2 = 0;
static int32_t notify_ch3 = 0;
static int32_t notify_ch4 = 0;
static int32_t notify_ch5 = 0;
static int32_t notify_ch6 = 0;
static uint16_t NotifyVoltBat = 2000; //0x07d0
static uint16_t NotifyTemperature = 200; //0x00c8
static uint16_t NotifyCycleNumber = 0;
static bool trig0_event_wait = false;
static bool trig1_event_wait = false;
static bool dual_trig_mode = false;
static bool single_trig_mode = false;
static void *workMode_p = NULL;
/* Trigger Flag */
static bool trig_PeriodicEvent = false;
static bool TRIG_TrigEnable = false;
static bool Trig_receive = false;
static bool trig0_event = false;
static bool trig1_event = false;
static bool FLT_event = false;
static bool PeriodicEvent = false;
static bool mode_init;
static bool finishMode = false;
PIN_Handle PinHandle;
static PIN_State PinStatus;
const PIN_Config Elite_pin[] = {
CC2650_LOAD0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
CC2650_LOAD1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
CC2650_LOAD2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
CC2650_SHUT_DOWN | PIN_INPUT_EN | PIN_PULLDOWN, // to sense switch
CC2650_TRIG_0 | PIN_INPUT_EN | PIN_PULLDOWN,
CC2650_FLT | PIN_INPUT_EN | PIN_PULLDOWN,
// CC2650_TRIG_1 | PIN_INPUT_EN | PIN_PULLDOWN,
PIN_TERMINATE
};
void elite_100us_task(void);
static void InitEliteInstruction(void);
static void set_channel_led(bool *chan_en);
static void elite_reset();
static void SendNotify();
static void FlushNotify();
static void key_manage(uint32_t delta_time);
static uint8_t pin_button_get(void);
static bool power_on(uint32_t delta_time);
static void GPT_timerIncrement();
static uint16_t Aout_decode(uint16_t input_code);
static void set_Aoutput(uint8_t GPIO_channel, uint16_t input_code);
static void TW1508reset();
static void curr_out();
static void aout_Curscan(void);
static uint16_t Usercode_Correction_to_Aout(uint8_t aout_chan, uint16_t usercode);
static void device_init();
static void send_device_info();
static void set_para(uint8_t elite_mode, uint16_t parameter, int32_t value);
static void chg_aout_para(uint16_t parameter, int32_t value);
static void trig_event_flush();
static void trig_callback(PIN_Handle handle, PIN_Id pinId);
static void trig_sense();
static void trig_en_check();
static void InitTrigChan();
static void PIN_trig_edge_set(uint8_t trig0_edge, uint8_t trig1_edge);
static void GPIO_SPI_transfer(uint32_t *GPIO_CLK_CH, uint16_t spi_GPIO_txbuf);
static void led_cs(uint8_t signal);
static void disable_trig_output();
static void PIN15_setOutputValue_refresh();
static void PIN15_setOutputValue(uint32_t latch_num, uint32_t pin_num, bool highlow);
static void update_latch_status(uint32_t latch_num, uint32_t elite_pin, bool highlow);
static void remove_elite_pin();
static void add_elite_pin();
static int wm_deinit(void);
static void *wm_get(void);
static void receive_instruction(uint8 *recv_instru);
static void elite_task(void);
#ifdef __cplusplus
}
#endif
#endif // APP_SER_H
@@ -0,0 +1,15 @@
#ifndef __MODE_ALL_OUTPUT_CTRL_H
#define __MODE_ALL_OUTPUT_CTRL_H
#ifdef __cplusplus
extern "C" {
#endif
void all_output_ctrl_mode_vsan(uint32_t delta_t);
int all_output_ctrl_mode_create(void);
void handle_all_output_mode_instru(uint8_t *recv_instru, struct elite_instru_t *instruction);
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,294 @@
#include <stdint.h>
#include "service/mode_all_output_ctrl.h"
struct ch_all_out_ctrl_ctx_t
{
// user setting
uint8_t used: 1,
v_early: 1,
v_mid: 4,
v_late: 1,
v_rsvd: 1;
uint32_t t_early;
uint32_t t_mid[4];
uint32_t t_late;
uint16_t cycle;
// automatic setting
uint32_t t_part[4];
uint32_t t_period;
uint8_t init: 1,
t_early_period: 1,
t_mid_period: 1,
t_late_period: 1,
rsvd: 4;
uint32_t v_scan_rate;
};
struct mode_all_out_ctrl_ctx_t
{
struct ch_all_out_ctrl_ctx_t channel[8];
};
void __all_output_ctrl_mode_ch_vsan(struct ch_all_out_ctrl_ctx_t *channel, uint32_t delta_t, uint8_t ch)
{
uint32_t m;
if (!channel->used)
return;
if (channel->init) {
channel->v_scan_rate = 0;
channel->init = false;
}
channel->v_scan_rate += delta_t;
if (channel->t_early_period) {
if (ch==CH_D0 && instru.tri_d0_as_5v_en==1) {
if(channel->v_early) {
chan_en[CH_D0] = 0;
chan_en[8] = 0;
} else {
chan_en[CH_D0] = 0;
chan_en[8] = 1;
}
} else if (ch==CH_D1 && instru.tri_d1_as_5v_en==1) {
if(channel->v_early) {
chan_en[CH_D1] = 0;
chan_en[9] = 0;
} else {
chan_en[CH_D1] = 0;
chan_en[9] = 1;
}
} else {
chan_en[ch] = channel->v_early;
}
if (channel->v_scan_rate >= channel->t_early) {
channel->v_scan_rate -= channel->t_early; //To get right time
channel->t_early_period = false;
channel->t_mid_period = true;
channel->v_scan_rate = 0;
}
return;
}
if (channel->t_mid_period) {
if (channel->v_scan_rate >= channel->t_period) {
channel->v_scan_rate -= channel->t_period; //To get right time
channel->cycle--;
if (channel->cycle == 0) {
channel->t_mid_period = false;
channel->t_late_period = true;
channel->v_scan_rate = 0;
return;
}
}
m = channel->v_scan_rate ? (channel->v_scan_rate % channel->t_period) : 0;
for(int i=0; i<4; i++) {
if (m < channel->t_part[i]) {
if (ch == CH_D0 && instru.tri_d0_as_5v_en==1) {
if(channel->v_mid & (1 << i)) {
chan_en[CH_D0] = 0;
chan_en[8] = 0;
} else {
chan_en[CH_D0] = 0;
chan_en[8] = 1;
}
} else if (ch == CH_D1 && instru.tri_d1_as_5v_en==1) {
if(channel->v_mid & (1 << i)) {
chan_en[CH_D1] = 0;
chan_en[9] = 0;
} else {
chan_en[CH_D1] = 0;
chan_en[9] = 1;
}
} else {
chan_en[ch] = channel->v_mid & (1 << i);
}
return;
}
}
return;
}
if (channel->t_late_period) {
if (ch==CH_D0 && instru.tri_d0_as_5v_en==1) {
if(channel->v_late) {
chan_en[CH_D0] = 0;
chan_en[8] = 0;
} else {
chan_en[CH_D0] = 0;
chan_en[8] = 1;
}
} else if (ch==CH_D1 && instru.tri_d1_as_5v_en==1) {
if(channel->v_late) {
chan_en[CH_D1] = 0;
chan_en[9] = 0;
} else {
chan_en[CH_D1] = 0;
chan_en[9] = 1;
}
} else {
chan_en[ch] = channel->v_late;
}
if (channel->v_scan_rate >= channel->t_late) {
channel->v_scan_rate -= channel->t_late; //To get right time
channel->used = false;
if (ch==CH_D0 && instru.tri_d0_as_5v_en==1) { //ending
chan_en[CH_D0] = 0;
chan_en[8] = 1;
} else if (ch==CH_D1 && instru.tri_d1_as_5v_en==1) {
chan_en[CH_D1] = 0;
chan_en[9] = 1;
} else {
chan_en[ch] = 0;
}
}
return;
}
}
void all_output_ctrl_mode_vsan(uint32_t delta_t)
{
struct mode_all_out_ctrl_ctx_t *mode = (struct mode_all_out_ctrl_ctx_t *)wm_get();
struct ch_all_out_ctrl_ctx_t *ch;
for(int i=CH_PR0; i<=CH_PR1; i++) {
ch = &mode->channel[i];
__all_output_ctrl_mode_ch_vsan(ch, delta_t, i);
}
if (mode->channel[CH_PR0].used == false &&
mode->channel[CH_D0].used == false &&
mode->channel[CH_A0].used == false &&
mode->channel[CH_A2].used == false &&
mode->channel[CH_A3].used == false &&
mode->channel[CH_A1].used == false &&
mode->channel[CH_D1].used == false &&
mode->channel[CH_PR1].used == false)
PeriodicEvent = false;
return;
}
int all_output_ctrl_mode_create(void)
{
struct mode_all_out_ctrl_ctx_t *p;
void **wm = &workMode_p;
if (*wm)
return -1;
p = malloc(sizeof(struct mode_all_out_ctrl_ctx_t));
if (!p)
return -2;
struct ch_all_out_ctrl_ctx_t *ch;
for (int i=CH_D0; i<=CH_D1; i++) {
ch = &p->channel[i];
ch->used = false;
}
*wm = p;
return 0;
}
void __all_output_ctrl_mode_channel_init(uint8_t *ins)
{
struct mode_all_out_ctrl_ctx_t *mode = (struct mode_all_out_ctrl_ctx_t *)wm_get();
struct ch_all_out_ctrl_ctx_t *ch;
uint8_t channel = ins[3];
uint8_t para_sequence = ins[4];
ch = &mode->channel[channel];
if (para_sequence == 1) {
ch->used = (ins[5] & 1<<0);
ch->v_early = (ins[5] & 1<<1) >> 1;
ch->v_late = (ins[5] & 1<<2) >> 2;
ch->v_mid = ins[6]; // |rsvd|v3|v2|v1|v0|
ch->cycle = (uint16_t)ins[7] << 8 | (uint16_t)ins[8];
ch->t_early = (uint32_t)ins[9] << 24 | (uint32_t)ins[10] << 16 | (uint32_t)ins[11] << 8 | (uint32_t)ins[12]; // 1ms->0.1ms
ch->t_early *=10;
ch->t_late = (uint32_t)ins[13] << 24 | (uint32_t)ins[14] << 16 | (uint32_t)ins[15] << 8 | (uint32_t)ins[16];
ch->t_late *=10;
} else if (para_sequence == 2) {
ch->t_mid[0] = (uint32_t)ins[5] << 24 | (uint32_t)ins[6] << 16 | (uint32_t)ins[7] << 8 | (uint32_t)ins[8];
ch->t_mid[0] *= 10;
ch->t_mid[1] = (uint32_t)ins[9] << 24 | (uint32_t)ins[10] << 16 | (uint32_t)ins[11] << 8 | (uint32_t)ins[12];
ch->t_mid[1] *= 10;
} else if (para_sequence == 3) {
ch->t_mid[2] = (uint32_t)ins[5] << 24 | (uint32_t)ins[6] << 16 | (uint32_t)ins[7] << 8 | (uint32_t)ins[8];
ch->t_mid[2] *= 10;
ch->t_mid[3] = (uint32_t)ins[9] << 24 | (uint32_t)ins[10] << 16 | (uint32_t)ins[11] << 8 | (uint32_t)ins[12];
ch->t_mid[3] *= 10;
ch->t_period = 0;
for (int i=0; i<4; i++) {
ch->t_period += ch->t_mid[i];
ch->t_part[i] = ch->t_period;
}
if (ch->used == true)
ch->init = true;
else
ch->init = false;
ch->t_early_period = true;
ch->t_mid_period = false;
ch->t_late_period = false;
} else if (para_sequence == 4) {
if (channel==CH_D0) {
instru.tri_d0_as_5v_en = ins[5];
} else if (channel==CH_D1) {
instru.tri_d1_as_5v_en = ins[5];
} else if (channel==CH_A0) {
instru.Trig_CurCon[0] = (uint16_t)ins[5] << 8 | (uint16_t)ins[6]; //5000=20mA
} else if (channel==CH_A1) {
instru.Trig_CurCon[1] = (uint16_t)ins[5] << 8 | (uint16_t)ins[6];
} else if (channel==CH_A2) {
instru.Trig_CurCon[2] = (uint16_t)ins[5] << 8 | (uint16_t)ins[6];
} else if (channel==CH_A3) {
instru.Trig_CurCon[3] = (uint16_t)ins[5] << 8 | (uint16_t)ins[6];
}
}
}
void handle_all_output_mode_instru(uint8_t *recv_instru, struct elite_instru_t *instruction)
{
uint8_t *ins = recv_instru;
uint8_t ch = ins[3];
switch (ch) {
case 0xFF:
instru.elite_mode = MODE_ALL_OUTPUT_CTRL;
all_output_ctrl_mode_create();
break;
case CH_PR0:
case CH_PR1:
case CH_D0:
case CH_D1:
case CH_A0:
case CH_A1:
case CH_A2:
case CH_A3:
__all_output_ctrl_mode_channel_init(ins);
break;
}
instruction->notify_rate = 5000;
}
@@ -9,7 +9,7 @@
Target Device: CC2650, CC2640
******************************************************************************
Copyright (c) 2013-2018, Texas Instruments Incorporated
All rights reserved.
@@ -105,11 +105,11 @@
#ifndef FEATURE_OAD
// Minimum connection interval (units of 1.25ms, 80=100ms) if automatic
// parameter update request is enabled
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL 80
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL 6 //ori:80
// Maximum connection interval (units of 1.25ms, 800=1000ms) if automatic
// parameter update request is enabled
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 800
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 6 //ori:800
#else //!FEATURE_OAD
// Minimum connection interval (units of 1.25ms, 8=10ms) if automatic
// parameter update request is enabled
@@ -147,7 +147,7 @@
#ifndef SBP_TASK_STACK_SIZE
#define SBP_TASK_STACK_SIZE 644
#define SBP_TASK_STACK_SIZE 844 //ori:644
#endif
// Internal Events for RTOS application
@@ -155,6 +155,7 @@
#define SBP_CHAR_CHANGE_EVT 0x0002
#define SBP_PERIODIC_EVT 0x0004
#define SBP_CONN_EVT_END_EVT 0x0008
#define SBP_KEY_CHANGE_EVT 0x0010
/*********************************************************************
* TYPEDEFS
@@ -181,7 +182,7 @@ typedef struct
static ICall_EntityID selfEntity;
// Semaphore globally used to post events to the application thread
static ICall_Semaphore sem;
static ICall_Semaphore semaphore;
// Clock instances for internal periodic events.
static Clock_Struct periodicClock;
@@ -207,6 +208,7 @@ Char sbpTaskStack[SBP_TASK_STACK_SIZE];
//static gaprole_States_t gapProfileState = GAPROLE_INIT;
// GAP - SCAN RSP data (max size = 31 bytes)
/*
static uint8_t scanRspData[] =
{
// complete name
@@ -245,6 +247,7 @@ static uint8_t scanRspData[] =
GAP_ADTYPE_POWER_LEVEL,
0 // 0dBm
};
*/
// GAP - Advertisement data (max size = 31 bytes, though this is
// best kept short to conserve power while advertisting)
@@ -276,7 +279,7 @@ static uint8_t advertData[] =
};
// GAP GATT Attributes
static uint8_t attDeviceName[GAP_DEVICE_NAME_LEN] = "Simple BLE Peripheral";
// static uint8_t attDeviceName[GAP_DEVICE_NAME_LEN] = "Simple BLE Peripheral";
// Globals used for ATT Response retransmission
static gattMsgEvent_t *pAttRsp = NULL;
@@ -293,9 +296,9 @@ static uint8_t SimpleBLEPeripheral_processStackMsg(ICall_Hdr *pMsg);
static uint8_t SimpleBLEPeripheral_processGATTMsg(gattMsgEvent_t *pMsg);
static void SimpleBLEPeripheral_processAppMsg(sbpEvt_t *pMsg);
static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState);
static void SimpleBLEPeripheral_processCharValueChangeEvt(uint8_t paramID);
static void SimpleBLEPeripheral_performPeriodicTask(void);
static void SimpleBLEPeripheral_clockHandler(UArg arg);
// static void SimpleBLEPeripheral_processCharValueChangeEvt(uint8_t paramID);
// static void SimpleBLEPeripheral_performPeriodicTask(void);
// static void SimpleBLEPeripheral_clockHandler(UArg arg);
static void SimpleBLEPeripheral_sendAttRsp(void);
static void SimpleBLEPeripheral_freeAttRsp(uint8_t status);
@@ -393,7 +396,7 @@ static void SimpleBLEPeripheral_init(void)
// ******************************************************************
// Register the current thread as an ICall dispatcher application
// so that the application can send and receive messages.
ICall_registerApp(&selfEntity, &sem);
ICall_registerApp(&selfEntity, &semaphore);
#ifdef USE_RCOSC
RCOSC_enableCalibration();
@@ -421,8 +424,8 @@ static void SimpleBLEPeripheral_init(void)
appMsgQueue = Util_constructQueue(&appMsg);
// Create one-shot clocks for internal periodic events.
Util_constructClock(&periodicClock, SimpleBLEPeripheral_clockHandler,
SBP_PERIODIC_EVT_PERIOD, 0, false, SBP_PERIODIC_EVT);
// Util_constructClock(&periodicClock, SimpleBLEPeripheral_clockHandler,
// SBP_PERIODIC_EVT_PERIOD, 0, false, SBP_PERIODIC_EVT);
// dispHandle = Display_open(Display_Type_LCD, NULL);
@@ -451,8 +454,8 @@ static void SimpleBLEPeripheral_init(void)
GAPRole_SetParameter(GAPROLE_ADVERT_OFF_TIME, sizeof(uint16_t),
&advertOffTime);
GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, sizeof(scanRspData),
scanRspData);
// GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, sizeof(scanRspData),
// scanRspData);
GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData);
GAPRole_SetParameter(GAPROLE_PARAM_UPDATE_ENABLE, sizeof(uint8_t),
@@ -468,7 +471,7 @@ static void SimpleBLEPeripheral_init(void)
}
// Set the GAP Characteristics
GGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName);
// GGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName);
// Set advertising interval
{
@@ -521,18 +524,18 @@ static void SimpleBLEPeripheral_init(void)
{
uint8_t charValue1 = 1;
uint8_t charValue2 = 2;
uint8_t charValue3 = 3;
uint8_t charValue4 = 4;
uint8_t charValue3[SIMPLEPROFILE_CHAR3_LEN] = {0};
uint8_t charValue4[SIMPLEPROFILE_CHAR4_LEN] = {0};
uint8_t charValue5[SIMPLEPROFILE_CHAR5_LEN] = { 1, 2, 3, 4, 5 };
SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR1, sizeof(uint8_t),
&charValue1);
SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR2, sizeof(uint8_t),
&charValue2);
SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR3, sizeof(uint8_t),
&charValue3);
SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t),
&charValue4);
SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR3, SIMPLEPROFILE_CHAR3_LEN,
charValue3);
SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, SIMPLEPROFILE_CHAR4_LEN,
charValue4);
SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR5, SIMPLEPROFILE_CHAR5_LEN,
charValue5);
}
@@ -554,6 +557,7 @@ static void SimpleBLEPeripheral_init(void)
GATT_RegisterForMsgs(selfEntity);
HCI_LE_ReadMaxDataLenCmd();
/*
#if defined FEATURE_OAD
#if defined (HAL_IMAGE_A)
@@ -567,6 +571,10 @@ static void SimpleBLEPeripheral_init(void)
*/
}
/*elite code*/
#include "service/app_ser.h"
/*********************************************************************
* @fn SimpleBLEPeripheral_taskFxn
*
@@ -578,101 +586,133 @@ static void SimpleBLEPeripheral_init(void)
*/
static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
{
// Initialize application
SimpleBLEPeripheral_init();
bool elite_on = false;
uint32_t check_key_time = 0;
static bool open_6994 = false;
// Application main loop
for (;;)
{
// Waits for a signal to the semaphore associated with the calling thread.
// Note that the semaphore associated with a thread is signaled when a
// message is queued to the message receive queue of the thread or when
// ICall_signal() function is called onto the semaphore.
ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER);
// Initialize application
SimpleBLEPeripheral_init();
if (errno == ICALL_ERRNO_SUCCESS)
{
ICall_EntityID dest;
ICall_ServiceEnum src;
ICall_HciExtEvt *pMsg = NULL;
device_init();
if (ICall_fetchServiceMsg(&src, &dest,
(void **)&pMsg) == ICALL_ERRNO_SUCCESS)
{
uint8 safeToDealloc = TRUE;
while(1) {
if (events & SBP_PERIODIC_EVT) {
events &= ~SBP_PERIODIC_EVT;
GPT_timerIncrement();
elite_on = power_on(gpt.gpt_delta);
}
if (elite_on)
break;
}
if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity))
{
ICall_Stack_Event *pEvt = (ICall_Stack_Event *)pMsg;
// Application main loop
for (;;) {
// Waits for a signal to the semaphore associated with the calling thread.
// Note that the semaphore associated with a thread is signaled when a
// message is queued to the message receive queue of the thread or when
// ICall_signal() function is called onto the semaphore.
// Check for BLE stack events first
if (pEvt->signature == 0xffff)
{
if (pEvt->event_flag & SBP_CONN_EVT_END_EVT)
{
// Try to retransmit pending ATT Response (if any)
SimpleBLEPeripheral_sendAttRsp();
ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER); // let errno wait for infinite time, if periodicClock time up then execute below code
if (errno == ICALL_ERRNO_SUCCESS) {
ICall_EntityID dest;
ICall_ServiceEnum src;
ICall_HciExtEvt *pMsg = NULL;
if (ICall_fetchServiceMsg(&src, &dest,
(void **)&pMsg) == ICALL_ERRNO_SUCCESS) {
uint8 safeToDealloc = TRUE;
if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity)) {
ICall_Stack_Event *pEvt = (ICall_Stack_Event *)pMsg;
// Check for BLE stack events first
if (pEvt->signature == 0xffff) {
if (pEvt->event_flag & SBP_CONN_EVT_END_EVT) {
// Try to retransmit pending ATT Response (if any)
SimpleBLEPeripheral_sendAttRsp();
}
} else {
// Process inter-task message
safeToDealloc = SimpleBLEPeripheral_processStackMsg((ICall_Hdr *)pMsg);
}
}
if (pMsg && safeToDealloc) {
ICall_freeMsg(pMsg);
}
}
// If RTOS queue is not empty, process app message.
while (!Queue_empty(appMsgQueue)) {
sbpEvt_t *pMsg = (sbpEvt_t *)Util_dequeueMsg(appMsgQueue);
if (pMsg) {
// Process message.
SimpleBLEPeripheral_processAppMsg(pMsg);
// Free the space from the message.
ICall_free(pMsg);
}
}
}
else
{
// Process inter-task message
safeToDealloc = SimpleBLEPeripheral_processStackMsg((ICall_Hdr *)pMsg);
}
}
if (pMsg && safeToDealloc)
{
ICall_freeMsg(pMsg);
if (events & SBP_PERIODIC_EVT) {
events &= ~SBP_PERIODIC_EVT;
GPT_timerIncrement();
check_key_time = check_key_time + gpt.gpt_delta;
/* routinely check the button status*/
if (check_key_time >= 200) {
key_manage(200);
check_key_time = 0;
}
if (!open_6994) {
static uint16_t cnt = 0;
if (cnt < 50000) //5000ms
cnt++;
else {
PIN15_setOutputValue(E_PIN_OFF, 0); // on=0, off=1, turn on 6994
open_6994 = true;
}
}
if (!PeriodicEvent) { // if there is no periodic event
if (TRIG_TrigEnable)
{
trig_sense();
if (trig_PeriodicEvent)
{
trig_PeriodicEvent = false;
PeriodicEvent = true;
mode_init = true;
}
}
} else { // if there is periodic event
// Perform periodic application task
elite_task();
}
}
}
// If RTOS queue is not empty, process app message.
while (!Queue_empty(appMsgQueue))
{
sbpEvt_t *pMsg = (sbpEvt_t *)Util_dequeueMsg(appMsgQueue);
if (pMsg)
{
// Process message.
SimpleBLEPeripheral_processAppMsg(pMsg);
// Free the space from the message.
ICall_free(pMsg);
}
}
}
if (events & SBP_PERIODIC_EVT)
{
events &= ~SBP_PERIODIC_EVT;
Util_startClock(&periodicClock);
// Perform periodic application task
SimpleBLEPeripheral_performPeriodicTask();
}
#ifdef FEATURE_OAD
while (!Queue_empty(hOadQ))
{
oadTargetWrite_t *oadWriteEvt = Queue_get(hOadQ);
while (!Queue_empty(hOadQ)) {
oadTargetWrite_t *oadWriteEvt = Queue_get(hOadQ);
// Identify new image.
if (oadWriteEvt->event == OAD_WRITE_IDENTIFY_REQ)
{
OAD_imgIdentifyWrite(oadWriteEvt->connHandle, oadWriteEvt->pData);
}
// Write a next block request.
else if (oadWriteEvt->event == OAD_WRITE_BLOCK_REQ)
{
OAD_imgBlockWrite(oadWriteEvt->connHandle, oadWriteEvt->pData);
}
// Identify new image.
if (oadWriteEvt->event == OAD_WRITE_IDENTIFY_REQ) {
OAD_imgIdentifyWrite(oadWriteEvt->connHandle, oadWriteEvt->pData);
} else if (oadWriteEvt->event == OAD_WRITE_BLOCK_REQ) { // Write a next block request.
OAD_imgBlockWrite(oadWriteEvt->connHandle, oadWriteEvt->pData);
}
// Free buffer.
ICall_free(oadWriteEvt);
}
// Free buffer.
ICall_free(oadWriteEvt);
}
#endif //FEATURE_OAD
}
}
}
/*********************************************************************
@@ -709,7 +749,7 @@ static uint8_t SimpleBLEPeripheral_processStackMsg(ICall_Hdr *pMsg)
AssertHandler(HAL_ASSERT_CAUSE_HARDWARE_ERROR,0);
}
break;
default:
break;
}
@@ -847,6 +887,23 @@ static void SimpleBLEPeripheral_freeAttRsp(uint8_t status)
}
}
#define BLE_INS_BUFF_CHAR SIMPLEPROFILE_CHAR3
#define BLE_INS_BUFF_SIZE SIMPLEPROFILE_CHAR3_LEN
static void elite_instru_handle(uint8_t characteristic)
{
uint8_t ins_buf[BLE_INS_BUFF_SIZE] = {0};
switch (characteristic)
{
case BLE_INS_BUFF_CHAR:
SimpleProfile_GetParameter(BLE_INS_BUFF_CHAR, ins_buf);
receive_instruction(ins_buf);
break;
default:
break;
}
}
/*********************************************************************
* @fn SimpleBLEPeripheral_processAppMsg
*
@@ -863,7 +920,8 @@ static void SimpleBLEPeripheral_processAppMsg(sbpEvt_t *pMsg) {
break;
case SBP_CHAR_CHANGE_EVT:
SimpleBLEPeripheral_processCharValueChangeEvt(pMsg->hdr.state);
// SimpleBLEPeripheral_processCharValueChangeEvt(pMsg->hdr.state);
elite_instru_handle(pMsg->hdr.state);
break;
default:
@@ -926,14 +984,10 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
DevInfo_SetParameter(DEVINFO_SYSTEM_ID, DEVINFO_SYSTEM_ID_LEN, systemId);
// Display device address
// Display_print0(dispHandle, 1, 0, Util_convertBdAddr2Str(ownAddress));
// Display_print0(dispHandle, 2, 0, "Initialized");
}
break;
case GAPROLE_ADVERTISING:
// Display_print0(dispHandle, 2, 0, "Advertising");
break;
#ifdef PLUS_BROADCASTER
@@ -944,7 +998,7 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
*/
case GAPROLE_ADVERTISING_NONCONN:
{
uint8_t advertEnabled = FALSE;
uint8_t advertEnabled = true; // do some change to experiment
// Disable non-connectable advertising.
GAPRole_SetParameter(GAPROLE_ADV_NONCONN_ENABLED, sizeof(uint8_t),
@@ -969,7 +1023,7 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
linkDBInfo_t linkInfo;
uint8_t numActive = 0;
Util_startClock(&periodicClock);
// Util_startClock(&periodicClock);
numActive = linkDB_NumActive();
@@ -977,8 +1031,6 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
// connection
if ( linkDB_GetInfo( numActive - 1, &linkInfo ) == SUCCESS )
{
// Display_print1(dispHandle, 2, 0, "Num Conns: %d", (uint16_t)numActive);
// Display_print0(dispHandle, 3, 0, Util_convertBdAddr2Str(linkInfo.addr));
}
else
{
@@ -986,8 +1038,6 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
GAPRole_GetParameter(GAPROLE_CONN_BD_ADDR, peerAddress);
// Display_print0(dispHandle, 2, 0, "Connected");
// Display_print0(dispHandle, 3, 0, Util_convertBdAddr2Str(peerAddress));
}
#ifdef PLUS_BROADCASTER
@@ -1015,26 +1065,16 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
break;
case GAPROLE_CONNECTED_ADV:
// Display_print0(dispHandle, 2, 0, "Connected Advertising");
break;
case GAPROLE_WAITING:
Util_stopClock(&periodicClock);
SimpleBLEPeripheral_freeAttRsp(bleNotConnected);
// Display_print0(dispHandle, 2, 0, "Disconnected");
// Clear remaining lines
// Display_clearLines(dispHandle, 3, 5);
update_led(LED_BT_WAIT);
break;
case GAPROLE_WAITING_AFTER_TIMEOUT:
SimpleBLEPeripheral_freeAttRsp(bleNotConnected);
// Display_print0(dispHandle, 2, 0, "Timed Out");
// Clear remaining lines
// Display_clearLines(dispHandle, 3, 5);
update_led(LED_BT_WAIT);
#ifdef PLUS_BROADCASTER
// Reset flag for next connection.
@@ -1043,11 +1083,9 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
break;
case GAPROLE_ERROR:
// Display_print0(dispHandle, 2, 0, "Error");
break;
default:
// Display_clearLine(dispHandle, 2);
break;
}
@@ -1082,6 +1120,7 @@ static void SimpleBLEPeripheral_charValueChangeCB(uint8_t paramID)
*
* @return None.
*/
/*
static void SimpleBLEPeripheral_processCharValueChangeEvt(uint8_t paramID)
{
#ifndef FEATURE_OAD_ONCHIP
@@ -1092,13 +1131,13 @@ static void SimpleBLEPeripheral_processCharValueChangeEvt(uint8_t paramID)
case SIMPLEPROFILE_CHAR1:
SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR1, &newValue);
// Display_print1(dispHandle, 4, 0, "Char 1: %d", (uint16_t)newValue);
Display_print1(dispHandle, 4, 0, "Char 1: %d", (uint16_t)newValue);
break;
case SIMPLEPROFILE_CHAR3:
SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR3, &newValue);
// Display_print1(dispHandle, 4, 0, "Char 3: %d", (uint16_t)newValue);
Display_print1(dispHandle, 4, 0, "Char 3: %d", (uint16_t)newValue);
break;
default:
@@ -1107,6 +1146,7 @@ static void SimpleBLEPeripheral_processCharValueChangeEvt(uint8_t paramID)
}
#endif //!FEATURE_OAD_ONCHIP
}
*/
/*********************************************************************
* @fn SimpleBLEPeripheral_performPeriodicTask
@@ -1121,8 +1161,10 @@ static void SimpleBLEPeripheral_processCharValueChangeEvt(uint8_t paramID)
*
* @return None.
*/
/*
static void SimpleBLEPeripheral_performPeriodicTask(void)
{
#ifndef FEATURE_OAD_ONCHIP
uint8_t valueToCopy;
@@ -1137,8 +1179,9 @@ static void SimpleBLEPeripheral_performPeriodicTask(void)
&valueToCopy);
}
#endif //!FEATURE_OAD_ONCHIP
}
}
*/
#ifdef FEATURE_OAD
/*********************************************************************
@@ -1171,7 +1214,7 @@ void SimpleBLEPeripheral_processOadWriteCB(uint8_t event, uint16_t connHandle,
Queue_put(hOadQ, (Queue_Elem *)oadWriteEvt);
// Post the application's semaphore.
Semaphore_post(sem);
Semaphore_post(semaphore);
}
else
{
@@ -1189,14 +1232,16 @@ void SimpleBLEPeripheral_processOadWriteCB(uint8_t event, uint16_t connHandle,
*
* @return None.
*/
/*
static void SimpleBLEPeripheral_clockHandler(UArg arg)
{
// Store the event.
events |= arg;
// Wake up the application.
Semaphore_post(sem);
Semaphore_post(semaphore);
}
*/
/*********************************************************************
* @fn SimpleBLEPeripheral_enqueueMsg
@@ -1219,9 +1264,17 @@ static void SimpleBLEPeripheral_enqueueMsg(uint8_t event, uint8_t state)
pMsg->hdr.state = state;
// Enqueue the message.
Util_enqueueMsg(appMsgQueue, sem, (uint8*)pMsg);
Util_enqueueMsg(appMsgQueue, semaphore, (uint8*)pMsg);
}
}
/*******************************************************************************************/
//clock
#include "driver/timers_c.h"
#include "driver/spi_ctrl_c.h"
#include "module/led_APA_102_c.h"
#include "service/app_ser_c.h"
#include "service/mode_all_output_ctrl_c.h"
/*********************************************************************
*********************************************************************/
@@ -9,7 +9,7 @@
Target Device: CC2650, CC2640
******************************************************************************
Copyright (c) 2010-2018, Texas Instruments Incorporated
All rights reserved.
@@ -135,7 +135,6 @@ static simpleProfileCBs_t *simpleProfile_AppCBs = NULL;
// Simple Profile Service attribute
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*/
@@ -144,13 +143,12 @@ 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;
@@ -159,11 +157,9 @@ static uint8 simpleProfileChar2Props = GATT_PROP_READ;
/*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;
@@ -172,11 +168,9 @@ static uint8 simpleProfileChar3Props = GATT_PROP_WRITE;
/*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;
@@ -185,7 +179,6 @@ static uint8 simpleProfileChar4Props = GATT_PROP_NOTIFY;
/*user insert*/
static uint8 simpleProfileChar4[SIMPLEPROFILE_CHAR4_LEN] = {0};
// Simple Profile Characteristic 4 Configuration Each client has its own
// instantiation of the Client Characteristic Configuration. Reads of the
// Client Characteristic Configuration only shows the configuration for
@@ -195,7 +188,6 @@ 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;
@@ -230,17 +222,17 @@ static gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] =
// Characteristic Value 1
{
{ ATT_BT_UUID_SIZE, simpleProfilechar1UUID },
GATT_PERMIT_READ,
0,
simpleProfileChar1
GATT_PERMIT_READ,
0,
simpleProfileChar1
},
// Characteristic 1 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar1UserDesp
GATT_PERMIT_READ,
0,
simpleProfileChar1UserDesp
},
// Characteristic 2 Declaration
@@ -254,112 +246,114 @@ static gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] =
// Characteristic Value 2
{
{ ATT_BT_UUID_SIZE, simpleProfilechar2UUID },
GATT_PERMIT_READ,
0,
simpleProfileChar2
},
GATT_PERMIT_READ,
0,
simpleProfileChar2
},
// Characteristic 2 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar2UserDesp
},
// Characteristic 2 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar2UserDesp
},
// Characteristic 3 Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&simpleProfileChar3Props
},
// Characteristic Value 3
{
{ ATT_BT_UUID_SIZE, simpleProfilechar3UUID },
GATT_PERMIT_WRITE,
0,
simpleProfileChar3
},
// Characteristic Value 3
{
{ ATT_BT_UUID_SIZE, simpleProfilechar3UUID },
GATT_PERMIT_WRITE,
0,
simpleProfileChar3
},
// Characteristic 3 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar3UserDesp
},
// Characteristic 3 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar3UserDesp
},
// Characteristic 4 Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&simpleProfileChar4Props
},
// Characteristic Value 4
{
{ ATT_BT_UUID_SIZE, simpleProfilechar4UUID },
0,
0,
simpleProfileChar4
},
// Characteristic Value 4
{
{ 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
},
// Characteristic 4 configuration
{
{ 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
},
// Characteristic 4 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar4UserDesp
},
// Characteristic 5 Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&simpleProfileChar5Props
},
// Characteristic Value 5
{
{ ATT_BT_UUID_SIZE, simpleProfilechar5UUID },
GATT_PERMIT_AUTHEN_READ,
0,
simpleProfileChar5
},
// Characteristic Value 5
{
{ ATT_BT_UUID_SIZE, simpleProfilechar5UUID },
GATT_PERMIT_AUTHEN_READ,
0,
simpleProfileChar5
},
// Characteristic 5 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar5UserDesp
},
// Characteristic 5 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar5UserDesp
},
};
/*********************************************************************
* 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);
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);
gattAttribute_t *pAttr,
uint8_t *pValue, uint16_t len,
uint16_t offset, uint8_t method);
/*********************************************************************
* PROFILE CALLBACKS
@@ -401,7 +395,7 @@ bStatus_t SimpleProfile_AddService( uint32 services )
// Allocate Client Characteristic Configuration table
simpleProfileChar4Config = (gattCharCfg_t *)ICall_malloc( sizeof(gattCharCfg_t) *
linkDBNumConns );
linkDBNumConns );
if ( simpleProfileChar4Config == NULL )
{
return ( bleMemAllocError );
@@ -414,9 +408,9 @@ bStatus_t SimpleProfile_AddService( uint32 services )
{
// Register GATT attribute list and CBs with GATT Server App
status = GATTServApp_RegisterService( simpleProfileAttrTbl,
GATT_NUM_ATTRS( simpleProfileAttrTbl ),
GATT_MAX_ENCRYPT_KEY_SIZE,
&simpleProfileCBs );
GATT_NUM_ATTRS( simpleProfileAttrTbl ),
GATT_MAX_ENCRYPT_KEY_SIZE,
&simpleProfileCBs );
}
else
{
@@ -474,7 +468,7 @@ bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value )
{
memcpy(simpleProfileChar1, value, len);
// simpleProfileChar1 = *((uint8*)value);
}
}
else
{
ret = bleInvalidRange;
@@ -488,7 +482,7 @@ bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value )
// simpleProfileChar2 = *((uint8*)value);
}
else
{
{
ret = bleInvalidRange;
}
break;
@@ -497,8 +491,7 @@ bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value )
if (len <= SIMPLEPROFILE_CHAR3_LEN)
{
memcpy(simpleProfileChar3, value, len);
// simpleProfileChar3 = *((uint8*)value);
}
}
else
{
ret = bleInvalidRange;
@@ -509,12 +502,9 @@ bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value )
if (len <= SIMPLEPROFILE_CHAR4_LEN)
{
memcpy(simpleProfileChar4, value, len);
// simpleProfileChar4 = *((uint8*)value);
// See if Notification has been enabled
GATTServApp_ProcessCharCfg( simpleProfileChar4Config, simpleProfileChar4, FALSE,
simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ),
INVALID_TASK_ID, simpleProfile_ReadAttrCB );
GATTServApp_ProcessCharCfg(simpleProfileChar4Config, simpleProfileChar4, FALSE, simpleProfileAttrTbl, GATT_NUM_ATTRS(simpleProfileAttrTbl), INVALID_TASK_ID, simpleProfile_ReadAttrCB);
}
else
{
@@ -523,9 +513,8 @@ bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value )
break;
case SIMPLEPROFILE_CHAR5:
if ( len == SIMPLEPROFILE_CHAR5_LEN )
{
VOID memcpy( simpleProfileChar5, value, SIMPLEPROFILE_CHAR5_LEN );
if (len == SIMPLEPROFILE_CHAR5_LEN) {
VOID memcpy(simpleProfileChar5, value, SIMPLEPROFILE_CHAR5_LEN);
}
else
{
@@ -554,41 +543,37 @@ 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 )
{
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;
memcpy(value, simpleProfileChar1, SIMPLEPROFILE_CHAR1_LEN);
// *((uint8*)value) = simpleProfileChar1;
break;
case SIMPLEPROFILE_CHAR2:
memcpy(value, simpleProfileChar2, SIMPLEPROFILE_CHAR2_LEN);
// *((uint8*)value) = simpleProfileChar2;
break;
memcpy(value, simpleProfileChar2, SIMPLEPROFILE_CHAR2_LEN);
// *((uint8*)value) = simpleProfileChar2;
break;
case SIMPLEPROFILE_CHAR3:
memcpy(value, simpleProfileChar3, SIMPLEPROFILE_CHAR3_LEN);
// *((uint8*)value) = simpleProfileChar3;
break;
memcpy(value, simpleProfileChar3, SIMPLEPROFILE_CHAR3_LEN);
break;
case SIMPLEPROFILE_CHAR4:
memcpy(value, simpleProfileChar4, SIMPLEPROFILE_CHAR4_LEN);
// *((uint8*)value) = simpleProfileChar4;
break;
memcpy(value, simpleProfileChar4, SIMPLEPROFILE_CHAR4_LEN);
break;
case SIMPLEPROFILE_CHAR5:
VOID memcpy( value, simpleProfileChar5, SIMPLEPROFILE_CHAR5_LEN );
break;
VOID memcpy(value, simpleProfileChar5, SIMPLEPROFILE_CHAR5_LEN);
break;
default:
ret = INVALIDPARAMETER;
break;
}
ret = INVALIDPARAMETER;
break;
}
return ( ret );
return (ret);
}
/*********************************************************************
@@ -606,65 +591,62 @@ 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)
{
bStatus_t status = SUCCESS;
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)
if ( offset > 0 )
{
return ( ATT_ERR_ATTR_NOT_LONG );
}
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 )
{
// No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
// gattserverapp handles those reads
// 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 );
case SIMPLEPROFILE_CHAR2_UUID:
*pLen = SIMPLEPROFILE_CHAR2_LEN;
VOID memcpy( pValue, pAttr->pValue, SIMPLEPROFILE_CHAR2_LEN );
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;
// Make sure it's not a blob operation (no attributes in the profile are long)
if (offset > 0) {
return (ATT_ERR_ATTR_NOT_LONG);
}
}
else
{
// 128-bit UUID
*pLen = 0;
status = ATT_ERR_INVALID_HANDLE;
}
return ( status );
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) {
// No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
// gattserverapp handles those reads
// 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 = 1;
// pValue[0] = *pAttr->pValue;
*pLen = SIMPLEPROFILE_CHAR2_LEN;
VOID memcpy(pValue, pAttr->pValue, SIMPLEPROFILE_CHAR2_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;
}
} else {
// 128-bit UUID
*pLen = 0;
status = ATT_ERR_INVALID_HANDLE;
}
return (status);
}
/*********************************************************************
@@ -681,83 +663,83 @@ static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle,
*
* @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)
{
bStatus_t status = SUCCESS;
uint8 notifyApp = 0xFF;
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 )
{
case SIMPLEPROFILE_CHAR1_UUID:
case SIMPLEPROFILE_CHAR3_UUID:
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;
}
//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;
}
//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;
}
} 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);
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;
}
else
{
status = ATT_ERR_ATTR_NOT_LONG;
}
//Write the value
if ( status == SUCCESS )
{
uint8 *pCurValue = (uint8 *)pAttr->pValue;
*pCurValue = pValue[0];
// 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 == simpleProfileChar1 )
{
notifyApp = SIMPLEPROFILE_CHAR1;
}
else
{
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;
} else {
// 128-bit UUID
status = ATT_ERR_INVALID_HANDLE;
}
}
else
{
// 128-bit UUID
status = ATT_ERR_INVALID_HANDLE;
}
// If a characteristic value changed then callback function to notify application of change
if ( (notifyApp != 0xFF ) && simpleProfile_AppCBs && simpleProfile_AppCBs->pfnSimpleProfileChange )
{
simpleProfile_AppCBs->pfnSimpleProfileChange( notifyApp );
}
// If a characteristic value changed then callback function to notify application of change
if ((notifyApp != 0xFF) && simpleProfile_AppCBs && simpleProfile_AppCBs->pfnSimpleProfileChange) {
simpleProfile_AppCBs->pfnSimpleProfileChange(notifyApp);
}
return ( status );
return (status);
}
/*********************************************************************
@@ -56,7 +56,7 @@ extern "C"
/*********************************************************************
* INCLUDES
*/
// #include "application_config/application_config.h"
/*********************************************************************
* CONSTANTS
*/
@@ -81,24 +81,12 @@ extern "C"
// Simple Keys Profile Services bit fields
#define SIMPLEPROFILE_SERVICE 0x00000001
#ifndef CUSTOM_GATT_LENGTH
// Length of Characteristic 5 in bytes
#define SIMPLEPROFILE_CHAR5_LEN 5
#define SIMPLEPROFILE_CHAR4_LEN 20
/*user insert*/
#define SIMPLEPROFILE_CHAR4_LEN 40
#define SIMPLEPROFILE_CHAR3_LEN 20
#define SIMPLEPROFILE_CHAR2_LEN 20
#define SIMPLEPROFILE_CHAR1_LEN 20
#else
/*user insert*/
#define SIMPLEPROFILE_CHAR5_LEN 5
#define SIMPLEPROFILE_CHAR4_LEN BLE_DAT_BUFF_SIZE
#define SIMPLEPROFILE_CHAR3_LEN BLE_INS_BUFF_SIZE
#define SIMPLEPROFILE_CHAR2_LEN BLE_CIS_BUFF_SIZE
#define SIMPLEPROFILE_CHAR1_LEN 20
#define BLE_CIS_BUFF_CHAR SIMPLEPROFILE_CHAR2
#define BLE_INS_BUFF_CHAR SIMPLEPROFILE_CHAR3
#define BLE_DAT_BUFF_CHAR SIMPLEPROFILE_CHAR4
#endif
/*********************************************************************
* TYPEDEFS
*/