Permalink
Browse files

Almost flight ready, I've been negligent in updating.

  • Loading branch information...
1 parent 176811c commit 3b798745a89ca03ef7f28dd4b01deef696de37a2 @Zuph Zuph committed Mar 20, 2011
Showing with 579 additions and 246 deletions.
  1. +12 −9 WSB Flight Computer.depend
  2. +33 −6 WSB Flight Computer.layout
  3. +13 −9 comm/outputParse.c
  4. +3 −3 dataStructures.h
  5. +3 −0 eepromVars.h
  6. +11 −11 lib/i2c.c
  7. +10 −4 logging/openlog.c
  8. +460 −195 main.c
  9. +3 −3 parsing/epoch.c
  10. +4 −3 parsing/gps.c
  11. +26 −2 queue.c
  12. +1 −1 queue.h
View
@@ -1,9 +1,10 @@
# depslib dependency file v1.0
-1298075086 source:/home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/comm/outputParse.c
+1298509975 source:/home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/comm/outputParse.c
<stdio.h>
<stdint.h>
<string.h>
<avr/io.h>
+ <avr/wdt.h>
<util/delay.h>
<avr/pgmspace.h>
<avr/eeprom.h>
@@ -13,7 +14,7 @@
"../lib/i2c.h"
"outputParse.h"
-1292657941 /home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/dataStructures.h
+1298238847 /home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/dataStructures.h
1297969849 /home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/progmemVars.h
<avr/pgmspace.h>
@@ -44,7 +45,7 @@
1292126383 /home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/lib/ds3231.h
-1296863073 source:/home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/lib/i2c.c
+1298240116 source:/home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/lib/i2c.c
<avr/io.h>
<avr/interrupt.h>
<stdio.h>
@@ -640,20 +641,21 @@
1281579115 /usr/lib/avr/include/util/twi.h
<avr/io.h>
-1298007806 source:/home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/logging/openlog.c
+1298510018 source:/home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/logging/openlog.c
<stdio.h>
<stdint.h>
<avr/io.h>
<util/delay.h>
"../dataStructures.h"
"openlog.h"
-1298074286 source:/home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/main.c
+1300128097 source:/home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/main.c
<stdio.h>
<stdint.h>
<avr/io.h>
<util/delay.h>
<string.h>
+ <avr/wdt.h>
<avr/interrupt.h>
<avr/eeprom.h>
<avr/pgmspace.h>
@@ -673,10 +675,10 @@
1297464879 /home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/parsing/gps.h
"../dataStructures.h"
-1293925726 /home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/queue.h
+1298250144 /home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/queue.h
"dataStructures.h"
-1297803282 source:/home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/parsing/epoch.c
+1299379087 source:/home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/parsing/epoch.c
<stdio.h>
<stdint.h>
<util/delay.h>
@@ -685,14 +687,15 @@
<avr/eeprom.h>
"../eepromVars.h"
-1297476419 /home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/eepromVars.h
+1298253528 /home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/eepromVars.h
<avr/eeprom.h>
-1297478793 source:/home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/parsing/gps.c
+1298507494 source:/home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/parsing/gps.c
<stdio.h>
<stdint.h>
<string.h>
<avr/pgmspace.h>
+ <avr/wdt.h>
"gps.h"
1292126383 source:/home/bradluyster/Dev/git/LVL1-Transatlantic-Balloon/Software/fcpu/WSB Flight Computer/queue.c
View
@@ -1,13 +1,40 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug" />
- <File name="comm/outputParse.c" open="1" top="0" tabpos="2">
- <Cursor position="790" topLine="26" />
+ <File name="comm/outputParse.c" open="1" top="0" tabpos="3">
+ <Cursor position="6847" topLine="0" />
</File>
- <File name="logging/openlog.c" open="1" top="1" tabpos="3">
- <Cursor position="1110" topLine="21" />
+ <File name="dataStructures.h" open="0" top="0" tabpos="0">
+ <Cursor position="814" topLine="12" />
</File>
- <File name="main.c" open="1" top="0" tabpos="1">
- <Cursor position="4963" topLine="157" />
+ <File name="eepromVars.h" open="0" top="0" tabpos="0">
+ <Cursor position="1937" topLine="33" />
+ </File>
+ <File name="lib/bmp085.c" open="0" top="0" tabpos="0">
+ <Cursor position="1753" topLine="28" />
+ </File>
+ <File name="lib/i2c.c" open="1" top="0" tabpos="4">
+ <Cursor position="7648" topLine="293" />
+ </File>
+ <File name="lib/i2c.h" open="0" top="0" tabpos="0">
+ <Cursor position="3645" topLine="82" />
+ </File>
+ <File name="logging/openlog.c" open="1" top="0" tabpos="5">
+ <Cursor position="3346" topLine="107" />
+ </File>
+ <File name="main.c" open="1" top="1" tabpos="1">
+ <Cursor position="44696" topLine="1490" />
+ </File>
+ <File name="parsing/epoch.c" open="1" top="0" tabpos="2">
+ <Cursor position="1326" topLine="43" />
+ </File>
+ <File name="parsing/gps.c" open="1" top="0" tabpos="6">
+ <Cursor position="4066" topLine="333" />
+ </File>
+ <File name="progmemVars.h" open="0" top="0" tabpos="0">
+ <Cursor position="519" topLine="0" />
+ </File>
+ <File name="queue.h" open="0" top="0" tabpos="0">
+ <Cursor position="656" topLine="0" />
</File>
</CodeBlocks_layout_file>
View
@@ -3,6 +3,7 @@
#include <stdint.h>
#include <string.h>
#include <avr/io.h>
+#include <avr/wdt.h>
#include <util/delay.h>
#include <avr/pgmspace.h>
@@ -61,13 +62,6 @@ uint16_t getTxSample(uint8_t *output, uint32_t *bitmask, uint16_t sampleNumber,
}
//Bitmask reversal words
- /*lprintf("%lx ", bitmask[0]);
- lprintf("%lx ", bitmask[1]);
- lprintf("%lx\n", bitmask[2]);
- lprintf("%lx ", reversedBitmask[0]);
- lprintf("%lx ", reversedBitmask[1]);
- lprintf("%lx\n", reversedBitmask[2]);*/
-
char sampleHolder[SAMPLESTRINGSIZEINCHARS+5];
memset(sampleHolder, 0, SAMPLESTRINGSIZEINCHARS+5);
@@ -216,7 +210,9 @@ void loadBatch(void)
{
uint8_t thisSample[MAXTXSAMPLESIZE];
uint8_t sizeOfSample;
+ memset(thisSample, 0x00, MAXTXSAMPLESIZE);
sizeOfSample = getTxSample(thisSample, currentBitmask, i, batchNumber);
+
#ifdef opdebug
lprintf("A Sample: ");
#endif
@@ -226,17 +222,21 @@ void loadBatch(void)
lprintf("%x ", thisSample[j]);
#endif
uint8_t data[3];
+ uint8_t error;
data[0] = commPromEnd >> 8;
data[1] = commPromEnd;
data[2] = thisSample[j];
#ifdef detacheeprom
- i2cMasterSendNI(COMPROM, 3, data);
+ while((error = i2cMasterSendNI(COMPROM, 3, data)) != I2C_OK);
#endif
+ eeprom_write_word(&EEbatchSampleStart, ++batchSampleStart);
+ wdt_reset();
commPromEnd++;
}
#ifdef opdebug
lprintf("\n");
#endif
+
}
batchNumber++;
@@ -264,6 +264,10 @@ void flushSatQueue(void)
uint8_t cpe1 = commPromEnd >> 8;
uint8_t cpe2 = commPromEnd;
+ #ifdef opdebug
+ lprintf_P(PSTR("CPS: %x %x CPE: %x %x\n"), cps1, cps2, cpe1, cpe2);
+ #endif
+
i2cSendStart();
i2cWaitForComplete();
i2cSendByte(0x10);
@@ -286,7 +290,7 @@ void flushSatQueue(void)
lprintf_P(PSTR("Done w/Long Report\n"));
#endif
- if(COMMPROMSIZE - commPromEnd < 1024)
+ if((COMMPROMSIZE - commPromEnd) < 1024)
commPromStart = commPromEnd = 0;
else
commPromStart = commPromEnd;
View
@@ -22,7 +22,7 @@
#define MAXTXSAMPLESIZE 150
-#define COMMPROMSIZE 32768
+#define COMMPROMSIZE 32767
typedef void (*scheduledFunction)(uint32_t);
@@ -32,7 +32,7 @@ struct dataSample
uint16_t flightComputerTemperature;
uint32_t barometricPressure;
//struct gpsData sampleGPS;
-
+
} dataSample;
struct gpsData
@@ -49,7 +49,7 @@ struct gpsData
uint8_t seconds;
uint16_t altitude;
uint8_t numberOfSats;
-
+
} gpsData;
View
@@ -70,6 +70,9 @@ uint16_t EEMEM EEcurrentTelemetryVersion; //Var 0x07
uint8_t EEMEM EEEpochLock = 0;
+uint16_t EEMEM EEhfTimeToTx;
+uint8_t EEMEM EEhfLenngthToTx;
+
//THIS IS ALSO DEFINED IN MAIN, REMEMBER TO CHANGE THIS DUMMY
#define VSPEEDSAMPLESDESIRED 20
View
@@ -100,9 +100,9 @@ void i2cInit(void)
//going to set it ourself, damnit
void i2cSetTheDamnTWBRMyself(uint8_t myOwnTWBR)
{
-
+
TWBR = myOwnTWBR;
-
+
}
void i2cSetBitrate(uint16_t bitrateKHz)
@@ -116,18 +116,18 @@ void i2cSetBitrate(uint16_t bitrateKHz)
// set TWPS to zero
TWSR &= ~(_BV(TWPS0) | _BV(TWPS1));
#endif
- // calculate bitrate division
+ // calculate bitrate division
//printf("1: %d\n", (uint16_t)(799./100.));
bitrate_div = (uint8_t)(((float)F_CPU/(float)10001))/(float)bitrateKHz;
if(bitrate_div >= 16)
bitrate_div = (bitrate_div-16)/2;
//printf("bitrate: %d\n", bitrate_div);
//printf("k: %d\n", bitrateKHz);
TWBR = bitrate_div;
-
+
//TWSR |= _BV(TWPS0) | _BV(TWPS1);
//TWBR = 97;
-
+
}
//Mask is right-adjusted
@@ -138,7 +138,7 @@ void i2cSetLocalDeviceAddr(uint8_t deviceAddr, uint8_t maskAddr, uint8_t genCall
TWAMR = maskAddr << 1;
I2cWhiteStarGeneralEn = wsGenCallEn;
I2cWhiteStarGeneralAddr = wsGenCallAddr;
-
+
}
void i2cSetSlaveReceiveHandler(void (*i2cSlaveRx_func)(uint8_t receiveDataLength, uint8_t* recieveData))
@@ -183,9 +183,9 @@ uint8_t i2cWaitForComplete(void)
while( !(TWCR & _BV(TWINT) ) && i < 100 )
{
i++;
- _delay_ms(1);
+ _delay_us(150);
}
- if(i >= 99)
+ if(i >= 98)
{
return 1;
}
@@ -376,7 +376,7 @@ void i2cMasterTransferNI(uint8_t deviceAddr, uint8_t sendlength, uint8_t* sendda
// send device address with write
i2cSendByte( deviceAddr & 0xFE );
i2cWaitForComplete();
-
+
// send data
while(sendlength)
{
@@ -412,7 +412,7 @@ void i2cMasterTransferNI(uint8_t deviceAddr, uint8_t sendlength, uint8_t* sendda
i2cWaitForComplete();
*receivedata++ = i2cGetReceivedByte();
}
-
+
// transmit stop condition
// leave with TWEA on for slave receiving
i2cSendStop();
@@ -441,7 +441,7 @@ ISR(TWI_vect)
// send device address
i2cSendByte(I2cDeviceAddrRW);
break;
-
+
// Master Transmitter & Receiver status codes
case TW_MT_SLA_ACK: // 0x18: Slave address acknowledged
case TW_MT_DATA_ACK: // 0x28: Data acknowledged
View
@@ -73,6 +73,10 @@ void initOpenLogFlight(void)
_delay_ms(2000);
//Ensure we're in command mode.
fprintf(&olout, "%c%c%c\r", (char)0x1a,(char)0x1a,(char)0x1a);
+ while((char)ol_getchar() != '>');
+
+ fprintf(&olout,"echo off\r");
+ while((char)ol_getchar() != '>');
}
@@ -107,7 +111,6 @@ void getDataSample(uint16_t sampleNumber, char *returnString)
i=0;
volatile char thisChar;
fprintf(&olout, "read samples.txt %ld %d", (uint32_t)((uint32_t)sampleNumber * (SAMPLESTRINGSIZEINCHARS + 5)), SAMPLESTRINGSIZEINCHARS);
-
loop_until_bit_is_set(UCSR0A, UDRE0);
UDR0 = '\r';
ol_getchar();
@@ -118,10 +121,13 @@ void getDataSample(uint16_t sampleNumber, char *returnString)
returnString[i] = thisChar;
i++;
}
- //lprintf("Read: %d %d\n", (sampleNumber * (SAMPLESTRINGSIZEINCHARS + 5)), SAMPLESTRINGSIZEINCHARS);
-
+ //lprintf("Read: %ld %d\n", (uint32_t)((uint32_t)sampleNumber * (SAMPLESTRINGSIZEINCHARS + 5)), SAMPLESTRINGSIZEINCHARS);
+ if(thisChar != '>')
+ {
+ while( (thisChar = (char)ol_getchar())!='>');
+ }
returnString[i] = '\0';
- //while( (thisChar = (char)ol_getchar())!='>');
+ //
}
Oops, something went wrong.

0 comments on commit 3b79874

Please sign in to comment.