Commit 62a444d7 authored by Ilias Daradimos's avatar Ilias Daradimos

Merge branch 'TIMPrescalers' into 'master'

adc

See merge request !10
parents 9078f444 e4cf96c3
Pipeline #58476070 passed with stage
in 1 minute and 28 seconds
......@@ -12,7 +12,7 @@ SourceFiles=../Src/main.c;../Src/freertos.c;../Src/stm32l4xx_it.c;../Src/stm32l4
HeaderPath=../Drivers/STM32L4xx_HAL_Driver/Inc;../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy;../Middlewares/Third_Party/FreeRTOS/Source/portable/IAR/ARM_CM4F;../Drivers/CMSIS/Device/ST/STM32L4xx/Include;../Middlewares/Third_Party/FreeRTOS/Source/include;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS;../Drivers/CMSIS/Include;../Inc;
[PreviousUsedSW4STM32Files]
SourceFiles=../Src/main.c;../Src/freertos.c;../Src/stm32l4xx_it.c;../Src/stm32l4xx_hal_msp.c;../Src/stm32l4xx_hal_timebase_TIM.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_can.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c;../Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c;../Middlewares/Third_Party/FreeRTOS/Source/croutine.c;../Middlewares/Third_Party/FreeRTOS/Source/timers.c;../Middlewares/Third_Party/FreeRTOS/Source/tasks.c;../Middlewares/Third_Party/FreeRTOS/Source/list.c;../Middlewares/Third_Party/FreeRTOS/Source/queue.c;../Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c;..//Src/system_stm32l4xx.c;../Drivers/CMSIS/Device/ST/STM32L4xx/Source/Templates/system_stm32l4xx.c;null;../Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c;../Middlewares/Third_Party/FreeRTOS/Source/croutine.c;../Middlewares/Third_Party/FreeRTOS/Source/timers.c;../Middlewares/Third_Party/FreeRTOS/Source/tasks.c;../Middlewares/Third_Party/FreeRTOS/Source/list.c;../Middlewares/Third_Party/FreeRTOS/Source/queue.c;../Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c;
SourceFiles=../Src/main.c;../Src/freertos.c;../Src/stm32l4xx_it.c;../Src/stm32l4xx_hal_msp.c;../Src/stm32l4xx_hal_timebase_TIM.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_can.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c;../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c;../Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c;../Middlewares/Third_Party/FreeRTOS/Source/croutine.c;../Middlewares/Third_Party/FreeRTOS/Source/timers.c;../Middlewares/Third_Party/FreeRTOS/Source/tasks.c;../Middlewares/Third_Party/FreeRTOS/Source/list.c;../Middlewares/Third_Party/FreeRTOS/Source/queue.c;../Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c;..//Src/system_stm32l4xx.c;../Drivers/CMSIS/Device/ST/STM32L4xx/Source/Templates/system_stm32l4xx.c;/home/drid/Devel/LSF/PQWS/pqws-atmo-sw//startup/startup_stm32l432xx.s;../Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c;../Middlewares/Third_Party/FreeRTOS/Source/croutine.c;../Middlewares/Third_Party/FreeRTOS/Source/timers.c;../Middlewares/Third_Party/FreeRTOS/Source/tasks.c;../Middlewares/Third_Party/FreeRTOS/Source/list.c;../Middlewares/Third_Party/FreeRTOS/Source/queue.c;../Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c;
HeaderPath=../Drivers/STM32L4xx_HAL_Driver/Inc;../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy;../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F;../Drivers/CMSIS/Device/ST/STM32L4xx/Include;../Middlewares/Third_Party/FreeRTOS/Source/include;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS;../Drivers/CMSIS/Include;../Inc;
CDefines=__weak:"__attribute__((weak))";__packed:"__attribute__((__packed__))";
......@@ -34,9 +34,9 @@
#define MQ_7_HI_PWM 2000
#define MQ_7_LOW_PWM 100
#define SENSOR_CO_CALC 0.05034709
#define SENSOR_O3_CALC 0.05034709
#define SENSOR_MICS_CALC 0.05034709
#define SENSOR_CO_CALC 0.805664063
#define SENSOR_O3_CALC 0.805664063
#define SENSOR_MICS_CALC 0.805664063
typedef struct {
uint16_t min;
......@@ -46,7 +46,7 @@ typedef struct {
} pq_atmo_measurement_t;
typedef enum {
POWER_OFF,
POWER_OFF=0,
POWER_LOW,
POWER_HIGH,
POWER_ON
......
......@@ -12,8 +12,8 @@
<targetDefinitions>
<board id="nucleo-l432kc">
<name>NUCLEO-L432KC</name>
<dbgIF>JTAG</dbgIF>
<dbgIF>SWD</dbgIF>
<dbgIF>JTAG</dbgIF>
<dbgDEV>ST-Link</dbgDEV>
<mcuId>stm32l432kcux</mcuId>
</board>
......
......@@ -730,23 +730,24 @@ void StartBMETask(void const * argument)
data.min = bme_data.pressure / 1000;
data.max = bme_data.pressure / 1000;
xQueueSend(CANTxQueueHandle, &data, 1000);
// // testing package TX
// //TODO: move to separate task once measurement sequence is decided
data.sensor_type = PQ_ATMO_MQ7;
data.average = sensor_read_CO(&hadc1);;
data.min = 1;
data.max = 2;
xQueueSend(CANTxQueueHandle, &data, 1000);
//TODO: move to separate task once measurement sequence is decided
// MQ131
data.sensor_type = PQ_ATMO_MQ131;
data.average = sensor_read_O3(&hadc1);;
data.min = 4;
data.max = 6;
data.average = sensor_read_O3(&hadc1);
data.min = data.average;
data.max = data.average;
xQueueSend(CANTxQueueHandle, &data, 1000);
//MQ7
data.sensor_type = PQ_ATMO_MQ7;
data.average = sensor_read_CO(&hadc1);
data.min = data.average;
data.max = data.average;
xQueueSend(CANTxQueueHandle, &data, 1000);
sensor_read_MICS(&hadc1);
//MICS
data.sensor_type = PQ_ATMO_MICS;
data.average = sensor_read_MICS(&hadc1);;
data.min = 7;
data.max = 9;
data.average = sensor_read_MICS(&hadc1);
data.min = data.average;
data.max = data.average;
xQueueSend(CANTxQueueHandle, &data, 1000);
}
}
......@@ -773,8 +774,6 @@ void StartCANSendData(void const * argument)
/* USER CODE BEGIN StartCANSendData */
pq_atmo_measurement_t data;
CAN_TxHeaderTypeDef TxHeader;
uint8_t TxData[8];
uint32_t TxMailbox;
/* Infinite loop */
for (;;) {
if (xQueueReceive(CANTxQueueHandle, &data, osWaitForever)) {
......@@ -785,10 +784,10 @@ void StartCANSendData(void const * argument)
TxHeader.IDE = CAN_ID_STD;
TxHeader.DLC = sizeof(data)-2;
TxHeader.TransmitGlobalTime = DISABLE;
while (HAL_CAN_IsTxMessagePending(&hcan1, TxMailbox));
while (HAL_CAN_IsTxMessagePending(&hcan1, TxMailbox)) {}
if (HAL_CAN_AddTxMessage(&hcan1, &TxHeader, TxData, &TxMailbox)
!= HAL_OK) {
//TODO: Handle error of single device on bus
// //TODO: Handle error of single device on bus
Error_Handler();
}
}
......
......@@ -252,7 +252,6 @@ uint16_t sensor_read_CO(ADC_HandleTypeDef *adc) {
uint16_t value;
//TODO: Sensor activate sequence
value = sensor_get_raw(adc, ADC_CHANNEL_MQ_7);
sensor_MQ7_power(POWER_OFF);
//TODO: convert to PPM
return value * SENSOR_CO_CALC;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment