1#![no_std]
10#![no_main]
11#![deny(missing_docs)]
12
13use core::ptr::addr_of;
14
15use kernel::capabilities;
16use kernel::component::Component;
17use kernel::hil::led::LedLow;
18use kernel::hil::time::Counter;
19use kernel::hil::usb::Client;
20use kernel::platform::{KernelResources, SyscallDriverLookup};
21use kernel::process::ProcessArray;
22use kernel::scheduler::round_robin::RoundRobinSched;
23#[allow(unused_imports)]
24use kernel::{create_capability, debug, debug_gpio, debug_verbose, static_init};
25
26use nrf52840::gpio::Pin;
27use nrf52840::interrupt_service::Nrf52840DefaultPeripherals;
28
29const LED_PIN: Pin = Pin::P1_11;
35
36const BUTTON_RST_PIN: Pin = Pin::P0_18;
37const BUTTON_PIN: Pin = Pin::P1_15;
38
39const GPIO_D0: Pin = Pin::P0_23;
40const GPIO_D1: Pin = Pin::P0_12;
41const GPIO_D2: Pin = Pin::P0_09;
42const GPIO_D3: Pin = Pin::P0_07;
43
44const _UART_TX_PIN: Pin = Pin::P0_06;
45const _UART_RX_PIN: Pin = Pin::P0_08;
46
47const I2C_SDA_PIN: Pin = Pin::P0_26;
49const I2C_SCL_PIN: Pin = Pin::P0_27;
50
51const PAN_ID: u16 = 0xABCD;
54const DST_MAC_ADDR: capsules_extra::net::ieee802154::MacAddress =
56    capsules_extra::net::ieee802154::MacAddress::Short(49138);
57const DEFAULT_CTX_PREFIX_LEN: u8 = 8; const DEFAULT_CTX_PREFIX: [u8; 16] = [0x0_u8; 16]; pub mod io;
62
63const FAULT_RESPONSE: capsules_system::process_policies::StopWithDebugFaultPolicy =
68    capsules_system::process_policies::StopWithDebugFaultPolicy {};
69
70const NUM_PROCS: usize = 8;
72
73type ChipHw = nrf52840::chip::NRF52<'static, Nrf52840DefaultPeripherals<'static>>;
74
75static mut PROCESSES: Option<&'static ProcessArray<NUM_PROCS>> = None;
77static mut CHIP: Option<&'static ChipHw> = None;
78static mut PROCESS_PRINTER: Option<&'static capsules_system::process_printer::ProcessPrinterText> =
79    None;
80static mut CDC_REF_FOR_PANIC: Option<
81    &'static capsules_extra::usb::cdc::CdcAcm<
82        'static,
83        nrf52::usbd::Usbd,
84        capsules_core::virtualizers::virtual_alarm::VirtualMuxAlarm<'static, nrf52::rtc::Rtc>,
85    >,
86> = None;
87static mut NRF52_POWER: Option<&'static nrf52840::power::Power> = None;
88
89kernel::stack_size! {0x1000}
90
91fn baud_rate_reset_bootloader_enter() {
93    unsafe {
94        NRF52_POWER.unwrap().set_gpregret(0x90);
96        cortexm4::scb::reset();
97    }
98}
99
100fn crc(s: &'static str) -> u32 {
101    kernel::utilities::helpers::crc32_posix(s.as_bytes())
102}
103
104type AlarmDriver = components::alarm::AlarmDriverComponentType<nrf52840::rtc::Rtc<'static>>;
109
110type Screen = components::ssd1306::Ssd1306ComponentType<nrf52840::i2c::TWI<'static>>;
111type ScreenDriver = components::screen::ScreenSharedComponentType<Screen>;
112
113type Ieee802154MacDevice = components::ieee802154::Ieee802154ComponentMacDeviceType<
114    nrf52840::ieee802154_radio::Radio<'static>,
115    nrf52840::aes::AesECB<'static>,
116>;
117type Ieee802154Driver = components::ieee802154::Ieee802154ComponentType<
118    nrf52840::ieee802154_radio::Radio<'static>,
119    nrf52840::aes::AesECB<'static>,
120>;
121type RngDriver = components::rng::RngComponentType<nrf52840::trng::Trng<'static>>;
122
123pub struct Platform {
125    ble_radio: &'static capsules_extra::ble_advertising_driver::BLE<
126        'static,
127        nrf52::ble_radio::Radio<'static>,
128        capsules_core::virtualizers::virtual_alarm::VirtualMuxAlarm<
129            'static,
130            nrf52::rtc::Rtc<'static>,
131        >,
132    >,
133    ieee802154_radio: &'static Ieee802154Driver,
134    console: &'static capsules_core::console::Console<'static>,
135    pconsole: &'static capsules_core::process_console::ProcessConsole<
136        'static,
137        { capsules_core::process_console::DEFAULT_COMMAND_HISTORY_LEN },
138        capsules_core::virtualizers::virtual_alarm::VirtualMuxAlarm<
139            'static,
140            nrf52::rtc::Rtc<'static>,
141        >,
142        components::process_console::Capability,
143    >,
144    gpio: &'static capsules_core::gpio::GPIO<'static, nrf52::gpio::GPIOPin<'static>>,
145    led: &'static capsules_core::led::LedDriver<
146        'static,
147        LedLow<'static, nrf52::gpio::GPIOPin<'static>>,
148        1,
149    >,
150    adc: &'static capsules_core::adc::AdcVirtualized<'static>,
151    rng: &'static RngDriver,
152    ipc: kernel::ipc::IPC<{ NUM_PROCS as u8 }>,
153    alarm: &'static AlarmDriver,
154    button: &'static capsules_core::button::Button<'static, nrf52840::gpio::GPIOPin<'static>>,
155    screen: &'static ScreenDriver,
156    udp_driver: &'static capsules_extra::net::udp::UDPDriver<'static>,
157    scheduler: &'static RoundRobinSched<'static>,
158    systick: cortexm4::systick::SysTick,
159}
160
161impl SyscallDriverLookup for Platform {
162    fn with_driver<F, R>(&self, driver_num: usize, f: F) -> R
163    where
164        F: FnOnce(Option<&dyn kernel::syscall::SyscallDriver>) -> R,
165    {
166        match driver_num {
167            capsules_core::console::DRIVER_NUM => f(Some(self.console)),
168            capsules_core::gpio::DRIVER_NUM => f(Some(self.gpio)),
169            capsules_core::alarm::DRIVER_NUM => f(Some(self.alarm)),
170            capsules_core::led::DRIVER_NUM => f(Some(self.led)),
171            capsules_core::button::DRIVER_NUM => f(Some(self.button)),
172            capsules_core::adc::DRIVER_NUM => f(Some(self.adc)),
173            capsules_core::rng::DRIVER_NUM => f(Some(self.rng)),
174            capsules_extra::screen::screen::DRIVER_NUM => f(Some(self.screen)),
175            capsules_extra::ble_advertising_driver::DRIVER_NUM => f(Some(self.ble_radio)),
176            capsules_extra::ieee802154::DRIVER_NUM => f(Some(self.ieee802154_radio)),
177            capsules_extra::net::udp::DRIVER_NUM => f(Some(self.udp_driver)),
178            kernel::ipc::DRIVER_NUM => f(Some(&self.ipc)),
179            _ => f(None),
180        }
181    }
182}
183
184impl KernelResources<nrf52::chip::NRF52<'static, Nrf52840DefaultPeripherals<'static>>>
185    for Platform
186{
187    type SyscallDriverLookup = Self;
188    type SyscallFilter = ();
189    type ProcessFault = ();
190    type Scheduler = RoundRobinSched<'static>;
191    type SchedulerTimer = cortexm4::systick::SysTick;
192    type WatchDog = ();
193    type ContextSwitchCallback = ();
194
195    fn syscall_driver_lookup(&self) -> &Self::SyscallDriverLookup {
196        self
197    }
198    fn syscall_filter(&self) -> &Self::SyscallFilter {
199        &()
200    }
201    fn process_fault(&self) -> &Self::ProcessFault {
202        &()
203    }
204    fn scheduler(&self) -> &Self::Scheduler {
205        self.scheduler
206    }
207    fn scheduler_timer(&self) -> &Self::SchedulerTimer {
208        &self.systick
209    }
210    fn watchdog(&self) -> &Self::WatchDog {
211        &()
212    }
213    fn context_switch_callback(&self) -> &Self::ContextSwitchCallback {
214        &()
215    }
216}
217
218#[inline(never)]
222pub unsafe fn start() -> (
223    &'static kernel::Kernel,
224    Platform,
225    &'static nrf52840::chip::NRF52<'static, Nrf52840DefaultPeripherals<'static>>,
226) {
227    nrf52840::init();
228
229    let ieee802154_ack_buf = static_init!(
230        [u8; nrf52840::ieee802154_radio::ACK_BUF_SIZE],
231        [0; nrf52840::ieee802154_radio::ACK_BUF_SIZE]
232    );
233
234    let nrf52840_peripherals = static_init!(
236        Nrf52840DefaultPeripherals,
237        Nrf52840DefaultPeripherals::new(ieee802154_ack_buf)
238    );
239
240    nrf52840_peripherals.init();
242    let base_peripherals = &nrf52840_peripherals.nrf52;
243
244    NRF52_POWER = Some(&base_peripherals.pwr_clk);
247
248    let processes = components::process_array::ProcessArrayComponent::new()
250        .finalize(components::process_array_component_static!(NUM_PROCS));
251    PROCESSES = Some(processes);
252
253    let board_kernel = static_init!(kernel::Kernel, kernel::Kernel::new(processes.as_slice()));
255
256    nrf52_components::startup::NrfStartupComponent::new(
259        false,
260        BUTTON_RST_PIN,
261        nrf52840::uicr::Regulator0Output::DEFAULT,
262        &base_peripherals.nvmc,
263    )
264    .finalize(());
265
266    let chip = static_init!(
267        nrf52840::chip::NRF52<Nrf52840DefaultPeripherals>,
268        nrf52840::chip::NRF52::new(nrf52840_peripherals)
269    );
270    CHIP = Some(chip);
271
272    let memory_allocation_capability = create_capability!(capabilities::MemoryAllocationCapability);
279
280    kernel::debug::assign_gpios(Some(&nrf52840_peripherals.gpio_port[LED_PIN]), None, None);
288
289    let gpio = components::gpio::GpioComponent::new(
294        board_kernel,
295        capsules_core::gpio::DRIVER_NUM,
296        components::gpio_component_helper!(
297            nrf52840::gpio::GPIOPin,
298            0 => &nrf52840_peripherals.gpio_port[GPIO_D0],
299            1 => &nrf52840_peripherals.gpio_port[GPIO_D1],
300            2 => &nrf52840_peripherals.gpio_port[GPIO_D2],
301            3 => &nrf52840_peripherals.gpio_port[GPIO_D3],
302        ),
303    )
304    .finalize(components::gpio_component_static!(nrf52840::gpio::GPIOPin));
305
306    let led = components::led::LedsComponent::new().finalize(components::led_component_static!(
311        LedLow<'static, nrf52840::gpio::GPIOPin>,
312        LedLow::new(&nrf52840_peripherals.gpio_port[LED_PIN]),
313    ));
314
315    let button = components::button::ButtonComponent::new(
320        board_kernel,
321        capsules_core::button::DRIVER_NUM,
322        components::button_component_helper!(
323            nrf52840::gpio::GPIOPin,
324            (
325                &nrf52840_peripherals.gpio_port[BUTTON_PIN],
326                kernel::hil::gpio::ActivationMode::ActiveLow,
327                kernel::hil::gpio::FloatingState::PullUp
328            )
329        ),
330    )
331    .finalize(components::button_component_static!(
332        nrf52840::gpio::GPIOPin
333    ));
334
335    let rtc = &base_peripherals.rtc;
340    let _ = rtc.start();
341
342    let mux_alarm = components::alarm::AlarmMuxComponent::new(rtc)
343        .finalize(components::alarm_mux_component_static!(nrf52::rtc::Rtc));
344    let alarm = components::alarm::AlarmDriverComponent::new(
345        board_kernel,
346        capsules_core::alarm::DRIVER_NUM,
347        mux_alarm,
348    )
349    .finalize(components::alarm_component_static!(nrf52::rtc::Rtc));
350
351    let serial_number_buf = static_init!([u8; 17], [0; 17]);
361    let serial_number_string: &'static str =
362        (*addr_of!(nrf52::ficr::FICR_INSTANCE)).address_str(serial_number_buf);
363    let strings = static_init!(
364        [&str; 3],
365        [
366            "MakePython",         "NRF52840 - TockOS",  serial_number_string, ]
370    );
371
372    let cdc = components::cdc::CdcAcmComponent::new(
373        &nrf52840_peripherals.usbd,
374        capsules_extra::usb::cdc::MAX_CTRL_PACKET_SIZE_NRF52840,
375        0x2341,
376        0x005a,
377        strings,
378        mux_alarm,
379        Some(&baud_rate_reset_bootloader_enter),
380    )
381    .finalize(components::cdc_acm_component_static!(
382        nrf52::usbd::Usbd,
383        nrf52::rtc::Rtc
384    ));
385    CDC_REF_FOR_PANIC = Some(cdc); let process_printer = components::process_printer::ProcessPrinterTextComponent::new()
389        .finalize(components::process_printer_text_component_static!());
390    PROCESS_PRINTER = Some(process_printer);
391
392    let uart_mux = components::console::UartMuxComponent::new(cdc, 115200)
394        .finalize(components::uart_mux_component_static!());
395
396    let pconsole = components::process_console::ProcessConsoleComponent::new(
397        board_kernel,
398        uart_mux,
399        mux_alarm,
400        process_printer,
401        Some(cortexm4::support::reset),
402    )
403    .finalize(components::process_console_component_static!(
404        nrf52::rtc::Rtc<'static>
405    ));
406
407    let console = components::console::ConsoleComponent::new(
409        board_kernel,
410        capsules_core::console::DRIVER_NUM,
411        uart_mux,
412    )
413    .finalize(components::console_component_static!());
414    components::debug_writer::DebugWriterComponent::new::<
416        <ChipHw as kernel::platform::chip::Chip>::ThreadIdProvider,
417    >(
418        uart_mux,
419        create_capability!(capabilities::SetDebugWriterCapability),
420    )
421    .finalize(components::debug_writer_component_static!());
422
423    let rng = components::rng::RngComponent::new(
428        board_kernel,
429        capsules_core::rng::DRIVER_NUM,
430        &base_peripherals.trng,
431    )
432    .finalize(components::rng_component_static!(nrf52840::trng::Trng));
433
434    base_peripherals.adc.calibrate();
438
439    let adc_mux = components::adc::AdcMuxComponent::new(&base_peripherals.adc)
440        .finalize(components::adc_mux_component_static!(nrf52840::adc::Adc));
441
442    let adc_syscall =
443        components::adc::AdcVirtualComponent::new(board_kernel, capsules_core::adc::DRIVER_NUM)
444            .finalize(components::adc_syscall_component_helper!(
445                components::adc::AdcComponent::new(
447                    adc_mux,
448                    nrf52840::adc::AdcChannelSetup::new(nrf52840::adc::AdcChannel::AnalogInput2)
449                )
450                .finalize(components::adc_component_static!(nrf52840::adc::Adc)),
451                components::adc::AdcComponent::new(
453                    adc_mux,
454                    nrf52840::adc::AdcChannelSetup::new(nrf52840::adc::AdcChannel::AnalogInput3)
455                )
456                .finalize(components::adc_component_static!(nrf52840::adc::Adc)),
457                components::adc::AdcComponent::new(
459                    adc_mux,
460                    nrf52840::adc::AdcChannelSetup::new(nrf52840::adc::AdcChannel::AnalogInput6)
461                )
462                .finalize(components::adc_component_static!(nrf52840::adc::Adc)),
463                components::adc::AdcComponent::new(
465                    adc_mux,
466                    nrf52840::adc::AdcChannelSetup::new(nrf52840::adc::AdcChannel::AnalogInput5)
467                )
468                .finalize(components::adc_component_static!(nrf52840::adc::Adc)),
469                components::adc::AdcComponent::new(
471                    adc_mux,
472                    nrf52840::adc::AdcChannelSetup::new(nrf52840::adc::AdcChannel::AnalogInput7)
473                )
474                .finalize(components::adc_component_static!(nrf52840::adc::Adc)),
475                components::adc::AdcComponent::new(
477                    adc_mux,
478                    nrf52840::adc::AdcChannelSetup::new(nrf52840::adc::AdcChannel::AnalogInput0)
479                )
480                .finalize(components::adc_component_static!(nrf52840::adc::Adc)),
481                components::adc::AdcComponent::new(
483                    adc_mux,
484                    nrf52840::adc::AdcChannelSetup::new(nrf52840::adc::AdcChannel::AnalogInput4)
485                )
486                .finalize(components::adc_component_static!(nrf52840::adc::Adc)),
487                components::adc::AdcComponent::new(
489                    adc_mux,
490                    nrf52840::adc::AdcChannelSetup::new(nrf52840::adc::AdcChannel::AnalogInput1)
491                )
492                .finalize(components::adc_component_static!(nrf52840::adc::Adc)),
493            ));
494
495    let i2c_bus = components::i2c::I2CMuxComponent::new(&base_peripherals.twi1, None)
500        .finalize(components::i2c_mux_component_static!(nrf52840::i2c::TWI));
501    base_peripherals.twi1.configure(
502        nrf52840::pinmux::Pinmux::new(I2C_SCL_PIN as u32),
503        nrf52840::pinmux::Pinmux::new(I2C_SDA_PIN as u32),
504    );
505
506    let ssd1306_i2c = components::i2c::I2CComponent::new(i2c_bus, 0x3c)
508        .finalize(components::i2c_component_static!(nrf52840::i2c::TWI));
509
510    let ssd1306 = components::ssd1306::Ssd1306Component::new(ssd1306_i2c, true)
512        .finalize(components::ssd1306_component_static!(nrf52840::i2c::TWI));
513
514    let apps_regions = static_init!(
524        [capsules_extra::screen::screen_shared::AppScreenRegion; 3],
525        [
526            capsules_extra::screen::screen_shared::AppScreenRegion::new(
527                kernel::process::ShortId::Fixed(core::num::NonZeroU32::new(crc("circle")).unwrap()),
528                0,     0,     8 * 8, 8 * 8  ),
533            capsules_extra::screen::screen_shared::AppScreenRegion::new(
534                kernel::process::ShortId::Fixed(core::num::NonZeroU32::new(crc("count")).unwrap()),
535                8 * 8, 0,     8 * 8, 4 * 8  ),
540            capsules_extra::screen::screen_shared::AppScreenRegion::new(
541                kernel::process::ShortId::Fixed(
542                    core::num::NonZeroU32::new(crc("tock-scroll")).unwrap()
543                ),
544                8 * 8, 4 * 8, 8 * 8, 4 * 8  )
549        ]
550    );
551
552    let screen = components::screen::ScreenSharedComponent::new(
553        board_kernel,
554        capsules_extra::screen::screen::DRIVER_NUM,
555        ssd1306,
556        apps_regions,
557    )
558    .finalize(components::screen_shared_component_static!(1032, Screen));
559
560    let ble_radio = components::ble::BLEComponent::new(
565        board_kernel,
566        capsules_extra::ble_advertising_driver::DRIVER_NUM,
567        &base_peripherals.ble_radio,
568        mux_alarm,
569    )
570    .finalize(components::ble_component_static!(
571        nrf52840::rtc::Rtc,
572        nrf52840::ble_radio::Radio
573    ));
574
575    use capsules_extra::net::ieee802154::MacAddress;
576
577    let aes_mux = components::ieee802154::MuxAes128ccmComponent::new(&base_peripherals.ecb)
578        .finalize(components::mux_aes128ccm_component_static!(
579            nrf52840::aes::AesECB
580        ));
581
582    let device_id = (*addr_of!(nrf52840::ficr::FICR_INSTANCE)).id();
583    let device_id_bottom_16 = u16::from_le_bytes([device_id[0], device_id[1]]);
584    let (ieee802154_radio, mux_mac) = components::ieee802154::Ieee802154Component::new(
585        board_kernel,
586        capsules_extra::ieee802154::DRIVER_NUM,
587        &nrf52840_peripherals.ieee802154_radio,
588        aes_mux,
589        PAN_ID,
590        device_id_bottom_16,
591        device_id,
592    )
593    .finalize(components::ieee802154_component_static!(
594        nrf52840::ieee802154_radio::Radio,
595        nrf52840::aes::AesECB<'static>
596    ));
597    use capsules_extra::net::ipv6::ip_utils::IPAddr;
598
599    let local_ip_ifaces = static_init!(
600        [IPAddr; 3],
601        [
602            IPAddr([
603                0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,
604                0x0e, 0x0f,
605            ]),
606            IPAddr([
607                0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
608                0x1e, 0x1f,
609            ]),
610            IPAddr::generate_from_mac(capsules_extra::net::ieee802154::MacAddress::Short(
611                device_id_bottom_16
612            )),
613        ]
614    );
615
616    let (udp_send_mux, udp_recv_mux, udp_port_table) = components::udp_mux::UDPMuxComponent::new(
617        mux_mac,
618        DEFAULT_CTX_PREFIX_LEN,
619        DEFAULT_CTX_PREFIX,
620        DST_MAC_ADDR,
621        MacAddress::Short(device_id_bottom_16),
622        local_ip_ifaces,
623        mux_alarm,
624    )
625    .finalize(components::udp_mux_component_static!(
626        nrf52840::rtc::Rtc,
627        Ieee802154MacDevice
628    ));
629
630    let udp_driver = components::udp_driver::UDPDriverComponent::new(
632        board_kernel,
633        capsules_extra::net::udp::DRIVER_NUM,
634        udp_send_mux,
635        udp_recv_mux,
636        udp_port_table,
637        local_ip_ifaces,
638    )
639    .finalize(components::udp_driver_component_static!(nrf52840::rtc::Rtc));
640
641    let sha = components::sha::ShaSoftware256Component::new()
647        .finalize(components::sha_software_256_component_static!());
648
649    let checking_policy = components::appid::checker_sha::AppCheckerSha256Component::new(sha)
651        .finalize(components::app_checker_sha256_component_static!());
652
653    let assigner = components::appid::assigner_name::AppIdAssignerNamesComponent::new()
655        .finalize(components::appid_assigner_names_component_static!());
656
657    let checker = components::appid::checker::ProcessCheckerMachineComponent::new(checking_policy)
659        .finalize(components::process_checker_machine_component_static!());
660
661    let storage_permissions_policy =
666        components::storage_permissions::individual::StoragePermissionsIndividualComponent::new()
667            .finalize(
668                components::storage_permissions_individual_component_static!(
669                    nrf52840::chip::NRF52<Nrf52840DefaultPeripherals>,
670                    kernel::process::ProcessStandardDebugFull,
671                ),
672            );
673
674    extern "C" {
680        static _sapps: u8;
682        static _eapps: u8;
684        static mut _sappmem: u8;
686        static _eappmem: u8;
688    }
689
690    let app_flash = core::slice::from_raw_parts(
691        core::ptr::addr_of!(_sapps),
692        core::ptr::addr_of!(_eapps) as usize - core::ptr::addr_of!(_sapps) as usize,
693    );
694    let app_memory = core::slice::from_raw_parts_mut(
695        core::ptr::addr_of_mut!(_sappmem),
696        core::ptr::addr_of!(_eappmem) as usize - core::ptr::addr_of!(_sappmem) as usize,
697    );
698
699    let _loader = components::loader::sequential::ProcessLoaderSequentialComponent::new(
701        checker,
702        board_kernel,
703        chip,
704        &FAULT_RESPONSE,
705        assigner,
706        storage_permissions_policy,
707        app_flash,
708        app_memory,
709    )
710    .finalize(components::process_loader_sequential_component_static!(
711        nrf52840::chip::NRF52<Nrf52840DefaultPeripherals>,
712        kernel::process::ProcessStandardDebugFull,
713        NUM_PROCS
714    ));
715
716    nrf52_components::NrfClockComponent::new(&base_peripherals.clock).finalize(());
723
724    let scheduler = components::sched::round_robin::RoundRobinComponent::new(processes)
725        .finalize(components::round_robin_component_static!(NUM_PROCS));
726
727    let platform = Platform {
728        ble_radio,
729        ieee802154_radio,
730        console,
731        pconsole,
732        adc: adc_syscall,
733        led,
734        button,
735        gpio,
736        rng,
737        screen,
738        alarm,
739        udp_driver,
740        ipc: kernel::ipc::IPC::new(
741            board_kernel,
742            kernel::ipc::DRIVER_NUM,
743            &memory_allocation_capability,
744        ),
745        scheduler,
746        systick: cortexm4::systick::SysTick::new_with_calibration(64000000),
747    };
748
749    cdc.enable();
751    cdc.attach();
752
753    debug!("Initialization complete. Entering main loop.");
766    let _ = platform.pconsole.start();
767
768    ssd1306.init_screen();
769
770    (board_kernel, platform, chip)
775}
776
777#[no_mangle]
779pub unsafe fn main() {
780    let main_loop_capability = create_capability!(capabilities::MainLoopCapability);
781
782    let (board_kernel, platform, chip) = start();
783    board_kernel.kernel_loop(&platform, chip, Some(&platform.ipc), &main_loop_capability);
784}