/* This is the use of the Xiao RP2040 and the Si5351 for a BFO for the TR3
*
*
*
*
*
*
*/
#include "xiaoRP2040pinNums.h" // Or use the device pin numbers with "u" suffix.
#include <Wire.h>
#include "si5351.h"
#define i2cSDA D4
#define i2cSCL D5
// Values in whole integer Hz
uint32_t bfo = 8998500; // Declared as a 32-bit unsigned integer
Si5351 si5351;
////========================================
////******** FUNCTION: setup ***************
////========================================
void setup() {
Serial.begin(57600);
Wire.begin();
// Initialize the Si5351
si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0, 0);
// Set Si5351 Clocks
si5351.set_freq(bfo* 100, SI5351_CLK2); // in integer hundredths of Hz (whole Hz times 100)
si5351.set_correction(1000,SI5351_PLL_INPUT_XO);
si5351.drive_strength(SI5351_CLK2,SI5351_DRIVE_8MA);
pinMode(2u, INPUT_PULLUP); // usb/Lsb select
}
// End of setup()
//========================================
//********* FUNCTION: (main)loop *********
//========================================
void loop() { // Empty
checkSideband();
}
//********************* Check Sideband********************
void checkSideband(){
if(digitalRead(2u)){ //********If SW is true do the following.
bfo = 8998500L;
if (bfo = 8998500L);
si5351.set_freq( bfo*100, SI5351_CLK2);
}
else{ //**********if not, do this.
bfo = 9001500L;
si5351.set_freq( bfo*100, SI5351_CLK2);
}
}