forgotten signaling stuff
This commit is contained in:
13
cube/User/Inc/signal.h
Normal file
13
cube/User/Inc/signal.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef _DEBUG_H_
|
||||||
|
#define _DEBUG_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef enum { DEBUG_1, DEBUG_2, LED_RED, LED_GREEN } signalPin_t;
|
||||||
|
typedef enum { ON, OFF, TOGGLE } signalAction_t;
|
||||||
|
|
||||||
|
void signal(signalPin_t signalPin, signalAction_t action);
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _DEBUG_H_
|
49
cube/User/Src/signal.c
Normal file
49
cube/User/Src/signal.c
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#include <main.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stm32f103xe.h>
|
||||||
|
|
||||||
|
|
||||||
|
void signal(signalPin_t signalPin, signalAction_t action) {
|
||||||
|
GPIO_TypeDef *port = NULL;
|
||||||
|
uint16_t pin = 0;
|
||||||
|
|
||||||
|
switch (signalPin) {
|
||||||
|
case DEBUG_1:
|
||||||
|
port = Debug_Signal_1_GPIO_Port;
|
||||||
|
pin = Debug_Signal_1_Pin;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DEBUG_2:
|
||||||
|
port = Debug_Signal_2_GPIO_Port;
|
||||||
|
pin = Debug_Signal_2_Pin;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LED_RED:
|
||||||
|
port = LED_Red_GPIO_Port;
|
||||||
|
pin = LED_Red_Pin;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LED_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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user