Initialize LEDs
This commit is contained in:
parent
bc3771c39a
commit
b28ff29f45
6
Core/Inc/leds.h
Normal file
6
Core/Inc/leds.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef __LEDS_H
|
||||
#define __LEDS_H
|
||||
|
||||
void leds_init();
|
||||
|
||||
#endif // __LEDS_H
|
27
Core/Src/leds.c
Normal file
27
Core/Src/leds.c
Normal file
@ -0,0 +1,27 @@
|
||||
#include "leds.h"
|
||||
#include "main.h"
|
||||
#include "stm32g4xx_hal.h"
|
||||
#include "stm32g4xx_hal_gpio.h"
|
||||
|
||||
void leds_init() {
|
||||
HAL_GPIO_WritePin(LED_NOE_GPIO_Port, LED_NOE_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LED_NCLR_GPIO_Port, LED_NCLR_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(LED_OCLK_GPIO_Port, LED_OCLK_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LED_ICLK_GPIO_Port, LED_ICLK_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(TOP_PWM_GPIO_Port, TOP_PWM_Pin, GPIO_PIN_SET);
|
||||
HAL_Delay(10);
|
||||
|
||||
for (int i = 0; i < 12; i++) {
|
||||
GPIO_PinState state = (i % 2 == 0) ? GPIO_PIN_SET : GPIO_PIN_RESET;
|
||||
HAL_GPIO_WritePin(LED_SER_GPIO_Port, LED_SER_Pin, state);
|
||||
HAL_Delay(5);
|
||||
HAL_GPIO_WritePin(LED_ICLK_GPIO_Port, LED_ICLK_Pin, GPIO_PIN_SET);
|
||||
HAL_Delay(10);
|
||||
HAL_GPIO_WritePin(LED_ICLK_GPIO_Port, LED_ICLK_Pin, GPIO_PIN_RESET);
|
||||
HAL_Delay(10);
|
||||
}
|
||||
|
||||
HAL_GPIO_WritePin(LED_OCLK_GPIO_Port, LED_OCLK_Pin, GPIO_PIN_SET);
|
||||
HAL_Delay(10);
|
||||
HAL_GPIO_WritePin(LED_OCLK_GPIO_Port, LED_OCLK_Pin, GPIO_PIN_RESET);
|
||||
}
|
@ -22,6 +22,7 @@
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "events.h"
|
||||
#include "leds.h"
|
||||
#include "rpi.h"
|
||||
#include "state.h"
|
||||
#include "vehicle.h"
|
||||
@ -105,6 +106,7 @@ int main(void) {
|
||||
MX_FDCAN1_Init();
|
||||
MX_I2C2_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
leds_init();
|
||||
state_init();
|
||||
vehicle_init(&hfdcan1);
|
||||
rpi_init(&hi2c2);
|
||||
|
@ -37,6 +37,7 @@ BUILD_DIR = build
|
||||
# C sources
|
||||
C_SOURCES = \
|
||||
Core/Src/events.c \
|
||||
Core/Src/leds.c \
|
||||
Core/Src/main.c \
|
||||
Core/Src/rpi.c \
|
||||
Core/Src/state.c \
|
||||
|
Loading…
x
Reference in New Issue
Block a user