Update Elite TRIG01 pin

This commit is contained in:
Benny Liu
2021-02-08 14:17:22 +08:00
parent 916a8f5dc7
commit 8be3c30b23
4 changed files with 84 additions and 46 deletions
@@ -176,9 +176,9 @@ static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool hig
break;
}
}
PIN_setOutputValue(&ZM_rst, latch_num, 1); // Turn on latch
latch_setOutputValue(latch_num, 1); // Turn on latch
// CPUdelay(10);
PIN_setOutputValue(&ZM_rst, latch_num, 0); // Turn off latch
latch_setOutputValue(latch_num, 0); // Turn off latch
remove_elite_pin();
ELITE15_SPI_HOLD();
}
@@ -195,12 +195,10 @@ static void Init_Elite15_PIN () {
PIN_setOutputValue(pin_handle, D5, 0);
PIN_setOutputValue(pin_handle, D6, 0);
PIN_setOutputValue(pin_handle, D7, 0);
PIN_setOutputValue(pin_handle, LOAD0, 0);
PIN_setOutputValue(pin_handle, LOAD1, 1);
PIN_setOutputValue(pin_handle, LOAD2, 1);
latch_setOutputValue(LOAD1, 1);
latch_setOutputValue(LOAD2, 1);
CPUdelay(10);
PIN_setOutputValue(pin_handle, LOAD1, 0);
PIN_setOutputValue(pin_handle, LOAD2, 0);
latch_setOutputValue(LOAD2, 0);
PIN_setOutputValue(pin_handle, D0, 0);
@@ -212,8 +210,8 @@ static void Init_Elite15_PIN () {
PIN_setOutputValue(pin_handle, D6, 1);
PIN_setOutputValue(pin_handle, D7, 1);
CPUdelay(10);
PIN_setOutputValue(pin_handle, LOAD0, 1);
PIN_setOutputValue(pin_handle, LOAD0, 0);
latch_setOutputValue(LOAD0, 1);
latch_setOutputValue(LOAD0, 0);
remove_elite_pin();
@@ -240,7 +238,37 @@ static void Init_Elite15_PIN () {
// remove_elite_pin();
}
static void latch_setOutputValue (uint32_t latch_num, bool highlow) {
// decode latch value for Elite trigger board
if (highlow) {
switch (latch_num) {
case LOAD0: {
PIN_setOutputValue(pin_handle, LOADA, 0);
PIN_setOutputValue(pin_handle, LOADB, 0);
break:
}
case LOAD1: {
PIN_setOutputValue(pin_handle, LOADA, 1);
PIN_setOutputValue(pin_handle, LOADB, 0);
break:
}
case LOAD2: {
PIN_setOutputValue(pin_handle, LOADA, 0);
PIN_setOutputValue(pin_handle, LOADB, 1);
break:
}
default: {
PIN_setOutputValue(pin_handle, LOADA, 1);
PIN_setOutputValue(pin_handle, LOADB, 1);
break;
}
}
} else { // All latch turn off
PIN_setOutputValue(pin_handle, LOADA, 1);
PIN_setOutputValue(pin_handle, LOADB, 1);
}
}
#endif
@@ -96,17 +96,15 @@ static void DAC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
// PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
}
static void ELITE15_SPI_HOLD() {
static void ELITE15_SPI_HOLD() {
Elite_SPI_init();
PIN_setOutputValue(pin_handle, LOAD0, 1);
PIN_setOutputValue(pin_handle, LOAD1, 0);
PIN_setOutputValue(pin_handle, LOAD2, 0);
PIN_setOutputValue(pin_handle, LOADA, 0);
PIN_setOutputValue(pin_handle, LOADB, 0);
}
static void ELITE15_SPI_CLOSE() {
PIN_setOutputValue(pin_handle, LOAD0, 0);
PIN_setOutputValue(pin_handle, LOAD1, 0);
PIN_setOutputValue(pin_handle, LOAD2, 0);
PIN_setOutputValue(pin_handle, LOADA, 1);
PIN_setOutputValue(pin_handle, LOADB, 1);
SPI_close(spiHandle0);
SPI_close(spiHandle1);
@@ -26,28 +26,36 @@
#define D6 IOID_9
#define D7 IOID_10
#define LOAD0 IOID_13
#define LOAD1 IOID_12
#define LOAD2 IOID_11
#define FLT IOID_13
#define LOADB IOID_12
#define LOADA IOID_11
#define ADC_CS LOAD0, D6
#define DAC_CS LOAD0, D7
#define ADC_DAC_SPI_MOSI LOAD0, D3
#define ADC_DAC_SPI_CLK LOAD0, D2
#define TW_SCKI_2 LOAD0, D6
#define TW_SCKI_3 LOAD0, D7
#define ADC_SPI_MOSI LOAD0, D3
#define ADC_SPI_CLK LOAD0, D2
#define LED_MOSI LOAD0, D1
#define LED_CLK LOAD0, D0
#define MEM_HOLD LOAD0, D4
#define MEM_CS LOAD0, D5
#define TW_SCKI_0 LOAD0, D4
#define TW_SCKI_1 LOAD0, D5
#define Turnon_I_MID LOAD2, D0
#define Turnon_I_SMALL LOAD2, D4
#define Turnon_I_LARGE LOAD2, D1
#define Turnon_V_SMALL LOAD2, D2
#define Turnon_V_MID LOAD2, D3
#define Turon_VOUT_SMALL LOAD2, D7
#define BAT_CHAR LOAD1, D0
#define BAT_OK LOAD1, D1
#define PULLUP_3V_0 LOAD1, D2
#define PULLUP_3V_1 LOAD1, D3
#define shutdown_6994 LOAD1, D4
#define OUT_5V_EN_0 LOAD1, D5
#define enable_5v LOAD1, D6
#define OUT_5V_EN_1 LOAD1, D7
//#define Turnon10K Turnon_I_MID
//#define Turnon200R Turnon_I_LARGE
#define DO_MOS_0 LOAD2, D0
#define DO_MOS_1 LOAD2, D1
#define AO_MOS_0 LOAD2, D2
#define AO_MOS_1 LOAD2, D3
#define AO_MOS_2 LOAD2, D4
#define AO_MOS_3 LOAD2, D5
#define DO_PR_0 LOAD2, D6
#define DO_PR_1 LOAD2, D7
/* I2C */
#ifdef ELITE_VERSION_1_4
@@ -55,11 +63,7 @@
#define Board_I2C0_SDA0 PIN_UNASSIGNED
#endif
#define shutdown_6994 LOAD2, D6
#define switch_on IOID_14
#define HIGH_Z_MODE LOAD2, D5
#define enable_10v LOAD1, D5
#define enable_5v LOAD1, D6
PIN_Handle pin_handle;
static PIN_State ZM_rst;
@@ -69,14 +73,13 @@ const PIN_Config BLE_IO[] = {
// D1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// D2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// D3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
D4 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
D5 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
D6 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
D7 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// D4 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// D5 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// D6 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
// D7 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
LOAD0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
LOAD1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
LOAD2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
LOADA | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
LOADB | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
switch_on | PIN_INPUT_EN | PIN_PULLDOWN, // to sense switch
@@ -93,7 +96,14 @@ static void add_elite_pin() {
D2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
PIN_add(pin_handle,
D3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
PIN_add(pin_handle,
D4 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
PIN_add(pin_handle,
D5 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
PIN_add(pin_handle,
D6 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
PIN_add(pin_handle,
D7 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
// if(elite15_status != PIN_SUCCESS) {
// LED_color(DARKLED, 0x0F, 0x0F, 0x0F);
// }
@@ -585,7 +585,9 @@ static void headstage_battery_volt();
static void EliteADCBattery();
static void VinADCGainControl(uint8_t VinADCLevel);
static void VoutGainControl(uint8_t VOUTLevel);
static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow);
static void latch_setOutputValue (uint32_t latch_num, bool highlow);
static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow);
// Elite key detection & turn on/ shutdown function (peripheral hardware control)
static void Elite_led_color(uint16_t color);