/************************simware add start***********************************/
static uint32_t gh3018_mfp_cfgs[] = {
MFP_REG(GPIO_32) | MFP_AF0 | MFP_DRIVE_MEDIUM | MFP_PULL_LOW | MFP_SLEEP_DIR | MFP_LPM_EDGE_NONE,
+ MFP_REG(GPIO_32) | MFP_AF0 | MFP_DRIVE_MEDIUM | MFP_PULL_LOW | MFP_SLEEP_DIR | MFP_LPM_EDGE_NONE,
+ MFP_REG(GPIO_18) | MFP_AF0 | MFP_DRIVE_MEDIUM | MFP_PULL_LOW | MFP_SLEEP_DIR | MFP_LPM_EDGE_NONE,
+ MFP_REG(GPIO_81) | MFP_AF0 | MFP_DRIVE_MEDIUM | MFP_PULL_LOW | MFP_SLEEP_DIR | MFP_LPM_EDGE_NONE,
+ MFP_REG(GPIO_84) | MFP_AF0 | MFP_DRIVE_MEDIUM | MFP_PULL_LOW | MFP_SLEEP_DIR | MFP_LPM_EDGE_NONE,
MFP_EOC
};
static const struct gh3018_info_s gh3018_info = {
static uint16_t HR_value = 0;
static uint16_t SPO2_value = 0;
static EMGh30xRunMode measure_mode = RUN_MODE_INVALID;
+static void gh3018_en_gpio_init(void)
+{
+ gpio_set_direction(GPIO18, GPIO_OUT);
+ gpio_set_direction(GPIO81, GPIO_OUT);
+ gpio_set_direction(GPIO84, GPIO_OUT);
+}
+//Hsensor 电源、复位
+static void gh3018_en_gpio_enable(bool param)
+{
+ static flag = 0;
+ if(param)
+ flag++;
+ else
+ {
+ if(flag > 0)
+ flag --;
+ }
+
+ if(flag > 0) {
+ gpio_set_value(GPIO18, GPIO_HIGH);
+ gpio_set_value(GPIO81, GPIO_HIGH);
+ gpio_set_value(GPIO84, GPIO_HIGH);
+ } else {
+ gpio_set_value(GPIO18, GPIO_LOW);
+ gpio_set_value(GPIO81, GPIO_LOW);
+ gpio_set_value(GPIO84, GPIO_LOW);
+ }
+}
static void gh3018_hisr_callback(void)
{
static void gh3018_start(void)
{
+ gh3018_en_gpio_enable(true);
Timer0_Switch(1);
+
gh30x_module_start_without_adt(measure_mode);
}
{
gh30x_module_stop();
Timer0_Switch(0);
+ gh3018_en_gpio_enable(false);
}
void gh3018_init(void)
uint8_t get_gh3018_id(void)
{
+ gh3018_en_gpio_enable(true);
+ hal_gh30x_delay_us(10000);
uint8_t cmd[] = {0xdd,0xdd,0xc0};
uint8_t reg_addr[] = {0x00,0x28};
uint8_t id_buf[2] = {0};
hal_gh30x_delay_us(1000);
hal_gh30x_i2c_read(sensor_addr, reg_addr, sizeof(reg_addr), id_buf, sizeof(id_buf));
if(id_buf[0] == 0x00 && id_buf[1] == 0x31)
- cplog_printf("GH3011 id : 0x0031\r\n");
+ printf("GH3011 id : 0x0031\r\n");
else
- cplog_printf("read id error\r\n");
+ printf("read id error\r\n");
id = id_buf[1] << 0;
id += id_buf[0] << 8;
+ gh3018_en_gpio_enable(false);
return id;
}
Timer0_Switch(1);
measure_mode = RUN_MODE_ADT_HB_DET;
+ hal_gh30x_int_init();
sensor_task_send_message(GH3018_ID,0);
}
// code implement by user
// must register func hal_gh30x_int_handler as callback
mfp_config(gh3018_mfp_cfgs);
+ gh3018_en_gpio_init();
printf("GH3018 ID : 0x%02x\n",get_gh3018_id());
sensor_drv_t sensor_drv;