Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • pmrust/pmrust.pages.upb.ro
  • genan.omer/pmrust.pages.upb.ro
  • vladut.chintoiu/pmrust.pages.upb.ro
  • petru.nania/website-pmrust-fork
  • sofia.huzan/pmrust.pages.upb.ro
  • ionut.pruteanu2308/arcade-game
  • luana.militaru/pong-game
  • sebastian.scrob/project
  • matei.bejinaru/website-bejinaru-matei
  • adragomir2806/website-dragomir-alexandru
  • fatemehsadat/pmrust.pages.upb.ro
  • razvan.costea2205/pmrust.pages.upb.ro
  • darius_gabriel.iuga/pm-website
  • andrei.neagu1910/pmrust.pages.upb.ro
  • irina.chiorean/pmrust.pages.upb.ro
  • adrian_costin.lungu/pmrust.pages.upb.ro
  • andrei.salavastru/pmrust.pages.upb.ro
17 results
Show changes
Showing
with 985 additions and 145 deletions
......@@ -6,11 +6,13 @@
},
{
"name": "SDA",
"wave": "1..0.1.......0.4.4.7.2.4.4.4.4.4.4.4.4.2.9......|..2.01.",
"data": ["a9", "a8",
"r/w",
"ack",
"a7",
"wave": "1..0.1.......0.4.4.7.2.4.4.4.4.4.4.4.4.2.9..|2.9..|2.01.",
"data": [
"a9",
"a8",
"r/w",
"ack",
"a7",
"a6",
"a5",
"a4",
......@@ -19,7 +21,9 @@
"a1",
"a0",
"ack",
"byte1 | byte2 ... ",
"byte1",
"ack",
"byte2",
"ack"
],
"phase": 1.5
......@@ -31,7 +35,7 @@
"start",
"upper addr",
"cmd",
"lower address",
"lower address",
"payload bytes",
"stop"
],
......@@ -41,4 +45,4 @@
"config": {
"skin": "narrow"
}
}
}
\ No newline at end of file
......@@ -10,9 +10,9 @@ Inter-Integrated Circuit
# Bibliography
for this section
1. **Raspberry Pi Ltd**, *[RP2040 Datasheet](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf)*
- Chapter 4 - *Peripherals*
- Chapter 4.3 - *I2C*
1. **Raspberry Pi Ltd**, *[RP2350 Datasheet](https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf)*
- Chapter 12 - *Peripherals*
- Chapter 12.2 - *I2C*
2. **Paul Denisowski**, *[Understanding I2C](https://www.youtube.com/watch?v=CAvawEcxoPU)*
......@@ -196,7 +196,7 @@ Transmission
- sensors
- small displays
- RP2040 has two I2C devices
- RP2350 has two I2C devices
<div align="center">
<img src="./raspberry_pi_pico_pins.jpg" class="rounded m-5 w-120">
......@@ -205,7 +205,7 @@ Transmission
---
---
# Embassy API
for RP2040, synchronous
for RP2350, synchronous
<div grid="~ cols-3 gap-5">
......@@ -237,12 +237,11 @@ pub enum Error {
</div>
```rust{all|1|3,4|6|8,9|11,12}
```rust {1|3,4|3-5|7,8|10,11|13|all}
use embassy_rp::i2c::Config as I2cConfig;
let sda = p.PIN_14;
let scl = p.PIN_15;
let mut i2c = i2c::I2c::new_blocking(p.I2C1, scl, sda, I2cConfig::default());
let tx_buf = [0x90];
......@@ -250,14 +249,16 @@ i2c.write(0x5e, &tx_buf).unwrap();
let mut rx_buf = [0x00u8; 7];
i2c.read(0x5e, &mut rx_buf).unwrap();
i2c.write_read(0x5e, &tx_buf, &mut rx_buf).unwrap();
```
---
---
# Embassy API
for RP2040, asynchronous
for RP2350, asynchronous
```rust{all|1|3-5|7,8|10|12,13|15,16}
```rust {1|3-5|7,8|7-9|11,12|14,15|17|all}
use embassy_rp::i2c::Config as I2cConfig;
bind_interrupts!(struct Irqs {
......@@ -266,7 +267,6 @@ bind_interrupts!(struct Irqs {
let sda = p.PIN_14;
let scl = p.PIN_15;
let mut i2c = i2c::I2c::new_async(p.I2C1, scl, sda, Irqs, I2cConfig::default());
let tx_buf = [0x90];
......@@ -274,4 +274,6 @@ i2c.write(0x5e, &tx_buf).await.unwrap();
let mut rx_buf = [0x00u8; 7];
i2c.read(0x5e, &mut rx_buf).await.unwrap();
i2c.write_read(0x5e, &tx_buf, &mut rx_buf).await.unwrap();
```
......@@ -81,7 +81,7 @@ using synchronous/asynchronous SPI to read the `press_lsb` register of BMP280
<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;
// enable the sensor
......@@ -98,7 +98,7 @@ cs.set_high();
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;
// enable the sensor
......@@ -118,9 +118,8 @@ let pressure_lsb = rx_buf[1];
</div>
---
---
# Writing to a digital 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
<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;
// see subchapters 3.3.2, 3.3.1 and 3.6
......@@ -145,7 +144,7 @@ spi.blocking_transfer_in_place(&mut buf);
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;
// see subchapters 3.3.2, 3.3.1 and 3.6
......
......@@ -81,27 +81,29 @@ using synchronous/asynchronous I2C to read the `press_lsb` register of BMP280
<div grid="~ cols-2 gap-5">
```rust{all|1|1,2|4|6,7|9,10}
```rust {all|1|1,2|4|6,7,8|10,11|all}
const DEVICE_ADDR: u8 = 0x77;
const REG_ADDR: u8 = 0xf8;
i2c.write(DEVICE_ADDR, &[REG_ADDR]).unwrap();
let mut buf = [0x00u8];
i2c.read(DEVICE_ADDR, &mut buf).unwrap();
i2c.write_read(
DEVICE_ADDR, &[REG_ADDR], &mut buf
).unwrap();
// use the value
let pressure_lsb = buf[1];
```
```rust{none|all||1|1,2|4|6,7|9,10}
```rust {none|1|1,2|4|6,7,8|10,11|all}
const DEVICE_ADDR: u8 = 0x77;
const REG_ADDR: u8 = 0xf8;
i2c.write(DEVICE_ADDR, &[REG_ADDR]).await.unwrap();
let mut buf = [0x00u8];
i2c.read(DEVICE_ADDR, &mut buf).await.unwrap();
i2c.write_read(
DEVICE_ADDR, &[REG_ADDR], &mut buf
).await.unwrap();
// use the value
let pressure_lsb = buf[1];
......@@ -109,7 +111,6 @@ let pressure_lsb = buf[1];
</div>
---
---
# Writing to a digital sensor
......@@ -119,28 +120,24 @@ using synchronous/asynchronous I2C to set up the `ctrl_meas` register of the BMP
<div grid="~ cols-2 gap-5">
```rust{all|1|1,2|4,5|7|9,10}
```rust {1|1,2|4,5|7,8|all}
const DEVICE_ADDR: u8 = 0x77;
const REG_ADDR: u8 = 0xf4;
// see subchapters 3.3.2, 3.3.1 and 3.6
let value = 0b100_010_11;
i2c.write(DEVICE_ADDR, &[REG_ADDR]);
let buf = [REG_ADDR, value];
i2c.write(DEVICE_ADDR, &buf).unwrap();
```
```rust{none|all|1|1,2|4,5|7|9,10}
```rust {none|1|1,2|4,5|7,8|all}
const DEVICE_ADDR: u8 = 0x77;
const REG_ADDR: u8 = 0xf4;
// see subchapters 3.3.2, 3.3.1 and 3.6
let value = 0b100_010_11;
i2c.write(DEVICE_ADDR, &[REG_ADDR]);
let buf = [REG_ADDR, value];
i2c.write(DEVICE_ADDR, &buf).await.unwrap();
```
......
......@@ -4,15 +4,14 @@ layout: section
# SPI
Serial Peripheral Interface
---
---
# Bibliography
for this section
1. **Raspberry Pi Ltd**, *[RP2040 Datasheet](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf)*
- Chapter 4 - *Peripherals*
- Chapter 4.4 - *SPI*
1. **Raspberry Pi Ltd**, *[RP2350 Datasheet](https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf)*
- Chapter 12 - *Peripherals*
- Chapter 12.3 - *SPI*
2. **Paul Denisowski**, *[Understanding SPI](https://www.youtube.com/watch?v=0nVNwozXsIc)*
......@@ -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 |
---
---
# Usage
- EEPROMs / Flash (usually in *QSPI* mode)
- Raspberry Pi Pico has its 2MB Flash connected using *QSPI*
- sensors
- small displays
- RP2040 has two SPI devices
- RP2350 has two SPI devices
<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>
---
---
# Embassy API
for RP2040, synchronous
......@@ -257,7 +256,7 @@ pub enum Polarity {
</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;
let mut config = SpiConfig::default();
config.frequency = 2_000_000;
......@@ -277,11 +276,11 @@ cs.set_high();
```
---
---
# Embassy API
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;
let mut config = SpiConfig::default();
config.frequency = 2_000_000;
......
......@@ -5,13 +5,13 @@ layout: section
Universal Asynchronous Receiver and Transmitter
---
---
# Bibliography
for this section
1. **Raspberry Pi Ltd**, *[RP2040 Datasheet](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf)*
- Chapter 4 - *Peripherals*
- Chapter 4.2 - *UART*
1. **Raspberry Pi Ltd**, *[RP2350 Datasheet](https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf)*
- Chapter 12 - *Peripherals*
- Chapter 12.1 - *UART*
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)*
......@@ -193,21 +193,21 @@ using the 8N1 data format
</div>
---
---
# Usage
- print debug information
- device console
- RP2040 has two USART devices
- RP2350 has two USART devices
<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>
---
# Embassy API
for RP2040, synchronous
for RP2350, synchronous
<div grid="~ cols-4 gap-5">
......@@ -250,7 +250,7 @@ pub enum Parity {
</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;
let config = UartConfig::default();
......@@ -264,13 +264,12 @@ let mut buf = [0; 5];
uart.blocking_read(&mut buf);
```
---
# 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;
bind_interrupts!(struct Irqs {
......
This diff is collapsed.
......@@ -398,12 +398,12 @@ Blink:
3. Write a firmware that changes the RED LED's intensity, using switch **SW_4** and switch **SW_5**. Switch **SW_4** will increase the intensity, and switch **SW_5** will decrease it. You will implement this in three ways: (**3p**)
1. Use three tasks : `main` to control the LED and another two for each button (one for switch **SW_4**, one for switch **SW_5**). Use a [`Channel`](#channel) to send commands from each button task to the main task.
1. Use three tasks : one task will be the `main` to control the LED and another two tasks for each button (one for switch **SW_4**, one for switch **SW_5**). Use a [`Channel`](#channel) to send commands from each button task to the main task.
:::tip
Use an `enum` to define the LED Intensity change command for point i.
:::
2. Use a single task (`main`). Use [`select`](#select) to check which of the buttons were pressed and change the LED intensity accordingly.
3. Use two tasks: `main` to control the LED and another one for both buttons. Use a [`Signal`](#signal) channel to transmit from the buttons task, the new value of the intensity which the LED will be set to. The `main` will wait for a new value on the `Signal` channel and change the intensity accordingly.
3. Use two tasks: one taks will be the `main` to control the LED and another one for both buttons. Use a [`Signal`](#signal) channel to transmit from the buttons task, the new value of the intensity which the LED will be set to. The `main` will wait for a new value on the `Signal` channel and change the intensity accordingly.
:::tip
Instead of sending commands over the channel like you did at point i, send the intensity value as a number.
:::
......@@ -439,9 +439,11 @@ However if the switch **SW4** is pressed the state of traffic light changes imme
For this exercise you only need one task. Define an `enum` to save the traffic light state (`Green`, `Yellow`,`Red`). Use `match` to check the current state of the traffic light. Then you need to wait for two futures, since the traffic light changes its color either because some time has elapsed or because the button was pressed. Use `select` to check which future completes first (`Timer` or button press).
:::
5. Continue exercise 4: this time, if switch **SW4** and switch **SW7** are pressed consecutively, change the state of the traffic light. Use `join` to check that both switches were pressed. (**1p**)
5. Continue exercise 4: this time, instead of using only the switch **SW4** to change the state of traffic light, we will use the switches **SW4** and **SW7** pressed consecutively to trigger a state change of the traffic light. Use `join` to check that both switches were pressed. (**1p**)
:::note
The switches don't need to be pressed at the same time, but one after the other. The order does not matter.
The traffic light transitions between states either based on the elapsed time or through pressing the switches as described above.
:::
6. Continue exercise 5:
......
website/lab/05/images/bmp280_wiring.png

181 KiB

website/lab/05/images/buzzer.png

107 KiB

website/lab/05/images/mpu6500_wiring.png

262 KiB

website/lab/05/images/pico-2-r4-pinout.png

174 KiB

website/lab/05/images/pico_pinout.png

174 KiB

website/lab/05/images/screen_wiring.png

389 KiB

website/lab/05/images/spi_read_write_bmp280.png

81 KiB

website/lab/05/images/spi_read_write_mpu6500.png

33.4 KiB

website/lab/06/images/J10_Breakout.png

501 KiB