Files @ df3cd2f9bf90
Branch filter:

Location: HydroBot/protomodule-firmware/Src/main.c

matthewreed
Started to add support for sgp30
#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;
}