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();
// Record the current tick count for time-keeping
ticks_t start = timer_clock();
#if MP1_USE_TX_QUEUE
ticks_t frameQueued = 0;
#endif
// Go into ye good ol' infinite loop
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
AFSK_HW_PTT_ON();
ticks_t start = timer_clock();
#if MP1_USE_TX_QUEUE
if (!mp1->queueProcessing) {
while (timer_clock() - start < ms_to_ticks(MP1_TXDELAY)) {
cpu_relax();
}
}
#else
while (timer_clock() - start < ms_to_ticks(MP1_TXDELAY)) {
cpu_relax();
}
#endif
// Get the transmit data buffer
uint8_t *buffer = (uint8_t *)_buffer;
@ -534,22 +541,29 @@ void mp1Send(MP1 *mp1, void *_buffer, size_t length) {
kfile_putc(HDLC_FLAG, mp1->modem);
// Turn off manual PTT
#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
// it in the transmission queue
void mp1QueueFrame(MP1 *mp1, void *_buffer, size_t length) {
#if MP1_USE_TX_QUEUE
void mp1QueueFrame(MP1 *mp1, void *_buffer, size_t length) {
if (mp1->queueLength < MP1_TX_QUEUE_LENGTH) {
uint8_t *buffer = (uint8_t *)_buffer;
mp1->frameLengths[mp1->queueLength] = length;
memcpy(mp1->frameQueue[mp1->queueLength++], buffer, length);
}
}
}
#endif
// This function processes the transmission
// queue.
void mp1ProcessQueue(MP1 *mp1) {
#if MP1_USE_TX_QUEUE
void mp1ProcessQueue(MP1 *mp1) {
int i = 0;
while (mp1->queueLength) {
mp1Send(mp1, mp1->frameQueue[i], mp1->frameLengths[i]);
@ -557,7 +571,8 @@ void mp1ProcessQueue(MP1 *mp1) {
mp1->queueLength--;
}
AFSK_HW_PTT_OFF();
}
}
#endif
// A simple form of P-persistent CSMA.
// Everytime we have heard activity

View File

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

View File

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