Skip to content
Snippets Groups Projects
Commit 1ab8b3f7 authored by Irina BRADU's avatar Irina BRADU
Browse files

Merge branch 'slides/fils_en/05' into 'main'

Add lecture 05 - UART & SPI

See merge request pmrust/pmrust.pages.upb.ro!73
parents c20bc814 4112037e
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,7 @@ Lecture 5 ...@@ -27,7 +27,7 @@ Lecture 5
--- ---
# UART & SPI # UART & SPI
used by RP2040 used by RP2350
- Direct Memory Access - Direct Memory Access
- Buses - Buses
...@@ -35,7 +35,9 @@ used by RP2040 ...@@ -35,7 +35,9 @@ used by RP2040
- Serial Peripheral Interface - Serial Peripheral Interface
- Analog and Digital Sensors - Analog and Digital Sensors
<!-- DMA --> <!--
DMA
-->
--- ---
src: ../../resources/dma/slides.md src: ../../resources/dma/slides.md
......
...@@ -6,14 +6,13 @@ layout: section ...@@ -6,14 +6,13 @@ layout: section
Direct Memory Access Direct Memory Access
--- ---
---
# Bibliography # Bibliography
for this section for this section
**Raspberry Pi Ltd**, *[RP2040 Datasheet](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf)* **Raspberry Pi Ltd**, *[RP2350 Datasheet](https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf)*
- Chapter 2 - *System Description* - Chapter 12 - *Peripherals*
- Chapter 2.5 - *DMA* - Chapter 16.6 - *DMA*
--- ---
layout: two-cols layout: two-cols
......
...@@ -81,7 +81,7 @@ using synchronous/asynchronous SPI to read the `press_lsb` register of BMP280 ...@@ -81,7 +81,7 @@ using synchronous/asynchronous SPI to read the `press_lsb` register of BMP280
<div grid="~ cols-2 gap-5"> <div grid="~ cols-2 gap-5">
```rust{all|1|3,4|6,7|6,7,8|10,11|13,14} ```rust {1|3,4|6,7|6,7,8|10,11|13,14|all}
const REG_ADDR: u8 = 0xf8; const REG_ADDR: u8 = 0xf8;
// enable the sensor // enable the sensor
...@@ -98,7 +98,7 @@ cs.set_high(); ...@@ -98,7 +98,7 @@ cs.set_high();
let pressure_lsb = buf[1]; let pressure_lsb = buf[1];
``` ```
```rust{none|all|1|3,4|6,7,8|6,7,8,9|11,12|14,15} ```rust {none|1|3,4|6,7,8|6,7,8,9|11,12|14,15|all}
const REG_ADDR: u8 = 0xf8; const REG_ADDR: u8 = 0xf8;
// enable the sensor // enable the sensor
...@@ -118,9 +118,8 @@ let pressure_lsb = rx_buf[1]; ...@@ -118,9 +118,8 @@ let pressure_lsb = rx_buf[1];
</div> </div>
---
--- ---
# Writing to a digital sensor # Writing to a digital sensor
using synchronous/asynchronous SPI to set up the `ctrl_meas` register of the BMP280 sensor using synchronous/asynchronous SPI to set up the `ctrl_meas` register of the BMP280 sensor
...@@ -128,7 +127,7 @@ using synchronous/asynchronous SPI to set up the `ctrl_meas` register of the BMP ...@@ -128,7 +127,7 @@ using synchronous/asynchronous SPI to set up the `ctrl_meas` register of the BMP
<div grid="~ cols-2 gap-5"> <div grid="~ cols-2 gap-5">
```rust{all|1|3,4|6,7|9,10|9,10,11|13,14} ```rust {1|3,4|6,7|9,10|9,10,11|13,14|all}
const REG_ADDR: u8 = 0xf4; const REG_ADDR: u8 = 0xf4;
// see subchapters 3.3.2, 3.3.1 and 3.6 // see subchapters 3.3.2, 3.3.1 and 3.6
...@@ -145,7 +144,7 @@ spi.blocking_transfer_in_place(&mut buf); ...@@ -145,7 +144,7 @@ spi.blocking_transfer_in_place(&mut buf);
cs.set_high(); cs.set_high();
``` ```
```rust{none|all|1|3,4|6,7|9,10|9,10,11|9,10,11,12|14,15} ```rust {none|1|3,4|6,7|9,10|9,10,11|9,10,11,12|14,15|all}
const REG_ADDR: u8 = 0xf4; const REG_ADDR: u8 = 0xf4;
// see subchapters 3.3.2, 3.3.1 and 3.6 // see subchapters 3.3.2, 3.3.1 and 3.6
......
...@@ -4,15 +4,14 @@ layout: section ...@@ -4,15 +4,14 @@ layout: section
# SPI # SPI
Serial Peripheral Interface Serial Peripheral Interface
---
--- ---
# Bibliography # Bibliography
for this section for this section
1. **Raspberry Pi Ltd**, *[RP2040 Datasheet](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf)* 1. **Raspberry Pi Ltd**, *[RP2350 Datasheet](https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf)*
- Chapter 4 - *Peripherals* - Chapter 12 - *Peripherals*
- Chapter 4.4 - *SPI* - Chapter 12.3 - *SPI*
2. **Paul Denisowski**, *[Understanding SPI](https://www.youtube.com/watch?v=0nVNwozXsIc)* 2. **Paul Denisowski**, *[Understanding SPI](https://www.youtube.com/watch?v=0nVNwozXsIc)*
...@@ -213,21 +212,21 @@ activate all the **sub** devices ...@@ -213,21 +212,21 @@ activate all the **sub** devices
| Speed | *no limit* | does not have any limit, it is limited by the **main** clock and the electronics wirings | | Speed | *no limit* | does not have any limit, it is limited by the **main** clock and the electronics wirings |
--- ---
---
# Usage # Usage
- EEPROMs / Flash (usually in *QSPI* mode) - EEPROMs / Flash (usually in *QSPI* mode)
- Raspberry Pi Pico has its 2MB Flash connected using *QSPI* - Raspberry Pi Pico has its 2MB Flash connected using *QSPI*
- sensors - sensors
- small displays - small displays
- RP2040 has two SPI devices - RP2350 has two SPI devices
<div align="center"> <div align="center">
<img src="./raspberry_pi_pico_pins.jpg" class="rounded m-5 w-120"> <img src="../rp2350/pico2w-pinout.svg" class="rounded m-5 w-100">
</div> </div>
--- ---
---
# Embassy API # Embassy API
for RP2040, synchronous for RP2040, synchronous
...@@ -257,7 +256,7 @@ pub enum Polarity { ...@@ -257,7 +256,7 @@ pub enum Polarity {
</div> </div>
```rust{all|1|2|2,3|5-7|5-8|10,11|13|13,14|13,14,15|13,14,15,16} ```rust {1|2|2,3|5-7|5-8|10,11|13|13,14|13,14,15|13,14,15,16|all}
use embassy_rp::spi::Config as SpiConfig; use embassy_rp::spi::Config as SpiConfig;
let mut config = SpiConfig::default(); let mut config = SpiConfig::default();
config.frequency = 2_000_000; config.frequency = 2_000_000;
...@@ -277,11 +276,11 @@ cs.set_high(); ...@@ -277,11 +276,11 @@ cs.set_high();
``` ```
--- ---
---
# Embassy API # Embassy API
for RP2040, asynchronous for RP2040, asynchronous
```rust{all|1|2|2,3|5-7|5-8|10,11|13|13,14,15|13,14,15,16|13,14,15,16,17} ```rust {1|2|2,3|5-7|5-8|10,11|13|13,14,15|13,14,15,16|13,14,15,16,17|all}
use embassy_rp::spi::Config as SpiConfig; use embassy_rp::spi::Config as SpiConfig;
let mut config = SpiConfig::default(); let mut config = SpiConfig::default();
config.frequency = 2_000_000; config.frequency = 2_000_000;
......
...@@ -5,13 +5,13 @@ layout: section ...@@ -5,13 +5,13 @@ layout: section
Universal Asynchronous Receiver and Transmitter Universal Asynchronous Receiver and Transmitter
--- ---
---
# Bibliography # Bibliography
for this section for this section
1. **Raspberry Pi Ltd**, *[RP2040 Datasheet](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf)* 1. **Raspberry Pi Ltd**, *[RP2350 Datasheet](https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf)*
- Chapter 4 - *Peripherals* - Chapter 12 - *Peripherals*
- Chapter 4.2 - *UART* - Chapter 12.1 - *UART*
2. **Paul Denisowski**, *[Understanding Serial Protocols](https://www.youtube.com/watch?v=LEz5UCN3aHA)* 2. **Paul Denisowski**, *[Understanding Serial Protocols](https://www.youtube.com/watch?v=LEz5UCN3aHA)*
3. **Paul Denisowski**, *[Understanding UART](https://www.youtube.com/watch?v=sTHckUyxwp8)* 3. **Paul Denisowski**, *[Understanding UART](https://www.youtube.com/watch?v=sTHckUyxwp8)*
...@@ -193,21 +193,21 @@ using the 8N1 data format ...@@ -193,21 +193,21 @@ using the 8N1 data format
</div> </div>
--- ---
---
# Usage # Usage
- print debug information - print debug information
- device console - device console
- RP2040 has two USART devices - RP2350 has two USART devices
<div align="center"> <div align="center">
<img src="../rp2040/rp2040_adafruit_pinout.png" class="rounded m-5 w-100"> <img src="../rp2350/pico2w-pinout.svg" class="rounded m-5 w-100">
</div> </div>
--- ---
# Embassy API # Embassy API
for RP2040, synchronous for RP2350, synchronous
<div grid="~ cols-4 gap-5"> <div grid="~ cols-4 gap-5">
...@@ -250,7 +250,7 @@ pub enum Parity { ...@@ -250,7 +250,7 @@ pub enum Parity {
</div> </div>
```rust{all|1|1,2|4,5|6,7|9,10,11} ```rust {1|1,2|4,5|6,7|9,10,11|all}
use embassy_rp::uart::Config as UartConfig; use embassy_rp::uart::Config as UartConfig;
let config = UartConfig::default(); let config = UartConfig::default();
...@@ -264,13 +264,12 @@ let mut buf = [0; 5]; ...@@ -264,13 +264,12 @@ let mut buf = [0; 5];
uart.blocking_read(&mut buf); uart.blocking_read(&mut buf);
``` ```
--- ---
# Embassy API # Embassy API
for RP2040, asynchronous for RP2350, asynchronous
```rust{all|1|3-5|7|9,10|12,13|15,16,17} ```rust {1|3-5|7|9,10|12,13|15,16,17|all}
use embassy_rp::uart::Config as UartConfig; use embassy_rp::uart::Config as UartConfig;
bind_interrupts!(struct Irqs { bind_interrupts!(struct Irqs {
......
--- ---
sidebar_position: 5 sidebar_position: 5
description: Direct Memory Access, Serial Port and SPI, Analog and Digital Sensors description: Direct Memory Access, Serial Port and SPI, Analog and Digital Sensors
unlisted: true
--- ---
# 05 - UART & SPI # 05 - UART & SPI
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment