rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
main.c File Reference

The panel application: app_main, the console report and the main loop's hardware glue. More...

#include <inttypes.h>
#include <stdatomic.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "driver/gpio.h"
#include "driver/temperature_sensor.h"
#include "esp_heap_caps.h"
#include "esp_log.h"
#include "esp_random.h"
#include "esp_system.h"
#include "esp_timer.h"
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "freertos/task.h"
#include "board.h"
#include "ui_band.h"
#include "board_pins.h"
#include "can_twai.h"
#include "busfault_screen.h"
#include "can_selftest.h"
#include "selftest.h"
#include "display.h"
#include "esc_profile.h"
#include "esc_sim.h"
#include "gfx.h"
#include "arming.h"
#include "art_flash_esp.h"
#include "art_fetch.h"
#include "art_store.h"
#include "heartbeat.h"
#include "bind_link.h"
#include "kst_link.h"
#include "prog_link.h"
#include "hitec_panel.h"
#include "kst_panel.h"
#include "kst_card.h"
#include "kst_files.h"
#include "kst_prog.h"
#include "link_bringup.h"
#include "link_host.h"
#include "link_pages.h"
#include "link_port.h"
#include "link_update_host.h"
#include "log_name.h"
#include "log_select.h"
#include "log_cadence.h"
#include "log_writer.h"
#include "motor_screen.h"
#include "servo_link.h"
#include "servo_page.h"
#include "servo_screen.h"
#include "pdmini.h"
#include "sense_link.h"
#include "sense_page.h"
#include "servo_source.h"
#include "tone_link.h"
#include "supply_link.h"
#include "supply_page.h"
#include "supply_screen.h"
#include "outputs_screen.h"
#include "overview_screen.h"
#include "picker_screen.h"
#include "esc_stick_panel.h"
#include "rcbench_version.h"
#include "flash_gate.h"
#include "safety_gate.h"
#include "settings.h"
#include "settings_screen.h"
#include "settings_sensors.h"
#include "sensors_rows.h"
#include "splash_screen.h"
#include "knob.h"
#include "knob_task.h"
#include "log_viewer_screen.h"
#include "coproc_update_screen.h"
#include "storage.h"
#include "telemetry_sim.h"
#include "touch_loss.h"
#include "outputs.h"
#include "outputs_pages.h"
#include "touch.h"
#include "touch_map.h"
#include "fw_install.h"
#include "fw_ota.h"
#include "fw_release.h"
#include "fw_trial.h"
#include "upd_screen.h"
#include "wifi_access.h"
#include "wifi_screen.h"
#include "ui_cats.h"
#include "ui_screen.h"
#include "ui_card_text.h"
#include "ui_text.h"
#include "ui_theme.h"
#include "panel.h"
#include "panel_main.h"
#include "panel_trial.h"

Macros

#define TOUCH_Q_LEN   32
#define CMD_Q_LEN   16
#define SAMPLE_Q_LEN   8
#define KST_Q_LEN   4
#define HITEC_Q_LEN   4
 The Hitec programmer's commands (hitec_prog_cmd_t) the queue holds, as KST_Q_LEN.

Functions

void publish_throttle_ramp (void)
uint32_t control_alert_numbered (const char *text)
void control_alert_withdraw (uint32_t gen)
static void servo_testing_told (bool running)
void log_post (log_row_t *row)
static bool servo_ctx_armed (void *ctx)
static bool servo_ctx_stopped (void *ctx)
static void servo_ctx_alert (void *ctx, servo_link_alert_t a)
static void servo_ctx_disarm (void *ctx, bool link_up)
static uint32_t servo_ctx_stop_count (void *ctx)
static void servo_ctx_arm_surfaces (void *ctx)
static log_run_kind_t log_run_wanted (void)
void log_follow_runs (void)
static void task_report (void)
 Every task with its core and priority, once at start-up.
void app_main (void)

Variables

atomic_uint s_throttle_ramp
static const char * TAG = "rcbench"
link_host_t s_host
atomic_uint s_capabilities
link_bringup_t s_bring
atomic_uint s_link_lost_ms
bool s_link_lost_shown
uint32_t s_recoveries
uint32_t s_recoveries_total
atomic_int s_outputs_result
bind_reading_t s_outputs_read
bool s_outputs_read_fresh
bind_read_t s_bind_read = BIND_READ_NONE
uint16_t s_far_minor
uint16_t s_board
QueueHandle_t s_touch_q
QueueHandle_t s_cmd_q
QueueHandle_t s_kst_q
QueueHandle_t s_sample_q
QueueHandle_t s_supply_q
QueueHandle_t s_enc_q
QueueHandle_t s_win_q
SemaphoreHandle_t s_snap_lock
panel_snap_t s_snap
outputs_t s_out
arming_t s_arm
uint16_t s_throttle_hundredths
atomic_bool s_stop_request
atomic_uint s_stop_counted
atomic_bool s_disarm_request
atomic_uint s_lets_go
atomic_bool s_supply_off_request
atomic_uint s_supply_offs
atomic_uint s_supply_set_mv
atomic_uint s_supply_set_ma
atomic_uint s_supply_vmax_mv
atomic_uint s_supply_imax_ma
atomic_uint s_supply_trip_ma
atomic_uint s_supply_trip_mv
atomic_uint s_supply_trip_ms
atomic_uint s_supply_ack
atomic_bool s_supply_live
atomic_uint s_supply_ons_sent
atomic_uint s_supply_ons_taken
atomic_uint s_pdmini_wiring
atomic_uint s_pdmini_edits
atomic_bool s_supply_real
atomic_uint s_supply_vin_mv
atomic_uint s_supply_baud
atomic_uint s_drv_gaps
atomic_uint s_tq_published
uint32_t s_lost_notice_seq
atomic_uint s_loss_gen
atomic_uint s_arm_ack
atomic_uint s_render_progress
 The render loop's progress: moved once a pass of panel_frame_loop() and once per card read the loop makes on LOGS (panel_card.c), read by the control task's watchdog (frame_watch.h, control_pump()).
uint32_t s_arm_take_gen
uint32_t s_arm_take_drv
uint32_t s_arm_gen
arm_watch_t s_arm_watch
atomic_bool s_poles_owed
atomic_uint s_poles_value
bool s_pump_live
log_cadence_t s_log_cad
static uint32_t s_log_run_ctr
log_run_kind_t s_log_kind
float s_log_t
atomic_bool s_servo_testing
atomic_ullong s_servo_pins
atomic_bool s_servo_pins_known
atomic_bool s_enc_held
static const servo_link_ctx_t k_servo_ctx

Detailed Description

The panel application: app_main, the console report and the main loop's hardware glue.

Brings the board up, reports each step to the splash as it happens, then runs the router at the panel's refresh rate.

This file is glue. What the screens decide, what the link carries, what the numbers mean and when the bench fails safe are pure C in shared/, tested on the host; this file holds the parts that need the hardware.

SPDX-License-Identifier: MIT

Function Documentation

◆ task_report()

void task_report ( void )
static

Every task with its core and priority, once at start-up.

A task created through xTaskCreate() or xTaskCreatePinnedToCore() without a core runs on core 0 (wifi_radio.c); core 1 belongs to the control task and the tasks pinned there. "any" would be a task that escaped that rule, such as one made with xTaskCreateStatic() without a core.

Variable Documentation

◆ k_servo_ctx

const servo_link_ctx_t k_servo_ctx
static
Initial value:
= {
.host = &s_host,
.port = &k_port,
.prog = &s_prog_link,
.ctx = NULL,
.armed = servo_ctx_armed,
.stopped = servo_ctx_stopped,
.alert = servo_ctx_alert,
.disarm = servo_ctx_disarm,
.stop_count = servo_ctx_stop_count,
.arm_surfaces = servo_ctx_arm_surfaces,
}

◆ s_cmd_q

QueueHandle_t s_cmd_q

app_main -> control task

◆ s_enc_q

QueueHandle_t s_enc_q

control task -> app_main

◆ s_kst_q

QueueHandle_t s_kst_q

app_main -> control task

◆ s_render_progress

atomic_uint s_render_progress

The render loop's progress: moved once a pass of panel_frame_loop() and once per card read the loop makes on LOGS (panel_card.c), read by the control task's watchdog (frame_watch.h, control_pump()).

The render loop's progress, for the control task's watchdog; see frame_watch.h and main.c.

The render loop's progress: moved once a pass of panel_frame_loop() and once per card read the loop makes on LOGS (panel_card.c), read by the control task's watchdog (frame_watch.h, control_pump()).

◆ s_sample_q

QueueHandle_t s_sample_q

control task -> app_main

◆ s_stop_counted

atomic_uint s_stop_counted

s_touch_q number of a counted STOP, 0 none

◆ s_supply_q

QueueHandle_t s_supply_q

control task -> app_main

◆ s_touch_q

QueueHandle_t s_touch_q

control task -> app_main

◆ s_win_q

QueueHandle_t s_win_q

control task -> app_main