aboutsummaryrefslogtreecommitdiffstats
path: root/sw/eval-clock-cw-tx/src/main.rs
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2021-03-31 17:40:53 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2021-03-31 17:40:53 +0200
commit62fdd309c55286222d1add4ca3051353da0e11b8 (patch)
tree1beb88a3d2e4b977b170f41f6d6de020aad8bf46 /sw/eval-clock-cw-tx/src/main.rs
parentb2b6ac9eea2eb5066942237bfced3f7f8b48c43c (diff)
downloadpicardy-62fdd309c55286222d1add4ca3051353da0e11b8.tar.gz
picardy-62fdd309c55286222d1add4ca3051353da0e11b8.tar.bz2
picardy-62fdd309c55286222d1add4ca3051353da0e11b8.zip
Enable USB CDC ACM for eval-clock-cw-tx
Diffstat (limited to 'sw/eval-clock-cw-tx/src/main.rs')
-rw-r--r--sw/eval-clock-cw-tx/src/main.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/sw/eval-clock-cw-tx/src/main.rs b/sw/eval-clock-cw-tx/src/main.rs
index c91c545..d30318b 100644
--- a/sw/eval-clock-cw-tx/src/main.rs
+++ b/sw/eval-clock-cw-tx/src/main.rs
@@ -46,6 +46,7 @@ use embedded_hal::digital::v2::InputPin;
use hd44780_driver::{Cursor, CursorBlink, Display, DisplayMode, HD44780};
pub mod ui;
+pub mod usb;
pub mod cw;
pub mod state;
pub mod si_clock;
@@ -92,8 +93,14 @@ fn main() -> ! {
let mut rcc = dp.RCC.constrain();
let mut afio = dp.AFIO.constrain(&mut rcc.apb2);
let clocks = rcc.cfgr
+ .use_hse(16.mhz())
+ .sysclk(48.mhz())
+ .pclk1(24.mhz())
.adcclk(2.mhz())
.freeze(&mut flash.acr);
+
+ assert!(clocks.usbclk_valid());
+
let mut delay = Delay::new(cp.SYST, clocks);
delay.delay_ms(200u16);
@@ -102,6 +109,10 @@ fn main() -> ! {
let mut gpiob = dp.GPIOB.split(&mut rcc.apb2);
let mut gpioc = dp.GPIOC.split(&mut rcc.apb2);
+ let usb_dm = gpioa.pa11;
+ let usb_dp = gpioa.pa12.into_floating_input(&mut gpioa.crh);
+ let usb = usb::USB::new(dp.USB, usb_dm, usb_dp);
+
// Buttons as analog inputs (multi-level)
let pb0 = gpiob.pb0.into_floating_input(&mut gpiob.crl); // BTN1 Button B, has external pullup
let pb1 = gpiob.pb1.into_floating_input(&mut gpiob.crl); // BTN0 Button A, has external pullup
@@ -173,6 +184,7 @@ fn main() -> ! {
lcd.write_str(" 30m CW TX 2021 ", &mut delay).unwrap();
delay.delay_ms(1_500u16);
+ usb.enable_interrupts();
let mut siclock = {
let shared = unsafe { &mut *SHARED.as_mut_ptr() };
@@ -349,6 +361,7 @@ fn TIM2() {
}
}
+#[allow(non_snake_case)]
#[cortex_m_rt::exception]
fn HardFault(ef: &ExceptionFrame) -> ! {
let periph = unsafe { cortex_m::Peripherals::steal() };
@@ -360,6 +373,7 @@ fn HardFault(ef: &ExceptionFrame) -> ! {
loop { }
}
+#[allow(non_snake_case)]
#[cortex_m_rt::exception]
fn DefaultHandler(irqn: i16) {
hprintln!("Unhandled exception (IRQn = {})", irqn).unwrap();