Files
@ df3cd2f9bf90
Branch filter:
Location: HydroBot/protomodule-firmware/Src/main.c
df3cd2f9bf90
2.1 KiB
text/plain
Started to add support for sgp30
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | #include "stm32f0xx_hal.h"
#include "can.h"
#include "gpio.h"
#include "system.h"
#include "led.h"
#include "protocol.h"
#include "i2c.h"
#include "sgp30.h"
int main(void)
{
HAL_Init();
system_init();
gpio_init();
//sgp30_init();
//sgp30_IAQinit();
protocol_init(PROTOMODULE);
led_init();
led_blink(LED_STATUS, 2000);
led_blink_once(LED_CAN, 2000);
led_set(LED_ERROR, 0);
uint32_t loop_timer_1ms = 0;
uint32_t loop_timer_10ms = 0;
uint32_t loop_timer_200ms = 0;
uint32_t loop_timer_1s = 0;
uint32_t loop_timer_2s = 0;
uint32_t loop_timer_data = 0;
while (1)
{
can_receive();
if (HAL_GetTick() - loop_timer_1ms >= 1)
{
can_process_receive_buffer();
led_update_all();
loop_timer_1ms = HAL_GetTick();
}
if (HAL_GetTick() - loop_timer_10ms >= 10)
{
loop_timer_10ms = HAL_GetTick();
}
if (HAL_GetTick() - loop_timer_200ms >= 200)
{
loop_timer_200ms = HAL_GetTick();
}
if (HAL_GetTick() - loop_timer_1s >= 1000)
{
//sgp30_IAQmeasure();
//protocol_send_data(NONE, 0, sgp30_get_tvoc());
loop_timer_1s = HAL_GetTick();
}
if (HAL_GetTick() - loop_timer_2s >= 2000)
{
loop_timer_2s = HAL_GetTick();
}
if (HAL_GetTick() - loop_timer_data >= (protocol_get_settings()->val.data_rate))
{
loop_timer_data = HAL_GetTick();
}
}
}
bool protocol_set_output(protocol_message_t* message)
{
bool result = false;
return result;
}
bool protocol_get_data(protocol_message_t* message)
{
bool result = false;
return result;
}
bool protocol_config(protocol_message_t* message)
{
bool result = false;
protocol_data_key_t data = (protocol_data_key_t)(uint16_t)message->data.float_data;
return result;
}
bool protocol_calibrate(protocol_message_t* message)
{
bool result = false;
return result;
}
|