Skip to content

Commit

Permalink
Merge branch 'master' into uart-hil-no-init
Browse files Browse the repository at this point in the history
Conflict with new imix components
  • Loading branch information
ppannuto committed Jul 16, 2018
2 parents 5ab00cf + 06d0b53 commit e821691
Show file tree
Hide file tree
Showing 41 changed files with 1,624 additions and 583 deletions.
8 changes: 8 additions & 0 deletions .github/CONTRIBUTING.md
Expand Up @@ -218,6 +218,14 @@ In order to land, a Pull Request needs to be reviewed and
commit access to the Tock repository and pass the continuous integration tests.
After that, as long as there are no objections, the Pull Request can be merged.

We use the bors-ng bot to merge PRs. In short, when someone replies `bors r+`,
your PR has been scheduled for final tests and will be automatically merged. If
a maintainer replies `bors delegate+`, then you have been granted the authority
to merge your own PR (usually this will happen if there are some trivial
changes required). For more on bors,
[see the bors documentation](https://bors.tech/documentation/).


## Issue Triage

Sometimes, an issue will stay open, even though the bug has been fixed. And
Expand Down
18 changes: 18 additions & 0 deletions .travis.yml
@@ -1,6 +1,24 @@
sudo: false
language: rust


# bors default configuration:
#branches:
# only:
# # This is where pull requests from "bors r+" are built.
# - staging
# # This is where pull requests from "bors try" are built.
# - trying
# # Uncomment this to enable building pull requests.
# - master
#
# Instead, I think we just want to disable to bors temp branch
branches:
except:
- staging.tmp
- trying.tmp


cache:
cargo: true

Expand Down
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -47,6 +47,7 @@ ci-travis:
@printf "$$(tput bold)* CI: Libraries *$$(tput sgr0)\n"
@printf "$$(tput bold)*****************$$(tput sgr0)\n"
@CI=true cd libraries/tock-cells && cargo test
@CI=true cd libraries/tock-register-interface && cargo test
@printf "$$(tput bold)**************$$(tput sgr0)\n"
@printf "$$(tput bold)* CI: Syntax *$$(tput sgr0)\n"
@printf "$$(tput bold)**************$$(tput sgr0)\n"
Expand Down
24 changes: 23 additions & 1 deletion README.md
Expand Up @@ -40,13 +40,18 @@ Find example applications that run on top of the Tock kernel written in both
[Rust](https://github.com/tock/libtock-rs) and
[C](https://github.com/tock/libtock-c).


### Develop Tock

Read our [getting started guide](doc/Getting_Started.md) to get the correct
version of the Rust compiler, then look through the `/kernel`, `/capsules`,
`/chips`, and `/boards` directories.

We're happy to accept pull requests and look forward to seeing how Tock grows.
We encourage contributions back to Tock and are happy to accept pull requests
for anything from small documentation fixes to whole new platforms.
For details, check out our [Contributing Guide](.github/CONTRIBUTING.md).
To get started, please do not hesitate to submit a PR. We'll happily guide you
through any needed changes.


### Keep Up To Date
Expand All @@ -58,3 +63,20 @@ post series highlights what's new in Tock. Also, follow
You can also browse our
[email group](https://groups.google.com/forum/#!forum/tock-dev) to see
discussions on Tock development.


License
-------

Licensed under either of

- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or
http://opensource.org/licenses/MIT)

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall
be dual licensed as above, without any additional terms or conditions.
59 changes: 59 additions & 0 deletions boards/imix/src/components/adc.rs
@@ -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
}
}
49 changes: 49 additions & 0 deletions boards/imix/src/components/alarm.rs
@@ -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
}
}
50 changes: 50 additions & 0 deletions boards/imix/src/components/button.rs
@@ -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
}
}
65 changes: 65 additions & 0 deletions boards/imix/src/components/console.rs
@@ -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
}
}
42 changes: 42 additions & 0 deletions boards/imix/src/components/crc.rs
@@ -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
}
}

0 comments on commit e821691

Please sign in to comment.