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