66fc6c92f5
2. after powering on, the state of all four electrodes is highZ 3. an electrode only changes to the idle state after it has been used
968 lines
32 KiB
C
968 lines
32 KiB
C
#include "cpg11_dev_mode.h"
|
|
#include "tw1508.h"
|
|
|
|
#include "nrf_gpio.h"
|
|
#include "nrf_log.h"
|
|
|
|
#if (DEF_ELITE_MODEL == DEF_CURRENT_PULSE_GANERATOR_11)
|
|
|
|
// The GPIO corresponding to the pin
|
|
const uint32_t pin_to_gpio_table[] = {
|
|
[6] = NRF_GPIO_PIN_MAP(0, 22),
|
|
[8] = NRF_GPIO_PIN_MAP(0, 25),
|
|
[9] = NRF_GPIO_PIN_MAP(0, 19),
|
|
[10] = NRF_GPIO_PIN_MAP(0, 21),
|
|
[11] = NRF_GPIO_PIN_MAP(1, 0),
|
|
[12] = NRF_GPIO_PIN_MAP(0, 18),
|
|
[13] = NRF_GPIO_PIN_MAP(0, 17),
|
|
[14] = NRF_GPIO_PIN_MAP(0, 20),
|
|
[16] = NRF_GPIO_PIN_MAP(0, 14),
|
|
[17] = NRF_GPIO_PIN_MAP(0, 13),
|
|
[18] = NRF_GPIO_PIN_MAP(0, 11),
|
|
[20] = NRF_GPIO_PIN_MAP(0, 15),
|
|
[25] = NRF_GPIO_PIN_MAP(1, 8),
|
|
[26] = NRF_GPIO_PIN_MAP(0, 12),
|
|
[27] = NRF_GPIO_PIN_MAP(0, 7),
|
|
[28] = NRF_GPIO_PIN_MAP(1, 9),
|
|
[29] = NRF_GPIO_PIN_MAP(0, 8),
|
|
[30] = NRF_GPIO_PIN_MAP(0, 6),
|
|
[31] = NRF_GPIO_PIN_MAP(0, 5),
|
|
[32] = NRF_GPIO_PIN_MAP(0, 27),
|
|
[33] = NRF_GPIO_PIN_MAP(0, 26),
|
|
[34] = NRF_GPIO_PIN_MAP(0, 4),
|
|
[36] = NRF_GPIO_PIN_MAP(0, 1),
|
|
[37] = NRF_GPIO_PIN_MAP(0, 29),
|
|
[38] = NRF_GPIO_PIN_MAP(0, 0),
|
|
[39] = NRF_GPIO_PIN_MAP(0, 31),
|
|
[40] = NRF_GPIO_PIN_MAP(1, 15),
|
|
[41] = NRF_GPIO_PIN_MAP(0, 2),
|
|
[42] = NRF_GPIO_PIN_MAP(0, 30),
|
|
[43] = NRF_GPIO_PIN_MAP(0, 28),
|
|
[44] = NRF_GPIO_PIN_MAP(1, 12),
|
|
[45] = NRF_GPIO_PIN_MAP(1, 14),
|
|
[46] = NRF_GPIO_PIN_MAP(0, 3),
|
|
[47] = NRF_GPIO_PIN_MAP(1, 13),
|
|
[48] = NRF_GPIO_PIN_MAP(1, 3),
|
|
[49] = NRF_GPIO_PIN_MAP(1, 10),
|
|
[50] = NRF_GPIO_PIN_MAP(1, 6),
|
|
[51] = NRF_GPIO_PIN_MAP(1, 11),
|
|
[52] = NRF_GPIO_PIN_MAP(0, 10),
|
|
[53] = NRF_GPIO_PIN_MAP(0, 9),
|
|
[59] = NRF_GPIO_PIN_MAP(1, 2),
|
|
[60] = NRF_GPIO_PIN_MAP(0, 24),
|
|
[61] = NRF_GPIO_PIN_MAP(0, 23),
|
|
[62] = NRF_GPIO_PIN_MAP(0, 16),
|
|
};
|
|
|
|
#define PULSE_GEN_A_NUMB 2
|
|
#define PULSE_GEN_B_NUMB 2
|
|
static pusle_gen_t p_pusle_genA[PULSE_GEN_A_NUMB];
|
|
static pusle_gen_t p_pusle_genB[PULSE_GEN_B_NUMB];
|
|
static pusle_gen_t pusle_gen[PULSE_GEN_A_NUMB+PULSE_GEN_B_NUMB];
|
|
|
|
static uint32_t bmd380pins_convert_to_gpio(uint32_t pin)
|
|
{
|
|
uint32_t gpio;
|
|
|
|
switch (pin)
|
|
{
|
|
case 6:
|
|
case 8:
|
|
case 9:
|
|
case 10:
|
|
case 11:
|
|
case 12:
|
|
case 13:
|
|
case 14:
|
|
case 16:
|
|
case 17:
|
|
case 18:
|
|
case 20:
|
|
case 25:
|
|
case 26:
|
|
case 27:
|
|
case 28:
|
|
case 29:
|
|
case 30:
|
|
case 31:
|
|
case 32:
|
|
case 33:
|
|
case 34:
|
|
case 36:
|
|
case 37:
|
|
case 38:
|
|
case 39:
|
|
case 40:
|
|
case 41:
|
|
case 42:
|
|
case 43:
|
|
case 44:
|
|
case 45:
|
|
case 46:
|
|
case 47:
|
|
case 48:
|
|
case 49:
|
|
case 50:
|
|
case 51:
|
|
case 52:
|
|
case 53:
|
|
case 59:
|
|
case 60:
|
|
case 61:
|
|
case 62:
|
|
gpio = pin_to_gpio_table[pin];
|
|
break;
|
|
default:
|
|
gpio = UNDEF_GPIO;
|
|
NRF_LOG_INFO("UNDEF_GPIO: pin number %02d can't convert to gpio number", pin);
|
|
break;
|
|
}
|
|
|
|
return gpio;
|
|
}
|
|
|
|
static void set_bmd380_pin_signal(uint32_t pin, uint32_t high_low)
|
|
{
|
|
uint32_t gpio = bmd380pins_convert_to_gpio(pin);
|
|
|
|
if (gpio != UNDEF_GPIO)
|
|
{
|
|
nrf_gpio_pin_write(gpio, high_low);
|
|
NRF_LOG_INFO("set pin number %02d (gpio %02d) = %d", pin, gpio, high_low);
|
|
}
|
|
}
|
|
|
|
#define ELECTRODE_A1B1_IDLE 0x09
|
|
#define ELECTRODE_A2B2_IDLE 0x0A
|
|
#define ELECTRODE_A3B3_IDLE 0x0B
|
|
#define ELECTRODE_A4B4_IDLE 0x0C
|
|
#define ELECTRODE_ALL_HIGHZ 0x0D
|
|
#define ELECTRODE_E1P_ENABLE 0x0E
|
|
#define ELECTRODE_E1P_DISABLE 0x0F
|
|
#define ELECTRODE_E1N_ENABLE 0x10
|
|
#define ELECTRODE_E1N_DISABLE 0x11
|
|
#define ELECTRODE_E2P_ENABLE 0x12
|
|
#define ELECTRODE_E2P_DISABLE 0x13
|
|
#define ELECTRODE_E2N_ENABLE 0x14
|
|
#define ELECTRODE_E2N_DISABLE 0x15
|
|
#define ELECTRODE_E3P_ENABLE 0x16
|
|
#define ELECTRODE_E3P_DISABLE 0x17
|
|
#define ELECTRODE_E3N_ENABLE 0x18
|
|
#define ELECTRODE_E3N_DISABLE 0x19
|
|
#define ELECTRODE_E4P_ENABLE 0x1A
|
|
#define ELECTRODE_E4P_DISABLE 0x1B
|
|
#define ELECTRODE_E4N_ENABLE 0x1C
|
|
#define ELECTRODE_E4N_DISABLE 0x1D
|
|
static void cpg11_electrodes(uint32_t electrodes_mode)
|
|
{
|
|
switch (electrodes_mode)
|
|
{
|
|
case ELECTRODE_A1B1_IDLE:
|
|
NRF_LOG_INFO("ELECTRODE_A1B1_IDLE()");
|
|
nrf_gpio_pin_write(VB1L_PIN, 0);
|
|
nrf_gpio_pin_write(VB1H_PIN, 1);
|
|
nrf_gpio_pin_write(VA1L_PIN, 0);
|
|
nrf_gpio_pin_write(VA1H_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_A2B2_IDLE:
|
|
NRF_LOG_INFO("ELECTRODE_A2B2_IDLE()");
|
|
nrf_gpio_pin_write(VB2L_PIN, 0);
|
|
nrf_gpio_pin_write(VB2H_PIN, 1);
|
|
nrf_gpio_pin_write(VA2L_PIN, 0);
|
|
nrf_gpio_pin_write(VA2H_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_A3B3_IDLE:
|
|
NRF_LOG_INFO("ELECTRODE_A3B3_IDLE()");
|
|
nrf_gpio_pin_write(VB3L_PIN, 0);
|
|
nrf_gpio_pin_write(VB3H_PIN, 1);
|
|
nrf_gpio_pin_write(VA3L_PIN, 0);
|
|
nrf_gpio_pin_write(VA3H_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_A4B4_IDLE:
|
|
NRF_LOG_INFO("ELECTRODE_A4B4_IDLE()");
|
|
nrf_gpio_pin_write(VB4L_PIN, 0);
|
|
nrf_gpio_pin_write(VB4H_PIN, 1);
|
|
nrf_gpio_pin_write(VA4L_PIN, 0);
|
|
nrf_gpio_pin_write(VA4H_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_ALL_HIGHZ:
|
|
NRF_LOG_INFO("ELECTRODE_ALL_HIGHZ()");
|
|
nrf_gpio_pin_write(VB1L_PIN, 0);
|
|
nrf_gpio_pin_write(VB1H_PIN, 0);
|
|
nrf_gpio_pin_write(VA1L_PIN, 0);
|
|
nrf_gpio_pin_write(VA1H_PIN, 0);
|
|
|
|
nrf_gpio_pin_write(VB2L_PIN, 0);
|
|
nrf_gpio_pin_write(VB2H_PIN, 0);
|
|
nrf_gpio_pin_write(VA2L_PIN, 0);
|
|
nrf_gpio_pin_write(VA2H_PIN, 0);
|
|
|
|
nrf_gpio_pin_write(VB3L_PIN, 0);
|
|
nrf_gpio_pin_write(VB3H_PIN, 0);
|
|
nrf_gpio_pin_write(VA3L_PIN, 0);
|
|
nrf_gpio_pin_write(VA3H_PIN, 0);
|
|
|
|
nrf_gpio_pin_write(VB4L_PIN, 0);
|
|
nrf_gpio_pin_write(VB4H_PIN, 0);
|
|
nrf_gpio_pin_write(VA4L_PIN, 0);
|
|
nrf_gpio_pin_write(VA4H_PIN, 0);
|
|
break;
|
|
|
|
case ELECTRODE_E1P_ENABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E1P_ENABLE()");
|
|
nrf_gpio_pin_write(VB1H_PIN, 0);
|
|
nrf_gpio_pin_write(VB1L_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_E1P_DISABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E1P_DISABLE()");
|
|
nrf_gpio_pin_write(VB1L_PIN, 0);
|
|
nrf_gpio_pin_write(VB1H_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_E1N_ENABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E1N_ENABLE()");
|
|
nrf_gpio_pin_write(VA1H_PIN, 0);
|
|
nrf_gpio_pin_write(VA1L_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_E1N_DISABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E1N_DISABLE()");
|
|
nrf_gpio_pin_write(VA1L_PIN, 0);
|
|
nrf_gpio_pin_write(VA1H_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_E2P_ENABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E2P_ENABLE()");
|
|
nrf_gpio_pin_write(VB2H_PIN, 0);
|
|
nrf_gpio_pin_write(VB2L_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_E2P_DISABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E2P_DISABLE()");
|
|
nrf_gpio_pin_write(VB2L_PIN, 0);
|
|
nrf_gpio_pin_write(VB2H_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_E2N_ENABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E2N_ENABLE()");
|
|
nrf_gpio_pin_write(VA2H_PIN, 0);
|
|
nrf_gpio_pin_write(VA2L_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_E2N_DISABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E2N_DISABLE()");
|
|
nrf_gpio_pin_write(VA2L_PIN, 0);
|
|
nrf_gpio_pin_write(VA2H_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_E3P_ENABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E3P_ENABLE()");
|
|
nrf_gpio_pin_write(VB3H_PIN, 0);
|
|
nrf_gpio_pin_write(VB3L_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_E3P_DISABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E3P_DISABLE()");
|
|
nrf_gpio_pin_write(VB3L_PIN, 0);
|
|
nrf_gpio_pin_write(VB3H_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_E3N_ENABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E3N_ENABLE()");
|
|
nrf_gpio_pin_write(VA3H_PIN, 0);
|
|
nrf_gpio_pin_write(VA3L_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_E3N_DISABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E3N_DISABLE()");
|
|
nrf_gpio_pin_write(VA3L_PIN, 0);
|
|
nrf_gpio_pin_write(VA3H_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_E4P_ENABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E4P_ENABLE()");
|
|
nrf_gpio_pin_write(VB4H_PIN, 0);
|
|
nrf_gpio_pin_write(VB4L_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_E4P_DISABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E4P_DISABLE()");
|
|
nrf_gpio_pin_write(VB4L_PIN, 0);
|
|
nrf_gpio_pin_write(VB4H_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_E4N_ENABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E4N_ENABLE()");
|
|
nrf_gpio_pin_write(VA4H_PIN, 0);
|
|
nrf_gpio_pin_write(VA4L_PIN, 1);
|
|
break;
|
|
|
|
case ELECTRODE_E4N_DISABLE:
|
|
NRF_LOG_INFO("ELECTRODE_E4N_DISABLE()");
|
|
nrf_gpio_pin_write(VA4L_PIN, 0);
|
|
nrf_gpio_pin_write(VA4H_PIN, 1);
|
|
break;
|
|
}
|
|
}
|
|
|
|
static void set_cpg_pulse_parameter(uint8_t *ins)
|
|
{
|
|
NRF_LOG_INFO("%s", __FUNCTION__);
|
|
uint8_t electrodes1_pulse_gen_sel = (ins[5] & 0b10000000) >> 7;
|
|
uint8_t electrodes2_pulse_gen_sel = (ins[5] & 0b01000000) >> 6;
|
|
uint8_t electrodes3_pulse_gen_sel = (ins[5] & 0b00100000) >> 5;
|
|
uint8_t electrodes4_pulse_gen_sel = (ins[5] & 0b00010000) >> 4;
|
|
uint32_t pulse_width_us = (uint32_t)ins[6] << 24 | (uint32_t)ins[7] << 16 | (uint32_t)ins[8] << 8 | (uint32_t)ins[9];
|
|
uint32_t freq_hz = (uint32_t)ins[10] << 24 | (uint32_t)ins[11] << 16 | (uint32_t)ins[12] << 8 | (uint32_t)ins[13];
|
|
|
|
if (electrodes1_pulse_gen_sel) {
|
|
pusle_gen[0] = (pusle_gen_t) {
|
|
.VBxH = VB1H_PIN,
|
|
.VBxL = VB1L_PIN,
|
|
.VAxH = VA1H_PIN,
|
|
.VAxL = VA1L_PIN,
|
|
.point_us[0] = 1,
|
|
.point_us[1] = pulse_width_us,
|
|
.point_us[2] = 1,
|
|
.point_us[3] = 0,
|
|
.point_us[4] = 1,
|
|
.point_us[5] = pulse_width_us,
|
|
.point_us[6] = 1,
|
|
.idle_us = 0,
|
|
.pulse_cnt = UINT32_MAX,
|
|
.pulse_id = PULSE_ID_NULL,
|
|
};
|
|
pusle_gen[0].idle_us = (1000000 / freq_hz) - (pusle_gen[0].point_us[0] +
|
|
pusle_gen[0].point_us[1] +
|
|
pusle_gen[0].point_us[2] +
|
|
pusle_gen[0].point_us[3] +
|
|
pusle_gen[0].point_us[4] +
|
|
pusle_gen[0].point_us[5] +
|
|
pusle_gen[0].point_us[6]);
|
|
NRF_LOG_INFO("[%d]a = %d us", 1, pusle_gen[0].point_us[0]);
|
|
NRF_LOG_INFO("[%d]b = %d us", 1, pusle_gen[0].point_us[1]);
|
|
NRF_LOG_INFO("[%d]c = %d us", 1, pusle_gen[0].point_us[2]);
|
|
NRF_LOG_INFO("[%d]d = %d us", 1, pusle_gen[0].point_us[3]);
|
|
NRF_LOG_INFO("[%d]e = %d us", 1, pusle_gen[0].point_us[4]);
|
|
NRF_LOG_INFO("[%d]f = %d us", 1, pusle_gen[0].point_us[5]);
|
|
NRF_LOG_INFO("[%d]g = %d us", 1, pusle_gen[0].point_us[6]);
|
|
NRF_LOG_INFO("[%d]idle = %d us", 1, pusle_gen[0].idle_us);
|
|
}
|
|
|
|
if (electrodes2_pulse_gen_sel) {
|
|
pusle_gen[1] = (pusle_gen_t) {
|
|
.VBxH = VB2H_PIN,
|
|
.VBxL = VB2L_PIN,
|
|
.VAxH = VA2H_PIN,
|
|
.VAxL = VA2L_PIN,
|
|
.point_us[0] = 1,
|
|
.point_us[1] = pulse_width_us,
|
|
.point_us[2] = 1,
|
|
.point_us[3] = 0,
|
|
.point_us[4] = 1,
|
|
.point_us[5] = pulse_width_us,
|
|
.point_us[6] = 1,
|
|
.idle_us = 0,
|
|
.pulse_cnt = UINT32_MAX,
|
|
.pulse_id = PULSE_ID_NULL,
|
|
};
|
|
|
|
pusle_gen[1].idle_us = (1000000 / freq_hz) - (pusle_gen[1].point_us[0] +
|
|
pusle_gen[1].point_us[1] +
|
|
pusle_gen[1].point_us[2] +
|
|
pusle_gen[1].point_us[3] +
|
|
pusle_gen[1].point_us[4] +
|
|
pusle_gen[1].point_us[5] +
|
|
pusle_gen[1].point_us[6]);
|
|
NRF_LOG_INFO("[%d]a = %d us", 2, pusle_gen[1].point_us[0]);
|
|
NRF_LOG_INFO("[%d]b = %d us", 2, pusle_gen[1].point_us[1]);
|
|
NRF_LOG_INFO("[%d]c = %d us", 2, pusle_gen[1].point_us[2]);
|
|
NRF_LOG_INFO("[%d]d = %d us", 2, pusle_gen[1].point_us[3]);
|
|
NRF_LOG_INFO("[%d]e = %d us", 2, pusle_gen[1].point_us[4]);
|
|
NRF_LOG_INFO("[%d]f = %d us", 2, pusle_gen[1].point_us[5]);
|
|
NRF_LOG_INFO("[%d]g = %d us", 2, pusle_gen[1].point_us[6]);
|
|
NRF_LOG_INFO("[%d]idle = %d us", 2, pusle_gen[1].idle_us);
|
|
}
|
|
|
|
if (electrodes3_pulse_gen_sel) {
|
|
pusle_gen[2] = (pusle_gen_t) {
|
|
.VBxH = VB3H_PIN,
|
|
.VBxL = VB3L_PIN,
|
|
.VAxH = VA3H_PIN,
|
|
.VAxL = VA3L_PIN,
|
|
.point_us[0] = 1,
|
|
.point_us[1] = pulse_width_us,
|
|
.point_us[2] = 1,
|
|
.point_us[3] = 0,
|
|
.point_us[4] = 1,
|
|
.point_us[5] = pulse_width_us,
|
|
.point_us[6] = 1,
|
|
.idle_us = 0,
|
|
.pulse_cnt = UINT32_MAX,
|
|
.pulse_id = PULSE_ID_NULL,
|
|
};
|
|
pusle_gen[2].idle_us = (1000000 / freq_hz) - (pusle_gen[2].point_us[0] +
|
|
pusle_gen[2].point_us[1] +
|
|
pusle_gen[2].point_us[2] +
|
|
pusle_gen[2].point_us[3] +
|
|
pusle_gen[2].point_us[4] +
|
|
pusle_gen[2].point_us[5] +
|
|
pusle_gen[2].point_us[6]);
|
|
NRF_LOG_INFO("[%d]a = %d us", 3, pusle_gen[2].point_us[0]);
|
|
NRF_LOG_INFO("[%d]b = %d us", 3, pusle_gen[2].point_us[1]);
|
|
NRF_LOG_INFO("[%d]c = %d us", 3, pusle_gen[2].point_us[2]);
|
|
NRF_LOG_INFO("[%d]d = %d us", 3, pusle_gen[2].point_us[3]);
|
|
NRF_LOG_INFO("[%d]e = %d us", 3, pusle_gen[2].point_us[4]);
|
|
NRF_LOG_INFO("[%d]f = %d us", 3, pusle_gen[2].point_us[5]);
|
|
NRF_LOG_INFO("[%d]g = %d us", 3, pusle_gen[2].point_us[6]);
|
|
NRF_LOG_INFO("[%d]idle = %d us", 3, pusle_gen[2].idle_us);
|
|
}
|
|
|
|
if (electrodes4_pulse_gen_sel) {
|
|
pusle_gen[3] = (pusle_gen_t) {
|
|
.VBxH = VB4H_PIN,
|
|
.VBxL = VB4L_PIN,
|
|
.VAxH = VA4H_PIN,
|
|
.VAxL = VA4L_PIN,
|
|
.point_us[0] = 1,
|
|
.point_us[1] = pulse_width_us,
|
|
.point_us[2] = 1,
|
|
.point_us[3] = 0,
|
|
.point_us[4] = 1,
|
|
.point_us[5] = pulse_width_us,
|
|
.point_us[6] = 1,
|
|
.idle_us = 0,
|
|
.pulse_cnt = UINT32_MAX,
|
|
.pulse_id = PULSE_ID_NULL,
|
|
};
|
|
pusle_gen[3].idle_us = (1000000 / freq_hz) - (pusle_gen[3].point_us[0] +
|
|
pusle_gen[3].point_us[1] +
|
|
pusle_gen[3].point_us[2] +
|
|
pusle_gen[3].point_us[3] +
|
|
pusle_gen[3].point_us[4] +
|
|
pusle_gen[3].point_us[5] +
|
|
pusle_gen[3].point_us[6]);
|
|
NRF_LOG_INFO("[%d]a = %d us", 4, pusle_gen[3].point_us[0]);
|
|
NRF_LOG_INFO("[%d]b = %d us", 4, pusle_gen[3].point_us[1]);
|
|
NRF_LOG_INFO("[%d]c = %d us", 4, pusle_gen[3].point_us[2]);
|
|
NRF_LOG_INFO("[%d]d = %d us", 4, pusle_gen[3].point_us[3]);
|
|
NRF_LOG_INFO("[%d]e = %d us", 4, pusle_gen[3].point_us[4]);
|
|
NRF_LOG_INFO("[%d]f = %d us", 4, pusle_gen[3].point_us[5]);
|
|
NRF_LOG_INFO("[%d]g = %d us", 4, pusle_gen[3].point_us[6]);
|
|
NRF_LOG_INFO("[%d]idle = %d us", 4, pusle_gen[3].idle_us);
|
|
}
|
|
|
|
NRF_LOG_INFO("set ok......");
|
|
|
|
}
|
|
|
|
static void start_which_electrodes(uint8_t *ins)
|
|
{
|
|
NRF_LOG_INFO("%s", __FUNCTION__);
|
|
uint8_t electrodes1_pulse_gen_en = (ins[5] & 0b10000000) >> 7;
|
|
uint8_t electrodes2_pulse_gen_en = (ins[5] & 0b01000000) >> 6;
|
|
uint8_t electrodes3_pulse_gen_en = (ins[5] & 0b00100000) >> 5;
|
|
uint8_t electrodes4_pulse_gen_en = (ins[5] & 0b00010000) >> 4;
|
|
uint32_t inum=0;
|
|
|
|
if (electrodes1_pulse_gen_en)
|
|
{
|
|
p_pusle_genA[0] = pusle_gen[0];
|
|
p_pusle_genA[0].pulse_id = PULSE_ID_A;
|
|
inum=0;
|
|
nrf_gpio_pin_clear(p_pusle_genA[inum].VBxL);
|
|
nrf_gpio_pin_set(p_pusle_genA[inum].VBxH);
|
|
nrf_gpio_pin_clear(p_pusle_genA[inum].VAxL);
|
|
nrf_gpio_pin_set(p_pusle_genA[inum].VAxH);
|
|
NRF_LOG_INFO("p_pusle_genA[%d].VBxL=%d", inum, p_pusle_genA[inum].VBxL);
|
|
NRF_LOG_INFO("p_pusle_genA[%d].VBxH=%d", inum, p_pusle_genA[inum].VBxH);
|
|
NRF_LOG_INFO("p_pusle_genA[%d].VAxL=%d", inum, p_pusle_genA[inum].VAxL);
|
|
NRF_LOG_INFO("p_pusle_genA[%d].VAxH=%d", inum, p_pusle_genA[inum].VAxH);
|
|
|
|
NRF_LOG_INFO("start electrodes1_pulse_gen");
|
|
}
|
|
|
|
if (electrodes2_pulse_gen_en)
|
|
{
|
|
p_pusle_genA[1] = pusle_gen[1];
|
|
p_pusle_genA[1].pulse_id = PULSE_ID_B;
|
|
inum=1;
|
|
nrf_gpio_pin_clear(p_pusle_genA[inum].VBxL);
|
|
nrf_gpio_pin_set(p_pusle_genA[inum].VBxH);
|
|
nrf_gpio_pin_clear(p_pusle_genA[inum].VAxL);
|
|
nrf_gpio_pin_set(p_pusle_genA[inum].VAxH);
|
|
NRF_LOG_INFO("p_pusle_genA[%d].VBxL=%d", inum, p_pusle_genA[inum].VBxL);
|
|
NRF_LOG_INFO("p_pusle_genA[%d].VBxH=%d", inum, p_pusle_genA[inum].VBxH);
|
|
NRF_LOG_INFO("p_pusle_genA[%d].VAxL=%d", inum, p_pusle_genA[inum].VAxL);
|
|
NRF_LOG_INFO("p_pusle_genA[%d].VAxH=%d", inum, p_pusle_genA[inum].VAxH);
|
|
|
|
NRF_LOG_INFO("start electrodes2_pulse_gen");
|
|
}
|
|
|
|
if (electrodes1_pulse_gen_en || electrodes2_pulse_gen_en) {
|
|
cpg11_pulse_init(0, &p_pusle_genA[0], 2);
|
|
cpg11_pulse_start(0, &p_pusle_genA[0]);
|
|
}
|
|
|
|
if (electrodes3_pulse_gen_en)
|
|
{
|
|
p_pusle_genB[0] = pusle_gen[2];
|
|
p_pusle_genB[0].pulse_id = PULSE_ID_C;
|
|
inum=0;
|
|
nrf_gpio_pin_clear(p_pusle_genB[inum].VBxL);
|
|
nrf_gpio_pin_set(p_pusle_genB[inum].VBxH);
|
|
nrf_gpio_pin_clear(p_pusle_genB[inum].VAxL);
|
|
nrf_gpio_pin_set(p_pusle_genB[inum].VAxH);
|
|
NRF_LOG_INFO("p_pusle_genB[%d].VBxL=%d", inum, p_pusle_genB[inum].VBxL);
|
|
NRF_LOG_INFO("p_pusle_genB[%d].VBxH=%d", inum, p_pusle_genB[inum].VBxH);
|
|
NRF_LOG_INFO("p_pusle_genB[%d].VAxL=%d", inum, p_pusle_genB[inum].VAxL);
|
|
NRF_LOG_INFO("p_pusle_genB[%d].VAxH=%d", inum, p_pusle_genB[inum].VAxH);
|
|
|
|
NRF_LOG_INFO("start electrodes3_pulse_gen");
|
|
}
|
|
|
|
if (electrodes4_pulse_gen_en)
|
|
{
|
|
p_pusle_genB[1] = pusle_gen[3];
|
|
p_pusle_genB[1].pulse_id = PULSE_ID_D;
|
|
inum=1;
|
|
nrf_gpio_pin_clear(p_pusle_genB[inum].VBxL);
|
|
nrf_gpio_pin_set(p_pusle_genB[inum].VBxH);
|
|
nrf_gpio_pin_clear(p_pusle_genB[inum].VAxL);
|
|
nrf_gpio_pin_set(p_pusle_genB[inum].VAxH);
|
|
NRF_LOG_INFO("p_pusle_genB[%d].VBxL=%d", inum, p_pusle_genB[inum].VBxL);
|
|
NRF_LOG_INFO("p_pusle_genB[%d].VBxH=%d", inum, p_pusle_genB[inum].VBxH);
|
|
NRF_LOG_INFO("p_pusle_genB[%d].VAxL=%d", inum, p_pusle_genB[inum].VAxL);
|
|
NRF_LOG_INFO("p_pusle_genB[%d].VAxH=%d", inum, p_pusle_genB[inum].VAxH);
|
|
|
|
NRF_LOG_INFO("start electrodes4_pulse_gen");
|
|
}
|
|
|
|
if (electrodes3_pulse_gen_en || electrodes4_pulse_gen_en) {
|
|
cpg11_pulse_init(1, &p_pusle_genB[0], 2);
|
|
cpg11_pulse_start(1, &p_pusle_genB[0]);
|
|
}
|
|
|
|
for (int i=0; i<2; i++) {
|
|
NRF_LOG_INFO("pusle_genA[%d]pulse_id: %d", i, p_pusle_genA[i].pulse_id);
|
|
}
|
|
for (int i=0; i<2; i++) {
|
|
NRF_LOG_INFO("pusle_genB[%d]pulse_id: %d", i, p_pusle_genB[i].pulse_id);
|
|
}
|
|
}
|
|
|
|
static void stop_which_electrodes(uint8_t *ins)
|
|
{
|
|
NRF_LOG_INFO("%s", __FUNCTION__);
|
|
uint8_t electrodes1_pulse_gen_dis = (ins[5] & 0b10000000) >> 7;
|
|
uint8_t electrodes2_pulse_gen_dis = (ins[5] & 0b01000000) >> 6;
|
|
uint8_t electrodes3_pulse_gen_dis = (ins[5] & 0b00100000) >> 5;
|
|
uint8_t electrodes4_pulse_gen_dis = (ins[5] & 0b00010000) >> 4;
|
|
|
|
if (electrodes1_pulse_gen_dis)
|
|
{
|
|
cpg11_pulse_stop_by_pulse_id(p_pusle_genA[0].pulse_id);
|
|
p_pusle_genA[0].pulse_id = PULSE_ID_NULL;
|
|
NRF_LOG_INFO("stop electrodes1_pulse_gen");
|
|
}
|
|
|
|
if (electrodes2_pulse_gen_dis)
|
|
{
|
|
cpg11_pulse_stop_by_pulse_id(p_pusle_genA[1].pulse_id);
|
|
p_pusle_genA[1].pulse_id = PULSE_ID_NULL;
|
|
NRF_LOG_INFO("stop electrodes2_pulse_gen");
|
|
}
|
|
|
|
if (electrodes3_pulse_gen_dis)
|
|
{
|
|
cpg11_pulse_stop_by_pulse_id(p_pusle_genB[0].pulse_id);
|
|
p_pusle_genB[0].pulse_id = PULSE_ID_NULL;
|
|
NRF_LOG_INFO("stop electrodes3_pulse_gen");
|
|
}
|
|
|
|
if (electrodes4_pulse_gen_dis)
|
|
{
|
|
cpg11_pulse_stop_by_pulse_id(p_pusle_genB[1].pulse_id);
|
|
p_pusle_genB[1].pulse_id = PULSE_ID_NULL;
|
|
NRF_LOG_INFO("stop electrodes4_pulse_gen");
|
|
}
|
|
|
|
for (int i=0; i<2; i++) {
|
|
NRF_LOG_INFO("pusle_genA[%d]pulse_id: %d", i, p_pusle_genA[i].pulse_id);
|
|
}
|
|
for (int i=0; i<2; i++) {
|
|
NRF_LOG_INFO("pusle_genB[%d]pulse_id: %d", i, p_pusle_genB[i].pulse_id);
|
|
}
|
|
|
|
NRF_LOG_INFO("\n\n")
|
|
}
|
|
|
|
static void set_cpg_pulse_cnt(uint8_t *ins)
|
|
{
|
|
NRF_LOG_INFO("%s", __FUNCTION__);
|
|
uint8_t electrodes1_pulse_gen_sel = (ins[5] & 0b10000000) >> 7;
|
|
uint8_t electrodes2_pulse_gen_sel = (ins[5] & 0b01000000) >> 6;
|
|
uint8_t electrodes3_pulse_gen_sel = (ins[5] & 0b00100000) >> 5;
|
|
uint8_t electrodes4_pulse_gen_sel = (ins[5] & 0b00010000) >> 4;
|
|
uint32_t pulse_cnt = (uint32_t)ins[6] << 24 | (uint32_t)ins[7] << 16 | (uint32_t)ins[8] << 8 | (uint32_t)ins[9];
|
|
|
|
if (electrodes1_pulse_gen_sel)
|
|
{
|
|
pusle_gen[0].pulse_cnt = pulse_cnt;
|
|
NRF_LOG_INFO("[1] pulse_cnt = %d cnt", pusle_gen[0].pulse_cnt);
|
|
}
|
|
|
|
if (electrodes2_pulse_gen_sel)
|
|
{
|
|
pusle_gen[1].pulse_cnt = pulse_cnt;
|
|
NRF_LOG_INFO("[2] pulse_cnt = %d cnt", pusle_gen[1].pulse_cnt);
|
|
}
|
|
|
|
if (electrodes3_pulse_gen_sel)
|
|
{
|
|
pusle_gen[2].pulse_cnt = pulse_cnt;
|
|
NRF_LOG_INFO("[3] pulse_cnt = %d cnt", pusle_gen[2].pulse_cnt);
|
|
}
|
|
|
|
if (electrodes4_pulse_gen_sel)
|
|
{
|
|
pusle_gen[3].pulse_cnt = pulse_cnt;
|
|
NRF_LOG_INFO("[4] pulse_cnt = %d cnt", pusle_gen[3].pulse_cnt);
|
|
}
|
|
}
|
|
|
|
void cpg_pulse_default_demo(void)
|
|
{
|
|
NRF_LOG_INFO("%s", __FUNCTION__);
|
|
pusle_gen_t pusle_gen_demo[PULSE_GEN_A_NUMB+PULSE_GEN_B_NUMB];
|
|
|
|
cpg11_pulse_stop_by_pulse_id(p_pusle_genA[0].pulse_id);
|
|
p_pusle_genA[0].pulse_id = PULSE_ID_NULL;
|
|
NRF_LOG_INFO("stop electrodes1_pulse_gen");
|
|
|
|
cpg11_pulse_stop_by_pulse_id(p_pusle_genA[1].pulse_id);
|
|
p_pusle_genA[1].pulse_id = PULSE_ID_NULL;
|
|
NRF_LOG_INFO("stop electrodes2_pulse_gen");
|
|
|
|
cpg11_pulse_stop_by_pulse_id(p_pusle_genB[0].pulse_id);
|
|
p_pusle_genB[0].pulse_id = PULSE_ID_NULL;
|
|
NRF_LOG_INFO("stop electrodes3_pulse_gen");
|
|
|
|
cpg11_pulse_stop_by_pulse_id(p_pusle_genB[1].pulse_id);
|
|
p_pusle_genB[1].pulse_id = PULSE_ID_NULL;
|
|
NRF_LOG_INFO("stop electrodes4_pulse_gen");
|
|
|
|
pusle_gen_demo[2] = (pusle_gen_t) {
|
|
.VBxH = VB3H_PIN,
|
|
.VBxL = VB3L_PIN,
|
|
.VAxH = VA3H_PIN,
|
|
.VAxL = VA3L_PIN,
|
|
.point_us[0] = 1,
|
|
.point_us[1] = 250,
|
|
.point_us[2] = 1,
|
|
.point_us[3] = 0,
|
|
.point_us[4] = 1,
|
|
.point_us[5] = 250,
|
|
.point_us[6] = 1,
|
|
.idle_us = 1000,
|
|
.pulse_cnt = UINT32_MAX,
|
|
.pulse_id = PULSE_ID_NULL,
|
|
};
|
|
|
|
p_pusle_genB[0] = pusle_gen_demo[2];
|
|
p_pusle_genB[0].pulse_id = PULSE_ID_C;
|
|
cpg11_pulse_init(1, &p_pusle_genB[0], 1);
|
|
cpg11_pulse_start(1, &p_pusle_genB[0]);
|
|
NRF_LOG_INFO("start electrodes3_pulse_gen");
|
|
}
|
|
|
|
/*
|
|
dev_mode_set_cpg11_electrodes
|
|
|
|
(1) 0x3000FF0009
|
|
- func: ELECTRODE_A1B1_IDLE
|
|
|
|
(2) 0x3000FF000A
|
|
- func: ELECTRODE_A2B2_IDLE
|
|
|
|
(3) 0x3000FF000B
|
|
- func: ELECTRODE_A3B3_IDLE
|
|
|
|
(4) 0x3000FF000C
|
|
- func: ELECTRODE_A4B4_IDLE
|
|
|
|
(5) 0x3000FF000D
|
|
- func: ELECTRODE_ALL_HIGHZ
|
|
|
|
(6) 0x3000FF000E
|
|
- func: ELECTRODE_E1P_ENABLE (electrode 1 positive)
|
|
|
|
(7) 0x3000FF000F
|
|
- func: ELECTRODE_E1P_DISABLE (electrode 1 positive)
|
|
|
|
(8) 0x3000FF0010
|
|
- func: ELECTRODE_E1N_ENABLE (electrode 1 negative)
|
|
|
|
(9) 0x3000FF0011
|
|
- func: ELECTRODE_E1N_DISABLE (electrode 1 negative)
|
|
|
|
(10) 0x3000FF0012
|
|
- func: ELECTRODE_E2P_ENABLE (electrode 2 positive)
|
|
|
|
(11) 0x3000FF0013
|
|
- func: ELECTRODE_E2P_DISABLE (electrode 2 positive)
|
|
|
|
(12) 0x3000FF0014
|
|
- func: ELECTRODE_E2N_ENABLE (electrode 2 negative)
|
|
|
|
(13) 0x3000FF0015
|
|
- func: ELECTRODE_E2N_DISABLE (electrode 2 negative)
|
|
|
|
(14) 0x3000FF0016
|
|
- func: ELECTRODE_E3P_ENABLE (electrode 3 positive)
|
|
|
|
(15) 0x3000FF0017
|
|
- func: ELECTRODE_E3P_DISABLE (electrode 3 positive)
|
|
|
|
(16) 0x3000FF0018
|
|
- func: ELECTRODE_E3N_ENABLE (electrode 3 negative)
|
|
|
|
(17) 0x3000FF0019
|
|
- func: ELECTRODE_E3N_DISABLE (electrode 3 negative)
|
|
|
|
(18) 0x3000FF001A
|
|
- func: ELECTRODE_E4P_ENABLE (electrode 4 positive)
|
|
|
|
(19) 0x3000FF001B
|
|
- func: ELECTRODE_E4P_DISABLE (electrode 4 positive)
|
|
|
|
(20) 0x3000FF001C
|
|
- func: ELECTRODE_E4N_ENABLE (electrode 4 negative)
|
|
|
|
(21) 0x3000FF001D
|
|
- func: ELECTRODE_E4N_DISABLE (electrode 4 negative)
|
|
|
|
*/
|
|
void dev_mode_set_cpg11_electrodes(uint8_t *ins)
|
|
{
|
|
struct __PACKED
|
|
{
|
|
uint8_t id : 4;
|
|
uint8_t : 4;
|
|
uint16_t magic : 16;
|
|
uint8_t dev_opcode;
|
|
uint8_t electrodes_opcode;
|
|
} *p_ins = (void *)ins;
|
|
|
|
cpg11_electrodes(p_ins->electrodes_opcode);
|
|
}
|
|
|
|
/*
|
|
dev_mode_set_cpg11_tw1508
|
|
|
|
(1) 0x3000FF0100
|
|
- func: tw1508_init() out_0 = 0, out_1 = 0
|
|
|
|
(2) 0x3000FF0101aaaabbbb
|
|
- func: tw1508_set()
|
|
- aaaa: out_0 value (0x0000 to 0x03FF [LSB])
|
|
- bbbb: out_1 value (0x0000 to 0x03FF [LSB])
|
|
*/
|
|
void dev_mode_set_cpg11_tw1508(uint8_t *ins)
|
|
{
|
|
struct __PACKED
|
|
{
|
|
uint8_t id : 4;
|
|
uint8_t : 4;
|
|
uint16_t magic : 16;
|
|
uint8_t dev_opcode;
|
|
uint8_t tw1508_opcode;
|
|
uint8_t param[];
|
|
} *p_ins = (void *)ins;
|
|
|
|
switch (p_ins->tw1508_opcode)
|
|
{
|
|
case 0x00: {
|
|
tw1508_init();
|
|
NRF_LOG_INFO("tw1508_init()");
|
|
break;
|
|
}
|
|
|
|
case 0x01: {
|
|
uint16_t out_0;
|
|
uint16_t out_1;
|
|
memcpy(&out_0, &p_ins->param[0], sizeof(out_0));
|
|
memcpy(&out_1, &p_ins->param[2], sizeof(out_1));
|
|
NRF_LOG_INFO("tw1508_set(%d, %d)", out_0, out_1);
|
|
tw1508_set(out_0, out_1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
dev_mode_ctrl_cpg11_electrodes_task
|
|
|
|
(1) 0x3000FF0205
|
|
- func: start the cpg_pulse_default_demo()
|
|
|
|
- electrode 1:
|
|
pulse_width_us: 250 us
|
|
freq_hz: 665 Hz
|
|
idle: 1000 us
|
|
|
|
- electrode 2:
|
|
pulse_width_us: 250 us
|
|
freq_hz: 665 Hz
|
|
idle: 1000 us
|
|
|
|
(2) 0x3000FF0206nnwwwwwwwwffffffff
|
|
- func: set_cpg_pulse_parameter value
|
|
- nn: set which group of electrodes (0x00 to 0xF0)
|
|
0x80 = 0b10000000: select electrode 1
|
|
0x40 = 0b01000000: select electrode 2
|
|
0x20 = 0b00100000: select electrode 3
|
|
0x10 = 0b00010000: select electrode 4
|
|
......
|
|
0xF0 = 0b11110000: select electrode 1~4
|
|
- wwwwwwww: pulse_width_us (0x00000000 to 0xFFFFFFFF)
|
|
- ffffffff: freq_hz (0x00000000 to 0xFFFFFFFF)
|
|
|
|
(3) 0x3000FF0207nn
|
|
- func: select which electrode's pulse to enable
|
|
- nn: which electrodes (0x00 to 0xF0)
|
|
0x80 = 0b10000000: electrode 1 enable pulse
|
|
0x40 = 0b01000000: electrode 2 enable pulse
|
|
0x20 = 0b00100000: electrode 3 enable pulse
|
|
0x10 = 0b00010000: electrode 4 enable pulse
|
|
......
|
|
0xF0 = 0b11110000: electrode 1~4 enable pulse
|
|
|
|
(4) 0x3000FF0208nn
|
|
- func: select which electrode's pulse to stop
|
|
- nn: which electrodes (0x00 to 0xF0)
|
|
0x80 = 0b10000000: electrode 1 stops pulsing
|
|
0x40 = 0b01000000: electrode 2 stops pulsing
|
|
0x20 = 0b00100000: electrode 3 stops pulsing
|
|
0x10 = 0b00010000: electrode 4 stops pulsing
|
|
......
|
|
0xF0 = 0b11110000: electrode 1~4 stops pulsing
|
|
|
|
(5) 0x3000FF0209nncccccccc
|
|
- func: set_cpg_pulse_cnt
|
|
- nn: set which group of electrodes (0x00 to 0xF0)
|
|
0x80 = 0b10000000: select electrode 1
|
|
0x40 = 0b01000000: select electrode 2
|
|
0x20 = 0b00100000: select electrode 3
|
|
0x10 = 0b00010000: select electrode 4
|
|
......
|
|
0xF0 = 0b11110000: select electrode 1~4
|
|
- cccccccc: pulse_cnt (0x00000001 to 0xFFFFFFFF)
|
|
*/
|
|
void dev_mode_ctrl_cpg11_electrodes_task(uint8_t *ins)
|
|
{
|
|
struct __PACKED
|
|
{
|
|
uint8_t id : 4;
|
|
uint8_t : 4;
|
|
uint16_t magic : 16;
|
|
uint8_t dev_opcode;
|
|
uint8_t electrodes_task_opcode;
|
|
uint8_t param[];
|
|
} *p_ins = (void *)ins;
|
|
|
|
switch (p_ins->electrodes_task_opcode)
|
|
{
|
|
case 0x05: {
|
|
cpg_pulse_default_demo();
|
|
break;
|
|
}
|
|
|
|
case 0x06: {
|
|
set_cpg_pulse_parameter(ins);
|
|
break;
|
|
}
|
|
|
|
case 0x07: {
|
|
start_which_electrodes(ins);
|
|
break;
|
|
}
|
|
|
|
case 0x08: {
|
|
stop_which_electrodes(ins);
|
|
break;
|
|
}
|
|
|
|
case 0x09: {
|
|
set_cpg_pulse_cnt(ins);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
dev_mode_gpio_function
|
|
|
|
(1) 0x3000FFA000ppss
|
|
- func: set_bmd380_pin_signal
|
|
- pp: pin number (0x06 to 0x3E)
|
|
0x06: P0.22_GPIO
|
|
0x08: P0.25_GPIO
|
|
......
|
|
0x3E: P0.16_GPIO
|
|
- ss: signal (0x00 or 0x01)
|
|
0x00: low
|
|
0x01: high
|
|
|
|
(2) 0x3000FFA001ss
|
|
|
|
- func: set all BMD380 PINs to high or low (except for HV_EN, SPI, and input GPIOs)
|
|
- pin_number[] = {
|
|
6, 8, 9, 10, 13, 14, 29, 30, 31, 32, 33, 34, 36, 38, 39,
|
|
40, 41, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 59, 60, 61
|
|
}
|
|
- ss: signal (0x00 or 0x01)
|
|
0x00: low
|
|
0x01: high
|
|
*/
|
|
void dev_mode_gpio_function(uint8_t *ins)
|
|
{
|
|
struct __PACKED
|
|
{
|
|
uint8_t id : 4;
|
|
uint8_t : 4;
|
|
uint16_t magic : 16;
|
|
uint8_t dev_opcode;
|
|
uint8_t gpio_function_opcode;
|
|
uint8_t param[];
|
|
} *p_ins = (void *)ins;
|
|
|
|
switch (p_ins->gpio_function_opcode)
|
|
{
|
|
case 0x00: {
|
|
uint32_t pin = p_ins->param[0];
|
|
uint32_t high_low = p_ins->param[1];
|
|
set_bmd380_pin_signal(pin, high_low);
|
|
break;
|
|
}
|
|
|
|
case 0x01: {
|
|
uint32_t high_low = p_ins->param[0];
|
|
uint32_t pin_number[] = { 6, 8, 9, 10, 13, 14, 29, 30, 31, 32, 33, 34, 36, 38, 39, 40, 41, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 59, 60, 61 };
|
|
|
|
for (int i = 0; i < sizeof(pin_number) / sizeof(pin_number[0]); i++)
|
|
{
|
|
set_bmd380_pin_signal(pin_number[i], high_low);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|