蓝牙提交
authorp15692025051 <846603105@qq.com>
Tue, 20 Feb 2024 02:07:00 +0000 (10:07 +0800)
committerp15692025051 <846603105@qq.com>
Tue, 20 Feb 2024 02:07:00 +0000 (10:07 +0800)
41 files changed:
1.doc/K18/BLE_Watch/code/ble_simple_central.c
1.doc/K18/BLE_Watch/code/proj_main.c
1.doc/K18/BLE_Watch/code/sensor_drive.c
1.doc/K18/BLE_Watch/components/ble/include/gap/gap_api.h
1.doc/K18/BLE_Watch/components/ble/include/gatt/gatt_api.h
1.doc/K18/BLE_Watch/components/ble/include/mesh/mesh_api.h
1.doc/K18/BLE_Watch/components/ble/library/libfr8010h_stack.a
1.doc/K18/BLE_Watch/components/ble/profiles/ble_AMS/AMS_client.c
1.doc/K18/BLE_Watch/components/ble/profiles/ble_ANCS_AMCS/ANCS_AMS_client.c
1.doc/K18/BLE_Watch/components/ble/profiles/ble_gap/gap_service.c
1.doc/K18/BLE_Watch/components/ble/profiles/ble_ota/ota.c
1.doc/K18/BLE_Watch/components/ble/profiles/ble_ota/ota.h
1.doc/K18/BLE_Watch/components/driver/IR/driver_ir_send.c
1.doc/K18/BLE_Watch/components/driver/driver_pmu.c
1.doc/K18/BLE_Watch/components/driver/include/driver_pmu.h
1.doc/K18/BLE_Watch/components/modules/audio_code_adpcm/adpcm.c
1.doc/K18/BLE_Watch/components/modules/os/include/os_mem.h
1.doc/K18/BLE_Watch/components/modules/sys/include/sys_utils.h
1.doc/K18/BLE_Watch/keil/BLE_Watch.uvgui.Administrator
1.doc/K18/BLE_Watch/keil/Imitate_IIC.c
1.doc/K18/BLE_Watch/keil/Objects/ble_simple_central.crf
1.doc/K18/BLE_Watch/keil/Objects/core_cm3_isr.crf
1.doc/K18/BLE_Watch/keil/Objects/driver_iic.crf
1.doc/K18/BLE_Watch/keil/Objects/driver_keyscan.crf
1.doc/K18/BLE_Watch/keil/Objects/driver_pmu.crf
1.doc/K18/BLE_Watch/keil/Objects/driver_pmu_qdec.crf
1.doc/K18/BLE_Watch/keil/Objects/driver_rtc.crf
1.doc/K18/BLE_Watch/keil/Objects/driver_wdt.crf
1.doc/K18/BLE_Watch/keil/Objects/imitate_iic.crf
1.doc/K18/BLE_Watch/keil/Objects/ota.crf
1.doc/K18/BLE_Watch/keil/Objects/ota_service.crf
1.doc/K18/BLE_Watch/keil/Objects/patch.crf
1.doc/K18/BLE_Watch/keil/Objects/proj_main.crf
1.doc/K18/BLE_Watch/keil/Objects/sensor_drive.crf
1.doc/K18/BLE_Watch/keil/Objects/simple_gatt_service.crf
1.doc/K18/BLE_Watch/keil/Objects/sl_watch_pedo_kcal_wrist_sleep_sway_l_application.crf
1.doc/K18/BLE_Watch/keil/Objects/uart.crf
1.doc/K18/BLE_Watch/keil/Objects/vc9202_user.crf
1.doc/K18/BLE_Watch/keil/VC9202/vc9202_user.c
1.doc/K18/BLE_Watch/keil/feedback.txt
1.doc/K18/BLE_Watch/keil/uart.c

index 2417d77..879a7f5 100644 (file)
@@ -48,7 +48,7 @@ static uint8_t scan_rsp_data[] =
   // complete name 设备名字
   0x0e,   // length of this data
   GAP_ADVTYPE_LOCAL_NAME_COMPLETE,
-  'A','a','t','c','h','_','B','P','_','T','e','s','t',
+  'Z','a','t','c','h','_','B','P','_','T','e','s','t',
 
   // Tx power level 发射功率
   0x02,   // length of this data
@@ -293,10 +293,15 @@ static void sp_start_adv(void)
  *
  * @return  None.
  */
+#include "uart.h"
+extern SysConfig sys_config;
 void simple_peripheral_init(void)
 {
     // set local device name
-    uint8_t local_name[] = "Aatch_BP_Test";
+    uint8_t local_name[13] = {0};
+
+    snprintf(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));
     os_timer_init( &update_param_timer,param_timer_func,NULL);
 
index 76c7379..edd7c9d 100644 (file)
@@ -37,8 +37,8 @@
 #include "flash_usage_config.h"
 #include "lib_hr.h"
 #include "sensor_drive.h"
-
-
+SysConfig sys_config ={0};
+void init_sys_config(void);
 /*
 * LOCAL VARIABLES
 */
@@ -51,7 +51,7 @@ const struct jump_table_version_t _jump_table_version __attribute__((section("ju
 const struct jump_table_image_t _jump_table_image __attribute__((section("jump_table_1"))) =
 {
        .image_type = IMAGE_TYPE_APP,
-       .image_size = 0x19000,      
+       .image_size = 0x32000,      
 };
 __attribute__((section("ram_code"))) void gap_rssi_ind(int8_t rssi, uint8_t conidx) 
 { 
@@ -70,12 +70,21 @@ __attribute__((section("ram_code"))) void gap_rssi_ind(int8_t rssi, uint8_t coni
 */
 void user_custom_parameters(void)
 {
+       init_sys_config();
        __jump_table.addr.addr[0] = 0xab;
        __jump_table.addr.addr[1] = 0x90;
        __jump_table.addr.addr[2] = 0x78;
        __jump_table.addr.addr[3] = 0x56;
        __jump_table.addr.addr[4] = 0x34;
        __jump_table.addr.addr[5] = 0xc0;
+       unsigned char IMEI_len = strlen(sys_config.IMEI);
+       if( IMEI_len> 6)
+       {
+               for(int i = 0; i < 6 ;i++)
+               {
+                       __jump_table.addr.addr[i] = (sys_config.IMEI[3+i*2]-'0')<<4 | (sys_config.IMEI[4+i*2]-'0');
+               }
+       }
        __jump_table.system_clk = SYSTEM_SYS_CLK_48M;
 }
 
@@ -212,7 +221,7 @@ void user_entry_before_ble_init(void)
 
 
 
-SysConfig sys_config ={0};
+
 
 void init_sys_config(void)
 {
@@ -252,18 +261,31 @@ void save_sys_config(void)
 
 
 
-
+extern unsigned char *UART_send_buf;
+extern uint8_t *uart0_rivce_data ;
 ///////main函数/////////////////////////////////////////////////
 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--------33333333333init_sys_config--------\r\n\r\n");
        //system_set_tx_power(RF_TX_POWER_POS_10dBm); //设置发射功率为10DB
        system_sleep_disable();  //关睡眠
        simple_peripheral_init();//蓝牙初始化
-       
-       //rtc_timer_arm(RTC_B,150); //RTC_B, 150us
-       init_sys_config();
+       co_printf("heap:%d!!!!!!!!!!\n\n",os_get_free_heap_size());
+       UART_send_buf = os_malloc(UART_SEND_MAX+10);
+       memset(UART_send_buf,0,UART_SEND_MAX);
+       co_printf("heap:%d!!!!!!!!!!\n\n",os_get_free_heap_size());
+       uart0_rivce_data = os_malloc(UART_READ_MAX+10);
+       co_printf("heap:%d!!!!!!!!!!\n\n",os_get_free_heap_size());
+       if(UART_send_buf == NULL)
+       {
+               while(1)
+               {
+                       co_printf("\r\n\r\nmemory error!!!!!!!!!\r\n\r\n");
+                       co_delay_100us(10000);
+               }
+               
+       }
        co_printf("\r\n\r\n--------system start end--------\r\n\r\n");  
        
        //                                      bool hr_out_flag;
@@ -272,18 +294,13 @@ void user_entry_after_ble_init(void)
        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 gsensor_buff[40] = {0};
-       // co_printf("test:ziseof():%d\n\n",sizeof(gsensor_buff));
        timer_init(TIMER0,10000,TIMER_PERIODIC);//10ms
        timer_run(TIMER0);
        NVIC_EnableIRQ(TIMER0_IRQn);
 
-
-
-       
-       
        sensor_init();
        os_user_loop_event_set(sensor_while);
+       
 
        // while(1)      
        // {
@@ -300,9 +317,9 @@ void user_entry_after_ble_init(void)
        //      /////////////////////血氧测量/////////////////////////////
        //      SPO2_test();
        //      /////////////////////中医测量/////////////////////////////
-       //      YYL_test();
+               //YYL_test();
        //      //////////////////////情绪测量//////////////////////////////////
-       //      EMO_test();             
+               //EMO_test();           
                
        //      co_delay_100us(500);
 
index 13f33a8..67ca63a 100644 (file)
@@ -32,7 +32,7 @@
 #include "sensor_drive.h"
 #include "algo.h"
 #include "yyl_pfev01.h"
-uint16_t task_sensor_id = 0;
+
 
 InitParamTypeDef pInit_Param={0};
 
@@ -40,8 +40,7 @@ char is_HA_activate = 0;
 #define HA_BUF_LEN 10*1024
 unsigned char HA_BUF[HA_BUF_LEN];//恒爱算法库和中医算法库缓冲区
 
-// char ppg_buf[PPG_BUF_LEN];
-// int ppg_buf_len = 0;
+
 int yyl_in_data_len = 0;
 extern   char  send_bp_data_flag;//发送血压数据标致位
 extern   char  send_hrs_data_flag;//发送心率数据标标致位
@@ -59,8 +58,10 @@ extern  uint8_t bp_data[49];
 uint8_t uart0_residue_data[]="\"}\n"; 
 extern AlgoCalcResultsTypeDef vc9202_alg_results;
 
-extern unsigned char UART_send_buf[UART_SEND_MAX] ;
+extern unsigned char *UART_send_buf;
+//extern unsigned char UART_send_buf[UART_SEND_MAX];
 extern int UART_send_buf_len ;
+
 ////////////////////////////中断处理////////////////////////// MCU响应太慢,中断时间太短无法捕获 3.2US 
 char task_sensor_evn_flag = 0;
 os_event_t evt;
@@ -92,12 +93,7 @@ void pmu_gpio_isr_ram(void) //中断处理
        }
        else if((pressed_key&0x20000000)==0x20000000)//PD5//血压中断
        {
-               //co_printf("PD5 = 0 \r\n");
-               
-               // evt.event_id = BP_IRQ;
-               // if(task_sensor_id != 0&&task_sensor_evn_flag==0)
-               //      os_msg_post(task_sensor_id,&evt);
-               //bp_int=1;
+
        }
        else if((pressed_key&0x10000000)==0x10000000)//PD4// 三轴地磁传感器中断
        {
@@ -248,27 +244,59 @@ void uintTOstr(uint8_t hex_data)//十六进制转字符串ASCII码
 
 char BP_test(void)
 {
-       if(send_bp_data_flag)//血压
-       {
-               //send_bp_data_flag=0;
+       // if(send_bp_data_flag)//血压
+       // {
+       //      //send_bp_data_flag=0;
                
-               //co_delay_10us(1);
+       //      //co_delay_10us(1);
                
                
-               co_printf("BP_test!!!\n");              
-               if(read_BP_data()==1)//读血压数据
+       //      co_printf("BP_test!!!\n");              
+       //      if(read_BP_data()==1)//读血压数据
+       //      {
+       //              //输出血压数据到串口0  
+       //              UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"bp_data\":\"");
+       //              uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
+       //              for(uint8_t i=0;i<48;i++)//转码
+       //              {
+       //                      uintTOstr(bp_data[i]);
+       //                      uart_putc_noint(UART0,str_high);
+       //                      uart_putc_noint(UART0,str_low);
+       //              }
+       //              uart0_write_for_hci(uart0_residue_data, 3,  NULL, NULL);        
+       //      }
+       // }
+       if(send_bp_data_flag)//血压
+       {
+               bool irq_flag=0;
+               while(send_bp_data_flag) 
                {
-                       //输出血压数据到串口0  
-                       UART_send_buf_len = snprintf((char *)UART_send_buf,sizeof(UART_send_buf),"{\"cmd\":\"2\",\"bp_data\":\"");
-                       uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
-                       for(uint8_t i=0;i<48;i++)//转码
+                       //co_printf("BP_test:IO%d\n",gpio_get_pin_value(GPIO_PORT_D, GPIO_BIT_5));
+                       //要放入采集时间,等待时间没采到退出
+                       while((gpio_get_pin_value(GPIO_PORT_D, GPIO_BIT_5)==0)&&send_bp_data_flag)//等待BP_INT变高 
+                       {
+                               uart0_receive();//串口0接收数据处理
+                               co_delay_100us(100);//不加延时串口获取数据异常      
+                               irq_flag=1;
+                               //co_printf("BP_test:irq_flag\n");
+                       }                       
+                       while(gpio_get_pin_value(GPIO_PORT_D, GPIO_BIT_5)&&irq_flag&&send_bp_data_flag) //等待BP_INT变低 
                        {
-                               uintTOstr(bp_data[i]);
-                               uart_putc_noint(UART0,str_high);
-                               uart_putc_noint(UART0,str_low);
+                               
+                               read_BP_data();//读血压数据
+                               //输出血压数据到串口0  
+                               uart0_write_for_hci("{\"cmd\":\"2\",\"bp_data\":\"",strlen("{\"cmd\":\"2\",\"bp_data\":\""),NULL, NULL);
+                               for(uint8_t i=0;i<48;i++)//转码
+                               {
+                                       uintTOstr(bp_data[i]);
+                                       uart_putc_noint(UART0,str_high);
+                                       uart_putc_noint(UART0,str_low);
+                               }
+                               uart0_write_for_hci(uart0_residue_data, 3,  NULL, NULL);        
+                               uart0_receive();//串口0接收数据处理     
+                               irq_flag=0;
                        }
-                       uart0_write_for_hci(uart0_residue_data, 3,  NULL, NULL);        
-               }
+               }               
        }
                
     return send_bp_data_flag;
@@ -306,74 +334,81 @@ char EMO_test(void)
        float emo_out_Fm[25][8];
        int emo_out_Fm_len = 0;
        char tmp_buf[30];
-       if(send_emo_data_flag)//情绪
+       bool irq_flag=0;
+       while(send_emo_data_flag) 
        {
-
-                                               
-               if(read_BP_data()==1)//读血压数据
+               //co_printf("BP_test:IO%d\n",gpio_get_pin_value(GPIO_PORT_D, GPIO_BIT_5));
+               //要放入采集时间,等待时间没采到退出
+               while((gpio_get_pin_value(GPIO_PORT_D, GPIO_BIT_5)==0)&&send_emo_data_flag)//等待BP_INT变高 
                {
-                       //输出血压数据到串口0  
-                       // float tmp = 3.33;
-                       // co_printf("  EMO_test:2.0:%s \n",UART_send_buf);     
-                       // UART_send_buf_len = sprintf((char *)UART_send_buf,"%.2f!!,",tmp);
-                       // co_printf("  EMO_test:2.1:%s \n",UART_send_buf);     
-                       UART_send_buf_len = 0;
-                       memset(UART_send_buf,0,sizeof(UART_send_buf));
-
-                       for(int i=0;i<16;i++)//转码
+                       uart0_receive();//串口0接收数据处理
+                       co_delay_100us(100);//不加延时串口获取数据异常      
+                       irq_flag=1;
+                       //co_printf("BP_test:irq_flag\n");
+               }                       
+               while(gpio_get_pin_value(GPIO_PORT_D, GPIO_BIT_5)&&irq_flag&&send_emo_data_flag) //等待BP_INT变低 
+               {                       
+                       if(read_BP_data()==1)//读血压数据
                        {
-                               emo_in_buf[emo_in_buf_len] = bp_data[i*3+0]<<16|bp_data[i*3+1]<<8|bp_data[i*3+2];
-                               //co_printf("  EMO_test:bp_data:0x%02X%02X%02X\n",bp_data[i*3+0],bp_data[i*3+1],bp_data[i*3+2]);
-                               //co_printf("  EMO_test:emo_in_buf[%d]:%d\n",emo_in_buf_len,emo_in_buf[emo_in_buf_len]);
-                               emo_in_buf_len++;
-                               
-                               if(emo_in_buf_len >= EMO_IN_BUF_SIZE)
+
+                               UART_send_buf_len = 0;
+                               memset(UART_send_buf,0,UART_SEND_MAX);
+
+                               for(int i=0;i<16;i++)//转码
                                {
-                                       //co_printf("  EMO_test:ppg_midvalue \n");
-                                       status = ppg_midvalue(emo_in_buf,emo_in_buf_len,SAMPLERATE,emo_out_Fm,&emo_out_Fm_len);
-                                       co_printf("  EMO_test:status:%d emo_out_Fm_len:%d\n",status,emo_out_Fm_len);
-                                       if(emo_out_Fm_len != 0)
+                                       emo_in_buf[emo_in_buf_len] = bp_data[i*3+0]<<16|bp_data[i*3+1]<<8|bp_data[i*3+2];
+                                       //co_printf("  EMO_test:bp_data:0x%02X%02X%02X\n",bp_data[i*3+0],bp_data[i*3+1],bp_data[i*3+2]);
+                                       //co_printf("  EMO_test:emo_in_buf[%d]:%d\n",emo_in_buf_len,emo_in_buf[emo_in_buf_len]);
+                                       emo_in_buf_len++;
+                                       
+                                       if(emo_in_buf_len >= EMO_IN_BUF_SIZE)
                                        {
-                                               UART_send_buf_len += snprintf((char *)UART_send_buf,sizeof(UART_send_buf),"{\"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++)
+                                               //co_printf("  EMO_test:ppg_midvalue \n");
+                                               status = ppg_midvalue(emo_in_buf,emo_in_buf_len,SAMPLERATE,emo_out_Fm,&emo_out_Fm_len);
+                                               co_printf("  EMO_test:status:%d emo_out_Fm_len:%d\n",status,emo_out_Fm_len);
+                                               if(emo_out_Fm_len != 0)
                                                {
-                                                       UART_send_buf_len += snprintf((char *)&UART_send_buf[UART_send_buf_len],sizeof(UART_send_buf)-UART_send_buf_len,
-                                                                                                                       "[");
-                                                       //co_printf("  EMO_test:2:%d \n",UART_send_buf_len);
-                                                       for(int k=0;k<8;k++)
+                                                       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++)
                                                        {
-                                                               //co_printf("  EMO_test:2.0:%s \n",UART_send_buf);
-                                                               memset(tmp_buf,0,sizeof(tmp_buf));
-                                                               char *float_str = _float_to_char(emo_out_Fm[j][k],tmp_buf,sizeof(tmp_buf));
-                                                               //int int_tmp = emo_out_Fm[j][k]*100;
-                                                               UART_send_buf_len += snprintf((char *)&UART_send_buf[UART_send_buf_len],sizeof(UART_send_buf)-UART_send_buf_len,
-                                                                                                                       "%s,",float_str);
-                                                               
-                                                               //co_printf("  EMO_test:float:%s \n",float_str);
-                                                               //co_printf("  EMO_test:hex:0x%X \n",emo_out_Fm[j][k]); 
-                                                               //printf("  EMO_test:printf:%f \n",emo_out_Fm[j][k]);                                           
+                                                               UART_send_buf_len += snprintf((char *)&UART_send_buf[UART_send_buf_len],UART_SEND_MAX-UART_send_buf_len,
+                                                                                                                               "[");
+                                                               //co_printf("  EMO_test:2:%d \n",UART_send_buf_len);
+                                                               for(int k=0;k<8;k++)
+                                                               {
+                                                                       //co_printf("  EMO_test:2.0:%s \n",UART_send_buf);
+                                                                       memset(tmp_buf,0,sizeof(tmp_buf));
+                                                                       char *float_str = _float_to_char(emo_out_Fm[j][k],tmp_buf,sizeof(tmp_buf));
+                                                                       //int int_tmp = emo_out_Fm[j][k]*100;
+                                                                       UART_send_buf_len += snprintf((char *)&UART_send_buf[UART_send_buf_len],UART_SEND_MAX-UART_send_buf_len,
+                                                                                                                               "%s,",float_str);
+                                                                       
+                                                                       //co_printf("  EMO_test:float:%s \n",float_str);
+                                                                       //co_printf("  EMO_test:hex:0x%X \n",emo_out_Fm[j][k]); 
+                                                                       //printf("  EMO_test:printf:%f \n",emo_out_Fm[j][k]);                                           
+                                                               }
+                                                               UART_send_buf_len-=1;//减去最后的逗号
+                                                               UART_send_buf_len += snprintf((char *)&UART_send_buf[UART_send_buf_len],UART_SEND_MAX-UART_send_buf_len,
+                                                                                                                               "],");
                                                        }
+                                                       //co_printf("  EMO_test:3:%d \n",UART_send_buf_len);
                                                        UART_send_buf_len-=1;//减去最后的逗号
-                                                       UART_send_buf_len += snprintf((char *)&UART_send_buf[UART_send_buf_len],sizeof(UART_send_buf)-UART_send_buf_len,
-                                                                                                                       "],");
+                                                       UART_send_buf_len += snprintf((char *)&UART_send_buf[UART_send_buf_len],UART_SEND_MAX-UART_send_buf_len,
+                                                                                                                               "]}\n");
+                                                       uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
+                                                       co_printf("  EMO_test:send_buf:%s\n",UART_send_buf);
                                                }
-                                               //co_printf("  EMO_test:3:%d \n",UART_send_buf_len);
-                                               UART_send_buf_len-=1;//减去最后的逗号
-                                               UART_send_buf_len += snprintf((char *)&UART_send_buf[UART_send_buf_len],sizeof(UART_send_buf)-UART_send_buf_len,
-                                                                                                                       "]}\n");
-                                               uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
-                                               co_printf("  EMO_test:send_buf:%s\n",UART_send_buf);
+                                               
+                                               
+                                               emo_in_buf_len = 0;
                                        }
-                                       
-                                       
-                                       emo_in_buf_len = 0;
                                }
                        }
                }
-               
-                               
        }
+                               
+       
     return send_emo_data_flag;
 }
 
@@ -388,11 +423,13 @@ char HRS_test(void)
                if(vc9202_alg_results.hr_rate >0)
                {
                        //co_printf("HRS_test3!!!!!!!!\n");
-                       //co_printf("hr_rate:%d \n",vc9202_alg_results.hr_rate);
-                       memset(UART_send_buf,0,sizeof(UART_send_buf));
-                       UART_send_buf_len = snprintf((char *)UART_send_buf,sizeof(UART_send_buf),"{\"cmd\":\"2\",\"hrs_data\":\"%d\"}\n",vc9202_alg_results.hr_rate);
+                       //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);
+                       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);
                        vc9202_alg_results.hr_rate = 0; 
+                       //co_printf("hr_rate2:%d \n",vc9202_alg_results.hr_rate);
                }       
        }
     return send_hrs_data_flag;
@@ -408,8 +445,8 @@ char HRV_test(void)
                // if(vc9202_alg_results.hr_rate >0)
                // {
                //      co_printf("hr_rate:%d \n",vc9202_alg_results.hr_rate);
-               //      memset(UART_send_buf,0,sizeof(UART_send_buf));
-               //      UART_send_buf_len = snprintf((char *)UART_send_buf,sizeof(UART_send_buf),"{\"cmd\":\"2\",\"hrs_data\":\"%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; 
                // }
@@ -426,8 +463,8 @@ char SPO2_test(void)
                if(vc9202_alg_results.spo2_val >0)
                {
                        co_printf("spo2_val:%d \n",vc9202_alg_results.spo2_val);
-                       memset(UART_send_buf,0,sizeof(UART_send_buf));
-                       UART_send_buf_len = snprintf((char *)UART_send_buf,sizeof(UART_send_buf),"{\"cmd\":\"2\",\"spo2_data\":\"%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);
                        vc9202_alg_results.spo2_val = 0;        
                }       
@@ -454,9 +491,9 @@ char YYL_test(void)
                        co_printf("YYL_Output_PFE!!\n");
                        pOutputData = YYL_Output_PFE(&pOutputData_len);
                        co_printf("YYL_test:pOutputData_len:%d\n",pOutputData_len);
-                       memset(UART_send_buf,0,sizeof(UART_send_buf));
+                       memset(UART_send_buf,0,UART_SEND_MAX);
                        co_printf("YYL_test:");
-                       UART_send_buf_len = snprintf((char *)UART_send_buf,sizeof(UART_send_buf),
+                       UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,
                                                                                "{\"cmd\":\"2\",\"yyl_data\":\"");
                        uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL);
                        co_printf("%s",UART_send_buf);
@@ -470,7 +507,7 @@ char YYL_test(void)
                                //      break;
                                //co_printf("pOutputData_tmp:%x\n",pOutputData_tmp);
                                unsigned int time_tmp = get_timestamp();
-                               UART_send_buf_len = snprintf((char *)UART_send_buf,sizeof(UART_send_buf),
+                               UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,
                                                                                "%u,%d,%d,%d,%d,%d,%d,%d,%d,%d,",
                                                                                        time_tmp,pOutputData_tmp->timestamp,pOutputData_tmp->areaUP,pOutputData_tmp->areaUPBase,pOutputData_tmp->areaUPHeight,
                                                                                        pOutputData_tmp->areaDOWN,pOutputData_tmp->areaDOWNBase,pOutputData_tmp->areaDOWNHeight,pOutputData_tmp->RRI,pOutputData_tmp->motion);
@@ -541,7 +578,7 @@ void temp_test(void)
        
        //send_temp_data_flag=0;
        get_tp_data();
-       UART_send_buf_len = snprintf((char *)UART_send_buf,sizeof(UART_send_buf),"{\"cmd\":\"2\",\"temp_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;
@@ -567,7 +604,7 @@ void gsensor_test(void)
        //gsensor_init();
        signed short  sl_x_dat[5], sl_y_dat[5],sl_z_dat[5];
        // sl_x_dat[5], sl_y_dat[5],sl_z_dat[5];
-       UART_send_buf_len = snprintf((char *)UART_send_buf,sizeof(UART_send_buf),"{\"cmd\":\"2\",\"gsensor_data\":\"");
+       UART_send_buf_len = snprintf((char *)UART_send_buf,UART_SEND_MAX,"{\"cmd\":\"2\",\"gsensor_data\":\"");
        uart0_write_for_hci(UART_send_buf,UART_send_buf_len,NULL, NULL); 
        for(uint8_t i=0;i<5;i++)//转码
        {
@@ -592,23 +629,13 @@ void gsensor_test(void)
        uart0_write_for_hci(uart0_residue_data, 3,  NULL, NULL);        
        
 }
-void BP_timer_cb(void *arg)
-{
-       // evt.event_id = BP_IRQ;
-       // co_printf("BP_timer_cb !!\n");
-       // if(task_sensor_id != 0&&task_sensor_evn_flag==0)
-       // {
-       //      os_msg_post(task_sensor_id,&evt);
-       //      co_printf("BP_timer_cb :os_msg_post!!\n");
-       // }
-       BP_IRQ_FLAG = 1;
-               
-}
-os_timer_t BP_timer = {0};//
+
+
 void BP_open(void)//血压
 {
 
        gpio_set_pin_value(GPIO_PORT_A, GPIO_BIT_1, 1); //血压使能
+       gpio_set_pin_value(GPIO_PORT_A, GPIO_BIT_0, 0);  //心率失能
        co_delay_100us(5000);
        IIC1_Start_I2c();
        IIC1_Write_One_Byte(0x0A);
@@ -619,14 +646,14 @@ void BP_open(void)//血压
        IIC1_Stop_I2c( ); 
        send_bp_data_flag = 1;
        co_printf(" BP_open \n");
-       if(BP_timer.timer_id != 0)
-               os_timer_start(&BP_timer, 100, true);
+
        
 }
 void EMO_open(void)//情绪
 {
 
        gpio_set_pin_value(GPIO_PORT_A, GPIO_BIT_1, 1); //血压使能
+       gpio_set_pin_value(GPIO_PORT_A, GPIO_BIT_0, 0);  //心率失能
        co_delay_100us(5000);
        IIC1_Start_I2c();
        IIC1_Write_One_Byte(0x0A);
@@ -636,6 +663,7 @@ void EMO_open(void)//情绪
        IIC1_Read_Ack();
        IIC1_Stop_I2c(); 
        send_emo_data_flag = 1;
+
        co_printf(" EMO_open \n");
        
 }
@@ -644,6 +672,7 @@ void YYL_open(void)//中医
 
        gpio_set_pin_value(GPIO_PORT_A, GPIO_BIT_0, 1);  //心率使能
        gpio_set_pin_value(GPIO_PORT_A, GPIO_BIT_1, 0); //血压使能 
+       pmu_port_wakeup_func_set(GPIO_PC7);//使能心率中断
        pInit_Param.work_mode = WORK_MODE_HRV;
        vc9202_usr_init(&pInit_Param);
        YYL_Init_PFE( HA_BUF, HA_BUF_LEN);//中医初始化
@@ -658,6 +687,7 @@ void HRS_open(void)//心率
 
        gpio_set_pin_value(GPIO_PORT_A, GPIO_BIT_0, 1);  //心率使能 
        gpio_set_pin_value(GPIO_PORT_A, GPIO_BIT_1, 0); //血压使能
+       pmu_port_wakeup_func_set(GPIO_PC7);//使能心率中断
        pInit_Param.work_mode = WORK_MODE_HR;
        vc9202_usr_init(&pInit_Param);
        send_hrs_data_flag = 1;
@@ -670,6 +700,7 @@ void SPO2_open(void)//血氧
 
        gpio_set_pin_value(GPIO_PORT_A, GPIO_BIT_0, 1);  //心率使能 
        gpio_set_pin_value(GPIO_PORT_A, GPIO_BIT_1, 0); //血压使能
+       pmu_port_wakeup_func_set(GPIO_PC7);//使能心率中断
        pInit_Param.work_mode = WORK_MODE_SPO2;
        vc9202_usr_init(&pInit_Param);
        send_spo2_data_flag = 1;
@@ -693,9 +724,8 @@ void sensor_close(void)
        send_wear_data_flag=0;//发送wear数据标致位
        gpio_set_pin_value(GPIO_PORT_A, GPIO_BIT_0, 0);  //心率使能  低电平
        gpio_set_pin_value(GPIO_PORT_A, GPIO_BIT_1, 0); //血压使能
-       if(BP_timer.timer_id != 0)
-               os_timer_stop(&BP_timer);
 
+       pmu_port_wakeup_func_clear(GPIO_PC7);//失能中断GPIO中断
        co_printf("  sensor_close \n");
 }
 
@@ -717,10 +747,10 @@ void sensor_while(void)
                YYL_test();
 
        }
-       if(BP_IRQ_FLAG == 1)
+       //if(BP_IRQ_FLAG == 1)
        {
                //co_printf("sensor_while:HR_IRQ_FLAG:%d BP_IRQ_FLAG:%d\n",HR_IRQ_FLAG,BP_IRQ_FLAG);
-               BP_IRQ_FLAG = 0;
+               //BP_IRQ_FLAG = 0;
                EMO_test();
                BP_test();
        }
@@ -729,8 +759,7 @@ void sensor_while(void)
 }
 void sensor_init(void)
 {
-       // task_sensor_id = os_task_create(task_sensor_evn);//sensro数据处理数据处理
-       // co_printf("task_sensor_id:%d\n",task_sensor_id);
+
        
        //HR_EN = PA0 //心率使能, 
        //BP_EN = PA1 //血压使能, 
@@ -771,11 +800,11 @@ void sensor_init(void)
 
        pmu_set_pin_pull(GPIO_PORT_C,BIT(7),true);//上拉//心率中断
        pmu_set_pin_pull(GPIO_PORT_D,BIT(4),true);//上拉// 三轴地磁传感器中断
-       //pmu_set_pin_pull(GPIO_PORT_D,BIT(5),true);//上拉//血压中断
+       pmu_set_pin_pull(GPIO_PORT_D,BIT(5),true);//上拉//血压中断
        pmu_set_pin_pull(GPIO_PORT_D,BIT(6),true);//上拉 //4G中断0
        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中断      
+       //pmu_port_wakeup_func_set(GPIO_PC7|GPIO_PD4|GPIO_PD6|GPIO_PD7);//GPIO中断    
        NVIC_EnableIRQ(PMU_IRQn);
        
        
@@ -787,6 +816,6 @@ void sensor_init(void)
        
        get_tp_data();
        gsensor_init();//gsensor初始化
-       os_timer_init(&BP_timer, BP_timer_cb, NULL);
-       // os_timer_start(&BP_timer, 100, true);
+
+       //SPO2_open();
 }
index 876ade9..a4360e7 100644 (file)
@@ -31,6 +31,7 @@
 #define GAP_ADV_MODE_NON_CONN_SCAN          0x04    /// scannalbe & non-connectable
 #define GAP_ADV_MODE_HDC_DIRECT             0x05    /// non-scannalbe & connectable
 #define GAP_ADV_MODE_BEACON                 0x06    /// non-scannalbe & non-connectable
+#define GAP_ADV_MODE_CUSTOM                 0x07    /// scannalbe & connectable & custom adv type flags
 
 #define GAP_ADV_MODE_EXTEND_CONN_UNDIRECT   0x11
 #define GAP_ADV_MODE_EXTEND_CONN_DIRECT     0x12
@@ -222,11 +223,12 @@ typedef enum
     GAP_EVT_PER_SYNC_ESTABLISHED,   //!< Per_sync is established
     GAP_EVT_PER_SYNC_END,           //!< Periodic adv sync event ended
     GAP_EVT_ADV_REPORT,             //!< Scan result report
+    GAP_EVT_REMOTE_SCAN_REQUEST,    //!< Remote device send scan request
     GAP_EVT_CONN_END,               //!< Connecion action is ended
     GAP_EVT_PEER_FEATURE,           //!< Got peer device supported features
     GAP_EVT_MTU,                    //!< MTU exchange event
     GAP_EVT_LINK_RSSI,              //!< Got RSSI value of link peer device
-    GAP_EVT_LINK_VER,              //!< Got version value of link peer device
+    GAP_EVT_LINK_VER,               //!< Got version value of link peer device
 
     GAP_SEC_EVT_MASTER_AUTH_REQ,    //!< As master role, got authentication request from slave
     GAP_SEC_EVT_MASTER_ENCRYPT,     //!< Link is encryted as master role
@@ -237,6 +239,9 @@ typedef enum
     GAP_SEC_EVT_BOND_FAIL,          //!< Link bond is failed
     GAP_SEC_EVT_BOND_SUCCESS,       //!< Link bond is successful
     GAP_SEC_EVT_PIN_CODE_REQ,       //!< Link bond request pin code inpu
+    GAP_SEC_EVT_PEER_IDENTITY_ADDR, //!< Identity address of bonding device
+    GAP_SEC_EVT_LTK_MISSING,        //!< Link key missing
+    GAP_SEC_EVT_NC_REQ,             //!< Secure connect NC(Numeric Comparison) requset
 
     GAP_LECB_CONNECT,           //!< Connected as lecb
     GAP_LECB_DISCONNECT,        //!< disconnected as lecb
@@ -362,6 +367,14 @@ typedef struct
     uint8_t         *data;          //!< Report data
 } gap_evt_adv_report_t;
 
+// Indicate reception of scan request
+typedef struct
+{
+    uint8_t actv_idx;               //!< Activity adv identifier
+    gap_mac_addr_t trans_addr;      //!< Transmitter device address
+} gap_evt_scan_request_t;
+
+
 // link peer device version
 typedef struct
 {
@@ -418,7 +431,17 @@ typedef struct
     uint8_t reason;             //!< Reason of enc fail
 } gap_evt_bond_fail_t;
 
+typedef struct{
+    uint8_t conidx;
+    mac_addr_t addr;
+    uint8_t addr_type;
+} gap_evt_bond_peer_identity_addr_t;
 
+typedef struct
+{
+    uint8_t  conidx;
+    uint32_t nc_data;
+} gap_evt_secure_connect_nc_req_t;
 
 // LE credit based connection indication
 typedef struct
@@ -509,6 +532,7 @@ typedef struct
         uint8_t                         per_sync_end_status;    //!< Per_sync event end status
         gap_evt_per_sync_ready_t        per_sync_ready;         //!< Per_sync is established
         gap_evt_adv_report_t            *adv_rpt;               //!< Scanning results
+        gap_evt_scan_request_t          scan_request;           //!< Remote device scan request
         uint8_t                         conn_end_reason;        //!< Connection end reason
         gap_evt_peer_feature_t          peer_feature;           //!< Peer device supported features
         gattc_mtu_t                     mtu;                    //!< MTU size
@@ -522,7 +546,10 @@ typedef struct
         uint8_t                         bond_start_conidx;   //!< link index, in which link, bond started
         uint8_t                         bond_success_conidx;   //!< link index, in which link, bond successed 
         gap_evt_bond_fail_t             bond_fail;   //!< link index, in which link, bond failed 
+        gap_evt_bond_peer_identity_addr_t peer_identity_addr;
+        uint8_t                         bond_ltk_missing_conidx; //!< link index, in which link, bond linkkey missing
         uint8_t                         bond_pin_code_req_conidx; //!< link index, in which link, bond procedure need pin code input
+        gap_evt_secure_connect_nc_req_t bond_secure_connect_nc_req;  //!< For GAP_SEC_EVT_NC_REQ Event.
 
         gap_lecb_conn_param_t           lecb_conn;
         gap_lecb_disconnect_t           lecb_disconn;
@@ -580,7 +607,7 @@ typedef struct
     uint8_t  io_cap;            //!< IO capbilities, see @ GAP_IO_CAP_DEFINES
     uint8_t  pair_init_mode;    //!< If initialize pairing procesure or not, see @ GAP_PAIRING_MODE_DEFINES
     bool     bond_auth;         //!< Bond_auth enable/disable,if true, then will distribute encryption key,and will check this key_req when bonding.
-    uint32_t password;          //!< Password.range:[000,000 , 999,999]. The keboard device shall ensure that all 6 digits are inputed ¡§C including zeros.
+    uint32_t password;          //!< Password.range:[000,000 , 999,999]. The keboard device shall ensure that all 6 digits are inputed ��C including zeros.
 } gap_security_param_t;
 
 // Gap bond information
@@ -732,7 +759,16 @@ void gap_set_per_adv_data1(uint8_t *p_per_adv_data, uint16_t per_adv_data_len);
 void gap_start_advertising1(uint16_t duration);
 void gap_stop_advertising1(void);
 /*****************functions for adv1 ****************/
-
+/*********************************************************************
+* @fn      patch_fast_scan_set
+*
+* @brief   Enable fast scan
+*
+* @param   flag - true: enable fast scan. false: disable fast scan.
+*
+* @return  None.
+*/
+void patch_fast_scan_set(bool flag);
 /*********************************************************************
 * @fn      gap_start_scan
 *
@@ -876,6 +912,20 @@ void gap_address_get(mac_addr_t *addr);
  * @return  None.
  */
 void gap_address_set(mac_addr_t *addr);
+
+/*********************************************************************
+ * @fn      gap_peer_identity_addr_get
+ *
+ * @brief   Used to get peer identity address after binding is finised.
+ *
+ * @param   conidx  - connection index
+ *          addr    - pointer used to store peer address
+ *          addr_type - pointer used to store peer address type, 0=public/1=private random
+ *
+ * @return  True: get peer identity address successfully.
+ */
+bool gap_peer_identity_addr_get(uint8_t conidx, mac_addr_t *addr, uint8_t *addr_type);
+
 /*********************************************************************
  * @fn      gap_set_mtu
  *
@@ -1005,7 +1055,16 @@ uint8_t gap_get_connect_num(void);
  * @return  None.
  */
 void gap_set_link_rssi_report(bool enable);
-
+/*********************************************************************
+ * @fn      rssi_threshold_set
+ *
+ * @brief   Set rssi threshold when connect ind packet.
+ *          
+ * @param   rssi  - range(0~-100)
+ *
+ * @return  None.
+ */
+void rssi_threshold_set(int8_t rssi);
 /*********************************************************************
  * @fn      gap_get_link_rssi
  *
@@ -1237,6 +1296,19 @@ bool gap_security_get_bond_req(void);
  */
 void gap_security_req(uint8_t conidx);
 
+/*********************************************************************
+ * @fn      gap_sec_nc_rsp
+ *
+ * @brief   When initiating an NC request from the peer, determine whether to accept the request.
+ *          For GAP_SEC_EVT_NC_REQ Event.
+ *
+ * @param   conidx      - connection index.
+ *          accept      - determine whether to accept the request.
+ *
+ * @return  None.
+ */
+void gap_sec_send_nc_rsp(uint8_t conidx, bool accept);
+
 /**********************************************************************
  * @fn      gap_get_latest_conn_parameter
  *
@@ -1281,7 +1353,19 @@ void gap_param_update_rsp(gap_evt_link_param_update_rsp_t *rsp);
  */
 void gap_set_channel_map(gap_channel_map_t *channel_map);
 
+/**********************************************************************
+ * @fn      gap_pairing_rsp
+ *
+ * @brief   rsp     - Whether to accept peer pairing request
+ *
+ * @param   accept_en     - true - accept peer pairing request
+ *                        - false - Do not accept peer pairing requests
+ *
+ * @return  None
+ */
+void gap_pairing_rsp(bool accept_en);
 
 #endif // end of #ifndef GAP_API_H
 
 
+
index fa50b68..a2f8f3f 100644 (file)
@@ -133,16 +133,18 @@ typedef struct
 */
 typedef enum
 {
-    GATTC_MSG_READ_REQ,         //!< GATT client read request
-    GATTC_MSG_WRITE_REQ,        //!< GATT client write request
-    GATTC_MSG_ATT_INFO_REQ,     //!< GATT client att information request
-    GATTC_MSG_NTF_REQ,          //!< GATT client notification received
-    GATTC_MSG_IND_REQ,          //!< GATT client indication received
-    GATTC_MSG_READ_IND,         //!< GATT client read response received
-    GATTC_MSG_CMP_EVT,          //!< GATT client message complete event
-    GATTC_MSG_LINK_CREATE,      //!< A Link is established
-    GATTC_MSG_LINK_LOST,        //!< A Link is lost
-    GATTC_MSG_SVC_REPORT,       //!< GATT client received peer service report
+    GATTC_MSG_READ_REQ,             //!< GATT client read request
+    GATTC_MSG_WRITE_REQ,            //!< GATT client write request
+    GATTC_MSG_ATT_INFO_REQ,         //!< GATT client att information request
+    GATTC_MSG_NTF_REQ,              //!< GATT client notification received
+    GATTC_MSG_IND_REQ,              //!< GATT client indication received
+    GATTC_MSG_READ_IND,             //!< GATT client read response received
+    GATTC_MSG_CMP_EVT,              //!< GATT client message complete event
+    GATTC_MSG_LINK_CREATE,          //!< A Link is established
+    GATTC_MSG_LINK_LOST,            //!< A Link is lost
+    GATTC_MSG_SVC_REPORT,           //!< GATT client received peer service report
+
+    GATTC_MSG_HANDLE_ERROR = 0x80,  //!< Application cannot deal message correctly, error code is stored in gatt_msg_t->op->status
 } gatt_msg_evt_t;
 
 /**
@@ -445,7 +447,9 @@ void gatt_add_client_uuid(gatt_uuid_t att_tb[], uint8_t att_nb, uint8_t conn_idx
        gatt_delete_svc((uint8_t *)&svc_uuid,2);
    }
  */
-void gatt_delete_svc(uint8_t *svc_uuid,uint8_t uuid_size);
+void gatt_delete_svc(uint8_t svc_id,uint8_t *svc_uuid,uint8_t uuid_size);
+void gatt_delete_svc_internal(uint8_t *svc_uuid,uint8_t uuid_size);
+
 
 /*********************************************************************
  * @fn      gatt_get_svc_hdl
@@ -521,6 +525,18 @@ void gatt_discovery_all_peer_svc(uint8_t client_id,uint8_t conidx);
  */
 void gatt_discovery_peer_svc(uint8_t client_id, uint8_t conidx, uint8_t uuid_len, uint8_t *group_uuid);
 
+/*********************************************************************
+ * @fn      gatt_clear_remote_svc
+ *
+ * @brief   used to clear discovered characters and descriptions stored in gatt_svc_list
+ *          after connection is removed.
+ *
+ * @param   conidx  - connection index.
+ *
+ * @return  None.
+ */
+void gatt_clear_remote_svc(uint8_t conidx);
+
 
 /*********************************************************************
  * @fn      gatt_client_direct_register
index e6fa477..14acc71 100644 (file)
@@ -17,7 +17,7 @@
 #include <stdint.h>
 
 #include "gap_api.h"
-#include "jump_table.h"
+
 /*
  * MACROS 
  */
@@ -131,17 +131,17 @@ typedef struct mesh_composition_cfg
     uint16_t vid;
 } mesh_composition_cfg_t ;
 
-// Mesh publish message type defineÍø¸ñ·¢²¼ÏûÏ¢ÀàÐͶ¨Òå
+// Mesh publish message type define
 typedef struct
 {
-    uint8_t     element_idx;    //!< Element index of the received message.½ÓÊÕµ½µÄÏûÏ¢µÄÔªËØË÷Òý¡£
-    uint32_t    model_id;       //!< Model ID of the received message.ÊÕµ½ÏûÏ¢µÄÐͺÅID
-    uint32_t    opcode;         //!< Mesh message operation code (can be 1, 2 or 3 octet operation code).Íø×´ÏûÏ¢²Ù×÷Â루¿ÉÒÔÊÇ1¡¢2»ò3¸ö°Ëλ×Ö½Ú²Ù×÷Â룩¡£
-    uint16_t    msg_len;        //!< Message length.ÏûÏ¢³¤¶È
-    uint8_t     msg[];          //!< Message data.ÏûÏ¢Êý¾Ý
+    uint8_t     element_idx;    //!< Element index of the received message.
+    uint32_t    model_id;       //!< Model ID of the received message.
+    uint32_t    opcode;         //!< Mesh message operation code (can be 1, 2 or 3 octet operation code).
+    uint16_t    msg_len;        //!< Message length.
+    uint8_t     msg[];          //!< Message data.
 } mesh_publish_msg_t;
 
-// Mesh response message type defineÍø¸ñÏìÓ¦ÏûÏ¢ÀàÐͶ¨Òå
+// Mesh response message type define
 typedef struct
 {
     uint8_t     element_idx;    //!< Element index of the sending message.
@@ -301,10 +301,10 @@ typedef struct
 // Mesh model struct.
 typedef struct
 {
-    uint32_t        model_id;                           //!< Model ID of the model to be added.ÒªÌí¼ÓµÄÄ£Ð͵ÄÄ£ÐÍID¡£
-    uint8_t         model_vendor;                       //!< If it is SIG model or vendor specific model. @MODEL_VENDOR_MODEÈç¹ûÊÇSIGÐͺŻò¹©Ó¦ÉÌÌØ¶¨ÐͺÅ
-    uint8_t         element_idx;                        //!< Element index in the mesh device.Íø¸ñÉ豸ÖеÄÔªËØË÷Òý
-    void (*msg_handler)(const mesh_model_msg_ind_t*);   //!< Model message handler.Ä£ÐÍÏûÏ¢´¦Àí³ÌÐò
+    uint32_t        model_id;                           //!< Model ID of the model to be added.
+    uint8_t         model_vendor;                       //!< If it is SIG model or vendor specific model. @MODEL_VENDOR_MODE
+    uint8_t         element_idx;                        //!< Element index in the mesh device.
+    void (*msg_handler)(const mesh_model_msg_ind_t*);   //!< Model message handler.
 } mesh_model_t;
 
 // Gap callback function define for mesh event handling.
@@ -533,7 +533,7 @@ void mesh_get_remote_param(uint16_t * src,uint8_t * app_key_lid);
 /*********************************************************************
  * @fn      mesh_publish_msg
  *
- * @brief   Publish a message in mesh network.ÔÚmeshÍøÂçÖз¢²¼ÏûÏ¢¡£
+ * @brief   Publish a message in mesh network.
  *
  * @param   mesh_publish_msg_t     - Address of message to be published.
  *
index 862f6ca..5204019 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/components/ble/library/libfr8010h_stack.a and b/1.doc/K18/BLE_Watch/components/ble/library/libfr8010h_stack.a differ
index 9051b94..565ea3c 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 /*
- * INCLUDES (°üº¬Í·Îļþ)
+ * INCLUDES (包含头文件)
  */
 #include <stdio.h>
 #include <string.h>
@@ -22,7 +22,7 @@
 
 
 /*
- * MACROS (ºê¶¨Òå)
+ * MACROS (宏定义)
  */
 #define REMOTE_CMD_UUID     {0xc2, 0x51, 0xca, 0xf7, 0x56, 0x0e, 0xdf, 0xb8, \
                                                 0x8a, 0x4a, 0xb1, 0x57, 0xd8,0x81, 0x3c, 0x9b}
                                                 0xd8, 0x46, 0xab, 0x23, 0x8c,0xf3, 0xb2, 0xc6}
 
 /*
- * CONSTANTS (³£Á¿¶¨Òå)
+ * CONSTANTS (常量定义)
  */
 
 /*
- * TYPEDEFS (ÀàÐͶ¨Òå)
+ * TYPEDEFS (类型定义)
  */
 
 /*
- * GLOBAL VARIABLES (È«¾Ö±äÁ¿)
+ * GLOBAL VARIABLES (全局变量)
  */
 
 
 /*
- * LOCAL VARIABLES (±¾µØ±äÁ¿)
+ * LOCAL VARIABLES (本地变量)
  */
 static void AMS_gatt_write_cmd(uint8_t conidx,enum ams_att_idx att_idx,uint8_t *p_data, uint16_t len);
 static void AMS_gatt_write_req(uint8_t conidx,enum ams_att_idx att_idx,uint8_t *p_data, uint16_t len);
@@ -58,9 +58,9 @@ uint8_t AMS_client_id;
 
 /*********************************************************************
  * Profile Attributes - Table
- * Ã¿Ò»Ïî¶¼ÊÇÒ»¸öcharacteristic attribute¶ÔÓ¦µÄUUIDµÄ¶¨Òå¡£
- * µÚÒ»¸öÊÇUUIDµÄ³¤¶È£¬
- * Ã¿¶þ¸öÊÇUUIDµÄÖµ¡£
+ * 每一项都是一个characteristic attribute对应的UUID的定义。
+ * 第一个是UUID的长度,
+ * 每二个是UUID的值。
  */
 const gatt_uuid_t AMS_att_tb[] =
 {
@@ -158,15 +158,19 @@ uint16_t AMS_gatt_msg_handler(gatt_msg_t *p_msg)
                 uint16_t att_handles[3];
                 memcpy(att_handles,p_msg->param.op.arg,6);
                 show_reg((uint8_t *)att_handles,6,1);
-
-                gatt_client_enable_ntf_t ntf_enable;
-                ntf_enable.conidx = p_msg->conn_idx;
-                ntf_enable.client_id = AMS_client_id;
-                ntf_enable.att_idx = AMS_ATT_IDX_ENT_UPDATE;
-                gatt_client_enable_ntf(ntf_enable);
-
-                ntf_enable.att_idx = AMS_ATT_IDX_REMOTE_CMD;
-                gatt_client_enable_ntf(ntf_enable);
+                                                               
+                if(att_handles[3] != 0)
+                {
+                    gatt_client_enable_ntf_t ntf_enable;
+                    ntf_enable.conidx = p_msg->conn_idx;
+                    ntf_enable.client_id = AMS_client_id;
+                    ntf_enable.att_idx = AMS_ATT_IDX_ENT_UPDATE;
+                    gatt_client_enable_ntf(ntf_enable);
+
+                    ntf_enable.att_idx = AMS_ATT_IDX_REMOTE_CMD;
+                    gatt_client_enable_ntf(ntf_enable);
+                }
+                
             }
             else if(p_msg->param.op.operation == GATT_OP_WRITE_REQ && p_msg->att_idx == AMS_ATT_IDX_ENT_ATT)
                 AMS_gatt_read(AMS_client_conidx,AMS_ATT_IDX_ENT_ATT);
@@ -252,10 +256,10 @@ void AMS_gatt_read(uint8_t conidx,enum ams_att_idx att_idx)
 }
 
 /*********************************************************************
- * @fn      AMS_gatt_add_client
+ * @fn      batt_gatt_add_service
  *
- * @brief   AMS Profile add GATT client function.
- *          Ìí¼ÓAMS GATT clientµ½ATTµÄÊý¾Ý¿âÀïÃæ¡£
+ * @brief   Simple Profile add GATT service function.
+ *          添加GATT service到ATT的数据库里面。
  *
  * @param   None.
  *
index ab67ae8..21b3fd6 100644 (file)
@@ -339,14 +339,18 @@ uint16_t ANCS_AMS_gatt_msg_handler(gatt_msg_t *p_msg)
                 memcpy(ANCS_hdl_cache,p_msg->param.op.arg,12);
                 show_reg((uint8_t *)ANCS_hdl_cache,12,1);
 
-                gatt_client_enable_ntf_t ntf_enable;
-                ntf_enable.conidx = p_msg->conn_idx;
-                ntf_enable.client_id = ANCS_AMS_client_id;
-                ntf_enable.att_idx = ANCS_ATT_IDX_NTF_SRC;
-                gatt_client_enable_ntf(ntf_enable);
-
-                ntf_enable.att_idx = ANCS_ATT_IDX_DATA_SRC;
-                gatt_client_enable_ntf(ntf_enable);
+                               if(ANCS_hdl_cache[0] != 0)
+                               {
+                                       gatt_client_enable_ntf_t ntf_enable;
+                           ntf_enable.conidx = p_msg->conn_idx;
+                           ntf_enable.client_id = ANCS_AMS_client_id;
+                           ntf_enable.att_idx = ANCS_ATT_IDX_NTF_SRC;
+                           gatt_client_enable_ntf(ntf_enable);
+
+                           ntf_enable.att_idx = ANCS_ATT_IDX_DATA_SRC;
+                           gatt_client_enable_ntf(ntf_enable);
+                               }
+                
             }
         }
         break;
index 2d585c7..5dab0a6 100644 (file)
@@ -208,7 +208,11 @@ static uint16_t gap_gatt_msg_handler(gatt_msg_t *p_msg)
             }
             else if(p_msg->att_idx == IDX_GAP_ICON)
             {
-                gap_set_dev_appearance((uint16_t)(p_msg->param.msg.p_msg_data));
+                if(p_msg->param.msg.msg_len == sizeof(uint16_t))
+                {
+                    uint16_t appearance = p_msg->param.msg.p_msg_data[0] | (p_msg->param.msg.p_msg_data[1] << 8);
+                    gap_set_dev_appearance(appearance);
+                }
             }
             break;
 
index 953e505..b6911ba 100644 (file)
@@ -24,6 +24,7 @@
 #include "flash_usage_config.h"
 #ifdef OTA_CRC_CHECK
 #include "os_timer.h"
+
 uint32_t Crc32CalByByte(int crc,uint8_t* ptr, int len);
 uint8_t app_otas_crc_cal(uint32_t firmware_length,uint32_t new_bin_addr,uint32_t crc_data_t);
 void enable_cache(uint8_t invalid_ram);
@@ -108,8 +109,6 @@ static uint32_t app_otas_get_image_size(void)
     return jump_table_tmp->image_size;
 }
 
-
-
 __attribute__((section("ram_code"))) static void app_otas_save_data(uint32_t dest, uint8_t *src, uint32_t len)
 {
     uint32_t current_remap_address, remap_size;
@@ -152,6 +151,46 @@ __attribute__((section("ram_code"))) static void app_otas_save_data(uint32_t des
     */
 }
 
+#ifdef OTA_FOR_FR8012HAQ_J
+#define REG_BLE_WR(addr, value)      (*(volatile uint32_t *)(addr)) = (value)
+#define REG_BLE_RD(addr)             (*(volatile uint32_t *)(addr))
+
+__attribute__((section("ram_code"))) static void app_otas_flash_read(uint32_t dest, uint8_t *src, uint32_t len)
+{
+    uint32_t current_remap_address, remap_size;
+    current_remap_address = system_regs->remap_virtual_addr;
+    remap_size = system_regs->remap_length;
+
+    GLOBAL_INT_DISABLE();
+    system_regs->remap_virtual_addr = 0;
+    system_regs->remap_length = 0;
+    disable_cache();
+    flash_read(dest,len,src);
+    enable_cache(true);
+    system_regs->remap_virtual_addr = current_remap_address;
+    system_regs->remap_length = remap_size;
+    GLOBAL_INT_RESTORE();
+}
+
+__attribute__((section("ram_code"))) static void app_otas_save_first_pkt(uint32_t dest,uint8_t *src,uint32_t len)
+{
+    uint8_t * first_page_data = NULL;
+    __disable_irq();
+    REG_BLE_WR(0x40000000, (REG_BLE_RD(0x40000000) & ~((uint32_t)0x80000000)) | ((uint32_t)1<< 31));
+    co_delay_100us(100);
+    first_page_data = (uint8_t *)0x40002000;
+    memset(first_page_data,0,0x1000);
+
+    app_otas_flash_read(dest,first_page_data,0x1000);
+    memcpy(first_page_data,src,len);
+    flash_erase(dest,0x1000);
+    app_otas_save_data(dest,first_page_data,0x1000);
+   
+    uart_finish_transfers(UART1_BASE);        
+    platform_reset_patch(0);
+}
+#endif
+
 void ota_clr_buffed_pkt(uint8_t conidx)
 {
     //current_conidx = 200;
@@ -192,6 +231,11 @@ void __attribute__((weak)) ota_recover_flash_pin(void)
 #ifdef OTA_CRC_CHECK
 void __attribute__((weak)) ota_start(void)
 {
+    co_printf("ota_start1\r\n\r\n");
+    //pmu_port_wakeup_func_clear(GPIO_PC7|GPIO_PD4|GPIO_PD6|GPIO_PD7);
+    //NVIC_DisableIRQ(UART0_IRQn);//¹ØÖжÏ
+    //NVIC_DisableIRQ(TIMER1_IRQn);//¹ØÖжÏ
+    os_user_loop_event_clear();
     os_timer_init(&os_timer_ota,os_timer_ota_cb,NULL);
     os_timer_start(&os_timer_ota, OTA_TIMEOUT, 0);
     co_printf("ota_start\r\n\r\n");
@@ -375,6 +419,17 @@ void app_otas_recv_data(uint8_t conidx,uint8_t *p_data,uint16_t len)
 #endif
             if(rsp_hdr->rsp.page_erase.base_address == new_bin_base)
             {
+#ifdef OTA_FOR_FR8012HAQ_J
+                uint8_t * head_pkt = NULL;
+                head_pkt = os_malloc(256);
+                if(head_pkt)
+                {
+                    app_otas_flash_read(rsp_hdr->rsp.page_erase.base_address,head_pkt,256);
+                    flash_erase(rsp_hdr->rsp.page_erase.base_address, 0x1000);
+                    app_otas_save_data(rsp_hdr->rsp.page_erase.base_address,head_pkt,256);
+                    os_free(head_pkt);
+                }
+#else                
                 for(uint16_t offset = 256; offset < 4096; offset += 256)
                 {
 #ifdef FLASH_PROTECT
@@ -385,6 +440,7 @@ void app_otas_recv_data(uint8_t conidx,uint8_t *p_data,uint16_t len)
                     flash_protect_enable(0);
 #endif
                 }
+#endif                
             }
             else
                 flash_erase(rsp_hdr->rsp.page_erase.base_address, 0x1000);
@@ -493,6 +549,10 @@ void app_otas_recv_data(uint8_t conidx,uint8_t *p_data,uint16_t len)
 #ifdef OTA_CRC_CHECK
                 if(app_otas_crc_cal(cmd_hdr->cmd.fir_crc_data.firmware_length,new_bin_base,cmd_hdr->cmd.fir_crc_data.CRC32_data)){
 #endif                    
+#ifdef OTA_FOR_FR8012HAQ_J
+                co_printf("crc32 check success\r\n");
+                app_otas_save_first_pkt(new_bin_base,first_pkt.buf,256);
+#else                    
 #ifdef FLASH_PROTECT
                 flash_protect_disable(0);
 #endif 
@@ -502,6 +562,7 @@ void app_otas_recv_data(uint8_t conidx,uint8_t *p_data,uint16_t len)
 #endif 
                                co_printf("crc32 check success\r\n");
                 app_otas_save_data(new_bin_base,first_pkt.buf,256);
+#endif                    
 #ifdef OTA_CRC_CHECK                           
                 }
                 else{
@@ -512,11 +573,13 @@ void app_otas_recv_data(uint8_t conidx,uint8_t *p_data,uint16_t len)
                 }
 #endif                    
             }
+#ifndef OTA_FOR_FR8012HAQ_J            
             app_set_ota_state(0);
             uart_finish_transfers(UART1_BASE);
             ota_clr_buffed_pkt(conidx);
             //NVIC_SystemReset();
             platform_reset_patch(0);
+#endif            
             break;
         default:
             rsp_hdr->result = OTA_RSP_UNKNOWN_CMD;
index d1e8582..e90ae44 100644 (file)
@@ -11,6 +11,7 @@
 #ifdef OTA_CRC_CHECK
 #define OTA_TIMEOUT  5000
 #endif
+#define OTA_FOR_FR8012HAQ_J
 typedef enum 
 {
     OTA_CMD_NVDS_TYPE,
index b669c93..0d9b06e 100644 (file)
@@ -290,7 +290,7 @@ __attribute__((section("ram_code")))uint8_t timer_init_count_us_reload(uint32_t
  */
 __attribute__((section("ram_code"))) void timer0_isr_ram(void)
 {
-//    uint32_t ir_carrier_cycle = 0;
+    uint32_t ir_carrier_cycle = 0;
     uint16_t i=0;
     timer_clear_interrupt(TIMER0);
 
index 67db1d0..931c53e 100644 (file)
@@ -393,7 +393,7 @@ void pmu_bg_trim(uint32_t trim_value)
 {
     uint32_t data[5];
     uint16_t ref_internal = 0,ref_avdd = 0;
-    uint8_t bg_set = 0;
+    uint16_t bg_set = 0;
     uint8_t correction_value = 0;
     uint16_t internal_adj, avdd_adj;
 
@@ -401,28 +401,32 @@ void pmu_bg_trim(uint32_t trim_value)
     {
         ref_internal = ((trim_value >> 12) & 0xfff);
         ref_avdd = (trim_value & 0xfff);
-        }
-        else
-        {
+    }
+    else
+    {
         flash_OTP_read(0x1000, 5*sizeof(uint32_t), (void *)data);
         if(data[0] == 0x31303030) {
             ref_internal = ((400*1024)/(data[3] / 32) + (800*1024)/(data[4] / 32)) / 2;
             ref_avdd = ((2400*1024)/(data[1] / 32) + (800*1024)/(data[2] / 32)) / 2;
         }
     }
-
+    
+    if(ref_avdd == 0)
+    {
+        return;
+    }
     if(ref_avdd >= 2925)
     {
         bg_set = ((ref_avdd*10-29000u)*100)/(125*29);
     }
     else if(ref_avdd < 2875)
-        {
+    {
         bg_set = ((29000u-ref_avdd*10)*100)/(125*29);
-        }
-        else
-        {
+    }
+    else
+    {
         bg_set = 0;       
-        }
+    }
     correction_value = bg_set % 10;
     bg_set = bg_set / 10;
     if(correction_value >= 5u)
@@ -445,7 +449,7 @@ void pmu_bg_trim(uint32_t trim_value)
         ref_internal += internal_adj;
         ref_avdd += avdd_adj;
     }
-
+    
     adc_set_ref_voltage(ref_avdd, ref_internal);
 }
 
@@ -477,7 +481,7 @@ void pmu_sub_init(void)
     /* change BUCK setting for better sensitivity performance */
     ool_write(PMU_REG_BUCK_CTRL0, 0x40);
     /* set BUCK voltage to min */
-    ool_write(PMU_REG_BUCK_CTRL1, 0x25);
+    ool_write(PMU_REG_BUCK_CTRL1, 0x45);
 
     /* set DLDO voltage to min */
     //ool_write(PMU_REG_DLDO_CTRL, 0x42);
@@ -485,15 +489,13 @@ void pmu_sub_init(void)
     /* separate PKVDD and PKVDDH */
     ool_write(PMU_REG_ALDO_BG_CTRL, 0x06);
     ool_write(PMU_REG_ALDO_BG_CTRL, 0x0e);
-    ool_write(PMU_REG_PKVDD_CTRL, 0x09 | 0xa4);
-    ool_write(PMU_REG_PKVDD_CTRL, 0x49 | 0xa4);
+    ool_write(PMU_REG_PKVDD_CTRL, 0x09 | 0x24);
+    ool_write(PMU_REG_PKVDD_CTRL, 0x49 | 0x24);
+    ool_write(PMU_REG_PKPD_CTRL_CFG, 0xa0);
 
     /* set PKVDDH to min */
     ool_write(PMU_REG_OTD_PKVDDH_CTRL, ool_read(PMU_REG_OTD_PKVDDH_CTRL) & 0xcf);
 
-    #ifdef CFG_FT_CODE
-    ool_write(PMU_REG_PKVDD_CTRL2, (ool_read(PMU_REG_PKVDD_CTRL2) & 0xF0) | 0x09);
-    #else   // CFG_FT_CODE
     /* set PKVDD voltage to 0.85v */
     uint32_t data0, data1, data2;
     uint8_t dldo_v = 0;
@@ -518,7 +520,6 @@ void pmu_sub_init(void)
     }
     /* set DLDO voltage to lower value */
     ool_write(PMU_REG_DLDO_CTRL, 0x62);
-    #endif  // CFG_FT_CODE
 
     /*
         1. set PMU interrupt wake up pmu ctrl first
@@ -628,9 +629,7 @@ void pmu_sub_init(void)
     ool_write(PMU_REG_DIAG_SEL, 0x42);
 #endif
 
-#ifndef CFG_FT_CODE
     pmu_bg_trim(data2);
-#endif
 }
 
 /*********************************************************************
@@ -905,7 +904,7 @@ __attribute__((weak)) __attribute__((section("ram_code"))) void otd_isr_ram(void
     co_printf("otd\r\n");
     pmu_disable_isr(PMU_ISR_OTP_EN);
 }
-__attribute__((weak)) __attribute__((section("ram_code"))) void pmu_gpio_isr_ram(void)  //GPIOÖжϠ ÔÚÆäËüµØ·½¶¨ÒåÕâÀï½ûÖ¹
+__attribute__((weak)) __attribute__((section("ram_code"))) void pmu_gpio_isr_ram(void)
 {
     //co_printf("gpio new value = 0x%08x.\r\n", ool_read32(PMU_REG_GPIOA_V));
     //uart_putc_noint_no_wait(UART1, 'g');
index 7efbe80..e41e93e 100644 (file)
@@ -65,6 +65,7 @@ enum pmu_aldo_voltage_t
     PMU_ALDO_VOL_2_5 = 0xa0,
     PMU_ALDO_VOL_2_3 = 0x90,
     PMU_ALDO_VOL_2_1 = 0x80,
+    PMU_ALDO_VOL_1_8 = 0x30,
 };
 
 enum pmu_lp_clk_src_t
index 4e55c59..450a6a7 100644 (file)
@@ -1,40 +1,40 @@
 #include <stdint.h>
 #include "adpcm.h"
-//This code is for dialogic ADPCM 
+//This code is for dialogic ADPCM
 /* Intel ADPCM step variation table */
 static int indexTable[16] =
 {
-       -1, -1, -1, -1, 2, 4, 6, 8,
-       -1, -1, -1, -1, 2, 4, 6, 8,
+    -1, -1, -1, -1, 2, 4, 6, 8,
+    -1, -1, -1, -1, 2, 4, 6, 8,
 };
 
 static int stepsizeTable[89] =
 {
-       7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
-       19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
-       50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
-       130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
-       337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
-       876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
-       2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
-       5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
-       15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
+    7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
+    19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
+    50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
+    130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
+    337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
+    876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
+    2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
+    5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
+    15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
 };
 
 void encode(struct CodecState* state, s16* input, int numSamples, u8* output)
 {
-    s16 *inp;                  /* Input buffer pointer */
-    u8 *outp;          /* output buffer pointer */
-    int val;                   /* Current input sample value */
-    int sign;                  /* Current adpcm sign bit */
-    int delta;                 /* Current adpcm output value */
-    int diff;                  /* Difference between val and valprev */
-    int step;                  /* Stepsize */
-    int valpred;               /* Predicted output value */
-    int vpdiff;                        /* Current change to valpred */
-    int index;                 /* Current step change index */
-    int outputbuffer;          /* place to keep previous 4-bit value */
-    int bufferstep;            /* toggle between outputbuffer/output */
+    s16 *inp;           /* Input buffer pointer */
+    u8 *outp;       /* output buffer pointer */
+    int val;            /* Current input sample value */
+    int sign;           /* Current adpcm sign bit */
+    int delta;          /* Current adpcm output value */
+    int diff;           /* Difference between val and valprev */
+    int step;           /* Stepsize */
+    int valpred;        /* Predicted output value */
+    int vpdiff;         /* Current change to valpred */
+    int index;          /* Current step change index */
+    int outputbuffer;       /* place to keep previous 4-bit value */
+    int bufferstep;     /* toggle between outputbuffer/output */
 
     outp = output;
     inp = input;
@@ -42,102 +42,102 @@ void encode(struct CodecState* state, s16* input, int numSamples, u8* output)
     valpred = state->valprev;
     index = state->index;
     step = stepsizeTable[index];
-    
+
     bufferstep = 1;
 
     for ( ; numSamples > 0 ; numSamples-- )
     {
-       val = *inp++;
-
-       /* Step 1 - compute difference with previous value */
-       diff = val - valpred;
-       sign = (diff < 0) ? 8 : 0;
-       if ( sign ) diff = (-diff);
-
-       /* Step 2 - Divide and clamp */
-       /* Note:
-       ** This code *approximately* computes:
-       **    delta = diff*4/step;
-       **    vpdiff = (delta+0.5)*step/4;
-       ** but in shift step bits are dropped. The net result of this is
-       ** that even if you have fast mul/div hardware you cannot put it to
-       ** good use since the fixup would be too expensive.
-       */
-       delta = 0;
-       vpdiff = (step >> 3);
-       
+        val = *inp++;
+
+        /* Step 1 - compute difference with previous value */
+        diff = val - valpred;
+        sign = (diff < 0) ? 8 : 0;
+        if ( sign ) diff = (-diff);
+
+        /* Step 2 - Divide and clamp */
+        /* Note:
+        ** This code *approximately* computes:
+        **    delta = diff*4/step;
+        **    vpdiff = (delta+0.5)*step/4;
+        ** but in shift step bits are dropped. The net result of this is
+        ** that even if you have fast mul/div hardware you cannot put it to
+        ** good use since the fixup would be too expensive.
+        */
+        delta = 0;
+        vpdiff = (step >> 3);
+
         if ( diff >= step )
         {
-           delta = 4;
-           diff -= step;
-           vpdiff += step;
-       }
-       step >>= 1;
+            delta = 4;
+            diff -= step;
+            vpdiff += step;
+        }
+        step >>= 1;
         if ( diff >= step  )
         {
-           delta |= 2;
-           diff -= step;
-           vpdiff += step;
-       }
-       step >>= 1;
+            delta |= 2;
+            diff -= step;
+            vpdiff += step;
+        }
+        step >>= 1;
         if ( diff >= step )
         {
-           delta |= 1;
-           vpdiff += step;
-       }
-
-       /* Step 3 - Update previous value */
-       if ( sign )
-         valpred -= vpdiff;
-       else
-         valpred += vpdiff;
-
-       /* Step 4 - Clamp previous value to 16 bits */
-       if ( valpred > 32767 )
-         valpred = 32767;
-       else if ( valpred < -32768 )
-         valpred = -32768;
-
-       /* Step 5 - Assemble value, update index and step values */
-       delta |= sign;
-       
-       index += indexTable[delta];
-       if ( index < 0 ) index = 0;
-       if ( index > 88 ) index = 88;
-       step = stepsizeTable[index];
-
-       /* Step 6 - Output value */
+            delta |= 1;
+            vpdiff += step;
+        }
+
+        /* Step 3 - Update previous value */
+        if ( sign )
+            valpred -= vpdiff;
+        else
+            valpred += vpdiff;
+
+        /* Step 4 - Clamp previous value to 16 bits */
+        if ( valpred > 32767 )
+            valpred = 32767;
+        else if ( valpred < -32768 )
+            valpred = -32768;
+
+        /* Step 5 - Assemble value, update index and step values */
+        delta |= sign;
+
+        index += indexTable[delta];
+        if ( index < 0 ) index = 0;
+        if ( index > 88 ) index = 88;
+        step = stepsizeTable[index];
+
+        /* Step 6 - Output value */
         if ( bufferstep )
         {
-           outputbuffer = (delta << 4) & 0xf0;
+            outputbuffer = (delta << 4) & 0xf0;
         }
         else
         {
-           *outp++ = (delta & 0x0f) | outputbuffer;
-       }
-       bufferstep = !bufferstep;
+            *outp++ = (delta & 0x0f) | outputbuffer;
+        }
+        bufferstep = !bufferstep;
     }
 
     /* Output last step, if needed */
     if ( !bufferstep )
-      *outp++ = outputbuffer;
-    
+        *outp++ = outputbuffer;
+
     state->valprev = valpred;
     state->index = index;
 }
 
 void decode(struct CodecState* state, u8* input, int numSamples, s16* output)
 {
-    u8 *inp;           /* Input buffer pointer */
-    s16 *outp;         /* output buffer pointer */
-    int sign;                  /* Current adpcm sign bit */
-    int delta;                 /* Current adpcm output value */
-    int step;                  /* Stepsize */
-    int valpred;               /* Predicted value */
-    int vpdiff;                        /* Current change to valpred */
-    int index;                 /* Current step change index */
-    int inputbuffer;           /* place to keep next 4-bit value */
-    int bufferstep;            /* toggle between inputbuffer/input */
+    u8 *inp;        /* Input buffer pointer */
+    s16 *outp;      /* output buffer pointer */
+    int sign;           /* Current adpcm sign bit */
+    int delta;          /* Current adpcm output value */
+    int step;           /* Stepsize */
+    int valpred;        /* Predicted value */
+    int vpdiff;         /* Current change to valpred */
+    int index;          /* Current step change index */
+    int inputbuffer;        /* place to keep next 4-bit value */
+    int bufferstep;     /* toggle between inputbuffer/input */
 
     outp = output;
     inp = input;
@@ -147,57 +147,57 @@ void decode(struct CodecState* state, u8* input, int numSamples, s16* output)
     step = stepsizeTable[index];
 
     bufferstep = 0;
-    
+
     for ( ; numSamples > 0 ; numSamples-- )
     {
-       
-       /* Step 1 - get the delta value */
+
+        /* Step 1 - get the delta value */
         if ( bufferstep )
         {
-           delta = inputbuffer & 0xf;
+            delta = inputbuffer & 0xf;
         }
         else
         {
-           inputbuffer = *inp++;
-           delta = (inputbuffer >> 4) & 0xf;
-       }
-       bufferstep = !bufferstep;
-
-       /* Step 2 - Find new index value (for later) */
-       index += indexTable[delta];
-       if ( index < 0 ) index = 0;
-       if ( index > 88 ) index = 88;
-
-       /* Step 3 - Separate sign and magnitude */
-       sign = delta & 8;
-       delta = delta & 7;
-
-       /* Step 4 - Compute difference and new predicted value */
-       /*
-       ** Computes 'vpdiff = (delta+0.5)*step/4', but see comment
-       ** in adpcm_coder.
-       */
-       vpdiff = step >> 3;
-       if ( delta & 4 ) vpdiff += step;
-       if ( delta & 2 ) vpdiff += step>>1;
-       if ( delta & 1 ) vpdiff += step>>2;
-
-       if ( sign )
-         valpred -= vpdiff;
-       else
-         valpred += vpdiff;
-
-       /* Step 5 - clamp output value */
-       if ( valpred > 32767 )
-         valpred = 32767;
-       else if ( valpred < -32768 )
-         valpred = -32768;
-
-       /* Step 6 - Update step value */
-       step = stepsizeTable[index];
-
-       /* Step 7 - Output value */
-       *outp++ = valpred;
+            inputbuffer = *inp++;
+            delta = (inputbuffer >> 4) & 0xf;
+        }
+        bufferstep = !bufferstep;
+
+        /* Step 2 - Find new index value (for later) */
+        index += indexTable[delta];
+        if ( index < 0 ) index = 0;
+        if ( index > 88 ) index = 88;
+
+        /* Step 3 - Separate sign and magnitude */
+        sign = delta & 8;
+        delta = delta & 7;
+
+        /* Step 4 - Compute difference and new predicted value */
+        /*
+        ** Computes 'vpdiff = (delta+0.5)*step/4', but see comment
+        ** in adpcm_coder.
+        */
+        vpdiff = step >> 3;
+        if ( delta & 4 ) vpdiff += step;
+        if ( delta & 2 ) vpdiff += step>>1;
+        if ( delta & 1 ) vpdiff += step>>2;
+
+        if ( sign )
+            valpred -= vpdiff;
+        else
+            valpred += vpdiff;
+
+        /* Step 5 - clamp output value */
+        if ( valpred > 32767 )
+            valpred = 32767;
+        else if ( valpred < -32768 )
+            valpred = -32768;
+
+        /* Step 6 - Update step value */
+        step = stepsizeTable[index];
+
+        /* Step 7 - Output value */
+        *outp++ = valpred;
     }
 
     state->valprev = valpred;
index 4327258..81b48a3 100644 (file)
 #include <stdint.h>
 #include <string.h>
 
+
+/// Used memory block delimiter structure (size must be word multiple)
+struct mblock_used
+{
+    /// Used to check if memory block has been corrupted or not
+    uint16_t corrupt_check;
+    /// Size of the current used block (including delimiter)
+    uint16_t size;
+};
+
 #if 0
 
 /*********************************************************************
@@ -93,7 +103,6 @@ void *ke_malloc(uint32_t size, uint8_t type);
 void ke_free(void *mem_ptr);
 uint16_t ke_get_mem_free(uint8_t type);
 
-
 /*********************************************************************
  * @fn      os_malloc
  *
@@ -181,10 +190,23 @@ __STATIC __INLINE void *os_calloc(uint32_t num,uint32_t size)
  */
 __STATIC __INLINE void *os_realloc(void *ptr,uint32_t new_size)
 {
-    void *new_ptr =  ke_malloc(new_size, 3);
+    void *new_ptr =  ke_malloc(new_size, 2);
+    struct mblock_used *hdr = (void *)ptr;
+    uint16_t old_buf_size;
+    
     if(new_ptr)
     {
-        memset(new_ptr, 0, new_size);
+        if(ptr) {
+            hdr--;
+            old_buf_size = hdr->size - sizeof(struct mblock_used);
+        
+            if(old_buf_size > new_size) {
+                memcpy(new_ptr, ptr, new_size);
+            }
+            else {
+                memcpy(new_ptr, ptr, old_buf_size);
+            }
+        }
     }
     os_free(ptr);
     return new_ptr;
index 92dc249..d55f41b 100644 (file)
 
 __STATIC __INLINE void show_reg(uint8_t *data,uint32_t len,uint8_t dbg_on)
 {
-    uint8_t i=0;
+    uint32_t i=0;
     if(len == 0 || (dbg_on==0)) return;
-       co_printf(" MAC: ");
-       //for(; i<len; i++)
-    for(i=len-1; i!=0xff; i--)
+    for(; i<len; i++)
     {
-       // co_printf(" 0x%02X ",data[i]);
-                       co_printf("%02X",data[i]);
+        co_printf("0x%02X,",data[i]);
     }
     co_printf("\r\n");
 }
@@ -51,8 +48,22 @@ void co_delay_100us(uint32_t num);
 /*
  * num should not be greater than 8_000_000
  */
+ /*********************************************************************
+ * @fn      system_get_spare_exmem
+ *
+ * @brief   Gets exmem unused regional base address and length.
+ * 
+ * @param   base:   return exmem unused regional base address.
+ *          length: return exmem unused regional length.
+ */
+void system_get_spare_exmem(uint32_t *base, uint32_t *length);
+
 void co_delay_10us(uint32_t num);
 void cpu_delay_100us(uint32_t num);
+float Smoothing_Filter_handle(uint8_t filter_id,float input);
+void Smoothing_Filter_reset(uint8_t filter_id);
+void Smoothing_Filter_destroy(uint8_t filter_id);
+void Smoothing_Filter_init(uint8_t * filter_id);
 uint8_t hex4bit_to_char(const uint8_t hex_value);
 uint8_t hex4bit_to_caps_char(const uint8_t hex_value);
 
index d4cb9e9..823c775 100644 (file)
         <yPos>-1</yPos>
       </MaxPosition>
       <NormalPosition>
-        <Top>213</Top>
-        <Left>226</Left>
-        <Right>1725</Right>
-        <Bottom>1069</Bottom>
+        <Top>184</Top>
+        <Left>-117</Left>
+        <Right>1382</Right>
+        <Bottom>1098</Bottom>
       </NormalPosition>
     </WindowPosition>
     <MDIClientArea>
       <RegID>0</RegID>
       <MDITabState>
-        <Len>1313</Len>
-        <Data>0100000004000000010000000100000001000000010000000000000002000000000000000100000001000000000000002800000028000000010000000B000000030000000100000042473A5C312E776F726B5C332E4153525C332E5A355C312E646F635C4B31385C424C455F57617463685C6B65696C5C5643393230325C7663393230325F757365722E63000000000D7663393230325F757365722E6300000000BECEA100FFFFFFFF5F473A5C312E776F726B5C332E4153525C332E5A355C312E646F635C4B31385C424C455F57617463685C6B65696C5C534C5F57617463685F5065646F5F4B63616C5F57726973745F536C6565705F537761795F4C5F416C676F726974686D2E680000000031534C5F57617463685F5065646F5F4B63616C5F57726973745F536C6565705F537761795F4C5F416C676F726974686D2E6800000000C5D4F200FFFFFFFF3C473A5C312E776F726B5C332E4153525C332E5A355C312E646F635C4B31385C424C455F57617463685C636F64655C73656E736F725F64726976652E68000000000E73656E736F725F64726976652E6800000000BECEA100FFFFFFFF3C473A5C312E776F726B5C332E4153525C332E5A355C312E646F635C4B31385C424C455F57617463685C636F64655C73656E736F725F64726976652E63000000000E73656E736F725F64726976652E6300000000C5D4F200FFFFFFFF42473A5C312E776F726B5C332E4153525C332E5A355C312E646F635C4B31385C424C455F57617463685C636F64655C626C655F73696D706C655F63656E7472616C2E630000000014626C655F73696D706C655F63656E7472616C2E6300000000F7B88600FFFFFFFF47473A5C312E776F726B5C332E4153525C332E5A355C312E646F635C4B31385C424C455F57617463685C636F6D706F6E656E74735C6472697665725C6472697665725F706D752E63000000000C6472697665725F706D752E63000000009CC1B600FFFFFFFF39473A5C312E776F726B5C332E4153525C332E5A355C312E646F635C4B31385C424C455F57617463685C636F64655C70726F6A5F6D61696E2E63000000000B70726F6A5F6D61696E2E6300000000BCA8E100FFFFFFFF49473A5C312E776F726B5C332E4153525C332E5A355C312E646F635C4B31385C424C455F57617463685C636F6D706F6E656E74735C6D6F64756C65735C70617463685C70617463682E63000000000770617463682E6300000000F0A0A100FFFFFFFF4D473A5C312E776F726B5C332E4153525C332E5A355C312E646F635C4B31385C424C455F57617463685C6B65696C5C5643393230325C7663393230325F6472697665725F746573746D6F64652E6300000000187663393230325F6472697665725F746573746D6F64652E6300000000FFDC7800FFFFFFFF42473A5C312E776F726B5C332E4153525C332E5A355C312E646F635C4B31385C424C455F57617463685C636F64655C626C655F73696D706C655F63656E7472616C2E680000000014626C655F73696D706C655F63656E7472616C2E6800000000C5D4F200FFFFFFFF39473A5C312E776F726B5C332E4153525C332E5A355C312E646F635C4B31385C424C455F57617463685C6B65696C5C626C655F355F302E736374000000000B626C655F355F302E73637400000000D9ADC200FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD5000100000000000000020000007E02000043010000B50600000B030000</Data>
+        <Len>348</Len>
+        <Data>01000000040000000100000001000000010000000100000000000000020000000000000001000000010000000000000028000000280000000100000002000000000000000100000039473A5C312E776F726B5C332E4153525C332E5A355C312E646F635C4B31385C424C455F57617463685C636F64655C70726F6A5F6D61696E2E63000000000B70726F6A5F6D61696E2E6300000000F6FA7D00FFFFFFFF3B473A5C312E776F726B5C332E4153525C332E5A355C312E646F635C4B31385C424C455F57617463685C6B65696C5C496D69746174655F4949432E63000000000D496D69746174655F4949432E6300000000FFDC7800FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD50001000000000000000200000027010000260100005E05000028030000</Data>
       </MDITabState>
     </MDIClientArea>
     <ViewEx>
         </RectRecentDocked>
         <RectRecentFloat>
           <Len>16</Len>
-          <Data>AD01000087000000A905000015010000</Data>
+          <Data>FE010000F5000000FA05000083010000</Data>
         </RectRecentFloat>
       </Window>
       <Window>
         <RecentRowIndex>0</RecentRowIndex>
         <RectRecentDocked>
           <Len>16</Len>
-          <Data>00000000630000009001000017020000</Data>
+          <Data>00000000630000009001000051020000</Data>
         </RectRecentDocked>
         <RectRecentFloat>
           <Len>16</Len>
         <RecentRowIndex>0</RecentRowIndex>
         <RectRecentDocked>
           <Len>16</Len>
-          <Data>0300000032020000C805000005030000</Data>
+          <Data>030000006C020000C80500003F030000</Data>
         </RectRecentDocked>
         <RectRecentFloat>
           <Len>16</Len>
         <RecentRowIndex>0</RecentRowIndex>
         <RectRecentDocked>
           <Len>16</Len>
-          <Data>0300000032020000C805000005030000</Data>
+          <Data>030000006C020000C80500003F030000</Data>
         </RectRecentDocked>
         <RectRecentFloat>
           <Len>16</Len>
         <RecentRowIndex>0</RecentRowIndex>
         <RectRecentDocked>
           <Len>16</Len>
-          <Data>0300000032020000C805000005030000</Data>
+          <Data>030000006C020000C80500003F030000</Data>
         </RectRecentDocked>
         <RectRecentFloat>
           <Len>16</Len>
         <RecentRowIndex>0</RecentRowIndex>
         <RectRecentDocked>
           <Len>16</Len>
-          <Data>0300000032020000C805000005030000</Data>
+          <Data>030000006C020000C80500003F030000</Data>
         </RectRecentDocked>
         <RectRecentFloat>
           <Len>16</Len>
         <RecentRowIndex>0</RecentRowIndex>
         <RectRecentDocked>
           <Len>16</Len>
-          <Data>000000001E030000CB05000031030000</Data>
+          <Data>0000000058030000CB0500006B030000</Data>
         </RectRecentDocked>
         <RectRecentFloat>
           <Len>16</Len>
       </Window>
       <DockMan>
         <Len>2619</Len>
-        <Data>000000000B000000000000000020000000000000FFFFFFFFFFFFFFFF94010000DD00000090050000E1000000000000000100000004000000010000000000000000000000FFFFFFFF06000000CB00000057010000CC000000F08B00005A01000079070000FFFF02000B004354616262656450616E650020000000000000AD01000087000000A905000015010000940100004F00000090050000DD0000000000000040280046060000000B446973617373656D626C7900000000CB00000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A6572000000005701000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A657200000000CC00000001000000FFFFFFFFFFFFFFFF0E4C6F67696320416E616C797A657200000000F08B000001000000FFFFFFFFFFFFFFFF0D436F646520436F766572616765000000005A01000001000000FFFFFFFFFFFFFFFF11496E737472756374696F6E205472616365000000007907000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFCB00000001000000FFFFFFFFCB000000000000000040000000000000FFFFFFFFFFFFFFFFFC0300004F0000000004000025020000000000000200000004000000010000000000000000000000FFFFFFFF17000000E2050000CA0900002D8C00002E8C00002F8C0000308C0000318C0000328C0000338C0000348C0000358C0000368C0000378C0000388C0000398C00003A8C00003B8C00003C8C00003D8C00003E8C00003F8C0000408C0000418C0000018000400000000000001904000087000000A90500005D020000000400004F00000090050000250200000000000040410046170000000753796D626F6C7300000000E205000001000000FFFFFFFFFFFFFFFF0A5472616365204461746100000000CA09000001000000FFFFFFFFFFFFFFFF00000000002D8C000001000000FFFFFFFFFFFFFFFF00000000002E8C000001000000FFFFFFFFFFFFFFFF00000000002F8C000001000000FFFFFFFFFFFFFFFF0000000000308C000001000000FFFFFFFFFFFFFFFF0000000000318C000001000000FFFFFFFFFFFFFFFF0000000000328C000001000000FFFFFFFFFFFFFFFF0000000000338C000001000000FFFFFFFFFFFFFFFF0000000000348C000001000000FFFFFFFFFFFFFFFF0000000000358C000001000000FFFFFFFFFFFFFFFF0000000000368C000001000000FFFFFFFFFFFFFFFF0000000000378C000001000000FFFFFFFFFFFFFFFF0000000000388C000001000000FFFFFFFFFFFFFFFF0000000000398C000001000000FFFFFFFFFFFFFFFF00000000003A8C000001000000FFFFFFFFFFFFFFFF00000000003B8C000001000000FFFFFFFFFFFFFFFF00000000003C8C000001000000FFFFFFFFFFFFFFFF00000000003D8C000001000000FFFFFFFFFFFFFFFF00000000003E8C000001000000FFFFFFFFFFFFFFFF00000000003F8C000001000000FFFFFFFFFFFFFFFF0000000000408C000001000000FFFFFFFFFFFFFFFF0000000000418C000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFE205000001000000FFFFFFFFE2050000000000000010000001000000FFFFFFFFFFFFFFFF900100004F0000009401000017020000010000000200001004000000010000000000000000000000FFFFFFFF05000000ED0300006D000000C3000000C400000073940000018000100000010000001900000087000000A901000089020000000000004F00000090010000170200000000000040410056050000000750726F6A65637401000000ED03000001000000FFFFFFFFFFFFFFFF05426F6F6B73000000006D00000001000000FFFFFFFFFFFFFFFF0946756E6374696F6E7300000000C300000001000000FFFFFFFFFFFFFFFF0954656D706C6174657300000000C400000001000000FFFFFFFFFFFFFFFF09526567697374657273000000007394000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFED03000001000000FFFFFFFFED030000000000000080000000000000FFFFFFFFFFFFFFFF0000000011020000900500001502000000000000010000000400000001000000000000000000000000000000000000000000000001000000C6000000FFFFFFFF0E0000008F070000930700009407000095070000960700009007000091070000B5010000B8010000B9050000BA050000BB050000BC050000CB09000001800080000000000000190000004D020000A9050000EF020000000000001502000090050000B702000000000000404100460E0000001343616C6C20537461636B202B204C6F63616C73000000008F07000001000000FFFFFFFFFFFFFFFF0755415254202331000000009307000001000000FFFFFFFFFFFFFFFF0755415254202332000000009407000001000000FFFFFFFFFFFFFFFF0755415254202333000000009507000001000000FFFFFFFFFFFFFFFF15446562756720287072696E74662920566965776572000000009607000001000000FFFFFFFFFFFFFFFF0757617463682031000000009007000001000000FFFFFFFFFFFFFFFF0757617463682032000000009107000001000000FFFFFFFFFFFFFFFF10547261636520457863657074696F6E7300000000B501000001000000FFFFFFFFFFFFFFFF0E4576656E7420436F756E7465727300000000B801000001000000FFFFFFFFFFFFFFFF084D656D6F7279203100000000B905000001000000FFFFFFFFFFFFFFFF084D656D6F7279203200000000BA05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203300000000BB05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203400000000BC05000001000000FFFFFFFFFFFFFFFF105472616365204E617669676174696F6E00000000CB09000001000000FFFFFFFFFFFFFFFFFFFFFFFF0000000001000000000000000000000001000000FFFFFFFFC802000015020000CC020000B702000000000000020000000400000000000000000000000000000000000000000000000000000002000000C6000000FFFFFFFF8F07000001000000FFFFFFFF8F07000001000000C6000000000000000080000001000000FFFFFFFFFFFFFFFF0000000017020000CB0500001B0200000100000001000010040000000100000061FEFFFF25010000FFFFFFFF04000000C5000000C7000000B40100007794000001800080000001000000190000008D020000E405000090030000000000001B020000CB0500001E0300000000000040820056040000000C4275696C64204F757470757401000000C500000001000000FFFFFFFFFFFFFFFF0D46696E6420496E2046696C657301000000C700000001000000FFFFFFFFFFFFFFFF0A4572726F72204C69737400000000B401000001000000FFFFFFFFFFFFFFFF0742726F77736572000000007794000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFC500000001000000FFFFFFFFC5000000000000000000000000000000</Data>
+        <Data>000000000B000000000000000020000000000000FFFFFFFFFFFFFFFF94010000DD00000090050000E1000000000000000100000004000000010000000000000000000000FFFFFFFF06000000CB00000057010000CC000000F08B00005A01000079070000FFFF02000B004354616262656450616E650020000000000000FE010000F5000000FA05000083010000940100004F00000090050000DD0000000000000040280046060000000B446973617373656D626C7900000000CB00000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A6572000000005701000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A657200000000CC00000001000000FFFFFFFFFFFFFFFF0E4C6F67696320416E616C797A657200000000F08B000001000000FFFFFFFFFFFFFFFF0D436F646520436F766572616765000000005A01000001000000FFFFFFFFFFFFFFFF11496E737472756374696F6E205472616365000000007907000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFCB00000001000000FFFFFFFFCB000000000000000040000000000000FFFFFFFFFFFFFFFFFC0300004F0000000004000025020000000000000200000004000000010000000000000000000000FFFFFFFF17000000E2050000CA0900002D8C00002E8C00002F8C0000308C0000318C0000328C0000338C0000348C0000358C0000368C0000378C0000388C0000398C00003A8C00003B8C00003C8C00003D8C00003E8C00003F8C0000408C0000418C0000018000400000000000006A040000F5000000FA050000CB020000000400004F00000090050000250200000000000040410046170000000753796D626F6C7300000000E205000001000000FFFFFFFFFFFFFFFF0A5472616365204461746100000000CA09000001000000FFFFFFFFFFFFFFFF00000000002D8C000001000000FFFFFFFFFFFFFFFF00000000002E8C000001000000FFFFFFFFFFFFFFFF00000000002F8C000001000000FFFFFFFFFFFFFFFF0000000000308C000001000000FFFFFFFFFFFFFFFF0000000000318C000001000000FFFFFFFFFFFFFFFF0000000000328C000001000000FFFFFFFFFFFFFFFF0000000000338C000001000000FFFFFFFFFFFFFFFF0000000000348C000001000000FFFFFFFFFFFFFFFF0000000000358C000001000000FFFFFFFFFFFFFFFF0000000000368C000001000000FFFFFFFFFFFFFFFF0000000000378C000001000000FFFFFFFFFFFFFFFF0000000000388C000001000000FFFFFFFFFFFFFFFF0000000000398C000001000000FFFFFFFFFFFFFFFF00000000003A8C000001000000FFFFFFFFFFFFFFFF00000000003B8C000001000000FFFFFFFFFFFFFFFF00000000003C8C000001000000FFFFFFFFFFFFFFFF00000000003D8C000001000000FFFFFFFFFFFFFFFF00000000003E8C000001000000FFFFFFFFFFFFFFFF00000000003F8C000001000000FFFFFFFFFFFFFFFF0000000000408C000001000000FFFFFFFFFFFFFFFF0000000000418C000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFE205000001000000FFFFFFFFE2050000000000000010000001000000FFFFFFFFFFFFFFFF900100004F0000009401000051020000010000000200001004000000010000000000000000000000FFFFFFFF05000000ED0300006D000000C3000000C400000073940000018000100000010000006A000000F5000000FA010000F7020000000000004F00000090010000510200000000000040410056050000000750726F6A65637401000000ED03000001000000FFFFFFFFFFFFFFFF05426F6F6B73000000006D00000001000000FFFFFFFFFFFFFFFF0946756E6374696F6E7300000000C300000001000000FFFFFFFFFFFFFFFF0954656D706C6174657300000000C400000001000000FFFFFFFFFFFFFFFF09526567697374657273000000007394000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFED03000001000000FFFFFFFFED030000000000000080000000000000FFFFFFFFFFFFFFFF0000000011020000900500001502000000000000010000000400000001000000000000000000000000000000000000000000000001000000C6000000FFFFFFFF0E0000008F070000930700009407000095070000960700009007000091070000B5010000B8010000B9050000BA050000BB050000BC050000CB090000018000800000000000006A000000BB020000FA0500005D030000000000001502000090050000B702000000000000404100460E0000001343616C6C20537461636B202B204C6F63616C73000000008F07000001000000FFFFFFFFFFFFFFFF0755415254202331000000009307000001000000FFFFFFFFFFFFFFFF0755415254202332000000009407000001000000FFFFFFFFFFFFFFFF0755415254202333000000009507000001000000FFFFFFFFFFFFFFFF15446562756720287072696E74662920566965776572000000009607000001000000FFFFFFFFFFFFFFFF0757617463682031000000009007000001000000FFFFFFFFFFFFFFFF0757617463682032000000009107000001000000FFFFFFFFFFFFFFFF10547261636520457863657074696F6E7300000000B501000001000000FFFFFFFFFFFFFFFF0E4576656E7420436F756E7465727300000000B801000001000000FFFFFFFFFFFFFFFF084D656D6F7279203100000000B905000001000000FFFFFFFFFFFFFFFF084D656D6F7279203200000000BA05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203300000000BB05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203400000000BC05000001000000FFFFFFFFFFFFFFFF105472616365204E617669676174696F6E00000000CB09000001000000FFFFFFFFFFFFFFFFFFFFFFFF0000000001000000000000000000000001000000FFFFFFFFC802000015020000CC020000B702000000000000020000000400000000000000000000000000000000000000000000000000000002000000C6000000FFFFFFFF8F07000001000000FFFFFFFF8F07000001000000C6000000000000000080000001000000FFFFFFFFFFFFFFFF0000000051020000CB050000550200000100000001000010040000000100000061FEFFFF25010000FFFFFFFF04000000C5000000C7000000B401000077940000018000800000010000006A000000FB02000035060000FE0300000000000055020000CB050000580300000000000040820056040000000C4275696C64204F757470757401000000C500000001000000FFFFFFFFFFFFFFFF0D46696E6420496E2046696C657301000000C700000001000000FFFFFFFFFFFFFFFF0A4572726F72204C69737400000000B401000001000000FFFFFFFFFFFFFFFF0742726F77736572000000007794000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFC500000001000000FFFFFFFFC5000000000000000000000000000000</Data>
       </DockMan>
       <ToolBar>
         <RegID>59392</RegID>
         <Name>File</Name>
         <Buttons>
-          <Len>2181</Len>
-          <Data>00200000010000002800FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000000000000000000000000000000000000000100000001000000018001E100000000000001000000000000000000000000000000000100000001000000018003E1000000000000020000000000000000000000000000000001000000010000000180CD7F0000000000000300000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018023E100000000040004000000000000000000000000000000000100000001000000018022E100000000040005000000000000000000000000000000000100000001000000018025E10000000000000600000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001802BE10000000004000700000000000000000000000000000000010000000100000001802CE10000000004000800000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001807A8A0000000000000900000000000000000000000000000000010000000100000001807B8A0000000004000A00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180D3B00000000000000B000000000000000000000000000000000100000001000000018015B10000000000000C0000000000000000000000000000000001000000010000000180F4B00000000000000D000000000000000000000000000000000100000001000000018036B10000000000000E00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FF88000000000400460000000000000000000000000000000001000000010000000180FE880000000004004500000000000000000000000000000000010000000100000001800B810000000004001300000000000000000000000000000000010000000100000001800C810000000004001400000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180F0880000020000000F000000000000000000000000000000000100000001000000FFFF0100120043555646696E64436F6D626F427574746F6EE803000000000000000000000000000000000000000000000001000000010000009600000002002050000000000D6F735F74696D65725F696E69749600000000000000080018706D755F706F72745F77616B6575705F66756E635F73657404626F6F6C0D464C4153485F50524F54454354156761705F73746172745F6164766572746973696E6718737065616B65725F676174745F6164645F736572766963650D6F735F74696D65725F696E69740D706D755F6973725F72616D5F430E7379735F74696D65725F696E69740000000000000000000000000000000000000000000000000000000000000000018024E10000000000001100000000000000000000000000000000010000000100000001800A810000000000001200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018022800000020000001500000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C488000000000000160000000000000000000000000000000001000000010000000180C988000000000400180000000000000000000000000000000001000000010000000180C788000000000000190000000000000000000000000000000001000000010000000180C8880000000000001700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6E4C010000020001001A0000000F50726F6A6563742057696E646F7773000000000000000000000000010000000100000000000000000000000100000008002880DD880000000000001A0000000750726F6A656374000000000000000000000000010000000100000000000000000000000100000000002880DC8B0000000000003A00000005426F6F6B73000000000000000000000000010000000100000000000000000000000100000000002880E18B0000000000003B0000000946756E6374696F6E73000000000000000000000000010000000100000000000000000000000100000000002880E28B000000000000400000000954656D706C6174657300000000000000000000000001000000010000000000000000000000010000000000288018890000000000003D0000000E536F757263652042726F777365720000000000000000000000000100000001000000000000000000000001000000000028800000000000000400FFFFFFFF00000000000000000001000000000000000100000000000000000000000100000000002880D988000000000000390000000C4275696C64204F7574707574000000000000000000000000010000000100000000000000000000000100000000002880E38B000000000000410000000B46696E64204F75747075740000000000000000000000000100000001000000000000000000000001000000000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FB7F0000000000001B000000000000000000000000000000000100000001000000000000000446696C65AC030000</Data>
+          <Len>2432</Len>
+          <Data>00200000010000002800FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000000000000000000000000000000000000000100000001000000018001E100000000000001000000000000000000000000000000000100000001000000018003E1000000000000020000000000000000000000000000000001000000010000000180CD7F0000000000000300000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018023E100000000040004000000000000000000000000000000000100000001000000018022E100000000040005000000000000000000000000000000000100000001000000018025E10000000000000600000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001802BE10000000004000700000000000000000000000000000000010000000100000001802CE10000000004000800000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001807A8A0000000000000900000000000000000000000000000000010000000100000001807B8A0000000004000A00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180D3B00000000000000B000000000000000000000000000000000100000001000000018015B10000000000000C0000000000000000000000000000000001000000010000000180F4B00000000000000D000000000000000000000000000000000100000001000000018036B10000000000000E00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FF88000000000400460000000000000000000000000000000001000000010000000180FE880000000004004500000000000000000000000000000000010000000100000001800B810000000004001300000000000000000000000000000000010000000100000001800C810000000004001400000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180F0880000020000000F000000000000000000000000000000000100000001000000FFFF0100120043555646696E64436F6D626F427574746F6EE8030000000000000000000000000000000000000000000000010000000100000096000000020020500000000018737065616B65725F676174745F6164645F736572766963659600000000000000140018737065616B65725F676174745F6164645F736572766963650D6F735F74696D65725F696E69740D706D755F6973725F72616D5F430E7379735F74696D65725F696E69740B636F6E6669675F666C616717534C5F5343374132305F4932635F5370695F5772697465117472616E73706172656E745F73746172740D6170705F61745F726563765F630D75617274305F6973725F72616D0A756172745F706172616D0D75617274315F6973725F72616D15766353706F72744D6F74696F6E416C676F496E69741273656E645F6872735F646174615F666C61670D554152545F73656E645F62756616766353706F72744D6F74696F6E43616C63756C61746509636F5F7072696E74660D7274635F6765745F76616C7565087265616C5F73706F1964656275675F73656E645F74696D65725F63616C6C6261636B0D7663393230325F636F6D6D6F6E0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018024E10000000000001100000000000000000000000000000000010000000100000001800A810000000000001200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018022800000020000001500000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C488000000000000160000000000000000000000000000000001000000010000000180C988000000000400180000000000000000000000000000000001000000010000000180C788000000000000190000000000000000000000000000000001000000010000000180C8880000000000001700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6E4C010000020001001A0000000F50726F6A6563742057696E646F7773000000000000000000000000010000000100000000000000000000000100000008002880DD880000000000001A0000000750726F6A656374000000000000000000000000010000000100000000000000000000000100000000002880DC8B0000000000003A00000005426F6F6B73000000000000000000000000010000000100000000000000000000000100000000002880E18B0000000000003B0000000946756E6374696F6E73000000000000000000000000010000000100000000000000000000000100000000002880E28B000000000000400000000954656D706C6174657300000000000000000000000001000000010000000000000000000000010000000000288018890000000000003D0000000E536F757263652042726F777365720000000000000000000000000100000001000000000000000000000001000000000028800000000000000400FFFFFFFF00000000000000000001000000000000000100000000000000000000000100000000002880D988000000000000390000000C4275696C64204F7574707574000000000000000000000000010000000100000000000000000000000100000000002880E38B000000000000410000000B46696E64204F75747075740000000000000000000000000100000001000000000000000000000001000000000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FB7F0000000000001B000000000000000000000000000000000100000001000000000000000446696C65AC030000</Data>
         </Buttons>
         <OriginalItems>
           <Len>1423</Len>
     <ActiveMDIGroup>0</ActiveMDIGroup>
     <MDIGroup>
       <Size>100</Size>
-      <ActiveTab>3</ActiveTab>
-      <Doc>
-        <Name>.\VC9202\vc9202_user.c</Name>
-        <ColumnNumber>0</ColumnNumber>
-        <TopLine>344</TopLine>
-        <CurrentLine>345</CurrentLine>
-        <Folding>1</Folding>
-        <ContractedFolders></ContractedFolders>
-        <PaneID>0</PaneID>
-      </Doc>
-      <Doc>
-        <Name>SL_Watch_Pedo_Kcal_Wrist_Sleep_Sway_L_Algorithm.h</Name>
-        <ColumnNumber>0</ColumnNumber>
-        <TopLine>64</TopLine>
-        <CurrentLine>78</CurrentLine>
-        <Folding>1</Folding>
-        <ContractedFolders></ContractedFolders>
-        <PaneID>0</PaneID>
-      </Doc>
-      <Doc>
-        <Name>..\code\sensor_drive.h</Name>
-        <ColumnNumber>0</ColumnNumber>
-        <TopLine>14</TopLine>
-        <CurrentLine>36</CurrentLine>
-        <Folding>1</Folding>
-        <ContractedFolders></ContractedFolders>
-        <PaneID>0</PaneID>
-      </Doc>
-      <Doc>
-        <Name>..\code\sensor_drive.c</Name>
-        <ColumnNumber>46</ColumnNumber>
-        <TopLine>768</TopLine>
-        <CurrentLine>790</CurrentLine>
-        <Folding>1</Folding>
-        <ContractedFolders></ContractedFolders>
-        <PaneID>0</PaneID>
-      </Doc>
-      <Doc>
-        <Name>..\code\ble_simple_central.c</Name>
-        <ColumnNumber>17</ColumnNumber>
-        <TopLine>287</TopLine>
-        <CurrentLine>294</CurrentLine>
-        <Folding>1</Folding>
-        <ContractedFolders></ContractedFolders>
-        <PaneID>0</PaneID>
-      </Doc>
-      <Doc>
-        <Name>..\components\driver\driver_pmu.c</Name>
-        <ColumnNumber>53</ColumnNumber>
-        <TopLine>910</TopLine>
-        <CurrentLine>936</CurrentLine>
-        <Folding>1</Folding>
-        <ContractedFolders></ContractedFolders>
-        <PaneID>0</PaneID>
-      </Doc>
+      <ActiveTab>0</ActiveTab>
       <Doc>
         <Name>..\code\proj_main.c</Name>
-        <ColumnNumber>11</ColumnNumber>
-        <TopLine>260</TopLine>
-        <CurrentLine>261</CurrentLine>
-        <Folding>1</Folding>
-        <ContractedFolders></ContractedFolders>
-        <PaneID>0</PaneID>
-      </Doc>
-      <Doc>
-        <Name>..\components\modules\patch\patch.c</Name>
-        <ColumnNumber>0</ColumnNumber>
-        <TopLine>274</TopLine>
-        <CurrentLine>286</CurrentLine>
-        <Folding>1</Folding>
-        <ContractedFolders></ContractedFolders>
-        <PaneID>0</PaneID>
-      </Doc>
-      <Doc>
-        <Name>.\VC9202\vc9202_driver_testmode.c</Name>
-        <ColumnNumber>28</ColumnNumber>
-        <TopLine>20</TopLine>
-        <CurrentLine>45</CurrentLine>
-        <Folding>1</Folding>
-        <ContractedFolders></ContractedFolders>
-        <PaneID>0</PaneID>
-      </Doc>
-      <Doc>
-        <Name>..\code\ble_simple_central.h</Name>
-        <ColumnNumber>28</ColumnNumber>
-        <TopLine>48</TopLine>
-        <CurrentLine>60</CurrentLine>
+        <ColumnNumber>36</ColumnNumber>
+        <TopLine>216</TopLine>
+        <CurrentLine>237</CurrentLine>
         <Folding>1</Folding>
         <ContractedFolders></ContractedFolders>
         <PaneID>0</PaneID>
       </Doc>
       <Doc>
-        <Name>G:\1.work\3.ASR\3.Z5\1.doc\K18\BLE_Watch\keil\ble_5_0.sct</Name>
-        <ColumnNumber>0</ColumnNumber>
-        <TopLine>13</TopLine>
-        <CurrentLine>36</CurrentLine>
+        <Name>.\Imitate_IIC.c</Name>
+        <ColumnNumber>32</ColumnNumber>
+        <TopLine>569</TopLine>
+        <CurrentLine>583</CurrentLine>
         <Folding>1</Folding>
         <ContractedFolders></ContractedFolders>
         <PaneID>0</PaneID>
index 3326781..a2494e6 100644 (file)
@@ -10,7 +10,7 @@
  
 #ifdef IO_I2C_TEST
      
-#define I2C_SCL_PIN_0          6   //ζȺÍGSESOR 
+#define I2C_SCL_PIN_0          6   //温度和GSESOR 
 #define I2C_SCL_DIR_OUT_0      (*(volatile uint32_t *)(GPIO_PORTA_DIR) &= ~(1<<I2C_SCL_PIN_0)) // gpio_set_dir((I2C_SCL_PIN/8),(I2C_SCL_PIN%8),0)
 #define I2C_SCL_DIR_IN_0       (*(volatile uint32_t *)(GPIO_PORTA_DIR) |= (1<<I2C_SCL_PIN_0))
 #define I2C_SCL_OUT_H_0        (*(volatile uint32_t *)(GPIO_PORTA_DATA) |= (1<<I2C_SCL_PIN_0))
@@ -18,7 +18,7 @@
 #define I2C_SCL_IN_VAL_0       (*(volatile uint32_t *)(GPIO_PORTA_DATA) & (1<<I2C_SCL_PIN_0))
 
      
-#define I2C_SDA_PIN_0          7      //ζȺÍGSESOR    
+#define I2C_SDA_PIN_0          7      //温度和GSESOR    
 #define I2C_SDA_DIR_OUT_0      (*(volatile uint32_t *)(GPIO_PORTA_DIR) &= ~(1<<I2C_SDA_PIN_0)) // gpio_set_dir((I2C_SCL_PIN/8),(I2C_SCL_PIN%8),0)
 #define I2C_SDA_DIR_IN_0       (*(volatile uint32_t *)(GPIO_PORTA_DIR) |= (1<<I2C_SDA_PIN_0))
 #define I2C_SDA_OUT_H_0        (*(volatile uint32_t *)(GPIO_PORTA_DATA) |= (1<<I2C_SDA_PIN_0))
 #define I2C_SDA_IN_VAL_0       (*(volatile uint32_t *)(GPIO_PORTA_DATA) & (1<<I2C_SDA_PIN_0))
  
 
-#define I2C_SCL_PIN_1          4  //ÐÄÂʺÍѪѹ     
+#define I2C_SCL_PIN_1          4  //心率和血压     
 #define I2C_SCL_DIR_OUT_1      (*(volatile uint32_t *)(GPIO_PORTA_DIR) &= ~(1<<I2C_SCL_PIN_1)) // gpio_set_dir((I2C_SCL_PIN/8),(I2C_SCL_PIN%8),0)
 #define I2C_SCL_DIR_IN_1       (*(volatile uint32_t *)(GPIO_PORTA_DIR) |= (1<<I2C_SCL_PIN_1))
 #define I2C_SCL_OUT_H_1        (*(volatile uint32_t *)(GPIO_PORTA_DATA) |= (1<<I2C_SCL_PIN_1))
 #define I2C_SCL_OUT_L_1        (*(volatile uint32_t *)(GPIO_PORTA_DATA) &= ~(1<<I2C_SCL_PIN_1))
 #define I2C_SCL_IN_VAL_1       (*(volatile uint32_t *)(GPIO_PORTA_DATA) & (1<<I2C_SCL_PIN_1))
 
- #define I2C_SDA_PIN_1         5   //ÐÄÂʺÍѪѹ 
+ #define I2C_SDA_PIN_1         5   //心率和血压 
 #define I2C_SDA_DIR_OUT_1      (*(volatile uint32_t *)(GPIO_PORTA_DIR) &= ~(1<<I2C_SDA_PIN_1)) // gpio_set_dir((I2C_SCL_PIN/8),(I2C_SCL_PIN%8),0)
 #define I2C_SDA_DIR_IN_1       (*(volatile uint32_t *)(GPIO_PORTA_DIR) |= (1<<I2C_SDA_PIN_1))
 #define I2C_SDA_OUT_H_1        (*(volatile uint32_t *)(GPIO_PORTA_DATA) |= (1<<I2C_SDA_PIN_1))
@@ -580,13 +580,14 @@ void user_i2c0_init(void)
                
 }
 uint8_t bp_data[49];
-//·µ»Ø1ΪÕý³£Êý¾Ý£¬·µ»Ø0ÎªÖØ¸´Êý¾Ý£¬Ð趪Æú
+uint8_t bp_data_reuse_count = 0;
+//返回1为正常数据,返回0为重复数据,需丢弃
 uint8_t read_BP_data(void)
 {      
        uint8_t bp_data_tmp[49] = {0};
        IIC1_Start_I2c();
-       IIC1_Write_One_Byte(0x0B);//дÈëÒª¶ÁµÄÆ÷¼þµØÖ·
-       if(!IIC1_Read_Ack())//¶ÁÓ¦´ðλ
+       IIC1_Write_One_Byte(0x0B);//写入要读的器件地址
+       if(!IIC1_Read_Ack())//读应答位
        {
                co_printf("No ack\r\n");
                IIC1_Stop_I2c(); 
@@ -604,11 +605,17 @@ uint8_t read_BP_data(void)
                else     
                        IIC1_Send_Ack();
        }       
-       if(memcmp(bp_data_tmp,bp_data) == 0)//ÖØ¸´Êý¾Ý²»Òª
-       {
-               return 0;
-       }else
-       {
+       // 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
+       // {
                memcpy(bp_data,bp_data_tmp,sizeof(bp_data));
                #if 1
                co_printf("BP_DATA : ");        
@@ -619,7 +626,7 @@ uint8_t read_BP_data(void)
                co_printf("\n");        
                #endif
                return 1;
-       }
+       //}
        
 }
 
index 9d155fe..31cabcc 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/ble_simple_central.crf and b/1.doc/K18/BLE_Watch/keil/Objects/ble_simple_central.crf differ
index 244c32f..c96d3d0 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/core_cm3_isr.crf and b/1.doc/K18/BLE_Watch/keil/Objects/core_cm3_isr.crf differ
index bfe0331..d8419ba 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/driver_iic.crf and b/1.doc/K18/BLE_Watch/keil/Objects/driver_iic.crf differ
index ebfbe07..d73c7b0 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/driver_keyscan.crf and b/1.doc/K18/BLE_Watch/keil/Objects/driver_keyscan.crf differ
index 4515623..089098a 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/driver_pmu.crf and b/1.doc/K18/BLE_Watch/keil/Objects/driver_pmu.crf differ
index b6ceac9..9695c48 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/driver_pmu_qdec.crf and b/1.doc/K18/BLE_Watch/keil/Objects/driver_pmu_qdec.crf differ
index 527882d..6a11d2b 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/driver_rtc.crf and b/1.doc/K18/BLE_Watch/keil/Objects/driver_rtc.crf differ
index ab52a9c..535e440 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/driver_wdt.crf and b/1.doc/K18/BLE_Watch/keil/Objects/driver_wdt.crf differ
index 54ad382..2637c68 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/imitate_iic.crf and b/1.doc/K18/BLE_Watch/keil/Objects/imitate_iic.crf differ
index 6b24ae3..2352b98 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/ota.crf and b/1.doc/K18/BLE_Watch/keil/Objects/ota.crf differ
index 60149d1..9da809f 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/ota_service.crf and b/1.doc/K18/BLE_Watch/keil/Objects/ota_service.crf differ
index 2806b16..4dec33e 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/patch.crf and b/1.doc/K18/BLE_Watch/keil/Objects/patch.crf differ
index af96217..f425133 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/proj_main.crf and b/1.doc/K18/BLE_Watch/keil/Objects/proj_main.crf differ
index 68bdb3e..01367cd 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/sensor_drive.crf and b/1.doc/K18/BLE_Watch/keil/Objects/sensor_drive.crf differ
index 5ce2351..cbcc567 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/simple_gatt_service.crf and b/1.doc/K18/BLE_Watch/keil/Objects/simple_gatt_service.crf differ
index a3a918d..f060d0a 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/sl_watch_pedo_kcal_wrist_sleep_sway_l_application.crf and b/1.doc/K18/BLE_Watch/keil/Objects/sl_watch_pedo_kcal_wrist_sleep_sway_l_application.crf differ
index c31de48..4b89be1 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/uart.crf and b/1.doc/K18/BLE_Watch/keil/Objects/uart.crf differ
index 476cd0a..3bd1293 100644 (file)
Binary files a/1.doc/K18/BLE_Watch/keil/Objects/vc9202_user.crf and b/1.doc/K18/BLE_Watch/keil/Objects/vc9202_user.crf differ
index 045df36..7e1d193 100644 (file)
@@ -708,7 +708,8 @@ void vc9202_usr_interrupt_handler( AlgoSportMode hr_alg_mode, unsigned char spo2
                ppg_size = sizeof(gsensor_data.gsensor_x_axis)/sizeof(int);
                co_printf("ppg_size be adjusted to %d!! \n",ppg_size);
        }
-       co_printf("  interrupt ppg_size:%d!! \n",ppg_size);
+       if(ppg_size)
+               co_printf("  interrupt ppg_size:%d!! \n",ppg_size);
        switch ( work_mode )
        {
                case WORK_MODE_HR:
index 69e8f2b..e477d7f 100644 (file)
@@ -1,4 +1,4 @@
-;#<FEEDBACK># ARM Linker, 5050106: Last Updated: Sat Feb 03 10:38:15 2024
+;#<FEEDBACK># ARM Linker, 5050106: Last Updated: Mon Feb 05 11:15:21 2024
 ;VERSION 0.2
 ;FILE acpower_add_doublefre.o
 acPower_add_doublefre_init <= USED 0
@@ -199,6 +199,7 @@ __asm___7_flash_c_48468d59____RRX <= USED 0
 flash_OTP_erase <= USED 0
 flash_OTP_protect <= USED 0
 flash_OTP_write <= USED 0
+flash_page_erase <= USED 0
 flash_protect_enable1 <= USED 0
 flash_read_id <= USED 0
 ;FILE freq_production.o
@@ -841,7 +842,6 @@ os_task_create <= USED 0
 os_task_create_x <= USED 0
 os_task_delete <= USED 0
 os_task_process_saved_msg <= USED 0
-os_user_loop_event_clear <= USED 0
 ;FILE os_timer.o
 ;FILE ota.o
 __asm___5_ota_c_56ada2da____REV16 <= USED 0
@@ -899,14 +899,14 @@ prf_register_atthdl2gatt <= USED 0
 prf_unpack_date_time <= USED 0
 prf_unregister_atthdl2gatt <= USED 0
 ;FILE proj_main.o
-__asm___11_proj_main_c_571a19f4____REV16 <= USED 0
-__asm___11_proj_main_c_571a19f4____REVSH <= USED 0
-__asm___11_proj_main_c_571a19f4____RRX <= USED 0
+__asm___11_proj_main_c_30fea291____REV16 <= USED 0
+__asm___11_proj_main_c_30fea291____REVSH <= USED 0
+__asm___11_proj_main_c_30fea291____RRX <= USED 0
 ;FILE rwble_hl.o
 ;FILE sensor_drive.o
-__asm___14_sensor_drive_c_dd6d544e____REV16 <= USED 0
-__asm___14_sensor_drive_c_dd6d544e____REVSH <= USED 0
-__asm___14_sensor_drive_c_dd6d544e____RRX <= 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
 ;FILE sha256.o
 sha256_final <= USED 0
 sha256_gatt_gen_auth_value <= USED 0
@@ -1005,6 +1005,13 @@ ble_bond_clr_all_info <= USED 0
 ble_bond_clr_info <= USED 0
 ble_bond_get_bond_info <= USED 0
 ble_bond_get_last_bond_idx <= USED 0
+;FILE user_mem.o
+ke_free_user <= USED 0
+ke_get_mem_max_usage <= USED 0
+ke_malloc_user <= USED 0
+show_ke_malloc <= USED 0
+show_mem_list <= USED 0
+show_msg_list <= USED 0
 ;FILE vc9202_driver.o
 vc9202_drv_electrostatic_death <= USED 0
 vc9202_drv_get_chip_id <= USED 0
index 5b259f7..3b1ea63 100644 (file)
@@ -12,7 +12,8 @@ char send_gs_data_flag= 0;//gsensor数据标致位
 char send_sleep_data_flag= 0;//sleep数据标致位
 char send_step_data_flag= 0;//step数据标致位
 char send_wear_data_flag= 0;//wear数据标致位
-uint8_t uart0_rivce_data[UART_READ_MAX];
+uint8_t *uart0_rivce_data = NULL;
+//uint8_t uart0_rivce_data[UART_READ_MAX] ;
 int uart0_data_len =0;
 unsigned int timestamp_d = 0; //秒的时间戳,需要配合RTC使用
 unsigned int get_timestamp(void)//获取时间戳
@@ -23,7 +24,8 @@ unsigned int get_timestamp(void)//获取时间戳
 
 
 extern char is_HA_activate ;
-unsigned char UART_send_buf[UART_SEND_MAX] = {0};
+unsigned char *UART_send_buf;
+//unsigned char UART_send_buf[UART_SEND_MAX];
 int UART_send_buf_len = 0;
 //                                             /*************************************************************
 //                                             *       函数名称: crc8
@@ -99,7 +101,7 @@ __attribute__((section("ram_code"))) void uart0_isr_ram(void)
                        
                        //co_printf("-%c",uart0_rivce_data[uart0_data_len]);
                        uart0_data_len++;
-                       if(uart0_data_len >= sizeof(uart0_rivce_data))
+                       if(uart0_data_len >= UART_READ_MAX)
                                uart0_data_len = 0;
            // app_at_recv_c(uart_reg_ram->u1.data);
         }
@@ -314,7 +316,7 @@ void uart0_receive(void)
                }
        }
         
-       for(int i=0;i<sizeof(uart0_rivce_data);i++){
+       for(int i=0;i<UART_READ_MAX;i++){
                //if(uart0_rivce_data[i]!=0)co_printf("uart0_rivce_data[%d]= %c  \n",i,uart0_rivce_data[i]);
                uart0_rivce_data[i]=0;
        } //清接收