Files
@ 55d6f1467ce4
Branch filter:
Location: windsonde/Source/main.c - annotation
55d6f1467ce4
2.4 KiB
text/plain
Add friendly mode and associated timeout
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 104 105 106 107 108 109 110 111 112 113 | 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 02d3447dac18 0f04af7169be 0f04af7169be 0f04af7169be f2c57ce0cd7b f2c57ce0cd7b f2c57ce0cd7b f2c57ce0cd7b f2c57ce0cd7b f2c57ce0cd7b 02d3447dac18 02d3447dac18 0f04af7169be 0f04af7169be 0f04af7169be 7ff1c5a59571 67d1f9d02048 02d3447dac18 0f04af7169be 0f04af7169be 0f04af7169be 7ff1c5a59571 0f04af7169be 0f04af7169be 0f04af7169be 0f04af7169be 0f04af7169be 0f04af7169be 67d1f9d02048 0f04af7169be 0f04af7169be 041562172b4a 7ff1c5a59571 f2c57ce0cd7b f2c57ce0cd7b f2c57ce0cd7b f2c57ce0cd7b f2c57ce0cd7b f2c57ce0cd7b f2c57ce0cd7b 0f04af7169be 0592d2a3ee8b 0f04af7169be 0f04af7169be 55d6f1467ce4 55d6f1467ce4 55d6f1467ce4 0f04af7169be 0f04af7169be 55d6f1467ce4 55d6f1467ce4 55d6f1467ce4 55d6f1467ce4 55d6f1467ce4 55d6f1467ce4 55d6f1467ce4 55d6f1467ce4 55d6f1467ce4 55d6f1467ce4 0f04af7169be 0592d2a3ee8b f2c57ce0cd7b f2c57ce0cd7b f2c57ce0cd7b f2c57ce0cd7b f2c57ce0cd7b f2c57ce0cd7b f2c57ce0cd7b c52174ca9326 0f04af7169be 0f04af7169be 0592d2a3ee8b 0592d2a3ee8b 0592d2a3ee8b 55d6f1467ce4 0592d2a3ee8b 0592d2a3ee8b 0592d2a3ee8b 0f04af7169be 0f04af7169be 0f04af7169be 0f04af7169be 0f04af7169be 0f04af7169be 0f04af7169be 2ee6c8e67f32 0f04af7169be 0f04af7169be 0f04af7169be 2ee6c8e67f32 2ee6c8e67f32 | /*
* 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"
#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
|