Skip to content

Code Structure

Peter Wittich edited this page Feb 18, 2022 · 1 revision

The main program for the microcontroller is the cm_mcu file. It is what is built by default (in addition to the boot loader).

On power-up, the MCU works as follows.

  • First the MCU starts the boot loader. The boot loader is a small program that is used to allow management of the main program file.
  • The main program (located at projects/cm_mcu/cm_mcu.c) then does the following
    • Initialize the hardware, including setting the I/O pins and the internal peripherals. Interrupts are not enabled at this point
    • Initialize the logging system and other monitoring data structures
    • Initialize FreeRTOS semaphores, queues, and tasks
    • Start setting up the interrupt service routines
    • Start the FreeRTOS scheduler.

At this point FreeRTOS takes over, and each task gets scheduled based on the priority set when they are created.

The list of tasks is below, with a brief description.

  • ADCMonitorTask -- use the internal ADCs to monitor voltages and currents on the board
  • CommandLineTask -- CLI interface
  • EEPROMTask -- gatekeeper task for the internal EEPROM
  • FireFlyTask -- gatekeeper for I2C controller that talks to the SamTec Firefly modules. Monitors these devices
  • GenericAlarmTask -- reacts to measurements going out of scope
  • I2CSlaveTask -- I2C target control gatekeeper task. This target is read out by I2C controller on the IPMC
  • InitTask -- run once on start
  • LedTask -- gatekeeper task for MCU LEDs
  • MonitorTask -- SMBus gatekeeper task. Used for FPGA and power supply monitoring.
  • PowerSupplyTask -- controls power supplies
  • WatchdogTask -- task for hardware watchdog; currently ~unusued
  • ZynqMonTask -- UART push of monitoring data to the Zynq.