Compare commits
224 Commits
main
..
elite/eis1.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 44e886e5b5 | |||
| 1df00344cb | |||
| dd7711dbcd | |||
| 56a62a7832 | |||
| 01fe904788 | |||
| c5bdf51133 | |||
| 92ba1effda | |||
| e64054876e | |||
| d64c0e3e9c | |||
| 1ef277eb20 | |||
| 86bd9a3bf5 | |||
| b6e46036fd | |||
| 3f01eb24b0 | |||
| 38114fb6d2 | |||
| eee7b9f956 | |||
| 01bf272bbc | |||
| 0904539315 | |||
| 10424c29a6 | |||
| 125f007998 | |||
| d10083ea05 | |||
| d75d3ca15c | |||
| ad275857f4 | |||
| 29ac10648a | |||
| ce4587d58a | |||
| deb08e758a | |||
| f4f5afa2ca | |||
| 54aa4e44e1 | |||
| fff2e0ebfe | |||
| 1001ce1964 | |||
| 7655469149 | |||
| c816d411d1 | |||
| 23004fd4c3 | |||
| ed414956ca | |||
| 4cc7989df9 | |||
| 0aa7312a5e | |||
| 6da3c7881a | |||
| a69dad5b4a | |||
| f2f1811eba | |||
| 5349be923d | |||
| ffb14c3bca | |||
| 19905f384a | |||
| 47046586c3 | |||
| 3dd5e2d8c4 | |||
| e4c16e003e | |||
| ed9010368f | |||
| b45c6a7fa6 | |||
| fcc1ac3020 | |||
| 7ec507fc2e | |||
| 9fdedc46d3 | |||
| 14d3f3730e | |||
| 13255847bb | |||
| 21285397fc | |||
| c9d46e2596 | |||
| 45a0fd2407 | |||
| 12448e324b | |||
| f902b3b892 | |||
| a1172a93b8 | |||
| ede480baf1 | |||
| 26f51a9427 | |||
| 570fae8f5f | |||
| f542b25e2e | |||
| a64fa32d0b | |||
| 9b3891689d | |||
| ad7cb37a20 | |||
| b1a127d6a8 | |||
| 412d18f559 | |||
| 8953b0a64c | |||
| 3cd58a0aab | |||
| e2602ef2da | |||
| 57e3f5573d | |||
| 262df2b662 | |||
| 23349cc4ba | |||
| fcf1dd5d6b | |||
| 014a2aded3 | |||
| c7ed0f9be3 | |||
| f2db9cdac8 | |||
| 98a98120a2 | |||
| 4fa47c35c9 | |||
| 70f758c3b9 | |||
| 8b367de5bb | |||
| 80c84295b3 | |||
| 9c67a4e2b7 | |||
| 14ef751386 | |||
| 927bef21bf | |||
| 8bfea5cb38 | |||
| 71272c6f8d | |||
| ebc30595e5 | |||
| 4243614dd8 | |||
| 7713cb57d3 | |||
| 245a5919ff | |||
| 3d8068fb18 | |||
| d2b88920a0 | |||
| 2c51a41cb8 | |||
| 7938d72e16 | |||
| ee3b6c8f6f | |||
| c617910ea5 | |||
| 8e414f717d | |||
| e2c255107d | |||
| acca41ac6b | |||
| a3eda0b1e0 | |||
| a63818ce44 | |||
| 584e17b3b9 | |||
| 1a2f0ba813 | |||
| a63a085ff3 | |||
| 3121aa49f2 | |||
| 7a8d7aa14f | |||
| 5b0c38159a | |||
| 7a4c7ef02c | |||
| d9a7152d73 | |||
| 166b466776 | |||
| 32a7580115 | |||
| c6aca9c17b | |||
| 2eddaf000b | |||
| 472b559293 | |||
| b0076cb246 | |||
| ed48823e10 | |||
| 8a72c5a150 | |||
| f32584d6e8 | |||
| da7d227ee4 | |||
| 01d5f76223 | |||
| 1a2e85ccad | |||
| 995b8033b6 | |||
| 6c204ad3fd | |||
| cb8590933e | |||
| e48d8c8d2f | |||
| 80929a01a8 | |||
| ca9a6bba52 | |||
| 991dfa7768 | |||
| 18954b9fbd | |||
| 65326acda2 | |||
| ca7da62fad | |||
| 18201de597 | |||
| a52486e9da | |||
| 79dc88a9d7 | |||
| fd6b005b02 | |||
| 4181dae796 | |||
| 505d5b9922 | |||
| eb8d745280 | |||
| effca2053f | |||
| 59f39871d3 | |||
| 1dcc8772b5 | |||
| cf417afd16 | |||
| 60d135cd03 | |||
| 1d1bd518f0 | |||
| 8409c0b700 | |||
| 3f034761d6 | |||
| 48a8bae1ea | |||
| 625a8c74e3 | |||
| b343d3d932 | |||
| 2aa566c0d4 | |||
| 4e56f8dfef | |||
| 853ba4008e | |||
| 843e5e98de | |||
| 6fcace98b2 | |||
| 8bbc749529 | |||
| 466df110c9 | |||
| 7d4927b77f | |||
| 640b39b4be | |||
| dcc71e2eee | |||
| 03910fce31 | |||
| 8fb81fa0b6 | |||
| 7e71e2d1a2 | |||
| 397675b555 | |||
| ffd84804d7 | |||
| e4b67e14c6 | |||
| 032efebe2a | |||
| 7b640757c8 | |||
| 7951610b95 | |||
| 128ea6900f | |||
| f3a0b38a67 | |||
| b914c1a191 | |||
| 94818213a3 | |||
| d63ecf71c5 | |||
| 06bf610897 | |||
| 58da7b6357 | |||
| 9bf87de46b | |||
| 95b5c11e95 | |||
| a30e569738 | |||
| d15afc6ab6 | |||
| cf2a19d24e | |||
| fc89183fee | |||
| 1aa26d9e1c | |||
| cac96f617f | |||
| 250a5e9d87 | |||
| 19a42da849 | |||
| c9194c804e | |||
| 1ee6b2f434 | |||
| 85c884ffb9 | |||
| ec9050a090 | |||
| ef9271239a | |||
| a299a3e1c1 | |||
| 9cf2e2301d | |||
| fb6a437db8 | |||
| 6bac8b436e | |||
| f09f3aa4a6 | |||
| d7535075fd | |||
| 7ce59c43fe | |||
| b54f79d51b | |||
| 91d71eabdc | |||
| 34861b98af | |||
| 7f8734d646 | |||
| 5922e8f2a1 | |||
| 7d93ed55bf | |||
| fe37d6a6eb | |||
| 240c869347 | |||
| 75c8a9d985 | |||
| c688ee4fda | |||
| d7c86b86a5 | |||
| 3174740201 | |||
| b33ef1b345 | |||
| 06b7317e31 | |||
| fcbbee1dbe | |||
| 6d044e1fb8 | |||
| c58e30d973 | |||
| a7fb922fa0 | |||
| 0d9e844383 | |||
| 9b8307c0e2 | |||
| 14d306e62c | |||
| 8fd201751d | |||
| be044cccb3 | |||
| 7ea34044c8 | |||
| 09eeec1593 | |||
| f3ddef1a3d | |||
| fd966a503b |
+42
-40
@@ -15,16 +15,16 @@ extern "C" {
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* | model name | hw upper board | hw lower board | product number | device name | data server lib name | UI |
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* | DEF_ELITE_EDC_1_4 | Elite1.4-re Jun.2019 | Elite1.4-re Jun. 2019 | 0, 2, 1, 5 | "Elite-EDC" | Elite_EDC_1.4 | null |
|
||||
* | DEF_ELITE_EDC_1_5 | Elite1.5 Dec. 2019 | Elite1.5 Dec. 2019 | 0, 2, 1, 6 | "Elite-EDC" | Elite_EDC_1.5 | EliteEDC |
|
||||
* | DEF_ELITE_EDC_1_5_RE | Elite1.5 Dec. 2019 | Elite1.5-re Jan. 2021 | 0, 2, 1, 7 | "Elite-EDC" | Elite_EDC_1.5re | EliteEDC |
|
||||
* | DEF_ELITE_EDC_1_5_R2 | Elite1.5 Dec. 2019 | Elite1.5-r2 May. 2022 | 0, 2, 1, 8 | "Elite-EDC" | Elite_EDC_1.5r2 | EliteEDC |
|
||||
* | DEF_ELITE_BAT_1_0 | Elite2.0 Feb. 2022 | 0, 3, 1, 0 | "Elite-BAT" | Elite_BAT_1.0 | EliteEDC |
|
||||
* | DEF_ELITE_EIS_1_0 | Elite1.5 Dec. 2019 | Elite EIS1.0 Aug. 2020 | 0, 4, 1, 0 | "Elite-EIS" | Elite_EIS_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_1_1 | Elite1.5 Dec. 2019 | Elite EIS1.1 Feb. 2022 | 0, 4, 1, 1 | "Elite-EIS" | Elite_EIS_1.1 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_MINI_1_0 | EIS MINI May. 2022 | 0, 4, 1, 2 | "Elite-EIS-MINI" | Elite_EIS_MINI_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_TRIG_0_1 | Elite TRIG01 Jan. 2021 | 0, 5, 1, 0 | "Elite-TRIG" | Elite_TRIG_0.1 | null |
|
||||
* | DEF_ELITE_MEGAFLY_0_1 | Elite1.5 Dec. 2019 | Elite Megafly Sep. 2020 | 0, 6, 1, 0 | "Elite-MEGAFLY" | Elite_MEGAFLY_0.1 | null |
|
||||
* | DEF_ELITE_EDC_14 | Elite1.4-re Jun.2019 | Elite1.4-re Jun. 2019 | 0, 2, 1, 5 | "Elite-EDC" | Elite_EDC_1.4 | null |
|
||||
* | DEF_ELITE_EDC_15 | Elite1.5 Dec. 2019 | Elite1.5 Dec. 2019 | 0, 2, 1, 6 | "Elite-EDC" | Elite_EDC_1.5 | EliteEDC |
|
||||
* | DEF_ELITE_EDC_15RE | Elite1.5 Dec. 2019 | Elite1.5-re Jan. 2021 | 0, 2, 1, 7 | "Elite-EDC" | Elite_EDC_1.5re | EliteEDC |
|
||||
* | DEF_ELITE_EDC_15R2 | Elite1.5 Dec. 2019 | Elite1.5-r2 May. 2022 | 0, 2, 1, 8 | "Elite-EDC" | Elite_EDC_1.5r2 | EliteEDC |
|
||||
* | DEF_ELITE_BAT_10 | Elite2.0 Feb. 2022 | 0, 3, 1, 0 | "Elite-BAT" | Elite_BAT_1.0 | EliteEDC |
|
||||
* | DEF_ELITE_EIS_10 | Elite1.5 Dec. 2019 | Elite EIS1.0 Aug. 2020 | 0, 4, 1, 0 | "Elite-EIS" | Elite_EIS_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_11 | Elite1.5 Dec. 2019 | Elite EIS1.1 Feb. 2022 | 0, 4, 1, 1 | "Elite-EIS" | Elite_EIS_1.1 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_MINI_10 | EIS MINI May. 2022 | 0, 4, 1, 2 | "Elite-EIS-MINI" | Elite_EIS_MINI_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_TRIG_01 | Elite TRIG01 Jan. 2021 | 0, 5, 1, 0 | "Elite-TRIG" | Elite_TRIG_0.1 | null |
|
||||
* | DEF_ELITE_MEGAFLY_01 | Elite1.5 Dec. 2019 | Elite Megafly Sep. 2020 | 0, 6, 1, 0 | "Elite-MEGAFLY" | Elite_MEGAFLY_0.1 | null |
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* ps.
|
||||
* model name is FW engineer defined
|
||||
@@ -32,40 +32,42 @@ extern "C" {
|
||||
*/
|
||||
|
||||
|
||||
#define DEF_ELITE_EDC_1_4 0
|
||||
#define DEF_ELITE_EDC_1_5 1
|
||||
#define DEF_ELITE_EDC_1_5_RE 2
|
||||
#define DEF_ELITE_EDC_1_5_R2 3
|
||||
#define DEF_ELITE_BAT_1_0 4
|
||||
#define DEF_ELITE_EIS_1_0 5
|
||||
#define DEF_ELITE_EIS_1_1 6
|
||||
#define DEF_ELITE_EIS_MINI_1_0 7
|
||||
#define DEF_ELITE_TRIG_0_1 8
|
||||
#define DEF_ELITE_MEGAFLY_0_1 9
|
||||
#define DEF_ELITE_EDC_14 0
|
||||
#define DEF_ELITE_EDC_15 1
|
||||
#define DEF_ELITE_EDC_15RE 2
|
||||
#define DEF_ELITE_EDC_15R2 3
|
||||
#define DEF_ELITE_BAT_10 4
|
||||
#define DEF_ELITE_EIS_10 5
|
||||
#define DEF_ELITE_EIS_11 6
|
||||
#define DEF_ELITE_EIS_MINI_10 7
|
||||
#define DEF_ELITE_TRIG_01 8
|
||||
#define DEF_ELITE_MEGAFLY_01 9
|
||||
#define DEF_ELITE_MAX 10
|
||||
|
||||
#define DEF_ELITE_MODEL DEF_ELITE_EDC_1_5_RE
|
||||
#define DEF_ELITE_MODEL DEF_ELITE_EIS_11
|
||||
#ifndef DEF_ELITE_MODEL
|
||||
#error "DEF_ELITE_MODEL not defined"
|
||||
#endif
|
||||
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_4)
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_14)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_RE)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15RE)
|
||||
#include "boards_config/pin_def_edc15re.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_R2)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15R2)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_0)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_10)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_1)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_11)
|
||||
#include "boards_config/pin_def_eis11.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_1_0)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_MINI_10)
|
||||
#include "boards_config/pin_config_eis_mini_10.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_10)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_0_1)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_01)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_0_1)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_01)
|
||||
#error "code no support" // need fix
|
||||
#else
|
||||
#error "no this model"
|
||||
@@ -73,61 +75,61 @@ extern "C" {
|
||||
|
||||
|
||||
// model information
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_4)
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_14)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 5
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 6
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_RE)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15RE)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 7
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_R2)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15R2)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 8
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_1_0)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_10)
|
||||
#define DEVICE_NAME "Elite-BAT"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 3
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_0)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_10)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_1)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_11)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 1
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_MINI_1_0)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_MINI_10)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 2
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_0_1)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_01)
|
||||
#define DEVICE_NAME "Elite-TRIG"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 5
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_0_1)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_01)
|
||||
#define DEVICE_NAME "Elite-MEGAFLY"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 6
|
||||
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* +------------------------------+
|
||||
* | CC2650moda |
|
||||
* +-------------+----------------+
|
||||
* | MISO | DIO1 |
|
||||
* | D0 | DIO3 |
|
||||
* | D1 | DIO4 |
|
||||
* | D2/JTAG_TDO | DIO5/JTAG_TDO |
|
||||
* | D3/JTAG_TDI | DIO6/JTAG_TDI |
|
||||
* | D4 | DIO7 |
|
||||
* | D5 | DIO8 |
|
||||
* | D6 | DIO9 |
|
||||
* | D7 | DIO10 |
|
||||
* | LOAD2 | DIO11 |
|
||||
* | LOAD1 | DIO12 |
|
||||
* | LOAD0 | DIO13 |
|
||||
* | SHUT_DOWN | DIO14 |
|
||||
* +-------------+----------------+
|
||||
*
|
||||
* +-----------------------------+
|
||||
* | Elite Pin for EIS1.1 Board |
|
||||
* +------------+----------------+
|
||||
* | AD_GPIO2 | D0 |
|
||||
* | AD_GPIO1 | D1 |
|
||||
* | AD_CLK | D2 |
|
||||
* | AD_MOSI | D3 |
|
||||
* | AD_RST | D4 |
|
||||
* | MEM_CS | D5 |
|
||||
* | 5V_ENABLE | D6 |
|
||||
* | AD_CS | D7 |
|
||||
* | AD_GPIO0 | LOAD2 |
|
||||
* | OFF | LOAD0 |<--OFF:shutdown_6994
|
||||
* | AD_MISO | MISO |
|
||||
* | SHUT_DOWN | SHUT_DOWN |<--SHUT_DOWN:switch on/off
|
||||
* +------------+----------------+
|
||||
* | LED_SCLK_A | E_PIN_AD_GPIO2 |<--jumper
|
||||
* | LED_MOSI_A | E_PIN_AD_GPIO1 |<--jumper
|
||||
* +------------+----------------+
|
||||
*/
|
||||
|
||||
/* CC2650moda */
|
||||
|
||||
/* Elite Pin for EIS1.1 Board */
|
||||
#define E_PIN_AD_GPIO2 DIO3
|
||||
#define E_PIN_AD_GPIO1 DIO4
|
||||
#define E_PIN_AD_CLK DIO5
|
||||
#define E_PIN_AD_MOSI DIO6
|
||||
#define E_PIN_AD_RST DIO7
|
||||
#define E_PIN_MEM_CS DIO8
|
||||
#define E_PIN_AD_CS DIO10
|
||||
#define E_PIN_AD_GPIO0 DIO11
|
||||
#define E_PIN_BAT DIO12
|
||||
#define E_PIN_AD_MISO DIO1
|
||||
#define E_PIN_SHUT_DOWN DIO14
|
||||
#define E_PIN_5V_ENABLE PIN_UNASSIGNED
|
||||
|
||||
#define E_PIN_LED_SCLK_A DIO2
|
||||
#define E_PIN_LED_MOSI_A DIO0
|
||||
|
||||
/* SPI Board */
|
||||
#define Board_SPI0_MISO PIN_UNASSIGNED
|
||||
#define Board_SPI0_MOSI E_PIN_LED_MOSI_A
|
||||
#define Board_SPI0_CLK E_PIN_LED_SCLK_A
|
||||
#define Board_SPI0_CS PIN_UNASSIGNED
|
||||
|
||||
#define Board_SPI1_MISO E_PIN_AD_MISO
|
||||
#define Board_SPI1_MOSI E_PIN_AD_MOSI
|
||||
#define Board_SPI1_CLK E_PIN_AD_CLK
|
||||
#define Board_SPI1_CS PIN_UNASSIGNED
|
||||
|
||||
/* I2C */
|
||||
#define Board_I2C0_SCL0 PIN_UNASSIGNED
|
||||
#define Board_I2C0_SDA0 PIN_UNASSIGNED
|
||||
|
||||
// delete in the future
|
||||
#define Turnon_I_LARGE PIN_UNASSIGNED
|
||||
#define Turnon_I_MID PIN_UNASSIGNED
|
||||
#define Turnon_I_SMALL PIN_UNASSIGNED
|
||||
#define Turnon_V_MID PIN_UNASSIGNED
|
||||
#define Turnon_V_SMALL PIN_UNASSIGNED
|
||||
#define Turon_VOUT_SMALL PIN_UNASSIGNED
|
||||
-63
@@ -1,63 +0,0 @@
|
||||
#ifndef PIN_DEF_EDC15RE_H
|
||||
#define PIN_DEF_EDC15RE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* +------------------------------+
|
||||
* | CC2650moda |
|
||||
* +-------------+----------------+
|
||||
* | MISO | DIO1 |
|
||||
* | D0 | DIO3 |
|
||||
* | D1 | DIO4 |
|
||||
* | D2/JTAG_TDO | DIO5/JTAG_TDO |
|
||||
* | D3/JTAG_TDI | DIO6/JTAG_TDI |
|
||||
* | D4 | DIO7 |
|
||||
* | D5 | DIO8 |
|
||||
* | D6 | DIO9 |
|
||||
* | D7 | DIO10 |
|
||||
* | LOAD2 | DIO11 |
|
||||
* | LOAD1 | DIO12 |
|
||||
* | LOAD0 | DIO13 |
|
||||
* | SHUT_DOWN | DIO14 |
|
||||
* +-------------+----------------+
|
||||
*/
|
||||
|
||||
|
||||
/* CC2650moda */
|
||||
#define E_PIN_MISO DIO1
|
||||
#define E_PIN_D0 DIO3
|
||||
#define E_PIN_D1 DIO4
|
||||
#define E_PIN_D2 DIO5
|
||||
#define E_PIN_D3 DIO6
|
||||
#define E_PIN_D4 DIO7
|
||||
#define E_PIN_D5 DIO8
|
||||
#define E_PIN_D6 DIO9
|
||||
#define E_PIN_D7 DIO10
|
||||
|
||||
#define E_PIN_LOAD2 DIO11
|
||||
#define E_PIN_LOAD1 DIO12
|
||||
#define E_PIN_LOAD0 DIO13
|
||||
#define E_PIN_SHUT_DOWN DIO14 // to sense switch
|
||||
|
||||
/* SPI Board */
|
||||
#define Board_SPI0_MISO PIN_UNASSIGNED
|
||||
#define Board_SPI0_MOSI E_PIN_D1
|
||||
#define Board_SPI0_CLK E_PIN_D0
|
||||
#define Board_SPI0_CS PIN_UNASSIGNED
|
||||
|
||||
#define Board_SPI1_MISO E_PIN_MISO
|
||||
#define Board_SPI1_MOSI E_PIN_D3
|
||||
#define Board_SPI1_CLK E_PIN_D2
|
||||
#define Board_SPI1_CS PIN_UNASSIGNED
|
||||
|
||||
/* I2C */
|
||||
#define Board_I2C0_SCL0 PIN_UNASSIGNED
|
||||
#define Board_I2C0_SDA0 PIN_UNASSIGNED
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // PIN_DEF_EDC15RE_H
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
#ifndef PIN_DEF_EIS11_H
|
||||
#define PIN_DEF_EIS11_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* +------------------------------+
|
||||
* | CC2650moda |
|
||||
* +-------------+----------------+
|
||||
* | MISO | DIO1 |
|
||||
* | D0 | DIO3 |
|
||||
* | D1 | DIO4 |
|
||||
* | D2/JTAG_TDO | DIO5/JTAG_TDO |
|
||||
* | D3/JTAG_TDI | DIO6/JTAG_TDI |
|
||||
* | D4 | DIO7 |
|
||||
* | D5 | DIO8 |
|
||||
* | D6 | DIO9 |
|
||||
* | D7 | DIO10 |
|
||||
* | LOAD2 | DIO11 |
|
||||
* | LOAD1 | DIO12 |
|
||||
* | LOAD0 | DIO13 |
|
||||
* | SHUT_DOWN | DIO14 |
|
||||
* +-------------+----------------+
|
||||
*
|
||||
* +------------------------------------+
|
||||
* | Elite Pin for ELITE_EIS_1_1 Board |
|
||||
* +------------+-----------------------+
|
||||
* | AD_GPIO2 | D0 |
|
||||
* | AD_GPIO1 | D1 |
|
||||
* | AD_CLK | D2 |
|
||||
* | AD_MOSI | D3 |
|
||||
* | AD_RST | D4 |
|
||||
* | MEM_CS | D5 |
|
||||
* | 5V_ENABLE | D6 |
|
||||
* | AD_CS | D7 |
|
||||
* | AD_GPIO0 | LOAD2 |
|
||||
* | OFF | LOAD0 |<--OFF: shutdown_6994
|
||||
* | AD_MISO | MISO |
|
||||
* | SHUT_DOWN | SHUT_DOWN |<--SHUT_DOWN: switch on/off
|
||||
* +------------+-----------------------+
|
||||
* | LED_SCLK_A | AD_GPIO2 |<--jumper
|
||||
* | LED_MOSI_A | AD_GPIO1 |<--jumper
|
||||
* +------------+-----------------------+
|
||||
*/
|
||||
|
||||
/* CC2650moda */
|
||||
#define MISO DIO1
|
||||
#define D0 DIO3
|
||||
#define D1 DIO4
|
||||
#define D2 DIO5
|
||||
#define D3 DIO6
|
||||
#define D4 DIO7
|
||||
#define D5 DIO8
|
||||
#define D6 DIO9
|
||||
#define D7 DIO10
|
||||
#define LOAD2 DIO11
|
||||
#define LOAD1 DIO12
|
||||
#define LOAD0 DIO13
|
||||
#define SHUT_DOWN DIO14
|
||||
|
||||
/* Elite Pin for ELITE_EIS_1_1 Board */
|
||||
#define E_PIN_AD_GPIO2 D0
|
||||
#define E_PIN_AD_GPIO1 D1
|
||||
#define E_PIN_AD_CLK D2
|
||||
#define E_PIN_AD_MOSI D3
|
||||
#define E_PIN_AD_RST D4 //eis1.1-> use D4; eis1.0-> use LOAD0
|
||||
#define E_PIN_MEM_CS D5
|
||||
#define E_PIN_5V_ENABLE D6
|
||||
#define E_PIN_AD_CS D7
|
||||
#define E_PIN_AD_GPIO0 LOAD2
|
||||
#define E_PIN_OFF LOAD0
|
||||
#define E_PIN_AD_MISO MISO
|
||||
#define E_PIN_SHUT_DOWN SHUT_DOWN
|
||||
|
||||
#define E_PIN_LED_SCLK_A E_PIN_AD_GPIO2
|
||||
#define E_PIN_LED_MOSI_A E_PIN_AD_GPIO1
|
||||
|
||||
/* SPI Board */
|
||||
#define Board_SPI0_MISO PIN_UNASSIGNED
|
||||
#define Board_SPI0_MOSI E_PIN_LED_MOSI_A
|
||||
#define Board_SPI0_CLK E_PIN_LED_SCLK_A
|
||||
#define Board_SPI0_CS PIN_UNASSIGNED
|
||||
|
||||
#define Board_SPI1_MISO E_PIN_AD_MISO
|
||||
#define Board_SPI1_MOSI E_PIN_AD_MOSI
|
||||
#define Board_SPI1_CLK E_PIN_AD_CLK
|
||||
#define Board_SPI1_CS PIN_UNASSIGNED
|
||||
|
||||
/* I2C */
|
||||
#define Board_I2C0_SCL0 PIN_UNASSIGNED
|
||||
#define Board_I2C0_SDA0 PIN_UNASSIGNED
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // PIN_DEF_EIS11_H
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
#ifndef GPIO_EDC15RE_H
|
||||
#define GPIO_EDC15RE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint8_t gpio_create(void);
|
||||
uint8_t add_pin_d0_d3(void);
|
||||
uint8_t remove_pin_d0_d3(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // GPIO_EDC15RE_H
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
#include <Board.h>
|
||||
#include <ti/drivers/pin/PINCC26XX.h>
|
||||
#include "driver/gpio_edc15re.h"
|
||||
|
||||
static PIN_Handle PinHandle;
|
||||
static PIN_State PinStatus;
|
||||
|
||||
const PIN_Config BLE_IO[] = {
|
||||
E_PIN_D0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_D1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_D2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_D3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_D4 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_D5 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_D6 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_D7 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_LOAD0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_LOAD1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
E_PIN_LOAD2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
|
||||
E_PIN_SHUT_DOWN | PIN_INPUT_EN | PIN_PULLDOWN,
|
||||
|
||||
PIN_TERMINATE
|
||||
};
|
||||
|
||||
static PIN_Handle __get_gpio_handle(void)
|
||||
{
|
||||
return PinHandle;
|
||||
}
|
||||
|
||||
static void __set_gpio_handle(PIN_Handle handle)
|
||||
{
|
||||
PinHandle = handle;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t gpio_create(void)
|
||||
{
|
||||
PIN_Handle h;
|
||||
|
||||
h = PIN_open(&PinStatus, BLE_IO);
|
||||
__set_gpio_handle(h);
|
||||
|
||||
if (h == NULL)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t add_pin_d0_d3(void)
|
||||
{
|
||||
PIN_Handle h = __get_gpio_handle();
|
||||
|
||||
PIN_add(h, E_PIN_D0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(h, E_PIN_D1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(h, E_PIN_D2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(h, E_PIN_D3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t remove_pin_d0_d3(void)
|
||||
{
|
||||
PIN_Handle h = __get_gpio_handle();
|
||||
|
||||
PIN_remove(h, E_PIN_D0);
|
||||
PIN_remove(h, E_PIN_D1);
|
||||
PIN_remove(h, E_PIN_D2);
|
||||
PIN_remove(h, E_PIN_D3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t pin_set(uint8_t pin, uint8_t set_value)
|
||||
{
|
||||
/*
|
||||
* if status = 0: success
|
||||
* else: fail
|
||||
*/
|
||||
uint8_t p = pin;
|
||||
uint8_t v = set_value;
|
||||
PIN_Status status;
|
||||
PIN_Handle h = __get_gpio_handle();
|
||||
|
||||
status = PIN_setOutputValue(h, p, v);
|
||||
|
||||
return (uint8_t)status;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#ifndef GPIO_EIS11_H
|
||||
#define GPIO_EIS11_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint8_t gpio_create(void);
|
||||
int8_t pin_set(uint8_t pin, uint8_t set_value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // GPIO_EIS11_H
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#include "board.h"
|
||||
#include <ti/drivers/pin/PINCC26XX.h>
|
||||
#include "driver/gpio_eis11.h"
|
||||
|
||||
static PIN_Handle PinHandle;
|
||||
static PIN_State PinStatus;
|
||||
|
||||
const PIN_Config BLE_IO[] = {
|
||||
E_PIN_5V_ENABLE | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
|
||||
E_PIN_AD_RST | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
|
||||
E_PIN_AD_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
|
||||
E_PIN_OFF | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, // E_PIN_OFF = 1: turn off 6994
|
||||
E_PIN_SHUT_DOWN | PIN_INPUT_EN | PIN_PULLDOWN,
|
||||
|
||||
PIN_TERMINATE
|
||||
};
|
||||
|
||||
static PIN_Handle __get_gpio_handle(void)
|
||||
{
|
||||
return PinHandle;
|
||||
}
|
||||
|
||||
static void __set_gpio_handle(PIN_Handle handle)
|
||||
{
|
||||
PinHandle = handle;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int8_t pin_set(uint8_t pin, uint8_t set_value)
|
||||
{
|
||||
/*
|
||||
* if status = 0: success
|
||||
* else: fail
|
||||
*/
|
||||
uint8_t p = pin;
|
||||
uint8_t v = set_value;
|
||||
PIN_Status status;
|
||||
|
||||
PIN_Handle handle = __get_gpio_handle();
|
||||
status = PIN_setOutputValue(handle, p, v);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
uint8_t gpio_create(void)
|
||||
{
|
||||
PIN_Handle h;
|
||||
|
||||
h = PIN_open(&PinStatus, BLE_IO);
|
||||
__set_gpio_handle(h);
|
||||
|
||||
if (h == NULL)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#ifndef GPIO_EIS_MINI10_H
|
||||
#define GPIO_EIS_MINI10_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint8_t gpio_create(void);
|
||||
int8_t pin_set(uint8_t pin, uint8_t set_value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // GPIO_EIS_MINI10_H
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#include "board.h"
|
||||
#include <ti/drivers/pin/PINCC26XX.h>
|
||||
#include "driver/gpio_eis_mini10.h"
|
||||
|
||||
static PIN_Handle PinHandle;
|
||||
static PIN_State PinStatus;
|
||||
|
||||
const PIN_Config BLE_IO[] = {
|
||||
E_PIN_5V_ENABLE | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
|
||||
E_PIN_AD_RST | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
|
||||
E_PIN_AD_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
|
||||
E_PIN_SHUT_DOWN | PIN_INPUT_EN | PIN_PULLDOWN,
|
||||
|
||||
PIN_TERMINATE
|
||||
};
|
||||
|
||||
static PIN_Handle __get_gpio_handle(void)
|
||||
{
|
||||
return PinHandle;
|
||||
}
|
||||
|
||||
static void __set_gpio_handle(PIN_Handle handle)
|
||||
{
|
||||
PinHandle = handle;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int8_t pin_set(uint8_t pin, uint8_t set_value)
|
||||
{
|
||||
/*
|
||||
* if status = 0: success
|
||||
* else: fail
|
||||
*/
|
||||
uint8_t p = pin;
|
||||
uint8_t v = set_value;
|
||||
PIN_Status status;
|
||||
|
||||
PIN_Handle handle = __get_gpio_handle();
|
||||
status = PIN_setOutputValue(handle, p, v);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
uint8_t gpio_create(void)
|
||||
{
|
||||
PIN_Handle h;
|
||||
|
||||
h = PIN_open(&PinStatus, BLE_IO);
|
||||
__set_gpio_handle(h);
|
||||
|
||||
if (h == NULL)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
#include <Board.h>
|
||||
#include "board.h"
|
||||
#include <ti/drivers/SPI.h>
|
||||
#include "driver/spi_ctrl.h"
|
||||
|
||||
@@ -138,7 +138,7 @@ uint8_t spi1_open(uint32_t bitRate, uint8_t polarity, uint8_t phase)
|
||||
|
||||
if (h != NULL)
|
||||
return 3;
|
||||
|
||||
|
||||
SPI_Params_init(para);
|
||||
para->bitRate = rate;
|
||||
para->mode = SPI_MASTER;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#include <Board.h>
|
||||
#include "board.h"
|
||||
#include <ti/drivers/timer/GPTimerCC26XX.h>
|
||||
#include <xdc/runtime/Types.h>
|
||||
#include <ti/sysbios/BIOS.h>
|
||||
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
#ifndef ELITE_LATCH_H
|
||||
#define ELITE_LATCH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LOAD0 0
|
||||
#define LOAD1 1
|
||||
#define LOAD2 2
|
||||
#define LOAD_MAX 3
|
||||
|
||||
#define D0 0
|
||||
#define D1 1
|
||||
#define D2 2
|
||||
#define D3 3
|
||||
#define D4 4
|
||||
#define D5 5
|
||||
#define D6 6
|
||||
#define D7 7
|
||||
#define D_MAX 8
|
||||
|
||||
// latch 1 control
|
||||
// #define E_LATCH_LED_SCLK_A LOAD0, D0 // not gpio
|
||||
// #define E_LATCH_LED_MOSI_A LOAD0, D1 // not gpio
|
||||
// #define E_LATCH_SCLK LOAD0, D2 // not gpio
|
||||
// #define E_LATCH_MOSI LOAD0, D3 // not gpio
|
||||
#define E_LATCH_HIGH_Z LOAD0, D4
|
||||
#define E_LATCH_CS_MEM LOAD0, D5
|
||||
#define E_LATCH_CS_ADC LOAD0, D6
|
||||
#define E_LATCH_CS_DAC LOAD0, D7
|
||||
|
||||
// latch 2 control
|
||||
#define E_LATCH_MEM_HOLD LOAD1, D0
|
||||
#define E_LATCH_10V_ENABLE LOAD1, D5
|
||||
#define E_LATCH_5V_ENABLE LOAD1, D6
|
||||
|
||||
// latch 3 control
|
||||
#define E_LATCH_I_MID_ON LOAD2, D0
|
||||
#define E_LATCH_I_LARGE_ON LOAD2, D1
|
||||
#define E_LATCH_V_SMALL_ON LOAD2, D2
|
||||
#define E_LATCH_V_MID_ON LOAD2, D3
|
||||
#define E_LATCH_I_SMALL_ON LOAD2, D4
|
||||
#define E_LATCH_OFF LOAD2, D6
|
||||
#define E_LATCH_VOUT_SMALL_ON LOAD2, D7
|
||||
|
||||
uint8_t update_latch_stat(uint8_t latch, uint8_t dio, uint8_t value);
|
||||
uint8_t latch_single_ctrl(uint8_t latch, uint8_t dio, uint8_t value);
|
||||
uint8_t latch_multi_ctrl(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // ELITE_LATCH_H
|
||||
-352
@@ -1,352 +0,0 @@
|
||||
#include "elite_task/elite_latch.h"
|
||||
#include "driver/gpio_edc15re.h"
|
||||
#include "driver/spi_ctrl.h"
|
||||
|
||||
enum pin_ctrl_e {
|
||||
PC_LOAD0_CLR = 0,
|
||||
PC_LOAD0_SET,
|
||||
PC_LOAD1_CLR,
|
||||
PC_LOAD1_SET,
|
||||
PC_LOAD2_CLR,
|
||||
PC_LOAD2_SET,
|
||||
PC_D0_CLR,
|
||||
PC_D0_SET,
|
||||
PC_D1_CLR,
|
||||
PC_D1_SET,
|
||||
PC_D2_CLR,
|
||||
PC_D2_SET,
|
||||
PC_D3_CLR,
|
||||
PC_D3_SET,
|
||||
PC_D4_CLR,
|
||||
PC_D4_SET,
|
||||
PC_D5_CLR,
|
||||
PC_D5_SET,
|
||||
PC_D6_CLR,
|
||||
PC_D6_SET,
|
||||
PC_D7_CLR,
|
||||
PC_D7_SET,
|
||||
PC_MAX,
|
||||
};
|
||||
|
||||
//d0.d1.d2.d3.d4.d5.d6.d7
|
||||
struct latch_t {
|
||||
uint8_t d7: 1,
|
||||
d6: 1,
|
||||
d5: 1,
|
||||
d4: 1,
|
||||
d3: 1,
|
||||
d2: 1,
|
||||
d1: 1,
|
||||
d0: 1;
|
||||
};
|
||||
|
||||
static struct latch_t LH0 = {0};
|
||||
static struct latch_t LH1 = {0};
|
||||
static struct latch_t LH2 = {0};
|
||||
|
||||
static uint8_t __pin_ctrl(uint8_t pin_control)
|
||||
{
|
||||
uint8_t pc = pin_control;
|
||||
int8_t st;
|
||||
|
||||
if (pc >= PC_MAX)
|
||||
return 1;
|
||||
|
||||
switch (pc) {
|
||||
case PC_LOAD0_CLR:
|
||||
st = pin_set(E_PIN_LOAD0, 0);
|
||||
break;
|
||||
|
||||
case PC_LOAD0_SET:
|
||||
st = pin_set(E_PIN_LOAD0, 1);
|
||||
break;
|
||||
|
||||
case PC_LOAD1_CLR:
|
||||
st = pin_set(E_PIN_LOAD1, 0);
|
||||
break;
|
||||
|
||||
case PC_LOAD1_SET:
|
||||
st = pin_set(E_PIN_LOAD1, 1);
|
||||
break;
|
||||
|
||||
case PC_LOAD2_CLR:
|
||||
st = pin_set(E_PIN_LOAD2, 0);
|
||||
break;
|
||||
|
||||
case PC_LOAD2_SET:
|
||||
st = pin_set(E_PIN_LOAD2, 1);
|
||||
break;
|
||||
|
||||
case PC_D0_CLR:
|
||||
st = pin_set(E_PIN_D0, 0);
|
||||
break;
|
||||
|
||||
case PC_D0_SET:
|
||||
st = pin_set(E_PIN_D0, 1);
|
||||
break;
|
||||
|
||||
case PC_D1_CLR:
|
||||
st = pin_set(E_PIN_D1, 0);
|
||||
break;
|
||||
|
||||
case PC_D1_SET:
|
||||
st = pin_set(E_PIN_D1, 1);
|
||||
break;
|
||||
|
||||
case PC_D2_CLR:
|
||||
st = pin_set(E_PIN_D2, 0);
|
||||
break;
|
||||
|
||||
case PC_D2_SET:
|
||||
st = pin_set(E_PIN_D2, 1);
|
||||
break;
|
||||
|
||||
case PC_D3_CLR:
|
||||
st = pin_set(E_PIN_D3, 0);
|
||||
break;
|
||||
|
||||
case PC_D3_SET:
|
||||
st = pin_set(E_PIN_D3, 1);
|
||||
break;
|
||||
|
||||
case PC_D4_CLR:
|
||||
st = pin_set(E_PIN_D4, 0);
|
||||
break;
|
||||
|
||||
case PC_D4_SET:
|
||||
st = pin_set(E_PIN_D4, 1);
|
||||
break;
|
||||
|
||||
case PC_D5_CLR:
|
||||
st = pin_set(E_PIN_D5, 0);
|
||||
break;
|
||||
|
||||
case PC_D5_SET:
|
||||
st = pin_set(E_PIN_D5, 1);
|
||||
break;
|
||||
|
||||
case PC_D6_CLR:
|
||||
st = pin_set(E_PIN_D6, 0);
|
||||
break;
|
||||
|
||||
case PC_D6_SET:
|
||||
st = pin_set(E_PIN_D6, 1);
|
||||
break;
|
||||
|
||||
case PC_D7_CLR:
|
||||
st = pin_set(E_PIN_D7, 0);
|
||||
break;
|
||||
|
||||
case PC_D7_SET:
|
||||
st = pin_set(E_PIN_D7, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (st)
|
||||
return 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct latch_t *__get_lh_stat(uint8_t latch)
|
||||
{
|
||||
uint8_t lh = latch;
|
||||
|
||||
if (lh == LOAD0)
|
||||
return &LH0;
|
||||
|
||||
if (lh == LOAD1)
|
||||
return &LH1;
|
||||
|
||||
if (lh == LOAD2)
|
||||
return &LH2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __latch0_set(void)
|
||||
{
|
||||
struct latch_t *lh_p = __get_lh_stat(LOAD0);
|
||||
|
||||
pin_set(E_PIN_D4, lh_p->d4);
|
||||
pin_set(E_PIN_D5, lh_p->d5);
|
||||
pin_set(E_PIN_D6, lh_p->d6);
|
||||
pin_set(E_PIN_D7, lh_p->d7);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __latch1_set(void)
|
||||
{
|
||||
struct latch_t *lh_p = __get_lh_stat(LOAD1);
|
||||
|
||||
pin_set(E_PIN_D0, lh_p->d0);
|
||||
pin_set(E_PIN_D5, lh_p->d5);
|
||||
pin_set(E_PIN_D6, lh_p->d6);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __latch2_set(void)
|
||||
{
|
||||
struct latch_t *lh_p = __get_lh_stat(LOAD2);
|
||||
|
||||
pin_set(E_PIN_D0, lh_p->d0);
|
||||
pin_set(E_PIN_D1, lh_p->d1);
|
||||
pin_set(E_PIN_D2, lh_p->d2);
|
||||
pin_set(E_PIN_D3, lh_p->d3);
|
||||
pin_set(E_PIN_D4, lh_p->d4);
|
||||
pin_set(E_PIN_D6, lh_p->d6);
|
||||
pin_set(E_PIN_D7, lh_p->d7);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static uint8_t __latch0_as_gpio(void)
|
||||
{
|
||||
__pin_ctrl(PC_LOAD0_CLR);
|
||||
|
||||
spi0_close();
|
||||
spi1_close();
|
||||
|
||||
add_pin_d0_d3();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t __latch0_as_spi(void)
|
||||
{
|
||||
remove_pin_d0_d3();
|
||||
|
||||
Board_initSPI();
|
||||
spi0_open(SPI_CLK_1M, POL0, PHA1); //SPI 1M: LED
|
||||
spi1_open(SPI_CLK_4M, POL0, PHA1); //SPI 4M: ADC、DAC
|
||||
|
||||
__latch0_set();
|
||||
__pin_ctrl(PC_LOAD0_SET);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t update_latch_stat(uint8_t latch, uint8_t dio, uint8_t value)
|
||||
{
|
||||
uint8_t lh = latch;
|
||||
uint8_t d = dio;
|
||||
uint8_t val = value;
|
||||
struct latch_t *lh_p;
|
||||
|
||||
if (lh >= LOAD_MAX)
|
||||
return 1;
|
||||
|
||||
if (d >= D_MAX)
|
||||
return 2;
|
||||
|
||||
if (val != 1 && value != 0)
|
||||
return 3;
|
||||
|
||||
lh_p = __get_lh_stat(lh);
|
||||
|
||||
switch (d) {
|
||||
case D0:
|
||||
lh_p->d0 = val;
|
||||
break;
|
||||
|
||||
case D1:
|
||||
lh_p->d1 = val;
|
||||
break;
|
||||
|
||||
case D2:
|
||||
lh_p->d2 = val;
|
||||
break;
|
||||
|
||||
case D3:
|
||||
lh_p->d3 = val;
|
||||
break;
|
||||
|
||||
case D4:
|
||||
lh_p->d4 = val;
|
||||
break;
|
||||
|
||||
case D5:
|
||||
lh_p->d5 = val;
|
||||
break;
|
||||
|
||||
case D6:
|
||||
lh_p->d6 = val;
|
||||
break;
|
||||
|
||||
case D7:
|
||||
lh_p->d7 = val;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t latch_single_ctrl(uint8_t latch, uint8_t dio, uint8_t value)
|
||||
{
|
||||
// control one latch pin -> update_latch_stat -> what latch to update? -> latch?_ctrl
|
||||
uint8_t lh = latch;
|
||||
uint8_t d = dio;
|
||||
uint8_t val = value;
|
||||
|
||||
if (lh >= LOAD_MAX)
|
||||
return 1;
|
||||
|
||||
if (d >= D_MAX)
|
||||
return 2;
|
||||
|
||||
if (val != 1 && value != 0)
|
||||
return 3;
|
||||
|
||||
update_latch_stat(lh, d, val);
|
||||
|
||||
switch (lh) {
|
||||
case LOAD0:
|
||||
__latch0_set();
|
||||
break;
|
||||
|
||||
case LOAD1:
|
||||
__latch0_as_gpio();
|
||||
|
||||
__latch1_set();
|
||||
__pin_ctrl(PC_LOAD1_SET);
|
||||
__pin_ctrl(PC_LOAD1_CLR);
|
||||
|
||||
__latch0_as_spi();
|
||||
break;
|
||||
|
||||
case LOAD2:
|
||||
__latch0_as_gpio();
|
||||
|
||||
__latch2_set();
|
||||
__pin_ctrl(PC_LOAD2_SET);
|
||||
__pin_ctrl(PC_LOAD2_CLR);
|
||||
|
||||
__latch0_as_spi();
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t latch_multi_ctrl(void)
|
||||
{
|
||||
// control many latch pin -> update_latch_stat -> update_latch_stat -> ... -> latch_ctrl 0.1.2
|
||||
__latch0_set();
|
||||
__pin_ctrl(PC_LOAD0_SET);
|
||||
|
||||
__latch0_as_gpio();
|
||||
|
||||
__latch1_set();
|
||||
__pin_ctrl(PC_LOAD1_SET);
|
||||
__pin_ctrl(PC_LOAD1_CLR);
|
||||
|
||||
__latch2_set();
|
||||
__pin_ctrl(PC_LOAD2_SET);
|
||||
__pin_ctrl(PC_LOAD2_CLR);
|
||||
|
||||
__latch0_as_spi();
|
||||
|
||||
return 0;
|
||||
}
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
#ifndef DAC_MAX5136_H
|
||||
#define DAC_MAX5136_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "driver/spi_ctrl.h"
|
||||
|
||||
#define CTRL_B_LDAC 0x01
|
||||
#define CTRL_B_CLR 0x02
|
||||
#define CTRL_B_POW_CTRL 0x03
|
||||
#define CTRL_B_LINEARITY 0x05
|
||||
#define CTRL_B_WRT(_d0, _d1) (0x10 | ((_d1) << 1) | (_d0))
|
||||
#define CTRL_B_WRT_THR(_d0, _d1) (0x30 | ((_d1) << 1) | (_d0))
|
||||
|
||||
#define DATA_B_LDAC(_d0, _d1) ((_d1) << 9 | (_d0) << 8)
|
||||
#define DATA_B_POW_CT(_d0, _d1, _rd) ((_d1) << 9 | (_d0) << 8 | (_rd) << 7)
|
||||
#define DATA_B_LINE(_en) ((_en) << 9)
|
||||
|
||||
#define DAC0_EN 1
|
||||
#define DAC0_DIS 0
|
||||
#define DAC1_EN 1
|
||||
#define DAC1_DIS 0
|
||||
|
||||
#define DAC0_W_T(_v) dac_write_through_mode(DAC0_EN, DAC1_DIS, _v);
|
||||
#define DAC0_W(_v) dac_write_mode(DAC0_EN, DAC1_DIS, _v);
|
||||
#define DAC0_P_C(_rdy) dac_power_control_mode(DAC0_EN, DAC1_DIS, _rdy);
|
||||
#define DAC0_LDAC() dac_ldac_mode(DAC0_EN, DAC1_DIS);
|
||||
|
||||
|
||||
int dac_ldac_mode(uint8_t dac0_enable, uint8_t dac1_enable);
|
||||
int dac_clear_mode();
|
||||
int dac_power_control_mode(uint8_t dac0_enable, uint8_t dac1_enable, uint8_t ready_enable);
|
||||
int dac_linearity_mode(uint8_t linear_enable);
|
||||
int dac_write_mode(uint8_t dac0_enable, uint8_t dac1_enable, uint16_t volts);
|
||||
int dac_write_through_mode(uint8_t dac0_enable, uint8_t dac1_enable, uint16_t volts);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //DAC_MAX5136_H
|
||||
-110
@@ -1,110 +0,0 @@
|
||||
#include "hardware/dac_MAX5136.h"
|
||||
|
||||
struct dac_series_data_t {
|
||||
uint8_t control_bits;
|
||||
uint16_t data_bits;
|
||||
}__attribute__((packed));
|
||||
|
||||
static struct dac_series_data_t dac_series_data_g = {0};
|
||||
|
||||
|
||||
static int __dac_transfer(struct dac_series_data_t *sd)
|
||||
{
|
||||
latch_single_ctrl(E_LATCH_CS_DAC, 0);
|
||||
|
||||
#define WRITE_TO_DAC(_d, _l) spi1_write(NULL, (uint8_t *)(_d), (_l))
|
||||
WRITE_TO_DAC(sd, sizeof(struct dac_series_data_t));
|
||||
|
||||
latch_single_ctrl(E_LATCH_CS_DAC, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dac_ldac_mode(uint8_t dac0_enable, uint8_t dac1_enable)
|
||||
{
|
||||
uint8_t d0 = dac0_enable;
|
||||
uint8_t d1 = dac1_enable;
|
||||
|
||||
struct dac_series_data_t *sd = &dac_series_data_g;
|
||||
sd->control_bits = CTRL_B_LDAC;
|
||||
sd->data_bits = REVERT_2_BYTE(DATA_B_LDAC(d0, d1));
|
||||
__dac_transfer(sd);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int dac_clear_mode()
|
||||
{
|
||||
struct dac_series_data_t *sd = &dac_series_data_g;
|
||||
sd->control_bits = CTRL_B_CLR;
|
||||
__dac_transfer(sd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int dac_power_control_mode(uint8_t dac0_enable, uint8_t dac1_enable, uint8_t ready_enable)
|
||||
{
|
||||
uint8_t d0 = dac0_enable;
|
||||
uint8_t d1 = dac1_enable;
|
||||
uint8_t rdy_en = ready_enable;
|
||||
struct dac_series_data_t *sd = &dac_series_data_g;
|
||||
|
||||
sd->control_bits = CTRL_B_POW_CTRL;
|
||||
sd->data_bits = REVERT_2_BYTE(DATA_B_POW_CT(d0, d1, rdy_en));
|
||||
|
||||
__dac_transfer(sd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int dac_linearity_mode(uint8_t linear_enable)
|
||||
{
|
||||
uint8_t lin_en = linear_enable;
|
||||
struct dac_series_data_t *sd = &dac_series_data_g;
|
||||
|
||||
sd->control_bits = CTRL_B_LINEARITY;
|
||||
sd->data_bits = REVERT_2_BYTE(DATA_B_LINE(lin_en));
|
||||
__dac_transfer(sd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int dac_write_mode(uint8_t dac0_enable, uint8_t dac1_enable, uint16_t volts)
|
||||
{
|
||||
uint8_t d0 = dac0_enable;
|
||||
uint8_t d1 = dac1_enable;
|
||||
uint16_t v = volts;
|
||||
struct dac_series_data_t *sd = &dac_series_data_g;
|
||||
|
||||
sd->control_bits = CTRL_B_WRT(d0, d1);
|
||||
sd->data_bits = REVERT_2_BYTE(v);
|
||||
__dac_transfer(sd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int dac_write_through_mode(uint8_t dac0_enable, uint8_t dac1_enable, uint16_t volts)
|
||||
{
|
||||
uint8_t d0 = dac0_enable;
|
||||
uint8_t d1 = dac1_enable;
|
||||
uint16_t v = volts;
|
||||
struct dac_series_data_t *sd = &dac_series_data_g;
|
||||
|
||||
sd->control_bits = CTRL_B_WRT_THR(d0, d1);
|
||||
sd->data_bits = REVERT_2_BYTE(v);
|
||||
__dac_transfer(sd);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
#ifndef DAC_ADS1118_H
|
||||
#define DAC_ADS1118_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "driver/spi_ctrl.h"
|
||||
|
||||
#define ADC_CH_CURR AIN0_GND
|
||||
#define ADC_CH_VIN AIN1_GND
|
||||
#define ADC_CH_VOUT AIN2_GND
|
||||
#define ADC_CH_BAT AIN3_GND
|
||||
|
||||
#define MEASURE_CURRENT() read_adc_data(ADC_CH_CURR, FSR3)
|
||||
#define MEASURE_VOLT() read_adc_data(ADC_CH_VIN, FSR3)
|
||||
#define MEASURE_DAC() read_adc_data(ADC_CH_VOUT, FSR3)
|
||||
#define MEASURE_BATTERY() read_adc_data(ADC_CH_BAT, FSR1)
|
||||
|
||||
|
||||
enum input_mux_e {
|
||||
AIN0_AIN1 = 0x00,
|
||||
AIN0_AIN3 = 0x01,
|
||||
AIN1_AIN3 = 0x02,
|
||||
AIN2_AIN3 = 0x03,
|
||||
AIN0_GND = 0x04,
|
||||
AIN1_GND = 0x05,
|
||||
AIN2_GND = 0x06,
|
||||
AIN3_GND = 0x07,
|
||||
};
|
||||
|
||||
/*
|
||||
* [Progrmmable gain amplifier configuration]
|
||||
*
|
||||
* The corresponing relationship of FSRx to volt will be the form:
|
||||
* FSRx <-> 0xXX <-> +- xV
|
||||
*
|
||||
* FSR1 <-> 0x00 <-> +-6.144V
|
||||
* FSR2 <-> 0x01 <-> +-4.096V
|
||||
* FSR3 <-> 0x02 <-> +-2.408V
|
||||
* FSR4 <-> 0x03 <-> +-1.024V
|
||||
* FSR5 <-> 0x04 <-> +-0.512V
|
||||
* FSR6 <-> 0x05 <-> +-0.256V
|
||||
* FSR7 <-> 0x06 <-> +-0.256V
|
||||
* FSR8 <-> 0x07 <-> +-0.256V
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
enum gain_amplifier_e {
|
||||
FSR1 = 0x00,
|
||||
FSR2 = 0x01,
|
||||
FSR3 = 0x02,
|
||||
FSR4 = 0X03,
|
||||
FSR5 = 0x04,
|
||||
FSR6 = 0x05,
|
||||
FSR7 = 0x06,
|
||||
FSR8 = 0x07,
|
||||
};
|
||||
|
||||
uint16_t read_adc_data(uint8_t AdcChannel, uint8_t gainAmp);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //ADC_ADS1118_H
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
#include "hardware/adc_ads1118.h"
|
||||
|
||||
static uint8_t spi_ADC_txbuf_l[2] = {0};
|
||||
static uint8_t spi_ADC_rxbuf_l[2] = {0};
|
||||
|
||||
|
||||
static void __ADC_read(uint8_t input_mux, uint8_t gAmp)
|
||||
{
|
||||
/*
|
||||
* write SPI to get ADC value
|
||||
* [7]~[0] should always be 0b11101011, data rate is 860 sps, other is default
|
||||
*
|
||||
* [15] : SS, 0 = no effect, 1 = start work, default 0b0
|
||||
* [14]~[12] : MUX[2:0], default 0b000
|
||||
*
|
||||
* [Input multiplexer configuration]
|
||||
*
|
||||
* the MUX selection will correspond to a pin pair
|
||||
* where the pair is positive and negative input
|
||||
*
|
||||
* MUX[2:0] <-> (AINp, AINn)
|
||||
*
|
||||
* 000 <-> AINp is AIN0, AINn is AIN1
|
||||
* 001 <-> AINp is AIN0, AINn is AIN3
|
||||
* 010 <-> AINp is AIN1, AINn is AIN3
|
||||
* 011 <-> AINp is AIN2, AINn is AIN3
|
||||
* 100 <-> AINp is AIN0, AINn is GND
|
||||
* 101 <-> AINp is AIN1, AINn is GND
|
||||
* 110 <-> AINp is AIN2, AINn is GND
|
||||
* 111 <-> AINp is AIN3, AINn is GND
|
||||
*
|
||||
*
|
||||
*
|
||||
* [11]~[9] : PGA[2:0], default 0b010 = FSR is ±2.048
|
||||
* [8] : mode, 0 = continuous, 1 = one shot, default 0b1 (Power-down and single-shot mode )
|
||||
*
|
||||
* [7]~[5] : data rate, default 0b100 = 128 SPS; 0b111 = 860 SPS
|
||||
* [4] : Temperature? default 0b0 = ADC mode
|
||||
* [3] : Pullup enable, default 0b1 = Pullup resistor enabled
|
||||
* [2]~[1] : NOP, default 0b01
|
||||
* [0] : reserved, default 0b1
|
||||
*
|
||||
*/
|
||||
|
||||
uint8_t *tx = spi_ADC_txbuf_l;
|
||||
uint8_t *rx = spi_ADC_rxbuf_l;
|
||||
uint8_t i_mux = input_mux;
|
||||
uint8_t ga = gAmp;
|
||||
|
||||
|
||||
tx[0] = i_mux << 4 | ga << 1 | 0b10000001;
|
||||
tx[1] = 0b11101011;
|
||||
|
||||
latch_single_ctrl(E_LATCH_CS_ADC, 0);
|
||||
spi1_write(NULL, tx, 2);
|
||||
latch_single_ctrl(E_LATCH_CS_ADC, 1);
|
||||
|
||||
memset(tx, 0, sizeof(tx));
|
||||
memset(rx, 0, sizeof(rx));
|
||||
|
||||
latch_single_ctrl(E_LATCH_CS_ADC, 0);
|
||||
spi1_write(rx, tx, 2);
|
||||
latch_single_ctrl(E_LATCH_CS_ADC, 1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t read_adc_data(uint8_t AdcChannel, uint8_t gainAmplifier)
|
||||
{
|
||||
uint8_t Adc_ch = AdcChannel;
|
||||
uint8_t gainAmp = gainAmplifier;
|
||||
uint16_t rx;
|
||||
|
||||
__ADC_read(Adc_ch, gainAmp);
|
||||
|
||||
rx = (uint16_t)spi_ADC_rxbuf_l[0] << 8 | (uint16_t)spi_ADC_rxbuf_l[1];
|
||||
|
||||
return rx;
|
||||
}
|
||||
+4943
File diff suppressed because it is too large
Load Diff
+4416
File diff suppressed because it is too large
Load Diff
+5
-1
@@ -21,7 +21,11 @@ extern "C" {
|
||||
|
||||
#include "driver/spi_ctrl.h"
|
||||
|
||||
#define DEF_LED_TANDEN_N 12
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EIS_11)
|
||||
#define DEF_LED_TANDEN_N 12
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_MINI_10)
|
||||
#define DEF_LED_TANDEN_N 1
|
||||
#endif
|
||||
|
||||
#ifdef DEF_LED_TANDEN_N
|
||||
#define LED_TANDEM_N DEF_LED_TANDEN_N
|
||||
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
|
||||
#ifndef AD5940
|
||||
#define AD5940
|
||||
|
||||
#define NV2USC(_n) (n / 1e7 * 625 + 25000) // [5nV] / 1e6 * 5 * 12.5 + 25000
|
||||
|
||||
static void setEIS_EIS_cali(void)
|
||||
{
|
||||
AD5940_SPIWriteReg(LPDACCON0, 0x00000001); // Direct from LPDACDAT0 | Vzero(6bit) & Vbias(12bit) | LP 2.5v as ref
|
||||
AD5940_SPIWriteReg(LPDACSW0, 0b111111); // orverride LPDACCON0[5] | LPDACSW0[0~5] close
|
||||
|
||||
AD5940_SPIWriteReg(HSRTIACON, 0x00000000); // CTIA=1pF | SW6 off(open) | RTIA=200R
|
||||
AD5940_SPIWriteReg(HSTIACON, 0x00000001); // Vzero
|
||||
|
||||
AD5940_SPIWriteReg(ADCCON, 0x00000101); // PGA=1 | HSTIA neg input | HSTIA pos signal
|
||||
AD5940_SPIWriteReg(DFTCON, 0x00000091); // DFTNUM=2048 | enable hanning window | SINC2
|
||||
AD5940_SPIWriteReg(SWCON, 0x00026355); // D5 | P5 | N3 | T6 | T9 close
|
||||
|
||||
if (instru.gain_lv_hstia < HSRTIA_MAX) {
|
||||
instru.HSTIAAutoGainEnable = 0;
|
||||
HSTIAGainCtrl(instru.gain_lv_hstia);
|
||||
} else {
|
||||
instru.HSTIAAutoGainEnable = 1;
|
||||
instru.gain_lv_hstia = HSRTIA_200R;
|
||||
HSTIAGainCtrl(instru.gain_lv_hstia);
|
||||
}
|
||||
|
||||
int32_t LPVolt = 0;
|
||||
LPVolt = (instru.dcbias - 25000) * 4 * 4000;
|
||||
DAC_outputV(LPVolt);
|
||||
cali_SetWGAmp(instru.acamp);
|
||||
|
||||
AD5940_SPIWriteReg(AFECON, 0x0031CFC0); // en dc DAC buf | HSDAC ref disable | LDO buf current limit enable | en SINC2 |
|
||||
// DFT hardware accelerator enable | waveform generator enable | HSTIA enable |
|
||||
// intru amplifier enable | excitation buf enable | ADC conversions enable |
|
||||
// ADC power enable | HSDAC enable | HP ref enable
|
||||
|
||||
//HIGH POWER MODE
|
||||
AD5940_SPIWriteReg(PMBW, 0x0000000D); // HS mode | Set cutooff frequency to 250kHz, -3 dB bandwidth
|
||||
AD5940_SPIWriteReg(CLKSEL, 0x0000);
|
||||
AD5940_SPIWriteReg(CLKCON0KEY, 0xA815); // !!!Write 0xA815 to this register before accessing the CLKCON0 register
|
||||
AD5940_SPIWriteReg(CLKCON0, 0x0442); //6bit system clock divider //set divider = 2
|
||||
AD5940_SPIWriteReg(HSOSCCON, 0x00000000); // HP osc select 32MHz output
|
||||
AD5940_SPIWriteReg(ADCFILTERCON, 0x00000311); // en DFT clk | en DAC wave clk | en SINC2 filter clk | 2 ADC samples used for average function |
|
||||
// SINC3 filter oversampling rate is 800kSPS |
|
||||
// SINC2 filter oversampling rate is 178 samples |
|
||||
// disable average | SINC3 filter enable |
|
||||
// Bypass 50/60Hz | ADC data rate 800kHz
|
||||
AD5940_SPIWriteReg(HSDACCON, 0x0000000E); // HSDAC gain = 2, DAC update rate = ACLK/HSDACCON = 32Mhz/7
|
||||
AD5940_SPIWriteReg(ADCBUFCON, 0x005F3D0F); //recommended
|
||||
SetEISHIGHZ(0);
|
||||
}
|
||||
|
||||
static void setEIS_CV (void)
|
||||
{
|
||||
//Clock and Ref
|
||||
AD5940_SPIWriteReg(CLKSEL, 0x0);
|
||||
AD5940_SPIWriteReg(HSOSCCON, 0x00000004); //16 MHz output
|
||||
AD5940_SPIWriteReg(0x2180, 0x00000037); //0b110110
|
||||
|
||||
//Configure LPDAC LPTIA
|
||||
AD5940_SPIWriteReg(LPREFBUFCON, 0x0); //enable lpref and lp 2.5V buffer
|
||||
AD5940_SPIWriteReg(LPDACSW0, 0x00000034); // disconnect Vbias and Vzero
|
||||
|
||||
AD5940_SPIWriteReg(LPTIASW0, 0x00000034); // SW2 | SW4 | SW5
|
||||
|
||||
LPTIAGainCtrl(instru.gain_lv_lptia);
|
||||
AD5940_SPIWriteReg(LPDACCON0, 0x00000001);
|
||||
|
||||
//Configure ADC | ADCDAT (0x2074)
|
||||
AD5940_SPIWriteReg(ADCCON, 0x00010221); //PGA = 1.5 | LPTIA- | LPTIA_OUT
|
||||
|
||||
AD5940_SPIWriteReg(ADCFILTERCON, 0x00002011); // Sinc3 En | SINC3OSR2 | SINC2OSR22
|
||||
AD5940_SPIWriteReg(DFTCON, 0x00000001); // Sinc2 to DFT | DFTNUM4
|
||||
|
||||
// mean function for calibration
|
||||
AD5940_SPIWriteReg(RRR_AFE_STATSCON, 0x00000001); // don't use mean function // dev | 128 samples | enable statistics
|
||||
|
||||
//AFE and PWMB
|
||||
AD5940_SPIWriteReg(AFECON, 0x00098780); //ADC on //0b10011000011110000000
|
||||
AD5940_SPIWriteReg(PMBW, 0x00000005); //fc 50kHz, low power mode
|
||||
}
|
||||
|
||||
static void set_hs_only(void)
|
||||
{
|
||||
AD5940_SPIWriteReg(LPDACCON0, 0x00000001); // Direct from LPDACDAT0 | Vzero(6bit) & Vbias(12bit) | LP 2.5v as ref
|
||||
AD5940_SPIWriteReg(LPDACSW0, 0b111111); // orverride LPDACCON0[5] | LPDACSW0[0~5] close
|
||||
|
||||
AD5940_SPIWriteReg(HSRTIACON, 0x00000000); // CTIA=1pF | SW6 off(open) | RTIA=200R
|
||||
AD5940_SPIWriteReg(HSTIACON, 0x00000001); // Vzero
|
||||
|
||||
AD5940_SPIWriteReg(ADCCON, 0x00000101); // PGA=1 | HSTIA neg input | HSTIA pos signal
|
||||
AD5940_SPIWriteReg(DFTCON, 0x00000091); // DFTNUM=2048 | enable hanning window | SINC2
|
||||
AD5940_SPIWriteReg(SWCON, 0x00026355); // D5 | P5 | N3 | T6 | T9 close
|
||||
|
||||
AD5940_SPIWriteReg(AFECON, 0x0031CFC0); // en dc DAC buf | HSDAC ref disable | LDO buf current limit enable | en SINC2 |
|
||||
// DFT hardware accelerator enable | waveform generator enable | HSTIA enable |
|
||||
// intru amplifier enable | excitation buf enable | ADC conversions enable |
|
||||
// ADC power enable | HSDAC enable | HP ref enable
|
||||
|
||||
//HIGH POWER MODE
|
||||
AD5940_SPIWriteReg(PMBW, 0x0000000D); // HS mode | Set cutooff frequency to 250kHz, -3 dB bandwidth
|
||||
AD5940_SPIWriteReg(CLKSEL, 0x0000);
|
||||
AD5940_SPIWriteReg(CLKCON0KEY, 0xA815); // !!!Write 0xA815 to this register before accessing the CLKCON0 register
|
||||
AD5940_SPIWriteReg(CLKCON0, 0x0442); //6bit system clock divider //set divider = 2
|
||||
AD5940_SPIWriteReg(HSOSCCON, 0x00000000); // HP osc select 32MHz output
|
||||
AD5940_SPIWriteReg(ADCFILTERCON, 0x00000311); // en DFT clk | en DAC wave clk | en SINC2 filter clk | 2 ADC samples used for average function |
|
||||
// SINC3 filter oversampling rate is 800kSPS |
|
||||
// SINC2 filter oversampling rate is 178 samples |
|
||||
// disable average | SINC3 filter enable |
|
||||
// Bypass 50/60Hz | ADC data rate 800kHz
|
||||
AD5940_SPIWriteReg(HSDACCON, 0x0000000E); // HSDAC gain = 2, DAC update rate = ACLK/HSDACCON = 32Mhz/7
|
||||
AD5940_SPIWriteReg(ADCBUFCON, 0x005F3D0F); //recommended
|
||||
SetEISHIGHZ(0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// static void AD5940_Initialize() {
|
||||
// AD5940_SPIWriteReg(0x0908, 0x02C9);//initiation
|
||||
// AD5940_SPIWriteReg(0x0C08, 0x206C);
|
||||
// AD5940_SPIWriteReg(0x21F0, 0x0010);
|
||||
// AD5940_SPIWriteReg(0x0410, 0x02C9);
|
||||
// AD5940_SPIWriteReg(0x0A28, 0x0009);
|
||||
// AD5940_SPIWriteReg(ADCBUFCON, 0x0104);
|
||||
// AD5940_SPIWriteReg(0x0A04, 0x4859);
|
||||
// AD5940_SPIWriteReg(0x0A04, 0xF27B);
|
||||
// AD5940_SPIWriteReg(0x0A00, 0x8009);
|
||||
// AD5940_SPIWriteReg(PMBW, 0x0000);
|
||||
// }
|
||||
|
||||
// static void AD5940_sftreset(){
|
||||
// AD5940_SPIWriteReg(0x0424, 0xA158);
|
||||
// CPUdelay_us(200);
|
||||
// }
|
||||
|
||||
#endif
|
||||
+823
-400
File diff suppressed because it is too large
Load Diff
+224
-28
@@ -4,34 +4,203 @@
|
||||
|
||||
static bool DACReset;
|
||||
|
||||
#define DACCLS 0x02
|
||||
#define DACOUT 0x31
|
||||
#define VBIAS_LSB 107422 // 2200/4096 [mV] = 107422 [5nV]
|
||||
#define VZERO_LSB 6875008 // VBIAS_LSB * 64
|
||||
#define DAC12BIT_LSB 107422
|
||||
|
||||
#define VOLT_MV_TO_5NV(_v) (_v * 200000)
|
||||
#define V_5nV(_v) VOLT_MV_TO_5NV(_v)
|
||||
|
||||
|
||||
/* user code: 0 ~ 35000; LPDAC bias value: -1.5V ~ +1.5V */
|
||||
static int32_t DAC_outputV(int32_t voltLVraw) { // LPDAC output, voltLV = Vbias-Vzero
|
||||
/* new code*/
|
||||
int32_t ret;
|
||||
int32_t vscan;
|
||||
int64_t v_z;
|
||||
int64_t v_zero;
|
||||
int64_t v_bias;
|
||||
uint8_t n_zero;//6btit
|
||||
uint16_t n_bias;//12bit
|
||||
uint32_t DACOutCode;
|
||||
|
||||
vscan = voltLVraw * (-1);
|
||||
|
||||
v_z = (V_5nV(2200) - (int64_t)vscan) * 200000 / 431579 + V_5nV(200); // v_z = (V_5nV(2200) - vscan)/2.157895 + V_5nV(200);
|
||||
n_zero = v_z * 100 / V_5nV(3438); // n_zero = v_z / V_5nV(34.38);
|
||||
v_zero = (int64_t)n_zero * V_5nV(3438) / 100; // v_zero = n_zero * V_5nV(34.38);
|
||||
//
|
||||
if (vscan < 0) { //
|
||||
v_zero -= V_5nV(5372) / 10000; // v_zero -= V_5nV(0.5372);
|
||||
} //
|
||||
//
|
||||
v_bias = vscan + v_zero; // v_bias = vscan + v_zero;
|
||||
n_bias = v_bias * 10000 / V_5nV(5372); // n_bias = v_bias / V_5nV(0.5372);
|
||||
|
||||
while (n_bias > 4095) {
|
||||
n_zero--;
|
||||
v_zero = (int64_t)n_zero * V_5nV(3438) / 100;
|
||||
|
||||
if (vscan < 0) {
|
||||
v_zero -= V_5nV(5372) / 10000;
|
||||
}
|
||||
|
||||
v_bias = vscan + v_zero;
|
||||
n_bias = v_bias * 10000 / V_5nV(5372);
|
||||
|
||||
if ((n_bias <= 4095) || ( n_bias > 4095 && n_zero > 63))
|
||||
break;
|
||||
}
|
||||
|
||||
if(n_bias > 4095) n_bias = 4095;
|
||||
if(n_zero > 63) n_zero = 63;
|
||||
DACOutCode = (0x0003FFFF & ((n_zero << 12) + n_bias));
|
||||
|
||||
AD5940_SPIWriteReg(LPDACDAT0, DACOutCode);
|
||||
|
||||
ret = (int32_t)(v_bias - v_zero); //vscan
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* user code: 0 ~ 50000: -2V ~ +2V */
|
||||
static void HSDAC_outputV(int32_t voltLVraw)
|
||||
{
|
||||
uint8_t n_zero;//6btit
|
||||
uint16_t n_bias;//12bit
|
||||
uint32_t DACOutCode;
|
||||
int64_t value = ((int64_t)voltLVraw * voltLVraw * CaliTable.ac_dcbais.up_a + voltLVraw * CaliTable.ac_dcbais.up_b + CaliTable.ac_dcbais.up_c + 5e11) / 1e12;
|
||||
if ( value < 1920)
|
||||
value = ((int64_t)voltLVraw * voltLVraw * CaliTable.ac_dcbais.down_a + voltLVraw * CaliTable.ac_dcbais.down_b + CaliTable.ac_dcbais.down_c + 5e11) / 1e12;
|
||||
n_zero = 30;
|
||||
n_bias = (uint16_t)value;
|
||||
|
||||
if(n_bias > 4095) n_bias = 4095;
|
||||
if(n_zero > 63) n_zero = 63;
|
||||
DACOutCode = (0x0003FFFF & ((n_zero << 12) + n_bias));
|
||||
|
||||
AD5940_SPIWriteReg(LPDACDAT0, DACOutCode);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* user code: 0 ~ 50000; LPDAC bias value: -2V ~ +2V */
|
||||
static void set_lpdac_ce_1100mv(uint8_t z, uint16_t b) { // LPDAC output, voltLV = Vbias-Vzero
|
||||
/* new code*/
|
||||
uint8_t n_zero = z;//6btit
|
||||
uint16_t n_bias = b;//12bit
|
||||
uint32_t DACOutCode;
|
||||
|
||||
DACOutCode = (0x0003FFFF & ((n_zero << 12) + n_bias));
|
||||
|
||||
AD5940_SPIWriteReg(LPDACDAT0, DACOutCode);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static uint32_t DAC_outputF(uint32_t freq) {
|
||||
AD5940_SPIWriteReg(WGFCW, freq);
|
||||
return freq;
|
||||
}
|
||||
|
||||
static void VoutGainControl(uint8_t VOUTLevel){
|
||||
if(VOUTLevel == 0){
|
||||
// VOUT gain level = 0, using 240K resister
|
||||
latch_single_ctrl(E_LATCH_VOUT_SMALL_ON, 0);
|
||||
}
|
||||
else if(VOUTLevel == 1){
|
||||
// VOUT gain level = 1, using 15K resister
|
||||
latch_single_ctrl(E_LATCH_VOUT_SMALL_ON, 1);
|
||||
}
|
||||
else if(VOUTLevel == 2){
|
||||
// VOUT gain level = 2, using 15K resister
|
||||
latch_single_ctrl(E_LATCH_VOUT_SMALL_ON, 1);
|
||||
}
|
||||
else{
|
||||
// default using 15K resister
|
||||
latch_single_ctrl(E_LATCH_VOUT_SMALL_ON, 1);
|
||||
}
|
||||
volt_rec_en = false;
|
||||
// if(VOUTLevel == 0){
|
||||
// // VOUT gain level = 0, using 240K resister
|
||||
// PIN_setOutputValue(pin_handle, Turon_VOUT_SMALL, 0);
|
||||
// }
|
||||
// else if(VOUTLevel == 1){
|
||||
// // VOUT gain level = 1, using 15K resister
|
||||
// PIN_setOutputValue(pin_handle, Turon_VOUT_SMALL, 1);
|
||||
// }
|
||||
// else if(VOUTLevel == 2){
|
||||
// // VOUT gain level = 2, using 15K resister
|
||||
// PIN_setOutputValue(pin_handle, Turon_VOUT_SMALL, 1);
|
||||
// }
|
||||
// else{
|
||||
// // default using 15K resister
|
||||
// PIN_setOutputValue(pin_handle, Turon_VOUT_SMALL, 1);
|
||||
// }
|
||||
// record_flag = false;
|
||||
}
|
||||
|
||||
static int32_t User2Real(uint16_t UserCode){
|
||||
/* transfer usercode to real voltage value (mV) */
|
||||
return (int32_t)((UserCode - 25000) / 5);
|
||||
static uint32_t CalcPeriod(uint32_t freq){ //One Second = 10000
|
||||
|
||||
uint32_t period;
|
||||
|
||||
if (freq == 1) {
|
||||
period = 666667;
|
||||
} else {
|
||||
period = (1000000 + freq / 2) / freq; // [sec]
|
||||
}
|
||||
|
||||
if (period < 20){
|
||||
period = 20;
|
||||
}
|
||||
|
||||
return period;
|
||||
}
|
||||
|
||||
static uint32_t CalcDelayTime(uint32_t freq){ //freq[10mHz]
|
||||
uint32_t delayTime, decadeSamplingTime;
|
||||
delayTime = CalcPeriod(freq) * instru.delay; //get delay time
|
||||
if (delayTime < 20) {
|
||||
delayTime = 20;
|
||||
} else {
|
||||
delayTime = (delayTime + 5) / 10;
|
||||
}
|
||||
|
||||
// 10kHz
|
||||
if (freq >= 1000000) {
|
||||
decadeSamplingTime = 1025;
|
||||
}
|
||||
|
||||
// 1kHz
|
||||
else if (freq >= 100000) {
|
||||
decadeSamplingTime = 1025;
|
||||
}
|
||||
|
||||
// 100Hz
|
||||
else if (freq >= 10000) {
|
||||
decadeSamplingTime = 1025;
|
||||
}
|
||||
|
||||
// 10Hz
|
||||
else if (freq >= 1000) {
|
||||
decadeSamplingTime = 11395;
|
||||
}
|
||||
|
||||
// 1Hz
|
||||
else if (freq >= 100) {
|
||||
decadeSamplingTime = 56900;
|
||||
}
|
||||
|
||||
//0.1Hz
|
||||
else if (freq >= 10) {
|
||||
decadeSamplingTime = 546000;
|
||||
}
|
||||
|
||||
// 0.015Hz | 136s
|
||||
else if (freq >= 1) {
|
||||
decadeSamplingTime = 1364995;
|
||||
}
|
||||
|
||||
delayTime += decadeSamplingTime; //delay+reading time
|
||||
|
||||
return delayTime;
|
||||
}
|
||||
|
||||
static uint32_t User2Freq(uint32_t UserCode){
|
||||
uint32_t freq;
|
||||
freq = UserCode * 15 / 10;
|
||||
return freq; //[10mHz]
|
||||
}
|
||||
|
||||
static uint32_t Freq2DAC(uint32_t freq){
|
||||
uint32_t code;
|
||||
code = freq * 10 / 15;
|
||||
return code; //return code
|
||||
}
|
||||
|
||||
// DAC Vout theoretical boundary <300, 100~ (mV)
|
||||
#define DAC_VOUT_GAIN_SMALL_BOUNDARY 100000 // 25500(usercode) = 100 mV
|
||||
@@ -44,20 +213,47 @@ static void AutoGainChangeVout(int32_t userCode){
|
||||
// switch to 1 level volt(small) 15K
|
||||
// switch to 2 level volt(large) 240K
|
||||
|
||||
if(instru.VoutGainLv == VOUT_GAIN_15K){
|
||||
if(instru.VoutGainLevel == VOUT_GAIN_AUTO){
|
||||
instru.VoutGainLevel = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLevel);
|
||||
}
|
||||
|
||||
if(instru.VoutGainLevel == 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);
|
||||
instru.VoutGainLevel = VOUT_GAIN_240K;
|
||||
VoutGainControl(instru.VoutGainLevel);
|
||||
}
|
||||
}
|
||||
else if(instru.VoutGainLv == VOUT_GAIN_240K){
|
||||
else if(instru.VoutGainLevel == 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);
|
||||
instru.VoutGainLevel = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void cali_SetWGAmp(uint32_t ampcode){
|
||||
AD5940_SPIWriteReg(WGCON, 0x0); // 0x0: DC disable ac first
|
||||
AD5940_SPIWriteReg(WGAMPLITUDE, ampcode);
|
||||
AD5940_SPIWriteReg(WGCON, 0x00000004); //0x4: Sinusoid
|
||||
}
|
||||
|
||||
static void SetWGAmp(uint16_t ampcode, uint32_t freq){
|
||||
uint32_t amplitude = 0;
|
||||
amplitude = Cali_HSAMP(ampcode, freq);
|
||||
|
||||
cali_SetWGAmp(amplitude);
|
||||
}
|
||||
|
||||
static void SetEISHIGHZ(uint8_t ret){
|
||||
uint32_t code;
|
||||
|
||||
// select_REG_RRR(LPTIASW0); //LPTIASW0
|
||||
code = AD5940_SPIReadReg(LPTIASW0);
|
||||
code = (code & (~(1 << 2))) | (ret << 2); //ret = 0 HighZ on | ret = 1 HighZ off
|
||||
AD5940_SPIWriteReg(LPTIASW0, code);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
-2439
File diff suppressed because it is too large
Load Diff
+226
-136
@@ -1,8 +1,5 @@
|
||||
/*=============================================================================
|
||||
= instr.h =
|
||||
=============================================================================*/
|
||||
#ifndef ELITE_INSTR_H
|
||||
#define ELITE_INSTR_H
|
||||
#ifndef __INSTR_H__
|
||||
#define __INSTR_H__
|
||||
|
||||
#ifdef __cpulsplus
|
||||
extern "C" {
|
||||
@@ -15,13 +12,9 @@ struct HEADSTAGE_INSTRUCTION {
|
||||
uint8_t chip_id;
|
||||
uint8_t eliteFxn;
|
||||
|
||||
// time relation
|
||||
/** DAC parameter **/
|
||||
uint8_t VsetRateIndex;
|
||||
uint32_t VsetRate;
|
||||
uint32_t sampleRate;
|
||||
uint32_t notifyRate;
|
||||
uint32_t period;
|
||||
|
||||
int32_t Vset;
|
||||
uint16_t VoltConstant;
|
||||
uint8_t directionInit;
|
||||
@@ -32,81 +25,175 @@ struct HEADSTAGE_INSTRUCTION {
|
||||
int32_t Vmax;
|
||||
int32_t Vmin;
|
||||
|
||||
uint32_t steptime;
|
||||
/** EIS **/
|
||||
uint32_t f1;
|
||||
uint32_t f2;
|
||||
uint32_t fmax;
|
||||
uint32_t fmin;
|
||||
uint32_t fset;
|
||||
uint16_t dcbias;
|
||||
uint16_t delay;
|
||||
uint16_t acamp;
|
||||
uint8_t avgnum;
|
||||
uint8_t rtia;
|
||||
uint16_t ppd;
|
||||
uint8_t scale;
|
||||
int32_t real;
|
||||
int32_t imag;
|
||||
uint8_t periodIndex;
|
||||
uint32_t delayTime;
|
||||
uint8_t settingIndex;
|
||||
|
||||
uint8_t IinADCAutoGainEn;
|
||||
uint8_t VinADCAutoGainEn;
|
||||
uint8_t VoutAutoGainEn;
|
||||
uint8_t IinADCGainLv;
|
||||
|
||||
/** ADC parameter **/
|
||||
uint8_t notifyRateIndex;
|
||||
uint32_t sampleRate;
|
||||
uint8_t VoViSwitch;
|
||||
uint8_t VinAutoGainEnable;
|
||||
uint8_t VoutAutoGainEnable;
|
||||
uint8_t ADCGainLv;
|
||||
|
||||
// voltage output gain
|
||||
uint16_t VoutGainLevel;
|
||||
uint8_t VinADCGainLv;
|
||||
uint16_t VoutGainLv;
|
||||
uint8_t gain_switch_on;
|
||||
uint8_t AdcChannel;
|
||||
bool hign_z_en;
|
||||
|
||||
/** Notify parameter **/
|
||||
uint32_t notifyRate;
|
||||
|
||||
/** mode parameter **/
|
||||
uint16_t cycleNumber;
|
||||
uint8_t charge;
|
||||
int32_t constantCurrent;
|
||||
uint8_t cc_resistance;
|
||||
uint8_t cc_cp_speed;
|
||||
|
||||
// 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;
|
||||
|
||||
int32_t Vout;
|
||||
|
||||
// not use
|
||||
int32_t Currentmax;
|
||||
uint8_t VoViSwitch;
|
||||
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;
|
||||
|
||||
uint16_t StepTime;
|
||||
|
||||
uint8_t AdcChannel;
|
||||
|
||||
/* EIS DAC parameter */
|
||||
uint8_t DAC_type;
|
||||
uint16_t VAmpSet; // DAC Voltage Amplitude
|
||||
|
||||
/* EIS ADC parameter */
|
||||
uint8_t gain_lv_hstia;
|
||||
uint8_t HSTIAAutoGainEnable;
|
||||
uint8_t gain_lv_lptia;
|
||||
uint8_t LPTIAAutoGainEnable;
|
||||
|
||||
//VT mode
|
||||
uint8_t measure_vin_range;
|
||||
} 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 **/
|
||||
#define I_GAIN_3M 0x07 // largest gain
|
||||
#define I_GAIN_100K 0x08
|
||||
#define I_GAIN_3K 0x09
|
||||
#define I_GAIN_100R 0x0A // the least gain
|
||||
#define I_GAIN_AUTO 0x04
|
||||
|
||||
// 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
|
||||
// EIS LPTIA Iin Gain Level //
|
||||
//#define LPRTIA_512K 0x00
|
||||
#define LPRTIA_64K 0x00
|
||||
#define LPRTIA_8K 0x01
|
||||
#define LPRTIA_1K 0x02
|
||||
#define LPRTIA_200R 0x03
|
||||
#define LPRTIA_GAIN_AUTO 0x04
|
||||
#define DISCONNECT_RTIA 0x05
|
||||
|
||||
// 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
|
||||
// EIS HSTIA Iin Gain Level
|
||||
enum hsrtia_gain_e {
|
||||
HSRTIA_160K = 0,
|
||||
HSRTIA_80K,
|
||||
HSRTIA_40K,
|
||||
HSRTIA_20K,
|
||||
HSRTIA_10K,
|
||||
HSRTIA_5K,
|
||||
HSRTIA_1K,
|
||||
HSRTIA_200R,
|
||||
|
||||
HSRTIA_MAX,
|
||||
};
|
||||
|
||||
// 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
|
||||
/** ADC Vin gain level **/
|
||||
#define VIN_GAIN_1M 0x00
|
||||
#define VIN_GAIN_30K 0x01
|
||||
#define VIN_GAIN_1K 0x02
|
||||
#define VIN_GAIN_AUTO 0x03
|
||||
|
||||
/** Vout gain level **/
|
||||
#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
|
||||
#define DAC_ZERO 25000
|
||||
#define EIS_HSDAC_ZERO 0x0800
|
||||
|
||||
// Step time macro
|
||||
#define STEPTIME_HALF_SEC 5000
|
||||
#define STEPTIME_ONE_SEC 10000
|
||||
#define STEPTIME_TWO_SEC 20000
|
||||
#define STEPTIME_HALF_SEC 5000
|
||||
#define STEPTIME_ONE_SEC 10000
|
||||
#define STEPTIME_TWO_SEC 20000
|
||||
|
||||
/* AVG Number */
|
||||
#define AVG2 0
|
||||
#define AVG4 1
|
||||
#define AVG8 2
|
||||
#define AVG16 3
|
||||
|
||||
#define ADC1M6sps 0
|
||||
#define ADC800Ksps 1
|
||||
|
||||
#define Sinc3OSR5 0
|
||||
#define Sinc3OSR4 1
|
||||
#define Sinc3OSR2 2
|
||||
|
||||
#define Sinc2OSR22 0
|
||||
#define Sinc2OSR44 1
|
||||
#define Sinc2OSR89 2
|
||||
#define Sinc2OSR178 3
|
||||
#define Sinc2OSR267 4
|
||||
#define Sinc2OSR533 5
|
||||
#define Sinc2OSR640 6
|
||||
#define Sinc2OSR667 7
|
||||
#define Sinc2OSR800 8
|
||||
#define Sinc2OSR889 9
|
||||
#define Sinc2OSR1067 10
|
||||
#define Sinc2OSR1333 11
|
||||
|
||||
#define DFTNUM4 0
|
||||
#define DFTNUM8 1
|
||||
#define DFTNUM16 2
|
||||
#define DFTNUM32 3
|
||||
#define DFTNUM64 4
|
||||
#define DFTNUM128 5
|
||||
#define DFTNUM256 6
|
||||
#define DFTNUM512 7
|
||||
#define DFTNUM1024 8
|
||||
#define DFTNUM2048 9
|
||||
#define DFTNUM4096 10
|
||||
#define DFTNUM8192 11
|
||||
#define DFTNUM16384 12
|
||||
|
||||
#define AD5940_SYS_CLOCK 16000000
|
||||
#define Cutoff_Freq 37000000 // 210kHz
|
||||
|
||||
static uint32_t HSRTIATable[4] = {160000, 20000, 5000, 200};
|
||||
|
||||
/*********************************************************************
|
||||
* @fn InitEliteInstruction
|
||||
@@ -117,80 +204,83 @@ struct HEADSTAGE_INSTRUCTION {
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
static void InitEliteInstruction(void)
|
||||
{
|
||||
instru.chip_id = 0;
|
||||
instru.eliteFxn = 0; //default is a null event
|
||||
static void InitEliteInstruction(){
|
||||
instru.chip_id = 0;
|
||||
instru.eliteFxn = 0; //default is a null event
|
||||
instru.VsetRateIndex = 0;
|
||||
instru.VsetRate = 2;
|
||||
instru.Vset = 0;
|
||||
instru.VoltConstant = DAC_ZERO; //DAC_ZERO is about 0V
|
||||
instru.directionInit = 1; //0:reverse 1:forward
|
||||
instru.step = 0;
|
||||
instru.Ve1 = DAC_ZERO;
|
||||
instru.Ve2 = DAC_ZERO;
|
||||
instru.Vinit = 0;
|
||||
instru.Vmax = 0;
|
||||
instru.Vmin = 0;
|
||||
instru.notifyRateIndex = 100;
|
||||
instru.sampleRate = 15;
|
||||
instru.VoViSwitch = 0x01; //0:user see Vo 1: user see Vi
|
||||
instru.VinAutoGainEnable = 1;
|
||||
instru.VoutAutoGainEnable = 1;
|
||||
instru.VoutGainLevel = VOUT_GAIN_AUTO;
|
||||
instru.VinADCGainLv = VIN_GAIN_AUTO;
|
||||
instru.notifyRate = STEPTIME_ONE_SEC;
|
||||
instru.cycleNumber = 1;
|
||||
instru.charge = 1; //0:discharge 1:charge
|
||||
instru.constantCurrent = 0;
|
||||
instru.Currentmax = 0;
|
||||
instru.StepTime = STEPTIME_ONE_SEC;
|
||||
instru.AdcChannel = 0;
|
||||
|
||||
instru.VsetRateIndex = 0; // vscan rate
|
||||
instru.VsetRate = 2;
|
||||
instru.sampleRate = 20; // ADC's sample rate
|
||||
instru.notifyRate = CLOCK_ONE_SECOND; // send data's rate
|
||||
instru.period = CLOCK_ONE_SECOND;
|
||||
//EIS
|
||||
instru.f1 = 0;
|
||||
instru.f2 = 0;
|
||||
instru.fset = 0;
|
||||
instru.fmax = 0;
|
||||
instru.fmin = 0;
|
||||
instru.delay = 0;
|
||||
instru.scale = 0;
|
||||
instru.avgnum = 0;
|
||||
instru.dcbias = 0;
|
||||
instru.acamp = 0;
|
||||
instru.ppd = 1;
|
||||
instru.periodIndex = 0;
|
||||
instru.delayTime = 0;
|
||||
instru.settingIndex = 0;
|
||||
|
||||
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_100R;
|
||||
instru.VinADCGainLv = VIN_GAIN_1K;
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
instru.gain_switch_on = 0b11110000; // cur auto gain switch, |lv0|lv1|lv2|lv3|none|none|none|none|
|
||||
instru.AdcChannel = 0; // RIS_ADC_IIN: 0x00, RIS_ADC_VIN: 0x01, RIS_DAC_VOUT: 0x02, RIS_HIGH_Z: 0x03
|
||||
instru.hign_z_en = 0;
|
||||
//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.cycleNumber = 1;
|
||||
instru.charge = 1; // 0:discharge, 1:charge
|
||||
instru.constantCurrent = 0;
|
||||
//General
|
||||
// EIS DAC
|
||||
instru.VAmpSet = EIS_HSDAC_ZERO;
|
||||
instru.DAC_type = 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;
|
||||
// EIS ADC
|
||||
instru.gain_lv_hstia = HSRTIA_200R;
|
||||
instru.HSTIAAutoGainEnable = 1;
|
||||
instru.gain_lv_lptia = LPRTIA_200R;
|
||||
instru.LPTIAAutoGainEnable = 1;
|
||||
|
||||
instru.Vout = 0;
|
||||
|
||||
// not use
|
||||
instru.Currentmax = 0;
|
||||
instru.VoViSwitch = 0x01;
|
||||
|
||||
return;
|
||||
// VT mode
|
||||
instru.measure_vin_range = 0;
|
||||
}
|
||||
|
||||
#ifdef __cpulsplus
|
||||
|
||||
+5
-25
@@ -40,7 +40,7 @@ static void ModeLED(uint16_t modeStatus) {
|
||||
|
||||
case POST_WORK:
|
||||
postWorkLedFlag = 1;
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_GREEN);
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_BLUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -66,35 +66,15 @@ static void checkFlafLED()
|
||||
static void WorkModeLED()
|
||||
{
|
||||
switch (instru.eliteFxn) {
|
||||
case CURVE_IV:
|
||||
case CURVE_VO:
|
||||
case CURVE_RT:
|
||||
case CURVE_VT:
|
||||
case CURVE_IT:
|
||||
case CURVE_EIS:
|
||||
case CURVE_CV:
|
||||
case CURVE_CA:
|
||||
case CURVE_CC:
|
||||
case CURVE_OCP:
|
||||
case CURVE_LSV:
|
||||
case CURVE_IV_CY:
|
||||
case CURVE_UNI_PULSE:
|
||||
case CURVE_DPV:
|
||||
case CURVE_DPV_SMPRATE:
|
||||
case CURVE_DPV_ADVANCE:
|
||||
case CURVE_DPV_ADVANCE_SMPRATE:
|
||||
case CURVE_VT:
|
||||
case CURVE_RT:
|
||||
case CURVE_CF:
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_CYAN);
|
||||
break;
|
||||
|
||||
case CURVE_CALI_ADC:
|
||||
if (instru.AdcChannel == RIS_ADC_IIN) {
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_RED);
|
||||
} else if (instru.AdcChannel == RIS_ADC_VIN) {
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_ORANGE);
|
||||
} else if (instru.AdcChannel == RIS_DAC_VOUT) {
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_BLUE);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
|
||||
+109
-58
@@ -8,25 +8,59 @@
|
||||
#define ELITENOTIFY
|
||||
|
||||
#include "headstage.h"
|
||||
#include <string.h>
|
||||
|
||||
/*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 NOTIFY_CURRENT 0
|
||||
#define NOTIFY_VOLT 1
|
||||
#define NOTIFY_IMPEDANCE 2
|
||||
#define NOTIFY_VOLT_BAT 3
|
||||
|
||||
#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 uint16_t NotifyVoltBat = 0;
|
||||
static uint16_t NotifyTemperature = 0;
|
||||
|
||||
static uint8_t NotifyCh1[4] = {0};
|
||||
static uint8_t NotifyCh2[4] = {0};
|
||||
static uint8_t NotifyCh3[4] = {0};
|
||||
static uint8_t NotifyVoltBat[4] = {0};
|
||||
static uint16_t NotifyCycleNumber = 0;
|
||||
static bool finishMode = false;
|
||||
static uint8_t finishMode = 0;
|
||||
static uint8_t gain = 0;
|
||||
static int32_t notify_one = 0;
|
||||
static int32_t notify_two = 0;
|
||||
static int32_t notify_three = 0;
|
||||
static uint32_t NotifyCh4 = 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 ***************************************** //
|
||||
|
||||
/*
|
||||
* Notify format
|
||||
@@ -52,67 +86,75 @@ static bool finishMode = false;
|
||||
*
|
||||
*
|
||||
*/
|
||||
static void SendNotify() {
|
||||
static uint8_t notify_times = 0;
|
||||
uint32_t bat = NotifyVoltBat;
|
||||
static void initDATBuf(void)
|
||||
{
|
||||
memset(not_buf, 0, BLE_DAT_BUFF_SIZE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void initINSBuf(void)
|
||||
{
|
||||
memset(ins_buf, 0, BLE_INS_BUFF_SIZE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void initCISBuf(void)
|
||||
{
|
||||
memset(cis_buf, 0, BLE_CIS_BUFF_SIZE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void SendNotify() {
|
||||
initDATBuf();
|
||||
|
||||
not_buf[0] = instru.chip_id;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
not_buf[i + 1] = NotifyCh1[i]; // 1 2 3 4
|
||||
not_buf[i + 5] = NotifyCh2[i]; // 5 6 7 8
|
||||
not_buf[i + 9] = NotifyCh3[i]; //9 10 11 12
|
||||
}
|
||||
|
||||
// 1 Timestamp = 32 usec; 31 Timestamp ~= 1 msec
|
||||
not_time_stamp = (Timestamp_get32()) / 31; // msec
|
||||
|
||||
not_buf[0] = instru.chip_id;
|
||||
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;
|
||||
|
||||
memcpy(not_buf+1, (uint8_t *)¬_time_stamp, sizeof(not_time_stamp));
|
||||
memcpy(not_buf+5, NotifyCurrent, sizeof(NotifyCurrent));
|
||||
memcpy(not_buf+9, NotifyVolt, sizeof(NotifyVolt));
|
||||
memcpy(not_buf+13, NotifyImpedance, sizeof(NotifyImpedance));
|
||||
memcpy(not_buf+17, (uint8_t *)&NotifyCycleNumber, sizeof(NotifyCycleNumber));
|
||||
not_buf[17] = (NotifyCycleNumber >> 8) & 0xff;
|
||||
not_buf[18] = NotifyCycleNumber & 0xff;
|
||||
|
||||
if (finishMode) {
|
||||
not_buf[19] = (FINISH_MODE_INS) & 0b11110000;
|
||||
} else {
|
||||
not_buf[19] = 0 & 0b11110000;
|
||||
}
|
||||
not_buf[19] = (finishMode << 7) & 0x80;
|
||||
not_buf[20] = gain;
|
||||
|
||||
memcpy(not_buf+20, (uint8_t *)&bat, sizeof(bat));
|
||||
memcpy(not_buf+24, ¬ify_times, sizeof(notify_times));
|
||||
memcpy(not_buf+21, (uint8_t *)&NotifyCh4, sizeof(NotifyCh4));
|
||||
memcpy(not_buf+25, (uint8_t *)¬ify_one, sizeof(notify_one));
|
||||
memcpy(not_buf+29, (uint8_t *)¬ify_two, sizeof(notify_two));
|
||||
memcpy(not_buf+33, (uint8_t *)¬ify_three, sizeof(notify_three));
|
||||
|
||||
for (int i = 25; i < BLE_DAT_BUFF_SIZE; i++){
|
||||
for (int i = 37; i < BLE_DAT_BUFF_SIZE; i++){
|
||||
not_buf[i] = 0;
|
||||
}
|
||||
|
||||
SimpleProfile_SetParameter(BLE_DAT_BUFF_CHAR, BLE_DAT_BUFF_SIZE, not_buf);
|
||||
notify_times++;
|
||||
}
|
||||
|
||||
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;
|
||||
finishMode = 0;
|
||||
|
||||
for (int i = 0; i < 4; i++){
|
||||
NotifyCurrent[i] = 0;
|
||||
NotifyVolt[i] = 0;
|
||||
NotifyImpedance[i] = 0;
|
||||
NotifyCh1[i] = 0;
|
||||
NotifyCh2[i] = 0;
|
||||
NotifyCh3[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,22 +171,31 @@ static void InputNotify(int NotifyType, int32_t Data){
|
||||
|
||||
switch (NotifyType) {
|
||||
case NOTIFY_CURRENT:
|
||||
memcpy(NotifyCurrent, (uint8_t *)&Data, sizeof(Data));
|
||||
NotifyCh1[0] = (uint8_t)((Data & 0xFF000000) >> 24);
|
||||
NotifyCh1[1] = (uint8_t)((Data & 0x00FF0000) >> 16);
|
||||
NotifyCh1[2] = (uint8_t)((Data & 0x0000FF00) >> 8);
|
||||
NotifyCh1[3] = (uint8_t)(Data & 0x000000FF);
|
||||
break;
|
||||
|
||||
case NOTIFY_IMPEDANCE:
|
||||
memcpy(NotifyImpedance, (uint8_t *)&Data, sizeof(Data));
|
||||
NotifyCh3[0] = (uint8_t)((Data & 0xFF000000) >> 24);
|
||||
NotifyCh3[1] = (uint8_t)((Data & 0x00FF0000) >> 16);
|
||||
NotifyCh3[2] = (uint8_t)((Data & 0x0000FF00) >> 8);
|
||||
NotifyCh3[3] = (uint8_t)(Data & 0x000000FF);
|
||||
break;
|
||||
|
||||
case NOTIFY_VOLT :
|
||||
memcpy(NotifyVolt, (uint8_t *)&Data, sizeof(Data));
|
||||
NotifyCh2[0] = (uint8_t)((Data & 0xFF000000) >> 24);
|
||||
NotifyCh2[1] = (uint8_t)((Data & 0x00FF0000) >> 16);
|
||||
NotifyCh2[2] = (uint8_t)((Data & 0x0000FF00) >> 8);
|
||||
NotifyCh2[3] = (uint8_t)(Data & 0x000000FF);
|
||||
break;
|
||||
|
||||
case NOTIFY_VOLT_BAT :
|
||||
NotifyVoltBat = (uint16_t)Data;
|
||||
break;
|
||||
case NOTIFY_TEMPERATURE :
|
||||
NotifyTemperature = (uint16_t)Data;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-32
@@ -3,47 +3,20 @@
|
||||
#define ELITERESET
|
||||
|
||||
static void reset() {
|
||||
mode_init = true;
|
||||
megaStiEnable = false;
|
||||
PeriodicEvent = false; // is there an PeriodicEvent?
|
||||
Free_Work_Mode = true; // Free(WorkModeData)
|
||||
InitPeriodicEvent = true; // need to create a WorkModeData?
|
||||
|
||||
initINSBuf();
|
||||
initDATBuf();
|
||||
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, 0); // HIGH Z MODE // 1: close; 0: open;
|
||||
|
||||
instru.VinADCGainLv = VIN_GAIN_1K;
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
instru.IinADCGainLv = I_GAIN_100R;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
DAC0_W_T(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
|
||||
|
||||
|
||||
AD5940_HWReset();
|
||||
AD5940_Initialize();
|
||||
|
||||
ModeLED(NO_EVENT);
|
||||
CPUdelay(1600);
|
||||
CPUdelay_us(500);
|
||||
}
|
||||
|
||||
static void Eliteinterrupt() {
|
||||
megaStiEnable = false;
|
||||
PeriodicEvent = false; // is there an PeriodicEvent?
|
||||
Free_Work_Mode = true; // Free(WorkModeData)
|
||||
|
||||
initINSBuf();
|
||||
initDATBuf();
|
||||
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, 0); // HIGH Z MODE // 1: close; 0: open;
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
DAC0_W_T(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
|
||||
|
||||
ADC_rxbuf = 0;
|
||||
|
||||
ModeLED(NO_EVENT);
|
||||
CPUdelay(8000);
|
||||
}
|
||||
#endif
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
|
||||
#ifndef ELITE_SPI
|
||||
#define ELITE_SPI
|
||||
|
||||
/*
|
||||
* Read SPI example in
|
||||
* http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/tirtos/2_14_02_22/
|
||||
* exports/tirtos_full_2_14_02_22/docs/doxygen/html/_s_p_i_c_c26_x_x_d_m_a_8h.html
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include <ti/drivers/SPI.h>
|
||||
#include <ti/drivers/dma/UDMACC26XX.h>
|
||||
#include <ti/drivers/spi/SPICC26XXDMA.h>
|
||||
|
||||
#define ELITE_VERSION_EIS
|
||||
|
||||
#ifdef ELITE_VERSION_EIS
|
||||
/* define SPI command */
|
||||
// datasheet page 98
|
||||
//#define SPICMD_SETADDR 0x20
|
||||
//#define SPICMD_WRITEREG 0x2D
|
||||
//#define SPICMD_READREG 0x6D
|
||||
|
||||
//define REG
|
||||
#define LPDACCON0 0x2128
|
||||
#define LPDACSW0 0x2124
|
||||
#define LPDACDAT0 0x2120
|
||||
#define LPREFBUFCON 0x2050
|
||||
#define SWMUX 0x235C
|
||||
#define LPTIASW0 0x20E4
|
||||
#define SWCON 0x200C
|
||||
#define HSDACCON 0x2010
|
||||
#define HSDACDAT 0x2048
|
||||
#define LPTIACON0 0x20EC
|
||||
#define HSTIACON 0x20FC
|
||||
#define AFECON 0x2000
|
||||
#define DSWFULLCON 0x2150
|
||||
#define NSWFULLCON 0x2154
|
||||
#define PSWFULLCON 0x2158
|
||||
#define TSWFULLCON 0x215C
|
||||
#define WGFCW 0x2030
|
||||
#define WGPHASE 0x2034
|
||||
#define WGOFFSET 0x2038
|
||||
#define WGAMPLITUDE 0x203C
|
||||
#define WGCON 0x2014
|
||||
#define DE0RESCON 0x20F8
|
||||
#define ADCCON 0x21A8
|
||||
#define DFTCON 0x20D0
|
||||
#define ADCFILTERCON 0x2044
|
||||
#define PMBW 0x22F0
|
||||
#define CLKSEL 0x0414
|
||||
#define CLKCON0 0x0408
|
||||
#define CLKCON0KEY 0x0420
|
||||
#define HSOSCCON 0x20BC
|
||||
#define ADCBUFCON 0x238C
|
||||
#define HSRTIACON 0x20F0
|
||||
|
||||
#define DFTREAL 0x2078
|
||||
#define DFTIMAG 0x207C
|
||||
#define ADCDAT 0x2074
|
||||
#define RRR_AFE_STATSCON 0x21C4 /* AFE Statistics Control */
|
||||
|
||||
#endif // ELITE_EIS
|
||||
|
||||
#endif // ELITE_SPI
|
||||
+131
-451
@@ -1,12 +1,10 @@
|
||||
/*=============================================================================
|
||||
= wm.h =
|
||||
=============================================================================*/
|
||||
#ifndef ELITE_WORK_DATA_H
|
||||
#define ELITE_WORK_DATA_H
|
||||
#ifndef ELITE_WORK_DATA
|
||||
#define ELITE_WORK_DATA
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#define CLOCK_ONE_SECOND 10000 // 1s
|
||||
|
||||
#include "EliteInstruction.h"
|
||||
|
||||
@@ -21,62 +19,61 @@ extern "C" {
|
||||
bool _current_direction_up; \
|
||||
uint16_t _cycleNumber
|
||||
|
||||
#define MEAS_CURR(_m) (((struct wm_meas_t *)(_m))->_measureCurrent)
|
||||
#define MEAS_VIN(_m) (((struct wm_meas_t *)(_m))->_measureVin)
|
||||
#define MEAS_VOUT(_m) (((struct wm_meas_t *)(_m))->_measureVout)
|
||||
#define MEAS_BAT(_m) (((struct wm_meas_t *)(_m))->_measureBat)
|
||||
#define VOLT_SW(_m) (((struct wm_meas_t *)(_m))->_VoViSwitch)
|
||||
|
||||
struct wm_meas_t {
|
||||
int32_t _measureCurrent;
|
||||
int32_t _measureVin;
|
||||
int32_t _measureVout;
|
||||
int32_t _measureBat;
|
||||
uint8_t _VoViSwitch;
|
||||
/* member of mode */
|
||||
struct wm_eis_ctx_t {
|
||||
uint32_t _f1;
|
||||
uint32_t _f2;
|
||||
uint32_t _fd1;
|
||||
uint32_t _fd2;
|
||||
uint32_t _fmax;
|
||||
uint32_t _fmin;
|
||||
uint8_t _decades; //num of decades in whole
|
||||
uint16_t _ppd;
|
||||
int8_t _decadeIndex; //index of decade max is 8
|
||||
int16_t _sweepIndex; //index of smaller decade max is 10
|
||||
bool _direction_up;
|
||||
bool _in_reset_flag;
|
||||
uint16_t _amp;
|
||||
};
|
||||
|
||||
struct wm_cf_ctx_t {
|
||||
uint32_t _f1;
|
||||
bool _in_reset_flag;
|
||||
uint16_t _amp;
|
||||
};
|
||||
|
||||
/* member of mode */
|
||||
struct wm_vo_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
int32_t _Vset;
|
||||
int32_t _Vinit;
|
||||
};
|
||||
|
||||
struct wm_it_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
int32_t _Vset;
|
||||
int32_t _Vinit;
|
||||
};
|
||||
|
||||
struct wm_vt_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
};
|
||||
|
||||
struct wm_rt_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
int32_t _Vset;
|
||||
int32_t _Vinit;
|
||||
};
|
||||
|
||||
struct wm_iv_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
VOUT_PARA;
|
||||
};
|
||||
|
||||
struct wm_iv_cy_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
VOUT_PARA;
|
||||
};
|
||||
|
||||
struct wm_cc_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
int32_t _Vmax;
|
||||
int32_t _Vmin;
|
||||
int32_t _Vset;
|
||||
@@ -86,26 +83,23 @@ struct wm_cc_ctx_t {
|
||||
|
||||
struct wm_cv_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
VOUT_PARA;
|
||||
int32_t _LPRtia;
|
||||
};
|
||||
|
||||
struct wm_lsv_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
VOUT_PARA;
|
||||
};
|
||||
|
||||
struct wm_ca_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
int32_t _Vinit;
|
||||
int32_t _Vset;
|
||||
};
|
||||
|
||||
struct wm_pulse_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
int32_t _Vset;
|
||||
int32_t _sti_v1;
|
||||
int32_t _sti_v2;
|
||||
@@ -128,84 +122,11 @@ struct wm_pulse_ctx_t {
|
||||
uint16_t _sti_lp;
|
||||
};
|
||||
|
||||
struct wm_uni_pulse_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
int32_t _Vset;
|
||||
|
||||
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_period;
|
||||
uint32_t _t_pa[4];
|
||||
|
||||
uint32_t _t_pulse_min[4];
|
||||
uint32_t _t_pulse_max[4];
|
||||
};
|
||||
|
||||
struct wm_dpv_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
int32_t _Vset;
|
||||
|
||||
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_period;
|
||||
uint32_t _t_pa[4];
|
||||
int32_t _v_stop;
|
||||
bool _v_curr_direc;
|
||||
int32_t _v_amp;
|
||||
|
||||
uint32_t _t_pulse_min[4];
|
||||
uint32_t _t_pulse_max[4];
|
||||
|
||||
bool _v_direc_init;
|
||||
};
|
||||
|
||||
struct wm_dpv_advance_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
int32_t _Vset;
|
||||
|
||||
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_period;
|
||||
uint32_t _t_pa[4];
|
||||
int32_t _v_stop;
|
||||
int32_t _v_up;
|
||||
int32_t _v_low;
|
||||
int32_t _v_amp;
|
||||
int32_t _v_1;
|
||||
int32_t _v_2;
|
||||
|
||||
uint32_t _t_pulse_min[4];
|
||||
uint32_t _t_pulse_max[4];
|
||||
|
||||
uint16_t _cycleNumber;
|
||||
|
||||
bool _v_curr_direc;
|
||||
bool _v_direc_init;
|
||||
bool _v_invert_option;
|
||||
bool _v_stop_direction;
|
||||
};
|
||||
|
||||
struct wm_ocp_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
};
|
||||
|
||||
int wm_init(void);
|
||||
int wm_init(void); //(void *instr_ctx);
|
||||
int wm_deinit(void);
|
||||
void *wm_get(void);
|
||||
|
||||
@@ -217,22 +138,74 @@ static void *workMode_p = NULL;
|
||||
static bool Free_Work_Mode = false;
|
||||
|
||||
/* init mode func */
|
||||
static int __eis_create(void)
|
||||
{
|
||||
struct wm_eis_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_eis_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
p->_f1 = instru.f1;
|
||||
p->_f2 = instru.f2;
|
||||
p->_fmax = instru.fmax;
|
||||
p->_fmin = instru.fmin;
|
||||
p->_fd1 = 0; //decade freq 1
|
||||
p->_fd2 = 0; //decade freq 2
|
||||
p->_ppd = instru.ppd; //points per decade
|
||||
p->_decades = 0;
|
||||
p->_sweepIndex = 0;
|
||||
p->_decadeIndex = 0;
|
||||
p->_direction_up = true;
|
||||
p->_in_reset_flag = false;
|
||||
p->_amp = instru.acamp;
|
||||
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __cf_create(void)
|
||||
{
|
||||
struct wm_cf_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_cf_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
p->_f1 = instru.f1; //[reg's value]
|
||||
p->_in_reset_flag = false;
|
||||
p->_amp = instru.acamp;
|
||||
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __ca_create(void)
|
||||
{
|
||||
struct wm_ca_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_ca_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
p->_Vinit = (instru.Vinit - 25000) * 4 * 4000; //[5nV]
|
||||
p->_Vset = 0;
|
||||
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __vo_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_vo_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_vo_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vinit = (instru.Vinit - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vset = 0;
|
||||
|
||||
@@ -243,23 +216,12 @@ static int __vo_create(void)
|
||||
|
||||
static int __it_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_it_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_it_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vinit = (instru.Vinit - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vset = 0;
|
||||
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
@@ -267,20 +229,12 @@ static int __it_create(void)
|
||||
|
||||
static int __vt_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_vt_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_vt_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
@@ -288,21 +242,13 @@ static int __vt_create(void)
|
||||
|
||||
static int __rt_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_rt_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_rt_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vinit = (instru.Vinit - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vinit = (instru.Vinit - 25000) * 4 * 4000; //[5nV]
|
||||
p->_Vset = 0;
|
||||
|
||||
*wm = p;
|
||||
@@ -312,23 +258,15 @@ static int __rt_create(void)
|
||||
|
||||
static int __iv_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_iv_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_iv_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vinit = (instru.Vinit - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmax = (instru.Vmax - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmin = (instru.Vmin - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vinit = instru.Vinit; //(instru.Vinit - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmax = instru.Vmax; //(instru.Vmax - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmin = instru.Vmin; //(instru.Vmin - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vset = 0;
|
||||
p->_Vstep = 0;
|
||||
p->_direction_up = true;
|
||||
@@ -342,20 +280,12 @@ static int __iv_create(void)
|
||||
|
||||
static int __iv_cy_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_iv_cy_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_iv_cy_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vinit = (instru.Vinit - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmax = (instru.Vmax - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmin = (instru.Vmin - 25000) * 4 * 10000; //[5nV]
|
||||
@@ -372,20 +302,12 @@ static int __iv_cy_create(void)
|
||||
|
||||
static int __cc_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_cc_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_cc_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vmax = (instru.Vmax - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmin = (instru.Vmin - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vset = 0;
|
||||
@@ -400,23 +322,18 @@ static int __cc_create(void)
|
||||
|
||||
static int __cv_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_cv_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_cv_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vinit = (instru.Vinit - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmax = (instru.Vmax - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmin = (instru.Vmin - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vinit = (instru.Vinit - 25000) * 4 * 4000; //[5nV]
|
||||
p->_Vmax = (instru.Vmax - 25000) * 4 * 4000; //[5nV]
|
||||
p->_Vmin = (instru.Vmin - 25000) * 4 * 4000; //[5nV]
|
||||
// p->_Vinit = (instru.Vinit - 25000) * 4 * 10000; //[5nV]
|
||||
// p->_Vmax = (instru.Vmax - 25000) * 4 * 10000; //[5nV]
|
||||
// p->_Vmin = (instru.Vmin - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vset = 0;
|
||||
p->_Vstep = 0;
|
||||
p->_direction_up = true;
|
||||
@@ -430,20 +347,12 @@ static int __cv_create(void)
|
||||
|
||||
static int __lsv_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_lsv_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_lsv_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vinit = (instru.Vinit - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmax = (instru.Vmax - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmin = (instru.Vmin - 25000) * 4 * 10000; //[5nV]
|
||||
@@ -458,219 +367,34 @@ static int __lsv_create(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __ca_create(void)
|
||||
static int __pulse_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_ca_ctx_t *p;
|
||||
struct wm_pulse_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_ca_ctx_t));
|
||||
p = malloc(sizeof(struct wm_pulse_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vinit = (instru.Vinit - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vset = 0;
|
||||
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __uni_pulse_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_uni_pulse_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
uint32_t pul_acc = 0;
|
||||
int i;
|
||||
|
||||
p = malloc(sizeof(struct wm_uni_pulse_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vset = 0;
|
||||
|
||||
p->_v0 = UC_TO_5NV(instru.v0); //[5nV]
|
||||
|
||||
p->_t_pulse[0] = instru.t_pulse[0];
|
||||
p->_t_pulse[1] = instru.t_pulse[1];
|
||||
p->_t_pulse[2] = instru.t_pulse[2];
|
||||
p->_t_pulse[3] = instru.t_pulse[3];
|
||||
|
||||
p->_v_initial[0] = UC_TO_5NV(instru.v_initial[0]); //[5nv]
|
||||
p->_v_initial[1] = UC_TO_5NV(instru.v_initial[1]); //[5nv]
|
||||
p->_v_initial[2] = UC_TO_5NV(instru.v_initial[2]); //[5nv]
|
||||
p->_v_initial[3] = UC_TO_5NV(instru.v_initial[3]); //[5nv]
|
||||
|
||||
p->_v_slope[0] = instru.v_slope[0];
|
||||
p->_v_slope[1] = instru.v_slope[1];
|
||||
p->_v_slope[2] = instru.v_slope[2];
|
||||
p->_v_slope[3] = instru.v_slope[3];
|
||||
|
||||
p->_v_step[0] = UC_TO_5NV(instru.v_step[0]); //[5nv]
|
||||
p->_v_step[1] = UC_TO_5NV(instru.v_step[1]); //[5nv]
|
||||
p->_v_step[2] = UC_TO_5NV(instru.v_step[2]); //[5nv]
|
||||
p->_v_step[3] = UC_TO_5NV(instru.v_step[3]); //[5nv]
|
||||
|
||||
p->_t_period = 0;
|
||||
|
||||
for (i=0; i<4; i++) {
|
||||
p->_t_pa[i] = pul_acc + p->_t_pulse[i];
|
||||
pul_acc = p->_t_pa[i];
|
||||
p->_t_period += p->_t_pulse[i];
|
||||
}
|
||||
|
||||
instru.period = p->_t_period;
|
||||
|
||||
p->_t_pulse_min[0] = (instru.t_pulse[0] - 100) * instru.t_pulse_min[0] / 100 + 50;
|
||||
p->_t_pulse_min[1] = (instru.t_pulse[1] - 100) * instru.t_pulse_min[1] / 100 + 50;
|
||||
p->_t_pulse_min[2] = (instru.t_pulse[2] - 100) * instru.t_pulse_min[2] / 100 + 50;
|
||||
p->_t_pulse_min[3] = (instru.t_pulse[3] - 100) * instru.t_pulse_min[3] / 100 + 50;
|
||||
|
||||
p->_t_pulse_max[0] = (instru.t_pulse[0] - 100) * instru.t_pulse_max[0] / 100 + 50;
|
||||
p->_t_pulse_max[1] = (instru.t_pulse[1] - 100) * instru.t_pulse_max[1] / 100 + 50;
|
||||
p->_t_pulse_max[2] = (instru.t_pulse[2] - 100) * instru.t_pulse_max[2] / 100 + 50;
|
||||
p->_t_pulse_max[3] = (instru.t_pulse[3] - 100) * instru.t_pulse_max[3] / 100 + 50;
|
||||
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __dpv_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_dpv_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
uint32_t pul_acc = 0;
|
||||
int i;
|
||||
|
||||
p = malloc(sizeof(struct wm_dpv_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vset = 0;
|
||||
|
||||
p->_v0 = instru.v0; //[5nV]
|
||||
p->_v_stop = instru.v_stop; //[5nV]
|
||||
|
||||
p->_t_pulse[0] = instru.t_pulse[0];
|
||||
p->_t_pulse[1] = instru.t_pulse[1];
|
||||
|
||||
p->_v_initial[0] = instru.v_initial[0]; //[5nv]
|
||||
p->_v_initial[1] = instru.v_initial[1]; //[5nv]
|
||||
|
||||
p->_v_slope[0] = instru.v_slope[0];
|
||||
p->_v_slope[1] = instru.v_slope[1];
|
||||
|
||||
p->_v_step[0] = instru.v_step[0]; //[5nv]
|
||||
p->_v_step[1] = instru.v_step[1]; //[5nv]
|
||||
|
||||
p->_t_period = 0;
|
||||
|
||||
for (i=0; i<4; i++) {
|
||||
p->_t_pa[i] = pul_acc + p->_t_pulse[i];
|
||||
pul_acc = p->_t_pa[i];
|
||||
p->_t_period += p->_t_pulse[i];
|
||||
}
|
||||
|
||||
instru.period = p->_t_period;
|
||||
|
||||
p->_v_direc_init = instru.directionInit;
|
||||
p->_v_curr_direc = instru.directionInit;
|
||||
p->_v_amp = instru.v_initial[1] - instru.v_initial[0];
|
||||
|
||||
p->_t_pulse_min[0] = (instru.t_pulse[0] - 100) * instru.t_pulse_min[0] / 100 + 50;
|
||||
p->_t_pulse_min[1] = (instru.t_pulse[1] - 100) * instru.t_pulse_min[1] / 100 + 50;
|
||||
|
||||
p->_t_pulse_max[0] = (instru.t_pulse[0] - 100) * instru.t_pulse_max[0] / 100 + 50;
|
||||
p->_t_pulse_max[1] = (instru.t_pulse[1] - 100) * instru.t_pulse_max[1] / 100 + 50;
|
||||
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __dpv_advance_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_dpv_advance_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
uint32_t pul_acc = 0;
|
||||
int i;
|
||||
|
||||
p = malloc(sizeof(struct wm_dpv_advance_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vset = 0;
|
||||
|
||||
p->_v0 = instru.v0; //[5nV]
|
||||
p->_v_stop = instru.v_stop; //[5nV]
|
||||
|
||||
p->_t_pulse[0] = instru.t_pulse[0];
|
||||
p->_t_pulse[1] = instru.t_pulse[1];
|
||||
|
||||
p->_v_initial[0] = instru.v_initial[0]; //[5nv]
|
||||
p->_v_initial[1] = instru.v_initial[1]; //[5nv]
|
||||
|
||||
p->_v_slope[0] = instru.v_slope[0];
|
||||
p->_v_slope[1] = instru.v_slope[1];
|
||||
|
||||
p->_v_step[0] = instru.v_step[0]; //[5nv]
|
||||
p->_v_step[1] = instru.v_step[1]; //[5nv]
|
||||
|
||||
p->_t_period = 0;
|
||||
|
||||
for (i=0; i<4; i++) {
|
||||
p->_t_pa[i] = pul_acc + p->_t_pulse[i];
|
||||
pul_acc = p->_t_pa[i];
|
||||
p->_t_period += p->_t_pulse[i];
|
||||
}
|
||||
|
||||
instru.period = p->_t_period;
|
||||
|
||||
p->_v_direc_init = instru.directionInit;
|
||||
p->_v_curr_direc = instru.directionInit;
|
||||
p->_v_stop_direction = instru.v_stop_direction;
|
||||
p->_v_up = instru.v_up;
|
||||
p->_v_low = instru.v_low;
|
||||
p->_v_amp = instru.v_initial[1] - instru.v_initial[0];
|
||||
p->_v_1 = instru.v_1;
|
||||
p->_v_2 = instru.v_2;
|
||||
|
||||
p->_t_pulse_min[0] = (instru.t_pulse[0] - 100) * instru.t_pulse_min[0] / 100 + 50;
|
||||
p->_t_pulse_min[1] = (instru.t_pulse[1] - 100) * instru.t_pulse_min[1] / 100 + 50;
|
||||
|
||||
p->_t_pulse_max[0] = (instru.t_pulse[0] - 100) * instru.t_pulse_max[0] / 100 + 50;
|
||||
p->_t_pulse_max[1] = (instru.t_pulse[1] - 100) * instru.t_pulse_max[1] / 100 + 50;
|
||||
|
||||
p->_cycleNumber = instru.cycleNumber;
|
||||
p->_v_invert_option = instru.v_invert_option;
|
||||
p->_sti_v1 = instru.sti_v1;
|
||||
p->_sti_v2 = instru.sti_v2;
|
||||
p->_sti_v3 = instru.sti_v3;
|
||||
p->_sti_v4 = instru.sti_v4;
|
||||
p->_sti_v5 = instru.sti_v5;
|
||||
p->_sti_v6 = instru.sti_v6;
|
||||
p->_sti_v7 = instru.sti_v7;
|
||||
p->_sti_t1 = instru.sti_t1;
|
||||
p->_sti_t2 = instru.sti_t2;
|
||||
p->_sti_t3 = instru.sti_t3;
|
||||
p->_sti_t4 = instru.sti_t4;
|
||||
p->_sti_t5 = instru.sti_t5;
|
||||
p->_sti_t6 = instru.sti_t6;
|
||||
p->_sti_t7 = instru.sti_t7;
|
||||
p->_sti_t = instru.sti_t1;
|
||||
p->_sti_v = instru.sti_v1;
|
||||
p->_sti_t_flag = 1;
|
||||
p->_sti_cy = instru.sti_cy;
|
||||
p->_sti_lp = instru.sti_loop;
|
||||
|
||||
*wm = p;
|
||||
|
||||
@@ -679,20 +403,12 @@ static int __dpv_advance_create(void)
|
||||
|
||||
static int __ocp_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_ocp_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_ocp_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
@@ -706,12 +422,20 @@ int wm_init(void)
|
||||
if (*wm) return -1;
|
||||
|
||||
switch (mode) {
|
||||
case CURVE_VO:
|
||||
if (__vo_create()) return -2;
|
||||
case CURVE_EIS:
|
||||
if (__eis_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_IT:
|
||||
if (__it_create()) return -2;
|
||||
case CURVE_CF:
|
||||
if (__cf_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_CV:
|
||||
if (__cv_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_CA:
|
||||
if (__ca_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_VT:
|
||||
@@ -722,51 +446,10 @@ int wm_init(void)
|
||||
if (__rt_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_IV:
|
||||
if (__iv_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_IV_CY:
|
||||
if (__iv_cy_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_CC:
|
||||
if (__cc_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_CV:
|
||||
if (__cv_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_LSV:
|
||||
if (__lsv_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_CA:
|
||||
if (__ca_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_UNI_PULSE:
|
||||
if (__uni_pulse_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_OCP:
|
||||
if (__ocp_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_DPV:
|
||||
case CURVE_DPV_SMPRATE:
|
||||
if (__dpv_create()) return -2;
|
||||
break;
|
||||
case CURVE_DPV_ADVANCE:
|
||||
case CURVE_DPV_ADVANCE_SMPRATE:
|
||||
if (__dpv_advance_create()) return -2;
|
||||
break;
|
||||
|
||||
default:
|
||||
// printf("DO NOT support!!");
|
||||
return -3;
|
||||
}
|
||||
};
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -792,7 +475,4 @@ void *wm_get(void)
|
||||
return wm;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
-99
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
***********************************************************
|
||||
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;
|
||||
|
||||
ADC_rxbuf = MEASURE_BATTERY();
|
||||
bat_volt = (uint32_t) ADC_rxbuf;
|
||||
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 bool EliteADCBattery(){
|
||||
static uint8_t ADCSwitch = 0;
|
||||
bool read_adc_flag = false;
|
||||
if(ADCSwitch == 0){ /**read V**/
|
||||
ADC_rxbuf = MEASURE_BATTERY();
|
||||
ADCSwitch++;
|
||||
}
|
||||
else if(ADCSwitch == 1){ /**read V**/
|
||||
ADC_rxbuf = MEASURE_BATTERY();
|
||||
ADCSwitch++;
|
||||
}
|
||||
else if(ADCSwitch == 2){ /**read V(buffer)**/
|
||||
headstage_battery_volt();
|
||||
headstage_temperature();
|
||||
ADCSwitch++;
|
||||
read_adc_flag = true;
|
||||
|
||||
}else if(ADCSwitch == 3){
|
||||
batteryCheck_flag = false;
|
||||
tempCheck_flag = false;
|
||||
ADCSwitch = 0;
|
||||
}
|
||||
|
||||
return read_adc_flag;
|
||||
}
|
||||
|
||||
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 = NotifyVoltBat;
|
||||
if( bat < 768 && bat > 20){
|
||||
latch_single_ctrl(E_LATCH_5V_ENABLE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // HEADSTAGE_BATT_H
|
||||
+36
-43
@@ -10,11 +10,7 @@
|
||||
#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
|
||||
|
||||
@@ -31,44 +27,59 @@ enum all_mode_e {
|
||||
CURVE_CV = 0x09, // Cyclic Voltammetry (CV)
|
||||
CURVE_LSV = 0x0A, // Linear Sweep Voltammetry (LSV)
|
||||
CURVE_CA = 0x0B, // Chronoamperometric Graph (CA)
|
||||
CURVE_CP = 0x0C, // Chronopotentiometry (CP)
|
||||
CURVE_UNI_PULSE = 0x0D, // Pulse Sensing (universal pulse)
|
||||
CURVE_DPV = 0x0E, // Differential Pulse Voltammetry (DPV)
|
||||
CURVE_DPV_SMPRATE = 0x0F,
|
||||
CURVE_DPV_ADVANCE = 0x10,
|
||||
CURVE_DPV_ADVANCE = 0x0F,
|
||||
CURVE_DPV_SMPRATE = 0x10,
|
||||
CURVE_DPV_ADVANCE_SMPRATE = 0x11,
|
||||
|
||||
CURVE_CALI_ADC = 0xF1, // Cali ADC - test
|
||||
CURVE_EIS = 0x12,
|
||||
CURVE_CF = 0x13, // Constant Frequency(CF)
|
||||
|
||||
|
||||
CURVE_CALI = 0xF1,
|
||||
////
|
||||
SET_SAMPLE_RATE = 0xE0,
|
||||
SET_ADC_DAC_GAIN = 0xE1,
|
||||
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
|
||||
#define CIS_LED_TEST 0x70
|
||||
#define CIS_CALI 0x30
|
||||
#define CIS_CALI2 0x90
|
||||
|
||||
#define CTL_WRT 0x20
|
||||
#define CTL_RD 0x21
|
||||
#define CTL_RD_DFTR 0x78
|
||||
#define CTL_RD_DFTI 0x7C
|
||||
#define CTL_RD_ADC 0x7A
|
||||
#define CTL_RESET 0x11
|
||||
|
||||
// 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
|
||||
#define PARA_1 0x01
|
||||
#define PARA_2 0x02
|
||||
#define PARA_3 0x03
|
||||
#define PARA_4 0x04
|
||||
#define PARA_5 0x05
|
||||
#define PARA_6 0x06
|
||||
#define PARA_7 0x07
|
||||
#define PARA_8 0x08
|
||||
#define PARA_9 0x09
|
||||
#define PARA_10 0x0A
|
||||
#define PARA_11 0x0B
|
||||
#define PARA_12 0x0C
|
||||
#define PARA_13 0x0D
|
||||
#define PARA_14 0x0E
|
||||
#define PARA_15 0x0F
|
||||
#define PARA_16 0x10
|
||||
#define PARA_17 0x11
|
||||
|
||||
//Elite LED
|
||||
#define COLOR_BLACK 0x00
|
||||
@@ -80,15 +91,8 @@ enum dev_para_e {
|
||||
#define COLOR_CYAN 0x06
|
||||
#define COLOR_MAGENTA 0x07
|
||||
#define COLOR_PURPLE 0x08
|
||||
#define COLOR_WHITE 0x09
|
||||
#define COLOR_WHITE 0x09
|
||||
#define COLOR_YELLOWGREEN 0x0A
|
||||
#define COLOR_EMERALD 0x0B
|
||||
#define COLOR_YELLOW_DARK 0xF3
|
||||
#define COLOR_GREEN_DARK 0xF4
|
||||
#define COLOR_BLUE_DARK 0xF5
|
||||
#define COLOR_CYAN_DARK 0xF6
|
||||
#define COLOR_PURPLE_DARK 0xF8
|
||||
|
||||
|
||||
#define BT_WAIT 0x01
|
||||
#define NO_EVENT 0x02
|
||||
@@ -96,15 +100,4 @@ enum dev_para_e {
|
||||
#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
|
||||
|
||||
+71
-826
@@ -1,906 +1,151 @@
|
||||
#include <math.h>
|
||||
|
||||
#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);
|
||||
DAC0_W_T(DACOutCode);
|
||||
static void freq_out()
|
||||
{
|
||||
DAC_outputF(instru.fset);
|
||||
return;
|
||||
}
|
||||
|
||||
static void vscan_volt_out(void)
|
||||
{
|
||||
void *wm = wm_get();
|
||||
uint16_t DACOutCode;
|
||||
int32_t DeltaVout;
|
||||
int32_t Vin;
|
||||
if (instru.eliteFxn == CURVE_CV) {
|
||||
struct wm_cv_ctx_t *cv = (struct wm_cv_ctx_t *)wm_get();
|
||||
void *wm = wm_get();
|
||||
|
||||
Vin = MEAS_VIN(wm) * 200;//[5nV]
|
||||
/* in [5nV] ver */
|
||||
DAC_outputV(instru.Vset);
|
||||
InputNotify(NOTIFY_VOLT, instru.Vset/200);
|
||||
} else if (instru.eliteFxn == CURVE_CA) {
|
||||
struct wm_ca_ctx_t *ca = (struct wm_ca_ctx_t *)wm_get();
|
||||
|
||||
if (DACReset) {
|
||||
instru.Vout = Vset + Vin;
|
||||
} else {
|
||||
DeltaVout = Vset - (instru.Vout - Vin);
|
||||
instru.Vout = instru.Vout + DeltaVout;
|
||||
void *wm = wm_get();
|
||||
|
||||
/* in [5nV] ver */
|
||||
DAC_outputV(instru.Vset);
|
||||
InputNotify(NOTIFY_VOLT, instru.Vset/200);
|
||||
} else if (instru.eliteFxn == CURVE_RT) {
|
||||
struct wm_rt_ctx_t *rt = (struct wm_rt_ctx_t *)wm_get();
|
||||
|
||||
void *wm = wm_get();
|
||||
|
||||
/* in [5nV] ver */
|
||||
DAC_outputV(instru.Vset);
|
||||
InputNotify(NOTIFY_VOLT, instru.Vset/200);
|
||||
}
|
||||
|
||||
instru.VoltConstant = instru.Vout / 40000 + 25000;//5nV=>usercode
|
||||
DACOutCode = Usercode_Correction_to_DAC(instru.VoutGainLv, instru.VoltConstant);
|
||||
DAC0_W_T(DACOutCode);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void CalcuResistance()
|
||||
|
||||
|
||||
static int32_t neg_18bit(int32_t ret)
|
||||
{
|
||||
/* Elite 100000 = 100R
|
||||
Elite 1000000 = 1KR
|
||||
Elite 10000000 = 10KR
|
||||
Elite 100000000 = 100KR
|
||||
Elite 1000000000 = 1MR
|
||||
*/
|
||||
// if (ret > 131072) {
|
||||
// ret = ret - 262144;
|
||||
// }
|
||||
ret &= 0x3FFFF;
|
||||
if (ret & (1 << 17)) {
|
||||
ret |= 0xFFFC0000;
|
||||
}
|
||||
|
||||
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);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void DACenable(uint8_t afterRead){
|
||||
//////EIS PLOT RELATED FUNCTION END//////
|
||||
|
||||
|
||||
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();
|
||||
case CURVE_EIS:
|
||||
case CURVE_CF:
|
||||
freq_out();
|
||||
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:{
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_MAGENTA);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* define how long damping time for manual current stalls, to skip damping time
|
||||
* any level switch to 0 level has 80ms damping time
|
||||
* any level switch to 1 level has 20ms damping time
|
||||
* any level switch to 2 level has 10ms damping time
|
||||
* any level switch to 3 level has 10ms damping time
|
||||
*/
|
||||
#define CNT_TO_I_GAIN_3M_IIN_VIN_VOUT_PLOT 7 // 7 * 12ms = 84ms
|
||||
#define CNT_TO_I_GAIN_100K_IIN_VIN_VOUT_PLOT 2 // 2 * 12ms = 24ms
|
||||
#define CNT_TO_I_GAIN_3K_IIN_VIN_VOUT_PLOT 5 // 5 * 12ms = 60ms
|
||||
#define CNT_TO_I_GAIN_100R_IIN_VIN_VOUT_PLOT 5 // 5 * 12ms = 60ms
|
||||
|
||||
#define CNT_TO_I_GAIN_3M_IIN_VIN_PLOT 10 // 10 * 8ms = 80ms
|
||||
#define CNT_TO_I_GAIN_100K_IIN_VIN_PLOT 3 // 3 * 8ms = 24ms
|
||||
#define CNT_TO_I_GAIN_3K_IIN_VIN_PLOT 5 // 5 * 8ms = 40ms
|
||||
#define CNT_TO_I_GAIN_100R_IIN_VIN_PLOT 5 // 5 * 8ms = 40ms
|
||||
|
||||
#define CNT_TO_I_GAIN_3M_IT_PLOT 20 // 20 * 4ms = 80ms
|
||||
#define CNT_TO_I_GAIN_100K_IT_PLOT 5 // 5 * 4ms = 20ms
|
||||
#define CNT_TO_I_GAIN_3K_IT_PLOT 5 // 5 * 4ms = 20ms
|
||||
#define CNT_TO_I_GAIN_100R_IT_PLOT 5 // 5 * 4ms = 20ms
|
||||
|
||||
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;
|
||||
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
MEAS_CURR(wm) = DecodeADCValue(instru.IinADCGainLv, RIS_ADC_IIN, ADC_rxbuf);
|
||||
|
||||
if (instru.IinADCAutoGainEn) {
|
||||
AutoGainChangeIin(MEAS_CURR(wm), plot, &no_rec_time);
|
||||
|
||||
} else {
|
||||
if (lastIinADCGainLevel != instru.IinADCGainLv) {
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
|
||||
if (plot_type == IT_PLOT) {
|
||||
if (instru.IinADCGainLv == I_GAIN_3K) {
|
||||
no_rec_time = CNT_TO_I_GAIN_3K_IT_PLOT;
|
||||
} else if (instru.IinADCGainLv == I_GAIN_100K) {
|
||||
no_rec_time = CNT_TO_I_GAIN_100K_IT_PLOT;
|
||||
} else if (instru.IinADCGainLv == I_GAIN_3M) {
|
||||
no_rec_time = CNT_TO_I_GAIN_3M_IT_PLOT;
|
||||
} else {
|
||||
no_rec_time = CNT_TO_I_GAIN_100R_IT_PLOT;
|
||||
}
|
||||
}
|
||||
|
||||
if (plot_type == IIN_VIN_PLOT) {
|
||||
if (instru.IinADCGainLv == I_GAIN_3K) {
|
||||
no_rec_time = CNT_TO_I_GAIN_3K_IIN_VIN_PLOT;
|
||||
} else if (instru.IinADCGainLv == I_GAIN_100K) {
|
||||
no_rec_time = CNT_TO_I_GAIN_100K_IIN_VIN_PLOT;
|
||||
} else if (instru.IinADCGainLv == I_GAIN_3M) {
|
||||
no_rec_time = CNT_TO_I_GAIN_3M_IIN_VIN_PLOT;
|
||||
} else {
|
||||
no_rec_time = CNT_TO_I_GAIN_100R_IIN_VIN_PLOT;
|
||||
}
|
||||
}
|
||||
|
||||
if (plot_type == IIN_VIN_VOUT_PLOT) {
|
||||
if (instru.IinADCGainLv == I_GAIN_3K) {
|
||||
no_rec_time = CNT_TO_I_GAIN_3K_IIN_VIN_VOUT_PLOT;
|
||||
} else if (instru.IinADCGainLv == I_GAIN_100K) {
|
||||
no_rec_time = CNT_TO_I_GAIN_100K_IIN_VIN_VOUT_PLOT;
|
||||
} else if (instru.IinADCGainLv == I_GAIN_3M) {
|
||||
no_rec_time = CNT_TO_I_GAIN_3M_IIN_VIN_VOUT_PLOT;
|
||||
} else {
|
||||
no_rec_time = CNT_TO_I_GAIN_100R_IIN_VIN_VOUT_PLOT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 void LPTIA_change_gain(void)
|
||||
{
|
||||
static uint8_t rec_cnt = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
if (instru.IinADCAutoGainEn > 1)
|
||||
if (instru.LPTIAAutoGainEnable > 1)
|
||||
return;
|
||||
|
||||
/* read Vin and do NOT record the Vin after changing gain twice */
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
MEAS_VIN(wm) = DecodeADCValue(instru.VinADCGainLv, RIS_ADC_VIN, ADC_rxbuf);
|
||||
if (instru.VinADCAutoGainEn) {
|
||||
AutoGainChangeVin(MEAS_VIN(wm));
|
||||
/* read Iin and do NOT record the Iin after changing gain twice */
|
||||
int32_t i;
|
||||
i = read_LPTIA_Iin();
|
||||
if (instru.LPTIAAutoGainEnable) {
|
||||
AutoChangeLPTIAGain(i);
|
||||
} else {
|
||||
if (lastVinADCGainLv != instru.VinADCGainLv) {
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
if (last_gain_lptia != instru.gain_lv_lptia) {
|
||||
LPTIAGainCtrl(instru.gain_lv_lptia);
|
||||
}
|
||||
}
|
||||
|
||||
if (volt_rec_en == false) {
|
||||
if (record_flag == false) {
|
||||
rec_cnt++;
|
||||
}
|
||||
|
||||
if (rec_cnt == 2) {
|
||||
volt_rec_en = true;
|
||||
record_flag = true;
|
||||
rec_cnt = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void read_Vout_change_gain(void)
|
||||
static void HSTIA_change_gain(void)
|
||||
{
|
||||
static uint8_t rec_cnt = 0;
|
||||
// static uint8_t rec_cnt = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
/* read Vout and do NOT record the Vout after changing gain twice */
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
MEAS_VOUT(wm) = DecodeADCValue(0, RIS_ADC_VOUT, ADC_rxbuf);
|
||||
|
||||
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;
|
||||
if (instru.HSTIAAutoGainEnable > 1)
|
||||
return;
|
||||
|
||||
/* read Iin and do NOT record the Iin after changing gain twice */
|
||||
int32_t i;
|
||||
i = read_HSTIA_Iin();
|
||||
if (instru.HSTIAAutoGainEnable) {
|
||||
AutoChangeHSTIAGain(i);
|
||||
} else {
|
||||
curr_avg = curr_sum / cnt;
|
||||
if (cnt == 0) {
|
||||
|
||||
return;
|
||||
if (last_gain_hstia != instru.gain_lv_hstia) {
|
||||
HSTIAGainCtrl(instru.gain_lv_hstia);
|
||||
}
|
||||
|
||||
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;
|
||||
bool read_adc_flag = false;
|
||||
|
||||
/* the time for measuring battery */
|
||||
if (batteryCheck_flag && tempCheck_flag) {
|
||||
read_adc_flag = EliteADCBattery();
|
||||
if (!read_adc_flag) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
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) {
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 2) {
|
||||
read_Vin_change_gain();
|
||||
DACenable(AFTER_READ_V);
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 3) {
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 4) {
|
||||
read_Vout_change_gain();
|
||||
DACenable(AFTER_READ_V);
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 5) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
ADC_cnt = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void Iin_Vin_Plot(void)
|
||||
{
|
||||
static uint8_t ADC_cnt = 0;
|
||||
void *wm = wm_get();
|
||||
bool read_adc_flag = false;
|
||||
|
||||
/* the time for measuring battery */
|
||||
if (batteryCheck_flag && tempCheck_flag) {
|
||||
read_adc_flag = EliteADCBattery();
|
||||
if (!read_adc_flag) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
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) {
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 2) {
|
||||
read_Vin_change_gain();
|
||||
DACenable(AFTER_READ_V);
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 3) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
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;
|
||||
bool read_adc_flag = false;
|
||||
|
||||
/* measure battery if needs */
|
||||
batteryCheck_flag = false;
|
||||
tempCheck_flag = false;
|
||||
|
||||
if (batteryCheck_flag || tempCheck_flag) {
|
||||
read_adc_flag = EliteADCBattery();
|
||||
if (!read_adc_flag) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
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) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
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) {
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
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) {
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
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) {
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
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) {
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
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 {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
MEAS_CURR(wm) = (int32_t) ADC_rxbuf;
|
||||
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) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
ADC_cnt++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ADC_cnt == 2) {
|
||||
ADC_rxbuf = MEASURE_CURRENT();
|
||||
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 {
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
MEAS_VIN(wm) = (int32_t) ADC_rxbuf;
|
||||
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) {
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
ADC_cnt++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ADC_cnt == 2) {
|
||||
ADC_rxbuf = MEASURE_VOLT();
|
||||
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) {
|
||||
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
MEAS_VOUT(wm) = (int32_t) ADC_rxbuf;
|
||||
|
||||
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) {
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
ADC_cnt++;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ADC_cnt == 2) {
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
ADC_cnt = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+8
-13
@@ -1,15 +1,10 @@
|
||||
#ifndef VERSION_DATE
|
||||
#define VERSION_DATE
|
||||
|
||||
#ifndef VERSION_DATE
|
||||
#define VERSION_DATE
|
||||
|
||||
#define VERSION_DATE_YEAR 22
|
||||
#define VERSION_DATE_MONTH 8
|
||||
#define VERSION_DATE_DAY 2
|
||||
#define VERSION_DATE_HOUR 11
|
||||
#define VERSION_DATE_MINUTE 33
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
#define VERSION_HASH 8808490caa465cc94d14896de28763a5e5c4672b
|
||||
#define VERSION_GIT_BRANCH Elite_OBJ_0.2mv
|
||||
#define VERSION_DATE_YEAR 23
|
||||
#define VERSION_DATE_MONTH 4
|
||||
#define VERSION_DATE_DAY 21
|
||||
#define VERSION_DATE_HOUR 14
|
||||
#define VERSION_DATE_MINUTE 33
|
||||
#endif
|
||||
|
||||
|
||||
+712
@@ -0,0 +1,712 @@
|
||||
#include "eis_cali_table.h"
|
||||
|
||||
#define CALI_SIZE BLE_CIS_BUFF_SIZE
|
||||
|
||||
uint8_t check_sum(uint8_t message[], int nBytes)
|
||||
{
|
||||
uint8_t sum = 0;
|
||||
|
||||
while (nBytes-- > 0) {
|
||||
sum += *(message++);
|
||||
}
|
||||
|
||||
return sum;
|
||||
|
||||
}
|
||||
|
||||
static void send_cali_version(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
|
||||
ctx[index++] = len-1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
ctx[index++] = (uint8_t)(CALI_VERSION >> 8);
|
||||
ctx[index++] = (uint8_t)(CALI_VERSION);
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain0_hstia(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].hstia_a >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].hstia_a >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].hstia_a >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].hstia_a);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].hstia_b >> 56);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].hstia_b >> 48);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].hstia_b >> 40);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].hstia_b >> 32);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].hstia_b >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].hstia_b >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].hstia_b >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].hstia_b);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].rolloff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].rolloff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].rolloff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[0][0].rolloff);
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain0_phase_freq0_freq1(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 0;
|
||||
uint8_t freq_lv_to = 1;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].coeff);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain0_phase_freq2_freq3(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 2;
|
||||
uint8_t freq_lv_to = 3;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].coeff);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[0][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain1_hstia(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].hstia_a >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].hstia_a >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].hstia_a >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].hstia_a);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].hstia_b >> 56);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].hstia_b >> 48);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].hstia_b >> 40);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].hstia_b >> 32);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].hstia_b >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].hstia_b >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].hstia_b >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].hstia_b);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].rolloff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].rolloff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].rolloff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[1][0].rolloff);
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain1_phase_freq0_freq1(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 0;
|
||||
uint8_t freq_lv_to = 1;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].coeff);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain1_phase_freq2_freq3(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 2;
|
||||
uint8_t freq_lv_to = 3;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].coeff);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[1][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain2_hstia(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].hstia_a >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].hstia_a >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].hstia_a >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].hstia_a);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].hstia_b >> 56);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].hstia_b >> 48);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].hstia_b >> 40);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].hstia_b >> 32);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].hstia_b >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].hstia_b >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].hstia_b >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].hstia_b);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].rolloff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].rolloff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].rolloff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[2][0].rolloff);
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain2_phase_freq0_freq1(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 0;
|
||||
uint8_t freq_lv_to = 1;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[2][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[2][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[2][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[2][i].coeff);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[2][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[2][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[2][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[2][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain2_phase_freq2_freq3(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 2;
|
||||
uint8_t freq_lv_to = 3;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t) (CaliTable.phase[2][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t) (CaliTable.phase[2][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t) (CaliTable.phase[2][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t) (CaliTable.phase[2][i].coeff);
|
||||
ctx[index++] = (uint8_t) (CaliTable.phase[2][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t) (CaliTable.phase[2][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t) (CaliTable.phase[2][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t) (CaliTable.phase[2][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain3_hstia(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].hstia_a >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].hstia_a >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].hstia_a >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].hstia_a);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].hstia_b >> 56);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].hstia_b >> 48);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].hstia_b >> 40);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].hstia_b >> 32);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].hstia_b >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].hstia_b >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].hstia_b >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].hstia_b);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].rolloff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].rolloff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].rolloff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[3][0].rolloff);
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain3_phase_freq0_freq1(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 0;
|
||||
uint8_t freq_lv_to = 1;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].coeff);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain3_phase_freq2_freq3(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 2;
|
||||
uint8_t freq_lv_to = 3;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].coeff);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[3][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain4_hstia(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].hstia_a >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].hstia_a >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].hstia_a >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].hstia_a);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].hstia_b >> 56);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].hstia_b >> 48);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].hstia_b >> 40);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].hstia_b >> 32);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].hstia_b >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].hstia_b >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].hstia_b >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].hstia_b);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].rolloff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].rolloff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].rolloff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[4][0].rolloff);
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain4_phase_freq0_freq1(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 0;
|
||||
uint8_t freq_lv_to = 1;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].coeff);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain4_phase_freq2_freq3(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 2;
|
||||
uint8_t freq_lv_to = 3;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].coeff);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[4][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain5_hstia(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].hstia_a >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].hstia_a >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].hstia_a >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].hstia_a);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].hstia_b >> 56);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].hstia_b >> 48);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].hstia_b >> 40);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].hstia_b >> 32);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].hstia_b >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].hstia_b >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].hstia_b >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].hstia_b);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].rolloff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].rolloff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].rolloff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[5][0].rolloff);
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain5_phase_freq0_freq1(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 0;
|
||||
uint8_t freq_lv_to = 1;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].coeff);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain5_phase_freq2_freq3(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 2;
|
||||
uint8_t freq_lv_to = 3;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].coeff);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[5][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain6_hstia(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].hstia_a >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].hstia_a >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].hstia_a >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].hstia_a);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].hstia_b >> 56);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].hstia_b >> 48);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].hstia_b >> 40);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].hstia_b >> 32);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].hstia_b >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].hstia_b >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].hstia_b >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].hstia_b);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].rolloff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].rolloff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].rolloff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[6][0].rolloff);
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain6_phase_freq0_freq1(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 0;
|
||||
uint8_t freq_lv_to = 1;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].coeff);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain6_phase_freq2_freq3(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 2;
|
||||
uint8_t freq_lv_to = 3;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].coeff);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[6][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain7_hstia(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].hstia_a >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].hstia_a >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].hstia_a >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].hstia_a);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].hstia_b >> 56);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].hstia_b >> 48);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].hstia_b >> 40);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].hstia_b >> 32);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].hstia_b >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].hstia_b >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].hstia_b >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].hstia_b);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].rolloff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].rolloff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].rolloff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.hstia_current[7][0].rolloff);
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain7_phase_freq0_freq1(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 0;
|
||||
uint8_t freq_lv_to = 1;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].coeff);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void send_cali_gain7_phase_freq2_freq3(void)
|
||||
{
|
||||
uint8_t len = CALI_SIZE;
|
||||
uint8_t ctx[CALI_SIZE] = {0};
|
||||
uint8_t index = 0;
|
||||
uint8_t freq_lv_from = 2;
|
||||
uint8_t freq_lv_to = 3;
|
||||
|
||||
ctx[index++] = len - 1;
|
||||
ctx[index++] = instru.chip_id;
|
||||
for (int i=freq_lv_from; i<=freq_lv_to; i++) {
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].coeff >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].coeff >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].coeff >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].coeff);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].offset >> 24);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].offset >> 16);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].offset >> 8);
|
||||
ctx[index++] = (uint8_t)(CaliTable.phase[7][i].offset);
|
||||
}
|
||||
ctx[len-1] = check_sum(ctx, len);
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, CALI_SIZE, ctx);
|
||||
|
||||
return;
|
||||
}
|
||||
+8813
File diff suppressed because it is too large
Load Diff
+495
-1283
File diff suppressed because it is too large
Load Diff
+209
-584
@@ -19,311 +19,30 @@
|
||||
// header
|
||||
#include "EliteWorkData.h"
|
||||
|
||||
static bool vscan_flag;
|
||||
static bool ADC_flag;
|
||||
static bool notifyFirst_flag;
|
||||
static bool leadTimeReset;
|
||||
static bool firstTimeReset;
|
||||
static bool fset_flag;
|
||||
|
||||
static void device_init(void)
|
||||
{
|
||||
gpio_create();
|
||||
InitEliteInstruction();
|
||||
static void vscan_ctrl(void);
|
||||
|
||||
update_latch_stat(E_LATCH_CS_MEM, 1);
|
||||
update_latch_stat(E_LATCH_CS_ADC, 1);
|
||||
update_latch_stat(E_LATCH_CS_DAC, 1);
|
||||
update_latch_stat(E_LATCH_OFF, 1); // E_LATCH_OFF = 1 => turn off 6994
|
||||
latch_multi_ctrl();
|
||||
|
||||
/* when elite open, must change vin level,
|
||||
measure battery value will be right */
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
DAC0_W_T(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
|
||||
|
||||
elite_gptimer_open();
|
||||
InitGPT();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#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) \
|
||||
#define IsPeriodicMode() ( \
|
||||
instru.eliteFxn == CURVE_EIS || \
|
||||
instru.eliteFxn == CURVE_CF || \
|
||||
instru.eliteFxn == CURVE_CV || \
|
||||
instru.eliteFxn == CURVE_CA || \
|
||||
instru.eliteFxn == CURVE_VT || \
|
||||
instru.eliteFxn == CURVE_RT \
|
||||
)
|
||||
|
||||
#define Ve1MatchVe2Mode() ( \
|
||||
(instru.eliteFxn == CURVE_IV) || \
|
||||
(instru.eliteFxn == CURVE_IV_CY) || \
|
||||
(instru.eliteFxn == CURVE_CV) || \
|
||||
(instru.eliteFxn == CURVE_LSV) \
|
||||
(instru.eliteFxn == CURVE_EIS) || \
|
||||
(instru.eliteFxn == CURVE_CF) || \
|
||||
(instru.eliteFxn == CURVE_CV) \
|
||||
)
|
||||
|
||||
static void peri_mode(void)
|
||||
{
|
||||
|
||||
|
||||
GPT.cnt_lead_time = GPT.cnt_lead_time + GPT.cnt_gpt_delta;
|
||||
if (leadTimeReset && GPT.cnt_lead_time <= 2000) {
|
||||
vscanReset = true;
|
||||
if (first_highz_flag && GPT.cnt_lead_time >= 1000) {
|
||||
if (instru.eliteFxn == CURVE_OCP) {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
|
||||
} else {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
|
||||
}
|
||||
first_highz_flag = false;
|
||||
}
|
||||
} else {
|
||||
if (notifyFirst_flag) {
|
||||
GPT.cnt_notify_rate = instru.notifyRate - 20;
|
||||
notifyFirst_flag = false;
|
||||
}
|
||||
vscanReset = false;
|
||||
leadTimeReset = false;
|
||||
}
|
||||
|
||||
//vscan counter
|
||||
GPT.cnt_v_scan_rate = GPT.cnt_v_scan_rate + GPT.cnt_gpt_delta;
|
||||
if (GPT.cnt_v_scan_rate >= instru.VsetRate) {
|
||||
if (GPT.cnt_v_scan_rate >= instru.VsetRate * 2) {
|
||||
GPT.GptimerMultiple = GPT.cnt_v_scan_rate / instru.VsetRate;
|
||||
} else {
|
||||
GPT.GptimerMultiple = 1;
|
||||
}
|
||||
GPT.cnt_v_scan_rate -= instru.VsetRate * GPT.GptimerMultiple; //To get right time
|
||||
vscan_ctrl(0);
|
||||
}
|
||||
|
||||
//battery counter
|
||||
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.cnt_gpt_delta;
|
||||
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.cnt_gpt_delta;
|
||||
if(GPT.BatteryCheckCounter >= 50000){
|
||||
GPT.BatteryCheckCounter -= 50000; //To get right time
|
||||
batteryCheck_flag = true;
|
||||
tempCheck_flag = true;
|
||||
if ((instru.eliteFxn == CURVE_IV) ||
|
||||
(instru.eliteFxn == CURVE_IV_CY) ||
|
||||
(instru.eliteFxn == CURVE_CC) ||
|
||||
(instru.eliteFxn == CURVE_CV) ||
|
||||
(instru.eliteFxn == CURVE_LSV) ||
|
||||
(instru.eliteFxn == CURVE_CA) ||
|
||||
(instru.eliteFxn == CURVE_OCP) ||
|
||||
(instru.eliteFxn == CURVE_UNI_PULSE) ||
|
||||
(instru.eliteFxn == CURVE_DPV) ||
|
||||
(instru.eliteFxn == CURVE_DPV_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_CALI_ADC)) {
|
||||
batteryCheck_flag = false;
|
||||
tempCheck_flag = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t bat = NotifyVoltBat;
|
||||
if( bat < 768 && bat > 20){
|
||||
// latch_single_ctrl(E_LATCH_5V_ENABLE, 0);
|
||||
}
|
||||
|
||||
//ADC counter
|
||||
GPT.cnt_adc_rate = GPT.cnt_adc_rate + GPT.cnt_gpt_delta;
|
||||
if(GPT.cnt_adc_rate >= instru.sampleRate){
|
||||
GPT.cnt_adc_rate = 0; //To get right data, ADC must be delay 1.5ms
|
||||
EliteADCControl(0);
|
||||
}
|
||||
|
||||
// Over temperature protection
|
||||
uint16_t CC2650temp = NotifyTemperature;
|
||||
if(CC2650temp > 40) {
|
||||
latch_single_ctrl(E_LATCH_5V_ENABLE, 0);
|
||||
}
|
||||
|
||||
//Notify counter(Notify control, check if we need to send notify)
|
||||
//please don't put Notify counter before ADC counter, maybe get wrong data
|
||||
GPT.cnt_notify_rate = GPT.cnt_notify_rate + GPT.cnt_gpt_delta;
|
||||
if(GPT.cnt_notify_rate >= instru.notifyRate){
|
||||
GPT.cnt_notify_rate -= instru.notifyRate; //To get right time
|
||||
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.cnt_lead_time = GPT.cnt_lead_time + GPT.cnt_gpt_delta;
|
||||
if (leadTimeReset && GPT.cnt_lead_time <= 2000) {
|
||||
vscanReset = true;
|
||||
GPT.cnt_v_scan_rate = 0xFFFFFFFF;
|
||||
dpv_step_cnt = 0;
|
||||
if (first_highz_flag && GPT.cnt_lead_time >= 1000) {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
|
||||
first_highz_flag = false;
|
||||
}
|
||||
} else {
|
||||
if (notifyFirst_flag) {
|
||||
GPT.cnt_notify_rate = instru.notifyRate - 20;
|
||||
notifyFirst_flag = false;
|
||||
}
|
||||
if (vscanReset) {
|
||||
GPT.cnt_v_scan_rate = 0xFFFFFFFF;
|
||||
dpv_step_cnt = 0;
|
||||
}
|
||||
vscanReset = false;
|
||||
leadTimeReset = false;
|
||||
}
|
||||
|
||||
//vscan counter
|
||||
GPT.cnt_v_scan_rate = GPT.cnt_v_scan_rate + GPT.cnt_gpt_delta;
|
||||
if (GPT.cnt_v_scan_rate >= instru.period) {
|
||||
GPT.cnt_v_scan_rate -= instru.period; //To get right time
|
||||
dpv_step_cnt +=1;
|
||||
}
|
||||
vscan_ctrl(GPT.cnt_v_scan_rate);
|
||||
|
||||
//battery counter
|
||||
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.cnt_gpt_delta;
|
||||
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.cnt_gpt_delta;
|
||||
if(GPT.BatteryCheckCounter >= 50000){
|
||||
GPT.BatteryCheckCounter -= 50000; //To get right time
|
||||
batteryCheck_flag = true;
|
||||
tempCheck_flag = true;
|
||||
|
||||
if ((instru.eliteFxn == CURVE_IV) ||
|
||||
(instru.eliteFxn == CURVE_IV_CY) ||
|
||||
(instru.eliteFxn == CURVE_CC) ||
|
||||
(instru.eliteFxn == CURVE_CV) ||
|
||||
(instru.eliteFxn == CURVE_LSV) ||
|
||||
(instru.eliteFxn == CURVE_CA) ||
|
||||
(instru.eliteFxn == CURVE_OCP) ||
|
||||
(instru.eliteFxn == CURVE_UNI_PULSE) ||
|
||||
(instru.eliteFxn == CURVE_DPV) ||
|
||||
(instru.eliteFxn == CURVE_DPV_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_CALI_ADC)) {
|
||||
batteryCheck_flag = false;
|
||||
tempCheck_flag = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//ADC counter
|
||||
GPT.cnt_adc_rate = GPT.cnt_adc_rate + GPT.cnt_gpt_delta;
|
||||
if(GPT.cnt_adc_rate >= instru.sampleRate){
|
||||
GPT.cnt_adc_rate = 0; //To get right data, ADC must be delay 1.5ms
|
||||
EliteADCControl(GPT.cnt_v_scan_rate);
|
||||
}
|
||||
|
||||
uint16_t bat = NotifyVoltBat;
|
||||
if( bat < 768 && bat > 20){
|
||||
// latch_single_ctrl(E_LATCH_5V_ENABLE, 0);
|
||||
}
|
||||
|
||||
// Over temperature protection
|
||||
uint16_t CC2650temp = NotifyTemperature;
|
||||
if(CC2650temp > 40) {
|
||||
latch_single_ctrl(E_LATCH_5V_ENABLE, 0);
|
||||
}
|
||||
|
||||
if (instru.eliteFxn == CURVE_DPV || instru.eliteFxn == CURVE_DPV_ADVANCE) {
|
||||
|
||||
} else {
|
||||
//Notify counter(Notify control, check if we need to send notify)
|
||||
//please don't put Notify counter before ADC counter, maybe get wrong data
|
||||
GPT.cnt_notify_rate = GPT.cnt_notify_rate + GPT.cnt_gpt_delta;
|
||||
if(GPT.cnt_notify_rate >= instru.notifyRate){
|
||||
GPT.cnt_notify_rate -= instru.notifyRate; //To get right time
|
||||
notify_flag = true;
|
||||
if (instru.eliteFxn == CURVE_UNI_PULSE) {
|
||||
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;
|
||||
}
|
||||
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
|
||||
if (Ve1MatchVe2Mode()) {
|
||||
if (instru.Ve1 == instru.Ve2) {
|
||||
DAC0_W_T(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
|
||||
PeriodicEvent = false;
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, 0); // 0: open highz;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SimpleBLEPeripheral_performPeriodicTask
|
||||
*
|
||||
@@ -333,231 +52,203 @@ static void mode_init_set(void)
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
static void elite_task(void)
|
||||
static void elite_task()
|
||||
{
|
||||
// GPT_timerIncrement();
|
||||
|
||||
if (IsPeriodicMode()) {
|
||||
if (mode_init) {
|
||||
mode_init = false;
|
||||
mode_init_set();
|
||||
InitGPT();
|
||||
GPT.cnt_adc_rate = instru.sampleRate - 10;
|
||||
GPT.cnt_v_scan_rate = instru.VsetRate - 1;
|
||||
if((instru.eliteFxn == CURVE_EIS) || (instru.eliteFxn == CURVE_CF)){
|
||||
|
||||
if (mode_init){
|
||||
GPT.cnt_adc_rate = 0;
|
||||
mode_init = false;
|
||||
gainChange_flag = false;
|
||||
firstFreq_flag = true;
|
||||
fset_flag = true;
|
||||
fout_flag = true;
|
||||
firstTimeReset = true;
|
||||
notifyFirst_flag = true;
|
||||
DACReset = true;
|
||||
vscanReset = true;
|
||||
leadTimeReset = true;
|
||||
|
||||
if ((instru.f1 == instru.f2) && (instru.eliteFxn == CURVE_EIS)) {
|
||||
DAC_outputF(instru.f1);
|
||||
PeriodicEvent = false;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
|
||||
SetEISHIGHZ(1);
|
||||
InitGPT();
|
||||
}
|
||||
|
||||
//vscan counter //fset counter
|
||||
if (fset_flag) {
|
||||
vscan_ctrl(); //set
|
||||
fset_flag = false;
|
||||
fout_flag = true;
|
||||
}
|
||||
|
||||
//ADC counter
|
||||
GPT.cnt_adc_rate = GPT.cnt_adc_rate + GPT.cnt_gpt_delta;
|
||||
if(GPT.cnt_adc_rate >= instru.sampleRate){
|
||||
GPT.cnt_adc_rate = 0; //To get right data, ADC must be delay 1.5ms
|
||||
ADC_flag = true;
|
||||
if(ADC_flag){
|
||||
EliteADCControl(); //read data
|
||||
ADC_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Notify counter(Notify control, check if we need to send notify)
|
||||
//please don't put Notify counter before ADC counter, maybe get wrong data
|
||||
if(vscanReset){
|
||||
notify_flag = false;
|
||||
}
|
||||
if(notify_flag){
|
||||
SendNotify(); //send
|
||||
notify_flag = false;
|
||||
fset_flag = true;
|
||||
}
|
||||
|
||||
mode_done(); //finishMode = 1, SendNotify(), reset()
|
||||
} else {
|
||||
/** Periodic Event **/
|
||||
// Default working flow is vscan -> ADC read -> send notify
|
||||
// We will need a flag to control vscan, ADC and notify
|
||||
|
||||
static bool first_highz_flag = false;
|
||||
|
||||
if (mode_init) {
|
||||
GPT.cnt_adc_rate = instru.sampleRate - 10;
|
||||
GPT.cnt_v_scan_rate = instru.VsetRate - 1;
|
||||
mode_init = false;
|
||||
batteryADC_flag = false;
|
||||
record_flag = true;
|
||||
fset_flag = true;
|
||||
firstTimeReset = true;
|
||||
notifyFirst_flag = true;
|
||||
first_highz_flag = true;
|
||||
I_GAIN_100R_counter = 0;
|
||||
I_GAIN_3K_counter = 0;
|
||||
I_GAIN_100K_counter = 0;
|
||||
I_GAIN_3M_counter = 0;
|
||||
VIN_GAIN_1M_counter = 0;
|
||||
VIN_GAIN_30K_counter = 0;
|
||||
VIN_GAIN_1K_counter = 0;
|
||||
VOUT_GAIN_240K_counter = 0;
|
||||
VOUT_GAIN_15K_counter = 0;
|
||||
DACReset = true;
|
||||
vscanReset = true;
|
||||
leadTimeReset = true;
|
||||
|
||||
if (Ve1MatchVe2Mode()) {
|
||||
if (instru.Ve1 == instru.Ve2) {
|
||||
DAC_outputV(instru.Ve1);
|
||||
PeriodicEvent = false;
|
||||
SetEISHIGHZ(1);
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
InitGPT();
|
||||
}
|
||||
|
||||
GPT.cnt_lead_time = GPT.cnt_lead_time + GPT.cnt_gpt_delta;
|
||||
if (leadTimeReset && GPT.cnt_lead_time <= 2000) {
|
||||
vscanReset = true;
|
||||
if (first_highz_flag && GPT.cnt_lead_time >= 1000) {
|
||||
SetEISHIGHZ(1); // // High Z | 1 off | 0 on
|
||||
first_highz_flag = false;
|
||||
}
|
||||
} else {
|
||||
if (notifyFirst_flag) {
|
||||
GPT.cnt_notify_rate = instru.notifyRate - 20;
|
||||
notifyFirst_flag = false;
|
||||
}
|
||||
vscanReset = false;
|
||||
leadTimeReset = false;
|
||||
}
|
||||
|
||||
//vscan counter //fset counter
|
||||
GPT.cnt_v_scan_rate = GPT.cnt_v_scan_rate + GPT.cnt_gpt_delta;
|
||||
if (GPT.cnt_v_scan_rate >= instru.VsetRate) {
|
||||
if (GPT.cnt_v_scan_rate >= instru.VsetRate * 2) {
|
||||
GPT.GptimerMultiple = GPT.cnt_v_scan_rate / instru.VsetRate;
|
||||
} else {
|
||||
GPT.GptimerMultiple = 1;
|
||||
}
|
||||
GPT.cnt_v_scan_rate -= instru.VsetRate * GPT.GptimerMultiple; //To get right time
|
||||
vscan_flag = true;
|
||||
if (vscan_flag) {
|
||||
vscan_ctrl(); //set
|
||||
vscan_volt_out();
|
||||
vscan_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
//ADC counter
|
||||
GPT.cnt_adc_rate = GPT.cnt_adc_rate + GPT.cnt_gpt_delta;
|
||||
if(GPT.cnt_adc_rate >= instru.sampleRate){
|
||||
GPT.cnt_adc_rate = 0; //To get right data, ADC must be delay 1.5ms
|
||||
ADC_flag = true;
|
||||
if(ADC_flag){
|
||||
EliteADCControl(); //read data
|
||||
ADC_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Notify counter(Notify control, check if we need to send notify)
|
||||
//please don't put Notify counter before ADC counter, maybe get wrong data
|
||||
GPT.cnt_notify_rate = GPT.cnt_notify_rate + GPT.cnt_gpt_delta;
|
||||
if(GPT.cnt_notify_rate >= instru.notifyRate){
|
||||
GPT.cnt_notify_rate -= instru.notifyRate; //To get right time
|
||||
notify_flag = true;
|
||||
if(vscanReset){
|
||||
notify_flag = false;
|
||||
}
|
||||
if(notify_flag){
|
||||
SendNotify(); //send
|
||||
notify_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
mode_done(); //finishMode = 1, SendNotify(), reset()
|
||||
|
||||
}
|
||||
|
||||
peri_mode();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (instru.eliteFxn == CURVE_UNI_PULSE) {
|
||||
if (mode_init) {
|
||||
mode_init = false;
|
||||
mode_init_set();
|
||||
InitGPT();
|
||||
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();
|
||||
InitGPT();
|
||||
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();
|
||||
InitGPT();
|
||||
}
|
||||
|
||||
uni_pulse_mode();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 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)
|
||||
static void EliteADCControl(void) //CURVE_IV => CC_Plot() | CURVE_CV => Iin_Vin_Vout_Plot
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
if (volt_rec_en) {
|
||||
InputNotify(NOTIFY_VOLT, instru.Vout/200);
|
||||
InputNotify(NOTIFY_IMPEDANCE, MEAS_VIN(wm));
|
||||
}
|
||||
case CURVE_EIS:
|
||||
gain = instru.gain_lv_hstia;
|
||||
EIS_Plot();
|
||||
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);
|
||||
}
|
||||
case CURVE_CF:
|
||||
gain = instru.gain_lv_hstia;
|
||||
CF_Plot();
|
||||
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);
|
||||
}
|
||||
gain = instru.gain_lv_lptia;
|
||||
CV_Plot();
|
||||
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);
|
||||
}
|
||||
case CURVE_CA:
|
||||
gain = instru.gain_lv_lptia;
|
||||
CA_Plot();
|
||||
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));
|
||||
}
|
||||
gain = instru.gain_lv_lptia;
|
||||
VT_Plot();
|
||||
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);
|
||||
}
|
||||
case CURVE_RT:
|
||||
gain = instru.gain_lv_lptia;
|
||||
RT_Plot();
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -565,118 +256,52 @@ static void EliteADCControl(uint32_t time)
|
||||
}
|
||||
}
|
||||
|
||||
static void mode_done(void)
|
||||
static void mode_done(void) //finishMode = 1, SendNotify(), reset()
|
||||
{
|
||||
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 (instru.eliteFxn == CURVE_CV) {
|
||||
if (!PeriodicEvent) {
|
||||
finishMode = true;
|
||||
finishMode = 1;
|
||||
SendNotify();
|
||||
Eliteinterrupt();
|
||||
reset();
|
||||
}
|
||||
} else if ((instru.eliteFxn == CURVE_EIS) || (instru.eliteFxn == CURVE_CF)){
|
||||
if (!PeriodicEvent) {
|
||||
reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void vscan_ctrl(uint32_t time)
|
||||
|
||||
|
||||
static void vscan_ctrl(void)
|
||||
{
|
||||
uint32_t t = time;
|
||||
|
||||
switch (instru.eliteFxn) {
|
||||
case CURVE_IV:
|
||||
iv_vscan();
|
||||
case CURVE_EIS:
|
||||
eis_fscan();
|
||||
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();
|
||||
case CURVE_CF:
|
||||
cf_fscan();
|
||||
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);
|
||||
case CURVE_RT:
|
||||
rt_vscan();
|
||||
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 uint32_t get_step_time(uint8_t StepTime){
|
||||
|
||||
switch (StepTime) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* IMPEDANCE_METER_H_ */
|
||||
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
#ifndef MODE_CA_H
|
||||
#define MODE_CA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static void decode_ca_mode(uint8 *ins)
|
||||
{
|
||||
instru.eliteFxn = CURVE_CA;
|
||||
instru.Vinit = (int32_t)ins[3] << 8 | (int32_t)ins[4]; //37500
|
||||
instru.notifyRate = (uint32_t)ins[7] << 8 | (uint32_t)ins[8]; //1000
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10; //100
|
||||
instru.VsetRate = VsetRateTable[0]; //2
|
||||
//instru.hign_z_en = ins[6] & 0x0F;
|
||||
|
||||
//instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
|
||||
setEIS_CV();
|
||||
ModeLED(WORKING);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void ca_vscan(void)
|
||||
{
|
||||
struct wm_ca_ctx_t *ca = (struct wm_ca_ctx_t *)wm_get();
|
||||
|
||||
if(vscanReset){
|
||||
instru.Vset = ca->_Vinit;
|
||||
}
|
||||
|
||||
if(!vscanReset){
|
||||
instru.Vset = ca->_Vinit;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void CA_Plot(void)
|
||||
{
|
||||
struct wm_ca_ctx_t *ca = (struct wm_ca_ctx_t *)wm_get();
|
||||
static uint8_t ADC_cnt = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
if (ADC_cnt == 0) {
|
||||
LPTIA_change_gain();
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 1) {
|
||||
read_LPTIA_Iin();
|
||||
ADC_cnt = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static void set_ca_volt(uint8 *ins)
|
||||
{
|
||||
struct wm_ca_ctx_t *ca = (struct wm_ca_ctx_t *)wm_get();
|
||||
instru.Vinit = (int32_t)ins[4] << 8 | (int32_t)ins[5]; //37500
|
||||
ca->_Vinit = (instru.Vinit - 25000) * 4 * 4000; //[5nV]
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // TIMERS_H
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
|
||||
|
||||
|
||||
|
||||
/***
|
||||
DC Volt 0 mv
|
||||
AC Amp 100 mv
|
||||
Freq 200000Hz~0.1Hz
|
||||
Points per decades 10 points
|
||||
Point spacing Logarithm
|
||||
Delay 0 points
|
||||
Average 2
|
||||
Current range Auto
|
||||
|
||||
[CC2650] att_write 360CD10100CB7355000000070000
|
||||
[CC2650] att_write 360BD10261A801000004000A00
|
||||
***/
|
||||
|
||||
#define DECODE_INS_1 0x01
|
||||
#define DECODE_INS_2 0x02
|
||||
#define DECODE_INS_MODE 0xFF
|
||||
|
||||
static void decode_cf_mode(uint8_t *instruction)
|
||||
{
|
||||
uint8_t *ins = instruction;
|
||||
uint8_t ins_step = ins[3];
|
||||
|
||||
|
||||
if (ins_step == DECODE_INS_1) {
|
||||
instru.f1 = (uint32_t)ins[4] << 24 | (uint32_t)ins[5] << 16 | (uint32_t)ins[6] << 8 | (uint32_t)ins[7]; //FREQ_START //13333333
|
||||
|
||||
instru.delay = (uint16_t)ins[12] << 8 | (uint16_t)ins[13]; //DELAY/10 how many periods //0
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ins_step == DECODE_INS_2) {
|
||||
instru.dcbias = (uint16_t)ins[4] << 8 | (uint16_t)ins[5]; //25000
|
||||
instru.acamp = (uint16_t)ins[6] << 8 | (uint16_t)ins[7]; //256
|
||||
instru.avgnum = (uint8_t)ins[8]; //0
|
||||
instru.gain_lv_hstia = (uint8_t)ins[9]; //4 = HSRTIA_200R //0
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ins_step == DECODE_INS_MODE) {
|
||||
instru.eliteFxn = CURVE_CF;
|
||||
|
||||
set_hs_only();
|
||||
if (instru.gain_lv_hstia < HSRTIA_MAX) {
|
||||
instru.HSTIAAutoGainEnable = 0;
|
||||
HSTIAGainCtrl(instru.gain_lv_hstia);
|
||||
} else {
|
||||
instru.HSTIAAutoGainEnable = 1;
|
||||
instru.gain_lv_hstia = HSRTIA_200R;
|
||||
HSTIAGainCtrl(instru.gain_lv_hstia);
|
||||
}
|
||||
HSDAC_outputV(instru.dcbias);
|
||||
AD5940_SPIWriteReg(WGFCW, instru.fset);
|
||||
AD5940_SPIWriteReg(WGCON, 0x0); // 0x0: DC disable ac first
|
||||
AD5940_SPIWriteReg(WGAMPLITUDE, instru.acamp);
|
||||
AD5940_SPIWriteReg(WGCON, 0x00000004); //0x4: Sinusoid
|
||||
ModeLED(WORKING);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void cf_fscan(void)
|
||||
{
|
||||
struct wm_cf_ctx_t *cf = (struct wm_cf_ctx_t *)wm_get();
|
||||
|
||||
if (vscanReset) {
|
||||
cf->_in_reset_flag = true;
|
||||
|
||||
cf->_f1 = User2Freq(cf->_f1);
|
||||
|
||||
instru.fset = cf->_f1;
|
||||
|
||||
vscanReset = false;
|
||||
SetWGAmp(instru.acamp,instru.fset);
|
||||
DAC_outputF(Freq2DAC(instru.fset)); //[10mHz->Reg's]
|
||||
}
|
||||
|
||||
if (!vscanReset) {
|
||||
instru.fset = cf->_f1;
|
||||
}
|
||||
|
||||
SetSamplingTime(instru.fset);
|
||||
|
||||
instru.sampleRate = 2000;
|
||||
}
|
||||
|
||||
static void CF_Plot(void) //real and imag impedance plot
|
||||
{
|
||||
static uint8_t avgNumTable[4] = {2, 4, 6, 8};
|
||||
struct wm_cf_ctx_t *cf = (struct wm_cf_ctx_t *)wm_get();
|
||||
static uint8_t ADC_cnt = 0;
|
||||
static int32_t realSum, imagSum = 0;
|
||||
int32_t avg_real, avg_imag = 0;
|
||||
static uint8_t avg_count = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
if (fout_flag){
|
||||
EnDFTnADC(1);
|
||||
instru.sampleRate = CalcDelayTime(instru.fset);
|
||||
fout_flag = false;
|
||||
if (cf->_in_reset_flag) {
|
||||
avg_count = 0;
|
||||
realSum = 0;
|
||||
imagSum = 0;
|
||||
ADC_cnt = 0;
|
||||
cf->_in_reset_flag = false;
|
||||
}
|
||||
} else {
|
||||
if (ADC_cnt == 0){
|
||||
HSTIA_change_gain(); // ADC measure
|
||||
if (gainChange_flag) {
|
||||
gainChange_flag = false;
|
||||
instru.sampleRate = CalcDelayTime(instru.fset);
|
||||
instru.real = 0;
|
||||
instru.imag = 0;
|
||||
ADC_cnt = 0;
|
||||
} else {
|
||||
instru.sampleRate = 15;
|
||||
ADC_cnt ++;
|
||||
}
|
||||
}
|
||||
else if (ADC_cnt == 1) {
|
||||
realSum += instru.real;
|
||||
imagSum += instru.imag;
|
||||
avg_count++;
|
||||
instru.sampleRate = 15;
|
||||
if (avg_count == avgNumTable[instru.avgnum]){
|
||||
avg_real = realSum / avg_count;
|
||||
avg_imag = imagSum / avg_count;
|
||||
|
||||
InputNotify(NOTIFY_CURRENT, avg_imag);
|
||||
InputNotify(NOTIFY_VOLT, avg_real);
|
||||
InputNotify(NOTIFY_IMPEDANCE, instru.fset);
|
||||
NotifyCh4 = (uint32_t)cf->_amp * 1000 * 800 / 2047; //[uV]
|
||||
|
||||
EnDFTnADC(0);
|
||||
avg_count = 0;
|
||||
realSum = 0;
|
||||
imagSum = 0;
|
||||
notify_flag = true;
|
||||
}
|
||||
ADC_cnt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
#define STEP_TO_VSETRATE(step) step2VsetRate(step)
|
||||
|
||||
static void decode_cv_mode(uint8 *ins)
|
||||
{
|
||||
if (ins[3] == PARA_1) {
|
||||
instru.Vinit = (int32_t)ins[4] << 8 | (int32_t)ins[5];
|
||||
instru.Ve1 = (uint16_t)ins[6] << 8 | (uint16_t)ins[7];
|
||||
instru.Ve2 = (uint16_t)ins[8] << 8 | (uint16_t)ins[9];
|
||||
instru.Vmax = (int32_t)VMAX(instru.Ve1,instru.Ve2);
|
||||
instru.Vmin = (int32_t)VMIN(instru.Ve1,instru.Ve2);
|
||||
if (instru.Vinit > instru.Ve1 || instru.Vinit == instru.Vmax){
|
||||
instru.directionInit = 0;//0:reverse 1:forward
|
||||
} else if (instru.Vinit <= instru.Ve1 || instru.Vinit == instru.Vmin){
|
||||
instru.directionInit = 1;
|
||||
}
|
||||
} else if (ins[3] == PARA_2) {
|
||||
instru.eliteFxn = CURVE_CV;
|
||||
instru.notifyRate = (uint32_t)ins[8] << 8 | (uint32_t)ins[9];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
//controller UI 0.01~1000mv send to Elite 1~100000
|
||||
instru.step = (uint32_t)ins[4] << 24 | (uint32_t)ins[5] << 16 | (uint32_t)ins[6] << 8 | (uint32_t)ins[7];
|
||||
STEP_TO_VSETRATE(instru.step); //step2VsetRate
|
||||
instru.VsetRate = VsetRateTable[instru.VsetRateIndex];//N
|
||||
instru.cycleNumber = (uint16_t)ins[10] << 8 | (uint16_t)ins[11];
|
||||
|
||||
setEIS_CV();
|
||||
ModeLED(WORKING);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Vstep = x * 20 * N, x=xmV ; N=VscanRate Vstep unit [5nV]/[0.1ms]
|
||||
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;
|
||||
}
|
||||
|
||||
instru.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) {
|
||||
instru.Vset += cv->_Vstep; //* GPT.GptimerMultiple;
|
||||
} else {
|
||||
instru.Vset -= cv->_Vstep; //* GPT.GptimerMultiple;
|
||||
}
|
||||
|
||||
if (instru.Vinit < instru.Ve1 && instru.Vinit < instru.Ve2) {
|
||||
if (instru.Vset == cv->_Vmin) {
|
||||
VminCounter = true;
|
||||
instru.Vinit = instru.Vmin;
|
||||
cv->_Vinit = cv->_Vmin;
|
||||
}
|
||||
} else if (instru.Vinit > instru.Ve1 && instru.Vinit > instru.Ve2) {
|
||||
if (instru.Vset == cv->_Vmax) {
|
||||
VmaxCounter = true;
|
||||
instru.Vinit = instru.Vmax;
|
||||
cv->_Vinit = cv->_Vmax;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (instru.Vset >= cv->_Vmax) {
|
||||
VmaxCounter = true;
|
||||
} else if (instru.Vset <= cv->_Vmin) {
|
||||
VminCounter = true;
|
||||
}
|
||||
|
||||
if (cv->_current_direction_up) {
|
||||
instru.Vset += cv->_Vstep;// * GPT.GptimerMultiple;
|
||||
} else {
|
||||
instru.Vset -= cv->_Vstep;// * GPT.GptimerMultiple;
|
||||
}
|
||||
|
||||
if (VmaxCounter && VminCounter) {
|
||||
if (cv->_direction_up && cv->_current_direction_up) {
|
||||
if (instru.Vset >= cv->_Vinit) {
|
||||
cv->_cycleNumber--;
|
||||
VminCounter = false;
|
||||
VmaxCounter = false;
|
||||
}
|
||||
}
|
||||
if (!cv->_direction_up && !cv->_current_direction_up) {
|
||||
if (instru.Vset <= cv->_Vinit) {
|
||||
cv->_cycleNumber--;
|
||||
VminCounter = false;
|
||||
VmaxCounter = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (instru.Vset >= cv->_Vmax) {
|
||||
cv->_current_direction_up = false;
|
||||
} else if (instru.Vset <= cv->_Vmin) {
|
||||
cv->_current_direction_up = true;
|
||||
}
|
||||
|
||||
/*stop condition*/
|
||||
if (cv->_cycleNumber == 0) {
|
||||
PeriodicEvent = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void CV_Plot(void)
|
||||
{
|
||||
struct wm_cv_ctx_t *cv = (struct wm_cv_ctx_t *)wm_get();
|
||||
static uint8_t ADC_cnt = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
if (ADC_cnt == 0) {
|
||||
LPTIA_change_gain();
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 1) {
|
||||
read_LPTIA_Iin();
|
||||
ADC_cnt = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
+314
@@ -0,0 +1,314 @@
|
||||
|
||||
|
||||
|
||||
|
||||
/***
|
||||
DC Volt 0 mv
|
||||
AC Amp 100 mv
|
||||
Freq 200000Hz~0.1Hz
|
||||
Points per decades 10 points
|
||||
Point spacing Logarithm
|
||||
Delay 0 points
|
||||
Average 2
|
||||
Current range Auto
|
||||
|
||||
[CC2650] att_write 360CD10100CB7355000000070000
|
||||
[CC2650] att_write 360BD10261A801000004000A00
|
||||
***/
|
||||
|
||||
#define DECODE_INS_1 0x01
|
||||
#define DECODE_INS_2 0x02
|
||||
#define DECODE_INS_MODE 0xFF
|
||||
|
||||
static void decode_eis_mode(uint8_t *instruction)
|
||||
{
|
||||
uint8_t *ins = instruction;
|
||||
uint8_t ins_step = ins[3];
|
||||
|
||||
|
||||
if (ins_step == DECODE_INS_1) {
|
||||
instru.f1 = (uint32_t)ins[4] << 24 | (uint32_t)ins[5] << 16 | (uint32_t)ins[6] << 8 | (uint32_t)ins[7]; //FREQ_START //13333333
|
||||
instru.f2 = (uint32_t)ins[8] << 24 | (uint32_t)ins[9] << 16 | (uint32_t)ins[10] << 8 | (uint32_t)ins[11]; //FREQ_STOP //7
|
||||
//instru.sampleRate = 15;//CalcDelayTime(User2Freq(instru.f1), true); //ms //read
|
||||
instru.fmax = (uint32_t)VMAX(instru.f1, instru.f2); //13333333
|
||||
instru.fmin = (uint32_t)VMIN(instru.f1, instru.f2); //7
|
||||
instru.delay = (uint16_t)ins[12] << 8 | (uint16_t)ins[13]; //DELAY/10 how many periods //0
|
||||
if (instru.f1 > instru.f2)
|
||||
instru.directionInit = 0; //0:reverse 1:forward //instru.directionInit = 0
|
||||
else if (instru.f1 <= instru.f2)
|
||||
instru.directionInit = 1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ins_step == DECODE_INS_2) {
|
||||
instru.dcbias = (uint16_t)ins[4] << 8 | (uint16_t)ins[5]; //25000
|
||||
instru.acamp = (uint16_t)ins[6] << 8 | (uint16_t)ins[7]; //256
|
||||
instru.avgnum = (uint8_t)ins[8]; //0
|
||||
instru.gain_lv_hstia = (uint8_t)ins[9]; //4 = HSRTIA_200R
|
||||
instru.ppd = (uint16_t)ins[10] << 8 | (uint16_t)ins[11]; //10
|
||||
instru.scale = (uint8_t)ins[12]; //0
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ins_step == DECODE_INS_MODE) {
|
||||
instru.eliteFxn = CURVE_EIS;
|
||||
set_hs_only();
|
||||
if (instru.gain_lv_hstia < HSRTIA_MAX) {
|
||||
instru.HSTIAAutoGainEnable = 0;
|
||||
HSTIAGainCtrl(instru.gain_lv_hstia);
|
||||
} else {
|
||||
instru.HSTIAAutoGainEnable = 1;
|
||||
instru.gain_lv_hstia = HSRTIA_200R;
|
||||
HSTIAGainCtrl(instru.gain_lv_hstia);
|
||||
}
|
||||
HSDAC_outputV(instru.dcbias);
|
||||
AD5940_SPIWriteReg(WGFCW, instru.fset);
|
||||
AD5940_SPIWriteReg(WGCON, 0x0); // 0x0: DC disable ac first
|
||||
AD5940_SPIWriteReg(WGAMPLITUDE, instru.acamp);
|
||||
AD5940_SPIWriteReg(WGCON, 0x00000004); //0x4: Sinusoid
|
||||
ModeLED(WORKING);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//////EIS PLOT RELATED FUNCTION START//////
|
||||
static uint8_t CalcDecade(uint32_t f1, uint32_t f2)
|
||||
{
|
||||
uint8_t decades; //max is 7
|
||||
decades = log10(f2/f1);
|
||||
return decades;
|
||||
}
|
||||
|
||||
static void eis_fscan(void)
|
||||
{
|
||||
struct wm_eis_ctx_t *eis = (struct wm_eis_ctx_t *)wm_get();
|
||||
static uint16_t LogSpacingTable10[10] = {1000, 1292, 1668, 2154, 2783, 3594, 4642, 5995, 7743, 10000};
|
||||
static uint16_t LogSpacingTable9[9] = {1000, 1334, 1778, 2371, 3162, 4217, 5623, 7499, 10000};
|
||||
static uint16_t LogSpacingTable8[8] = {1000, 1389, 1931, 2683, 3728, 5179, 7197, 10000};
|
||||
static uint16_t LogSpacingTable7[7] = {1000, 1468, 2154, 3162, 4642, 6813, 10000};
|
||||
static uint16_t LogSpacingTable6[6] = {1000, 1585, 2512, 3981, 6310, 10000};
|
||||
static uint16_t LogSpacingTable5[5] = {1000, 1778, 3162, 5623, 10000};
|
||||
static uint16_t LogSpacingTable4[4] = {1000, 2154, 4642, 10000};
|
||||
static uint16_t LogSpacingTable3[3] = {1000, 3162, 10000};
|
||||
static uint16_t LogSpacingTable2[2] = {1000, 10000};
|
||||
static uint32_t TenPowerTable[9] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000};
|
||||
|
||||
if (vscanReset) {
|
||||
eis->_in_reset_flag = true;
|
||||
|
||||
eis->_f1 = User2Freq(eis->_f1);
|
||||
eis->_f2 = User2Freq(eis->_f2);
|
||||
eis->_fmax = User2Freq(eis->_fmax);
|
||||
eis->_fmin = User2Freq(eis->_fmin);
|
||||
|
||||
if (instru.directionInit == 1) {
|
||||
eis->_direction_up = true;
|
||||
} else if (instru.directionInit == 0) {
|
||||
eis->_direction_up = false;
|
||||
}
|
||||
|
||||
eis->_decades = CalcDecade(instru.fmin, instru.fmax);
|
||||
|
||||
instru.fset = eis->_f1;
|
||||
|
||||
vscanReset = false;
|
||||
}
|
||||
|
||||
if (!vscanReset) {
|
||||
if(eis->_direction_up) {
|
||||
if(eis->_sweepIndex == 0){
|
||||
if(eis->_decadeIndex < eis->_decades) {
|
||||
eis->_fd1 = eis->_f1 * TenPowerTable[eis->_decadeIndex];
|
||||
eis->_fd2 = eis->_f1 * TenPowerTable[eis->_decadeIndex + 1];
|
||||
} else if (eis->_decadeIndex == eis->_decades) {
|
||||
eis->_fd1 = eis->_fd2;//eis->_f1 * TenPowerTable[decadeIndex];
|
||||
eis->_fd2 = eis->_fmax;
|
||||
}
|
||||
}
|
||||
|
||||
if(eis->_decadeIndex != 0 && eis->_sweepIndex == 0){
|
||||
eis->_sweepIndex++;
|
||||
}
|
||||
|
||||
if(instru.scale == 0) { // logarithm
|
||||
if (eis->_ppd == 10) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable10[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 9){
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable9[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 8) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable8[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 7) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable7[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 6) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable6[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 5) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable5[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 4) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable4[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 3) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable3[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
else if (eis->_ppd == 2) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable2[eis->_sweepIndex] + 500)/ 1000;
|
||||
}
|
||||
}
|
||||
else if (instru.scale == 1) { // linear
|
||||
instru.fset = eis->_fd1 + eis->_sweepIndex * ((eis->_fd2 - eis->_fd1) / (eis->_ppd - 1));
|
||||
}
|
||||
|
||||
if(instru.fset > eis->_fmax){
|
||||
instru.fset = eis->_fmax;
|
||||
}
|
||||
|
||||
} else { //reverse
|
||||
if(eis->_sweepIndex == 0){
|
||||
if(eis->_decadeIndex < eis->_decades){
|
||||
eis->_fd1 = eis->_f1 / TenPowerTable[eis->_decadeIndex];
|
||||
eis->_fd2 = eis->_f1 / TenPowerTable[eis->_decadeIndex + 1];
|
||||
} else if (eis->_decadeIndex == eis->_decades){
|
||||
eis->_fd1 = eis->_fd2; //eis->_f1 / TenPowerTable[eis->_decadeIndex];
|
||||
eis->_fd2 = eis->_fmin;
|
||||
}
|
||||
}
|
||||
|
||||
if(eis->_decadeIndex != 0 && eis->_sweepIndex == 0){
|
||||
eis->_sweepIndex++;
|
||||
}
|
||||
|
||||
if(instru.scale == 0) { // logarithm
|
||||
if (eis->_ppd == 10) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable10[9 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 9) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable9[8 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 8) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable8[7 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 7) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable7[6 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 6) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable6[5 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 5) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable5[4 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 4) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable4[3 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 3) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable3[2 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
else if (eis->_ppd == 2) {
|
||||
instru.fset = ((uint64_t)eis->_fd1 * LogSpacingTable2[1 - eis->_sweepIndex] + 5000)/ 10000;
|
||||
}
|
||||
}
|
||||
else if(instru.scale == 1) { // linear
|
||||
instru.fset = eis->_fd1 - eis->_sweepIndex * ((eis->_fd1 - eis->_fd2) / (eis->_ppd - 1));
|
||||
}
|
||||
|
||||
if(instru.fset < eis->_fmin){
|
||||
instru.fset = eis->_fmin;
|
||||
}
|
||||
}
|
||||
if (!gainChange_flag) {
|
||||
if (++eis->_sweepIndex == eis->_ppd) {
|
||||
eis->_sweepIndex = 0;
|
||||
eis->_decadeIndex ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SetSamplingTime(instru.fset);
|
||||
|
||||
instru.sampleRate = 2000;
|
||||
}
|
||||
|
||||
static void EIS_Plot(void) //real and imag impedance plot
|
||||
{
|
||||
static uint8_t avgNumTable[4] = {2, 4, 6, 8};
|
||||
struct wm_eis_ctx_t *eis = (struct wm_eis_ctx_t *)wm_get();
|
||||
static uint8_t ADC_cnt = 0;
|
||||
static int32_t realSum, imagSum = 0;
|
||||
int32_t avg_real, avg_imag = 0;
|
||||
static uint8_t avg_count = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
if (fout_flag){
|
||||
SetWGAmp(instru.acamp,instru.fset);
|
||||
DAC_outputF(Freq2DAC(instru.fset)); //[10mHz->Reg's]
|
||||
EnDFTnADC(1);
|
||||
instru.sampleRate = CalcDelayTime(instru.fset);
|
||||
fout_flag = false;
|
||||
if (eis->_in_reset_flag) {
|
||||
avg_count = 0;
|
||||
realSum = 0;
|
||||
imagSum = 0;
|
||||
ADC_cnt = 0;
|
||||
eis->_in_reset_flag = false;
|
||||
}
|
||||
} else {
|
||||
if (ADC_cnt == 0){
|
||||
HSTIA_change_gain(); // ADC measure
|
||||
if (gainChange_flag) {
|
||||
gainChange_flag = false;
|
||||
instru.sampleRate = CalcDelayTime(instru.fset);
|
||||
instru.real = 0;
|
||||
instru.imag = 0;
|
||||
ADC_cnt = 0;
|
||||
} else {
|
||||
instru.sampleRate = 15;
|
||||
ADC_cnt ++;
|
||||
}
|
||||
}
|
||||
else if (ADC_cnt == 1) {
|
||||
realSum += instru.real;
|
||||
imagSum += instru.imag;
|
||||
avg_count++;
|
||||
instru.sampleRate = 15;
|
||||
if (avg_count == avgNumTable[instru.avgnum]){
|
||||
avg_real = realSum / avg_count;
|
||||
avg_imag = imagSum / avg_count;
|
||||
|
||||
InputNotify(NOTIFY_CURRENT, avg_imag);
|
||||
InputNotify(NOTIFY_VOLT, avg_real);
|
||||
InputNotify(NOTIFY_IMPEDANCE, instru.fset);
|
||||
NotifyCh4 = (uint32_t)eis->_amp * 1000 * 800 / 2047; //[uV]
|
||||
|
||||
if(eis->_direction_up){
|
||||
if (instru.fset >= eis->_fmax) {
|
||||
PeriodicEvent = false;
|
||||
finishMode = 1;
|
||||
}
|
||||
} else {
|
||||
if (instru.fset <= eis->_fmin) {
|
||||
PeriodicEvent = false;
|
||||
finishMode = 1;
|
||||
}
|
||||
}
|
||||
EnDFTnADC(0);
|
||||
avg_count = 0;
|
||||
realSum = 0;
|
||||
imagSum = 0;
|
||||
notify_flag = true;
|
||||
}
|
||||
ADC_cnt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
static void decode_rt_mode(uint8 *ins)
|
||||
{
|
||||
instru.eliteFxn = CURVE_RT;
|
||||
instru.notifyRate = (uint32_t)ins[7] << 8 | (uint32_t)ins[8];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
// instru.notifyRate = 100;
|
||||
// instru.measure_vin_range = ins[7];
|
||||
// instru.measure_vin_range = 0;
|
||||
setEIS_CV();
|
||||
instru.Vinit = (uint32_t)ins[3] << 8 | (uint32_t)ins[4];
|
||||
|
||||
ModeLED(WORKING);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void CalcuResistance(int32_t Iin)
|
||||
{
|
||||
/* 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();
|
||||
int64_t resist;
|
||||
int64_t volt = instru.Vset / 200; // [uV]
|
||||
int64_t current = Iin;
|
||||
|
||||
resist = volt * 1000000 / current; //R = V / Iin; [mOhm]
|
||||
InputNotify(NOTIFY_IMPEDANCE, resist);
|
||||
}
|
||||
|
||||
static void RT_Plot(void)
|
||||
{
|
||||
struct wm_rt_ctx_t *rt = (struct wm_rt_ctx_t *)wm_get();
|
||||
static uint8_t ADC_cnt = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
if (ADC_cnt == 0) {
|
||||
LPTIA_change_gain();
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 1) {
|
||||
int32_t Iin = read_LPTIA_Iin();
|
||||
CalcuResistance(Iin);
|
||||
ADC_cnt = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void rt_vscan(void)
|
||||
{
|
||||
struct wm_rt_ctx_t *rt = (struct wm_rt_ctx_t *)wm_get();
|
||||
|
||||
if(vscanReset){
|
||||
instru.Vset = rt->_Vinit;
|
||||
}
|
||||
|
||||
if(!vscanReset){
|
||||
instru.Vset = rt->_Vinit;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void set_rt_volt(int32_t volt)
|
||||
{
|
||||
struct wm_rt_ctx_t *rt = (struct wm_rt_ctx_t *)wm_get();
|
||||
|
||||
volt = (volt - 25000) * 4 * 4000;
|
||||
|
||||
rt->_Vinit = volt;
|
||||
|
||||
return;
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
|
||||
|
||||
static void decode_vt_mode(uint8 *ins)
|
||||
{
|
||||
instru.eliteFxn = CURVE_VT;
|
||||
instru.notifyRate = (uint32_t)ins[5] << 8 | (uint32_t)ins[6];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.measure_vin_range = ins[7];
|
||||
setEIS_CV();
|
||||
AD5940_SPIWriteReg(ADCCON, 0x0001080E); //PGA = 1.5 //VT
|
||||
uint8_t z;
|
||||
uint16_t b;
|
||||
if (instru.measure_vin_range == 0) { //measure +volt
|
||||
z = 0;
|
||||
b = 0;
|
||||
} else if (instru.measure_vin_range == 1) { //measure +-1V
|
||||
z = 32;
|
||||
b = 2048;
|
||||
} else if (instru.measure_vin_range == 2) { //measure -volt
|
||||
z = 62;
|
||||
b = 3910;
|
||||
}
|
||||
set_lpdac_ce_1100mv(z, b);
|
||||
disconnect_rtia();
|
||||
ModeLED(WORKING);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void VT_Plot(void)
|
||||
{
|
||||
struct wm_ca_ctx_t *ca = (struct wm_ca_ctx_t *)wm_get();
|
||||
static uint8_t ADC_cnt = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
if (ADC_cnt == 0) {
|
||||
// LPTIA_change_gain();
|
||||
ADC_cnt++;
|
||||
|
||||
} else if (ADC_cnt == 1) {
|
||||
read_LPTIA_Vin();
|
||||
ADC_cnt = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
-790
@@ -1,790 +0,0 @@
|
||||
#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 DELTAVOLTMAX 20000000 //2000000 = 10mV //10000000 = 50mV //20000000 = 100mV
|
||||
#define RESISTANCE_100R 1 // 100V/1A = 1[5nV]/50[pA]
|
||||
|
||||
static void cc_vscan(void)
|
||||
{
|
||||
/* 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
|
||||
*/
|
||||
|
||||
struct wm_cc_ctx_t *cc = (struct wm_cc_ctx_t *)wm_get();
|
||||
struct wm_meas_t *m = &cc->measure;
|
||||
uint16_t divisionRate;
|
||||
int32_t deltaI;
|
||||
int32_t deltaV;
|
||||
int32_t Iin;
|
||||
int32_t Voutin;
|
||||
uint8_t cc_cp_speed = instru.cc_cp_speed; // 0:low 1:normal 2:high
|
||||
uint8_t cc_resistance = instru.cc_resistance; // 0:vout has 0R 1:vout has 100R
|
||||
static int32_t i_set = 0;
|
||||
|
||||
if (vscanReset) {
|
||||
Vset = 0;
|
||||
|
||||
if (cc->_charge == 0) {
|
||||
i_set = cc->_Iset * (-1);
|
||||
} else if(cc->_charge == 1) {
|
||||
i_set = cc->_Iset;
|
||||
}
|
||||
|
||||
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
|
||||
Voutin = m->_measureVout * 200; //[5nV]
|
||||
|
||||
if (cc_resistance == 1) //vout has 100R
|
||||
Vset = Voutin + (i_set * RESISTANCE_100R); //[5nV]
|
||||
else
|
||||
Vset = Voutin; //[5nV]
|
||||
|
||||
if (Vset >= 1100000000) { // 5.5V
|
||||
Vset = 1100000000;
|
||||
} else if (Vset <= -1000000000) { //-5V
|
||||
Vset = -1000000000;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vscanReset) {
|
||||
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
|
||||
deltaI = Iin - i_set;
|
||||
|
||||
if (deltaI > 400000 || deltaI < -400000) { //20uA
|
||||
if (instru.cc_cp_speed == 0) { // 0:low 1:normal 2:high
|
||||
cc_cp_speed = 100;
|
||||
} else if (instru.cc_cp_speed == 1) {
|
||||
cc_cp_speed = 10;
|
||||
} else {
|
||||
cc_cp_speed = 1;
|
||||
}
|
||||
} else {
|
||||
if (instru.cc_cp_speed == 0) { // 0:low 1:normal 2:high
|
||||
cc_cp_speed = 100;
|
||||
} else if (instru.cc_cp_speed == 1) {
|
||||
cc_cp_speed = 20;
|
||||
} else {
|
||||
cc_cp_speed = 20;
|
||||
}
|
||||
}
|
||||
|
||||
divisionRate = cc_cp_speed;
|
||||
|
||||
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
|
||||
|
||||
if (deltaV > DELTAVOLTMAX) { //2000000 = 10mV
|
||||
deltaV = DELTAVOLTMAX;
|
||||
} else if (deltaV < (-DELTAVOLTMAX)) {
|
||||
deltaV = (-DELTAVOLTMAX);
|
||||
}
|
||||
|
||||
Vset = Vset + deltaV; //[5nV]
|
||||
|
||||
if (Vset >= 1100000000) { // 5.5V
|
||||
Vset = 1100000000;
|
||||
} else if (Vset <= -1000000000) { //-5V
|
||||
Vset = -1000000000;
|
||||
}
|
||||
|
||||
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 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
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
# $python .\simplelink\ble_sdk_2_02_02_25\src\examples\simple_peripheral\cc26xx\app\python\update_elite_version.py
|
||||
|
||||
import datetime
|
||||
import os
|
||||
|
||||
print(datetime.datetime.now())
|
||||
# print(datetime.datetime.now().year)
|
||||
# print(datetime.datetime.now().month)
|
||||
# print(datetime.datetime.now().day)
|
||||
# print(datetime.datetime.now().hour)
|
||||
# print(datetime.datetime.now().minute)
|
||||
# print(datetime.datetime.now().strftime("%H:%M:%S"))
|
||||
|
||||
y = datetime.datetime.now().year % 100
|
||||
m = datetime.datetime.now().month
|
||||
d = datetime.datetime.now().day
|
||||
hour = datetime.datetime.now().hour
|
||||
minute = datetime.datetime.now().minute
|
||||
|
||||
path = os.getcwd()
|
||||
path += '/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h'
|
||||
print('save:', path)
|
||||
|
||||
with open(path, 'w') as f:
|
||||
f.write('#ifndef VERSION_DATE\t\t' + '\n')
|
||||
f.write('#define VERSION_DATE\t\t' + '\n\n')
|
||||
f.write('#define VERSION_DATE_YEAR\t\t' + str(y) + '\n')
|
||||
f.write('#define VERSION_DATE_MONTH\t\t' + str(m) + '\n')
|
||||
f.write('#define VERSION_DATE_DAY\t\t' + str(d) + '\n')
|
||||
f.write('#define VERSION_DATE_HOUR\t\t' + str(hour) + '\n')
|
||||
f.write('#define VERSION_DATE_MINUTE\t\t' + str(minute) + '\n')
|
||||
|
||||
f.write('#endif' + '\n\n')
|
||||
+39
-39
@@ -588,16 +588,19 @@ static void SimpleBLEPeripheral_init(void)
|
||||
#include "hardware/led_APA_102.h"
|
||||
#include "driver/timers.h"
|
||||
#include "elite_task/elite_GPtimer.h"
|
||||
#include "hardware/dac_MAX5136.h"
|
||||
#include "hardware/adc_ads1118.h"
|
||||
#include "driver/gpio_edc15re.h"
|
||||
#include "elite_task/elite_latch.h"
|
||||
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EIS_11)
|
||||
#include "driver/gpio_eis11.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_MINI_10)
|
||||
#include "driver/gpio_eis_mini10.h"
|
||||
#endif
|
||||
|
||||
#include "hardware/chip_ad5940.h"
|
||||
|
||||
|
||||
|
||||
|
||||
struct gptimer0_t GPT;
|
||||
static uint16_t ADC_rxbuf = 0;
|
||||
|
||||
|
||||
|
||||
@@ -619,14 +622,14 @@ static bool power_on(uint32_t delta_time)
|
||||
keyTimer = keyTimer + t;
|
||||
|
||||
if (keyTimer >= 10000) {
|
||||
latch_single_ctrl(E_LATCH_5V_ENABLE, 1);
|
||||
latch_single_ctrl(E_LATCH_10V_ENABLE, 1);
|
||||
pin_set(E_PIN_5V_ENABLE, 1);
|
||||
|
||||
CPUdelay_us(320); // need delay 320us to stablize power
|
||||
ModeLED(BT_WAIT);
|
||||
//AD5940_Initialize();
|
||||
|
||||
headstage_battery_volt();
|
||||
AD5940_Initialize();
|
||||
|
||||
// headstage_battery_volt();
|
||||
headstage_init_device_info();
|
||||
|
||||
elite_on = true;
|
||||
@@ -668,8 +671,7 @@ static void key_manage(uint32_t delta_time)
|
||||
|
||||
keyTimer = keyTimer + t;
|
||||
if (keyTimer >= 30000){
|
||||
latch_single_ctrl(E_LATCH_5V_ENABLE, 0);
|
||||
|
||||
pin_set(E_PIN_5V_ENABLE, 0);
|
||||
} else if (keyTimer >= 10000 && !byPass1sec) {
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_ORANGE);
|
||||
byPass1sec = true;
|
||||
@@ -678,13 +680,21 @@ static void key_manage(uint32_t delta_time)
|
||||
return;
|
||||
}
|
||||
|
||||
static void device_init(void)
|
||||
{
|
||||
gpio_create();
|
||||
InitEliteInstruction();
|
||||
|
||||
/* toggle 6994 to on*/
|
||||
static void toggle_6994(uint16_t counter6994) {
|
||||
if(counter6994 == CLOCK_ONE_SECOND*5) {
|
||||
latch_single_ctrl(E_LATCH_OFF, 0); // OFF = 1 => turn off 6994
|
||||
}
|
||||
Board_initSPI();
|
||||
spi0_open(SPI_CLK_1M, POL0, PHA1); //SPI 1M: LED
|
||||
spi1_open(SPI_CLK_4M, POL0, PHA0); //SPI 4M: AD5941
|
||||
|
||||
elite_gptimer_open();
|
||||
InitGPT();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SimpleBLEPeripheral_taskFxn
|
||||
*
|
||||
@@ -696,11 +706,9 @@ static void toggle_6994(uint16_t counter6994) {
|
||||
*/
|
||||
static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
|
||||
{
|
||||
uint8_t key= 0;
|
||||
bool elite_on = false;
|
||||
batteryADC_flag = false;
|
||||
uint32_t check_key_time = 0;
|
||||
uint16_t counter6994 = 0;
|
||||
|
||||
// Initialize application
|
||||
SimpleBLEPeripheral_init();
|
||||
@@ -770,28 +778,17 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
|
||||
|
||||
GPT_timerIncrement();
|
||||
check_key_time = check_key_time + GPT.cnt_gpt_delta;
|
||||
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.cnt_gpt_delta;
|
||||
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.cnt_gpt_delta;
|
||||
|
||||
if (events & SBP_PERIODIC_EVT) {
|
||||
events &= ~SBP_PERIODIC_EVT;
|
||||
|
||||
/* routinely check the button status*/
|
||||
if (check_key_time >= 200) {
|
||||
key_manage(200);
|
||||
key_manage(check_key_time);
|
||||
check_key_time = 0;
|
||||
}
|
||||
|
||||
if (!PeriodicEvent) { // if there is no periodic event
|
||||
if (counter6994 <= CLOCK_ONE_SECOND*5) {
|
||||
toggle_6994(counter6994);
|
||||
counter6994++;
|
||||
}
|
||||
|
||||
key = PIN_getInputValue(E_PIN_SHUT_DOWN);
|
||||
if (key != 0) { //detect Elite battery power when no periodic event
|
||||
measureBat();
|
||||
}
|
||||
if (Free_Work_Mode) {
|
||||
wm_deinit();
|
||||
InitEliteInstruction();
|
||||
@@ -801,10 +798,10 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
|
||||
if(InitPeriodicEvent){
|
||||
wm_init();
|
||||
InitPeriodicEvent = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Perform periodic application task
|
||||
SimpleBLEPeripheral_performPeriodicTask();
|
||||
// Perform periodic application task
|
||||
SimpleBLEPeripheral_performPeriodicTask();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1168,7 +1165,7 @@ static void SimpleBLEPeripheral_processStateChangeEvt(gaprole_States_t newState)
|
||||
|
||||
case GAPROLE_WAITING_AFTER_TIMEOUT:
|
||||
SimpleBLEPeripheral_freeAttRsp(bleNotConnected);
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_RED);
|
||||
ModeLED(BT_WAIT);
|
||||
|
||||
#ifdef PLUS_BROADCASTER
|
||||
// Reset flag for next connection.
|
||||
@@ -1368,9 +1365,12 @@ static void SimpleBLEPeripheral_enqueueMsg(uint8_t event, uint8_t state)
|
||||
|
||||
#include "hardware/led_APA_102_c.h"
|
||||
#include "driver/spi_ctrl_c.h"
|
||||
#include "driver/timers_c.h"
|
||||
#include "driver/timers_c.h"
|
||||
#include "elite_task/elite_GPtimer_c.h"
|
||||
#include "hardware/DAC_MAX5136_c.h"
|
||||
#include "hardware/adc_ads1118_c.h"
|
||||
#include "driver/gpio_edc15re_c.h"
|
||||
#include "elite_task/elite_latch_c.h"
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EIS_11)
|
||||
#include "driver/gpio_eis11_c.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_MINI_10)
|
||||
#include "driver/gpio_eis_mini10_c.h"
|
||||
#endif
|
||||
|
||||
#include "hardware/chip_ad5940_c.h"
|
||||
|
||||
Reference in New Issue
Block a user