Simone: a game of visual memory and speed
port_rgb_light.h File Reference

Header for the portable functions to interact with the HW of the RGB light system. The functions must be implemented in the platform-specific code. More...

#include <stdint.h>
#include "rgb_colors.h"

Macros

#define PORT_RGB_LIGHT_ID   0
 

Functions

void port_rgb_light_init (uint8_t rgb_light_id)
 Configure the HW specifications of a given RGB light. More...
 
void port_rgb_light_set_rgb (uint8_t rgb_light_id, rgb_color_t color)
 Set the Capture/Compare register values for each channel of the RGB LED given a color. More...
 

Detailed Description

Header for the portable functions to interact with the HW of the RGB light system. The functions must be implemented in the platform-specific code.

Author
Sistemas Digitales II
Date
2026-01-01

Macro Definition Documentation

◆ PORT_RGB_LIGHT_ID

#define PORT_RGB_LIGHT_ID   0

RGB light system identifier of Simone

Function Documentation

◆ port_rgb_light_init()

void port_rgb_light_init ( uint8_t  rgb_light_id)

Configure the HW specifications of a given RGB light.

Assuming we are using an STM32F4-based platform, this function must call the following functions:

TODO alumnos:

✅ 1. Retrieve the RGB light configuration struct calling _stm32f4_rgb_light_get().
✅ 2. Call function stm32f4_system_gpio_config() with the right arguments to configure each RGB LED as in alternate mode and no pull up neither pull down connection.
✅ 3. Call function stm32f4_system_gpio_config_alternate() with the right arguments to configure the alternate function of the each RGB LED.
✅ 4. Call function _timer_pwm_config() to configure the timer and the PWM signal of the RGB light.
✅ 5. Call function port_rgb_light_set_rgb() to set the RGB LED to off.

Parameters
rgb_light_idRGB light ID. This index is used to select the element of the rgb_lights_arr[] array

◆ port_rgb_light_set_rgb()

void port_rgb_light_set_rgb ( uint8_t  rgb_light_id,
rgb_color_t  color 
)

Set the Capture/Compare register values for each channel of the RGB LED given a color.

This function disables the timer associated to the RGB LEDs, sets the Capture/Compare register values for each channel of the RGB LED, and enables the timer.

Warning
This function is valid for any given RGB LED, however, each RGB LED has its own timer. Write the code in a conditional statement to check the rgb_light_id.

TODO alumnos:

✅ 1. Retrieve the individual RGB values from the color parameter and follow the flowchart given in the lab notebook to set the RGB LED color by configuring the PWM signals appropriately.

Parameters
rgb_light_idRGB light system identifier number.
colorRGB color to set.