Improve doxygen comments in code.
This commit is contained in:
@@ -67,13 +67,13 @@ static void setup_nvic_priorities(void)
|
||||
FATFS fs;
|
||||
#define fs_ptr (&fs)
|
||||
|
||||
/**
|
||||
* @brief Configure UART GPIOs
|
||||
* In case the application is build in debug mode, use the TX/RX Pins on the debug header
|
||||
* else the Pins on the DIGIO header are configured in the digio module and this function does nothing.
|
||||
*/
|
||||
static inline void uart_gpio_config(void)
|
||||
{
|
||||
/*
|
||||
* In case the application is build in debug mode, use the TX/RX Pins on the debug header
|
||||
* else the Pins on the DIGIO header are configured in the digio module
|
||||
*/
|
||||
|
||||
#if defined(DEBUGBUILD) || defined(UART_ON_DEBUG_HEADER)
|
||||
rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(SHELL_UART_PORT_RCC_MASK));
|
||||
SHELL_UART_PORT->MODER &= MODER_DELETE(SHELL_UART_TX_PIN) & MODER_DELETE(SHELL_UART_RX_PIN);
|
||||
@@ -86,9 +86,19 @@ static inline void uart_gpio_config(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief TX buffer for the shell's uart
|
||||
*/
|
||||
static char shell_uart_tx_buff[256];
|
||||
|
||||
/**
|
||||
* @brief RX buffer for the shell's uart
|
||||
*/
|
||||
static char shell_uart_rx_buff[48];
|
||||
|
||||
/**
|
||||
* @brief The uart instance handling the shellmatta shell.
|
||||
*/
|
||||
struct stm_uart shell_uart;
|
||||
|
||||
static shellmatta_retCode_t write_shell_callback(const char *data, uint32_t len)
|
||||
@@ -97,6 +107,12 @@ static shellmatta_retCode_t write_shell_callback(const char *data, uint32_t len)
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the UART for the shellmatta shell.
|
||||
*
|
||||
* This will configure the UART for use with a DMA ring buffer.
|
||||
* @param uart
|
||||
*/
|
||||
static inline void setup_shell_uart(struct stm_uart *uart)
|
||||
{
|
||||
uart->rx = 1;
|
||||
@@ -119,6 +135,11 @@ static inline void setup_shell_uart(struct stm_uart *uart)
|
||||
NVIC_EnableIRQ(DMA2_Stream7_IRQn);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Mount the SD card if available and not already mounted
|
||||
* @param mounted The current mounting state of the SD card
|
||||
* @return true if mounted, false if an error occured or the SD is not inserted and cannot be mounted
|
||||
*/
|
||||
static bool mount_sd_card_if_avail(bool mounted)
|
||||
{
|
||||
FRESULT res;
|
||||
@@ -148,6 +169,13 @@ static bool mount_sd_card_if_avail(bool mounted)
|
||||
return mounted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Process the boot status structure in the safety (backup) RAM
|
||||
* Depending on the flags set there, this function will:
|
||||
* - Reboot into the ram code for reflashing
|
||||
* - Display the PANIC message
|
||||
* - Display if the flash has been successfully updated
|
||||
*/
|
||||
static inline void handle_boot_status(void)
|
||||
{
|
||||
struct safety_memory_boot_status status;
|
||||
@@ -183,34 +211,69 @@ static inline void handle_boot_status(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Setup the system.
|
||||
*
|
||||
* This function does all basic initializations of the MCU and its peripherals
|
||||
*/
|
||||
static inline void setup_system(void)
|
||||
{
|
||||
float tmp;
|
||||
|
||||
/** - Setup the NVIC priorities of the core peripherals using interrupts */
|
||||
setup_nvic_priorities();
|
||||
|
||||
/* Init safety controller and safety memory */
|
||||
/** - Init safety controller and safety memory */
|
||||
safety_controller_init();
|
||||
|
||||
/** - Setup the systick module generating the 100us tick fort the GUI and
|
||||
* the 1ms tick for the global systick timestamp
|
||||
*/
|
||||
systick_setup();
|
||||
|
||||
/** - Initialize the oven output driver outputting the wavepacket control signal for the SSR and */
|
||||
oven_driver_init();
|
||||
|
||||
/** - Initialize all DIGIO Pins to theri default state and pin functions */
|
||||
digio_setup_default_all();
|
||||
|
||||
/** - Set-up the LED outputs */
|
||||
led_setup();
|
||||
|
||||
/** - Set-up the loudspeaker / beeper output */
|
||||
loudspeaker_setup();
|
||||
|
||||
/** - Initialize the GUI */
|
||||
gui_init();
|
||||
|
||||
/** - Initialize the pins for the uart interface. */
|
||||
uart_gpio_config();
|
||||
|
||||
/** - Set-up the settings module */
|
||||
settings_setup();
|
||||
|
||||
/* Load the overtemperature limit from eeprom if available. Otherwise the default value will be used */
|
||||
/** - Load the overtemperature limit from eeprom if available. Otherwise the default value will be used */
|
||||
if (settings_load_overtemp_limit(&tmp) == SETT_LOAD_SUCCESS)
|
||||
safety_controller_set_overtemp_limit(tmp);
|
||||
|
||||
/** - Handle the boot status struct in the safety memory */
|
||||
handle_boot_status();
|
||||
|
||||
/** - Initialize the shell UART */
|
||||
setup_shell_uart(&shell_uart);
|
||||
|
||||
/** - Enable the ADC for PT1000 measurement */
|
||||
adc_pt1000_setup_meas();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handle the input for the shell instance.
|
||||
*
|
||||
* This function will check if the RX ring buffer of the UART contains data.
|
||||
* If so, it will prowvide it to the shellmatta shell.
|
||||
*
|
||||
* @param shell_handle Handle to the shellmatta instance
|
||||
*/
|
||||
static void handle_shell_uart_input(shellmatta_handle_t shell_handle)
|
||||
{
|
||||
int uart_receive_status;
|
||||
@@ -223,6 +286,10 @@ static void handle_shell_uart_input(shellmatta_handle_t shell_handle)
|
||||
shell_handle_input(shell_handle, uart_input, uart_input_len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This is the main function containing the initilizations and the cyclic main loop
|
||||
* @return Don't care. This function will never return. We're on an embedded device...
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
bool cal_active;
|
||||
@@ -235,21 +302,30 @@ int main(void)
|
||||
int menu_wait_request;
|
||||
uint64_t quarter_sec_timestamp = 0ULL;
|
||||
|
||||
/* Setup all the peripherals and external componets like LCD, EEPROM etc. and the safety controller */
|
||||
/** - Setup all the peripherals and external componets like LCD, EEPROM etc. and the safety controller */
|
||||
setup_system();
|
||||
|
||||
/* Try load the calibration. This will only succeed if there's an EEPROM */
|
||||
/** - Try load the calibration. This will only succeed if there's an EEPROM */
|
||||
status = settings_load_calibration(&sens, &offset);
|
||||
if (!status)
|
||||
adc_pt1000_set_resistance_calibration(offset, sens, true);
|
||||
|
||||
/** - Initialize the shellmatta shell */
|
||||
shell_handle = shell_init(write_shell_callback);
|
||||
|
||||
/** - Print motd to shell */
|
||||
shell_print_motd(shell_handle);
|
||||
|
||||
/** - Set the main cycle counter to 0 */
|
||||
main_cycle_counter_init();
|
||||
|
||||
/** - Do a loop over the following */
|
||||
while (1) {
|
||||
|
||||
/** - If 250 ms have passed since the last time this step was reached, we try to initialize the
|
||||
* SD card. If the card has been mounted and there is no current resistance calibration,
|
||||
* it is tried to load it from SD card.
|
||||
*/
|
||||
if (systick_ticks_have_passed(quarter_sec_timestamp, 250)) {
|
||||
led_set(1, 0);
|
||||
sd_old = sd_card_mounted;
|
||||
@@ -267,29 +343,47 @@ int main(void)
|
||||
quarter_sec_timestamp = systick_get_global_tick();
|
||||
}
|
||||
|
||||
/** - Handle the GUI */
|
||||
menu_wait_request = gui_handle();
|
||||
|
||||
/** - Handle the uart input for the shell */
|
||||
handle_shell_uart_input(shell_handle);
|
||||
|
||||
/* Execute current profile step, if a profile is active */
|
||||
/** - Execute current profile step, if a profile is active */
|
||||
temp_profile_executer_handle();
|
||||
|
||||
/** - Handle the safety controller. This must be called! Otherwise a watchdog reset will occur */
|
||||
safety_controller_handle();
|
||||
|
||||
/** - If the Oven PID controller is running, we handle its sample function */
|
||||
if (oven_pid_get_status() == OVEN_PID_RUNNING)
|
||||
oven_pid_handle();
|
||||
|
||||
/** - Apply the power level of the oven driver */
|
||||
oven_driver_apply_power_level();
|
||||
|
||||
/** - Report the main loop timing to the timing monitor to detect a slowed down main loop */
|
||||
safety_controller_report_timing(ERR_TIMING_MAIN_LOOP);
|
||||
|
||||
/** - If the menu requests a directly following loop run, the main loop will continue.
|
||||
* Otherwise it will wait for the next interrupt
|
||||
*/
|
||||
if (menu_wait_request)
|
||||
__WFI();
|
||||
else
|
||||
__NOP();
|
||||
/** - Increment the main cycle counter */
|
||||
main_cycle_counter_inc();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Callback function for the SDIO driver to wait \p ms milliseconds
|
||||
* @param ms
|
||||
* @warning This function relies on the systick and must not be used in interrupt context.
|
||||
*/
|
||||
void sdio_wait_ms(uint32_t ms)
|
||||
{
|
||||
systick_wait_ms(ms);
|
||||
|
Reference in New Issue
Block a user