树莓派博通BCM2835芯片手册导读

驱动两大利器︰电路图(通过电路图找寄存器)和芯片手册。

寄存器

在这里插入图片描述

芯片手册第六章P89∶

字段名描述用法
GPFSEL0GPIO Function select 0,功能选择输出/输入以引脚9举例:000 = GPIO Pin 9 is an input
001 = GPIO Pin 9 is an output
GPSET0GPIO Pin output Set 0,输出00 = No effect
1 = Set GPIO pin n
GPSET1GPIO Pin output set 1,输出10 = No effect
1 = Set GPIO pin n
GPCLR0GPIO Pin output clear 0,清00 = No effect
1 = Clear GPIO pin n

文档中的功能说的非常清楚了,引脚输出是001,输入是000等等,我们的寄存器都是分组的,寄存器第0组是FESL0–9,寄存器第1组是FESL0–9…如图所示。

在这里插入图片描述

需要注意的是,我们寄存器对应的引脚是BCM,而不是wiringPi的引脚,如图所示。

在这里插入图片描述

更多的引脚详细介绍可以去树莓派官网查看

https://pinout.xyz/pinout/pin7_gpio4

在这里插入图片描述

我们在编写驱动程序的时候,IO空间的起始地址是0x3f000000,加上GPIO的偏移量0x2000000,所以GPIO的物理地址应该是从0x3f200000开始的,然后在这个基础上进行Linux系统的MMU内存虚拟化管理,映射到虚拟地址上。

特别注意,BCM2708 和BCM2709 IO起始地址不同,BCM2708是0x20000000,BCM2709是0x3f000000,这是造成大部分人驱动出现“段错误”的原因。树莓派3B的CPU为BCM2709。

通过对首图的尾部偏移,那么GPIO的物理地址0x3f200000的偏移也应如此。
GPFSEL0 0x3f200000
GPSET0 0x3f20001c
GPCLR0 0x3f200028

Table of Contents 1 Introduction 4 1.1 Overview 4 1.2 Address map 4 1.2.1 Diagrammatic overview 4 1.2.2 ARM virtual addresses (standard Linux kernel only) 6 1.2.3 ARM physical addresses 6 1.2.4 Bus addresses 6 1.3 Peripheral access precautions for correct memory ordering 7 2 Auxiliaries: UART1 & SPI1, SPI2 8 2.1 Overview 8 2.1.1 AUX registers 9 2.2 Mini UART 10 2.2.1 Mini UART implementation details. 11 2.2.2 Mini UART register details. 11 2.3 Universal SPI Master (2x) 20 2.3.1 SPI implementation details 20 2.3.2 Interrupts 21 2.3.3 Long bit streams 21 2.3.4 SPI register details. 22 3 BSC 28 3.1 Introduction 28 3.2 Register View 28 3.3 10 Bit Addressing 36 4 DMA Controller 38 4.1 Overview 38 4.2 DMA Controller Registers 39 4.2.1 DMA Channel Register Address Map 40 4.3 AXI Bursts 63 4.4 Error Handling 63 4.5 DMA LITE Engines 63 5 External Mass Media Controller 65 o Introduction 65 o Registers 66 6 General Purpose I/O (GPIO) 89 6.1 Register View 90 6.2 Alternative Function Assignments 102 6.3 General Purpose GPIO Clocks 105 7 Interrupts 109 7.1 Introduction 109 7.2 Interrupt pending. 110 7.3 Fast Interrupt (FIQ). 110 7.4 Interrupt priority. 110 7.5 Registers 112 8 PCM / I2S Audio 119 8.1 Block Diagram 120 8.2 Typical Timing 120 8.3 Operation 121 8.4 Software Operation 122 8.4.1 Operating in Polled mode 122 8.4.2 Operating in Interrupt mode 123 8.4.3 DMA 123 8.5 Error Handling. 123 8.6 PDM Input Mode Operation 124 8.7 GRAY Code Input Mode Operation 124 8.8 PCM Register Map 125 9 Pulse Width Modulator 138 9.1 Overview 138 9.2 Block Diagram 138 9.3 PWM Implementation 139 9.4 Modes of Operation 139 9.5 Quick Reference 140 9.6 Control and Status Registers 141 10 SPI 148 10.1 Introduction 148 10.2 SPI Master Mode 148 10.2.1 Standard mode 148 10.2.2 Bidirectional mode 149 10.3 LoSSI mode 150 10.3.1 Command write 150 10.3.2 Parameter write 150 10.3.3 Byte read commands 151 10.3.4 24bit read command 151 10.3.5 32bit read command 151 10.4 Block Diagram 152 10.5 SPI Register Map 152 10.6 Software Operation 158 10.6.1 Polled 158 10.6.2 Interrupt 158 10.6.3 DMA 158 10.6.4 Notes 159 11 SPI/BSC SLAVE 160 11.1 Introduction 160 11.2 Registers 160 12 System Timer 172 12.1 System Timer Registers 172 13 UART 175 13.1 Variations from the 16C650 UART 175 13.2 Primary UART Inputs and Outputs 176 13.3 UART Interrupts 176 13.4 Register View 177 14 Timer (ARM side) 196 14.1 Introduction 196 14.2 Timer Registers: 196 15 USB 200 15.1 Configuration 200 15.2 Extra / Adapted registers. 202
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

石子君

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值