Prusa-MMU-Private
PrusaMultiMaterialUpgradev3firmwareforMK3SMK4
Functions
main.cpp File Reference
#include "hal/cpu.h"
#include "hal/adc.h"
#include "hal/gpio.h"
#include "hal/shr16.h"
#include "hal/spi.h"
#include "hal/usart.h"
#include "hal/watchdog.h"
#include "pins.h"
#include <avr/interrupt.h>
#include <util/delay.h>
#include "modules/buttons.h"
#include "modules/finda.h"
#include "modules/fsensor.h"
#include "modules/globals.h"
#include "modules/idler.h"
#include "modules/leds.h"
#include "modules/protocol.h"
#include "modules/pulley.h"
#include "modules/selector.h"
#include "modules/user_input.h"
#include "modules/timebase.h"
#include "modules/motion.h"
#include "modules/usb_cdc.h"
#include "modules/voltage.h"
#include "application.h"
#include "logic/hw_sanity.h"
#include "logic/start_up.h"
Include dependency graph for main.cpp:

Functions

static void setup ()
 
static void setup2 ()
 Second part of setup - executed with interrupts enabled.
 
void Panic (ErrorCode ec)
 
void RuntimeHWChecks ()
 
void loop ()
 
int main ()
 
void __cxa_pure_virtual ()
 

Function Documentation

◆ loop()

void loop ( )

Main loop of the firmware Proposed architecture checkMsgs(); if(msg is command){ activate command handling } else if(msg is query){ format response to query } StepCurrentCommand(); StepMotors(); StepLED(); StepWhateverElseNeedsStepping(); The idea behind the Step* routines is to keep each automaton non-blocking allowing for some “concurrency”. Some FW components will leverage ISR to do their stuff (UART, motor stepping?, etc.)

◆ main()

int main ( )

enable interrupts

◆ Panic()

void Panic ( ErrorCode  ec)

Switches the currently active logic state machine into an error state of code ec. It shall be used to halt the firmware while retaining the capability of reporting the error state to the printer

  • a kind of similar to runtime assertions. Implementation is in main.cpp, where we know the currently active logic state machine. The only way out is to reset the board.

◆ setup()

static void setup ( )
static

One-time setup of HW and SW components Called before entering the loop() function Green LEDs signalize the progress of initialization. If anything goes wrong we shall turn on a red LED Executed with interrupts disabled