This commit is contained in:
Mark Qvist 2014-04-28 17:53:43 +02:00
parent d8a89c5de2
commit 13b792fcbe
4 changed files with 37 additions and 17 deletions

View File

@ -89,7 +89,9 @@ int main(void)
init(); init();
// Record the current tick count for time-keeping // Record the current tick count for time-keeping
ticks_t start = timer_clock(); ticks_t start = timer_clock();
ticks_t frameQueued = 0; #if MP1_USE_TX_QUEUE
ticks_t frameQueued = 0;
#endif
// Go into ye good ol' infinite loop // Go into ye good ol' infinite loop
while (1) while (1)

View File

@ -412,11 +412,18 @@ void mp1Send(MP1 *mp1, void *_buffer, size_t length) {
// Open transmitter and wait for MP1_TXDELAY msecs // Open transmitter and wait for MP1_TXDELAY msecs
AFSK_HW_PTT_ON(); AFSK_HW_PTT_ON();
ticks_t start = timer_clock(); ticks_t start = timer_clock();
#if MP1_USE_TX_QUEUE
if (!mp1->queueProcessing) { if (!mp1->queueProcessing) {
while (timer_clock() - start < ms_to_ticks(MP1_TXDELAY)) { while (timer_clock() - start < ms_to_ticks(MP1_TXDELAY)) {
cpu_relax(); cpu_relax();
} }
} }
#else
while (timer_clock() - start < ms_to_ticks(MP1_TXDELAY)) {
cpu_relax();
}
#endif
// Get the transmit data buffer // Get the transmit data buffer
uint8_t *buffer = (uint8_t *)_buffer; uint8_t *buffer = (uint8_t *)_buffer;
@ -534,30 +541,38 @@ void mp1Send(MP1 *mp1, void *_buffer, size_t length) {
kfile_putc(HDLC_FLAG, mp1->modem); kfile_putc(HDLC_FLAG, mp1->modem);
// Turn off manual PTT // Turn off manual PTT
if (!mp1->queueProcessing) AFSK_HW_PTT_OFF(); #if MP1_USE_TX_QUEUE
if (!mp1->queueProcessing) AFSK_HW_PTT_OFF();
#else
AFSK_HW_PTT_OFF();
#endif
} }
// This function accepts a frame and stores // This function accepts a frame and stores
// it in the transmission queue // it in the transmission queue
void mp1QueueFrame(MP1 *mp1, void *_buffer, size_t length) { #if MP1_USE_TX_QUEUE
if (mp1->queueLength < MP1_TX_QUEUE_LENGTH) { void mp1QueueFrame(MP1 *mp1, void *_buffer, size_t length) {
uint8_t *buffer = (uint8_t *)_buffer; if (mp1->queueLength < MP1_TX_QUEUE_LENGTH) {
mp1->frameLengths[mp1->queueLength] = length; uint8_t *buffer = (uint8_t *)_buffer;
memcpy(mp1->frameQueue[mp1->queueLength++], buffer, length); mp1->frameLengths[mp1->queueLength] = length;
memcpy(mp1->frameQueue[mp1->queueLength++], buffer, length);
}
} }
} #endif
// This function processes the transmission // This function processes the transmission
// queue. // queue.
void mp1ProcessQueue(MP1 *mp1) { #if MP1_USE_TX_QUEUE
int i = 0; void mp1ProcessQueue(MP1 *mp1) {
while (mp1->queueLength) { int i = 0;
mp1Send(mp1, mp1->frameQueue[i], mp1->frameLengths[i]); while (mp1->queueLength) {
i++; mp1Send(mp1, mp1->frameQueue[i], mp1->frameLengths[i]);
mp1->queueLength--; i++;
mp1->queueLength--;
}
AFSK_HW_PTT_OFF();
} }
AFSK_HW_PTT_OFF(); #endif
}
// A simple form of P-persistent CSMA. // A simple form of P-persistent CSMA.
// Everytime we have heard activity // Everytime we have heard activity

View File

@ -8,6 +8,8 @@
#define MP1_ENABLE_TCP_COMPATIBILITY false #define MP1_ENABLE_TCP_COMPATIBILITY false
#if MP1_ENABLE_TCP_COMPATIBILITY #if MP1_ENABLE_TCP_COMPATIBILITY
#define MP1_ENABLE_COMPRESSION false #define MP1_ENABLE_COMPRESSION false
#else
#define MP1_ENABLE_COMPRESSION true
#endif #endif
#define MP1_ENABLE_CSMA true #define MP1_ENABLE_CSMA true
@ -15,6 +17,7 @@
#define MP1_INTERLEAVE_SIZE 12 #define MP1_INTERLEAVE_SIZE 12
#if MP1_ENABLE_COMPRESSION #if MP1_ENABLE_COMPRESSION
#define MP1_MAX_FRAME_LENGTH 22 * MP1_INTERLEAVE_SIZE #define MP1_MAX_FRAME_LENGTH 22 * MP1_INTERLEAVE_SIZE
#define MP1_USE_TX_QUEUE false
#else #else
#define MP1_MAX_FRAME_LENGTH 25 * MP1_INTERLEAVE_SIZE #define MP1_MAX_FRAME_LENGTH 25 * MP1_INTERLEAVE_SIZE
#define MP1_USE_TX_QUEUE true #define MP1_USE_TX_QUEUE true

View File

@ -1,2 +1,2 @@
#define VERS_BUILD 1724 #define VERS_BUILD 1734
#define VERS_HOST "shard" #define VERS_HOST "shard"