Added mcu_control
This commit is contained in:
parent
79f64d47ab
commit
a2cd4a6f5e
Binary file not shown.
|
|
@ -353,7 +353,7 @@
|
|||
</dependencies>
|
||||
<project id="common.services.usb.class.cdc.device.example.samd21_xpro" value="Add" config="" content-id="Atmel.ASF" />
|
||||
<board id="board.samd21_xplained_pro" value="Add" config="" content-id="Atmel.ASF" />
|
||||
</framework-data>
|
||||
</framework-data>
|
||||
</AsfFrameworkConfig>
|
||||
<avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
|
||||
<avrtoolserialnumber>J41800067100</avrtoolserialnumber>
|
||||
|
|
@ -1760,6 +1760,9 @@
|
|||
<Compile Include="src\include\light_ws2812_cortex.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\include\mcu_control.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\include\ntc.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
|
|
@ -1802,6 +1805,9 @@
|
|||
<Compile Include="src\source\light_ws2812_cortex.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\source\mcu_control.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\source\ntc.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* mcu_control.h
|
||||
*
|
||||
* Created: 12.01.2021 23:17:47
|
||||
* Author: Lexus
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MCU_CONTROL_H_
|
||||
#define MCU_CONTROL_H_
|
||||
|
||||
#define MAX_STR_FLOAT 12
|
||||
|
||||
void MCU_control_init(void);
|
||||
void MCU_control(void);
|
||||
|
||||
#endif /* MCU_CONTROL_H_ */
|
||||
|
|
@ -186,7 +186,7 @@ void Task_measure(void *parameters)
|
|||
if(fpclassify(Controller.temps.MCU_Temp) == FP_NAN)
|
||||
printf(">NTC_MCU_TEMP = NAN\n\r");
|
||||
else
|
||||
printf(">NTC_MCU_TEMP = %d, NTC_TEC_TEMP = %d\n\r", (int)Controller.temps.MCU_Temp, (int)Controller.temps.TEC_Temp);
|
||||
printf(">NTC_MCU_TEMP = %d\n\r", (int)Controller.temps.MCU_Temp);//printf(">NTC_MCU_TEMP = %d, NTC_TEC_TEMP = %d\n\r", (int)Controller.temps.MCU_Temp, (int)Controller.temps.TEC_Temp);
|
||||
}
|
||||
LED_Toggle(LED_PIN);
|
||||
uxHighWaterMark_mesure = uxTaskGetStackHighWaterMark( NULL );
|
||||
|
|
|
|||
|
|
@ -58,11 +58,17 @@ typedef struct
|
|||
float MCU_Temp;
|
||||
float DHT22_Temp;
|
||||
float DS1820_Temp;
|
||||
}Temperatures_t;
|
||||
} Temperatures_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float tecV;
|
||||
float tecI;
|
||||
} TecState_t;
|
||||
typedef struct
|
||||
{
|
||||
Temperatures_t temps;
|
||||
TecState_t tecState;
|
||||
} Controller_t;
|
||||
|
||||
void prvGetRegistersFromStack (uint32_t *pulFaultStackAddress);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* mcu_control.c
|
||||
*
|
||||
* Created: 12.01.2021 23:17:16
|
||||
* Author: Lexus
|
||||
*/
|
||||
#include "mcu_control.h"
|
||||
#include <asf.h>
|
||||
#include "ntc.h"
|
||||
#include "dht.h"
|
||||
#include "adn8831.h"
|
||||
#include "tm_onewire.h"
|
||||
#include "tm_ds18b20.h"
|
||||
|
||||
void MCU_control_init(void){
|
||||
|
||||
}
|
||||
|
||||
void MCU_control(void){
|
||||
char t_TEC_str[MAX_STR_FLOAT];
|
||||
char t_MCU_str[MAX_STR_FLOAT];
|
||||
TM_OneWire_t ow_instance;
|
||||
// MCU temp
|
||||
float t = NTC_MCU_get_temp(NULL);
|
||||
make_float2str(t_MCU_str, MAX_STR_FLOAT, (float)t);
|
||||
|
||||
// TEC temp
|
||||
float t_TEC = NTC_TEC_get_temp(NULL, NULL);
|
||||
make_float2str(t_TEC_str, MAX_STR_FLOAT, (float)t_TEC);
|
||||
|
||||
// voltage LFB, SFB, CS
|
||||
float Vin_LFB, Vin_SFB, Vin_CS;//, Vin_VTEC;
|
||||
Vin_LFB = adc_get_V_spec(chan_LFB);
|
||||
Vin_SFB = adc_get_V_spec(chan_SFB);
|
||||
Vin_CS = adc_get_V_spec(chan_CS);
|
||||
|
||||
char Vin_LFB_str[MAX_STR_FLOAT];
|
||||
char Vin_SFB_str[MAX_STR_FLOAT];
|
||||
char Vin_CS_str[MAX_STR_FLOAT];
|
||||
|
||||
make_float2str(Vin_LFB_str, MAX_STR_FLOAT, (float)Vin_LFB);
|
||||
make_float2str(Vin_SFB_str, MAX_STR_FLOAT, (float)Vin_SFB);
|
||||
make_float2str(Vin_CS_str, MAX_STR_FLOAT, (float)Vin_CS);
|
||||
|
||||
DHT_data d;
|
||||
uint8_t ret = DHT_getData(DHT22, &d);
|
||||
char DHT22_Temp[MAX_STR_FLOAT];
|
||||
char DHT22_Hum[MAX_STR_FLOAT];
|
||||
make_float2str(DHT22_Temp, MAX_STR_FLOAT, (float)d.temp);
|
||||
make_float2str(DHT22_Hum, MAX_STR_FLOAT, (float)d.hum);
|
||||
if(ret){
|
||||
printf("DHT22 error: %d\r\n",(int)ret);
|
||||
}
|
||||
|
||||
// DS1820
|
||||
char DS1820_Temp_str[MAX_STR_FLOAT];
|
||||
//bool ow_connected __attribute__((used)) =false;
|
||||
float DS1820_temp=0.0;
|
||||
cpu_irq_disable();
|
||||
if (TM_OneWire_First(&ow_instance)) {
|
||||
//ow_connected=true;
|
||||
if(TM_DS18B20_Is(ow_instance.ROM_NO)){
|
||||
while(!TM_DS18B20_AllDone(&ow_instance)){};
|
||||
ret = TM_DS18B20_Read(&ow_instance, ow_instance.ROM_NO, &DS1820_temp);
|
||||
if(!ret){
|
||||
printf("TM_DS18B20_Read() - error\r\n");
|
||||
}
|
||||
ret = TM_DS18B20_Start(&ow_instance, ow_instance.ROM_NO);
|
||||
if(!ret){
|
||||
printf("TM_DS18B20_Start() - ROM isn't correct\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
cpu_irq_enable();
|
||||
make_float2str(DS1820_Temp_str, MAX_STR_FLOAT, (float)DS1820_temp);
|
||||
|
||||
// printf("Info: t_MCU: %10s, t_TEC:%10s, Vin_LFB: %6s, Vin_SFB: %6s, Vin_CS: %6s, DHT22_Temp: %s, DHT22_Hum: %s, OW_STATE: %d, DS1820_Temp: %s\r\n",t_MCU_str, t_TEC_str, Vin_LFB_str, Vin_SFB_str, Vin_CS_str, DHT22_Temp, DHT22_Hum, (int)ow_connected, DS1820_Temp_str);
|
||||
// printf("Info: t_MCU: %10s, t_TEC:%10s, RS: %d, DHT22_Temp: %s, DHT22_Hum: %s, OW_STATE: %d, DS1820_Temp: %s\r\n",t_MCU_str, t_TEC_str, (int)rs_power, DHT22_Temp, DHT22_Hum, (int)ow_connected, DS1820_Temp_str);
|
||||
vTaskDelay(2000);//delay_ms(2000);
|
||||
}
|
||||
Loading…
Reference in New Issue