Added void Task_mesure(void *parameters)

This commit is contained in:
AlexeiBazlaev 2021-01-05 10:18:47 +07:00
parent f5441b6257
commit f7613b61f7
6 changed files with 53 additions and 10 deletions

Binary file not shown.

View File

@ -9,7 +9,7 @@
#ifndef NTC_H_
#define NTC_H_
#include <asf.h>
#include "adc_user.h"
// ADC value to R
float NTC_MCU_value2R(uint16_t value);

View File

@ -41,6 +41,7 @@
#include <string.h>
//#include <stdlib.h>
#include "realsence.h"
#include "ntc.h"
#define PORT_STDIO 0
#define PORT_DATA 1
@ -48,10 +49,10 @@
//char rcvBuff[128] = {0};
char str[128] = {0};
UBaseType_t uxHighWaterMark_cdc_rx_check;
UBaseType_t uxHighWaterMark_led_blink;
UBaseType_t uxHighWaterMark_led_blink, uxHighWaterMark_mesure;
static volatile bool main_b_cdc_enable = false;
struct measured_params m_params;
Controller_t Controller;
/*! \brief Main function. Execution starts here.
*/
@ -75,7 +76,7 @@ int main(void)
InitTask_cdc_rx_check();
// Init LED
InitTask_led_blink();//ui_init();//ui_powerdown();
InitTask_mesure();
vTaskStartScheduler();
while(true){
__BKPT();
@ -171,13 +172,33 @@ void Task_led_blink(void *parameters)
}
}
void Task_mesure(void *parameters)
{
uxHighWaterMark_mesure = uxTaskGetStackHighWaterMark( NULL );
for (;;)
{
Controller.temps.MCU_Temp = NTC_MCU_get_temp();
if (main_b_cdc_enable && udi_cdc_multi_is_tx_ready(PORT0))
printf(">%f\n\r", Controller.temps.MCU_Temp);
LED_Toggle(LED_PIN);
uxHighWaterMark_mesure = uxTaskGetStackHighWaterMark( NULL );
vTaskDelay(1000);
}
}
void InitTask_led_blink(void)
{
led_configure_port_pins();
LED_Off(LED_PIN);
xTaskCreate(Task_led_blink, (const char*)"Task_led_blink", configMINIMAL_STACK_SIZE*2, NULL,configMAX_PRIORITIES-1, NULL);
//xTaskCreate(Task_led_blink, (const char*)"Task_led_blink", configMINIMAL_STACK_SIZE*2, NULL,configMAX_PRIORITIES-1, NULL);
}
void InitTask_mesure(void)
{
configure_adc();
xTaskCreate(Task_mesure, (const char*)"Task_mesure", configMINIMAL_STACK_SIZE*2, NULL,configMAX_PRIORITIES-1, NULL);
}
void main_suspend_action(void)

View File

@ -39,7 +39,8 @@
#include "usb_protocol_cdc.h"
struct measured_params{
typedef struct measured_params{
float TEC_Temp;
float MCU_Temp;
float Vin_LFB;
@ -49,15 +50,34 @@ struct measured_params{
float DHT22_Hum;
float DS1820_Temp;
float TEC_Power;
};
}measured_params_t;
typedef struct
{
float TEC_Temp;
float MCU_Temp;
float DHT22_Temp;
float DS1820_Temp;
}Temperatures_t;
typedef struct
{
Temperatures_t temps;
} Controller_t;
void prvGetRegistersFromStack (uint32_t *pulFaultStackAddress);
void led_configure_port_pins(void);
void vApplicationMallocFailedHook (void);
void vApplicationStackOverflowHook (void);
void Task_cdc_rx_check(void *parameters);
void Task_led_blink(void *parameters);
void Task_mesure(void *parameters);
void Task_regulator(void *parameters);
void InitTask_cdc_rx_check(void);
void InitTask_led_blink(void);
void InitTask_regulator(void);
void InitTask_mesure(void);
/*! \brief Opens the communication port
* This is called by CDC interface when USB Host enable it.
*

View File

@ -42,14 +42,16 @@ uint16_t adc_read_value_spec(ADC_chan_t chan)
return adc_read_value();
}
float adc_get_Q(uint16_t value){
float adc_get_Q(uint16_t value)
{
float gane_factor=0.5;
float vref_k=1.0/1.48;
float ADC_range = 4096.0;
return (value*vref_k)/(gane_factor*ADC_range);
}
float adc_get_V(uint16_t value){
float adc_get_V(uint16_t value)
{
float Uvcc=3.3;
return adc_get_Q(value) * Uvcc;
}

View File

@ -6,7 +6,7 @@
*/
#include "ntc.h"
#include <arm_math.h>
#include "adc_user.h"
#define MCU_CONTROL
// ADC value to R