aboutsummaryrefslogtreecommitdiffstats
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/picardy/src/main.rs53
1 files changed, 35 insertions, 18 deletions
diff --git a/sw/picardy/src/main.rs b/sw/picardy/src/main.rs
index b7b2dad..71c8475 100644
--- a/sw/picardy/src/main.rs
+++ b/sw/picardy/src/main.rs
@@ -32,7 +32,7 @@ use panic_semihosting as _;
use stm32f1xx_hal::{
prelude::*,
pac,
- i2c::{BlockingI2c, Mode},
+ i2c::{BlockingI2c, Mode, DutyCycle},
delay::Delay,
timer::{Timer},
};
@@ -75,27 +75,22 @@ fn main() -> ! {
let mut led = gpiob.pb14.into_push_pull_output(&mut gpiob.crh);
led.set_low().unwrap();
- loop {
- led.toggle().unwrap();
- delay.delay_ms(500u16);
- }
-
let c1 = gpioa.pa6;
let c2 = gpioa.pa7;
let qei = Timer::tim3(dp.TIM3, &clocks, &mut rcc.apb1)
.qei((c1, c2), &mut afio.mapr);
- // Configure I2C1 to be used for Si5351 and display
- let scl = gpiob.pb6.into_alternate_open_drain(&mut gpiob.crl);
- let sda = gpiob.pb7.into_alternate_open_drain(&mut gpiob.crl);
+ // Configure I2C2 for display
+ let scl2 = gpiob.pb10.into_alternate_open_drain(&mut gpiob.crh);
+ let sda2 = gpiob.pb11.into_alternate_open_drain(&mut gpiob.crh);
- let i2c = BlockingI2c::i2c1(
- dp.I2C1,
- (scl, sda),
- &mut afio.mapr,
- Mode::Standard {
- frequency: 100_000.hz(),
+ let i2c2 = BlockingI2c::i2c2(
+ dp.I2C2,
+ (scl2, sda2),
+ Mode::Fast {
+ frequency: 400_000.hz(),
+ duty_cycle: DutyCycle::Ratio2to1,
},
clocks,
&mut rcc.apb1,
@@ -105,10 +100,10 @@ fn main() -> ! {
/* data_timeout_us */ 1000,
);
- let i2c_busmanager = shared_bus::CortexMBusManager::new(i2c);
+ let i2c2_busmanager = shared_bus::CortexMBusManager::new(i2c2);
const I2C_ADDRESS: u8 = 0b010_0000; // MCP23008, depending on solder bridges
- let mut lcd = match HD44780::new_i2c_mcp23008(i2c_busmanager.acquire(), I2C_ADDRESS, &mut delay) {
+ let mut lcd = match HD44780::new_i2c_mcp23008(i2c2_busmanager.acquire(), I2C_ADDRESS, &mut delay) {
Ok(lcd) => lcd,
Err(_) => panic!("HD44780 init fail"),
};
@@ -125,7 +120,29 @@ fn main() -> ! {
lcd.set_cursor_pos(0, &mut delay).unwrap();
lcd.write_str("Hello, world!", &mut delay).unwrap();
- //let mut siclock = si_clock::SiClock::new(i2c_busmanager.acquire());
+
+ /*
+ // Configure I2C1 to be used for Si5351
+ let scl = gpiob.pb6.into_alternate_open_drain(&mut gpiob.crl);
+ let sda = gpiob.pb7.into_alternate_open_drain(&mut gpiob.crl);
+
+ let i2c = BlockingI2c::i2c1(
+ dp.I2C1,
+ (scl, sda),
+ &mut afio.mapr,
+ Mode::Standard {
+ frequency: 100_000.hz(),
+ },
+ clocks,
+ &mut rcc.apb1,
+ /* start_timeout_us */ 1000,
+ /* start_retries */ 10,
+ /* addr_timeout_us */ 1000,
+ /* data_timeout_us */ 1000,
+ );
+ let i2c_busmanager = shared_bus::CortexMBusManager::new(i2c);
+ let mut siclock = si_clock::SiClock::new(i2c_busmanager.acquire());
+ */
lcd.set_cursor_pos(0, &mut delay).unwrap();
lcd.write_str("Clocks set. ", &mut delay).unwrap();