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
111 lines
2.3 KiB
C
111 lines
2.3 KiB
C
#include "cpg11_dev_mode.h"
|
|
#include "pel.h"
|
|
#include "pel10_io.h"
|
|
|
|
#include "elite_def.h"
|
|
|
|
#include "nrf_delay.h"
|
|
#include "nrf_gpio.h"
|
|
#include "nrf_log.h"
|
|
|
|
#include "tw1508.h"
|
|
|
|
#if (DEF_ELITE_MODEL == DEF_CURRENT_PULSE_GANERATOR_11)
|
|
|
|
#define VERSION_DATE_YEAR 24
|
|
#define VERSION_DATE_MONTH 8
|
|
#define VERSION_DATE_DAY 30
|
|
#define VERSION_DATE_HOUR 16
|
|
#define VERSION_DATE_MINUTE 50
|
|
static void cis_version(uint8_t *ins, uint16_t size)
|
|
{
|
|
NRF_LOG_INFO("%s", __FUNCTION__);
|
|
uint8_t cis_ver[] = {
|
|
CIS_VERSION,
|
|
VERSION_DATE_YEAR,
|
|
VERSION_DATE_MONTH,
|
|
VERSION_DATE_DAY,
|
|
VERSION_DATE_HOUR,
|
|
VERSION_DATE_MINUTE,
|
|
};
|
|
extern ret_code_t le_data_upadate(uint8_t * p_value, uint16_t len);
|
|
le_data_upadate((void *)cis_ver, sizeof(cis_ver));
|
|
}
|
|
|
|
static void vis_rst(uint8_t *ins, uint16_t size)
|
|
{
|
|
NRF_LOG_INFO("%s", __FUNCTION__);
|
|
}
|
|
|
|
void dev_mode(uint8_t *ins, uint16_t size)
|
|
{
|
|
NRF_LOG_INFO("%s", __FUNCTION__);
|
|
|
|
struct __PACKED
|
|
{
|
|
uint8_t id : 4;
|
|
uint8_t : 4;
|
|
uint16_t magic : 16;
|
|
uint8_t dev_opcode;
|
|
uint8_t function_opcode;
|
|
uint8_t param[];
|
|
} *p_ins = (void *)ins;
|
|
|
|
switch (p_ins->dev_opcode)
|
|
{
|
|
case 0x00:
|
|
dev_mode_set_cpg11_electrodes(ins);
|
|
break;
|
|
|
|
case 0x01:
|
|
dev_mode_set_cpg11_tw1508(ins);
|
|
break;
|
|
|
|
case 0x02:
|
|
dev_mode_ctrl_cpg11_electrodes_task(ins);
|
|
break;
|
|
|
|
// 0xA0 to 0xBF are reserved for controlling the BMD380
|
|
case 0xA0:
|
|
dev_mode_gpio_function(ins);
|
|
break;
|
|
|
|
case 0xA1:
|
|
// spi
|
|
break;
|
|
|
|
case 0xA2:
|
|
// i2c
|
|
break;
|
|
|
|
// 0xF0 to 0xFF are reserved for calibration
|
|
case 0xF0:
|
|
// cali
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
const elite_instance_t cpg_elite_instance = {
|
|
.cis_func = {
|
|
[CIS_VERSION] = cis_version,
|
|
},
|
|
.vis_func = {
|
|
[VIS_RST] = vis_rst,
|
|
},
|
|
.ris_func = {
|
|
[DEV_MODE] = dev_mode,
|
|
}
|
|
};
|
|
|
|
const elite_instance_t *cpg_init(void)
|
|
{
|
|
tw1508_init();
|
|
tw1508_set(5, 5); // 5*0.13= 0.65mA, formula:value*0.13=mA
|
|
return &cpg_elite_instance;
|
|
}
|
|
|
|
#endif
|