/* * 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 . * * Ethan Zonca * */ #include "stm32f0xx_hal.h" #include "config.h" #include "error.h" #ifdef LPS25H #include "lps25h.h" #else #include "bme280.h" #endif #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(); #ifdef LPS25H lps25h_init(); #else bme280_init(); #endif // Software timers uint32_t last_transmission = HAL_GetTick(); uint32_t last_led = HAL_GetTick(); uint32_t transmission_rate = 700; uint32_t is_friendly = 0; while (1) { #ifdef FRIENDLY_MODE if(!is_friendly && HAL_GetTick() > 1000 * FRIENDLY_TIMEOUT) { transmission_rate = FRIENDLY_TX_RATE; is_friendly = 1; } #endif // Transmit RF packet if(HAL_GetTick() - last_transmission > transmission_rate) { gps_update_data(); // Will always return at 1hz rate (default measurement rate) #ifdef LPS25H lps25h_read(); #else bme280_update(); #endif while(afsk_busy()); // ensure previous message finished aprs_send(); last_transmission = HAL_GetTick(); } // Blink LEDs 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