From dfbcd444ddeb4156bd647a44467162c80804b390 Mon Sep 17 00:00:00 2001 From: Andre Richter Date: Tue, 21 Jul 2020 17:48:07 +0200 Subject: [PATCH] Update some readmes --- 06_drivers_gpio_uart/README.md | 10 +++++++--- 07_uart_chainloader/README.md | 4 ++-- 08_timestamps/README.md | 2 +- 14_exceptions_part2_peripheral_IRQs/README.md | 12 ++++++------ 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/06_drivers_gpio_uart/README.md b/06_drivers_gpio_uart/README.md index 2c54731a..bf140013 100644 --- a/06_drivers_gpio_uart/README.md +++ b/06_drivers_gpio_uart/README.md @@ -275,7 +275,7 @@ diff -uNr 05_safe_globals/src/bsp/device_driver/bcm/bcm2xxx_gpio.rs 06_drivers_g diff -uNr 05_safe_globals/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs 06_drivers_gpio_uart/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs --- 05_safe_globals/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs +++ 06_drivers_gpio_uart/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs -@@ -0,0 +1,307 @@ +@@ -0,0 +1,311 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// +// Copyright (c) 2018-2020 Andre Richter @@ -452,8 +452,12 @@ diff -uNr 05_safe_globals/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs 06_dri + + /// Set up baud rate and characteristics. + /// -+ /// Results in 8N1 and 230400 baud (if the clk has been previously set to 48 MHz by the -+ /// firmware). ++ /// The calculation for the BRD given a target rate of 2300400 and a clock set to 48 MHz is: ++ /// `(48_000_000/16)/230400 = 13,02083`. `13` goes to the `IBRD` (integer field). The `FBRD` ++ /// (fractional field) is only 6 bits so `0,0208*64 = 1,3312 rounded to 1` will give the best ++ /// approximation we can get. A 5 modulo error margin is acceptable for UART and we're now at 0,01 modulo. ++ /// ++ /// This results in 8N1 and 230400 baud (we set the clock to 48 MHz in config.txt). + pub fn init(&mut self) { + // Turn it off temporarily. + self.registers.CR.set(0); diff --git a/07_uart_chainloader/README.md b/07_uart_chainloader/README.md index f5af6405..a342893a 100644 --- a/07_uart_chainloader/README.md +++ b/07_uart_chainloader/README.md @@ -197,7 +197,7 @@ diff -uNr 06_drivers_gpio_uart/src/_arch/aarch64/cpu.rs 07_uart_chainloader/src/ diff -uNr 06_drivers_gpio_uart/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs 07_uart_chainloader/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs --- 06_drivers_gpio_uart/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs +++ 07_uart_chainloader/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs -@@ -267,6 +267,16 @@ +@@ -271,6 +271,16 @@ let mut r = &self.inner; r.lock(|inner| fmt::Write::write_fmt(inner, args)) } @@ -214,7 +214,7 @@ diff -uNr 06_drivers_gpio_uart/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs 0 } impl console::interface::Read for PL011Uart { -@@ -278,18 +288,21 @@ +@@ -282,18 +292,21 @@ cpu::nop(); } diff --git a/08_timestamps/README.md b/08_timestamps/README.md index 8421db63..bc599b28 100644 --- a/08_timestamps/README.md +++ b/08_timestamps/README.md @@ -227,7 +227,7 @@ diff -uNr 07_uart_chainloader/src/_arch/aarch64/time.rs 08_timestamps/src/_arch/ diff -uNr 07_uart_chainloader/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs 08_timestamps/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs --- 07_uart_chainloader/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs +++ 08_timestamps/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs -@@ -288,11 +288,18 @@ +@@ -292,11 +292,18 @@ cpu::nop(); } diff --git a/14_exceptions_part2_peripheral_IRQs/README.md b/14_exceptions_part2_peripheral_IRQs/README.md index 112de42d..b0f592e4 100644 --- a/14_exceptions_part2_peripheral_IRQs/README.md +++ b/14_exceptions_part2_peripheral_IRQs/README.md @@ -1893,7 +1893,7 @@ diff -uNr 13_integrated_testing/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs } //-------------------------------------------------------------------------------------------------- -@@ -186,6 +238,10 @@ +@@ -190,6 +242,10 @@ self.registers .LCRH .write(LCRH::WLEN::EightBit + LCRH::FEN::FifosEnabled); // 8N1 + Fifo on @@ -1904,7 +1904,7 @@ diff -uNr 13_integrated_testing/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs self.registers .CR .write(CR::UARTEN::Enabled + CR::TXE::Enabled + CR::RXE::Enabled); -@@ -203,6 +259,35 @@ +@@ -207,6 +263,35 @@ self.chars_written += 1; } @@ -1940,7 +1940,7 @@ diff -uNr 13_integrated_testing/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs } /// Implementing `core::fmt::Write` enables usage of the `format_args!` macros, which in turn are -@@ -228,9 +313,10 @@ +@@ -232,9 +317,10 @@ /// # Safety /// /// - The user must ensure to provide the correct `base_addr`. @@ -1953,7 +1953,7 @@ diff -uNr 13_integrated_testing/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs } } } -@@ -251,6 +337,21 @@ +@@ -255,6 +341,21 @@ Ok(()) } @@ -1975,7 +1975,7 @@ diff -uNr 13_integrated_testing/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs } impl console::interface::Write for PL011Uart { -@@ -282,25 +383,7 @@ +@@ -286,25 +387,7 @@ impl console::interface::Read for PL011Uart { fn read_char(&self) -> char { let mut r = &self.inner; @@ -2002,7 +2002,7 @@ diff -uNr 13_integrated_testing/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs } fn clear(&self) { -@@ -325,3 +408,25 @@ +@@ -329,3 +412,25 @@ r.lock(|inner| inner.chars_read) } }