Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into uart-hil-no-init
Conflict with new imix components
- Loading branch information
Showing
41 changed files
with
1,624 additions
and
583 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//! Component for the ADC on the imix board. | ||
//! | ||
//! This provides one Component, AdcComponent, which implements | ||
//! a userspace syscall interface to the SAM4L ADC. It provides | ||
//! 6 ADC channels, AD0-AD5. | ||
//! | ||
//! Usage | ||
//! ----- | ||
//! ```rust | ||
//! let adc = AdcComponent::new().finalize(); | ||
//! ``` | ||
|
||
// Author: Philip Levis <pal@cs.stanford.edu> | ||
// Last modified: 6/20/2018 | ||
|
||
#![allow(dead_code)] // Components are intended to be conditionally included | ||
|
||
use capsules::adc; | ||
use kernel::component::Component; | ||
use sam4l; | ||
|
||
pub struct AdcComponent {} | ||
|
||
impl AdcComponent { | ||
pub fn new() -> AdcComponent { | ||
AdcComponent {} | ||
} | ||
} | ||
|
||
impl Component for AdcComponent { | ||
type Output = &'static adc::Adc<'static, sam4l::adc::Adc>; | ||
|
||
unsafe fn finalize(&mut self) -> Self::Output { | ||
let adc_channels = static_init!( | ||
[&'static sam4l::adc::AdcChannel; 6], | ||
[ | ||
&sam4l::adc::CHANNEL_AD1, // AD0 | ||
&sam4l::adc::CHANNEL_AD2, // AD1 | ||
&sam4l::adc::CHANNEL_AD3, // AD2 | ||
&sam4l::adc::CHANNEL_AD4, // AD3 | ||
&sam4l::adc::CHANNEL_AD5, // AD4 | ||
&sam4l::adc::CHANNEL_AD6, // AD5 | ||
] | ||
); | ||
let adc = static_init!( | ||
adc::Adc<'static, sam4l::adc::Adc>, | ||
adc::Adc::new( | ||
&mut sam4l::adc::ADC0, | ||
adc_channels, | ||
&mut adc::ADC_BUFFER1, | ||
&mut adc::ADC_BUFFER2, | ||
&mut adc::ADC_BUFFER3 | ||
) | ||
); | ||
sam4l::adc::ADC0.set_client(adc); | ||
|
||
adc | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//! Component for harware timer Alarms on the imix board. | ||
//! | ||
//! This provides one component, AlarmDriverComponent, which provides | ||
//! an alarm system call interface. | ||
//! | ||
//! Usage | ||
//! ----- | ||
//! ```rust | ||
//! let alarm = AlarmDriverComponent::new(mux_alarm).finalize(); | ||
//! ``` | ||
|
||
// Author: Philip Levis <pal@cs.stanford.edu> | ||
// Last modified: 6/20/2018 | ||
|
||
#![allow(dead_code)] // Components are intended to be conditionally included | ||
|
||
use capsules::alarm::AlarmDriver; | ||
use capsules::virtual_alarm::{MuxAlarm, VirtualMuxAlarm}; | ||
use kernel; | ||
use kernel::component::Component; | ||
use sam4l; | ||
|
||
pub struct AlarmDriverComponent { | ||
alarm_mux: &'static MuxAlarm<'static, sam4l::ast::Ast<'static>>, | ||
} | ||
|
||
impl AlarmDriverComponent { | ||
pub fn new(mux: &'static MuxAlarm<'static, sam4l::ast::Ast>) -> AlarmDriverComponent { | ||
AlarmDriverComponent { alarm_mux: mux } | ||
} | ||
} | ||
|
||
impl Component for AlarmDriverComponent { | ||
type Output = &'static AlarmDriver<'static, VirtualMuxAlarm<'static, sam4l::ast::Ast<'static>>>; | ||
|
||
unsafe fn finalize(&mut self) -> Self::Output { | ||
let virtual_alarm1 = static_init!( | ||
VirtualMuxAlarm<'static, sam4l::ast::Ast>, | ||
VirtualMuxAlarm::new(self.alarm_mux) | ||
); | ||
let alarm = static_init!( | ||
AlarmDriver<'static, VirtualMuxAlarm<'static, sam4l::ast::Ast>>, | ||
AlarmDriver::new(virtual_alarm1, kernel::Grant::create()) | ||
); | ||
|
||
virtual_alarm1.set_client(alarm); | ||
alarm | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//! Component for imix board buttons. | ||
//! | ||
//! This provides one Component, ButtonComponent, which implements a | ||
//! userspace syscall interface to the one imix on-board button (pin | ||
//! 24). | ||
//! | ||
//! Usage | ||
//! ----- | ||
//! ```rust | ||
//! let button = ButtonComponent::new().finalize(); | ||
//! ``` | ||
|
||
// Author: Philip Levis <pal@cs.stanford.edu> | ||
// Last modified: 6/20/2018 | ||
|
||
#![allow(dead_code)] // Components are intended to be conditionally included | ||
|
||
use capsules::button; | ||
use kernel; | ||
use kernel::component::Component; | ||
use sam4l; | ||
|
||
pub struct ButtonComponent {} | ||
|
||
impl ButtonComponent { | ||
pub fn new() -> ButtonComponent { | ||
ButtonComponent {} | ||
} | ||
} | ||
|
||
impl Component for ButtonComponent { | ||
type Output = &'static button::Button<'static, sam4l::gpio::GPIOPin>; | ||
|
||
unsafe fn finalize(&mut self) -> Self::Output { | ||
let button_pins = static_init!( | ||
[(&'static sam4l::gpio::GPIOPin, button::GpioMode); 1], | ||
[(&sam4l::gpio::PC[24], button::GpioMode::LowWhenPressed)] | ||
); | ||
|
||
let button = static_init!( | ||
button::Button<'static, sam4l::gpio::GPIOPin>, | ||
button::Button::new(button_pins, kernel::Grant::create()) | ||
); | ||
for &(btn, _) in button_pins.iter() { | ||
btn.set_client(button); | ||
} | ||
|
||
button | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//! Component for Console on the imix board. | ||
//! | ||
//! This provides one Component, ConsoleComponent, which implements | ||
//! a buffered read/write console over a serial port. This is typically | ||
//! USART3 (the DEBUG USB connector). It attaches kernel debug output | ||
//! to this console (for panic!, print!, debug!, etc.). | ||
//! | ||
//! Usage | ||
//! ----- | ||
//! ```rust | ||
//! let spi_syscalls = SpiSyscallComponent::new(mux_spi).finalize(); | ||
//! let rf233_spi = SpiComponent::new(mux_spi).finalize(); | ||
//! ``` | ||
|
||
// Author: Philip Levis <pal@cs.stanford.edu> | ||
// Last modified: 6/20/2018 | ||
|
||
#![allow(dead_code)] // Components are intended to be conditionally included | ||
|
||
use capsules::console; | ||
use hil; | ||
use kernel; | ||
use kernel::component::Component; | ||
use kernel::Grant; | ||
use sam4l; | ||
|
||
pub struct ConsoleComponent { | ||
uart: &'static sam4l::usart::USART, | ||
baud_rate: u32, | ||
} | ||
|
||
impl ConsoleComponent { | ||
pub fn new(uart: &'static sam4l::usart::USART, rate: u32) -> ConsoleComponent { | ||
ConsoleComponent { | ||
uart: uart, | ||
baud_rate: rate, | ||
} | ||
} | ||
} | ||
|
||
impl Component for ConsoleComponent { | ||
type Output = &'static console::Console<'static, sam4l::usart::USART>; | ||
|
||
unsafe fn finalize(&mut self) -> Self::Output { | ||
sam4l::usart::USART3.set_mode(sam4l::usart::UsartMode::Uart); | ||
let console = static_init!( | ||
console::Console<sam4l::usart::USART>, | ||
console::Console::new( | ||
self.uart, | ||
self.baud_rate, | ||
&mut console::WRITE_BUF, | ||
&mut console::READ_BUF, | ||
Grant::create() | ||
) | ||
); | ||
hil::uart::UART::set_client(self.uart, console); | ||
console.initialize(); | ||
|
||
// Attach the kernel debug interface to this console | ||
let kc = static_init!(console::App, console::App::default()); | ||
kernel::debug::assign_console_driver(Some(console), kc); | ||
|
||
console | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//! Component for CRC syscall interface on imix board. | ||
//! | ||
//! This provides one Component, CrcComponent, which implements a | ||
//! userspace syscall interface to the CRC peripheral (CRCCU) on the | ||
//! SAM4L. | ||
//! | ||
//! Usage | ||
//! ----- | ||
//! ```rust | ||
//! let crc = CrcComponent::new().finalize(); | ||
//! ``` | ||
|
||
// Author: Philip Levis <pal@cs.stanford.edu> | ||
// Last modified: 6/20/2018 | ||
|
||
#![allow(dead_code)] // Components are intended to be conditionally included | ||
|
||
use capsules::crc; | ||
use kernel; | ||
use kernel::component::Component; | ||
use sam4l; | ||
|
||
pub struct CrcComponent {} | ||
|
||
impl CrcComponent { | ||
pub fn new() -> CrcComponent { | ||
CrcComponent {} | ||
} | ||
} | ||
|
||
impl Component for CrcComponent { | ||
type Output = &'static crc::Crc<'static, sam4l::crccu::Crccu<'static>>; | ||
|
||
unsafe fn finalize(&mut self) -> Self::Output { | ||
let crc = static_init!( | ||
crc::Crc<'static, sam4l::crccu::Crccu<'static>>, | ||
crc::Crc::new(&mut sam4l::crccu::CRCCU, kernel::Grant::create()) | ||
); | ||
|
||
crc | ||
} | ||
} |
Oops, something went wrong.