当前位置:网站首页>GPIO configuration of SOC
GPIO configuration of SOC
2022-06-28 07:40:00 【youbin2013】
SOC Of GPIO To configure
1 GPIO working principle
Soc Co integration 40 Two way GPIO, Every way GPIO The input / output direction of is controlled by the direction register , The input / output level value of the pin is saved in the corresponding input / Output value register . The external signal is input to the internal and then synchronized by three stages , refilter , The filter width can be configured through the corresponding filter width register , The filter width range supported is 0~63 Two system clock cycles . If the pulse width of the input signal can reach the set value of the register , Is allowed to be sampled , Otherwise it will be regarded as “ skin needling ” Filter .GPIO The output adopts register output , By writing GPIO The output value register directly outputs the signal to the outside through the pin .GPIO The structure of the module is shown in the figure 1 Shown :

chart 1 gpio structure
Be careful : There is a conflict between the data manual and the actual use , In the manual GPIO Yes 60 However, in the actual use process, only 40 road ,40 road GPIO There are two sets of registers for configuration ,0-9 road GPIO Using registers 1 Of 22-31 Bits to configure , after 30 With registers 2 Of 0-29 Bits to configure .
2 The configuration process
GPIO The configuration process is as follows :
- Enable the whole GPIO Peripheral clock , Configure peripheral clock registers ( The address is 0x40C00000) Of 24 Position as 1.
- The configuration pin is multiplexed to GPIO, Configure pin multiplexing register ( The address is 0x40C00004) Of the 2 Position and number 3 Position as 0x0, Both the interrupt multiplexing pin and the extended memory pin are configured as GPIO function .
- To configure GPIO Mode register GPIOEN device , Make corresponding IO Work for GPIO Mouth mode , If GPIO The number is less than 10 Then configure GPIOEN1 Corresponding IO The value of mouth is 0x1, If GPIO Number is greater than or equal to 10 Then configure GPIOEN2 Corresponding IO The value of mouth is 0x1.
- To configure GPIO Direction register GPIODIR, Configure its corresponding IO Is the port input or output , The corresponding bit is 1 Indicative output , The corresponding bit is 0 Indicates input .
- Set output IO The level of the port , To configure GPIO Output level register GPIOODR The corresponding bit of is 1 Indicates the output high level , The corresponding bit is 0 Indicates that the output is low .
- Get input IO Level value of port , obtain GPIO Input level register GPIOIDR The value of the corresponding bit of , if 1 Indicates that a high level is obtained , If 0 Indicates that the low level is obtained .
3 Data structure encapsulation
according to GPIO The distribution of module register addresses in the memory allocation graph , Define its address as an integer macro definition , The register is defined as the structural union of each functional bit field . In this way, the integer address is converted to the structural union pointer of the register , You can write the underlying driver through the register bit field , chart 1 Represents the definition and type conversion of the macro definition register , chart 2 Represents the register structure union definition .

chart 1


chart 2
边栏推荐
猜你喜欢

Leetcode learning records

GoLand IDE and delve debug Go programs in kubernetes cluster

Kubernetes deploys a secret pit where thanos ruler sends repeated alarms

Section VII starting principle and configuration of zynq

What is EC blower fan?
![[ thanos源码分析系列 ]thanos query组件源码简析](/img/e4/2a87ef0d5cee0cc1c1e1b91b6fd4af.png)
[ thanos源码分析系列 ]thanos query组件源码简析

Section 8: DMA of zynq

A gadget can write crawlers faster

kubernetes集群命令行工具kubectl

Section 9: dual core startup of zynq
随机推荐
卸载重装最新版mysql数据库亲测有效
数字藏品市场“三大套路”
Real time database - Notes
Flex layout
flex布局
Ice - resources
Vivo browser rapid development platform practice - Overview
打新债注册开户靠谱吗?安全吗?
Investment transaction and settlement of the fund
The practice of traffic and data isolation in vivo Reviews
open62541直接导入NodeSet文件
Design of DSP image data stream
Path alias specified in vite2.9
自动化测试的生命周期是什么?
8 张图 | 剖析 Eureka 的首次同步注册表
2021 VDC: technological architecture evolution of vivo Internet service for 100 million users | PPT download attached
Unity-UI-shadow组件
kubernetes删除pod的流程的源码简析
QT -- communication protocol
No suspense about the No. 1 Internet company overtime table