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

Function main

c1minimal/src/main.rs:66–185  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64
65#[entry]
66fn main() -> ! {
67 let mut pac = pac::Peripherals::take().unwrap();
68 let core = pac::CorePeripherals::take().unwrap();
69 let mut watchdog = Watchdog::new(pac.WATCHDOG);
70 let sio = Sio::new(pac.SIO);
71
72 let clocks = init_clocks_and_plls(
73 bsp::XOSC_CRYSTAL_FREQ,
74 pac.XOSC,
75 pac.CLOCKS,
76 pac.PLL_SYS,
77 pac.PLL_USB,
78 &mut pac.RESETS,
79 &mut watchdog,
80 )
81 .ok()
82 .unwrap();
83
84 let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().to_Hz());
85
86 let pins = bsp::Pins::new(
87 pac.IO_BANK0,
88 pac.PADS_BANK0,
89 sio.gpio_bank0,
90 &mut pac.RESETS,
91 );
92
93 // Set up the USB driver
94 let usb_bus = UsbBusAllocator::new(usb::UsbBus::new(
95 pac.USBCTRL_REGS,
96 pac.USBCTRL_DPRAM,
97 clocks.usb_clock,
98 true,
99 &mut pac.RESETS,
100 ));
101
102 // Set up the USB Communications Class Device driver
103 let mut serial = SerialPort::new(&usb_bus);
104
105 let serialnum = if let Some(serialnum) = get_serialnum() {
106 serialnum.serialnum
107 } else {
108 DEFAULT_SERIAL
109 };
110
111 let mut usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(0x32ac, 0x0022))
112 .manufacturer("Framework Computer Inc")
113 .product("C1 Minimal Input Module")
114 .serial_number(serialnum)
115 .max_power(500) // TODO: Check how much
116 .device_release(device_release())
117 .device_class(USB_CLASS_CDC)
118 .build();
119
120 let sleep = pins.sleep.into_pull_down_input();
121
122 let mut state = C1MinimalState {
123 sleeping: SimpleSleepState::Awake,

Callers

nothing calls this directly

Calls 7

get_serialnumFunction · 0.85
device_releaseFunction · 0.85
brightnessFunction · 0.85
parse_commandFunction · 0.85
handle_commandFunction · 0.85
unwrapMethod · 0.80
handle_sleepFunction · 0.70

Tested by

no test coverage detected