S3C2440 GPIO (使用miniARM 2440)
S3C2440 GPIO (使用miniARM 2440)
S3C2440 GPIO (使用miniARM 2440):
- #ifndef LDE_H
- #define LED_H
- #include "2440addr.h"
- //GPB 有 PIN0 到 PIN10 共11个引脚
- //rGPBCON 寄存器的每两个位控制一个IO的输入输出方向
- //其中00表示输入
- // 01表示输出
- // 10为使用第二功能
- // 11为出厂保留
- //***************************************************
- //功能:流水灯
- //接口: GPB5 -> LED1 低 灯亮
- // GPB6 -> LED2
- // GPB7 -> LED3
- // GPB8 -> LED4
- // GPB0 -> 蜂鸣器 高 蜂鸣器响
- //***************************************************
- extern void delay(U32 tt);
- extern void BeeperInit(void);
- extern void BeeperControl(U8 flag);
- extern void LedInit(void);
- extern void LedControl(U8 led,U8 flag );
- #endif
- #include "led.h"
- void delay(U32 tt)
- {
- U32 i;
- for(;tt>0;tt--)
- {
- for(i=0;i<10000;i++){}
- }
- }
- void BeeperInit(void)
- {
- //
- rGPBCON &= 0xfffffffc; //清除
- rGPBCON |= 0x00000001; //置低位为0001,使PIN0输出
- }
- void BeeperControl(U8 flag)
- {
- if(flag)
- rGPBDAT |=0x00000001;
- else
- rGPBDAT &=0xfffffffe;
- }
- void LedInit(void)
- {
- //设置GPB PIN5678 输出
- rGPBCON &= 0xfffc03ff;
- rGPBCON |= (0x00000001<<10) |(0x00000001<<12)|(0x00000001<<14)|(0x00000001<<16);
- //rGPBCON |= 0x155555;
- }
- void LedControl(U8 led,U8 flag )
- {
- if(flag==0)
- rGPBDAT &= ~(0x00000001<<(led+4));
- else
- rGPBDAT |= (0x00000001<<(led+4));
- }
评论暂时关闭