HRI board firmware v2.1 Microcontroller firmware of the board used during the HRI labs.

HRI board firmware documentation

# Introduction

This is the documentation of the HRI board firmware. You will find a description of the provided library and drivers. As all the hardware and software is very new, please do not hesitate to suggest improvements to the course assistants (Romain Baud, Philipp Hörler and Laurent Jenni).

# Code structure

The code is divided into 3 parts:

- main: this is where the controllers and the communication protocol are implemented. The call of all the initialization functions is also made here.
- library: all the algorithms, data structures that could be used at many places, are put into the library.
- drivers: there is one driver per peripheral. All the hardware-specific code is wrapped into these files, so that the user does not have to worry about the microcontroller operation (and spend a lot of time to read the documentation).

One module (controller, communication, library or driver) is always splitted in two files, .h and .c, like in C++.

# How to use the provided library

For most of the driver/library modules, call x_Init() only once, when the program starts (typically in the main()). Then, you can call x_Step()/x_Set()/x_Get() everytime as needed, typically in the control functions called periodically (ctrl_RegulatePosition()...).

See the "Modules" section of this documentation to see how they work.

# STM32's resources usage

## Timers

- TIM1: PWM of the 4 user LEDs.
- TIM2: -
- TIM3: -
- TIM4: -
- TIM5: encoder quadrature decoder.
- TIM6: position loop.
- TIM7: variables streaming loop.
- TIM8: H-bridge PWM.
- TIM9: -
- TIM10: current loop.
- TIM11: -
- TIM12: -
- TIM13: -
- TIM14: -

## ADCs

- ADC1: general purpose ADC.
- ADC2: -
- ADC3: motor current sensor ADC.

## DAC

- DAC: DAC extension.

## Communication buses

- USART1: UART extension.
- USART2: USB communication UART.
- I2C1: I2C extension.
- SPI3: SPI extension.