Compare commits
64 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b7b515da9 | |||
| 5f6b3ba7e5 | |||
| 84f2016346 | |||
| 4597e042fe | |||
| bd7c6e7567 | |||
| faca2637d0 | |||
| 4bb99ccfc9 | |||
| 7e16710cdd | |||
| 8e10e98e79 | |||
| 9493fd9a1b | |||
| 98ae27edf4 | |||
| f5213ffe60 | |||
| 6e8e974e04 | |||
| d7c2bc3fbb | |||
| d18bc134b8 | |||
| f58407f238 | |||
| b9f169d8f7 | |||
| c5aa04e8e2 | |||
| 550c424d32 | |||
| 1bb045ae27 | |||
| aced7380a9 | |||
| b9685340b3 | |||
| 0c690e9503 | |||
| 52c4cba192 | |||
| 0dd9a20114 | |||
| 4d6bd34faa | |||
| e7ca6205d1 | |||
| fcd6f9bd3f | |||
| 6df8353ca7 | |||
| 5f7cac01d3 | |||
| 8c8cd6b55a | |||
| 8622ed2057 | |||
| bb535e2c64 | |||
| a04cec2dad | |||
| d62c2814ea | |||
| 55866be4ed | |||
| 2e615c7e74 | |||
| a17bd344af | |||
| 0667c9397f | |||
| 40ad3b62fb | |||
| 8cddab21ab | |||
| b09afc4699 | |||
| ea9cc17494 | |||
| 8be6e779fa | |||
| aa864aad9a | |||
| a97f5a0fb1 | |||
| f8520cdcfd | |||
| 276b793687 | |||
| 45fc016bd5 | |||
| 78177025de | |||
| c1cd6260b7 | |||
| 9e1a734c3d | |||
| 2ba852f6d5 | |||
| 5495362f46 | |||
| e75a837994 | |||
| 4480b34948 | |||
| 5ac63bbce4 | |||
| f15971c28a | |||
| f6f0e47ee7 | |||
| 099d1ec72e | |||
| fbb98c3c24 | |||
| c8c101ae98 | |||
| ad1ed81f00 | |||
| 69416bc58e |
@@ -1,185 +1,316 @@
|
||||
# WTP_cc2650_development
|
||||
|
||||
## Device
|
||||
## Source code path
|
||||
|
||||
### Device major source code path
|
||||
1. Device major source code path
|
||||
|
||||
- main code
|
||||
|
||||
`E:\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\examples\simple_peripheral\cc26xx\app\main.c`
|
||||
|
||||
`E:\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\examples\simple_peripheral\cc26xx\app\simple_peripheral.c`
|
||||
|
||||
`E:\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\examples\simple_peripheral\cc26xx\app\headstage\headstage.h`
|
||||
|
||||
- gpio table
|
||||
- main code
|
||||
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\boards\BOOSTXL_CC2650MA\BOOSTXL_CC2650MA.h`
|
||||
`E:\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\examples\simple_peripheral\cc26xx\app\main.c`
|
||||
|
||||
`E:\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\examples\simple_peripheral\cc26xx\app\simple_peripheral.c`
|
||||
|
||||
`E:\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\examples\simple_peripheral\cc26xx\app\headstage\headstage.h`
|
||||
|
||||
- gpio table
|
||||
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\boards\CC2650_LAUNCHXL\CC2650_LAUNCHXL.h`
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\boards\BOOSTXL_CC2650MA\BOOSTXL_CC2650MA.h`
|
||||
|
||||
- GATT
|
||||
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\profiles\simple_profile\simple_gatt_profile.h`
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\boards\CC2650_LAUNCHXL\CC2650_LAUNCHXL.h`
|
||||
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\profiles\simple_profile\cc26xx\simple_gatt_profile.c`
|
||||
- GATT
|
||||
|
||||
### Memory board major source code path:
|
||||
- cc2650 host_test
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\profiles\simple_profile\simple_gatt_profile.h`
|
||||
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\profiles\simple_profile\cc26xx\simple_gatt_profile.c`
|
||||
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\examples\host_test\cc26xx\app\host_test_app.c`
|
||||
2. Memory board major source code path
|
||||
- cc2650 host_test
|
||||
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\examples\host_test\cc26xx\app\main.c`
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\examples\host_test\cc26xx\app\host_test_app.c`
|
||||
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\examples\host_test\cc26xx\app\main.c`
|
||||
|
||||
- cc2650 central
|
||||
- cc2650 central
|
||||
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\examples\simple_central\cc26xx\app\main.c`
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\examples\simple_central\cc26xx\app\main.c`
|
||||
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\examples\simple_central\cc26xx\app\simple_central.c`
|
||||
`E:\WT_project_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\examples\simple_central\cc26xx\app\simple_central.c`
|
||||
|
||||
* * *
|
||||
|
||||
## How to install this project in your PC
|
||||
|
||||
### Prerequisite:
|
||||
- Prerequisite:
|
||||
|
||||
anti-virus software might cause some problems, disable it while installing is recommended.
|
||||
anti-virus software might cause some problems, disable it while installing is recommended.
|
||||
|
||||
### Install CCStudio
|
||||
- Install CCStudio
|
||||
|
||||
1. [code composer studio](https://www.ti.com/tool/CCSTUDIO) :
|
||||
1. [code composer studio](https://www.ti.com/tool/CCSTUDIO) :
|
||||
choose the latest version (we use Version: 11.1.0.00011 Release date: 20 Dec 2021, Windows single file installer for CCS IDE) of Code Composer Studio.
|
||||
|
||||
2. unzip it
|
||||
2. unzip it
|
||||
|
||||
3. open the folder **CCS11.1.0.00011_win64** -> Open sub-folder **CCS11.1.0.00011_win64**
|
||||
3. open the folder **CCS11.1.0.00011_win64** -> Open sub-folder **CCS11.1.0.00011_win64**
|
||||
|
||||
4. run installer **ccs_setup_11.1.0.00011.exe**
|
||||
4. run installer **ccs_setup_11.1.0.00011.exe**
|
||||
|
||||
5. accept the license
|
||||
5. accept the license
|
||||
|
||||
6. install at folder `C:\ti\ccs1110`
|
||||
6. install at folder `C:\ti\ccs1110`
|
||||
|
||||
7. select installation type: Custom installation
|
||||
7. select installation type: Custom installation
|
||||
|
||||
8. select Components: SimpleLink CC13xx and CC26xx Wireless MCUs
|
||||
8. select Components: SimpleLink CC13xx and CC26xx Wireless MCUs
|
||||
|
||||
9. select all Debug Probes
|
||||
9. select all Debug Probes
|
||||
|
||||
10. finish. Wait for the install process......
|
||||
10. finish. Wait for the install process......
|
||||
|
||||
11. select options to create desktop shortcut and launch CCStudio
|
||||
11. select options to create desktop shortcut and launch CCStudio
|
||||
|
||||
12. at the first launch, CCStudio will ask you to select a directory as workspace. use directory `C:\Users\kimwu\workspace_ti` -> Launch
|
||||
12. at the first launch, CCStudio will ask you to select a directory as workspace. use directory `C:\Users\kimwu\workspace_ti` -> Launch
|
||||
|
||||
### install BLE STACK
|
||||
- Install BLE STACK
|
||||
|
||||
1. [BLE STACK](https://www.ti.com/tool/BLE-STACK-ARCHIVE):
|
||||
1. [BLE STACK](https://www.ti.com/tool/BLE-STACK-ARCHIVE):
|
||||
choose **BLE-STACK-2-2-2 — BLE-STACK V2.2.2 (Support for CC2640/CC2650)** Free version.
|
||||
(a TI account is required)
|
||||
|
||||
2. run **ble_sdk_2_02_02_25_setup.exe**
|
||||
2. run **ble_sdk_2_02_02_25_setup.exe**
|
||||
|
||||
3. accept the license agreement
|
||||
3. accept the license agreement
|
||||
|
||||
4. install **the BLE-Stack SDK** at the directory `C:\ti\simplelink` -> wait for the install process......
|
||||
4. install **the BLE-Stack SDK** at the directory `C:\ti\simplelink` -> wait for the install process......
|
||||
|
||||
5. **Setup - TI-RTOS for CC13xx and CC26xx Wireless MCUs 2.21.01.08** will jump out -> use installation directory `C:\ti` -> next
|
||||
5. **Setup - TI-RTOS for CC13xx and CC26xx Wireless MCUs 2.21.01.08** will jump out -> use installation directory `C:\ti` -> next
|
||||
|
||||
at the same time, **ble_sdk_2_02_02_25_setup.exe** will still be running, don't close the window
|
||||
<font color='red'> !!! </font> at the same time, **ble_sdk_2_02_02_25_setup.exe** will still be running, don't close the window
|
||||
|
||||
6. wait for the install process......
|
||||
6. wait for the install process......
|
||||
|
||||
7. finish
|
||||
7. finish
|
||||
|
||||
### First run CCStudio and setting
|
||||
- First run CCStudio and setting
|
||||
|
||||
1. start CCStudio, Use the default.`C:\Users\kimwu\workspace_ti` -> Launch
|
||||
1. start CCStudio, Use the default. `C:\Users\kimwu\workspace_ti`
|
||||
|
||||
2. Project -> Import CCS Projects -> Select search-directory `C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral` -> OK -> select all discovered projects -> finish
|
||||
-> Launch
|
||||
|
||||
4. right click `simple_peripheral_cc2650em_app` -> Properties -> General -> Products -> double click **com.ti.rtsc.TIRTOSCC13XX_CC26XX [2.21.1.08]** -> Preferences -> refresh -> select ```"C:\ti\tirtos_cc13xx_cc26xx_2_21_01_08"``` and ```"C:\ti\xdctools_3_32_00_06_core"``` -> Install -> restart CCS
|
||||
|
||||
5. right click `simple_peripheral_cc2650em_app` -> Properties -> General -> Project: Compiler version -> Tool-chain: **Compiler version: TI v20.2.5LTS** -> apply amd close
|
||||
2. Project
|
||||
|
||||
6. right click `simple_peripheral_cc2650em_stack` -> Properties -> General -> Project: Compiler version -> Tool-chain: **Compiler version: TI v20.2.5LTS** -> apply amd close
|
||||
-> Import CCS Projects
|
||||
|
||||
7. click `simple_peripheral_cc2650em_app`, Click *build* and it's done
|
||||
|
||||
8. click `simple_peripheral_cc2650em_stack` Click *build* and it has error: "C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/osal/src/common/osal.c", line 408: error #167: too few arguments in function call
|
||||
|
||||
modify code: osal.c line:408
|
||||
return ( (unsigned char*)ltoa( l, (char *)buf) ); -> return ( (unsigned char*)ltoa( l, (char *)buf, radix) );
|
||||
|
||||
and then, click *build* and it's done
|
||||
-> Select search-directory `C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral`
|
||||
|
||||
-> OK
|
||||
|
||||
-> select all discovered projects
|
||||
|
||||
-> finish
|
||||
|
||||
|
||||
### clone this project
|
||||
|
||||
#### with Command line interface (git-bash)
|
||||
|
||||
1. clone our project to E:\MCU_code\.
|
||||
3. right click `simple_peripheral_cc2650em_app`
|
||||
|
||||
`git clone [WTP_cc2650_development URL]`, where URL is our project url on gitlab.
|
||||
2. copy `E:\MCU_code\wtp_cc2650_development\backup\examples` to `E:\MCU_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25`
|
||||
-> Properties
|
||||
|
||||
-> General
|
||||
|
||||
-> Products
|
||||
|
||||
-> double click **com.ti.rtsc.TIRTOSCC13XX_CC26XX [2.21.1.08]**
|
||||
|
||||
-> Preferences
|
||||
|
||||
-> refresh
|
||||
|
||||
-> select `"C:\ti\tirtos_cc13xx_cc26xx_2_21_01_08"` and `"C:\ti\xdctools_3_32_00_06_core"`
|
||||
|
||||
-> Install
|
||||
|
||||
-> restart CCS
|
||||
|
||||
terminal:
|
||||
$cd /e/MCU_code/wtp_cc2650_development
|
||||
$cp -r ./backup/examples ./simplelink/ble_sdk_2_02_02_25/
|
||||
4. right click `simple_peripheral_cc2650em_app`
|
||||
|
||||
-> Properties
|
||||
|
||||
-> General
|
||||
|
||||
-> Project
|
||||
|
||||
-> Tool-chain: **Compiler version: TI v20.2.5LTS**
|
||||
|
||||
Device: **Connection: Texas Instrument XDS110 USB Debug Probe[Default]**
|
||||
|
||||
-> apply amd close
|
||||
|
||||
5. click `simple_peripheral_cc2650em_app`, Click *build* and it's done
|
||||
|
||||
6. right click `simple_peripheral_cc2650em_stack`
|
||||
|
||||
-> Properties
|
||||
|
||||
-> General
|
||||
|
||||
-> Project: Compiler version
|
||||
|
||||
-> Tool-chain: **Compiler version: TI v20.2.5LTS**
|
||||
|
||||
Device: **Connection: Texas Instrument XDS110 USB Debug Probe[Default]**
|
||||
|
||||
-> apply amd close
|
||||
|
||||
|
||||
|
||||
### select project at CCS
|
||||
1. start CCStudio, Use the directory.`C:\Users\kimwu\workspace_ti_wtp_cc2650_development` -> Launch
|
||||
|
||||
2. Project -> Import CCS Projects -> Select search-directory `E:\MCU_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral` -> OK
|
||||
|
||||
3. select all discovered projects -> finish
|
||||
|
||||
4. right click `simple_peripheral_cc2650em_app` -> Properties -> Build-> Arm Compiler -> Include Options
|
||||
-> change `"D:\MCU_code\wtp_cc2650_simple_func\simplelink\ble_sdk_2_02_02_25\src\examples\simple_peripheral\cc26xx\app\headstage"`
|
||||
to `"E:\MCU_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\src\examples\simple_peripheral\cc26xx\app\headstage"`
|
||||
-> Apply and Close
|
||||
7. click `simple_peripheral_cc2650em_stack` Click *build* and it has error: "C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/osal/src/common/osal.c", line 408: error #167: too few arguments in function call
|
||||
|
||||
8. modify code: osal.c line:408
|
||||
```c
|
||||
return ( (unsigned char*)ltoa( l, (char *)buf) );
|
||||
```
|
||||
change to
|
||||
|
||||
```c
|
||||
return ( (unsigned char*)ltoa( l, (char *)buf, radix) );
|
||||
```
|
||||
|
||||
9. and then, click *build* and it's done
|
||||
|
||||
|
||||
- Clone this project(with Command line interface `git-bash`)
|
||||
|
||||
1. clone our project to E:\MCU_code\.
|
||||
|
||||
`git clone [WTP_cc2650_development URL]`, where URL is our project url on gitlab.
|
||||
2. copy `E:\MCU_code\wtp_cc2650_development\backup\examples` to `E:\MCU_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25`
|
||||
```linux
|
||||
terminal:
|
||||
$cd /e/MCU_code/wtp_cc2650_development
|
||||
$cp -r ./backup/examples ./simplelink/ble_sdk_2_02_02_25/
|
||||
```
|
||||
|
||||
- select project at CCS
|
||||
1. start CCStudio, Use the directory.
|
||||
|
||||
`C:\Users\kimwu\workspace_ti_wtp_cc2650_development`
|
||||
|
||||
-> Launch
|
||||
|
||||
2. 先設置 device compiler 環境
|
||||
|
||||
- switch branch to elite/edc1.5re
|
||||
|
||||
```linux
|
||||
terminal:
|
||||
$git checkout elite/edc1.5re
|
||||
```
|
||||
|
||||
- Project
|
||||
|
||||
-> Import CCS Projects
|
||||
|
||||
-> Select search-directory `E:\MCU_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral`
|
||||
|
||||
-> OK
|
||||
|
||||
- select all discovered projects
|
||||
|
||||
-> finish
|
||||
|
||||
- right click `simple_peripheral_cc2650em_app`
|
||||
|
||||
-> Properties
|
||||
|
||||
-> Build-> Arm Compiler
|
||||
|
||||
-> Include Options
|
||||
|
||||
-> change `"D:\MCU_code\wtp_cc2650_simple_func\simplelink\ble_sdk_2_02_02_25\src\examples\simple_peripheral\cc26xx\app\headstage"`
|
||||
to `"${SRC_EX}/examples/simple_peripheral/cc26xx/app/headstage"`
|
||||
|
||||
-> Apply and Close
|
||||
|
||||
- and then, click *build* and it's done
|
||||
|
||||
3. 再設置 memory board compiler 環境
|
||||
|
||||
- switch branch to rel/mb/central/v1.7.0
|
||||
```linux
|
||||
terminal:
|
||||
$git checkout rel/mb/central/v1.7.0
|
||||
```
|
||||
|
||||
- Project -> Import CCS Projects
|
||||
|
||||
-> Select search-directory `E:\MCU_code\wtp_cc2650_development\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_central`
|
||||
|
||||
-> OK
|
||||
|
||||
- select all discovered projects
|
||||
|
||||
-> finish
|
||||
|
||||
- right click `simple_central_cc2650em_app`
|
||||
|
||||
-> Properties
|
||||
|
||||
-> Build
|
||||
|
||||
-> Arm Compiler
|
||||
|
||||
-> Advanced Options
|
||||
|
||||
-> Predefined Symbols
|
||||
|
||||
-> add "MODA_MEMORY_BOARD" 、 "BOOSTXL_CC2650MA"
|
||||
|
||||
-> remove "CC2650DK_7ID"
|
||||
|
||||
-> Apply and Close
|
||||
|
||||
- and then, click *build* and it's done
|
||||
|
||||
|
||||
|
||||
* * *
|
||||
|
||||
### Optional
|
||||
|
||||
#### install git if you don't install it
|
||||
- install git if you don't install it
|
||||
|
||||
- https://git-scm.com/download/win
|
||||
- https://git-scm.com/download/win
|
||||
|
||||
- choose corresponding version for your computer from 'Git for Windows Setup'
|
||||
- choose corresponding version for your computer from 'Git for Windows Setup'
|
||||
|
||||
|
||||
#### doxygen: tool to help documenting code
|
||||
- doxygen: tool to help documenting code
|
||||
|
||||
- download from main page http://www.doxygen.nl/download.html
|
||||
- download from main page http://www.doxygen.nl/download.html
|
||||
|
||||
- according to different OS, download corresponding version.
|
||||
- according to different OS, download corresponding version.
|
||||
|
||||
- press keyboard 'ctrl' + 'shift' + 'a' to search external tool, select 'external tools-setting'
|
||||
- press keyboard 'ctrl' + 'shift' + 'a' to search external tool, select 'external tools-setting'
|
||||
|
||||
- add external tool by pressing '+'
|
||||
- add external tool by pressing '+'
|
||||
|
||||
- name this external tool in the column 'name'
|
||||
- name this external tool in the column 'name'
|
||||
|
||||
- set the path of doxygen execute file in the column 'program'
|
||||
- set the path of doxygen execute file in the column 'program'
|
||||
|
||||
- set the repository we want to generate document automatically in the column 'working directory'
|
||||
- set the repository we want to generate document automatically in the column 'working directory'
|
||||
|
||||
- set hotkey of doxygen to run : 'File' -> 'Setting' -> 'Keymap' -> 'external tools'
|
||||
- set hotkey of doxygen to run : 'File' -> 'Setting' -> 'Keymap' -> 'external tools'
|
||||
|
||||
- press the hotkey to run doxygen
|
||||
- press the hotkey to run doxygen
|
||||
|
||||
|
||||
### Troubleshooting
|
||||
- Troubleshooting
|
||||
|
||||
- jump a dialog with **MSVC components failed to install.
|
||||
Please install executables manually from c:/ti/ccsv8/installers before using CCS**
|
||||
- jump a dialog with **MSVC components failed to install.
|
||||
Please install executables manually from c:/ti/ccsv8/installers before using CCS**
|
||||
|
||||
ignore it.
|
||||
ignore it.
|
||||
|
||||
- jumps a warning dialog of Windows Defender
|
||||
- jumps a warning dialog of Windows Defender
|
||||
Allow the network access.
|
||||
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 144 KiB |
|
After Width: | Height: | Size: 128 KiB |
|
After Width: | Height: | Size: 152 KiB |
|
After Width: | Height: | Size: 173 KiB |
|
After Width: | Height: | Size: 203 KiB |
|
After Width: | Height: | Size: 149 KiB |
|
After Width: | Height: | Size: 127 KiB |
|
After Width: | Height: | Size: 112 KiB |
|
After Width: | Height: | Size: 174 KiB |
|
After Width: | Height: | Size: 208 KiB |
|
After Width: | Height: | Size: 155 KiB |
|
After Width: | Height: | Size: 133 KiB |
|
After Width: | Height: | Size: 154 KiB |
|
After Width: | Height: | Size: 171 KiB |
|
After Width: | Height: | Size: 212 KiB |
|
After Width: | Height: | Size: 152 KiB |
|
After Width: | Height: | Size: 135 KiB |
|
After Width: | Height: | Size: 107 KiB |
|
After Width: | Height: | Size: 169 KiB |
|
After Width: | Height: | Size: 203 KiB |
@@ -44,6 +44,8 @@ extern "C" {
|
||||
#define E_LATCH_OFF LOAD2, D6
|
||||
#define E_LATCH_VOUT_SMALL_ON LOAD2, D7
|
||||
|
||||
#define HIGH_Z_OPEN() latch_single_ctrl(E_LATCH_HIGH_Z, 0);
|
||||
#define HIGH_Z_CLOSE() latch_single_ctrl(E_LATCH_HIGH_Z, 1);
|
||||
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);
|
||||
|
||||
@@ -9,8 +9,8 @@ extern "C" {
|
||||
|
||||
#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 ADC_CH_VOUT AIN2_GND
|
||||
|
||||
#define MEASURE_CURRENT() read_adc_data(ADC_CH_CURR, FSR3)
|
||||
#define MEASURE_VOLT() read_adc_data(ADC_CH_VIN, FSR3)
|
||||
|
||||
@@ -67,6 +67,7 @@ enum led_color_e {
|
||||
LED_CLR_MAGENTA,
|
||||
LED_CLR_YELLOWGREEN,
|
||||
LED_CLR_EMERALD,
|
||||
LED_CLR_LOW_BAT,
|
||||
|
||||
LED_CLR_MAX,
|
||||
};
|
||||
|
||||
@@ -26,6 +26,7 @@ const struct led_color_t led_color_list_g[LED_CLR_MAX] = {
|
||||
{0xFF, 0x00, 0xFF}, // LED_CLR_MAGENTA
|
||||
{0x00, 0xA6, 0x64}, // LED_CLR_YELLOWGREEN
|
||||
{0x78, 0xC8, 0x50}, // LED_CLR_EMERALD
|
||||
{0x05, 0x35, 0x9E}, // LED_CLR_LOW_BAT (orange)
|
||||
};
|
||||
|
||||
static int __led_single_set(struct led_series_data_t *led_s_d, struct led_frame_t *led_f, enum led_series_nb_e led_nb)
|
||||
|
||||
@@ -604,48 +604,48 @@ struct correction_ctx_t Correction = {
|
||||
.ADC_current[3].coeff = 30800455379,
|
||||
.ADC_current[3].offset = (-501709286949801),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10513739),
|
||||
.Usercode2DAC[0].offset = 582219968611,
|
||||
.Usercode2DAC[0].coeff = (-10514623),
|
||||
.Usercode2DAC[0].offset = 582327592403,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178675535),
|
||||
.Usercode2DAC[1].offset = 4787365510181,
|
||||
.Usercode2DAC[1].offset = 4786928374132,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6287576),
|
||||
.ADC_Vout_volt[0].offset = 102718216344,
|
||||
.ADC_Vout_volt[0].coeff = (-6253328),
|
||||
.ADC_Vout_volt[0].offset = 101918078788,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_C7_05
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6270,
|
||||
.ADC_volt[0].offset = (-101708636),
|
||||
.ADC_volt[0].coeff = 6269,
|
||||
.ADC_volt[0].offset = (-101813048),
|
||||
|
||||
.ADC_volt[1].coeff = 215326,
|
||||
.ADC_volt[1].offset = (-3500271646),
|
||||
.ADC_volt[1].coeff = 215354,
|
||||
.ADC_volt[1].offset = (-3500610940),
|
||||
|
||||
.ADC_volt[2].coeff = 6248605,
|
||||
.ADC_volt[2].offset = (-101537997610),
|
||||
.ADC_volt[2].coeff = 6248559,
|
||||
.ADC_volt[2].offset = (-101543256078),
|
||||
|
||||
.ADC_current[0].coeff = 3137340,
|
||||
.ADC_current[0].offset = (-51089248567),
|
||||
.ADC_current[0].coeff = 3144823,
|
||||
.ADC_current[0].offset = (-51183412127),
|
||||
|
||||
.ADC_current[1].coeff = 71976315,
|
||||
.ADC_current[1].offset = (-1171632911763),
|
||||
.ADC_current[1].coeff = 72137934,
|
||||
.ADC_current[1].offset = (-1174253060754),
|
||||
|
||||
.ADC_current[2].coeff = 1463669941,
|
||||
.ADC_current[2].offset = (-23824343179693),
|
||||
.ADC_current[2].coeff = 1470780978,
|
||||
.ADC_current[2].offset = (-23938930473261),
|
||||
|
||||
.ADC_current[3].coeff = 30765153597,
|
||||
.ADC_current[3].offset = (-500795713627025),
|
||||
.ADC_current[3].coeff = 30871875361,
|
||||
.ADC_current[3].offset = (-502531399257398),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10508598),
|
||||
.Usercode2DAC[0].offset = 581941588060,
|
||||
.Usercode2DAC[0].coeff = (-10511339),
|
||||
.Usercode2DAC[0].offset = 582043250535,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178181743),
|
||||
.Usercode2DAC[1].offset = 4774410348777,
|
||||
.Usercode2DAC[1].coeff = (-178194193),
|
||||
.Usercode2DAC[1].offset = 4774760094641,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6240501),
|
||||
.ADC_Vout_volt[0].offset = 101578728712,
|
||||
.ADC_Vout_volt[0].coeff = (-6239525),
|
||||
.ADC_Vout_volt[0].offset = 101557531789,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -848,8 +848,8 @@ struct correction_ctx_t Correction = {
|
||||
.Usercode2DAC[1].coeff = (-178253119),
|
||||
.Usercode2DAC[1].offset = 4776203208556,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6279589),
|
||||
.ADC_Vout_volt[0].offset = 102655566741,
|
||||
.ADC_Vout_volt[0].coeff = (-6220139),
|
||||
.ADC_Vout_volt[0].offset = 100997305774,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -923,35 +923,35 @@ struct correction_ctx_t Correction = {
|
||||
|
||||
#ifdef BOARD_F0_10
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6264,
|
||||
.ADC_volt[0].offset = (-101827242),
|
||||
.ADC_volt[0].coeff = 6265,
|
||||
.ADC_volt[0].offset = (-102044175),
|
||||
|
||||
.ADC_volt[1].coeff = 215510,
|
||||
.ADC_volt[1].offset = (-3511696676),
|
||||
.ADC_volt[1].coeff = 215568,
|
||||
.ADC_volt[1].offset = (-3513041278),
|
||||
|
||||
.ADC_volt[2].coeff = 6290202,
|
||||
.ADC_volt[2].offset = (-102477894660),
|
||||
.ADC_volt[2].coeff = 6291508,
|
||||
.ADC_volt[2].offset = (-102503354601),
|
||||
|
||||
.ADC_current[0].coeff = 3130598,
|
||||
.ADC_current[0].offset = (-50933088275),
|
||||
.ADC_current[0].coeff = 3130478,
|
||||
.ADC_current[0].offset = (-50927860729),
|
||||
|
||||
.ADC_current[1].coeff = 71666311,
|
||||
.ADC_current[1].offset = (-1166101924066),
|
||||
.ADC_current[1].coeff = 71668268,
|
||||
.ADC_current[1].offset = (-1166167114301),
|
||||
|
||||
.ADC_current[2].coeff = 1457527703,
|
||||
.ADC_current[2].offset = (-23714693740871),
|
||||
.ADC_current[2].coeff = 1455740220,
|
||||
.ADC_current[2].offset = (-23685588119096),
|
||||
|
||||
.ADC_current[3].coeff = 30743976838,
|
||||
.ADC_current[3].offset = (-500271783722752),
|
||||
.ADC_current[3].coeff = 30724351409,
|
||||
.ADC_current[3].offset = (-499938195908892),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10586934),
|
||||
.Usercode2DAC[0].offset = 584427803593,
|
||||
.Usercode2DAC[0].coeff = (-10589030),
|
||||
.Usercode2DAC[0].offset = 584528260879,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178989664),
|
||||
.Usercode2DAC[1].offset = 4795123745196,
|
||||
.Usercode2DAC[1].coeff = (-178994142),
|
||||
.Usercode2DAC[1].offset = 4795272847587,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6267473),
|
||||
.ADC_Vout_volt[0].offset = 101911592737,
|
||||
.ADC_Vout_volt[0].coeff = (-6266232),
|
||||
.ADC_Vout_volt[0].offset = 101900496712,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -984,76 +984,79 @@ struct correction_ctx_t Correction = {
|
||||
.Usercode2DAC[1].coeff = (-178890877),
|
||||
.Usercode2DAC[1].offset = 4792844364937,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6268586),
|
||||
.ADC_Vout_volt[0].offset = 102208366701,
|
||||
// .ADC_Vout_volt[0].coeff = (-6268586),
|
||||
// .ADC_Vout_volt[0].offset = 102208366701,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6294265),
|
||||
.ADC_Vout_volt[0].offset = 102439579115,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_EF_30
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6224,
|
||||
.ADC_volt[0].offset = (-101482705),
|
||||
.ADC_volt[0].coeff = 6225,
|
||||
.ADC_volt[0].offset = (-101627266),
|
||||
|
||||
.ADC_volt[1].coeff = 215101,
|
||||
.ADC_volt[1].offset = (-3509641322),
|
||||
.ADC_volt[1].coeff = 215149,
|
||||
.ADC_volt[1].offset = (-3511057579),
|
||||
|
||||
.ADC_volt[2].coeff = 6246780,
|
||||
.ADC_volt[2].offset = (-101898385637),
|
||||
.ADC_volt[2].coeff = 6248130,
|
||||
.ADC_volt[2].offset = (-101942172967),
|
||||
|
||||
.ADC_current[0].coeff = 3128363,
|
||||
.ADC_current[0].offset = (-50740267256),
|
||||
.ADC_current[0].coeff = 3126816,
|
||||
.ADC_current[0].offset = (-50730387482),
|
||||
|
||||
.ADC_current[1].coeff = 71567078,
|
||||
.ADC_current[1].offset = (-1161022341958),
|
||||
.ADC_current[1].coeff = 71569011,
|
||||
.ADC_current[1].offset = (-1161194768228),
|
||||
|
||||
.ADC_current[2].coeff = 1458204300,
|
||||
.ADC_current[2].offset = (-23653917452276),
|
||||
.ADC_current[2].coeff = 1454505767,
|
||||
.ADC_current[2].offset = (-23598273597511),
|
||||
|
||||
.ADC_current[3].coeff = 30729271484,
|
||||
.ADC_current[3].offset = (-498485906840636),
|
||||
.ADC_current[3].coeff = 30709412216,
|
||||
.ADC_current[3].offset = (-498226800571450),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10549571),
|
||||
.Usercode2DAC[0].offset = 582512458586,
|
||||
.Usercode2DAC[0].coeff = (-10551063),
|
||||
.Usercode2DAC[0].offset = 582600574408,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178148358),
|
||||
.Usercode2DAC[1].offset = 4773663573254,
|
||||
.Usercode2DAC[1].coeff = (-178153942),
|
||||
.Usercode2DAC[1].offset = 4773288311275,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6321555),
|
||||
.ADC_Vout_volt[0].offset = 102546560215,
|
||||
.ADC_Vout_volt[0].coeff = (-6316986),
|
||||
.ADC_Vout_volt[0].offset = 102477154168,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_EF_50
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6283,
|
||||
.ADC_volt[0].offset = (-101767945),
|
||||
.ADC_volt[0].coeff = 6225,
|
||||
.ADC_volt[0].offset = (-101618312),
|
||||
|
||||
.ADC_volt[1].coeff = 216065,
|
||||
.ADC_volt[1].offset = (-3501551610),
|
||||
.ADC_volt[1].coeff = 215145,
|
||||
.ADC_volt[1].offset = (-3510989671),
|
||||
|
||||
.ADC_volt[2].coeff = 6306682,
|
||||
.ADC_volt[2].offset = (-102180214441),
|
||||
.ADC_volt[2].coeff = 6247552,
|
||||
.ADC_volt[2].offset = (-101927817096),
|
||||
|
||||
.ADC_current[0].coeff = 3128182,
|
||||
.ADC_current[0].offset = (-50737329547),
|
||||
.ADC_current[0].coeff = 3126845,
|
||||
.ADC_current[0].offset = (-50724794193),
|
||||
|
||||
.ADC_current[1].coeff = 71641515,
|
||||
.ADC_current[1].offset = (-1162021060417),
|
||||
.ADC_current[1].coeff = 71570973,
|
||||
.ADC_current[1].offset = (-1161201810400),
|
||||
|
||||
.ADC_current[2].coeff = 1458995896,
|
||||
.ADC_current[2].offset = (-23664100171335),
|
||||
.ADC_current[2].coeff = 1454921704,
|
||||
.ADC_current[2].offset = (-23601524459072),
|
||||
|
||||
.ADC_current[3].coeff = 30772918949,
|
||||
.ADC_current[3].offset = (-499127290875218),
|
||||
.ADC_current[3].coeff = 30725601837,
|
||||
.ADC_current[3].offset = (-498468641607526),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10569684),
|
||||
.Usercode2DAC[0].offset = 583829765172,
|
||||
.Usercode2DAC[0].coeff = (-10570997),
|
||||
.Usercode2DAC[0].offset = 583893803683,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-179104179),
|
||||
.Usercode2DAC[1].offset = 4797937207579,
|
||||
.Usercode2DAC[1].coeff = (-179121228),
|
||||
.Usercode2DAC[1].offset = 4798271733613,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6255163),
|
||||
.ADC_Vout_volt[0].offset = 101420622200,
|
||||
.ADC_Vout_volt[0].coeff = (-6256034),
|
||||
.ADC_Vout_volt[0].offset = 101461890090,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1329,37 +1332,37 @@ struct correction_ctx_t Correction = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_F0_D6
|
||||
#ifdef BOARD_33
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6241,
|
||||
.ADC_volt[0].offset = (-101304384),
|
||||
.ADC_volt[0].coeff = 6237,
|
||||
.ADC_volt[0].offset = (-101455030),
|
||||
|
||||
.ADC_volt[1].coeff = 214311,
|
||||
.ADC_volt[1].offset = (-3488649993),
|
||||
.ADC_volt[1].coeff = 214265,
|
||||
.ADC_volt[1].offset = (-3487092245),
|
||||
|
||||
.ADC_volt[2].coeff = 6257745,
|
||||
.ADC_volt[2].offset = (-101849976860),
|
||||
.ADC_volt[2].coeff = 6256397,
|
||||
.ADC_volt[2].offset = (-101799846487),
|
||||
|
||||
.ADC_current[0].coeff = 3132731,
|
||||
.ADC_current[0].offset = (-50996576598),
|
||||
.ADC_current[0].coeff = 3134559,
|
||||
.ADC_current[0].offset = (-51000796097),
|
||||
|
||||
.ADC_current[1].coeff = 71830539,
|
||||
.ADC_current[1].offset = (-1169069919126),
|
||||
.ADC_current[1].coeff = 71833792,
|
||||
.ADC_current[1].offset = (-1168845243874),
|
||||
|
||||
.ADC_current[2].coeff = 1459933756,
|
||||
.ADC_current[2].offset = (-23758077806427),
|
||||
.ADC_current[2].coeff = 1457375736,
|
||||
.ADC_current[2].offset = (-23712358183121),
|
||||
|
||||
.ADC_current[3].coeff = 30677690111,
|
||||
.ADC_current[3].offset = (-499219141105443),
|
||||
.ADC_current[3].coeff = 30705728614,
|
||||
.ADC_current[3].offset = (-499576184270009),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10537841),
|
||||
.Usercode2DAC[0].offset = 582836251520,
|
||||
.Usercode2DAC[0].coeff = (-10540269),
|
||||
.Usercode2DAC[0].offset = 582832342863,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178609851),
|
||||
.Usercode2DAC[1].offset = 4785293091556,
|
||||
.Usercode2DAC[1].coeff = (-178624388),
|
||||
.Usercode2DAC[1].offset = 4785585799142,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6278711),
|
||||
.ADC_Vout_volt[0].offset = 101747778735,
|
||||
.ADC_Vout_volt[0].coeff = (-6278424),
|
||||
.ADC_Vout_volt[0].offset = 101716668226,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -2072,8 +2075,8 @@ struct correction_ctx_t Correction = {
|
||||
.Usercode2DAC[1].coeff = (-178938545),
|
||||
.Usercode2DAC[1].offset = 4791672708498,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6287121),
|
||||
.ADC_Vout_volt[0].offset = 101919340594,
|
||||
.ADC_Vout_volt[0].coeff = (-6290289),
|
||||
.ADC_Vout_volt[0].offset = 101948252657,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -2100,14 +2103,14 @@ struct correction_ctx_t Correction = {
|
||||
.ADC_current[3].coeff = 30728459175,
|
||||
.ADC_current[3].offset = (-501347924376505),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10522914),
|
||||
.Usercode2DAC[0].offset = 582323677692,
|
||||
.Usercode2DAC[0].coeff = (-10523008),
|
||||
.Usercode2DAC[0].offset = 582337733055,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178029958),
|
||||
.Usercode2DAC[1].offset = 4770650014378,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6278317),
|
||||
.ADC_Vout_volt[0].offset = 102365137425,
|
||||
.ADC_Vout_volt[0].coeff = (-6278757),
|
||||
.ADC_Vout_volt[0].offset = 102372047377,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -2168,14 +2171,14 @@ struct correction_ctx_t Correction = {
|
||||
.ADC_current[3].coeff = 30772133023,
|
||||
.ADC_current[3].offset = (-501193399098681),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10525509),
|
||||
.Usercode2DAC[0].offset = 583168750255,
|
||||
.Usercode2DAC[0].coeff = (-10525471),
|
||||
.Usercode2DAC[0].offset = 583189390824,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178502405),
|
||||
.Usercode2DAC[1].offset = 4783222906500,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6246238),
|
||||
.ADC_Vout_volt[0].offset = 101174300735,
|
||||
.ADC_Vout_volt[0].coeff = (-6246261),
|
||||
.ADC_Vout_volt[0].offset = 101085080282,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -2304,17 +2307,630 @@ struct correction_ctx_t Correction = {
|
||||
.ADC_current[3].coeff = 30691748879,
|
||||
.ADC_current[3].offset = (-498801800724347),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10538563),
|
||||
.Usercode2DAC[0].offset = 583007751105,
|
||||
.Usercode2DAC[0].coeff = (-10533019),
|
||||
.Usercode2DAC[0].offset = 582641154592,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178520622),
|
||||
.Usercode2DAC[1].offset = 4783591915817,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6245655),
|
||||
.ADC_Vout_volt[0].offset = 101405660400,
|
||||
.ADC_Vout_volt[0].coeff = (-6263836),
|
||||
.ADC_Vout_volt[0].offset = 101716253010,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_22
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6265,
|
||||
.ADC_volt[0].offset = (-102238659),
|
||||
|
||||
.ADC_volt[1].coeff = 215666,
|
||||
.ADC_volt[1].offset = (-3523733071),
|
||||
|
||||
.ADC_volt[2].coeff = 6281019,
|
||||
.ADC_volt[2].offset = (-102607574036),
|
||||
|
||||
.ADC_current[0].coeff = 3117685,
|
||||
.ADC_current[0].offset = (-50891354366),
|
||||
|
||||
.ADC_current[1].coeff = 71664440,
|
||||
.ADC_current[1].offset = (-1170062448388),
|
||||
|
||||
.ADC_current[2].coeff = 1453230203,
|
||||
.ADC_current[2].offset = (-23727270940921),
|
||||
|
||||
.ADC_current[3].coeff = 30744385993,
|
||||
.ADC_current[3].offset = (-501949279942466),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10559090),
|
||||
.Usercode2DAC[0].offset = 585205338442,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178804719),
|
||||
.Usercode2DAC[1].offset = 4791979065499,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6264062),
|
||||
.ADC_Vout_volt[0].offset = 102147147764,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_23
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6246,
|
||||
.ADC_volt[0].offset = (-101834271),
|
||||
|
||||
.ADC_volt[1].coeff = 214817,
|
||||
.ADC_volt[1].offset = (-3504630035),
|
||||
|
||||
.ADC_volt[2].coeff = 6242155,
|
||||
.ADC_volt[2].offset = (-101815366298),
|
||||
|
||||
.ADC_current[0].coeff = 3117784,
|
||||
.ADC_current[0].offset = (-50723747715),
|
||||
|
||||
.ADC_current[1].coeff = 71786481,
|
||||
.ADC_current[1].offset = (-1168005098689),
|
||||
|
||||
.ADC_current[2].coeff = 1456687834,
|
||||
.ADC_current[2].offset = (-23695941580383),
|
||||
|
||||
.ADC_current[3].coeff = 30751319703,
|
||||
.ADC_current[3].offset = (-500307035913259),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10559652),
|
||||
.Usercode2DAC[0].offset = 585312217983,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178702823),
|
||||
.Usercode2DAC[1].offset = 4789521529638,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6246051),
|
||||
.ADC_Vout_volt[0].offset = 101364913234,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_24
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6269,
|
||||
.ADC_volt[0].offset = (-102371985),
|
||||
|
||||
.ADC_volt[1].coeff = 215426,
|
||||
.ADC_volt[1].offset = (-3519852615),
|
||||
|
||||
.ADC_volt[2].coeff = 6289743,
|
||||
.ADC_volt[2].offset = (-102741632981),
|
||||
|
||||
.ADC_current[0].coeff = 3123620,
|
||||
.ADC_current[0].offset = (-50878963042),
|
||||
|
||||
.ADC_current[1].coeff = 71897961,
|
||||
.ADC_current[1].offset = (-1171173265898),
|
||||
|
||||
.ADC_current[2].coeff = 1458335466,
|
||||
.ADC_current[2].offset = (-23755136584192),
|
||||
|
||||
.ADC_current[3].coeff = 30754197788,
|
||||
.ADC_current[3].offset = (-500955744139560),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10531965),
|
||||
.Usercode2DAC[0].offset = 583045401341,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178973598),
|
||||
.Usercode2DAC[1].offset = 4794616083098,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6247139),
|
||||
.ADC_Vout_volt[0].offset = 102266969798,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_25
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6259,
|
||||
.ADC_volt[0].offset = (-100906460),
|
||||
|
||||
.ADC_volt[1].coeff = 215387,
|
||||
.ADC_volt[1].offset = (-3477115000),
|
||||
|
||||
.ADC_volt[2].coeff = 6280117,
|
||||
.ADC_volt[2].offset = (-101367770021),
|
||||
|
||||
.ADC_current[0].coeff = 3142737,
|
||||
.ADC_current[0].offset = (-50912916739),
|
||||
|
||||
.ADC_current[1].coeff = 71830513,
|
||||
.ADC_current[1].offset = (-1163727489761),
|
||||
|
||||
.ADC_current[2].coeff = 1459146639,
|
||||
.ADC_current[2].offset = (-23637891932849),
|
||||
|
||||
.ADC_current[3].coeff = 30737911805,
|
||||
.ADC_current[3].offset = (-497956559680527),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10538107),
|
||||
.Usercode2DAC[0].offset = 581974515579,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-179241918),
|
||||
.Usercode2DAC[1].offset = 4800217823823,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6252217),
|
||||
.ADC_Vout_volt[0].offset = 100459702001,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_26
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6271,
|
||||
.ADC_volt[0].offset = (-102212976),
|
||||
|
||||
.ADC_volt[1].coeff = 215307,
|
||||
.ADC_volt[1].offset = (-3508534812),
|
||||
|
||||
.ADC_volt[2].coeff = 6259217,
|
||||
.ADC_volt[2].offset = (-101975646807),
|
||||
|
||||
.ADC_current[0].coeff = 3117078,
|
||||
.ADC_current[0].offset = (-50763039812),
|
||||
|
||||
.ADC_current[1].coeff = 71606560,
|
||||
.ADC_current[1].offset = (-1166202042177),
|
||||
|
||||
.ADC_current[2].coeff = 1454618433,
|
||||
.ADC_current[2].offset = (-23688587866431),
|
||||
|
||||
.ADC_current[3].coeff = 30575482137,
|
||||
.ADC_current[3].offset = (-497947921109186),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10517147),
|
||||
.Usercode2DAC[0].offset = 581355114556,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178259895),
|
||||
.Usercode2DAC[1].offset = 4775537428945,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6239667),
|
||||
.ADC_Vout_volt[0].offset = 101618247506,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_27
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6280,
|
||||
.ADC_volt[0].offset = (-102420482),
|
||||
|
||||
.ADC_volt[1].coeff = 215531,
|
||||
.ADC_volt[1].offset = (-3514073301),
|
||||
|
||||
.ADC_volt[2].coeff = 6278633,
|
||||
.ADC_volt[2].offset = (-102342343153),
|
||||
|
||||
.ADC_current[0].coeff = 3124523,
|
||||
.ADC_current[0].offset = (-50857660549),
|
||||
|
||||
.ADC_current[1].coeff = 71611024,
|
||||
.ADC_current[1].offset = (-1165596393940),
|
||||
|
||||
.ADC_current[2].coeff = 1456815320,
|
||||
.ADC_current[2].offset = (-23710661083268),
|
||||
|
||||
.ADC_current[3].coeff = 30535651038,
|
||||
.ADC_current[3].offset = (-497004648381251),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10581655),
|
||||
.Usercode2DAC[0].offset = 583870065329,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178861456),
|
||||
.Usercode2DAC[1].offset = 4791438555456,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6234702),
|
||||
.ADC_Vout_volt[0].offset = 101641687363,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_28
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6323,
|
||||
.ADC_volt[0].offset = (-102642791),
|
||||
|
||||
.ADC_volt[1].coeff = 216810,
|
||||
.ADC_volt[1].offset = (-3517634300),
|
||||
|
||||
.ADC_volt[2].coeff = 6316545,
|
||||
.ADC_volt[2].offset = (-102455301502),
|
||||
|
||||
.ADC_current[0].coeff = 3115138,
|
||||
.ADC_current[0].offset = (-50604325502),
|
||||
|
||||
.ADC_current[1].coeff = 71803482,
|
||||
.ADC_current[1].offset = (-1166497894902),
|
||||
|
||||
.ADC_current[2].coeff = 1454907213,
|
||||
.ADC_current[2].offset = (-23634072061022),
|
||||
|
||||
.ADC_current[3].coeff = 30500463970,
|
||||
.ADC_current[3].offset = (-495479520913833),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10576656),
|
||||
.Usercode2DAC[0].offset = 583571679995,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178051142),
|
||||
.Usercode2DAC[1].offset = 4771027513848,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6208633),
|
||||
.ADC_Vout_volt[0].offset = 101267011106,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_29
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6273,
|
||||
.ADC_volt[0].offset = (-102778246),
|
||||
|
||||
.ADC_volt[1].coeff = 215201,
|
||||
.ADC_volt[1].offset = (-3530824456),
|
||||
|
||||
.ADC_volt[2].coeff = 6265268,
|
||||
.ADC_volt[2].offset = (-102774563158),
|
||||
|
||||
.ADC_current[0].coeff = 3104221,
|
||||
.ADC_current[0].offset = (-50623744309),
|
||||
|
||||
.ADC_current[1].coeff = 71378018,
|
||||
.ADC_current[1].offset = (-1164103109327),
|
||||
|
||||
.ADC_current[2].coeff = 1452168578,
|
||||
.ADC_current[2].offset = (-23681013484180),
|
||||
|
||||
.ADC_current[3].coeff = 30433406851,
|
||||
.ADC_current[3].offset = (-496330318436492),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10528279),
|
||||
.Usercode2DAC[0].offset = 582340200416,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178160205),
|
||||
.Usercode2DAC[1].offset = 4773766362066,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6265997),
|
||||
.ADC_Vout_volt[0].offset = 102416665324,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_30
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6192,
|
||||
.ADC_volt[0].offset = (-101325473),
|
||||
|
||||
.ADC_volt[1].coeff = 213222,
|
||||
.ADC_volt[1].offset = (-3488594513),
|
||||
|
||||
.ADC_volt[2].coeff = 6204761,
|
||||
.ADC_volt[2].offset = (-101492930405),
|
||||
|
||||
.ADC_current[0].coeff = 3125901,
|
||||
.ADC_current[0].offset = (-50933571693),
|
||||
|
||||
.ADC_current[1].coeff = 71688255,
|
||||
.ADC_current[1].offset = (-1168127344789),
|
||||
|
||||
.ADC_current[2].coeff = 1453189223,
|
||||
.ADC_current[2].offset = (-23677501714303),
|
||||
|
||||
.ADC_current[3].coeff = 30557055266,
|
||||
.ADC_current[3].offset = (-497913600274073),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10508180),
|
||||
.Usercode2DAC[0].offset = 580911728121,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178285026),
|
||||
.Usercode2DAC[1].offset = 4775944030805,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6252740),
|
||||
.ADC_Vout_volt[0].offset = 101371524241,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_31
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6274,
|
||||
.ADC_volt[0].offset = (-102299525),
|
||||
|
||||
.ADC_volt[1].coeff = 216012,
|
||||
.ADC_volt[1].offset = (-3527719530),
|
||||
|
||||
.ADC_volt[2].coeff = 6290092,
|
||||
.ADC_volt[2].offset = (-102703668763),
|
||||
|
||||
.ADC_current[0].coeff = 3137730,
|
||||
.ADC_current[0].offset = (-50901199477),
|
||||
|
||||
.ADC_current[1].coeff = 72061616,
|
||||
.ADC_current[1].offset = (-1169077860275),
|
||||
|
||||
.ADC_current[2].coeff = 1462194415,
|
||||
.ADC_current[2].offset = (-23720235949804),
|
||||
|
||||
.ADC_current[3].coeff = 30666304552,
|
||||
.ADC_current[3].offset = (-497505580276767),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10567174),
|
||||
.Usercode2DAC[0].offset = 582656368880,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178938695),
|
||||
.Usercode2DAC[1].offset = 4792602131903,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6246562),
|
||||
.ADC_Vout_volt[0].offset = 101518895627,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_32
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6256,
|
||||
.ADC_volt[0].offset = (-101726466),
|
||||
|
||||
.ADC_volt[1].coeff = 214901,
|
||||
.ADC_volt[1].offset = (-3494652239),
|
||||
|
||||
.ADC_volt[2].coeff = 6265518,
|
||||
.ADC_volt[2].offset = (-101860749000),
|
||||
|
||||
.ADC_current[0].coeff = 3137692,
|
||||
.ADC_current[0].offset = (-51016804942),
|
||||
|
||||
.ADC_current[1].coeff = 72140042,
|
||||
.ADC_current[1].offset = (-1173010857060),
|
||||
|
||||
.ADC_current[2].coeff = 1465662717,
|
||||
.ADC_current[2].offset = (-23830561290533),
|
||||
|
||||
.ADC_current[3].coeff = 30764787940,
|
||||
.ADC_current[3].offset = (-500226686734714),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10512090),
|
||||
.Usercode2DAC[0].offset = 581678783913,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178879947),
|
||||
.Usercode2DAC[1].offset = 4791503914142,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6216258),
|
||||
.ADC_Vout_volt[0].offset = 101074276780,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_34
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6266,
|
||||
.ADC_volt[0].offset = (-102057552),
|
||||
|
||||
.ADC_volt[1].coeff = 215152,
|
||||
.ADC_volt[1].offset = (-3505776556),
|
||||
|
||||
.ADC_volt[2].coeff = 6247530,
|
||||
.ADC_volt[2].offset = (-101774556705),
|
||||
|
||||
.ADC_current[0].coeff = 3135347,
|
||||
.ADC_current[0].offset = (-51155591320),
|
||||
|
||||
.ADC_current[1].coeff = 71912282,
|
||||
.ADC_current[1].offset = (-1173377232155),
|
||||
|
||||
.ADC_current[2].coeff = 1462013521,
|
||||
.ADC_current[2].offset = (-23853460369807),
|
||||
|
||||
.ADC_current[3].coeff = 30861536514,
|
||||
.ADC_current[3].offset = (-503541385864864),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10528669),
|
||||
.Usercode2DAC[0].offset = 582397433169,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178489372),
|
||||
.Usercode2DAC[1].offset = 4782067563825,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6255030),
|
||||
.ADC_Vout_volt[0].offset = 102118159563,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_35
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6269,
|
||||
.ADC_volt[0].offset = (-101914839),
|
||||
|
||||
.ADC_volt[1].coeff = 214959,
|
||||
.ADC_volt[1].offset = (-3493752987),
|
||||
|
||||
.ADC_volt[2].coeff = 6267030,
|
||||
.ADC_volt[2].offset = (-101834425380),
|
||||
|
||||
.ADC_current[0].coeff = 3130241,
|
||||
.ADC_current[0].offset = (-50964164016),
|
||||
|
||||
.ADC_current[1].coeff = 71937210,
|
||||
.ADC_current[1].offset = (-1171150188188),
|
||||
|
||||
.ADC_current[2].coeff = 1459358035,
|
||||
.ADC_current[2].offset = (-23759236427806),
|
||||
|
||||
.ADC_current[3].coeff = 30776937969,
|
||||
.ADC_current[3].offset = (-501094608703935),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10544074),
|
||||
.Usercode2DAC[0].offset = 581468789380,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178969538),
|
||||
.Usercode2DAC[1].offset = 4792733838744,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6267021),
|
||||
.ADC_Vout_volt[0].offset = 101843399161,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_36
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6281,
|
||||
.ADC_volt[0].offset = (-102123495),
|
||||
|
||||
.ADC_volt[1].coeff = 216252,
|
||||
.ADC_volt[1].offset = (-3515703990),
|
||||
|
||||
.ADC_volt[2].coeff = 6277260,
|
||||
.ADC_volt[2].offset = (-102028401662),
|
||||
|
||||
.ADC_current[0].coeff = 3152607,
|
||||
.ADC_current[0].offset = (-51487356975),
|
||||
|
||||
.ADC_current[1].coeff = 72284272,
|
||||
.ADC_current[1].offset = (-1180436017406),
|
||||
|
||||
.ADC_current[2].coeff = 1467427835,
|
||||
.ADC_current[2].offset = (-23962904666231),
|
||||
|
||||
.ADC_current[3].coeff = 30929911579,
|
||||
.ADC_current[3].offset = (-505100448244360),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10442292),
|
||||
.Usercode2DAC[0].offset = 580714146994,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-177976355),
|
||||
.Usercode2DAC[1].offset = 4769711791877,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6256522),
|
||||
.ADC_Vout_volt[0].offset = 102072185212,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_37
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6212,
|
||||
.ADC_volt[0].offset = (-101615287),
|
||||
|
||||
.ADC_volt[1].coeff = 213529,
|
||||
.ADC_volt[1].offset = (-3493371893),
|
||||
|
||||
.ADC_volt[2].coeff = 6236454,
|
||||
.ADC_volt[2].offset = (-102005196953),
|
||||
|
||||
.ADC_current[0].coeff = 3124706,
|
||||
.ADC_current[0].offset = (-50716788493),
|
||||
|
||||
.ADC_current[1].coeff = 71900140,
|
||||
.ADC_current[1].offset = (-1167040468847),
|
||||
|
||||
.ADC_current[2].coeff = 1456382343,
|
||||
.ADC_current[2].offset = (-23637515080284),
|
||||
|
||||
.ADC_current[3].coeff = 30751452831,
|
||||
.ADC_current[3].offset = (-499127994978925),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10555418),
|
||||
.Usercode2DAC[0].offset = 582941594573,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178890976),
|
||||
.Usercode2DAC[1].offset = 4791943825357,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6263897),
|
||||
.ADC_Vout_volt[0].offset = 101733138808,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_38
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6243,
|
||||
.ADC_volt[0].offset = (-101766094),
|
||||
|
||||
.ADC_volt[1].coeff = 214698,
|
||||
.ADC_volt[1].offset = (-3497938802),
|
||||
|
||||
.ADC_volt[2].coeff = 6251822,
|
||||
.ADC_volt[2].offset = (-101828841596),
|
||||
|
||||
.ADC_current[0].coeff = 3136475,
|
||||
.ADC_current[0].offset = (-50961049124),
|
||||
|
||||
.ADC_current[1].coeff = 71971124,
|
||||
.ADC_current[1].offset = (-1169309879043),
|
||||
|
||||
.ADC_current[2].coeff = 1464557648,
|
||||
.ADC_current[2].offset = (-23793035455836),
|
||||
|
||||
.ADC_current[3].coeff = 30802360296,
|
||||
.ADC_current[3].offset = (-500429036987644),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10512228),
|
||||
.Usercode2DAC[0].offset = 581455512799,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178964504),
|
||||
.Usercode2DAC[1].offset = 4793390963979,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6244072),
|
||||
.ADC_Vout_volt[0].offset = 101795360640,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_39
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6256,
|
||||
.ADC_volt[0].offset = (-101760960),
|
||||
|
||||
.ADC_volt[1].coeff = 215114,
|
||||
.ADC_volt[1].offset = (-3497784640),
|
||||
|
||||
.ADC_volt[2].coeff = 6269088,
|
||||
.ADC_volt[2].offset = (-101909915670),
|
||||
|
||||
.ADC_current[0].coeff = 3127115,
|
||||
.ADC_current[0].offset = (-51038867037),
|
||||
|
||||
.ADC_current[1].coeff = 72028439,
|
||||
.ADC_current[1].offset = (-1175508696397),
|
||||
|
||||
.ADC_current[2].coeff = 1459106337,
|
||||
.ADC_current[2].offset = (-23811256774288),
|
||||
|
||||
.ADC_current[3].coeff = 30743910594,
|
||||
.ADC_current[3].offset = (-501711816817810),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10510690),
|
||||
.Usercode2DAC[0].offset = 582178407408,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178350210),
|
||||
.Usercode2DAC[1].offset = 4778795974043,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6270698),
|
||||
.ADC_Vout_volt[0].offset = 101963443631,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_40
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6283,
|
||||
.ADC_volt[0].offset = (-101813210),
|
||||
|
||||
.ADC_volt[1].coeff = 216252,
|
||||
.ADC_volt[1].offset = (-3505963394),
|
||||
|
||||
.ADC_volt[2].coeff = 6308337,
|
||||
.ADC_volt[2].offset = (-102247905362),
|
||||
|
||||
.ADC_current[0].coeff = 3129650,
|
||||
.ADC_current[0].offset = (-50861921809),
|
||||
|
||||
.ADC_current[1].coeff = 71776770,
|
||||
.ADC_current[1].offset = (-1166339056525),
|
||||
|
||||
.ADC_current[2].coeff = 1459520412,
|
||||
.ADC_current[2].offset = (-23715160633416),
|
||||
|
||||
.ADC_current[3].coeff = 30732290365,
|
||||
.ADC_current[3].offset = (-499378682723182),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10519491),
|
||||
.Usercode2DAC[0].offset = 582197203052,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-177718029),
|
||||
.Usercode2DAC[1].offset = 4762788252522,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6268744),
|
||||
.ADC_Vout_volt[0].offset = 101759799080,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
int32_t DecodeADCValue(uint8_t adc_gain, uint8_t adc_channel, uint16_t adc_rxbuf);
|
||||
uint16_t Usercode_Correction_to_DAC(uint8_t dac_gain, uint16_t usercode);
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ static void WorkModeLED()
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_CYAN);
|
||||
break;
|
||||
|
||||
case CURVE_CALI_ADC:
|
||||
case CURVE_CALI:
|
||||
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) {
|
||||
|
||||
@@ -11,47 +11,32 @@
|
||||
#include <string.h>
|
||||
|
||||
/*notify's input type*/
|
||||
#define NOTIFY_CURRENT 0
|
||||
#define NOTIFY_VOLT 1
|
||||
#define NOTIFY_IMPEDANCE 2
|
||||
#define NOTIFY_CH1 0
|
||||
#define NOTIFY_CH2 1
|
||||
#define NOTIFY_CH3 2
|
||||
#define NOTIFY_VOLT_BAT 3
|
||||
#define NOTIFY_TEMPERATURE 4
|
||||
|
||||
#define FINISH_MODE_INS 0b10100000
|
||||
|
||||
static uint32_t not_time_stamp;
|
||||
static uint8_t NotifyCurrent[4] = {0};
|
||||
static uint8_t NotifyVolt[4] = {0};
|
||||
static uint8_t NotifyImpedance[4] = {0};
|
||||
static uint8_t notify_ch1[4] = {0};
|
||||
static uint8_t notify_ch2[4] = {0};
|
||||
static uint8_t notify_ch3[4] = {0};
|
||||
static uint16_t NotifyVoltBat = 0;
|
||||
static uint16_t NotifyTemperature = 0;
|
||||
static uint16_t NotifyCycleNumber = 0;
|
||||
static bool finishMode = false;
|
||||
static int32_t notify_ch4 = 0;
|
||||
static int32_t notify_ch5 = 0;
|
||||
static int32_t notify_ch6 = 0;
|
||||
|
||||
/*
|
||||
* 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 |
|
||||
| impedance |
|
||||
| time stamp |
|
||||
| cycle number |
|
||||
|
||||
cycle number
|
||||
for cyclic voltammetry use, we save it as channel number.
|
||||
0xFF
|
||||
|
||||
* header = device ID
|
||||
* I = current (nA), V = voltage (uV),
|
||||
* Z = impedance (ohm), T = time (ms)
|
||||
*
|
||||
*
|
||||
*/
|
||||
* +--------+----------+---------+---------+---------+-----------+-----------------+
|
||||
* | id(1B) | time(4B) | ch1(4B) | ch2(4B) | ch3(4B) | cycle(2B) | finish_flag(1B) |
|
||||
* | bat(4B) | notify#(1B) | ch4(4B) | ch5(4B) | ch6(4B) | __(3B) |
|
||||
* +---------+-------------+---------+---------+---------+--------+
|
||||
*/
|
||||
static void SendNotify() {
|
||||
static uint8_t notify_times = 0;
|
||||
uint32_t bat = NotifyVoltBat;
|
||||
@@ -64,9 +49,9 @@ static void SendNotify() {
|
||||
not_buf[0] = instru.chip_id;
|
||||
|
||||
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+5, notify_ch1, sizeof(notify_ch1));
|
||||
memcpy(not_buf+9, notify_ch2, sizeof(notify_ch2));
|
||||
memcpy(not_buf+13, notify_ch3, sizeof(notify_ch3));
|
||||
memcpy(not_buf+17, (uint8_t *)&NotifyCycleNumber, sizeof(NotifyCycleNumber));
|
||||
|
||||
if (finishMode) {
|
||||
@@ -77,8 +62,11 @@ static void SendNotify() {
|
||||
|
||||
memcpy(not_buf+20, (uint8_t *)&bat, sizeof(bat));
|
||||
memcpy(not_buf+24, ¬ify_times, sizeof(notify_times));
|
||||
memcpy(not_buf+25, (uint8_t *)¬ify_ch4, sizeof(notify_ch4));
|
||||
memcpy(not_buf+29, (uint8_t *)¬ify_ch5, sizeof(notify_ch5));
|
||||
memcpy(not_buf+33, (uint8_t *)¬ify_ch6, sizeof(notify_ch6));
|
||||
|
||||
for (int i = 25; i < BLE_DAT_BUFF_SIZE; i++){
|
||||
for (int i = 37; i < BLE_DAT_BUFF_SIZE; i++){
|
||||
not_buf[i] = 0;
|
||||
}
|
||||
|
||||
@@ -110,10 +98,13 @@ static void initRawDataBuf(){
|
||||
finishMode = false;
|
||||
|
||||
for (int i = 0; i < 4; i++){
|
||||
NotifyCurrent[i] = 0;
|
||||
NotifyVolt[i] = 0;
|
||||
NotifyImpedance[i] = 0;
|
||||
notify_ch1[i] = 0;
|
||||
notify_ch2[i] = 0;
|
||||
notify_ch3[i] = 0;
|
||||
}
|
||||
notify_ch4 = 0;
|
||||
notify_ch5 = 0;
|
||||
notify_ch6 = 0;
|
||||
}
|
||||
|
||||
static void FlushNotify(){
|
||||
@@ -128,16 +119,16 @@ static void FlushNotify(){
|
||||
static void InputNotify(int NotifyType, int32_t Data){
|
||||
|
||||
switch (NotifyType) {
|
||||
case NOTIFY_CURRENT:
|
||||
memcpy(NotifyCurrent, (uint8_t *)&Data, sizeof(Data));
|
||||
case NOTIFY_CH1:
|
||||
memcpy(notify_ch1, (uint8_t *)&Data, sizeof(Data));
|
||||
break;
|
||||
|
||||
case NOTIFY_IMPEDANCE:
|
||||
memcpy(NotifyImpedance, (uint8_t *)&Data, sizeof(Data));
|
||||
case NOTIFY_CH3:
|
||||
memcpy(notify_ch3, (uint8_t *)&Data, sizeof(Data));
|
||||
break;
|
||||
|
||||
case NOTIFY_VOLT :
|
||||
memcpy(NotifyVolt, (uint8_t *)&Data, sizeof(Data));
|
||||
case NOTIFY_CH2 :
|
||||
memcpy(notify_ch2, (uint8_t *)&Data, sizeof(Data));
|
||||
break;
|
||||
|
||||
case NOTIFY_VOLT_BAT :
|
||||
|
||||
@@ -205,6 +205,17 @@ struct wm_ocp_ctx_t {
|
||||
struct wm_meas_t measure;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct wm_adc_cali_ctx_t {
|
||||
struct wm_meas_t measure;
|
||||
uint16_t _cali_count;
|
||||
int32_t _ADCValueSUM;
|
||||
};
|
||||
|
||||
#define GET_ADC_SUM(_m) (((struct wm_adc_cali_ctx_t *)(_m))->_ADCValueSUM)
|
||||
#define GET_CALI_COUNT(_m) (((struct wm_adc_cali_ctx_t *)(_m))->_cali_count)
|
||||
|
||||
struct wm_cp_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
@@ -708,6 +719,29 @@ static int __ocp_create(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __adc_cali_create()
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_adc_cali_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_adc_cali_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->_ADCValueSUM = 0;
|
||||
p->_cali_count = 0;
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __cp_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
@@ -800,6 +834,9 @@ int wm_init(void)
|
||||
case CURVE_DPV_ADVANCE_SMPRATE:
|
||||
if (__dpv_advance_create()) return -2;
|
||||
break;
|
||||
case CURVE_CALI:
|
||||
if (__adc_cali_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_CP:
|
||||
if (__cp_create()) return -2;
|
||||
|
||||
@@ -35,9 +35,19 @@ 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;
|
||||
bat_volt = ADC_rxbuf;
|
||||
bat_volt = (400 * bat_volt) - 268300; // uV
|
||||
|
||||
bat_volt /= 1e3;
|
||||
|
||||
|
||||
// initCISBuf();
|
||||
// cis_buf[0] = 6; //data len
|
||||
// cis_buf[1] = BAT_DEV_TEST;
|
||||
// cis_buf[2] = (uint8_t)(bat_volt >> 8);
|
||||
// cis_buf[3] = (uint8_t)(bat_volt);
|
||||
|
||||
// SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
|
||||
InputNotify(NOTIFY_VOLT_BAT, bat_volt);
|
||||
}
|
||||
@@ -91,7 +101,10 @@ static void measureBat(){
|
||||
}
|
||||
|
||||
uint16_t bat = NotifyVoltBat;
|
||||
if( bat < 768 && bat > 20){
|
||||
|
||||
if( bat < 2900 && bat > 20){
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_LOW_BAT);
|
||||
CPUdelay_ms(500);
|
||||
latch_single_ctrl(E_LATCH_5V_ENABLE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ enum all_mode_e {
|
||||
CURVE_DPV_ADVANCE = 0x10,
|
||||
CURVE_DPV_ADVANCE_SMPRATE = 0x11,
|
||||
|
||||
CURVE_CALI_ADC = 0xF1, // Cali ADC - test
|
||||
CURVE_CALI = 0xF1,
|
||||
|
||||
|
||||
SET_SAMPLE_RATE = 0xE0,
|
||||
|
||||
@@ -65,7 +65,7 @@ static void CalcuResistance()
|
||||
int64_t current = (int64_t)(m->_measureCurrent);
|
||||
|
||||
resist = volt * 1000000 / current; //R = V / Iin; [mOhm]
|
||||
InputNotify(NOTIFY_IMPEDANCE, resist);
|
||||
InputNotify(NOTIFY_CH3, resist);
|
||||
}
|
||||
|
||||
static void DACenable(uint8_t afterRead){
|
||||
@@ -274,9 +274,9 @@ static void read_Vout_change_gain(void)
|
||||
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;
|
||||
void *wm = wm_get();
|
||||
int64_t curr_avg = 0;
|
||||
uint32_t m;
|
||||
uint32_t t = time;
|
||||
@@ -285,7 +285,7 @@ void EliteCalcAvg(uint32_t time)
|
||||
|
||||
if (calc_avg_en) {
|
||||
cnt++;
|
||||
curr_sum = curr_sum + meas->_measureCurrent;
|
||||
curr_sum = curr_sum + MEAS_CURR(wm);
|
||||
|
||||
} else {
|
||||
curr_avg = curr_sum / cnt;
|
||||
@@ -295,11 +295,11 @@ void EliteCalcAvg(uint32_t time)
|
||||
}
|
||||
|
||||
if (m < p->_t_pa[0]) {
|
||||
InputNotify(NOTIFY_CURRENT, curr_avg);
|
||||
InputNotify(NOTIFY_CH1, curr_avg);
|
||||
SendNotify();
|
||||
|
||||
} else if (m < p->_t_pa[1]) {
|
||||
InputNotify(NOTIFY_VOLT, curr_avg);
|
||||
InputNotify(NOTIFY_CH2, curr_avg);
|
||||
SendNotify();
|
||||
|
||||
} else if (m < p->_t_pa[2]) {
|
||||
@@ -320,9 +320,9 @@ void EliteCalcAvg(uint32_t time)
|
||||
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;
|
||||
void *wm = wm_get();
|
||||
int64_t curr_avg = 0;
|
||||
uint32_t m;
|
||||
uint32_t t = time;
|
||||
@@ -332,10 +332,10 @@ void dpv_EliteCalcAvg(uint32_t time)
|
||||
|
||||
if (calc_avg_en) {
|
||||
cnt++;
|
||||
curr_sum = curr_sum + meas->_measureCurrent;
|
||||
curr_sum = curr_sum + MEAS_CURR(wm);
|
||||
if (first_v_rec) {
|
||||
InputNotify(NOTIFY_VOLT, instru.Vout/200 - meas->_measureVin);
|
||||
InputNotify(NOTIFY_IMPEDANCE, instru.Vout/200);
|
||||
InputNotify(NOTIFY_CH2, instru.Vout/200 - MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CH3, instru.Vout/200);
|
||||
first_v_rec = false;
|
||||
}
|
||||
|
||||
@@ -348,11 +348,11 @@ void dpv_EliteCalcAvg(uint32_t time)
|
||||
}
|
||||
|
||||
if (m < p->_t_pa[0]) {
|
||||
InputNotify(NOTIFY_CURRENT, curr_avg);
|
||||
InputNotify(NOTIFY_CH1, curr_avg);
|
||||
SendNotify();
|
||||
|
||||
} else if (m < p->_t_pa[1]) {
|
||||
InputNotify(NOTIFY_CURRENT, curr_avg);
|
||||
InputNotify(NOTIFY_CH1, curr_avg);
|
||||
SendNotify();
|
||||
|
||||
} else if (m < p->_t_pa[2]) {
|
||||
@@ -373,9 +373,9 @@ void dpv_EliteCalcAvg(uint32_t time)
|
||||
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;
|
||||
void *wm = wm_get();
|
||||
int64_t curr_avg = 0;
|
||||
uint32_t m;
|
||||
uint32_t t = time;
|
||||
@@ -385,10 +385,10 @@ void dpv_advance_EliteCalcAvg(uint32_t time)
|
||||
|
||||
if (calc_avg_en) {
|
||||
cnt++;
|
||||
curr_sum = curr_sum + meas->_measureCurrent;
|
||||
curr_sum = curr_sum + MEAS_CURR(wm);
|
||||
if (first_v_rec) {
|
||||
InputNotify(NOTIFY_VOLT, instru.Vout/200 - meas->_measureVin);
|
||||
InputNotify(NOTIFY_IMPEDANCE, instru.Vout/200);
|
||||
InputNotify(NOTIFY_CH2, instru.Vout/200 - MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CH3, instru.Vout/200);
|
||||
first_v_rec = false;
|
||||
}
|
||||
|
||||
@@ -401,11 +401,11 @@ void dpv_advance_EliteCalcAvg(uint32_t time)
|
||||
}
|
||||
|
||||
if (m < p->_t_pa[0]) {
|
||||
InputNotify(NOTIFY_CURRENT, curr_avg);
|
||||
InputNotify(NOTIFY_CH1, curr_avg);
|
||||
SendNotify();
|
||||
|
||||
} else if (m < p->_t_pa[1]) {
|
||||
InputNotify(NOTIFY_CURRENT, curr_avg);
|
||||
InputNotify(NOTIFY_CH1, curr_avg);
|
||||
SendNotify();
|
||||
|
||||
} else if (m < p->_t_pa[2]) {
|
||||
@@ -663,8 +663,6 @@ static void Vout_Plot(void)
|
||||
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;
|
||||
@@ -694,10 +692,10 @@ static void cali_IT_plot(void) {
|
||||
if (curr_rec_en == false) {
|
||||
rec_cnt++;
|
||||
} else {
|
||||
if (cali_count >= cali_count_max) {
|
||||
ADCValueAVG = ADCValueSUM / cali_count;
|
||||
if (GET_CALI_COUNT(wm) >= cali_count_max) {
|
||||
ADCValueAVG = GET_ADC_SUM(wm) / GET_CALI_COUNT(wm);
|
||||
|
||||
InputNotify(NOTIFY_CURRENT, ADCValueAVG);
|
||||
InputNotify(NOTIFY_CH1, ADCValueAVG);
|
||||
SendNotify();
|
||||
|
||||
uint8_t CIS_buf[9] = {0};
|
||||
@@ -710,19 +708,19 @@ static void cali_IT_plot(void) {
|
||||
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);
|
||||
GET_CALI_COUNT(wm)++;
|
||||
GET_ADC_SUM(wm) = GET_ADC_SUM(wm) + MEAS_CURR(wm);
|
||||
ADCValueAVG = GET_ADC_SUM(wm) / GET_CALI_COUNT(wm);
|
||||
InputNotify(NOTIFY_CH1, ADCValueAVG);
|
||||
InputNotify(NOTIFY_CH2, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_CH3, (int32_t)GET_CALI_COUNT(wm));
|
||||
}
|
||||
}
|
||||
|
||||
if (rec_cnt == 2) {
|
||||
volt_rec_en = true;
|
||||
curr_rec_en = true;
|
||||
rec_cnt = 0;
|
||||
}
|
||||
@@ -751,8 +749,6 @@ static void cali_IT_plot(void) {
|
||||
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;
|
||||
@@ -780,10 +776,10 @@ static void cali_VT_plot(void) {
|
||||
if (volt_rec_en == false) {
|
||||
rec_cnt++;
|
||||
} else {
|
||||
if (cali_count >= cali_count_max) {
|
||||
ADCValueAVG = ADCValueSUM / cali_count;
|
||||
if (GET_CALI_COUNT(wm) >= cali_count_max) {
|
||||
ADCValueAVG = GET_ADC_SUM(wm) / GET_CALI_COUNT(wm);
|
||||
|
||||
InputNotify(NOTIFY_VOLT, ADCValueAVG);
|
||||
InputNotify(NOTIFY_CH2, ADCValueAVG);
|
||||
SendNotify();
|
||||
|
||||
uint8_t CIS_buf[9] = {0};
|
||||
@@ -796,20 +792,21 @@ static void cali_VT_plot(void) {
|
||||
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);
|
||||
GET_CALI_COUNT(wm)++;
|
||||
GET_ADC_SUM(wm) = GET_ADC_SUM(wm) + MEAS_VIN(wm);
|
||||
ADCValueAVG = GET_ADC_SUM(wm) / GET_CALI_COUNT(wm);
|
||||
InputNotify(NOTIFY_CH2, MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CH1, ADCValueAVG);
|
||||
InputNotify(NOTIFY_CH3, (int32_t)GET_CALI_COUNT(wm));
|
||||
}
|
||||
}
|
||||
|
||||
if (rec_cnt == 2) {
|
||||
volt_rec_en = true;
|
||||
curr_rec_en = true;
|
||||
rec_cnt = 0;
|
||||
}
|
||||
ADC_cnt++;
|
||||
@@ -833,20 +830,29 @@ static void cali_VT_plot(void) {
|
||||
|
||||
return;
|
||||
}
|
||||
static void count_sum_clear(void) {
|
||||
void *wm = wm_get();
|
||||
if(wm) {
|
||||
GET_CALI_COUNT(wm) = 0;
|
||||
GET_ADC_SUM(wm) = 0;
|
||||
}
|
||||
|
||||
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;
|
||||
uint16_t cali_count_max = 2000;
|
||||
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(vscanReset)
|
||||
return;
|
||||
if (ADC_cnt == 0) {
|
||||
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
@@ -855,36 +861,19 @@ static void cali_Vout_plot(void) {
|
||||
if (volt_rec_en == false) {
|
||||
rec_cnt++;
|
||||
} else {
|
||||
if (cali_count >= cali_count_max) {
|
||||
ADCValueAVG = ADCValueSUM / cali_count;
|
||||
|
||||
InputNotify(NOTIFY_VOLT, ADCValueAVG);
|
||||
SendNotify();
|
||||
GET_CALI_COUNT(wm)++;
|
||||
GET_ADC_SUM(wm) = GET_ADC_SUM(wm) + MEAS_VOUT(wm);
|
||||
ADCValueAVG = GET_ADC_SUM(wm) / GET_CALI_COUNT(wm);
|
||||
InputNotify(NOTIFY_CH2, MEAS_VOUT(wm));
|
||||
InputNotify(NOTIFY_CH1, ADCValueAVG);
|
||||
InputNotify(NOTIFY_CH3, (int32_t)GET_CALI_COUNT(wm));
|
||||
|
||||
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;
|
||||
curr_rec_en = true;
|
||||
rec_cnt = 0;
|
||||
}
|
||||
ADC_cnt++;
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
#ifndef VERSION_DATE
|
||||
#define VERSION_DATE
|
||||
|
||||
#define VERSION_DATE_YEAR 22
|
||||
#define VERSION_DATE_MONTH 8
|
||||
#define VERSION_DATE_DAY 11
|
||||
#define VERSION_DATE_HOUR 15
|
||||
#define VERSION_DATE_MINUTE 58
|
||||
#define VERSION_DATE_YEAR 23
|
||||
#define VERSION_DATE_MONTH 3
|
||||
#define VERSION_DATE_DAY 7
|
||||
#define VERSION_DATE_HOUR 17
|
||||
#define VERSION_DATE_MINUTE 41
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
|
||||
@@ -526,6 +526,9 @@ static bool first_highz_flag;
|
||||
static bool tempCheck_flag;
|
||||
static bool calc_avg_en;
|
||||
static uint16_t dpv_step_cnt = 0;
|
||||
// cp mode use
|
||||
static int16_t cp_devis = 0;
|
||||
static bool cp_devis_en = FALSE;
|
||||
|
||||
//pulse mode variable
|
||||
static bool stiFirstTime;
|
||||
@@ -894,14 +897,16 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
switch(ins[4]) {
|
||||
case 0x00 : {
|
||||
if (PeriodicEvent) {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, 0); // 0 => open high_z mode
|
||||
//latch_single_ctrl(E_LATCH_HIGH_Z, 0); // 0 => open high_z mode
|
||||
HIGH_Z_OPEN();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 0x01 : {
|
||||
if (PeriodicEvent) {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, 1); // 1 => close high_z mode
|
||||
//latch_single_ctrl(E_LATCH_HIGH_Z, 1); // 1 => close high_z mode
|
||||
HIGH_Z_CLOSE();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -918,29 +923,50 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_CALI_ADC: {
|
||||
case CURVE_CALI: {
|
||||
switch(ins[3]) {
|
||||
case RIS_ADC_IIN : { // 0x00
|
||||
instru.eliteFxn = CURVE_CALI_ADC;
|
||||
instru.eliteFxn = CURVE_CALI;
|
||||
instru.AdcChannel = RIS_ADC_IIN;
|
||||
instru.notifyRate = 1000;
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
case RIS_ADC_VIN : { // 0x01
|
||||
instru.eliteFxn = CURVE_CALI_ADC;
|
||||
instru.eliteFxn = CURVE_CALI;
|
||||
instru.AdcChannel = RIS_ADC_VIN;
|
||||
instru.notifyRate = 1000;
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
case RIS_DAC_VOUT : { // 0x02
|
||||
instru.eliteFxn = CURVE_CALI_ADC;
|
||||
instru.eliteFxn = CURVE_CALI;
|
||||
instru.AdcChannel = RIS_DAC_VOUT;
|
||||
instru.notifyRate = 1000;
|
||||
instru.VoltConstant = ( ((uint16_t)(ins[4])) << 8) | (uint16_t)(ins[5]); // output voltage
|
||||
instru.hign_z_en = 1;
|
||||
|
||||
switch(ins[4]) {
|
||||
case 0x00: {
|
||||
instru.VoltConstant = 0x2710;
|
||||
break;
|
||||
}
|
||||
case 0x01: {
|
||||
instru.VoltConstant = 0x61A8;
|
||||
break;
|
||||
}
|
||||
case 0x02: {
|
||||
instru.VoltConstant = 0xC350;
|
||||
break;
|
||||
}
|
||||
case 0x03: {
|
||||
instru.VoltConstant = 0xEA60;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DAC0_W_T(instru.VoltConstant);
|
||||
|
||||
ModeLED(WORKING);
|
||||
count_sum_clear();
|
||||
break;
|
||||
}
|
||||
default : {
|
||||
@@ -1322,17 +1348,17 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
case BAT_DEV_TEST: {
|
||||
headstage_battery_volt();
|
||||
|
||||
uint32_t bat = (uint32_t)NotifyVoltBat;
|
||||
// uint32_t bat = (uint32_t)NotifyVoltBat;
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = 6; //data len
|
||||
cis_buf[1] = BAT_DEV_TEST;
|
||||
cis_buf[2] = (uint8_t)(bat >> 24);
|
||||
cis_buf[3] = (uint8_t)(bat >> 16);
|
||||
cis_buf[4] = (uint8_t)(bat >> 8);
|
||||
cis_buf[5] = (uint8_t)(bat);
|
||||
cis_buf[6] = 0x00;
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
// initCISBuf();
|
||||
// cis_buf[0] = 6; //data len
|
||||
// cis_buf[1] = BAT_DEV_TEST;
|
||||
// cis_buf[2] = (uint8_t)(bat >> 24);
|
||||
// cis_buf[3] = (uint8_t)(bat >> 16);
|
||||
// cis_buf[4] = (uint8_t)(bat >> 8);
|
||||
// cis_buf[5] = (uint8_t)(bat);
|
||||
// cis_buf[6] = 0x00;
|
||||
// SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1349,7 +1375,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
break;
|
||||
}
|
||||
|
||||
case LED_DEV_TEST: {
|
||||
case LED_DEV_TEST: { // 0x3000FF 04
|
||||
uint8_t *p = ins;
|
||||
struct led_color_t led_c;
|
||||
uint8_t led_item = p[4];
|
||||
@@ -1370,63 +1396,42 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
|
||||
if (led_item == DEV_LED_LIGHT_COLOR)
|
||||
led_color_code_set(LED_NB_MAX, LED_BR_LV8, &led_c);
|
||||
|
||||
|
||||
if (led_item == 4) {
|
||||
led_color_code_set(LED_NB_MAX, LED_BR_LV1, &led_c);
|
||||
/* led_color_set(LED_NB_2, LED_BR_LV1, LED_CLR_ORANGE);
|
||||
led_color_set(LED_NB_3, LED_BR_LV1, LED_CLR_ORANGE);
|
||||
led_color_set(LED_NB_5, LED_BR_LV1, LED_CLR_ORANGE);
|
||||
led_color_set(LED_NB_6, LED_BR_LV1, LED_CLR_ORANGE);
|
||||
led_color_set(LED_NB_8, LED_BR_LV1, LED_CLR_ORANGE);
|
||||
led_color_set(LED_NB_9, LED_BR_LV1, LED_CLR_ORANGE);
|
||||
led_color_set(LED_NB_11, LED_BR_LV1, LED_CLR_ORANGE);
|
||||
led_color_set(LED_NB_12, LED_BR_LV1, LED_CLR_ORANGE); */
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x50: {
|
||||
initCISBuf();
|
||||
case 0x30: { // update divis on cp mode
|
||||
uint8_t *p = ins;
|
||||
cp_devis = p[5] << 8 | p[6];
|
||||
if (p[4] == 0)
|
||||
cp_devis_en = FALSE;
|
||||
else
|
||||
cp_devis_en = TRUE;
|
||||
|
||||
cis_buf[0] = 2;
|
||||
cis_buf[1] = (uint8_t) ADC_rxbuf >> 8;
|
||||
cis_buf[2] = (uint8_t) ADC_rxbuf;
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case 0x51: {
|
||||
initCISBuf();
|
||||
cis_buf[0] = 2;
|
||||
cis_buf[1] = (uint8_t) ADC_rxbuf >> 8;
|
||||
cis_buf[2] = (uint8_t) ADC_rxbuf;
|
||||
uint32_t temperature = (uint32_t)NotifyTemperature;
|
||||
cis_buf[0] = 6; //data len
|
||||
cis_buf[1] = 0x30;
|
||||
cis_buf[2] = 3;
|
||||
cis_buf[3] = cp_devis_en;
|
||||
cis_buf[4] = (uint8_t)(cp_devis >> 8);
|
||||
cis_buf[5] = (uint8_t)(cp_devis);
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case 0x61: {
|
||||
dac_ldac_mode(ins[4], ins[5]);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x62: {
|
||||
dac_clear_mode();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x63: {
|
||||
dac_power_control_mode(ins[4], ins[5], ins[6]);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x64: {
|
||||
dac_linearity_mode(ins[4]);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x65: {
|
||||
uint16_t volts = (uint16_t)ins[6] << 8 | ins[7];
|
||||
dac_write_mode(ins[4], ins[5], volts);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x66: {
|
||||
uint16_t volts = (uint16_t)ins[6] << 8 | ins[7];
|
||||
DAC0_W_T(volts);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ static void device_init(void)
|
||||
(instru.eliteFxn == CURVE_CA) || \
|
||||
(instru.eliteFxn == CURVE_VO) || \
|
||||
(instru.eliteFxn == CURVE_OCP) || \
|
||||
(instru.eliteFxn == CURVE_CALI_ADC) \
|
||||
(instru.eliteFxn == CURVE_CALI) \
|
||||
)
|
||||
|
||||
#define Ve1MatchVe2Mode() ( \
|
||||
@@ -76,9 +76,15 @@ static void peri_mode(void)
|
||||
vscanReset = true;
|
||||
if (first_highz_flag && GPT.cnt_lead_time >= 1000) {
|
||||
if (instru.eliteFxn == CURVE_OCP || instru.eliteFxn == CURVE_CC || instru.eliteFxn == CURVE_CP) {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, 0); // HIGH Z MODE // 1: close; 0: open;
|
||||
HIGH_Z_OPEN(); // 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;
|
||||
//latch_single_ctrl(E_LATCH_HIGH_Z, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
|
||||
if(instru.hign_z_en == 1) {
|
||||
HIGH_Z_CLOSE();
|
||||
}
|
||||
else{
|
||||
HIGH_Z_OPEN();
|
||||
}
|
||||
}
|
||||
first_highz_flag = false;
|
||||
}
|
||||
@@ -126,7 +132,7 @@ static void peri_mode(void)
|
||||
(instru.eliteFxn == CURVE_DPV_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_CALI_ADC)) {
|
||||
(instru.eliteFxn == CURVE_CALI)) {
|
||||
batteryCheck_flag = false;
|
||||
tempCheck_flag = false;
|
||||
|
||||
@@ -230,7 +236,7 @@ static void uni_pulse_mode(void)
|
||||
(instru.eliteFxn == CURVE_DPV_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_CALI_ADC)) {
|
||||
(instru.eliteFxn == CURVE_CALI)) {
|
||||
batteryCheck_flag = false;
|
||||
tempCheck_flag = false;
|
||||
|
||||
@@ -398,26 +404,39 @@ static void elite_task(void)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Notify data:
|
||||
* +--------+----------+---------+---------+---------+-----------+-----------------+
|
||||
* | id(1B) | time(4B) | ch1(4B) | ch2(4B) | ch3(4B) | cycle(2B) | finish_flag(1B) |
|
||||
* | bat(4B) | notify#(1B) | ch4(4B) | ch5(4B) | ch6(4B) | __(3B) |
|
||||
* +---------+-------------+---------+---------+---------+--------+
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 | |
|
||||
* +-----------------+-----------+-----------+-----------+
|
||||
* +---------------------------+-----------+-----------+-----------+-----------+-----------+
|
||||
* | MODE | ch1 | ch2 | ch3 | cycle | ch4 |
|
||||
* +---------------------------+-----------+-----------+-----------+-----------+-----------+
|
||||
* | CURVE_IV | Iin | Vout | Vin | | Vmon |
|
||||
* | CURVE_IV_CY | Iin | Vout | Vin | v | Vmon |
|
||||
* | CURVE_VO | Iin | Vout | Vin | | Vmon |
|
||||
* | CURVE_RT | Iin | Vout | R | | Vmon |
|
||||
* | CURVE_VT | Iin | Vin | | | |
|
||||
* | CURVE_IT | Iin | Vin | Vout | | Vmon |
|
||||
* | CURVE_CC | Iin | Vin | Vout | | Vmon |
|
||||
* | CURVE_CP | Iin | Vout-Vin | Vout | | Vmon |
|
||||
* | CURVE_CV | Iin | Vout-Vin | Vout | v | Vmon |
|
||||
* | CURVE_LSV | Iin | Vout-Vin | Vout | | Vmon |
|
||||
* | CURVE_CA | Iin | Vout-Vin | Vout | | Vmon |
|
||||
* | CURVE_OCP | Iin | Vmon-Vin | Vin | | Vmon |
|
||||
* | CURVE_UNI_PULSE | pul1_Iin | pul2_Iin | | | |
|
||||
* | CURVE_DPV | c1&c2_avg | Vout-Vin | Vout | | Vmon |
|
||||
* | CURVE_DPV_SMPRATE | Iin | Vout-Vin | Vout | | Vmon |
|
||||
* | CURVE_DPV_ADVANCE | c1&c2_avg | Vout-Vin | Vout | | Vmon |
|
||||
* | CURVE_DPV_ADVANCE_SMPRATE | Iin | Vout-Vin | Vout | | Vmon |
|
||||
* +---------------------------+-----------+-----------+-----------+-----------+-----------+
|
||||
*
|
||||
* ps. c1_avg = pul1_Iin
|
||||
* ps. c2_avg = pul2_Iin
|
||||
*/
|
||||
|
||||
static void EliteADCControl(uint32_t time)
|
||||
@@ -430,47 +449,51 @@ static void EliteADCControl(uint32_t time)
|
||||
case CURVE_IV_CY:
|
||||
Iin_Vin_Vout_Plot(t);
|
||||
if (curr_rec_en) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_CH1, MEAS_CURR(wm));
|
||||
}
|
||||
|
||||
if (volt_rec_en) {
|
||||
InputNotify(NOTIFY_VOLT, instru.Vout/200);
|
||||
InputNotify(NOTIFY_IMPEDANCE, MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CH2, instru.Vout/200);
|
||||
InputNotify(NOTIFY_CH3, MEAS_VIN(wm));
|
||||
notify_ch4 = MEAS_VOUT(wm);
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_RT:
|
||||
Iin_Vin_Vout_Plot(t);
|
||||
if (curr_rec_en) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_CH1, MEAS_CURR(wm));
|
||||
}
|
||||
|
||||
if (volt_rec_en) {
|
||||
InputNotify(NOTIFY_VOLT, instru.Vout/200);
|
||||
InputNotify(NOTIFY_CH2, instru.Vout/200);
|
||||
notify_ch4 = MEAS_VOUT(wm);
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_CC:
|
||||
Iin_Vin_Vout_Plot(t);
|
||||
if (curr_rec_en) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_CH1, MEAS_CURR(wm));
|
||||
}
|
||||
|
||||
if (volt_rec_en) {
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_IMPEDANCE, instru.Vout/200);
|
||||
InputNotify(NOTIFY_CH2, MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CH3, instru.Vout/200);
|
||||
notify_ch4 = MEAS_VOUT(wm);
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_CP:
|
||||
Iin_Vin_Vout_Plot(t);
|
||||
if (curr_rec_en) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_CH1, MEAS_CURR(wm));
|
||||
}
|
||||
|
||||
if (volt_rec_en) {
|
||||
InputNotify(NOTIFY_VOLT, instru.Vout/200 - MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_IMPEDANCE, instru.Vout/200);
|
||||
InputNotify(NOTIFY_CH2, instru.Vout/200 - MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CH3, instru.Vout/200);
|
||||
notify_ch4 = MEAS_VOUT(wm);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -479,61 +502,66 @@ static void EliteADCControl(uint32_t time)
|
||||
case CURVE_LSV:
|
||||
Iin_Vin_Vout_Plot(t);
|
||||
if (curr_rec_en) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_CH1, MEAS_CURR(wm));
|
||||
}
|
||||
|
||||
if (volt_rec_en) {
|
||||
InputNotify(NOTIFY_VOLT, instru.Vout/200 - MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_IMPEDANCE, instru.Vout/200);
|
||||
InputNotify(NOTIFY_CH2, instru.Vout/200 - MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CH3, instru.Vout/200);
|
||||
notify_ch4 = MEAS_VOUT(wm);
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_IT:
|
||||
Iin_Vin_Vout_Plot(t);
|
||||
if (curr_rec_en) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_CH1, MEAS_CURR(wm));
|
||||
}
|
||||
|
||||
if(volt_rec_en) {
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_IMPEDANCE, instru.Vout/200);
|
||||
InputNotify(NOTIFY_CH2, MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CH3, instru.Vout/200);
|
||||
notify_ch4 = MEAS_VOUT(wm);
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_VT:
|
||||
Iin_Vin_Plot();
|
||||
if (curr_rec_en) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_CH1, MEAS_CURR(wm));
|
||||
}
|
||||
|
||||
if (volt_rec_en) {
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CH2, MEAS_VIN(wm));
|
||||
notify_ch4 = MEAS_VOUT(wm);
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_VO:
|
||||
Iin_Vin_Vout_Plot(t);
|
||||
if (curr_rec_en) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_CH1, MEAS_CURR(wm));
|
||||
}
|
||||
if (volt_rec_en) {
|
||||
InputNotify(NOTIFY_VOLT, instru.Vout/200);
|
||||
InputNotify(NOTIFY_IMPEDANCE, MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CH2, instru.Vout/200);
|
||||
InputNotify(NOTIFY_CH3, MEAS_VIN(wm));
|
||||
notify_ch4 = MEAS_VOUT(wm);
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_OCP:
|
||||
Iin_Vin_Vout_Plot(t);
|
||||
if (curr_rec_en) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_CH1, MEAS_CURR(wm));
|
||||
}
|
||||
if (volt_rec_en) {
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VOUT(wm) - MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_IMPEDANCE, MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CH2, MEAS_VOUT(wm) - MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CH3, MEAS_VIN(wm));
|
||||
notify_ch4 = MEAS_VOUT(wm);
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_CALI_ADC:
|
||||
case CURVE_CALI:
|
||||
if (instru.AdcChannel == RIS_ADC_IIN) {
|
||||
cali_IT_plot();
|
||||
} else if (instru.AdcChannel == RIS_ADC_VIN) {
|
||||
@@ -549,31 +577,35 @@ static void EliteADCControl(uint32_t time)
|
||||
|
||||
case CURVE_DPV:
|
||||
Iin_Vin_Vout_Plot(t);
|
||||
notify_ch4 = MEAS_VOUT(wm);
|
||||
break;
|
||||
|
||||
case CURVE_DPV_SMPRATE:
|
||||
Iin_Vin_Vout_Plot(t);
|
||||
if (curr_rec_en) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_CH1, MEAS_CURR(wm));
|
||||
}
|
||||
if (volt_rec_en) {
|
||||
InputNotify(NOTIFY_VOLT, instru.Vout/200 - MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_IMPEDANCE, instru.Vout/200);
|
||||
InputNotify(NOTIFY_CH2, instru.Vout/200 - MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CH3, instru.Vout/200);
|
||||
notify_ch4 = MEAS_VOUT(wm);
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_DPV_ADVANCE:
|
||||
Iin_Vin_Vout_Plot(t);
|
||||
notify_ch4 = MEAS_VOUT(wm);
|
||||
break;
|
||||
|
||||
case CURVE_DPV_ADVANCE_SMPRATE:
|
||||
Iin_Vin_Vout_Plot(t);
|
||||
if (curr_rec_en) {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_CH1, MEAS_CURR(wm));
|
||||
}
|
||||
if (volt_rec_en) {
|
||||
InputNotify(NOTIFY_VOLT, instru.Vout/200 - MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_IMPEDANCE, instru.Vout/200);
|
||||
InputNotify(NOTIFY_CH2, instru.Vout/200 - MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CH3, instru.Vout/200);
|
||||
notify_ch4 = MEAS_VOUT(wm);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -588,10 +620,13 @@ static void mode_done(void)
|
||||
(instru.eliteFxn == CURVE_CV) ||
|
||||
(instru.eliteFxn == CURVE_LSV) ||
|
||||
(instru.eliteFxn == CURVE_IV_CY) ||
|
||||
(instru.eliteFxn == CURVE_CC) ||
|
||||
(instru.eliteFxn == CURVE_DPV) ||
|
||||
(instru.eliteFxn == CURVE_DPV_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE)) {
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_CALI))
|
||||
{
|
||||
if (!PeriodicEvent) {
|
||||
finishMode = true;
|
||||
SendNotify();
|
||||
|
||||
@@ -196,80 +196,75 @@ static void cc_vscan(void)
|
||||
int32_t deltaI;
|
||||
int32_t deltaV;
|
||||
int32_t Iin;
|
||||
int32_t Vin;
|
||||
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) {
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
|
||||
deltaI = Iin - i_set;
|
||||
|
||||
if (deltaI > 400000 || deltaI < -400000) { //20uA
|
||||
if (cc_cp_speed == 0) { // 0:low 1:normal 2:high
|
||||
divisionRate = 100;
|
||||
} else if (cc_cp_speed == 1) {
|
||||
divisionRate = 10;
|
||||
} else {
|
||||
divisionRate = 1;
|
||||
}
|
||||
} else {
|
||||
if (cc_cp_speed == 0) { // 0:low 1:normal 2:high
|
||||
divisionRate = 100;
|
||||
} else if (cc_cp_speed == 1) {
|
||||
divisionRate = 20;
|
||||
} else {
|
||||
divisionRate = 20;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vscanReset) {
|
||||
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
|
||||
deltaI = Iin - i_set;
|
||||
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (deltaV > DELTAVOLTMAX) { //2000000 = 10mV
|
||||
deltaV = DELTAVOLTMAX;
|
||||
} else if (deltaV < (-DELTAVOLTMAX)) {
|
||||
deltaV = (-DELTAVOLTMAX);
|
||||
}
|
||||
|
||||
divisionRate = cc_cp_speed;
|
||||
Vset = Vset + deltaV; //[5nV]
|
||||
|
||||
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
|
||||
if (Vset >= 1100000000) { // 5.5V
|
||||
Vset = 1100000000;
|
||||
} else if (Vset <= -1000000000) { //-5V
|
||||
Vset = -1000000000;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
Vin = m->_measureVin * 200; //[5nV]
|
||||
if (Vin <= cc->_Vmin && cc->_charge == 0) { // discharge
|
||||
PeriodicEvent = false;
|
||||
} else if (Vin >= cc->_Vmax && cc->_charge == 1) { // charge
|
||||
PeriodicEvent = false;
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -277,93 +272,96 @@ static void cc_vscan(void)
|
||||
|
||||
static void cp_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_cp_ctx_t *cp = (struct wm_cp_ctx_t *)wm_get();
|
||||
struct wm_meas_t *m = &cp->measure;
|
||||
uint16_t divisionRate;
|
||||
int32_t deltaI;
|
||||
int32_t deltaV;
|
||||
uint8_t cc_cp_speed = instru.cc_cp_speed; // 0:low 1:normal 2:high
|
||||
|
||||
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;
|
||||
static uint8_t sum_cnt;
|
||||
static int64_t sum_adc_delta_Voutin; //[5nV]
|
||||
static int64_t sum_adc_delta_Iin; //[50pA]
|
||||
static int32_t resis;
|
||||
int16_t divisionRate;
|
||||
static int64_t deltaI;
|
||||
static int64_t deltaV;
|
||||
static int32_t i_set;
|
||||
static int64_t Rd = 0;
|
||||
|
||||
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
|
||||
Voutin = m->_measureVout * 200; //[5nV] uV => 5nV
|
||||
|
||||
if (vscanReset) {
|
||||
Vset = 0;
|
||||
sum_cnt = 0;
|
||||
sum_adc_delta_Voutin = 0;
|
||||
sum_adc_delta_Iin = 0;
|
||||
resis = 1000;
|
||||
|
||||
if (cp->_charge == 0) {
|
||||
if (cp->_charge == 0) { // discharge
|
||||
i_set = cp->_Iset * (-1);
|
||||
} else if(cp->_charge == 1) {
|
||||
Vset = Voutin - 1000000; //[5nV] 1000000 = 5mV
|
||||
} else if(cp->_charge == 1) { // charge
|
||||
i_set = cp->_Iset;
|
||||
Vset = Voutin + 1000000; //[5nV] 1000000 = 5mV
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (cp_devis_en == TRUE) {
|
||||
divisionRate = cp_devis;
|
||||
} else {
|
||||
if (cc_cp_speed == 0) { // 0:low 1:normal 2:high
|
||||
divisionRate = 100;
|
||||
} else if (cc_cp_speed == 1) {
|
||||
divisionRate = 10;
|
||||
} else {
|
||||
divisionRate = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vscanReset) {
|
||||
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
|
||||
deltaI = Iin - i_set;
|
||||
deltaI = Iin - i_set;
|
||||
sum_adc_delta_Voutin += Voutin;
|
||||
sum_adc_delta_Iin += Iin;
|
||||
sum_cnt++;
|
||||
|
||||
if (sum_cnt == 5) {
|
||||
Rd = sum_adc_delta_Voutin * 100 / sum_adc_delta_Iin;
|
||||
|
||||
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;
|
||||
if ((sum_adc_delta_Iin >= 12000 || sum_adc_delta_Iin <= -12000) && Rd >= 0) { // sum_delIin >= 600nA
|
||||
if (Rd <= 10) {
|
||||
resis = 10;
|
||||
} else if (Rd >= 10000000) {
|
||||
resis = 10000000;
|
||||
} 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;
|
||||
resis = Rd;
|
||||
}
|
||||
}
|
||||
|
||||
divisionRate = cc_cp_speed;
|
||||
sum_cnt = 0;
|
||||
sum_adc_delta_Voutin = 0;
|
||||
sum_adc_delta_Iin = 0;
|
||||
}
|
||||
|
||||
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
|
||||
deltaV = -1 * deltaI * resis / 100 / (int64_t)divisionRate;
|
||||
Vset = Vset + deltaV;
|
||||
|
||||
// if (deltaV > DELTAVOLTMAX) { //2000000 = 10mV
|
||||
// deltaV = DELTAVOLTMAX;
|
||||
// } else if (deltaV < (-DELTAVOLTMAX)) {
|
||||
// deltaV = (-DELTAVOLTMAX);
|
||||
// }
|
||||
if (Vset >= 1100000000) { // 5.5V
|
||||
Vset = 1100000000;
|
||||
} else if (Vset <= -1000000000) { //-5V
|
||||
Vset = -1000000000;
|
||||
}
|
||||
|
||||
Vset = Vset + deltaV; //[5nV]
|
||||
|
||||
if (Vset >= 1100000000) { // 5.5V
|
||||
Vset = 1100000000;
|
||||
} else if (Vset <= -1000000000) { //-5V
|
||||
Vset = -1000000000;
|
||||
}
|
||||
|
||||
if (Vset <= cp->_Vmin) {
|
||||
Vset = cp->_Vmin;
|
||||
} else if (Vset >= cp->_Vmax) {
|
||||
Vset = cp->_Vmax;
|
||||
}
|
||||
if (Vset <= cp->_Vmin) {
|
||||
Vset = cp->_Vmin;
|
||||
} else if (Vset >= cp->_Vmax) {
|
||||
Vset = cp->_Vmax;
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -480,8 +478,6 @@ 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;
|
||||
|
||||
@@ -799,12 +799,12 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
|
||||
}
|
||||
} else { // if there is periodic event
|
||||
if(InitPeriodicEvent){
|
||||
wm_init();
|
||||
InitPeriodicEvent = false;
|
||||
}
|
||||
wm_init();
|
||||
InitPeriodicEvent = false;
|
||||
}
|
||||
|
||||
// Perform periodic application task
|
||||
SimpleBLEPeripheral_performPeriodicTask();
|
||||
// Perform periodic application task
|
||||
SimpleBLEPeripheral_performPeriodicTask();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1168,7 +1168,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.
|
||||
|
||||