Defines | |
#define | IO_FLASH_CS PIN_A0 |
Flash Chip Select - Port A0. | |
#define | IO_CUT_DOWN PIN_A1 |
#define | IO_BALLAST_PUMP PIN_A2 |
#define | IO_PS0 PIN_A3 |
#define | IO_UPDATE PIN_A5 |
#define | IO_CS PIN_B0 |
#define | IO_PA PIN_B2 |
#define | IO_GPS_PWR PIN_B3 |
#define | IO_LED PIN_B4 |
#define | IO_PS1 PIN_C0 |
#define | IO_OSK PIN_C2 |
#define | TIME_DUTYCYCLE_0 0 |
#define | TIME_DUTYCYCLE_20 2 |
#define | TIME_DUTYCYCLE_70 7 |
#define | BALLAST_3D_FIX_COUNT 10 |
Number of consecutive 3D GPS fixes required to assert altitude as valid. | |
#define | BALLAST_HOLD_ALTITUDE 30500l |
Altitude in feet used to control ballast pump. | |
#define | CUTDOWN_3D_FIX_COUNT 10 |
Count of 3D fixes required to assert GPS altitude is valid. | |
#define | DDS_AD9954_CFR1 0x00 |
AD9954 CFR1 - Control functions including RAM, profiles, OSK, sync, sweep, SPI, and power control settings. | |
#define | DDS_AD9954_CFR2 0x01 |
AD9954 CFR2 - Control functions including sync, PLL multiplier, VCO range, and charge pump current. | |
#define | DDS_AD9954_ASF 0x02 |
AD9954 ASF - Auto ramp rate speed control and output scale factor (0x0000 to 0x3fff). | |
#define | DDS_AD9954_ARR 0x03 |
AD9954 ARR - Amplitude ramp rate for OSK function. | |
#define | DDS_AD9954_FTW0 0x04 |
AD9954 FTW0 - Frequency tuning word 0. | |
#define | DDS_AD9954_FTW1 0x06 |
AD9954 FTW1 - Frequency tuning word 1. | |
#define | DDS_AD9954_NLSCW 0x07 |
AD9954 NLSCW - Negative Linear Sweep Control Word used for spectral shaping in FSK mode. | |
#define | DDS_AD9954_PLSCW 0x08 |
AD9954 PLSCW - Positive Linear Sweep Control Word used for spectral shaping in FSK mode. | |
#define | DDS_AD9954_RWCW0 0x07 |
AD9954 RSCW0 - RAM Segment Control Word 0. | |
#define | DDS_AD9954_RWCW1 0x08 |
AD9954 RSCW0 - RAM Segment Control Word 1. | |
#define | DDS_RAM 0x0b |
AD9954 RAM segment. | |
#define | DDS_FREQ_TO_FTW_DIGITS 9 |
Number of digits in DDS frequency to FTW conversion. | |
#define | DIAG_BYTES_PER_LINE 32 |
Number of bytes per line to display when reading flight data recorder. | |
#define | GPS_BUFFER_SIZE 50 |
The maximum length of a binary GPS engine message. | |
#define | LOG_WRITE_BUFFER_SIZE 255 |
Number of bytes to buffer before writing to flash memory. | |
#define | PSK_MAX_PACKET 160 |
The maximum ASCII length of a PSK 31 message. | |
#define | PSK31_TIMESLOT 0 |
The UTC time in seconds to send a PSK31 data stream. | |
#define | PSK_SYNC_LENGTH 32 |
Number of 0 bits to transmit at start of message. | |
#define | PSK_END_LENGTH 8 |
Number of 0 bits to transmit at end of message. | |
#define | SERIAL_BUFFER_SIZE 64 |
Note this size must be a power of 2, i.e. 2, 4, 8, 16, etc. | |
#define | SERIAL_BUFFER_MASK 0x3f |
Mask to wrap around at end of circular buffer. (SERIAL_BUFFER_SIZE - 1). | |
#define | TIME_RATE_PSK31 4800 |
The change in the CCP_1 register for each interrupt period. 1mS for PSK31, 104uS for 9600 baud APRS, 3.3mS for 300 baud HF-APRS. | |
#define | TIME_RATE_APRS 500 |
#define | TIME_RATE_HF_APRS 16000 |
#define | TIME_ROLLOVER_PSK31 100 |
The number of interrupts in a 100mS time period. | |
#define | TIME_ROLLOVER_APRS 960 |
#define | TIME_ROLLOVER_HF_APRS 30 |
#define | TNC_TX_DELAY 45 |
The number of start flag bytes to send before the packet message. (300mS). | |
#define | TNC_TIMESLOT 55 |
The UTC time in seconds to send an APRS packet. | |
#define | TNC_BUFFER_SIZE 80 |
#define | TNC_DWELL_TIME 3600 |
Typedefs | |
typedef boolean | bool_t |
Boolean value { false, true }. | |
typedef signed int8 | int8_t |
Signed 8-bit number in the range -128 through 127. | |
typedef unsigned int8 | uint8_t |
Unsigned 8-bit number in the range 0 through 255. | |
typedef signed int16 | int16_t |
Signed 16-bit number in the range -32768 through 32767. | |
typedef unsigned int16 | uint16_t |
Unsigned 16-bit number in the range 0 through 65535. | |
typedef signed int32 | int32_t |
Signed 32-bit number in the range -2147483648 through 2147483647. | |
typedef unsigned int32 | uint32_t |
Unsigned 32-bit number in the range 0 through 4294967296. | |
Enumerations | |
enum | DDS_MODE { DDS_MODE_POWERDOWN, DDS_MODE_APRS, DDS_MODE_PSK31, DDS_MODE_HF_APRS } |
Constants to select the DDS mode in method ddsSetMode. More... | |
enum | GPS_FIX_TYPE { GPS_NO_FIX, GPS_2D_FIX, GPS_3D_FIX } |
Type of GPS fix. More... | |
enum | LOG_TYPE { LOG_BOOTED = 0xb4, LOG_COORD = 0xa5, LOG_TEMPERATURE_1 = 0x96, LOG_VOLTAGE = 0x87, LOG_TEMPERATURE_2 = 0x78, LOG_PUMP = 0x69 } |
Define the log record types. More... | |
enum | TIME_MODE { TIME_MODE_APRS, TIME_MODE_PSK31, TIME_MODE_HF_APRS } |
enum | TNC_PACKET_TYPE { TNC_BOOT_MESSAGE, TNC_STATUS, TNC_GGA, TNC_RMC } |
enum | BALLAST_MODE { WAIT_ACTIVATION, CONTROL_ALTITUDE, PUMP_RUN, PUMP_RUN_DELAY } |
Ballast pump state machine. More... | |
enum | GPS_PARSE_STATE_MACHINE { GPS_START1, GPS_START2, GPS_COMMAND1, GPS_COMMAND2, GPS_READMESSAGE, GPS_CHECKSUMMESSAGE, GPS_EOMCR, GPS_EOMLF } |
GPS parse engine state machine values. More... | |
enum | PSK_MODE { PSK_WAIT_MSG, PSK_TX_SYNC, PSK_TX_MESSAGE, PSK_TX_END } |
PSK-31 state machine. More... | |
enum | TNC_MODE { TNC_TX_READY, TNC_TX_SYNC, TNC_TX_HEADER, TNC_TX_DATA, TNC_TX_END } |
TNC state machine. More... | |
Functions | |
bool_t | cutDownIsActivate () |
Determine if cut down has been activated. | |
void | ddsInit () |
Initialize the DDS regsiters and RAM. | |
void | ddsPhase (bool_t phase) |
Set the output phase. | |
void | ddsSetOutputScale (uint16_t scale) |
Set DDS amplitude value in the range 0 to 16383 where 16383 is full scale. | |
void | ddsSetAmplitude (uint8_t amplitude) |
Set the DDS amplitude in units of dBc of full scale where 1 is 0.1 dB. | |
void | ddsPTT (bool_t state) |
Turn on the DDS output. | |
void | ddsSetFreq (uint32_t freq) |
Convert frequency in hertz to 32-bit DDS FTW (Frequency Tune Word). | |
void | ddsSetFTW (uint32_t ftw) |
Set DDS frequency tuning word. | |
void | ddsSetMode (DDS_MODE mode) |
Set the DDS to run in A-FSK, FSK, or PSK31 mode. | |
void | flashErase () |
Erase the entire flash device (all locations set to 0xff). | |
uint8_t | flashGetByte () |
Read a single byte from the flash device through the serial interface. | |
uint8_t | flashReadElectronicSignature () |
Read the flash electronic signature byte. | |
void | flashReadBlock (uint32_t address, uint8_t *block, uint16_t length) |
Read a block of memory from the flash device. | |
void | flashSendByte (uint8_t value) |
Write a single byte to the flash device through the serial interface. | |
void | flashSendAddress (uint32_t address) |
Write the 24-bit address to the flash device through the serial interface. | |
void | flashWriteBlock (uint32_t address, uint8_t *block, uint8_t length) |
Write a block of memory to the flash device. | |
uint8_t | flashReadES () |
void | gpsInit () |
Initialize the GPS subsystem. | |
bool_t | gpsIsReady () |
Determine if new GPS message is ready to process. | |
GPS_FIX_TYPE | gpsGetFixType () |
Get the type of fix. | |
int32_t | gpsGetPeakAltitude () |
Peak altitude detected while GPS is in 3D fix mode since the system was booted. | |
void | gpsPowerOn () |
Turn on the GPS engine power and serial interface. | |
void | gpsPowerOff () |
Turn off the GPS engine power and serial interface. | |
bool_t | gpsSetup () |
Verify the GPS engine is sending the @Hb position report message. | |
void | gpsUpdate () |
Read the serial FIFO and process complete GPS messages. | |
int16_t | lm92GetTemp () |
Read the LM92 temperature value in 0.1 degrees F. | |
void | logInit () |
Prepare the flight data recorder for logging. | |
uint32_t | logGetAddress () |
Last used address in flash memory. | |
void | logSetDisableFlag (bool_t disableFlag) |
Enable and disable flash write operations. | |
void | logType (LOG_TYPE type) |
Start a entry in the data log. | |
void | logUint8 (uint8_t value) |
Save an unsigned, 8-bit value in the log. | |
void | logInt16 (int16_t value) |
Save a signed, 16-bit value in the log. | |
void | logInt32 (int32_t value) |
Save a signed, 32-bit value in the log. | |
bool_t | psk31CreateDataPacket () |
Create the PSK 31 packet. | |
void | psk31Init () |
Initialize the PSK 31 modulator. | |
void | psk31TimeUpdate () |
This method should be called every 1 milliseconds by the timer interrupt. | |
void | psk31TxPacket (uint8_t minutes) |
Generate and start transmision of PSK-31 message. | |
void | psk31TxByte (uint8_t value) |
Write value to the PSK 31 buffer. | |
void | psk31TxNull () |
void | psk31TxString (char *string, uint8_t length) |
Write length characters of string. | |
bool_t | serialHasData () |
Determine if the FIFO contains data. | |
void | serialInit () |
Initialize the serial processor. | |
uint8_t | serialRead () |
Get the oldest character from the FIFO. | |
void | serialUpdate () |
Read and store any characters in the PIC serial port in a FIFO. | |
uint16_t | sysCRC16 (uint8_t *buffer, uint8_t length, uint16_t crc) |
Calculate the CRC-16 CCITT of buffer that is length bytes long. | |
void | sysPAOutput (bool_t state) |
Control the PA output. | |
uint8_t | timeGetTicks () |
Running 8-bit counter that ticks every 100mS. | |
void | timeInit () |
Initialize the real-time clock. | |
uint8_t | timeGetHours () |
Get the time since boot in hours. | |
uint8_t | timeGetMinutes () |
Get the time since boot in minutes. | |
void | timeSetDutyCycle (uint8_t dutyCycle) |
Set the blink duty cycle of the heartbeat LED. | |
void | timeSetMode (TIME_MODE mode) |
Set the time base for PSK31 or APRS. | |
void | timeUpdate () |
void | tncInit () |
bool_t | tncIsFree () |
Determine if the hardware if ready to transmit a 1200 baud packet. | |
void | tncTimeUpdate () |
void | tncTxByte (uint8_t value) |
Write value to the TNC buffer. | |
void | tncTxPacket (TNC_PACKET_TYPE tncPacketType) |
Prepare an AX.25 data packet. | |
uint16_t | ballastGetPumpCount () |
Return the number of times the ballast pump has been commanded to run. | |
void | ballastInit () |
Setup the ballast controls system. | |
void | ballastSetState (bool_t state) |
Set the ballast control operation. | |
void | ballastLogEvent (bool_t state) |
Log the ballast pump command on or off. | |
void | ballastCheck () |
Function that should be called once a second with each GPS fix to determine ballast pump operation. | |
void | cutDownInit () |
Initialize the cut down control system. | |
void | cutDownActivate () |
Activate the I/O and timers for the cutdown. | |
void | cutDownCheck () |
Fucntion that is called each time a new GPS message position report is received. | |
void | diagEraseFlash () |
Process the command to erase the data logger flash. | |
void | diagReadFlash () |
Process the command to dump the contents of the data logger flash. | |
void | diagMenu () |
Display the engineering mode menu. | |
void | diagPort () |
Process commands through the external RS-232 port. | |
bool_t | flashIsWriteInProgress () |
Determine if a flash write or erase operation is currently in progress. | |
void | flashInit () |
Initialize the flash memory subsystem. | |
uint8_t | gpsNMEAChecksum (uint8_t *buffer, uint8_t length) |
Calculate NMEA-0183 message checksum of buffer that is length bytes long. | |
void | gpsParsePositionMessage () |
Parse the Motorola @Hb (Short position/message) report. | |
void | logFlush () |
Write the contents of the temporary log buffer to the flash device. | |
void | logUint16 (uint16_t value) |
Save an unsigned, 16-bit value in the log. | |
bool_t | psk31IsFree () |
Determine if the hardware if ready to a PSK 31 packet. | |
bool_t | psk31IsMessageDone () |
void | sysLogGPSData () |
Log the current GPS position. | |
void | timeSetRunFlag () |
Set a flag to indicate the flight time should run. | |
void | tncNMEATime () |
Generate the GPS NMEA standard UTC time stamp. | |
void | tncNMEAFix () |
Generate the GPS NMEA standard latitude/longitude fix. | |
void | tncStatusPacket () |
Generate the plain text status packet. | |
void | tncGPGGAPacket () |
Generate the GPS NMEA-0183 $GPGGA packet. | |
void | tncGPRMCPacket () |
Generate the GPS NMEA-0183 $GPRMC packet. | |
void | main () |
Variables | |
GPSPOSITION_STRUCT | gpsPosition |
Last verified GPS message received. | |
uint16_t | ballastPumpCount |
Number of times the ballast pump has been commanded to run. | |
uint8_t | ballast3DFixCount |
Count of 3D fixes required to assert GPS altitude is valid. | |
uint8_t | ballastTimeCount |
Counter used to track number of seconds pump is on or off. | |
BALLAST_MODE | ballastMode |
Enumerated type that indicates the current ballast mode. | |
bool_t | ballastState |
Flag used to enable/disable ballast control. | |
uint8_t | cutDownTimer |
Counter used to track how long the nichrome wire has been active. | |
uint8_t | cutDown3DFixCount |
Count of 3D fixes required to assert GPS altitude is valid. | |
bool_t | cutDownFlag |
Flag that is set when the cut down has been fired. | |
const uint32_t | DDS_MULT [DDS_FREQ_TO_FTW_DIGITS] = { 11, 1, 8, 4, 8, 1, 0, 6, 6 } |
Array of multiplication factors used to convert frequency to the FTW. | |
const uint32_t | DDS_DIVISOR [DDS_FREQ_TO_FTW_DIGITS-1] = { 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 } |
Array of divisors used to convert frequency to the FTW. | |
const uint16_t | DDS_AMP_TO_SCALE [] |
Lookup table to convert dB amplitude scale in 0.5 steps to a linear DDS scale factor. | |
const uint32_t | freqTable [256] |
uint8_t | gpsIndex |
Index into gpsBuffer used to store message data. | |
GPS_PARSE_STATE_MACHINE | gpsParseState |
State machine used to parse the GPS message stream. | |
uint8_t | gpsBuffer [GPS_BUFFER_SIZE] |
Buffer to store data as it is read from the GPS engine. | |
int32_t | gpsPeakAltitude |
Peak altitude detected while GPS is in 3D fix mode. | |
uint8_t | gpsChecksum |
Checksum used to verify binary message from GPS engine. | |
uint32_t | logAddress |
Last used address in flash memory. | |
uint8_t | logBuffer [LOG_WRITE_BUFFER_SIZE] |
Temporary buffer that holds data before it is written to flash device. | |
uint8_t | logIndex |
Current index into log buffer. | |
bool_t | logDisableFlag |
Flag that disable writes to flash. | |
const uint16_t | PSK31_VARICODE [] |
const uint32_t | PSK31_FREQ_LIST [] = { 14070450, 14070450, 14070450 } |
PSK 31 frequency and amplitude list for minutes 0 through 2 modulo 2. | |
const uint16_t | PSK31_AMP_LIST [] = { 105, 105, 105 } |
uint8_t | pskCount |
Counts the number of 1mS time slices in each 32mS of a bit time. | |
uint16_t | pskData |
The current PSK output character. | |
bool_t | pskPhase |
The current DDS phase offset where true is 180 degreees and false is 0 degrees. | |
char | pskBuffer [PSK_MAX_PACKET] |
Buffer that holds PSK packet. | |
PSK_MODE | pskMode |
State machine variable that indicates current transmit state. | |
uint8_t | pskLastBits |
Last 4 bits that were transmitted. | |
uint8_t | pskIndex |
Index into the PSK packet buffer. | |
bool_t | pskMessageDoneFlag |
Flag that is set when PSK-31 message is completed. | |
uint8_t | serialHead |
Index to the next free location in the buffer. | |
uint8_t | serialTail |
Index to the next oldest data in the buffer. | |
uint8_t | serialBuffer [SERIAL_BUFFER_SIZE] |
Buffer to hold serial data. | |
uint8_t | timeTicks |
A counter that ticks every 100mS. | |
uint16_t | timeInterruptCount |
Counts the number of 1mS interrupts for a 100mS time period. | |
uint8_t | time100ms |
Counts the number of 100mS time periods in 1 second. | |
uint8_t | timeSeconds |
System time in seconds. | |
uint8_t | timeMinutes |
System time in minutes. | |
uint8_t | timeHours |
System time in hours. | |
uint8_t | timeDutyCycle |
Desired LED duty cycle 0 to 9. | |
uint16_t | timeCompare |
Time compare register 1 value. | |
uint16_t | timeRate |
The CCP1 timer delta between each interrupt. | |
bool_t | timeUpdateFlag |
Flag set true once per second. | |
bool_t | timeRunFlag |
Flag that indicate the flight time should run. | |
uint16_t | timeInterruptCountRollOver |
The number of interrupts in a 100mS time period. The value changes based on the current mode. | |
TIME_MODE | timeMode |
The current time base mode. | |
uint8_t | TNC_AX25_HEADER [30] |
uint8_t | tncLastBit |
uint8_t | tncPacketType |
TNC_MODE | tncMode |
Current mode of the 1200 bps state machine. | |
uint8_t | tncBitCount |
Counter for each bit (0 - 7) that we are going to transmit. | |
uint8_t | tncShift |
A shift register that holds the data byte as we bit shift it for transmit. | |
uint8_t | tncIndex |
Index into the APRS header and data array for each byte as we transmit it. | |
uint8_t | tncLength |
The number of bytes in the message portion of the AX.25 message. | |
uint8_t | tncBitStuff |
A copy of the last 5 bits we've transmitted to determine if we need to bit stuff on the next bit. | |
uint8_t * | tncBufferPnt |
Pointer to TNC buffer as we save each byte during message preparation. | |
uint8_t | tncBuffer [TNC_BUFFER_SIZE] |
Buffer to hold the message portion of the AX.25 packet as we prepare it. | |
uint16_t | tncTestCount |
uint16_t | timeNCO |
16-bit NCO where the upper 8-bits are used to index into the frequency generation table. | |
uint16_t | timeNCOFreq |
Audio tone NCO update step (phase). | |
uint8_t | timeLowRateCount |
Counter used to deciminate down from the 104uS to 833uS interrupt rate. (9600 to 1200 baud). |
#define IO_BALLAST_PUMP PIN_A2 |
Referenced by ballastCheck(), and diagPort().
#define IO_CS PIN_B0 |
Referenced by ddsInit(), ddsPhase(), ddsSetFTW(), ddsSetMode(), and ddsSetOutputScale().
#define IO_CUT_DOWN PIN_A1 |
Referenced by cutDownActivate(), cutDownCheck(), diagPort(), and main().
#define IO_FLASH_CS PIN_A0 |
Flash Chip Select - Port A0.
Referenced by flashErase(), flashInit(), flashIsWriteInProgress(), flashReadBlock(), flashReadElectronicSignature(), and flashWriteBlock().
#define IO_GPS_PWR PIN_B3 |
Referenced by gpsPowerOff(), gpsPowerOn(), and main().
#define IO_LED PIN_B4 |
Referenced by diagPort(), main(), and timeUpdate().
#define IO_OSK PIN_C2 |
Referenced by ddsInit(), ddsPTT(), ddsSetAmplitude(), diagPort(), and psk31TimeUpdate().
#define IO_PA PIN_B2 |
Referenced by main(), and sysPAOutput().
#define IO_PS0 PIN_A3 |
Referenced by ddsInit().
#define IO_PS1 PIN_C0 |
Referenced by ddsInit().
#define IO_UPDATE PIN_A5 |
Referenced by ddsInit(), ddsPhase(), ddsSetFTW(), ddsSetMode(), and ddsSetOutputScale().
#define TIME_DUTYCYCLE_0 0 |
Referenced by main().
#define TIME_DUTYCYCLE_20 2 |
Referenced by gpsSetup().
#define TIME_DUTYCYCLE_70 7 |
Referenced by timeInit().
typedef boolean bool_t |
Boolean value { false, true }.
typedef signed int16 int16_t |
Signed 16-bit number in the range -32768 through 32767.
typedef signed int32 int32_t |
Signed 32-bit number in the range -2147483648 through 2147483647.
typedef signed int8 int8_t |
Signed 8-bit number in the range -128 through 127.
typedef unsigned int16 uint16_t |
Unsigned 16-bit number in the range 0 through 65535.
typedef unsigned int32 uint32_t |
Unsigned 32-bit number in the range 0 through 4294967296.
typedef unsigned int8 uint8_t |
Unsigned 8-bit number in the range 0 through 255.
enum DDS_MODE |
enum GPS_FIX_TYPE |
enum LOG_TYPE |
enum TIME_MODE |
enum TNC_PACKET_TYPE |
uint8_t flashReadES | ( | ) |
void main | ( | ) |
References ballastCheck(), ballastInit(), cutDownCheck(), cutDownInit(), ddsInit(), diagPort(), GPS_3D_FIX, gpsGetFixType(), gpsInit(), gpsIsReady(), gpsPosition, gpsSetup(), gpsUpdate(), IO_CUT_DOWN, IO_GPS_PWR, IO_LED, IO_PA, lm92GetTemp(), LOG_BOOTED, LOG_TEMPERATURE_2, logInit(), logInt16(), logType(), logUint8(), PSK31_TIMESLOT, psk31Init(), psk31IsMessageDone(), psk31TxPacket(), serialInit(), sysLogGPSData(), TIME_DUTYCYCLE_0, timeInit(), timeSetDutyCycle(), timeSetRunFlag(), timeUpdateFlag, TNC_BOOT_MESSAGE, TNC_GGA, TNC_RMC, TNC_STATUS, TNC_TIMESLOT, tncInit(), and tncTxPacket().
GPSPOSITION_STRUCT gpsPosition |
Last verified GPS message received.
Referenced by ballastCheck(), ballastLogEvent(), cutDownCheck(), gpsGetFixType(), gpsInit(), gpsIsReady(), gpsParsePositionMessage(), main(), psk31CreateDataPacket(), sysLogGPSData(), tncGPGGAPacket(), tncGPRMCPacket(), tncNMEAFix(), tncNMEATime(), and tncStatusPacket().