1#![no_std]
10#![no_main]
11#![deny(missing_docs)]
12
13use core::ptr::addr_of_mut;
14
15use capsules_core::virtualizers::virtual_alarm::VirtualMuxAlarm;
16use components::gpio::GpioComponent;
17use kernel::capabilities;
18use kernel::component::Component;
19use kernel::hil::led::LedHigh;
20use kernel::platform::{KernelResources, SyscallDriverLookup};
21use kernel::process::ProcessArray;
22use kernel::scheduler::round_robin::RoundRobinSched;
23use kernel::{create_capability, debug, static_init};
24
25use stm32f429zi::chip_specs::Stm32f429Specs;
26use stm32f429zi::clocks::hsi::HSI_FREQUENCY_MHZ;
27use stm32f429zi::gpio::{AlternateFunction, Mode, PinId, PortId};
28use stm32f429zi::interrupt_service::Stm32f429ziDefaultPeripherals;
29
30pub mod io;
32
33const NUM_PROCS: usize = 4;
35
36static mut PROCESSES: Option<&'static ProcessArray<NUM_PROCS>> = None;
38static mut CHIP: Option<&'static stm32f429zi::chip::Stm32f4xx<Stm32f429ziDefaultPeripherals>> =
39 None;
40static mut PROCESS_PRINTER: Option<&'static capsules_system::process_printer::ProcessPrinterText> =
41 None;
42
43const FAULT_RESPONSE: capsules_system::process_policies::PanicFaultPolicy =
45 capsules_system::process_policies::PanicFaultPolicy {};
46
47kernel::stack_size! {0x2000}
48
49type TemperatureSTMSensor = components::temperature_stm::TemperatureSTMComponentType<
54 capsules_core::virtualizers::virtual_adc::AdcDevice<'static, stm32f429zi::adc::Adc<'static>>,
55>;
56type TemperatureDriver = components::temperature::TemperatureComponentType<TemperatureSTMSensor>;
57type RngDriver = components::rng::RngComponentType<stm32f429zi::trng::Trng<'static>>;
58
59pub const NUCLEO_F429ZI_HSE_FREQUENCY_MHZ: usize = 8;
61
62struct NucleoF429ZI {
65 console: &'static capsules_core::console::Console<'static>,
66 ipc: kernel::ipc::IPC<{ NUM_PROCS as u8 }>,
67 led: &'static capsules_core::led::LedDriver<
68 'static,
69 LedHigh<'static, stm32f429zi::gpio::Pin<'static>>,
70 3,
71 >,
72 button: &'static capsules_core::button::Button<'static, stm32f429zi::gpio::Pin<'static>>,
73 adc: &'static capsules_core::adc::AdcVirtualized<'static>,
74 dac: &'static capsules_extra::dac::Dac<'static>,
75 alarm: &'static capsules_core::alarm::AlarmDriver<
76 'static,
77 VirtualMuxAlarm<'static, stm32f429zi::tim2::Tim2<'static>>,
78 >,
79 temperature: &'static TemperatureDriver,
80 gpio: &'static capsules_core::gpio::GPIO<'static, stm32f429zi::gpio::Pin<'static>>,
81 rng: &'static RngDriver,
82
83 scheduler: &'static RoundRobinSched<'static>,
84 systick: cortexm4::systick::SysTick,
85 can: &'static capsules_extra::can::CanCapsule<'static, stm32f429zi::can::Can<'static>>,
86 date_time: &'static capsules_extra::date_time::DateTimeCapsule<
87 'static,
88 stm32f429zi::rtc::Rtc<'static>,
89 >,
90}
91
92impl SyscallDriverLookup for NucleoF429ZI {
94 fn with_driver<F, R>(&self, driver_num: usize, f: F) -> R
95 where
96 F: FnOnce(Option<&dyn kernel::syscall::SyscallDriver>) -> R,
97 {
98 match driver_num {
99 capsules_core::console::DRIVER_NUM => f(Some(self.console)),
100 capsules_core::led::DRIVER_NUM => f(Some(self.led)),
101 capsules_core::button::DRIVER_NUM => f(Some(self.button)),
102 capsules_core::adc::DRIVER_NUM => f(Some(self.adc)),
103 capsules_core::alarm::DRIVER_NUM => f(Some(self.alarm)),
104 capsules_extra::temperature::DRIVER_NUM => f(Some(self.temperature)),
105 kernel::ipc::DRIVER_NUM => f(Some(&self.ipc)),
106 capsules_core::gpio::DRIVER_NUM => f(Some(self.gpio)),
107 capsules_core::rng::DRIVER_NUM => f(Some(self.rng)),
108 capsules_extra::can::DRIVER_NUM => f(Some(self.can)),
109 capsules_extra::dac::DRIVER_NUM => f(Some(self.dac)),
110 capsules_extra::date_time::DRIVER_NUM => f(Some(self.date_time)),
111 _ => f(None),
112 }
113 }
114}
115
116impl
117 KernelResources<
118 stm32f429zi::chip::Stm32f4xx<
119 'static,
120 stm32f429zi::interrupt_service::Stm32f429ziDefaultPeripherals<'static>,
121 >,
122 > for NucleoF429ZI
123{
124 type SyscallDriverLookup = Self;
125 type SyscallFilter = ();
126 type ProcessFault = ();
127 type Scheduler = RoundRobinSched<'static>;
128 type SchedulerTimer = cortexm4::systick::SysTick;
129 type WatchDog = ();
130 type ContextSwitchCallback = ();
131
132 fn syscall_driver_lookup(&self) -> &Self::SyscallDriverLookup {
133 self
134 }
135 fn syscall_filter(&self) -> &Self::SyscallFilter {
136 &()
137 }
138 fn process_fault(&self) -> &Self::ProcessFault {
139 &()
140 }
141 fn scheduler(&self) -> &Self::Scheduler {
142 self.scheduler
143 }
144 fn scheduler_timer(&self) -> &Self::SchedulerTimer {
145 &self.systick
146 }
147 fn watchdog(&self) -> &Self::WatchDog {
148 &()
149 }
150 fn context_switch_callback(&self) -> &Self::ContextSwitchCallback {
151 &()
152 }
153}
154
155unsafe fn setup_dma(
157 dma: &stm32f429zi::dma::Dma1,
158 dma_streams: &'static [stm32f429zi::dma::Stream<stm32f429zi::dma::Dma1>; 8],
159 usart3: &'static stm32f429zi::usart::Usart<stm32f429zi::dma::Dma1>,
160) {
161 use stm32f429zi::dma::Dma1Peripheral;
162 use stm32f429zi::usart;
163
164 dma.enable_clock();
165
166 let usart3_tx_stream = &dma_streams[Dma1Peripheral::USART3_TX.get_stream_idx()];
167 let usart3_rx_stream = &dma_streams[Dma1Peripheral::USART3_RX.get_stream_idx()];
168
169 usart3.set_dma(
170 usart::TxDMA(usart3_tx_stream),
171 usart::RxDMA(usart3_rx_stream),
172 );
173
174 usart3_tx_stream.set_client(usart3);
175 usart3_rx_stream.set_client(usart3);
176
177 usart3_tx_stream.setup(Dma1Peripheral::USART3_TX);
178 usart3_rx_stream.setup(Dma1Peripheral::USART3_RX);
179
180 cortexm4::nvic::Nvic::new(Dma1Peripheral::USART3_TX.get_stream_irqn()).enable();
181 cortexm4::nvic::Nvic::new(Dma1Peripheral::USART3_RX.get_stream_irqn()).enable();
182}
183
184unsafe fn set_pin_primary_functions(
186 syscfg: &stm32f429zi::syscfg::Syscfg,
187 gpio_ports: &'static stm32f429zi::gpio::GpioPorts<'static>,
188) {
189 use kernel::hil::gpio::Configure;
190
191 syscfg.enable_clock();
192
193 gpio_ports.get_port_from_port_id(PortId::B).enable_clock();
194
195 gpio_ports.get_pin(PinId::PB07).map(|pin| {
197 pin.make_output();
198
199 kernel::debug::assign_gpios(Some(pin), None, None);
201 });
202
203 gpio_ports.get_port_from_port_id(PortId::D).enable_clock();
204
205 gpio_ports.get_pin(PinId::PD08).map(|pin| {
207 pin.set_mode(Mode::AlternateFunctionMode);
208 pin.set_alternate_function(AlternateFunction::AF7);
210 });
211 gpio_ports.get_pin(PinId::PD09).map(|pin| {
212 pin.set_mode(Mode::AlternateFunctionMode);
213 pin.set_alternate_function(AlternateFunction::AF7);
215 });
216
217 gpio_ports.get_port_from_port_id(PortId::C).enable_clock();
218
219 gpio_ports.get_pin(PinId::PC13).map(|pin| {
221 pin.enable_interrupt();
222 });
223
224 gpio_ports.get_pin(PinId::PG09).map(|pin| {
226 pin.enable_interrupt();
227 });
228
229 gpio_ports.get_port_from_port_id(PortId::A).enable_clock();
232 gpio_ports.get_port_from_port_id(PortId::E).enable_clock();
234 gpio_ports.get_port_from_port_id(PortId::F).enable_clock();
235 gpio_ports.get_port_from_port_id(PortId::G).enable_clock();
236 gpio_ports.get_port_from_port_id(PortId::H).enable_clock();
237
238 gpio_ports.get_pin(PinId::PA03).map(|pin| {
240 pin.set_mode(stm32f429zi::gpio::Mode::AnalogMode);
241 });
242
243 gpio_ports.get_pin(PinId::PC00).map(|pin| {
245 pin.set_mode(stm32f429zi::gpio::Mode::AnalogMode);
246 });
247
248 gpio_ports.get_pin(PinId::PC03).map(|pin| {
250 pin.set_mode(stm32f429zi::gpio::Mode::AnalogMode);
251 });
252
253 gpio_ports.get_pin(PinId::PB01).map(|pin| {
255 pin.set_mode(stm32f429zi::gpio::Mode::AnalogMode);
256 });
257
258 gpio_ports.get_pin(PinId::PC02).map(|pin| {
260 pin.set_mode(stm32f429zi::gpio::Mode::AnalogMode);
261 });
262
263 gpio_ports.get_pin(PinId::PD00).map(|pin| {
264 pin.set_mode(Mode::AlternateFunctionMode);
265 pin.set_alternate_function(AlternateFunction::AF9);
267 pin.set_floating_state(kernel::hil::gpio::FloatingState::PullDown);
268 });
269 gpio_ports.get_pin(PinId::PD01).map(|pin| {
270 pin.set_mode(Mode::AlternateFunctionMode);
271 pin.set_alternate_function(AlternateFunction::AF9);
273 });
274
275 gpio_ports.get_pin(PinId::PA04).map(|pin| {
277 pin.set_mode(stm32f429zi::gpio::Mode::AnalogMode);
278 });
279}
280
281unsafe fn setup_peripherals(
283 tim2: &stm32f429zi::tim2::Tim2,
284 trng: &stm32f429zi::trng::Trng,
285 can1: &'static stm32f429zi::can::Can,
286 rtc: &'static stm32f429zi::rtc::Rtc,
287) {
288 cortexm4::nvic::Nvic::new(stm32f429zi::nvic::USART3).enable();
290
291 tim2.enable_clock();
293 tim2.start();
294 cortexm4::nvic::Nvic::new(stm32f429zi::nvic::TIM2).enable();
295
296 trng.enable_clock();
298
299 can1.enable_clock();
301
302 rtc.enable_clock();
304}
305
306#[inline(never)]
310unsafe fn start() -> (
311 &'static kernel::Kernel,
312 NucleoF429ZI,
313 &'static stm32f429zi::chip::Stm32f4xx<'static, Stm32f429ziDefaultPeripherals<'static>>,
314) {
315 stm32f429zi::init();
316
317 let rcc = static_init!(stm32f429zi::rcc::Rcc, stm32f429zi::rcc::Rcc::new());
319 let clocks = static_init!(
320 stm32f429zi::clocks::Clocks<Stm32f429Specs>,
321 stm32f429zi::clocks::Clocks::new(rcc)
322 );
323
324 let syscfg = static_init!(
325 stm32f429zi::syscfg::Syscfg,
326 stm32f429zi::syscfg::Syscfg::new(clocks)
327 );
328 let exti = static_init!(
329 stm32f429zi::exti::Exti,
330 stm32f429zi::exti::Exti::new(syscfg)
331 );
332 let dma1 = static_init!(stm32f429zi::dma::Dma1, stm32f429zi::dma::Dma1::new(clocks));
333 let dma2 = static_init!(stm32f429zi::dma::Dma2, stm32f429zi::dma::Dma2::new(clocks));
334
335 let peripherals = static_init!(
336 Stm32f429ziDefaultPeripherals,
337 Stm32f429ziDefaultPeripherals::new(clocks, exti, dma1, dma2)
338 );
339 peripherals.init();
340 let base_peripherals = &peripherals.stm32f4;
341
342 setup_peripherals(
343 &base_peripherals.tim2,
344 &peripherals.trng,
345 &peripherals.can1,
346 &peripherals.rtc,
347 );
348
349 set_pin_primary_functions(syscfg, &base_peripherals.gpio_ports);
350
351 setup_dma(
352 dma1,
353 &base_peripherals.dma1_streams,
354 &base_peripherals.usart3,
355 );
356
357 let processes = components::process_array::ProcessArrayComponent::new()
359 .finalize(components::process_array_component_static!(NUM_PROCS));
360 PROCESSES = Some(processes);
361
362 let board_kernel = static_init!(kernel::Kernel, kernel::Kernel::new(processes.as_slice()));
364
365 let chip = static_init!(
366 stm32f429zi::chip::Stm32f4xx<Stm32f429ziDefaultPeripherals>,
367 stm32f429zi::chip::Stm32f4xx::new(peripherals)
368 );
369 CHIP = Some(chip);
370
371 base_peripherals.usart3.enable_clock();
375 let uart_mux = components::console::UartMuxComponent::new(&base_peripherals.usart3, 115200)
376 .finalize(components::uart_mux_component_static!());
377
378 (*addr_of_mut!(io::WRITER)).set_initialized();
379
380 let memory_allocation_capability = create_capability!(capabilities::MemoryAllocationCapability);
383 let process_management_capability =
384 create_capability!(capabilities::ProcessManagementCapability);
385
386 let console = components::console::ConsoleComponent::new(
388 board_kernel,
389 capsules_core::console::DRIVER_NUM,
390 uart_mux,
391 )
392 .finalize(components::console_component_static!());
393 components::debug_writer::DebugWriterComponent::new(
395 uart_mux,
396 create_capability!(capabilities::SetDebugWriterCapability),
397 )
398 .finalize(components::debug_writer_component_static!());
399
400 let gpio_ports = &base_peripherals.gpio_ports;
404
405 let led = components::led::LedsComponent::new().finalize(components::led_component_static!(
406 LedHigh<'static, stm32f429zi::gpio::Pin>,
407 LedHigh::new(gpio_ports.get_pin(stm32f429zi::gpio::PinId::PB00).unwrap()),
408 LedHigh::new(gpio_ports.get_pin(stm32f429zi::gpio::PinId::PB07).unwrap()),
409 LedHigh::new(gpio_ports.get_pin(stm32f429zi::gpio::PinId::PB14).unwrap()),
410 ));
411
412 let button = components::button::ButtonComponent::new(
414 board_kernel,
415 capsules_core::button::DRIVER_NUM,
416 components::button_component_helper!(
417 stm32f429zi::gpio::Pin,
418 (
419 gpio_ports.get_pin(stm32f429zi::gpio::PinId::PC13).unwrap(),
420 kernel::hil::gpio::ActivationMode::ActiveHigh,
421 kernel::hil::gpio::FloatingState::PullNone
422 )
423 ),
424 )
425 .finalize(components::button_component_static!(stm32f429zi::gpio::Pin));
426
427 let tim2 = &base_peripherals.tim2;
430 let mux_alarm = components::alarm::AlarmMuxComponent::new(tim2).finalize(
431 components::alarm_mux_component_static!(stm32f429zi::tim2::Tim2),
432 );
433
434 let alarm = components::alarm::AlarmDriverComponent::new(
435 board_kernel,
436 capsules_core::alarm::DRIVER_NUM,
437 mux_alarm,
438 )
439 .finalize(components::alarm_component_static!(stm32f429zi::tim2::Tim2));
440
441 let gpio = GpioComponent::new(
443 board_kernel,
444 capsules_core::gpio::DRIVER_NUM,
445 components::gpio_component_helper!(
446 stm32f429zi::gpio::Pin,
447 0 => gpio_ports.get_pin(PinId::PG09).unwrap(), 1 => gpio_ports.pins[6][14].as_ref().unwrap(), 2 => gpio_ports.pins[5][15].as_ref().unwrap(), 3 => gpio_ports.pins[4][13].as_ref().unwrap(), 4 => gpio_ports.pins[5][14].as_ref().unwrap(), 5 => gpio_ports.pins[4][11].as_ref().unwrap(), 6 => gpio_ports.pins[4][9].as_ref().unwrap(), 7 => gpio_ports.pins[5][13].as_ref().unwrap(), 8 => gpio_ports.pins[5][12].as_ref().unwrap(), 9 => gpio_ports.pins[3][15].as_ref().unwrap(), 10 => gpio_ports.pins[3][14].as_ref().unwrap(), 11 => gpio_ports.pins[0][7].as_ref().unwrap(), 12 => gpio_ports.pins[0][6].as_ref().unwrap(), 13 => gpio_ports.pins[0][5].as_ref().unwrap(), 14 => gpio_ports.pins[1][9].as_ref().unwrap(), 15 => gpio_ports.pins[1][8].as_ref().unwrap(), 16 => gpio_ports.pins[2][6].as_ref().unwrap(), 17 => gpio_ports.pins[1][15].as_ref().unwrap(), 18 => gpio_ports.pins[1][13].as_ref().unwrap(), 19 => gpio_ports.pins[1][12].as_ref().unwrap(), 20 => gpio_ports.pins[0][15].as_ref().unwrap(), 21 => gpio_ports.pins[2][7].as_ref().unwrap(), 26 => gpio_ports.pins[1][6].as_ref().unwrap(), 27 => gpio_ports.pins[1][2].as_ref().unwrap(), 28 => gpio_ports.pins[3][13].as_ref().unwrap(), 29 => gpio_ports.pins[3][12].as_ref().unwrap(), 30 => gpio_ports.pins[3][11].as_ref().unwrap(), 31 => gpio_ports.pins[4][2].as_ref().unwrap(), 32 => gpio_ports.pins[0][0].as_ref().unwrap(), 33 => gpio_ports.pins[1][0].as_ref().unwrap(), 34 => gpio_ports.pins[4][0].as_ref().unwrap(), 35 => gpio_ports.pins[1][11].as_ref().unwrap(), 36 => gpio_ports.pins[1][10].as_ref().unwrap(), 37 => gpio_ports.pins[4][15].as_ref().unwrap(), 38 => gpio_ports.pins[4][14].as_ref().unwrap(), 39 => gpio_ports.pins[4][12].as_ref().unwrap(), 40 => gpio_ports.pins[4][10].as_ref().unwrap(), 41 => gpio_ports.pins[4][7].as_ref().unwrap(), 42 => gpio_ports.pins[4][8].as_ref().unwrap(), 43 => gpio_ports.pins[2][8].as_ref().unwrap(), 44 => gpio_ports.pins[2][9].as_ref().unwrap(), 45 => gpio_ports.pins[2][10].as_ref().unwrap(), 46 => gpio_ports.pins[2][11].as_ref().unwrap(), 47 => gpio_ports.pins[2][12].as_ref().unwrap(), 48 => gpio_ports.pins[3][2].as_ref().unwrap(), 49 => gpio_ports.pins[6][2].as_ref().unwrap(), 50 => gpio_ports.pins[6][3].as_ref().unwrap(), 51 => gpio_ports.pins[3][7].as_ref().unwrap(), 52 => gpio_ports.pins[3][6].as_ref().unwrap(), 53 => gpio_ports.pins[3][5].as_ref().unwrap(), 54 => gpio_ports.pins[3][4].as_ref().unwrap(), 55 => gpio_ports.pins[3][3].as_ref().unwrap(), 56 => gpio_ports.pins[4][2].as_ref().unwrap(), 57 => gpio_ports.pins[4][4].as_ref().unwrap(), 58 => gpio_ports.pins[4][5].as_ref().unwrap(), 59 => gpio_ports.pins[4][6].as_ref().unwrap(), 60 => gpio_ports.pins[4][3].as_ref().unwrap(), 61 => gpio_ports.pins[5][8].as_ref().unwrap(), 62 => gpio_ports.pins[5][7].as_ref().unwrap(), 63 => gpio_ports.pins[5][9].as_ref().unwrap(), 64 => gpio_ports.pins[6][1].as_ref().unwrap(), 65 => gpio_ports.pins[6][0].as_ref().unwrap(), 66 => gpio_ports.pins[3][1].as_ref().unwrap(), 67 => gpio_ports.pins[3][0].as_ref().unwrap(), 68 => gpio_ports.pins[5][0].as_ref().unwrap(), 69 => gpio_ports.pins[5][1].as_ref().unwrap(), 70 => gpio_ports.pins[5][2].as_ref().unwrap(), 71 => gpio_ports.pins[0][7].as_ref().unwrap(), 75 => gpio_ports.pins[5][3].as_ref().unwrap(), 76 => gpio_ports.pins[5][5].as_ref().unwrap(), 77 => gpio_ports.pins[5][10].as_ref().unwrap(), 80 => gpio_ports.pins[5][4].as_ref().unwrap() ),
540 )
541 .finalize(components::gpio_component_static!(stm32f429zi::gpio::Pin));
542
543 let adc_mux = components::adc::AdcMuxComponent::new(&base_peripherals.adc1)
545 .finalize(components::adc_mux_component_static!(stm32f429zi::adc::Adc));
546
547 let temp_sensor = components::temperature_stm::TemperatureSTMComponent::new(
548 adc_mux,
549 stm32f429zi::adc::Channel::Channel18,
550 2.5,
551 0.76,
552 )
553 .finalize(components::temperature_stm_adc_component_static!(
554 stm32f429zi::adc::Adc
555 ));
556
557 let temp = components::temperature::TemperatureComponent::new(
558 board_kernel,
559 capsules_extra::temperature::DRIVER_NUM,
560 temp_sensor,
561 )
562 .finalize(components::temperature_component_static!(
563 TemperatureSTMSensor
564 ));
565
566 let adc_channel_0 =
567 components::adc::AdcComponent::new(adc_mux, stm32f429zi::adc::Channel::Channel3)
568 .finalize(components::adc_component_static!(stm32f429zi::adc::Adc));
569
570 let adc_channel_1 =
571 components::adc::AdcComponent::new(adc_mux, stm32f429zi::adc::Channel::Channel10)
572 .finalize(components::adc_component_static!(stm32f429zi::adc::Adc));
573
574 let adc_channel_2 =
575 components::adc::AdcComponent::new(adc_mux, stm32f429zi::adc::Channel::Channel13)
576 .finalize(components::adc_component_static!(stm32f429zi::adc::Adc));
577
578 let adc_channel_3 =
579 components::adc::AdcComponent::new(adc_mux, stm32f429zi::adc::Channel::Channel9)
580 .finalize(components::adc_component_static!(stm32f429zi::adc::Adc));
581
582 let adc_channel_4 =
583 components::adc::AdcComponent::new(adc_mux, stm32f429zi::adc::Channel::Channel12)
584 .finalize(components::adc_component_static!(stm32f429zi::adc::Adc));
585
586 let adc_syscall =
587 components::adc::AdcVirtualComponent::new(board_kernel, capsules_core::adc::DRIVER_NUM)
588 .finalize(components::adc_syscall_component_helper!(
589 adc_channel_0,
590 adc_channel_1,
591 adc_channel_2,
592 adc_channel_3,
593 adc_channel_4,
594 ));
595
596 let process_printer = components::process_printer::ProcessPrinterTextComponent::new()
597 .finalize(components::process_printer_text_component_static!());
598 PROCESS_PRINTER = Some(process_printer);
599
600 let dac = components::dac::DacComponent::new(&base_peripherals.dac)
602 .finalize(components::dac_component_static!());
603
604 let rng = components::rng::RngComponent::new(
606 board_kernel,
607 capsules_core::rng::DRIVER_NUM,
608 &peripherals.trng,
609 )
610 .finalize(components::rng_component_static!(stm32f429zi::trng::Trng));
611
612 let can = components::can::CanComponent::new(
614 board_kernel,
615 capsules_extra::can::DRIVER_NUM,
616 &peripherals.can1,
617 )
618 .finalize(components::can_component_static!(
619 stm32f429zi::can::Can<'static>
620 ));
621
622 if let Err(e) = peripherals.rtc.rtc_init() {
624 debug!("{:?}", e)
625 }
626
627 let date_time = components::date_time::DateTimeComponent::new(
628 board_kernel,
629 capsules_extra::date_time::DRIVER_NUM,
630 &peripherals.rtc,
631 )
632 .finalize(components::date_time_component_static!(
633 stm32f429zi::rtc::Rtc<'static>
634 ));
635
636 let process_console = components::process_console::ProcessConsoleComponent::new(
638 board_kernel,
639 uart_mux,
640 mux_alarm,
641 process_printer,
642 Some(cortexm4::support::reset),
643 )
644 .finalize(components::process_console_component_static!(
645 stm32f429zi::tim2::Tim2
646 ));
647 let _ = process_console.start();
648
649 let scheduler = components::sched::round_robin::RoundRobinComponent::new(processes)
650 .finalize(components::round_robin_component_static!(NUM_PROCS));
651
652 let nucleo_f429zi = NucleoF429ZI {
653 console,
654 ipc: kernel::ipc::IPC::new(
655 board_kernel,
656 kernel::ipc::DRIVER_NUM,
657 &memory_allocation_capability,
658 ),
659 adc: adc_syscall,
660 dac,
661 led,
662 temperature: temp,
663 button,
664 alarm,
665 gpio,
666 rng,
667
668 scheduler,
669 systick: cortexm4::systick::SysTick::new_with_calibration(
670 (HSI_FREQUENCY_MHZ * 1_000_000) as u32,
671 ),
672 can,
673 date_time,
674 };
675
676 debug!("Initialization complete. Entering main loop");
682
683 extern "C" {
685 static _sapps: u8;
687 static _eapps: u8;
689 static mut _sappmem: u8;
691 static _eappmem: u8;
693 }
694
695 kernel::process::load_processes(
696 board_kernel,
697 chip,
698 core::slice::from_raw_parts(
699 core::ptr::addr_of!(_sapps),
700 core::ptr::addr_of!(_eapps) as usize - core::ptr::addr_of!(_sapps) as usize,
701 ),
702 core::slice::from_raw_parts_mut(
703 core::ptr::addr_of_mut!(_sappmem),
704 core::ptr::addr_of!(_eappmem) as usize - core::ptr::addr_of!(_sappmem) as usize,
705 ),
706 &FAULT_RESPONSE,
707 &process_management_capability,
708 )
709 .unwrap_or_else(|err| {
710 debug!("Error loading processes!");
711 debug!("{:?}", err);
712 });
713
714 (board_kernel, nucleo_f429zi, chip)
720}
721
722#[no_mangle]
724pub unsafe fn main() {
725 let main_loop_capability = create_capability!(capabilities::MainLoopCapability);
726
727 let (board_kernel, platform, chip) = start();
728 board_kernel.kernel_loop(&platform, chip, Some(&platform.ipc), &main_loop_capability);
729}