Prusa MINI Firmware overview
app.h File Reference
#include <inttypes.h>

Go to the source code of this file.

Functions

void app_setup (void)
 
void app_run (void)
 
void app_error (void)
 
void app_assert (uint8_t *file, uint32_t line)
 
void app_cdc_rx (uint8_t *buffer, uint32_t length)
 
void app_tim6_tick (void)
 
void app_tim14_tick (void)
 
void app_usbhost_reenum (void)
 

Function Documentation

◆ app_setup()

void app_setup ( void  )
51  {
52  setup();
53 
54  init_tmc();
55  //DBG("after init_tmc (%ld ms)", HAL_GetTick());
56 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ app_run()

void app_run ( void  )
62  {
63  DBG("app_run");
64 
65 #ifdef ETHERNET
66  if (diag_fastboot)
68 #endif //ETHERNET
69 
70  uint8_t defaults_loaded = eeprom_init();
71 
74 
75  adc_init();
76 
77 #ifdef SIM_HEATER
79 #endif //SIM_HEATER
80 
81  //DBG("before setup (%ld ms)", HAL_GetTick());
82  if (diag_fastboot || (!sys_fw_is_valid())) {
84  if (!sys_fw_is_valid()) // following code will be done only with invalidated firmware
85  {
86  hwio_safe_state(); // safe states
87  for (int i = 0; i < hwio_fan_get_cnt(); ++i)
88  hwio_fan_set_pwm(i, 0); // disable fans
89  }
90  } else
91  app_setup();
92  //DBG("after setup (%ld ms)", HAL_GetTick());
93 
94  if (defaults_loaded && marlin_server_processing())
95  {
96  settings.reset();
97 #ifndef _DEBUG
99 #endif //_DEBUG
100  settings.save();
101 #ifndef _DEBUG
103 #endif //_DEBUG
104  }
105 
106  while (1) {
107  if (marlin_server_processing()) {
108  loop();
109  }
113  osDelay(0); // switch to other threads - without this is UI slow
114 #ifdef JOGWHEEL_TRACE
115  static int signals = jogwheel_signals;
116  if (signals != jogwheel_signals) {
117  signals = jogwheel_signals;
118  DBG("%d %d", signals, jogwheel_encoder);
119  }
120 #endif //JOGWHEEL_TRACE
121 #ifdef SIM_MOTION_TRACE_X
122  static int32_t x = sim_motion_pos[0];
123  if (x != sim_motion_pos[0]) {
124  x = sim_motion_pos[0];
125  DBG("X:%li", x);
126  }
127 #endif //SIM_MOTION_TRACE_X
128 #ifdef SIM_MOTION_TRACE_Y
129  static int32_t y = sim_motion_pos[1];
130  if (y != sim_motion_pos[1]) {
131  y = sim_motion_pos[1];
132  DBG("Y:%li", y);
133  }
134 #endif //SIM_MOTION_TRACE_Y
135 #ifdef SIM_MOTION_TRACE_Z
136  static int32_t z = sim_motion_pos[2];
137  if (z != sim_motion_pos[2]) {
138  z = sim_motion_pos[2];
139  DBG("Z:%li", z);
140  }
141 #endif //SIM_MOTION_TRACE_Z
142  }
143 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ app_error()

void app_error ( void  )
145  {
146  bsod("app_error");
147 }
Here is the caller graph for this function:

◆ app_assert()

void app_assert ( uint8_t file,
uint32_t  line 
)
149  {
150  bsod("app_assert");
151 }

◆ app_cdc_rx()

void app_cdc_rx ( uint8_t buffer,
uint32_t  length 
)
153  {
154  USBSerial_put_rx_data(buffer, length);
155 }

◆ app_tim6_tick()

void app_tim6_tick ( void  )
157  {
158  adc_cycle();
159 #ifdef SIM_HEATER
160  static uint8_t cnt_sim_heater = 0;
161  if (++cnt_sim_heater >= 50) // sim_heater freq = 20Hz
162  {
164  cnt_sim_heater = 0;
165  }
166 #endif //SIM_HEATER
167 
168 #ifdef SIM_MOTION
170 #endif //SIM_MOTION
171 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ app_tim14_tick()

void app_tim14_tick ( void  )
173  {
175  hwio_update_1ms();
176 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ app_usbhost_reenum()

void app_usbhost_reenum ( void  )
187  {
188  static uint32_t timer = 0; // static timer variable
189  uint32_t tick = HAL_GetTick(); // read tick
190  if ((tick - timer) > 100) { // every 100ms
191  // timer is valid, UsbHost is in enumeration state
192  if ((timer) && (hUsbHostHS.gState == HOST_ENUMERATION) && (hUsbHostHS.EnumState == ENUM_IDLE)) {
193  // longer than 500ms
194  if ((tick - timer) > 500) {
195  _dbg("USB host reenumerating"); // trace
196  USBH_ReEnumerate(&hUsbHostHS); // re-enumerate UsbHost
197  }
198  }
199  else // otherwise update timer
200  timer = tick;
201  }
202 }
Here is the call graph for this function:
Here is the caller graph for this function:
hwio_safe_state
void hwio_safe_state(void)
Put hardware into safe state.
Definition: safe_state.c:8
settings
MarlinSettings settings
Definition: configuration_store.cpp:344
app_setup
void app_setup(void)
Definition: appmain.cpp:51
uartslave_cycle
void uartslave_cycle(uartslave_t *pslave)
Definition: uartslave.c:68
setup
void setup(void)
Definition: Marlin.cpp:818
osThreadResume
osStatus osThreadResume(osThreadId thread_id)
Resume execution of a suspended thread.
Definition: cmsis_os.c:1494
marlin_server_stop_processing
void marlin_server_stop_processing(void)
Definition: marlin_server.cpp:293
i
uint8_t i
Definition: screen_test_graph.c:72
init_tmc
void init_tmc(void)
diag_fastboot
int diag_fastboot
Definition: diag.c:11
HOST_ENUMERATION
Definition: usbh_def.h:333
MarlinSettings::save
static bool save()
Definition: configuration_store.cpp:2198
MarlinSettings::reset
static void reset()
Definition: configuration_store.cpp:2208
eeprom_init
uint8_t eeprom_init(void)
Definition: eeprom.c:53
osDelay
osStatus osDelay(uint32_t millisec)
Wait for Timeout (Time Delay)
Definition: cmsis_os.c:365
HAL_GetTick
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
Definition: stm32f4xx_hal.c:339
hwio_update_1ms
void hwio_update_1ms(void)
Definition: hwio_a3ides_2209_02.c:539
uart6slave
uartslave_t uart6slave
Definition: main.c:149
jogwheel_encoder
int32_t jogwheel_encoder
Definition: jogwheel.c:10
HAL_IWDG_Refresh
HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg)
adc_cycle
void adc_cycle(void)
Definition: adc.c:65
loop
void loop(void)
Definition: Marlin.cpp:1127
ENUM_IDLE
Definition: usbh_def.h:346
hwio_fan_get_cnt
int hwio_fan_get_cnt(void)
Definition: hwio_a3ides_2209_02.c:444
sys_fw_is_valid
int sys_fw_is_valid(void)
Definition: sys.cpp:266
jogwheel_signals
uint8_t jogwheel_signals
Definition: jogwheel.c:7
DBG
#define DBG
Definition: appmain.cpp:33
webServerTaskHandle
osThreadId webServerTaskHandle
Definition: main.c:100
USBH_ReEnumerate
USBH_StatusTypeDef USBH_ReEnumerate(USBH_HandleTypeDef *phost)
HCD_ReEnumerate Perform a new Enumeration phase.
Definition: usbh_core.c:371
hwio_fan_set_pwm
void hwio_fan_set_pwm(int i_fan, int val)
Definition: hwio_a3ides_2209_02.c:447
hUsbHostHS
USBH_HandleTypeDef hUsbHostHS
Definition: usb_host.c:74
uint8_t
const uint8_t[]
Definition: 404_html.c:3
_dbg
#define _dbg(...)
Definition: dbg.h:50
sim_heater_init
void sim_heater_init(void)
app_idle
void app_idle(void)
Definition: appmain.cpp:58
jogwheel_update_1ms
void jogwheel_update_1ms(void)
Definition: jogwheel.c:22
_USBH_HandleTypeDef::EnumState
ENUM_StateTypeDef EnumState
Definition: usbh_def.h:453
app_usbhost_reenum
void app_usbhost_reenum(void)
Definition: appmain.cpp:187
marlin_server_loop
int marlin_server_loop(void)
Definition: marlin_server.cpp:239
bsod
#define bsod(fmt,...)
Definition: bsod.h:20
hiwdg
IWDG_HandleTypeDef hiwdg
Definition: watchdog.h:24
marlin_server_idle_cb
marlin_server_idle_t * marlin_server_idle_cb
Definition: marlin_server.cpp:94
marlin_server_init
void marlin_server_init(void)
Definition: marlin_server.cpp:154
sim_motion_pos
int32_t sim_motion_pos[4]
USBSerial_put_rx_data
void USBSerial_put_rx_data(uint8_t *buffer, uint32_t length)
Definition: USBSerial.cpp:53
length
png_uint_32 length
Definition: png.c:2247
adc_init
void adc_init(void)
Definition: adc.c:53
_USBH_HandleTypeDef::gState
__IO HOST_StateTypeDef gState
Definition: usbh_def.h:452
sim_heater_cycle
void sim_heater_cycle(void)
sim_motion_cycle
void sim_motion_cycle(void)
marlin_server_processing
int marlin_server_processing(void)
Definition: marlin_server.cpp:284