Merge pull request #266 from alanbjohnston/pico-v0.40-bus2

Pico v0.40 bus2
pull/267/head
alanbjohnston 3 years ago committed by GitHub
commit 556aacdc9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -376,6 +376,7 @@ bool voltage_read = false;
bool ina219_started = false;
bool camera_detected = false;
bool rotate_flag = true;
bool clockgen_present = false;
int led_builtin_pin;

@ -90,6 +90,22 @@ void setup() {
set_sys_clock_khz(133000, true);
Serial.begin(115200);
config_gpio();
/**/
if (check_for_wifi()) {
wifi = true;
led_builtin_pin = LED_BUILTIN; // use default GPIO for Pico W
pinMode(LED_BUILTIN, OUTPUT);
// configure_wifi();
} else {
led_builtin_pin = 25; // manually set GPIO 25 for Pico board
// pinMode(25, OUTPUT);
pinMode(led_builtin_pin, OUTPUT);
}
/**/
blink(50);
delay(10000);
@ -108,25 +124,18 @@ void setup() {
// otherwise, run CubeSatSim Pico code
Serial.println("CubeSatSim Pico v0.41 starting...\n");
Serial.println("CubeSatSim Pico v0.41 starting...\n");
/**/
if (check_for_wifi()) {
wifi = true;
led_builtin_pin = LED_BUILTIN; // use default GPIO for Pico W
pinMode(LED_BUILTIN, OUTPUT);
// configure_wifi();
} else {
led_builtin_pin = 25; // manually set GPIO 25 for Pico board
// pinMode(25, OUTPUT);
pinMode(led_builtin_pin, OUTPUT);
}
/**/
config_gpio();
//// config_gpio();
get_input();
if (wifi)
Serial.println("\nPico W detected!\n");
else
Serial.println("\nPico detected!\n");
start_clockgen();
EEPROM.begin(512);
@ -549,7 +558,7 @@ void transmit_on() {
ret = clockgen.enableOutputs(true);
Serial.println("Enable clock outputs!");
}
*/
*/ if (clockgen_present) {
if (clockgen.enableOutputs(true)) {
start_clockgen();
if (mode == BPSK)
@ -561,6 +570,7 @@ void transmit_on() {
} else {
Serial.println("Enable clock outputs");
}
}
}
else if (mode == CW) {
// Serial.println("Transmit on!");
@ -589,7 +599,7 @@ void transmit_off() {
Serial.println("Disable clock outputs!");
}
// clockgen.enableOutputs(false)
*/
*/ if (clockgen_present) {
if (clockgen.enableOutputs(false)) {
start_clockgen();
clockgen.enableOutputs(false);
@ -597,6 +607,7 @@ void transmit_off() {
} else {
Serial.println("Disable clock outputs");
}
}
}
else if (mode == SSTV)
@ -2222,7 +2233,8 @@ void config_radio()
if (sr_frs_present)
digitalWrite(PD_PIN, HIGH); // Enable SR_FRS
else {
start_clockgen();
start_clockgen();
if (clockgen_present) {
if (clockgen.setClockFSK(frequency_offset)) {
start_clockgen();
clockgen.setClockFSK(frequency_offset);
@ -2233,7 +2245,8 @@ void config_radio()
digitalWrite(PD_PIN, LOW); // disable SR_FRS
clockgen.enableOutputs(false);
digitalWrite(BPSK_CONTROL_B, LOW);
digitalWrite(BPSK_CONTROL_A, LOW);
digitalWrite(BPSK_CONTROL_A, LOW);
}
}
@ -2246,7 +2259,7 @@ void config_radio()
Serial.println("Config clock for BPSK");
}
*/
if (clockgen_present) {
if (clockgen.setClockBPSK(frequency_offset)) {
start_clockgen();
clockgen.setClockBPSK(frequency_offset);
@ -2254,6 +2267,7 @@ void config_radio()
} else {
Serial.println("Config clock for BPSK");
}
}
transmit_on();
}
else if (mode == FSK) {// || (mode == SSTV))
@ -2264,14 +2278,15 @@ void config_radio()
ret = clockgen.setClockFSK();
Serial.println("Config clock for FSK");
}
*/
*/ if (clockgen_present) {
if (clockgen.setClockFSK(frequency_offset)) {
start_clockgen();
clockgen.setClockFSK(frequency_offset);
Serial.println("Config clock for FSK");
} else {
Serial.println("Config clock for FSK");
}
}
}
transmit_on();
}
@ -2371,7 +2386,7 @@ void read_ina219()
loadvoltage = busvoltage + (shuntvoltage / 1000);
if ((debug_mode) || (voltage_read)) {
Serial.print("+Bat (1 0x44) Voltage: ");
Serial.print("Bat (1 0x44) Voltage: ");
Serial.print(loadvoltage);
Serial.print("V Current: ");
Serial.print(current_mA);
@ -3720,6 +3735,7 @@ void config_gpio() {
Serial.println(digitalRead(PI_3V3_PIN));
if (digitalRead(PI_3V3_PIN) == HIGH) {
// {
delay(10000);
Serial.print("Pi Zero present, so running Payload OK code instead of CubeSatSim code.");
start_payload();
while(true) {
@ -3952,11 +3968,11 @@ bool check_for_wifi() {
// if (result < 0x100) {
if (result < 0x10) {
Serial.println("\nPico W detected!\n");
// Serial.println("\nPico W detected!\n");
return(true);
}
else {
Serial.println("\nPico detected!\n");
// Serial.println("\nPico detected!\n");
return(false);
}
}
@ -4098,14 +4114,19 @@ void transmit_cw(int freq, float duration) { // freq in Hz, duration in millise
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);
// clockgen.enableOutputs(true);
if (clockgen_present) {
clockgen.enableOutputOnly(0);
digitalWrite(BPSK_CONTROL_A, HIGH);
}
while((micros() - start) < duration_us) { }
digitalWrite(BPSK_CONTROL_A, LOW);
clockgen.enableOutputs(false);
if (clockgen_present) {
digitalWrite(BPSK_CONTROL_A, LOW);
clockgen.enableOutputs(false);
}
}
// if (!wifi)
@ -4134,18 +4155,25 @@ void transmit_callsign(char *callsign) {
print_string(id);
if (!sr_frs_present) {
start_clockgen();
if (clockgen.setClockFSK(frequency_offset)) {
start_clockgen();
clockgen.setClockFSK(frequency_offset);
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);
// Serial.println("before start");
// start_clockgen();
// Serial.println("after start");
if (clockgen_present) {
if (clockgen.setClockFSK(frequency_offset)) {
start_clockgen();
if (clockgen_present)
clockgen.setClockFSK(frequency_offset);
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
if (clockgen_present) {
clockgen.enableOutputs(false);
digitalWrite(BPSK_CONTROL_B, LOW);
digitalWrite(BPSK_CONTROL_A, LOW);
}
}
/*
if (reset_count == 0) {
@ -5020,6 +5048,7 @@ void write_mode(int save_mode) {
}
void start_clockgen() {
clockgen_present = false;
Wire1.setSDA(2);
Wire1.setSCL(3);
@ -5036,18 +5065,22 @@ void start_clockgen() {
Serial.println("No Si5351 detected on bus 2 ... Check your wiring or I2C ADDR!");
clockgen.begin(&Wire); // go back to Wire so that it doesn't lock up with no clockgen
return;
} else
} else {
Serial.println("Si5351 detected on bus 2");
clockgen_present = true;
}
} else
} else {
Serial.println("Si5351 detected on bus 1");
clockgen_present = true;
}
Serial.println("Starting clockgen frequency 434.9 MHz");
if (clockgen_present) {
Serial.println("Starting clockgen frequency 434.9 MHz");
// clockgen.setClockFSK(); // default to FSK
clockgen.enableOutputs(false);
clockgen.enableOutputs(false);
}
}
void get_input() {

Loading…
Cancel
Save

Powered by TurnKey Linux.