Breath4Life / controller

5 stars 1 forks source link

Breath4Life software controller

Please read this entire README before writing code. All commits will be peer-reviewed, commits that do not respect the architectural organization or the coding style will be rejected!

Requirements

This controller is supposed to run on an Arduino Mega2560. This project requires the following tools and librairies to be installed:

Compilation & flashing

To compile the project, use make. The project can be cleaned using make clean.

To flash the Arduino after compilation, use tools/flash.sh [<DEV>] where <DEV> is an optional argument indicating the device path (default: /dev/ttyACM0). The UART0 bus displaying the debug messages uses a baud rate of 19200.

Note: An easy way to read the UART from a linux machine: screen /dev/ttyACM0 19200.

Hierarchy organization

All source files have to be written in C11. The src/ folder is organized as follows:

It is important to respect this organization, as providing a separate HAL allows to easily change of MCU in the future if needs be. If your feature requires the usage of a new library, please include it into the lib/ folder and update the Makefile.

Coding style

This section presents some rules regarding the coding style used in this project. Their enforcement is mandatory.

Architecture

Several real times tasks are spawned in the main function. They are listed by descending order of priority:

  1. MotorControlTask: control the motor.
  2. MainTask: handle the peripherals related to the user interface (buttons, LEDs, ...), except the LCD screen, the global state of the system, and the alarms.
  3. LCDDisplayTask: handle the display of the LCD screen.
  4. AlarmsTask: handle the buzzer.
  5. AnalogReadTask: read the analog sensors

Technical note

enum dio_pin and struct io_pin_config DIO_PIN_CONFIG[] should stay aligned as the dio_pin is used to index the array.

Do not forget to init your ios in the initHardware() in main.c. In the future, we could add the dio_mode into io_pin_conf, so the digital io setup could be done automatically (a loop on DIO_PIN_CONFIG).

1 Tick = 5 ms