Compare commits
86 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0eae7257f3 | |||
| 118f61c8bf | |||
| be49fe80c4 | |||
| 94b0a701a9 | |||
| 313891d241 | |||
| 852e920c09 | |||
| 55645315af | |||
| fb4ff0805b | |||
| a9c98d9833 | |||
| 3b6ea50ee6 | |||
| 5288394e8f | |||
| 1ab61280ef | |||
| fadbe0eada | |||
| 065827f6af | |||
| 5ee3614c42 | |||
| efd206104b | |||
| e1d3710526 | |||
| 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 | |||
| 9c29ad0a86 | |||
| 6b421d73e9 | |||
| 34107872ec | |||
| f6719c3182 | |||
| 79188d76b9 |
@@ -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 |
@@ -15,16 +15,16 @@ extern "C" {
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* | model name | hw upper board | hw lower board | product number | device name | data server lib name | UI |
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* | DEF_ELITE_EDC_1_4 | Elite1.4-re Jun.2019 | Elite1.4-re Jun. 2019 | 0, 2, 1, 5 | "Elite-EDC" | Elite_EDC_1.4 | null |
|
||||
* | DEF_ELITE_EDC_1_5 | Elite1.5 Dec. 2019 | Elite1.5 Dec. 2019 | 0, 2, 1, 6 | "Elite-EDC" | Elite_EDC_1.5 | EliteEDC |
|
||||
* | DEF_ELITE_EDC_1_5_RE | Elite1.5 Dec. 2019 | Elite1.5-re Jan. 2021 | 0, 2, 1, 7 | "Elite-EDC" | Elite_EDC_1.5re | EliteEDC |
|
||||
* | DEF_ELITE_EDC_1_5_R2 | Elite1.5 Dec. 2019 | Elite1.5-r2 May. 2022 | 0, 2, 1, 8 | "Elite-EDC" | Elite_EDC_1.5r2 | EliteEDC |
|
||||
* | DEF_ELITE_BAT_1_0 | Elite2.0 Feb. 2022 | 0, 3, 1, 0 | "Elite-BAT" | Elite_BAT_1.0 | EliteEDC |
|
||||
* | DEF_ELITE_EIS_1_0 | Elite1.5 Dec. 2019 | Elite EIS1.0 Aug. 2020 | 0, 4, 1, 0 | "Elite-EIS" | Elite_EIS_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_1_1 | Elite1.5 Dec. 2019 | Elite EIS1.1 Feb. 2022 | 0, 4, 1, 1 | "Elite-EIS" | Elite_EIS_1.1 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_MINI_1_0 | EIS MINI May. 2022 | 0, 4, 1, 2 | "Elite-EIS-MINI" | Elite_EIS_MINI_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_TRIG_0_1 | Elite TRIG01 Jan. 2021 | 0, 5, 1, 0 | "Elite-TRIG" | Elite_TRIG_0.1 | null |
|
||||
* | DEF_ELITE_MEGAFLY_0_1 | Elite1.5 Dec. 2019 | Elite Megafly Sep. 2020 | 0, 6, 1, 0 | "Elite-MEGAFLY" | Elite_MEGAFLY_0.1 | null |
|
||||
* | DEF_ELITE_EDC_14 | Elite1.4-re Jun.2019 | Elite1.4-re Jun. 2019 | 0, 2, 1, 5 | "Elite-EDC" | Elite_EDC_1.4 | null |
|
||||
* | DEF_ELITE_EDC_15 | Elite1.5 Dec. 2019 | Elite1.5 Dec. 2019 | 0, 2, 1, 6 | "Elite-EDC" | Elite_EDC_1.5 | EliteEDC |
|
||||
* | DEF_ELITE_EDC_15RE | Elite1.5 Dec. 2019 | Elite1.5-re Jan. 2021 | 0, 2, 1, 7 | "Elite-EDC" | Elite_EDC_1.5re | EliteEDC |
|
||||
* | DEF_ELITE_EDC_15R2 | Elite1.5 Dec. 2019 | Elite1.5-r2 May. 2022 | 0, 2, 1, 8 | "Elite-EDC" | Elite_EDC_1.5r2 | EliteEDC |
|
||||
* | DEF_ELITE_BAT_10 | Elite2.0 Feb. 2022 | 0, 3, 1, 0 | "Elite-BAT" | Elite_BAT_1.0 | EliteEDC |
|
||||
* | DEF_ELITE_EIS_10 | Elite1.5 Dec. 2019 | Elite EIS1.0 Aug. 2020 | 0, 4, 1, 0 | "Elite-EIS" | Elite_EIS_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_11 | Elite1.5 Dec. 2019 | Elite EIS1.1 Feb. 2022 | 0, 4, 1, 1 | "Elite-EIS" | Elite_EIS_1.1 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_MINI_10 | EIS MINI May. 2022 | 0, 4, 1, 2 | "Elite-EIS-MINI" | Elite_EIS_MINI_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_TRIG_01 | Elite TRIG01 Jan. 2021 | 0, 5, 1, 0 | "Elite-TRIG" | Elite_TRIG_0.1 | null |
|
||||
* | DEF_ELITE_MEGAFLY_01 | Elite1.5 Dec. 2019 | Elite Megafly Sep. 2020 | 0, 6, 1, 0 | "Elite-MEGAFLY" | Elite_MEGAFLY_0.1 | null |
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* ps.
|
||||
* model name is FW engineer defined
|
||||
@@ -32,40 +32,40 @@ extern "C" {
|
||||
*/
|
||||
|
||||
|
||||
#define DEF_ELITE_EDC_1_4 0
|
||||
#define DEF_ELITE_EDC_1_5 1
|
||||
#define DEF_ELITE_EDC_1_5_RE 2
|
||||
#define DEF_ELITE_EDC_1_5_R2 3
|
||||
#define DEF_ELITE_BAT_1_0 4
|
||||
#define DEF_ELITE_EIS_1_0 5
|
||||
#define DEF_ELITE_EIS_1_1 6
|
||||
#define DEF_ELITE_EIS_MINI_1_0 7
|
||||
#define DEF_ELITE_TRIG_0_1 8
|
||||
#define DEF_ELITE_MEGAFLY_0_1 9
|
||||
#define DEF_ELITE_EDC_14 0
|
||||
#define DEF_ELITE_EDC_15 1
|
||||
#define DEF_ELITE_EDC_15RE 2
|
||||
#define DEF_ELITE_EDC_15R2 3
|
||||
#define DEF_ELITE_BAT_10 4
|
||||
#define DEF_ELITE_EIS_10 5
|
||||
#define DEF_ELITE_EIS_11 6
|
||||
#define DEF_ELITE_EIS_MINI_10 7
|
||||
#define DEF_ELITE_TRIG_01 8
|
||||
#define DEF_ELITE_MEGAFLY_01 9
|
||||
#define DEF_ELITE_MAX 10
|
||||
|
||||
#define DEF_ELITE_MODEL DEF_ELITE_EDC_1_5_RE
|
||||
#define DEF_ELITE_MODEL DEF_ELITE_EDC_15RE
|
||||
#ifndef DEF_ELITE_MODEL
|
||||
#error "DEF_ELITE_MODEL not defined"
|
||||
#endif
|
||||
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_4)
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_14)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_RE)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15RE)
|
||||
#include "boards_config/pin_def_edc15re.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_R2)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15R2)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_0)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_10)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_1)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_11)
|
||||
#include "boards_config/pin_def_eis11.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_1_0)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_10)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_0_1)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_01)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_0_1)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_01)
|
||||
#error "code no support" // need fix
|
||||
#else
|
||||
#error "no this model"
|
||||
@@ -73,61 +73,61 @@ extern "C" {
|
||||
|
||||
|
||||
// model information
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_4)
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_14)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 5
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 6
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_RE)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15RE)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 7
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_R2)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_15R2)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 8
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_1_0)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_10)
|
||||
#define DEVICE_NAME "Elite-BAT"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 3
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_0)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_10)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_1)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_11)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 1
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_MINI_1_0)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_MINI_10)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 2
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_0_1)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_01)
|
||||
#define DEVICE_NAME "Elite-TRIG"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 5
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_0_1)
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_01)
|
||||
#define DEVICE_NAME "Elite-MEGAFLY"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 6
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -47,7 +47,7 @@ struct HEADSTAGE_INSTRUCTION {
|
||||
uint16_t cycleNumber;
|
||||
uint8_t charge;
|
||||
int32_t constantCurrent;
|
||||
uint8_t cc_resistance;
|
||||
// uint8_t cc_resistance;
|
||||
uint8_t cc_cp_speed;
|
||||
|
||||
// uni pulse mode
|
||||
|
||||
@@ -74,6 +74,7 @@ static void WorkModeLED()
|
||||
case CURVE_CV:
|
||||
case CURVE_CA:
|
||||
case CURVE_CC:
|
||||
case CURVE_CP:
|
||||
case CURVE_OCP:
|
||||
case CURVE_LSV:
|
||||
case CURVE_IV_CY:
|
||||
@@ -85,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,27 @@ 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;
|
||||
int32_t _Vmax;
|
||||
int32_t _Vmin;
|
||||
int32_t _Vset;
|
||||
int32_t _Iset;
|
||||
uint8_t _charge;
|
||||
};
|
||||
|
||||
int wm_init(void);
|
||||
int wm_deinit(void);
|
||||
void *wm_get(void);
|
||||
@@ -698,6 +719,57 @@ 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;
|
||||
struct wm_cp_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_cp_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
p->_Vmax = (instru.Vmax - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vmin = (instru.Vmin - 25000) * 4 * 10000; //[5nV]
|
||||
p->_Vset = 0;
|
||||
p->_charge = instru.charge;
|
||||
p->_Iset = instru.constantCurrent * 200 ;
|
||||
//[50pA] //controller UI 15000uA => Elite 1500000 => 1500000 * 10 * 1000 / 50 [50pA]
|
||||
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wm_init(void)
|
||||
{
|
||||
int mode = instru.eliteFxn;
|
||||
@@ -762,7 +834,14 @@ 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;
|
||||
break;
|
||||
|
||||
default:
|
||||
// printf("DO NOT support!!");
|
||||
return -3;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,13 +31,14 @@ enum all_mode_e {
|
||||
CURVE_CV = 0x09, // Cyclic Voltammetry (CV)
|
||||
CURVE_LSV = 0x0A, // Linear Sweep Voltammetry (LSV)
|
||||
CURVE_CA = 0x0B, // Chronoamperometric Graph (CA)
|
||||
CURVE_CP = 0x0C,
|
||||
CURVE_UNI_PULSE = 0x0D, // Pulse Sensing (universal pulse)
|
||||
CURVE_DPV = 0x0E, // Differential Pulse Voltammetry (DPV)
|
||||
CURVE_DPV_SMPRATE = 0x0F,
|
||||
CURVE_DPV_ADVANCE = 0x10,
|
||||
CURVE_DPV_ADVANCE_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){
|
||||
@@ -78,6 +78,11 @@ static void DACenable(uint8_t afterRead){
|
||||
volt_out();
|
||||
break;
|
||||
|
||||
case CURVE_CP:
|
||||
cp_vscan();
|
||||
volt_out();
|
||||
break;
|
||||
|
||||
case CURVE_UNI_PULSE:
|
||||
volt_out();
|
||||
break;
|
||||
@@ -269,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;
|
||||
@@ -280,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;
|
||||
@@ -290,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]) {
|
||||
@@ -315,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;
|
||||
@@ -327,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;
|
||||
}
|
||||
|
||||
@@ -343,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]) {
|
||||
@@ -368,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;
|
||||
@@ -380,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;
|
||||
}
|
||||
|
||||
@@ -396,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]) {
|
||||
@@ -658,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;
|
||||
@@ -689,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};
|
||||
@@ -705,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;
|
||||
}
|
||||
@@ -746,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;
|
||||
@@ -775,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};
|
||||
@@ -791,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++;
|
||||
@@ -828,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();
|
||||
@@ -850,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 2
|
||||
#define VERSION_DATE_HOUR 11
|
||||
#define VERSION_DATE_MINUTE 33
|
||||
#define VERSION_DATE_YEAR 23
|
||||
#define VERSION_DATE_MONTH 7
|
||||
#define VERSION_DATE_DAY 27
|
||||
#define VERSION_DATE_HOUR 10
|
||||
#define VERSION_DATE_MINUTE 45
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
|
||||
@@ -443,6 +443,15 @@ enum send_ins_para_order_e {
|
||||
PARA_FINAL = 0xFF,
|
||||
};
|
||||
|
||||
enum dev_led_item_e {
|
||||
DEV_LED_LIMIT_COLOR = 0,
|
||||
DEV_LED_DARK_COLOR,
|
||||
DEV_LED_LIGHT_COLOR,
|
||||
DEV_LED_RAINBOW,
|
||||
|
||||
DEV_LED_MAX,
|
||||
};
|
||||
|
||||
#define UC_TO_5NV(_v) (_v - 25000) * 4 * 10000; //userode to 5nv per unit
|
||||
|
||||
#include "Elite_def.h"
|
||||
@@ -517,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;
|
||||
@@ -544,6 +556,7 @@ static void lsv_vscan(void);
|
||||
static void ca_vscan(void);
|
||||
static void cv_vscan(void);
|
||||
static void cc_vscan(void);
|
||||
static void cp_vscan(void);
|
||||
|
||||
//mode (DAC)
|
||||
static void DACenable(uint8_t afterRead);
|
||||
@@ -716,7 +729,31 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.Vmax = (uint32_t)(ins[8]) << 8 | (uint32_t)(ins[9]);
|
||||
instru.Vmin = (uint32_t)(ins[10]) << 8 | (uint32_t)(ins[11]);
|
||||
instru.hign_z_en = ins[13] & 0x0F;
|
||||
instru.cc_resistance = ins[16] & 0xF0; // 0:vout has 0R 1:vout has 100R
|
||||
// instru.cc_resistance = ins[16] & 0xF0; // 0:vout has 0R 1:vout has 100R
|
||||
instru.cc_cp_speed = ins[16] & 0x0F; // 0:low 1:normal 2:high
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
|
||||
ModeLED(WORKING);
|
||||
/*******************************************************
|
||||
controller instruction
|
||||
ins[3] -> Charge, 0:discharge 1:charge
|
||||
ins[6:9] -> ConstantCurrent, 0 ~ 15000uA : 0 ~ 1500000
|
||||
********************************************************/
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_CP: { //vscan's cc
|
||||
instru.eliteFxn = CURVE_CP;
|
||||
instru.notifyRate = ((uint32_t)ins[14] << 8) | (uint32_t)ins[15];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.charge = ins[3]; //0:discharge 1:charge
|
||||
instru.constantCurrent = (uint32_t)(ins[4]) << 24 | (uint32_t)(ins[5]) << 16 | (uint32_t)(ins[6]) << 8 | (uint32_t)(ins[7]);
|
||||
instru.Vmax = (uint32_t)(ins[8]) << 8 | (uint32_t)(ins[9]);
|
||||
instru.Vmin = (uint32_t)(ins[10]) << 8 | (uint32_t)(ins[11]);
|
||||
instru.hign_z_en = ins[13] & 0x0F;
|
||||
// instru.cc_resistance = ins[16] & 0xF0; // 0:vout has 0R 1:vout has 100R
|
||||
instru.cc_cp_speed = ins[16] & 0x0F; // 0:low 1:normal 2:high
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
@@ -860,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;
|
||||
}
|
||||
@@ -884,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 : {
|
||||
@@ -1288,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;
|
||||
}
|
||||
|
||||
@@ -1315,64 +1375,63 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
break;
|
||||
}
|
||||
|
||||
case LED_DEV_TEST: {
|
||||
led_rainbow(LED_BR_LV8);
|
||||
case LED_DEV_TEST: { // 0x3000FF 04
|
||||
uint8_t *p = ins;
|
||||
struct led_color_t led_c;
|
||||
uint8_t led_item = p[4];
|
||||
uint8_t c_num = p[5];
|
||||
|
||||
led_c.r = p[5];
|
||||
led_c.g = p[6];
|
||||
led_c.b = p[7];
|
||||
|
||||
if (led_item == DEV_LED_RAINBOW)
|
||||
led_rainbow(LED_BR_LV1);
|
||||
|
||||
if (led_item == DEV_LED_LIMIT_COLOR)
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, (enum led_color_e)c_num);
|
||||
|
||||
if (led_item == DEV_LED_DARK_COLOR)
|
||||
led_color_code_set(LED_NB_MAX, LED_BR_LV1, &led_c);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -51,12 +51,13 @@ static void device_init(void)
|
||||
(instru.eliteFxn == CURVE_VT) || \
|
||||
(instru.eliteFxn == CURVE_RT) || \
|
||||
(instru.eliteFxn == CURVE_CC) || \
|
||||
(instru.eliteFxn == CURVE_CP) || \
|
||||
(instru.eliteFxn == CURVE_CV) || \
|
||||
(instru.eliteFxn == CURVE_LSV) || \
|
||||
(instru.eliteFxn == CURVE_CA) || \
|
||||
(instru.eliteFxn == CURVE_VO) || \
|
||||
(instru.eliteFxn == CURVE_OCP) || \
|
||||
(instru.eliteFxn == CURVE_CALI_ADC) \
|
||||
(instru.eliteFxn == CURVE_CALI) \
|
||||
)
|
||||
|
||||
#define Ve1MatchVe2Mode() ( \
|
||||
@@ -74,10 +75,16 @@ static void peri_mode(void)
|
||||
if (leadTimeReset && GPT.cnt_lead_time <= 2000) {
|
||||
vscanReset = true;
|
||||
if (first_highz_flag && GPT.cnt_lead_time >= 1000) {
|
||||
if (instru.eliteFxn == CURVE_OCP) {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
|
||||
if (instru.eliteFxn == CURVE_OCP || instru.eliteFxn == CURVE_CC || instru.eliteFxn == CURVE_CP) {
|
||||
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;
|
||||
}
|
||||
@@ -85,6 +92,9 @@ static void peri_mode(void)
|
||||
if (notifyFirst_flag) {
|
||||
GPT.cnt_notify_rate = instru.notifyRate - 20;
|
||||
notifyFirst_flag = false;
|
||||
if (instru.eliteFxn == CURVE_CC || instru.eliteFxn == CURVE_CP) {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
|
||||
}
|
||||
}
|
||||
vscanReset = false;
|
||||
leadTimeReset = false;
|
||||
@@ -112,6 +122,7 @@ static void peri_mode(void)
|
||||
if ((instru.eliteFxn == CURVE_IV) ||
|
||||
(instru.eliteFxn == CURVE_IV_CY) ||
|
||||
(instru.eliteFxn == CURVE_CC) ||
|
||||
(instru.eliteFxn == CURVE_CP) ||
|
||||
(instru.eliteFxn == CURVE_CV) ||
|
||||
(instru.eliteFxn == CURVE_LSV) ||
|
||||
(instru.eliteFxn == CURVE_CA) ||
|
||||
@@ -121,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;
|
||||
|
||||
@@ -225,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;
|
||||
|
||||
@@ -393,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)
|
||||
@@ -425,35 +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_CH1, MEAS_CURR(wm));
|
||||
}
|
||||
|
||||
if (volt_rec_en) {
|
||||
InputNotify(NOTIFY_CH2, instru.Vout/200 - MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CH3, instru.Vout/200);
|
||||
notify_ch4 = MEAS_VOUT(wm);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -462,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) {
|
||||
@@ -532,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;
|
||||
|
||||
@@ -571,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,82 +196,174 @@ 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
|
||||
// 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]
|
||||
Vset = Voutin + (i_set * RESISTANCE_100R); //[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);
|
||||
}
|
||||
|
||||
Vset = Vset + deltaV; //[5nV]
|
||||
|
||||
if (Vset >= 1100000000) { // 5.5V
|
||||
Vset = 1100000000;
|
||||
} else if (Vset <= -1000000000) { //-5V
|
||||
Vset = -1000000000;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static void cp_vscan(void)
|
||||
{
|
||||
struct wm_cp_ctx_t *cp = (struct wm_cp_ctx_t *)wm_get();
|
||||
struct wm_meas_t *m = &cp->measure;
|
||||
uint8_t cc_cp_speed = instru.cc_cp_speed; // 0:low 1:normal 2:high
|
||||
|
||||
int32_t Iin;
|
||||
int32_t Voutin;
|
||||
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) {
|
||||
sum_cnt = 0;
|
||||
sum_adc_delta_Voutin = 0;
|
||||
sum_adc_delta_Iin = 0;
|
||||
resis = 1000;
|
||||
|
||||
if (cp->_charge == 0) { // discharge
|
||||
i_set = cp->_Iset * (-1);
|
||||
Vset = Voutin - 1000000; //[5nV] 1000000 = 5mV
|
||||
} else if(cp->_charge == 1) { // charge
|
||||
i_set = cp->_Iset;
|
||||
Vset = Voutin + 1000000; //[5nV] 1000000 = 5mV
|
||||
}
|
||||
|
||||
divisionRate = cc_cp_speed;
|
||||
|
||||
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
|
||||
|
||||
if (deltaV > DELTAVOLTMAX) { //2000000 = 10mV
|
||||
deltaV = DELTAVOLTMAX;
|
||||
} else if (deltaV < (-DELTAVOLTMAX)) {
|
||||
deltaV = (-DELTAVOLTMAX);
|
||||
}
|
||||
|
||||
Vset = Vset + deltaV; //[5nV]
|
||||
|
||||
if (Vset >= 1100000000) { // 5.5V
|
||||
Vset = 1100000000;
|
||||
} else if (Vset <= -1000000000) { //-5V
|
||||
Vset = -1000000000;
|
||||
}
|
||||
|
||||
if (Vset <= cc->_Vmin) {
|
||||
Vset = cc->_Vmin;
|
||||
} else if (Vset >= cc->_Vmax) {
|
||||
Vset = cc->_Vmax;
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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 ((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 {
|
||||
resis = Rd;
|
||||
}
|
||||
}
|
||||
|
||||
sum_cnt = 0;
|
||||
sum_adc_delta_Voutin = 0;
|
||||
sum_adc_delta_Iin = 0;
|
||||
}
|
||||
|
||||
deltaV = -1 * deltaI * resis / 100 / (int64_t)divisionRate;
|
||||
Vset = Vset + deltaV;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -386,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;
|
||||
|
||||
@@ -619,9 +619,9 @@ static bool power_on(uint32_t delta_time)
|
||||
keyTimer = keyTimer + t;
|
||||
|
||||
if (keyTimer >= 10000) {
|
||||
latch_single_ctrl(E_LATCH_5V_ENABLE, 1);
|
||||
latch_single_ctrl(E_LATCH_10V_ENABLE, 1);
|
||||
|
||||
latch_single_ctrl(E_LATCH_5V_ENABLE, 1);
|
||||
|
||||
CPUdelay_us(320); // need delay 320us to stablize power
|
||||
ModeLED(BT_WAIT);
|
||||
//AD5940_Initialize();
|
||||
@@ -668,6 +668,7 @@ static void key_manage(uint32_t delta_time)
|
||||
|
||||
keyTimer = keyTimer + t;
|
||||
if (keyTimer >= 30000){
|
||||
latch_single_ctrl(E_LATCH_10V_ENABLE, 0);
|
||||
latch_single_ctrl(E_LATCH_5V_ENABLE, 0);
|
||||
|
||||
} else if (keyTimer >= 10000 && !byPass1sec) {
|
||||
@@ -799,12 +800,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 +1169,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.
|
||||
|
||||