当前位置:网站首页>【位带操作对寄存器赋值】基于ADuCM4050的GPIO复用模式初始化
【位带操作对寄存器赋值】基于ADuCM4050的GPIO复用模式初始化
2022-08-07 09:14:00 【网易独家音乐人Mike Zhou】
【位带操作对寄存器赋值】基于ADuCM4050的GPIO复用模式初始化
#define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2))
#define MEM_ADDR(addr) *((volatile unsigned long *)(addr))
#define BIT_ADDR(addr, bitnum) MEM_ADDR(BITBAND(addr, bitnum))
#define GPIO0_MUL_Addr (ADI_GPIO0_BASE+0) //0x40020000
#define P0_M(n) BIT_ADDR(GPIO0_MUL_Addr,n)
#define GPIO1_MUL_Addr (ADI_GPIO1_BASE+0) //0x40020000
#define P1_M(n) BIT_ADDR(GPIO1_MUL_Addr,n)
#define GPIO2_MUL_Addr (ADI_GPIO2_BASE+0) //0x40020000
#define P2_M(n) BIT_ADDR(GPIO2_MUL_Addr,n)
#define GPIO3_MUL_Addr (ADI_GPIO3_BASE+0) //0x40020000
#define P3_M(n) BIT_ADDR(GPIO3_MUL_Addr,n)
void mux_GPIO(uint8_t ports,uint8_t pins,uint8_t mux)
{
uint8_t a,b;
a = pins*2-1;
b = pins*2;
uint8_t c,d;
c=mux>>1;
c=0x01 & c;
d=0x01 & mux;
if(ports == 0)
{
P0_M(a) = c;
P0_M(b) = d;
}
else if(ports == 1)
{
P1_M(a) = c;
P1_M(b) = d;
}
else if(ports == 2)
{
P2_M(a) = c;
P2_M(b) = d;
}
else if(ports == 3)
{
P3_M(a) = c;
P3_M(b) = d;
}
else{
}
}
边栏推荐
猜你喜欢

LeetCode【206.反转链表】(1)

redis的原理和源码-事务机制

New in ABP 6.0.0-rc.1

window.requestAnimationFrame Web3D渲染帧率控制

4.2 实现注册与登录模块

LeetCode #100. 相同的树

运筹学基础【二】 之 预测

Today's sleep quality record 74 points

Unity 3D 游戏通用系统设置页面,自定义按键设置,背景虚化,图像设置,亮度对比度饱和度音量调节,分辨率窗口化,帧率垂直同步,抗锯齿,阴影质量,纹理质量设置

【正点原子STM32连载】第六章 新建寄存器版本MDK工程 摘自【正点原子】MiniPro STM32H750 开发指南_V1.1
随机推荐
Prediction of Operations Research Fundamentals [2]
背包理论之01背包
The principle and source code of redis-server introduction and source code analysis (execution process of command request, server initialization process)
The principle and source code of redis - the principle and source code analysis of cluster (on)
基于密码芯片的 DDR 加速器的设计与实现
3. Advanced ROS communication mechanism
力扣:1049. 最后一块石头的重量 II
(一)UPF之电源网络(Supply_port、Supply_net、Supply_set)
redis的原理和源码-数据持久化方式AOF的介绍和源码解析
Canvas image drawing (with zoom in, zoom out and drag functions)
数组的创建以及常见的方法
multiplexing technology
思维和方法:冯诺依曼代码分析法:高效阅读理解和写代码
关于在物联网公司实习这几天的收获
ABP 6.0.0-rc.1的新特性
redis的原理和源码-sentinel哨兵的原理和源码解析(上)
电商数仓笔记1(数据仓库概念,项目需求及架构设计,数据生成模块)
An API writing method
The principle and source code of redis-sentinel sentinel principle and source code analysis (on)
背包理论之01背包(滚动数组)