使用GPIO控制蜂鸣器
#include "config.h"
#define BEEPCON 0x00000080
void DelayNS(uint32 dly)
{
uint32 i;
for(;dly>0;dly--)
for(i=0;i<5000;i++);
}
int main(void){
PINSEL0 = 0x00000000;
IO0DIR = BEEPCON;
while(1){
IO0SET = BEEPCON;
DelayNS(10);
IO0SET = BEEPCON;
DelayNS(10);
}
return 0;
}