2016-09-17 20:26:03 +02:00
|
|
|
/*
|
2016-09-20 19:49:58 +02:00
|
|
|
* Author: klaute -Kai Lauterbach - @kailauterbach - me@klaute.de
|
|
|
|
* Date: 09/2016
|
|
|
|
* License: GPLv3
|
2016-09-17 20:26:03 +02:00
|
|
|
*/
|
|
|
|
|
2016-09-17 20:50:47 +02:00
|
|
|
#include <si5351.h>
|
2016-09-17 20:26:03 +02:00
|
|
|
#include "Wire.h"
|
|
|
|
|
2016-09-18 08:05:46 +02:00
|
|
|
extern "C" {
|
|
|
|
#include "globals.h"
|
|
|
|
}
|
2016-09-17 20:26:03 +02:00
|
|
|
|
|
|
|
Si5351 si5351;
|
|
|
|
|
2016-09-19 21:09:21 +02:00
|
|
|
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;
|
|
|
|
|
2016-09-17 20:26:03 +02:00
|
|
|
void setup()
|
|
|
|
{
|
2016-09-19 21:09:21 +02:00
|
|
|
pinMode(A0, INPUT);
|
|
|
|
pinMode(A1, INPUT);
|
|
|
|
|
2016-09-18 11:41:59 +02:00
|
|
|
// Init the serial connection
|
2016-09-20 13:08:56 +02:00
|
|
|
Serial.begin(115200);
|
2016-09-18 11:41:59 +02:00
|
|
|
|
|
|
|
// initialize the command control module
|
|
|
|
cc_init();
|
|
|
|
|
|
|
|
// init the Si5351
|
2016-09-17 20:26:03 +02:00
|
|
|
si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0);
|
|
|
|
|
2016-09-19 21:09:21 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
/*
|
2016-09-17 20:26:03 +02:00
|
|
|
// Set CLK0 to output 14 MHz with a fixed PLL frequency
|
|
|
|
si5351.set_pll(SI5351_PLL_FIXED, SI5351_PLLA);
|
|
|
|
si5351.set_freq(1400000000ULL, SI5351_PLL_FIXED, SI5351_CLK0);
|
|
|
|
|
|
|
|
// Set CLK1 to output 20 MHz
|
|
|
|
si5351.set_freq(2000000000ULL, 0ULL, SI5351_CLK1);
|
2016-09-17 20:50:47 +02:00
|
|
|
|
|
|
|
si5351.output_enable(SI5351_CLK0, 1); // enable clock output 0
|
|
|
|
si5351.drive_strength(SI5351_CLK0, SI5351_DRIVE_2MA); // 2 4 6 8ma
|
2016-09-19 21:09:21 +02:00
|
|
|
*/
|
2016-09-20 19:41:41 +02:00
|
|
|
//delay(500);
|
2016-09-20 18:51:20 +02:00
|
|
|
|
2016-09-20 19:41:41 +02:00
|
|
|
//Serial.println("SWR Meter firmware v0.1 by Kai Lauterbach (me@klaute.de)");
|
2016-09-17 20:26:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
// Read the Status Register and print it every 10 seconds
|
|
|
|
si5351.update_status();
|
2016-09-18 11:41:59 +02:00
|
|
|
|
|
|
|
/*
|
2016-09-17 20:26:03 +02:00
|
|
|
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);
|
2016-09-18 11:41:59 +02:00
|
|
|
*/
|
2016-09-17 20:26:03 +02:00
|
|
|
|
2016-09-18 11:41:59 +02:00
|
|
|
if (Serial.available() > 0)
|
|
|
|
{
|
|
|
|
uint8_t c = Serial.read() & 0xff;
|
2016-09-20 12:57:28 +02:00
|
|
|
//Serial.write(c); // TODO
|
2016-09-18 11:41:59 +02:00
|
|
|
cc_processData(c);
|
|
|
|
}
|
|
|
|
|
2016-09-19 22:38:37 +02:00
|
|
|
//cc_abort();
|
|
|
|
|
2016-09-18 11:41:59 +02:00
|
|
|
delay(100);
|
2016-09-17 20:26:03 +02:00
|
|
|
}
|
2016-09-18 11:41:59 +02:00
|
|
|
|