You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.7 KiB
Rust
50 lines
1.7 KiB
Rust
5 years ago
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||
|
//
|
||
4 years ago
|
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||
5 years ago
|
|
||
|
//! BSP driver support.
|
||
|
|
||
|
use crate::driver;
|
||
|
|
||
|
//--------------------------------------------------------------------------------------------------
|
||
4 years ago
|
// Private Definitions
|
||
5 years ago
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
||
|
/// Device Driver Manager type.
|
||
4 years ago
|
struct BSPDriverManager {
|
||
5 years ago
|
device_drivers: [&'static (dyn DeviceDriver + Sync); 2],
|
||
|
}
|
||
|
|
||
|
//--------------------------------------------------------------------------------------------------
|
||
|
// Global instances
|
||
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
||
|
static BSP_DRIVER_MANAGER: BSPDriverManager = BSPDriverManager {
|
||
|
device_drivers: [&super::GPIO, &super::PL011_UART],
|
||
|
};
|
||
|
|
||
|
//--------------------------------------------------------------------------------------------------
|
||
|
// Public Code
|
||
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
||
|
/// Return a reference to the driver manager.
|
||
|
pub fn driver_manager() -> &'static impl driver::interface::DriverManager {
|
||
|
&BSP_DRIVER_MANAGER
|
||
|
}
|
||
|
|
||
|
//------------------------------------------------------------------------------
|
||
|
// OS Interface Code
|
||
|
//------------------------------------------------------------------------------
|
||
|
use driver::interface::DeviceDriver;
|
||
|
|
||
|
impl driver::interface::DriverManager for BSPDriverManager {
|
||
|
fn all_device_drivers(&self) -> &[&'static (dyn DeviceDriver + Sync)] {
|
||
|
&self.device_drivers[..]
|
||
|
}
|
||
|
|
||
|
fn post_device_driver_init(&self) {
|
||
|
// Configure PL011Uart's output pins.
|
||
|
super::GPIO.map_pl011_uart();
|
||
|
}
|
||
|
}
|