Compare commits

...

456 Commits

Author SHA1 Message Date
Roy 64efb1685c V3 2021-11-30 09:31:27 +08:00
Roy 68c8b58575 V2 test 2021-11-26 14:23:48 +08:00
Roy 26eb94972f v1 test 2021-11-26 11:19:01 +08:00
Roy 179895df57 add BOARD_F09F calibration data 2021-11-19 10:30:05 +08:00
Roy 0bdb108deb add BOARD_EDA9 & BOARD_F0D6 calibration data 2021-11-18 17:36:28 +08:00
Roy 12616ebf26 update BOARD_F0C0 calibration data 2021-11-17 15:03:27 +08:00
Roy b625609973 update BOARD_EF20 calibration data 2021-11-17 13:20:13 +08:00
Roy 44664f1081 update BOARD_F01C calibration data 2021-11-17 12:25:52 +08:00
Roy 5eb03e21f7 add BOARD_F0C0 calibration data 2021-11-16 15:57:06 +08:00
Roy fad33ae7b8 add BOARD_F01C calibration data 2021-11-11 10:51:02 +08:00
Roy ea904f1be5 update dpv mode 2021-11-10 17:58:04 +08:00
Roy 93f1bc3cba fix CURVE_DPV_SMPRATE mode led 2021-11-01 17:20:14 +08:00
Roy ceec1dc934 add BOARD_F057 calibration data 2021-11-01 17:18:23 +08:00
Roy 3b11f4b166 new dpv mode v.1 2021-10-29 19:01:32 +08:00
Roy d2f4e80ac7 add BOARD_EF20 calibration data 2021-10-26 13:23:14 +08:00
Roy 6de9d27c10 new dpv mode 2021-10-26 13:19:09 +08:00
Roy 853f1a588e update FINISH_MODE_INS 2021-10-07 15:39:19 +08:00
Roy 9c7cd4deae update device name 2021-10-06 16:14:17 +08:00
Roy cb5fb2ace3 add BOARD_ECDB & BOARD_C81C calibration data 2021-09-29 12:49:25 +08:00
Roy 5dc38146b8 add BOARD_EFD8 calibration data 2021-09-22 18:32:43 +08:00
Benny Liu 785358ea83 Update F08F calibration value 2021-09-16 16:22:26 +08:00
Roy ecc6841a05 update BOARD_EF30 & EE3A & ED21 & EF50 calibration data 2021-09-14 23:08:31 +08:00
Roy 5b2889cbc7 don't update Iin channel when change gain 2021-09-09 18:01:12 +08:00
Roy f638c872ad add BOARD_EF30 & BOARD_EF50 calibration data 2021-09-03 15:19:31 +08:00
Roy a0ddb1f13b cal impedance use Vout_set for RT 2021-09-01 18:03:07 +08:00
Roy cfe3aacfc5 fix change Iin gain damping 2021-08-25 14:18:34 +08:00
Roy f38c99a226 VT mode use Iin_Vin_Plot and send Iin & Vin 2021-08-24 16:33:41 +08:00
Roy b958536d96 fix realtime instruction 2021-08-20 16:19:10 +08:00
Roy 489047b7f6 annotation 2021-08-20 11:19:38 +08:00
Roy 9138b93e80 update all mode data 2021-08-19 13:33:04 +08:00
Roy cdec2f5134 update CV & CA & LSV data 2021-08-17 13:57:42 +08:00
Benny Liu 9f5f87d3bd Update BOARD_C5AF & BOARD_F08F calibration data 2021-08-12 18:20:50 +08:00
Roy 39280c1bce CV.LSV.CA Vscan is Vset - Vin 2021-08-12 11:14:14 +08:00
Roy 565c415762 notify cycle in CV mode 2021-08-05 09:35:19 +08:00
Roy 97adad6ef1 take away read bettery in CURVE_UNI_PULSE mode 2021-08-02 12:53:30 +08:00
Roy 6cdbd35a8a update CURVE_UNI_PULSE mode 2021-07-23 19:13:15 +08:00
Roy 04d4af4cad change in sequence of IT_plot & VT_plot 2021-07-22 10:28:12 +08:00
Roy 7a0691a221 sort out code (correction.h) 2021-07-21 14:15:23 +08:00
Roy e420b535d7 update adc relation function 2021-07-20 18:53:03 +08:00
Roy 568489d39e update LED_DEV_TEST 2021-07-20 18:10:34 +08:00
Roy 95cf4a7f73 fix CIS return date (insert data length) 2021-07-20 17:29:22 +08:00
Roy 1d0ab06900 sort out code 2021-07-15 18:36:25 +08:00
Roy 52dd0e8585 sort out code 2021-07-15 16:02:11 +08:00
Roy 0749a7390d multi channel separate from Iin, and calculate average skip 10ms 2021-07-15 13:28:24 +08:00
Roy baa0894240 fix leadtime & vscantime 2021-07-12 23:22:08 +08:00
Roy e29e5f4127 update OCP highz instruction 2021-07-12 16:01:47 +08:00
Roy ca4a265b65 improve mode instruction, and change it & rt & vo volt anytime 2021-07-09 16:10:33 +08:00
Roy 0aea99cb2f chart ugly 2021-07-07 18:46:16 +08:00
Roy 33f2e77ed9 new uni_pulse mode 2021-07-07 15:41:03 +08:00
Benny Liu 34838a793f Combine battery voltage and CC2650 temperature measurement. 2021-07-06 14:57:25 +08:00
Benny Liu 9a87a5316f Add over temperature protection check. 2021-07-05 16:23:11 +08:00
Benny Liu a23235085d Add Temperature sensing function. (Not done yet) 2021-07-05 14:00:48 +08:00
Benny Liu 78cc816ba3 Run Iin_Vin_Vout_plot() at CURVE_IT. 2021-07-02 11:22:28 +08:00
Benny Liu 2ff582a0c5 Merge branch 'Elite1.5_Vout_in_RT_0628' into Elite1.5
# Conflicts:
#	simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_mode_ADC_DAC.h
#	simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h
2021-07-02 10:14:16 +08:00
Roy 23d16b37dc modulize ADC.h 2021-07-01 19:02:23 +08:00
Roy 5eb08c48e5 modulize ADC.h 2021-07-01 15:52:09 +08:00
Roy 8d9d9a4955 optimize auto gain changer 2021-07-01 15:50:33 +08:00
Benny Liu c5d487f7c7 Set Vout voltage and send notify at IT mode. 2021-06-30 13:56:39 +08:00
Roy cfa28f9d7d modify IV.CV notify 2021-06-28 18:18:24 +08:00
Benny Liu d44843d525 Add parameter from UI. 2021-06-28 17:10:18 +08:00
Benny Liu 43d2623eb2 RT mode output 0.1V 2021-06-28 16:39:44 +08:00
Roy be8a39694e take away Old boundary 2021-06-28 12:13:22 +08:00
Roy 6f6fd80488 take away Old boundary 2021-06-28 11:58:51 +08:00
Roy cfd06ea0ea modify SIMPLEPROFILE_CHAR4_LEN 60 to 20 2021-06-22 16:46:33 +08:00
Roy faff6a229a nothing 2021-06-18 16:38:45 +08:00
Benny Liu aa5d0be31e Add calibration coeff. and offset for Vout_volt 2021-06-18 13:28:57 +08:00
Benny Liu 376d1777ba Add calibration Vout plot and device correction parameter for Vout_in 2021-06-18 11:50:36 +08:00
Roy 12241635a3 [update] update CURVE_CALI_ADC 2021-06-17 12:18:24 +08:00
Roy 18eba87064 [update] update OCP mode & merge vscan_volt 2021-06-17 11:48:18 +08:00
Roy d313f48eaa [update] new OCP mode and centralized notify 2021-06-16 22:32:54 +08:00
Roy 117336020f [update] new Vout_Plot 2021-06-15 14:03:49 +08:00
Roy cf3172f99a [update] update Elite_mode_ADC_DAC file 2021-06-09 14:28:16 +08:00
Roy 8b32a6d2d1 [cali] add BOARD_F08F & E774 & ED21 & EE3A & F010 & EEEF calibration data. 2021-06-07 15:27:44 +08:00
Roy 3e7d3abed7 [update] change to ELITE_PIN_1_5_RE version 2021-05-25 10:12:33 +08:00
Roy 6ac29b48c2 [update] change to ELITE_PIN_1_5_RE 2021-05-25 09:56:56 +08:00
Roy d0d83e6ae6 [cali] add BOARD_C5AF & C6E7 & ED49 calibration data. 2021-05-25 09:36:48 +08:00
Roy 0e181aaa07 [cali] add BOARD_C68B & ED5A & C705 & C6EF calibration data. 2021-05-21 15:32:40 +08:00
Roy a7b0b3965c RT send resister in denomination of mOhm to controller 2021-04-19 10:18:13 +08:00
Roy dbbb44e0d2 new sps on IT.VT.RT.CC.VOUT mode 2021-04-14 09:28:08 +08:00
Roy 156927e8f9 new sps on IT.VT.RT.CC.VOUT mode 2021-04-13 11:31:27 +08:00
Roy daab3bed0b GPtimer CLOCK_FREQ 4800 -> 4769 2021-04-12 09:37:02 +08:00
Roy 7c6d7c68de CC MODE deltaV = 10mV 2021-04-09 16:23:10 +08:00
Roy eff1e4a43e new 1.5re pin (use define) 2021-04-09 10:48:25 +08:00
Roy 9678266e59 fix RT (no 10 ohm) 2021-04-08 14:10:31 +08:00
Roy 6f74dc2c05 datalength extension:60bytes 2021-04-08 11:07:44 +08:00
Roy 910576ac6d datalength extension 200 bytes 2021-03-31 10:19:35 +08:00
Roy 9377dc517f battery < 3V when running mode, don't close elite 2021-03-16 14:25:21 +08:00
Roy e44d3d8e60 adjusted cc value 2021-03-16 11:24:45 +08:00
Roy f5416d5e1f measure battery when run mode 2021-03-15 15:44:47 +08:00
Roy 0d60074697 send mode finish flag 2021-03-12 12:12:24 +08:00
Roy 3c74358634 update notify rate 2021-03-10 17:25:12 +08:00
Roy 398f9977b8 add debug battery func 2021-03-08 10:05:53 +08:00
Roy 89db7e4575 don't measure battery when run mode 2021-03-08 10:01:46 +08:00
Roy 2b99b96f0f don't measure battery when run mode 2021-03-05 12:15:47 +08:00
Roy 1b67c809a9 open highz when finish experiment 2021-03-05 11:55:07 +08:00
Roy 59aac611f6 open highz when finish experiment 2021-03-05 11:31:14 +08:00
Roy 6f5baf38ce open highz when finish experiment 2021-03-05 10:29:20 +08:00
Roy 05f8eb4c51 change vin level when open elite, battery value is right 2021-03-04 11:48:12 +08:00
Roy 9bd536bb68 [update] don't meas battery when no reriodicEvent 2021-01-28 11:06:08 +08:00
Roy 81d9aaab1f [update] organize code 2021-01-28 10:41:45 +08:00
Roy 341c5939ac [update] organize code 2021-01-27 17:45:43 +08:00
Roy c50c0b4dec [update] close highz & set DAC value in pre-treated (100ms) 2021-01-27 15:03:39 +08:00
Roy 1639eddc6d [update] free malloc when change mode 2021-01-26 18:08:27 +08:00
Roy cc50bbc0a4 [update] pulse module 2021-01-26 16:08:24 +08:00
Roy 913d269a32 [update] ca module 2021-01-26 15:44:26 +08:00
Roy 5938d6645f [update] lsv module 2021-01-26 15:33:02 +08:00
Roy 3fda9fff6c [update] cv module 2021-01-26 15:16:30 +08:00
Roy 6f6346ac45 Merge branch 'Elite1.5_dev_module_0125_4' into Elite1.5_dev_module_0125_5 2021-01-26 13:42:36 +08:00
Roy 4ca15b1ec9 [update] open highz when elite int() & reset() 2021-01-26 13:40:38 +08:00
Roy 4c0cdcbfe9 [update] cc module 2021-01-26 12:30:46 +08:00
Roy ccb6939b34 [update] iv_cy module 2021-01-26 11:59:48 +08:00
Roy 27baa87562 [update] iv module 2021-01-26 11:12:00 +08:00
Roy ea862012b8 Merge branch 'Elite1.5_dev_module_0125_3' into Elite1.5_dev_module_0125_4 2021-01-26 10:53:44 +08:00
Roy d8c0d5e420 [update] open highz when elite turn on 2021-01-26 10:45:41 +08:00
Roy 43c606577a [update] rt module 2021-01-26 10:40:05 +08:00
Roy 72a64479d4 [update] vo module 2021-01-25 18:29:35 +08:00
Roy c6b45ecca4 [update] it module 2021-01-25 17:56:09 +08:00
Roy 11d828bfc7 [update] vt module 2021-01-25 17:12:09 +08:00
Roy 79bca317c2 [update] vt module 2021-01-25 17:02:32 +08:00
Roy ea254423d6 [cali] add BOARD_C5CD calibration data. 2021-01-25 10:47:06 +08:00
Roy f151d5a74d [update] fix CC mode 2021-01-25 10:18:40 +08:00
Roy 5cc2d878be [update] fix Vout mode 2021-01-22 18:31:31 +08:00
Roy 18eeeec7cc [update] update cycle 8bit to 16bit 2021-01-22 18:20:08 +08:00
Roy 81d753b5f0 [update] fix RT mode 2021-01-17 17:40:30 +08:00
Roy 0841d08972 [update] fix Vout mode (ok) 2021-01-11 23:35:43 +08:00
Roy de5bb460fc [update] fix WM (not ok) 2021-01-11 00:47:35 +08:00
Roy eb45ca6d81 [update] test struct ok 2021-01-08 18:05:27 +08:00
Roy b0d2697c92 [update] test struct fail 2021-01-08 12:27:28 +08:00
Roy 0dc0b66234 [update] test struct fail 2021-01-08 10:39:49 +08:00
Roy 11da60ab8f test struct 2021-01-08 00:42:28 +08:00
Roy 41c7db8776 [update] test TT-CURVE 2021-01-07 18:22:26 +08:00
Roy 916a8f5dc7 [update] fix Cycle I-V cycle 2021-01-05 11:08:06 +08:00
Roy 25cc8b16fa [update] fix CV3 cycle 2021-01-05 10:31:08 +08:00
Roy 67bf8b67dd [cali] add BOARD_C797 & BOARD_C639 calibration data. 2020-12-31 09:40:38 +08:00
Roy 13dfdbd502 [update] fix problem for change level 2020-12-30 16:36:16 +08:00
Roy e0ae30d40d [update] add dark led fun() 2020-12-29 11:45:09 +08:00
Roy 2c3a0a7ee8 [cali] add BOARD_C615 & BOARD_C78B calibration data. 2020-12-29 10:43:51 +08:00
Benny Liu f1086df363 turn on 6994 shutdown 2020-12-17 12:40:07 +08:00
Roy 6345ee875a [cali] add BOARD_C60C calibration data. 2020-12-16 09:59:21 +08:00
Roy 69061f9afd [cali] add BOARD_C903 calibration data. 2020-12-15 10:00:58 +08:00
Roy 3aecb50b47 [cali] add BOARD_C69F calibration data. 2020-12-14 18:37:01 +08:00
Roy e030578fd8 [update] update headstage version on elite1.5 (0,2,1,6) 2020-12-10 17:16:37 +08:00
Roy c05fefe71c Merge branch 'Elite1.5_developement_testmode1210' into Elite1.5_developement 2020-12-10 17:04:31 +08:00
Roy 177b56e8f9 [update] update pulsemode on elite1.5 2020-12-10 17:03:08 +08:00
Benny Liu aeb7a8afaf cali_count_max = 5000 for smallest Vin and Iin gain 2020-12-10 15:53:35 +08:00
Roy 0edaa77857 [update] match 1.5 ui (cali code) 2020-12-04 11:28:33 +08:00
Roy c656eebcbc [update] align notify (match megafly ui) 2020-11-26 22:48:53 +08:00
Roy e17e78bc18 [update] add Vout boundary (usc) 2020-11-26 16:14:31 +08:00
Benny Liu c3235e985f Change 1.5 Iin measurement range. 2020-11-26 15:48:01 +08:00
Roy 656e0fb485 [cali] update BOARD_C7A1 calibration data. 2020-11-23 12:12:09 +08:00
Roy d3dd5270dd [update] tag controller version 2020-11-23 10:18:46 +08:00
Roy e588b30c8b [update] monitor bat 2020-11-20 14:45:21 +08:00
Roy d3f9aec31c add BOARD_C604 calibration data. 2020-11-20 11:50:17 +08:00
Roy ed617c88c9 [update] remove megafly pin 2020-11-20 11:14:01 +08:00
Roy 0b8f4c2414 Merge branch 'Elite1.5_developement_magafly_1119_1' into Elite1.5_developement 2020-11-20 11:08:51 +08:00
Roy b5449b7404 [update]update pulsefly INSTRUCTION.notifyRate 2020-11-20 11:06:12 +08:00
Roy a3c1241f38 Merge branch 'Elite1.5_calibration' into Elite1.5_developement 2020-11-20 11:01:45 +08:00
Roy bbf60ebfed test periodicEvent 2020-11-19 16:00:51 +08:00
Roy 0e9f40bdd5 Megafly trigger yes yes. 2020-11-19 15:47:07 +08:00
Roy e32897f6b5 [update] Megafly notify check. & Megafly trigger. 2020-11-19 15:40:12 +08:00
Roy 6ee4b47d90 [update]update pulsefly INSTRUCTION.notifyRate 2020-11-18 11:57:53 +08:00
YiChin dac19f62b2 test ok,but T2~T3=0 can't handle 2020-11-16 14:43:50 +08:00
YiChin 8e6d112729 test ok,but T2~T3=0 can't handle 2020-11-16 14:30:27 +08:00
YiChin 9e1dc1e3f4 test ok,but T1~T5=0 can't handle 2020-11-13 18:28:48 +08:00
YiChin 49fb3afc01 test ok,but T1~T5=0 can't handle 2020-11-13 13:30:47 +08:00
YiChin f3b402fce9 test ok 2020-11-12 18:01:32 +08:00
YiChin ef9a38d7fc test not ok(RT not ok) 2020-11-12 17:24:04 +08:00
YiChin 67275a7921 test not ok(RT not ok) 2020-11-12 16:17:15 +08:00
YiChin 0ddaa02414 test not ok 2020-11-12 15:39:44 +08:00
YiChin 96d5735164 test not ok 2020-11-12 14:55:28 +08:00
YiChin ac32fb9c73 test not ok 2020-11-12 12:23:14 +08:00
Benny Liu 9acc242ff6 Add Megafly pin. 2020-11-12 10:22:31 +08:00
YiChin d8a403c410 add BOARD_C771 calibration data. 2020-11-12 10:18:12 +08:00
YiChin f1d0acef23 update pulse mode 2020-11-12 10:16:40 +08:00
YiChin 9811572f47 add pulse mode 2020-11-11 16:44:49 +08:00
YiChin 8753e2ddc6 dont send battery information 2020-10-22 10:38:09 +08:00
YiChin f6167c25ca update SPI hold & take away AutoGainChangeVout() 2020-10-20 18:41:00 +08:00
YiChin cb3894712e take away AutoGainChangeVout() 2020-10-20 18:23:13 +08:00
YiChin 995a47e200 update SPI hold 2020-10-20 17:11:36 +08:00
YiChin cde9096018 update SPI hold 2020-10-20 12:18:29 +08:00
YiChin 6c1bd24b92 update SPI hold 2020-10-19 18:40:35 +08:00
YiChin 0c129bc99b take away bat() 2020-09-25 09:43:39 +08:00
YiChin cbe9bd8211 CV mode foolproof 2020-09-07 17:58:18 +08:00
YiChin 0293647d0c update cali dac mod 2020-09-04 16:32:53 +08:00
YiChin 87d187c3a5 add cali dac mode, need to take away auto change voutgain 2020-09-03 18:30:39 +08:00
YiChin 09fbfd9dda update cali adc mode 2020-09-03 14:49:33 +08:00
YiChin 74ca631309 add cali adc mode 2020-09-02 15:49:49 +08:00
YiChin 03e86e175d add cali mode 9/1 2020-09-01 15:44:42 +08:00
YiChin 1c54525256 update cali code 2020-09-01 13:41:02 +08:00
YiChin d49874a666 add Vout of DAC 2020-08-28 13:30:35 +08:00
YiChin 6d6ba43d81 fix Iin of ADC 2020-08-26 09:50:37 +08:00
YiChin 4914498732 fix Vin of ADC 2020-08-25 18:10:08 +08:00
YiChin 85220734de spi hold when run mode 2020-08-24 15:59:18 +08:00
YiChin 7531a6638b update Iin boundary 2020-08-20 11:50:21 +08:00
Benny Liu 4088a4d38b Calibration data of BOARD_C6D4. 2020-08-19 18:18:53 +08:00
YiChin 1b3d057d33 update LED fun 2020-08-18 14:18:35 +08:00
YiChin 17e1846afa fix slowly vscan of CV3 & CV & LSV mode 2020-08-18 14:09:14 +08:00
YiChin 0407690197 fix slowly vscan of IV mode 2020-08-14 09:22:21 +08:00
YiChin 55e8b37f13 test Vout & highZ 2020-08-12 14:52:47 +08:00
YiChin fb4c0a59e8 update Vin boundary 2020-08-11 16:35:39 +08:00
YiChin ea3d146c86 test Vin change level 2020-08-11 15:38:32 +08:00
YiChin cddafdffff Modify ADC test for calibration. 2020-08-11 15:11:50 +08:00
YiChin 05e953d6e2 test Vin change level 2020-08-11 15:09:57 +08:00
YiChin 9b7e960bec test Vin change level 2020-08-11 14:42:27 +08:00
YiChin c3aa2f7178 test Vin change level 2020-08-11 14:37:37 +08:00
YiChin 5b4970d814 test Vin change level 2020-08-11 14:09:19 +08:00
YiChin 46c43afa26 test Vin change level 2020-08-10 18:08:27 +08:00
YiChin 6bcfc74d1a test Vin change level 2020-08-10 17:25:23 +08:00
YiChin 4d920209f7 test ADC code 2020-08-10 16:11:36 +08:00
YiChin 52f8708905 test ADC code 2020-08-10 15:46:53 +08:00
YiChin b7024363ee test ADC code 2020-08-10 14:54:09 +08:00
YiChin 1a6d30606c test ADC code 2020-08-10 10:48:09 +08:00
YiChin e72698dea3 test ADC code 2020-08-07 14:36:04 +08:00
YiChin 3100dded42 update BOARD_C6E1 calibration data. 2020-08-06 18:23:55 +08:00
YiChin 53584f2b5b add BOARD_C6E1 calibration data. 2020-08-06 15:35:03 +08:00
YiChin b2d924228a fix auto change level 2020-08-06 13:48:28 +08:00
YiChin f3de02477d fix change level ok 2020-08-06 10:01:48 +08:00
YiChin 77a2bc2d8f fix change level ok 2020-08-06 09:49:25 +08:00
YiChin c56a07ead8 test ADC_TEST 2020-08-05 09:37:25 +08:00
YiChin 2e3ca56ece test ADC_TEST 2020-08-04 16:35:42 +08:00
YiChin b8588393b7 test ADC_TEST 2020-08-04 16:31:27 +08:00
YiChin ea33b37080 test ADC_TEST 2020-08-04 15:22:40 +08:00
YiChin ea7815dc64 Elite 1.4 upgrade to Elite 1.5 2020-08-04 12:36:31 +08:00
YiChin 2340b0e88c add BOARD_7C4F calibration data. 2020-08-03 17:22:36 +08:00
YiChin d05d42415a add BOARDs calibration data. 2020-08-03 17:10:03 +08:00
YiChin e34db21efd update BOARDs calibration data. 2020-07-30 17:07:02 +08:00
YiChin f6a1a9fa4e take away ZT_plot 2020-07-29 15:21:38 +08:00
YiChin a567483ffa Merge branch 'Elite_OBJ_0.2mv_fixLV_0727_1' into Elite_OBJ_0.2mv 2020-07-29 14:38:11 +08:00
YiChin 9dc0a0109a cv mode instruction split twice 2020-07-29 14:29:06 +08:00
YiChin afd9ac1223 update BOARDs calibration data. 2020-07-29 09:57:02 +08:00
YiChin 30ff3a6d69 test 2020-07-28 18:15:22 +08:00
YiChin 50781513dc take away BT config 2020-07-28 17:22:07 +08:00
YiChin fab091d3ec fix change level 2020-07-28 10:09:33 +08:00
YiChin b734f2d44c fix change level 2020-07-27 18:27:10 +08:00
YiChin 576c6e5177 fix change level 2020-07-27 18:17:13 +08:00
YiChin 70a8640327 fix change level 2020-07-27 18:06:12 +08:00
YiChin 72d95dac61 fix change level 2020-07-27 17:21:20 +08:00
YiChin 84367ae2d3 fix change level 2020-07-27 11:22:38 +08:00
YiChin c06a9a996e Merge branch 'Elite_OBJ_0.2mv_datalength_07211' into Elite_OBJ_0.2mv_fixLV_0727_1 2020-07-27 10:00:04 +08:00
YiChin 699c6d1365 update LED code 2020-07-22 10:42:24 +08:00
YiChin cbad40dc5a add BOARD_5AB8 calibration data. 2020-07-22 09:41:06 +08:00
YiChin 53afd6dd2f add BOARD_5AB8 calibration data. 2020-07-22 09:39:44 +08:00
YiChin 5f12e4b10d update LED code 2020-07-22 09:31:20 +08:00
YiChin 28f6c39288 update LED code 2020-07-21 17:26:38 +08:00
YiChin ec7bd09b70 update CV3 surge & update BT config 2020-07-21 16:31:22 +08:00
YiChin dc6ac4cf19 BT config(data length) 2020-07-21 14:33:14 +08:00
YiChin 15cde79313 take away BT config 2020-07-20 18:34:11 +08:00
YiChin ac6767f082 720 version 2020-07-20 17:53:22 +08:00
YiChin 4f7c2205b0 Update BOARD_7A7A calibration data. 2020-07-20 14:35:19 +08:00
Benny Liu f576158d38 Merge remote-tracking branch 'origin/Elite_OBJ_0.2mv' into Elite_OBJ_0.2mv
# Conflicts:
#	simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDeviceCorrection.h
2020-07-17 16:06:40 +08:00
Benny Liu 47fc620923 Update BOARD_C758 calibration data. 2020-07-17 16:04:55 +08:00
YiChin 897270dab4 Update BOARD_C758 calibration data. 2020-07-17 13:54:06 +08:00
YiChin 3becd44444 Update BOARD_C758 calibration data. 2020-07-17 12:20:24 +08:00
YiChin 4bfa35858d BT config 2020-07-16 18:19:15 +08:00
YiChin d6068f8e5c BT config 2020-07-16 15:36:15 +08:00
YiChin 2ea33f0269 measure battery when recording 2020-07-16 12:45:45 +08:00
YiChin f9da0bbad4 measure battery when recording 2020-07-16 12:25:12 +08:00
YiChin 46bd7e04cf Merge branch 'Elite_OBJ_0.2mv_0702_eventBat4_F5' into Elite_OBJ_0.2mv_add_battery
# Conflicts:
#	simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDeviceCorrection.h
2020-07-16 12:12:52 +08:00
YiChin e3a04ad8e5 measure battery when recording 2020-07-16 11:20:07 +08:00
YiChin 6cfde66c24 add BOARD_7C62&7C2E calibration data. 2020-07-16 09:32:36 +08:00
YiChin f9f0aeaf87 measure battery when recording 2020-07-15 17:58:39 +08:00
YiChin 1856096cf3 fix Vout mode 2020-07-15 15:57:52 +08:00
Benny Liu eb1b4ddf30 Update BOARD_CHAO_I calibration data. 2020-07-15 10:50:05 +08:00
YiChin e960b0859a measure battery when recording 2020-07-14 18:17:38 +08:00
YiChin bcebfaa777 measure battery when recording 2020-07-14 17:53:18 +08:00
YiChin 5be3e2ec10 measure battery when recording 2020-07-14 17:37:36 +08:00
YiChin 49f2f6b1ea update init code 2020-07-14 16:36:12 +08:00
YiChin 9afe79edfb update init code 2020-07-14 15:56:23 +08:00
YiChin fc67ea915e update init code 2020-07-14 14:42:57 +08:00
YiChin 7b866d025a update init code 2020-07-14 11:47:39 +08:00
YiChin 13864e766a update init code 2020-07-13 18:14:47 +08:00
YiChin ee0ff789f3 update init code 2020-07-13 15:51:15 +08:00
YiChin 7f6a871501 update workdata code 2020-07-13 13:26:41 +08:00
YiChin d4681171b4 fix cc i = 0 2020-07-13 12:34:52 +08:00
Benny Liu 52139ec1b1 Update BOARD_7A42 calibration data. 2020-07-10 18:10:00 +08:00
YiChin 9b61eda6c2 take away something 2020-07-10 18:02:19 +08:00
Benny Liu 142c8c38e1 Update BOARD_7A42 calibration data. 2020-07-10 18:01:21 +08:00
Benny Liu e1acbf5681 Update BOARD_C682 calibration data. 2020-07-10 16:32:51 +08:00
YiChin 0bc5b8bfb8 update CV3 LSV CA code (ADC) 2020-07-10 16:07:13 +08:00
Benny Liu 3e8bbbeaf8 Update BOARD_C77F calibration data. 2020-07-10 15:35:30 +08:00
YiChin 4c88d96928 update CC code (ADC) 2020-07-10 14:59:16 +08:00
YiChin ffeb980a39 update IT VT RT IV CV code (ADC) 2020-07-10 14:21:10 +08:00
Benny Liu b0ced97ffb Update BOARD_C73D calibration data. 2020-07-10 11:48:15 +08:00
YiChin 1876714222 update CA code (Chronoamperometry mode) 2020-07-10 10:37:13 +08:00
YiChin 075e65604b update LSV code 2020-07-10 10:22:31 +08:00
YiChin 7dbc090909 update CV3 code 2020-07-10 09:31:13 +08:00
YiChin c95e379cd1 update CV3 code 2020-07-09 18:32:11 +08:00
YiChin 9284cfacfc update IV CV CC code 2020-07-09 17:30:10 +08:00
YiChin dcced24976 update IV CV code 2020-07-09 16:29:16 +08:00
YiChin 286164a76d update IV code 2020-07-09 14:57:39 +08:00
YiChin 51d2e88978 update IT VT RT code 2020-07-09 10:27:15 +08:00
YiChin 29b73a88ae update workdata code 2020-07-09 09:51:23 +08:00
YiChin 99f2e53b34 update workdata code 2020-07-08 18:09:40 +08:00
YiChin 6d14af0e18 update workdata code 2020-07-08 17:11:46 +08:00
YiChin 43282ac881 update workdata code 2020-07-08 16:29:09 +08:00
Benny Liu 67a82d0cb1 Update BOARD_C73D calibration data. 2020-07-08 15:55:35 +08:00
YiChin aec07f750b update workdata code 2020-07-08 14:59:07 +08:00
YiChin 5c38dd785a update header code 2020-07-08 14:31:44 +08:00
YiChin 46473fbae0 take away RVout mode 2020-07-08 14:13:12 +08:00
YiChin cf876bfaf9 update DEFAULT_DESIRED_CONN_INTERVAL range 6~6 2020-07-08 10:19:22 +08:00
YiChin 2fe991a23b update calibration data. 2020-07-08 09:22:10 +08:00
YiChin b9f8938c0e update calibration data. 2020-07-07 10:41:57 +08:00
Benny Liu 14129b8b3c update calibration data. 2020-07-06 15:24:59 +08:00
YiChin 502daf7204 update BOARD_C688 & BOARD_C5F1 calibration data. 2020-07-03 17:44:01 +08:00
YiChin 3013e88dca add BOARD_7C73 calibration data. 2020-07-03 12:09:07 +08:00
YiChin d37cf0f694 add BOARD_7C7E calibration data. 2020-07-02 18:24:56 +08:00
YiChin 4cf062fb06 update calibration data. 2020-07-02 18:16:05 +08:00
YiChin 4a8e090ff1 update calibration data. 2020-07-02 18:04:39 +08:00
YiChin 576df09f24 add BOARD_7AA4 & BOARD_7CE0 calibration data. 2020-07-02 18:02:36 +08:00
YiChin 3a01d5cc2c update BOARD_7A4F calibration data. 2020-07-02 15:04:43 +08:00
YiChin 165c89e6aa fix CC speed 2020-07-02 10:53:34 +08:00
YiChin 9eaedfc0e5 update header 2020-07-02 09:42:28 +08:00
YiChin 5eba9eff3a fix CC speed 2020-07-02 09:41:09 +08:00
Benny Liu b985a09863 Add calibration data. 2020-07-01 18:54:49 +08:00
YiChin 68aa82bbd8 Merge branch 'Elite_OBJ_0.2mv_0616_CVSCANf5' into Elite_OBJ_0.2mv2
# Conflicts:
#	simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDeviceCorrection.h
#	simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h
#	simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c
2020-07-01 14:41:32 +08:00
Benny Liu 6b1c0ca9aa Don't care. 2020-07-01 14:37:30 +08:00
YiChin d176628edb LED not run when battery volt < 3V (boot) 2020-07-01 12:20:53 +08:00
YiChin 8548712049 update batt.h 2020-07-01 10:47:18 +08:00
YiChin bc819082cc measure bat volt (no periodic event) 2020-07-01 10:18:24 +08:00
YiChin 64fb0fc78a add Battery Counter 2020-06-30 18:31:42 +08:00
YiChin 0a4303dff0 when PeriodicEvent = true, headstage_battery_volt() not perform 2020-06-30 17:15:51 +08:00
YiChin caa0bfaf8d add NotifyVoltBat buffer 2020-06-30 16:44:25 +08:00
Benny Liu c6e300bfff don't care. 2020-06-30 14:32:23 +08:00
YiChin cf1d92d9ec test 2020-06-30 14:12:28 +08:00
YiChin 25796a879d test 2020-06-30 13:57:30 +08:00
Benny Liu f6e8385a8f Disable battery voltage detection. 2020-06-30 13:32:22 +08:00
Benny Liu b52ea2fe1e BOARD_C5DA calibration data.
Disable battery voltage detection.
2020-06-30 13:21:13 +08:00
YiChin 2a6920a3d3 test 2020-06-30 11:05:41 +08:00
YiChin fac1427eb6 test battery(not ok) 2020-06-29 18:47:14 +08:00
Benny Liu ed13172c92 BOARD_C5DA calibration data. 2020-06-29 18:28:02 +08:00
YiChin 07ebae4f64 Elite power off when low battery[init] 2020-06-29 15:35:18 +08:00
Benny Liu 1391ebd695 BOARD_C5DA calibration data. 2020-06-29 15:11:25 +08:00
YiChin 6cf988a54c Elite power off when low battery[init] 2020-06-24 17:42:14 +08:00
YiChin 76b74b53f9 Elite power off when low battery 2020-06-24 17:22:28 +08:00
YiChin 786991d971 update battery 2020-06-24 16:36:15 +08:00
YiChin c33b46521e test battery 2020-06-23 13:44:14 +08:00
YiChin fc41b62329 CC mode use GAIN_AUTO 2020-06-23 11:56:30 +08:00
YiChin ab2eeb7f96 CC mode use GAIN_200R 2020-06-23 11:05:07 +08:00
YiChin bc3106fc26 fix CC mode (not ok) 2020-06-22 11:10:32 +08:00
YiChin f2d404ed60 fix CC mode (not ok) 2020-06-20 16:13:01 +08:00
YiChin 53038c0c84 update BOARDs calibration data. 2020-06-19 18:19:06 +08:00
YiChin b835a0136b update BORAD_CHAO_I calibration data. 2020-06-19 15:41:43 +08:00
YiChin e12102a8a7 update BOARDs calibration data. 2020-06-19 14:50:18 +08:00
YiChin 728b9ae8bf update DEFAULT_DESIRED_CONN_INTERVAL range 8~16 2020-06-19 11:01:49 +08:00
YiChin 9f5a6a09de update RT mode 2020-06-18 17:57:11 +08:00
YiChin d26da674f5 update VT mode 2020-06-18 14:59:11 +08:00
YiChin b781023863 update VT mode 2020-06-18 14:31:06 +08:00
YiChin a42f6441fa update IT mode 2020-06-18 12:07:22 +08:00
YiChin 2c4122bb77 update VO mode 2020-06-18 11:36:11 +08:00
YiChin a05b81a7b4 add CVSCAN_Plot() & CVSCANCurve() 2020-06-17 15:22:34 +08:00
YiChin 2c8cc334e2 add CONSTANT_VSCAN mode instruction 2020-06-17 12:10:25 +08:00
YiChin 59786e995f update BOARD_ANGUS calibration data. 2020-06-16 18:25:58 +08:00
YiChin ebc1d29195 update BOARD_C635 calibration data. 2020-06-16 09:53:26 +08:00
YiChin 2d8d706141 update BOARD_C682 calibration data. 2020-06-15 18:23:10 +08:00
YiChin eb25a2e674 update BOARD_C73D calibration data. 2020-06-15 16:22:23 +08:00
YiChin 241ff38555 update CC mode LED 2020-06-12 18:25:46 +08:00
YiChin 059bc76536 end of LSV&CV3 is cc i =0 2020-06-12 12:12:04 +08:00
YiChin 4678e304ee add LSVCurve() 2020-06-12 12:10:27 +08:00
YiChin db7d1e1141 add LSV_Plot() 2020-06-12 12:07:14 +08:00
YiChin 218997b6b3 add LSV instruction 2020-06-12 11:55:12 +08:00
YiChin f05c37d53e update DEFAULT_DESIRED_CONN_INTERVAL range 8~20 2020-06-12 11:52:24 +08:00
YiChin 90767f36e5 Change BOARD_517 feedback R to 200k, 6.2k, 200R. & update calibration code. 2020-06-12 11:08:15 +08:00
YiChin 81b1ff935a fix cycle I-V cycle 2020-06-09 18:31:50 +08:00
YiChin 0f5f228707 add high cycle CV3 mode 2020-06-08 13:55:08 +08:00
YiChin f0ea8bfcf5 update CV3 unit to 5nv 2020-06-08 11:06:00 +08:00
YiChin a2f0d62819 fix cc mode 2020-06-05 17:03:50 +08:00
YiChin e238d117a9 update cc mode's magnification 2020-06-05 10:30:35 +08:00
YiChin 82dbe82bd1 update calibration code. 2020-06-03 10:34:43 +08:00
Benny Liu 8ba6180c8c update calibration code. 2020-06-02 18:44:49 +08:00
Benny Liu e2d5470b47 update calibration code. 2020-06-02 18:36:30 +08:00
YiChin 2532e703ae Merge branch 'Elite_OBJ_0.2mv_0525_currentAutoGain' into Elite_OBJ_0.2mv
# Conflicts:
#	simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDeviceCorrection.h
#	simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h
2020-06-02 13:56:28 +08:00
Benny Liu 10497683c8 update calibration code. 2020-06-02 13:50:11 +08:00
YiChin 53932d4cb3 fix cc mode switch 2020-06-02 13:20:22 +08:00
YiChin 7b0f5ce687 fix cc mode 2020-06-01 17:06:19 +08:00
YiChin 653c2059e2 fix cc mode 2020-06-01 16:09:32 +08:00
YiChin 5c949be67c IV CV CC mode print Vout 2020-06-01 12:47:39 +08:00
YiChin c73ab1bbd4 add BOARDs calibration data. 2020-05-29 18:23:13 +08:00
YiChin 083cbb0611 cc mode NotifyRate = 100ms 2020-05-29 17:08:11 +08:00
YiChin f998c01010 fix VIS_CC_ZERO 2020-05-29 16:49:22 +08:00
YiChin faf57cba6a BOARD_C666 C77F 7AA3 7A42 calibration data. 2020-05-29 11:47:10 +08:00
YiChin 83b70de310 BOARD_7ACD 7AEC 7C45 7ADE calibration data. 2020-05-29 11:22:36 +08:00
YiChin b4fb63f1e8 fix CC mode 2020-05-29 10:57:35 +08:00
YiChin 832fe1695f fix CC mode 2020-05-28 17:34:55 +08:00
YiChin d6b6b65e5f test CC mode 2020-05-28 15:25:29 +08:00
YiChin 1698f0b544 fix RT ADC 2020-05-27 16:13:24 +08:00
YiChin d10a6d16a8 fix IV & CV2 & CV3 ADC step 2020-05-27 15:34:59 +08:00
YiChin f864acfa26 fix VT ADC 2020-05-27 14:36:51 +08:00
YiChin ba7703a772 fix IT ADC 2020-05-27 14:21:12 +08:00
YiChin b7739ab42d fix cycle-IV cycle 2020-05-27 12:40:29 +08:00
YiChin a6208f00d0 let ADC data right, ADC time must be delay 2020-05-27 12:01:33 +08:00
YiChin c53a2d8872 fix ADCGain 2020-05-26 16:10:26 +08:00
YiChin 9c69e16046 fix ADCGain 2020-05-26 15:19:02 +08:00
YiChin cc57bc47a6 fix ADCGain 2020-05-26 15:07:58 +08:00
YiChin b2b07ae05f fix ADCGain 2020-05-26 11:10:40 +08:00
YiChin fec9ddcdf8 fix ADCGain 2020-05-26 10:46:41 +08:00
YiChin 3eb17d14e6 add ADCGain counter 2020-05-25 18:11:29 +08:00
YiChin 8ca4eb3812 take away if(PreviousGain != INSTRUCTION.ADCGainLevel) 2020-05-25 15:52:38 +08:00
YiChin 8341560686 fix OldStep2NewStepTime() 2020-05-22 15:42:33 +08:00
YiChin 39f39773b8 [test version] 2020-05-22 12:55:34 +08:00
YiChin a01c9b9dc0 [test version] 2020-05-22 12:30:15 +08:00
YiChin 124ca6ea84 send IT data 2020-05-22 11:41:34 +08:00
YiChin befb4f80e2 adjust CV3 & CV & IV DAC 2020-05-22 10:01:10 +08:00
Roy 5a7980dca5 fix CV3 cycle 2020-05-21 21:45:32 +08:00
YiChin 889a3d4147 fix CV3 cycle 2020-05-21 18:01:28 +08:00
YiChin 0245adae4a fix CV cycle 2020-05-21 16:35:29 +08:00
YiChin 8b94eaa6dd test LeadTimeCounter maybe ok 2020-05-21 12:43:53 +08:00
YiChin 323dc2cf77 test LeadTimeCounter 2020-05-21 11:03:21 +08:00
YiChin e89cd406e4 test LeadTimeCounter 2020-05-20 18:24:11 +08:00
YiChin 8de29a213c don't care 2020-05-19 18:24:59 +08:00
YiChin 571edc35aa fix cv mode 2020-05-19 18:17:23 +08:00
YiChin ee04ca568e BOARD_7CC4 calibration data. 2020-05-19 15:26:51 +08:00
YiChin 67ef9adad1 fix flag 2020-05-19 15:17:42 +08:00
YiChin 4ec0bb12f7 add InitEliteGPtimer() 2020-05-19 12:12:35 +08:00
YiChin 5f5921e411 BOARD_7A96 calibration data. 2020-05-18 17:05:21 +08:00
YiChin da6a3f90f9 add ADCflag 2020-05-18 16:56:19 +08:00
YiChin 21135acf32 fix IV mode 2020-05-15 18:22:03 +08:00
YiChin b8e052de0d CV3 cycle number 2020-05-15 12:05:38 +08:00
YiChin cf33bcba2a [515 version] 2020-05-15 11:32:37 +08:00
YiChin 45e7e2d5b7 CV3 send vout data 2020-05-15 09:38:46 +08:00
YiChin 04286e891d BOARD_7C8C calibration data. 2020-05-14 17:56:41 +08:00
YiChin 2e4720c607 fix StepTime 2020-05-14 15:58:36 +08:00
YiChin 5333cd9c98 fix autoGain 2020-05-14 15:51:22 +08:00
YiChin a116cbfa3e fix Steptime 2020-05-14 15:27:36 +08:00
YiChin bae6a4bce3 fix notifytimer 2020-05-14 13:51:02 +08:00
YiChin bc10083c25 fix notifytimer flag 2020-05-14 11:13:13 +08:00
YiChin 6f7cea2590 fix notifytimer 2020-05-14 11:11:35 +08:00
YiChin f3c010ebf8 fix gptimer 2020-05-14 10:21:41 +08:00
YiChin ffbdd27df0 add gptimer counter 2020-05-14 10:19:40 +08:00
YiChin 4f9fb2b8fb Merge branch 'Elite_OBJ_0.2mv_addCV3' into Elite_OBJ_0.2mv 2020-05-14 10:15:58 +08:00
Benny Liu f7d2b168d4 BOARD_CHAO_I calibration data. 2020-05-11 17:26:03 +08:00
YiChin 5a9a3754e7 clear buffer when mdoe done ok 2020-04-30 17:33:23 +08:00
YiChin 97040855af clear buffer when mdoe done 2020-04-30 17:09:46 +08:00
YiChin 77ee73a878 fix DAC 2020-04-30 15:29:57 +08:00
YiChin cbd8f96f60 change ADC step 2020-04-30 15:26:45 +08:00
YiChin 631396c50e add InputNitify() 2020-04-30 15:24:06 +08:00
YiChin d25103373e take away CPUdelay() 2020-04-30 15:17:45 +08:00
YiChin 8ddb66393d [Shipping version]CV3:E1&E2 UI, Enter is cc i=0, show Vscan 2020-04-28 17:14:13 +08:00
YiChin f8d37fcf20 CV3_demo 2020-04-24 18:42:55 +08:00
YiChin a22253e384 CV3 read Vscan, when cc i = 0 2020-04-20 13:39:07 +08:00
YiChin 116d4cfb76 fix VIS_CC_ZERO is CC i=0 ,without VIS_STI 2020-04-17 10:02:14 +08:00
YiChin bd070a4ce8 fix VIS_CC_ZERO is CC i=0 2020-04-16 10:53:24 +08:00
YiChin 5beb62613f VIS_CC_ZERO is CC i=0 (maybe ok) 2020-04-16 10:05:28 +08:00
YiChin e27204bd50 when E1 = E2, PeriodicEvent = false 2020-04-15 10:26:46 +08:00
YiChin 34e9c644c5 take away CV3's direction 2020-04-13 11:32:52 +08:00
YiChin 74d2024731 Vmax & Vmin => E1 & E2 2020-04-10 14:53:46 +08:00
YiChin 7615f141ef VIS_CC_ZERO is Vout = 1V 2020-04-09 16:20:08 +08:00
YiChin 38a45cdb1d CV3 2020-04-09 16:16:45 +08:00
YiChin 9623751337 CV3 instruction 2020-04-09 15:51:10 +08:00
YiChin dbf25c5712 take away READ_VOUT_VALUE instruction 2020-04-09 15:42:40 +08:00
yichin 7b2a51ee24 update cali script 2020-03-16 12:39:08 +08:00
yichin bf57c10785 update cali script 2020-03-16 12:06:07 +08:00
yichin 854e82a198 update cali script 2020-03-16 10:45:57 +08:00
yichin 3107807268 update cali script 2020-03-16 10:41:15 +08:00
YiChin dff6c0a9e2 modify RT 2020-03-11 13:52:35 +08:00
royluo 8480f60266 update version script 2020-03-11 12:00:27 +08:00
YiChin 8808490caa modify device information 2020-03-09 09:47:14 +08:00
47 changed files with 7386 additions and 4757 deletions
+2 -1
View File
@@ -5,4 +5,5 @@ xdctools_*/
ccsv8/
# CSS build files
FlashROM/
FlashROM/
/simplelink/ble_sdk_2_02_02_25/examples/cc2650em/simple_central/ccs/app/.xdchelp
Executable
+39
View File
@@ -0,0 +1,39 @@
#!/bin/bash
#path=$(pwd)
#folder=$($path | awk -F"/" '{$NF}')
folder=$(basename "$(pwd)")
if [ "$folder" == "bioprocc2650" ]; then
year=$(date +%-y)
month=$(date +%-m)
day=$(date +%-d)
hour=$(date +%-H)
minute=$(date +%-M)
hash=$(git rev-parse HEAD)
branch=$(git rev-parse --abbrev-ref HEAD)
sed -i "5c #define VERSION_DATE_YEAR ${year}"\
./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h
sed -i "6c #define VERSION_DATE_MONTH ${month}"\
./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h
sed -i "7c #define VERSION_DATE_DAY ${day}"\
./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h
sed -i "8c #define VERSION_DATE_HOUR ${hour}"\
./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h
sed -i "9c #define VERSION_DATE_MINUTE ${minute}"\
./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h
sed -i "13c #define VERSION_HASH ${hash}"\
./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h
sed -i "14c #define VERSION_GIT_BRANCH ${branch}"\
./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h
#cat ./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h
fi
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
inEditor=false
onBuild=false
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.cdt.debug.core.toggleBreakpointModel=com.ti.ccstudio.debug.CCSBreakpointMarker
@@ -0,0 +1,32 @@
eclipse.preferences.version=1
encoding//FlashROM/Application/subdir_rules.mk=UTF-8
encoding//FlashROM/Application/subdir_vars.mk=UTF-8
encoding//FlashROM/Drivers/Display/subdir_rules.mk=UTF-8
encoding//FlashROM/Drivers/Display/subdir_vars.mk=UTF-8
encoding//FlashROM/Drivers/ECC/subdir_rules.mk=UTF-8
encoding//FlashROM/Drivers/ECC/subdir_vars.mk=UTF-8
encoding//FlashROM/Drivers/PIN/subdir_rules.mk=UTF-8
encoding//FlashROM/Drivers/PIN/subdir_vars.mk=UTF-8
encoding//FlashROM/Drivers/RF/subdir_rules.mk=UTF-8
encoding//FlashROM/Drivers/RF/subdir_vars.mk=UTF-8
encoding//FlashROM/Drivers/SPI/subdir_rules.mk=UTF-8
encoding//FlashROM/Drivers/SPI/subdir_vars.mk=UTF-8
encoding//FlashROM/Drivers/TRNG/subdir_rules.mk=UTF-8
encoding//FlashROM/Drivers/TRNG/subdir_vars.mk=UTF-8
encoding//FlashROM/Drivers/UART/subdir_rules.mk=UTF-8
encoding//FlashROM/Drivers/UART/subdir_vars.mk=UTF-8
encoding//FlashROM/Drivers/UDMA/subdir_rules.mk=UTF-8
encoding//FlashROM/Drivers/UDMA/subdir_vars.mk=UTF-8
encoding//FlashROM/ICall/subdir_rules.mk=UTF-8
encoding//FlashROM/ICall/subdir_vars.mk=UTF-8
encoding//FlashROM/ICallBLE/subdir_rules.mk=UTF-8
encoding//FlashROM/ICallBLE/subdir_vars.mk=UTF-8
encoding//FlashROM/PROFILES/subdir_rules.mk=UTF-8
encoding//FlashROM/PROFILES/subdir_vars.mk=UTF-8
encoding//FlashROM/Startup/subdir_rules.mk=UTF-8
encoding//FlashROM/Startup/subdir_vars.mk=UTF-8
encoding//FlashROM/TOOLS/subdir_rules.mk=UTF-8
encoding//FlashROM/TOOLS/subdir_vars.mk=UTF-8
encoding//FlashROM/makefile=UTF-8
encoding//FlashROM/objects.mk=UTF-8
encoding//FlashROM/sources.mk=UTF-8
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
inEditor=false
onBuild=false
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.cdt.debug.core.toggleBreakpointModel=com.ti.ccstudio.debug.CCSBreakpointMarker
@@ -18,8 +18,8 @@
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="out" artifactName="${ProjName}" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" errorParsers="org.eclipse.rtsc.xdctools.parsers.ErrorParser;com.ti.rtsc.XDCtools.parsers.ErrorParser;com.ti.ccstudio.errorparser.CoffErrorParser;com.ti.ccstudio.errorparser.LinkErrorParser;com.ti.ccstudio.errorparser.AsmErrorParser;org.eclipse.cdt.core.GmakeErrorParser" id="com.ti.ccstudio.buildDefinitions.TMS470.Default.67178137" name="FlashROM" parent="com.ti.ccstudio.buildDefinitions.TMS470.Default" postbuildStep="${CG_TOOL_HEX} -order MS --memwidth=8 --romwidth=8 --intel -o ${ProjName}.hex ${ProjName}.out" prebuildStep="">
<folderInfo id="com.ti.ccstudio.buildDefinitions.TMS470.Default.67178137." name="/" resourcePath="">
<toolChain id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.DebugToolchain.1369151231" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.linkerDebug.223507680">
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.732777020" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">
<toolChain id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.DebugToolchain.410623502" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.linkerDebug.1351821865">
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.1751124300" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">
<listOptionValue builtIn="false" value="DEVICE_CONFIGURATION_ID=Cortex M.CC2650F128"/>
<listOptionValue builtIn="false" value="DEVICE_ENDIANNESS=little"/>
<listOptionValue builtIn="false" value="OUTPUT_FORMAT=ELF"/>
@@ -34,17 +34,17 @@
<listOptionValue builtIn="false" value="LINK_ORDER=TOOLS/ccs_linker_defines.cmd;TOOLS/cc26xx_app.cmd;"/>
<listOptionValue builtIn="false" value="RTSC_MBS_VERSION=2.2.0"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.579299287" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="18.1.4.LTS" valueType="string"/>
<targetPlatform id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.targetPlatformDebug.2112816025" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.targetPlatformDebug"/>
<builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.builderDebug.1418617668" name="GNU Make.FlashROM" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.builderDebug"/>
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.compilerDebug.1368914557" name="ARM Compiler" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.compilerDebug">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.SILICON_VERSION.872349905" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.SILICON_VERSION" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.SILICON_VERSION.7M3" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CODE_STATE.1023813954" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CODE_STATE" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CODE_STATE.16" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.ABI.1674413144" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.ABI" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.ABI.eabi" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.LITTLE_ENDIAN.184317276" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.LITTLE_ENDIAN" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_LEVEL.1068578615" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_LEVEL" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_LEVEL.4" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_FOR_SPEED.1943600764" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_FOR_SPEED" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_FOR_SPEED.0" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.INCLUDE_PATH.644525479" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.INCLUDE_PATH" valueType="includePath">
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.277675815" name="Compiler version" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="18.1.4.LTS" valueType="string"/>
<targetPlatform id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.targetPlatformDebug.1593934674" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.targetPlatformDebug"/>
<builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.builderDebug.632414212" keepEnvironmentInBuildfile="false" name="GNU Make" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.builderDebug"/>
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.compilerDebug.154623462" name="ARM Compiler" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.compilerDebug">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.SILICON_VERSION.974280107" name="Target processor version (--silicon_version, -mv)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.SILICON_VERSION" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.SILICON_VERSION.7M3" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CODE_STATE.1783826131" name="Designate code state, 16-bit (thumb) or 32-bit (--code_state)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CODE_STATE" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CODE_STATE.16" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.ABI.1536570599" name="Application binary interface. (--abi)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.ABI" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.ABI.eabi" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.LITTLE_ENDIAN.1895413316" name="Little endian code [See 'General' page to edit] (--little_endian, -me)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.LITTLE_ENDIAN" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_LEVEL.322983319" name="Optimization level (--opt_level, -O)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_LEVEL" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_LEVEL.4" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_FOR_SPEED.1305400753" name="Speed vs. size trade-offs (--opt_for_speed, -mf)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_FOR_SPEED" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.OPT_FOR_SPEED.0" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.INCLUDE_PATH.1468985930" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.INCLUDE_PATH" valueType="includePath">
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/include"/>
<listOptionValue builtIn="false" value="C:\ti\simplelink\ble_sdk_2_02_02_25\src\examples\simple_peripheral\cc26xx\app\headstage"/>
<listOptionValue builtIn="false" value="${SRC_EX}/examples/simple_peripheral/cc26xx/app"/>
@@ -70,7 +70,7 @@
<listOptionValue builtIn="false" value="${SRC_BLE_CORE}/rom"/>
<listOptionValue builtIn="false" value="${CC26XXWARE}"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEFINE.1330623088" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEFINE" valueType="definedSymbols">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEFINE.1897088" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEFINE" valueType="definedSymbols">
<listOptionValue builtIn="false" value="BOARD_DISPLAY_EXCLUDE_UART"/>
<listOptionValue builtIn="false" value="POWER_SAVING"/>
<listOptionValue builtIn="false" value="BOOSTXL_CC2650MA"/>
@@ -86,71 +86,71 @@
<listOptionValue builtIn="false" value="xdc_runtime_Assert_DISABLE_ALL"/>
<listOptionValue builtIn="false" value="xdc_runtime_Log_DISABLE_ALL"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEBUGGING_MODEL.1308360247" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.C_DIALECT.504235202" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.C_DIALECT" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.C_DIALECT.C99" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GCC.105967788" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GCC" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_SUPPRESS.698913237" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_SUPPRESS" valueType="stringList">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEBUGGING_MODEL.871011287" name="Debugging model" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.C_DIALECT.863089168" name="C Dialect" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.C_DIALECT" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.C_DIALECT.C99" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GCC.1454248503" name="Enable support for GCC extensions (DEPRECATED) (--gcc)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GCC" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_SUPPRESS.1965115059" name="Suppress diagnostic &lt;id&gt; (--diag_suppress, -pds)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_SUPPRESS" valueType="stringList">
<listOptionValue builtIn="false" value="48"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WARNING.1399241416" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WARNING" valueType="stringList">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WARNING.1638011093" name="Treat diagnostic &lt;id&gt; as warning (--diag_warning, -pdsw)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WARNING" valueType="stringList">
<listOptionValue builtIn="false" value="225"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WRAP.867926379" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WRAP.off" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DISPLAY_ERROR_NUMBER.980626282" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GEN_FUNC_SUBSECTIONS.374992114" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GEN_FUNC_SUBSECTIONS" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GEN_FUNC_SUBSECTIONS.on" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CMD_FILE.1890491357" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CMD_FILE" valueType="stringList">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WRAP.1920170652" name="Wrap diagnostic messages (--diag_wrap)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DIAG_WRAP.off" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DISPLAY_ERROR_NUMBER.2038786257" name="Emit diagnostic identifier numbers (--display_error_number, -pden)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GEN_FUNC_SUBSECTIONS.811478344" name="Place each function in a separate subsection (--gen_func_subsections, -ms)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GEN_FUNC_SUBSECTIONS" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.GEN_FUNC_SUBSECTIONS.on" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CMD_FILE.1229809338" name="Read options from specified file (--cmd_file, -@)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compilerID.CMD_FILE" valueType="stringList">
<listOptionValue builtIn="false" value="${SRC_EX}/config/build_components.opt"/>
<listOptionValue builtIn="false" value="${ORG_PROJ_DIR}/build_config.opt"/>
<listOptionValue builtIn="false" value="${ORG_PROJ_DIR}/../../ccs/config/ccs_compiler_defines.bcfg"/>
</option>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__C_SRCS.263445006" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__C_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__CPP_SRCS.1235873701" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__CPP_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__ASM_SRCS.207268648" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__ASM_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__ASM2_SRCS.1068957263" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__ASM2_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__C_SRCS.1540775079" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__C_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__CPP_SRCS.319000695" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__CPP_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__ASM_SRCS.270651019" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__ASM_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__ASM2_SRCS.463094612" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.compiler.inputType__ASM2_SRCS"/>
</tool>
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.linkerDebug.223507680" name="ARM Linker" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.linkerDebug">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.STACK_SIZE.698430423" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.STACK_SIZE" value="256" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.HEAP_SIZE.402182782" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.HEAP_SIZE" value="0" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.MAP_FILE.1628689699" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.MAP_FILE" value="&quot;${ProjName}.map&quot;" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.OUTPUT_FILE.2141951901" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.OUTPUT_FILE" value="${ProjName}.out" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.LIBRARY.679112687" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.LIBRARY" valueType="libs">
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.linkerDebug.1351821865" name="ARM Linker" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exe.linkerDebug">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.STACK_SIZE.174129193" name="Set C system stack size (--stack_size, -stack)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.STACK_SIZE" value="256" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.HEAP_SIZE.567300083" name="Heap size for C/C++ dynamic memory allocation (--heap_size, -heap)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.HEAP_SIZE" value="0" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.MAP_FILE.1800982811" name="Link information (map) listed into &lt;file&gt; (--map_file, -m)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.MAP_FILE" value="&quot;${ProjName}.map&quot;" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.OUTPUT_FILE.1091211742" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.OUTPUT_FILE" value="${ProjName}.out" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.LIBRARY.1479599481" name="Include library file or command file as input (--library, -l)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.LIBRARY" valueType="libs">
<listOptionValue builtIn="false" value="libc.a"/>
<listOptionValue builtIn="false" value="${CC26XXWARE}/driverlib/bin/ccs/driverlib.lib"/>
<listOptionValue builtIn="false" value="${ROM}/common_rom_releases/03282014/common_rom.symbols"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.SEARCH_PATH.650613345" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.SEARCH_PATH" valueType="libPaths">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.SEARCH_PATH.672837228" name="Add &lt;dir&gt; to library search path (--search_path, -i)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.SEARCH_PATH" valueType="libPaths">
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/lib"/>
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/include"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_SUPPRESS.782343525" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_SUPPRESS" valueType="stringList">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_SUPPRESS.544523272" name="Suppress diagnostic &lt;id&gt; (--diag_suppress)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_SUPPRESS" valueType="stringList">
<listOptionValue builtIn="false" value="10247-D"/>
<listOptionValue builtIn="false" value="16002-D"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_WRAP.1555270082" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_WRAP.off" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DISPLAY_ERROR_NUMBER.16105060" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.XML_LINK_INFO.1713299511" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.XML_LINK_INFO" value="&quot;${ProjName}_linkInfo.xml&quot;" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.COMPRESS_DWARF.68776981" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.COMPRESS_DWARF" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.COMPRESS_DWARF.on" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.UNUSED_SECTION_ELIMINATION.1860389255" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.UNUSED_SECTION_ELIMINATION" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.UNUSED_SECTION_ELIMINATION.on" valueType="enumerated"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__CMD_SRCS.152379533" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__CMD_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__CMD2_SRCS.158095632" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__CMD2_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__GEN_CMDS.978853236" name="Generated Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__GEN_CMDS"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_WRAP.1281207998" name="Wrap diagnostic messages (--diag_wrap)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DIAG_WRAP.off" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DISPLAY_ERROR_NUMBER.468817864" name="Emit diagnostic identifier numbers (--display_error_number)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.XML_LINK_INFO.1679096029" name="Detailed link information data-base into &lt;file&gt; (--xml_link_info, -xml_link_info)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.XML_LINK_INFO" value="&quot;${ProjName}_linkInfo.xml&quot;" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.COMPRESS_DWARF.254835397" name="Aggressively reduce size of the DWARF information (--compress_dwarf)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.COMPRESS_DWARF" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.COMPRESS_DWARF.on" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.UNUSED_SECTION_ELIMINATION.1848192295" name="Eliminate sections not needed in the executable (--unused_section_elimination)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.UNUSED_SECTION_ELIMINATION" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.linkerID.UNUSED_SECTION_ELIMINATION.on" valueType="enumerated"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__CMD_SRCS.1999849945" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__CMD_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__CMD2_SRCS.25027104" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__CMD2_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__GEN_CMDS.888093741" name="Generated Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.exeLinker.inputType__GEN_CMDS"/>
</tool>
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.2015106526" name="ARM Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.ROMWIDTH.1270425102" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.ROMWIDTH" value="8" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.MEMWIDTH.16813235" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.MEMWIDTH" value="8" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.OUTPUT_FORMAT.318851558" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.OUTPUT_FORMAT" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.OUTPUT_FORMAT.INTEL" valueType="enumerated"/>
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.19288898" name="ARM Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.ROMWIDTH.11734737" name="Specify rom width (--romwidth, -romwidth=width)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.ROMWIDTH" value="8" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.MEMWIDTH.466140455" name="Specify memory width (--memwidth, -memwidth=width)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.MEMWIDTH" value="8" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.OUTPUT_FORMAT.824070691" name="Output format" superClass="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.OUTPUT_FORMAT" value="com.ti.ccstudio.buildDefinitions.TMS470_18.1.hex.OUTPUT_FORMAT.INTEL" valueType="enumerated"/>
</tool>
<tool id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.927640565" name="XDCtools" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool">
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.XDC_PATH.1908494509" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.XDC_PATH" valueType="stringList">
<tool id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.1392704063" name="XDCtools" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool">
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.XDC_PATH.225737408" name="Package repositories (--xdcpath)" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.XDC_PATH" valueType="stringList">
<listOptionValue builtIn="false" value="${COM_TI_RTSC_TIRTOSCC13XX_CC26XX_REPOS}"/>
<listOptionValue builtIn="false" value="${TARGET_CONTENT_BASE}"/>
</option>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.TARGET.1746187707" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.TARGET" value="ti.targets.arm.elf.M3" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM.884959194" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM" value="ti.platforms.simplelink:CC2640F128" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM_RAW.943624305" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM_RAW" value="ti.platforms.simplelink:CC2640F128" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.BUILD_PROFILE.1521167272" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.BUILD_PROFILE" value="release" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.CODEGEN_TOOL_DIR.1901654533" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.CODEGEN_TOOL_DIR" value="${CG_TOOL_ROOT}" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.COMPILE_OPTIONS.138005453" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.COMPILE_OPTIONS" value="&quot;${COMPILER_FLAGS}&quot;" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.TARGET.571281110" name="Target (-t)" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.TARGET" value="ti.targets.arm.elf.M3" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM.205178830" name="Platform (-p)" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM" value="ti.platforms.simplelink:CC2640F128" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM_RAW.1097777495" name="Platform (-p)" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.PLATFORM_RAW" value="ti.platforms.simplelink:CC2640F128" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.BUILD_PROFILE.744121344" name="Build-profile (-r)" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.BUILD_PROFILE" value="release" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.CODEGEN_TOOL_DIR.165807018" name="Compiler tools directory (-c)" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.CODEGEN_TOOL_DIR" value="${CG_TOOL_ROOT}" valueType="string"/>
<option id="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.COMPILE_OPTIONS.391961861" name="Additional compiler options (--compileOptions)" superClass="com.ti.rtsc.buildDefinitions.XDC_3.16.tool.COMPILE_OPTIONS" value="&quot;${COMPILER_FLAGS}&quot;" valueType="string"/>
</tool>
</toolChain>
</folderInfo>
@@ -3,16 +3,20 @@
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot; ?&gt;&#10;&lt;PropertyValues&gt;&#10;&#10; &lt;property id=&quot;ConnectOnStartup&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;EnableInstalledBreakpoint&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;IgnoreSoftLaunchFailures&quot;&gt;&#10; &lt;curValue&gt;0&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10;&lt;/PropertyValues&gt;&#10;"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot; ?&gt;&#10;&lt;PropertyValues&gt;&#10;&#10; &lt;property id=&quot;ConnectOnStartup&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;EnableInstalledBreakpoint&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;IgnoreSoftLaunchFailures&quot;&gt;&#10; &lt;curValue&gt;0&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10;&lt;/PropertyValues&gt;&#10;"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot; ?&gt;&#10;&lt;PropertyValues&gt;&#10;&#10; &lt;property id=&quot;ConnectOnStartup&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;EnableInstalledBreakpoint&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;IgnoreSoftLaunchFailures&quot;&gt;&#10; &lt;curValue&gt;0&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10;&lt;/PropertyValues&gt;&#10;"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot; ?&gt;&#10;&lt;PropertyValues&gt;&#10;&#10; &lt;property id=&quot;ConnectOnStartup&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;EnableInstalledBreakpoint&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;IgnoreSoftLaunchFailures&quot;&gt;&#10; &lt;curValue&gt;0&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10;&lt;/PropertyValues&gt;&#10;"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="${build_artifact:simple_peripheral_cc2650em_app}"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="simple_peripheral_cc2650em_app"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_TARGET_CONFIG" value="${target_config_active_default:simple_peripheral_cc2650em_app}"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS100v3 USB Debug Probe_0/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\targetConfigs\CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="C:/ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.CC2650F128.ccxml.Texas Instruments XDS110 USB Debug Probe_0/Cortex_M3_0" value="C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\app\FlashROM\simple_peripheral_cc2650em_app.out"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/simple_peripheral_cc2650em_app"/>
</listAttribute>
@@ -0,0 +1,246 @@
#ifndef Elite15_PIN
#define Elite_15PIN
#include "Elite_PIN.h"
static void update_latch_status (uint32_t latch_num, uint32_t elite_pin, bool highlow) {
switch (latch_num) {
case LOAD0: {
switch (elite_pin) {
case D0: {
LH.LATCH0[0] = highlow;
break;
}
case D1: {
LH.LATCH0[1] = highlow;
break;
}
case D2: {
LH.LATCH0[2] = highlow;
break;
}
case D3: {
LH.LATCH0[3] = highlow;
break;
}
case D4: {
LH.LATCH0[4] = highlow;
break;
}
case D5: {
LH.LATCH0[5] = highlow;
break;
}
case D6: {
LH.LATCH0[6] = highlow;
break;
}
case D7: {
LH.LATCH0[7] = highlow;
break;
}
default: {
break;
}
}
break;
}
case LOAD1: {
switch (elite_pin) {
case D0: {
LH.LATCH1[0] = highlow;
break;
}
case D1: {
LH.LATCH1[1] = highlow;
break;
}
case D2: {
LH.LATCH1[2] = highlow;
break;
}
case D3: {
LH.LATCH1[3] = highlow;
break;
}
case D4: {
LH.LATCH1[4] = highlow;
break;
}
case D5: {
LH.LATCH1[5] = highlow;
break;
}
case D6: {
LH.LATCH1[6] = highlow;
break;
}
case D7: {
LH.LATCH1[7] = highlow;
break;
}
default: {
break;
}
}
break;
}
case LOAD2: {
switch (elite_pin) {
case D0: {
LH.LATCH2[0] = highlow;
break;
}
case D1: {
LH.LATCH2[1] = highlow;
break;
}
case D2: {
LH.LATCH2[2] = highlow;
break;
}
case D3: {
LH.LATCH2[3] = highlow;
break;
}
case D4: {
LH.LATCH2[4] = highlow;
break;
}
case D5: {
LH.LATCH2[5] = highlow;
break;
}
case D6: {
LH.LATCH2[6] = highlow;
break;
}
case D7: {
LH.LATCH2[7] = highlow;
break;
}
default: {
break;
}
}
break;
}
default: {
break;
}
}
}
static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow) {
ELITE15_SPI_CLOSE();
add_elite_pin();
update_latch_status (latch_num, pin_num, highlow);
// PIN_setOutputValue(&ZM_rst, latch_num, 1); // Turn on latch
switch (latch_num) {
case LOAD0: {
// PIN_setOutputValue(&ZM_rst, D0, LH.LATCH0[0]);
// PIN_setOutputValue(&ZM_rst, D1, LH.LATCH0[1]);
// PIN_setOutputValue(&ZM_rst, D2, LH.LATCH0[2]);
// PIN_setOutputValue(&ZM_rst, D3, LH.LATCH0[3]);
PIN_setOutputValue(pin_handle, D4, LH.LATCH0[4]);
PIN_setOutputValue(pin_handle, D5, LH.LATCH0[5]);
PIN_setOutputValue(pin_handle, D6, LH.LATCH0[6]);
PIN_setOutputValue(pin_handle, D7, LH.LATCH0[7]);
break;
}
case LOAD1: {
PIN_setOutputValue(pin_handle, D0, LH.LATCH1[0]);
PIN_setOutputValue(pin_handle, D1, LH.LATCH1[1]);
PIN_setOutputValue(pin_handle, D2, LH.LATCH1[2]);
PIN_setOutputValue(pin_handle, D3, LH.LATCH1[3]);
PIN_setOutputValue(pin_handle, D4, LH.LATCH1[4]);
PIN_setOutputValue(pin_handle, D5, LH.LATCH1[5]);
PIN_setOutputValue(pin_handle, D6, LH.LATCH1[6]);
PIN_setOutputValue(pin_handle, D7, LH.LATCH1[7]);
break;
}
case LOAD2: {
PIN_setOutputValue(pin_handle, D0, LH.LATCH2[0]);
PIN_setOutputValue(pin_handle, D1, LH.LATCH2[1]);
PIN_setOutputValue(pin_handle, D2, LH.LATCH2[2]);
PIN_setOutputValue(pin_handle, D3, LH.LATCH2[3]);
PIN_setOutputValue(pin_handle, D4, LH.LATCH2[4]);
PIN_setOutputValue(pin_handle, D5, LH.LATCH2[5]);
PIN_setOutputValue(pin_handle, D6, LH.LATCH2[6]);
PIN_setOutputValue(pin_handle, D7, LH.LATCH2[7]);
break;
}
default: {
break;
}
}
PIN_setOutputValue(&ZM_rst, latch_num, 1); // Turn on latch
// CPUdelay(10);
PIN_setOutputValue(&ZM_rst, latch_num, 0); // Turn off latch
remove_elite_pin();
ELITE15_SPI_HOLD();
}
static void Init_Elite15_PIN () {
InitLH();
add_elite_pin();
PIN_setOutputValue(pin_handle, D0, 0);
PIN_setOutputValue(pin_handle, D1, 0);
PIN_setOutputValue(pin_handle, D2, 0);
PIN_setOutputValue(pin_handle, D3, 0);
PIN_setOutputValue(pin_handle, D4, 0);
PIN_setOutputValue(pin_handle, D5, 0);
PIN_setOutputValue(pin_handle, D6, 0);
PIN_setOutputValue(pin_handle, D7, 0);
PIN_setOutputValue(pin_handle, LOAD0, 0);
PIN_setOutputValue(pin_handle, LOAD1, 1);
PIN_setOutputValue(pin_handle, LOAD2, 1);
CPUdelay(10);
PIN_setOutputValue(pin_handle, LOAD1, 0);
PIN_setOutputValue(pin_handle, LOAD2, 0);
PIN_setOutputValue(pin_handle, D0, 0);
PIN_setOutputValue(pin_handle, D1, 0);
PIN_setOutputValue(pin_handle, D2, 0);
PIN_setOutputValue(pin_handle, D3, 0);
PIN_setOutputValue(pin_handle, D4, 1);
PIN_setOutputValue(pin_handle, D5, 1);
PIN_setOutputValue(pin_handle, D6, 1);
PIN_setOutputValue(pin_handle, D7, 1);
CPUdelay(10);
PIN_setOutputValue(pin_handle, LOAD0, 1);
PIN_setOutputValue(pin_handle, LOAD0, 0);
remove_elite_pin();
// InitLH();
// add_elite_pin();
//
// PIN_setOutputValue(pin_handle, LOAD0, 1);
// PIN_setOutputValue(pin_handle, LOAD1, 1);
// PIN_setOutputValue(pin_handle, LOAD2, 1);
// CPUdelay(10);
// PIN_setOutputValue(pin_handle, D0, 0);
// PIN_setOutputValue(pin_handle, D1, 0);
// PIN_setOutputValue(pin_handle, D2, 0);
// PIN_setOutputValue(pin_handle, D3, 0);
// PIN_setOutputValue(pin_handle, D4, 0);
// PIN_setOutputValue(pin_handle, D5, 0);
// PIN_setOutputValue(pin_handle, D6, 0);
// PIN_setOutputValue(pin_handle, D7, 0);
// CPUdelay(10);
// PIN_setOutputValue(pin_handle, LOAD0, 0);
// PIN_setOutputValue(pin_handle, LOAD1, 0);
// PIN_setOutputValue(pin_handle, LOAD2, 0);
//
// remove_elite_pin();
}
#endif
@@ -1,27 +1,65 @@
/*=============================================================================
= EliteADC.h =
=============================================================================*/
#ifndef EliteADC
#define EliteADC
#include "Elite_PIN.h"
#include "EliteSPI.h"
#include "EliteNotify.h"
// Elite ADC macro
// ADC command, Elite will use these cmd to control ADC
#define CMD_CURRENT_MEASURE 0xC5
#define CMD_VOLT_MEASURE 0xD5
#define CMD_DAC_MEASURE 0xE5
#define CMD_BATTERY_MEASURE 0xF5
#define CMD_BATTERY_MEASURE 0xF1
// controller command, these are command from control box
#define ADC_CH_CURRENT 0x00
#define ADC_CH_VOLT 0x01
#define ADC_CH_DAC 0x02
#define ADC_CH_CURR 0x00
#define ADC_CH_VIN 0x01
#define ADC_CH_VOUT 0x02
#define ADC_CH_BAT 0x03
static void ADC_write(uint8_t ADCin) {
/* for Elite1.5-re */
// Iin theoretical boundary <2.67, 1.89~80, 63~2600, >1900 (uA)
#define I_GAIN_SMALL_BOUNDARY 4000 // 4 uA = 4,000,000 pA
#define I_GAIN_MID1_BOUNDARY1 2500 // 2.5 uA = 2,500,000 pA
#define I_GAIN_MID1_BOUNDARY2 100000 // 100 uA = 100,000,000 pA
#define I_GAIN_MID2_BOUNDARY1 85000 // 85 uA = 85,000,000 pA
#define I_GAIN_MID2_BOUNDARY2 2050000 // 2050 uA = 2,050,000 nA
#define I_GAIN_LARGE_BOUNDARY 1800000 // 1800 uA = 1,800,000 nA
// Vin theoretical boundary <7, 5~200, >100 (mV)
#define VIN_GAIN_SMALL_BOUNDARY 7000 // 7 mV = 7,000,000 nV
#define VIN_GAIN_MID1_BOUNDARY1 5000 // 5 mV = 5,000,000 nV
#define VIN_GAIN_MID1_BOUNDARY2 300000 // 300 mV = 300,000,000 nV
#define VIN_GAIN_LARGE_BOUNDARY 250000 // 250 mV = 250,000,000 nV
/*
* skip damping times in Iin channel
* 0 switch to 1 level has 5ms damping
* higher switch to 0 level has 80ms damping
*/
#define CNT_H2L_IIN_VIN_VOUT_PLOT 6 // need skip 9 * 9ms = 81ms notify data //skip 50ms
#define CNT_L2H_IIN_VIN_VOUT_PLOT 1 // need skip 1 * 9ms = 9ms notify data
#define CNT_H2L_IIN_VIN_PLOT 9 // 14 * 6ms = 84ms
#define CNT_L2H_IIN_VIN_PLOT 1 // 1 * 6ms = 6ms
#define CNT_H2L_IT_PLOT 17 // 27 * 3ms = 81ms
#define CNT_L2H_IT_PLOT 2 // 2 * 3ms = 6ms
void IinADCGainCtrl(uint8_t IinADCLevel);
void VinADCGainCtrl(uint8_t VinADCLevel);
void read_adc_raw_data(uint8_t AdcChannel, uint8_t *rxbuf, uint8_t *txbuf);
void AutoGainChangeIin(int32_t RealCurrent, uint16_t plot_type, uint16_t *no_rec_time);
void AutoGainChangeVin(int32_t RealVin);
/*=============================================================================
= EliteADC.c =
=============================================================================*/
static void __ADC_write(uint8_t ADCin, uint8_t *rxbuf, uint8_t *txbuf)
{
/*
* write SPI to get ADC value
* This function can only define [15]~[8] through ADCin
* [7]~[0] should always be 0b11101011
*
@@ -37,305 +75,604 @@ static void ADC_write(uint8_t ADCin) {
* [0] : reserved, default 0b1
*
*/
uint8_t *rx = rxbuf;
uint8_t *tx = txbuf;
// tx[0] = 0b00000101;
for (int i=0; i<SPI_ADC_SIZE; i++) {
tx[i] = 0;
rx[i] = 0;
// spi_ADC_txbuf[0] = 0b00000101;
for(int i=0 ; i<SPI_ADC_SIZE ; i++){
spi_ADC_txbuf[i] = 0;
spi_ADC_rxbuf[i] = 0;
}
spi_ADC_txbuf[0] = ADCin;
spi_ADC_txbuf[1] = 0b11101011;
tx[0] = ADCin;
tx[1] = 0b11101011;
ADC_SPI(2, tx, rx);
ADC_SPI(2, spi_ADC_txbuf, spi_ADC_rxbuf);
return;
}
static void ADC_read(uint8_t *ADCdata){
for(int i=0 ; i<SPI_ADC_SIZE ; i++){
spi_ADC_txbuf[i] = 0;
spi_ADC_rxbuf[i] = 0;
static void __ADC_read(uint8_t *rxbuf, uint8_t *txbuf)
{
/*
* read SPI to get ADC value
*/
uint8_t *rx = rxbuf;
uint8_t *tx = txbuf;
for (int i=0; i<SPI_ADC_SIZE; i++) {
tx[i] = 0;
rx[i] = 0;
}
ADC_SPI(SPI_ADC_SIZE, spi_ADC_txbuf, ADCdata);
ADC_SPI(2, tx, rx);
return;
}
static void ADCGainControl(uint8_t ADCLevel){
if(ADCLevel == 0){
// ADC gain level = 0, using 200K resister
PIN_setOutputValue(pin_handle, Turnon10K, 0);
PIN_setOutputValue(pin_handle, Turnon200R, 0);
}
else if(ADCLevel == 1){
// ADC gain level = 1, using 10K resister
PIN_setOutputValue(pin_handle, Turnon10K, 1);
PIN_setOutputValue(pin_handle, Turnon200R, 0);
}
else if(ADCLevel == 2){
// ADC gain level = 2, using 200R resister
PIN_setOutputValue(pin_handle, Turnon10K, 0);
PIN_setOutputValue(pin_handle, Turnon200R, 1);
}
else if(ADCLevel == 3){
// ADC gain level = 0, auto gain (using 200R resister)
PIN_setOutputValue(pin_handle, Turnon10K, 0);
PIN_setOutputValue(pin_handle, Turnon200R, 1);
}
else{
// default using 200R resister
PIN_setOutputValue(pin_handle, Turnon10K, 0);
PIN_setOutputValue(pin_handle, Turnon200R, 1);
static void __ADC_ch_sel(uint8_t AdcChannel, uint8_t *rxbuf, uint8_t *txbuf)
{
/*
* choise ADC channel to write
*
* set ADC parameter
* 0xC1~F1 = reading AIN0~AIN3. Using FSR+-6V, resolution = 187.5uV
* 0xC5~F5 = reading AIN0~AIN3. Using FSR+-2V, resolution = 62.5 uV
*
* ADCChannel == ADC_CH_CURR: - AINp is AIN0; AINn is GND
* - measure AIN0, which is a current measure
* == ADC_CH_VIN: - AINp is AIN1; AINn is GND
* - AIN1, which is a volt measure
* == ADC_CH_VOUT: - AINp is AIN2; AINn is GND
* - AIN2, measure DAC voltage (Note that this is NOT DAC real output value!!)
* == ADC_CH_BAT: - measure battery volt
*
*/
uint8_t ch = AdcChannel;
uint8_t *rx = rxbuf;
uint8_t *tx = txbuf;
switch (ch) {
case ADC_CH_CURR:
__ADC_write(CMD_CURRENT_MEASURE, rx, tx);
break;
case ADC_CH_VIN:
__ADC_write(CMD_VOLT_MEASURE, rx, tx);
break;
case ADC_CH_VOUT:
__ADC_write(CMD_DAC_MEASURE, rx, tx);
break;
case ADC_CH_BAT:
__ADC_write(CMD_BATTERY_MEASURE, rx, tx);
break;
default:
break;
}
return;
}
static void __read_ADC_value(uint8_t AdcChannel, uint8_t *rxbuf, uint8_t *txbuf)
{
uint8_t ch = AdcChannel;
uint8_t *rx = rxbuf;
uint8_t *tx = txbuf;
static void ADCChannelSelect(uint8_t ADCChannel){
// set ADC parameter
// 0xC1~F1 = reading AIN0~AIN3. Using FSR+-6V, resolution = 187.5uV
// 0xC5~F5 = reading AIN0~AIN3. Using FSR+-2V, resolution = 62.5 uV
switch(ADCChannel){
// AINp is AIN0; AINn is GND
// measure AIN0, which is a current measure
case ADC_CH_CURRENT :{
ADC_write(CMD_CURRENT_MEASURE);
break;
}
// AINp is AIN1; AINn is GND
// AIN1, which is a volt measure
case ADC_CH_VOLT :{
ADC_write(CMD_VOLT_MEASURE);
break;
}
// AINp is AIN2; AINn is GND
// AIN2, measure DAC voltage (Note that this is NOT DAC real output value!!)
case ADC_CH_DAC :{
ADC_write(CMD_DAC_MEASURE);
break;
}
// measure battery volt
case ADC_CH_BAT :{
ADC_write(CMD_BATTERY_MEASURE);
break;
}
default :{
break;
}
}
}
static void ReadVolt(uint8_t *buf){
// Read data twice since the first data we get is previous data
ADCChannelSelect(ADC_CH_VOLT);
CPUdelay(10);
ADC_read(buf);
__ADC_ch_sel(ch, rx, tx);
__ADC_read(rx, tx);
ADCChannelSelect(ADC_CH_VOLT);
CPUdelay(10);
ADC_read(buf);
__ADC_ch_sel(ch, rx, tx);
__ADC_read(rx, tx);
return;
}
static void ReadVoutVolt(uint8_t *buf){
// Read data twice since the first data we get is previous data
ADCChannelSelect(ADC_CH_DAC);
CPUdelay(10);
ADC_read(buf);
static void __reset_i_gain_cnt(int16_t *I_100R_cnt, int16_t *I_3K_cnt, int16_t *I_100K_cnt, int16_t *I_3M_cnt)
{
*I_3M_cnt = 0;
*I_100K_cnt = 0;
*I_3K_cnt = 0;
*I_100R_cnt = 0;
ADCChannelSelect(ADC_CH_DAC);
CPUdelay(10);
ADC_read(buf);
return;
}
static void ReadCurrent(uint8_t *buf){
// Read data twice since the first data we get is previous data
ADCGainControl(INSTRUCTION.ADCGainLevel);
ADCChannelSelect(ADC_CH_CURRENT);
CPUdelay(10);
ADC_read(buf);
static void __switch_lv0(uint8_t gain0_en, uint16_t plot, int16_t *I_GAIN_3M_counter, uint16_t *no_rec_cnt)
{
int16_t *gain_cnt = I_GAIN_3M_counter;
uint16_t *no_rec = no_rec_cnt;
uint8_t gain_en = gain0_en;
uint16_t pt = plot;
ADCChannelSelect(ADC_CH_CURRENT);
CPUdelay(10);
ADC_read(buf);
}
if (gain_en) {
*gain_cnt += 1;
static void ReadBatVolt(uint8_t *buf){
// Read data twice since the first data we get is previous data
ADCChannelSelect(ADC_CH_BAT);
CPUdelay(10);
ADC_read(buf);
if (*gain_cnt > 2) {
instru.IinADCGainLv = I_GAIN_3M;
IinADCGainCtrl(instru.IinADCGainLv);
*gain_cnt = 0;
ADCChannelSelect(ADC_CH_BAT);
CPUdelay(10);
ADC_read(buf);
}
if (pt == IIN_VIN_VOUT_PLOT) {
*no_rec = CNT_H2L_IIN_VIN_VOUT_PLOT;
// theoretical boundary <20, 10~500, >100 (uA)
#define GAIN_SMALL_BOUNDARY 40000 // 40 uA = 40,000,000 pA
#define GAIN_MID_BOUNDARY1 20000 // 20 uA = 20,000,000 pA
#define GAIN_MID_BOUNDARY2 400000 // 400 uA = 400,000,000 pA
#define GAIN_LARGE_BOUNDARY 200000 // 200 uA = 200,000 nA
} else if (pt == IIN_VIN_PLOT) {
*no_rec = CNT_H2L_IIN_VIN_PLOT;
//#define GAIN_SMALL_BOUNDARY 8000 // 8 uA = 8,000,000 pA
//#define GAIN_MID_BOUNDARY1 3000 // 3 uA = 3,000,000 pA
//#define GAIN_MID_BOUNDARY2 90000 // 90 uA = 90,000,000 pA
//#define GAIN_LARGE_BOUNDARY 70000 // 70 uA = 70,000 nA
} else if (pt == IT_PLOT) {
*no_rec = CNT_H2L_IT_PLOT;
static int32_t AutoGainReadCurrent(uint8_t *buf){
int32_t Real_Current = 0;
if(INSTRUCTION.ADCGainLevel == GAIN_AUTO){
INSTRUCTION.ADCGainLevel = GAIN_200R;
}
if(INSTRUCTION.ADCGainLevel == GAIN_200R){
uint8_t CurrentCount1 = 0;
while(CurrentCount1 < 5){
ReadCurrent(spi_ADC_rxbuf);
CurrentCount1++;
if(CurrentCount1 == 5){
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
break;
}
}
// switch to mid range current
if(Real_Current < GAIN_LARGE_BOUNDARY && Real_Current > -1*GAIN_LARGE_BOUNDARY){
uint8_t CurrentCount = 0;
// switch to small range current
if (Real_Current < GAIN_MID_BOUNDARY1 && Real_Current > -1*GAIN_MID_BOUNDARY1){
INSTRUCTION.ADCGainLevel = GAIN_200K;
while(CurrentCount < 5){
ReadCurrent(spi_ADC_rxbuf);
CurrentCount++;
if(CurrentCount == 5){
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
break;
}
}
}else{
CurrentCount = 0;
INSTRUCTION.ADCGainLevel = GAIN_10K;
while(CurrentCount < 5){
ReadCurrent(spi_ADC_rxbuf);
CurrentCount++;
if(CurrentCount == 5){
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
break;
}
}
}
// LED_color(DARKLED, 0x00, 0xFF, 0x00);
// // switch to small range current
// if (Real_Current < GAIN_MID_BOUNDARY1 && Real_Current > -1*GAIN_MID_BOUNDARY1){
// INSTRUCTION.ADCGainLevel = GAIN_200K;
// ReadCurrent(spi_ADC_rxbuf);
// Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
// LED_color(DARKLED, 0xFF, 0x00, 0x00);
// }
}
}
else if(INSTRUCTION.ADCGainLevel == GAIN_10K){
uint8_t CurrentCount1 = 0;
while(CurrentCount1 < 3){
ReadCurrent(spi_ADC_rxbuf);
CurrentCount1++;
if(CurrentCount1 == 3){
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
break;
}
}
// switch to large range current
if(Real_Current > GAIN_MID_BOUNDARY2 || Real_Current < -1*GAIN_MID_BOUNDARY2){
uint8_t CurrentCount = 0;
INSTRUCTION.ADCGainLevel = GAIN_200R;
while(CurrentCount < 3){
ReadCurrent(spi_ADC_rxbuf);
CurrentCount++;
if(CurrentCount == 3){
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
break;
}
}
}
// switch to small range current
else if (Real_Current < GAIN_MID_BOUNDARY1 && Real_Current > -1*GAIN_MID_BOUNDARY1){
uint8_t CurrentCount = 0;
INSTRUCTION.ADCGainLevel = GAIN_200K;
while(CurrentCount < 3){
ReadCurrent(spi_ADC_rxbuf);
CurrentCount++;
if(CurrentCount == 3){
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
break;
}
}
}
}
else if(INSTRUCTION.ADCGainLevel == GAIN_200K){
uint8_t CurrentCount1 = 0;
while(CurrentCount1 < 5){
ReadCurrent(spi_ADC_rxbuf);
CurrentCount1++;
if(CurrentCount1 == 5){
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
break;
return;
}
static void __switch_lv3(uint8_t gain3_en, uint16_t plot, int16_t *I_GAIN_100R_counter, uint16_t *no_rec_cnt)
{
int16_t *gain_cnt = I_GAIN_100R_counter;
uint16_t *no_rec = no_rec_cnt;
uint8_t gain_en = gain3_en;
if (gain_en) {
*gain_cnt += 1;
if (*gain_cnt > 2) {
instru.IinADCGainLv = I_GAIN_100R;
IinADCGainCtrl(instru.IinADCGainLv);
*gain_cnt = 0;
*no_rec = 0;
}
}
return;
}
static void __large_switch_lv1(uint8_t gain1_en, uint16_t plot, int16_t *I_GAIN_100K_counter, uint16_t *no_rec_cnt)
{
int16_t *gain_cnt = I_GAIN_100K_counter;
uint16_t *no_rec = no_rec_cnt;
uint8_t gain_en = gain1_en;
uint16_t pt = plot;
if (gain_en) {
*gain_cnt += 1;
if (*gain_cnt > 2) {
instru.IinADCGainLv = I_GAIN_100K;
IinADCGainCtrl(instru.IinADCGainLv);
*gain_cnt = 0;
*no_rec = 0;
if (pt == IIN_VIN_VOUT_PLOT) {
*no_rec = CNT_H2L_IIN_VIN_VOUT_PLOT;
} else if (pt == IIN_VIN_PLOT) {
*no_rec = CNT_H2L_IIN_VIN_PLOT;
} else if (pt == IT_PLOT) {
*no_rec = CNT_H2L_IT_PLOT;
}
}
}
return;
}
static void __small_switch_lv1(uint8_t gain1_en, uint16_t plot, int16_t *I_GAIN_100K_counter, uint16_t *no_rec_cnt)
{
int16_t *gain_cnt = I_GAIN_100K_counter;
uint16_t *no_rec = no_rec_cnt;
uint8_t gain_en = gain1_en;
uint16_t pt = plot;
if (gain_en) {
*gain_cnt += 1;
if (*gain_cnt > 2) {
instru.IinADCGainLv = I_GAIN_100K;
IinADCGainCtrl(instru.IinADCGainLv);
*gain_cnt = 0;
if (pt == IIN_VIN_VOUT_PLOT) {
*no_rec = CNT_L2H_IIN_VIN_VOUT_PLOT;
} else if (pt == IIN_VIN_PLOT) {
*no_rec = CNT_L2H_IIN_VIN_PLOT;
} else if (pt == IT_PLOT) {
*no_rec = CNT_L2H_IT_PLOT;
}
}
//Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
}
// switch to mid range current
if(Real_Current > GAIN_SMALL_BOUNDARY || Real_Current < -1*GAIN_SMALL_BOUNDARY){
uint8_t CurrentCount = 0;
// switch to large range current
if(Real_Current > GAIN_MID_BOUNDARY2 || Real_Current < -1*GAIN_MID_BOUNDARY2){
INSTRUCTION.ADCGainLevel = GAIN_200R;
while(CurrentCount < 5){
ReadCurrent(spi_ADC_rxbuf);
CurrentCount++;
if(CurrentCount == 5){
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
break;
}
}
}else{
CurrentCount = 0;
INSTRUCTION.ADCGainLevel = GAIN_10K;
while(CurrentCount < 5){
ReadCurrent(spi_ADC_rxbuf);
CurrentCount++;
if(CurrentCount == 5){
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
break;
}
return;
}
static void __large_switch_lv2(uint8_t gain2_en, uint16_t plot, int16_t *I_GAIN_3K_counter, uint16_t *no_rec_cnt)
{
int16_t *gain_cnt = I_GAIN_3K_counter;
uint16_t *no_rec = no_rec_cnt;
uint8_t gain_en = gain2_en;
if (gain_en) {
*gain_cnt += 1;
if (*gain_cnt > 2) {
instru.IinADCGainLv = I_GAIN_3K;
IinADCGainCtrl(instru.IinADCGainLv);
*gain_cnt = 0;
*no_rec = 0;
}
}
return;
}
static void __small_switch_lv2(uint8_t gain2_en, uint16_t plot, int16_t *I_GAIN_3K_counter, uint16_t *no_rec_cnt)
{
int16_t *gain_cnt = I_GAIN_3K_counter;
uint16_t *no_rec = no_rec_cnt;
uint8_t gain_en = gain2_en;
if (gain_en) {
*gain_cnt += 1;
if (*gain_cnt > 2) {
instru.IinADCGainLv = I_GAIN_3K;
IinADCGainCtrl(instru.IinADCGainLv);
*gain_cnt = 0;
*no_rec = 0;
}
}
return;
}
void IinADCGainCtrl(uint8_t IinADCLevel)
{
if (IinADCLevel == 0) {
// ADC gain level = 0, using 3M resister
PIN15_setOutputValue(Turnon_I_LARGE, 0);
PIN15_setOutputValue(Turnon_I_MID, 0);
PIN15_setOutputValue(Turnon_I_SMALL, 0);
} else if (IinADCLevel == 1) {
// ADC gain level = 1, using 100K resister
PIN15_setOutputValue(Turnon_I_LARGE, 0);
PIN15_setOutputValue(Turnon_I_MID, 0);
PIN15_setOutputValue(Turnon_I_SMALL, 1);
} else if (IinADCLevel == 2) {
// ADC gain level = 2, using 3K resister
PIN15_setOutputValue(Turnon_I_LARGE, 0);
PIN15_setOutputValue(Turnon_I_MID, 1);
PIN15_setOutputValue(Turnon_I_SMALL, 0);
} else if (IinADCLevel == 3) {
// ADC gain level = 3, using 100R resistor
PIN15_setOutputValue(Turnon_I_LARGE, 1);
PIN15_setOutputValue(Turnon_I_MID, 0);
PIN15_setOutputValue(Turnon_I_SMALL, 0);
} else if (IinADCLevel == 4) {
// ADC gain level = 3, auto gain (using 100R resister)
PIN15_setOutputValue(Turnon_I_LARGE, 1);
PIN15_setOutputValue(Turnon_I_MID, 0);
PIN15_setOutputValue(Turnon_I_SMALL, 0);
} else {
// default using 100R resister
PIN15_setOutputValue(Turnon_I_LARGE, 1);
PIN15_setOutputValue(Turnon_I_MID, 0);
PIN15_setOutputValue(Turnon_I_SMALL, 0);
}
if (IinADCLevel == 0 || IinADCLevel == 1 || IinADCLevel == 2 || IinADCLevel == 3) {
lastIinADCGainLevel = IinADCLevel;
} else {
lastIinADCGainLevel = 3;
}
curr_rec_en = false;
return;
}
void VinADCGainCtrl(uint8_t VinADCLevel)
{
if (VinADCLevel == 0) {
// Vin ADC gain level = 0, using 1M resister
PIN15_setOutputValue(Turnon_V_SMALL, 0);
PIN15_setOutputValue(Turnon_V_MID, 0);
} else if (VinADCLevel == 1) {
// Vin ADC gain level = 1, using 30K resister
PIN15_setOutputValue(Turnon_V_SMALL, 0);
PIN15_setOutputValue(Turnon_V_MID, 1);
} else if (VinADCLevel == 2) {
// Vin ADC gain level = 2, using 1K resister
PIN15_setOutputValue(Turnon_V_SMALL, 1);
PIN15_setOutputValue(Turnon_V_MID, 0);
} else if (VinADCLevel == 3) {
// Vin ADC gain level = 3, auto gain (using 1K resister)
PIN15_setOutputValue(Turnon_V_SMALL, 1);
PIN15_setOutputValue(Turnon_V_MID, 0);
} else {
// default using 1K resister
PIN15_setOutputValue(Turnon_V_SMALL, 1);
PIN15_setOutputValue(Turnon_V_MID, 0);
}
if (VinADCLevel == 0 || VinADCLevel == 1 || VinADCLevel == 2) {
lastVinADCGainLv = VinADCLevel;
} else {
lastVinADCGainLv = 2;
}
volt_rec_en = false;
return;
}
void read_adc_raw_data(uint8_t AdcChannel, uint8_t *rxbuf, uint8_t *txbuf)
{
uint8_t ch = AdcChannel;
uint8_t *rx = rxbuf;
uint8_t *tx = txbuf;
if (ch == RIS_ADC_IIN) {
__read_ADC_value(ADC_CH_CURR, rx, tx);
return;
}
if (ch == RIS_ADC_VIN) {
__read_ADC_value(ADC_CH_VIN, rx, tx);
return;
}
if (ch == RIS_ADC_VOUT) {
__read_ADC_value(ADC_CH_VOUT, rx, tx);
return;
}
if (ch == RIS_ADC_BAT) {
__read_ADC_value(ADC_CH_BAT, rx, tx);
return;
}
return;
}
void AutoGainChangeIin(int32_t RealCurrent, uint16_t plot_type, uint16_t *no_rec_time)
{
/*
* instru.IinADCGainLv == I_GAIN_100R: 3 level current(large)
* == I_GAIN_3K: 2 level current
* == I_GAIN_100K: 1 level current
* == I_GAIN_3M: 0 level current(small)
* no_rec_time: skip hardware damping
*/
int32_t curr = RealCurrent;
uint16_t plot = plot_type;
uint16_t *skip_time = no_rec_time;
static int16_t I_100R_cnt = 0;
static int16_t I_3K_cnt = 0;
static int16_t I_100K_cnt = 0;
static int16_t I_3M_cnt = 0;
int64_t small_gain = I_GAIN_SMALL_BOUNDARY;
int64_t mid1_gain1 = I_GAIN_MID1_BOUNDARY1;
int64_t mid1_gain2 = I_GAIN_MID1_BOUNDARY2;
int64_t mid2_gain1 = I_GAIN_MID2_BOUNDARY1;
int64_t mid2_gain2 = I_GAIN_MID2_BOUNDARY2;
int64_t large_gain = I_GAIN_LARGE_BOUNDARY;
uint8_t gain0_en = (instru.gain_switch_on & 0b10000000) >> 7;
uint8_t gain1_en = (instru.gain_switch_on & 0b01000000) >> 6;
uint8_t gain2_en = (instru.gain_switch_on & 0b00100000) >> 5;
uint8_t gain3_en = (instru.gain_switch_on & 0b00010000) >> 4;
if (instru.IinADCGainLv == I_GAIN_100R) {
if (curr < large_gain && curr > -1 * large_gain) {
if (curr < mid1_gain1 && curr > -1 * mid1_gain1) {
__switch_lv0(gain0_en, plot, &I_3M_cnt, skip_time);
} else if (curr < mid2_gain1 && curr > -1 * mid2_gain1) {
__large_switch_lv1(gain1_en, plot, &I_100K_cnt, skip_time);
} else {
__large_switch_lv2(gain2_en, plot, &I_3K_cnt, skip_time);
}
} else {
__reset_i_gain_cnt(&I_100R_cnt, &I_3K_cnt, &I_100K_cnt, &I_3M_cnt);
}
return;
}
if (instru.IinADCGainLv == I_GAIN_3K) {
if (curr > mid2_gain2 || curr < -1 * mid2_gain2) {
__switch_lv3(gain3_en, plot, &I_100R_cnt, skip_time);
} else if (curr < mid2_gain1 && curr > -1 * mid2_gain1) {
if (curr < mid1_gain1 && curr > -1 * mid1_gain1) {
__switch_lv0(gain0_en, plot, &I_3M_cnt, skip_time);
} else {
__large_switch_lv1(gain1_en, plot, &I_100K_cnt, skip_time);
}
} else {
__reset_i_gain_cnt(&I_100R_cnt, &I_3K_cnt, &I_100K_cnt, &I_3M_cnt);
}
return;
}
if (instru.IinADCGainLv == I_GAIN_100K) {
if (curr < mid1_gain1 && curr > -1 * mid1_gain1) {
__switch_lv0(gain0_en, plot, &I_3M_cnt, skip_time);
} else if (curr > mid1_gain2 || curr < -1 * mid1_gain2) {
if (curr > mid2_gain2 || curr < -1 * mid2_gain2) {
__switch_lv3(gain3_en, plot, &I_100R_cnt, skip_time);
} else {
__small_switch_lv2(gain2_en, plot, &I_3K_cnt, skip_time);
}
} else {
__reset_i_gain_cnt(&I_100R_cnt, &I_3K_cnt, &I_100K_cnt, &I_3M_cnt);
}
return;
}
if (instru.IinADCGainLv == I_GAIN_3M) {
if (curr > small_gain || curr < -1 * small_gain) {
if (curr > mid2_gain2 || curr < -1 * mid2_gain2) {
__switch_lv3(gain3_en, plot, &I_100R_cnt, skip_time);
} else if (curr > mid1_gain2 || curr < -1 * mid1_gain2) {
__small_switch_lv2(gain2_en, plot, &I_3K_cnt, skip_time);
} else {
__small_switch_lv1(gain1_en, plot, &I_100K_cnt, skip_time);
}
} else {
__reset_i_gain_cnt(&I_100R_cnt, &I_3K_cnt, &I_100K_cnt, &I_3M_cnt);
}
return;
}
return;
}
void AutoGainChangeVin(int32_t RealVin)
{
/*
* instru.IinADCGainLv == VIN_GAIN_1K: 2 level volt(large)
* == VIN_GAIN_30K: 1 level volt
* == VIN_GAIN_1M: 0 level volt(small)
*
*/
static int16_t VIN_GAIN_1M_counter = 0;
static int16_t VIN_GAIN_30K_counter = 0;
static int16_t VIN_GAIN_1K_counter = 0;
if(instru.VinADCGainLv == VIN_GAIN_1M){
if(RealVin > VIN_GAIN_SMALL_BOUNDARY || RealVin < -1*VIN_GAIN_SMALL_BOUNDARY){
// switch to 2 level volt(large)
if (RealVin > VIN_GAIN_MID1_BOUNDARY2 || RealVin < -1*VIN_GAIN_MID1_BOUNDARY2){
VIN_GAIN_1K_counter++;
if(VIN_GAIN_1K_counter > 2){
instru.VinADCGainLv = VIN_GAIN_1K;
VinADCGainCtrl(instru.VinADCGainLv);
VIN_GAIN_1K_counter = 0;
}
}
// switch to large range current
// if(Real_Current > GAIN_MID_BOUNDARY2 || Real_Current < -1*GAIN_MID_BOUNDARY2){
// INSTRUCTION.ADCGainLevel = GAIN_200R;
// ReadCurrent(spi_ADC_rxbuf);
// Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
// }
}
// switch to 1 level volt
else{
VIN_GAIN_30K_counter++;
if(VIN_GAIN_30K_counter > 2){
instru.VinADCGainLv = VIN_GAIN_30K;
VinADCGainCtrl(instru.VinADCGainLv);
VIN_GAIN_30K_counter = 0;
}
}
}else{
VIN_GAIN_1M_counter = 0;
VIN_GAIN_30K_counter = 0;
VIN_GAIN_1K_counter = 0;
}
}
else if(instru.VinADCGainLv == VIN_GAIN_30K){
// switch to 0 level volt(small)
if(RealVin < VIN_GAIN_MID1_BOUNDARY1 && RealVin > -1*VIN_GAIN_MID1_BOUNDARY1){
VIN_GAIN_1M_counter++;
if(VIN_GAIN_1M_counter > 2){
instru.VinADCGainLv = VIN_GAIN_1M;
VinADCGainCtrl(instru.VinADCGainLv);
VIN_GAIN_1M_counter = 0;
}
}
else if (RealVin > VIN_GAIN_MID1_BOUNDARY2 || RealVin < -1*VIN_GAIN_MID1_BOUNDARY2){
// switch to 2 level volt
VIN_GAIN_1K_counter++;
if(VIN_GAIN_1K_counter > 2){
instru.VinADCGainLv = VIN_GAIN_1K;
VinADCGainCtrl(instru.VinADCGainLv);
VIN_GAIN_1K_counter = 0;
}
}else{
VIN_GAIN_1M_counter = 0;
VIN_GAIN_30K_counter = 0;
VIN_GAIN_1K_counter = 0;
}
}
else if(instru.VinADCGainLv == VIN_GAIN_1K){
if(RealVin < VIN_GAIN_LARGE_BOUNDARY && RealVin > -1*VIN_GAIN_LARGE_BOUNDARY){
// switch to 0 level volt(small)
if (RealVin < VIN_GAIN_MID1_BOUNDARY1 && RealVin > -1*VIN_GAIN_MID1_BOUNDARY1){
VIN_GAIN_1M_counter++;
if(VIN_GAIN_1M_counter > 2){
instru.VinADCGainLv = VIN_GAIN_1M;
VinADCGainCtrl(instru.VinADCGainLv);
VIN_GAIN_1M_counter = 0;
}
}
// switch to 1 level volt
else{
VIN_GAIN_30K_counter++;
if(VIN_GAIN_30K_counter > 2){
instru.VinADCGainLv = VIN_GAIN_30K;
VinADCGainCtrl(instru.VinADCGainLv);
VIN_GAIN_30K_counter = 0;
}
}
}else{
VIN_GAIN_1M_counter = 0;
VIN_GAIN_30K_counter = 0;
VIN_GAIN_1K_counter = 0;
}
}
return Real_Current;
}
#endif
@@ -1,32 +0,0 @@
#ifndef ELITECCC
#define ELITECCC
#include "EliteCCMode.h"
// XXX : should we reset DAC output after STOP?
static void CCModeReverseCurrent(CCCMode *CCC){
if(CCC->StandBy){
if(CT.StandByCounter == CCC->StandByTime){
CCC->StandBy = false;
CT.StandByCounter = 0;
}
else{
CT.StandByCounter ++;
}
}
else{
// reverse charge/discharge
if(CCC->BatteryV == CCC->VMax){
CCC->StandBy = true;
CCC->value = CCC->DischargeCurrent;
}
else if(CCC->BatteryV == CCC->VMin){
CCC->StandBy = true;
CCC->value = CCC->ChargeCurrent;
}
}
}
#endif
@@ -1,132 +0,0 @@
#ifndef ELITECCMODE
#define ELITECCMODE
static void CCModeDACControl(CCMode *CC, int32_t IUC_Measure_Difference);
static int32_t CCModeReadCurrent(CCMode *CC){
static uint8_t VoltCurrentSwitch = 0;
CCModeDACEnable = 1; // This flag will control DAC working
// decode ADC value and put it into notify buffer
// Use 5-th measure value as real-measure value
// because some value in the begin are garbage
if(VoltCurrentSwitch < 5){
ReadCurrent(spi_ADC_rxbuf);
VoltCurrentSwitch ++;
}
else if(VoltCurrentSwitch == 5){
// read current
if(INSTRUCTION.AutoGainEnable){
CC->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
}
else{
ReadCurrent(spi_ADC_rxbuf);
CC->_MeasureData = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
}
VoltCurrentSwitch ++;
}
else if(VoltCurrentSwitch <10){
// read volt
ReadVolt(spi_ADC_rxbuf);
VoltCurrentSwitch++;
}
else if(VoltCurrentSwitch == 10){
/** read battery voltage **/
ReadVolt(spi_ADC_rxbuf);
CC->BatteryV = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
// if Iin have a offset if current !=0
CC->BatteryV = CC->BatteryV - (CC->value - CC_ZERO_POINT)*10/1e5; // I_set * 10R = V_Iin2GND (mA * ohm)
VoltCurrentSwitch++;
// NotifyReady = true;
}
else{
VoltCurrentSwitch = 0;
}
NotifyVolt[0] = (uint8_t) (CC->BatteryV >> 24);
NotifyVolt[1] = (uint8_t) ((CC->BatteryV & 0x00FF0000) >> 16);
NotifyVolt[2] = (uint8_t) ((CC->BatteryV & 0x0000FF00) >> 8);
NotifyVolt[3] = (uint8_t) (CC->BatteryV & 0x000000FF);
return CC->_MeasureData;
}
static int32_t CCModeVoltOut(CCMode *CC){
int32_t IUCCurrent = 0;
if(!CCModeDACEnable){
// DAC should not work now
return 0;
}
IUCCurrent = CC->_Transform2RealnA( (struct CCModePara *) CC);
CCModeDACControl(CC, IUCCurrent - CC->_MeasureData);
CCModeDACEnable = 0;
return CC->_MeasureData;
}
static void CCModeDACControl(CCMode *CC, int32_t IUC_Measure_Difference){
int32_t step;
if(IUC_Measure_Difference < 300 && IUC_Measure_Difference > -300){
step = 0;
}
else if( CC->Charge && CC->BatteryV >= ( (int32_t) (CC->VMax - DAC_ZERO)/5 ) ){
CC->value = 0;
step = (IUC_Measure_Difference > 0) ? 1:-1;
}
else if( (!CC->Charge) && CC->BatteryV <= ( (int32_t) (CC->VMin - DAC_ZERO)/5 ) ){
// Ignore VMin condition
if(CC->Done < 25000){
CC->Done ++;
step = (IUC_Measure_Difference > 0) ? 2:-2;
}
// after ignore few second, active VMin condition
else{
CC->value = 0;
step = (IUC_Measure_Difference > 0) ? 1:-1;
}
}
else{
step = (IUC_Measure_Difference > 0) ? 1:-1;
}
// over/under flow
if( (INSTRUCTION.VoltConstant + step) > MAX_DAC_UC || (INSTRUCTION.VoltConstant + step) < MIN_DAC_UC ){
if(step > 0){
INSTRUCTION.VoltConstant = (INSTRUCTION.VoltConstant + MAX_DAC_UC)/2;
}
else{
INSTRUCTION.VoltConstant = (INSTRUCTION.VoltConstant + MIN_DAC_UC)/2;
}
}
else{
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant + step;
}
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
// step = CC->Done;
// NotifyImpedance[0] = (uint8_t) (step >> 24);
// NotifyImpedance[1] = (uint8_t) ((step & 0x00FF0000) >> 16);
// NotifyImpedance[2] = (uint8_t) ((step & 0x0000FF00) >> 8);
// NotifyImpedance[3] = (uint8_t) (step & 0x000000FF);
}
/* Transform setting CC into IUC
*
* User code in CC mode : 0 ~ 3000000
* Real current value : -15.00000 ~ 15.00000 mA
* => user code = 1500000 mapping to 0.00000 mA
*/
static void CCCurrent2IUC(CCMode *CC){
int32_t CurrentValue = 0;
CC->value = INSTRUCTION.ConstantCurrent;
CurrentValue = CC->value - CC_ZERO_POINT;
}
#endif
@@ -1,598 +0,0 @@
#ifndef ELITECV
#define ELITECV
static uint16_t SWVCurve(WorkMode *WorkModeData) {
static uint8_t counter;
static uint16_t outputV;
static uint16_t Volt;
static bool direction_up;
// reset origin volt at the begin
if (DACReset) {
Volt = INSTRUCTION.VoltOrigin;
outputV = INSTRUCTION.VoltOrigin;
if (INSTRUCTION.VoltOrigin < INSTRUCTION.VoltFinal)
direction_up = true;
else
direction_up = false;
counter = 1;
DACReset = false;
}
if (counter == 2 * PulseWidth)
counter = 1;
else
counter++;
// output a certain volt
outputV = Volt;
DAC_outputV(outputV);
// VoltValue = (ramp1*16 + ramp0/16) * 3.05;
// check if we reach the final volt
if ((outputV >= INSTRUCTION.VoltFinal && direction_up) || (outputV <= INSTRUCTION.VoltFinal && !direction_up)) {
PeriodicEvent = false;
DACReset = true;
}
// prepare the next output volt
if (direction_up) {
if (counter == PulseWidth)
Volt = Volt + Amplitude;
else if (counter == 2 * PulseWidth)
Volt = Volt - (Amplitude - INSTRUCTION.Step);
else
Volt = Volt;
} else {
if (counter == PulseWidth)
Volt = Volt - Amplitude;
else if (counter == 2 * PulseWidth)
Volt = Volt + (Amplitude - INSTRUCTION.Step);
else
Volt = Volt;
}
return outputV;
}
static uint16_t DPVCurve(WorkMode *WorkModeData) {
static uint8_t counter;
static uint16_t Volt1;
static uint16_t Volt2;
static uint16_t outputV;
static bool direction_up;
// reset origin volt at the begin
if (DACReset) {
if (INSTRUCTION.VoltOrigin < INSTRUCTION.VoltFinal)
direction_up = true;
else
direction_up = false;
Volt1 = INSTRUCTION.VoltOrigin;
if (direction_up)
Volt2 = INSTRUCTION.VoltOrigin + Amplitude;
else
Volt2 = INSTRUCTION.VoltOrigin - Amplitude;
counter = 1;
DACReset = false;
}
if (counter == PulsePeriod)
counter = 1;
else
counter++;
// output a certain volt
if (counter <= (PulsePeriod - PulseWidth)) {
outputV = Volt1;
DAC_outputV(Volt1);
} else {
outputV = Volt2;
DAC_outputV(Volt2);
}
// VoltValue = (ramp1*16 + ramp0/16) * 3.05;
// check if we reach the final volt
if (((outputV >= INSTRUCTION.VoltFinal) && direction_up) || ((outputV <= INSTRUCTION.VoltFinal) && !direction_up)) {
PeriodicEvent = false;
DACReset = true;
}
// check overflow/underflow and prepare for next output
if (direction_up) {
if (Volt1 + INSTRUCTION.Step < Volt1)
Volt1 = 0xffff;
else
Volt1 = Volt1 + INSTRUCTION.Step;
if (Volt2 + INSTRUCTION.Step < Volt2)
Volt2 = 0xffff;
else
Volt2 = Volt2 + INSTRUCTION.Step;
} else {
if (Volt1 - INSTRUCTION.Step > Volt1)
Volt1 = 0x0000;
else
Volt1 = Volt1 - INSTRUCTION.Step;
if (Volt2 - INSTRUCTION.Step > Volt2)
Volt2 = 0x0000;
else
Volt2 = Volt2 - INSTRUCTION.Step;
}
if (counter + 1 <= (PulsePeriod - PulseWidth)) {
return Volt1;
} else {
return Volt2;
}
}
static uint16_t CVCurve(CVMode *CV) {
static uint16_t DACOutCode;
static bool direction_up; // direction_up = true, if Vfinal > Vorigin
static bool current_direction_up; // current_direction_up = true, Vstep => positive. vice versa
static bool firstADCData; //firstADCdata=true,when min<x<max,cyclenumber--
// reset origin volt at the begin
if (DACReset) {
INSTRUCTION.VoltConstant = CV->_VOrigin;
if (CV->_VStop > CV->_VOrigin) {
direction_up = true;
current_direction_up = true;
} else {
direction_up = false;
current_direction_up = false;
}
DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant);
DAC_outputV(DACOutCode); // output VOLT_ORIGIN
DACReset = false;
firstADCData = true;
return DACOutCode;
}
if (CT.StepTimeCounter == CV->_StepTime) {
// Decide next direction
if (CV->_VoVi_Switch == 0x00){ //user see Vout
if (direction_up) {
if (INSTRUCTION.VoltConstant >= CV->_VStop) {
current_direction_up = false; // problem occurs when origin == 0000 final == ffff!!!!!!
firstADCData = false;
}
else if (INSTRUCTION.VoltConstant <= CV->_VOrigin) {
current_direction_up = true;
firstADCData = false;
if (CV->_CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
}
CV->_CycleNumber--;
}
else if(current_direction_up){
if(INSTRUCTION.VoltConstant + CV->_Step > CV->_VStop){
current_direction_up = false;
}
}
else if(!current_direction_up){
if(INSTRUCTION.VoltConstant - CV->_Step < CV->_VOrigin){
current_direction_up = true;
if (CV->_CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
}
CV->_CycleNumber--;
}
}
if (firstADCData){
CV->_CycleNumber--;
firstADCData = false;
}
} else {
if (INSTRUCTION.VoltConstant < CV->_VStop) {
current_direction_up = true; // problem occurs when origin == 0000 final == ffff!!!!!!
firstADCData = false;
}
else if (INSTRUCTION.VoltConstant > CV->_VOrigin) {
current_direction_up = false;
firstADCData = false;
if (CV->_CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
}
CV->_CycleNumber--;
}
else if(current_direction_up){
if(INSTRUCTION.VoltConstant + CV->_Step > CV->_VOrigin){
current_direction_up = false;
if (CV->_CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
}
CV->_CycleNumber--;
}
}
else if(!current_direction_up){
if(INSTRUCTION.VoltConstant - CV->_Step < CV->_VStop){
current_direction_up = true;
}
}
if (firstADCData){//first data =2899mv,CV->_CycleNumber--;
CV->_CycleNumber--;
firstADCData = false;
}
}
}
else if (CV->_VoVi_Switch == 0x01){ //user see Vin
if (direction_up) {
if (INSTRUCTION.VoltConstant >= CV->_VStop) {
current_direction_up = false; // problem occurs when origin == 0000 final == ffff!!!!!!
firstADCData = false;
}
else if (INSTRUCTION.VoltConstant <= CV->_VOrigin) {
current_direction_up = true;
firstADCData = false;
if (CV->_CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
}
CV->_CycleNumber--;
}
else if(current_direction_up){
if(INSTRUCTION.VoltConstant + CV->_Step > CV->_VStop){
current_direction_up = false;
}
}
else if(!current_direction_up){
if(INSTRUCTION.VoltConstant - CV->_Step < CV->_VOrigin){
current_direction_up = true;
if (CV->_CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
}
CV->_CycleNumber--;
}
}
if (firstADCData){
CV->_CycleNumber--;
firstADCData = false;
}
} else {
if (INSTRUCTION.VoltConstant < CV->_VStop) {
current_direction_up = true; // problem occurs when origin == 0000 final == ffff!!!!!!
firstADCData = false;
}
else if (INSTRUCTION.VoltConstant > CV->_VOrigin){
current_direction_up = false;
firstADCData = false;
if (CV->_CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
}
CV->_CycleNumber--;
}
else if(current_direction_up){
if(INSTRUCTION.VoltConstant + CV->_Step > CV->_VOrigin){
current_direction_up = false;
if (CV->_CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
}
CV->_CycleNumber--;
}
}
else if(!current_direction_up){
if(INSTRUCTION.VoltConstant - CV->_Step < CV->_VStop){
current_direction_up = true;
}
}
if (firstADCData){//first data =2899mv,CV->_CycleNumber--;
CV->_CycleNumber--;
firstADCData = false;
}
}
}
// if (current_direction_up == true){
// LED_color(DARKLED, 255, 0, 0);
// }
// else if (current_direction_up == false){
// LED_color(DARKLED, 255, 0, 255);
// }
// Next output voltage
if (CV->_VoVi_Switch == 0x00){
if (direction_up) {
if (current_direction_up) {
// DACUserCode overflow ?
if (INSTRUCTION.VoltConstant + CV->_Step < INSTRUCTION.VoltConstant) {
INSTRUCTION.VoltConstant = CV->_VStop;
}
// reach Vfinal ?
else if (INSTRUCTION.VoltConstant + CV->_Step > CV->_VStop) {
INSTRUCTION.VoltConstant =CV->_VStop;
}
else if (INSTRUCTION.VoltConstant >= CV->_VStop){
INSTRUCTION.VoltConstant =CV->_VStop;
}
else {
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant + CV->_Step;
}
}
else {
// DACUserCode underflow ?
if (INSTRUCTION.VoltConstant - CV->_Step > INSTRUCTION.VoltConstant) {
INSTRUCTION.VoltConstant = CV->_VOrigin;
}
// reach Vorigin ?
else if (INSTRUCTION.VoltConstant - CV->_Step < CV->_VOrigin) {
INSTRUCTION.VoltConstant = CV->_VOrigin;
}
else if (INSTRUCTION.VoltConstant <= CV->_VOrigin){
INSTRUCTION.VoltConstant = CV->_VOrigin;
}
else {
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant - CV->_Step;
if(INSTRUCTION.VoltConstant > 60000){
INSTRUCTION.VoltConstant = 0;
current_direction_up = true;
if (CV->_CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
}
CV->_CycleNumber--;
}
}
}
}
else {
if (current_direction_up) {
if (INSTRUCTION.VoltConstant + CV->_Step < INSTRUCTION.VoltConstant) {
INSTRUCTION.VoltConstant = CV->_VOrigin;
}
else if (INSTRUCTION.VoltConstant + CV->_Step > CV->_VOrigin) {
INSTRUCTION.VoltConstant = CV->_VOrigin;
}
else if (INSTRUCTION.VoltConstant >= CV->_VOrigin){
INSTRUCTION.VoltConstant = CV->_VOrigin;
}
else {
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant + CV->_Step;
}
}
else {
if (INSTRUCTION.VoltConstant - CV->_Step > INSTRUCTION.VoltConstant) {
INSTRUCTION.VoltConstant = CV->_VStop ;
}
else if (INSTRUCTION.VoltConstant - CV->_Step < CV->_VStop) {
INSTRUCTION.VoltConstant = CV->_VStop;
}
else if(INSTRUCTION.VoltConstant <= CV->_VStop){
INSTRUCTION.VoltConstant = CV->_VStop;
}
else {
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant - CV->_Step;
if(INSTRUCTION.VoltConstant > 60000){
INSTRUCTION.VoltConstant = 0;
current_direction_up = true;
}
}
}
}
}
else if (CV->_VoVi_Switch == 0x01){
if (direction_up) {
if (current_direction_up) {
// DACUserCode overflow ?
if (INSTRUCTION.VoltConstant + CV->_Step < INSTRUCTION.VoltConstant) {
INSTRUCTION.VoltConstant = CV->_VStop;
}
// reach Vfinal ?
else if (INSTRUCTION.VoltConstant + CV->_Step > CV->_VStop) {
INSTRUCTION.VoltConstant =CV->_VStop;
}
else if (INSTRUCTION.VoltConstant >= CV->_VStop){
INSTRUCTION.VoltConstant =CV->_VStop;
}
else {
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant + CV->_Step;
}
}
else {
// DACUserCode underflow ?
if (INSTRUCTION.VoltConstant - CV->_Step > INSTRUCTION.VoltConstant) {
INSTRUCTION.VoltConstant = CV->_VOrigin;
}
// reach Vorigin ?
else if (INSTRUCTION.VoltConstant - CV->_Step < CV->_VOrigin) {
INSTRUCTION.VoltConstant = CV->_VOrigin;
}
else if (INSTRUCTION.VoltConstant <= CV->_VOrigin){
INSTRUCTION.VoltConstant = CV->_VOrigin;
}
else {
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant - CV->_Step;
if(INSTRUCTION.VoltConstant > 60000){
INSTRUCTION.VoltConstant = 0;
current_direction_up = true;
if (CV->_CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
}
CV->_CycleNumber--;
}
}
}
}
else {
if (current_direction_up) {
// DACUserCode overflow ?
if (INSTRUCTION.VoltConstant + CV->_Step < INSTRUCTION.VoltConstant) {
INSTRUCTION.VoltConstant = CV->_VOrigin;
}
// ex:command 3->1V ,when 1 to 3V, 2.99+0.1 > 3V
else if (INSTRUCTION.VoltConstant + CV->_Step > CV->_VOrigin) {
INSTRUCTION.VoltConstant = CV->_VOrigin;
}
else if (INSTRUCTION.VoltConstant >= CV->_VOrigin){
INSTRUCTION.VoltConstant = CV->_VOrigin;
}
else {
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant + CV->_Step;
}
}
else {
if (INSTRUCTION.VoltConstant - CV->_Step > INSTRUCTION.VoltConstant) {
INSTRUCTION.VoltConstant = CV->_VStop ;
}
else if (INSTRUCTION.VoltConstant - CV->_Step < CV->_VStop) {
INSTRUCTION.VoltConstant = CV->_VStop;
}
else if(INSTRUCTION.VoltConstant <= CV->_VStop){
INSTRUCTION.VoltConstant = CV->_VStop;
}
else {
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant - CV->_Step;
if(INSTRUCTION.VoltConstant > 60000){
INSTRUCTION.VoltConstant = 0;
current_direction_up = true;
}
}
}
}
}
// NotifyImpedance[0] = 0x00;
// NotifyImpedance[1] = 0x00;
// NotifyImpedance[2] = (uint8_t)((DACOutCode & 0xFF00) >> 8);
// NotifyImpedance[3] = (uint8_t)(DACOutCode & 0x00FF);
DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant);
DAC_outputV(DACOutCode);
}
return DACOutCode;
}
static void CV_Plot(CVMode *CV){
static uint8_t PreviousGain = GAIN_200R;
static uint8_t VoltCurrentSwitch = 0;
uint16_t ADC_measure = 0;
if(VoltCurrentSwitch < 5){
ReadCurrent(spi_ADC_rxbuf);
VoltCurrentSwitch ++;
}
else if(VoltCurrentSwitch == 5){
// read current
if(INSTRUCTION.AutoGainEnable){
CV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
if(PreviousGain != INSTRUCTION.ADCGainLevel){
PreviousGain = INSTRUCTION.ADCGainLevel;
CV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
CV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
}
if(PreviousGain != INSTRUCTION.ADCGainLevel){
PreviousGain = INSTRUCTION.ADCGainLevel;
CV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
CV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
}
}
else{
ReadCurrent(spi_ADC_rxbuf);
CV->_MeasureData = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
}
VoltCurrentSwitch ++;
}
// else if(VoltCurrentSwitch < 9){
// // read volt
// ReadVolt(spi_ADC_rxbuf);
// VoltCurrentSwitch++;
// }
// else if(VoltCurrentSwitch == 9){
// /** read battery voltage **/
// ReadVolt(spi_ADC_rxbuf);
// ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
// //CV->MeasureVolt = 20000;
// CV->MeasureVolt = DecodeADCVolt(ADC_measure);
// VoltCurrentSwitch++;
// }
else if(VoltCurrentSwitch < 9){
if(CV->_VoVi_Switch == 0x01){
// read vin volt
ReadVolt(spi_ADC_rxbuf);
}else if(CV->_VoVi_Switch == 0x00){
// read vout volt
ReadVoutVolt(spi_ADC_rxbuf);
}
VoltCurrentSwitch++;
}
else if(VoltCurrentSwitch == 9){
if(CV->_VoVi_Switch == 0x01){
// read vin volt
ReadVolt(spi_ADC_rxbuf);
ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
//CV->MeasureVolt = 20000;
CV->MeasureVolt = DecodeADCVolt(ADC_measure);
}else if(CV->_VoVi_Switch == 0x00){
// read vout volt
ReadVoutVolt(spi_ADC_rxbuf);
ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
CV->MeasureVolt = DecodeADCVoutVolt(ADC_measure);
}
VoltCurrentSwitch++;
}
// else if (VoltCurrentSwitch < 13){
// ReadBatVolt(spi_ADC_rxbuf);
// VoltCurrentSwitch ++;
// }
// else if (VoltCurrentSwitch == 13){
// // read battery volt
// ReadBatVolt(spi_ADC_rxbuf);
// ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
// CV->_MeasureBatvolt = DecodeADCBatVolt(ADC_measure);
// CV->_MeasureBatvolt = CV->_MeasureBatvolt/10 - 250; // (5.00V) 5000->250 usercode
// VoltCurrentSwitch ++;
// }
else{
VoltCurrentSwitch = 0;
}
NotifyCurrent[0] = (uint8_t) (CV->_MeasureData >> 24);
NotifyCurrent[1] = (uint8_t) ((CV->_MeasureData & 0x00FF0000) >> 16);
NotifyCurrent[2] = (uint8_t) ((CV->_MeasureData & 0x0000FF00) >> 8);
NotifyCurrent[3] = (uint8_t) (CV->_MeasureData & 0x000000FF);
if ((CV->_VoVi_Switch == 0x01) || (CV->_VoVi_Switch == 0x00)){ //user see Vin || user see Vout
// NotifyVolt[0] = (uint8_t) (CV->MeasureVolt >> 24);
// NotifyVolt[1] = (uint8_t) ((CV->MeasureVolt & 0x00FF0000) >> 16);
// NotifyVolt[2] = (uint8_t) ((CV->MeasureVolt & 0x0000FF00) >> 8);
// NotifyVolt[3] = (uint8_t) (CV->MeasureVolt & 0x000000FF);
int32_t RealV;
RealV = (int32_t)(INSTRUCTION.VoltConstant - 25000)*1000/5;
NotifyVolt[0] = (uint8_t)((RealV & 0xFF000000) >> 24);
NotifyVolt[1] = (uint8_t)((RealV & 0x00FF0000) >> 16);
NotifyVolt[2] = (uint8_t)((RealV & 0x0000FF00) >> 8);
NotifyVolt[3] = (uint8_t)(RealV & 0x000000FF);
}
// NotifyBatVolt = (uint8_t) (CV->_MeasureBatvolt & 0x000000FF);
}
#endif
@@ -4,31 +4,6 @@
static bool DACReset;
//#ifdef ELITE_VERSION_1_3
//#define DACOUT 0x30
//
//static void DAC_outputV(uint16_t voltLV) {
// // C = command, X = don't care, D = data
// // CCCC XXXX = command
// // DDDD DDDD = v1
// // DDDD XXXX = v2
//
// uint8_t v1, v2 = 0;
// v1 = (uint8_t) (voltLV >> 4) & 0xFF;
// v2 = (uint8_t) ((voltLV & 0x000F) << 4) & 0xF0;
//
// spi_DACtxbuf[0] = command;
// spi_DACtxbuf[1] = v1;
// spi_DACtxbuf[2] = v2;
// for (int i = 3; i < SPI_DAC_SIZE; i++) {
// spi_DACtxbuf[i] = 0;
// }
//
// DAC_SPI(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
//}
//#endif
#ifdef ELITE_VERSION_1_4
#define DACCLS 0x02
#define DACOUT 0x31
@@ -52,14 +27,68 @@ static uint16_t DAC_outputV(uint16_t voltLV) {
spi_DACtxbuf[2] = v2;
DAC_SPI(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
return voltLV;
}
static void VoutGainControl(uint8_t VOUTLevel){
if(VOUTLevel == 0){
// VOUT gain level = 0, using 240K resister
PIN15_setOutputValue(Turnon_VOUT_SMALL, 0);
}
else if(VOUTLevel == 1){
// VOUT gain level = 1, using 15K resister
PIN15_setOutputValue(Turnon_VOUT_SMALL, 1);
}
else if(VOUTLevel == 2){
// VOUT gain level = 2, using 15K resister
PIN15_setOutputValue(Turnon_VOUT_SMALL, 1);
}
else{
// default using 15K resister
PIN15_setOutputValue(Turnon_VOUT_SMALL, 1);
}
volt_rec_en = false;
}
#endif
static int32_t User2Real(uint16_t UserCode){
/* transfer usercode to real voltage value (mV) */
return (int32_t) ((UserCode - 25000)*2)/10;
return (int32_t)((UserCode - 25000) / 5);
}
// DAC Vout theoretical boundary <300, 100~ (mV)
#define DAC_VOUT_GAIN_SMALL_BOUNDARY 100000 // 25500(usercode) = 100 mV
#define DAC_VOUT_GAIN_LARGE_BOUNDARY 300000 // 26500(usercode) = 300 mV
#define DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE 26500 // 26500(usercode) = 300 mV
#define DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE 23500 // 23500(usercode) = -300 mV
static void AutoGainChangeVout(int32_t userCode){
int32_t RealVolt = (userCode - 25000) * 200; // (userCode - 25000) / 5 * 1000 [1uV]
// switch to 1 level volt(small) 15K
// switch to 2 level volt(large) 240K
if(instru.VoutGainLv == VOUT_GAIN_AUTO){
instru.VoutGainLv = VOUT_GAIN_15K;
VoutGainControl(instru.VoutGainLv);
}
if(instru.VoutGainLv == VOUT_GAIN_15K){
if(RealVolt > DAC_VOUT_GAIN_LARGE_BOUNDARY || RealVolt < -1 * DAC_VOUT_GAIN_LARGE_BOUNDARY){
// switch to 2 level volt(large)
instru.VoutGainLv = VOUT_GAIN_240K;
VoutGainControl(instru.VoutGainLv);
}
}
else if(instru.VoutGainLv == VOUT_GAIN_240K){
if(RealVolt < DAC_VOUT_GAIN_SMALL_BOUNDARY && RealVolt > -1 * DAC_VOUT_GAIN_SMALL_BOUNDARY ){
// switch to 1 level volt(small)
instru.VoutGainLv = VOUT_GAIN_15K;
VoutGainControl(instru.VoutGainLv);
}
}
}
#endif
@@ -2,21 +2,31 @@
#ifndef ELITE_FLAG_CT_INIT
#define ELITE_FLAG_CT_INIT
static void InitCT(){
CT.SampleRate_counter = 1;
CT.StepTimeCounter = 1;
CT.NotifyCounter = 1;
CT.StandByCounter = 0;
}
// GPT counter
struct _GPT{
uint32_t GptimerCounter;
uint32_t GptimerCounter0;
uint8_t DeltaGptimerCounter;
uint32_t SampleRateCounter;
uint32_t NotifyCounter;
uint32_t VscanRateCounter;
uint32_t LeadTimeCounter;
uint32_t BatteryADCCounter;
uint32_t BatteryCheckCounter;
uint32_t GptimerMultiple;
uint32_t StiCounter;
}GPT = {0};
static void InitFlag(){
PeriodicEvent = false; // is there an PeriodicEvent?
InitPeriodicEvent = true; // need to create a WorkModeData?
DACReset = true;
CCModeDACEnable = 0; // to make sure DAC work after ADC
Free_Work_Mode = true; // Free(WorkModeData)
// NotifyReady = false;
// DiscardIVFirstData = 0;
static void InitGPT(){
GPT.GptimerCounter = 0;
GPT.GptimerCounter0 = 0;
GPT.DeltaGptimerCounter = 0;
GPT.SampleRateCounter = 0;
GPT.NotifyCounter = 0;
GPT.VscanRateCounter = 0;
GPT.LeadTimeCounter = 0;
GPT.BatteryADCCounter = 0;
GPT.BatteryCheckCounter = 0;
GPT.StiCounter = 0;
}
#endif
@@ -17,7 +17,7 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In
#define elite_gptimer_start() GPTimerCC26XX_start(gptimer_handle)
#define elite_gptimer_stop() GPTimerCC26XX_stop(gptimer_handle)
#define elite_gptimer_close() GPTimerCC26XX_close(gptimer_handle)
#define CLOCK_FREQ 4000 // clock freq = 0.1 ms
#define CLOCK_FREQ 4769 // clock freq = 0.1 ms(4800), Measured(4769)
#define elite_gptimer_open() \
do { \
@@ -1,84 +0,0 @@
#ifndef ELITEIT
#define ELITEIT
#define absolute(a) ((a<0)? -a:a)
//static int32_t IT_Plot() {
// // read ADC current
// int32_t Real_Current = 0;
// ADCGainControl(INSTRUCTION.ADCGainLevel);
// ADCChannelSelect(ADC_CH_CURRENT);
// CPUdelay(10);
// ADC_read(spi_ADC_rxbuf);
//
// // check if ADC over/under flow
// // let the output saturate if over/under flow
//// ADC_overflow(INSTRUCTION.ADCGainLevel, spi_ADC_rxbuf);
//
// // decode ADC value and put it into notify buffer
// Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
//
// return Real_Current;
//}
static int32_t IT_Plot(WorkMode *WorkModeData) {
switch (INSTRUCTION.eliteFxn) {
case IV_CURVE:{
#define CURRENT_MODE WorkModeData->IV
break;
}
case CV_CURVE:{
#define CURRENT_MODE WorkModeData->CV
break;
}
case IT_CURVE:{
#define CURRENT_MODE WorkModeData->IT
break;
}
default: {
#define CURRENT_MODE WorkModeData->IT
break;
}
}
// read ADC current
int32_t RealCurrent = 0, RealVolt = 0;
static uint8_t PreviousGain = GAIN_200R;
if(INSTRUCTION.AutoGainEnable){
RealCurrent = AutoGainReadCurrent(spi_ADC_rxbuf);
if(PreviousGain != INSTRUCTION.ADCGainLevel){
PreviousGain = INSTRUCTION.ADCGainLevel;
CURRENT_MODE->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
CURRENT_MODE->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
}
if(PreviousGain != INSTRUCTION.ADCGainLevel){
PreviousGain = INSTRUCTION.ADCGainLevel;
CURRENT_MODE->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
CURRENT_MODE->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
}
}
else{
ReadCurrent(spi_ADC_rxbuf);
RealCurrent = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
}
CURRENT_MODE->_MeasureData = RealCurrent;
// if(INSTRUCTION.eliteFxn == IV_CURVE){
// // RealVo = Vo - RealCurrent * 100R
// RealVolt = (INSTRUCTION.VoltConstant - DAC_ZERO)/5 - 200*(RealCurrent/1e6);
//
// NotifyVolt[0] = (uint8_t) (RealVolt >> 24);
// NotifyVolt[1] = (uint8_t) ((RealVolt & 0x00FF0000) >> 16);
// NotifyVolt[2] = (uint8_t) ((RealVolt & 0x0000FF00) >> 8);
// NotifyVolt[3] = (uint8_t) (RealVolt & 0x000000FF);
// }
return RealCurrent;
}
#endif
@@ -1,263 +0,0 @@
#ifndef ELITEIV
#define ELITEIV
static uint16_t VoltScan(WorkMode *WorkModeData) {
uint16_t Voltage;
if (INSTRUCTION.VoltOrigin == INSTRUCTION.VoltFinal) {
Voltage = Usercode_Correction_to_DAC(INSTRUCTION.VoltOrigin);
DAC_outputV(Voltage);
PeriodicEvent = false;
return Voltage;
} else if (INSTRUCTION.eliteFxn == SQUARE_WAVE_VOLTAMMETRY) {
Voltage = SWVCurve(WorkModeData);
} else if (INSTRUCTION.eliteFxn == DIFFERENTIAL_PULSE_VOLTAMMETRY) {
Voltage = DPVCurve(WorkModeData);
} else if (INSTRUCTION.eliteFxn == CV_CURVE) {
Voltage = CVCurve(WorkModeData->CV);
}
// IV plot mode
else {
Voltage = OneWayVoltScan(WorkModeData->IV);
}
return Voltage;
}
static uint16_t OneWayVoltScan(IVMode *IV) {
uint16_t DACOutCode;
// reset origin volt at the begin
if (DACReset) {
// DACUserCode = IV->GetVOrigin((struct VoltOutPara *) IV);
INSTRUCTION.VoltConstant = IV->_VOrigin;
DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant);
DACReset = false;
// output VOLT_ORIGIN
DAC_outputV(DACOutCode);
return DACOutCode;
}
if (CT.StepTimeCounter == IV->_StepTime){
if (IV->_VOrigin < IV->_VStop) {//4~5V
// output the next output volt
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant + IV->_Step;
// Only used in two-wire IV
// if(INSTRUCTION.VoltConstant > IV->_VStop){
// INSTRUCTION.VoltConstant = IV->_VStop;
// }
DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant);
DAC_outputV(DACOutCode);
// end IV task if we reach INSTRUCTION.VoltFinal
// if (INSTRUCTION.VoltConstant >= IV->_VStop) {
// PeriodicEvent = false;
// DACReset = true;
// }
} else {
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant - IV->_Step;
// check if DACUserCode underflow
if(INSTRUCTION.VoltConstant >= 60000){
INSTRUCTION.VoltConstant = IV->_VStop;
}
// output the next output volt
DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant);
DAC_outputV(DACOutCode);
// end IV task if we reach INSTRUCTION.VoltFinal
// if (INSTRUCTION.VoltConstant <= IV->_VStop){
// PeriodicEvent = false;
// DACReset = true;
//// reset();
// }
}
// if (IV->_VoVi_Switch == 0x00 || IV->_VoVi_Switch == 0x01){ //user see Vout/user see Vin
// if (IV->_VOrigin < IV->_VStop) {
// if(INSTRUCTION.VoltConstant >= IV->_VStop){
// PeriodicEvent = false;
// DACReset = true;
// }
// }
// else{
// if(INSTRUCTION.VoltConstant <= IV->_VStop){
// PeriodicEvent = false;
// DACReset = true;
// }
// }
// }
// int32_t RealV;
// RealV = DAC_to_realV(DACOutCode);
// NotifyVolt[0] = (uint8_t)((RealV & 0xFF000000) >> 24);
// NotifyVolt[1] = (uint8_t)((RealV & 0x00FF0000) >> 16);
// NotifyVolt[2] = (uint8_t)((RealV & 0x0000FF00) >> 8);
// NotifyVolt[3] = (uint8_t)(RealV & 0x000000FF);
// int32_t RealV;
// RealV = (int32_t)(INSTRUCTION.VoltConstant - 25000)/5*1000;
// NotifyVolt[0] = (uint8_t)((RealV & 0xFF000000) >> 24);
// NotifyVolt[1] = (uint8_t)((RealV & 0x00FF0000) >> 16);
// NotifyVolt[2] = (uint8_t)((RealV & 0x0000FF00) >> 8);
// NotifyVolt[3] = (uint8_t)(RealV & 0x000000FF);
// NotifyImpedance[0] = 0x00;
// NotifyImpedance[1] = 0x00;
// NotifyImpedance[2] = (uint8_t)((INSTRUCTION.VoltConstant & 0xFF00) >> 8);
// NotifyImpedance[3] = (uint8_t)(INSTRUCTION.VoltConstant & 0x00FF);
}
return DACOutCode;
}
static void IV_Plot(IVMode *IV) {
static uint8_t VoltCurrentSwitch = 0;
static uint8_t PreviousGain = GAIN_200R;
uint16_t ADC_measure = 0;
if(VoltCurrentSwitch < 5){
ReadCurrent(spi_ADC_rxbuf);
VoltCurrentSwitch ++;
}
else if(VoltCurrentSwitch == 5){
// read current
if(INSTRUCTION.AutoGainEnable){
IV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
if(PreviousGain != INSTRUCTION.ADCGainLevel){
PreviousGain = INSTRUCTION.ADCGainLevel;
IV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
IV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
}
if(PreviousGain != INSTRUCTION.ADCGainLevel){
PreviousGain = INSTRUCTION.ADCGainLevel;
IV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
IV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
}
}
else{
ReadCurrent(spi_ADC_rxbuf);
IV->_MeasureData = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
}
VoltCurrentSwitch ++;
}
// else if(VoltCurrentSwitch < 9){
// // read volt
// ReadVolt(spi_ADC_rxbuf);
// VoltCurrentSwitch++;
// }
// else if(VoltCurrentSwitch == 9){
// /** read battery voltage **/
// ReadVolt(spi_ADC_rxbuf);
// ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
// IV->MeasureVolt = DecodeADCVolt(ADC_measure);
// VoltCurrentSwitch++;
// }
else if(VoltCurrentSwitch < 9){
if(IV->_VoVi_Switch == 0x01){
// read vin volt
ReadVolt(spi_ADC_rxbuf);
}else if(IV->_VoVi_Switch == 0x00){
// read vout volt
ReadVoutVolt(spi_ADC_rxbuf);
}
VoltCurrentSwitch++;
}
else if(VoltCurrentSwitch == 9){
if(IV->_VoVi_Switch == 0x01){
// read vin volt
ReadVolt(spi_ADC_rxbuf);
ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
IV->MeasureVolt = DecodeADCVolt(ADC_measure);
}else if(IV->_VoVi_Switch == 0x00){
// read vout volt
ReadVoutVolt(spi_ADC_rxbuf);
ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
IV->MeasureVolt = DecodeADCVoutVolt(ADC_measure);
}
VoltCurrentSwitch++;
}
// else if (VoltCurrentSwitch < 13){
// ReadBatVolt(spi_ADC_rxbuf);
// VoltCurrentSwitch ++;
// }
// else if (VoltCurrentSwitch == 13){
// // read battery volt
// ReadBatVolt(spi_ADC_rxbuf);
// ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
// IV->_MeasureBatvolt = DecodeADCBatVolt(ADC_measure);
// IV->_MeasureBatvolt = IV->_MeasureBatvolt/10 - 250; // (5.00V) 5000->250 usercode
// VoltCurrentSwitch ++;
// }
else{
VoltCurrentSwitch = 0;
}
NotifyCurrent[0] = (uint8_t) (IV->_MeasureData >> 24);
NotifyCurrent[1] = (uint8_t) ((IV->_MeasureData & 0x00FF0000) >> 16);
NotifyCurrent[2] = (uint8_t) ((IV->_MeasureData & 0x0000FF00) >> 8);
NotifyCurrent[3] = (uint8_t) (IV->_MeasureData & 0x000000FF);
// if((IV->_VoVi_Switch == 0x01) || (IV->_VoVi_Switch == 0x00)){ //user see Vin || user see Vout
//// NotifyVolt[0] = (uint8_t) (IV->MeasureVolt >> 24);
//// NotifyVolt[1] = (uint8_t) ((IV->MeasureVolt & 0x00FF0000) >> 16);
//// NotifyVolt[2] = (uint8_t) ((IV->MeasureVolt & 0x0000FF00) >> 8);
//// NotifyVolt[3] = (uint8_t) (IV->MeasureVolt & 0x000000FF);
// int32_t RealV;
// RealV = (int32_t)(INSTRUCTION.VoltConstant - 25000)/5*1000;
// NotifyVolt[0] = (uint8_t)((RealV & 0xFF000000) >> 24);
// NotifyVolt[1] = (uint8_t)((RealV & 0x00FF0000) >> 16);
// NotifyVolt[2] = (uint8_t)((RealV & 0x0000FF00) >> 8);
// NotifyVolt[3] = (uint8_t)(RealV & 0x000000FF);
//
// if (IV->_VOrigin < IV->_VStop) {
// if((IV->MeasureVolt/1000) >= ((int32_t) (IV->_VStop) - DAC_ZERO)/5){
// PeriodicEvent = false;
// DACReset = true;
// }
// }
// else{
// if((IV->MeasureVolt/1000) <= ((int32_t) (IV->_VStop) - DAC_ZERO)/5){
// PeriodicEvent = false;
// DACReset = true;
// }
// }
// }
if (IV->_VoVi_Switch == 0x00 || IV->_VoVi_Switch == 0x01){ //user see Vout/user see Vin
int32_t RealV;
RealV = (int32_t)(INSTRUCTION.VoltConstant - 25000)*1000/5;
NotifyVolt[0] = (uint8_t)((RealV & 0xFF000000) >> 24);
NotifyVolt[1] = (uint8_t)((RealV & 0x00FF0000) >> 16);
NotifyVolt[2] = (uint8_t)((RealV & 0x0000FF00) >> 8);
NotifyVolt[3] = (uint8_t)(RealV & 0x000000FF);
if (IV->_VOrigin < IV->_VStop) {
if(INSTRUCTION.VoltConstant >= IV->_VStop){
PeriodicEvent = false;
DACReset = true;
}
}
else{
if(INSTRUCTION.VoltConstant <= IV->_VStop){
PeriodicEvent = false;
DACReset = true;
}
}
}
// NotifyBatVolt = (uint8_t) (IV->_MeasureBatvolt & 0x000000FF);
}
#endif
@@ -1,83 +1,133 @@
/*=============================================================================
= instr.h =
=============================================================================*/
#ifndef ELITE_INSTR_H
#define ELITE_INSTR_H
#ifndef ELITEINSTRUCTION
#define ELITEINSTRUCTION
/** ADC gain level **/
#define GAIN_200K 0x00 // largest gain
#define GAIN_10K 0x01
#define GAIN_200R 0x02 // the least gain
#define GAIN_AUTO 0x03
/** Resister meter **/
#define RESISTER_METER_SMALL 0x00
#define RESISTER_METER_MIDDLE1 0x01
#define RESISTER_METER_MIDDLE2 0x02
#define RESISTER_METER_LARGE 0x03
/** CC mode parameter **/
// CurrentLV
#define CURRENT_LV_NA 0x00
#define CURRENT_LV_UA 0x01
#define CURRENT_LV_MA 0x02
/* DAC reset parameter */
#define DAC_ZERO 25000
#define DAC_POS_MAX 0x0000
#define DAC_NEG_MAX 0xFFFF
// Step time macro
#define STEPTIME_HALF_SEC 5000
#define STEPTIME_ONE_SEC 10000
#define STEPTIME_TWO_SEC 20000
#ifdef __cpulsplus
extern "C" {
#endif
/*==============================
==== headstage instruction ====
=============================*/
struct HEADSTAGE_INSTRUCTION {
/** chip ID */
uint8_t chip_id;
uint8_t chip_id;
uint8_t eliteFxn;
/** Sample rate **/
// SampleRate = SampleRateTable[SampleRateIndex]
uint8_t SampleRateIndex;
uint32_t SampleRate;
// time relation
uint8_t VsetRateIndex;
uint32_t VsetRate;
uint32_t sampleRate;
uint32_t notifyRate;
uint32_t period;
/** DAC parameter **/
// volt san parameter
uint16_t VoltOrigin;
uint16_t VoltFinal;
uint16_t Step;
uint16_t StepTime;
// constant volt
// which is used in CC mode as VMax and VMin
int32_t Vset;
uint16_t VoltConstant;
uint8_t directionInit;
uint32_t step;
uint16_t Ve1;
uint16_t Ve2;
int32_t Vinit;
int32_t Vmax;
int32_t Vmin;
/** ADC parameter **/
uint8_t ADCGainLevel;
uint32_t steptime;
uint8_t AutoGainEnable;
uint8_t IinADCAutoGainEn;
uint8_t VinADCAutoGainEn;
uint8_t VoutAutoGainEn;
uint8_t IinADCGainLv;
uint8_t VinADCGainLv;
uint16_t VoutGainLv;
uint8_t gain_switch_on;
uint8_t AdcChannel;
bool hign_z_en;
/** Notify parameter **/
uint16_t NotifyRate;
uint16_t cycleNumber;
uint8_t charge;
int32_t constantCurrent;
/** Constant Current Parameter **/
// Charge is a bool; true => current > 0, vice versa
uint8_t Charge;
int32_t ConstantCurrent;
uint16_t VoltLimit;
// uni pulse mode
int32_t v0;
uint32_t t_pulse[4];
int32_t v_initial[4];
int32_t v_slope[4];
int32_t v_step[4];
uint32_t t_pulse_min[4];
uint32_t t_pulse_max[4];
int32_t v_stop;
int32_t v_up;
int32_t v_low;
bool v_invert_option;
bool v_stop_direction;
int32_t v_1;
int32_t v_2;
/** Resister Measure **/
uint8_t ResisterMeter;
// elite function
uint8_t eliteFxn;
// pulse mode
int32_t sti_v1;
int32_t sti_v2;
int32_t sti_v3;
int32_t sti_v4;
int32_t sti_v5;
int32_t sti_v6;
int32_t sti_v7;
int32_t sti_t1;
int32_t sti_t2;
int32_t sti_t3;
int32_t sti_t4;
int32_t sti_t5;
int32_t sti_t6;
int32_t sti_t7;
uint16_t sti_cy;
uint16_t sti_loop;
uint8_t CycleNumber;
int32_t Vout;
uint8_t VoVi_Switch;
// not use
int32_t Currentmax;
uint8_t VoViSwitch;
} INSTRUCTION = {0};
} instru = {0};
/** Iin, Vin, Vout **/
#define RIS_ADC_IIN 0x00
#define RIS_ADC_VIN 0x01
#define RIS_DAC_VOUT 0x02
#define RIS_HIGH_Z 0x03
#define RIS_ADC_VOUT 0x04
#define RIS_ADC_BAT 0x05
// ADC Iin gain level !!! move to ADC.h in future
#define I_GAIN_3M 0x00 // lv0,largest gain
#define I_GAIN_100K 0x01 // lv1
#define I_GAIN_3K 0x02 // lv2
#define I_GAIN_100R 0x03 // lv3,the least gain
#define I_GAIN_AUTO 0x04
// ADC Vin gain level !!! move to ADC.h in future
#define VIN_GAIN_1M 0x00
#define VIN_GAIN_30K 0x01
#define VIN_GAIN_1K 0x02
#define VIN_GAIN_AUTO 0x03
// DAC Vout gain level !!! move to DAC.h in future
#define VOUT_GAIN_240K 0x00
#define VOUT_GAIN_15K 0x01
#define VOUT_GAIN_AUTO 0x02
/* DAC reset parameter */
#define DAC_ZERO 25000 // DAC_ZERO is about 0V
// Step time macro
#define STEPTIME_HALF_SEC 5000
#define STEPTIME_ONE_SEC 10000
#define STEPTIME_TWO_SEC 20000
/*********************************************************************
* @fn InitEliteInstruction
@@ -88,52 +138,103 @@ struct HEADSTAGE_INSTRUCTION {
*
* @return None.
*/
static void InitEliteInstruction(){
INSTRUCTION.chip_id = 0;
INSTRUCTION.SampleRateIndex = 1;
INSTRUCTION.SampleRate = 100;
INSTRUCTION.VoltOrigin = DAC_ZERO;
INSTRUCTION.VoltFinal = DAC_ZERO;
INSTRUCTION.Step = 0x0005; // 0x0005 = 1mV
INSTRUCTION.StepTime = STEPTIME_ONE_SEC; // about 0.5 sec
INSTRUCTION.VoltConstant = DAC_ZERO; // is about 0V
INSTRUCTION.ADCGainLevel = GAIN_AUTO;
INSTRUCTION.AutoGainEnable = 1;
INSTRUCTION.NotifyRate = STEPTIME_ONE_SEC/10;
INSTRUCTION.ResisterMeter = RESISTER_METER_LARGE;
INSTRUCTION.Charge = 1;
INSTRUCTION.ConstantCurrent = 0x00000000;
INSTRUCTION.VoltLimit = 0x0000;
INSTRUCTION.eliteFxn = 0; // default is a null event
INSTRUCTION.CycleNumber = 0;
INSTRUCTION.VoVi_Switch = 0x01; //VoVi_Switch == 0 => user see Vo / VoVi_Switch == 1 => user see Vi
static void InitEliteInstruction(void)
{
instru.chip_id = 0;
instru.eliteFxn = 0; //default is a null event
instru.VsetRateIndex = 0; // vscan rate
instru.VsetRate = 2;
instru.sampleRate = 15; // ADC's sample rate
instru.notifyRate = CLOCK_ONE_SECOND; // send data's rate
instru.period = CLOCK_ONE_SECOND;
instru.Vset = 0; // vscan's volt[5nv]
instru.VoltConstant = DAC_ZERO; // DAC's volt[UC]
instru.directionInit = 1; // 0:reverse, 1:forward
instru.step = 0;
instru.Ve1 = DAC_ZERO; // user set volt[UC]
instru.Ve2 = DAC_ZERO; // user set volt[UC]
instru.Vinit = 0; // user set init volt[5nv]
instru.Vmax = 0; // user set max volt[5nv]
instru.Vmin = 0; // user set min voit[5nv]
instru.IinADCAutoGainEn = 1;
instru.VinADCAutoGainEn = 1;
instru.VoutAutoGainEn = 1;
instru.IinADCGainLv = I_GAIN_AUTO;
instru.VinADCGainLv = VIN_GAIN_AUTO;
instru.VoutGainLv = VOUT_GAIN_AUTO;
instru.gain_switch_on = 0b11110000; // cur auto gain switch, |lv0|lv1|lv2|lv3|none|none|none|none|
instru.AdcChannel = 0; // RIS_ADC_IIN: 0x00, RIS_ADC_VIN: 0x01, RIS_DAC_VOUT: 0x02, RIS_HIGH_Z: 0x03
instru.hign_z_en = 1;
instru.cycleNumber = 1;
instru.charge = 1; // 0:discharge, 1:charge
instru.constantCurrent = 0;
// uni pulse mode
instru.v0 = DAC_ZERO; // t < 0, volt is 0v
instru.v_stop = 0;
instru.t_pulse[0] = 0;
instru.t_pulse[1] = 0;
instru.t_pulse[2] = 0;
instru.t_pulse[3] = 0;
instru.v_initial[0] = 0;
instru.v_initial[1] = 0;
instru.v_initial[2] = 0;
instru.v_initial[3] = 0;
instru.v_slope[0] = 0;
instru.v_slope[1] = 0;
instru.v_slope[2] = 0;
instru.v_slope[3] = 0;
instru.v_step[0] = 0;
instru.v_step[1] = 0;
instru.v_step[2] = 0;
instru.v_step[3] = 0;
instru.t_pulse_min[0] = 0;
instru.t_pulse_min[1] = 0;
instru.t_pulse_min[2] = 0;
instru.t_pulse_min[3] = 0;
instru.t_pulse_max[0] = 0;
instru.t_pulse_max[1] = 0;
instru.t_pulse_max[2] = 0;
instru.t_pulse_max[3] = 0;
instru.v_invert_option = false;
instru.v_stop_direction = true;
instru.v_1 = 0;
instru.v_2 = 0;
//pulse mode
instru.sti_t1 = 0;
instru.sti_t2 = 0;
instru.sti_t3 = 0;
instru.sti_t4 = 0;
instru.sti_t5 = 0;
instru.sti_t6 = 0;
instru.sti_t7 = 0;
instru.sti_v1 = DAC_ZERO;
instru.sti_v2 = DAC_ZERO;
instru.sti_v3 = DAC_ZERO;
instru.sti_v4 = DAC_ZERO;
instru.sti_v5 = DAC_ZERO;
instru.sti_v6 = DAC_ZERO;
instru.sti_v7 = DAC_ZERO;
instru.sti_loop = 1;
instru.sti_cy = 0;
instru.Vout = 0;
// not use
instru.Currentmax = 0;
instru.VoViSwitch = 0x01;
return;
}
/*********************************************************************
* @fn GetInstructionParameter
*
* @brief Get Constant Current mode parameter.
*
* @param ins - instruction including current value and unit
*
* @return None.
*/
static void GetInstructionParameter(uint8 *ins){
// CurrentLV=0 => unit is nA
// CurrentLV=1 => unit is uA
// CurrentLV=2 => unit is mA
// INSTRUCTION.CurrentLV = (*ins);
// ConstantCurrentRange=0 => current value is 0~499
// ConstantCurrentRange=1 => current value is 500~999
// INSTRUCTION.ConstantCurrentRange = (*ins) & 0x0F;
// ConstantCurrent divide ConstantCurrentRange into 50000 count (thus each count is 0.01)
// e.g. 485.7 uA can be represent by
// CurrentLV = 1 (unit is uA)
// ConstantCurrentRange = 0 (current range is 0~499)
// ConstantCurrent = 48570
INSTRUCTION.ConstantCurrent = (uint32_t) (*(ins+1))<<24 | (uint32_t) (*(ins+2))<<16 | (uint32_t) (*(ins+3))<<8 | (uint32_t) (*(ins+4));
#ifdef __cpulsplus
}
#endif
#endif
@@ -2,25 +2,31 @@
#ifndef ELITEKEYDETECT
#define ELITEKEYDETECT
#define CLOCK_ONE_SECOND 10000
static bool TurnOnElite(uint8_t key) {
static uint16_t TurnOnCounter = 0;
if (key == 0) {
// press 1 sec, power on LED
// press 1 sec, power on LED, read bat power
if (TurnOnCounter >= CLOCK_ONE_SECOND) {
PIN_setOutputValue(pin_handle, enable_5v, 1); // enable 5V
TurnOn10V();
LEDPowerON();
return true;
headstage_battery_volt();
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) |
((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
if( bat < 768 && bat > 20){
PIN15_setOutputValue(enable_5v, 0);
return false;
}else{
PIN15_setOutputValue(enable_5v, 1); // enable 5V
TurnOn10V();
ModeLED(BT_WAIT);
return true;
}
} else {
TurnOnCounter++;
return false;
}
} else {
TurnOnCounter = 0;
PIN_setOutputValue(pin_handle, enable_5v, 0); // enable 5V
PIN15_setOutputValue(enable_5v, 0); // disable 5V
return false;
}
}
@@ -34,36 +40,35 @@ static void EliteKeyPress(uint8_t key) {
// press key => bight LED
if (ShutDownCounter == CLOCK_ONE_SECOND) {
KeyWorkModeLED();
KEYLED();
}
// press 3~4 sec, shutdown 2650
else if (ShutDownCounter > (CLOCK_ONE_SECOND*3) ) {
LED_color(DARKLED, 0xFF, 0xFF, 0x00);
PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V
PIN15_setOutputValue(enable_5v, 0); // disable 5V
}
ShutDownCounter ++;
} else {
if (OriginEliteFxn == INSTRUCTION.eliteFxn) { // old function == currunt instruction
if (OriginEliteFxn == instru.eliteFxn) { // old function == currunt instruction
if (ShutDownCounter != 0) {
// dark LED
WorkModeLED();
checkFlafLED();
ShutDownCounter = 0;
}
} else { // old function != currunt instruction
OriginEliteFxn = INSTRUCTION.eliteFxn;
OriginEliteFxn = instru.eliteFxn;
if (ShutDownCounter != 0) {
ShutDownCounter = 0;
}
// dark mode LED
WorkModeLED();
checkFlafLED();
}
}
}
static void TurnOn10V() {
If10Von = true;
PIN_setOutputValue(pin_handle, enable_10v, 1);
PIN15_setOutputValue(enable_10v, 1);
CPUdelay(8000);
}
@@ -2,12 +2,16 @@
#ifndef ELITELED
#define ELITELED
#define DARKLED 0xE1
#define LIGHTLED 0xE8
static void LED_color(uint8_t bright, uint8_t red, uint8_t green, uint8_t blue);
#define LEDPowerON() LED_color(DARKLED, 0x00, 0xFA, 0x00)
#define WORKLED() LED_color(0xE2, 0x00, 0x40, 0x40)
#define KEYLED() LED_color(LIGHTLED, 0xF0, 0xA0, 0x00)
#define DARKLED 0xE1
#define LIGHTLED 0xE8
static bool btWaitLedFlag = 0;
static bool noEventLedFlag = 0;
static bool preWorkLedFlag = 0;
static bool workingLedFlag = 0;
static bool postWorkLedFlag = 0;
static void WorkModeLED();
static void LED_color(uint8_t bright, uint8_t red, uint8_t green, uint8_t blue) {
spi_LEDtxbuf[0] = 0x0000;
@@ -23,57 +27,112 @@ static void LED_color(uint8_t bright, uint8_t red, uint8_t green, uint8_t blue)
LED_SPI(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf);
}
static void WorkModeLED() {
switch (INSTRUCTION.eliteFxn) {
case IV_CURVE: {
WORKLED();
static void Elite_led_color(uint16_t color){
switch (color) {
case COLOR_RED: {
LED_color(DARKLED, 0xFF, 0x00, 0x00);
break;
}
case COLOR_ORANGE: {
LED_color(DARKLED, 0xFF, 0x58, 0x09);
break;
}
case COLOR_YELLOW: {
LED_color(LIGHTLED, 0xFF, 0x80, 0x00);
break;
}
case COLOR_GREEN: {
LED_color(DARKLED, 0x00, 0xFA, 0x00);
break;
}
case COLOR_YELLOWGREEN: {
LED_color(DARKLED, 0x64, 0xA6, 0x00);
break;
}
case COLOR_BLUE: {
LED_color(DARKLED, 0x00, 0x00, 0xAA);
break;
}
case COLOR_CYAN: {
LED_color(DARKLED, 0x00, 0x40, 0x40);
break;
}
case COLOR_MAGENTA: {
LED_color(DARKLED, 0xFF, 0x00, 0x80);
break;
}
case COLOR_PURPLE: {
LED_color(DARKLED, 0xFF, 0x00, 0xFF);
break;
}
case COLOR_WHITE: {
LED_color(DARKLED, 0xCA, 0xFF, 0xFF);
break;
}
case COLOR_BLACK: {
LED_color(0x00, 0x00, 0x00, 0x00);
break;
}
//dark LED
case COLOR_YELLOW_DARK: {
LED_color(DARKLED, 0xFF, 0x80, 0x00);
break;
}
case COLOR_GREEN_DARK: {
LED_color(DARKLED, 0x00, 0x33, 0x00);
break;
}
case COLOR_BLUE_DARK: {
LED_color(DARKLED, 0x00, 0x00, 0x33);
break;
}
case COLOR_CYAN_DARK: {
LED_color(DARKLED, 0x00, 0x10, 0x10);
break;
}
case COLOR_PURPLE_DARK: {
LED_color(DARKLED, 0x55, 0x00, 0x55);
break;
}
default: {
break;
}
}
}
static void ModeLED(uint16_t modeStatus) {
btWaitLedFlag = 0;
noEventLedFlag = 0;
preWorkLedFlag = 0;
workingLedFlag = 0;
postWorkLedFlag = 0;
switch (modeStatus) {
case BT_WAIT: {
btWaitLedFlag = 1;
BT_WAIT_LED();
break;
}
case CV_CURVE: {
WORKLED();
break;
}
case DIFFERENTIAL_PULSE_VOLTAMMETRY: {
WORKLED();
break;
}
case SQUARE_WAVE_VOLTAMMETRY: {
WORKLED();
break;
}
case VOLT_OUTPUT: {
WORKLED();
break;
}
case ZT_CURVE: {
WORKLED();
break;
}
case VT_CURVE: {
WORKLED();
break;
}
case IT_CURVE: {
WORKLED();
break;
}
case CONSTANT_CURRENT:{
WORKLED();
break;
}
case VIS_RST: {
case NO_EVENT: {
noEventLedFlag = 1;
LEDPowerON();
break;
}
case ADC_TEST: {
WORKLED();
case PRE_WORK: {
preWorkLedFlag = 1;
Elite_led_color(COLOR_BLUE);
break;
}
case READ_VOUT_VALUE: {
WORKLED();
case WORKING: {
workingLedFlag = 1;
WorkModeLED();
break;
}
case POST_WORK: {
postWorkLedFlag = 1;
Elite_led_color(COLOR_BLUE);
break;
}
default: {
LEDPowerON();
break;
@@ -81,58 +140,62 @@ static void WorkModeLED() {
}
}
static void KeyWorkModeLED() {
KEYLED();
/*
switch(INSTRUCTION.eliteFxn){
case IV_CURVE:{
LED_color(LIGHTLED, 0xF0, 0xF0, 0x00);
break;
}
case CV_CURVE:{
LED_color(LIGHTLED, 0xF0, 0xF0, 0x00);
break;
}
case DIFFERENTIAL_PULSE_VOLTAMMETRY:{
LED_color(LIGHTLED, 0xF0, 0xF0, 0x00);
break;
}
case SQUARE_WAVE_VOLTAMMETRY:{
LED_color(LIGHTLED, 0xF0, 0xF0, 0x00);
break;
}
case VOLT_OUTPUT:{
LED_color(LIGHTLED, 0xF0, 0xF0, 0x00);
break;
}
case ZT_CURVE:{
LED_color(LIGHTLED, 0xF0, 0xF0, 0x00);
break;
}
case VT_CURVE:{
LED_color(LIGHTLED, 0xF0, 0xF0, 0x00);
break;
}
case IT_CURVE:{
LED_color(LIGHTLED, 0xF0, 0xF0, 0x00);
break;
}
case VIS_RST:{
LED_color(LIGHTLED, 0xF0, 0xF0, 0x00);
break;
}
case ADC_TEST:{
LED_color(LIGHTLED, 0xF0, 0xF0, 0x00);
break;
}
default:{
LED_color(LIGHTLED, 0xF0, 0xF0, 0x00);
break;
}
static void checkFlafLED()
{
if(btWaitLedFlag == 1){
ModeLED(BT_WAIT);
}
else if(noEventLedFlag == 1){
ModeLED(NO_EVENT);
}
else if(preWorkLedFlag == 1){
ModeLED(PRE_WORK);
}
else if(workingLedFlag == 1){
ModeLED(WORKING);
}
else if(postWorkLedFlag == 1){
ModeLED(POST_WORK);
}
}
static void WorkModeLED()
{
switch (instru.eliteFxn) {
case CURVE_IV:
case CURVE_VO:
case CURVE_RT:
case CURVE_VT:
case CURVE_IT:
case CURVE_CV:
case CURVE_CA:
case CURVE_CC:
case CURVE_OCP:
case CURVE_LSV:
case CURVE_IV_CY:
case CURVE_PULSE:
case CURVE_UNI_PULSE:
case CURVE_DPV:
case CURVE_DPV_SMPRATE:
case CURVE_DPV_ADVANCE:
case CURVE_DPV_ADVANCE_SMPRATE:
WORKLED();
break;
case CURVE_CALI_ADC:
if (instru.AdcChannel == RIS_ADC_IIN) {
Elite_led_color(COLOR_RED);
} else if (instru.AdcChannel == RIS_ADC_VIN) {
Elite_led_color(COLOR_ORANGE);
} else if (instru.AdcChannel == RIS_DAC_VOUT) {
Elite_led_color(COLOR_BLUE);
}
break;
default:
break;
}
*/
}
#endif
@@ -0,0 +1,16 @@
#ifndef ELITE_LATCH_INIT
#define ELITE_LATCH_INIT
static void InitLH() {
for (int i=0; i<LATCH_BUFF_SIZE; i++) {
LH.LATCH0[i] = 0;
LH.LATCH1[i] = 0;
LH.LATCH2[i] = 0;
}
LH.LoadState = 0;
}
#endif
@@ -1,67 +1,31 @@
#ifndef ELITENOTIFY
#define ELITENOTIFY
#include "headstage.h"
/**
* notify data buffer.
* the length equals to the characteristic 4 which value is 20 bytes.
*
*/
#ifndef ELITENOTIFY
#define ELITENOTIFY
#define NOT_BUF_OFFSET_INIT 8
#include "headstage.h"
/**
* the index where to start insert data into buffer.
* start from 6.
*/
static size_t not_buf_offset = NOT_BUF_OFFSET_INIT;
/*notify's input type*/
#define NOTIFY_CURRENT 0
#define NOTIFY_VOLT 1
#define NOTIFY_IMPEDANCE 2
#define NOTIFY_VOLT_BAT 3
#define NOTIFY_TEMPERATURE 4
#define FINISH_MODE_INS 0b10100000
static uint32_t not_time_stamp;
static uint8_t NotifyCurrent[4] = {0};
static uint8_t NotifyVolt[4] = {0};
static uint8_t NotifyImpedance[4] = {0};
static uint8_t NotifyBatVolt = 0;
/**
* counter of notify send.
*/
static uint32_t notify_counter = 0;
// ****************** New Notify Format ******************************** //
/*
* Notify format
*
*
| | 1 | 2 | 3 |
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 2
-----------------------------------------------------------------
| header |
| current |
| voltage or impedance |
| mode & gain |
| time stamp |
| cycle number |
mode & gain
this byte include Elite working mode and ADC gain level
we use "(mode & 0xF0) | (gain & 0x0F)" to encode these two information
cycle number
for cyclic voltammetry use, we save it as channel number.
0xFF
* header = device ID
* I = current (0.001nA), V = voltage (mV),
* Z = impedance (k ohm), T = time (ms)
*
*
*/
// ********* End New Format Notify ***************************************** //
static uint8_t NotifyCurrent[4] = {0};
static uint8_t NotifyVolt[4] = {0};
static uint8_t NotifyImpedance[4] = {0};
static uint8_t NotifyVoltBat[4] = {0};
static uint8_t NotifyTemperature[4] = {0};
static uint16_t NotifyCycleNumber = 0;
static bool finishMode = false;
/*
* Notify format
@@ -82,13 +46,15 @@ static uint32_t notify_counter = 0;
0xFF
* header = device ID
* I = current (0.001nA), V = voltage (mV),
* Z = impedance (k ohm), T = time (ms)
* I = current (nA), V = voltage (uV),
* Z = impedance (ohm), T = time (ms)
*
*
*/
static void SendNotify() {
not_buf[0] = INSTRUCTION.chip_id;
initDATBuf();
not_buf[0] = instru.chip_id;
for (int i = 0; i < 4; i++) {
not_buf[i + 1] = NotifyCurrent[i];
@@ -104,39 +70,98 @@ static void SendNotify() {
not_buf[15] = (not_time_stamp >> 16) & 0xff;
not_buf[16] = (not_time_stamp >> 24) & 0xff;
// cyclic voltametry cycle number
not_buf[17] = INSTRUCTION.CycleNumber;
not_buf[17] = (NotifyCycleNumber >> 8) & 0xff;
not_buf[18] = NotifyCycleNumber & 0xff;
//battery volt
not_buf[18] = NotifyBatVolt;
if (finishMode) {
not_buf[19] = (FINISH_MODE_INS) & 0b11110000;
} else {
not_buf[19] = 0 & 0b11110000;
}
// for (int i = 20; i < BLE_DAT_BUFF_SIZE; i++){
// not_buf[i] = 0;
// }
SimpleProfile_SetParameter(BLE_DAT_BUFF_CHAR, BLE_DAT_BUFF_SIZE, not_buf);
}
static void initDATBuf(){
for (int i = 0; i < BLE_DAT_BUFF_SIZE; i++){
not_buf[i] = 0;
}
}
static void initINSBuf(){
for (int i = 0; i < BLE_INS_BUFF_SIZE; i++){
ins_buf[i] = 0;
}
}
static void initCISBuf(){
for (int i = 0; i < BLE_CIS_BUFF_SIZE; i++){
cis_buf[i] = 0;
}
}
static void initRawDataBuf(){
not_time_stamp = 0;
NotifyCycleNumber = 0;
finishMode = false;
for (int i = 0; i < 4; i++){
NotifyCurrent[i] = 0;
NotifyVolt[i] = 0;
NotifyImpedance[i] = 0;
}
}
static void FlushNotify(){
not_buf[0] = INSTRUCTION.chip_id;
initRawDataBuf();
initDATBuf();
for (int i = 0; i < 4; i++) {
not_buf[i + 1] = 0;
not_buf[i + 5] = 0;
not_buf[i + 9] = 0;
}
// 1 Timestamp = 32 usec; 31 Timestamp ~= 1 msec
not_time_stamp = 0; // msec
not_buf[13] = not_time_stamp & 0xff;
not_buf[14] = (not_time_stamp >> 8) & 0xff;
not_buf[15] = (not_time_stamp >> 16) & 0xff;
not_buf[16] = (not_time_stamp >> 24) & 0xff;
// cyclic voltametry cycle number
not_buf[17] = 0x00;
//battery volt
not_buf[18] = 0x00;
not_buf[0] = instru.chip_id;
SimpleProfile_SetParameter(BLE_DAT_BUFF_CHAR, BLE_DAT_BUFF_SIZE, not_buf);
}
static void InputNotify(int NotifyType, int32_t Data){
switch (NotifyType) {
case NOTIFY_CURRENT:
NotifyCurrent[0] = (uint8_t)((Data & 0xFF000000) >> 24);
NotifyCurrent[1] = (uint8_t)((Data & 0x00FF0000) >> 16);
NotifyCurrent[2] = (uint8_t)((Data & 0x0000FF00) >> 8);
NotifyCurrent[3] = (uint8_t)(Data & 0x000000FF);
break;
case NOTIFY_IMPEDANCE:
NotifyImpedance[0] = (uint8_t)((Data & 0xFF000000) >> 24);
NotifyImpedance[1] = (uint8_t)((Data & 0x00FF0000) >> 16);
NotifyImpedance[2] = (uint8_t)((Data & 0x0000FF00) >> 8);
NotifyImpedance[3] = (uint8_t)(Data & 0x000000FF);
break;
case NOTIFY_VOLT :
NotifyVolt[0] = (uint8_t)((Data & 0xFF000000) >> 24);
NotifyVolt[1] = (uint8_t)((Data & 0x00FF0000) >> 16);
NotifyVolt[2] = (uint8_t)((Data & 0x0000FF00) >> 8);
NotifyVolt[3] = (uint8_t)(Data & 0x000000FF);
break;
case NOTIFY_VOLT_BAT :
NotifyVoltBat[0] = (uint8_t)((Data & 0xFF000000) >> 24);
NotifyVoltBat[1] = (uint8_t)((Data & 0x00FF0000) >> 16);
NotifyVoltBat[2] = (uint8_t)((Data & 0x0000FF00) >> 8);
NotifyVoltBat[3] = (uint8_t)(Data & 0x000000FF);
break;
case NOTIFY_TEMPERATURE :
NotifyTemperature[0] = (uint8_t)((Data & 0xFF000000) >> 24);
NotifyTemperature[1] = (uint8_t)((Data & 0x00FF0000) >> 16);
NotifyTemperature[2] = (uint8_t)((Data & 0x0000FF00) >> 8);
NotifyTemperature[3] = (uint8_t)(Data & 0x000000FF);
break;
}
}
#endif
@@ -1,22 +0,0 @@
#ifndef ELITERVout
#define ELITERVout
static void RVout_Plot(RVoutMode *RVout) {
// ADC gain is don't care when measuring voltage
INSTRUCTION.ADCGainLevel = GAIN_200R;
ADCGainControl(INSTRUCTION.ADCGainLevel);
// read ADC VoutVolt
ReadVoutVolt(spi_ADC_rxbuf);
// decode ADC value and put it into notify buffer
RVout->_MeasureData = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
NotifyVolt[0] = (uint8_t) (RVout->_MeasureData >> 24);
NotifyVolt[1] = (uint8_t) ((RVout->_MeasureData & 0x00FF0000) >> 16);
NotifyVolt[2] = (uint8_t) ((RVout->_MeasureData & 0x0000FF00) >> 8);
NotifyVolt[3] = (uint8_t) (RVout->_MeasureData & 0x000000FF);
}
#endif
@@ -3,26 +3,21 @@
#define ELITERESET
static void reset() {
InitFlag();
InitCT();
megaStiEnable = false;
PeriodicEvent = false; // is there an PeriodicEvent?
Free_Work_Mode = true; // Free(WorkModeData)
// IV/CV mode reset
DiscardIVFirstData = 0;
avg_number = 0;
ADCRealCurrent_long = 0;
initINSBuf();
initDATBuf();
ADCGainControl(INSTRUCTION.ADCGainLevel);
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
PIN15_setOutputValue(HIGH_Z_MODE, 0); // HIGH Z MODE // 1: close; 0: open;
if (INSTRUCTION.eliteFxn == CONSTANT_CURRENT){
INSTRUCTION.eliteFxn = 0;
VinADCGainCtrl(VIN_GAIN_AUTO);
IinADCGainCtrl(I_GAIN_AUTO);
}
LEDPowerON();
for (int i = 0; i < BLE_INS_BUFF_SIZE; i++) {
ins_buf[i] = 0;
}
instru.VoutGainLv = VOUT_GAIN_15K;
VoutGainControl(instru.VoutGainLv);
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
for (int i = 0; i < SPI_LED_SIZE; i++) {
spi_LEDtxbuf[i] = 0;
@@ -39,30 +34,23 @@ static void reset() {
spi_ADC_rxbuf[i] = 0;
}
for (int i = 0; i < BLE_DAT_BUFF_SIZE; i++) {
not_buf[i] = 0;
}
PIN_setOutputValue(pin_handle, ADC_CS, 1); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, DAC_CS, 1); // DAC_CS HIGH
ModeLED(NO_EVENT);
CPUdelay(1600);
}
static void Eliteinterrupt() {
InitFlag();
InitCT();
megaStiEnable = false;
PeriodicEvent = false; // is there an PeriodicEvent?
Free_Work_Mode = true; // Free(WorkModeData)
// IV/CV mode reset
DiscardIVFirstData = 0;
avg_number = 0;
ADCRealCurrent_long = 0;
ADCGainControl(GAIN_AUTO);
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
initINSBuf();
initDATBuf();
LEDPowerON();
for (int i = 0; i < BLE_INS_BUFF_SIZE; i++) {
ins_buf[i] = 0;
}
PIN15_setOutputValue(HIGH_Z_MODE, 0); // HIGH Z MODE // 1: close; 0: open;
instru.VoutGainLv = VOUT_GAIN_15K;
VoutGainControl(instru.VoutGainLv);
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
for (int i = 0; i < SPI_LED_SIZE; i++) {
spi_LEDtxbuf[i] = 0;
@@ -79,45 +67,7 @@ static void Eliteinterrupt() {
spi_ADC_rxbuf[i] = 0;
}
for (int i = 0; i < BLE_DAT_BUFF_SIZE; i++) {
not_buf[i] = 0;
}
PIN_setOutputValue(pin_handle, ADC_CS, 1); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, DAC_CS, 1); // DAC_CS HIGH
ModeLED(NO_EVENT);
CPUdelay(8000);
}
static void CleanBuffer() {
InitFlag();
InitEliteInstruction();
InitCT();
DiscardIVFirstData = 0;
avg_number = 0;
ADCRealCurrent_long = 0;
for (int i = 0; i < SPI_LED_SIZE; i++) {
spi_LEDtxbuf[i] = 0;
spi_LEDrxbuf[i] = 0;
}
for (int i = 0; i < SPI_DAC_SIZE; i++) {
spi_DACtxbuf[i] = 0;
spi_rxbuf[i] = 0;
}
for (int i = 0; i < SPI_ADC_SIZE; i++) {
spi_ADC_txbuf[i] = 0;
spi_ADC_rxbuf[i] = 0;
}
for (int i = 0; i < BLE_DAT_BUFF_SIZE; i++) {
not_buf[i] = 0;
}
PIN_setOutputValue(pin_handle, ADC_CS, 1); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, DAC_CS, 1); // DAC_CS HIGH
CPUdelay(8000);
}
#endif
@@ -36,6 +36,8 @@ static SPI_Params spiParams1;
static SPI_Transaction LED_transaction;
static SPI_Transaction ADC_DAC_transaction;
static void ELITE15_SPI_HOLD();
static void ELITE15_SPI_CLOSE();
static void Elite_SPI_init(){
SPI_init();
@@ -63,26 +65,73 @@ static void LED_SPI(uint8_t length, uint16_t *spi_txbuf, uint16_t *spi_rxbuf) {
}
static void ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
// PIN15_setOutputValue(ADC_CS, 0); // ADC_CS LOW
PIN_setOutputValue(pin_handle, LOAD0, 1);
PIN_setOutputValue(pin_handle, D6, 0); // ADC_CS LOW
ADC_DAC_transaction.count = length;
ADC_DAC_transaction.txBuf = spi_txbuf;
ADC_DAC_transaction.rxBuf = spi_rxbuf;
PIN_setOutputValue(pin_handle, DAC_CS, 1); // DAC_CS HIGH
PIN_setOutputValue(pin_handle, ADC_CS, 0); // ADC_CS LOW
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
PIN_setOutputValue(pin_handle, ADC_CS, 1); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, D6, 1); // ADC_CS HIGH
update_latch_status (ADC_CS, 1);
// PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
}
static void DAC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
ADC_DAC_transaction.count = length;
ADC_DAC_transaction.txBuf = spi_txbuf;
ADC_DAC_transaction.rxBuf = spi_rxbuf;
// PIN15_setOutputValue(DAC_CS, 0); // DAC_CS LOW
PIN_setOutputValue(pin_handle, LOAD0, 1);
PIN_setOutputValue(pin_handle, D7, 0); // DAC_CS LOW
PIN_setOutputValue(pin_handle, ADC_CS, 1); // ADC_CS HIGH
PIN_setOutputValue(pin_handle, DAC_CS, 0); // DAC_CS LOW
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
PIN_setOutputValue(pin_handle, DAC_CS, 1); // DAC_CS HIGH
ADC_DAC_transaction.count = length;
ADC_DAC_transaction.txBuf = spi_txbuf;
ADC_DAC_transaction.rxBuf = spi_rxbuf;
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
PIN_setOutputValue(pin_handle, D7, 1); // DAC_CS HIGH
update_latch_status (DAC_CS, 1);
// PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
}
static void ELITE15_SPI_HOLD() {
Elite_SPI_init();
#ifdef ELITE_PIN_1_5_RE
PIN_setOutputValue(pin_handle, D6, LH.LATCH0[6]); // ADC_CS
PIN_setOutputValue(pin_handle, D7, LH.LATCH0[7]); // DAC_CS
PIN_setOutputValue(pin_handle, D4, LH.LATCH0[4]); // update HIGH_Z_MODE
#endif
PIN_setOutputValue(pin_handle, LOAD0, 1);
PIN_setOutputValue(pin_handle, LOAD1, 0);
PIN_setOutputValue(pin_handle, LOAD2, 0);
}
static void ELITE15_SPI_CLOSE() {
PIN_setOutputValue(pin_handle, LOAD0, 0);
PIN_setOutputValue(pin_handle, LOAD1, 0);
PIN_setOutputValue(pin_handle, LOAD2, 0);
SPI_close(spiHandle0);
SPI_close(spiHandle1);
}
/* Elite1.5 Calibration SPI */
static void CAL_ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
// PIN15_setOutputValue(ADC_CS, 0); // ADC_CS LOW
PIN_setOutputValue(pin_handle, LOAD0, 1);
PIN_setOutputValue(pin_handle, D6, 0); // ADC_CS LOW
ADC_DAC_transaction.count = length;
ADC_DAC_transaction.txBuf = spi_txbuf;
ADC_DAC_transaction.rxBuf = spi_rxbuf;
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
PIN_setOutputValue(pin_handle, D6, 1); // ADC_CS HOGH
update_latch_status (ADC_CS, 1);
// PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
}
#endif // ELITE_SPI
@@ -1,22 +0,0 @@
#ifndef ELITEVT
#define ELITEVT
static void VT_Plot(VTMode *VT) {
// ADC gain is don't care when measuring voltage
INSTRUCTION.ADCGainLevel = GAIN_200R;
ADCGainControl(INSTRUCTION.ADCGainLevel);
// read ADC volt
ReadVolt(spi_ADC_rxbuf);
// decode ADC value and put it into notify buffer
VT->_MeasureData = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
NotifyVolt[0] = (uint8_t) (VT->_MeasureData >> 24);
NotifyVolt[1] = (uint8_t) ((VT->_MeasureData & 0x00FF0000) >> 16);
NotifyVolt[2] = (uint8_t) ((VT->_MeasureData & 0x0000FF00) >> 8);
NotifyVolt[3] = (uint8_t) (VT->_MeasureData & 0x000000FF);
}
#endif
@@ -1,109 +0,0 @@
#ifndef ELITEZT
#define ELITEZT
static void ZT_notify(int32_t impedance);
// output a certain voltage e.g. 2v
// and measure the input voltage
// => calculate the resister
// change the output voltage step
// => get a R-T curve (with resolution = 1 sample/volt step )
static void ZT_Plot(RTMode *RT) {
// int32_t Real_Resister = 0;
// static uint16_t CurrentMeasure=0, VoltMeasure=0;
// uint8_t SPICurrent[SPI_ADC_SIZE]={0}, SPIVolt[SPI_ADC_SIZE]={0};
// static uint8_t VoltCurrentSwitch = 0;
int32_t volt_32 = 0;
int32_t current_32 = 0;
int32_t resister_32 = 0;
if(INSTRUCTION.AutoGainEnable){
current_32 = AutoGainReadCurrent(spi_ADC_rxbuf);
}
else{
ReadCurrent(spi_ADC_rxbuf);
current_32 = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
}
volt_32 = User2Real(INSTRUCTION.VoltConstant)*1e5;
// ReadVolt(SPIVolt);
// VoltMeasure = (uint16_t) (SPIVolt[0] << 8) | (uint16_t) (SPIVolt[1]);
// volt_32 = DecodeADCVolt(VoltMeasure)*1e4;
resister_32 = volt_32 / current_32;
volt_32 = volt_32 / 1e2; //uV
NotifyVolt[0] = (uint8_t) (volt_32 >> 24);
NotifyVolt[1] = (uint8_t) ((volt_32 & 0x00FF0000) >> 16);
NotifyVolt[2] = (uint8_t) ((volt_32 & 0x0000FF00) >> 8);
NotifyVolt[3] = (uint8_t) (volt_32 & 0x000000FF);
NotifyCurrent[0] = (uint8_t) (current_32 >> 24);
NotifyCurrent[1] = (uint8_t) ((current_32 & 0x00FF0000) >> 16);
NotifyCurrent[2] = (uint8_t) ((current_32 & 0x0000FF00) >> 8);
NotifyCurrent[3] = (uint8_t) (current_32 & 0x000000FF);
NotifyImpedance[0] = (uint8_t) (resister_32 >> 24);
NotifyImpedance[1] = (uint8_t) ((resister_32 & 0x00FF0000) >> 16);
NotifyImpedance[2] = (uint8_t) ((resister_32 & 0x0000FF00) >> 8);
NotifyImpedance[3] = (uint8_t) (resister_32 & 0x000000FF);
// set ADC GAIN
// if(INSTRUCTION.ResisterMeter == RESISTER_METER_LARGE){
// INSTRUCTION.ADCGainLevel = GAIN_200R;
// }
// else if(INSTRUCTION.ResisterMeter == RESISTER_METER_MIDDLE2){
// INSTRUCTION.ADCGainLevel = GAIN_200R;
// }
// else if(INSTRUCTION.ResisterMeter == RESISTER_METER_MIDDLE1){
// INSTRUCTION.ADCGainLevel = GAIN_10K;
// }
// else{
// INSTRUCTION.ADCGainLevel = GAIN_200K;
// }
// ADCGainControl(INSTRUCTION.ADCGainLevel);
// Use 9-th measure value as real-measure value
// because some value in the begin are garbage
// if(VoltCurrentSwitch < 9){
// ADCChannelSelect(ADC_CH_CURRENT);
// CPUdelay(10);
// ADC_read(SPICurrent);
// VoltCurrentSwitch ++;
// }
// else if(VoltCurrentSwitch == 9){
// // read current
// ADCChannelSelect(ADC_CH_CURRENT);
// CPUdelay(10);
// ADC_read(SPICurrent);
// CurrentMeasure = (uint16_t) (SPICurrent[0] << 8) | (uint16_t) (SPICurrent[1]);
// VoltCurrentSwitch ++;
// }
// else if(VoltCurrentSwitch <18){
// // read volt
// ADCChannelSelect(ADC_CH_VOLT);
// CPUdelay(10);
// ADC_read(SPIVolt);
// VoltCurrentSwitch++;
// }
// else if(VoltCurrentSwitch == 18){
// // read volt
// ADCChannelSelect(ADC_CH_VOLT);
// CPUdelay(10);
// ADC_read(SPIVolt);
// VoltMeasure = (uint16_t) (SPIVolt[0] << 8) | (uint16_t) (SPIVolt[1]);
// VoltCurrentSwitch++;
// }
// else{
// VoltCurrentSwitch = 0;
// }
// decode ADC value and put it into notify buffer
// DecodeResister(INSTRUCTION.ADCGainLevel, CurrentMeasure, VoltMeasure);
// Real_Resister = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
}
#endif
@@ -6,52 +6,114 @@
#include <Board.h>
#include <ti/drivers/PIN.h>
//#define ELITE_PIN_1_5
#define ELITE_PIN_1_5_RE
/* SPI Board */
#define Board_SPI0_MISO PIN_UNASSIGNED
#define Board_SPI0_MOSI IOID_1
#define Board_SPI0_CLK IOID_0
#define Board_SPI0_MOSI D1
#define Board_SPI0_CLK D0
#define Board_SPI0_CS PIN_UNASSIGNED
#define Board_SPI1_MISO IOID_3
#define Board_SPI1_MOSI IOID_2
#define Board_SPI1_CLK IOID_4
#define Board_SPI1_MISO IOID_1
#define Board_SPI1_MOSI D3
#define Board_SPI1_CLK D2
#define Board_SPI1_CS PIN_UNASSIGNED
#define ADC_CS IOID_8
#define DAC_CS IOID_9
#define D0 IOID_3
#define D1 IOID_4
#define D2 IOID_5
#define D3 IOID_6
#define D4 IOID_7
#define D5 IOID_8
#define D6 IOID_9
#define D7 IOID_10
#define Turnon200R IOID_5
#define Turnon10K IOID_6
#define LOAD0 IOID_13
#define LOAD1 IOID_12
#define LOAD2 IOID_11
#define ADC_CS LOAD0, D6
#define DAC_CS LOAD0, D7
#define ADC_DAC_SPI_MOSI LOAD0, D3
#define ADC_DAC_SPI_CLK LOAD0, D2
#define LED_MOSI LOAD0, D1
#define LED_CLK LOAD0, D0
#define MEM_CS LOAD0, D5
#ifdef ELITE_PIN_1_5
#define MEM_HOLD LOAD0, D4
#define HIGH_Z_MODE LOAD2, D5
#endif
#ifdef ELITE_PIN_1_5_RE
#define MEM_HOLD LOAD1, D0
#define HIGH_Z_MODE LOAD0, D4
#endif
#define Turnon_I_MID LOAD2, D0
#define Turnon_I_SMALL LOAD2, D4
#define Turnon_I_LARGE LOAD2, D1
#define Turnon_V_SMALL LOAD2, D2
#define Turnon_V_MID LOAD2, D3
#define Turnon_VOUT_SMALL LOAD2, D7
#define shutdown_6994 LOAD2, D6
//#define Turnon10K Turnon_I_MID
//#define Turnon200R Turnon_I_LARGE
/* I2C */
#ifdef ELITE_VERSION_1_4
#define Board_I2C0_SCL0 IOID_7
#define Board_I2C0_SDA0 IOID_1
#define Board_I2C0_SCL0 PIN_UNASSIGNED
#define Board_I2C0_SDA0 PIN_UNASSIGNED
#endif
#define shutdown_6994 IOID_10
#define switch_on IOID_11
#define enable_10v IOID_12
#define enable_5v IOID_13
#define switch_on IOID_14
#define enable_10v LOAD1, D5
#define enable_5v LOAD1, D6
PIN_Handle pin_handle;
static PIN_State ZM_rst;
const PIN_Config BLE_IO[] = {
//
ADC_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, // ADC_CS
DAC_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, // DAC_CS
// D0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// D1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// D2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// D3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
D4 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
D5 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
D6 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
D7 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
enable_10v | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, // 10V_enable
enable_5v | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, // 5V_enable
shutdown_6994 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, // turn off power
Turnon200R | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Turnon10K | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
switch_on | PIN_INPUT_EN | PIN_PULLDOWN,
LOAD0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
LOAD1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
LOAD2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
switch_on | PIN_INPUT_EN | PIN_PULLDOWN, // to sense switch
PIN_TERMINATE
};
static void add_elite_pin() {
// PIN_Status elite15_status;
PIN_add(pin_handle,
D0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
PIN_add(pin_handle,
D1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
PIN_add(pin_handle,
D2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
PIN_add(pin_handle,
D3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
// if(elite15_status != PIN_SUCCESS) {
// LED_color(DARKLED, 0x0F, 0x0F, 0x0F);
// }
}
static void remove_elite_pin() {
PIN_close(pin_handle);
pin_handle = PIN_open(&ZM_rst, BLE_IO);
}
/*!
* @def BOOSTXL_CC2650MA_SPIName
* @brief Enum of SPI names on the CC2650 Booster Pack
@@ -0,0 +1,93 @@
/*
***********************************************************
Read battery's method
***********************************************************
1.read_adc_raw_data(RIS_ADC_BAT, spi_ADC_rxbuf, spi_ADC_txbuf);
let "spi_ADC_rxbuf" be 8000
8000 * 187.5uV * 2 = 3000000uV = 3V ;
2.AONBatMonBatteryVoltageGet()
let "AONBatMonBatteryVoltageGet()" be 768
768 * 125 / 320 / 100 = 768 / 256 = 3V ;
if you want to use first method, and get value 768
conversion: 8000 * 187.5 * 1e-6 * 2 / 125 * 320 * 100 = 768
=> 8000 * 12 / 125 = 768
*/
#ifndef HEADSTAGE_BATT_H
#define HEADSTAGE_BATT_H
#include <driverlib/aon_batmon.h>
#define MAX_BATTERY_CAPACITY 4200
static uint8_t headstage_battery_percent() {
static uint8_t battery_percent = 100;
uint8_t internal_battery_percent;
uint32_t internal_batt_sense = AONBatMonBatteryVoltageGet();
internal_batt_sense = (internal_batt_sense * 125) >> 5;
internal_batt_sense = (internal_batt_sense * 100) / MAX_BATTERY_CAPACITY;
internal_battery_percent = internal_batt_sense & 0xFF;
if (internal_battery_percent < battery_percent) battery_percent = internal_battery_percent;
return battery_percent;
}
static void headstage_battery_volt(){
uint32_t bat_volt = 0;
read_adc_raw_data(RIS_ADC_BAT, spi_ADC_rxbuf, spi_ADC_txbuf);
bat_volt = (uint32_t) (spi_ADC_rxbuf[0] << 8) | (uint32_t) (spi_ADC_rxbuf[1]);
bat_volt = bat_volt * 12 / 125; //x * 187.5 * 1e-6 * 2 / 125 * 320 * 100 ;
// bat_volt = (bat_volt - 1) * 187.5 * 2;
InputNotify(NOTIFY_VOLT_BAT, bat_volt);
}
static void headstage_temperature(void) {
int32_t curTemp = 0;
curTemp = AONBatMonTemperatureGetDegC();
InputNotify(NOTIFY_TEMPERATURE,curTemp);
}
static void EliteADCBattery(){
static uint8_t ADCSwitch = 0;
if(ADCSwitch == 0){ /**read V**/
read_adc_raw_data(RIS_ADC_BAT, spi_ADC_rxbuf, spi_ADC_txbuf);
ADCSwitch++;
}
else if(ADCSwitch == 1){ /**read V**/
read_adc_raw_data(RIS_ADC_BAT, spi_ADC_rxbuf, spi_ADC_txbuf);
ADCSwitch++;
}
else if(ADCSwitch == 2){ /**read V(buffer)**/
headstage_battery_volt();
batteryCheck_flag = false;
headstage_temperature();
tempCheck_flag = false;
ADCSwitch = 0;
}
}
static void measureBat(){
if(GPT.BatteryCheckCounter >= 50000){//5min=3000000, 5s=50000
GPT.BatteryCheckCounter = 0;
batteryCheck_flag = true;
}
if(GPT.BatteryADCCounter >= 15 && batteryCheck_flag){
GPT.BatteryADCCounter = 0; //To get the data right, ADC must be delay 1.5ms
batteryADC_flag = true;
if(batteryADC_flag){
EliteADCBattery();
batteryADC_flag = false;
}
}
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) |
((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
if( bat < 768 && bat > 20){
PIN15_setOutputValue(enable_5v, 0);
}
}
#endif // HEADSTAGE_BATT_H
@@ -0,0 +1,116 @@
#ifndef ELITE_DEF
#define ELITE_DEF
// 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_ASK 0x30
#define VIS_STI 0xC0
#define VIS_FUH 0x90
#define VIS_INT 0x60
#define VIS_SHIFT_200K 0xA0
#define VIS_SHIFT_10K 0xE0
#define VIS_SHIFT_200R 0x80
#define VIS_DEVICE_SHINY 0x10
#define VIS_SHINY_DIS 0x20
#define VIS_CC_ZERO 0x40
// RIS (real instruction)
enum all_mode_e {
CURVE_IV = 0x01, // I-V Curve //0x10,
CURVE_IV_CY = 0x02, // Cycle I-V //0x20,
CURVE_VO = 0x03, // Function Generator //0x30,
CURVE_RT = 0x04, // R-T Graph //0x40,
CURVE_VT = 0x05, // V-T Graph //0x50,
CURVE_IT = 0x06, // I-T Graph //0x60,
CURVE_CC = 0x07, // Constant Current (CC) //0xD0,
CURVE_OCP = 0x08, // Open Circuit Potential (OCP)
CURVE_CV = 0x09, // Cyclic Voltammetry (CV) //0xC0,
CURVE_LSV = 0x0A, // Linear Sweep Voltammetry (LSV) //0x02,
CURVE_CA = 0x0B, // Chronoamperometric Graph (CA) //0x03,
CURVE_PULSE = 0x0C, //0x94,
CURVE_UNI_PULSE = 0x0D, // universal pulse
CURVE_DPV = 0x0E,
CURVE_DPV_SMPRATE = 0x0F,
CURVE_DPV_ADVANCE = 0x10,
CURVE_DPV_ADVANCE_SMPRATE = 0x11,
CURVE_CALI_ADC = 0xF1, // Cali ADC - test //0x92,
SET_SAMPLE_RATE = 0xE0, //0x70,
SET_ADC_DAC_GAIN = 0xE1, //0x80,
SET_PARA = 0xE2
};
enum set_para_e {
DAC_VOLT = 0x01,
};
enum dev_para_e {
VERSION_DEV_TEST = 0x01,
BAT_DEV_TEST = 0x02,
TEMP_DEV_TEST = 0x03,
LED_DEV_TEST = 0x04,
};
// CIS (control instruction)
#define CIS_VERSION 0x40
#define CIS_VOLT 0x10
#define CIS_TEMPERATURE 0x80
// mode parameter
#define STEP_TO_VSETRATE(step) step2VsetRate(step)
#define VMAX(v1,v2) ((v1 >= v2) ? v1 : v2)
#define VMIN(v1,v2) ((v1 < v2) ? v1 : v2)
#define VDIRECTION(v1,v2) ((v1 > v2) ? 0 : 1)
#define AFTER_READ_I 0
#define AFTER_READ_V 1
//Elite LED
#define COLOR_BLACK 0x00
#define COLOR_RED 0x01
#define COLOR_ORANGE 0x02
#define COLOR_YELLOW 0x03
#define COLOR_GREEN 0x04
#define COLOR_BLUE 0x05
#define COLOR_CYAN 0x06
#define COLOR_MAGENTA 0x07
#define COLOR_PURPLE 0x08
#define COLOR_WHITE 0x09
#define COLOR_YELLOWGREEN 0x0A
#define COLOR_YELLOW_DARK 0xF3
#define COLOR_GREEN_DARK 0xF4
#define COLOR_BLUE_DARK 0xF5
#define COLOR_CYAN_DARK 0xF6
#define COLOR_PURPLE_DARK 0xF8
#define LEDPowerON() Elite_led_color(COLOR_GREEN)
#define WORKLED() Elite_led_color(COLOR_CYAN)
#define KEYLED() Elite_led_color(COLOR_YELLOW)
#define BT_WAIT_LED() Elite_led_color(COLOR_YELLOWGREEN)
#define BT_WAIT 0x01
#define NO_EVENT 0x02
#define PRE_WORK 0x03
#define WORKING 0x04
#define POST_WORK 0x05
#define VALUE_ZERO_TO_ONE(_v) (_v == 0) ? 1 : _v
//plot_type
#define IT_PLOT 1
#define VT_PLOT 2
#define VOUT_PLOT 3
#define IIN_VIN_PLOT 4
#define IIN_VIN_VOUT_PLOT 5
#define CLOCK_ONE_SECOND 10000
#endif
@@ -0,0 +1,849 @@
#ifndef ELITE_MODE_ADC_DAC
#define ELITE_MODE_ADC_DAC
#define Vset instru.Vset
static void volt_out() {
static uint16_t DACOutCode;
static int32_t DeltaVout;
if (DACReset) {
instru.Vout = Vset;
} else {
DeltaVout = Vset - (instru.Vout);
instru.Vout = instru.Vout + DeltaVout;
}
if (instru.Vout >= 1100000000) { //1100000000 = 5.5V
instru.Vout = 1100000000;
} else if (instru.Vout <= -1000000000) { //-1000000000 = -5V
instru.Vout = -1000000000;
}
instru.VoltConstant = instru.Vout / 40000 + 25000; //5nV=>usercode
DACOutCode = Usercode_Correction_to_DAC(instru.VoutGainLv, instru.VoltConstant);
DAC_outputV(DACOutCode);
return;
}
static void vscan_volt_out(void)
{
void *wm = wm_get();
uint16_t DACOutCode;
int32_t DeltaVout;
int32_t Vin;
Vin = MEAS_VIN(wm) * 200;//[5nV]
if (DACReset) {
instru.Vout = Vset + Vin;
} else {
DeltaVout = Vset - (instru.Vout - Vin);
instru.Vout = instru.Vout + DeltaVout;
}
instru.VoltConstant = instru.Vout / 40000 + 25000;//5nV=>usercode
DACOutCode = Usercode_Correction_to_DAC(instru.VoutGainLv, instru.VoltConstant);
DAC_outputV(DACOutCode);
return;
}
static void CalcuResistance()
{
/* Elite 100000 = 100R
Elite 1000000 = 1KR
Elite 10000000 = 10KR
Elite 100000000 = 100KR
Elite 1000000000 = 1MR
*/
struct wm_rt_ctx_t *rt = (struct wm_rt_ctx_t *)wm_get();
struct wm_meas_t *m = &rt->measure;
int64_t resist;
int64_t volt = instru.Vout / 200; // [uV]
int64_t current = (int64_t)(m->_measureCurrent);
resist = volt * 1000000 / current; //R = V / Iin; [mOhm]
InputNotify(NOTIFY_IMPEDANCE, resist);
}
static void DACenable(uint8_t afterRead){
void *wm = wm_get();
if (afterRead == AFTER_READ_I) {
switch (instru.eliteFxn) {
case CURVE_CC:
cc_vscan();
volt_out();
break;
case CURVE_UNI_PULSE:
volt_out();
break;
default:
break;
}
} else if (afterRead == AFTER_READ_V) {
switch (instru.eliteFxn) {
case CURVE_IV_CY:
case CURVE_IV:
case CURVE_IT:
case CURVE_VO:
volt_out();
break;
case CURVE_RT:
volt_out();
CalcuResistance();
break;
case CURVE_CV:
case CURVE_CA:
case CURVE_LSV:
case CURVE_DPV:
case CURVE_DPV_SMPRATE:
case CURVE_DPV_ADVANCE:
case CURVE_DPV_ADVANCE_SMPRATE:
vscan_volt_out();
break;
default:{
break;
}
}
}
}
static void read_Iin_change_gain(uint16_t plot_type)
{
/* read Iin and cali value save as MEAS_CURR(wm)
* if auto gain:
* do NOT record the Iin after changing gain, time is according to damping time
* if static gain:
* change gain if gain is different from last gain
*/
uint16_t plot = plot_type;
static uint16_t no_rec_time = 0;
static uint8_t cnt = 0;
void *wm = wm_get();
if (instru.IinADCAutoGainEn > 1)
return;
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
MEAS_CURR(wm) = DecodeADCValue(instru.IinADCGainLv, RIS_ADC_IIN, spi_ADC_rxbuf);
if (instru.IinADCAutoGainEn) {
AutoGainChangeIin(MEAS_CURR(wm), plot, &no_rec_time);
} else {
if (lastIinADCGainLevel != instru.IinADCGainLv) {
IinADCGainCtrl(instru.IinADCGainLv);
no_rec_time = 2;
}
}
if (curr_rec_en == false) {
cnt++;
}
if (cnt >= no_rec_time) {
curr_rec_en = true;
cnt = 0;
}
return;
}
static void read_Vin_change_gain(void)
{
static uint8_t rec_cnt = 0;
void *wm = wm_get();
if (instru.IinADCAutoGainEn > 1)
return;
/* read Vin and do NOT record the Vin after changing gain twice */
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
MEAS_VIN(wm) = DecodeADCValue(instru.VinADCGainLv, RIS_ADC_VIN, spi_ADC_rxbuf);
if (instru.VinADCAutoGainEn) {
AutoGainChangeVin(MEAS_VIN(wm));
} else {
if (lastVinADCGainLv != instru.VinADCGainLv) {
VinADCGainCtrl(instru.VinADCGainLv);
}
}
if (volt_rec_en == false) {
rec_cnt++;
}
if (rec_cnt == 2) {
volt_rec_en = true;
rec_cnt = 0;
}
return;
}
static void read_Vout_change_gain(void)
{
static uint8_t rec_cnt = 0;
void *wm = wm_get();
/* read Vout and do NOT record the Vout after changing gain twice */
read_adc_raw_data(RIS_ADC_VOUT, spi_ADC_rxbuf, spi_ADC_txbuf);
MEAS_VOUT(wm) = DecodeADCValue(0, RIS_ADC_VOUT, spi_ADC_rxbuf);
if (volt_rec_en == false) {
rec_cnt++;
}
if (rec_cnt == 2) {
volt_rec_en = true;
rec_cnt = 0;
}
return;
}
void EliteCalcAvg(uint32_t time)
{
struct wm_uni_pulse_ctx_t *p = (struct wm_uni_pulse_ctx_t *)wm_get();
struct wm_meas_t *meas = &p->measure;
static uint32_t cnt = 0;
static int64_t curr_sum = 0;
int64_t curr_avg = 0;
uint32_t m;
uint32_t t = time;
m = t % p->_t_period;
if (calc_avg_en) {
cnt++;
curr_sum = curr_sum + meas->_measureCurrent;
} else {
curr_avg = curr_sum / cnt;
if (cnt == 0) {
return;
}
if (m < p->_t_pa[0]) {
InputNotify(NOTIFY_CURRENT, curr_avg);
SendNotify();
} else if (m < p->_t_pa[1]) {
InputNotify(NOTIFY_VOLT, curr_avg);
SendNotify();
} else if (m < p->_t_pa[2]) {
} else if (m < p->_t_pa[3]) {
}
cnt = 0;
curr_sum = 0;
curr_avg = 0;
}
return;
}
void dpv_EliteCalcAvg(uint32_t time)
{
struct wm_dpv_ctx_t *p = (struct wm_dpv_ctx_t *)wm_get();
struct wm_meas_t *meas = &p->measure;
static uint32_t cnt = 0;
static int64_t curr_sum = 0;
int64_t curr_avg = 0;
uint32_t m;
uint32_t t = time;
m = t % p->_t_period;
static bool first_v_rec = true;
if (calc_avg_en) {
cnt++;
curr_sum = curr_sum + meas->_measureCurrent;
if (first_v_rec) {
InputNotify(NOTIFY_VOLT, instru.Vout/200 - meas->_measureVin);
InputNotify(NOTIFY_IMPEDANCE, instru.Vout/200);
first_v_rec = false;
}
} else {
first_v_rec = true;
curr_avg = curr_sum / cnt;
if (cnt == 0) {
return;
}
if (m < p->_t_pa[0]) {
InputNotify(NOTIFY_CURRENT, curr_avg);
SendNotify();
} else if (m < p->_t_pa[1]) {
InputNotify(NOTIFY_CURRENT, curr_avg);
SendNotify();
} else if (m < p->_t_pa[2]) {
} else if (m < p->_t_pa[3]) {
}
cnt = 0;
curr_sum = 0;
curr_avg = 0;
}
return;
}
void dpv_advance_EliteCalcAvg(uint32_t time)
{
struct wm_dpv_advance_ctx_t *p = (struct wm_dpv_advance_ctx_t *)wm_get();
struct wm_meas_t *meas = &p->measure;
static uint32_t cnt = 0;
static int64_t curr_sum = 0;
int64_t curr_avg = 0;
uint32_t m;
uint32_t t = time;
m = t % p->_t_period;
static bool first_v_rec = true;
if (calc_avg_en) {
cnt++;
curr_sum = curr_sum + meas->_measureCurrent;
if (first_v_rec) {
InputNotify(NOTIFY_VOLT, instru.Vout/200 - meas->_measureVin);
InputNotify(NOTIFY_IMPEDANCE, instru.Vout/200);
first_v_rec = false;
}
} else {
first_v_rec = true;
curr_avg = curr_sum / cnt;
if (cnt == 0) {
return;
}
if (m < p->_t_pa[0]) {
InputNotify(NOTIFY_CURRENT, curr_avg);
SendNotify();
} else if (m < p->_t_pa[1]) {
InputNotify(NOTIFY_CURRENT, curr_avg);
SendNotify();
} else if (m < p->_t_pa[2]) {
} else if (m < p->_t_pa[3]) {
}
cnt = 0;
curr_sum = 0;
curr_avg = 0;
}
return;
}
static void Iin_Vin_Vout_Plot(uint32_t time)
{
static uint8_t ADC_cnt = 0;
void *wm = wm_get();
uint32_t t = time;
/* the time for measuring battery */
if (batteryCheck_flag && tempCheck_flag) {
EliteADCBattery();
if (!batteryCheck_flag) {
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt = 5;
}
return;
}
/* the time for Not measuring battery */
/* ADC_cnt: 0 - read Iin and do NOT buffer the Iin after changing gain twice,
* and output DAC, and read Vin, and increase ADC_cnt
* 1 - read Vin and increase ADC_cnt
* 2 - read Vin and do NOT buffer the Vin after changing gain twice,
* and output DAC, and read Vout, and increase ADC_cnt
* 3 - read Vout and increase ADC_cnt
* 4 - read Vout and do NOT buffer the Vout after changing gain twice,
* and output DAC, and read Iin, and increase ADC_cnt
* 5 - read Iin and reset ADC_cnt
*/
if (ADC_cnt == 0) {
read_Iin_change_gain(IIN_VIN_VOUT_PLOT);
if (instru.eliteFxn == CURVE_DPV && vscanReset == false) {
dpv_EliteCalcAvg(t);
}
else if (instru.eliteFxn == CURVE_DPV_ADVANCE && vscanReset == false) {
dpv_advance_EliteCalcAvg(t);
}
DACenable(AFTER_READ_I);
ADC_cnt++;
} else if (ADC_cnt == 1) {
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt++;
} else if (ADC_cnt == 2) {
read_Vin_change_gain();
DACenable(AFTER_READ_V);
ADC_cnt++;
} else if (ADC_cnt == 3) {
read_adc_raw_data(RIS_ADC_VOUT, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt++;
} else if (ADC_cnt == 4) {
read_Vout_change_gain();
DACenable(AFTER_READ_V);
ADC_cnt++;
} else if (ADC_cnt == 5) {
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt = 0;
}
return;
}
static void Iin_Vin_Plot(void)
{
static uint8_t ADC_cnt = 0;
void *wm = wm_get();
/* the time for measuring battery */
if (batteryCheck_flag && tempCheck_flag) {
EliteADCBattery();
if (!batteryCheck_flag) {
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt = 3;
}
return;
}
/* the time for Not measuring battery */
/* ADC_cnt: 0 - read Iin and do NOT buffer the Iin after changing gain twice,
* and output DAC, and read Vin, and increase ADC_cnt
* 1 - read Vin and increase ADC_cnt
* 2 - read Vin and do NOT buffer the Vin after changing gain twice,
* and output DAC, and read Iin, and increase ADC_cnt
* 3 - read Iin and reset ADC_cnt
*/
if (ADC_cnt == 0) {
read_Iin_change_gain(IIN_VIN_PLOT);
DACenable(AFTER_READ_I);
ADC_cnt++;
} else if (ADC_cnt == 1) {
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt++;
} else if (ADC_cnt == 2) {
read_Vin_change_gain();
DACenable(AFTER_READ_V);
ADC_cnt++;
} else if (ADC_cnt == 3) {
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt = 0;
}
return;
}
static void IT_Plot(uint32_t time)
{
static uint8_t ADC_cnt = 0;
void *wm = wm_get();
uint32_t t = time;
/* measure battery if needs */
batteryCheck_flag = false;
tempCheck_flag = false;
if (batteryCheck_flag || tempCheck_flag) {
EliteADCBattery();
if (!batteryCheck_flag) {
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt = 1;
}
return;
}
/* ADC_cnt: 0 - read Iin and do NOT buffer the Iin after changing gain twice, read Iin and increase ADC_cnt
* 1 - read Iin and reset ADC_cnt
*/
if (ADC_cnt == 0) {
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt++;
return;
}
if (ADC_cnt == 1) {
read_Iin_change_gain(IT_PLOT);
if (instru.eliteFxn == CURVE_UNI_PULSE && vscanReset == false) {
EliteCalcAvg(t);
}
DACenable(AFTER_READ_I);
ADC_cnt = 0;
return;
}
return;
}
static void VT_Plot(void)
{
static uint8_t ADC_cnt = 0;
void *wm = wm_get();
/* measure battery if needs */
if (batteryCheck_flag && tempCheck_flag) {
EliteADCBattery();
if (!batteryCheck_flag) {
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt = 1;
}
return;
}
/* ADC_cnt: 0 - read Vin and do NOT buffer the Vin after changing gain twice, read Vin and increase ADC_cnt
* 1 - read Vin and reset ADC_cnt
*/
if (ADC_cnt == 0) {
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt++;
return;
}
if (ADC_cnt == 1) {
read_Vin_change_gain();
DACenable(AFTER_READ_V);
ADC_cnt = 0;
return;
}
return;
}
static void Vout_Plot(void)
{
static uint8_t ADC_cnt = 0;
void *wm = wm_get();
/* measure battery if needs */
if (batteryCheck_flag && tempCheck_flag) {
EliteADCBattery();
if (!batteryCheck_flag) {
read_adc_raw_data(RIS_ADC_VOUT, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt = 1;
}
return;
}
/* ADC_cnt: 0 - read Vout and do NOT buffer the Vout after changing gain twice, read Vout and increase ADC_cnt
* 1 - read Vout and reset ADC_cnt
*/
if (ADC_cnt == 0) {
read_adc_raw_data(RIS_ADC_VOUT, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt++;
return;
}
if (ADC_cnt == 1) {
read_Vout_change_gain();
DACenable(AFTER_READ_V);
ADC_cnt = 0;
return;
}
return;
}
static void cali_IT_plot(void) {
void *wm = wm_get();
static int32_t ADCValueSUM = 0;
static uint16_t cali_count = 0;
static uint8_t ADC_cnt = 0;
static uint8_t rec_cnt = 0;
static uint16_t cali_count_max = 1000;
int32_t ADCValueAVG = 0;
/* ADC_cnt: 0 - read Iin and do NOT buffer the Iin after changing gain twice
* 1 - read Iin and increase ADC_cnt
* 2 - read Iin and reset ADC_cnt
*/
if (ADC_cnt == 0) {
if (instru.IinADCAutoGainEn) {
MEAS_CURR(wm) = 0xFFFF;
} else {
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
MEAS_CURR(wm) = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
if (lastIinADCGainLevel != instru.IinADCGainLv) {
IinADCGainCtrl(instru.IinADCGainLv);
}
}
if (instru.IinADCGainLv == 0) {
cali_count_max = 5000;
} else {
cali_count_max = 1000;
}
if (curr_rec_en == false) {
rec_cnt++;
} else {
if (cali_count >= cali_count_max) {
ADCValueAVG = ADCValueSUM / cali_count;
InputNotify(NOTIFY_CURRENT, ADCValueAVG);
SendNotify();
uint8_t CIS_buf[9] = {0};
CIS_buf[0] = 5; //data len
CIS_buf[1] = instru.chip_id;
CIS_buf[2] = (uint8_t) ((ADCValueAVG & 0xFF00) >> 8);
CIS_buf[3] = (uint8_t) (ADCValueAVG & 0x00FF);
CIS_buf[4] = 0x00;
CIS_buf[5] = instru.IinADCGainLv;
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 9, CIS_buf);
PeriodicEvent = false;
ADCValueSUM = 0;
cali_count = 0;
ModeLED(NO_EVENT);
} else {
cali_count++;
ADCValueSUM = ADCValueSUM + MEAS_CURR(wm);
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
InputNotify(NOTIFY_VOLT, ADCValueSUM);
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
}
}
if (rec_cnt == 2) {
curr_rec_en = true;
rec_cnt = 0;
}
ADC_cnt++;
return;
}
if (ADC_cnt == 1) {
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt++;
return;
}
if (ADC_cnt == 2) {
read_adc_raw_data(RIS_ADC_IIN, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt = 0;
return;
}
return;
}
static void cali_VT_plot(void) {
void *wm = wm_get();
static int32_t ADCValueSUM = 0;
static uint16_t cali_count = 0;
static uint8_t ADC_cnt = 0;
static uint8_t rec_cnt = 0;
uint16_t cali_count_max = 0;
int32_t ADCValueAVG = 0;
/* ADC_cnt: 0 - read Vin and do NOT buffer the Vin after changing gain twice
* 1 - read Vin and increase ADC_cnt
* 2 - read Vin and reset ADC_cnt
*/
if (ADC_cnt == 0) {
if (instru.VinADCAutoGainEn) {
MEAS_VIN(wm) = 0xFFFF;
} else {
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
MEAS_VIN(wm) = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
if (lastVinADCGainLv != instru.VinADCGainLv) VinADCGainCtrl(instru.VinADCGainLv);
}
if (instru.VinADCGainLv == 0) {
cali_count_max = 5000;
} else {
cali_count_max = 1000;
}
if (volt_rec_en == false) {
rec_cnt++;
} else {
if (cali_count >= cali_count_max) {
ADCValueAVG = ADCValueSUM / cali_count;
InputNotify(NOTIFY_VOLT, ADCValueAVG);
SendNotify();
uint8_t CIS_buf[9] = {0};
CIS_buf[0] = 5; //data len
CIS_buf[1] = instru.chip_id;
CIS_buf[2] = (uint8_t) ((ADCValueAVG & 0xFF00) >> 8);
CIS_buf[3] = (uint8_t) (ADCValueAVG & 0x00FF);
CIS_buf[4] = 0x00;
CIS_buf[5] = instru.VinADCGainLv;
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 9, CIS_buf);
PeriodicEvent = false;
ADCValueSUM = 0;
cali_count = 0;
ModeLED(NO_EVENT);
} else {
cali_count++;
ADCValueSUM = ADCValueSUM + MEAS_VIN(wm);
InputNotify(NOTIFY_VOLT, MEAS_VIN(wm));
InputNotify(NOTIFY_CURRENT, ADCValueSUM);
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
}
}
if (rec_cnt == 2) {
volt_rec_en = true;
rec_cnt = 0;
}
ADC_cnt++;
return;
}
if (ADC_cnt == 1) {
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt++;
return;
}
if (ADC_cnt == 2) {
read_adc_raw_data(RIS_ADC_VIN, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt = 0;
return;
}
return;
}
static void cali_Vout_plot(void) {
void *wm = wm_get();
static int32_t ADCValueSUM = 0;
static uint16_t cali_count = 0;
static uint8_t ADC_cnt = 0;
static uint8_t rec_cnt = 0;
uint16_t cali_count_max = 1000;
int32_t ADCValueAVG = 0;
/* ADC_cnt: 0 - read Vin and do NOT buffer the Vin after changing gain twice
* 1 - read Vin and increase ADC_cnt
* 2 - read Vin and reset ADC_cnt
*/
if (ADC_cnt == 0) {
read_adc_raw_data(RIS_ADC_VOUT, spi_ADC_rxbuf, spi_ADC_txbuf);
MEAS_VOUT(wm) = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
if (volt_rec_en == false) {
rec_cnt++;
} else {
if (cali_count >= cali_count_max) {
ADCValueAVG = ADCValueSUM / cali_count;
InputNotify(NOTIFY_VOLT, ADCValueAVG);
SendNotify();
uint8_t CIS_buf[9] = {0};
CIS_buf[0] = 5; //data len
CIS_buf[1] = instru.chip_id;
CIS_buf[2] = (uint8_t) ((ADCValueAVG & 0xFF00) >> 8);
CIS_buf[3] = (uint8_t) (ADCValueAVG & 0x00FF);
CIS_buf[4] = 0x00;
CIS_buf[5] = instru.VinADCGainLv;
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 9, CIS_buf);
PeriodicEvent = false;
ADCValueSUM = 0;
cali_count = 0;
ModeLED(NO_EVENT);
} else {
cali_count++;
ADCValueSUM = ADCValueSUM + MEAS_VOUT(wm);
InputNotify(NOTIFY_VOLT, MEAS_VOUT(wm));
InputNotify(NOTIFY_CURRENT, ADCValueSUM);
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
}
}
if (rec_cnt == 2) {
volt_rec_en = true;
rec_cnt = 0;
}
ADC_cnt++;
return;
}
if (ADC_cnt == 1) {
read_adc_raw_data(RIS_ADC_VOUT, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt++;
return;
}
if (ADC_cnt == 2) {
read_adc_raw_data(RIS_ADC_VOUT, spi_ADC_rxbuf, spi_ADC_txbuf);
ADC_cnt = 0;
return;
}
return;
}
#endif
@@ -0,0 +1,9 @@
#ifndef HEADSTAGE_POWER_H
#define HEADSTAGE_POWER_H
#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26XX.h>
#define headstage_power_shutdown() Power_shutdown(NULL, 0)
#endif // HEADSTAGE_POWER_H
@@ -0,0 +1,15 @@
#ifndef VERSION_DATE
#define VERSION_DATE
#define VERSION_DATE_YEAR 21
#define VERSION_DATE_MONTH 11
#define VERSION_DATE_DAY 10
#define VERSION_DATE_HOUR 17
#define VERSION_DATE_MINUTE 58
// this is NOT the version hash !!
// it's the last version hash
#define VERSION_HASH 8808490caa465cc94d14896de28763a5e5c4672b
#define VERSION_GIT_BRANCH Elite_OBJ_0.2mv
#endif
@@ -30,6 +30,12 @@
#define SPI_BUFFER_SIZE 16
/**
* the pointer to point which channel is used currently.
* -1 for not beginning.
*/
static int8 channel_pointer = -1;
static uint8_t spi_txbuf[SPI_BUFFER_SIZE] = {0};
static uint8_t spi_rxbuf[SPI_BUFFER_SIZE] = {0};
@@ -129,16 +135,16 @@ static void update_ins_sti_channel(uint8_t *buf, uint8 sti_chp, uint8 sti_chn) {
static void update_ins_buffer() {
uint8 header = 0b10100000;
uint8 amp_gain = (INSTRUCTION.amp_gain & 0b11) << 3;
uint8 amp_lbf = INSTRUCTION.amp_low_band_freq & 0b111;
uint8 amp_gain = (instru.amp_gain & 0b11) << 3;
uint8 amp_lbf = instru.amp_low_band_freq & 0b111;
uint8 channel = 0; // should be call update_ins_channel to modify this value
uint8 chopper = (INSTRUCTION.chopper) ? 0b00001000 : 0;
uint8 fast_settle = (INSTRUCTION.fast_settle) ? 0b00000100 : 0;
uint8 sti_enable = (INSTRUCTION.work_mode != STI_MODE_DISABLE) ? 0b00000010 : 0;
uint8 sti_volt_l = (INSTRUCTION.sti_volt & 0b11111) >> 4;
uint8 sti_volt_h = (INSTRUCTION.sti_volt & 0b01111) << 4;
uint8 sti_chp = INSTRUCTION.sti_channel_pmos & 0b1111;
uint8 sti_chn = (INSTRUCTION.sti_channel_nmos & 0b1111) << 4;
uint8 chopper = (instru.chopper) ? 0b00001000 : 0;
uint8 fast_settle = (instru.fast_settle) ? 0b00000100 : 0;
uint8 sti_enable = (instru.work_mode != STI_MODE_DISABLE) ? 0b00000010 : 0;
uint8 sti_volt_l = (instru.sti_volt & 0b11111) >> 4;
uint8 sti_volt_h = (instru.sti_volt & 0b01111) << 4;
uint8 sti_chp = instru.sti_channel_pmos & 0b1111;
uint8 sti_chn = (instru.sti_channel_nmos & 0b1111) << 4;
uint8 clk_signal = 0; // should be call update_ins_clock to modify this value
spi_txbuf[0] = header | amp_gain | amp_lbf;
@@ -193,7 +199,7 @@ static bool update_ins_rec_buffer() {
* @param: buf: pointer of the SPI buffer.
*/
static void update_ins_sti_buffer() {
switch (INSTRUCTION.work_mode) {
switch (instru.work_mode) {
case STI_MODE_POS:
case STI_MODE_NEG:
// copy [4:7]
@@ -215,7 +221,7 @@ static void update_ins_sti_buffer() {
update_ins_sti_enable(spi_txbuf, TRUE);
// ins buf [4:7]
update_ins_sti_enable(spi_txbuf + 4, TRUE);
update_ins_sti_channel(spi_txbuf + 4, 0xF, INSTRUCTION.sti_channel_pmos);
update_ins_sti_channel(spi_txbuf + 4, 0xF, instru.sti_channel_pmos);
// ins buf [8:B]
update_ins_sti_enable(spi_txbuf + 8, FALSE);
break;
@@ -238,13 +244,13 @@ static void update_ins_sti_buffer() {
spi_txbuf[15] = spi_txbuf[3];
// change content
update_ins_sti_enable(spi_txbuf + 0, TRUE);
update_ins_sti_channel(spi_txbuf + 0, INSTRUCTION.sti_channel_pmos, INSTRUCTION.sti_channel_nmos);
update_ins_sti_channel(spi_txbuf + 0, instru.sti_channel_pmos, instru.sti_channel_nmos);
// ins buf [4:7]
update_ins_sti_enable(spi_txbuf + 4, TRUE);
update_ins_sti_channel(spi_txbuf + 4, INSTRUCTION.sti_channel_nmos, INSTRUCTION.sti_channel_pmos);
update_ins_sti_channel(spi_txbuf + 4, instru.sti_channel_nmos, instru.sti_channel_pmos);
// ins buf [8:B]
update_ins_sti_enable(spi_txbuf + 8, TRUE);
update_ins_sti_channel(spi_txbuf + 8, 0xF, INSTRUCTION.sti_channel_nmos);
update_ins_sti_channel(spi_txbuf + 8, 0xF, instru.sti_channel_nmos);
// ins buf [C:F]
update_ins_sti_enable(spi_txbuf + 12, FALSE);
break;
@@ -281,12 +287,12 @@ static void headstage_tni_update_instruction_callback(uint8_t ins_type, uint8_t
}
static uint8_t *spi_transact_rec_instruction() {
if (IS_REC_MODE(INSTRUCTION.work_mode)) {
if (IS_REC_MODE(instru.work_mode)) {
PIN_setOutputValue(pin_handle, IOID_13, 1); // DBS_P2S turn on
headstage_spi_transaction(SPI_BUFFER_SIZE, spi_txbuf, spi_rxbuf);
PIN_setOutputValue(pin_handle, IOID_13, 0); // DBS_P2S turn off
} else if (IS_ARM_MODE(INSTRUCTION.work_mode) && !adc_clock_signal) {
} else if (IS_ARM_MODE(instru.work_mode) && !adc_clock_signal) {
create_ramp(spi_rxbuf);
}
@@ -1,11 +0,0 @@
#ifndef VERSION_DATE
#define VERSION_DATE
#define VERSION_DATE_YEAR 20
#define VERSION_DATE_MONTH 2
#define VERSION_DATE_DAY 25
#define VERSION_DATE_HOUR 18
#define VERSION_DATE_MINUTE 32
#endif
@@ -20,8 +20,9 @@
#include <ti/drivers/PIN.h>
#include "board.h"
#include "EliteWorkData.h"
#include <driverlib/aon_batmon.h>
static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData);
static void SimpleBLEPeripheral_performPeriodicTask(void);
static void SimpleBLEPeripheral_clockHandler(UArg arg) {
// Store the event.
@@ -34,6 +35,7 @@ static void SimpleBLEPeripheral_clockHandler(UArg arg) {
static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) {
events |= SBP_PERIODIC_EVT;
Semaphore_post(semaphore);
GPT.GptimerCounter++;
}
@@ -44,16 +46,26 @@ static void ZM_init() {
// initialize
pin_handle = PIN_open(&ZM_rst, BLE_IO);
Init_Elite15_PIN();
ELITE15_SPI_HOLD();
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
PIN15_setOutputValue(shutdown_6994, 1); // OFF = 1 => turn off 6994
PIN15_setOutputValue(enable_10v, 0); // enable 10V
PIN15_setOutputValue(HIGH_Z_MODE, 0); // HIGH Z MODE // 1: close; 0: open;
InitEliteInstruction();
ADCGainControl(GAIN_AUTO);
// init DAC, set output ~= 0 V
instru.VoutGainLv = VOUT_GAIN_15K;
VoutGainControl(instru.VoutGainLv);
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
/* when elite open, must change vin level,
measure battery value will be right */
VinADCGainCtrl(VIN_GAIN_AUTO);
elite_gptimer_open();
elite_gptimer_start();
// PIN_registerIntCb(pin_handle, switch_on_callback);
// PIN_setInterrupt(pin_handle, switch_on | PIN_IRQ_POSEDGE);
@@ -61,26 +73,355 @@ static void ZM_init() {
static void ZM_update_instruction_callback(uint8_t ins_type, uint8_t chip_ID, uint8_t *ins) {}
#define IsPeriodicMode() ( \
(instru.eliteFxn == CURVE_IV) || \
(instru.eliteFxn == CURVE_IV_CY) || \
(instru.eliteFxn == CURVE_IT) || \
(instru.eliteFxn == CURVE_VT) || \
(instru.eliteFxn == CURVE_RT) || \
(instru.eliteFxn == CURVE_CC) || \
(instru.eliteFxn == CURVE_CV) || \
(instru.eliteFxn == CURVE_LSV) || \
(instru.eliteFxn == CURVE_CA) || \
(instru.eliteFxn == CURVE_VO) || \
(instru.eliteFxn == CURVE_OCP) || \
(instru.eliteFxn == CURVE_CALI_ADC) \
)
static void DACCode2Real2Notify(uint16_t DACcode) {
int32_t RealV;
RealV = DAC_to_realV(DACcode);
#define Ve1MatchVe2Mode() ( \
(instru.eliteFxn == CURVE_IV) || \
(instru.eliteFxn == CURVE_IV_CY) || \
(instru.eliteFxn == CURVE_CV) || \
(instru.eliteFxn == CURVE_LSV) \
)
static void pulse_mode(void)
{
// Default working flow is vscan -> ADC read -> send notify
// We will need a flag to control vscan, ADC and notify
if(mode_init){
GPT.SampleRateCounter = instru.sampleRate - 10;
GPT.VscanRateCounter = instru.VsetRate - 1;
mode_init = false;
batteryADC_flag = false;
volt_rec_en = true;
curr_rec_en = true;
firstTimeReset = true;
notifyFirst_flag = true;
//pulsemode variable
stiFirstTime = true;
VinADCGainCtrl(instru.VinADCGainLv);
IinADCGainCtrl(instru.IinADCGainLv);
VoutGainControl(instru.VoutGainLv);
if (Ve1MatchVe2Mode()) {
if (instru.Ve1 == instru.Ve2) {
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLv, instru.Ve1));
PeriodicEvent = false;
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0: open highz;
ModeLED(NO_EVENT);
}
} else if (instru.eliteFxn == CURVE_PULSE) {
if(!megaStiEnable){
PeriodicEvent = false;
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0: open highz;
ModeLED(NO_EVENT);
}
}
}
GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
if(leadTimeReset && GPT.LeadTimeCounter <= 2000){
vscanReset = true;
}else{
if(notifyFirst_flag){
GPT.NotifyCounter = instru.notifyRate - 20;
notifyFirst_flag = false;
}
vscanReset = false;
leadTimeReset = false;
}
//vscan counter
GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
//pulse mode counter
GPT.StiCounter = GPT.StiCounter + GPT.DeltaGptimerCounter;
if (vscanReset) {
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
//vscanReset = false;
}else{
if (megaStiEnable) {
pulse_vscan();
}
}
//battery counter
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
if(GPT.BatteryCheckCounter >= 50000){
GPT.BatteryCheckCounter -= 50000; //To get right time
batteryCheck_flag = true;
tempCheck_flag = true;
}
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
if( bat < 768 && bat > 20){
PIN15_setOutputValue(enable_5v, 0);
}
//ADC counter
GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
if(GPT.SampleRateCounter >= instru.sampleRate){
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
EliteADCControl(0);
}
//Notify counter(Notify control, check if we need to send notify)
//please don't put Notify counter before ADC counter, maybe get wrong data
GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
if(GPT.NotifyCounter >= instru.notifyRate){
GPT.NotifyCounter -= instru.notifyRate; //To get right time
notify_flag = true;
if(vscanReset){
notify_flag = false;
}
if(notify_flag){
SendNotify();
notify_flag = false;
}
}
mode_done();
NotifyVolt[0] = (uint8_t)((RealV & 0xFF000000) >> 24);
NotifyVolt[1] = (uint8_t)((RealV & 0x00FF0000) >> 16);
NotifyVolt[2] = (uint8_t)((RealV & 0x0000FF00) >> 8);
NotifyVolt[3] = (uint8_t)(RealV & 0x000000FF);
}
#define IsPeriodicMode() ( \
(INSTRUCTION.eliteFxn == IV_CURVE) || \
(INSTRUCTION.eliteFxn == CV_CURVE) || \
(INSTRUCTION.eliteFxn == IT_CURVE) || \
(INSTRUCTION.eliteFxn == VT_CURVE) || \
(INSTRUCTION.eliteFxn == ZT_CURVE) || \
(INSTRUCTION.eliteFxn == CONSTANT_CURRENT) || \
(INSTRUCTION.eliteFxn == READ_VOUT_VALUE) \
)
static void peri_mode(void)
{
GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
if (leadTimeReset && GPT.LeadTimeCounter <= 2000) {
vscanReset = true;
if (first_highz_flag && GPT.LeadTimeCounter >= 1000) {
if (instru.eliteFxn == CURVE_OCP) {
PIN15_setOutputValue(HIGH_Z_MODE, 0);
} else {
PIN15_setOutputValue(HIGH_Z_MODE, 1); // HIGH Z MODE // 1: close; 0: open;
}
first_highz_flag = false;
}
} else {
if (notifyFirst_flag) {
GPT.NotifyCounter = instru.notifyRate - 20;
notifyFirst_flag = false;
}
vscanReset = false;
leadTimeReset = false;
}
//vscan counter
GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
if (GPT.VscanRateCounter >= instru.VsetRate) {
if (GPT.VscanRateCounter >= instru.VsetRate * 2) {
GPT.GptimerMultiple = GPT.VscanRateCounter / instru.VsetRate;
} else {
GPT.GptimerMultiple = 1;
}
GPT.VscanRateCounter -= instru.VsetRate * GPT.GptimerMultiple; //To get right time
vscan_ctrl(0);
}
//battery counter
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
if(GPT.BatteryCheckCounter >= 50000){
GPT.BatteryCheckCounter -= 50000; //To get right time
batteryCheck_flag = true;
tempCheck_flag = true;
}
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
if( bat < 768 && bat > 20){
// PIN15_setOutputValue(enable_5v, 0);
}
//ADC counter
GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
if(GPT.SampleRateCounter >= instru.sampleRate){
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
EliteADCControl(0);
}
// Over temperature protection
uint16_t CC2650temp = ((uint16_t)(NotifyTemperature[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyTemperature[3]) & 0x00FF);
if(CC2650temp > 40) {
PIN15_setOutputValue(enable_5v, 0);
}
//Notify counter(Notify control, check if we need to send notify)
//please don't put Notify counter before ADC counter, maybe get wrong data
GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
if(GPT.NotifyCounter >= instru.notifyRate){
GPT.NotifyCounter -= instru.notifyRate; //To get right time
notify_flag = true;
if(vscanReset){
notify_flag = false;
}
if (!volt_rec_en || !curr_rec_en) {
notify_flag = false;
}
if(notify_flag){
SendNotify();
notify_flag = false;
}
}
mode_done();
}
static void uni_pulse_mode(void)
{
// Default working flow is vscan -> ADC read -> send notify
// We will need a flag to control vscan, ADC and notify
GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
if (leadTimeReset && GPT.LeadTimeCounter <= 2000) {
vscanReset = true;
GPT.VscanRateCounter = 0xFFFFFFFF;
dpv_step_cnt = 0;
if (first_highz_flag && GPT.LeadTimeCounter >= 1000) {
PIN15_setOutputValue(HIGH_Z_MODE, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
first_highz_flag = false;
}
} else {
if (notifyFirst_flag) {
GPT.NotifyCounter = instru.notifyRate - 20;
notifyFirst_flag = false;
}
if (vscanReset) {
GPT.VscanRateCounter = 0xFFFFFFFF;
dpv_step_cnt = 0;
}
vscanReset = false;
leadTimeReset = false;
}
//vscan counter
GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
if (GPT.VscanRateCounter >= instru.period) {
GPT.VscanRateCounter -= instru.period; //To get right time
dpv_step_cnt +=1;
}
vscan_ctrl(GPT.VscanRateCounter);
//battery counter
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
if(GPT.BatteryCheckCounter >= 50000){
GPT.BatteryCheckCounter -= 50000; //To get right time
batteryCheck_flag = true;
tempCheck_flag = true;
}
//ADC counter
GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
if(GPT.SampleRateCounter >= instru.sampleRate){
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
EliteADCControl(GPT.VscanRateCounter);
}
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
if( bat < 768 && bat > 20){
// PIN15_setOutputValue(enable_5v, 0);
}
// Over temperature protection
uint16_t CC2650temp = ((uint16_t)(NotifyTemperature[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyTemperature[3]) & 0x00FF);
if(CC2650temp > 40) {
PIN15_setOutputValue(enable_5v, 0);
}
//Notify counter(Notify control, check if we need to send notify)
//please don't put Notify counter before ADC counter, maybe get wrong data
GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
if(GPT.NotifyCounter >= instru.notifyRate){
GPT.NotifyCounter -= instru.notifyRate; //To get right time
notify_flag = true;
if (instru.eliteFxn == CURVE_UNI_PULSE || instru.eliteFxn == CURVE_DPV || instru.eliteFxn == CURVE_DPV_ADVANCE) {
notify_flag = false;
}
if(vscanReset){
notify_flag = false;
}
if (!volt_rec_en || !curr_rec_en) {
notify_flag = false;
}
if(notify_flag){
SendNotify();
notify_flag = false;
}
}
mode_done();
}
static void mode_init_set(void)
{
batteryADC_flag = false;
volt_rec_en = true;
curr_rec_en = true;
firstTimeReset = true;
notifyFirst_flag = true;
first_highz_flag = true;
DACReset = true;
vscanReset = true;
leadTimeReset = true;
if (instru.notifyRate > 1000) {
// slow notify rate, < 10sps, auto gain changer only use ADC gain level = 1.2.3.4
// gain_switch_on: [1:4]: none
// [5]: ADC gain level = 4, if value = 1, gain 4 switch on
// [6]: ADC gain level = 3, if value = 1, gain 3 switch on
// [7]: ADC gain level = 2, if value = 1, gain 2 switch on
// [8]: ADC gain level = 1, if value = 1, gain 1 switch on
instru.gain_switch_on = 0b11110000;
} else {
// fast notify rate, >= 10sps, auto gain changer only use ADC gain level = 1.2.3
instru.gain_switch_on = 0b01110000;
}
if (instru.IinADCGainLv == I_GAIN_AUTO) {
instru.IinADCGainLv = I_GAIN_100R;
}
if (instru.VinADCAutoGainEn == VIN_GAIN_AUTO) {
instru.VinADCGainLv = VIN_GAIN_1K;
}
VinADCGainCtrl(instru.VinADCGainLv);
IinADCGainCtrl(instru.IinADCGainLv);
VoutGainControl(instru.VoutGainLv);
if (Ve1MatchVe2Mode()) {
if (instru.Ve1 == instru.Ve2) {
DAC_outputV(Usercode_Correction_to_DAC(instru.VoutGainLv, instru.Ve1));
PeriodicEvent = false;
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0: open highz;
ModeLED(NO_EVENT);
}
}
return;
}
/*********************************************************************
* @fn SimpleBLEPeripheral_performPeriodicTask
@@ -91,212 +432,360 @@ static void DACCode2Real2Notify(uint16_t DACcode) {
*
* @return None.
*/
static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
if ( IsPeriodicMode() ){
static void SimpleBLEPeripheral_performPeriodicTask(void)
{
GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
GPT.GptimerCounter0 = GPT.GptimerCounter;
// DAC counter
if (CT.StepTimeCounter == INSTRUCTION.StepTime){
CT.StepTimeCounter = 1;
}
else{
CT.StepTimeCounter++;
if (IsPeriodicMode()) {
if (mode_init) {
GPT.SampleRateCounter = instru.sampleRate - 10;
GPT.VscanRateCounter = instru.VsetRate - 1;
mode_init = false;
mode_init_set();
}
// ADC counter
if (CT.SampleRate_counter == INSTRUCTION.SampleRate){
CT.SampleRate_counter = 1;
}
else{
CT.SampleRate_counter++;
}
peri_mode();
// notify counter
if (CT.NotifyCounter == INSTRUCTION.NotifyRate){
CT.NotifyCounter = 1;
}
else{
CT.NotifyCounter ++;
}
/** Periodic Event **/
// Default working flow is DAC out -> ADC read -> send notify
// We will need a flag to control DAC, if we want to exchange to ADC -> DAC -> notify
// This flag can be named by FxnNameDACReset
// In IV, CV, and func-gen mode, DAC will output voltage
// else DAC do nothing.
EliteDACControl(WorkModeData);
// Control ADC to sample rate
EliteADCControl(WorkModeData);
// Notify control, check if we need to send notify
EliteNotifyControl();
}
else if(INSTRUCTION.eliteFxn == VOLT_OUTPUT){
// assign WorkModeData->VO = INSTRUCTION.VoltConstant
WorkModeData->VO->_VoltOut = INSTRUCTION.VoltConstant;
// UserCode -> DAC code -> DAC out
DAC_outputV(Usercode_Correction_to_DAC(WorkModeData->VO->_VoltOut));
// DAC_outputV(WorkModeData->VO->_VoltOut); // for voltage output calibration
FreeWorkMode(WorkModeData);
PeriodicEvent = false;
InitPeriodicEvent = true;
}
else{
PeriodicEvent = false;
}
}
static void EliteDACControl(WorkMode *WorkModeData) {
if (INSTRUCTION.eliteFxn == IV_CURVE) {
// output a certain voltage and put it into NotifyVolt
if(WorkModeData->IV->_VoVi_Switch == 0x00){ //user see Vout
//DACCode2Real2Notify(VoltScan(WorkModeData));
uint16_t DACcode;
DACcode = VoltScan(WorkModeData);
}
else if (WorkModeData->IV->_VoVi_Switch == 0x01){ //user see Vin
VoltScan(WorkModeData);
}
}
else if(INSTRUCTION.eliteFxn == CV_CURVE){
if (WorkModeData->CV->_VoVi_Switch == 0x00){
DACCode2Real2Notify(VoltScan(WorkModeData));
}
else if (WorkModeData->CV->_VoVi_Switch == 0x01){
VoltScan(WorkModeData);
}
}
else if (INSTRUCTION.eliteFxn == ZT_CURVE){
if(INSTRUCTION.ResisterMeter == RESISTER_METER_SMALL){
// output 1V
if (DACReset) {
INSTRUCTION.VoltConstant = 25000 + 5000;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
DACReset = false;
}
}
else{
// output 1V
if (DACReset) {
INSTRUCTION.VoltConstant = 25000 + 5000;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
DACReset = false;
}
}
}
else if(INSTRUCTION.eliteFxn == CONSTANT_CURRENT){
if (DACReset) {
DAC_outputV(Usercode_Correction_to_DAC(25000));
DACReset = false;
}
CCModeVoltOut(WorkModeData->CC);
}
else{
// IT, VT need only ADC measure
return;
}
if (instru.eliteFxn == CURVE_UNI_PULSE) {
if (mode_init) {
mode_init = false;
mode_init_set();
calc_avg_en = false;
}
uni_pulse_mode();
return;
}
if (instru.eliteFxn == CURVE_DPV || instru.eliteFxn == CURVE_DPV_ADVANCE) {
if (mode_init) {
mode_init = false;
mode_init_set();
calc_avg_en = false;
}
uni_pulse_mode();
return;
}
if (instru.eliteFxn == CURVE_DPV_SMPRATE || instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE) {
if (mode_init) {
mode_init = false;
mode_init_set();
}
uni_pulse_mode();
return;
}
return;
}
static void EliteADCControl(WorkMode *WorkModeData) {
if (CT.SampleRate_counter == INSTRUCTION.SampleRate - 1) {
switch (INSTRUCTION.eliteFxn) {
case IV_CURVE:{
IV_Plot(WorkModeData->IV);
// IT_Plot(WorkModeData);
break;
}
case CV_CURVE:{
CV_Plot(WorkModeData->CV);
break;
}
case IT_CURVE:{
IT_Plot(WorkModeData);
// NotifyReady = true;
break;
}
case VT_CURVE:{
// read volt through ADC and put it into notify buffer
VT_Plot(WorkModeData->VT);
// NotifyReady = true;
break;
}
case ZT_CURVE:{
ZT_Plot(WorkModeData->RT);
// NotifyReady = true;
break;
}
case CONSTANT_CURRENT:{
CCModeReadCurrent(WorkModeData->CC);
// CCModeReverseCurrent(WorkModeData->CC);
break;
}
case READ_VOUT_VALUE:{
RVout_Plot(WorkModeData->RVout);
/*uint8_t ReadVoutBuf[2] = {0};
ADC_write(0xA4);
ADC_read(ReadVoutBuf);
SimpleProfile_SetParameter(BLE_DAT_BUFF_CHAR, 2, ReadVoutBuf);*/
break;
/*
* EliteADCControl(): use ADC plot, and send what data to controller
* +-----------------+-----------+-----------+-----------+
* | MODE | ch1 | ch2 | ch3 |
* +-----------------+-----------+-----------+-----------+
* | CURVE_IV | Iin | Vout | Vin |
* | CURVE_IV_CY | Iin | Vout | Vin |
* | CURVE_VO | Iin | Vout | Vin |
* | CURVE_RT | Iin | Vout | R |
* | CURVE_VT | Iin | Vin | |
* | CURVE_IT | Iin | Vin | Vout |
* | CURVE_CC | Iin | Vin | Vout |
* | CURVE_CV | Iin | Vout-Vin | Vout |
* | CURVE_LSV | Iin | Vout-Vin | Vout |
* | CURVE_CA | Iin | Vout-Vin | Vout |
* | CURVE_OCP | Iin | Vmon-Vin | Vin |
* | CURVE_UNI_PULSE | pul1_Iin | pul2_Iin | |
* +-----------------+-----------+-----------+-----------+
*/
static void EliteADCControl(uint32_t time)
{
void *wm = wm_get();
uint32_t t = time;
switch (instru.eliteFxn) {
case CURVE_IV:
case CURVE_IV_CY:
Iin_Vin_Vout_Plot(t);
if (curr_rec_en) {
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
}
default:{
IT_Plot(WorkModeData);
// NotifyReady = true;
break;
if (volt_rec_en) {
InputNotify(NOTIFY_VOLT, instru.Vout/200);
InputNotify(NOTIFY_IMPEDANCE, MEAS_VIN(wm));
}
}
break;
case CURVE_RT:
Iin_Vin_Vout_Plot(t);
if (curr_rec_en) {
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
}
if (volt_rec_en) {
InputNotify(NOTIFY_VOLT, instru.Vout/200);
}
break;
case CURVE_CC:
Iin_Vin_Vout_Plot(t);
if (curr_rec_en) {
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
}
if (volt_rec_en) {
InputNotify(NOTIFY_VOLT, MEAS_VIN(wm));
InputNotify(NOTIFY_IMPEDANCE, instru.Vout/200);
}
break;
case CURVE_CV:
case CURVE_CA:
case CURVE_LSV:
Iin_Vin_Vout_Plot(t);
if (curr_rec_en) {
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
}
if (volt_rec_en) {
InputNotify(NOTIFY_VOLT, instru.Vout/200 - MEAS_VIN(wm));
InputNotify(NOTIFY_IMPEDANCE, instru.Vout/200);
}
break;
case CURVE_PULSE:
Iin_Vin_Vout_Plot(t);
if (curr_rec_en) {
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
}
if (volt_rec_en) {
InputNotify(NOTIFY_VOLT, MEAS_VIN(wm));
InputNotify(NOTIFY_IMPEDANCE, MEAS_VOUT(wm));
}
break;
case CURVE_IT:
Iin_Vin_Vout_Plot(t);
if (curr_rec_en) {
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
}
if(volt_rec_en) {
InputNotify(NOTIFY_VOLT, MEAS_VIN(wm));
InputNotify(NOTIFY_IMPEDANCE, instru.Vout/200);
}
break;
case CURVE_VT:
Iin_Vin_Plot();
if (curr_rec_en) {
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
}
if (volt_rec_en) {
InputNotify(NOTIFY_VOLT, MEAS_VIN(wm));
}
break;
case CURVE_VO:
Iin_Vin_Vout_Plot(t);
if (curr_rec_en) {
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
}
if (volt_rec_en) {
InputNotify(NOTIFY_VOLT, instru.Vout/200);
InputNotify(NOTIFY_IMPEDANCE, MEAS_VIN(wm));
}
break;
case CURVE_OCP:
Iin_Vin_Vout_Plot(t);
if (curr_rec_en) {
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
}
if (volt_rec_en) {
InputNotify(NOTIFY_VOLT, MEAS_VOUT(wm) - MEAS_VIN(wm));
InputNotify(NOTIFY_IMPEDANCE, MEAS_VIN(wm));
}
break;
case CURVE_CALI_ADC:
if (instru.AdcChannel == RIS_ADC_IIN) {
cali_IT_plot();
} else if (instru.AdcChannel == RIS_ADC_VIN) {
cali_VT_plot();
} else if (instru.AdcChannel == RIS_DAC_VOUT) {
cali_Vout_plot();
}
break;
case CURVE_UNI_PULSE:
IT_Plot(t);
break;
case CURVE_DPV:
Iin_Vin_Vout_Plot(t);
break;
case CURVE_DPV_SMPRATE:
Iin_Vin_Vout_Plot(t);
if (curr_rec_en) {
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
}
if (volt_rec_en) {
InputNotify(NOTIFY_VOLT, instru.Vout/200 - MEAS_VIN(wm));
InputNotify(NOTIFY_IMPEDANCE, instru.Vout/200);
}
break;
case CURVE_DPV_ADVANCE:
Iin_Vin_Vout_Plot(t);
break;
case CURVE_DPV_ADVANCE_SMPRATE:
Iin_Vin_Vout_Plot(t);
if (curr_rec_en) {
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
}
if (volt_rec_en) {
InputNotify(NOTIFY_VOLT, instru.Vout/200 - MEAS_VIN(wm));
InputNotify(NOTIFY_IMPEDANCE, instru.Vout/200);
}
break;
default:
break;
}
}
static void EliteNotifyControl() {
if ((INSTRUCTION.eliteFxn == IV_CURVE) || (INSTRUCTION.eliteFxn == CV_CURVE)) {
// output the last notify, and reset Elite
static void mode_done(void)
{
if ((instru.eliteFxn == CURVE_IV) ||
(instru.eliteFxn == CURVE_CV) ||
(instru.eliteFxn == CURVE_LSV) ||
(instru.eliteFxn == CURVE_IV_CY) ||
(instru.eliteFxn == CURVE_DPV) ||
(instru.eliteFxn == CURVE_DPV_SMPRATE) ||
(instru.eliteFxn == CURVE_DPV_ADVANCE) ||
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE)) {
if (!PeriodicEvent) {
finishMode = true;
SendNotify();
reset();
} else if (CT.StepTimeCounter == INSTRUCTION.StepTime/2) {
SendNotify();
Eliteinterrupt();
}
}
else if(INSTRUCTION.eliteFxn == CONSTANT_CURRENT){
if(CT.NotifyCounter == INSTRUCTION.NotifyRate){
SendNotify();
}
}
else if (CT.SampleRate_counter == INSTRUCTION.SampleRate) {
SendNotify();
}
}
static void vscan_ctrl(uint32_t time)
{
uint32_t t = time;
static uint16_t StepCode2DACcode(uint16_t StepCode){
return (StepCode * 0x0005 / 10);
switch (instru.eliteFxn) {
case CURVE_IV:
iv_vscan();
break;
case CURVE_IV_CY:
iv_cy_vscan();
break;
case CURVE_VO:
vo_vscan();
break;
case CURVE_RT:
rt_vscan();
break;
case CURVE_IT:
it_vscan();
break;
case CURVE_CV:
cv_vscan();
break;
case CURVE_LSV:
lsv_vscan();
break;
case CURVE_CA:
ca_vscan();
break;
case CURVE_UNI_PULSE:
uni_pulse_vscan(t);
break;
case CURVE_DPV:
case CURVE_DPV_SMPRATE:
dpv_vscan(t);
break;
case CURVE_DPV_ADVANCE:
case CURVE_DPV_ADVANCE_SMPRATE:
dpv_advance_vscan(t);
break;
default:{
break;
}
}
}
static uint16_t OldStep2NewStepTime(uint8_t StepTime) {
static uint32_t OldStep2NewStepTime(uint32_t StepTime){
uint8_t StepTimeLevel = 0;
StepTimeLevel = StepTime / 0x12;
switch (StepTimeLevel) {
case 0: { //0.5 sec
return STEPTIME_HALF_SEC;
}
case 1: { //1 sec
return STEPTIME_ONE_SEC;
}
case 2: { //2 sec
return STEPTIME_TWO_SEC;
}
default: { //1 sec
return STEPTIME_ONE_SEC;
case 0: { //0.5 sec
return STEPTIME_HALF_SEC;
}
case 1: { //1 sec
return STEPTIME_ONE_SEC;
}
case 2: { //2 sec
return STEPTIME_TWO_SEC;
}
default: { //1 sec
return STEPTIME_ONE_SEC;
}
}
}
static void step2VsetRate(uint32_t step){
/*step = 100 mv, index = 0, n = 2
10 mv, index = 1, n = 10
1 mv, index = 2, n = 100
0.1 mv, index = 3, n = 1000
0.01mv, index = 4, n = 10000 */
if(step >= 10000){
instru.VsetRateIndex = 0;
}else if (step >= 1000){
instru.VsetRateIndex = 1;
}else if (step >= 100){
instru.VsetRateIndex = 2;
}else if (step >= 10){
instru.VsetRateIndex = 3;
}else if (step >= 1){
instru.VsetRateIndex = 4;
}
}
@@ -0,0 +1,889 @@
#ifndef SCAN_VOLT_H
#define SCAN_VOLT_H
#ifdef __cplusplus
extern "C" {
#endif
#define Vset instru.Vset
static void iv_vscan(void)
{
struct wm_iv_ctx_t *iv = (struct wm_iv_ctx_t *)wm_get();
if (vscanReset) {
if (instru.directionInit == 1) {
iv->_direction_up = true;
iv->_current_direction_up = true;
} else if (instru.directionInit == 0) {
iv->_direction_up = false;
iv->_current_direction_up = false;
}
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
if (instru.step <= 10) {
iv->_Vstep = instru.step * instru.VsetRate / 5;
} else {
iv->_Vstep = instru.step / 5 * instru.VsetRate;
}
Vset = iv->_Vinit;
}
if (!vscanReset) {
if (iv->_current_direction_up) {
if (Vset >= iv->_Vmax) {
PeriodicEvent = false;
}
} else {
if (Vset <= iv->_Vmin) {
PeriodicEvent = false;
}
}
if (iv->_current_direction_up) {
Vset = Vset + iv->_Vstep * GPT.GptimerMultiple;
} else {
Vset = Vset - iv->_Vstep * GPT.GptimerMultiple;
}
}
return;
}
static void iv_cy_vscan(void)
{
struct wm_iv_cy_ctx_t *iv_cy = (struct wm_iv_cy_ctx_t *)wm_get();
static bool VminCounter;
static bool VmaxCounter;
NotifyCycleNumber = (instru.cycleNumber - iv_cy->_cycleNumber + 1);
if(vscanReset){
VmaxCounter = false;
VminCounter = false;
if(instru.directionInit == 1){
iv_cy->_direction_up = true;
iv_cy->_current_direction_up = true;
}else if(instru.directionInit == 0){
iv_cy->_direction_up = false;
iv_cy->_current_direction_up = false;
}
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
if(instru.step <= 10){
iv_cy->_Vstep = instru.step * instru.VsetRate / 5;
}else{
iv_cy->_Vstep = instru.step / 5 * instru.VsetRate;
}
if(iv_cy->_Vmin == iv_cy->_Vinit){
VminCounter = true;
}
if(iv_cy->_Vmax == iv_cy->_Vinit){
VmaxCounter = true;
}
Vset = iv_cy->_Vinit;
}
if(!vscanReset){
if (Vset >= iv_cy->_Vmax){
VmaxCounter = true;
}else if (Vset <= iv_cy->_Vmin){
VminCounter = true;
}
if (iv_cy->_current_direction_up){
Vset = Vset + iv_cy->_Vstep * GPT.GptimerMultiple;
}else{
Vset = Vset - iv_cy->_Vstep * GPT.GptimerMultiple;
}
if(VmaxCounter && VminCounter){
if(iv_cy->_direction_up && iv_cy->_current_direction_up){
if(Vset >= iv_cy->_Vinit){
iv_cy->_cycleNumber--;
VminCounter = false;
VmaxCounter = false;
}
}
if(!iv_cy->_direction_up && !iv_cy->_current_direction_up){
if(Vset <= iv_cy->_Vinit){
iv_cy->_cycleNumber--;
VminCounter = false;
VmaxCounter = false;
}
}
}
if (Vset >= iv_cy->_Vmax){
iv_cy->_current_direction_up = false;
}else if (Vset <= iv_cy->_Vmin){
iv_cy->_current_direction_up = true;
}
/*stop condition*/
if(iv_cy->_cycleNumber == 0){
PeriodicEvent = false;
}
}
return;
}
static void it_vscan(void)
{
struct wm_it_ctx_t *it = (struct wm_it_ctx_t *)wm_get();
if (vscanReset) {
Vset = it->_Vinit;
}
if(!vscanReset) {
Vset = it->_Vinit;
}
return;
}
static void rt_vscan(void)
{
struct wm_rt_ctx_t *rt = (struct wm_rt_ctx_t *)wm_get();
if (vscanReset) {
Vset = rt->_Vinit;
}
if(!vscanReset) {
Vset = rt->_Vinit;
}
return;
}
static void vo_vscan(void)
{
struct wm_vo_ctx_t *vo = (struct wm_vo_ctx_t *)wm_get();
if (vscanReset) {
Vset = vo->_Vinit;
}
if(!vscanReset) {
Vset = vo->_Vinit;
}
return;
}
#define __CC_I_BASIC_SMALLEST (1 * 1000000 / 50) // 1uA
#define __CC_V_DELTAV_LARGEST (100 * 1000000 / 5) // 100 mv
#define __CC_VOLT_HIGH_SPEED (1000 * 1000000 / 5) // 1V
#define __CC_VOLT_LOW_SPEED (100 * 100000 / 5) // 10mv
#define __CC_I_HIGH_SPEED_LIMIT (2 * 1000000 / 50) // 2uA
static void cc_vscan(void)
{
struct wm_cc_ctx_t *cc = (struct wm_cc_ctx_t *)wm_get();
struct wm_meas_t *m = &cc->measure;
int32_t Iin;
int32_t Vin;
int32_t i_delta;
int32_t i_basic; // I Magnification Denominator
int32_t i_err; // deviation
int32_t multiple;
int32_t v_delta;
if (vscanReset) {
Vset = 0;
if (cc->_charge == 0) {
cc->_Iset = instru.constantCurrent * 200 * (-1);
//[50pA] //controller UI 15000uA => Elite 1500000 => 1500000 * 10 * 1000 / 50 [50pA];
}
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
Vin = m->_measureVin * 200; //[5nV]
Vset = Vin + cc->_Iset; //[5nV]
}
if (!vscanReset) {
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
i_delta = Iin - cc->_Iset;
// calc I Magnification
if (abs(cc->_Iset) > __CC_I_BASIC_SMALLEST)
i_basic = abs(cc->_Iset);
else
i_basic = abs(__CC_I_BASIC_SMALLEST);
//calc deviation value
multiple = abs(i_delta / i_basic);
if (multiple <= 1)
i_err = i_delta * 1000 / i_basic;
else if (multiple <= 10)
i_err = i_delta * 100 / i_basic * 10;
else if (multiple <= 100)
i_err = i_delta * 10 / i_basic * 100;
else
i_err = i_delta / i_basic * 1000;
if (abs(i_err) > 2 * 1E9 / (__CC_VOLT_HIGH_SPEED / 1000)) {
if (i_delta > 0)
v_delta = __CC_V_DELTAV_LARGEST;
else if (i_delta < 0)
v_delta = -1 * __CC_V_DELTAV_LARGEST;
} else {
if (abs(i_delta) > __CC_I_HIGH_SPEED_LIMIT && i_err > 1000 * 5 / 100)
v_delta = i_err * (__CC_VOLT_HIGH_SPEED / 1000);
else
v_delta = i_err * (__CC_VOLT_LOW_SPEED / 1000);
}
if (i_delta > 0 && v_delta > __CC_V_DELTAV_LARGEST)
v_delta = __CC_V_DELTAV_LARGEST;
else if (i_delta < 0 && v_delta < -1 * __CC_V_DELTAV_LARGEST)
v_delta = -1 * __CC_V_DELTAV_LARGEST;
Vset = Vset - v_delta; //[5nV]
if (Vset <= cc->_Vmin) {
Vset = cc->_Vmin;
} else if (Vset >= cc->_Vmax) {
Vset = cc->_Vmax;
}
}
return;
}
static void cv_vscan(void)
{
struct wm_cv_ctx_t *cv = (struct wm_cv_ctx_t *)wm_get();
static bool VminCounter;
static bool VmaxCounter;
NotifyCycleNumber = (instru.cycleNumber - cv->_cycleNumber + 1);
if (vscanReset) {
VmaxCounter = false;
VminCounter = false;
if (instru.directionInit == 1) {
cv->_direction_up = true;
cv->_current_direction_up = true;
} else {
cv->_direction_up = false;
cv->_current_direction_up = false;
}
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
if (instru.step <= 10) {
cv->_Vstep = instru.step * instru.VsetRate / 5;
} else {
cv->_Vstep = instru.step / 5 * instru.VsetRate;
}
if (cv->_Vmin == cv->_Vinit) {
VminCounter = true;
}
if (cv->_Vmax == cv->_Vinit) {
VmaxCounter = true;
}
Vset = cv->_Vinit;
}
if (!vscanReset) {
if ((instru.Vinit < instru.Ve1 && instru.Vinit < instru.Ve2) ||
(instru.Vinit > instru.Ve1 && instru.Vinit > instru.Ve2)
) {
if (cv->_current_direction_up) {
Vset = Vset + cv->_Vstep * GPT.GptimerMultiple;
} else {
Vset = Vset - cv->_Vstep * GPT.GptimerMultiple;
}
if (instru.Vinit < instru.Ve1 && instru.Vinit < instru.Ve2) {
if (Vset == cv->_Vmin) {
VminCounter = true;
instru.Vinit = instru.Vmin;
cv->_Vinit = cv->_Vmin;
}
} else if (instru.Vinit > instru.Ve1 && instru.Vinit > instru.Ve2) {
if (Vset == cv->_Vmax) {
VmaxCounter = true;
instru.Vinit = instru.Vmax;
cv->_Vinit = cv->_Vmax;
}
}
} else {
if (Vset >= cv->_Vmax) {
VmaxCounter = true;
} else if (Vset <= cv->_Vmin) {
VminCounter = true;
}
if (cv->_current_direction_up) {
Vset = Vset + cv->_Vstep * GPT.GptimerMultiple;
} else {
Vset = Vset - cv->_Vstep * GPT.GptimerMultiple;
}
if (VmaxCounter && VminCounter) {
if (cv->_direction_up && cv->_current_direction_up) {
if (Vset >= cv->_Vinit) {
cv->_cycleNumber--;
VminCounter = false;
VmaxCounter = false;
}
}
if (!cv->_direction_up && !cv->_current_direction_up) {
if (Vset <= cv->_Vinit) {
cv->_cycleNumber--;
VminCounter = false;
VmaxCounter = false;
}
}
}
if (Vset >= cv->_Vmax) {
cv->_current_direction_up = false;
} else if (Vset <= cv->_Vmin) {
cv->_current_direction_up = true;
}
/*stop condition*/
if (cv->_cycleNumber == 0) {
PeriodicEvent = false;
}
}
}
return;
}
static void lsv_vscan(void)
{
struct wm_lsv_ctx_t *lsv = (struct wm_lsv_ctx_t *)wm_get();
NotifyCycleNumber = (instru.cycleNumber - lsv->_cycleNumber + 1);
if (vscanReset) {
if (instru.directionInit == 1) {
lsv->_direction_up = true;
lsv->_current_direction_up = true;
} else {
lsv->_direction_up = false;
lsv->_current_direction_up = false;
}
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
if (instru.step <= 10) {
lsv->_Vstep = instru.step * instru.VsetRate / 5;
} else {
lsv->_Vstep = instru.step / 5 * instru.VsetRate;
}
Vset = lsv->_Vinit;
}
if (!vscanReset) {
if (lsv->_current_direction_up) {
Vset = Vset + lsv->_Vstep * GPT.GptimerMultiple;
} else {
Vset = Vset - lsv->_Vstep * GPT.GptimerMultiple;
}
/*stop condition*/
if (Vset >= lsv->_Vmax) {
PeriodicEvent = false;
} else if (Vset <= lsv->_Vmin) {
PeriodicEvent = false;
}
}
return;
}
static void ca_vscan(void)
{
struct wm_ca_ctx_t *ca = (struct wm_ca_ctx_t *)wm_get();
if(vscanReset){
Vset = ca->_Vinit;
}
if(!vscanReset){
Vset = ca->_Vinit;
}
return;
}
static void uni_pulse_vscan(uint32_t time)
{
uint32_t t = time;
struct wm_uni_pulse_ctx_t *p = (struct wm_uni_pulse_ctx_t *)wm_get();
uint32_t m;
uint32_t t_min;
uint32_t t_max;
if(vscanReset){
Vset = p->_v0;
return;
}
if(!vscanReset){
if (t == 0) {
m = 0;
} else {
m = t % p->_t_period;
}
if (m < p->_t_pa[0]) {
p->_Vset = p->_v_initial[0] + p->_v_slope[0] * t + p->_v_step[0] * (int32_t)(t / p->_t_period);
Vset = p->_Vset;
t_min = p->_t_pulse_min[0];
t_max = p->_t_pulse_max[0];
if (m > t_min && m < t_max) {
calc_avg_en = true;
} else {
calc_avg_en = false;
}
return;
}
if (m < p->_t_pa[1]) {
p->_Vset = p->_v_initial[1] + p->_v_slope[1] * t + p->_v_step[1] * (int32_t)(t / p->_t_period);
Vset = p->_Vset;
t_min = p->_t_pa[0] + p->_t_pulse_min[1];
t_max = p->_t_pa[0] + p->_t_pulse_max[1];
if (m > t_min && m < t_max) {
calc_avg_en = true;
} else {
calc_avg_en = false;
}
return;
}
if (m < p->_t_pa[2]) {
p->_Vset = p->_v_initial[2] + p->_v_slope[2] * t + p->_v_step[2] * (int32_t)(t / p->_t_period);
Vset = p->_Vset;
t_min = p->_t_pa[1] + p->_t_pulse_min[2];
t_max = p->_t_pa[1] + p->_t_pulse_max[2];
if (m > t_min && m < t_max) {
calc_avg_en = true;
} else {
calc_avg_en = false;
}
return;
}
if (m < p->_t_pa[3]) {
p->_Vset = p->_v_initial[3] + p->_v_slope[3] * t + p->_v_step[3] * (int32_t)(t / p->_t_period);
Vset = p->_Vset;
t_min = p->_t_pa[2] + p->_t_pulse_min[3];
t_max = p->_t_pa[2] + p->_t_pulse_max[3];
if (m > t_min && m < t_max) {
calc_avg_en = true;
} else {
calc_avg_en = false;
}
return;
}
return;
}
return;
}
static void dpv_vscan(uint32_t time)
{
uint32_t t = time;
struct wm_dpv_ctx_t *p = (struct wm_dpv_ctx_t *)wm_get();
uint32_t m;
uint32_t t_min;
uint32_t t_max;
if(vscanReset){
Vset = p->_v0;
return;
}
if(!vscanReset){
if (t == 0) {
m = 0;
} else {
m = t % p->_t_period;
}
if (m < p->_t_pa[0]) {
p->_Vset = p->_v_initial[0] + p->_v_slope[0] * t / 1000 + p->_v_step[0] * (int32_t)dpv_step_cnt; // _v_slope/100 = slope
Vset = p->_Vset;
t_min = p->_t_pulse_min[0];
t_max = p->_t_pulse_max[0];
if (m > t_min && m < t_max) {
calc_avg_en = true;
} else {
calc_avg_en = false;
}
if ((p->_v_curr_direc && Vset >= p->_v_stop) ||
(!p->_v_curr_direc && Vset <= p->_v_stop)) {
PeriodicEvent = false;
}
return;
}
if (m < p->_t_pa[1]) {
p->_Vset = p->_v_initial[1] + p->_v_slope[1] * t / 1000 + p->_v_step[1] * (int32_t)dpv_step_cnt;
Vset = p->_Vset;
t_min = p->_t_pa[0] + p->_t_pulse_min[1];
t_max = p->_t_pa[0] + p->_t_pulse_max[1];
if (m > t_min && m < t_max) {
calc_avg_en = true;
} else {
calc_avg_en = false;
}
return;
}
return;
}
return;
}
static void dpv_advance_vscan(uint32_t time)
{
uint32_t t = time;
struct wm_dpv_advance_ctx_t *p = (struct wm_dpv_advance_ctx_t *)wm_get();
uint32_t m;
uint32_t t_min;
uint32_t t_max;
static bool VminCounter;
static bool VmaxCounter;
if(vscanReset){
if (p->_v_direc_init) {
if (p->_v0 <= p->_v_up && p->_v0 <= p->_v_low && p->_v_2 > p->_v_1) {
VminCounter = true;
}
} else {
if (p->_v0 >= p->_v_up && p->_v0 >= p->_v_low && p->_v_1 > p->_v_2) {
VmaxCounter = true;
}
}
p->_Vset = p->_v0;
Vset = p->_Vset;
return;
}
if(!vscanReset){
if (t == 0) {
m = 0;
} else {
m = t % p->_t_period;
}
if (m < p->_t_pa[0]) {
t_min = p->_t_pulse_min[0];
t_max = p->_t_pulse_max[0];
if (m > t_min && m < t_max) {
calc_avg_en = true;
} else {
calc_avg_en = false;
}
p->_Vset = p->_v_initial[0] + p->_v_slope[0] * t / 1000 + p->_v_step[0] * (int32_t)dpv_step_cnt; // _v_slope/100 = slope
Vset = p->_Vset;
if (VminCounter == true && VmaxCounter == true) {
p->_cycleNumber--;
VminCounter = false;
VmaxCounter = false;
}
if (p->_cycleNumber <= 0) {
if (p->_v_stop_direction == true && p->_Vset >= p->_v_stop - p->_v_amp + p->_v_step[0]) {
PeriodicEvent = false;
} else if (p->_v_stop_direction == false && p->_Vset <= p->_v_stop - p->_v_amp + p->_v_step[0]) {
PeriodicEvent = false;
}
}
if (p->_v_curr_direc && p->_Vset >= p->_v_up - p->_v_amp + p->_v_step[0]) {
if (p->_v_invert_option) {
p->_v_amp = p->_v_amp * (-1);
}
p->_v_initial[0] = p->_Vset;
p->_v_initial[1] = p->_v_initial[0] + p->_v_amp;
dpv_step_cnt = 0;
p->_v_step[0] = (-1) * p->_v_step[0];
p->_v_step[1] = (-1) * p->_v_step[1];
p->_v_curr_direc = false;
VmaxCounter = true;
p->_Vset = p->_v_initial[0] + p->_v_slope[0] * t / 1000 * (int32_t)dpv_step_cnt; // _v_slope/100 = slope
Vset = p->_Vset;
} else if (!p->_v_curr_direc && p->_Vset <= p->_v_low - p->_v_amp + p->_v_step[0]) {
if (p->_v_invert_option) {
p->_v_amp = p->_v_amp * (-1);
}
p->_v_initial[0] = p->_Vset;
p->_v_initial[1] = p->_v_initial[0] + p->_v_amp;
dpv_step_cnt = 0;
p->_v_step[0] = (-1) * p->_v_step[0];
p->_v_step[1] = (-1) * p->_v_step[1];
p->_v_curr_direc = true;
VminCounter = true;
p->_Vset = p->_v_initial[0] + p->_v_slope[0] * t / 1000 * (int32_t)dpv_step_cnt; // _v_slope/100 = slope
Vset = p->_Vset;
}
return;
}
if (m < p->_t_pa[1]) {
p->_Vset = p->_v_initial[1] + p->_v_slope[1] * t / 1000 + p->_v_step[1] * (int32_t)dpv_step_cnt;
Vset = p->_Vset;
t_min = p->_t_pa[0] + p->_t_pulse_min[1];
t_max = p->_t_pa[0] + p->_t_pulse_max[1];
if (m > t_min && m < t_max) {
calc_avg_en = true;
} else {
calc_avg_en = false;
}
return;
}
return;
}
return;
}
static void pulse_vscan(void)
{
struct wm_pulse_ctx_t *pulse = (struct wm_pulse_ctx_t *)wm_get();
static uint16_t lastVolt;
if (stiFirstTime) {
stiFirstTime = false;
lastVolt = 25000;
pulse->_sti_t_flag = 1;
pulse->_sti_v = pulse->_sti_v1;
pulse->_sti_t = pulse->_sti_t1;
if (pulse->_sti_t == 1) {
pulse->_sti_v = lastVolt;
}
} else if(!stiFirstTime) {
if (GPT.StiCounter >= pulse->_sti_t) {
GPT.StiCounter -= pulse->_sti_t; //to get right time
if (pulse->_sti_lp > 0) {
if (pulse->_sti_cy > 0) {
if (pulse->_sti_t_flag == 1) {
pulse->_sti_t_flag = 2;
pulse->_sti_v = pulse->_sti_v2;
pulse->_sti_t = pulse->_sti_t2;
if (pulse->_sti_t == 1) {
pulse->_sti_v = lastVolt;
}
} else if (pulse->_sti_t_flag == 2) {
pulse->_sti_t_flag = 3;
pulse->_sti_v = pulse->_sti_v3;
pulse->_sti_t = pulse->_sti_t3;
if (pulse->_sti_t == 1) {
pulse->_sti_v = lastVolt;
}
} else if (pulse->_sti_t_flag == 3) {
pulse->_sti_cy -- ;
if (pulse->_sti_cy == 0) {
pulse->_sti_t_flag = 4;
pulse->_sti_v = pulse->_sti_v4;
pulse->_sti_t = pulse->_sti_t4;
if (pulse->_sti_t == 1) {
pulse->_sti_v = lastVolt;
}
} else {
pulse->_sti_t_flag = 2;
pulse->_sti_v = pulse->_sti_v2;
pulse->_sti_t = pulse->_sti_t2;
if (pulse->_sti_t == 1) {
pulse->_sti_v = lastVolt;
}
}
}
} else if (pulse->_sti_cy <= 0){
if (pulse->_sti_t_flag == 4) {
pulse->_sti_lp -- ;
if (pulse->_sti_lp > 0) {
pulse->_sti_cy = instru.sti_cy;
pulse->_sti_t_flag = 2;
pulse->_sti_v = pulse->_sti_v2;
pulse->_sti_t = pulse->_sti_t2;
if (pulse->_sti_t == 1) {
pulse->_sti_v = lastVolt;
}
} else {
pulse->_sti_t_flag = 5;
pulse->_sti_v = pulse->_sti_v5;
pulse->_sti_t = pulse->_sti_t5;
if (pulse->_sti_t == 1) {
pulse->_sti_v = lastVolt;
}
}
}
}
} else if (pulse->_sti_lp <= 0) {
if (pulse->_sti_t_flag == 5) {
pulse->_sti_t_flag = 6;
pulse->_sti_v = pulse->_sti_v6;
pulse->_sti_t = pulse->_sti_t6;
if (pulse->_sti_t == 1) {
pulse->_sti_v = lastVolt;
}
} else if (pulse->_sti_t_flag == 6) {
pulse->_sti_t_flag = 7;
pulse->_sti_v = pulse->_sti_v7;
pulse->_sti_t = pulse->_sti_t7;
if (pulse->_sti_t == 1) {
pulse->_sti_v = lastVolt;
}
} else if (pulse->_sti_t_flag == 7) {
pulse->_sti_v = 25000;
PeriodicEvent = false;
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0: open highz;
ModeLED(NO_EVENT);
}
}
}
}
if (lastVolt != pulse->_sti_v) {
lastVolt = pulse->_sti_v;
//if (pulse->_sti_v == 25000) {
// PIN15_setOutputValue(HIGH_Z_MODE, 0); // 1 => close high_z mode
//} else {
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
//}
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, pulse->_sti_v));
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, pulse->_sti_v));
}
return;
}
static void chg_vo_para(uint16_t parameter, int32_t value)
{
uint16_t pa = parameter;
int32_t val = value;
struct wm_vo_ctx_t *vo = (struct wm_vo_ctx_t *)wm_get();
if (pa == DAC_VOLT) {
vo->_Vinit = val;
}
return;
}
static void chg_it_para(uint16_t parameter, int32_t value)
{
uint16_t pa = parameter;
int32_t val = value;
struct wm_it_ctx_t *it = (struct wm_it_ctx_t *)wm_get();
if (pa == DAC_VOLT) {
it->_Vinit = val;
}
return;
}
static void chg_rt_para(uint16_t parameter, int32_t value)
{
uint16_t pa = parameter;
int32_t val = value;
struct wm_rt_ctx_t *rt = (struct wm_rt_ctx_t *)wm_get();
if (pa == DAC_VOLT) {
rt->_Vinit = val;
}
return;
}
static void set_para(uint8_t eliteFxn, uint16_t parameter, int32_t value)
{
uint8_t mode = eliteFxn;
uint16_t pa = parameter;
int32_t val = value;
if (mode == CURVE_VO) {
chg_vo_para(pa, val);
return;
}
if (mode == CURVE_IT) {
chg_it_para(pa, val);
return;
}
if (mode == CURVE_RT) {
chg_rt_para(pa, val);
return;
}
return;
}
#endif
@@ -543,25 +543,21 @@ static void SimpleBLEPeripheral_init(void) {
// static void detectKey_clockHandler(UArg arg);
static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
uint8_t key= 0;
bool EliteOn = 0;
uint16_t counter6994 = 0;
batteryADC_flag = false;
#define CLOCK_ONE_SECOND 10000
// Initialize application
SimpleBLEPeripheral_init();
headstage_init_device_info();
ZM_init();
Elite_SPI_init();
WorkMode *WorkModeData = CreateWorkMode();
uint8_t key = 0;
uint16_t counter6994 = 0;
bool EliteOn = 0;
// init DAC, set output ~= 0 V
DAC_outputV(Usercode_Correction_to_DAC(25000));
elite_gptimer_start();
// Application main loops
GPT.GptimerCounter0 = GPT.GptimerCounter;
headstage_battery_volt();
headstage_init_device_info();
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
@@ -609,65 +605,53 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
}
}
}
if(events & SBP_PERIODIC_EVT){
events &= ~SBP_PERIODIC_EVT;
if (!PeriodicEvent) { // if there is no periodic event
if (!PeriodicEvent) { // if there is no periodic event
key = PIN_getInputValue(switch_on);
if (EliteOn) {
if (counter6994 < CLOCK_ONE_SECOND/2) { // counter6994 enable a IC after 35 counts
if (counter6994 < CLOCK_ONE_SECOND*5) { // counter6994 enable a IC after 35 counts
counter6994++;
} else if (counter6994 == CLOCK_ONE_SECOND/2) {
PIN_setOutputValue(pin_handle, shutdown_6994, 1); // OFF = 1 => turn off 6994
// #ifdef ELITE_VERSION_1_4
// SPI_close(spiHandle0);
// I2Cinit();
// I2C_close(I2Chandle);
// spiHandle0 = SPI_open(Board_SPI0, &spiParams0); // LED SPI
// #endif
} else if (counter6994 == CLOCK_ONE_SECOND*5) {
PIN15_setOutputValue(shutdown_6994, 0); // OFF = 1 => turn off 6994
counter6994++;
} else if (counter6994 > CLOCK_ONE_SECOND*5) {
counter6994 = 0;
}
EliteKeyPress(key);
if(Free_Work_Mode){
FreeWorkMode(WorkModeData);
InitEliteInstruction();
ADCGainControl(INSTRUCTION.ADCGainLevel);
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
GPT.GptimerCounter0 = GPT.GptimerCounter;
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
if(key != 0){ //detect Elite battery power when no periodic event
measureBat();
}
if(Free_Work_Mode){
wm_deinit();
InitEliteInstruction();
Free_Work_Mode = false;
}
} else {
EliteOn = TurnOnElite(key);
}
}
// if there is periodic event
else {
else { // if there is periodic event
if(InitPeriodicEvent){
InitWorkMode(WorkModeData);
wm_init();
InitPeriodicEvent = false;
}
// Perform periodic application task
SimpleBLEPeripheral_performPeriodicTask(WorkModeData);
// Turn off Elite if battery voltage < 3V
// ReadBatVolt(spi_ADC_rxbuf);
SimpleBLEPeripheral_performPeriodicTask();
key = PIN_getInputValue(switch_on);
EliteKeyPress(key); // onPress=> key = 0; 1.lighten LED 2.long press shut down 2650
}
}
// if (events & SBP_PERIODIC_EVT)
// {
// events &= ~SBP_PERIODIC_EVT;
// Util_startClock(&periodicClock);
// Perform periodic application task
// SimpleBLEPeripheral_performPeriodicTask();
// }
// headstage_gptimer_main_handle();
#ifdef FEATURE_OAD
while (!Queue_empty(hOadQ)) {
oadTargetWrite_t *oadWriteEvt = Queue_get(hOadQ);
@@ -941,6 +925,17 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
numActive = linkDB_NumActive();
uint16_t cxnHandle;
// requestedPDUSize = LL payload = L2CAP_header + ATT header + BLE_NOT_BUFF_SIZE = 7 + BLE_NOT_BUFF_SIZE //roy
uint16_t requestedPDUSize = 251; //251 roy
uint16_t requestTxTime = 2120; // (LL payload + 14) * 8 //2120 roy
GAPRole_GetParameter(GAPROLE_CONNHANDLE, &cxnHandle);
if (SUCCESS == HCI_LE_SetDataLenCmd(cxnHandle, requestedPDUSize, requestTxTime)) {
// LED_color(DARKLED, 0xFF, 0x00, 0xFF);
}
// Use numActive to determine the connection handle of the last
// connection
if (linkDB_GetInfo(numActive - 1, &linkInfo) == SUCCESS) {
@@ -975,11 +970,12 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
case GAPROLE_WAITING:
SimpleBLEPeripheral_freeAttRsp(bleNotConnected);
ModeLED(BT_WAIT);
break;
case GAPROLE_WAITING_AFTER_TIMEOUT:
SimpleBLEPeripheral_freeAttRsp(bleNotConnected);
ModeLED(BT_WAIT);
#ifdef PLUS_BROADCASTER
// Reset flag for next connection.
+91
View File
@@ -0,0 +1,91 @@
#!/bin/bash
#input="./Elite_test.txt"
input="D:/Elite/Calibration_data/$1.txt"
output="./simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDeviceCorrection.h"
#variable
declare -i current_line=79
declare -i col_index=0
declare -i row_index=0
#declare -i coeff=1
#declare -i offset=0
declare -i current_gain=0
#declare -i vin_gain=0
#declare -i vout_gain=0
MAC="MAC"
#constant
declare -i ADC_CURRENT_GAIN_NUMBER=3
declare -i ADC_VOLTAGE_GAIN_NUMBER=1
declare -i DAC_GAIN_NUMBER=1
while read -r line; do
for word in $line; do
# get device MAC
if [ $row_index -eq 0 ] && [ $col_index -eq 1 ];then
MAC=$word
sed -i "${current_line} i {" "$output"
sed -i "${current_line} i \\\n#ifdef BOARD_${MAC}" "$output"
sed -i 's/:/_/g' "$output"
current_line=$current_line+3
fi
#get ADC current cali data
declare -i Iin_range=2+$ADC_CURRENT_GAIN_NUMBER
if [ $row_index -gt 1 ] && [ $row_index -lt $Iin_range ];then
if [ $col_index -eq 1 ];then
sed -i "${current_line} i \\\t.ADC_current[${current_gain}].coeff = ($word)," "$output"
current_line=$current_line+1
elif [ $col_index -eq 2 ];then
sed -i "${current_line} i \\\t.ADC_current[${current_gain}].offset = ($word)," "$output"
current_line=$current_line+1
if [ $current_gain -lt 2 ];then
current_gain=$current_gain+1
else
current_gain=0
fi
fi
#get DAC Vout cali data
declare -i Vout_range=$Iin_range+$DAC_GAIN_NUMBER
elif [ $row_index -gt 1 ] && [ $row_index -lt $Vout_range ];then
if [ $col_index -eq 1 ];then
sed -i "${current_line} i \\\t.Usercode2DAC.coeff = ($word)," "$output"
current_line=$current_line+1
elif [ $col_index -eq 2 ];then
sed -i "${current_line} i \\\t.Usercode2DAC.offset = ($word)," "$output"
current_line=$current_line+1
fi
#get ADC Vin cali data
declare -i Vin_range=$Vout_range+$ADC_VOLTAGE_GAIN_NUMBER
elif [ $row_index -gt 1 ] && [ $row_index -lt $Vin_range ];then
if [ $col_index -eq 1 ];then
sed -i "${current_line} i \\\t.ADC_volt.coeff = ($word)," "$output"
current_line=$current_line+1
elif [ $col_index -eq 2 ];then
sed -i "${current_line} i \\\t.ADC_volt.offset = ($word)," "$output"
current_line=$current_line+1
fi
fi
#update index
if [ $col_index -lt 2 ];then
col_index=$col_index+1
else
col_index=0
row_index=$row_index+1
fi
done
done < $input
sed -i "${current_line} i };" "$output"
current_line=$current_line+1
sed -i "${current_line} i #endif" "$output"