2021-04-05 19:18:30 +00:00
|
|
|
/*
|
|
|
|
* uSDR.c
|
|
|
|
*
|
|
|
|
* Created: Mar 2021
|
|
|
|
* Author: Arjan te Marvelde
|
|
|
|
*
|
|
|
|
* The main loop of the application.
|
|
|
|
* This initializes the units that do the actual work, and then loops in the background.
|
|
|
|
* Other units are:
|
|
|
|
* - dsp.c, containing all signal processing in RX and TX branches. This part runs on the second processor core.
|
|
|
|
* - si5351.c, containing all controls for setting up the si5351 clock generator.
|
|
|
|
* - lcd.c, contains all functions to put something on the LCD
|
|
|
|
* - hmi.c, contains all functions that handle user inputs
|
|
|
|
*/
|
|
|
|
|
2021-04-03 19:39:24 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "pico/stdlib.h"
|
|
|
|
#include "hardware/pio.h"
|
|
|
|
#include "hardware/timer.h"
|
|
|
|
#include "hardware/clocks.h"
|
|
|
|
|
|
|
|
#include "lcd.h"
|
|
|
|
#include "dsp.h"
|
|
|
|
#include "si5351.h"
|
2021-04-05 19:18:30 +00:00
|
|
|
#include "monitor.h"
|
2021-04-03 19:39:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
uint8_t display1[16];
|
|
|
|
uint8_t display2[16];
|
|
|
|
|
|
|
|
|
|
|
|
/* LED TIMER definition and callback */
|
|
|
|
struct repeating_timer led_timer;
|
|
|
|
bool led_callback(struct repeating_timer *t)
|
|
|
|
{
|
|
|
|
static bool led_state;
|
|
|
|
|
|
|
|
gpio_put(PICO_DEFAULT_LED_PIN, led_state);
|
|
|
|
led_state = (led_state?false:true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Initialize LED pin output */
|
|
|
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
|
|
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
|
|
|
gpio_put(PICO_DEFAULT_LED_PIN, true); // Set LED on
|
|
|
|
add_repeating_timer_ms(-1000, led_callback, NULL, &led_timer);
|
|
|
|
|
2021-04-05 19:18:30 +00:00
|
|
|
/* Initialize units */
|
|
|
|
si_init(); // VFO control unit
|
|
|
|
lcd_init(); // LCD output unit
|
|
|
|
dsp_init(); // Signal processing unit
|
2021-04-07 20:13:13 +00:00
|
|
|
mon_init();
|
2021-04-03 19:39:24 +00:00
|
|
|
|
|
|
|
SI_SETFREQ(0, 2*7074000UL); // Set freq to 2*7074 kHz
|
2021-04-05 19:18:30 +00:00
|
|
|
SI_SETPHASE(0,2); // Set phase to 180deg
|
2021-04-07 20:13:13 +00:00
|
|
|
si_evaluate(); // Commit setting
|
|
|
|
|
|
|
|
lcd_test(); // Test LCD character set
|
|
|
|
|
|
|
|
lcd_ctrl(LCD_GOTO, 0, 0);
|
|
|
|
sprintf(display1, " 7074.0 kHz");
|
|
|
|
lcd_write(display1,11);
|
|
|
|
lcd_ctrl(LCD_GOTO, 1, 0);
|
|
|
|
lcd_ctrl(LCD_CURSOR, 1, 0);
|
2021-04-03 19:39:24 +00:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
/* Check for monitor input */
|
2021-04-05 19:18:30 +00:00
|
|
|
mon_read(100000L); // Wait max 100msec
|
2021-04-03 19:39:24 +00:00
|
|
|
|
|
|
|
/* Check whether VFO settings have changed */
|
2021-04-05 19:18:30 +00:00
|
|
|
si_evaluate();
|
2021-04-03 19:39:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|