1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- /*
- * Copyright (c) 2020 Jinan Bosai Network Technology Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- #include <stdio.h>
- #include <string.h>
- #include <unistd.h>
- // #include "max30102.h"
- #include "algorithm.h"
- #include "cmsis_os2.h"
- #include "ohos_init.h"
- #include "blood.h"
- #define TASK_STACK_SIZE 1024 * 8
- #define TASK_PRIO 25
- uint32_t aun_ir_buffer[500]; //IR LED sensor data
- int32_t n_ir_buffer_length; //data length
- uint32_t aun_red_buffer[500]; //Red LED sensor data
- int32_t n_sp02; //SPO2 value
- int8_t ch_spo2_valid; //indicator to show if the SP02 calculation is valid
- int32_t n_heart_rate; //heart rate value
- int8_t ch_hr_valid; //indicator to show if the heart rate calculation is valid
- uint8_t uch_dummy;
- #define MAX_BRIGHTNESS 255
- static void ExampleTask(void)
- {
- //variables to calculate the on-board LED brightness that reflects the heartbeats
- uint32_t un_min, un_max, un_prev_data;
- int i;
- int32_t n_brightness;
- float f_temp;
- uint8_t temp_num=0;
- uint8_t temp[6]={0,0,0,0,0,0};
- uint8_t str[100];
- uint8_t dis_hr=0,dis_spo2=0;
- BoardInit();
- maxim_max30102_init();
- printf("\r\n MAX30102 init \r\n");
- for(i = 0;i < 128;i++)
- {
- while(GetInit()==0)
- {
- max30102_read_fifo();
- }
- }
- while(1)
- {
- // deal_Temp();
- blood_Loop();
- }
- }
- static void ExampleEntry(void)
- {
- osThreadAttr_t attr;
- attr.name = "ExampleTask";
- attr.attr_bits = 0U;
- attr.cb_mem = NULL;
- attr.cb_size = 0U;
- attr.stack_mem = NULL;
- attr.stack_size = TASK_STACK_SIZE;
- attr.priority = TASK_PRIO;
- if (osThreadNew((osThreadFunc_t)ExampleTask, NULL, &attr) == NULL) {
- printf("Failed to create ExampleTask!\n");
- }
- }
- APP_FEATURE_INIT(ExampleEntry);
|