40 lines
780 B
C
40 lines
780 B
C
#include <main.h>
|
|
#include <led.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <stm32f103xe.h>
|
|
|
|
|
|
void led(ledColor_t color, ledAction_t action) {
|
|
GPIO_TypeDef *port = NULL;
|
|
uint16_t pin = 0;
|
|
|
|
switch (color) {
|
|
case RED:
|
|
port = LED_Red_GPIO_Port;
|
|
pin = LED_Red_Pin;
|
|
break;
|
|
|
|
case GREEN:
|
|
port = LED_Green_GPIO_Port;
|
|
pin = LED_Green_Pin;
|
|
break;
|
|
}
|
|
|
|
if (port != NULL) {
|
|
switch (action) {
|
|
case ON:
|
|
HAL_GPIO_WritePin(port, pin, GPIO_PIN_SET);
|
|
break;
|
|
|
|
case OFF:
|
|
HAL_GPIO_WritePin(port, pin, GPIO_PIN_RESET);
|
|
break;
|
|
|
|
case TOGGLE:
|
|
HAL_GPIO_TogglePin(port, pin);
|
|
break;
|
|
}
|
|
}
|
|
}
|