update status LED code
This commit is contained in:
		@ -1,20 +1,10 @@
 | 
			
		||||
#include "status_led.h"
 | 
			
		||||
#include "main.h"
 | 
			
		||||
#include "stm32h7xx_hal_gpio.h"
 | 
			
		||||
#include "ts_state_machine.h"
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
#define STATUS_LED_GPIO_PORT GPIOA //TODO: change to correct values for the board
 | 
			
		||||
 | 
			
		||||
#define STATUS_LED_1_RED_PIN GPIO_PIN_10 //TODO: change to correct values for the board
 | 
			
		||||
#define STATUS_LED_1_GREEN_PIN GPIO_PIN_11
 | 
			
		||||
#define STATUS_LED_1_BLUE_PIN GPIO_PIN_12
 | 
			
		||||
 | 
			
		||||
#define STATUS_LED_2_RED_PIN GPIO_PIN_13 //TODO: change to correct values for the board
 | 
			
		||||
#define STATUS_LED_2_GREEN_PIN GPIO_PIN_14
 | 
			
		||||
#define STATUS_LED_2_BLUE_PIN GPIO_PIN_15
 | 
			
		||||
 | 
			
		||||
//TODO: change to correct values for the board
 | 
			
		||||
#warning "GPIO pins for status LEDs are not set correctly"
 | 
			
		||||
#warning enable the second LED
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
    uint8_t red : 1;
 | 
			
		||||
@ -27,17 +17,6 @@ typedef enum {
 | 
			
		||||
    LED_2
 | 
			
		||||
} LedId;
 | 
			
		||||
 | 
			
		||||
void status_led_init() {
 | 
			
		||||
    GPIO_InitTypeDef GPIO_InitStruct = {0};
 | 
			
		||||
 | 
			
		||||
    GPIO_InitStruct.Pin = STATUS_LED_1_RED_PIN | STATUS_LED_1_GREEN_PIN | STATUS_LED_1_BLUE_PIN | STATUS_LED_2_RED_PIN | STATUS_LED_2_GREEN_PIN | STATUS_LED_2_BLUE_PIN;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
 | 
			
		||||
    HAL_GPIO_Init(STATUS_LED_GPIO_PORT, &GPIO_InitStruct);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void set_led_color(LedId id, LedColor color) {
 | 
			
		||||
    GPIO_PinState red = color.red ? GPIO_PIN_SET : GPIO_PIN_RESET;
 | 
			
		||||
    GPIO_PinState green = color.green ? GPIO_PIN_SET : GPIO_PIN_RESET;
 | 
			
		||||
@ -45,14 +24,14 @@ static void set_led_color(LedId id, LedColor color) {
 | 
			
		||||
 | 
			
		||||
    switch (id) {
 | 
			
		||||
        case LED_1:
 | 
			
		||||
            HAL_GPIO_WritePin(STATUS_LED_GPIO_PORT, STATUS_LED_1_RED_PIN, red);
 | 
			
		||||
            HAL_GPIO_WritePin(STATUS_LED_GPIO_PORT, STATUS_LED_1_GREEN_PIN, green);
 | 
			
		||||
            HAL_GPIO_WritePin(STATUS_LED_GPIO_PORT, STATUS_LED_1_BLUE_PIN, blue);
 | 
			
		||||
            HAL_GPIO_WritePin(STATUS_LED_R_GPIO_Port, STATUS_LED_R_Pin, red);
 | 
			
		||||
            HAL_GPIO_WritePin(STATUS_LED_G_GPIO_Port, STATUS_LED_G_Pin, green);
 | 
			
		||||
            HAL_GPIO_WritePin(STATUS_LED_B_GPIO_Port, STATUS_LED_B_Pin, blue);
 | 
			
		||||
            break;
 | 
			
		||||
        case LED_2:
 | 
			
		||||
            HAL_GPIO_WritePin(STATUS_LED_GPIO_PORT, STATUS_LED_2_RED_PIN, red);
 | 
			
		||||
            HAL_GPIO_WritePin(STATUS_LED_GPIO_PORT, STATUS_LED_2_GREEN_PIN, green);
 | 
			
		||||
            HAL_GPIO_WritePin(STATUS_LED_GPIO_PORT, STATUS_LED_2_BLUE_PIN, blue);
 | 
			
		||||
            //HAL_GPIO_WritePin(STATUS_LED_GPIO_PORT, STATUS_LED_2_RED_PIN, red);
 | 
			
		||||
            //HAL_GPIO_WritePin(STATUS_LED_GPIO_PORT, STATUS_LED_2_GREEN_PIN, green);
 | 
			
		||||
            //HAL_GPIO_WritePin(STATUS_LED_GPIO_PORT, STATUS_LED_2_BLUE_PIN, blue);
 | 
			
		||||
            break;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user