# HG changeset patch # User Ethan Zonca # Date 2016-07-30 10:14:52 # Node ID 21759af9d2addaa87e313d67f9b252a4c98196db # Parent 702f27a0e2031064bcba2a4365d23fdb257502cd Various changes diff --git a/.cproject b/.cproject --- a/.cproject +++ b/.cproject @@ -1,8 +1,8 @@ - - + + @@ -14,110 +14,112 @@ - - - - - + - + - + + + + + + + diff --git a/.project b/.project --- a/.project +++ b/.project @@ -20,6 +20,7 @@ org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature org.eclipse.cdt.managedbuilder.core.managedBuildNature org.eclipse.cdt.managedbuilder.core.ScannerConfigNature diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -1,11 +1,11 @@ - + - + diff --git a/src/gps.c b/src/gps.c --- a/src/gps.c +++ b/src/gps.c @@ -63,6 +63,7 @@ void gps_update_position() uint8_t request[8] = {0xB5, 0x62, 0x01, 0x02, 0x00, 0x00, 0x03, 0x0A}; //_gps_send_msg(request, 8); + uint8_t flushed = uart_gethandle()->Instance->RDR; HAL_UART_Transmit(uart_gethandle(), request, 8, 100); uint8_t buf[36]; @@ -89,7 +90,8 @@ void gps_update_position() position.altitude = (int32_t)buf[22] | (int32_t)buf[23] << 8 | (int32_t)buf[24] << 16 | (int32_t)buf[25] << 24; - //if( !_gps_verify_checksum(&buf[2], 32) ) led_set(LED_RED, 1); + if( !_gps_verify_checksum(&buf[2], 32) ) + led_blink(2); } @@ -98,6 +100,7 @@ void gps_update_time(uint8_t* hour, uint // Send a NAV-TIMEUTC message to the receiver uint8_t request[8] = {0xB5, 0x62, 0x01, 0x21, 0x00, 0x00, 0x22, 0x67}; + uint8_t flushed = uart_gethandle()->Instance->RDR; HAL_UART_Transmit(uart_gethandle(), request, 8, 100); // Get the message back from the GPS @@ -126,6 +129,7 @@ void gps_check_lock(uint8_t* lock, uint8 // Construct the request to the GPS uint8_t request[8] = {0xB5, 0x62, 0x01, 0x06, 0x00, 0x00, 0x07, 0x16}; + uint8_t flushed = uart_gethandle()->Instance->RDR; HAL_UART_Transmit(uart_gethandle(), request, 8, 100); // Get the message back from the GPS @@ -158,6 +162,7 @@ uint8_t gps_check_nav(void) { uint8_t request[8] = {0xB5, 0x62, 0x06, 0x24, 0x00, 0x00, 0x2A, 0x84}; + uint8_t flushed = uart_gethandle()->Instance->RDR; HAL_UART_Transmit(uart_gethandle(), request, 8, 100); // Get the message back from the GPS diff --git a/src/main.c b/src/main.c --- a/src/main.c +++ b/src/main.c @@ -31,24 +31,18 @@ int main(void) HAL_GPIO_WritePin(OSC_NOTEN, 1); HAL_GPIO_WritePin(TCXO_EN, 0); - HAL_GPIO_TogglePin(LED_BLUE); - uint32_t led_timer = HAL_GetTick(); uint32_t last_gps = HAL_GetTick(); uint32_t last_wspr = HAL_GetTick(); //0xfffff; // start immediately. - HAL_GPIO_TogglePin(LED_BLUE); - HAL_Delay(100); - HAL_GPIO_TogglePin(LED_BLUE); - HAL_Delay(100); - HAL_GPIO_TogglePin(LED_BLUE); - HAL_Delay(100); - HAL_GPIO_TogglePin(LED_BLUE); - HAL_Delay(100); + + led_blink(4); uint8_t lastMinute = 0; uint16_t blink_rate = 250; + gps_poweron(); + HAL_Delay(500); gps_update_position(); while (1) @@ -72,28 +66,28 @@ int main(void) } // EMZ TODO: this needs to trigger off of RTC minute, not GPS minute -// volatile uint8_t minute = get_timestamp()[3] - 0x30; -// -// // If last minute was odd and this minute is even (transition) -// if(lastMinute%2 == 1 && minute%2 == 0) -// { -// // Wait until the first second of the minute -// HAL_Delay(1000); -// wspr_transmit(); -// } + volatile uint8_t minute = get_timestamp()[3] - 0x30; -// lastMinute = minute; + // If last minute was odd and this minute is even (transition) + if(lastMinute%2 == 1 && minute%2 == 0) + { + // Wait until the first second of the minute + HAL_Delay(1000); + wspr_transmit(); + } + + lastMinute = minute; last_wspr = HAL_GetTick(); } if(HAL_GetTick() - led_timer > blink_rate) { - HAL_GPIO_TogglePin(LED_BLUE); + // HAL_GPIO_TogglePin(LED_BLUE); led_timer = HAL_GetTick(); } if(HAL_GetTick() - last_gps > 10) { - //gps_process(); + gps_process(); last_gps = HAL_GetTick(); }