MCPcopy Index your code
hub / github.com/FrameworkComputer/inputmodule-rs / main

Function main

b1display/src/main.rs:77–344  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75
76#[entry]
77fn main() -> ! {
78 let mut pac = pac::Peripherals::take().unwrap();
79 let core = pac::CorePeripherals::take().unwrap();
80 let mut watchdog = Watchdog::new(pac.WATCHDOG);
81 let sio = Sio::new(pac.SIO);
82
83 let clocks = init_clocks_and_plls(
84 bsp::XOSC_CRYSTAL_FREQ,
85 pac.XOSC,
86 pac.CLOCKS,
87 pac.PLL_SYS,
88 pac.PLL_USB,
89 &mut pac.RESETS,
90 &mut watchdog,
91 )
92 .ok()
93 .unwrap();
94
95 let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().to_Hz());
96
97 let pins = bsp::Pins::new(
98 pac.IO_BANK0,
99 pac.PADS_BANK0,
100 sio.gpio_bank0,
101 &mut pac.RESETS,
102 );
103
104 // Set up the USB driver
105 let usb_bus = UsbBusAllocator::new(usb::UsbBus::new(
106 pac.USBCTRL_REGS,
107 pac.USBCTRL_DPRAM,
108 clocks.usb_clock,
109 true,
110 &mut pac.RESETS,
111 ));
112
113 // Set up the USB Communications Class Device driver
114 let mut serial = SerialPort::new(&usb_bus);
115
116 let serialnum = if let Some(serialnum) = get_serialnum() {
117 serialnum.serialnum
118 } else {
119 DEFAULT_SERIAL
120 };
121
122 let mut usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(0x32ac, 0x0021))
123 .manufacturer("Framework Computer Inc")
124 .product("B1 Display")
125 .serial_number(serialnum)
126 .max_power(500) // TODO: Check how much
127 .device_release(device_release()) // TODO: Assign dynamically based on crate version
128 .device_class(USB_CLASS_CDC)
129 .build();
130
131 // Display SPI pins
132 let _spi_sclk = pins.scl.into_mode::<bsp::hal::gpio::FunctionSpi>();
133 let _spi_mosi = pins.sda.into_mode::<bsp::hal::gpio::FunctionSpi>();
134 let _spi_miso = pins.miso.into_mode::<bsp::hal::gpio::FunctionSpi>();

Callers

nothing calls this directly

Calls 8

get_serialnumFunction · 0.85
device_releaseFunction · 0.85
draw_logoFunction · 0.85
draw_textFunction · 0.85
parse_commandFunction · 0.85
handle_commandFunction · 0.85
unwrapMethod · 0.80
handle_sleepFunction · 0.70

Tested by

no test coverage detected