Files
@ 83633fbb38d0
Branch filter:
Location: seniordesign-firmware/master/master/master.c - annotation
83633fbb38d0
3.7 KiB
text/plain
Changed APRS transmission rate for development
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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | 02b6a488f4ee 02b6a488f4ee 02b6a488f4ee 02b6a488f4ee 02b6a488f4ee 02b6a488f4ee 02b6a488f4ee 02b6a488f4ee 02b6a488f4ee 02b6a488f4ee dc014539e59f dc014539e59f dc014539e59f dc014539e59f dc014539e59f dc014539e59f dc014539e59f dc66341db814 28bdbd881b55 48acfcb35ad3 48acfcb35ad3 dc014539e59f dc014539e59f 11be7f0ce05b 5109fd6856e1 dc014539e59f 0062f8daffe7 dc66341db814 0062f8daffe7 0062f8daffe7 0062f8daffe7 0062f8daffe7 0062f8daffe7 0062f8daffe7 5a775958ef65 48acfcb35ad3 104a7b37e488 261d812b2664 dc014539e59f dc014539e59f dc014539e59f 0e169f68c994 4e5c6467cd01 48acfcb35ad3 28bdbd881b55 0e169f68c994 4e5c6467cd01 48acfcb35ad3 48acfcb35ad3 4e5c6467cd01 261d812b2664 48acfcb35ad3 48acfcb35ad3 48acfcb35ad3 4e5c6467cd01 4e5c6467cd01 0e169f68c994 4e5c6467cd01 4e5c6467cd01 28bdbd881b55 a20e51697fd8 a20e51697fd8 6314aa4c9143 0e169f68c994 6060ac6db4a5 48acfcb35ad3 4e5c6467cd01 4e5c6467cd01 94648aa82312 48acfcb35ad3 70abc5d16090 70abc5d16090 0e169f68c994 70abc5d16090 104a7b37e488 104a7b37e488 104a7b37e488 48acfcb35ad3 fb6b4f86ee7b 48acfcb35ad3 0e169f68c994 0e169f68c994 d62f0f469869 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 0e169f68c994 d62f0f469869 d62f0f469869 94648aa82312 dc014539e59f 0e169f68c994 4e5c6467cd01 0e169f68c994 0e169f68c994 d62f0f469869 d62f0f469869 d62f0f469869 0e169f68c994 0e169f68c994 0e169f68c994 48acfcb35ad3 b6a1b8d502cc b6a1b8d502cc 4e5c6467cd01 0062f8daffe7 d62f0f469869 4e5c6467cd01 4e5c6467cd01 4e5c6467cd01 a20e51697fd8 4e5c6467cd01 4e5c6467cd01 0062f8daffe7 4e5c6467cd01 fb6b4f86ee7b 0e169f68c994 4e5c6467cd01 a20e51697fd8 a20e51697fd8 4e5c6467cd01 4e5c6467cd01 70abc5d16090 70abc5d16090 7c7bd3044e69 0e169f68c994 48acfcb35ad3 b6a1b8d502cc b6a1b8d502cc 70abc5d16090 d62f0f469869 70abc5d16090 0e169f68c994 2e9d4bb3d9c7 48acfcb35ad3 48acfcb35ad3 261d812b2664 4f2720815741 261d812b2664 261d812b2664 261d812b2664 261d812b2664 4f2720815741 4f2720815741 48acfcb35ad3 70abc5d16090 70abc5d16090 5109fd6856e1 0e169f68c994 104a7b37e488 4f2720815741 0062f8daffe7 dc66341db814 dc014539e59f d56808391611 | /*
* Master Firmware
*
* Wireless Observational Modular Aerial Network
*
* Ethan Zonca
* Matthew Kanning
* Kyle Ripperger
* Matthew Kroening
*
*/
#include "config.h"
#include <avr/io.h>
#include <util/delay.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>
#include <stdio.h>
#include <stdbool.h>
#include "lib/serial.h"
#include "lib/aprs.h"
#include "lib/afsk.h"
#include "lib/led.h"
#include "lib/logger.h"
#include "lib/watchdog.h"
#include "lib/trackuinoGPS/gpsMKa.h"
#include "lib/i2c.h"
#include "lib/boardtemp.h"
#include "lib/looptime.h"
#include "lib/slavesensors.h"
#include "lib/serparser.h"
#include "lib/sensordata.h"
int main(void)
{
_delay_ms(1500); // warmup
// Initialize libraries
time_setup();
watchdog_setup(); // enables interrupts
led_setup();
serial0_setup();
serial1_setup();
i2c_init();
sensordata_setup(); // must happen before sensors/logger/afsk
slavesensors_setup();
logger_setup();
afsk_setup();
//\f
serial0_sendString("\r\n---------------------------------\r\n");
serial0_sendString("HAB Controller 1.0 - Initialized!\r\n");
serial0_sendString("---------------------------------\r\n");
serial0_sendString("\r\nHello.\r\n\r\n");
slavesensors_network_scan();
led_on(LED_POWER);
led_off(LED_SIDEBOARD);
// Buffer for string operations
char logbuf[128];
char debugBuf[128];
// Software timers
uint32_t lastAprsBroadcast = 0;
uint32_t lastLog = 0;
uint32_t lastLedCycle = 0;
// Result of last parser run
int parseResult = PARSERESULT_NODATA;
// Write CSV header to SD card
//logger_log("ProgramTime,LastAprsBroadcast,LastLog\n");
uint8_t ctr = 0;
void spin() {
if(ctr == 0) {
led_on(LED_ACT0);
led_off(LED_ACT1);
led_off(LED_ACT2);
led_off(LED_ACT3);
}
else if (ctr == 1) {
led_on(LED_ACT1);
led_off(LED_ACT0);
led_off(LED_ACT2);
led_off(LED_ACT3);
}
else if (ctr == 2) {
led_on(LED_ACT2);
led_off(LED_ACT1);
led_off(LED_ACT0);
led_off(LED_ACT3);
}
else if (ctr == 3) {
led_on(LED_ACT3);
led_off(LED_ACT1);
led_off(LED_ACT2);
led_off(LED_ACT0);
}
ctr = (ctr + 1) % 4;
}
serial1_ioff();
while(1)
{
// Periodic: LED execution indicator
if(time_millis() - lastLedCycle > LEDCYCLE_RATE) {
spin();
if(!afsk_busy())
serial1_ion();
lastLedCycle = time_millis();
}
// Periodic: Logging
if(time_millis() - lastLog > LOGGER_RATE)
{
led_on(LED_CYCLE);
// Print out GPS debug
snprintf(debugBuf, 128, "GPS> time: %s lat: %s lon: %s speed: %s hdop: %s course: %s\r\n",
get_timestamp(),get_latitude(),get_longitude(),get_speedKnots(),get_hdop(), get_course());
//serial0_sendString(debugBuf);
sensors_readBoardTemp(); // i2c read, 400k
snprintf(logbuf, 128, "%lu,%d,%uF,%s,%s,%s,%s,%s\r\n", time_millis(), sensors_getBoardTemp(),get_timestamp(),get_latitude(),get_longitude(),get_speedKnots(),get_hdop(), get_course());
logger_log(logbuf);
// Print out logger debug
//serial0_sendString("LOG> ");
//serial0_sendString(logbuf);
led_off(LED_CYCLE);
lastLog = time_millis();
}
// Periodic: APRS transmission
if(time_millis() - lastAprsBroadcast > APRS_TRANSMIT_PERIOD)
{
while(afsk_busy());
serial1_ioff();
aprs_send(); // non-blocking
//serial0_sendString("Initiating APRS transmission...\r\n");
// Start getting values for next transmission
if(slavesensors_isrequesting())
{
// TODO: something is terribly wrong
}
else
{
slavesensors_startprocess();
}
lastAprsBroadcast = time_millis();
}
parseResult = serparser_parse();
slavesensors_process(parseResult);
parse_gps_transmission();
wdt_reset();
}
}
|