Merge pull request #250 from alanbjohnston/pico

Pico
pull/251/head
alanbjohnston 3 years ago committed by GitHub
commit e66cd24b1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -381,6 +381,7 @@ RPI_PICO_Timer ITimer1(1);
bool timer0_on = false; bool timer0_on = false;
volatile int timer_counter; volatile int timer_counter;
bool filter_present = false; // BPF installation state for transmitter bool filter_present = false; // BPF installation state for transmitter
bool sr_frs_present = false; // SR_FRS FM transmitter module state
char callsign[20]; char callsign[20];
int morse_timing = 60; // ms for a dit int morse_timing = 60; // ms for a dit

@ -474,7 +474,8 @@ void send_aprs_packet() {
} }
void send_cw() { void send_cw() {
if (filter_present) { // only transmit CW packet if BPF filter is present // if (filter_present)
{ // only transmit CW packet if BPF filter is present
char de[] = " DE "; char de[] = " DE ";
char telem[1000]; char telem[1000];
@ -506,7 +507,7 @@ void transmit_on() {
if (debug_mode) if (debug_mode)
Serial.println("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_A_PIN, (config.top + 1) * 0.5);
// pwm_set_gpio_level(BPSK_PWM_B_PIN, (config.top + 1) * 0.5); // pwm_set__level(BPSK_PWM_B_PIN, (config.top + 1) * 0.5);
/* /*
int ret = 1; int ret = 1;
int i = 0; int i = 0;
@ -2165,12 +2166,31 @@ void config_radio()
pinMode(TEMPERATURE_PIN, INPUT); pinMode(TEMPERATURE_PIN, INPUT);
pinMode(AUDIO_IN_PIN, INPUT); pinMode(AUDIO_IN_PIN, INPUT);
*/ */
if ((mode == AFSK) || (mode == SSTV) || (mode == CW)) { if ((mode == AFSK) || (mode == SSTV)) {
digitalWrite(PD_PIN, HIGH); // Enable SR_FRS digitalWrite(PD_PIN, HIGH); // Enable SR_FRS
// pinMode(AUDIO_OUT_PIN, OUTPUT); // pinMode(AUDIO_OUT_PIN, OUTPUT);
// program_radio(); // remove for now // program_radio(); // remove for now
} else if (mode == CW) {
if (sr_frs_present)
digitalWrite(PD_PIN, HIGH); // Enable SR_FRS
else {
start_clockgen();
if (clockgen.setClockFSK()) {
start_clockgen();
clockgen.setClockFSK();
Serial.println("Config clock for CW without SR_FRS!");
} else {
Serial.println("Config clock for CW without SR_FRS");
}
digitalWrite(PD_PIN, LOW); // disable SR_FRS
clockgen.enableOutputs(false);
digitalWrite(BPSK_CONTROL_B, LOW);
digitalWrite(BPSK_CONTROL_A, LOW);
}
} else if (mode == BPSK) { } else if (mode == BPSK) {
/* /*
int ret = 1; int ret = 1;
@ -3530,16 +3550,20 @@ void config_gpio() {
// pinMode(SQUELCH, INPUT); // Squelch from TXC // pinMode(SQUELCH, INPUT); // Squelch from TXC
if (digitalRead(BPF_PIN) == FALSE) { if (digitalRead(BPF_PIN) == FALSE) {
// if (digitalRead(BPF_PIN) == FALSE) { // force BPF present
Serial.println("BPF present - transmit enabled"); Serial.println("BPF present - transmit enabled");
filter_present = true; filter_present = true;
} }
else else
Serial.println("BPF not present - no transmitting after CW ID"); Serial.println("BPF not present - no transmitting after CW ID");
if (digitalRead(TXC_PIN) == FALSE) if (digitalRead(TXC_PIN) == FALSE) {
Serial.println("TXC present"); // if (digitalRead(TXC_PIN) != FALSE) { // force SR_FRS not present
Serial.println("SR_FRS present");
sr_frs_present = true;
}
else else
Serial.println("TXC not present"); Serial.println("SR_FRS not present");
// Serial.print("Squelch: "); // Serial.print("Squelch: ");
// Serial.println(digitalRead(SQUELCH)); // Serial.println(digitalRead(SQUELCH));
@ -3584,14 +3608,14 @@ bool TimerHandler0(struct repeating_timer *t) {
// delayMicroseconds(10); // delayMicroseconds(10);
digitalWrite(BPSK_CONTROL_A, HIGH); digitalWrite(BPSK_CONTROL_A, HIGH);
// Serial.print("-"); // Serial.print("-");
// clockgen.enableOutputOnly(1); if (mode == FSK) clockgen.enableOutputOnly(1);
} else { } else {
// digitalWrite(BPSK_CONTROL_A, LOW); // digitalWrite(BPSK_CONTROL_A, LOW);
digitalWrite(BPSK_CONTROL_A, LOW); digitalWrite(BPSK_CONTROL_A, LOW);
// delayMicroseconds(10); // delayMicroseconds(10);
digitalWrite(BPSK_CONTROL_B, HIGH); digitalWrite(BPSK_CONTROL_B, HIGH);
// Serial.print("_"); // Serial.print("_");
// clockgen.enableOutputOnly(0); if (mode == FSK) clockgen.enableOutputOnly(0);
} }
if (wav_position > bufLen) { // 300) { if (wav_position > bufLen) { // 300) {
wav_position = wav_position % bufLen; wav_position = wav_position % bufLen;
@ -3829,8 +3853,10 @@ void transmit_cw(int freq, float duration) { // freq in Hz, duration in millise
digitalWrite(LED_BUILTIN, HIGH); // Transmit LED on digitalWrite(LED_BUILTIN, HIGH); // Transmit LED on
digitalWrite(MAIN_LED_BLUE, HIGH); digitalWrite(MAIN_LED_BLUE, HIGH);
unsigned long start = micros();
unsigned long duration_us = duration * 1000; unsigned long duration_us = duration * 1000;
if (sr_frs_present) {
unsigned long start = micros();
float period_us = (0.5E6) / (float)(freq); float period_us = (0.5E6) / (float)(freq);
bool phase = HIGH; bool phase = HIGH;
while((micros() - start) < duration_us) { while((micros() - start) < duration_us) {
@ -3840,6 +3866,18 @@ void transmit_cw(int freq, float duration) { // freq in Hz, duration in millise
sleep(min(time_left, period_us) / 1.0E6); sleep(min(time_left, period_us) / 1.0E6);
} }
digitalWrite(AUDIO_OUT_PIN, LOW); digitalWrite(AUDIO_OUT_PIN, LOW);
}
else {
// Serial.println("No sr_frs present!");
unsigned long start = micros();
// clockgen.enableOutputs(true);
clockgen.enableOutputOnly(0);
digitalWrite(BPSK_CONTROL_A, HIGH);
while((micros() - start) < duration_us) { }
digitalWrite(BPSK_CONTROL_A, LOW);
clockgen.enableOutputs(false);
}
// if (!wifi) // if (!wifi)
digitalWrite(LED_BUILTIN, LOW); // Transmit LED off digitalWrite(LED_BUILTIN, LOW); // Transmit LED off
digitalWrite(MAIN_LED_BLUE, LOW); digitalWrite(MAIN_LED_BLUE, LOW);
@ -3853,6 +3891,21 @@ void transmit_callsign(char *callsign) {
strcat(id, callsign); strcat(id, callsign);
Serial.print("Transmitting CW id: "); Serial.print("Transmitting CW id: ");
print_string(id); print_string(id);
if (!sr_frs_present) {
start_clockgen();
if (clockgen.setClockFSK()) {
start_clockgen();
clockgen.setClockFSK();
Serial.println("Config clock for CW without SR_FRS!");
} else {
Serial.println("Config clock for CW without SR_FRS");
}
digitalWrite(PD_PIN, LOW); // disable SR_FRS
clockgen.enableOutputs(false);
digitalWrite(BPSK_CONTROL_B, LOW);
digitalWrite(BPSK_CONTROL_A, LOW);
}
/* /*
if (reset_count == 0) { if (reset_count == 0) {
program_radio(); program_radio();
@ -3867,10 +3920,12 @@ void transmit_string(char *string) {
int j = 0; int j = 0;
if (debug_mode) if (debug_mode)
Serial.println("Transmit on"); Serial.println("Transmit on");
if (sr_frs_present) {
digitalWrite(PD_PIN, HIGH); // Enable SR_FRS digitalWrite(PD_PIN, HIGH); // Enable SR_FRS
digitalWrite(MAIN_LED_BLUE, HIGH);
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(PTT_PIN, LOW); digitalWrite(PTT_PIN, LOW);
}
//// digitalWrite(MAIN_LED_BLUE, HIGH);
//// digitalWrite(LED_BUILTIN, HIGH);
while ((string[j] != '\0') && (j < 256) && !cw_stop) { while ((string[j] != '\0') && (j < 256) && !cw_stop) {
// Serial.print("j = "); // Serial.print("j = ");
@ -3896,8 +3951,8 @@ void transmit_string(char *string) {
if (debug_mode) if (debug_mode)
Serial.println("Transmit off"); Serial.println("Transmit off");
digitalWrite(MAIN_LED_BLUE, LOW); //// digitalWrite(MAIN_LED_BLUE, LOW);
digitalWrite(LED_BUILTIN, LOW); //// digitalWrite(LED_BUILTIN, LOW);
digitalWrite(PTT_PIN, HIGH); digitalWrite(PTT_PIN, HIGH);
digitalWrite(PD_PIN, LOW); // disable SR_FRS digitalWrite(PD_PIN, LOW); // disable SR_FRS
} }
@ -4422,7 +4477,7 @@ void set_lat_lon() {
} }
void program_radio() { void program_radio() {
if (sr_frs_present) {
Serial.println("Programming SR_FRS!"); Serial.println("Programming SR_FRS!");
digitalWrite(PD_PIN, HIGH); // enable SR_FRS digitalWrite(PD_PIN, HIGH); // enable SR_FRS
@ -4442,6 +4497,7 @@ void program_radio() {
sleep(0.5); sleep(0.5);
mySerial.println("AT+DMOSETMIC=8,0\r"); // was 8 mySerial.println("AT+DMOSETMIC=8,0\r"); // was 8
}
} }
digitalWrite(PD_PIN, LOW); // disable SR_FRS digitalWrite(PD_PIN, LOW); // disable SR_FRS
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.