Skip to content

Commit

Permalink
Did a Bad Thing and linked against the full version of vfprintf for f…
Browse files Browse the repository at this point in the history
…loating point support
  • Loading branch information
Jon Sowman committed Mar 23, 2012
1 parent 350a32e commit 821b6ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion firmware/Makefile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ OBJECTS = $(SOURCES:.c=.o)
AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) -C /etc/avrdude.conf AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) -C /etc/avrdude.conf


# Disable warning of strict-aliasing since uIP type-puns # Disable warning of strict-aliasing since uIP type-puns
COMPILE = avr-gcc -Wall -Os -fno-strict-aliasing -gdwarf-2 -std=gnu99 -DF_CPU=$(CLOCK) -mmcu=atmega328p COMPILE = avr-gcc -Wall -Os -fno-strict-aliasing -gdwarf-2 -std=gnu99 -Wl,-u,vfprintf -lprintf_flt -lm -DF_CPU=$(CLOCK) -mmcu=atmega328p


# symbolic targets: # symbolic targets:
all: main.hex all: main.hex
Expand Down
22 changes: 10 additions & 12 deletions firmware/main.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <avr/eeprom.h> #include <avr/eeprom.h>
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h>


#include "led.h" #include "led.h"
#include "radio.h" #include "radio.h"
Expand All @@ -31,18 +32,13 @@ int main()
_delay_ms(1000); _delay_ms(1000);


// Set the radio shift and baud rate // Set the radio shift and baud rate
radio_set_shift(0x0600);
radio_set_baud(RADIO_BAUD_300);

_radio_dac_write(RADIO_COARSE, 0xf000); _radio_dac_write(RADIO_COARSE, 0xf000);
_radio_dac_write(RADIO_FINE, 0); _radio_dac_write(RADIO_FINE, 0);
radio_set_shift(0x0600);
radio_set_baud(RADIO_BAUD_300);


int32_t lat = 0; int32_t lat = 0, lon = 0, alt = 0;
int32_t lon = 0; uint8_t hour = 0, minute = 0, second = 0;
int32_t alt = 0;
uint8_t hour = 0;
uint8_t minute = 0;
uint8_t second = 0;


while(true) while(true)
{ {
Expand All @@ -57,9 +53,11 @@ int main()
led_set(LED_GREEN, 0); led_set(LED_GREEN, 0);


// Format the telemetry string & transmit // Format the telemetry string & transmit
sprintf(s, "$$JOEY,%02u:%02u:%02u,%ld,%ld,%ld,%u,%x\n", double lat_fmt = (double)lat / 10000000.0;
hour, minute, second, lat, lon, double lon_fmt = (double)lon / 10000000.0;
alt, sats, lock);
sprintf(s, "$$JOEY,%02u:%02u:%02u,%02.7f,%03.7f,%ld,%u,%x\n",
hour, minute, second, lat_fmt, lon_fmt, alt, sats, lock);
radio_transmit_string(s); radio_transmit_string(s);


led_set(LED_RED, 0); led_set(LED_RED, 0);
Expand Down

0 comments on commit 821b6ac

Please sign in to comment.