博客
来源:互联网 发布:淘宝销量信誉互刷平台 编辑:程序博客网 时间:2024/05/16 13:38
#include "s3c2451_gpio.h"
GPIO_MemMapPtr const PORT_BASE_PTR[7] = {GPIOA_BASE_PTR,GPIOB_BASE_PTR,GPIOC_BASE_PTR,GPIOD_BASE_PTR,GPIOE_BASE_PTR,GPIOF_BASE_PTR,GPIOG_BASE_PTR};
void GPIO_Init(GPIO_Typedef portx,GPIO_Init_Typedef gpio_init_struct)
{
U8 i=0;
for(i=0;i<32;i++)
{
if((gpio_init_struct.pinx&(1<<i)) == (1<<i))
{
//select mode
if(GPIOA ==portx)
{
if(gpio_init_struct.mode == GPIO_MODE_OUT)
{
PORT_BASE_PTR[portx]->GPCON &= ~(1<<i);
}
else if(gpio_init_struct.mode == GPIO_MODE_ALT)
{
PORT_BASE_PTR[portx]->GPCON |= (1<<i);
}
}else{
PORT_BASE_PTR[portx]->GPCON &= ~(3<<(2*i));
PORT_BASE_PTR[portx]->GPCON |= (gpio_init_struct.mode<<(2*i));
//pull - up
PORT_BASE_PTR[portx]->GPUDP &= ~(3<<(2*i));
PORT_BASE_PTR[portx]->GPUDP |= (gpio_init_struct.udp<<(2*i));
}
}
}
}
void GPIO_WriteBit(GPIO_Typedef portx,U32 pinx,BIT_Typedef bit)
{
if( BIT_SET == bit)
{
PORT_BASE_PTR[portx]->GPDAT |= pinx;
}else
{
PORT_BASE_PTR[portx]->GPDAT &= ~pinx;
}
}
BIT_Typedef GPIO_ReadBit(GPIO_Typedef portx,U32 pinx)
{
if((PORT_BASE_PTR[portx]->GPDAT & pinx) == pinx)
{
return BIT_SET;
}else
{
return BIT_RESET;
}
}
- 博客
- 博客
- 博客
- 博客
- 博客
- 博客
- 博客
- 博客
- 博客
- 博客
- 博客
- 博客
- 博客
- 博客
- 博客
- 博客
- 博客
- 博客
- 如何配置Linux网卡
- 在POM配置Maven plugin提示错误“Plugin execution not covered by lifecycle configuration”的解决方案
- sun.misc.BASE64Encoder找不到jar包的解决方法
- Codeforces Round #394 (Div. 2) A. Dasha and Stairs 易错
- spoj XXXXXXXX
- 博客
- Maven私服Nexus3.x环境构建操作记录
- Spring Boot 框架介绍和使用
- OpenGL ES总结(四)OpenGL 渲染视频画面
- 不要使用sun.misc.BASE64Encoder
- 001-使用OpenVR开发时,VR头显无法正常工作
- ACMpoj 1953斐波拉契数列
- H5混合开发 js与java相互调用
- 延时的任务可以不等待延时期满