generated from Embedded_Projects/N32WB031_Template
48 lines
1.0 KiB
C
48 lines
1.0 KiB
C
#include "n32wb03x.h"
|
|
#include "n32wb03x_gpio.h"
|
|
|
|
static volatile uint32_t uwTick = 0U;
|
|
|
|
static void HAL_Delay(uint32_t msec);
|
|
|
|
int main(void) {
|
|
SysTick_Config(SystemCoreClock / 1000);
|
|
|
|
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOA, ENABLE);
|
|
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOB, ENABLE);
|
|
|
|
GPIO_InitType led;
|
|
|
|
led.Pin = GPIO_PIN_0;
|
|
led.GPIO_Mode = GPIO_MODE_OUTPUT_PP;
|
|
led.GPIO_Speed = GPIO_SPEED_LOW;
|
|
led.GPIO_Current = GPIO_DC_12MA;
|
|
led.GPIO_Pull = GPIO_NO_PULL;
|
|
led.GPIO_Alternate = GPIO_AF0;
|
|
|
|
GPIO_InitPeripheral(GPIOB, &led);
|
|
|
|
led.Pin = GPIO_PIN_6;
|
|
GPIO_InitPeripheral(GPIOA, &led);
|
|
|
|
GPIO_TogglePin(GPIOB, GPIO_PIN_0);
|
|
|
|
for (;;) {
|
|
GPIO_TogglePin(GPIOB, GPIO_PIN_0);
|
|
GPIO_TogglePin(GPIOA, GPIO_PIN_6);
|
|
HAL_Delay(500);
|
|
}
|
|
}
|
|
|
|
static void HAL_Delay(uint32_t msec) {
|
|
uint32_t t_start = uwTick;
|
|
|
|
while (uwTick - t_start < msec) {
|
|
__WFI();
|
|
}
|
|
}
|
|
|
|
void SysTick_Handler(void) {
|
|
uwTick++;
|
|
}
|