📄 main.c
字号:
#define IN_MAIN
#include "config.h"
#pragma import(__use_no_semihosting_swi) //don't delete this line
#define BEEP (1 << 7) //蜂鸣器控制引脚为P0.7
/*********************************************************************************************************
** Function name: IRQ_Exception
**
** Descriptions: interrupt exceptional handler , change it as needed
** don't delete this function
********************************************************************************************************/
void IRQ_Exception(void)
{
}
/*********************************************************************************************************
** 函数名称:Delay
** 函数功能:延时子程序。
** 入口参数:dly 延时参数
********************************************************************************************************/
void Delay(uint32 dly)
{
uint32 i;
for(;dly > 0;dly--)
for(i = 0;i < 50000;i++);
}
/*********************************************************************************************************
** 函数名称:Main
** 函数功能:蜂鸣器控制程序。
** 说明:跳线JP9短接,JP4、JP1断开。
********************************************************************************************************/
void Main(void)
{
TargetInit(VPBDIV_DATA, PLLCFG_DATA, MAMTIM_DATA); // don't delete
while((PLLSTAT & (1 << 10)) == 0); // can delete
PINSEL0 = 0x00000000; //蜂鸣器控制端口设置为GPIO模式
IO0DIR = BEEP; //P0.7设置为输出模式
while(1) //控制蜂鸣器间歇鸣叫
{
IO0SET = BEEP;
Delay(50);
IO0CLR = BEEP;
Delay(50);
}
}
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -