Stm32f303 target speed trivial check (#66)

* Check new I2C target_speed config setting

* Corrected incorrect doc comment
wch-ch32v003
Marnix Klooster 2 years ago committed by GitHub
parent e60d59ce49
commit e5b8d57c72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -148,8 +148,7 @@ pub const Pins = struct {
sda: ?type = null, sda: ?type = null,
}; };
/// A UART configuration. The config defaults to the *8N1* setting, so "8 data bits, no parity, 1 stop bit" which is the /// An I2C configuration.
/// most common serial format.
pub const Config = struct { pub const Config = struct {
/// The target speed in bit/s. Note that the actual speed can differ from this, due to prescaler rounding. /// The target speed in bit/s. Note that the actual speed can differ from this, due to prescaler rounding.
target_speed: u32, target_speed: u32,

@ -274,8 +274,6 @@ pub fn I2CController(comptime index: usize, comptime pins: micro.i2c.Pins) type
const Self = @This(); const Self = @This();
pub fn init(config: micro.i2c.Config) !Self { pub fn init(config: micro.i2c.Config) !Self {
// TODO: use config
_ = config;
// CONFIGURE I2C1 // CONFIGURE I2C1
// connected to APB1, MCU pins PB6 + PB7 = I2C1_SCL + I2C1_SDA, // connected to APB1, MCU pins PB6 + PB7 = I2C1_SCL + I2C1_SDA,
// if GPIO port B is configured for alternate function 4 for these PB pins. // if GPIO port B is configured for alternate function 4 for these PB pins.
@ -307,6 +305,7 @@ pub fn I2CController(comptime index: usize, comptime pins: micro.i2c.Pins) type
// 4-6. Configure I2C1 timing, based on 8 MHz I2C clock, run at 100 kHz // 4-6. Configure I2C1 timing, based on 8 MHz I2C clock, run at 100 kHz
// (Not using https://controllerstech.com/stm32-i2c-configuration-using-registers/ // (Not using https://controllerstech.com/stm32-i2c-configuration-using-registers/
// but copying an example from the reference manual, RM0316 section 28.4.9.) // but copying an example from the reference manual, RM0316 section 28.4.9.)
if (config.target_speed != 100_000) @panic("TODO: Support speeds other than 100 kHz");
regs.I2C1.TIMINGR.modify(.{ regs.I2C1.TIMINGR.modify(.{
.PRESC = 1, .PRESC = 1,
.SCLL = 0x13, .SCLL = 0x13,

Loading…
Cancel
Save