diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-01-02 22:13:26 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-01-02 22:13:26 +0100 |
commit | 7bcd939a5044d6613a457b32fe813b668f9cd379 (patch) | |
tree | a6be9ca111d664eded8fb5aa50224e9810cc83ab | |
parent | a0696e7931dcd61cc667722466e5deaa83cca98d (diff) | |
download | glutte-o-matic-7bcd939a5044d6613a457b32fe813b668f9cd379.tar.gz glutte-o-matic-7bcd939a5044d6613a457b32fe813b668f9cd379.tar.bz2 glutte-o-matic-7bcd939a5044d6613a457b32fe813b668f9cd379.zip |
Combine PSK and CW triggers in FSM. Done signal needs some sort of synchronisation.
-rw-r--r-- | src/fsm/cw.c | 8 | ||||
-rw-r--r-- | src/fsm/fsm.c | 40 | ||||
-rw-r--r-- | src/fsm/fsm.h | 19 | ||||
-rw-r--r-- | src/fsm/main.c | 21 |
4 files changed, 36 insertions, 52 deletions
diff --git a/src/fsm/cw.c b/src/fsm/cw.c index f3d4335..7528fa8 100644 --- a/src/fsm/cw.c +++ b/src/fsm/cw.c @@ -274,12 +274,12 @@ void cw_psk31_init(unsigned int samplerate) cw_psk31_samplerate = samplerate; cw_transmit_ongoing = 0; - cw_msg_queue = xQueueCreate(15, sizeof(struct cw_message_s)); + cw_msg_queue = xQueueCreate(10, sizeof(struct cw_message_s)); if (cw_msg_queue == 0) { while(1); /* fatal error */ } - cw_audio_queue = xQueueCreate(2, AUDIO_BUF_LEN * sizeof(int16_t)); + cw_audio_queue = xQueueCreate(1, AUDIO_BUF_LEN * sizeof(int16_t)); if (cw_audio_queue == 0) { while(1); /* fatal error */ } @@ -289,7 +289,7 @@ void cw_psk31_init(unsigned int samplerate) "CWPSKTask", 8*configMINIMAL_STACK_SIZE, (void*) NULL, - tskIDLE_PRIORITY + 2UL, + tskIDLE_PRIORITY + 3UL, NULL); } @@ -408,7 +408,7 @@ static size_t psk31_text_to_phase_buffer(const char* instr, uint8_t* outbits) /* Header of 0s */ for (j=0; j < 20; j++) { - outbits[i++] = '0'; + outbits[i++] = 0; } /* Encode the message, with 00 between letters */ diff --git a/src/fsm/fsm.c b/src/fsm/fsm.c index 1ef92bf..4b83ebe 100644 --- a/src/fsm/fsm.c +++ b/src/fsm/fsm.c @@ -91,8 +91,7 @@ void fsm_update() { // Some defaults for the outgoing signals fsm_out.tx_on = 0; fsm_out.modulation = 0; - fsm_out.cw_trigger = 0; - fsm_out.psk_trigger = 0; + fsm_out.cw_psk31_trigger = 0; fsm_out.cw_dit_duration = 50; fsm_out.msg_frequency = 960; // other output signals keep their value @@ -141,9 +140,9 @@ void fsm_update() { fsm_out.msg_frequency = 696; fsm_out.cw_dit_duration = 70; } - fsm_out.cw_trigger = 1; + fsm_out.cw_psk31_trigger = 1; - if (fsm_in.cw_done) { + if (fsm_in.cw_psk31_done) { next_state = FSM_ECOUTE; } break; @@ -207,9 +206,9 @@ void fsm_update() { fsm_out.tx_on = 1; // No modulation! fsm_out.msg = "HI HI"; - fsm_out.cw_trigger = 1; + fsm_out.cw_psk31_trigger = 1; - if (fsm_in.cw_done) { + if (fsm_in.cw_psk31_done) { next_state = FSM_BLOQUE; } break; @@ -226,12 +225,12 @@ void fsm_update() { fsm_out.msg_frequency = 696; fsm_out.cw_dit_duration = 70; fsm_out.msg = "73"; - fsm_out.cw_trigger = 1; + fsm_out.cw_psk31_trigger = 1; if (fsm_in.sq) { next_state = FSM_QSO; } - else if (fsm_in.cw_done) { + else if (fsm_in.cw_psk31_done) { next_state = FSM_OISIF; } break; @@ -242,12 +241,12 @@ void fsm_update() { fsm_out.msg_frequency = 696; fsm_out.cw_dit_duration = 70; fsm_out.msg = "HB9G"; - fsm_out.cw_trigger = 1; + fsm_out.cw_psk31_trigger = 1; if (fsm_in.sq) { next_state = FSM_QSO; } - else if (fsm_in.cw_done) { + else if (fsm_in.cw_psk31_done) { next_state = FSM_OISIF; } break; @@ -265,19 +264,18 @@ void fsm_update() { else { fsm_out.msg = "HB9G JN36BK"; } - fsm_out.cw_trigger = 1; + fsm_out.cw_psk31_trigger = 1; if (fsm_in.sq) { next_state = FSM_QSO; } - else if (fsm_in.cw_done) { + else if (fsm_in.cw_psk31_done) { next_state = FSM_OISIF; } break; case FSM_BALISE_LONGUE: fsm_out.tx_on = 1; - fsm_out.msg_frequency = 588; fsm_out.cw_dit_duration = 110; @@ -293,12 +291,12 @@ void fsm_update() { fsm_out.msg = "HB9G JN36BK 1628M U 10V5 = T 11 #"; // The # is the SK digraph } - fsm_out.psk_trigger = 1; + fsm_out.cw_psk31_trigger = 1; - if (fsm_in.sq) { + if (fsm_in.cw_psk31_done && fsm_in.sq) { next_state = FSM_OPEN2; } - else if (fsm_in.psk_done) { + else if (fsm_in.cw_psk31_done) { next_state = FSM_OISIF; } break; @@ -315,12 +313,12 @@ void fsm_update() { else { fsm_out.msg = "HB9G U 10V5 #"; // The # is the SK digraph } - fsm_out.cw_trigger = 1; + fsm_out.cw_psk31_trigger = 1; - if (fsm_in.sq) { + if (fsm_in.cw_psk31_done && fsm_in.sq) { next_state = FSM_OPEN2; } - else if (fsm_in.cw_done) { + else if (fsm_in.cw_psk31_done) { next_state = FSM_OISIF; } break; @@ -347,12 +345,12 @@ void fsm_update() { fsm_out.msg = "HB9G JN36BK 1628M"; } } - fsm_out.cw_trigger = 1; + fsm_out.cw_psk31_trigger = 1; if (fsm_in.sq) { next_state = FSM_OPEN2; } - else if (fsm_in.cw_done) { + else if (fsm_in.cw_psk31_done) { next_state = FSM_OISIF; } break; diff --git a/src/fsm/fsm.h b/src/fsm/fsm.h index 49853b1..ed918bc 100644 --- a/src/fsm/fsm.h +++ b/src/fsm/fsm.h @@ -63,8 +63,7 @@ struct fsm_input_signals_t { int sstv_mode; // The 1750Hz filter is disabled, permitting SSTV usage /* Signals coming from CW and PSK generator */ - int cw_done; // The CW generator has finished transmitting the message - int psk_done; // The PSK generator has finished transmitting the message + int cw_psk31_done; // The CW and PSK generator has finished transmitting the message /* Signal coming from the standing wave ratio meter */ int swr_high; // We see a lot of return power @@ -74,16 +73,16 @@ struct fsm_input_signals_t { // All signals the FSM has to control struct fsm_output_signals_t { /* Signals to the repeater electronics */ - int qrp; // Place the repeater in QRP mode - int tx_on; // Enable TX circuitry - int modulation; // Enable repeater RX to TX modulation + int qrp; // Place the repeater in QRP mode + int tx_on; // Enable TX circuitry + int modulation; // Enable repeater RX to TX modulation /* Signals to the CW and PSK generator */ - const char* msg; // The message to transmit - int msg_frequency; // What audio frequency for the CW or PSK message - int cw_dit_duration;// CW speed, dit duration in ms - int cw_trigger; // Set to true to trigger a CW transmission - int psk_trigger; // Set to true to trigger a PSK transmission + const char* msg; // The message to transmit + int msg_frequency; // What audio frequency for the CW or PSK message + int cw_dit_duration; // CW speed, dit duration in ms + int cw_psk31_trigger; // Set to true to trigger a CW or PSK31 transmission. + // PSK31 is sent if cw_dit_duration is 0 }; // Initialise local structures diff --git a/src/fsm/main.c b/src/fsm/main.c index e901c5d..f50e144 100644 --- a/src/fsm/main.c +++ b/src/fsm/main.c @@ -61,12 +61,6 @@ static void launcher_task(void *pvParameters); // Audio callback function static void audio_callback(void* context, int select_buffer); -struct cw_msg_s { - const char* msg; - int freq; - int dit_duration; -}; - void vApplicationStackOverflowHook( TaskHandle_t xTask, signed char *pcTaskName ) { @@ -242,7 +236,6 @@ static struct fsm_input_signals_t fsm_input; static void exercise_fsm(void *pvParameters) { int cw_last_trigger = 0; - int psk31_last_trigger = 0; int last_tm_trigger = 0; fsm_input.humidity = 0; @@ -259,9 +252,9 @@ static void exercise_fsm(void *pvParameters) fsm_input.sq = fsm_input.carrier; // TODO clarify - fsm_input.cw_done = !cw_psk31_busy(); + fsm_input.cw_psk31_done = !cw_psk31_busy(); - if (fsm_input.cw_done) { + if (fsm_input.cw_psk31_done) { GPIO_ResetBits(GPIOD, GPIOD_BOARD_LED_ORANGE); } else { @@ -279,16 +272,10 @@ static void exercise_fsm(void *pvParameters) pio_set_led_grn(fsm_input.carrier); // Add message to CW generator only on rising edge of trigger - if (fsm_out.cw_trigger && !cw_last_trigger) { + if (fsm_out.cw_psk31_trigger && !cw_last_trigger) { cw_psk31_push_message(fsm_out.msg, fsm_out.cw_dit_duration, fsm_out.msg_frequency); } - cw_last_trigger = fsm_out.cw_trigger; - - // Same for PSK31 - if (fsm_out.psk_trigger && !psk31_last_trigger) { - cw_psk31_push_message(fsm_out.msg, 0, fsm_out.msg_frequency); - } - psk31_last_trigger = fsm_out.psk_trigger; + cw_last_trigger = fsm_out.cw_psk31_trigger; } } |