Skip to content
Browse files

cleaning up code

  • Loading branch information...
1 parent 83027c3 commit e6faaddb182aee2c7e576e3d12f37f76dc10d3b3 @Zuph Zuph committed Mar 15, 2012
Showing with 45 additions and 88 deletions.
  1. +1 −1 Makefile
  2. +1 −0 lib/bmp085.c
  3. +0 −1 lib/bmp085.h
  4. +1 −42 lib/i2c.h
  5. +1 −2 logging/openlog.c
  6. +2 −38 main.c
  7. +2 −0 parsing/gps.c
  8. +0 −4 parsing/gps.h
  9. +30 −0 uart.c
  10. +7 −0 uart.h
View
2 Makefile
@@ -61,7 +61,7 @@ TARGET = main
# List C source files here. (C dependencies are automatically generated.)
-SRC = eepromVars.c lib/i2c.c lib/tmp100.c lib/bmp085.c lib/ds3231.c\
+SRC = uart.c eepromVars.c lib/i2c.c lib/tmp100.c lib/bmp085.c lib/ds3231.c\
queue.c parsing/epoch.c parsing/gps.c logging/openlog.c comm/outputParse.c lprintf.c $(TARGET).c
View
1 lib/bmp085.c
@@ -23,6 +23,7 @@
#include <avr/eeprom.h>
+#include "../lprintf.h"
#include "i2c.h"
#include "bmp085.h"
View
1 lib/bmp085.h
@@ -13,7 +13,6 @@
#define BMP085FC 0xEE
#define OSS 0
-extern int lprintf(char *, ...);
void BMP085_Calibration(void);
short bmp085ReadShort(unsigned char address);
unsigned long bmp085ReadTemp(void);
View
43 lib/i2c.h
@@ -20,48 +20,7 @@
#define TRUE 1
#define FALSE 0
-//#include "global.h"
-
-// include project-specific configuration
-//#include "i2cconf.h"
-
-/*// TWSR values (not bits)
-// (taken from avr-libc twi.h - thank you Marek Michalkiewicz)
-// Master
-#define TW_START 0x08
-#define TW_REP_START 0x10
-// Master Transmitter
-#define TW_MT_SLA_ACK 0x18
-#define TW_MT_SLA_NACK 0x20
-#define TW_MT_DATA_ACK 0x28
-#define TW_MT_DATA_NACK 0x30
-#define TW_MT_ARB_LOST 0x38
-// Master Receiver
-#define TW_MR_ARB_LOST 0x38
-#define TW_MR_SLA_ACK 0x40
-#define TW_MR_SLA_NACK 0x48
-#define TW_MR_DATA_ACK 0x50
-#define TW_MR_DATA_NACK 0x58
-// Slave Transmitter
-#define TW_ST_SLA_ACK 0xA8
-#define TW_ST_ARB_LOST_SLA_ACK 0xB0
-#define TW_ST_DATA_ACK 0xB8
-#define TW_ST_DATA_NACK 0xC0
-#define TW_ST_LAST_DATA 0xC8
-// Slave Receiver
-#define TW_SR_SLA_ACK 0x60
-#define TW_SR_ARB_LOST_SLA_ACK 0x68
-#define TW_SR_GCALL_ACK 0x70
-#define TW_SR_ARB_LOST_GCALL_ACK 0x78
-#define TW_SR_DATA_ACK 0x80
-#define TW_SR_DATA_NACK 0x88
-#define TW_SR_GCALL_DATA_ACK 0x90
-#define TW_SR_GCALL_DATA_NACK 0x98
-#define TW_SR_STOP 0xA0
-// Misc
-#define TW_NO_INFO 0xF8
-#define TW_BUS_ERROR 0x00
-*/
+
// defines and constants
#define TWCR_CMD_MASK 0x0F
#define TWSR_STATUS_MASK 0xF8
View
3 logging/openlog.c
@@ -27,14 +27,13 @@
#include <util/delay.h>
#include "../dataStructures.h"
+#include "lprintf.h"
#include "openlog.h"
#define OPENLOGUBRR 77 //9600 baud
static FILE olout = FDEV_SETUP_STREAM(ol_putchar, NULL, _FDEV_SETUP_WRITE);
-extern int lprintf(char *, ...);
-extern int lprintf_P(const char *, ...);
//REMOVE BEFORE FLIGHT, THIS REMOVES THE LOG ON INIT
void initOpenLogTest(void)
View
40 main.c
@@ -13,12 +13,6 @@
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************
-//*****************************************************************************
-//
-// TODO: Before flight, have at least 2 people go through this code with a fine
-// tooth comb to root out any "remove or change before flight" comments.
-//
-//*****************************************************************************
#include <stdio.h>
#include <stdint.h>
#include <avr/io.h>
@@ -30,6 +24,8 @@
#include <avr/eeprom.h>
#include <avr/pgmspace.h>
+#include "uart.h"
+
#include "lprintf.h"
#include "lib/i2c.h"
@@ -94,10 +90,6 @@
//======================
uint32_t now(void);
void ioinit(void); // initializes IO
-static int uart_putchar(char c, FILE *stream);
-uint8_t uart_getchar(void);
-int lprintf(char *, ...);
-int lprintf_P(const char *str, ...);
void receiveCommandHandler(uint8_t receiveDataLength, uint8_t* recieveData);
//Test Vars
@@ -1740,34 +1732,6 @@ void ioinit (void)
}
-
-
-static int uart_putchar(char c, FILE *stream)
-{
- if (c == '\n') uart_putchar('\r', stream);
-
- loop_until_bit_is_set(UCSR1A, UDRE1);
- UDR1 = c;
-
- return 0;
-}
-
-uint8_t uart_getchar(void)
-{
- uint16_t errorCounter = 0xFFFF;
- while( !(UCSR1A & (1<<RXC1)) && (errorCounter > 100))
- {
- errorCounter--;
- }
- if(errorCounter <= 101)
- {
- return 0xff;
- } else {
- return UDR1;
- }
-
-}
-
void get_mcusr(void)
{
mcusr_mirror = MCUSR;
View
2 parsing/gps.c
@@ -21,6 +21,8 @@
#include <avr/pgmspace.h>
#include <avr/wdt.h>
+#include "../uart.h"
+#include "../lprintf.h"
#include "gps.h"
View
4 parsing/gps.h
@@ -18,9 +18,5 @@
#include "../dataStructures.h"
-extern uint8_t uart_getchar(void);
-extern int lprintf(char *, ...);
-extern int lprintf_P(const char *, ...);
-
void getGPS(struct gpsData *outputData);
void debugPrintRawStrings(void);
View
30 uart.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <avr/io.h>
+
+#include "uart.h"
+
+int uart_putchar(char c, FILE *stream)
+{
+ if (c == '\n') uart_putchar('\r', stream);
+
+ loop_until_bit_is_set(UCSR1A, UDRE1);
+ UDR1 = c;
+
+ return 0;
+}
+
+uint8_t uart_getchar(void)
+{
+ uint16_t errorCounter = 0xFFFF;
+ while( !(UCSR1A & (1<<RXC1)) && (errorCounter > 100))
+ {
+ errorCounter--;
+ }
+ if(errorCounter <= 101)
+ {
+ return 0xff;
+ } else {
+ return UDR1;
+ }
+
+}
View
7 uart.h
@@ -0,0 +1,7 @@
+#ifndef UART_H
+#define UART_H
+
+int uart_putchar(char, FILE *);
+uint8_t uart_getchar(void);
+
+#endif

0 comments on commit e6faadd

Please sign in to comment.
Something went wrong with that request. Please try again.