From e6ebb190376a5fb6eb5062a65008bfa8fc982ab8 Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Tue, 2 Feb 2021 02:25:21 +1300 Subject: [PATCH] Update the examples in the README to newer APIs --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 882ba00..8eba8b2 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ This library provides a set of reusable components for the Arduino Uno. ### Register and bit definitions ```rust -use ruduino::PORTB; // Register -use ruduino::PORTB7; // Pin +use ruduino::cores::current::PORTB; // Register +use ruduino::cores::current::PORTB7; // Pin ``` ### Prelude @@ -26,11 +26,10 @@ without_interrupts(|| { Configure a timer. ```rust -const CPU_FREQUENCY_HZ: u64 = 16_000_000; const DESIRED_HZ_TIM1: f64 = 2.0; const TIM1_PRESCALER: u64 = 1024; const INTERRUPT_EVERY_1_HZ_1024_PRESCALER: u16 = - ((CPU_FREQUENCY_HZ as f64 / (DESIRED_HZ_TIM1 * TIM1_PRESCALER as f64)) as u64 - 1) as u16; + ((ruduino::config::CPU_FREQUENCY_HZ as f64 / (DESIRED_HZ_TIM1 * TIM1_PRESCALER as f64)) as u64 - 1) as u16; timer1::Timer::new() .waveform_generation_mode(timer1::WaveformGenerationMode::ClearOnTimerMatchOutputCompare) @@ -54,9 +53,8 @@ pub unsafe extern "avr-interrupt" fn _ivr_timer1_compare_a() { Configure the serial port. ```rust -const CPU_FREQUENCY_HZ: u64 = 16_000_000; const BAUD: u64 = 9600; -const UBRR: u16 = (CPU_FREQUENCY_HZ / 16 / BAUD - 1) as u16; +const UBRR: u16 = (ruduino::config::CPU_FREQUENCY_HZ / 16 / BAUD - 1) as u16; serial::Serial::new(UBRR) .character_size(serial::CharacterSize::EightBits) @@ -82,3 +80,4 @@ if let Some(b) = serial::try_receive() { serial::transmit(b); } ``` +