|
- #include "MKV56F24.h"
- #include "fsl_common.h"
- #include "fsl_gpio.h"
- #include "fsl_port.h"
-
- /*********************************************
- PTA15——LED灯闪烁
- **********************************************/
- volatile uint32_t g_systickCounter;
- void SysTick_DelayTicks(uint32_t n); //滴答定时器延时函数
- void main()
- {
- CLOCK_EnableClock(kCLOCK_PortA); //开启PORT时钟
- port_pin_config_t GPIO_Port_Init =
- {
- kPORT_PullUp , //上拉
- kPORT_FastSlewRate, //快速压摆率
- kPORT_PassiveFilterDisable, //无源滤波器
- kPORT_OpenDrainDisable, //推挽输出
- kPORT_LowDriveStrength, //低驱动力
- kPORT_MuxAsGpio, //普通GPIO模式
- kPORT_UnlockRegister, //
- };
- PORT_SetPinConfig(PORTA, 15U, &GPIO_Port_Init); //设置引脚复用方式
- gpio_pin_config_t config =
- {
- kGPIO_DigitalOutput, //输出模式
- 0,
- };
- GPIO_PinInit(GPIOA, 15U, &config); //初始化PTA15
- GPIO_PinWrite(GPIOA, 15, 1); //PTA15写1
-
- /* Set systick reload value to generate 1ms interrupt */
- if (SysTick_Config(SystemCoreClock / 1000U))
- {
- while (1)
- {
- }
- }
- while (1)
- {
- GPIO_PinWrite(GPIOA, 15, 0);
- SysTick_DelayTicks(500U);
- GPIO_PinWrite(GPIOA, 15, 1);
- SysTick_DelayTicks(500U);
- }
-
- }
-
-
- void SysTick_Handler(void)
- {
- if (g_systickCounter != 0U)
- {
- g_systickCounter--;
- }
- }
-
- void SysTick_DelayTicks(uint32_t n)
- {
- g_systickCounter = n;
- while (g_systickCounter != 0U)
- {
- }
- }
|