/*
* FeatherHAB
*
* This file is part of FeatherHAB.
*
* FeatherHab is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FeatherHab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with FeatherHAB. If not, see <http://www.gnu.org/licenses/>.
*
* Ethan Zonca
*
*/
#include "stm32f0xx_hal.h"
#include "config.h"
#include "error.h"
//#include "pressure.h"
#include "bme280.h"
#include "gps.h"
#include "system/gpio.h"
#include "system/sysclk.h"
#include "system/watchdog.h"
#include "system/uart.h"
#include "system/adc.h"
#include "si446x/si446x.h"
#include "aprs/aprs.h"
#include "aprs/afsk.h"
int main(void)
{
hal_init();
sysclock_init();
gpio_init();
adc_init();
afsk_init();
si446x_init();
si446x_init();
gps_poweron();
// pressure_init();
bme280_init();
// Software timers
uint32_t last_transmission = HAL_GetTick();
uint32_t last_led = HAL_GetTick();
while (1)
{
// Blink LEDs
if(HAL_GetTick() - last_transmission > 700)
{
gps_update_data(); // Will always return at 1hz rate (default measurement rate)
//pressure_read();
bme280_update();
while(afsk_busy()); // ensure previous message finished
aprs_send();
last_transmission = HAL_GetTick();
}
if(HAL_GetTick() - last_led > 100)
{
HAL_GPIO_TogglePin(LED_POWER);
last_led = HAL_GetTick();
}
if(afsk_request_cwoff())
si446x_cw_off();
// High-frequency function calls
watchdog_feed();
}
}
// vim:softtabstop=4 shiftwidth=4 expandtab