From 57164d49fab7bdf0c2da883b12bf352d0db1151f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 18 Sep 2022 16:01:54 -0400 Subject: [PATCH] changed to start_clockgen --- cubesatsim/cubesatsim.ino | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 8780c3bf..668316fd 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -490,12 +490,18 @@ void transmit_on() { Serial.println("Transmit on!!!"); // pwm_set_gpio_level(BPSK_PWM_A_PIN, (config.top + 1) * 0.5); // pwm_set_gpio_level(BPSK_PWM_B_PIN, (config.top + 1) * 0.5); +/* int ret = 1; int i = 0; while ((i++ < 5) && (ret != 0)) { ret = clockgen.enableOutputs(true); Serial.println("Enable clock outputs!"); - } + } +*/ + if (!clockgen.enableOutputs(trie)) { + start_clockgen(); + clockgen.enableOutputs(true); + } } else if (mode == CW) { // Serial.println("Transmit on!"); @@ -515,6 +521,7 @@ void transmit_off() { digitalWrite(BPSK_CONTROL_B, LOW); // pwm_set_gpio_level(BPSK_PWM_A_PIN, 0); // pwm_set_gpio_level(BPSK_PWM_B_PIN, 0); +/* int ret = 1; int i = 0; while ((i++ < 5) && (ret != 0)) { @@ -522,6 +529,12 @@ void transmit_off() { Serial.println("Disable clock outputs!"); } // clockgen.enableOutputs(false) +*/ + if (!clockgen.enableOutputs(false)) { + start_clockgen(); + clockgen.enableOutputs(false); + } + } else if (mode == SSTV) sstv_end(); @@ -2126,24 +2139,34 @@ void config_radio() program_radio(); } else if (mode == BPSK) { - +/* int ret = 1; int i = 0; while ((i++ < 5) && (ret != 0)) { ret = clockgen.setClockBPSK(); Serial.println("Config clock for BPSK"); } +*/ + if (!clockgen.setClockBPSK()) { + start_clockgen(); + clockgen.setClockBPSK(); + } transmit_on(); } else if (mode == FSK) {// || (mode == SSTV)) - +/* int ret = 1; int i = 0; while ((i++ < 5) && (ret != 0)) { ret = clockgen.setClockFSK(); Serial.println("Config clock for FSK"); - } + } +*/ + if (!clockgen.setClockFSK()) { + start_clockgen(); + clockgen.setClockFSK(); + } transmit_on(); } }