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