Comments (2)
I will try to start this. Probably I will have lot of questions...
- This is the
generic algorithm
mentioned by youlet brr = CLOCK::FREQ / (16 * baud) - 1;
? Baundrate
should be defined as distinct file under generic src like Clock?
from avr-hal.
This is the generic algorithm mentioned by you let brr = CLOCK::FREQ / (16 * baud) - 1;?
Yes, it's this code:
avr-hal/avr-hal-generic/src/serial.rs
Lines 56 to 58 in bad9277
In comparison, Arduino upstream uses this code:
// Try u2x mode first
uint16_t baud_setting = (F_CPU / 4 / baud - 1) / 2;
*_ucsra = 1 << U2X0;
// hardcoded exception for 57600 for compatibility with the bootloader
// shipped with the Duemilanove and previous boards and the firmware
// on the 8U2 on the Uno and Mega 2560. Also, The baud_setting cannot
// be > 4095, so switch back to non-u2x mode if the baud rate is too
// low.
if (((F_CPU == 16000000UL) && (baud == 57600)) || (baud_setting >4095))
{
*_ucsra = 0;
baud_setting = (F_CPU / 8 / baud - 1) / 2;
}
// assign the baud_setting, a.k.a. ubrr (USART Baud Rate Register)
*_ubrrh = baud_setting >> 8;
*_ubrrl = baud_setting;
Baundrate should be defined as distinct file under generic src like Clock?
No, I'd prefer putting that in avr-hal-generic/src/serial.rs
as it is very closely tied to it.
Probably I will have lot of questions...
Sure, please don't hesitate asking if anything is unclear!
from avr-hal.
Related Issues (20)
- Ravedude freezes on programmer uploading HOT 5
- Arduino Nano: avrdude error: programmer is not responding HOT 11
- Watchdog intterupt mode HOT 1
- [Solved] Cannot find `pwm` in `embedded_hal` HOT 2
- peripherals type alias HOT 2
- Enhance `avr_hal_generic::renamed_pins! {}` to also generate type aliases for each pin
- tier 3 target and broken HOT 6
- Utilising the `atmega2560`'s "USART in SPI Mode" HOT 10
- Issue with math calculations with floats to serial port output HOT 6
- Incorrect ADC readings after toolchain bump HOT 15
- Weird issue with two u8 ranged loops HOT 14
- error: no matching package named `avr-hal` found HOT 7
- Serial writes aren't working on `rustc 1.82.0-nightly (8e86c9567 2024-08-01)` HOT 12
- Possible miscompilation in LLVM HOT 14
- Can't specify different upload and monitor serial ports. HOT 3
- Ravedude Console Timeout HOT 1
- Document new Ravedude.toml manifest HOT 1
- Compiler Rejects Floats (Defined twice?) HOT 3
- Making a tri-state pin (switching between input and output), perhaps like `embedded_hal::digital::IoPin` HOT 4
- Conformity of SPI implementation with embedded_hal::spi::SpiBus trait HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avr-hal.