Initialize on-board LEDs.
Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
parent
eb3df334f6
commit
d8b2fa2ae8
|
@ -53,6 +53,7 @@ set(TARGET_SOURCES
|
|||
"SDK/Drivers/PY32F0xx_HAL_Driver/Src/py32f0xx_ll_utils.c"
|
||||
"SDK/Drivers/CMSIS/Device/PY32F0xx/Source/gcc/startup_py32f030x6.s"
|
||||
"SDK/Drivers/CMSIS/Device/PY32F0xx/Source/system_py32f0xx.c"
|
||||
"board/board.c"
|
||||
"src/py32f0xx_hal_msp.c"
|
||||
"src/py32f0xx_it.c"
|
||||
"src/app_syscalls.c"
|
||||
|
@ -67,6 +68,7 @@ set(TARGET_C_INCLUDES
|
|||
"SDK/Drivers/PY32F0xx_HAL_Driver/Inc"
|
||||
"SDK/Drivers/CMSIS/Include"
|
||||
"SDK/Drivers/CMSIS/Device/PY32F0xx/Include"
|
||||
"board"
|
||||
"include"
|
||||
)
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#include "board.h"
|
||||
|
||||
#include "py32f0xx_hal.h"
|
||||
|
||||
void BOARD_InitBootPins(void) {
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
|
||||
GPIO_InitTypeDef init = {
|
||||
.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3,
|
||||
.Mode = GPIO_MODE_OUTPUT_PP,
|
||||
.Speed = GPIO_SPEED_FREQ_LOW,
|
||||
.Pull = GPIO_NOPULL,
|
||||
};
|
||||
|
||||
HAL_GPIO_Init(GPIOB, &init);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef BOARD_H
|
||||
#define BOARD_H
|
||||
|
||||
#define BOARD_LED_1_PORT GPIOB
|
||||
#define BOARD_LED_2_PORT GPIOB
|
||||
#define BOARD_LED_3_PORT GPIOB
|
||||
|
||||
#define BOARD_LED_1_PIN GPIO_PIN_1
|
||||
#define BOARD_LED_2_PIN GPIO_PIN_0
|
||||
#define BOARD_LED_3_PIN_GPIO_PIN_3
|
||||
|
||||
void BOARD_InitBootPins(void);
|
||||
|
||||
#endif // BOARD_H
|
|
@ -1,5 +1,8 @@
|
|||
#include <stdio.h>
|
||||
|
||||
/* BSP */
|
||||
#include "board.h"
|
||||
|
||||
/* App */
|
||||
#include "app_syscalls.h"
|
||||
#include "main.h"
|
||||
|
@ -9,11 +12,14 @@ UART_HandleTypeDef huart1;
|
|||
int main(void) {
|
||||
HAL_Init();
|
||||
|
||||
BOARD_InitBootPins();
|
||||
|
||||
app_syscalls_init();
|
||||
|
||||
printf("Hello world.\r\n");
|
||||
|
||||
for (;;) {
|
||||
/* -- */
|
||||
HAL_GPIO_TogglePin(BOARD_LED_1_PORT, BOARD_LED_1_PIN);
|
||||
HAL_Delay(500);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue