Compare commits
142 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 49b11af639 | |||
| 7f703de601 | |||
| d0988e4027 | |||
| 3f416f17b3 | |||
| d706fe9c3e | |||
| c52078cc30 | |||
| 9472ff4ce2 | |||
| 52643ae5d7 | |||
| 09d51b5fd6 | |||
| fe13bf4f42 | |||
| 0607d6cf9b | |||
| 2361e857e9 | |||
| 49d13b8d34 | |||
| 1462879b29 | |||
| 9484705b3b | |||
| 35502b18f0 | |||
| 1dbffad946 | |||
| 65bb984692 | |||
| 890df7ce16 | |||
| 56dca39a16 | |||
| 8162d4eca6 | |||
| 2067de1fb6 | |||
| 2bcccf6036 | |||
| 31c8797a82 | |||
| b359ebf5f9 | |||
| 55c4df4dcb | |||
| 2fbd57cfb4 | |||
| 75e21615d0 | |||
| 97495ceb25 | |||
| 258b8a1c02 | |||
| 46ea9c7afd | |||
| e188cd23c4 | |||
| da720eb9f4 | |||
| d342ae3e9c | |||
| a9d24ad477 | |||
| 7759c9eae9 | |||
| 9e42593882 | |||
| af03bc03e2 | |||
| d096eabf47 | |||
| 441bd80595 | |||
| 3557c3d288 | |||
| 16ac2ab82d | |||
| 6756a057bc | |||
| 00c61096b7 | |||
| 119285f7c8 | |||
| fce1a943e1 | |||
| 30bd896d4c | |||
| 5b2ccf8e7c | |||
| ea24ba5406 | |||
| a23083c080 | |||
| 735ffa2bef | |||
| 5ad2759a81 | |||
| 31c990bc18 | |||
| 9c839a181f | |||
| a10517bf38 | |||
| ac7aaad5a2 | |||
| bc21e3cb27 | |||
| 9baa4e8ae0 | |||
| 00e233cc9e | |||
| 13b4e2253c | |||
| 9c29ad0a86 | |||
| 6b421d73e9 | |||
| 34107872ec | |||
| f6719c3182 | |||
| 79188d76b9 | |||
| 3e5c9b9b73 | |||
| f1fa366b8f | |||
| 16814ad816 | |||
| 92ae63b7f9 | |||
| 1f3e7a5efe | |||
| c573135e98 | |||
| 5d4c5b5a86 | |||
| caf6985e66 | |||
| a7a1f7f2b5 | |||
| 45182935b7 | |||
| 6958c410a1 | |||
| a337434903 | |||
| 14c897c26e | |||
| 02a6018cac | |||
| 544b571f85 | |||
| 939de9098a | |||
| 7441d9a5c8 | |||
| a680f59277 | |||
| b595215326 | |||
| 901108ea90 | |||
| 16dc76833a | |||
| e6993f5a4a | |||
| a2b5a5728b | |||
| 4d76e4585e | |||
| 43e72567c0 | |||
| 311f0d1238 | |||
| 7177e8549b | |||
| 7106f59122 | |||
| 2c203b73a1 | |||
| ba7552e091 | |||
| 4b65c8666e | |||
| 5dc35425d5 | |||
| 790db4bcf4 | |||
| d9cc6f2ba6 | |||
| 5e04fcb7e2 | |||
| dc5cabf2ae | |||
| 7cf60e2717 | |||
| f1ab4be88a | |||
| 3509b6df00 | |||
| 26b37b759f | |||
| 6321fdca51 | |||
| c496ccb791 | |||
| c8aeabdfeb | |||
| 9bfc251029 | |||
| 0273a9571b | |||
| 5318a89132 | |||
| a4f653951e | |||
| 925447817f | |||
| b64a3d031f | |||
| 6fc7b2591f | |||
| 00cc58e720 | |||
| fcc1477acd | |||
| 545fc8323c | |||
| 4c654982d2 | |||
| d7a4e02349 | |||
| ee1d052c3a | |||
| 7acafa81b8 | |||
| e97d556dd9 | |||
| c227d21546 | |||
| f9e33d0ede | |||
| a9fd1028d1 | |||
| f6a20eaea5 | |||
| f904bbd522 | |||
| 6f3a1b57ae | |||
| b795b7eb6b | |||
| a1adf82f2b | |||
| 061064c27a | |||
| 2d1556686c | |||
| 0d7f334499 | |||
| b849231be3 | |||
| 060dde64a8 | |||
| 6be73528d4 | |||
| 7b4436920f | |||
| b34e947cc8 | |||
| 8c4737e494 | |||
| 6f36e781b7 | |||
| 8403c16fa0 |
@@ -0,0 +1,55 @@
|
||||
#Generated from Visual Studio settings
|
||||
---
|
||||
BasedOnStyle: webkit
|
||||
BraceWrapping:
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
AfterClass: true
|
||||
AfterFunction: true
|
||||
AfterControlStatement: true
|
||||
AfterEnum: true
|
||||
AfterNamespace: true
|
||||
AfterObjCDeclaration: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterExternBlock: true
|
||||
ColumnLimit: 0
|
||||
BreakBeforeBraces: Custom
|
||||
NamespaceIndentation: All
|
||||
TabWidth: 4
|
||||
IndentCaseLabels: true
|
||||
AlignAfterOpenBracket: Align
|
||||
PointerAlignment: Right
|
||||
AlignOperands: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakAfterJavaFieldAnnotations: true
|
||||
AlignConsecutiveAssignments: true
|
||||
AlignTrailingComments: true
|
||||
BreakConstructorInitializers: AfterColon
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: true
|
||||
AcrossComments: true
|
||||
AlignArrayOfStructures: Right
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: true
|
||||
PadOperators: true
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: true
|
||||
PadOperators: true
|
||||
AlignEscapedNewlines: Right
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
...
|
||||
@@ -50,7 +50,7 @@ extern "C" {
|
||||
* ==========================================================================*/
|
||||
#include <ti/drivers/PIN.h>
|
||||
#include <driverlib/ioc.h>
|
||||
#include "boards_config/elite_pin_conf.h"
|
||||
#include "boards_config/elite_boards_select.h"
|
||||
|
||||
/** ============================================================================
|
||||
* Externs
|
||||
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
#ifndef ELITE_BOARDS_SELECT_H
|
||||
#define ELITE_BOARDS_SELECT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
*
|
||||
* product number: MAJOR_PRODUCT_NUMBER, MINOR_PRODUCT_NUMBER, MAJOR_VERSION_NUMBER, MINOR_VERSION_NUMBER
|
||||
* MAJOR_PRODUCT_NUMBER -> 0:Elite, 1:other serial
|
||||
* Elite:
|
||||
* MINOR_PRODUCT_NUMBER -> 1:legacy, 2:EDC, 3:BAT, 4:EIS, 5:TRIG, 6:MEGAFLY
|
||||
*
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* | model name | hw upper board | hw lower board | product number | device name | data server lib name | UI |
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* | DEF_ELITE_EDC_1_4 | Elite1.4-re Jun.2019 | Elite1.4-re Jun. 2019 | 0, 2, 1, 5 | "Elite-EDC" | Elite_EDC_1.4 | null |
|
||||
* | DEF_ELITE_EDC_1_5 | Elite1.5 Dec. 2019 | Elite1.5 Dec. 2019 | 0, 2, 1, 6 | "Elite-EDC" | Elite_EDC_1.5 | EliteEDC |
|
||||
* | DEF_ELITE_EDC_1_5_RE | Elite1.5 Dec. 2019 | Elite1.5-re Jan. 2021 | 0, 2, 1, 7 | "Elite-EDC" | Elite_EDC_1.5re | EliteEDC |
|
||||
* | DEF_ELITE_EDC_1_5_R2 | Elite1.5 Dec. 2019 | Elite1.5-r2 May. 2022 | 0, 2, 1, 8 | "Elite-EDC" | Elite_EDC_1.5r2 | EliteEDC |
|
||||
* | DEF_ELITE_BAT_1_0 | Elite2.0 Feb. 2022 | 0, 3, 1, 0 | "Elite-BAT" | Elite_BAT_1.0 | EliteEDC |
|
||||
* | DEF_ELITE_EIS_1_0 | Elite1.5 Dec. 2019 | Elite EIS1.0 Aug. 2020 | 0, 4, 1, 0 | "Elite-EIS" | Elite_EIS_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_1_1 | Elite1.5 Dec. 2019 | Elite EIS1.1 Feb. 2022 | 0, 4, 1, 1 | "Elite-EIS" | Elite_EIS_1.1 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_MINI_1_0 | EIS MINI May. 2022 | 0, 4, 1, 2 | "Elite-EIS-MINI" | Elite_EIS_MINI_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_TRIG_0_1 | Elite TRIG01 Jan. 2021 | 0, 5, 1, 0 | "Elite-TRIG" | Elite_TRIG_0.1 | null |
|
||||
* | DEF_ELITE_MEGAFLY_0_1 | Elite1.5 Dec. 2019 | Elite Megafly Sep. 2020 | 0, 6, 1, 0 | "Elite-MEGAFLY" | Elite_MEGAFLY_0.1 | null |
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* ps.
|
||||
* model name is FW engineer defined
|
||||
* device name is used for controller
|
||||
*/
|
||||
|
||||
|
||||
#define DEF_ELITE_EDC_1_4 0
|
||||
#define DEF_ELITE_EDC_1_5 1
|
||||
#define DEF_ELITE_EDC_1_5_RE 2
|
||||
#define DEF_ELITE_EDC_1_5_R2 3
|
||||
#define DEF_ELITE_BAT_1_0 4
|
||||
#define DEF_ELITE_EIS_1_0 5
|
||||
#define DEF_ELITE_EIS_1_1 6
|
||||
#define DEF_ELITE_EIS_MINI_1_0 7
|
||||
#define DEF_ELITE_TRIG_0_1 8
|
||||
#define DEF_ELITE_MEGAFLY_0_1 9
|
||||
#define DEF_ELITE_MAX 10
|
||||
|
||||
#define DEF_ELITE_MODEL DEF_ELITE_TRIG_0_1
|
||||
#ifndef DEF_ELITE_MODEL
|
||||
#error "DEF_ELITE_MODEL not defined"
|
||||
#endif
|
||||
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_4)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_RE)
|
||||
#include "boards_config/pin_def_edc15re.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_R2)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_0)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_1)
|
||||
#include "boards_config/pin_def_eis11.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_1_0)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_0_1)
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_0_1)
|
||||
#include "boards_config/pin_def_trig01.h"
|
||||
#else
|
||||
#error "no this model"
|
||||
#endif
|
||||
|
||||
|
||||
// model information
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_4)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 5
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 6
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_RE)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 7
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_R2)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 8
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_1_0)
|
||||
#define DEVICE_NAME "Elite-BAT"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 3
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_0)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_1)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 1
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_MINI_1_0)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 2
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_0_1)
|
||||
#define DEVICE_NAME "Elite-TRIG"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 5
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_0_1)
|
||||
#define DEVICE_NAME "Elite-MEGAFLY"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 6
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // ELITE_BOARDS_SELECT_H
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
#define DEF_ELITE_EDC_2_0
|
||||
|
||||
#if defined (DEF_ELITE_EDC_1_5_RE)
|
||||
#include "boards_config/pin_config_edc15re.h"
|
||||
#elif defined (DEF_ELITE_EDC_1_5)
|
||||
#include "boards_config/pin_config_edc15.h"
|
||||
#elif defined (DEF_ELITE_EDC_2_0)
|
||||
#include "boards_config/pin_config_edc20.h"
|
||||
|
||||
#endif
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
#define D0 DIO3
|
||||
#define D1 DIO4
|
||||
#define D2 DIO5
|
||||
#define D3 DIO6
|
||||
#define D4 DIO7
|
||||
#define D5 DIO8
|
||||
#define D6 DIO9
|
||||
#define D7 DIO10
|
||||
#define LOAD0 DIO13
|
||||
#define LOAD1 DIO12
|
||||
#define LOAD2 DIO11
|
||||
#define SHUT_DOWN DIO14
|
||||
|
||||
/* SPI Board */
|
||||
#define Board_SPI0_MISO PIN_UNASSIGNED
|
||||
#define Board_SPI0_MOSI D1
|
||||
#define Board_SPI0_CLK D0
|
||||
#define Board_SPI0_CS PIN_UNASSIGNED
|
||||
|
||||
#define Board_SPI1_MISO DIO1
|
||||
#define Board_SPI1_MOSI D3
|
||||
#define Board_SPI1_CLK D2
|
||||
#define Board_SPI1_CS PIN_UNASSIGNED
|
||||
|
||||
#define CS_ADC LOAD0, D6
|
||||
#define CS_DAC LOAD0, D7
|
||||
#define MOSI LOAD0, D3
|
||||
#define SCLK LOAD0, D2
|
||||
#define LED_MOSI_A LOAD0, D1
|
||||
#define LED_SCLK_A LOAD0, D0
|
||||
#define CS_MEM LOAD0, D5
|
||||
|
||||
#define MEM_HOLD LOAD0, D4
|
||||
#define HIGH_Z LOAD2, D5
|
||||
|
||||
#define I_MID_ON LOAD2, D0
|
||||
#define I_SMALL_ON LOAD2, D4
|
||||
#define I_LARGE_ON LOAD2, D1
|
||||
#define V_SMALL_ON LOAD2, D2
|
||||
#define V_MID_ON LOAD2, D3
|
||||
#define VOUT_SMALL_ON LOAD2, D7
|
||||
#define OFF LOAD2, D6
|
||||
|
||||
#define P_10V_enable LOAD1, D5
|
||||
#define P_5V_enable LOAD1, D6
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
#define D0 DIO3
|
||||
#define D1 DIO4
|
||||
#define D2 DIO5
|
||||
#define D3 DIO6
|
||||
#define D4 DIO7
|
||||
#define D5 DIO8
|
||||
#define D6 DIO9
|
||||
#define D7 DIO10
|
||||
#define LOAD0 DIO13
|
||||
#define LOAD1 DIO12
|
||||
#define LOAD2 DIO11
|
||||
|
||||
#define SHUT_DOWN DIO14 //switch_on
|
||||
|
||||
/* SPI Board */
|
||||
#define Board_SPI0_MISO PIN_UNASSIGNED
|
||||
#define Board_SPI0_MOSI D1
|
||||
#define Board_SPI0_CLK D0
|
||||
#define Board_SPI0_CS PIN_UNASSIGNED
|
||||
|
||||
#define Board_SPI1_MISO DIO1
|
||||
#define Board_SPI1_MOSI D3
|
||||
#define Board_SPI1_CLK D2
|
||||
#define Board_SPI1_CS PIN_UNASSIGNED
|
||||
|
||||
#define LED_SCLK_A LOAD0, D0
|
||||
#define LED_MOSI_A LOAD0, D1
|
||||
#define SCLK LOAD0, D2
|
||||
#define MOSI LOAD0, D3
|
||||
#define HIGH_Z LOAD0, D4
|
||||
#define CS_MEM LOAD0, D5
|
||||
#define CS_ADC LOAD0, D6
|
||||
#define CS_DAC LOAD0, D7
|
||||
|
||||
#define MEM_HOLD LOAD1, D0
|
||||
#define P_10V_enable LOAD1, D5
|
||||
#define P_5V_enable LOAD1, D6
|
||||
|
||||
#define I_MID_ON LOAD2, D0
|
||||
#define I_LARGE_ON LOAD2, D1
|
||||
#define V_SMALL_ON LOAD2, D2
|
||||
#define V_MID_ON LOAD2, D3
|
||||
#define I_SMALL_ON LOAD2, D4
|
||||
#define OFF LOAD2, D6 //6994
|
||||
#define VOUT_SMALL_ON LOAD2, D7
|
||||
|
||||
-85
@@ -1,85 +0,0 @@
|
||||
/* Elite Pin Board */
|
||||
#define E_PIN_LED_SPI_CLK DIO5
|
||||
#define E_PIN_LED_SPI_SDI DIO6
|
||||
#define E_PIN_ADCA0 DIO0
|
||||
#define E_PIN_ADCA1 DIO1
|
||||
#define E_PIN_ADCA2 DIO7
|
||||
#define E_PIN_SWCSBB DIO2
|
||||
#define E_PIN_MEMCS DIO3
|
||||
#define E_PIN_DIO4 DIO4
|
||||
#define E_PIN_I2C_SCK DIO8
|
||||
#define E_PIN_I2C_SDA DIO9
|
||||
#define E_PIN_DACCS DIO10
|
||||
#define E_PIN_ADCCS DIO11
|
||||
#define E_PIN_SCLK0 DIO12
|
||||
#define E_PIN_MOSI DIO13
|
||||
#define E_PIN_MISO DIO14
|
||||
|
||||
/* SPI Board */
|
||||
#define Board_SPI0_MISO PIN_UNASSIGNED
|
||||
#define Board_SPI0_MOSI E_PIN_LED_SPI_SDI
|
||||
#define Board_SPI0_CLK E_PIN_LED_SPI_CLK
|
||||
#define Board_SPI0_CS PIN_UNASSIGNED
|
||||
|
||||
#define Board_SPI1_MISO E_PIN_MISO
|
||||
#define Board_SPI1_MOSI E_PIN_MOSI
|
||||
#define Board_SPI1_CLK E_PIN_SCLK0
|
||||
#define Board_SPI1_CS PIN_UNASSIGNED
|
||||
|
||||
/* I2C */
|
||||
#define Board_I2C0_SCL0 E_PIN_I2C_SCK
|
||||
#define Board_I2C0_SDA0 E_PIN_I2C_SDA
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define D0 PIN_UNASSIGNED
|
||||
#define D1 PIN_UNASSIGNED
|
||||
#define D2 PIN_UNASSIGNED
|
||||
#define D3 PIN_UNASSIGNED
|
||||
#define D4 PIN_UNASSIGNED
|
||||
#define D5 PIN_UNASSIGNED
|
||||
#define D6 PIN_UNASSIGNED
|
||||
#define D7 PIN_UNASSIGNED
|
||||
#define LOAD0 PIN_UNASSIGNED
|
||||
#define LOAD1 PIN_UNASSIGNED
|
||||
#define LOAD2 PIN_UNASSIGNED
|
||||
|
||||
#define SHUT_DOWN PIN_UNASSIGNED //switch_on
|
||||
|
||||
|
||||
|
||||
// #define ADC_CS DIO11
|
||||
//#define DAC_CS DIO10
|
||||
|
||||
#define HIGH_Z LOAD0, PIN_UNASSIGNED
|
||||
#define CS_MEM LOAD0, PIN_UNASSIGNED
|
||||
#define CS_ADC LOAD0, PIN_UNASSIGNED
|
||||
#define CS_DAC LOAD0, PIN_UNASSIGNED
|
||||
|
||||
#define MEM_HOLD LOAD1, PIN_UNASSIGNED
|
||||
#define P_10V_enable LOAD1, PIN_UNASSIGNED
|
||||
#define P_5V_enable LOAD1, PIN_UNASSIGNED
|
||||
|
||||
#define I_MID_ON LOAD2, PIN_UNASSIGNED
|
||||
#define I_LARGE_ON LOAD2, PIN_UNASSIGNED
|
||||
#define V_SMALL_ON LOAD2, PIN_UNASSIGNED
|
||||
#define V_MID_ON LOAD2, PIN_UNASSIGNED
|
||||
#define I_SMALL_ON LOAD2, PIN_UNASSIGNED
|
||||
#define OFF LOAD2, PIN_UNASSIGNED //6994
|
||||
#define VOUT_SMALL_ON LOAD2, PIN_UNASSIGNED
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
#ifndef PIN_DEF_TRIG01_H
|
||||
#define PIN_DEF_TRIG01_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*
|
||||
* +------------------------------+
|
||||
* | CC2650moda |
|
||||
* +-------------+----------------+
|
||||
* | TRIG_0 | DIO_0 |
|
||||
* | MISO | DIO_1 |
|
||||
* | TRIG_1 | DIO_2 | re: short TRIG_1 & LOAD2
|
||||
* | D0 | DIO_3 |
|
||||
* | D1 | DIO_4 |
|
||||
* | D2/JTAG_TDO | DIO_5/JTAG_TDO |
|
||||
* | D3/JTAG_TDI | DIO_6/JTAG_TDI |
|
||||
* | D4 | DIO_7 |
|
||||
* | D5 | DIO_8 |
|
||||
* | D6 | DIO_9 |
|
||||
* | D7 | DIO_10 |
|
||||
* | LOAD0 | DIO_11 |
|
||||
* | LOAD1 | DIO_12 |
|
||||
* | FLT | DIO_13 |
|
||||
* | SHUT_DOWN | DIO_14 |
|
||||
* +-------------+----------------+
|
||||
*/
|
||||
|
||||
#define CC2650_TRIG_0 DIO0
|
||||
#define CC2650_MISO DIO1
|
||||
#define CC2650_TRIG_1 DIO2
|
||||
#define CC2650_D0 DIO3
|
||||
#define CC2650_D1 DIO4
|
||||
#define CC2650_D2 DIO5
|
||||
#define CC2650_D3 DIO6
|
||||
#define CC2650_D4 DIO7
|
||||
#define CC2650_D5 DIO8
|
||||
#define CC2650_D6 DIO9
|
||||
#define CC2650_D7 DIO10
|
||||
#define CC2650_LOAD0 DIO11
|
||||
#define CC2650_LOAD1 DIO12
|
||||
#define CC2650_FLT DIO13
|
||||
#define CC2650_SHUT_DOWN DIO14
|
||||
#define CC2650_LOAD2 CC2650_TRIG_1
|
||||
|
||||
#define E_PIN_LED_SCLK_A CC2650_LOAD0, CC2650_D0
|
||||
#define E_PIN_LED_MOSI_A CC2650_LOAD0, CC2650_D1
|
||||
#define E_PIN_SCLK CC2650_LOAD0, CC2650_D2
|
||||
#define E_PIN_MOSI CC2650_LOAD0, CC2650_D3
|
||||
#define E_PIN_TW_SCKI_0 CC2650_LOAD0, CC2650_D4
|
||||
#define E_PIN_TW_SCKI_1 CC2650_LOAD0, CC2650_D5
|
||||
#define E_PIN_TW_SCKI_2 CC2650_LOAD0, CC2650_D6
|
||||
#define E_PIN_TW_SCKI_3 CC2650_LOAD0, CC2650_D7
|
||||
|
||||
#define E_PIN_BAT_CHAR CC2650_LOAD1, CC2650_D0
|
||||
#define E_PIN_BAT_OK CC2650_LOAD1, CC2650_D1
|
||||
#define E_PIN_3V_PULL_UP_DOWN_0 CC2650_LOAD1, CC2650_D2
|
||||
#define E_PIN_3V_PULL_UP_DOWN_1 CC2650_LOAD1, CC2650_D3
|
||||
#define E_PIN_OFF CC2650_LOAD1, CC2650_D4
|
||||
#define E_PIN_5V_OUT_EN_0 CC2650_LOAD1, CC2650_D5
|
||||
#define E_PIN_5V_enable CC2650_LOAD1, CC2650_D6
|
||||
#define E_PIN_5V_OUT_EN_1 CC2650_LOAD1, CC2650_D7
|
||||
|
||||
#define E_PIN_DO_MOS_0 CC2650_LOAD2, CC2650_D0
|
||||
#define E_PIN_DO_MOS_1 CC2650_LOAD2, CC2650_D1
|
||||
#define E_PIN_AO_MOS_0 CC2650_LOAD2, CC2650_D2
|
||||
#define E_PIN_AO_MOS_1 CC2650_LOAD2, CC2650_D3
|
||||
#define E_PIN_AO_MOS_2 CC2650_LOAD2, CC2650_D4
|
||||
#define E_PIN_AO_MOS_3 CC2650_LOAD2, CC2650_D5
|
||||
#define E_PIN_D0_PR_0 CC2650_LOAD2, CC2650_D6
|
||||
#define E_PIN_D0_PR_1 CC2650_LOAD2, CC2650_D7
|
||||
|
||||
/* SPI Board */
|
||||
#define Board_SPI0_MISO PIN_UNASSIGNED
|
||||
#define Board_SPI0_MOSI CC2650_D1 // load0 need to activate
|
||||
#define Board_SPI0_CLK CC2650_D0 // load0 need to activate
|
||||
#define Board_SPI0_CS PIN_UNASSIGNED
|
||||
|
||||
#define Board_SPI1_MISO CC2650_MISO
|
||||
#define Board_SPI1_MOSI CC2650_D3 // load0 need to activate
|
||||
#define Board_SPI1_CLK CC2650_D2 // load0 need to activate
|
||||
#define Board_SPI1_CS PIN_UNASSIGNED
|
||||
|
||||
/* I2C */
|
||||
#define Board_I2C0_SCL0 PIN_UNASSIGNED
|
||||
#define Board_I2C0_SDA0 PIN_UNASSIGNED
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // PIN_DEF_TRIG01_H
|
||||
+16
-19
@@ -1,29 +1,26 @@
|
||||
#ifndef SPI_CTRL_H
|
||||
#define SPI_CTRL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define POL0 0
|
||||
#define POL1 1
|
||||
#define PHA0 0
|
||||
#define PHA1 1
|
||||
#define SPI0 0
|
||||
#define SPI1 1
|
||||
#define SPI_POL0 0
|
||||
#define SPI_POL1 1
|
||||
#define SPI_PHA0 0
|
||||
#define SPI_PHA1 1
|
||||
|
||||
#define SPI_CLK_10M 10000000
|
||||
#define SPI_CLK_4M 4000000
|
||||
#define SPI_RATE_1M 1000000
|
||||
#define SPI_RATE_4M 4000000
|
||||
#define SPI_RATE_6M 6000000
|
||||
|
||||
uint8_t spi_open(uint8_t spi_n, uint32_t b_rate, uint8_t pol, uint8_t pha);
|
||||
uint8_t spi_close(uint8_t spi_n);
|
||||
uint8_t spi_write(uint8_t spi_n, uint8_t *rxBuf, uint8_t *txBuf, uint8_t len);
|
||||
|
||||
bool spi0_open(uint32_t bitRate, uint8_t polarity, uint8_t phase);
|
||||
void spi0_close(void);
|
||||
int spi0_write(uint8_t *rxBuf, uint8_t *txBuf, uint8_t len);
|
||||
|
||||
bool spi1_open(uint32_t bitRate, uint8_t polarity, uint8_t phase);
|
||||
void spi1_close(void);
|
||||
int spi1_write(uint8_t *rxBuf, uint8_t *txBuf, uint8_t len);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif // SPI_CTRL_H
|
||||
|
||||
+117
-86
@@ -1,112 +1,143 @@
|
||||
#include <ti/drivers/SPI.h>
|
||||
#include "board.h"
|
||||
#include "driver/spi_ctrl.h"
|
||||
static SPI_Handle spiHandle0 = NULL;
|
||||
static SPI_Params spiParams0;
|
||||
|
||||
/* system use SPI parameters */
|
||||
static SPI_Handle spiHandle1 = NULL;
|
||||
static SPI_Params spiParams1;
|
||||
#define CC2650_SPI_BITRATE_MAX 6e6 // Full-duplex maximum speed = 6M
|
||||
|
||||
static SPI_Handle handle0 = NULL;
|
||||
static SPI_Handle handle1 = NULL;
|
||||
|
||||
bool spi0_open(uint32_t bitRate, uint8_t polarity, uint8_t phase)
|
||||
/**
|
||||
* _get_spi_mode - transfer both polarity and phase to pol_pha_combine
|
||||
* @pol: polarity
|
||||
* @pha: phase
|
||||
* Returns: spi mode
|
||||
*/
|
||||
static SPI_FrameFormat _get_spi_mode(uint8_t pol, uint8_t pha)
|
||||
{
|
||||
uint8_t pol = polarity;
|
||||
uint8_t pha = phase;
|
||||
SPI_FrameFormat frameFormat;
|
||||
SPI_FrameFormat spi_mode;
|
||||
|
||||
if (pol == 0 && pha == 0)
|
||||
frameFormat = SPI_POL0_PHA0;
|
||||
spi_mode = SPI_POL0_PHA0;
|
||||
else if (pol == 0 && pha == 1)
|
||||
frameFormat = SPI_POL0_PHA1;
|
||||
spi_mode = SPI_POL0_PHA1;
|
||||
else if (pol == 1 && pha == 0)
|
||||
frameFormat = SPI_POL1_PHA0;
|
||||
spi_mode = SPI_POL1_PHA0;
|
||||
else if (pol == 1 && pha == 1)
|
||||
frameFormat = SPI_POL1_PHA1;
|
||||
spi_mode = SPI_POL1_PHA1;
|
||||
|
||||
/* Configure SPI as master */
|
||||
SPI_Params_init(&spiParams0);
|
||||
spiParams0.bitRate = bitRate;
|
||||
spiParams0.mode = SPI_MASTER;
|
||||
spiParams0.dataSize = 8;
|
||||
spiParams0.frameFormat = frameFormat;
|
||||
|
||||
/* Attempt to open SPI. */
|
||||
spiHandle0 = SPI_open(Board_SPI0, &spiParams0);
|
||||
|
||||
return spiHandle0 != NULL;
|
||||
return spi_mode;
|
||||
}
|
||||
|
||||
/* Close the RTOS SPI driver */
|
||||
void spi0_close(void)
|
||||
/**
|
||||
* spi_open -
|
||||
* @spi_n: which SPI
|
||||
* @b_rate: bit rate of SPI
|
||||
* @pol: polarity
|
||||
* @pha: phase
|
||||
* Returns: 0 on success, 1 on no this spi module, 2 on spi already open,
|
||||
* 3 on unsupported bit rate, 4 on unsupported polarity and phase,
|
||||
* while (1); on failure
|
||||
* note: Before using PIN_open() and SPI_open(), make sure that the pins are
|
||||
* not already registered, otherwise it will crash.
|
||||
*/
|
||||
uint8_t spi_open(uint8_t spi_n, uint32_t b_rate, uint8_t pol, uint8_t pha)
|
||||
{
|
||||
if (spiHandle0 != NULL)
|
||||
{
|
||||
// Close the RTOS driver
|
||||
SPI_close(spiHandle0);
|
||||
spiHandle0 = NULL;
|
||||
}
|
||||
SPI_Params para;
|
||||
|
||||
if (spi_n >= 2)
|
||||
return 1;
|
||||
|
||||
if ((spi_n == SPI0 && handle0) || (spi_n == SPI1 && handle1))
|
||||
return 2;
|
||||
|
||||
if (b_rate > CC2650_SPI_BITRATE_MAX)
|
||||
return 3;
|
||||
|
||||
if (pol > 1 || pha > 1)
|
||||
return 4;
|
||||
|
||||
SPI_Params_init(¶);
|
||||
para.bitRate = b_rate;
|
||||
para.mode = SPI_MASTER;
|
||||
para.dataSize = 8;
|
||||
para.frameFormat = _get_spi_mode(pol, pha);
|
||||
|
||||
if (spi_n == SPI0) {
|
||||
handle0 = SPI_open(Board_SPI0, ¶);
|
||||
if (handle0 == NULL) {
|
||||
while (1);
|
||||
}
|
||||
|
||||
} else {
|
||||
handle1 = SPI_open(Board_SPI1, ¶);
|
||||
if (handle1 == NULL) {
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int spi0_write(uint8_t *rxBuf, uint8_t *txBuf, uint8_t len)
|
||||
/**
|
||||
* spi_close -
|
||||
* @spi_n: which SPI
|
||||
* Returns: 0 on success, 1 on no this spi module, 2 on no instance
|
||||
* note: Before using PIN_close() and SPI_close(), make sure that there is \
|
||||
* an instance available, otherwise it will crash.
|
||||
*/
|
||||
uint8_t spi_close(uint8_t spi_n)
|
||||
{
|
||||
SPI_Transaction spi0Transaction;
|
||||
if (spi_n >= 2)
|
||||
return 1;
|
||||
|
||||
spi0Transaction.count = len;
|
||||
spi0Transaction.txBuf = txBuf;
|
||||
spi0Transaction.arg = NULL;
|
||||
spi0Transaction.rxBuf = NULL;
|
||||
if ((spi_n == SPI0 && !handle0) || (spi_n == SPI1 && !handle1))
|
||||
return 2;
|
||||
|
||||
return SPI_transfer(spiHandle0, &spi0Transaction) ? 0 : -1;
|
||||
if (spi_n == SPI0) {
|
||||
SPI_close(handle0);
|
||||
handle0 = NULL;
|
||||
} else {
|
||||
SPI_close(handle1);
|
||||
handle1 = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Open the RTOS SPI driver */
|
||||
bool spi1_open(uint32_t bitRate, uint8_t polarity, uint8_t phase)
|
||||
/**
|
||||
* spi_write -
|
||||
* @spi_n: which SPI
|
||||
* @*rxBuf: rxbuf
|
||||
* @*txBuf: txbuf
|
||||
* @len: what is the required length
|
||||
* Returns: 0 on success, 1 on no this spi module, 2 on no instance,
|
||||
* 3 on write failure
|
||||
*/
|
||||
uint8_t spi_write(uint8_t spi_n, uint8_t *rxBuf, uint8_t *txBuf, uint8_t len)
|
||||
{
|
||||
uint32_t rate = bitRate;
|
||||
uint8_t pol = polarity;
|
||||
uint8_t pha = phase;
|
||||
SPI_FrameFormat frameFormat;
|
||||
bool transferOK;
|
||||
SPI_Transaction spi_tran;
|
||||
|
||||
if (pol == 0 && pha == 0)
|
||||
frameFormat = SPI_POL0_PHA0;
|
||||
else if (pol == 0 && pha == 1)
|
||||
frameFormat = SPI_POL0_PHA1;
|
||||
else if (pol == 1 && pha == 0)
|
||||
frameFormat = SPI_POL1_PHA0;
|
||||
else if (pol == 1 && pha == 1)
|
||||
frameFormat = SPI_POL1_PHA1;
|
||||
if (spi_n >= 2)
|
||||
return 1;
|
||||
|
||||
if ((spi_n == SPI0 && !handle0) || (spi_n == SPI1 && !handle1))
|
||||
return 2;
|
||||
|
||||
spi_tran.count = len;
|
||||
spi_tran.txBuf = txBuf;
|
||||
spi_tran.rxBuf = rxBuf;
|
||||
|
||||
if (spi_n == SPI0) {
|
||||
transferOK = SPI_transfer(handle0, &spi_tran);
|
||||
} else {
|
||||
transferOK = SPI_transfer(handle1, &spi_tran);
|
||||
}
|
||||
|
||||
/* Configure SPI as master */
|
||||
SPI_Params_init(&spiParams1);
|
||||
spiParams1.bitRate = rate;
|
||||
spiParams1.mode = SPI_MASTER;
|
||||
spiParams1.dataSize = 8;
|
||||
spiParams1.frameFormat = frameFormat;
|
||||
|
||||
/* Attempt to open SPI. */
|
||||
spiHandle1 = SPI_open(Board_SPI1, &spiParams1);
|
||||
|
||||
return spiHandle1 != NULL;
|
||||
}
|
||||
|
||||
/* Close the RTOS SPI driver */
|
||||
void spi1_close(void)
|
||||
{
|
||||
if (spiHandle1 != NULL)
|
||||
{
|
||||
// Close the RTOS driver
|
||||
SPI_close(spiHandle1);
|
||||
spiHandle1 = NULL;
|
||||
if (!transferOK) {
|
||||
// Error in SPI or transfer already in progress.
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
int spi1_write(uint8_t *rxBuf, uint8_t *txBuf, uint8_t len)
|
||||
{
|
||||
SPI_Transaction spi1Transaction;
|
||||
|
||||
spi1Transaction.count = len;
|
||||
spi1Transaction.txBuf = txBuf;
|
||||
spi1Transaction.arg = NULL;
|
||||
spi1Transaction.rxBuf = rxBuf;
|
||||
|
||||
return SPI_transfer(spiHandle1, &spi1Transaction) ? 0 : -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
#ifndef __TIMERS_H
|
||||
#define __TIMERS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void elite_gptimer_open(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Texas Instruments Incorporated
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of Texas Instruments Incorporated nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <ti/drivers/timer/GPTimerCC26XX.h>
|
||||
#include <xdc/runtime/Types.h>
|
||||
#include <ti/sysbios/BIOS.h>
|
||||
#include "board.h"
|
||||
#include "driver/timers.h"
|
||||
#include "service/app_ser.h"
|
||||
|
||||
#define CLOCK_FREQ 4769 // clock freq = 0.1 ms(4800), Measured(4769)
|
||||
|
||||
static void __timerCallback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask)
|
||||
{
|
||||
// interrupt callback code goes here. Minimize processing in interrupt.
|
||||
elite_100us_task();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void elite_gptimer_open(void)
|
||||
{
|
||||
GPTimerCC26XX_Handle hTimer;
|
||||
GPTimerCC26XX_Params params;
|
||||
GPTimerCC26XX_Params_init(¶ms);
|
||||
params.width = GPT_CONFIG_16BIT;
|
||||
params.mode = GPT_MODE_PERIODIC_UP;
|
||||
params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
|
||||
hTimer = GPTimerCC26XX_open(Board_GPTIMER0A, ¶ms);
|
||||
if (hTimer == NULL) {
|
||||
Task_exit();
|
||||
}
|
||||
|
||||
Types_FreqHz freq;
|
||||
BIOS_getCpuFreq(&freq);
|
||||
//GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; //47999 = 1ms
|
||||
GPTimerCC26XX_Value loadVal = CLOCK_FREQ; //0.1ms
|
||||
GPTimerCC26XX_setLoadValue(hTimer, loadVal);
|
||||
GPTimerCC26XX_registerInterrupt(hTimer, __timerCallback, GPT_INT_TIMEOUT);
|
||||
GPTimerCC26XX_start(hTimer);
|
||||
|
||||
return;
|
||||
}
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
#ifndef ADGS1412_H
|
||||
#define ADGS1412_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define SIZE_OF_DAISY_CHAIN_COMMAND 2
|
||||
|
||||
|
||||
struct switch_series_data_t {
|
||||
uint8_t device8_switch;
|
||||
uint8_t device7_switch;
|
||||
uint8_t device6_switch;
|
||||
uint8_t device5_switch;
|
||||
uint8_t device4_switch;
|
||||
uint8_t device3_switch;
|
||||
uint8_t device2_switch;
|
||||
uint8_t device1_switch;
|
||||
}__attribute__((packed));
|
||||
|
||||
|
||||
enum ADGS1412_SWITCH_ENABLE_e {
|
||||
ALL_OPEN = 0x00, // 0b00000000
|
||||
SINGLE_S1 = 0x01, // 0b00000001
|
||||
SINGLE_S2 = 0x02, // 0b00000010
|
||||
S1_S2_ON = 0x03, // 0b00000011
|
||||
SINGLE_S3 = 0x04, // 0b00000100
|
||||
S3_S1_ON = 0x05, // 0b00000101
|
||||
S3_S2_ON = 0x06, // 0b00000110
|
||||
S3_S2_S1_ON = 0x07, // 0b00000111
|
||||
SINGLE_S4 = 0x08, // 0b00001000
|
||||
S4_S1_ON = 0x09, // 0b00001001
|
||||
S4_S2_ON = 0x0A, // 0b00001010
|
||||
S4_S2_S1_ON = 0x0B, // 0b00001011
|
||||
S4_S3_ON = 0x0C, // 0b00001100
|
||||
S4_S3_S1_ON = 0x0D, // 0b00001101
|
||||
S4_S3_S2_ON = 0x0E, // 0b00001110
|
||||
ALL_ON = 0x0F, // 0b00001111
|
||||
};
|
||||
|
||||
|
||||
enum ADGS1412_module_e {
|
||||
ADGS1412_MODULE_U14 = 0,
|
||||
ADGS1412_MODULE_U13,
|
||||
ADGS1412_MODULE_U18,
|
||||
ADGS1412_MODULE_U20,
|
||||
ADGS1412_MODULE_U26,
|
||||
ADGS1412_MODULE_U29,
|
||||
ADGS1412_MODULE_U22,
|
||||
ADGS1412_MODULE_U24,
|
||||
|
||||
ADGS1412_MODULE_MAX,
|
||||
};
|
||||
|
||||
|
||||
static struct switch_series_data_t switch_series_data_g = {0};
|
||||
|
||||
int switch_ctrl(uint8_t switch_module_number, uint8_t enable_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
-107
@@ -1,107 +0,0 @@
|
||||
#include "hardware/ADGS1412.h"
|
||||
|
||||
|
||||
static const uint8_t SPI_DAISY_CHAIN_COMMAND[2] = {0x25, 0x00};
|
||||
|
||||
static int __switch_transfer(struct switch_series_data_t *sd)
|
||||
{
|
||||
spi1_close();
|
||||
spi1_open(SPI_CLK_4M, POL0, PHA0);
|
||||
|
||||
pin_set(E_PIN_SWCSBB, 0);
|
||||
#define WRITE_TO_SWITCH(_d, _l) spi1_write(NULL, (uint8_t *)(_d), (_l))
|
||||
WRITE_TO_SWITCH(sd, 8);
|
||||
pin_set(E_PIN_SWCSBB, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int __switch_daisy_chain_mode() {
|
||||
spi1_close();
|
||||
spi1_open(SPI_CLK_4M, POL0, PHA0);
|
||||
|
||||
|
||||
pin_set(E_PIN_SWCSBB, 0);
|
||||
spi1_write(NULL, SPI_DAISY_CHAIN_COMMAND, 2);
|
||||
pin_set(E_PIN_SWCSBB, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int __set_switch_param(enum ADGS1412_module_e switch_module, enum ADGS1412_SWITCH_ENABLE_e enable_type, struct switch_series_data_t *switch_data)
|
||||
{
|
||||
struct switch_series_data_t *sd = switch_data;
|
||||
enum ADGS1412_module_e sw_module = switch_module;
|
||||
enum ADGS1412_SWITCH_ENABLE_e en_type = enable_type;
|
||||
|
||||
switch(sw_module) {
|
||||
case ADGS1412_MODULE_U14:
|
||||
sd->device8_switch = (uint8_t)en_type;
|
||||
break;
|
||||
|
||||
case ADGS1412_MODULE_U13:
|
||||
sd->device7_switch = (uint8_t)en_type;
|
||||
break;
|
||||
|
||||
case ADGS1412_MODULE_U18:
|
||||
sd->device6_switch = (uint8_t)en_type;
|
||||
break;
|
||||
|
||||
case ADGS1412_MODULE_U20:
|
||||
sd->device5_switch = (uint8_t)en_type;
|
||||
break;
|
||||
|
||||
case ADGS1412_MODULE_U26:
|
||||
sd->device4_switch = (uint8_t)en_type;
|
||||
break;
|
||||
|
||||
case ADGS1412_MODULE_U29:
|
||||
sd->device3_switch = (uint8_t)en_type;
|
||||
break;
|
||||
|
||||
case ADGS1412_MODULE_U22:
|
||||
sd->device2_switch = (uint8_t)en_type;
|
||||
break;
|
||||
|
||||
case ADGS1412_MODULE_U24:
|
||||
sd->device1_switch = (uint8_t)en_type;
|
||||
break;
|
||||
case ADGS1412_MODULE_MAX:
|
||||
*sd = (struct switch_series_data_t) {.device8_switch = (uint8_t)en_type,
|
||||
.device7_switch = (uint8_t)en_type,
|
||||
.device6_switch = (uint8_t)en_type,
|
||||
.device5_switch = (uint8_t)en_type,
|
||||
.device4_switch = (uint8_t)en_type,
|
||||
.device3_switch = (uint8_t)en_type,
|
||||
.device2_switch = (uint8_t)en_type,
|
||||
.device1_switch = (uint8_t)en_type,
|
||||
};
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int switch_ctrl(uint8_t switch_module_number, uint8_t enable_type)
|
||||
{
|
||||
|
||||
struct switch_series_data_t *sd = &switch_series_data_g;
|
||||
enum ADGS1412_module_e sw_module = (enum ADGS1412_module_e) switch_module_number;
|
||||
enum ADGS1412_SWITCH_ENABLE_e en_type = (enum ADGS1412_SWITCH_ENABLE_e) enable_type;
|
||||
|
||||
if(sw_module > ADGS1412_MODULE_MAX)
|
||||
return -1;
|
||||
|
||||
if(en_type > ALL_ON)
|
||||
return -2;
|
||||
|
||||
if (sw_module == ADGS1412_MODULE_U24 && en_type == S1_S2_ON)
|
||||
return -3;
|
||||
|
||||
__switch_daisy_chain_mode();
|
||||
__set_switch_param(sw_module, en_type, sd);
|
||||
__switch_transfer(sd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
#ifndef DAC_MAX5136_H
|
||||
#define DAC_MAX5136_H
|
||||
|
||||
|
||||
#define REVERT_2_BYTE(_b) ((_b) >> 8 | (((_b) & 0xFF) << 8))
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX5136_NUM_MAX 2
|
||||
#define SIZEOFDAC_SPI MAX5136_NUM_MAX*3
|
||||
// #include "driver/spi_ctrl.h"
|
||||
|
||||
|
||||
|
||||
#define CTRL_B_LDAC 0x01
|
||||
#define CTRL_B_CLR 0x02
|
||||
#define CTRL_B_POW_CTRL 0x03
|
||||
#define CTRL_B_LINEARITY 0x05
|
||||
#define CTRL_B_WRT(_d0, _d1) (0x10 | ((_d1) << 1) | (_d0))
|
||||
#define CTRL_B_WRT_THR(_d0, _d1) (0x30 | ((_d1) << 1) | (_d0))
|
||||
|
||||
#define DATA_B_LDAC(_d0, _d1) ((_d1) << 9 | (_d0) << 8)
|
||||
#define DATA_B_POW_CT(_d0, _d1, _rd) ((_d1) << 9 | (_d0) << 8 | (_rd) << 7)
|
||||
#define DATA_B_LINE(_en) ((_en) << 9)
|
||||
|
||||
#define DAC0_EN 1
|
||||
#define DAC0_DIS 0
|
||||
#define DAC1_EN 1
|
||||
#define DAC1_DIS 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enum MAX5136_num_e {
|
||||
DAC_NB_0 = 0x00,
|
||||
DAC_NB_1,
|
||||
DAC_NB_MAX = 0x02,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
struct dac_series_control_t
|
||||
{
|
||||
uint8_t dac0_enable;
|
||||
uint8_t dac1_enable;
|
||||
uint16_t volts;
|
||||
}__attribute__((packed));
|
||||
|
||||
|
||||
struct dac_series_control_t dac_series_control_g[MAX5136_NUM_MAX] = {0};
|
||||
|
||||
|
||||
|
||||
//int dac_write_through_mode(uint8_t dac0_enable, uint8_t dac1_enable, uint16_t volts, struct dac_series_data_t *sd_dac);
|
||||
// int dac_series_control_clear();
|
||||
int dac_enable_all_output(struct dac_series_control_t *seriesPtr);
|
||||
int dac_enable_single_output(uint8_t dac0_enable, uint8_t dac1_enable, uint16_t volts, enum MAX5136_num_e dac_num);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //DAC_MAX5136_H
|
||||
-110
@@ -1,110 +0,0 @@
|
||||
#include "hardware/DAC_MAX5136.h"
|
||||
|
||||
|
||||
struct dac_series_data_t {
|
||||
uint8_t control_bits;
|
||||
uint16_t data_bits;
|
||||
}__attribute__((packed));
|
||||
|
||||
|
||||
static struct dac_series_data_t dac_series_data_g[MAX5136_NUM_MAX] = {0};
|
||||
|
||||
|
||||
static int __dac_transfer(struct dac_series_data_t *sd)
|
||||
{
|
||||
|
||||
|
||||
spi1_close();
|
||||
spi1_open(SPI_CLK_4M, POL1, PHA0);
|
||||
|
||||
pin_set(E_PIN_DACCS, 0);
|
||||
|
||||
#define WRITE_TO_DAC(_d, _l) spi1_write(NULL, (uint8_t *)(_d), (_l))
|
||||
WRITE_TO_DAC(sd, SIZEOFDAC_SPI);
|
||||
|
||||
pin_set(E_PIN_DACCS, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int __dac_write_through_mode(uint8_t dac0_enable, uint8_t dac1_enable, uint16_t volts, struct dac_series_data_t *sd_dac)
|
||||
{
|
||||
uint8_t d0 = dac0_enable;
|
||||
uint8_t d1 = dac1_enable;
|
||||
uint16_t v = volts;
|
||||
|
||||
struct dac_series_data_t *sd = sd_dac;
|
||||
|
||||
sd->control_bits = CTRL_B_WRT_THR(d0, d1);
|
||||
sd->data_bits = REVERT_2_BYTE(v);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int dac_series_control_clear() {
|
||||
for(int i = DAC_NB_0; i < DAC_NB_MAX; i++) {
|
||||
dac_series_control_g[i].dac0_enable = 0;
|
||||
dac_series_control_g[i].dac1_enable = 0;
|
||||
dac_series_control_g[i].volts = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int dac_enable_all_output(struct dac_series_control_t *seriesPtr)
|
||||
{
|
||||
struct dac_series_data_t *sd = dac_series_data_g;
|
||||
|
||||
for(int i = DAC_NB_0; i < DAC_NB_MAX; i++) {
|
||||
if (seriesPtr[i].dac0_enable || seriesPtr[i].dac1_enable) {
|
||||
uint8_t dac0_en = seriesPtr[i].dac0_enable;
|
||||
uint8_t dac1_en = seriesPtr[i].dac1_enable;
|
||||
uint16_t v = seriesPtr[i].volts;
|
||||
__dac_write_through_mode(dac0_en, dac1_en, v, (sd + i));
|
||||
}
|
||||
}
|
||||
|
||||
__dac_transfer(sd);
|
||||
|
||||
dac_series_control_clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int dac_enable_single_output(uint8_t dac0_enable, uint8_t dac1_enable, uint16_t volts, enum MAX5136_num_e dac_num) {
|
||||
uint8_t dac0_en = dac0_enable;
|
||||
uint8_t dac1_en = dac1_enable;
|
||||
uint16_t v = volts;
|
||||
enum MAX5136_num_e dac_n = dac_num;
|
||||
struct dac_series_data_t *sd = dac_series_data_g;
|
||||
|
||||
if(dac_n >= DAC_NB_MAX)
|
||||
return -1;
|
||||
|
||||
for(int i = DAC_NB_0; i < DAC_NB_MAX; i++) {
|
||||
if(i == dac_n)
|
||||
__dac_write_through_mode(dac0_en, dac1_en, v, (sd+i));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
#ifndef MCP23008_H
|
||||
#define MCP23008_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//i2c addr
|
||||
/************************************************************************************************
|
||||
* .h
|
||||
************************************************************************************************/
|
||||
/*
|
||||
* Register addresses
|
||||
* +---------+-------------------+
|
||||
* | Address | Access to: |
|
||||
* +---------+-------------------+
|
||||
* | 00h | IODIR |
|
||||
* | 01h | IPOL |
|
||||
* | 02h | GPINTEN |
|
||||
* | 03h | DEFVAL |
|
||||
* | 04h | INTCON |
|
||||
* | 05h | IOCON |
|
||||
* | 06h | GPPU |
|
||||
* | 07h | INTF |
|
||||
* | 08h | INTCAP(Read-only) |
|
||||
* | 09h | GPIO |
|
||||
* | 0Ah | OLAT |
|
||||
* +---------+-------------------+
|
||||
*/
|
||||
|
||||
#define MCP23008_WT_BIT 0
|
||||
#define MCP23008_RD_BIT 1
|
||||
|
||||
|
||||
|
||||
#define GET_INPUT_SW_SEN() ((chip_MCP23008_rd_reg_stat(MCP23008_MODULE_U503, MCP23008_REG_GPIO) & 0x40) >> 6)
|
||||
|
||||
#define PUSH_KEY (GET_INPUT_SW_SEN() == 0)
|
||||
|
||||
#define SET_VLOGIC_EN_GPIO(_v) (chip_MCP23008_set(MCP23008_MODULE_U503, MCP23008_REG_GPIO, MCP23008_P4, _v))
|
||||
#define SET_VLOGIC_EN_IODIR(_v) (chip_MCP23008_set(MCP23008_MODULE_U503, MCP23008_REG_IODIR, MCP23008_P4, _v))
|
||||
#define SET_SW_EN_GPIO(_v) (chip_MCP23008_set(MCP23008_MODULE_U503, MCP23008_REG_GPIO, MCP23008_P5, _v))
|
||||
|
||||
|
||||
|
||||
enum mcp23008_module_e {
|
||||
MCP23008_MODULE_U503 = 0,
|
||||
MCP23008_MODULE_U505,
|
||||
|
||||
MCP23008_MODULE_MAX,
|
||||
};
|
||||
|
||||
enum mcp23008_reg_name_e {
|
||||
MCP23008_REG_IODIR = 0x00,
|
||||
MCP23008_REG_IPOL,
|
||||
MCP23008_REG_GPINTEN,
|
||||
MCP23008_REG_DEFVAL,
|
||||
MCP23008_REG_INTCON,
|
||||
MCP23008_REG_IOCON,
|
||||
MCP23008_REG_GPPU,
|
||||
MCP23008_REG_INTF,
|
||||
MCP23008_REG_INTCAP,
|
||||
MCP23008_REG_GPIO,
|
||||
MCP23008_REG_OLAT,
|
||||
|
||||
MCP23008_REG_MAX,
|
||||
};
|
||||
|
||||
enum mcp23008_gpio_e {
|
||||
MCP23008_P0 = 0,
|
||||
MCP23008_P1,
|
||||
MCP23008_P2,
|
||||
MCP23008_P3,
|
||||
MCP23008_P4,
|
||||
MCP23008_P5,
|
||||
MCP23008_P6,
|
||||
MCP23008_P7,
|
||||
|
||||
MCP23008_PIN_ALL,
|
||||
};
|
||||
|
||||
struct mcp23008_reg_name_t {
|
||||
uint8_t iodir;
|
||||
uint8_t gpio;
|
||||
};
|
||||
|
||||
struct mcp23008_set_para_t {
|
||||
enum mcp23008_module_e chip_module;
|
||||
enum mcp23008_reg_name_e reg_addr;
|
||||
uint8_t val;
|
||||
};
|
||||
|
||||
static struct mcp23008_reg_name_t mcp23008_reg_name_g[MCP23008_MODULE_MAX] = {0};
|
||||
|
||||
static uint8_t module_addr_g[MCP23008_MODULE_MAX] = {
|
||||
0x46, // MCP23008_MODULE_U503
|
||||
0x4C, // MCP23008_MODULE_U505
|
||||
};
|
||||
|
||||
|
||||
|
||||
int chip_MCP23008_set(enum mcp23008_module_e i2c_module, enum mcp23008_reg_name_e reg_address, enum mcp23008_gpio_e wt_bit, uint8_t value);
|
||||
uint8_t chip_MCP23008_rd_reg_stat(enum mcp23008_module_e i2c_module, enum mcp23008_reg_name_e reg_address);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
-149
@@ -1,149 +0,0 @@
|
||||
#include "hardware/MCP23008.h"
|
||||
|
||||
static uint8_t __mcp23008_reg_value_get(struct mcp23008_set_para_t *mcp23008_ctrl_para)
|
||||
{
|
||||
struct mcp23008_set_para_t *para = mcp23008_ctrl_para;
|
||||
struct mcp23008_reg_name_t *p;
|
||||
uint8_t ret;
|
||||
|
||||
p = mcp23008_reg_name_g + para->chip_module;
|
||||
|
||||
switch(para->reg_addr) {
|
||||
case MCP23008_REG_GPIO:
|
||||
ret = p->gpio;
|
||||
break;
|
||||
|
||||
case MCP23008_REG_IODIR:
|
||||
ret = p->iodir;
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void __mcp23008_reg_value_set(struct mcp23008_set_para_t *mcp23008_ctrl_para)
|
||||
{
|
||||
struct mcp23008_set_para_t *para = mcp23008_ctrl_para;
|
||||
struct mcp23008_reg_name_t *p;
|
||||
|
||||
p = mcp23008_reg_name_g + para->chip_module;
|
||||
|
||||
switch(para->reg_addr) {
|
||||
case MCP23008_REG_GPIO:
|
||||
p->gpio = para->val;
|
||||
break;
|
||||
|
||||
case MCP23008_REG_IODIR:
|
||||
p->iodir = para->val;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static int __chip_MCP23008_i2c_write(struct mcp23008_set_para_t *mcp23008_ctrl_para)
|
||||
{
|
||||
struct mcp23008_set_para_t *para = mcp23008_ctrl_para;
|
||||
struct i2c_para_t i2c_send;
|
||||
struct i2c_para_t *send = &i2c_send;
|
||||
|
||||
send->i2c_txlen = 2;
|
||||
send->i2c_rxlen = 0;
|
||||
send->i2c_addr = module_addr_g[para->chip_module] | MCP23008_WT_BIT;
|
||||
memcpy(send->i2c_tx, ¶->reg_addr, 1);
|
||||
memcpy(&send->i2c_tx[1], ¶->val, 1);
|
||||
|
||||
return i2c0_write(send);
|
||||
}
|
||||
|
||||
static uint8_t __chip_MCP23008_i2c_read(struct mcp23008_set_para_t *mcp23008_ctrl_para)
|
||||
{
|
||||
struct mcp23008_set_para_t *para = mcp23008_ctrl_para;
|
||||
struct i2c_para_t i2c_read;
|
||||
struct i2c_para_t *read = &i2c_read;
|
||||
|
||||
read->i2c_txlen = 1;
|
||||
read->i2c_rxlen = 1;
|
||||
read->i2c_addr = module_addr_g[para->chip_module] | MCP23008_RD_BIT;
|
||||
memcpy(read->i2c_tx, ¶->reg_addr, 1);
|
||||
|
||||
if (i2c0_write(read) == 0) {
|
||||
para->val = read->i2c_rx[0];
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int chip_MCP23008_set(enum mcp23008_module_e i2c_module, enum mcp23008_reg_name_e reg_address, enum mcp23008_gpio_e wt_bit, uint8_t value)
|
||||
{
|
||||
struct mcp23008_set_para_t mcp23008_ctrl_para;
|
||||
struct mcp23008_set_para_t *para = &mcp23008_ctrl_para;
|
||||
enum mcp23008_module_e modul = i2c_module;
|
||||
enum mcp23008_reg_name_e reg = reg_address; // for current version, it selects IODIR or GPIO
|
||||
enum mcp23008_gpio_e wt_b = wt_bit; //
|
||||
uint8_t v = value;
|
||||
uint8_t set_val = 0;
|
||||
|
||||
if (modul > MCP23008_MODULE_MAX)
|
||||
return -1;
|
||||
|
||||
if (reg >= MCP23008_REG_MAX)
|
||||
return -2;
|
||||
|
||||
if (wt_b > MCP23008_PIN_ALL)
|
||||
return -3;
|
||||
|
||||
if (wt_b < MCP23008_PIN_ALL && v > 1)
|
||||
return -4;
|
||||
|
||||
para->chip_module = modul;
|
||||
para->reg_addr = reg;
|
||||
para->val = v;
|
||||
|
||||
if (wt_b < MCP23008_PIN_ALL) {
|
||||
set_val = __mcp23008_reg_value_get(para);
|
||||
set_val &= ~(1 << wt_b);
|
||||
set_val |= v << wt_b;
|
||||
para->val = set_val;
|
||||
}
|
||||
|
||||
if (__chip_MCP23008_i2c_write(para) == 0) {
|
||||
__mcp23008_reg_value_set(para);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
uint8_t chip_MCP23008_rd_reg_stat(enum mcp23008_module_e i2c_module, enum mcp23008_reg_name_e reg_address)
|
||||
{
|
||||
struct mcp23008_set_para_t mcp23008_ctrl_para;
|
||||
struct mcp23008_set_para_t *para = &mcp23008_ctrl_para;
|
||||
enum mcp23008_module_e modul = i2c_module;
|
||||
enum mcp23008_reg_name_e reg = reg_address;
|
||||
|
||||
if (modul >= MCP23008_MODULE_MAX)
|
||||
return 0;
|
||||
|
||||
if (reg >= MCP23008_REG_MAX)
|
||||
return 0;
|
||||
|
||||
para->chip_module = modul;
|
||||
para->reg_addr = reg;
|
||||
|
||||
__chip_MCP23008_i2c_read(para);
|
||||
|
||||
return para->val;
|
||||
}
|
||||
-271
@@ -1,271 +0,0 @@
|
||||
/* .h */
|
||||
|
||||
/*
|
||||
* APA-102-2020-256-8A-20190612: Series data structure
|
||||
* +-------------------+------------------------- ... -+-----------------+
|
||||
* | start_frame(4B) | led_frame(4B) *LED_TANDEM_N | end_frame(4B) |
|
||||
* +-------------------+------------------------- ... -+-----------------+
|
||||
* / \
|
||||
* / led_frame(4B) \
|
||||
* / \
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | 111 | bright | blue | green | red |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*/
|
||||
|
||||
#ifdef DEF_LED_TANDEN_N
|
||||
#define LED_TANDEM_N DEF_LED_TANDEN_N
|
||||
#else
|
||||
#define LED_TANDEM_N 12
|
||||
#endif
|
||||
|
||||
enum led_series_nb_e {
|
||||
LED_NB_1 = 0,
|
||||
LED_NB_2,
|
||||
LED_NB_3,
|
||||
LED_NB_4,
|
||||
LED_NB_5,
|
||||
LED_NB_6,
|
||||
LED_NB_7,
|
||||
LED_NB_8,
|
||||
LED_NB_9,
|
||||
LED_NB_10,
|
||||
LED_NB_11,
|
||||
LED_NB_12,
|
||||
|
||||
LED_NB_MAX = LED_TANDEM_N,
|
||||
};
|
||||
|
||||
enum led_bright_e {
|
||||
LED_BR_LV0 = 0x00,
|
||||
LED_BR_LV1 = 0x01,
|
||||
LED_BR_LV8 = 0x08,
|
||||
|
||||
LED_BR_MAX = 0x1F,
|
||||
};
|
||||
|
||||
enum led_color_e {
|
||||
LED_CLR_BLACK = 0,
|
||||
LED_CLR_WHITE,
|
||||
LED_CLR_RED,
|
||||
LED_CLR_ORANGE,
|
||||
LED_CLR_YELLOW,
|
||||
LED_CLR_GREEN,
|
||||
LED_CLR_CYAN,
|
||||
LED_CLR_BLUE,
|
||||
LED_CLR_PURPLE,
|
||||
LED_CLR_MAGENTA,
|
||||
LED_CLR_YELLOWGREEN,
|
||||
LED_CLR_EMERALD,
|
||||
|
||||
LED_CLR_MAX,
|
||||
};
|
||||
|
||||
struct led_color_t {
|
||||
uint8_t b;
|
||||
uint8_t g;
|
||||
uint8_t r;
|
||||
};
|
||||
|
||||
struct led_frame_t {
|
||||
uint8_t bright: 5,
|
||||
rsvd: 3;
|
||||
struct led_color_t color;
|
||||
};
|
||||
|
||||
int led_color_set(enum led_series_nb_e led_nb, enum led_bright_e bright, enum led_color_e color);
|
||||
int led_color_code_set(enum led_series_nb_e led_nb, enum led_bright_e bright, struct led_color_t *color);
|
||||
int led_rainbow(enum led_bright_e bright);
|
||||
|
||||
|
||||
|
||||
|
||||
/* .c */
|
||||
#define LED_FRME_FILL_RSVD(_f) (_f)->rsvd = 0x07 // 0x11100000 || bright
|
||||
#define LED_SERIES_D_START 0x00000000
|
||||
#define LED_SERIES_D_END 0xFFFFFFFF
|
||||
|
||||
struct led_series_data_t {
|
||||
uint32_t f_start;
|
||||
struct led_frame_t f_led[LED_TANDEM_N];
|
||||
uint32_t f_end;
|
||||
};
|
||||
|
||||
static struct led_series_data_t led_series_data_g = {0};
|
||||
|
||||
const struct led_color_t led_color_list_g[LED_CLR_MAX] = {
|
||||
// {blue, green, red}
|
||||
{0x00, 0x00, 0x00}, // LED_CLR_BLACK
|
||||
{0xFF, 0xFF, 0xCA}, // LED_CLR_WHITE
|
||||
{0x00, 0x00, 0xFF}, // LED_CLR_RED
|
||||
{0x09, 0x58, 0xFF}, // LED_CLR_ORANGE
|
||||
{0x00, 0xE1, 0xE1}, // LED_CLR_YELLOW
|
||||
{0x00, 0xFA, 0x00}, // LED_CLR_GREEN
|
||||
{0x40, 0x40, 0x00}, // LED_CLR_CYAN
|
||||
{0xAA, 0x00, 0x00}, // LED_CLR_BLUE
|
||||
{0x6F, 0x00, 0x3A}, // LED_CLR_PURPLE
|
||||
{0xFF, 0x00, 0xFF}, // LED_CLR_MAGENTA
|
||||
{0x00, 0xA6, 0x64}, // LED_CLR_YELLOWGREEN
|
||||
{0x78, 0xC8, 0x50}, // LED_CLR_EMERALD
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
struct led_series_data_t *sd = led_s_d;
|
||||
struct led_frame_t *f = led_f;
|
||||
enum led_series_nb_e nb = led_nb;
|
||||
|
||||
memcpy(&sd->f_led[nb], f, sizeof(struct led_frame_t));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __led_multiple_set(struct led_series_data_t *led_s_d, struct led_frame_t *led_f)
|
||||
{
|
||||
struct led_series_data_t *sd = led_s_d;
|
||||
struct led_frame_t *f = led_f;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* use __led_single_set() to finish all led;
|
||||
*/
|
||||
for (i = LED_NB_1; i < LED_NB_MAX; i++) {
|
||||
__led_single_set(sd, f, (enum led_series_nb_e)i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __led_complete(struct led_series_data_t *led_s_d)
|
||||
{
|
||||
struct led_series_data_t *sd = led_s_d;
|
||||
struct led_frame_t *f = sd->f_led;
|
||||
int i;
|
||||
|
||||
for (i = LED_NB_1; i < LED_NB_MAX; i++) {
|
||||
LED_FRME_FILL_RSVD(f);
|
||||
f++;
|
||||
}
|
||||
|
||||
sd->f_start = LED_SERIES_D_START;
|
||||
sd->f_end = LED_SERIES_D_END;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __led_color_set(enum led_series_nb_e led_nb, struct led_frame_t *led_f)
|
||||
{
|
||||
enum led_series_nb_e nb = led_nb;
|
||||
struct led_frame_t *f = led_f;
|
||||
struct led_series_data_t *sd = &led_series_data_g;
|
||||
|
||||
if (f == NULL)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* nb - < LED_NB_MAX: fill one led_frame
|
||||
* == LED_NB_MAX: fill multiple led_frame
|
||||
*
|
||||
* complete: then, fill (start_frame, end_frame and the rsvd of every led_frame)
|
||||
*
|
||||
* finally, write cmd to hw by spi
|
||||
*/
|
||||
if (nb < LED_NB_MAX) {
|
||||
__led_single_set(sd, f, nb);
|
||||
} else if (nb == LED_NB_MAX) {
|
||||
__led_multiple_set(sd, f);
|
||||
} else {
|
||||
return -2;
|
||||
}
|
||||
|
||||
__led_complete(sd);
|
||||
|
||||
#define WRITE_TO_HW(_d, _l) spi0_write(NULL, (void *)(_d), (_l))
|
||||
WRITE_TO_HW(sd, sizeof(struct led_series_data_t));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int led_color_set(enum led_series_nb_e led_nb, enum led_bright_e bright, enum led_color_e color)
|
||||
{
|
||||
enum led_series_nb_e nb = led_nb;
|
||||
enum led_bright_e b = bright;
|
||||
enum led_color_e c = color;
|
||||
struct led_frame_t led_f;
|
||||
|
||||
if (nb > LED_NB_MAX)
|
||||
return -1;
|
||||
|
||||
if (c >= LED_CLR_MAX)
|
||||
return -2;
|
||||
|
||||
if (b > LED_BR_MAX)
|
||||
return -3;
|
||||
|
||||
led_f.bright = b;
|
||||
led_f.color = led_color_list_g[c];
|
||||
__led_color_set(nb, &led_f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int led_color_code_set(enum led_series_nb_e led_nb, enum led_bright_e bright, struct led_color_t *color)
|
||||
{
|
||||
enum led_series_nb_e nb = led_nb;
|
||||
enum led_bright_e b = bright;
|
||||
struct led_color_t *c = color;
|
||||
struct led_frame_t led_f;
|
||||
|
||||
// valid the input values
|
||||
if (nb > LED_NB_MAX)
|
||||
return -1;
|
||||
|
||||
if (b > LED_BR_MAX)
|
||||
return -2;
|
||||
|
||||
led_f.bright = b;
|
||||
memcpy(&led_f.color, c, sizeof(struct led_color_t));
|
||||
|
||||
__led_color_set(nb, &led_f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int led_rainbow(enum led_bright_e bright)
|
||||
{
|
||||
enum led_bright_e b = bright;
|
||||
int i;
|
||||
|
||||
if (b > LED_BR_MAX)
|
||||
return -1;
|
||||
|
||||
for(i=0; i<LED_NB_MAX; i++) {
|
||||
led_color_set((enum led_series_nb_e)i, b, (enum led_color_e)i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* example -
|
||||
* customize color:
|
||||
* struct led_color_t led_c;
|
||||
* uint8_t bri;
|
||||
* // { ins, ins, num, r, g, b, bri};
|
||||
* uint8_t ins[20] = {0x30, 0x00, LED_NB_4, 0xFF, 0x00, 0x44, 0x3};
|
||||
* led_c.r = ins[3];
|
||||
* led_c.g = ins[4];
|
||||
* led_c.b = ins[5];
|
||||
* bri = ins[6];
|
||||
* led_color_code_set(LED_NB_4, bri, &led_c);
|
||||
*
|
||||
* single led:
|
||||
* led_color_set(LED_NB_1, LED_BR_LV1, LED_CLR_WHITE);
|
||||
*
|
||||
* multiple led:
|
||||
* led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_BLUE);
|
||||
*
|
||||
* rainbow led:
|
||||
* led_rainbow(LED_BR_LV1);
|
||||
*/
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*=============================================================================
|
||||
= EliteCorrection.h =
|
||||
=============================================================================*/
|
||||
#ifndef EliteCorrection
|
||||
#define EliteCorrection
|
||||
|
||||
#define BOARD_E7A4
|
||||
|
||||
struct formula_ctx_t
|
||||
{
|
||||
long long coeff;
|
||||
long long offset;
|
||||
};
|
||||
|
||||
struct correction_ctx_t
|
||||
{
|
||||
struct formula_ctx_t Usercode2Aout[4];
|
||||
};
|
||||
|
||||
#ifdef BOARD_EE59 // Elite trigger
|
||||
struct correction_ctx_t Correction = {
|
||||
|
||||
.Usercode2Aout[0].coeff = 9544555,
|
||||
.Usercode2Aout[0].offset = 624861853,
|
||||
|
||||
.Usercode2Aout[1].coeff = 9544555,
|
||||
.Usercode2Aout[1].offset = 624861853,
|
||||
|
||||
.Usercode2Aout[2].coeff = 9544555,
|
||||
.Usercode2Aout[2].offset = 624861853,
|
||||
|
||||
.Usercode2Aout[3].coeff = 9544555,
|
||||
.Usercode2Aout[3].offset = 624861853,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_E7A4 // Elite trigger
|
||||
struct correction_ctx_t Correction = {
|
||||
|
||||
.Usercode2Aout[0].coeff = 9603806,
|
||||
.Usercode2Aout[0].offset = 284189190,
|
||||
|
||||
.Usercode2Aout[1].coeff = 9716008,
|
||||
.Usercode2Aout[1].offset = 231112610,
|
||||
|
||||
.Usercode2Aout[2].coeff = 9617383,
|
||||
.Usercode2Aout[2].offset = 82131390,
|
||||
|
||||
.Usercode2Aout[3].coeff = 9688579,
|
||||
.Usercode2Aout[3].offset = 469137665,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_EEA9 // Elite trigger
|
||||
struct correction_ctx_t Correction = {
|
||||
|
||||
.Usercode2Aout[0].coeff = 9647437,
|
||||
.Usercode2Aout[0].offset = 137525701,
|
||||
|
||||
.Usercode2Aout[1].coeff = 9675906,
|
||||
.Usercode2Aout[1].offset = 490863999,
|
||||
|
||||
.Usercode2Aout[2].coeff = 9668886,
|
||||
.Usercode2Aout[2].offset = 94793912,
|
||||
|
||||
.Usercode2Aout[3].coeff = 9717771,
|
||||
.Usercode2Aout[3].offset = 94763422,
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+5
-11
@@ -1,15 +1,9 @@
|
||||
|
||||
#ifndef VERSION_DATE
|
||||
#define VERSION_DATE
|
||||
|
||||
#define VERSION_DATE_YEAR 22
|
||||
#define VERSION_DATE_MONTH 6
|
||||
#define VERSION_DATE_DAY 9
|
||||
#define VERSION_DATE_HOUR 10
|
||||
#define VERSION_DATE_MINUTE 32
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
#define VERSION_HASH 8808490caa465cc94d14896de28763a5e5c4672b
|
||||
#define VERSION_GIT_BRANCH Elite_OBJ_0.2mv
|
||||
#define VERSION_DATE_YEAR 24
|
||||
#define VERSION_DATE_MONTH 1
|
||||
#define VERSION_DATE_DAY 8
|
||||
#define VERSION_DATE_HOUR 17
|
||||
#define VERSION_DATE_MINUTE 41
|
||||
#endif
|
||||
|
||||
-975
@@ -1,975 +0,0 @@
|
||||
/*
|
||||
* Real instruction(RIS)
|
||||
* 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
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | 0011 |Mem id| Payload len | Payload ...
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* ... ... |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* Bytestream:
|
||||
* 34 0C 01 61 A8 75 30 03 E8 12 43 21 03 E8
|
||||
* 34 03 E1 01 03
|
||||
*
|
||||
*
|
||||
* Virtual instruction(VIS)
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | 1100 |Mem id| operation |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* Bytestream:
|
||||
* C4 C0
|
||||
* C4 60
|
||||
*
|
||||
*
|
||||
* Control instruction(CIS)
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | 0111 |Mem id| operation |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* Bytestream:
|
||||
* 74 40
|
||||
* 74 10
|
||||
*/
|
||||
|
||||
/*
|
||||
* RIS Payload
|
||||
* +----------------------------------+-------------------------------+
|
||||
* | mode(1B) | ... ... |
|
||||
* +----------------------------------+-------------------------------+
|
||||
* | CURVE_IV = 0x01 | ... ... |
|
||||
* | CURVE_IV_CY = 0x02 | ... ... |
|
||||
* | CURVE_VO = 0x03 | ... ... |
|
||||
* | CURVE_RT = 0x04 | ... ... |
|
||||
* | CURVE_VT = 0x05 | ... ... |
|
||||
* | CURVE_IT = 0x06 | ... ... |
|
||||
* | CURVE_CC = 0x07 | ... ... |
|
||||
* | CURVE_OCP = 0x08 | ... ... |
|
||||
* | CURVE_CV = 0x09 | ... ... |
|
||||
* | CURVE_LSV = 0x0A | ... ... |
|
||||
* | CURVE_CA = 0x0B | ... ... |
|
||||
* | CURVE_PULSE = 0x0C | ... ... |
|
||||
* | CURVE_UNI_PULSE = 0x0D | ... ... |
|
||||
* | CURVE_DPV = 0x0E | ... ... |
|
||||
* | CURVE_DPV_SMPRATE = 0x0F | ... ... |
|
||||
* | CURVE_DPV_ADVANCE = 0x10 | ... ... |
|
||||
* | CURVE_DPV_ADVANCE_SMPRATE = 0x11 | ... ... |
|
||||
* | CURVE_CALI_ADC = 0xF1 | ... ... |
|
||||
* | MODE_DEV_TOOL = 0xFF | ... ... |
|
||||
* | SET_SAMPLE_RATE = 0xE0 | ... ... |
|
||||
* | SET_ADC_DAC_GAIN = 0xE1 | ... ... |
|
||||
* | SET_PARA = 0xE2 | ... ... |
|
||||
* +----------------------------------+----------------------------------
|
||||
*/
|
||||
|
||||
static uint32_t OldStep2NewStepTime(uint32_t StepTime){
|
||||
uint8_t StepTimeLevel = 0;
|
||||
StepTimeLevel = StepTime / 0x12;
|
||||
|
||||
switch (StepTimeLevel) {
|
||||
case 0: { //0.5 sec
|
||||
return STEPTIME_HALF_SEC;
|
||||
}
|
||||
case 1: { //1 sec
|
||||
return STEPTIME_ONE_SEC;
|
||||
}
|
||||
case 2: { //2 sec
|
||||
return STEPTIME_TWO_SEC;
|
||||
}
|
||||
default: { //1 sec
|
||||
return STEPTIME_ONE_SEC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define STEP_TO_VSETRATE(step) step2VsetRate(step)
|
||||
|
||||
static void step2VsetRate(uint32_t step){
|
||||
/*step = 100 mv, index = 0, n = 2
|
||||
10 mv, index = 1, n = 10
|
||||
1 mv, index = 2, n = 100
|
||||
0.1 mv, index = 3, n = 1000
|
||||
0.01mv, index = 4, n = 10000 */
|
||||
|
||||
if(step >= 10000){
|
||||
instru.VsetRateIndex = 0;
|
||||
}else if (step >= 1000){
|
||||
instru.VsetRateIndex = 1;
|
||||
}else if (step >= 100){
|
||||
instru.VsetRateIndex = 2;
|
||||
}else if (step >= 10){
|
||||
instru.VsetRateIndex = 3;
|
||||
}else if (step >= 1){
|
||||
instru.VsetRateIndex = 4;
|
||||
}
|
||||
}
|
||||
|
||||
#include "headstage/mode_dev_tool.h"
|
||||
static void ins_decode_ris(uint8_t *ins_buf)
|
||||
{
|
||||
uint8_t *p = ins_buf;
|
||||
uint8_t mode = p[2];
|
||||
|
||||
switch (mode) {
|
||||
case CURVE_IV: {
|
||||
instru.eliteFxn = CURVE_IV;
|
||||
instru.Ve1 = ((uint16_t)(p[3]) << 8) | (uint16_t)(p[4]);
|
||||
instru.Ve2 = ((uint16_t)(p[5]) << 8) | (uint16_t)(p[6]);
|
||||
instru.Vinit = (int32_t)instru.Ve1;
|
||||
instru.Vmax = (int32_t)VMAX(instru.Ve1,instru.Ve2);
|
||||
instru.Vmin = (int32_t)VMIN(instru.Ve1,instru.Ve2);
|
||||
instru.directionInit = VDIRECTION(instru.Ve1,instru.Ve2);
|
||||
instru.steptime = (uint32_t)(p[9]);
|
||||
instru.steptime = OldStep2NewStepTime(instru.steptime); //5000;10000;20000;
|
||||
instru.step = ((uint32_t)(p[7]) << 8) | (uint32_t)(p[8]);//1~1000 = 0.1mv ~ 100mv
|
||||
instru.step = instru.step * 100000 / instru.steptime;
|
||||
STEP_TO_VSETRATE(instru.step);
|
||||
instru.VsetRate = VsetRateTable[instru.VsetRateIndex];//N
|
||||
instru.cycleNumber = 1;
|
||||
instru.hign_z_en = ~(p[11] & 0x0F);
|
||||
instru.notifyRate = ((uint32_t)p[12] << 8) | (uint32_t)p[13];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
|
||||
if ((instru.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE)
|
||||
&& (instru.Ve2 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve2 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE)) {
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
} else {
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
}
|
||||
|
||||
ModeLED(WORKING);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_IV_CY: {
|
||||
instru.eliteFxn = CURVE_IV_CY;
|
||||
instru.Ve1 = ((uint16_t)(p[3]) << 8) | (uint16_t)(p[4]);
|
||||
instru.Ve2 = ((uint16_t)(p[5]) << 8) | (uint16_t)(p[6]);
|
||||
instru.Vinit = (int32_t)instru.Ve1;
|
||||
instru.Vmax = (int32_t)VMAX(instru.Ve1,instru.Ve2);
|
||||
instru.Vmin = (int32_t)VMIN(instru.Ve1,instru.Ve2);
|
||||
instru.directionInit = VDIRECTION(instru.Ve1,instru.Ve2);
|
||||
instru.steptime = (uint32_t)(p[9]);
|
||||
instru.steptime = OldStep2NewStepTime(instru.steptime); //5000;10000;20000;
|
||||
instru.step = ((uint32_t)(p[7]) << 8) | (uint32_t)(p[8]);//1~1000 = 0.1mv ~ 100mv
|
||||
instru.step = instru.step * 100000 / instru.steptime;
|
||||
STEP_TO_VSETRATE(instru.step);
|
||||
instru.VsetRate = VsetRateTable[instru.VsetRateIndex];//N
|
||||
instru.cycleNumber = ((uint16_t)(p[10]) << 8) | (uint16_t)(p[11]);
|
||||
instru.hign_z_en = ~(p[13] & 0x0F);
|
||||
instru.notifyRate = ((uint32_t)p[14] << 8) | (uint32_t)p[15];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
|
||||
if ((instru.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE)
|
||||
&& (instru.Ve2 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve2 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE)) {
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
} else {
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
}
|
||||
|
||||
ModeLED(WORKING);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_VO: {
|
||||
instru.eliteFxn = CURVE_VO;
|
||||
instru.Ve1 = ((uint16_t)p[3] << 8) | (uint16_t)p[4];
|
||||
instru.Vinit = (int32_t)instru.Ve1;
|
||||
instru.hign_z_en = ~(p[6] & 0x0F);
|
||||
|
||||
if (instru.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE) {
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
} else {
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
}
|
||||
|
||||
instru.notifyRate = ((uint32_t)p[7] << 8) | (uint32_t)p[8];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
|
||||
ModeLED(WORKING);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_RT: {
|
||||
instru.eliteFxn = CURVE_RT;
|
||||
instru.notifyRate = ((uint32_t)p[7] << 8) | (uint32_t)p[8];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.VsetRate = 2;
|
||||
instru.Ve1 = ((uint16_t)p[3] << 8) | (uint16_t)p[4];
|
||||
instru.Vinit = (int32_t)instru.Ve1;
|
||||
instru.hign_z_en = ~(p[6] & 0x0F);
|
||||
|
||||
if (instru.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE) {
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
} else {
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
}
|
||||
|
||||
ModeLED(WORKING);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_VT: {
|
||||
instru.eliteFxn = CURVE_VT;
|
||||
instru.notifyRate = ((uint32_t)p[5] << 8) | (uint32_t)p[6];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.hign_z_en = ~(p[4] & 0x0F);
|
||||
|
||||
ModeLED(WORKING);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_IT: {
|
||||
instru.eliteFxn = CURVE_IT;
|
||||
instru.notifyRate = ((uint32_t)p[7] << 8) | (uint32_t)p[8];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.Ve1 = ((uint16_t)p[3] << 8) | (uint16_t)p[4];
|
||||
instru.Vinit = (int32_t)instru.Ve1;
|
||||
instru.hign_z_en = ~(p[6] & 0x0F);
|
||||
|
||||
if (instru.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && instru.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE) {
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
} else {
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
}
|
||||
|
||||
ModeLED(WORKING);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_CC: {
|
||||
instru.eliteFxn = CURVE_CC;
|
||||
instru.notifyRate = ((uint32_t)p[14] << 8) | (uint32_t)p[15];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.charge = p[3]; //0:discharge 1:charge
|
||||
instru.constantCurrent = (uint32_t)(p[4]) << 24 | (uint32_t)(p[5]) << 16 | (uint32_t)(p[6]) << 8 | (uint32_t)(p[7]);
|
||||
instru.Vmax = (uint32_t)(p[8]) << 8 | (uint32_t)(p[9]);
|
||||
instru.Vmin = (uint32_t)(p[10]) << 8 | (uint32_t)(p[11]);
|
||||
instru.hign_z_en = ~(p[13] & 0x0F);
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
|
||||
ModeLED(WORKING);
|
||||
/*******************************************************
|
||||
controller instruction
|
||||
p[3] -> Charge, 0:discharge 1:charge
|
||||
p[6:9] -> ConstantCurrent, 0 ~ 15000uA : 0 ~ 1500000
|
||||
********************************************************/
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_CV: {
|
||||
if (p[3] == PARA_1) {
|
||||
instru.Vinit = ((int32_t)(p[4]) << 8) | (int32_t)(p[5]);
|
||||
instru.Ve1 = ((uint16_t)(p[6]) << 8) | (uint16_t)(p[7]);
|
||||
instru.Ve2 = ((uint16_t)(p[8]) << 8) | (uint16_t)(p[9]);
|
||||
instru.Vmax = (int32_t)VMAX(instru.Ve1,instru.Ve2);
|
||||
instru.Vmin = (int32_t)VMIN(instru.Ve1,instru.Ve2);
|
||||
if (instru.Vinit > instru.Ve1 || instru.Vinit == instru.Vmax) {
|
||||
instru.directionInit = 0;//0:reverse 1:forward
|
||||
} else if (instru.Vinit <= instru.Ve1 || instru.Vinit == instru.Vmin) {
|
||||
instru.directionInit = 1;
|
||||
}
|
||||
|
||||
//controller UI 0.01~1000mv send to Elite 1~100000
|
||||
instru.step = (uint32_t)(p[10]) << 24 | (uint32_t)(p[11]) << 16 | (uint32_t)(p[12]) << 8 | (uint32_t)(p[13]);
|
||||
STEP_TO_VSETRATE(instru.step);
|
||||
instru.VsetRate = VsetRateTable[instru.VsetRateIndex];//N
|
||||
|
||||
instru.Currentmax = (int32_t)(p[14]) << 24 | (int32_t)(p[15]) << 16 | (int32_t)(p[16]) << 8 | (int32_t)(p[17]);
|
||||
|
||||
} else if (p[3] == PARA_2) {
|
||||
instru.eliteFxn = CURVE_CV;
|
||||
instru.cycleNumber = ((uint16_t)(p[4]) << 8) | (uint16_t)(p[5]);
|
||||
instru.notifyRate = (uint32_t)(p[8]) << 8 | (uint32_t)(p[9]);
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.hign_z_en = ~(p[7] & 0x0F);
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
ModeLED(WORKING);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_LSV: {
|
||||
if (p[3] == PARA_1) {
|
||||
instru.Ve1 = ((uint16_t)(p[4]) << 8) | (uint16_t)(p[5]);
|
||||
instru.Ve2 = ((uint16_t)(p[6]) << 8) | (uint16_t)(p[7]);
|
||||
instru.Vinit = (int32_t)instru.Ve1;
|
||||
instru.Vmax = (int32_t)VMAX(instru.Ve1,instru.Ve2);
|
||||
instru.Vmin = (int32_t)VMIN(instru.Ve1,instru.Ve2);
|
||||
instru.directionInit = VDIRECTION(instru.Ve1,instru.Ve2);
|
||||
instru.Currentmax = (int32_t)(p[12]) << 24 | (int32_t)(p[13]) << 16 | (int32_t)(p[14]) << 8 | (int32_t)(p[15]);
|
||||
|
||||
//controller UI 0.01~1000mv send to Elite 1~100000
|
||||
instru.step = (uint32_t)(p[8]) << 24 | (uint32_t)(p[9]) << 16 | (uint32_t)(p[10]) << 8 | (uint32_t)(p[11]);
|
||||
STEP_TO_VSETRATE(instru.step);
|
||||
instru.VsetRate = VsetRateTable[instru.VsetRateIndex];//N
|
||||
instru.cycleNumber = 1;//p[16.17];
|
||||
|
||||
} else if (p[3] == PARA_2) {
|
||||
instru.eliteFxn = CURVE_LSV;
|
||||
instru.notifyRate = (uint32_t)(p[6]) << 8 | (uint32_t)(p[7]);
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.hign_z_en = ~(p[5] & 0x0F);
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
|
||||
ModeLED(WORKING);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_CA: {
|
||||
instru.eliteFxn = CURVE_CA;
|
||||
instru.Vinit = ((int32_t)(p[3]) << 8) | (int32_t)(p[4]);
|
||||
instru.notifyRate = (uint32_t)(p[7]) << 8 | (uint32_t)(p[8]);
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.VsetRate = VsetRateTable[0];
|
||||
instru.hign_z_en = ~(p[6] & 0x0F);
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_OCP: {
|
||||
instru.eliteFxn = CURVE_OCP;
|
||||
instru.notifyRate = ((uint32_t)p[5] << 8) | (uint32_t)p[6];
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
instru.hign_z_en = 0;
|
||||
|
||||
ModeLED(WORKING);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SET_SAMPLE_RATE: {
|
||||
instru.notifyRate = (uint32_t)(p[3]) << 8 | (uint32_t)(p[4]);
|
||||
instru.notifyRate = 10000 / instru.notifyRate * 10;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SET_ADC_DAC_GAIN: {
|
||||
switch (p[3]) {
|
||||
case RIS_ADC_IIN: {
|
||||
instru.IinADCGainLv = p[4];
|
||||
if (instru.IinADCGainLv != I_GAIN_AUTO) {
|
||||
instru.IinADCAutoGainEn = 0;
|
||||
} else {
|
||||
instru.IinADCAutoGainEn = 1;
|
||||
instru.IinADCGainLv = I_GAIN_100R;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RIS_ADC_VIN: {
|
||||
instru.VinADCGainLv = p[4];
|
||||
if (instru.VinADCGainLv != VIN_GAIN_AUTO) {
|
||||
instru.VinADCAutoGainEn = 0;
|
||||
} else {
|
||||
instru.VinADCAutoGainEn = 1;
|
||||
instru.VinADCGainLv = VIN_GAIN_1K;
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RIS_DAC_VOUT: {
|
||||
// instru.VoutGainLv = p[4];
|
||||
// if (instru.VoutGainLv == VOUT_GAIN_AUTO) {
|
||||
// instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
// }
|
||||
instru.VoutGainLv = p[4];
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
break;
|
||||
}
|
||||
case RIS_HIGH_Z: {
|
||||
switch (p[4]) {
|
||||
case 0x00:
|
||||
PIN15_setOutputValue(HIGH_Z, 0); // 0 => open high_z mode
|
||||
break;
|
||||
|
||||
case 0x01:
|
||||
PIN15_setOutputValue(HIGH_Z, 1); // 1 => close high_z mode
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_CALI_ADC: {
|
||||
switch (p[3]) {
|
||||
case RIS_ADC_IIN: { // 0x00
|
||||
instru.eliteFxn = CURVE_CALI_ADC;
|
||||
instru.AdcChannel = RIS_ADC_IIN;
|
||||
instru.notifyRate = 1000;
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
case RIS_ADC_VIN: { // 0x01
|
||||
instru.eliteFxn = CURVE_CALI_ADC;
|
||||
instru.AdcChannel = RIS_ADC_VIN;
|
||||
instru.notifyRate = 1000;
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
case RIS_DAC_VOUT: { // 0x02
|
||||
instru.eliteFxn = CURVE_CALI_ADC;
|
||||
instru.AdcChannel = RIS_DAC_VOUT;
|
||||
instru.notifyRate = 1000;
|
||||
instru.VoltConstant = ( ((uint16_t)(p[4])) << 8) | (uint16_t)(p[5]); // output voltage
|
||||
DAC_outputV(instru.VoltConstant); //UserCode -> DAC code -> DAC out
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_PULSE: {
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
instru.notifyRate = 100;
|
||||
if (p[3] == PARA_1) {
|
||||
instru.sti_t1 = (int32_t)(p[4]) << 24 | (int32_t)(p[5]) << 16 | (int32_t)(p[6]) << 8 | (int32_t)(p[7]);
|
||||
instru.sti_t2 = (int32_t)(p[8]) << 24 | (int32_t)(p[9]) << 16 | (int32_t)(p[10]) << 8 | (int32_t)(p[11]);
|
||||
instru.sti_t3 = (int32_t)(p[12]) << 24 | (int32_t)(p[13]) << 16 | (int32_t)(p[14]) << 8 | (int32_t)(p[15]);
|
||||
instru.sti_t4 = (int32_t)(p[16]) << 24 | (int32_t)(p[17]) << 16 | (int32_t)(p[18]) << 8 | (int32_t)(p[19]);
|
||||
} else if (p[3] == PARA_2) {
|
||||
instru.sti_t5 = (int32_t)(p[4]) << 24 | (int32_t)(p[5]) << 16 | (int32_t)(p[6]) << 8 | (int32_t)(p[7]);
|
||||
instru.sti_v1 = 25000; //8~11
|
||||
instru.sti_v2 = 50000; //12~15 //41406.43161.
|
||||
instru.sti_v3 = 25000; //16~19
|
||||
} else if (p[3] == PARA_3) {
|
||||
instru.sti_v4 = 25000; //4~7
|
||||
instru.sti_v5 = 25000; //8~11
|
||||
instru.sti_cy = (uint16_t)(p[12]); //12
|
||||
instru.sti_loop = (uint16_t)(p[13]); //13
|
||||
} else if (p[3] == PARA_4) {
|
||||
instru.sti_t6 = (int32_t)(p[4]) << 24 | (int32_t)(p[5]) << 16 | (int32_t)(p[6]) << 8 | (int32_t)(p[7]); //4~7
|
||||
instru.sti_t7 = (int32_t)(p[8]) << 24 | (int32_t)(p[9]) << 16 | (int32_t)(p[10]) << 8 | (int32_t)(p[11]); //8~11
|
||||
instru.sti_v6 = 25000; //12~15
|
||||
instru.sti_v7 = 25000; //16~19
|
||||
instru.sti_t1 = VALUE_ZERO_TO_ONE(instru.sti_t1);
|
||||
instru.sti_t2 = VALUE_ZERO_TO_ONE(instru.sti_t2);
|
||||
instru.sti_t3 = VALUE_ZERO_TO_ONE(instru.sti_t3);
|
||||
instru.sti_t4 = VALUE_ZERO_TO_ONE(instru.sti_t4);
|
||||
instru.sti_t5 = VALUE_ZERO_TO_ONE(instru.sti_t5);
|
||||
instru.sti_t6 = VALUE_ZERO_TO_ONE(instru.sti_t6);
|
||||
instru.sti_t7 = VALUE_ZERO_TO_ONE(instru.sti_t7);
|
||||
megaStiEnable = true;
|
||||
} else if (p[3] == PARA_17) {
|
||||
instru.eliteFxn = CURVE_PULSE;
|
||||
ModeLED(WORKING);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_UNI_PULSE: {
|
||||
if (p[3] == PARA_1) {
|
||||
uint8_t seg_index = p[12];
|
||||
instru.v_initial[seg_index] = (int32_t)p[4] << 8 | (int32_t)p[5];
|
||||
instru.v0 = instru.v_initial[0];
|
||||
instru.t_pulse[seg_index] = (uint32_t)p[6] << 24 | (uint32_t)p[7] << 16 | (uint32_t)p[8] << 8 | (uint32_t)p[9];
|
||||
instru.t_pulse_min[seg_index] = (uint32_t)p[10];
|
||||
instru.t_pulse_max[seg_index] = (uint32_t)p[11];
|
||||
instru.v_slope[seg_index] = 0;
|
||||
instru.v_step[seg_index] = 0;
|
||||
|
||||
} else if (p[3] == PARA_2) {
|
||||
uint8_t seg_index = p[12];
|
||||
instru.v_initial[seg_index] = (int32_t)p[4] << 8 | (int32_t)p[5];
|
||||
instru.t_pulse[seg_index] = (uint32_t)p[6] << 24 | (uint32_t)p[7] << 16 | (uint32_t)p[8] << 8 | (uint32_t)p[9];
|
||||
instru.t_pulse_min[seg_index] = (uint32_t)p[10];
|
||||
instru.t_pulse_max[seg_index] = (uint32_t)p[11];
|
||||
instru.v_slope[seg_index] = 0;
|
||||
instru.v_step[seg_index] = 0;
|
||||
|
||||
} else if (p[3] == PARA_3) {
|
||||
uint8_t seg_index = p[12];
|
||||
instru.v_initial[seg_index] = (int32_t)p[4] << 8 | (int32_t)p[5];
|
||||
instru.t_pulse[seg_index] = (uint32_t)p[6] << 24 | (uint32_t)p[7] << 16 | (uint32_t)p[8] << 8 | (uint32_t)p[9];
|
||||
instru.t_pulse_min[seg_index] = (uint32_t)p[10];
|
||||
instru.t_pulse_max[seg_index] = (uint32_t)p[11];
|
||||
instru.v_slope[seg_index] = 0;
|
||||
instru.v_step[seg_index] = 0;
|
||||
|
||||
} else if (p[3] == PARA_4) {
|
||||
uint8_t seg_index = p[12];
|
||||
instru.v_initial[seg_index] = (int32_t)p[4] << 8 | (int32_t)p[5];
|
||||
instru.t_pulse[seg_index] = (uint32_t)p[6] << 24 | (uint32_t)p[7] << 16 | (uint32_t)p[8] << 8 | (uint32_t)p[9];
|
||||
instru.t_pulse_min[seg_index] = (uint32_t)p[10];
|
||||
instru.t_pulse_max[seg_index] = (uint32_t)p[11];
|
||||
instru.v_slope[seg_index] = 0;
|
||||
instru.v_step[seg_index] = 0;
|
||||
|
||||
} else if (p[3] == PARA_FINAL) {
|
||||
instru.eliteFxn = CURVE_UNI_PULSE;
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
|
||||
ModeLED(WORKING);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_DPV: {
|
||||
|
||||
/*
|
||||
* DPV mode --auto
|
||||
* +----------+------------+-------------+-----------------+---------------+---------------+
|
||||
* | UI | E Initial | E Final | Pulse Amplitude | Pulse Width | Increment |
|
||||
* | json | DPV_e_init | DPV_e_final | DPV_amp | DPV_pul_width | DPV_increment |
|
||||
* +----------+------------+-------------+-----------------+---------------+---------------+
|
||||
* | UI | Step Time | Sample rate | (audio) | (audio) |
|
||||
* | json | DPV_step_time | DPV_notify_rate | DPV_mode | DPV_engineering_enable |
|
||||
* +----------+---------------+-----------------+----------+------------------------+
|
||||
* hide parameter
|
||||
* +----------+-------------------------------------+
|
||||
* | UI | Current Recording Period(Slots) |
|
||||
* | json | DPV_curr_rec_max | DPV_curr_rec_min |
|
||||
* +----------+------------------+------------------+
|
||||
*
|
||||
*/
|
||||
//--mode
|
||||
static uint8_t dpv_option;
|
||||
|
||||
//--Auto
|
||||
static int32_t dpv_e_init;
|
||||
static int32_t dpv_e_final;
|
||||
static int32_t dpv_amp;
|
||||
static uint32_t dpv_pul_width;
|
||||
static int32_t dpv_increment;
|
||||
static uint32_t dpv_step_time;
|
||||
static uint32_t dpv_notify_rate;
|
||||
static uint32_t dpv_curr_rec_percent_min[4];
|
||||
static uint32_t dpv_curr_rec_percent_max[4];
|
||||
|
||||
//--engineering
|
||||
static uint8_t dpv_engi_advanced_en;
|
||||
|
||||
if (p[3] == PARA_1) {
|
||||
dpv_option = p[4];
|
||||
dpv_engi_advanced_en = p[5];
|
||||
|
||||
} else if (p[3] == PARA_2) {
|
||||
dpv_e_init = (int32_t)p[4] << 8 | (int32_t)p[5];
|
||||
dpv_e_final = (int32_t)p[6] << 8 | (int32_t)p[7];
|
||||
dpv_amp = (int32_t)p[8] << 8 | (int32_t)p[9];
|
||||
dpv_pul_width = (uint32_t)p[10] << 24 | (uint32_t)p[11] << 16 | (uint32_t)p[12] << 8 | (uint32_t)p[13];
|
||||
dpv_increment = (int32_t)p[14] << 8 | (int32_t)p[15];
|
||||
|
||||
} else if (p[3] == PARA_3) {
|
||||
dpv_step_time = (uint32_t)p[4] << 24 | (uint32_t)p[5] << 16 | (uint32_t)p[6] << 8 | (uint32_t)p[7];
|
||||
dpv_notify_rate = (uint32_t)p[8] << 8 | (uint32_t)p[9];
|
||||
dpv_curr_rec_percent_min[0] = (uint32_t)p[10];
|
||||
dpv_curr_rec_percent_max[0] = (uint32_t)p[11];
|
||||
dpv_curr_rec_percent_min[1] = (uint32_t)p[10];
|
||||
dpv_curr_rec_percent_max[1] = (uint32_t)p[11];
|
||||
|
||||
} else if (p[3] == PARA_FINAL) {
|
||||
dpv_e_init = UC_TO_5NV(dpv_e_init);
|
||||
dpv_e_final = UC_TO_5NV(dpv_e_final);
|
||||
dpv_amp = UC_TO_5NV(dpv_amp);
|
||||
dpv_pul_width = dpv_pul_width * 10;
|
||||
dpv_increment = UC_TO_5NV(dpv_increment);
|
||||
dpv_increment = abs(dpv_increment);
|
||||
dpv_step_time = dpv_step_time * 10;
|
||||
dpv_notify_rate = 10000 / dpv_notify_rate * 10;
|
||||
|
||||
instru.v0 = dpv_e_init;
|
||||
instru.v_stop = dpv_e_final;
|
||||
instru.t_pulse[0] = dpv_step_time - dpv_pul_width;
|
||||
instru.t_pulse[1] = dpv_pul_width;
|
||||
instru.v_initial[0] = dpv_e_init;
|
||||
instru.v_initial[1] = dpv_e_init + dpv_amp;
|
||||
instru.v_step[0] = dpv_increment;
|
||||
instru.v_step[1] = dpv_increment;
|
||||
instru.notifyRate = dpv_notify_rate;
|
||||
instru.v_slope[0] = 0; // 1234 = slop 1.234, same as scanrate
|
||||
instru.v_slope[1] = 0; // 1234 = slop 1.234
|
||||
instru.t_pulse_min[0] = dpv_curr_rec_percent_min[0];
|
||||
instru.t_pulse_max[0] = dpv_curr_rec_percent_max[0];
|
||||
instru.t_pulse_min[1] = dpv_curr_rec_percent_min[1];
|
||||
instru.t_pulse_max[1] = dpv_curr_rec_percent_max[1];
|
||||
|
||||
if (instru.v0 > instru.v_stop) {
|
||||
instru.directionInit = 0;//0:reverse 1:forward
|
||||
instru.v_step[0] = (-1) * instru.v_step[0];
|
||||
instru.v_step[1] = (-1) * instru.v_step[1];
|
||||
} else if (instru.v0 < instru.v_stop) {
|
||||
instru.directionInit = 1;
|
||||
}
|
||||
|
||||
if (dpv_option == 0) {
|
||||
instru.eliteFxn = CURVE_DPV;
|
||||
} else if (dpv_option == 2) {
|
||||
instru.eliteFxn = CURVE_DPV_SMPRATE;
|
||||
}
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
ModeLED(WORKING);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_DPV_ADVANCE: {
|
||||
|
||||
/*
|
||||
* DPV mode --advanced
|
||||
* +----------+------------+---------+---------+-------------+-----------------+---------------+---------------+
|
||||
* | UI | E Initial | E 1 | E 2 | E Final | Pulse Amplitude | Pulse Width | Increment |
|
||||
* | json | DPV_e_init | DPV_e_1 | DPV_e_2 | DPV_e_final | DPV_amp | DPV_pul_width | DPV_increment |
|
||||
* +----------+------------+---------+---------+-------------+-----------------+---------------+---------------+
|
||||
* | UI | Step Time | Sample rate | Current Recording Period(Slots) |
|
||||
* | json | DPV_step_time | DPV_notify_rate | DPV_curr_rec_max | DPV_curr_rec_min |
|
||||
* +----------+---------------+-----------------+------------------+------------------+
|
||||
* | UI | (audio) | (audio) |
|
||||
* | json | DPV_mode | DPV_engineering_enable |
|
||||
* +----------+----------+------------------------+
|
||||
*
|
||||
*/
|
||||
//--mode
|
||||
static uint8_t dpv_option;
|
||||
|
||||
//--advanced
|
||||
static int32_t dpv_e_init;
|
||||
static int32_t dpv_e_final;
|
||||
static int32_t dpv_amp;
|
||||
static uint32_t dpv_pul_width;
|
||||
static int32_t dpv_increment;
|
||||
static uint32_t dpv_step_time;
|
||||
static uint32_t dpv_notify_rate;
|
||||
static uint32_t dpv_curr_rec_percent_min[4];
|
||||
static uint32_t dpv_curr_rec_percent_max[4];
|
||||
static int32_t dpv_e_1;
|
||||
static int32_t dpv_e_2;
|
||||
static uint8_t dpv_invert_option;
|
||||
static uint16_t dpv_cycle;
|
||||
|
||||
//--engineering
|
||||
static uint8_t dpv_engi_advanced_en;
|
||||
|
||||
if (p[3] == PARA_1) {
|
||||
dpv_option = p[4];
|
||||
dpv_engi_advanced_en = p[5];
|
||||
|
||||
} else if (p[3] == PARA_2) {
|
||||
dpv_e_init = (int32_t)p[4] << 8 | (int32_t)p[5];
|
||||
dpv_e_final = (int32_t)p[6] << 8 | (int32_t)p[7];
|
||||
dpv_amp = (int32_t)p[8] << 8 | (int32_t)p[9];
|
||||
dpv_pul_width = (uint32_t)p[10] << 24 | (uint32_t)p[11] << 16 | (uint32_t)p[12] << 8 | (uint32_t)p[13];
|
||||
dpv_increment = (int32_t)p[14] << 8 | (int32_t)p[15];
|
||||
|
||||
} else if (p[3] == PARA_3) {
|
||||
dpv_step_time = (uint32_t)p[4] << 24 | (uint32_t)p[5] << 16 | (uint32_t)p[6] << 8 | (uint32_t)p[7];
|
||||
dpv_notify_rate = (uint32_t)p[8] << 8 | (uint32_t)p[9];
|
||||
dpv_curr_rec_percent_min[0] = (uint32_t)p[10];
|
||||
dpv_curr_rec_percent_max[0] = (uint32_t)p[11];
|
||||
dpv_curr_rec_percent_min[1] = (uint32_t)p[10];
|
||||
dpv_curr_rec_percent_max[1] = (uint32_t)p[11];
|
||||
|
||||
} else if (p[3] == PARA_4) {
|
||||
dpv_e_1 = (int32_t)p[4] << 8 | (int32_t)p[5];
|
||||
dpv_e_2 = (int32_t)p[6] << 8 | (int32_t)p[7];
|
||||
dpv_invert_option = p[8];
|
||||
dpv_cycle = (uint16_t)p[9] << 8 | (uint16_t)p[10];
|
||||
|
||||
} else if (p[3] == PARA_FINAL) {
|
||||
dpv_e_init = UC_TO_5NV(dpv_e_init);
|
||||
dpv_e_final = UC_TO_5NV(dpv_e_final);
|
||||
dpv_amp = UC_TO_5NV(dpv_amp);
|
||||
dpv_pul_width = dpv_pul_width * 10;
|
||||
dpv_increment = UC_TO_5NV(dpv_increment);
|
||||
dpv_increment = abs(dpv_increment);
|
||||
dpv_step_time = dpv_step_time * 10;
|
||||
dpv_notify_rate = 10000 / dpv_notify_rate * 10;
|
||||
dpv_e_1 = UC_TO_5NV(dpv_e_1);
|
||||
dpv_e_2 = UC_TO_5NV(dpv_e_2);
|
||||
|
||||
instru.v0 = dpv_e_init;
|
||||
instru.v_stop = dpv_e_final;
|
||||
instru.t_pulse[0] = dpv_step_time - dpv_pul_width;
|
||||
instru.t_pulse[1] = dpv_pul_width;
|
||||
instru.v_initial[0] = dpv_e_init;
|
||||
instru.v_initial[1] = dpv_e_init + dpv_amp;
|
||||
instru.v_step[0] = abs(dpv_increment);
|
||||
instru.v_step[1] = abs(dpv_increment);
|
||||
instru.notifyRate = dpv_notify_rate;
|
||||
instru.v_slope[0] = 0; // 1234 = slop 1.234, same as scanrate
|
||||
instru.v_slope[1] = 0; // 1234 = slop 1.234
|
||||
instru.t_pulse_min[0] = dpv_curr_rec_percent_min[0];
|
||||
instru.t_pulse_max[0] = dpv_curr_rec_percent_max[0];
|
||||
instru.t_pulse_min[1] = dpv_curr_rec_percent_min[1];
|
||||
instru.t_pulse_max[1] = dpv_curr_rec_percent_max[1];
|
||||
instru.v_1 = dpv_e_1;
|
||||
instru.v_2 = dpv_e_2;
|
||||
instru.cycleNumber = dpv_cycle;
|
||||
if (dpv_invert_option == 1) {
|
||||
instru.v_invert_option = true;
|
||||
} else {
|
||||
instru.v_invert_option = false;
|
||||
}
|
||||
|
||||
|
||||
if (instru.v0 > dpv_e_1) {
|
||||
instru.directionInit = 0;//0:reverse 1:forward
|
||||
instru.v_step[0] = (-1) * instru.v_step[0];
|
||||
instru.v_step[1] = (-1) * instru.v_step[1];
|
||||
|
||||
} else if (instru.v0 < dpv_e_1) {
|
||||
instru.directionInit = 1;
|
||||
|
||||
}
|
||||
|
||||
if (dpv_e_1 > dpv_e_2) {
|
||||
instru.v_up = dpv_e_1;
|
||||
instru.v_low = dpv_e_2;
|
||||
instru.v_stop_direction = 1;//0:reverse 1:forward
|
||||
|
||||
} else if (dpv_e_1 < dpv_e_2) {
|
||||
instru.v_up = dpv_e_2;
|
||||
instru.v_low = dpv_e_1;
|
||||
instru.v_stop_direction = 0;//0:reverse 1:forward
|
||||
}
|
||||
|
||||
if (dpv_option == 1) {
|
||||
instru.eliteFxn = CURVE_DPV_ADVANCE;
|
||||
} else if (dpv_option == 2) {
|
||||
instru.eliteFxn = CURVE_DPV_ADVANCE_SMPRATE;
|
||||
}
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
ModeLED(WORKING);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SET_PARA: {
|
||||
int32_t value;
|
||||
|
||||
if (instru.eliteFxn == CURVE_VO) {
|
||||
switch (p[3]) {
|
||||
case DAC_VOLT:
|
||||
value = (p[4] << 8) | p[5]; // usercode
|
||||
|
||||
if (value < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && value > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE) {
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
} else {
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
}
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
|
||||
value = (value - 25000) * 4 * 10000; //[5nV]
|
||||
set_para(instru.eliteFxn, DAC_VOLT, value);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (instru.eliteFxn == CURVE_IT) {
|
||||
switch (p[3]) {
|
||||
case DAC_VOLT:
|
||||
value = (p[4] << 8) | p[5]; // usercode
|
||||
|
||||
if (value < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && value > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE) {
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
} else {
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
}
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
|
||||
value = (value - 25000) * 4 * 10000; //[5nV]
|
||||
set_para(instru.eliteFxn, DAC_VOLT, value);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (instru.eliteFxn == CURVE_RT) {
|
||||
switch (p[3]) {
|
||||
case DAC_VOLT:
|
||||
value = (p[4] << 8) | p[5]; // usercode
|
||||
|
||||
if (value < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && value > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE) {
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
} else {
|
||||
instru.VoutGainLv = VOUT_GAIN_240K;
|
||||
}
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
|
||||
value = (value - 25000) * 4 * 10000; //[5nV]
|
||||
set_para(instru.eliteFxn, DAC_VOLT, value);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case MODE_DEV_TOOL: { // 0x3000FF
|
||||
mode_dev_tool(p);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
/** **/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void ins_decode_vis(uint8_t *ins_buf)
|
||||
{
|
||||
uint8_t *p = ins_buf;
|
||||
uint8_t oper = p[1]; // this is don't care in RIS
|
||||
switch (oper) {
|
||||
// reset all variables ( Ins = 0xC0F0)
|
||||
case VIS_RST: {
|
||||
instru.eliteFxn = VIS_RST;
|
||||
reset();
|
||||
break;
|
||||
}
|
||||
|
||||
case VIS_ASK: {
|
||||
not_buf[0] = BLE_DAT_BUFF_SIZE - 1; //data len
|
||||
for (int i = 0; i < BLE_DAT_BUFF_SIZE; i++) {
|
||||
not_buf[i] = i;
|
||||
}
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_DAT_BUFF_SIZE, not_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
case VIS_STI: {
|
||||
for(int i = 0; i < 12; i++) {
|
||||
FlushNotify();
|
||||
}
|
||||
PeriodicEvent = true;
|
||||
InitPeriodicEvent = true; // need to create a WorkModeData?
|
||||
mode_init = true;
|
||||
InitGPT();
|
||||
break;
|
||||
}
|
||||
|
||||
case VIS_FUH: {
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_RED);
|
||||
break;
|
||||
}
|
||||
|
||||
case VIS_INT: {
|
||||
Eliteinterrupt();
|
||||
for (int i = 0; i < 12; i++) {
|
||||
FlushNotify();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VIS_DEVICE_SHINY: {
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_MAGENTA);
|
||||
break;
|
||||
}
|
||||
|
||||
case VIS_SHINY_DIS: {
|
||||
if (PeriodicEvent) {
|
||||
WORKLED();
|
||||
} else if (!PeriodicEvent) {
|
||||
LEDPowerON();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VIS_CC_ZERO: {
|
||||
instru.eliteFxn = CURVE_OCP;
|
||||
instru.notifyRate = 500;
|
||||
|
||||
if (instru.notifyRate > 1000) {
|
||||
// slow notify rate, < 10sps, auto gain changer only use ADC gain level = 1.2.3.4
|
||||
instru.gain_switch_on = 0b11110000;
|
||||
|
||||
} else {
|
||||
// fast notify rate, >= 10sps, auto gain changer only use ADC gain level = 1.2.3
|
||||
instru.gain_switch_on = 0b01110000;
|
||||
}
|
||||
|
||||
ModeLED(PRE_WORK);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ins_decode_cis(uint8_t *ins_buf)
|
||||
{
|
||||
uint8_t *p = ins_buf;
|
||||
uint8_t oper = p[1]; // this is don't care in RIS
|
||||
|
||||
switch (oper) {
|
||||
case CIS_VERSION: {
|
||||
initCISBuf();
|
||||
cis_buf[0] = 6; //data len
|
||||
cis_buf[1] = CIS_VERSION;
|
||||
cis_buf[2] = VERSION_DATE_YEAR;
|
||||
cis_buf[3] = VERSION_DATE_MONTH;
|
||||
cis_buf[4] = VERSION_DATE_DAY;
|
||||
cis_buf[5] = VERSION_DATE_HOUR;
|
||||
cis_buf[6] = VERSION_DATE_MINUTE;
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
case CIS_VOLT: {
|
||||
// uint32_t bat = headstage_battery_volt();
|
||||
// initCISBuf();
|
||||
// cis_buf[0] = 5; //data len
|
||||
// cis_buf[1] = CIS_VOLT;
|
||||
// memcpy(&cis_buf[2], (uint8_t *)&bat, sizeof(bat));
|
||||
// SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
case CIS_TEMPERATURE: { //0x7080
|
||||
int32_t t = headstage_temperature();
|
||||
initCISBuf();
|
||||
cis_buf[0] = 5; //data len
|
||||
cis_buf[1] = CIS_TEMPERATURE;
|
||||
memcpy(&cis_buf[2], (uint8_t *)&t, sizeof(t));
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
-313
@@ -1,313 +0,0 @@
|
||||
|
||||
#include "hardware/DAC_MAX5136.h"
|
||||
/*
|
||||
* MODE_DEV_TOOL 0xFF
|
||||
* DEV_TOOL_VERSION [34 LL FF 01]
|
||||
*
|
||||
* DEV_TOOL_BAT [34 LL FF 02]
|
||||
*
|
||||
* DEV_TOOL_TEMP [34 LL FF 03]
|
||||
*
|
||||
* DEV_TOOL_LED [34 LL FF 04]
|
||||
* DEV_LED_LIMIT_COLOR [00 NN]
|
||||
* DEV_LED_DARK_COLOR [01 RR GG BB]
|
||||
* DEV_LED_LIGHT_COLOR [02 RR GG BB]
|
||||
* DEV_LED_RAINBOW [03]
|
||||
*
|
||||
* DEV_TOOL_SPI [34 LL FF 20 pp RR WW ss ss ss ...]
|
||||
* DT_CHIP_ADC pp = [00]
|
||||
* DT_CHIP_DAC pp = [01]
|
||||
* DT_CHIP_MEM pp = [02]
|
||||
* DT_CHIP_SWITCH pp = [03]
|
||||
*
|
||||
* DEV_TOOL_I2C [34 LL FF 28 qq RR WW ss ss ss ...]
|
||||
*
|
||||
* DEV_TOOL_GPIO_EDC20_ADC_CH [34 LL FF 31 cc]
|
||||
* cc = 07 => all open
|
||||
* cc = 04 => open A2
|
||||
* cc = 02 => open A1
|
||||
* cc = 01 => open A0
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
enum dev_tool_para_e {
|
||||
DEV_TOOL_VERSION = 0x01,
|
||||
DEV_TOOL_BAT = 0x02,
|
||||
DEV_TOOL_TEMP = 0x03,
|
||||
DEV_TOOL_LED = 0x04,
|
||||
DEV_TOOL_SPI = 0x20,
|
||||
DEV_TOOL_I2C = 0x28,
|
||||
DEV_TOOL_GPIO_EDC20_ADC_CH = 0x31,
|
||||
DEV_TOOL_OUT0_WRITE_THROUGH = 0x50,
|
||||
DEV_TOOL_SWITCH_SELECT = 0x60,
|
||||
};
|
||||
|
||||
enum dev_tool_chip_e {
|
||||
DT_CHIP_ADC = 0,
|
||||
DT_CHIP_DAC,
|
||||
DT_CHIP_MEM,
|
||||
DT_CHIP_SWITCH,
|
||||
DT_OPEN_SPI1 = 0x11,
|
||||
|
||||
DT_CHIP_MAX,
|
||||
};
|
||||
|
||||
enum dev_led_item_e {
|
||||
DEV_LED_LIMIT_COLOR = 0,
|
||||
DEV_LED_DARK_COLOR,
|
||||
DEV_LED_LIGHT_COLOR,
|
||||
DEV_LED_RAINBOW,
|
||||
|
||||
DEV_LED_MAX,
|
||||
};
|
||||
|
||||
static void dev_tool_version()
|
||||
{
|
||||
initCISBuf();
|
||||
cis_buf[0] = 6; //data len
|
||||
cis_buf[1] = DEV_TOOL_VERSION;
|
||||
cis_buf[2] = VERSION_DATE_YEAR;
|
||||
cis_buf[3] = VERSION_DATE_MONTH;
|
||||
cis_buf[4] = VERSION_DATE_DAY;
|
||||
cis_buf[5] = VERSION_DATE_HOUR;
|
||||
cis_buf[6] = VERSION_DATE_MINUTE;
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
}
|
||||
|
||||
static void dev_tool_battery()
|
||||
{
|
||||
uint32_t bat;
|
||||
bat = headstage_battery_volt();
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = 5; //data len
|
||||
cis_buf[1] = DEV_TOOL_BAT;
|
||||
memcpy(&cis_buf[2], (uint8_t *)&bat, sizeof(bat));
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
}
|
||||
|
||||
static void dev_tool_temp()
|
||||
{
|
||||
int32_t t;
|
||||
|
||||
t = headstage_temperature();
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = 5; //data len
|
||||
cis_buf[1] = DEV_TOOL_TEMP;
|
||||
memcpy(&cis_buf[2], (uint8_t *)&t, sizeof(t));
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
}
|
||||
|
||||
static int dev_tool_led(uint8_t *ins_buf)
|
||||
{
|
||||
uint8_t *p = ins_buf;
|
||||
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_MAX)
|
||||
return -1;
|
||||
|
||||
if (led_item == DEV_LED_RAINBOW)
|
||||
return led_rainbow(LED_BR_LV1);
|
||||
|
||||
if (led_item == DEV_LED_LIMIT_COLOR)
|
||||
return led_color_set(LED_NB_MAX, LED_BR_LV1, (enum led_color_e)c_num);
|
||||
|
||||
if (led_item == DEV_LED_DARK_COLOR)
|
||||
return led_color_code_set(LED_NB_MAX, LED_BR_LV1, &led_c);
|
||||
|
||||
if (led_item == DEV_LED_LIGHT_COLOR)
|
||||
return led_color_code_set(LED_NB_MAX, LED_BR_LV8, &led_c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dev_tool_spi(uint8_t *ins_buf)
|
||||
{
|
||||
uint8_t *p = ins_buf;
|
||||
uint8_t chip_sel = p[4];
|
||||
|
||||
//ADC、DAC、MEM、SWITCH
|
||||
uint8_t rxlen = p[5];
|
||||
uint8_t txlen = p[6];
|
||||
uint8_t tx[250] = {0};
|
||||
uint8_t rx[250] = {0};
|
||||
|
||||
//set spi config
|
||||
uint8_t pol = p[5] >> 4;
|
||||
uint8_t pha = p[5] & 0X0F;
|
||||
|
||||
if (chip_sel >= DT_CHIP_MAX)
|
||||
return;
|
||||
|
||||
switch (chip_sel) {
|
||||
case DT_CHIP_ADC:
|
||||
pin_set(E_PIN_ADCCS, 0);
|
||||
memcpy(tx, &p[7], txlen);
|
||||
spi1_write(rx, tx, txlen);
|
||||
pin_set(E_PIN_ADCCS, 1);
|
||||
break;
|
||||
|
||||
case DT_CHIP_DAC:
|
||||
pin_set(E_PIN_DACCS, 0);
|
||||
memcpy(tx, &p[7], txlen);
|
||||
spi1_write(rx, tx, txlen);
|
||||
pin_set(E_PIN_DACCS, 1);
|
||||
break;
|
||||
|
||||
case DT_CHIP_MEM:
|
||||
pin_set(E_PIN_MEMCS, 0);
|
||||
memcpy(tx, &p[7], txlen);
|
||||
spi1_write(rx, tx, txlen);
|
||||
pin_set(E_PIN_MEMCS, 1);
|
||||
break;
|
||||
|
||||
case DT_CHIP_SWITCH:
|
||||
pin_set(E_PIN_SWCSBB, 0);
|
||||
memcpy(tx, &p[7], txlen);
|
||||
spi1_write(rx, tx, txlen);
|
||||
pin_set(E_PIN_SWCSBB, 1);
|
||||
break;
|
||||
|
||||
case DT_OPEN_SPI1:
|
||||
spi1_close();
|
||||
spi1_open(SPI_CLK_4M, pol, pha);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = rxlen + 1; //data len
|
||||
cis_buf[1] = DEV_TOOL_SPI;
|
||||
memcpy(&cis_buf[2], rx, rxlen);
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
|
||||
}
|
||||
|
||||
static void dev_tool_i2c(uint8_t *ins_buf)
|
||||
{
|
||||
uint8_t *p = ins_buf;
|
||||
struct i2c_para_t i2c_send;
|
||||
struct i2c_para_t *send = &i2c_send;
|
||||
|
||||
send->i2c_addr = p[4];
|
||||
send->i2c_rxlen = p[5];
|
||||
send->i2c_txlen = p[6];
|
||||
memcpy(send->i2c_tx, &p[7], send->i2c_txlen);
|
||||
|
||||
i2c0_write(send);
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = send->i2c_rxlen + 1; //data len
|
||||
cis_buf[1] = DEV_TOOL_I2C;
|
||||
memcpy(&cis_buf[2], send->i2c_rx, send->i2c_rxlen);
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
}
|
||||
|
||||
static void dev_tool_gpio_edc20_adc_ch(uint8_t *ins_buf)
|
||||
{
|
||||
uint8_t *p = ins_buf;
|
||||
uint8_t adc_selector = p[4];
|
||||
|
||||
adc_sel_set(adc_selector);
|
||||
|
||||
}
|
||||
|
||||
static void dev_tool_dac_write(uint8_t *ins_buf)
|
||||
{
|
||||
|
||||
|
||||
uint8_t *p = ins_buf;
|
||||
dac_series_control_g[DAC_NB_0].dac0_enable = (p[4] & 0xf0) >> 4;
|
||||
dac_series_control_g[DAC_NB_0].dac1_enable = (p[4] & 0x0f);
|
||||
dac_series_control_g[DAC_NB_0].volts = (uint16_t) p[5] << 8 | (uint16_t) p[6];
|
||||
|
||||
dac_series_control_g[DAC_NB_1].dac0_enable = (p[7] & 0xf0) >> 4;
|
||||
dac_series_control_g[DAC_NB_1].dac1_enable = (p[7] & 0x0f);
|
||||
dac_series_control_g[DAC_NB_1].volts = (uint16_t) p[8] << 8 | (uint16_t) p[9];
|
||||
|
||||
dac_enable_all_output(dac_series_control_g);
|
||||
}
|
||||
|
||||
|
||||
static void dev_tool_dac_write_single(uint8_t *ins_buf) {
|
||||
uint8_t *p = ins_buf;
|
||||
uint8_t dac0_enable = (p[4] & 0xf0) >> 4;
|
||||
uint8_t dac1_enable = (p[4] & 0x0f);
|
||||
uint16_t volts = (uint16_t) p[5] << 8 | (uint16_t) p[6];
|
||||
enum MAX5136_num_e dac_num = (enum MAX5136_num_e) p[7];
|
||||
|
||||
dac_enable_single_output(dac0_enable, dac1_enable, volts, dac_num);
|
||||
}
|
||||
|
||||
static void dev_tool_switch_select(uint8_t *ins_buf)
|
||||
{
|
||||
uint8_t *p = ins_buf;
|
||||
|
||||
uint8_t switch_module_number = p[4];
|
||||
uint8_t enable_type = p[5];
|
||||
|
||||
switch_ctrl(switch_module_number, enable_type);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void mode_dev_tool(uint8_t *ins_buf)
|
||||
{
|
||||
uint8_t *p = ins_buf;
|
||||
uint8_t dev_item = p[3];
|
||||
|
||||
switch (dev_item) {
|
||||
case DEV_TOOL_VERSION:
|
||||
dev_tool_version();
|
||||
break;
|
||||
|
||||
case DEV_TOOL_BAT:
|
||||
dev_tool_battery();
|
||||
break;
|
||||
|
||||
case DEV_TOOL_TEMP:
|
||||
dev_tool_temp();
|
||||
break;
|
||||
|
||||
case DEV_TOOL_LED:
|
||||
dev_tool_led(p);
|
||||
break;
|
||||
|
||||
case DEV_TOOL_SPI:
|
||||
dev_tool_spi(p);
|
||||
break;
|
||||
|
||||
case DEV_TOOL_I2C:
|
||||
dev_tool_i2c(p);
|
||||
break;
|
||||
|
||||
case DEV_TOOL_GPIO_EDC20_ADC_CH:
|
||||
dev_tool_gpio_edc20_adc_ch(p);
|
||||
break;
|
||||
|
||||
case DEV_TOOL_OUT0_WRITE_THROUGH:
|
||||
dev_tool_dac_write(p);
|
||||
break;
|
||||
|
||||
case DEV_TOOL_SWITCH_SELECT:
|
||||
dev_tool_switch_select(p);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -50,15 +50,9 @@
|
||||
|
||||
#include <xdc/runtime/Error.h>
|
||||
|
||||
|
||||
#include <ti/drivers/Power.h>
|
||||
#include <ti/drivers/power/PowerCC26XX.h>
|
||||
#include <ti/sysbios/BIOS.h>
|
||||
#include <ti/drivers/SPI.h>
|
||||
#include <ti/drivers/spi/SPICC26XXDMA.h>
|
||||
#include <ti/drivers/dma/UDMACC26XX.h>
|
||||
#include <ti/drivers/I2C.h>
|
||||
#include <ti/drivers/i2c/I2CCC26XX.h>
|
||||
|
||||
#include "icall.h"
|
||||
#include "hal_assert.h"
|
||||
@@ -254,47 +248,46 @@ int main()
|
||||
void AssertHandler(uint8 assertCause, uint8 assertSubcause)
|
||||
{
|
||||
// Open the display if the app has not already done so
|
||||
// if ( !dispHandle )
|
||||
// {
|
||||
// dispHandle = Display_open(Display_Type_LCD, NULL);
|
||||
// }
|
||||
// if ( !dispHandle )
|
||||
// {
|
||||
// dispHandle = Display_open(Display_Type_LCD, NULL);
|
||||
// }
|
||||
|
||||
// Display_print0(dispHandle, 0, 0, ">>>STACK ASSERT");
|
||||
|
||||
// Display_print0(dispHandle, 0, 0, ">>>STACK ASSERT");
|
||||
// // check the assert cause
|
||||
// switch (assertCause)
|
||||
// {
|
||||
// case HAL_ASSERT_CAUSE_OUT_OF_MEMORY:
|
||||
// Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
// Display_print0(dispHandle, 2, 0, ">> OUT OF MEMORY!");
|
||||
// break;
|
||||
|
||||
// check the assert cause
|
||||
// switch (assertCause)
|
||||
// {
|
||||
// case HAL_ASSERT_CAUSE_OUT_OF_MEMORY:
|
||||
// Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
// Display_print0(dispHandle, 2, 0, ">> OUT OF MEMORY!");
|
||||
// break;
|
||||
//
|
||||
// case HAL_ASSERT_CAUSE_INTERNAL_ERROR:
|
||||
// // check the subcause
|
||||
// if (assertSubcause == HAL_ASSERT_SUBCAUSE_FW_INERNAL_ERROR)
|
||||
// {
|
||||
// Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
// Display_print0(dispHandle, 2, 0, ">> INTERNAL FW ERROR!");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
// Display_print0(dispHandle, 2, 0, ">> INTERNAL ERROR!");
|
||||
// }
|
||||
// break;
|
||||
//
|
||||
// case HAL_ASSERT_CAUSE_ICALL_ABORT:
|
||||
// Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
// Display_print0(dispHandle, 2, 0, ">> ICALL ABORT!");
|
||||
// HAL_ASSERT_SPINLOCK;
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
// Display_print0(dispHandle, 2, 0, ">> DEFAULT SPINLOCK!");
|
||||
// HAL_ASSERT_SPINLOCK;
|
||||
// }
|
||||
// case HAL_ASSERT_CAUSE_INTERNAL_ERROR:
|
||||
// // check the subcause
|
||||
// if (assertSubcause == HAL_ASSERT_SUBCAUSE_FW_INERNAL_ERROR)
|
||||
// {
|
||||
// Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
// Display_print0(dispHandle, 2, 0, ">> INTERNAL FW ERROR!");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
// Display_print0(dispHandle, 2, 0, ">> INTERNAL ERROR!");
|
||||
// }
|
||||
// break;
|
||||
|
||||
// case HAL_ASSERT_CAUSE_ICALL_ABORT:
|
||||
// Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
// Display_print0(dispHandle, 2, 0, ">> ICALL ABORT!");
|
||||
// HAL_ASSERT_SPINLOCK;
|
||||
// break;
|
||||
|
||||
// default:
|
||||
// Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
// Display_print0(dispHandle, 2, 0, ">> DEFAULT SPINLOCK!");
|
||||
// HAL_ASSERT_SPINLOCK;
|
||||
// }
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
#ifndef LED_APA_102_H
|
||||
#define LED_APA_102_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* APA-102-2020-256-8A-20190612: Series data structure
|
||||
* +-------------------+------------------------- ... -+-----------------+
|
||||
* | start_frame(4B) | led_frame(4B) *LED_TANDEM_N | end_frame(4B) |
|
||||
* +-------------------+------------------------- ... -+-----------------+
|
||||
* / \
|
||||
* / led_frame(4B) \
|
||||
* / \
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | 111 | bright | blue | green | red |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*/
|
||||
|
||||
#include "driver/spi_ctrl.h"
|
||||
|
||||
#define DEF_LED_TANDEN_N 8
|
||||
|
||||
#ifdef DEF_LED_TANDEN_N
|
||||
#define LED_TANDEM_N DEF_LED_TANDEN_N
|
||||
#else
|
||||
#define LED_TANDEM_N 12
|
||||
#endif
|
||||
|
||||
enum led_series_nb_e {
|
||||
LED_NB_1 = 0,
|
||||
LED_NB_2,
|
||||
LED_NB_3,
|
||||
LED_NB_4,
|
||||
LED_NB_5,
|
||||
LED_NB_6,
|
||||
LED_NB_7,
|
||||
LED_NB_8,
|
||||
LED_NB_9,
|
||||
LED_NB_10,
|
||||
LED_NB_11,
|
||||
LED_NB_12,
|
||||
|
||||
LED_NB_MAX = LED_TANDEM_N,
|
||||
};
|
||||
|
||||
enum led_bright_e {
|
||||
LED_BR_LV0 = 0x00,
|
||||
LED_BR_LV1 = 0x01,
|
||||
LED_BR_LV8 = 0x08,
|
||||
|
||||
LED_BR_MAX = 0x1F,
|
||||
};
|
||||
|
||||
enum led_color_e {
|
||||
LED_CLR_BLACK = 0,
|
||||
LED_CLR_WHITE,
|
||||
LED_CLR_RED,
|
||||
LED_CLR_ORANGE,
|
||||
LED_CLR_YELLOW,
|
||||
LED_CLR_GREEN,
|
||||
LED_CLR_CYAN,
|
||||
LED_CLR_BLUE,
|
||||
LED_CLR_PURPLE,
|
||||
LED_CLR_MAGENTA,
|
||||
LED_CLR_YELLOWGREEN,
|
||||
LED_CLR_EMERALD,
|
||||
LED_CLR_LOW_BAT,
|
||||
|
||||
LED_CLR_MAX,
|
||||
};
|
||||
|
||||
struct led_color_t {
|
||||
uint8_t b;
|
||||
uint8_t g;
|
||||
uint8_t r;
|
||||
};
|
||||
|
||||
int led_color_set(enum led_series_nb_e led_nb, enum led_bright_e bright, enum led_color_e color);
|
||||
int led_color_code_set(enum led_series_nb_e led_nb, enum led_bright_e bright, struct led_color_t *color);
|
||||
int led_rainbow(enum led_bright_e bright);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // LED_APA_102_H
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "module/led_APA_102.h"
|
||||
|
||||
#define LED_FRAME_RSVD 0x07 // 0x11100000 || bright
|
||||
#define LED_SERIES_D_START 0x00000000
|
||||
#define LED_SERIES_D_END 0xFFFFFFFF
|
||||
|
||||
struct led_frame_t {
|
||||
uint8_t bright: 5,
|
||||
rsvd: 3;
|
||||
struct led_color_t color;
|
||||
};
|
||||
|
||||
struct led_series_data_t {
|
||||
uint32_t f_start;
|
||||
struct led_frame_t f_led[LED_TANDEM_N];
|
||||
uint32_t f_end;
|
||||
};
|
||||
|
||||
const struct led_color_t led_color_list_g[LED_CLR_MAX] = {
|
||||
// {blue, green, red}
|
||||
{0x00, 0x00, 0x00}, // LED_CLR_BLACK
|
||||
{0xFF, 0xFF, 0xCA}, // LED_CLR_WHITE
|
||||
{0x00, 0x00, 0xFF}, // LED_CLR_RED
|
||||
{0x09, 0x58, 0xFF}, // LED_CLR_ORANGE
|
||||
{0x00, 0xE1, 0xE1}, // LED_CLR_YELLOW
|
||||
{0x00, 0xFA, 0x00}, // LED_CLR_GREEN
|
||||
{0x40, 0x40, 0x00}, // LED_CLR_CYAN
|
||||
{0xAA, 0x00, 0x00}, // LED_CLR_BLUE
|
||||
{0x6F, 0x00, 0x3A}, // LED_CLR_PURPLE
|
||||
{0xFF, 0x00, 0xFF}, // LED_CLR_MAGENTA
|
||||
{0x00, 0xA6, 0x64}, // LED_CLR_YELLOWGREEN
|
||||
{0x78, 0xC8, 0x50}, // LED_CLR_EMERALD
|
||||
{0x05, 0x35, 0x9E}, // LED_CLR_LOW_BAT (orange)
|
||||
};
|
||||
|
||||
static int __led_complete(struct led_series_data_t *sd)
|
||||
{
|
||||
for (int i = LED_NB_1; i < LED_NB_MAX; i++)
|
||||
sd->f_led[i].rsvd = LED_FRAME_RSVD;
|
||||
|
||||
sd->f_start = LED_SERIES_D_START;
|
||||
sd->f_end = LED_SERIES_D_END;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __led_color_set(enum led_series_nb_e led_nb, struct led_frame_t *led_f)
|
||||
{
|
||||
static struct led_series_data_t led_series_data_g = {0};
|
||||
struct led_series_data_t *sd = &led_series_data_g;
|
||||
|
||||
/*
|
||||
* led_nb - < LED_NB_MAX: fill one led_frame
|
||||
* == LED_NB_MAX: fill multiple led_frame
|
||||
*
|
||||
* complete: then, fill (start_frame, end_frame and the rsvd of every led_frame)
|
||||
*
|
||||
* finally, write cmd to hw by spi
|
||||
*/
|
||||
if (led_nb < LED_NB_MAX) {
|
||||
memcpy(&sd->f_led[led_nb], led_f, sizeof(struct led_frame_t));
|
||||
} else if (led_nb == LED_NB_MAX) {
|
||||
for (enum led_series_nb_e i = LED_NB_1; i < LED_NB_MAX; i++) {
|
||||
memcpy(&sd->f_led[i], led_f, sizeof(struct led_frame_t));
|
||||
}
|
||||
}
|
||||
__led_complete(sd);
|
||||
|
||||
spi_open(SPI0, SPI_RATE_1M, SPI_POL0, SPI_PHA1); //SPI 1M: LED
|
||||
led_cs(1);
|
||||
spi_write(SPI0, NULL, (uint8_t *)sd, sizeof(struct led_series_data_t));
|
||||
led_cs(0);
|
||||
spi_close(SPI0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int led_color_set(enum led_series_nb_e led_nb, enum led_bright_e bright, enum led_color_e color)
|
||||
{
|
||||
struct led_frame_t led_f = {0};
|
||||
|
||||
if (led_nb > LED_NB_MAX)
|
||||
return -1;
|
||||
|
||||
if (bright > LED_BR_MAX)
|
||||
return -2;
|
||||
|
||||
if (color >= LED_CLR_MAX)
|
||||
return -3;
|
||||
|
||||
led_f.bright = bright;
|
||||
led_f.color = led_color_list_g[color];
|
||||
__led_color_set(led_nb, &led_f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int led_color_code_set(enum led_series_nb_e led_nb, enum led_bright_e bright, struct led_color_t *color)
|
||||
{
|
||||
struct led_frame_t led_f = {0};
|
||||
|
||||
if (led_nb > LED_NB_MAX)
|
||||
return -1;
|
||||
|
||||
if (bright > LED_BR_MAX)
|
||||
return -2;
|
||||
|
||||
led_f.bright = bright;
|
||||
memcpy(&led_f.color, &color, sizeof(struct led_color_t));
|
||||
__led_color_set(led_nb, &led_f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int led_rainbow(enum led_bright_e bright)
|
||||
{
|
||||
if (bright > LED_BR_MAX)
|
||||
return -1;
|
||||
|
||||
for(enum led_series_nb_e i=LED_NB_1; i<LED_NB_MAX; i++)
|
||||
led_color_set(i, bright, (enum led_color_e)i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* example -
|
||||
* customize color:
|
||||
* struct led_color_t led_c;
|
||||
* uint8_t bri;
|
||||
* // { ins, ins, num, r, g, b, bri};
|
||||
* uint8_t ins[20] = {0x30, 0x00, LED_NB_4, 0xFF, 0x00, 0x44, 0x3};
|
||||
* led_c.r = ins[3];
|
||||
* led_c.g = ins[4];
|
||||
* led_c.b = ins[5];
|
||||
* bri = ins[6];
|
||||
* led_color_code_set(LED_NB_4, bri, led_c);
|
||||
*
|
||||
* single led:
|
||||
* led_color_set(LED_NB_1, LED_BR_LV1, LED_CLR_WHITE);
|
||||
*
|
||||
* multiple led:
|
||||
* led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_BLUE);
|
||||
*
|
||||
* rainbow led:
|
||||
* led_rainbow(LED_BR_LV1);
|
||||
*/
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
# $python .\simplelink\ble_sdk_2_02_02_25\src\examples\simple_peripheral\cc26xx\app\python\update_elite_version.py
|
||||
|
||||
import datetime
|
||||
import os
|
||||
|
||||
print(datetime.datetime.now())
|
||||
# print(datetime.datetime.now().year)
|
||||
# print(datetime.datetime.now().month)
|
||||
# print(datetime.datetime.now().day)
|
||||
# print(datetime.datetime.now().hour)
|
||||
# print(datetime.datetime.now().minute)
|
||||
# print(datetime.datetime.now().strftime("%H:%M:%S"))
|
||||
|
||||
y = datetime.datetime.now().year % 100
|
||||
m = datetime.datetime.now().month
|
||||
d = datetime.datetime.now().day
|
||||
hour = datetime.datetime.now().hour
|
||||
minute = datetime.datetime.now().minute
|
||||
|
||||
path = os.getcwd()
|
||||
path += '/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h'
|
||||
print('save:', path)
|
||||
|
||||
with open(path, 'w') as f:
|
||||
f.write('#ifndef VERSION_DATE' + '\n')
|
||||
f.write('#define VERSION_DATE' + '\n\n')
|
||||
f.write('#define VERSION_DATE_YEAR ' + str(y) + '\n')
|
||||
f.write('#define VERSION_DATE_MONTH ' + str(m) + '\n')
|
||||
f.write('#define VERSION_DATE_DAY ' + str(d) + '\n')
|
||||
f.write('#define VERSION_DATE_HOUR ' + str(hour) + '\n')
|
||||
f.write('#define VERSION_DATE_MINUTE ' + str(minute) + '\n')
|
||||
|
||||
f.write('#endif' + '\n')
|
||||
+274
@@ -0,0 +1,274 @@
|
||||
#ifndef APP_SER_H
|
||||
#define APP_SER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct elite_instru_t
|
||||
{
|
||||
uint8_t memoryboard_id;
|
||||
uint8_t elite_mode;
|
||||
|
||||
// time relation
|
||||
uint32_t vscan_rate;
|
||||
uint32_t notify_rate;
|
||||
|
||||
/** TRIG output channel **/
|
||||
bool tri_d0_as_5v_en;
|
||||
bool tri_d1_as_5v_en;
|
||||
|
||||
/** trigger mode enable **/
|
||||
bool trig0_en;
|
||||
bool trig1_en;
|
||||
uint8_t trig0_edge;
|
||||
uint8_t trig1_edge;
|
||||
|
||||
// about a0~a3
|
||||
uint16_t Trig_CurCon[4];
|
||||
};
|
||||
|
||||
#include "Elite_version.h"
|
||||
#include "driver/timers.h"
|
||||
#include "driver/spi_ctrl.h"
|
||||
#include "module/led_APA_102.h"
|
||||
#include "service/mode_all_output_ctrl.h"
|
||||
|
||||
// LED
|
||||
#define LED_BT_WAIT 0x01
|
||||
#define LED_NO_EVENT 0x02
|
||||
#define LED_WORKING 0x04
|
||||
static uint8_t led_status = LED_NO_EVENT;
|
||||
static void update_led(uint8_t led);
|
||||
|
||||
/**
|
||||
* Trigger channel initialize
|
||||
*/
|
||||
#define PIN_PR0 0
|
||||
#define PIN_D0_SW 1
|
||||
#define PIN_A0 2
|
||||
#define PIN_A2 3
|
||||
#define PIN_A3 4
|
||||
#define PIN_A1 5
|
||||
#define PIN_D1_SW 6
|
||||
#define PIN_PR1 7
|
||||
#define PIN_D0_5V 8
|
||||
#define PIN_D1_5V 9
|
||||
#define PIN_OUT_CH_MAX 10
|
||||
bool chan_en[PIN_OUT_CH_MAX]; // [pr0_en, d0_mos_en, a0_en, a2_en, a3_en,
|
||||
// a1_en, d1_mos_en, pr1_en, d0_5v_en, d1_5v_en]
|
||||
|
||||
|
||||
/** TRIG01 trigger edge type **/
|
||||
#define TRIG_POSEDGE 0x00
|
||||
#define TRIG_NEGEDGE 0x01
|
||||
#define TRIG_BOTHEDGE 0x02
|
||||
#define TRIG_DIS 0x03
|
||||
// define BT instruction
|
||||
#define INS_TYPE_RIS 0x30
|
||||
#define INS_TYPE_VIS 0xC0
|
||||
#define INS_TYPE_CIS 0x70
|
||||
|
||||
// VIS (virtual instruction)
|
||||
#define VIS_RST 0xF0
|
||||
#define VIS_STI 0xC0
|
||||
#define VIS_INT 0x60
|
||||
#define VIS_DEVICE_SHINY 0x10
|
||||
#define VIS_SHINY_DIS 0x20
|
||||
|
||||
//clock
|
||||
/***************************************************
|
||||
* Q: Why define CPU_1us = 16?
|
||||
* A:
|
||||
* 3 cycles per loop: 16 loops @ 48 Mhz ~= 1 us
|
||||
* 3 cycles * X loops / 48Mhz = 1us(ideal value)
|
||||
* 3 cycles * X loops / 48us = 1us(ideal value)
|
||||
* X = 48 / 3 => X = 16 loops
|
||||
***************************************************/
|
||||
#define CPU_1us 16
|
||||
#define CPU_1ms 16000
|
||||
|
||||
// Elite TRIG01 ADC command
|
||||
#define CMD_DOUT_5V_IMON_0 0xC5
|
||||
#define CMD_DOUT_5V_IMON_1 0xD5
|
||||
|
||||
#define Aout_CH_0 0x00
|
||||
#define Aout_CH_1 0x01
|
||||
#define Aout_CH_2 0x02
|
||||
#define Aout_CH_3 0x03
|
||||
|
||||
|
||||
|
||||
#define LATCH_BUFF_SIZE 8 // define latch
|
||||
|
||||
// CIS (control instruction)
|
||||
#define CIS_VERSION 0x40
|
||||
#define CIS_VOLT 0x10
|
||||
#define CIS_TEMPERATURE 0x80
|
||||
|
||||
/* TRIG01 define */
|
||||
#define TRIG_PR 0x00
|
||||
#define TRIG_MOS_DOUT 0x01
|
||||
#define TRIG_MOS_AOUT 0x02
|
||||
#define TRIG_5V_OUT 0x03
|
||||
#define TRIG_input 0x04
|
||||
// #define TRIG_CHAN_COUNT 10 // channel count of TRIG01
|
||||
|
||||
|
||||
|
||||
// gptimer
|
||||
struct gptimer_t
|
||||
{
|
||||
uint32_t gpt_now;
|
||||
uint32_t gpt_last;
|
||||
uint8_t gpt_delta;
|
||||
};
|
||||
|
||||
/* member of mode */
|
||||
struct wm_aout_ctx_t
|
||||
{
|
||||
int32_t _Vset;
|
||||
int32_t _Curset0;
|
||||
int32_t _Curset1;
|
||||
int32_t _Curset2;
|
||||
int32_t _Curset3;
|
||||
};
|
||||
|
||||
/* member of mode */
|
||||
#define CH_PR0 0
|
||||
#define CH_D0 1
|
||||
#define CH_A0 2
|
||||
#define CH_A2 3
|
||||
#define CH_A3 4
|
||||
#define CH_A1 5
|
||||
#define CH_D1 6
|
||||
#define CH_PR1 7
|
||||
|
||||
|
||||
/**
|
||||
* Latch initialize
|
||||
*/
|
||||
struct _LH
|
||||
{
|
||||
bool LATCH0[LATCH_BUFF_SIZE];
|
||||
bool LATCH1[LATCH_BUFF_SIZE];
|
||||
bool LATCH2[LATCH_BUFF_SIZE];
|
||||
};
|
||||
|
||||
// RIS (real instruction)
|
||||
enum all_mode_e
|
||||
{
|
||||
MODE_ANALOG_CURRENT_CTRL = 0x0E, // 0x0E
|
||||
MODE_ALL_OUTPUT_CTRL = 0x0F, // 0x0F
|
||||
DEV_TEST = 0xFF, // 0xFF,
|
||||
SET_SAMPLE_RATE = 0xE0, // 0xE0,
|
||||
SET_EN_CHAN = 0x81, // 0x81,
|
||||
SET_PARA = 0xE2, // 0xE2,
|
||||
SET_TRIG_EN = 0x41 // 0x41,
|
||||
};
|
||||
|
||||
enum dev_para_e
|
||||
{
|
||||
VERSION_DEV_TEST = 0x01,
|
||||
BAT_DEV_TEST = 0x02,
|
||||
TEMP_DEV_TEST = 0x03,
|
||||
LED_DEV_TEST = 0x04,
|
||||
AOUT_DEV_TEST = 0x05,
|
||||
DOUT_DEV_TEST = 0x06,
|
||||
PR_DEV_TEST = 0x07,
|
||||
OUT_5VEN_DEV_TEST = 0x08,
|
||||
SET_EN_CHAN_DEV_TEST = 0x0F,
|
||||
VIS_DEV_TRIG_EN = 0x09,
|
||||
Init_DEV_Trig_flag = 0x0A
|
||||
};
|
||||
|
||||
enum set_para_e
|
||||
{
|
||||
AOUT_CURRENT = 0x02,
|
||||
};
|
||||
|
||||
struct _LH LH = { 0 };
|
||||
struct elite_instru_t instru = { 0 };
|
||||
struct gptimer_t gpt = {0};
|
||||
static int32_t notify_ch1 = 0;
|
||||
static int32_t notify_ch2 = 0;
|
||||
static int32_t notify_ch3 = 0;
|
||||
static int32_t notify_ch4 = 0;
|
||||
static int32_t notify_ch5 = 0;
|
||||
static int32_t notify_ch6 = 0;
|
||||
static uint16_t NotifyVoltBat = 2000; //0x07d0
|
||||
static uint16_t NotifyTemperature = 200; //0x00c8
|
||||
static uint16_t NotifyCycleNumber = 0;
|
||||
static bool trig0_event_wait = false;
|
||||
static bool trig1_event_wait = false;
|
||||
static bool dual_trig_mode = false;
|
||||
static bool single_trig_mode = false;
|
||||
static void *workMode_p = NULL;
|
||||
/* Trigger Flag */
|
||||
static bool trig_PeriodicEvent = false;
|
||||
static bool TRIG_TrigEnable = false;
|
||||
static bool Trig_receive = false;
|
||||
static bool trig0_event = false;
|
||||
static bool trig1_event = false;
|
||||
static bool FLT_event = false;
|
||||
static bool PeriodicEvent = false;
|
||||
static bool mode_init;
|
||||
static bool finishMode = false;
|
||||
PIN_Handle PinHandle;
|
||||
static PIN_State PinStatus;
|
||||
|
||||
const PIN_Config Elite_pin[] = {
|
||||
CC2650_LOAD0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
CC2650_LOAD1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
CC2650_LOAD2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
CC2650_SHUT_DOWN | PIN_INPUT_EN | PIN_PULLDOWN, // to sense switch
|
||||
CC2650_TRIG_0 | PIN_INPUT_EN | PIN_PULLDOWN,
|
||||
CC2650_FLT | PIN_INPUT_EN | PIN_PULLDOWN,
|
||||
// CC2650_TRIG_1 | PIN_INPUT_EN | PIN_PULLDOWN,
|
||||
PIN_TERMINATE
|
||||
};
|
||||
|
||||
void elite_100us_task(void);
|
||||
|
||||
|
||||
static void InitEliteInstruction(void);
|
||||
static void set_channel_led(bool *chan_en);
|
||||
static void elite_reset();
|
||||
static void SendNotify();
|
||||
static void FlushNotify();
|
||||
static void key_manage(uint32_t delta_time);
|
||||
static uint8_t pin_button_get(void);
|
||||
static bool power_on(uint32_t delta_time);
|
||||
static void GPT_timerIncrement();
|
||||
static uint16_t Aout_decode(uint16_t input_code);
|
||||
static void set_Aoutput(uint8_t GPIO_channel, uint16_t input_code);
|
||||
static void TW1508reset();
|
||||
static void curr_out();
|
||||
static void aout_Curscan(void);
|
||||
static uint16_t Usercode_Correction_to_Aout(uint8_t aout_chan, uint16_t usercode);
|
||||
static void device_init();
|
||||
static void send_device_info();
|
||||
static void set_para(uint8_t elite_mode, uint16_t parameter, int32_t value);
|
||||
static void chg_aout_para(uint16_t parameter, int32_t value);
|
||||
static void trig_event_flush();
|
||||
static void trig_callback(PIN_Handle handle, PIN_Id pinId);
|
||||
static void trig_sense();
|
||||
static void trig_en_check();
|
||||
static void InitTrigChan();
|
||||
static void PIN_trig_edge_set(uint8_t trig0_edge, uint8_t trig1_edge);
|
||||
static void GPIO_SPI_transfer(uint32_t *GPIO_CLK_CH, uint16_t spi_GPIO_txbuf);
|
||||
static void led_cs(uint8_t signal);
|
||||
static void disable_trig_output();
|
||||
static void PIN15_setOutputValue_refresh();
|
||||
static void PIN15_setOutputValue(uint32_t latch_num, uint32_t pin_num, bool highlow);
|
||||
static void update_latch_status(uint32_t latch_num, uint32_t elite_pin, bool highlow);
|
||||
static void remove_elite_pin();
|
||||
static void add_elite_pin();
|
||||
static int wm_deinit(void);
|
||||
static void *wm_get(void);
|
||||
static void receive_instruction(uint8 *recv_instru);
|
||||
static void elite_task(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // APP_SER_H
|
||||
+1774
File diff suppressed because it is too large
Load Diff
+15
@@ -0,0 +1,15 @@
|
||||
#ifndef __MODE_ALL_OUTPUT_CTRL_H
|
||||
#define __MODE_ALL_OUTPUT_CTRL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void all_output_ctrl_mode_vsan(uint32_t delta_t);
|
||||
int all_output_ctrl_mode_create(void);
|
||||
void handle_all_output_mode_instru(uint8_t *recv_instru, struct elite_instru_t *instruction);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
+294
@@ -0,0 +1,294 @@
|
||||
#include <stdint.h>
|
||||
#include "service/mode_all_output_ctrl.h"
|
||||
|
||||
struct ch_all_out_ctrl_ctx_t
|
||||
{
|
||||
// user setting
|
||||
uint8_t used: 1,
|
||||
v_early: 1,
|
||||
v_mid: 4,
|
||||
v_late: 1,
|
||||
v_rsvd: 1;
|
||||
uint32_t t_early;
|
||||
uint32_t t_mid[4];
|
||||
uint32_t t_late;
|
||||
uint16_t cycle;
|
||||
|
||||
// automatic setting
|
||||
uint32_t t_part[4];
|
||||
uint32_t t_period;
|
||||
uint8_t init: 1,
|
||||
t_early_period: 1,
|
||||
t_mid_period: 1,
|
||||
t_late_period: 1,
|
||||
rsvd: 4;
|
||||
uint32_t v_scan_rate;
|
||||
};
|
||||
|
||||
struct mode_all_out_ctrl_ctx_t
|
||||
{
|
||||
struct ch_all_out_ctrl_ctx_t channel[8];
|
||||
};
|
||||
|
||||
void __all_output_ctrl_mode_ch_vsan(struct ch_all_out_ctrl_ctx_t *channel, uint32_t delta_t, uint8_t ch)
|
||||
{
|
||||
uint32_t m;
|
||||
|
||||
if (!channel->used)
|
||||
return;
|
||||
|
||||
if (channel->init) {
|
||||
channel->v_scan_rate = 0;
|
||||
channel->init = false;
|
||||
}
|
||||
|
||||
channel->v_scan_rate += delta_t;
|
||||
|
||||
if (channel->t_early_period) {
|
||||
if (ch==CH_D0 && instru.tri_d0_as_5v_en==1) {
|
||||
if(channel->v_early) {
|
||||
chan_en[CH_D0] = 0;
|
||||
chan_en[8] = 0;
|
||||
} else {
|
||||
chan_en[CH_D0] = 0;
|
||||
chan_en[8] = 1;
|
||||
}
|
||||
} else if (ch==CH_D1 && instru.tri_d1_as_5v_en==1) {
|
||||
if(channel->v_early) {
|
||||
chan_en[CH_D1] = 0;
|
||||
chan_en[9] = 0;
|
||||
} else {
|
||||
chan_en[CH_D1] = 0;
|
||||
chan_en[9] = 1;
|
||||
}
|
||||
} else {
|
||||
chan_en[ch] = channel->v_early;
|
||||
}
|
||||
|
||||
if (channel->v_scan_rate >= channel->t_early) {
|
||||
channel->v_scan_rate -= channel->t_early; //To get right time
|
||||
channel->t_early_period = false;
|
||||
channel->t_mid_period = true;
|
||||
channel->v_scan_rate = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (channel->t_mid_period) {
|
||||
if (channel->v_scan_rate >= channel->t_period) {
|
||||
channel->v_scan_rate -= channel->t_period; //To get right time
|
||||
channel->cycle--;
|
||||
if (channel->cycle == 0) {
|
||||
channel->t_mid_period = false;
|
||||
channel->t_late_period = true;
|
||||
channel->v_scan_rate = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m = channel->v_scan_rate ? (channel->v_scan_rate % channel->t_period) : 0;
|
||||
|
||||
for(int i=0; i<4; i++) {
|
||||
if (m < channel->t_part[i]) {
|
||||
if (ch == CH_D0 && instru.tri_d0_as_5v_en==1) {
|
||||
if(channel->v_mid & (1 << i)) {
|
||||
chan_en[CH_D0] = 0;
|
||||
chan_en[8] = 0;
|
||||
} else {
|
||||
chan_en[CH_D0] = 0;
|
||||
chan_en[8] = 1;
|
||||
}
|
||||
} else if (ch == CH_D1 && instru.tri_d1_as_5v_en==1) {
|
||||
if(channel->v_mid & (1 << i)) {
|
||||
chan_en[CH_D1] = 0;
|
||||
chan_en[9] = 0;
|
||||
} else {
|
||||
chan_en[CH_D1] = 0;
|
||||
chan_en[9] = 1;
|
||||
}
|
||||
} else {
|
||||
chan_en[ch] = channel->v_mid & (1 << i);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (channel->t_late_period) {
|
||||
if (ch==CH_D0 && instru.tri_d0_as_5v_en==1) {
|
||||
if(channel->v_late) {
|
||||
chan_en[CH_D0] = 0;
|
||||
chan_en[8] = 0;
|
||||
} else {
|
||||
chan_en[CH_D0] = 0;
|
||||
chan_en[8] = 1;
|
||||
}
|
||||
} else if (ch==CH_D1 && instru.tri_d1_as_5v_en==1) {
|
||||
if(channel->v_late) {
|
||||
chan_en[CH_D1] = 0;
|
||||
chan_en[9] = 0;
|
||||
} else {
|
||||
chan_en[CH_D1] = 0;
|
||||
chan_en[9] = 1;
|
||||
}
|
||||
} else {
|
||||
chan_en[ch] = channel->v_late;
|
||||
}
|
||||
|
||||
if (channel->v_scan_rate >= channel->t_late) {
|
||||
channel->v_scan_rate -= channel->t_late; //To get right time
|
||||
channel->used = false;
|
||||
if (ch==CH_D0 && instru.tri_d0_as_5v_en==1) { //ending
|
||||
chan_en[CH_D0] = 0;
|
||||
chan_en[8] = 1;
|
||||
} else if (ch==CH_D1 && instru.tri_d1_as_5v_en==1) {
|
||||
chan_en[CH_D1] = 0;
|
||||
chan_en[9] = 1;
|
||||
} else {
|
||||
chan_en[ch] = 0;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void all_output_ctrl_mode_vsan(uint32_t delta_t)
|
||||
{
|
||||
struct mode_all_out_ctrl_ctx_t *mode = (struct mode_all_out_ctrl_ctx_t *)wm_get();
|
||||
struct ch_all_out_ctrl_ctx_t *ch;
|
||||
|
||||
for(int i=CH_PR0; i<=CH_PR1; i++) {
|
||||
ch = &mode->channel[i];
|
||||
__all_output_ctrl_mode_ch_vsan(ch, delta_t, i);
|
||||
}
|
||||
|
||||
if (mode->channel[CH_PR0].used == false &&
|
||||
mode->channel[CH_D0].used == false &&
|
||||
mode->channel[CH_A0].used == false &&
|
||||
mode->channel[CH_A2].used == false &&
|
||||
mode->channel[CH_A3].used == false &&
|
||||
mode->channel[CH_A1].used == false &&
|
||||
mode->channel[CH_D1].used == false &&
|
||||
mode->channel[CH_PR1].used == false)
|
||||
PeriodicEvent = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int all_output_ctrl_mode_create(void)
|
||||
{
|
||||
struct mode_all_out_ctrl_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
if (*wm)
|
||||
return -1;
|
||||
|
||||
p = malloc(sizeof(struct mode_all_out_ctrl_ctx_t));
|
||||
|
||||
if (!p)
|
||||
return -2;
|
||||
|
||||
struct ch_all_out_ctrl_ctx_t *ch;
|
||||
for (int i=CH_D0; i<=CH_D1; i++) {
|
||||
ch = &p->channel[i];
|
||||
ch->used = false;
|
||||
}
|
||||
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __all_output_ctrl_mode_channel_init(uint8_t *ins)
|
||||
{
|
||||
struct mode_all_out_ctrl_ctx_t *mode = (struct mode_all_out_ctrl_ctx_t *)wm_get();
|
||||
struct ch_all_out_ctrl_ctx_t *ch;
|
||||
uint8_t channel = ins[3];
|
||||
uint8_t para_sequence = ins[4];
|
||||
ch = &mode->channel[channel];
|
||||
|
||||
if (para_sequence == 1) {
|
||||
ch->used = (ins[5] & 1<<0);
|
||||
ch->v_early = (ins[5] & 1<<1) >> 1;
|
||||
ch->v_late = (ins[5] & 1<<2) >> 2;
|
||||
ch->v_mid = ins[6]; // |rsvd|v3|v2|v1|v0|
|
||||
ch->cycle = (uint16_t)ins[7] << 8 | (uint16_t)ins[8];
|
||||
ch->t_early = (uint32_t)ins[9] << 24 | (uint32_t)ins[10] << 16 | (uint32_t)ins[11] << 8 | (uint32_t)ins[12]; // 1ms->0.1ms
|
||||
ch->t_early *=10;
|
||||
ch->t_late = (uint32_t)ins[13] << 24 | (uint32_t)ins[14] << 16 | (uint32_t)ins[15] << 8 | (uint32_t)ins[16];
|
||||
ch->t_late *=10;
|
||||
|
||||
} else if (para_sequence == 2) {
|
||||
ch->t_mid[0] = (uint32_t)ins[5] << 24 | (uint32_t)ins[6] << 16 | (uint32_t)ins[7] << 8 | (uint32_t)ins[8];
|
||||
ch->t_mid[0] *= 10;
|
||||
ch->t_mid[1] = (uint32_t)ins[9] << 24 | (uint32_t)ins[10] << 16 | (uint32_t)ins[11] << 8 | (uint32_t)ins[12];
|
||||
ch->t_mid[1] *= 10;
|
||||
|
||||
} else if (para_sequence == 3) {
|
||||
ch->t_mid[2] = (uint32_t)ins[5] << 24 | (uint32_t)ins[6] << 16 | (uint32_t)ins[7] << 8 | (uint32_t)ins[8];
|
||||
ch->t_mid[2] *= 10;
|
||||
ch->t_mid[3] = (uint32_t)ins[9] << 24 | (uint32_t)ins[10] << 16 | (uint32_t)ins[11] << 8 | (uint32_t)ins[12];
|
||||
ch->t_mid[3] *= 10;
|
||||
ch->t_period = 0;
|
||||
for (int i=0; i<4; i++) {
|
||||
ch->t_period += ch->t_mid[i];
|
||||
ch->t_part[i] = ch->t_period;
|
||||
}
|
||||
|
||||
if (ch->used == true)
|
||||
ch->init = true;
|
||||
else
|
||||
ch->init = false;
|
||||
|
||||
ch->t_early_period = true;
|
||||
ch->t_mid_period = false;
|
||||
ch->t_late_period = false;
|
||||
|
||||
} else if (para_sequence == 4) {
|
||||
if (channel==CH_D0) {
|
||||
instru.tri_d0_as_5v_en = ins[5];
|
||||
} else if (channel==CH_D1) {
|
||||
instru.tri_d1_as_5v_en = ins[5];
|
||||
} else if (channel==CH_A0) {
|
||||
instru.Trig_CurCon[0] = (uint16_t)ins[5] << 8 | (uint16_t)ins[6]; //5000=20mA
|
||||
} else if (channel==CH_A1) {
|
||||
instru.Trig_CurCon[1] = (uint16_t)ins[5] << 8 | (uint16_t)ins[6];
|
||||
} else if (channel==CH_A2) {
|
||||
instru.Trig_CurCon[2] = (uint16_t)ins[5] << 8 | (uint16_t)ins[6];
|
||||
} else if (channel==CH_A3) {
|
||||
instru.Trig_CurCon[3] = (uint16_t)ins[5] << 8 | (uint16_t)ins[6];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void handle_all_output_mode_instru(uint8_t *recv_instru, struct elite_instru_t *instruction)
|
||||
{
|
||||
uint8_t *ins = recv_instru;
|
||||
uint8_t ch = ins[3];
|
||||
|
||||
switch (ch) {
|
||||
case 0xFF:
|
||||
instru.elite_mode = MODE_ALL_OUTPUT_CTRL;
|
||||
all_output_ctrl_mode_create();
|
||||
break;
|
||||
|
||||
case CH_PR0:
|
||||
case CH_PR1:
|
||||
case CH_D0:
|
||||
case CH_D1:
|
||||
case CH_A0:
|
||||
case CH_A1:
|
||||
case CH_A2:
|
||||
case CH_A3:
|
||||
__all_output_ctrl_mode_channel_init(ins);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
instruction->notify_rate = 5000;
|
||||
|
||||
}
|
||||
|
||||
+684
-8388
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user