feat: new dev_mode: setting_cpg_pulse_parameter & start_which_electrodes
This commit is contained in:
@@ -15,9 +15,9 @@
|
||||
|
||||
#define VERSION_DATE_YEAR 24
|
||||
#define VERSION_DATE_MONTH 7
|
||||
#define VERSION_DATE_DAY 18
|
||||
#define VERSION_DATE_HOUR 16
|
||||
#define VERSION_DATE_MINUTE 17
|
||||
#define VERSION_DATE_DAY 31
|
||||
#define VERSION_DATE_HOUR 17
|
||||
#define VERSION_DATE_MINUTE 11
|
||||
static void cis_version(uint8_t *ins, uint16_t size)
|
||||
{
|
||||
NRF_LOG_INFO("%s", __FUNCTION__);
|
||||
|
||||
+127
-4
@@ -55,6 +55,41 @@ const uint32_t pin_to_gpio_table[] = {
|
||||
[62] = NRF_GPIO_PIN_MAP(0, 16),
|
||||
};
|
||||
|
||||
static pusle_gen_t dev_mode_pusle_gen[2] = {
|
||||
{
|
||||
.VBxH = VB1H_PIN,
|
||||
.VBxL = VB1L_PIN,
|
||||
.VAxH = VA1H_PIN,
|
||||
.VAxL = VA1L_PIN,
|
||||
.idle_us = 1000,
|
||||
.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,
|
||||
.pulse_cnt = 0,
|
||||
.op_mode = 0,
|
||||
},
|
||||
{
|
||||
.VBxH = VB2H_PIN,
|
||||
.VBxL = VB2L_PIN,
|
||||
.VAxH = VA2H_PIN,
|
||||
.VAxL = VA2L_PIN,
|
||||
.idle_us = 1000,
|
||||
.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,
|
||||
.pulse_cnt = 0xFFFFFFFF,
|
||||
.op_mode = 1,
|
||||
}
|
||||
};
|
||||
|
||||
static uint32_t bmd380pins_convert_to_gpio(uint32_t pin)
|
||||
{
|
||||
uint32_t gpio;
|
||||
@@ -321,6 +356,66 @@ static void electrodes_4_task(void *pArg)
|
||||
}
|
||||
}
|
||||
|
||||
void setting_cpg_pulse_parameter(uint8_t *ins)
|
||||
{
|
||||
NRF_LOG_INFO("%s", __FUNCTION__);
|
||||
uint8_t electrodes_num = ins[5];
|
||||
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 (electrodes_num == 1)
|
||||
{
|
||||
dev_mode_pusle_gen[0].point_us[1] = pulse_width_us;
|
||||
dev_mode_pusle_gen[0].point_us[5] = pulse_width_us;
|
||||
dev_mode_pusle_gen[0].idle_us = (1000000 / freq_hz) - (dev_mode_pusle_gen[0].point_us[0] + dev_mode_pusle_gen[0].point_us[1] + dev_mode_pusle_gen[0].point_us[2] + dev_mode_pusle_gen[0].point_us[3] + dev_mode_pusle_gen[0].point_us[4] + dev_mode_pusle_gen[0].point_us[5] + dev_mode_pusle_gen[0].point_us[6]);
|
||||
NRF_LOG_INFO("[1]a = %d us", dev_mode_pusle_gen[0].point_us[0]);
|
||||
NRF_LOG_INFO("[1]b = %d us", dev_mode_pusle_gen[0].point_us[1]);
|
||||
NRF_LOG_INFO("[1]c = %d us", dev_mode_pusle_gen[0].point_us[2]);
|
||||
NRF_LOG_INFO("[1]d = %d us", dev_mode_pusle_gen[0].point_us[3]);
|
||||
NRF_LOG_INFO("[1]e = %d us", dev_mode_pusle_gen[0].point_us[4]);
|
||||
NRF_LOG_INFO("[1]f = %d us", dev_mode_pusle_gen[0].point_us[5]);
|
||||
NRF_LOG_INFO("[1]g = %d us", dev_mode_pusle_gen[0].point_us[6]);
|
||||
NRF_LOG_INFO("[1]idle = %d us", dev_mode_pusle_gen[0].idle_us);
|
||||
}
|
||||
else if (electrodes_num == 2)
|
||||
{
|
||||
dev_mode_pusle_gen[1].point_us[1] = pulse_width_us;
|
||||
dev_mode_pusle_gen[1].point_us[5] = pulse_width_us;
|
||||
dev_mode_pusle_gen[1].idle_us = (1000000 / freq_hz) - (dev_mode_pusle_gen[1].point_us[0] + dev_mode_pusle_gen[1].point_us[1] + dev_mode_pusle_gen[1].point_us[2] + dev_mode_pusle_gen[1].point_us[3] + dev_mode_pusle_gen[1].point_us[4] + dev_mode_pusle_gen[1].point_us[5] + dev_mode_pusle_gen[1].point_us[6]);
|
||||
NRF_LOG_INFO("[2]a = %d us", dev_mode_pusle_gen[1].point_us[0]);
|
||||
NRF_LOG_INFO("[2]b = %d us", dev_mode_pusle_gen[1].point_us[1]);
|
||||
NRF_LOG_INFO("[2]c = %d us", dev_mode_pusle_gen[1].point_us[2]);
|
||||
NRF_LOG_INFO("[2]d = %d us", dev_mode_pusle_gen[1].point_us[3]);
|
||||
NRF_LOG_INFO("[2]e = %d us", dev_mode_pusle_gen[1].point_us[4]);
|
||||
NRF_LOG_INFO("[2]f = %d us", dev_mode_pusle_gen[1].point_us[5]);
|
||||
NRF_LOG_INFO("[2]g = %d us", dev_mode_pusle_gen[1].point_us[6]);
|
||||
NRF_LOG_INFO("[2]idle = %d us", dev_mode_pusle_gen[1].idle_us);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (electrodes1_pulse_gen_en)
|
||||
{
|
||||
NRF_LOG_INFO("start electrodes1_pulse_gen");
|
||||
extern bool cpg10_pulse_gen(uint32_t idx, pusle_gen_t * p_pusle_gen);
|
||||
cpg10_pulse_gen(0, &dev_mode_pusle_gen[0]);
|
||||
}
|
||||
|
||||
if (electrodes2_pulse_gen_en)
|
||||
{
|
||||
NRF_LOG_INFO("start electrodes2_pulse_gen");
|
||||
extern bool cpg10_pulse_gen(uint32_t idx, pusle_gen_t * p_pusle_gen);
|
||||
cpg10_pulse_gen(1, &dev_mode_pusle_gen[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
dev_mode_set_cpg10_electrodes
|
||||
(1)0x3000FF0001
|
||||
@@ -441,7 +536,25 @@ void dev_mode_set_cpg10_tw1508(uint8_t *ins)
|
||||
00h: stop electrodes_4_task
|
||||
01h: start electrodes_4_task
|
||||
(5)0x3000FF0205
|
||||
-func: start cpg_pulse_demo()
|
||||
-func: start cpg_pulse_default_demo()
|
||||
(6)0x3000FF0206nnwwwwwwwwffffffff
|
||||
-func: setting cpg_pulse_parameter
|
||||
-nn: set which group of electrodes
|
||||
01h: electrode1
|
||||
02h: electrode2
|
||||
03h: electrode3
|
||||
04h: electrode4
|
||||
-wwwwwwww: pulse_width_us
|
||||
-ffffffff: freq_hz
|
||||
(7)0x3000FF0207nn
|
||||
-func: start which electrodes
|
||||
-nn: start which electrodes (0x00 to 0xFF)
|
||||
0x80 = 0b10000000: electrode1 enable pulse
|
||||
0x40 = 0b01000000: electrode2 enable pulse
|
||||
0x20 = 0b00100000: electrode3 enable pulse
|
||||
0x10 = 0b00010000: electrode4 enable pulse
|
||||
......
|
||||
0xF0 = 0b11110000: electrode1~4 enable pulse
|
||||
*/
|
||||
void dev_mode_ctrl_cpg10_electrodes_task(uint8_t *ins)
|
||||
{
|
||||
@@ -535,9 +648,19 @@ void dev_mode_ctrl_cpg10_electrodes_task(uint8_t *ins)
|
||||
}
|
||||
|
||||
case 0x05: {
|
||||
NRF_LOG_INFO("[test] 2 pin cpg_pulse_demo()");
|
||||
extern void cpg_pulse_demo(void);
|
||||
cpg_pulse_demo();
|
||||
NRF_LOG_INFO("[test] cpg_pulse_default_demo()");
|
||||
extern void cpg_pulse_default_demo(void);
|
||||
cpg_pulse_default_demo();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x06: {
|
||||
setting_cpg_pulse_parameter(ins);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x07: {
|
||||
start_which_electrodes(ins);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+8
-20
@@ -36,18 +36,6 @@ const uint32_t grp0_pin[] = {
|
||||
VA1L_PIN,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t VAxH;
|
||||
uint32_t VAxL;
|
||||
uint32_t VBxH;
|
||||
uint32_t VBxL;
|
||||
uint32_t idle_us; // min: 500us, max: 60sec
|
||||
uint32_t point_us[7]; // toggle point timestamp
|
||||
uint32_t pulse_cnt; // min: 1, max: 0xFFFFFFFF
|
||||
uint32_t op_mode;
|
||||
} pusle_gen_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const uint32_t gpiote_idx[4];
|
||||
@@ -201,7 +189,7 @@ bool cpg10_pulse_gen(uint32_t idx, pusle_gen_t *p_pusle_gen)
|
||||
return true;
|
||||
}
|
||||
|
||||
void cpg_pulse_demo(void)
|
||||
void cpg_pulse_default_demo(void)
|
||||
{
|
||||
pusle_gen_t pusle_gen[2] = {
|
||||
{
|
||||
@@ -211,13 +199,13 @@ void cpg_pulse_demo(void)
|
||||
.VAxL = VA1L_PIN,
|
||||
.idle_us = 1000,
|
||||
.point_us[0] = 1,
|
||||
.point_us[1] = 10,
|
||||
.point_us[1] = 250,
|
||||
.point_us[2] = 1,
|
||||
.point_us[3] = 0,
|
||||
.point_us[4] = 1,
|
||||
.point_us[5] = 10,
|
||||
.point_us[5] = 250,
|
||||
.point_us[6] = 1,
|
||||
.pulse_cnt = 3,
|
||||
.pulse_cnt = 0,
|
||||
.op_mode = 0,
|
||||
},
|
||||
{
|
||||
@@ -227,18 +215,18 @@ void cpg_pulse_demo(void)
|
||||
.VAxL = VA2L_PIN,
|
||||
.idle_us = 1000,
|
||||
.point_us[0] = 1,
|
||||
.point_us[1] = 10,
|
||||
.point_us[1] = 250,
|
||||
.point_us[2] = 1,
|
||||
.point_us[3] = 0,
|
||||
.point_us[4] = 1,
|
||||
.point_us[5] = 10,
|
||||
.point_us[5] = 250,
|
||||
.point_us[6] = 1,
|
||||
.pulse_cnt = 5,
|
||||
.pulse_cnt = 0xFFFFFFFF,
|
||||
.op_mode = 1,
|
||||
}
|
||||
};
|
||||
|
||||
cpg10_pulse_gen(0, &pusle_gen[0]);
|
||||
// cpg10_pulse_gen(0, &pusle_gen[0]); //!!!hw problem, don't use
|
||||
|
||||
cpg10_pulse_gen(1, &pusle_gen[1]);
|
||||
}
|
||||
|
||||
+12
@@ -55,6 +55,18 @@ extern "C"
|
||||
#define ADPT1_S3_PIN NRF_GPIO_PIN_MAP(0, 23)
|
||||
#define ADPT1_S2_PIN NRF_GPIO_PIN_MAP(0, 16)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t VAxH;
|
||||
uint32_t VAxL;
|
||||
uint32_t VBxH;
|
||||
uint32_t VBxL;
|
||||
uint32_t idle_us; // min: 500us, max: 60sec
|
||||
uint32_t point_us[7]; // toggle point timestamp
|
||||
uint32_t pulse_cnt; // min: 1, max: 0xFFFFFFFF
|
||||
uint32_t op_mode;
|
||||
} pusle_gen_t;
|
||||
|
||||
void spim_xfer(uint32_t cs_pin,
|
||||
nrf_spim_mode_t spi_mode,
|
||||
uint8_t *p_tx_buffer,
|
||||
|
||||
Reference in New Issue
Block a user