b072f22ede
tw1508 = 0
97 lines
1.9 KiB
C
97 lines
1.9 KiB
C
#include "cpg10_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_10)
|
|
|
|
#define VERSION_DATE_YEAR 24
|
|
#define VERSION_DATE_MONTH 5
|
|
#define VERSION_DATE_DAY 21
|
|
#define VERSION_DATE_HOUR 18
|
|
#define VERSION_DATE_MINUTE 39
|
|
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 0x90:
|
|
dev_mode_set_cpg10_electrodes(ins);
|
|
break;
|
|
|
|
case 0xA0:
|
|
dev_mode_gpio_function(ins);
|
|
break;
|
|
|
|
case 0xA1:
|
|
// spi
|
|
break;
|
|
|
|
case 0xA2:
|
|
// i2c
|
|
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)
|
|
{
|
|
tw1805_init();
|
|
tw1508_set(0, 0);
|
|
return &cpg_elite_instance;
|
|
}
|
|
|
|
#endif
|