diff --git a/master/master/config.h b/master/master/config.h --- a/master/master/config.h +++ b/master/master/config.h @@ -12,6 +12,15 @@ #define F_CPU 11059200 #define MODULE_ID '1' + + +// -------------------------------------------------------------------------- +// USART config (serial.c) +// -------------------------------------------------------------------------- + +#define USART0_BAUDRATE 115200 +#define USART1_BAUDRATE 115200 + // -------------------------------------------------------------------------- // AX.25 config (ax25.c) // -------------------------------------------------------------------------- diff --git a/master/master/lib/serial.c b/master/master/lib/serial.c --- a/master/master/lib/serial.c +++ b/master/master/lib/serial.c @@ -10,62 +10,76 @@ #include -void serial_setup() { - // Set registers! - - // from mnl - // uart - //UBRRH = (BAUD_PRESCALE >> 8); // 0 - //UBRRL = BAUD_PRESCALE; // 8 - //UCSRA = 0; - //UCSRB = 0x18; - //UCSRC = 0x06; - //OCR0B = 0xff; - //OCR0A = 0xff; - //OCR1AL = 0xff; - //OCR1BL = 0xff; - - +void serial0_setup() { /* Set baud rate */ - UBRR0H = (unsigned char)(BAUD_PRESCALE>>8); - UBRR0L = (unsigned char)BAUD_PRESCALE; + UBRR0H = (unsigned char)(USART0_BAUD_PRESCALE>>8); + UBRR0L = (unsigned char)USART0_BAUD_PRESCALE; /* Enable receiver and transmitter */ UCSR0B = (1<>8); + UBRR1L = (unsigned char)USART1_BAUD_PRESCALE; + /* Enable receiver and transmitter */ + UCSR1B = (1< -#define USART_BAUDRATE 19200 -#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) -1 ) +#define USART0_BAUD_PRESCALE (((F_CPU / (USART0_BAUDRATE * 16UL))) -1 ) +#define USART1_BAUD_PRESCALE (((F_CPU / (USART1_BAUDRATE * 16UL))) -1 ) + +void serial0_sendChar( unsigned char byte ); +void serial1_sendChar( unsigned char byte ); -void serial_SendChar( char byte ); -void serial_SendCommand( char moduleID, char sensorID, uint8_t dataLength, char* data ); -void serial_SendResponseData(); -void serial_setup(); +void serial0_setup(); +void serial1_setup(); + +void serial0_sendString(char* stringPtr); +void serial1_sendString(char* stringPtr); + +void serial_sendCommand( char moduleID, char sensorID, uint8_t dataLength, char* data ); +void serial_sendResponseData(); + #endif /* SERIAL_H_ */ \ No newline at end of file diff --git a/master/master/lib/trackuinoGPS/config.h b/master/master/lib/trackuinoGPS/config.h --- a/master/master/lib/trackuinoGPS/config.h +++ b/master/master/lib/trackuinoGPS/config.h @@ -78,12 +78,12 @@ // // When launching multiple balloons, use the same APRS_PERIOD in all balloons // and set APRS_SLOT so that the packets are spaced equally in time. -// Eg. for two balloons and APRS_PERIOD = 60, set APRS_SLOT to 0 and 30, +// E.g. for two balloons and APRS_PERIOD = 60, set APRS_SLOT to 0 and 30, // respectively. The first balloon will transmit at 00:00:00, 00:01:00, -// 00:02:00, etc. amd the second balloon will transmit at 00:00:30, 00:01:30, +// 00:02:00, etc. and the second balloon will transmit at 00:00:30, 00:01:30, // 00:02:30, etc. #define APRS_SLOT 0 // seconds. -1 disables slotted transmissions -#define APRS_PERIOD 60 // seconds +#define APRS_PERIOD 5 // seconds // GPS baud rate (in bits per second). This is also the baud rate at which // debug data will be printed out the serial port. diff --git a/master/master/lib/trackuinoGPS/gpsMKa.c b/master/master/lib/trackuinoGPS/gpsMKa.c --- a/master/master/lib/trackuinoGPS/gpsMKa.c +++ b/master/master/lib/trackuinoGPS/gpsMKa.c @@ -4,6 +4,7 @@ * Created: 11/15/2012 12:02:38 PM * Author: mkanning */ +/* #include #include #include "gpsMKa.h" @@ -290,5 +291,5 @@ void parse_gps_transmission(void){ } } - +*/ /// MKa GPS transmission parser END \ No newline at end of file diff --git a/master/master/master.c b/master/master/master.c --- a/master/master/master.c +++ b/master/master/master.c @@ -39,30 +39,46 @@ int main(void) micro_setup(); watchdog_setup(); led_setup(); - serial_setup(); // Config serial ports + serial0_setup(); // Config serial ports + serial1_setup(); // Config serial ports logger_setup(); // this takes a few ms afsk_setup(); // can take a few ms - + - //led_on(POWER); + led_on(POWER); uint16_t ctr1 = 0; uint16_t ctr2 = 255; char logbuf[32]; + uint32_t lastAprsBroadcast = 0; + uint32_t lastLog = 0; + while(1) { - led_on(STAT); - //sprintf(logbuf, "%d,%d,%d,%d,%d,%d\n", time_millis(),5*ctr1,ctr2, 12*ctr2,43*ctr1,5*ctr2); - sprintf(logbuf, "%d,\n", time_millis()); - logger_log(logbuf); - led_off(STAT); + + if(time_millis() - lastLog > 1000) { + led_on(STAT); + sprintf(logbuf, "%lu,%u,%u,%u,%u,%u\r\n", time_millis(),5*ctr1,ctr2, 12*ctr2,43*ctr1,5*ctr2); + logger_log(logbuf); + serial0_sendString("I am serial port 0!\r\n"); + serial1_sendString("I am serial port 1!\r\n"); + led_off(STAT); + lastLog = time_millis(); + } // Wait for transmission to complete before starting another. // Hopefully this will never delay because it should issue on a timed schedule. Software timers! - while(afsk_busy()); - aprs_send(); // non-blocking + + // 8 second periodic for APRS transmission + // for some reason this seems to lock up and the WDT resets everything when the period exceeds 8 seconds. Which is the WDTimeout. Weird. + // If we want ~8+ seconds, then we'll need to do something fun here. Maybe reset the wdt... + if(time_millis() - lastAprsBroadcast > 10000) { + while(afsk_busy()); + aprs_send(); // non-blocking + lastAprsBroadcast = time_millis(); + } ctr1++; ctr2-=6;