{
// set local device name
uint8_t local_name[13] = {0};
-
+ mac_addr_t addr;
snprintf((char *)local_name,sizeof(local_name),"ZH_%s",sys_config.IMEI+6);
memcpy(scan_rsp_data+2,local_name,13);
gap_set_dev_name(local_name, sizeof(local_name));
+ memcpy(addr.addr,sys_config.IMEI+10,5);
+ addr.addr[5] = 0x0c;
+ gap_address_set(&addr);
+
os_timer_init( &update_param_timer,param_timer_func,NULL);
#if 0 //security encryption
gap_bond_manager_init(BLE_BONDING_INFO_SAVE_ADDR, BLE_REMOTE_SERVICE_SAVE_ADDR, 8, true);
//gap_bond_manager_delete_all();
- mac_addr_t addr;
+
gap_address_get(&addr);
co_printf("Local BDADDR: 0x%2X%2X%2X%2X%2X%2X\r\n", addr.addr[0], addr.addr[1], addr.addr[2], addr.addr[3], addr.addr[4], addr.addr[5]);
#include "lib_hr.h"
#include "sensor_drive.h"
#include "user_task.h"
+#include "driver_uart.h"
SysConfig sys_config ={0};
void init_sys_config(void);
/*
*/
__attribute__((section("ram_code"))) void user_entry_before_sleep_imp(void)
{
- //pmu_set_gpio_value(GPIO_PORT_A, BIT(0), 1);//心率使能 高电平
- //co_printf("sleep\r\n");
+
+ //co_printf("s\r\n");
+
}
/*********************************************************************
* @fn user_entry_after_sleep_imp
system_set_port_pull(GPIO_PC6, true);
system_set_port_mux(GPIO_PORT_C, GPIO_BIT_6, PORTC6_FUNC_UART0_RXD);
system_set_port_mux(GPIO_PORT_C, GPIO_BIT_5, PORTC5_FUNC_UART0_TXD);
- uart_init(UART0, BAUD_RATE_921600);
+ //uart_init(UART0, BAUD_RATE_921600);
+ uart_param_t param =
+ {
+ .baud_rate = 921600,
+ .data_bit_num = 8,
+ .pari = 0,
+ .stop_bit = 1,
+ };
+ uart_init1(UART0, param);
NVIC_EnableIRQ(UART0_IRQn);
+
/* set PA2 and PA3 for AT command interface */
system_set_port_pull(GPIO_PA2, true);
system_set_port_mux(GPIO_PORT_A, GPIO_BIT_2, PORTA2_FUNC_UART1_RXD);
system_set_port_mux(GPIO_PORT_A, GPIO_BIT_3, PORTA3_FUNC_UART1_TXD);
uart_init(UART1, BAUD_RATE_921600);
- NVIC_EnableIRQ(UART1_IRQn);
+ //NVIC_EnableIRQ(UART1_IRQn);
-
+
+ //4G读数据中断
+ // pmu_set_port_mux(GPIO_PORT_D, GPIO_BIT_7, PMU_PORT_MUX_GPIO);
+ // pmu_set_pin_to_PMU(GPIO_PORT_D, BIT(7));
+ // pmu_set_pin_dir(GPIO_PORT_D, BIT(7), GPIO_DIR_IN);
+ // pmu_port_wakeup_func_set(GPIO_PD7);//GPIO中断
NVIC_EnableIRQ(PMU_IRQn);
user_i2c1_init();
user_i2c0_init();
+
//co_printf("UP\r\n");
+
+
}
/*********************************************************************
system_set_port_pull(GPIO_PC6, true);
system_set_port_mux(GPIO_PORT_C, GPIO_BIT_6, PORTC6_FUNC_UART0_RXD);
system_set_port_mux(GPIO_PORT_C, GPIO_BIT_5, PORTC5_FUNC_UART0_TXD);
- uart_init(UART0, BAUD_RATE_921600);
+ //uart_init(UART0, BAUD_RATE_921600);
+ uart_param_t param =
+ {
+ .baud_rate = 921600,
+ .data_bit_num = 8,
+ .pari = 0,
+ .stop_bit = 1,
+ };
+ uart_init1(UART0, param);
NVIC_EnableIRQ(UART0_IRQn);
- co_printf("user_entry_before_ble_init!!!!!\n\n\n");
+ //co_printf("user_entry_before_ble_init!!!!!\n\n\n");
// NVIC_EnableIRQ(UART0_IRQn);
flash_read(CONFIG_SAVE_ADDR,sizeof(sys_config),(uint8_t *)&sys_config);
- co_printf("init_sys_config:config_flag:0x%x\n",sys_config.config_flag);
+ //co_printf("init_sys_config:config_flag:0x%x\n",sys_config.config_flag);
if(sys_config.config_flag != 0xaa)//第一次开机,执行初始化
{
co_printf("init_sys_config:init config_flag\n");
void user_entry_after_ble_init(void)
{
- co_printf("\r\n\r\n--------init_sys_config--------\r\n\r\n");
- co_printf("\r\n\r\n--------%s--------\r\n\r\n",Versions);
+ //co_printf("\r\n\r\n--------init_sys_config--------\r\n\r\n");
+ co_printf("\r\n\r\n--------Versions:%s--------\r\n\r\n",Versions);
//system_set_tx_power(RF_TX_POWER_POS_10dBm); //设置发射功率为10DB
//system_sleep_disable(); //关睡眠
}
}
- co_printf("\r\n\r\n--------system start end--------\r\n\r\n");
+ //co_printf("\r\n\r\n--------system start end--------\r\n\r\n");
// bool hr_out_flag;
- mac_addr_t MAC_T = {0};
- gap_address_get(&MAC_T);
- co_printf("MAC: %X:%X:%X:%X:%X:%X\n",MAC_T.addr[0],MAC_T.addr[1],MAC_T.addr[2],MAC_T.addr[3],MAC_T.addr[4],MAC_T.addr[5]);
+ // mac_addr_t MAC_T = {0};
+ // gap_address_get(&MAC_T);
+ // co_printf("MAC: %X:%X:%X:%X:%X:%X\n",MAC_T.addr[0],MAC_T.addr[1],MAC_T.addr[2],MAC_T.addr[3],MAC_T.addr[4],MAC_T.addr[5]);
// timer_init(TIMER0,10000,TIMER_PERIODIC);//10ms
// timer_run(TIMER0);
// NVIC_EnableIRQ(TIMER0_IRQn);
sensor_init();
//os_user_loop_event_set(sensor_while);
- system_sleep_enable();
+ //system_sleep_enable();
}
char is_HA_activate = 0;
#define HA_BUF_LEN 6*1024
unsigned char *HA_BUF = NULL;//恒爱算法库和中医算法库缓冲区
-
+static os_timer_t YYL_timer = {0};
+static os_timer_t sensor_timer = {0};
int yyl_in_data_len = 0;
char yyl_close_flag = 0;
extern char send_wear_data_flag;//发送wear数据标致位
extern char send_yyl_data_flag;//中医标致位
extern char send_emo_data_flag;//情绪标致位
-extern uint8_t bp_data[49];
+extern uint8_t *bp_data;
uint8_t uart0_residue_data[]="\"}\n";
extern AlgoCalcResultsTypeDef vc9202_alg_results;
char task_sensor_evn_flag = 0;
os_event_t evt;
int os_msg_post_count = 0;
-unsigned char USER_IRQ_FLAG = 0;
+unsigned char USER_IRQ_LOCK = 0;
unsigned char BP_IRQ_FLAG = 0;
__attribute__((section("ram_code"))) void pmu_gpio_isr_ram(void) //中断处理
// ool_write32(PMU_REG_PORTD_LAST, gpio_value);
//co_printf("IRQ\r\n");
//co_printf("pressed_key:0x%x,gpio_value:0x%x,pmu_int_pin_setting:0x%x,GPIO_PC7:0x%x!!!!!!!!!\r\n", pressed_key,gpio_value,pmu_int_pin_setting,GPIO_PC7);//PD PC PB PA
- if(USER_IRQ_FLAG == 1)
+ //
+
+ if(USER_IRQ_LOCK == 1)
{
+ //co_printf("g:0x%x\r\n",gpio_value);
//co_printf("IRQ_FLAG_ERROR\r\n");
return;
}
- //if((pressed_key&GPIO_PC7)!=0)//PC7//心率中断 低电平
+
+ if((gpio_value&GPIO_PD7)==0)//PD7 //4G中断0
{
+ user_event_send(USER_4G_IRQ, NULL, NULL);
+ //co_printf("PD7 = 0 \r\n");
+ USER_IRQ_LOCK =1;
+ }
+ else if((gpio_value&GPIO_PC7)==0)//PC7//心率中断 低电平
+ {
+
+ USER_IRQ_LOCK =1;
//co_printf("PC7 = 0 \r\n");
- user_event_send(USER_IRQ, NULL, NULL);//无法判断是哪个中断产生,只能都执行
+
+ user_event_send(USER_VC_IRQ, NULL, NULL);//
//co_printf("IRQ_ERROR1:gpio_value:0x%x\r\n",gpio_value);
- USER_IRQ_FLAG =1;
+
+
+
+ }else
+ {
+ co_printf("x:0x%x\r\n",gpio_value);
}
- // if((pressed_key&GPIO_PD7)==0)//PD7 //4G中断1
- // {
- // user_event_send(USER_4G_IRQ, NULL, NULL);
- // co_printf("PD7 = 0 \r\n");
- // }
- // if((pressed_key&GPIO_PD6)!=0)//PD6 //4G中断0
- // {
- // //co_printf("PD6 = 0 \r\n");
- // }
- // if((pressed_key&GPIO_PD5)!=0)//PD5//血压中断
- // {
- // //co_printf("PD5 = 0 \r\n");
- // BP_IRQ_FLAG = 1;
- // }
- // if((pressed_key&GPIO_PD4)!=0)//PD4// 三轴地磁传感器中断
- // {
- // //co_printf("PD4 = 0 \r\n");
- // }
- //NVIC_DisableIRQ(PMU_IRQn);
+
}
return 1;
}
-////////////////////////////获取Gsensor数据//////////////////////////////////////////////////////
+void sensor_timer_handle(void *arg)
+{
+ static unsigned char wear_tmp = 3;
+ UART_send_buf_len = 0;
+ memset(UART_send_buf,0,UART_SEND_MAX);
+ //co_printf("sensor_timer_handle!!!\r\n");
+ if(send_hrs_data_flag)//心率数据发送
+ {
+ if(vc9202_alg_results.hr_rate != 0)
+ {
+
+ co_printf("hr_rate:%d \n",vc9202_alg_results.hr_rate);
+ UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"hrs_data\":\"%d\"}\n",vc9202_alg_results.hr_rate);
+
+ }
+ }else if(send_spo2_data_flag )//血氧数据发送
+ {
+ if(vc9202_alg_results.spo2_val != 0 )
+ {
+ co_printf("spo2_val:%d \n",vc9202_alg_results.spo2_val);
+ memset(UART_send_buf,0,UART_SEND_MAX);
+ UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"spo2_data\":\"%d\"}\n",vc9202_alg_results.spo2_val);
+ }
+ }else if(send_temp_data_flag )//温度数据发送
+ {
+ float temp = get_tp_data();
+ UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"temp_data\":\"%f\"}\n",temp);
+ }
+ if(wear_tmp == 3 || vc9202_alg_results.wear_status != wear_tmp)//佩戴状态发送改变时,发送佩戴状态
+ {
+
+ UART_send_buf_len += snprintf((char *)UART_send_buf+UART_send_buf_len,UART_SEND_MAX-UART_send_buf_len,"{\"cmd\":\"2\",\"wear_data\":\"%d\"}\n",vc9202_alg_results.wear_status);
+ co_printf("wear:%s\r\n",UART_send_buf);
+ }
+ if(UART_send_buf[0]!= 0x00)//发送数据
+ {
+
+ uart0_write_data(UART_send_buf,UART_send_buf_len);
+ }
+
+ wear_tmp = vc9202_alg_results.wear_status;
+
+}
+void switch_sensor_timer(bool en)
+{
+ if(sensor_timer.timer_id == 0)
+ {
+ os_timer_init(&sensor_timer, sensor_timer_handle, NULL);
+ }
+ if(en)
+ {
+ if(send_hrs_data_flag)//心率,5秒上传一次
+ {
+ os_timer_start(&sensor_timer, 5*1000, true);
+ }else if(send_spo2_data_flag )//血氧,5秒上传一次
+ {
+ os_timer_start(&sensor_timer, 5*1000, true);
+ }else if(send_temp_data_flag )//温度,5秒上传一次
+ {
+ os_timer_start(&sensor_timer, 5*1000, true);
+ }else if(send_wear_data_flag )//佩戴,5秒上传一次
+ {
+ os_timer_start(&sensor_timer, 5*1000, true);
+ }else if(send_yyl_data_flag )//中医更新佩戴模式,5秒上传一次
+ {
+ os_timer_start(&sensor_timer, 5*1000, true);
+ }
+ }else
+ {
+ if(sensor_timer.timer_id != 0)
+ {
+ os_timer_stop(&sensor_timer);
+ }
+ }
+
+
+
+}
+////////////////////////////获取Gsensor数据//////////////////////////////////////////////////////
void gsensor_init(void)
{
signed short sl_x_dat[5], sl_y_dat[5],sl_z_dat[5];
- co_delay_100us(5);
+ //co_delay_100us(5);
SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_INIT();
//while(1)
//{
read_BP_data();//读血压数据
read_BP_data_len += 16;
- co_printf("read_BP_data_len :%d\r\n",read_BP_data_len);
+
uart0_receive();//串口0接收数据处理
irq_flag=0;
}
return send_bp_data_flag;
}
+
+void send_BP_data(void)
+{
+
+ if(bp_data_len != 0)
+ {
+ unsigned int count = 1000;//1s超时
+ pmu_set_gpio_value(GPIO_PORT_D, BIT(6), 0);//唤醒4g要写数据了
+ while(pmu_get_gpio_value(GPIO_PORT_D,GPIO_BIT_7))//等待唤醒成功
+ {
+ count --;
+ co_delay_10us(100);
+ if(count <= 0)
+ {
+
+ break;
+ }
+ }
+
+ //输出血压数据到串口0
+ //co_printf("bp_data_len:%d\n",bp_data_len);
+ uart0_write_for_hci("{\"cmd\":\"2\",\"bp_data\":\"",strlen("{\"cmd\":\"2\",\"bp_data\":\""),NULL, NULL);
+ UART_send_buf_len = 0;
+
+ for(int i=0;i<bp_data_len;i++)//转码
+ {
+ UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"%02X",bp_data[i]);
+ // uintTOstr(bp_data[i]);
+ // uart_putc_noint(UART0,str_high);
+ // uart_putc_noint(UART0,str_low);
+ uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
+ }
+ uart0_write_for_hci("\"}\r\n", 3, NULL, NULL);
+ memset(bp_data,0,sizeof(bp_data));
+
+ bp_data_len =0;
+ pmu_set_gpio_value(GPIO_PORT_D, BIT(6), 1);//恢复
+ co_printf("send_BP_data:read_BP_data_lenL:%d,count:%d\r\n",read_BP_data_len,count);
+ user_event_send(USER_4G_IRQ, NULL, NULL);//读取数据
+
+ }
+
+}
+
#define EMO_IN_BUF_SIZE SAMPLERATE*SAMPLETIME
static char * _float_to_char(float x, char *p,int buf_len) {
char *s = p + buf_len; // go to end of buffer
co_printf(" EMO_test:status:%d emo_out_Fm_len:%d\n",status,emo_out_Fm_len);
if(emo_out_Fm_len != 0)
{
- //sensor_INT();//唤醒上位机
UART_send_buf_len += snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"emo_data\":[");
//co_printf(" EMO_test:1:%d \n",UART_send_buf_len);
for(int j=0;j<emo_out_Fm_len;j++)
return send_emo_data_flag;
}
-#if !VC9202_OPEN_IRQ //不开中断,死循环测试
-char HRS_test(void)
-{
- bool irq_flag=0;
- while(send_hrs_data_flag)//心率
- {
- while(gpio_get_pin_value(GPIO_PORT_C, GPIO_BIT_7)==1&&send_hrs_data_flag)//等待HR_INT变低
- {
- //co_printf(" get_HR_waite \n");
- //vcHr02IRQHandler();
- co_delay_100us(10);
- irq_flag=1;
- uart0_receive();//串口0接收数据处理
- }
- while((gpio_get_pin_value(GPIO_PORT_C, GPIO_BIT_7)==0)&&irq_flag&&send_hrs_data_flag)//等待HR_INT变高 //高电平获取数据
- {
- //co_printf("HRS_test1!!!!!!!!\n");
- vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,1);
- //co_printf("HRS_test2!!!!!!!!\n");
- uart0_receive();//串口0接收数据处理
- irq_flag = 0;
- }
- }
- return send_hrs_data_flag;
-}
-char HRV_test(void)
-{
- if(send_hrv_data_flag)//心率变异性
- {
-
- vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,1);
-
- uart0_receive();//串口0接收数据处理
- // if(vc9202_alg_results.hr_rate >0)
- // {
- // co_printf("hr_rate:%d \n",vc9202_alg_results.hr_rate);
- // memset(UART_send_buf,0,UART_SEND_MAX);
- // UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"hrs_data\":\"%d\"}\n",vc9202_alg_results.hr_rate);
- // uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
- // vc9202_alg_results.hr_rate = 0;
- // }
-
- }
- return send_hrv_data_flag;
-}
-char SPO2_test(void)
-{
- char irq_flag;
- while(send_spo2_data_flag)//放入定时测量的值,如果1分钟内没检测到值就退出
- {
- while(gpio_get_pin_value(GPIO_PORT_C, GPIO_BIT_7)==1&&send_spo2_data_flag)//等待HR_INT变低
- {
- //co_printf(" get_SPO2_waite \n");
- //vcHr02IRQHandler();
- co_delay_100us(10);
- irq_flag=1;
- uart0_receive();//串口0接收数据处理
- }
- while((gpio_get_pin_value(GPIO_PORT_C, GPIO_BIT_7)==0)&&irq_flag&&send_spo2_data_flag)//等待HR_INT变高
- {
- irq_flag=0;
- uart0_receive();//串口0接收数据处理
-
- vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,1);
-
- }
- }
-
- return send_spo2_data_flag;
-}
-char wear_test(void)
-{
- char irq_flag;
- while(send_wear_data_flag)//放入定时测量的值
- {
- while(gpio_get_pin_value(GPIO_PORT_C, GPIO_BIT_7)==1&&send_wear_data_flag)//等待HR_INT变低
- {
- //co_printf(" get_SPO2_waite \n");
- //vcHr02IRQHandler();
- co_delay_100us(10);
- irq_flag=1;
- uart0_receive();//串口0接收数据处理
- }
- while((gpio_get_pin_value(GPIO_PORT_C, GPIO_BIT_7)==0)&&irq_flag&&send_wear_data_flag)//等待HR_INT变高
- {
- irq_flag=0;
- uart0_receive();//串口0接收数据处理
-
- vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,1);
-
- }
- }
-
- return send_wear_data_flag;
-}
-//工厂模式
-char factory_test(void)
-{
- char irq_flag;
- while(send_factory_data_flag)//放入定时测量的值,如果1分钟内没检测到值就退出
- {
- while(gpio_get_pin_value(GPIO_PORT_C, GPIO_BIT_7)==1&&send_factory_data_flag)//等待HR_INT变低
- {
- //co_printf(" get_factory_waite \n");
- //vcHr02IRQHandler();
- irq_flag=1;
- uart0_receive();//串口0接收数据处理
- }
- while((gpio_get_pin_value(GPIO_PORT_C, GPIO_BIT_7)==0)&&irq_flag&&send_factory_data_flag)//等待HR_INT变高
- {
- irq_flag=0;
- uart0_receive();//串口0接收数据处理
-
- vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,1);//在中断处理函数返回协议数据
- }
- }
-
- return send_factory_data_flag;
-}
-////////////////////////////////////云医链中医测试////////////////////////////////////////////////
-char YYL_test(void)
-{
- char irq_flag;
-
- while(send_yyl_data_flag==1)//中医
- {
- while(gpio_get_pin_value(GPIO_PORT_C, GPIO_BIT_7)==1&&send_yyl_data_flag)//等待HR_INT变低
- {
- //co_printf(" get_SPO2_waite \n");
- //vcHr02IRQHandler();
- irq_flag=1;
- uart0_receive();//串口0接收数据处理
- }
- while((gpio_get_pin_value(GPIO_PORT_C, GPIO_BIT_7)==0)&&irq_flag&&send_yyl_data_flag)//等待HR_INT变高
- {
- //加心率获取到数据退出测量或者加获取有效数据次数或者测试时间
-
- //co_printf("YYL_test1!!\n");
- vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,1);//里面获取ppg数据
- uart0_receive();//串口0接收数据处理
- if(yyl_in_data_len< YYL_PPG_TEST_LEN-1)
- {
-
-
- }else
- {
- // sensor_INT();//唤醒上位机
- // co_delay_10us(100*1000);
- }
- irq_flag = 0;
- //co_printf("YYL_test2!!\n");
- }
- }
-
-
- // YYL_test_count++;
- // co_printf("os_msg_post_count:%d YYL_test_count:%d\n",os_msg_post_count,YYL_test_count);
- return send_yyl_data_flag;
-}
-char temp_test(void)
-{
- bool irq_flag=0;
- while(send_temp_data_flag)
- {
- while(gpio_get_pin_value(GPIO_PORT_C, GPIO_BIT_7)==1&&send_temp_data_flag)//等待HR_INT变低
- {
- //vcHr02IRQHandler();
- co_delay_100us(10);
- uart0_receive();//串口0接收数据处理
- irq_flag = 1;
- }
- while((gpio_get_pin_value(GPIO_PORT_C, GPIO_BIT_7)==0)&&irq_flag&&send_temp_data_flag)//等待HR_INT变高 //高电平获取数据
- {
- vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,1);
- uart0_receive();//串口0接收数据处理
- irq_flag = 0;
- }
- }
- return send_temp_data_flag;
-}
-#endif
////////////////////////////////////云医链中医测试////////////////////////////////////////////////
// }
if(yyl_in_data_len>= YYL_PPG_TEST_LEN-1)
{
+ unsigned int count = 1000;//1s超时
+ pmu_set_gpio_value(GPIO_PORT_D, BIT(6), 0);//唤醒4g要写数据了
+ while(pmu_get_gpio_value(GPIO_PORT_D,GPIO_BIT_7))//等待唤醒成功
+ {
+ count --;
+ co_delay_10us(100);
+ if(count <= 0)
+ {
+ break;
+ }
+ }
+
+
co_printf("WORK_MODE_HRV hr:%d \nPPG:",vc9202_alg_results.hr_rate);
pOutputData = YYL_Output_PFE(&pOutputData_len);
co_printf("YYL_test:pOutputData_len:%d\n",pOutputData_len);
"{\"cmd\":\"2\",\"yyl_data\":\"");
uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
printf_len+=UART_send_buf_len;
- co_printf("%s",UART_send_buf);
+ //co_printf("%s",UART_send_buf);
//pOutputData_len = 10;
if(pOutputData_len > 50)
pOutputData_len = 50;
uart0_write_for_hci("\"}\n",sizeof("\"}\n"),NULL, NULL);
printf_len+=3;
co_printf("%s","\"}\n");
- co_printf("YYL_test:printf_len:%d\n",printf_len);
+ co_printf("YYL_test:printf_len:%d,count:%d\r\n",printf_len,count);
if(HA_BUF != NULL)
YYL_Init_PFE( HA_BUF, HA_BUF_LEN);//中医初始化
yyl_in_data_len =0;
- // ///////关闭//////////
- // pInit_Param.work_mode = WORK_MODE_NONE;
- // vc9202_usr_init(&pInit_Param);
- // send_yyl_data_flag=2;
-
- //co_printf(" colse\n");
+
+ pmu_set_gpio_value(GPIO_PORT_D, BIT(6), 1);//恢复
}
}
////////////////////////////获取温度数据//////////////////////////////////////////////////////
int temper_data;
-void get_tp_data()
+float get_tp_data()
{
#define ACNT117_ADDR 0x49
char write_buffer[2] = {0};
- co_delay_100us(5);
+ //co_delay_100us(5);
IIC0_Start_I2c();
IIC0_Write_One_Byte(ACNT117_ADDR);
IIC0_Read_NAck();
temp = temper_data;
temp = (temp) /256;
// co_printf(" temp = %d \n",(int)(tmp*100));
- co_printf(" temp = %d.%d \n",(int)temp,(int)(temp*100)%100);
+
//休眠
write_buffer[0] = 0xA0 ;
write_buffer[1] = 0x60;
IIC0_Write_handle(ACNT117_ADDR, 0x01,(void *)write_buffer, 2);
- co_delay_100us(500);
+ //co_delay_100us(500);
// }
+ co_printf(" temp = %d.%d \n",(int)temp,(int)(temp*100)%100);
+ return temp;
}
void send_temp_data(void)
{
//co_printf("[CHENG]:send_temp_data\r\n");
- get_tp_data();
- UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"temp_data\":\"");
- uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
- float shi=0.00,ge=0.00;
- shi=(temper_data/256)/10;
- ge=(temper_data/256)%10;
- uart_putc_noint(UART0,(int)(shi+48)); //0x30
- uart_putc_noint(UART0,(int)(ge+48));
- uart_putc_noint(UART0,'.');
- shi = temper_data;
- shi = shi/256;
- shi = (int)(shi*100)%100/10;
- uart_putc_noint(UART0,(int)shi+48); //0x30
- ge= temper_data;
- ge = ge/256;
- ge = (int)(ge*100)%100%10;
- uart_putc_noint(UART0,(int)ge+48); //0x30
- uart0_write_for_hci(uart0_residue_data, 3, NULL, NULL);
- //co_delay_100us(1000);
+ float temp = get_tp_data();
+ UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"temp_data\":\"%f\"}\n",temp);
+ uart0_write_data(UART_send_buf,UART_send_buf_len);
+
}
gpio_set_dir(GPIO_PORT_D, GPIO_BIT_5, GPIO_DIR_IN);
system_set_port_pull(GPIO_PD5, true); //设置上拉
//gpio_set_pin_value(GPIO_PORT_D, GPIO_BIT_5, 1); //血压中断
+
pmu_set_gpio_value(GPIO_PORT_A, BIT(1), 1); //血压使能
pmu_set_gpio_value(GPIO_PORT_A, BIT(0), 1); //心率失能
//pmu_port_wakeup_func_set(GPIO_PD5);//使能血压中断
- pmu_port_wakeup_func_clear(GPIO_PC7);//使能心率中断
+ pmu_port_wakeup_func_clear(GPIO_PC7);//关闭心率中断
+ pmu_port_wakeup_func_clear(GPIO_PD7);//关闭4G中断
co_delay_100us(5000);
IIC1_Start_I2c();
IIC1_Write_One_Byte(0x0A);
IIC1_Stop_I2c( );
send_bp_data_flag = 1;
read_BP_data_len =0;
+
+ if(bp_data != NULL)
+ {
+ os_free(bp_data);
+ bp_data = NULL;
+ }
+ bp_data = os_malloc(BP_DATA_MAX_LEN);
co_printf(" BP_open \n");
+
user_event_send(USER_EVT_OPEN_BP, NULL, NULL);
}
co_printf(" EMO_open \n");
}
-static os_timer_t YYL_timer = {0};
+
void YYL_timer_handle(void *arg)//1分钟开始一次
{
+ co_printf(" YYL_timer_handle!!!!\r\n");
if(send_yyl_data_flag == 0)
{
co_printf(" YYL_timer_handle return \n");
pInit_Param.work_mode = WORK_MODE_HRV;
vc9202_usr_init(&pInit_Param);
yyl_in_data_len = 0;
+ co_printf("timer YYL mode !!!\r\n");
}
void YYL_open(void)//中医
{
pmu_set_gpio_value(GPIO_PORT_A, BIT(0), 1); //心率使能
pmu_set_gpio_value(GPIO_PORT_A, BIT(1), 0); //血压使能
pmu_port_wakeup_func_set(GPIO_PC7);//使能心率中断
+ pmu_port_wakeup_func_set(GPIO_PD7);//GPIO中断
pInit_Param.work_mode = WORK_MODE_HRV;
vc9202_usr_init(&pInit_Param);
if(HA_BUF != NULL)
send_yyl_data_flag = 1;
if(YYL_timer.timer_id == 0)
{
+ //co_printf("YYL_timer init \r\n");
os_timer_init(&YYL_timer, YYL_timer_handle, NULL);
os_timer_start(&YYL_timer, 60*1000, true);
}
-
- co_printf(" YYL_open \n");
+ switch_sensor_timer(true);
+ co_printf(" YYL_open \r\n");
yyl_in_data_len = 0;
//init_algorithm(HA_BUF, sizeof(HA_BUF));
pmu_set_gpio_value(GPIO_PORT_A, BIT(0), 1); //心率使能
pmu_set_gpio_value(GPIO_PORT_A, BIT(1), 0); //血压使能
pmu_port_wakeup_func_set(GPIO_PC7);//使能心率中断
+ pmu_port_wakeup_func_set(GPIO_PD7);//GPIO中断
pInit_Param.work_mode = WORK_MODE_HR;
vc9202_usr_init(&pInit_Param);
send_hrs_data_flag = 1;
//vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,1);
+ switch_sensor_timer(true);
co_printf(" HRS_open \n");
}
pmu_set_gpio_value(GPIO_PORT_A, BIT(0), 1); //心率使能
pmu_set_gpio_value(GPIO_PORT_A, BIT(1), 0); //血压使能
pmu_port_wakeup_func_set(GPIO_PC7);//使能心率中断
+ pmu_port_wakeup_func_set(GPIO_PD7);//GPIO中断
pInit_Param.work_mode = WORK_MODE_SPO2;
vc9202_usr_init(&pInit_Param);
send_spo2_data_flag = 1;
co_printf(" SPO2_open \n");
-
+ switch_sensor_timer(true);
//vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,1);
}
pmu_set_gpio_value(GPIO_PORT_A, BIT(0), 1); //心率使能
pmu_set_gpio_value(GPIO_PORT_A, BIT(1), 0); //血压使能
pmu_port_wakeup_func_set(GPIO_PC7);//使能心率中断
+ pmu_port_wakeup_func_set(GPIO_PD7);//GPIO中断
pInit_Param.work_mode = WORK_MODE_WEAR; // WORK_MODE_TEMPERATURE;
vc9202_usr_init(&pInit_Param);
send_temp_data_flag = 1;
+ switch_sensor_timer(true);
//co_printf("[CHENG]:temp_open\r\n");
}
pmu_set_gpio_value(GPIO_PORT_A, BIT(0), 1); //心率使能
pmu_set_gpio_value(GPIO_PORT_A, BIT(1), 0); //血压使能
pmu_port_wakeup_func_set(GPIO_PC7);//使能心率中断
+ pmu_port_wakeup_func_set(GPIO_PD7);//GPIO中断
pInit_Param.work_mode = WORK_MODE_WEAR;
vc9202_usr_init(&pInit_Param);
send_wear_data_flag = 1;
+ switch_sensor_timer(true);
co_printf(" wear_open \n");
//vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,1);
pmu_set_gpio_value(GPIO_PORT_A, BIT(0), 1); //心率使能
pmu_set_gpio_value(GPIO_PORT_A, BIT(1), 0); //血压使能
pmu_port_wakeup_func_set(GPIO_PC7);//使能心率中断
+ pmu_port_wakeup_func_set(GPIO_PD7);//GPIO中断
pInit_Param.work_mode = WORK_MODE_FACTORY;
vc9202_usr_init(&pInit_Param);
send_factory_data_flag = 1;
+ switch_sensor_timer(true);
co_printf(" factory_open \n");
//vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,1);
}
if(YYL_timer.timer_id != 0)
os_timer_stop(&YYL_timer);
+ switch_sensor_timer(false);
co_printf(" sensor_close \n");
}
void sensor_while(void)
{
- uart0_receive();
+ //uart0_receive();
//factory_open();
#if VC9202_OPEN_IRQ
- if(USER_IRQ_FLAG == 1)
+ if(USER_IRQ_LOCK == 1)
{
- USER_IRQ_FLAG = 0;
+ USER_IRQ_LOCK = 0;
vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,1);
//system_sleep_enable();
}
//if(BP_IRQ_FLAG == 1)
{
- //co_printf("sensor_while:USER_IRQ_FLAG:%d BP_IRQ_FLAG:%d\r\n",USER_IRQ_FLAG,BP_IRQ_FLAG);
+ //co_printf("sensor_while:USER_IRQ_LOCK:%d BP_IRQ_FLAG:%d\r\n",USER_IRQ_LOCK,BP_IRQ_FLAG);
BP_IRQ_FLAG = 0;
EMO_test();
BP_test();
//4G_INT1 = PD7 //4G中断1
pmu_set_aldo_voltage(PMU_ALDO_MODE_NORMAL,PMU_ALDO_VOL_2_1); //设置内部LDO输出电压
- // system_set_port_mux(GPIO_PORT_D, GPIO_BIT_6, PORTD0_FUNC_D0);
- // pmu_set_pin_to_PMU(GPIO_PORT_D, BIT(6) );
- // pmu_set_pin_pull(GPIO_PORT_D, BIT(6) , false);
- // pmu_set_pin_dir(GPIO_PORT_D, BIT(6), GPIO_DIR_OUT);
- // pmu_set_gpio_value(GPIO_PORT_D, BIT(6), 0);//中断信号使能 低电平
+ //system_set_port_mux(GPIO_PORT_D, GPIO_BIT_6, PORTD0_FUNC_D0);
+ pmu_set_port_mux(GPIO_PORT_D, GPIO_BIT_6, PMU_PORT_MUX_GPIO);
+ pmu_set_pin_to_PMU(GPIO_PORT_D, BIT(6) );
+ pmu_set_pin_pull(GPIO_PORT_D, BIT(6) , false);
+ pmu_set_pin_dir(GPIO_PORT_D, BIT(6), GPIO_DIR_OUT);
+ pmu_set_gpio_value(GPIO_PORT_D, BIT(6), 1);//中断信号使能 低电平
//4G读数据中断
// pmu_set_port_mux(GPIO_PORT_D, GPIO_BIT_6, PMU_PORT_MUX_GPIO);
// pmu_set_pin_to_PMU(GPIO_PORT_D, BIT(6));
//pmu_set_pin_pull(GPIO_PORT_D,BIT(7),true);//上拉 //4G中断1
//pmu_port_wakeup_func_set(GPIO_PC7|GPIO_PD4|GPIO_PD5|GPIO_PD6|GPIO_PD7);//GPIO中断
//pmu_port_wakeup_func_set(GPIO_PC7|GPIO_PD4|GPIO_PD6|GPIO_PD7);//GPIO中断
- NVIC_EnableIRQ(PMU_IRQn);
+
user_i2c0_init();
get_tp_data();
gsensor_init();//gsensor初始化
-
+ NVIC_EnableIRQ(PMU_IRQn);
+ vc9202_alg_results.wear_status = 1;
//测试代码
//OTA_open();//OTA升级
//wear_open();//佩戴
// #define PPG_BUF_LEN 60*100
// extern char ppg_buf[PPG_BUF_LEN];
// extern int ppg_buf_len ;
+#define BP_DATA_MAX_LEN 81*3*2
#define YYL_PPG_TEST_LEN 2000 //中医一分钟测试数据量
typedef enum
{
BP_IRQ ,//血压中断
}SENSOR_IRQ;
-
+extern uint8_t *bp_data;
+extern uint16_t bp_data_len ;
extern int yyl_in_data_len;
int task_sensor_evn(os_event_t *param);
void BP_open(void);//血压
void sensor_close(void);
void gsensor_init(void);
char BP_test(void);
+void send_BP_data(void);
char HRS_test(void);
char HRV_test(void);
char SPO2_test(void);
char YYL_test(void);
void YYL_test_timer(void);
char EMO_test(void);
-void get_tp_data(void);
+float get_tp_data(void);
//void temp_test(void);
void send_temp_data(void);
void gsensor_test(void);
#include "sensor_drive.h"
uint16_t user_task_id = 0;
extern int uart0_data_len ;
+extern uint8_t *uart0_rivce_data ;
extern char uart0_flag;
-extern unsigned char USER_IRQ_FLAG;
+extern unsigned char USER_IRQ_LOCK;
static int user_task_func(os_event_t *param)
{
- static int USER_IRQ_count = 0;
+ //static int USER_IRQ_count = 0;
+ //co_printf("user_task_func!!param->event_id:%d\r\n",param->event_id);
+ unsigned int while_count = 100;
+ //uart0_isr_ram();//读串口数据
+
switch (param->event_id)
{
- case USER_IRQ:
- //
- USER_IRQ_count++;
- co_delay_10us(1);
- if(USER_IRQ_count > 50)//等待1.5ms再处理数据
+ case USER_4G_IRQ:
+ pmu_set_gpio_value(GPIO_PORT_D, BIT(6), 0);//告诉4g可以写数据了
+ while(while_count--)
{
- //co_printf("USER_IRQ!!uart0_data_len:%d\r\n",uart0_data_len);
- if(uart0_data_len > 0 )
+ uart0_isr_ram();//读串口数据
+ if(uart0_flag != 0 )
{
- if(uart0_flag == 0 && USER_IRQ_count < 80000)//数据没接收完,等待数据接收完,最大等待800ms
- {
- user_event_send(USER_IRQ, NULL, NULL);
- }
- else
- {
- USER_IRQ_count = 0;
- user_parse_data();//串口数据处理
- USER_IRQ_FLAG = 0;
- system_sleep_enable();//睡眠
- }
-
+ break;
}
- else
- {
- USER_IRQ_count = 0;
- //co_printf("USER_HR_IRQ!!\r\n");
- vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,1);//心率中断处理
- USER_IRQ_FLAG = 0;
- system_sleep_enable();//睡眠
- }
-
- }else
- user_event_send(USER_IRQ, NULL, NULL);
-
+
+ co_delay_10us(100);
+ }
+ if(while_count == 0)
+ co_printf("USER_IRQ timerout uart0_data_len:%d,while_count:%d3333333333333333333!!!!!\r\n",uart0_data_len,while_count);
+ uart0_receive();
+ pmu_set_gpio_value(GPIO_PORT_D, BIT(6), 1);//休眠 低电平
break;
+ case USER_VC_IRQ: //4g中断可能触发这里
+ //o_printf("USER_VC_IRQ!!!!!!\r\n");
+ vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,1);//心率中断处理
+
+
+ break;
case USER_EVT_OPEN_BP:
+ pmu_set_gpio_value(GPIO_PORT_D, BIT(6), 0);//告诉4g可以写数据了
BP_test();
+ pmu_set_gpio_value(GPIO_PORT_D, BIT(6), 1);//告诉4g可以写数据了
break;
case USER_EVT_ENTER_SLEEP:
co_printf("exit sleep!!\r\n");
break;
}
-
+ USER_IRQ_LOCK = 0;
return EVT_CONSUMED;
}
void user_task_init(void)
user_event.param = p_data;
user_event.param_len = len;
if(user_task_id != 0)
- os_msg_post(user_task_id, &user_event);
+ {
+ //co_printf("user_event_send user_task_id:%d event:%d!!\r\n",user_task_id,event);
+ os_msg_post(user_task_id, &user_event);
+ }
+ else
+ {
+ co_printf("user_event_send error!!\r\n");
+ }
}
enum user_event_t {
- USER_IRQ,
+ USER_4G_IRQ,
+ USER_VC_IRQ,
USER_EVT_OPEN_BP,
USER_EVT_ENTER_SLEEP,
USER_EVT_EXIT_SLEEP,
}
}
-__attribute__((weak)) __attribute__((section("ram_code"))) void uart0_isr_ram(void)
-{
- uint8_t int_id;
- uint8_t c;
- volatile struct uart_reg_t *uart_reg = (volatile struct uart_reg_t *)UART0_BASE;
-
- int_id = uart_reg->u3.iir.int_id;
- if(int_id == 0x04 || int_id == 0x0c ) /* Receiver data available or Character time-out indication */
- {
- c = uart_reg->u1.data;
- uart_putc_noint(UART0,c);
- }
- else if(int_id == 0x06)
- {
- volatile uint32_t line_status = uart_reg->lsr;
- }
-}
#endif
void uart_init1(uint32_t uart_addr, uart_param_t param)
*/
void uart1_write_for_hci(uint8_t *bufptr, uint32_t size, uart_int_callback callback, void *dummy);
#define uart1_write(bufptr, size, callback) uart1_write_for_hci(bufptr, size, callback, NULL)
-
+void uart_init1(uint32_t uart_addr, uart_param_t param);
/// @} UART
#endif /* _DRIVER_UART_H_ */
<Header>### uVision Project, (C) Keil Software</Header>
<PrjGuiSettings>
- <LastAddFilePath>H:\1.work\3.ASR\3.Z5\1.doc\K18\BLE_Watch\code</LastAddFilePath>
+ <LastAddFilePath>H:\1.work\3.ASR\3.Z5\1.doc\K18\BLE_Watch\keil\VC9202</LastAddFilePath>
</PrjGuiSettings>
<ViewPool/>
<yPos>-1</yPos>
</MaxPosition>
<NormalPosition>
- <Top>235</Top>
- <Left>142</Left>
- <Right>1417</Right>
- <Bottom>963</Bottom>
+ <Top>214</Top>
+ <Left>57</Left>
+ <Right>1424</Right>
+ <Bottom>1125</Bottom>
</NormalPosition>
</WindowPosition>
<MDIClientArea>
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
- <Data>F20200002D0100008E070000BB010000</Data>
+ <Data>790200000A0100001507000098010000</Data>
</RectRecentFloat>
</Window>
<Window>
<RecentRowIndex>0</RecentRowIndex>
<RectRecentDocked>
<Len>16</Len>
- <Data>03000000660000004A010000C3010000</Data>
+ <Data>03000000660000004A0100007A020000</Data>
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<RecentRowIndex>0</RecentRowIndex>
<RectRecentDocked>
<Len>16</Len>
- <Data>03000000660000004A010000C3010000</Data>
+ <Data>03000000660000004A0100007A020000</Data>
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<RecentRowIndex>0</RecentRowIndex>
<RectRecentDocked>
<Len>16</Len>
- <Data>03000000660000004A010000C3010000</Data>
+ <Data>03000000660000004A0100007A020000</Data>
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<RecentRowIndex>0</RecentRowIndex>
<RectRecentDocked>
<Len>16</Len>
- <Data>03000000660000004A010000C3010000</Data>
+ <Data>03000000660000004A0100007A020000</Data>
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<RecentRowIndex>0</RecentRowIndex>
<RectRecentDocked>
<Len>16</Len>
- <Data>03000000F7010000E804000085020000</Data>
+ <Data>03000000AE020000440500003C030000</Data>
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<RecentRowIndex>0</RecentRowIndex>
<RectRecentDocked>
<Len>16</Len>
- <Data>03000000F7010000E804000085020000</Data>
+ <Data>03000000AE020000440500003C030000</Data>
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<RecentRowIndex>0</RecentRowIndex>
<RectRecentDocked>
<Len>16</Len>
- <Data>03000000660000004A0100008A010000</Data>
+ <Data>03000000660000004A010000C3010000</Data>
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<RecentRowIndex>0</RecentRowIndex>
<RectRecentDocked>
<Len>16</Len>
- <Data>03000000F7010000E804000085020000</Data>
+ <Data>03000000AE020000E80400003C030000</Data>
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<RecentRowIndex>0</RecentRowIndex>
<RectRecentDocked>
<Len>16</Len>
- <Data>03000000F7010000E804000085020000</Data>
+ <Data>03000000AE020000E80400003C030000</Data>
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<RecentRowIndex>0</RecentRowIndex>
<RectRecentDocked>
<Len>16</Len>
- <Data>03000000F7010000E804000085020000</Data>
+ <Data>03000000AE020000E80400003C030000</Data>
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<RecentRowIndex>0</RecentRowIndex>
<RectRecentDocked>
<Len>16</Len>
- <Data>03000000F7010000E804000085020000</Data>
+ <Data>03000000AE020000E80400003C030000</Data>
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<RecentRowIndex>0</RecentRowIndex>
<RectRecentDocked>
<Len>16</Len>
- <Data>000000009E020000EB040000B1020000</Data>
+ <Data>00000000550300004705000068030000</Data>
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
</Window>
<DockMan>
<Len>3312</Len>
- <Data>000000000B000000000000000020000000000000FFFFFFFFFFFFFFFFF4000000DD00000090050000E1000000000000000100000004000000010000000000000000000000FFFFFFFF08000000CB00000057010000CC000000F08B00005A01000079070000D601000045890000FFFF02000B004354616262656450616E650020000000000000F20200002D0100008E070000BB010000F40000004F00000090050000DD0000000000000040280046080000000B446973617373656D626C7900000000CB00000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A6572000000005701000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A657200000000CC00000001000000FFFFFFFFFFFFFFFF0E4C6F67696320416E616C797A657200000000F08B000001000000FFFFFFFFFFFFFFFF0D436F646520436F766572616765000000005A01000001000000FFFFFFFFFFFFFFFF11496E737472756374696F6E205472616365000000007907000001000000FFFFFFFFFFFFFFFF0F53797374656D20416E616C797A657200000000D601000001000000FFFFFFFFFFFFFFFF104576656E742053746174697374696373000000004589000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFCB00000001000000FFFFFFFFCB000000000000000040000000000000FFFFFFFFFFFFFFFF9C0400004F000000A004000025020000000000000200000004000000010000000000000000000000FFFFFFFF2B000000E2050000CA0900002D8C00002E8C00002F8C0000308C0000318C0000328C0000338C0000348C0000358C0000368C0000378C0000388C0000398C00003A8C00003B8C00003C8C00003D8C00003E8C00003F8C0000408C0000418C000050C3000051C3000052C3000053C3000054C3000055C3000056C3000057C3000058C3000059C300005AC300005BC300005CC300005DC300005EC300005FC3000060C3000061C3000062C3000063C30000018000400000000000009E0600002D0100008E07000003030000A00400004F000000900500002502000000000000404100462B0000000753796D626F6C7300000000E205000001000000FFFFFFFFFFFFFFFF0A5472616365204461746100000000CA09000001000000FFFFFFFFFFFFFFFF00000000002D8C000001000000FFFFFFFFFFFFFFFF00000000002E8C000001000000FFFFFFFFFFFFFFFF00000000002F8C000001000000FFFFFFFFFFFFFFFF0000000000308C000001000000FFFFFFFFFFFFFFFF0000000000318C000001000000FFFFFFFFFFFFFFFF0000000000328C000001000000FFFFFFFFFFFFFFFF0000000000338C000001000000FFFFFFFFFFFFFFFF0000000000348C000001000000FFFFFFFFFFFFFFFF0000000000358C000001000000FFFFFFFFFFFFFFFF0000000000368C000001000000FFFFFFFFFFFFFFFF0000000000378C000001000000FFFFFFFFFFFFFFFF0000000000388C000001000000FFFFFFFFFFFFFFFF0000000000398C000001000000FFFFFFFFFFFFFFFF00000000003A8C000001000000FFFFFFFFFFFFFFFF00000000003B8C000001000000FFFFFFFFFFFFFFFF00000000003C8C000001000000FFFFFFFFFFFFFFFF00000000003D8C000001000000FFFFFFFFFFFFFFFF00000000003E8C000001000000FFFFFFFFFFFFFFFF00000000003F8C000001000000FFFFFFFFFFFFFFFF0000000000408C000001000000FFFFFFFFFFFFFFFF0000000000418C000001000000FFFFFFFFFFFFFFFF000000000050C3000001000000FFFFFFFFFFFFFFFF000000000051C3000001000000FFFFFFFFFFFFFFFF000000000052C3000001000000FFFFFFFFFFFFFFFF000000000053C3000001000000FFFFFFFFFFFFFFFF000000000054C3000001000000FFFFFFFFFFFFFFFF000000000055C3000001000000FFFFFFFFFFFFFFFF000000000056C3000001000000FFFFFFFFFFFFFFFF000000000057C3000001000000FFFFFFFFFFFFFFFF000000000058C3000001000000FFFFFFFFFFFFFFFF000000000059C3000001000000FFFFFFFFFFFFFFFF00000000005AC3000001000000FFFFFFFFFFFFFFFF00000000005BC3000001000000FFFFFFFFFFFFFFFF00000000005CC3000001000000FFFFFFFFFFFFFFFF00000000005DC3000001000000FFFFFFFFFFFFFFFF00000000005EC3000001000000FFFFFFFFFFFFFFFF00000000005FC3000001000000FFFFFFFFFFFFFFFF000000000060C3000001000000FFFFFFFFFFFFFFFF000000000061C3000001000000FFFFFFFFFFFFFFFF000000000062C3000001000000FFFFFFFFFFFFFFFF000000000063C3000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFE205000001000000FFFFFFFFE2050000000000000010000001000000FFFFFFFFFFFFFFFF4D0100004F00000051010000DC010000010000000200001004000000010000006DFEFFFF4D030000FFFFFFFF05000000ED0300006D000000C3000000C40000007394000001800010000001000000FE0100002D0100004B03000081020000000000004F0000004D010000DC0100000000000040410056050000000750726F6A65637401000000ED03000001000000FFFFFFFFFFFFFFFF05426F6F6B73010000006D00000001000000FFFFFFFFFFFFFFFF0946756E6374696F6E7301000000C300000001000000FFFFFFFFFFFFFFFF0954656D706C6174657301000000C400000001000000FFFFFFFFFFFFFFFF09526567697374657273000000007394000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFED03000001000000FFFFFFFFED030000000000000080000000000000FFFFFFFFFFFFFFFF0000000011020000900500001502000000000000010000000400000001000000000000000000000000000000000000000000000001000000C6000000FFFFFFFF0F0000008F070000930700009407000095070000960700009007000091070000B5010000B801000038030000B9050000BA050000BB050000BC050000CB09000001800080000000000000FE010000F30200008E07000095030000000000001502000090050000B702000000000000404100460F0000001343616C6C20537461636B202B204C6F63616C73000000008F07000001000000FFFFFFFFFFFFFFFF0755415254202331000000009307000001000000FFFFFFFFFFFFFFFF0755415254202332000000009407000001000000FFFFFFFFFFFFFFFF0755415254202333000000009507000001000000FFFFFFFFFFFFFFFF15446562756720287072696E74662920566965776572000000009607000001000000FFFFFFFFFFFFFFFF0757617463682031000000009007000001000000FFFFFFFFFFFFFFFF0757617463682032000000009107000001000000FFFFFFFFFFFFFFFF10547261636520457863657074696F6E7300000000B501000001000000FFFFFFFFFFFFFFFF0E4576656E7420436F756E7465727300000000B801000001000000FFFFFFFFFFFFFFFF09554C494E4B706C7573000000003803000001000000FFFFFFFFFFFFFFFF084D656D6F7279203100000000B905000001000000FFFFFFFFFFFFFFFF084D656D6F7279203200000000BA05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203300000000BB05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203400000000BC05000001000000FFFFFFFFFFFFFFFF105472616365204E617669676174696F6E00000000CB09000001000000FFFFFFFFFFFFFFFFFFFFFFFF0000000001000000000000000000000001000000FFFFFFFFC802000015020000CC020000B702000000000000020000000400000000000000000000000000000000000000000000000000000002000000C6000000FFFFFFFF8F07000001000000FFFFFFFF8F07000001000000C6000000000000000080000001000000FFFFFFFFFFFFFFFF00000000DC010000EB040000E0010000010000000100001004000000010000007FFDFFFF8C000000FFFFFFFF06000000C5000000C7000000B4010000D2010000CF0100007794000001800080000001000000FE01000085020000E90600004303000000000000E0010000EB0400009E0200000000000040820056060000000C4275696C64204F757470757401000000C500000001000000FFFFFFFFFFFFFFFF0D46696E6420496E2046696C657301000000C700000001000000FFFFFFFFFFFFFFFF0A4572726F72204C69737400000000B401000001000000FFFFFFFFFFFFFFFF0E536F757263652042726F7773657200000000D201000001000000FFFFFFFFFFFFFFFF0E416C6C205265666572656E63657300000000CF01000001000000FFFFFFFFFFFFFFFF0742726F77736572000000007794000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFC500000001000000FFFFFFFFC5000000000000000000000000000000</Data>
+ <Data>000000000B000000000000000020000000000000FFFFFFFFFFFFFFFFF4000000DD00000090050000E1000000000000000100000004000000010000000000000000000000FFFFFFFF08000000CB00000057010000CC000000F08B00005A01000079070000D601000045890000FFFF02000B004354616262656450616E650020000000000000790200000A0100001507000098010000F40000004F00000090050000DD0000000000000040280046080000000B446973617373656D626C7900000000CB00000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A6572000000005701000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A657200000000CC00000001000000FFFFFFFFFFFFFFFF0E4C6F67696320416E616C797A657200000000F08B000001000000FFFFFFFFFFFFFFFF0D436F646520436F766572616765000000005A01000001000000FFFFFFFFFFFFFFFF11496E737472756374696F6E205472616365000000007907000001000000FFFFFFFFFFFFFFFF0F53797374656D20416E616C797A657200000000D601000001000000FFFFFFFFFFFFFFFF104576656E742053746174697374696373000000004589000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFCB00000001000000FFFFFFFFCB000000000000000040000000000000FFFFFFFFFFFFFFFF9C0400004F000000A004000025020000000000000200000004000000010000000000000000000000FFFFFFFF2B000000E2050000CA0900002D8C00002E8C00002F8C0000308C0000318C0000328C0000338C0000348C0000358C0000368C0000378C0000388C0000398C00003A8C00003B8C00003C8C00003D8C00003E8C00003F8C0000408C0000418C000050C3000051C3000052C3000053C3000054C3000055C3000056C3000057C3000058C3000059C300005AC300005BC300005CC300005DC300005EC300005FC3000060C3000061C3000062C3000063C3000001800040000000000000250600000A01000015070000E0020000A00400004F000000900500002502000000000000404100462B0000000753796D626F6C7300000000E205000001000000FFFFFFFFFFFFFFFF0A5472616365204461746100000000CA09000001000000FFFFFFFFFFFFFFFF00000000002D8C000001000000FFFFFFFFFFFFFFFF00000000002E8C000001000000FFFFFFFFFFFFFFFF00000000002F8C000001000000FFFFFFFFFFFFFFFF0000000000308C000001000000FFFFFFFFFFFFFFFF0000000000318C000001000000FFFFFFFFFFFFFFFF0000000000328C000001000000FFFFFFFFFFFFFFFF0000000000338C000001000000FFFFFFFFFFFFFFFF0000000000348C000001000000FFFFFFFFFFFFFFFF0000000000358C000001000000FFFFFFFFFFFFFFFF0000000000368C000001000000FFFFFFFFFFFFFFFF0000000000378C000001000000FFFFFFFFFFFFFFFF0000000000388C000001000000FFFFFFFFFFFFFFFF0000000000398C000001000000FFFFFFFFFFFFFFFF00000000003A8C000001000000FFFFFFFFFFFFFFFF00000000003B8C000001000000FFFFFFFFFFFFFFFF00000000003C8C000001000000FFFFFFFFFFFFFFFF00000000003D8C000001000000FFFFFFFFFFFFFFFF00000000003E8C000001000000FFFFFFFFFFFFFFFF00000000003F8C000001000000FFFFFFFFFFFFFFFF0000000000408C000001000000FFFFFFFFFFFFFFFF0000000000418C000001000000FFFFFFFFFFFFFFFF000000000050C3000001000000FFFFFFFFFFFFFFFF000000000051C3000001000000FFFFFFFFFFFFFFFF000000000052C3000001000000FFFFFFFFFFFFFFFF000000000053C3000001000000FFFFFFFFFFFFFFFF000000000054C3000001000000FFFFFFFFFFFFFFFF000000000055C3000001000000FFFFFFFFFFFFFFFF000000000056C3000001000000FFFFFFFFFFFFFFFF000000000057C3000001000000FFFFFFFFFFFFFFFF000000000058C3000001000000FFFFFFFFFFFFFFFF000000000059C3000001000000FFFFFFFFFFFFFFFF00000000005AC3000001000000FFFFFFFFFFFFFFFF00000000005BC3000001000000FFFFFFFFFFFFFFFF00000000005CC3000001000000FFFFFFFFFFFFFFFF00000000005DC3000001000000FFFFFFFFFFFFFFFF00000000005EC3000001000000FFFFFFFFFFFFFFFF00000000005FC3000001000000FFFFFFFFFFFFFFFF000000000060C3000001000000FFFFFFFFFFFFFFFF000000000061C3000001000000FFFFFFFFFFFFFFFF000000000062C3000001000000FFFFFFFFFFFFFFFF000000000063C3000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFE205000001000000FFFFFFFFE2050000000000000010000001000000FFFFFFFFFFFFFFFF4D0100004F0000005101000093020000010000000200001004000000010000006DFEFFFF4D030000FFFFFFFF05000000ED0300006D000000C3000000C40000007394000001800010000001000000850100000A010000D202000097020000000000004F0000004D010000930200000000000040410056050000000750726F6A65637401000000ED03000001000000FFFFFFFFFFFFFFFF05426F6F6B73010000006D00000001000000FFFFFFFFFFFFFFFF0946756E6374696F6E7301000000C300000001000000FFFFFFFFFFFFFFFF0954656D706C6174657301000000C400000001000000FFFFFFFFFFFFFFFF09526567697374657273000000007394000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFED03000001000000FFFFFFFFED030000000000000080000000000000FFFFFFFFFFFFFFFF0000000011020000900500001502000000000000010000000400000001000000000000000000000000000000000000000000000001000000C6000000FFFFFFFF0F0000008F070000930700009407000095070000960700009007000091070000B5010000B801000038030000B9050000BA050000BB050000BC050000CB0900000180008000000000000085010000D00200001507000072030000000000001502000090050000B702000000000000404100460F0000001343616C6C20537461636B202B204C6F63616C73000000008F07000001000000FFFFFFFFFFFFFFFF0755415254202331000000009307000001000000FFFFFFFFFFFFFFFF0755415254202332000000009407000001000000FFFFFFFFFFFFFFFF0755415254202333000000009507000001000000FFFFFFFFFFFFFFFF15446562756720287072696E74662920566965776572000000009607000001000000FFFFFFFFFFFFFFFF0757617463682031000000009007000001000000FFFFFFFFFFFFFFFF0757617463682032000000009107000001000000FFFFFFFFFFFFFFFF10547261636520457863657074696F6E7300000000B501000001000000FFFFFFFFFFFFFFFF0E4576656E7420436F756E7465727300000000B801000001000000FFFFFFFFFFFFFFFF09554C494E4B706C7573000000003803000001000000FFFFFFFFFFFFFFFF084D656D6F7279203100000000B905000001000000FFFFFFFFFFFFFFFF084D656D6F7279203200000000BA05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203300000000BB05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203400000000BC05000001000000FFFFFFFFFFFFFFFF105472616365204E617669676174696F6E00000000CB09000001000000FFFFFFFFFFFFFFFFFFFFFFFF0000000001000000000000000000000001000000FFFFFFFFC802000015020000CC020000B702000000000000020000000400000000000000000000000000000000000000000000000000000002000000C6000000FFFFFFFF8F07000001000000FFFFFFFF8F07000001000000C6000000000000000080000001000000FFFFFFFFFFFFFFFF00000000930200004705000097020000010000000100001004000000010000007FFDFFFF8C000000FFFFFFFF06000000C5000000C7000000B4010000D2010000CF0100007794000001800080000001000000850100009B0200007006000059030000000000009702000047050000550300000000000040820056060000000C4275696C64204F757470757401000000C500000001000000FFFFFFFFFFFFFFFF0D46696E6420496E2046696C657301000000C700000001000000FFFFFFFFFFFFFFFF0A4572726F72204C69737400000000B401000001000000FFFFFFFFFFFFFFFF0E536F757263652042726F7773657200000000D201000001000000FFFFFFFFFFFFFFFF0E416C6C205265666572656E63657300000000CF01000001000000FFFFFFFFFFFFFFFF0742726F77736572000000007794000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFC500000001000000FFFFFFFFC5000000000000000000000000000000</Data>
</DockMan>
<ToolBar>
<RegID>59392</RegID>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
- <PathWithFileName>.\VC9202\lib_hr_yll_v0.5.3.031624.lib</PathWithFileName>
- <FilenameWithoutPath>lib_hr_yll_v0.5.3.031624.lib</FilenameWithoutPath>
+ <PathWithFileName>.\VC9202\lib_hr_yll_v0.5.3.041924.lib</PathWithFileName>
+ <FilenameWithoutPath>lib_hr_yll_v0.5.3.041924.lib</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<FilePath>.\VC9202\vc9202_user_debug.c</FilePath>
</File>
<File>
- <FileName>lib_hr_yll_v0.5.3.031624.lib</FileName>
+ <FileName>lib_hr_yll_v0.5.3.041924.lib</FileName>
<FileType>4</FileType>
- <FilePath>.\VC9202\lib_hr_yll_v0.5.3.031624.lib</FilePath>
+ <FilePath>.\VC9202\lib_hr_yll_v0.5.3.041924.lib</FilePath>
</File>
</Files>
</Group>
#include "sys_utils.h"
#include "imitate_iic.h"
#include "string.h"
+#include "sensor_drive.h"
#define IO_I2C_TEST
//IIC0_Write_handle(0x42,0x01,write_data,2);
}
-uint8_t bp_data[250];
+uint8_t *bp_data = NULL ;
uint16_t bp_data_len = 0;
uint8_t bp_data_reuse_count = 0;
//返回1为正常数据,返回0为重复数据,需丢弃
else
IIC1_Send_Ack();
}
- // if(memcmp(bp_data_tmp,bp_data) == 0)//重复数据不要
- // {
- // bp_data_reuse_count++;
- // if(bp_data_reuse_count >= 1)//重复2次以上,保留数据
- // {
- // bp_data_reuse_count = 0;
- // memset(bp_data,0,sizeof(bp_data));
- // }
- // return 0;
- // }else
- // {
- if(bp_data_len+48 < sizeof(bp_data))
+
+ if(bp_data != NULL)
+ {
+ if(bp_data_len+48 <= BP_DATA_MAX_LEN)
{
memcpy(bp_data+bp_data_len,bp_data_tmp,48);
bp_data_len += 48;
- }else
+ }else//满了发送数据
{
+ send_BP_data();
bp_data_len = 0;
memcpy(bp_data+bp_data_len,bp_data_tmp,48);
bp_data_len += 48;
}
-
- #if 0
- co_printf("BP_DATA : ");
- for(uint8_t i=0;i<48;i++)
- {
- co_printf("%02X ",bp_data[i]);
- }
- co_printf("\n");
-
- #endif
- return 1;
- //}
+ }
+
+
+ #if 0
+ co_printf("BP_DATA : ");
+ for(uint8_t i=0;i<48;i++)
+ {
+ co_printf("%02X ",bp_data_tmp[i]);
+ }
+ co_printf("\n");
+ #endif
+ return 1;
+
}
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:5c22272267508b1deb0bad53dd1772c5d1e58bdb1789d0eed789fa46c2898ba3
+size 202272
if (WORK_MODE_HRV == dev9202_info.work_mode)
{
dev9202_info.work_frequency = 100;
- dev9202_info.fifo_time = 200;
+ //dev9202_info.fifo_time = 200;
}else if(WORK_MODE_WEAR == dev9202_info.work_mode)
{
- dev9202_info.fifo_time = 2000;
+ dev9202_info.fifo_time = 3000;
}
fifo_div = dev9202_info.fifo_time / (1000 / dev9202_info.work_frequency) - 1;
clk_div = (20000 / dev9202_info.work_frequency) - 1;
#include "driver_gpio.h"
#include "SL_Watch_Pedo_Kcal_Wrist_Sleep_Sway_L_Algorithm.h"
#include "uart.h"
+extern char send_temp_data_flag;//发送温度标致位
static WorkModeTypeDef work_mode = WORK_MODE_NONE;
AlgoCalcResultsTypeDef vc9202_alg_results = {0};
extern unsigned char *UART_send_buf;
user_i2c1_init();
- co_delay_100us(500);
- co_printf("rtc_get_value = %d \r\n",rtc_get_value());
- co_delay_100us(500);
- co_printf("rtc_get_value = %d \r\n",rtc_get_value());
+ // co_delay_100us(500);
+ // co_printf("rtc_get_value = %d \r\n",rtc_get_value());
+ // co_delay_100us(500);
+ // co_printf("rtc_get_value = %d \r\n",rtc_get_value());
}
/**
vc9202_drv_reg_init( pInitParam );
unsigned char pchip_id=0; unsigned char pvers_id=0;
vc9202_usr_get_chip_id(&pchip_id,&pvers_id);
+ vc9202_alg_results.wear_status = 1;//默认佩戴
co_printf("pchip_id:0x%X pvers_id:0x%X\r\n",pchip_id,pvers_id);
}
GsensorTypeDef gsensor_data = {0};
unsigned char gsensor_size = 0;
unsigned char ppg_size = 0;
+
vc9202_drv_get_sampling_data( &data, &ppg_size );
if(ppg_size > sizeof(gsensor_data.gsensor_x_axis)/sizeof(int))
{
if(vc9202_alg_results.wear_status)
{
vc9202_alg_results.hr_rate = alg_calculate_hr_handler( vc9202_alg_results.hr_rate, &data, ppg_size, &gsensor_data, hr_alg_mode );
-
//vc9202_debug_send_heart_rate_data( &data, &gsensor_data, vc9202_alg_results.hr_rate, hr_alg_mode, ppg_size );
}
else
{
vc9202_alg_results.spo2_val = alg_calculate_spo2_handler( vc9202_alg_results.spo2_val, &data, ppg_size/2, &gsensor_data, spo2_alg_mode );
//vc9202_debug_send_spo2_data( &data, &gsensor_data, vc9202_alg_results.spo2_val, ppg_size/2 );
+
}
else
{
}
//co_printf(" \n");
- co_printf("WORK_MODE_HRV4 yyl_in_data_len:%d\n",yyl_in_data_len);
+ //co_printf("WORK_MODE_HRV4 yyl_in_data_len:%d\n",yyl_in_data_len);
}
if(yyl_in_data_len >= YYL_PPG_TEST_LEN-1) //存满3000个关闭
{
+ YYL_out_data();
pInit_Param.work_mode = WORK_MODE_WEAR;
vc9202_usr_init(&pInit_Param);
+ co_printf("open wear mode yyl_in_data_len:%d\r\n",yyl_in_data_len);
yyl_close_flag = 1;
}
case WORK_MODE_STRESS:
if( vc9202_usr_get_int_reason()&(VC9202_EVENT_PS_MARK|VC9202_EVENT_FIFO_MARK) )
{
- vc9202_alg_results.wear_status = vc9202_usr_get_wear_status();
+ vc9202_alg_results.wear_status= vc9202_usr_get_wear_status();
get_gsensor_data(&gsensor_data, &gsensor_size, ppg_size);
if(vc9202_alg_results.wear_status)
{
break;
case WORK_MODE_WEAR:
+ //co_printf("IRQ:WORK_MODE_WEAR\r\n");
if( vc9202_usr_get_int_reason() & VC9202_EVENT_PS_MARK )
{
vc9202_alg_results.wear_status = vc9202_usr_get_wear_status();
{
vc9202_usr_gsensor_actuating_quantity( gsensor_data.gsensor_x_axis[0], gsensor_data.gsensor_y_axis[0], gsensor_data.gsensor_z_axis[0] );
}
+
+
//co_printf("WORK_MODE_WEAR:wear_status: %d\r\n",vc9202_alg_results.wear_status);
/* 根据佩戴状态添加对应的处理代码 */
if(vc9202_alg_results.wear_status)
{
+
}
else
{
}
break;
case WORK_MODE_FACTORY:
- sensor_INT();//唤醒上位机
factory_test_function(&data);
co_printf("WORK_MODE_FACTORY:apre_val[0]:%d,apre_val[1]:%d,aps_val:%d\n",data.apre_val[0],data.apre_val[1],data.aps_val);
UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"factory_data\":\"%d,%d,%d\"}\n",data.apre_val[0],data.apre_val[1],data.aps_val);
- uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
+ uart0_write_data(UART_send_buf,UART_send_buf_len);
break;
case WORK_MODE_FPC_TEST:
fpc_test_function(&data);
default:
break;
}
+
+
}
#if 0
unsigned char sensing_range; /* ±4G, ±8G, ±16G*/
unsigned char effective_bits; /* 11(12)bit, 15(16)bit */
- int gsensor_x_axis[40];
- int gsensor_y_axis[40];
- int gsensor_z_axis[40];
+ int gsensor_x_axis[60];
+ int gsensor_y_axis[60];
+ int gsensor_z_axis[60];
}GsensorTypeDef;
-;#<FEEDBACK># ARM Linker, 5060960: Last Updated: Fri Apr 19 18:18:55 2024
+;#<FEEDBACK># ARM Linker, 5060960: Last Updated: Mon Apr 29 17:41:08 2024
;VERSION 0.2
;FILE acpower_add_doublefre.o
acPower_add_doublefre_init <= USED 0
pmu_disable_irq <= USED 0
pmu_enable_charge <= USED 0
pmu_get_gpio_port_value <= USED 0
-pmu_get_gpio_value <= USED 0
pmu_set_led1_as_pwm <= USED 0
pmu_set_led1_value <= USED 0
pmu_set_led2_as_pwm <= USED 0
__asm___12_driver_rtc_c_rtc_init____RRX <= USED 0
rtc_alarm <= USED 0
rtc_disalarm <= USED 0
+rtc_get_value <= USED 0
rtc_init <= USED 0
;FILE driver_timer.o
__asm___14_driver_timer_c_89f15fa2____REV16 <= USED 0
__asm___13_driver_uart_c_a128b2d1____REV16 <= USED 0
__asm___13_driver_uart_c_a128b2d1____REVSH <= USED 0
__asm___13_driver_uart_c_a128b2d1____RRX <= USED 0
-uart_init1 <= USED 0
;FILE driver_wdt.o
wdt_start <= USED 0
wdt_stop <= USED 0
;FILE frequency_spectrum.o
frequency_spectrum_init <= USED 0
;FILE gap_api.o
-gap_address_set <= USED 0
gap_bond_manager_add_info <= USED 0
gap_bond_manager_delete <= USED 0
gap_bond_manager_delete_all <= USED 0
__asm___14_sensor_drive_c_eae9c459____REV16 <= USED 0
__asm___14_sensor_drive_c_eae9c459____REVSH <= USED 0
__asm___14_sensor_drive_c_eae9c459____RRX <= USED 0
+sensor_INT <= USED 0
sensor_while <= USED 0
;FILE sha256.o
sha256_final <= USED 0
char send_wear_data_flag= 0;//wear数据标致位
uint8_t *uart0_rivce_data = NULL;
//uint8_t uart0_rivce_data[UART_READ_MAX] ;
-char *Versions = "20240419-v0.5.3.031624";
+char *Versions = "20240429-v0.5.3.041924";
int uart0_data_len =0;
static int32_t system_curr_time = 0;//设置时间的时候保存的系统运行时间
uint8_t int_id;
volatile struct uart_reg_t * const uart_reg_ram = (volatile struct uart_reg_t *)UART0_BASE;
int_id = uart_reg_ram->u3.iir.int_id;
-
+ //co_printf("uart0_isr_ram int_id:0x%x,lsr:0x%x!!!!!\r\n",int_id,uart_reg_ram->lsr);
if(int_id == 0x04 || int_id == 0x0c ) /* Receiver data available or Character time-out indication */
{
while(uart_reg_ram->lsr & 0x01)
{
uart0_rivce_data[uart0_data_len] = uart_reg_ram->u1.data;
if(uart0_rivce_data[uart0_data_len] == '}')
+ {
uart0_flag = 1;
-
+ //co_printf("uart0_isr_ram uart0_rivce_data:%s\r\n",uart0_rivce_data);
+ }
//co_printf("-%c",uart0_rivce_data[uart0_data_len]);
uart0_data_len++;
if(uart0_data_len >= UART_READ_MAX)
}
else if(int_id == 0x06)
{
- uart_reg_ram->lsr = uart_reg_ram->lsr;
- uart_reg_ram->u3.iir.int_id = int_id;
- uart_reg_ram->u2.ier.erlsi = 0;
- }
+ while(uart_reg_ram->lsr & 0x01)
+ {
+ uart0_rivce_data[uart0_data_len] = uart_reg_ram->u1.data;
+ if(uart0_rivce_data[uart0_data_len] == '}')
+ {
+ uart0_flag = 1;
+ //co_printf("uart0_isr_ram uart0_rivce_data:%s\r\n",uart0_rivce_data);
+ }
+ //co_printf("-%c",uart0_rivce_data[uart0_data_len]);
+ uart0_data_len++;
+ if(uart0_data_len >= UART_READ_MAX)
+ uart0_data_len = 0;
+ // app_at_recv_c(uart_reg_ram->u1.data);
+ }
+ volatile uint32_t line_status = uart_reg_ram->lsr;
+ // uart_reg_ram->lsr = uart_reg_ram->lsr;
+ // uart_reg_ram->u3.iir.int_id = int_id;
+ // uart_reg_ram->u2.ier.erlsi = 0;
+ }else
+ {
+ //co_printf("uart0_isr_ram not data int_id:0x%x,lsr:0x%x!!!!!\r\n",int_id,uart_reg_ram->lsr);
+ }
}
#include "vc9202_user.h"
+void uart0_write_data(unsigned char *buf,int len)
+{
+ unsigned int count = 1000;//1s超时
+ pmu_set_gpio_value(GPIO_PORT_D, BIT(6), 0);//唤醒4g要写数据了
+ while(pmu_get_gpio_value(GPIO_PORT_D,GPIO_BIT_7))//等待唤醒成功
+ {
+ count --;
+ co_delay_10us(100);
+ if(count <= 0)
+ {
+
+ break;
+ }
+ }
+ uart0_write_for_hci(buf,len,NULL,NULL);
+ pmu_set_gpio_value(GPIO_PORT_D, BIT(6), 1);//恢复
+ //co_printf("uart0_write_data:count:%d,%s\r\n",count,buf);
+ //user_event_send(USER_4G_IRQ, NULL, NULL);//读取数据
+}
//unsigned int uart0_timer = 0;
-extern uint8_t bp_data[100];
-extern uint16_t bp_data_len ;
+
extern AlgoCalcResultsTypeDef vc9202_alg_results;
+extern int read_BP_data_len ;
void uart0_receive(void)
{
// }
if(uart0_flag == 0)
{
-
+
return ;
}
user_parse_data();
void user_parse_data(void)
{
//uart0_timer = 0;//
- if(uart0_data_len >0)
- co_printf("uart_read:%s\n",uart0_rivce_data);
+ // if(uart0_data_len >0)
+ // co_printf("uart_read:%s\n",uart0_rivce_data);
//return ;
//co_printf("uart0_receive:%s\n",uart0_rivce_data);
if(strstr((char *)uart0_rivce_data,"\"cmd\":\"1\""))//{"cmd":"
send_sleep_data_flag=0;//发送sleep数据标致位
send_step_data_flag=0;//发送step数据标致位
send_wear_data_flag=0;//发送wear数据标致位
- sensor_INT();//唤醒上位机
if(strstr((char *)uart0_rivce_data,"\"bp\""))//bp:血压模式
{
- uart0_write_for_hci("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", sizeof("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n")-1, NULL, NULL);
vc9202_alg_results.wear_status = 1;//血压暂时不测佩戴
BP_open();//血压
+ uart0_write_data("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", strlen("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n"));
+
}
else if(strstr((char *)uart0_rivce_data,"\"hrs\""))//:"hrs"}//hrs:心率模式
{
- uart0_write_for_hci("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", sizeof("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n")-1, NULL, NULL);
-
HRS_open();//心率
-
+ uart0_write_data("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", strlen("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n"));
}
else if(strstr((char *)uart0_rivce_data,"\"hrv\""))//:"hrv"}//hrv:HRV模式
{
- uart0_write_for_hci("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", sizeof("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n")-1, NULL, NULL);
+ uart0_write_data("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", strlen("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n"));
send_hrv_data_flag=1;
}
else if(strstr((char *)uart0_rivce_data,"\"spo2\""))//:"spo2"}//spo2:血氧模式
{
- uart0_write_for_hci("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", sizeof("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n")-1, NULL, NULL);
-
SPO2_open();//血氧
+ uart0_write_data("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", strlen("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n"));
+
+
}else if(strstr((char *)uart0_rivce_data,"\"yyl\""))//yyl:中医模式
{
-
- uart0_write_for_hci("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", sizeof("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n")-1, NULL, NULL);
YYL_open();//中医
+ uart0_write_data("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", strlen("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n"));
}else if(strstr((char *)uart0_rivce_data,"\"emo\""))//emo:情绪模式
{
-
- uart0_write_for_hci("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", sizeof("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n")-1, NULL, NULL);
- EMO_open();//情绪
+ EMO_open();//情绪
+ uart0_write_data("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", strlen("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n"));
}
else if(strstr((char *)uart0_rivce_data,"\"wear\""))//:"wear"}//wear:佩戴模式
{
- uart0_write_for_hci("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", sizeof("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n")-1, NULL, NULL);
wear_open();//佩戴
+ uart0_write_data("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", strlen("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n"));
+
}
else if(strstr((char *)uart0_rivce_data,"\"temp\""))//:"temp"}//temp:温度模式
{
- uart0_write_for_hci("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", sizeof("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n")-1, NULL, NULL);
temp_open();
+ uart0_write_data("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", strlen("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n")-1);
}else if(strstr((char *)uart0_rivce_data,"\"factory\""))//:"factory"}//factory:工厂模式
{
- uart0_write_for_hci("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", sizeof("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n")-1, NULL, NULL);
factory_open();//工厂模式
+ uart0_write_data("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", strlen("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n"));
+
}else if(strstr((char *)uart0_rivce_data,"\"OTA\""))//:"OTA"}//OTA:蓝牙OTA升级模式
{
- uart0_write_for_hci("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", sizeof("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n")-1, NULL, NULL);
OTA_open();//
+ uart0_write_data("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", strlen("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n"));
+
}
else if(strstr((char *)uart0_rivce_data,"\"close\""))//:"close"}//close:关闭所有测试,进入低功耗待机模式
{
- uart0_write_for_hci("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", sizeof("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n")-1, NULL, NULL);
///////////////////////////////// 关闭测量//////////////////////////////////////////////
sensor_close();
+ uart0_write_data("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n", strlen("{\"cmd\":\"1\",\"work_mode\":\"1\"}\r\n"));
+
}
}
//////////////////////////////获取测试数值///////////////////////////主控->血压模块{"cmd":"2","get_data":"bp"}
{
vc9202_alg_results.wear_status = 1;//血压暂时不测佩戴
send_bp_data_flag = 1;
- if(bp_data_len != 0)
- {
- sensor_INT();//唤醒上位机
- //输出血压数据到串口0
- co_printf("bp_data_len:%d\n",bp_data_len);
- uart0_write_for_hci("{\"cmd\":\"2\",\"bp_data\":\"",strlen("{\"cmd\":\"2\",\"bp_data\":\""),NULL, NULL);
- UART_send_buf_len = 0;
-
- for(uint8_t i=0;i<bp_data_len;i++)//转码
- {
- UART_send_buf_len += snprintf((char *)UART_send_buf+i*2,UART_SEND_MAX,"%02X",bp_data[i]);
- // uintTOstr(bp_data[i]);
- // uart_putc_noint(UART0,str_high);
- // uart_putc_noint(UART0,str_low);
- }
- uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
- uart0_write_for_hci("\"}\n", 3, NULL, NULL);
- memset(bp_data,0,sizeof(bp_data));
- bp_data_len =0;
- }
+ send_BP_data();
}
//co_printf("HRS_test3!!!!!!!!\n");
//co_printf("hr_rate0:%d UART_send_buf:0x%x\n",vc9202_alg_results.hr_rate,UART_send_buf);
memset(UART_send_buf,0,UART_SEND_MAX);
- sensor_INT();//唤醒上位机
co_printf("hr_rate:%d \n",vc9202_alg_results.hr_rate);
UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"hrs_data\":\"%d\"}\n",vc9202_alg_results.hr_rate);
- uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
+ uart0_write_data(UART_send_buf,UART_send_buf_len);
vc9202_alg_results.hr_rate = 0;
//co_printf("hr_rate2:%d \n",vc9202_alg_results.hr_rate);
}
send_spo2_data_flag = 1;
if(vc9202_alg_results.spo2_val >0)
{
- sensor_INT();//唤醒上位机
co_printf("spo2_val:%d \n",vc9202_alg_results.spo2_val);
memset(UART_send_buf,0,UART_SEND_MAX);
UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"spo2_data\":\"%d\"}\n",vc9202_alg_results.spo2_val);
- uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
+ uart0_write_data(UART_send_buf,UART_send_buf_len);
vc9202_alg_results.spo2_val = 0;
}
}if(strstr((char *)uart0_rivce_data,"\"get_data\":\"yyl\""))//:"yyl"}//yyl:获取中医数据
{
// unsigned char wear = vc9202_usr_get_wear_status();//获取佩戴状态
// co_printf("wear_val:%d \n",wear);
- // memset(UART_send_buf,0,UART_SEND_MAX);
- //UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"wear_data\":\"%d\"}\n",vc9202_alg_results.wear_status);
- //uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
+ memset(UART_send_buf,0,UART_SEND_MAX);
+ UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"wear_data\":\"%d\"}\n",vc9202_alg_results.wear_status);
+ uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
}
if(strstr((char *)uart0_rivce_data,"\"get_data\":\"step\""))//:"step"}//step:获取累计步数
{
}
if(strstr((char *)uart0_rivce_data,"\"get_data\":\"is_HA_activate\""))//:获取恒爱库是否激活状态
{
- sensor_INT();//唤醒上位机
UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"is_HA_activate\":\"%d,%s\"}\n",is_HA_activate,Versions);
- uart0_write_for_hci(UART_send_buf, UART_send_buf_len, NULL, NULL);
+ uart0_write_data(UART_send_buf, UART_send_buf_len);
}
if(strstr((char *)uart0_rivce_data,"\"get_data\":\"HA_req_code\""))//:获取恒爱库请求码
{
unsigned int req_len = 0;
- sensor_INT();//唤醒上位机
request_validation((unsigned char *)"ZHSX",4,(unsigned char *)sys_config.IMEI,strlen(sys_config.IMEI),(unsigned char *)sys_config.HA_req_code,&req_len);
sys_config.HA_req_code[req_len] = 0;
UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"HA_req_code\":\"%s\"}\n",sys_config.HA_req_code);
- uart0_write_for_hci(UART_send_buf, UART_send_buf_len, NULL, NULL);
+ uart0_write_data(UART_send_buf, UART_send_buf_len);
co_printf("HA_req_code:HA_req_code:%s \n",sys_config.HA_req_code);
save_sys_config();//保存配置
}
//co_printf("[CHENG]:send_wear_status=%d\r\n", vc9202_alg_results.wear_status);
- UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"wear_data\":\"%d\"}\n",vc9202_alg_results.wear_status);
- uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
- co_printf("%s",UART_send_buf);
+ // UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"wear_data\":\"%d\"}\n",vc9202_alg_results.wear_status);
+ // uart0_write_data(UART_send_buf,UART_send_buf_len,NULL, NULL);
+ //co_printf("%s",UART_send_buf);
// memset(UART_send_buf,0,UART_SEND_MAX);
// UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"wear_data\":\"%d\"}\n",wear);
// uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
str_tmp = strstr((char *)uart0_rivce_data,"\"set_IMEI\":\"");//设置IMEI号
if(str_tmp)
{
- sensor_INT();//唤醒上位机
str_tmp+=strlen("\"set_IMEI\":\"");
len_tmp = find_c(str_tmp,'\"');
if(len_tmp >= sizeof(sys_config.IMEI))
UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"3\",\"set_config\":\"1\"}\n");
- uart0_write_for_hci(UART_send_buf, UART_send_buf_len, NULL, NULL);
+ uart0_write_data(UART_send_buf, UART_send_buf_len);
}
str_tmp = strstr((char *)uart0_rivce_data,"\"set_time\":\"");//设置时间戳
if(str_tmp)
{
- sensor_INT();//唤醒上位机
str_tmp+=strlen("\"set_time\":\"");
len_tmp = find_c(str_tmp,'\"');
co_printf("timestamp_d:%d\n",timestamp_d);
UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"3\",\"set_config\":\"1\"}\n");
- uart0_write_for_hci(UART_send_buf, UART_send_buf_len, NULL, NULL);
+ uart0_write_data(UART_send_buf, UART_send_buf_len);
}
str_tmp = strstr((char *)uart0_rivce_data,"\"set_HA_key_code\":\"");//设置恒爱算法库激活码
if(str_tmp)
{
- sensor_INT();//唤醒上位机
str_tmp+=strlen("\"set_HA_key_code\":\"");
len_tmp = find_c(str_tmp,'\"');
if(len_tmp < sizeof(sys_config.HA_key_code))
save_sys_config();//保存配置
}
UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"3\",\"HA_activate\":\"%d\"}\n",is_HA_activate);
- uart0_write_for_hci(UART_send_buf, UART_send_buf_len, NULL, NULL);
+ uart0_write_data(UART_send_buf, UART_send_buf_len);
}
}
extern void save_sys_config(void);
unsigned int get_timestamp(void);
void user_parse_data(void);
+void uart0_isr_ram(void);
+void uart0_write_data(unsigned char *buf,int len);
#endif