85 lines
1.8 KiB
C++
85 lines
1.8 KiB
C++
/*
|
|
* Author: klaute -Kai Lauterbach - @kailauterbach - me@klaute.de
|
|
* Date: 09/2016
|
|
* License: GPLv3
|
|
*/
|
|
|
|
#include <si5351.h>
|
|
#include "Wire.h"
|
|
|
|
extern "C" {
|
|
#include "globals.h"
|
|
}
|
|
|
|
Si5351 si5351;
|
|
|
|
uint32_t start_freq = 10000;
|
|
uint32_t end_freq = 50000000;
|
|
uint32_t step_freq = 1000000; // 1 MHz default step size
|
|
uint16_t intervall = 1000; // intervall to change the frequency as milli seconds
|
|
enum si5351_drive drive_str = SI5351_DRIVE_2MA;
|
|
|
|
void setup()
|
|
{
|
|
// manage the analog pins
|
|
pinMode(A0, INPUT); // forward SWR measurement
|
|
pinMode(A1, INPUT); // backward SWR measurement
|
|
pinMode(A2, OUTPUT);
|
|
pinMode(A3, OUTPUT);
|
|
pinMode(A6, OUTPUT);
|
|
pinMode(A7, OUTPUT);
|
|
|
|
digitalWrite(A2, LOW);
|
|
digitalWrite(A3, LOW);
|
|
digitalWrite(A6, LOW);
|
|
digitalWrite(A7, LOW);
|
|
|
|
// Init the serial connection
|
|
Serial.begin(115200);
|
|
|
|
// initialize the command control module
|
|
cc_init();
|
|
|
|
// init the Si5351
|
|
si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0);
|
|
|
|
si5351.set_pll(SI5351_PLL_FIXED, SI5351_PLLA);
|
|
|
|
si5351.output_enable(SI5351_CLK0, 0); // disable clock output 0
|
|
si5351.output_enable(SI5351_CLK1, 0); // disable clock output 1
|
|
si5351.output_enable(SI5351_CLK2, 0); // disable clock output 2
|
|
|
|
analogReference(DEFAULT); // 5V reference
|
|
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
// Read the Status Register and print it every 10 seconds
|
|
si5351.update_status();
|
|
|
|
/*
|
|
Serial.print("SYS_INIT: ");
|
|
Serial.print(si5351.dev_status.SYS_INIT);
|
|
Serial.print(" LOL_A: ");
|
|
Serial.print(si5351.dev_status.LOL_A);
|
|
Serial.print(" LOL_B: ");
|
|
Serial.print(si5351.dev_status.LOL_B);
|
|
Serial.print(" LOS: ");
|
|
Serial.print(si5351.dev_status.LOS);
|
|
Serial.print(" REVID: ");
|
|
Serial.println(si5351.dev_status.REVID);
|
|
*/
|
|
|
|
if (Serial.available() > 0)
|
|
{
|
|
uint8_t c = Serial.read() & 0xff;
|
|
|
|
cc_processData(c);
|
|
}
|
|
|
|
//cc_abort();
|
|
|
|
delay(100);
|
|
}
|
|
|