12#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_watchdog)
13#define WDT_NODE DT_COMPAT_GET_ANY_STATUS_OKAY(st_stm32_watchdog)
15#error "IWDG is not available. Check the device tree configuration"
18const struct device *
v_bat_dev = DEVICE_DT_GET(DT_ALIAS(vbat));
20const struct gpio_dt_spec
led0 = GPIO_DT_SPEC_GET(DT_ALIAS(
led0), gpios);
21const struct gpio_dt_spec
led1 = GPIO_DT_SPEC_GET(DT_ALIAS(
led1), gpios);
24 .frequency = 10000000,
25 .operation = SPI_OP_MODE_MASTER | SPI_TRANSFER_MSB | SPI_WORD_SET(8) |
26 SPI_LINES_SINGLE | SPI_FULL_DUPLEX | SPI_FRAME_FORMAT_MOTOROLA,
27 .cs = {.gpio = {.port =
nullptr, .pin = 0, .dt_flags = 0}, .delay = 0}};
30 GPIO_DT_SPEC_GET(DT_NODELABEL(
radio_cs), gpios);
33 GPIO_DT_SPEC_GET(DT_NODELABEL(
radio_rst), gpios);
36 GPIO_DT_SPEC_GET(DT_NODELABEL(en_ext_clk), gpios);
40 .operation = SPI_OP_MODE_MASTER | SPI_TRANSFER_MSB | SPI_WORD_SET(8) |
41 SPI_LINES_SINGLE | SPI_FULL_DUPLEX | SPI_FRAME_FORMAT_MOTOROLA,
42 .cs = {.gpio = SPI_CS_GPIOS_DT_SPEC_GET(DT_NODELABEL(
fpga_spi)),
44const struct device *
fpga_spi_dev = DEVICE_DT_GET(DT_NODELABEL(spi2));
47 GPIO_DT_SPEC_GET(DT_NODELABEL(
fpga_done), gpios);
49#if DT_NODE_EXISTS(DT_NODELABEL(fpga_boot_sel0)) && \
50 DT_NODE_EXISTS(DT_NODELABEL(fpga_boot_sel1))
51const struct gpio_dt_spec fpga_boot_sel1 =
52 GPIO_DT_SPEC_GET(DT_NODELABEL(fpga_boot_sel1), gpios);
53const struct gpio_dt_spec fpga_boot_sel0 =
54 GPIO_DT_SPEC_GET(DT_NODELABEL(fpga_boot_sel0), gpios);
58 GPIO_DT_SPEC_GET(DT_NODELABEL(
p5v_rf_en), gpios);
61const struct device *
sens_i2c = DEVICE_DT_GET(DT_ALIAS(sensorsi2c));
64 GPIO_DT_SPEC_GET(DT_NODELABEL(
can1_en), gpios);
68 GPIO_DT_SPEC_GET(DT_NODELABEL(
can2_en), gpios);
73 GPIO_DT_SPEC_GET(DT_NODELABEL(
p5v_rf_pg), gpios);
77#if DT_NODE_EXISTS(DT_NODELABEL(p3v3_rf_pg))
79 GPIO_DT_SPEC_GET(DT_NODELABEL(
p3v3_rf_pg), gpios);
81const struct gpio_dt_spec
p3v3_rf_pg = {.port =
nullptr, 0, 0};
85 GPIO_DT_SPEC_GET(DT_NODELABEL(
en_uhf), gpios);
87 GPIO_DT_SPEC_GET(DT_NODELABEL(
uhf_pgood), gpios);
89 GPIO_DT_SPEC_GET(DT_NODELABEL(
en_sband), gpios);
94 GPIO_DT_SPEC_GET(DT_NODELABEL(
en_agc_uhf), gpios);
101 GPIO_DT_SPEC_GET(DT_NODELABEL(
mixer_rst), gpios);
103 GPIO_DT_SPEC_GET(DT_NODELABEL(
mixer_enx), gpios);
105 GPIO_DT_SPEC_GET(DT_NODELABEL(
mixer_scl), gpios);
107 GPIO_DT_SPEC_GET(DT_NODELABEL(
mixer_sda), gpios);
117 GPIO_DT_SPEC_GET(DT_NODELABEL(
emmc_en), gpios);
119 GPIO_DT_SPEC_GET(DT_NODELABEL(
emmc_sel), gpios);
121 GPIO_DT_SPEC_GET(DT_NODELABEL(
emmc_rst), gpios);
123static const struct adc_dt_spec adc_1_16 =
124 ADC_DT_SPEC_GET_BY_NAME(DT_PATH(zephyr_user), imon_3v3_d);
125static const struct adc_dt_spec adc_3_0 =
126 ADC_DT_SPEC_GET_BY_NAME(DT_PATH(zephyr_user), imon_5v_rf);
127static const struct adc_dt_spec adc_3_1 =
128 ADC_DT_SPEC_GET_BY_NAME(DT_PATH(zephyr_user), imon_5v_fpga);
130const struct device *
dac1 = DEVICE_DT_GET(DT_NODELABEL(
dac1));
136radio_trx_irq_handler(
struct k_work *item)
144radio_trx_irq_callback(
const struct device *dev,
struct gpio_callback *cb,
152static struct k_work_q asynq_workq;
163#if DT_NODE_EXISTS(DT_NODELABEL(fpga_boot_sel0)) && \
164 DT_NODE_EXISTS(DT_NODELABEL(fpga_boot_sel1))
215static adc_bsp adc_imon_3v3_d(adc_1_16);
216static adc_bsp adc_imon_5v_rf(adc_3_0);
217static adc_bsp adc_imon_5v_fpga(adc_3_1);
222 CONFIG_R_LIM_5V_FPGA);
225 .rf_5v_en = gpio_p5v_rf,
226 .fpga_5v_en = gpio_p5v_fpga,
227 .can1_en = gpio_can1_en,
228 .can1_low_pwr = gpio_can1_low_pwr,
229 .can2_en = gpio_can2_en,
230 .can2_low_pwr = gpio_can2_low_pwr,
231 .rf_5v_pgood = gpio_rf_5v_pgood,
232 .fpga_5v_pgood = gpio_fpga_5v_pgood,
233 .uhf_en = gpio_en_uhf,
234 .uhf_pgood = gpio_uhf_pgood,
235 .sband_en = gpio_en_sband,
236 .sband_pgood = gpio_sband_pgood,
237 .imon_3v3_d = adc_imon_3v3_d,
238 .imon_5v_rf = adc_imon_5v_rf,
239 .imon_fpga = adc_imon_5v_fpga,
242 .efuse_adc_current_gain =
243 CONFIG_EFUSE_ADC_CURRENT_GAIN};
246static auto uhf_antenna = []() ->
auto {
248#if DT_NODE_HAS_PROP(DT_ALIAS(uhf_antenna), deploy_gpios)
251 static const struct gpio_dt_spec deploy_gpio =
252 GPIO_DT_SPEC_GET(DT_ALIAS(uhf_antenna), deploy_gpios);
253 static const struct gpio_dt_spec sense_gpio =
254 GPIO_DT_SPEC_GET(DT_ALIAS(uhf_antenna), sense_gpios);
256 static gpio_bsp deploy0(&deploy_gpio);
257 static gpio_bsp sense0(&sense_gpio);
264#elif DT_NODE_HAS_PROP(DT_ALIAS(uhf_antenna), i2c_dev)
265 static const struct device *antenna_i2c =
266 DEVICE_DT_GET(DT_PROP(DT_ALIAS(uhf_antenna), i2c_dev));
267 static i2c_bsp antenna_i2c_bsp(antenna_i2c);
270#if DT_NODE_HAS_PROP(DT_ALIAS(uhf_antenna), pwr_gpios)
271 static const struct gpio_dt_spec pwr_gpio =
272 GPIO_DT_SPEC_GET(DT_ALIAS(uhf_antenna), pwr_gpios);
278 "uhf-isis", antenna_i2c_bsp, DT_PROP(DT_ALIAS(uhf_antenna), addr), pwr);
289static auto sband_antenna = []() ->
auto {
291#if DT_NODE_HAS_PROP(DT_ALIAS(sband_antenna), deploy_gpios)
294 static const struct gpio_dt_spec deploy_gpio =
295 GPIO_DT_SPEC_GET(DT_ALIAS(sband_antenna), deploy_gpios);
296 static const struct gpio_dt_spec sense_gpio =
297 GPIO_DT_SPEC_GET(DT_ALIAS(sband_antenna), sense_gpios);
299 static gpio_bsp deploy0(&deploy_gpio);
300 static gpio_bsp sense0(&sense_gpio);
307#elif DT_NODE_HAS_PROP(DT_ALIAS(sband_antenna), i2c_dev)
322 .en_agc = gpio_en_agc_uhf,
326 .flt_sel = gpio_flt_sel_uhf};
330 .flt_sel = gpio_flt_sel_sband,
331 .mixer_clk = gpio_mixer_scl,
332 .mixer_rst = gpio_mixer_rst,
333 .mixer_enx = gpio_mixer_enx,
334 .mixer_sda = gpio_mixer_sda,
338 .nreset = radio_nrst,
339 .en_ext_clk = radio_en_ext_clk,
345 .emmc_sel = gpio_emmc_sel,
346 .emmc_rst = gpio_emmc_rst,
352 .alert_t_pa_uhf = gpio_alert_uhf_pa_temp,
353 .alert_t_pa_sband = gpio_alert_sband_pa_temp,
356 .fpga_done = gpio_fpga_done,
359 .uhf_antenna = uhf_antenna,
360 .sband_antenna = sband_antenna};
366 log.log(
"Unhandled exception");
368 if (std::current_exception()) {
369 std::rethrow_exception(std::current_exception());
374 }
catch (
const etl::exception &e) {
376 }
catch (
const std::exception &e) {
394 const struct device *hw_wdt_dev = DEVICE_DT_GET_OR_NULL(WDT_NODE);
395 int ret = task_wdt_init(hw_wdt_dev);
398 log.log(
"Failed to initialize the Task Watchdog");
402 (
void *)k_current_get());
408 task_wdt_feed(m_wdgid);
411 SET_BIT(PWR->CR3, PWR_CR3_VBE);
412 SET_BIT(PWR->CR3, PWR_CR3_VBRS);
417 const k_work_queue_config cfg = {.name =
"asynq_workq", .no_yield = 0};
418 k_work_queue_start(&asynq_workq, async_workq_stack,
419 K_THREAD_STACK_SIZEOF(async_workq_stack),
420 CONFIG_ASYNC_WORKQUEUE_PRIO, &cfg);
452 param::UHF_AGC0_RANGE_MAX>()},
457 .get<settings::param::UHF_GAIN0_RANGE_MAX>()},
460 param::UHF_AGC0_CALIB_SLOPE>(),
464 param::UHF_AGC0_CALIB_INTRCPT>()},
469 .get<settings::param::UHF_GAIN0_CALIB_INTRCPT>()}},
475 .get<settings::param::SBAND_RX_RANGE_MAX>()},
480 .get<settings::param::SBAND_TX_RANGE_MAX>()},
485 .get<settings::param::SBAND_AGC0_RANGE_MAX>()},
500 SBAND_GAIN0_CALIB_INTRCPT>()}},
501 .uhf_len = {.tx = CONFIG_UHF_TX_FRAME_LEN,
502 .rx = CONFIG_UHF_RX_FRAME_LEN},
503 .sband_len = {.tx = CONFIG_SBAND_TX_FRAME_LEN,
504 .rx = CONFIG_SBAND_RX_FRAME_LEN},
506 {{{.freq = {2270000000, 2290000000}, .lo = 182000000},
507 {.freq = {2200000000, 2270000000}, .lo = 216000000}}},
509 {{{.freq = {2025000000, 2070000000}, .lo = 390000000},
510 {.freq = {2070000000, 2110000000}, .lo = 369000000}}},
532 auto &fpga = board.fpga();
549 task_wdt_feed(m_wdgid);
556 task_wdt_feed(m_wdgid);
566 gpio_pin_interrupt_configure_dt(&
radio_trx_irq, GPIO_INT_EDGE_TO_ACTIVE);
570 "All threads started succesfully!");
void start()
Starts the io_wdg. This method should be called after the board initialization process (satnogs::comm...
static io_wdg & get_instance()
Singleton access to the io_wdg subsystem.
static io & get_instance()
This class implements a simple GPIO-based antenna deployment mechanism, using for each controllable e...
This class implements the management of Antenna System2 from ISIS.
Generic antenna definition.
IO peripherals required for the control of the various subsystems of the board.
Board initialization parameters.
static void init(const io_conf &io, const params &p)
Initializes the board and creates a single instance.
static board & get_instance()
Gets a reference to the single instance of the Board interface class.
A dummy GPIO implementation with no effect. Can be used for CI testing or default construction of gpi...
Represents the I/O configuration for the power management system.
Current limit resistor configuration.
IO configuration that is necessary for the radio to operate.
static const uint16_t UHF_AGC_VOUT_DAC_CH
static int trx_irq_handler()
The IRQ handler of the AT86RF215 IRQ.
static const uint16_t SBAND_AGC_VOUT_DAC_CH
IO configuration for controlling the various peripherals of the S-Band frontend.
@ UART
UART logging output.
@ RTT
Real-Time Transfer logging (Segger RTT).
static logger & get_instance()
Singleton access to the logger subsystem.
static memory_monitor & get_instance()
Mission specific generic callback service.
void start() const
This method is called at the end of the startup::start().
static mission & get_instance()
Get a singleton access to the mission subsystem.
void pre_init() const
This method is called before the satnogs::comms::lib::board::init().
void post_init() const
This method is called after the satnogs::comms::lib::board::init().
static msg_arbiter & get_instance()
Singleton access to a unique and global msg_arbiter instance.
Store and retrieve reliably persistent settings.
static settings & get_instance()
Get a singleton access to the settings subsystem.
auto get()
Get a specific core setting from RAM shadow table.
param
Specific setting identifier.
@ SBAND_GAIN0_CALIB_SLOPE
@ SBAND_AGC0_CALIB_INTRCPT
lib::radio::clk_src radio_clk_src()
Returns the current radio clock source.
void incr_boot_cnt()
Increments the current boot count and stores it at the persistent storage.
Same as the spi_bsp but with manual control of the CS line.
struct k_work_q * workq()
void prepare()
Prepares and initializes the transceiver.
startup(startup const &)=delete
int wdg_id() const
Returns the Task Watchdog ID registered at the contructor.
void start()
Starts the execution of all the subsystems and their coressponding tasks.
static thermal & get_instance()
const struct gpio_dt_spec en_uhf
const struct gpio_dt_spec emmc_en
const struct gpio_dt_spec radio_ext_clk
const struct device * dac1
scl::rf_frontend09::io_conf rffe09_io
const struct gpio_dt_spec p5v_fpga_en
const struct gpio_dt_spec fpga_done
dac_bsp agc_vout_sband(dac1, scl::radio::SBAND_AGC_VOUT_DAC_CH, 12)
scl::board::io_conf board_io
const struct gpio_dt_spec en_sband
const struct gpio_dt_spec p5v_fpga_pg
scl::rf_frontend24::io_conf rffe24_io
const struct gpio_dt_spec p5v_rf_en
scl::power::r_lim adc_rlim(CONFIG_R_LIM_3V3_D, CONFIG_R_LIM_5V_RF, CONFIG_R_LIM_5V_FPGA)
const struct device * sens_i2c
const struct gpio_dt_spec en_agc_sband
const struct gpio_dt_spec sband_pgood
const struct gpio_dt_spec flt_sel_sband
const struct spi_config radio_spi_cfg
scl::bsp::dummy_gpio gpio_fpga_boot_sel_1
const struct gpio_dt_spec mixer_scl
const struct gpio_dt_spec emmc_rst
const struct gpio_dt_spec en_agc_uhf
const struct gpio_dt_spec alert_uhf_pa_temp
spi_bsp fpga_spi(fpga_spi_dev, fpga_spi_cfg)
const struct gpio_dt_spec can1_en
scl::radio::io_conf radio_cnf
const struct device * radio_spi_dev
const struct gpio_dt_spec radio_cs
sensor_bsp v_bat(v_bat_dev)
struct k_work radio_trx_irq_work
const struct gpio_dt_spec can2_low_pwr
const struct device * fpga_spi_dev
void task_wdt_callback(int channel_id, void *user_data)
scl::power::io_conf pwr_cnf
const struct gpio_dt_spec radio_rst
const struct device * v_bat_dev
const struct gpio_dt_spec led1
const struct gpio_dt_spec mixer_rst
const struct gpio_dt_spec flt_sel_uhf
const struct gpio_dt_spec can2_en
struct gpio_callback radio_trx_irq_clbk_h
K_THREAD_STACK_DEFINE(radio_rx_thread_stack, CONFIG_RADIO_RX_THREAD_STACK_SIZE)
scl::bsp::dummy_gpio gpio_fpga_boot_sel_0
dac_bsp agc_vout_uhf(dac1, scl::radio::UHF_AGC_VOUT_DAC_CH, 12)
const struct gpio_dt_spec alert_sband_pa_temp
const struct gpio_dt_spec uhf_pgood
const struct gpio_dt_spec can1_low_pwr
const struct gpio_dt_spec led0
const struct gpio_dt_spec mixer_enx
const struct gpio_dt_spec radio_trx_irq
spi_manual_cs_bsp radio_spi(radio_spi_dev, radio_spi_cfg, &radio_cs)
i2c_bsp sensors_i2c(sens_i2c)
const struct gpio_dt_spec mixer_sda
const struct gpio_dt_spec p3v3_rf_pg
const struct gpio_dt_spec emmc_sel
const struct spi_config fpga_spi_cfg
void unhandled_exception()
const struct gpio_dt_spec p5v_rf_pg