Added some documentation

This commit is contained in:
Mark Qvist 2014-05-20 08:52:10 +02:00
parent b97a469718
commit f0237a9c7d
14 changed files with 3007 additions and 3150 deletions

File diff suppressed because it is too large Load diff

View file

@ -5,22 +5,22 @@
#ifndef FSK_MODEM_H
#define FSK_MODEM_H
#include "config.h" // Various configuration values
#include "hardware.h" // Hardware functions
#include "config.h" // Various configuration values
#include "hardware.h" // Hardware functions
#include <cfg/compiler.h> // Compiler info from BertOS
#include <struct/fifobuf.h> // FIFO buffer implementation from BertOS
#include <io/kfile.h> // The BertOS KFile interface. This is
// used for letting other functions read
// from or write to the modem like a
// file descriptor.
#include <cfg/compiler.h> // Compiler info from BertOS
#include <struct/fifobuf.h> // FIFO buffer implementation from BertOS
#include <io/kfile.h> // The BertOS KFile interface. This is
// used for letting other functions read
// from or write to the modem like a
// file descriptor.
//////////////////////////////////////////////////////
// Our type definitions and function declarations //
//////////////////////////////////////////////////////
#define SAMPLERATE 9600 // The rate at which we are sampling and synthesizing
#define BITRATE 1200 // The actual bitrate at baseband. This is the baudrate.
#define SAMPLERATE 9600 // The rate at which we are sampling and synthesizing
#define BITRATE 1200 // The actual bitrate at baseband. This is the baudrate.
#define SAMPLESPERBIT (SAMPLERATE / BITRATE) // How many DAC/ADC samples constitute one bit (8).
// This defines an errortype for a receive-
@ -32,10 +32,10 @@
// and synchronise to byte boundaries.
typedef struct Hdlc
{
uint8_t demodulatedBits; // Incoming bitstream from demodulator
uint8_t bitIndex; // The current received bit in the current received byte
uint8_t currentByte; // The byte we're currently receiving
bool receiving; // Whether or not where actually receiving data (or just noise ;P)
uint8_t demodulatedBits; // Incoming bitstream from demodulator
uint8_t bitIndex; // The current received bit in the current received byte
uint8_t currentByte; // The byte we're currently receiving
bool receiving; // Whether or not where actually receiving data (or just noise ;P)
} Hdlc;
// This is our primary modem struct. It defines
@ -43,48 +43,48 @@ typedef struct Hdlc
// demodulate data from the physical medium.
typedef struct Afsk
{
KFile fd; // A file descriptor for reading from and
// writing to the modem
KFile fd; // A file descriptor for reading from and
// writing to the modem
// I/O hardware pins
int adcPin; // Pin for incoming signal
// I/O hardware pins
int adcPin; // Pin for incoming signal
// General values
Hdlc hdlc; // We need a link control structure
uint16_t preambleLength; // Length of sync preamble
uint16_t tailLength; // Length of transmission tail
// General values
Hdlc hdlc; // We need a link control structure
uint16_t preambleLength; // Length of sync preamble
uint16_t tailLength; // Length of transmission tail
// Modulation values
uint8_t sampleIndex; // Current sample index for outgoing bit
uint8_t currentOutputByte; // Current byte to be modulated
uint8_t txBit; // Mask of current modulated bit
bool bitStuff; // Whether bitstuffing is allowed
// Modulation values
uint8_t sampleIndex; // Current sample index for outgoing bit
uint8_t currentOutputByte; // Current byte to be modulated
uint8_t txBit; // Mask of current modulated bit
bool bitStuff; // Whether bitstuffing is allowed
uint8_t bitstuffCount; // Counter for bit-stuffing
uint8_t bitstuffCount; // Counter for bit-stuffing
uint16_t phaseAcc; // Phase accumulator
uint16_t phaseInc; // Phase increment per sample
uint16_t phaseAcc; // Phase accumulator
uint16_t phaseInc; // Phase increment per sample
FIFOBuffer txFifo; // FIFO for transmit data
uint8_t txBuf[CONFIG_AFSK_TX_BUFLEN]; // Actial data storage for said FIFO
FIFOBuffer txFifo; // FIFO for transmit data
uint8_t txBuf[CONFIG_AFSK_TX_BUFLEN]; // Actial data storage for said FIFO
volatile bool sending; // Set when modem is sending
volatile bool sending; // Set when modem is sending
// Demodulation values
FIFOBuffer delayFifo; // Delayed FIFO for frequency discrimination
int8_t delayBuf[SAMPLESPERBIT / 2 + 1];// Actual data storage for said FIFO
// Demodulation values
FIFOBuffer delayFifo; // Delayed FIFO for frequency discrimination
int8_t delayBuf[SAMPLESPERBIT / 2 + 1]; // Actual data storage for said FIFO
FIFOBuffer rxFifo; // FIFO for received data
uint8_t rxBuf[CONFIG_AFSK_RX_BUFLEN]; // Actual data storage for said FIFO
FIFOBuffer rxFifo; // FIFO for received data
uint8_t rxBuf[CONFIG_AFSK_RX_BUFLEN]; // Actual data storage for said FIFO
int16_t iirX[2]; // IIR Filter X cells
int16_t iirY[2]; // IIR Filter Y cells
int16_t iirX[2]; // IIR Filter X cells
int16_t iirY[2]; // IIR Filter Y cells
uint8_t sampledBits; // Bits sampled by the demodulator (at ADC speed)
int8_t currentPhase; // Current phase of the demodulator
uint8_t actualBits; // Actual found bits at correct bitrate
uint8_t sampledBits; // Bits sampled by the demodulator (at ADC speed)
int8_t currentPhase; // Current phase of the demodulator
uint8_t actualBits; // Actual found bits at correct bitrate
volatile int status; // Status of the modem, 0 means OK
volatile int status; // Status of the modem, 0 means OK
} Afsk;

View file

@ -8,18 +8,18 @@
#define AUTOREPLY false
// Modem options
#define TX_MAXWAIT 2UL // How many milliseconds should pass with no
// no incoming data before it is transmitted
#define CONFIG_AFSK_RX_BUFLEN 64 // The size of the modems receive buffer
#define CONFIG_AFSK_TX_BUFLEN 64 // The size of the modems transmit buffer
#define CONFIG_AFSK_DAC_SAMPLERATE 9600 // The samplerate of the DAC. Note that
// changing it here will not change the
// actual sample rate. It is defined here
// so various functions can use it.
#define CONFIG_AFSK_RXTIMEOUT 0 // How long a read operation from the modem
// will wait for data before timing out.
#define TX_MAXWAIT 2UL // How many milliseconds should pass with no
// no incoming data before it is transmitted
#define CONFIG_AFSK_RX_BUFLEN 64 // The size of the modems receive buffer
#define CONFIG_AFSK_TX_BUFLEN 64 // The size of the modems transmit buffer
#define CONFIG_AFSK_DAC_SAMPLERATE 9600 // The samplerate of the DAC. Note that
// changing it here will not change the
// actual sample rate. It is defined here
// so various functions can use it.
#define CONFIG_AFSK_RXTIMEOUT 0 // How long a read operation from the modem
// will wait for data before timing out.
#define CONFIG_AFSK_PREAMBLE_LEN 400UL // The length of the packet preamble in milliseconds
#define CONFIG_AFSK_TRAILER_LEN 50UL // The length of the packet tail in milliseconds
#define CONFIG_AFSK_PREAMBLE_LEN 350UL // The length of the packet preamble in milliseconds
#define CONFIG_AFSK_TRAILER_LEN 50UL // The length of the packet tail in milliseconds
#endif
#endif

View file

@ -8,10 +8,11 @@
#define MP1_ENABLE_TCP_COMPATIBILITY false
#if MP1_ENABLE_TCP_COMPATIBILITY
#define MP1_ENABLE_COMPRESSION false
#define MP1_ENABLE_CSMA true
#else
#define MP1_ENABLE_COMPRESSION true
#define MP1_ENABLE_CSMA false
#endif
#define MP1_ENABLE_CSMA true
// Frame sizing & checksum
#define MP1_INTERLEAVE_SIZE 12
@ -33,10 +34,10 @@
// These two parameters are used for
// P-persistent CSMA
#define MP1_SETTLE_TIME 175UL // The minimum wait time before considering sending
#define MP1_SETTLE_TIME 100UL // The minimum wait time before considering sending
#define MP1_SLOT_TIME 100UL // The time to wait if deciding not to send
#define MP1_P_PERSISTENCE 85UL // The probability (between 0 and 255) for sending
#define MP1_TXDELAY 0UL // Delay between turning on the transmitter and sending
#define MP1_TXDELAY 0UL // Delay between turning on the transmitter and sending
// We need to know some basic HDLC flag bytes
#define HDLC_FLAG 0x7E