Skip to content

Commit

Permalink
PR #1046
Browse files Browse the repository at this point in the history
  • Loading branch information
bradjc committed Jul 10, 2018
1 parent 8f30164 commit 8ed57a8
Show file tree
Hide file tree
Showing 12 changed files with 744 additions and 449 deletions.
43 changes: 35 additions & 8 deletions boards/ek-tm4c1294xl/src/main.rs
Expand Up @@ -12,6 +12,7 @@ extern crate cortexm4;
extern crate tm4c129x;

use capsules::virtual_alarm::{MuxAlarm, VirtualMuxAlarm};
use capsules::virtual_uart::{UartDevice, UartMux};
use kernel::hil;
use kernel::hil::Controller;
use kernel::Platform;
Expand Down Expand Up @@ -43,7 +44,7 @@ pub static mut STACK_MEMORY: [u8; 0x1000] = [0; 0x1000];
/// A structure representing this platform that holds references to all
/// capsules for this platform.
struct EkTm4c1294xl {
console: &'static capsules::console::Console<'static, tm4c129x::uart::UART>,
console: &'static capsules::console::Console<'static, UartDevice<'static>>,
alarm: &'static capsules::alarm::AlarmDriver<
'static,
VirtualMuxAlarm<'static, tm4c129x::gpt::AlarmTimer>,
Expand Down Expand Up @@ -80,19 +81,49 @@ pub unsafe fn reset_handler() {
tm4c129x::sysctl::PSYSCTLM
.setup_system_clock(tm4c129x::sysctl::SystemClockSource::PllPioscAt120MHz);

// Create a shared UART channel for the console and for kernel debug.
let uart_mux = static_init!(
UartMux<'static>,
UartMux::new(&tm4c129x::uart::UART0, &mut capsules::virtual_uart::RX_BUF)
);
hil::uart::UART::set_client(&tm4c129x::uart::UART0, uart_mux);

// Create a UartDevice for the console.
let console_uart = static_init!(UartDevice, UartDevice::new(uart_mux, true));
console_uart.setup();

let console = static_init!(
capsules::console::Console<tm4c129x::uart::UART>,
capsules::console::Console<UartDevice>,
capsules::console::Console::new(
&tm4c129x::uart::UART0,
console_uart,
115200,
&mut capsules::console::WRITE_BUF,
&mut capsules::console::READ_BUF,
kernel::Grant::create()
)
);
hil::uart::UART::set_client(&tm4c129x::uart::UART0, console);
hil::uart::UART::set_client(console_uart, console);
tm4c129x::uart::UART0.specify_pins(&tm4c129x::gpio::PA[0], &tm4c129x::gpio::PA[1]);

// Create virtual device for kernel debug.
let debugger_uart = static_init!(UartDevice, UartDevice::new(uart_mux, false));
debugger_uart.setup();
let debugger = static_init!(
kernel::debug::DebugWriter,
kernel::debug::DebugWriter::new(
debugger_uart,
&mut kernel::debug::OUTPUT_BUF,
&mut kernel::debug::INTERNAL_BUF,
)
);
hil::uart::UART::set_client(debugger_uart, debugger);

let debug_wrapper = static_init!(
kernel::debug::DebugWriterWrapper,
kernel::debug::DebugWriterWrapper::new(debugger)
);
kernel::debug::set_debug_writer_wrapper(debug_wrapper);

// Alarm
let alarm_timer = &tm4c129x::gpt::TIMER0;
let mux_alarm = static_init!(
Expand Down Expand Up @@ -193,10 +224,6 @@ pub unsafe fn reset_handler() {

tm4c1294.console.initialize();

// Attach the kernel debug interface to this console
let kc = static_init!(capsules::console::App, capsules::console::App::default());
kernel::debug::assign_console_driver(Some(tm4c1294.console), kc);

debug!("Initialization complete. Entering main loop...\r");

let board_kernel = static_init!(kernel::Kernel, kernel::Kernel::new());
Expand Down
44 changes: 36 additions & 8 deletions boards/hail/src/main.rs
Expand Up @@ -18,6 +18,7 @@ extern crate sam4l;
use capsules::virtual_alarm::{MuxAlarm, VirtualMuxAlarm};
use capsules::virtual_i2c::{I2CDevice, MuxI2C};
use capsules::virtual_spi::{MuxSpiMaster, VirtualSpiMasterDevice};
use capsules::virtual_uart::{UartDevice, UartMux};
use kernel::hil;
use kernel::hil::spi::SpiMaster;
use kernel::hil::Controller;
Expand Down Expand Up @@ -60,7 +61,7 @@ pub static mut STACK_MEMORY: [u8; 0x1000] = [0; 0x1000];
/// A structure representing this platform that holds references to all
/// capsules for this platform.
struct Hail {
console: &'static capsules::console::Console<'static, sam4l::usart::USART>,
console: &'static capsules::console::Console<'static, UartDevice<'static>>,
gpio: &'static capsules::gpio::GPIO<'static, sam4l::gpio::GPIOPin>,
alarm: &'static capsules::alarm::AlarmDriver<
'static,
Expand Down Expand Up @@ -200,17 +201,27 @@ pub unsafe fn reset_handler() {

let mut chip = sam4l::chip::Sam4l::new();

// Create a shared UART channel for the console and for kernel debug.
let uart_mux = static_init!(
UartMux<'static>,
UartMux::new(&sam4l::usart::USART0, &mut capsules::virtual_uart::RX_BUF)
);
hil::uart::UART::set_client(&sam4l::usart::USART0, uart_mux);

// Create a UartDevice for the console.
let console_uart = static_init!(UartDevice, UartDevice::new(uart_mux, true));
console_uart.setup();
let console = static_init!(
capsules::console::Console<sam4l::usart::USART>,
capsules::console::Console<UartDevice>,
capsules::console::Console::new(
&sam4l::usart::USART0,
console_uart,
115200,
&mut capsules::console::WRITE_BUF,
&mut capsules::console::READ_BUF,
kernel::Grant::create()
)
);
hil::uart::UART::set_client(&sam4l::usart::USART0, console);
hil::uart::UART::set_client(console_uart, console);

// Create the Nrf51822Serialization driver for passing BLE commands
// over UART to the nRF51822 radio.
Expand Down Expand Up @@ -476,17 +487,34 @@ pub unsafe fn reset_handler() {
}
sam4l::gpio::PA[17].set();

// Initialize the UART bus.
hail.console.initialize();
// Attach the kernel debug interface to this console
let kc = static_init!(capsules::console::App, capsules::console::App::default());
kernel::debug::assign_console_driver(Some(hail.console), kc);

// Create virtual device for kernel debug.
let debugger_uart = static_init!(UartDevice, UartDevice::new(uart_mux, false));
debugger_uart.setup();
let debugger = static_init!(
kernel::debug::DebugWriter,
kernel::debug::DebugWriter::new(
debugger_uart,
&mut kernel::debug::OUTPUT_BUF,
&mut kernel::debug::INTERNAL_BUF,
)
);
hil::uart::UART::set_client(debugger_uart, debugger);

let debug_wrapper = static_init!(
kernel::debug::DebugWriterWrapper,
kernel::debug::DebugWriterWrapper::new(debugger)
);
kernel::debug::set_debug_writer_wrapper(debug_wrapper);

hail.nrf51822.initialize();

// Uncomment to measure overheads for TakeCell and MapCell:
// test_take_map_cell::test_take_map_cell();

// debug!("Initialization complete. Entering main loop");
debug!("Initialization complete. Entering main loop");

let board_kernel = static_init!(kernel::Kernel, kernel::Kernel::new());

Expand Down
40 changes: 33 additions & 7 deletions boards/imix/src/main.rs
Expand Up @@ -24,6 +24,7 @@ use capsules::rf233::RF233;
use capsules::virtual_alarm::{MuxAlarm, VirtualMuxAlarm};
use capsules::virtual_i2c::{I2CDevice, MuxI2C};
use capsules::virtual_spi::{MuxSpiMaster, VirtualSpiMasterDevice};
use capsules::virtual_uart::{UartDevice, UartMux};
use kernel::hil;
use kernel::hil::radio;
use kernel::hil::radio::{RadioConfig, RadioData};
Expand Down Expand Up @@ -82,7 +83,7 @@ type RF233Device =
capsules::rf233::RF233<'static, VirtualSpiMasterDevice<'static, sam4l::spi::SpiHw>>;

struct Imix {
console: &'static capsules::console::Console<'static, sam4l::usart::USART>,
console: &'static capsules::console::Console<'static, UartDevice<'static>>,
gpio: &'static capsules::gpio::GPIO<'static, sam4l::gpio::GPIOPin>,
alarm: &'static AlarmDriver<'static, VirtualMuxAlarm<'static, sam4l::ast::Ast<'static>>>,
temp: &'static capsules::temperature::TemperatureSensor<'static>,
Expand Down Expand Up @@ -255,22 +256,47 @@ pub unsafe fn reset_handler() {

// # CONSOLE

// Create a shared UART channel for the console and for kernel debug.
let uart_mux = static_init!(
UartMux<'static>,
UartMux::new(&sam4l::usart::USART3, &mut capsules::virtual_uart::RX_BUF)
);
hil::uart::UART::set_client(&sam4l::usart::USART3, uart_mux);

// Create a UartDevice for the console.
let console_uart = static_init!(UartDevice, UartDevice::new(uart_mux, true));
console_uart.setup();
let console = static_init!(
capsules::console::Console<sam4l::usart::USART>,
capsules::console::Console<UartDevice>,
capsules::console::Console::new(
&sam4l::usart::USART3,
console_uart,
115200,
&mut capsules::console::WRITE_BUF,
&mut capsules::console::READ_BUF,
kernel::Grant::create()
)
);
hil::uart::UART::set_client(&sam4l::usart::USART3, console);
hil::uart::UART::set_client(console_uart, console);
console.initialize();

// Attach the kernel debug interface to this console
let kc = static_init!(capsules::console::App, capsules::console::App::default());
kernel::debug::assign_console_driver(Some(console), kc);
// Create virtual device for kernel debug.
let debugger_uart = static_init!(UartDevice, UartDevice::new(uart_mux, false));
debugger_uart.setup();
let debugger = static_init!(
kernel::debug::DebugWriter,
kernel::debug::DebugWriter::new(
debugger_uart,
&mut kernel::debug::OUTPUT_BUF,
&mut kernel::debug::INTERNAL_BUF,
)
);
hil::uart::UART::set_client(debugger_uart, debugger);

let debug_wrapper = static_init!(
kernel::debug::DebugWriterWrapper,
kernel::debug::DebugWriterWrapper::new(debugger)
);
kernel::debug::set_debug_writer_wrapper(debug_wrapper);

// Create the Nrf51822Serialization driver for passing BLE commands
// over UART to the nRF51822 radio.
Expand Down
42 changes: 35 additions & 7 deletions boards/launchxl/src/main.rs
Expand Up @@ -12,8 +12,10 @@ extern crate cc26xx;
#[macro_use(debug, debug_gpio, static_init)]
extern crate kernel;

use capsules::virtual_uart::{UartDevice, UartMux};
use cc26xx::aon;
use cc26xx::prcm;
use kernel::hil;

#[macro_use]
pub mod io;
Expand All @@ -38,7 +40,7 @@ pub static mut STACK_MEMORY: [u8; 0x1000] = [0; 0x1000];
pub struct Platform {
gpio: &'static capsules::gpio::GPIO<'static, cc26xx::gpio::GPIOPin>,
led: &'static capsules::led::LED<'static, cc26xx::gpio::GPIOPin>,
console: &'static capsules::console::Console<'static, cc26xx::uart::UART>,
console: &'static capsules::console::Console<'static, UartDevice<'static>>,
button: &'static capsules::button::Button<'static, cc26xx::gpio::GPIOPin>,
alarm: &'static capsules::alarm::AlarmDriver<
'static,
Expand Down Expand Up @@ -125,23 +127,49 @@ pub unsafe fn reset_handler() {
}

// UART
// Create a shared UART channel for the console and for kernel debug.
let uart_mux = static_init!(
UartMux<'static>,
UartMux::new(&cc26xx::uart::UART0, &mut capsules::virtual_uart::RX_BUF)
);
hil::uart::UART::set_client(&cc26xx::uart::UART0, uart_mux);

// Create a UartDevice for the console.
let console_uart = static_init!(UartDevice, UartDevice::new(uart_mux, true));
console_uart.setup();

cc26xx::uart::UART0.set_pins(3, 2);
let console = static_init!(
capsules::console::Console<cc26xx::uart::UART>,
capsules::console::Console<UartDevice>,
capsules::console::Console::new(
&cc26xx::uart::UART0,
console_uart,
115200,
&mut capsules::console::WRITE_BUF,
&mut capsules::console::READ_BUF,
kernel::Grant::create()
)
);
kernel::hil::uart::UART::set_client(&cc26xx::uart::UART0, console);
kernel::hil::uart::UART::set_client(console_uart, console);
console.initialize();

// Attach the kernel debug interface to this console
let kc = static_init!(capsules::console::App, capsules::console::App::default());
kernel::debug::assign_console_driver(Some(console), kc);
// Create virtual device for kernel debug.
let debugger_uart = static_init!(UartDevice, UartDevice::new(uart_mux, false));
debugger_uart.setup();
let debugger = static_init!(
kernel::debug::DebugWriter,
kernel::debug::DebugWriter::new(
debugger_uart,
&mut kernel::debug::OUTPUT_BUF,
&mut kernel::debug::INTERNAL_BUF,
)
);
hil::uart::UART::set_client(debugger_uart, debugger);

let debug_wrapper = static_init!(
kernel::debug::DebugWriterWrapper,
kernel::debug::DebugWriterWrapper::new(debugger)
);
kernel::debug::set_debug_writer_wrapper(debug_wrapper);

// Setup for remaining GPIO pins
let gpio_pins = static_init!(
Expand Down
43 changes: 36 additions & 7 deletions boards/nordic/nrf51dk/src/main.rs
Expand Up @@ -57,6 +57,8 @@ extern crate nrf5x;

use capsules::alarm::AlarmDriver;
use capsules::virtual_alarm::{MuxAlarm, VirtualMuxAlarm};
use capsules::virtual_uart::{UartDevice, UartMux};
use kernel::hil;
use kernel::hil::uart::UART;
use kernel::{Chip, SysTick};
use nrf5x::pinmux::Pinmux;
Expand Down Expand Up @@ -106,7 +108,7 @@ pub struct Platform {
VirtualMuxAlarm<'static, Rtc>,
>,
button: &'static capsules::button::Button<'static, nrf5x::gpio::GPIOPin>,
console: &'static capsules::console::Console<'static, nrf51::uart::UART>,
console: &'static capsules::console::Console<'static, UartDevice<'static>>,
gpio: &'static capsules::gpio::GPIO<'static, nrf5x::gpio::GPIOPin>,
led: &'static capsules::led::LED<'static, nrf5x::gpio::GPIOPin>,
temp: &'static capsules::temperature::TemperatureSensor<'static>,
Expand Down Expand Up @@ -235,22 +237,49 @@ pub unsafe fn reset_handler() {
Pinmux::new(10), /* cts */
Pinmux::new(8), /*. rts */
);

// Create a shared UART channel for the console and for kernel debug.
let uart_mux = static_init!(
UartMux<'static>,
UartMux::new(&nrf51::uart::UART0, &mut capsules::virtual_uart::RX_BUF)
);
hil::uart::UART::set_client(&nrf51::uart::UART0, uart_mux);

// Create a UartDevice for the console.
let console_uart = static_init!(UartDevice, UartDevice::new(uart_mux, true));
console_uart.setup();

let console = static_init!(
capsules::console::Console<nrf51::uart::UART>,
capsules::console::Console<UartDevice>,
capsules::console::Console::new(
&nrf51::uart::UART0,
console_uart,
115200,
&mut capsules::console::WRITE_BUF,
&mut capsules::console::READ_BUF,
kernel::Grant::create()
)
);
UART::set_client(&nrf51::uart::UART0, console);
UART::set_client(console_uart, console);
console.initialize();

// Attach the kernel debug interface to this console
let kc = static_init!(capsules::console::App, capsules::console::App::default());
kernel::debug::assign_console_driver(Some(console), kc);
// Create virtual device for kernel debug.
let debugger_uart = static_init!(UartDevice, UartDevice::new(uart_mux, false));
debugger_uart.setup();
let debugger = static_init!(
kernel::debug::DebugWriter,
kernel::debug::DebugWriter::new(
debugger_uart,
&mut kernel::debug::OUTPUT_BUF,
&mut kernel::debug::INTERNAL_BUF,
)
);
hil::uart::UART::set_client(debugger_uart, debugger);

let debug_wrapper = static_init!(
kernel::debug::DebugWriterWrapper,
kernel::debug::DebugWriterWrapper::new(debugger)
);
kernel::debug::set_debug_writer_wrapper(debug_wrapper);

let rtc = &nrf5x::rtc::RTC;
rtc.start();
Expand Down

0 comments on commit 8ed57a8

Please sign in to comment.