-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename nrf52840dk_2 to thread tutorial configuration board
- Loading branch information
1 parent
8589674
commit 2336b57
Showing
12 changed files
with
208 additions
and
148 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
18 changes: 18 additions & 0 deletions
18
boards/configurations/nrf52840dk/nrf52840dk-thread-tutorial/Cargo.toml
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,18 @@ | ||
# Licensed under the Apache License, Version 2.0 or the MIT License. | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
# Copyright Tock Contributors 2022. | ||
|
||
[package] | ||
name = "nrf52840dk-thread-tutorial" | ||
version.workspace = true | ||
authors.workspace = true | ||
build = "../../../build.rs" | ||
edition.workspace = true | ||
|
||
[dependencies] | ||
kernel = { path = "../../../../kernel" } | ||
nrf52840 = { path = "../../../../chips/nrf52840" } | ||
nrf52840dk = { path = "../../../nordic/nrf52840dk" } | ||
capsules-core = { path = "../../../../capsules/core" } | ||
capsules-extra = { path = "../../../../capsules/extra" } | ||
components = { path = "../../../components" } |
9 changes: 9 additions & 0 deletions
9
boards/configurations/nrf52840dk/nrf52840dk-thread-tutorial/Makefile
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,9 @@ | ||
# Licensed under the Apache License, Version 2.0 or the MIT License. | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
# Copyright Tock Contributors 2022. | ||
|
||
TARGET=thumbv7em-none-eabi | ||
PLATFORM=nrf52840dk-thread-tutorial | ||
|
||
include ../../../Makefile.common | ||
include ../nrf52840dk.mk |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
166 changes: 166 additions & 0 deletions
166
boards/configurations/nrf52840dk/nrf52840dk-thread-tutorial/src/main.rs
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,166 @@ | ||
// Licensed under the Apache License, Version 2.0 or the MIT License. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// Copyright Tock Contributors 2022. | ||
|
||
//! Tock kernel for the Nordic Semiconductor nRF52840 development kit (DK). | ||
#![no_std] | ||
// Disable this attribute when documenting, as a workaround for | ||
// https://github.com/rust-lang/rust/issues/62184. | ||
#![cfg_attr(not(doc), no_main)] | ||
#![deny(missing_docs)] | ||
|
||
use kernel::platform::{SyscallDriverLookup, KernelResources}; | ||
use kernel::{capabilities, create_capability}; | ||
use kernel::component::Component; | ||
use nrf52840::gpio::Pin; | ||
use nrf52840dk_lib; | ||
|
||
fn crc(s: &'static str) -> u32 { | ||
kernel::utilities::helpers::crc32_posix(s.as_bytes()) | ||
} | ||
|
||
type Screen = components::ssd1306::Ssd1306ComponentType<nrf52840::i2c::TWI<'static>>; | ||
// type ScreenDriver = components::screen::ScreenSharedComponentType<Screen>; | ||
type ScreenDriver = components::screen::ScreenComponentType; | ||
|
||
struct Platform { | ||
base: nrf52840dk_lib::Platform, | ||
screen: &'static ScreenDriver, | ||
} | ||
|
||
impl SyscallDriverLookup for Platform { | ||
fn with_driver<F, R>(&self, driver_num: usize, f: F) -> R | ||
where | ||
F: FnOnce(Option<&dyn kernel::syscall::SyscallDriver>) -> R, | ||
{ | ||
match driver_num { | ||
capsules_extra::screen::DRIVER_NUM => f(Some(self.screen)), | ||
_ => self.base.with_driver(driver_num, f), | ||
} | ||
} | ||
} | ||
|
||
type Chip = nrf52840dk_lib::Chip; | ||
|
||
impl KernelResources<Chip> | ||
for Platform | ||
{ | ||
type SyscallDriverLookup = Self; | ||
type SyscallFilter = <nrf52840dk_lib::Platform as KernelResources<Chip>>::SyscallFilter; | ||
type ProcessFault = <nrf52840dk_lib::Platform as KernelResources<Chip>>::ProcessFault; | ||
type Scheduler = <nrf52840dk_lib::Platform as KernelResources<Chip>>::Scheduler; | ||
type SchedulerTimer = <nrf52840dk_lib::Platform as KernelResources<Chip>>::SchedulerTimer; | ||
type WatchDog = <nrf52840dk_lib::Platform as KernelResources<Chip>>::WatchDog; | ||
type ContextSwitchCallback = <nrf52840dk_lib::Platform as KernelResources<Chip>>::ContextSwitchCallback; | ||
|
||
fn syscall_driver_lookup(&self) -> &Self::SyscallDriverLookup { | ||
self | ||
} | ||
fn syscall_filter(&self) -> &Self::SyscallFilter { | ||
self.base.syscall_filter() | ||
} | ||
fn process_fault(&self) -> &Self::ProcessFault { | ||
self.base.process_fault() | ||
} | ||
fn scheduler(&self) -> &Self::Scheduler { | ||
self.base.scheduler() | ||
} | ||
fn scheduler_timer(&self) -> &Self::SchedulerTimer { | ||
self.base.scheduler_timer() | ||
} | ||
fn watchdog(&self) -> &Self::WatchDog { | ||
self.base.watchdog() | ||
} | ||
fn context_switch_callback(&self) -> &Self::ContextSwitchCallback { | ||
self.base.context_switch_callback() | ||
} | ||
} | ||
|
||
|
||
/// Main function called after RAM initialized. | ||
#[no_mangle] | ||
pub unsafe fn main() { | ||
let main_loop_capability = create_capability!(capabilities::MainLoopCapability); | ||
|
||
// Create the base board: | ||
let (board_kernel, base_platform, chip, base_peripherals) = nrf52840dk_lib::start(); | ||
|
||
//-------------------------------------------------------------------------- | ||
// SCREEN | ||
//-------------------------------------------------------------------------- | ||
|
||
const SCREEN_I2C_SDA_PIN: Pin = Pin::P1_10; | ||
const SCREEN_I2C_SCL_PIN: Pin = Pin::P1_11; | ||
|
||
let i2c_bus = components::i2c::I2CMuxComponent::new(&base_peripherals.twi0, None) | ||
.finalize(components::i2c_mux_component_static!(nrf52840::i2c::TWI)); | ||
base_peripherals.twi0.configure( | ||
nrf52840::pinmux::Pinmux::new(SCREEN_I2C_SCL_PIN as u32), | ||
nrf52840::pinmux::Pinmux::new(SCREEN_I2C_SDA_PIN as u32), | ||
); | ||
base_peripherals.twi0.set_speed(nrf52840::i2c::Speed::K400); | ||
|
||
// I2C address is b011110X, and on this board D/C̅ is GND. | ||
let ssd1306_i2c = components::i2c::I2CComponent::new(i2c_bus, 0x3c) | ||
.finalize(components::i2c_component_static!(nrf52840::i2c::TWI)); | ||
|
||
// Create the ssd1306 object for the actual screen driver. | ||
let ssd1306 = components::ssd1306::Ssd1306Component::new(ssd1306_i2c, true) | ||
.finalize(components::ssd1306_component_static!(nrf52840::i2c::TWI)); | ||
|
||
// // Assign screen regions to specific apps. | ||
// let apps_regions = static_init!( | ||
// [capsules_extra::screen_shared::AppScreenRegion; 3], | ||
// [ | ||
// capsules_extra::screen_shared::AppScreenRegion::new( | ||
// kernel::process::ShortID::Fixed(core::num::NonZeroU32::new(crc("circle")).unwrap()), | ||
// 0, // x | ||
// 0, // y | ||
// 8 * 8, // width | ||
// 8 * 8 // height | ||
// ), | ||
// capsules_extra::screen_shared::AppScreenRegion::new( | ||
// kernel::process::ShortID::Fixed(core::num::NonZeroU32::new(crc("count")).unwrap()), | ||
// 8 * 8, // x | ||
// 0, // y | ||
// 8 * 8, // width | ||
// 4 * 8 // height | ||
// ), | ||
// capsules_extra::screen_shared::AppScreenRegion::new( | ||
// kernel::process::ShortID::Fixed( | ||
// core::num::NonZeroU32::new(crc("tock-scroll")).unwrap() | ||
// ), | ||
// 8 * 8, // x | ||
// 4 * 8, // y | ||
// 8 * 8, // width | ||
// 4 * 8 // height | ||
// ) | ||
// ] | ||
// ); | ||
|
||
// let screen = components::screen::ScreenSharedComponent::new( | ||
// board_kernel, | ||
// capsules_extra::screen::DRIVER_NUM, | ||
// ssd1306, | ||
// apps_regions, | ||
// ) | ||
// .finalize(components::screen_shared_component_static!(1032, Screen)); | ||
|
||
let screen = components::screen::ScreenComponent::new( | ||
board_kernel, | ||
capsules_extra::screen::DRIVER_NUM, | ||
ssd1306, | ||
None, | ||
) | ||
.finalize(components::screen_component_static!(1032)); | ||
|
||
let platform = Platform { | ||
base: base_platform, | ||
screen, | ||
}; | ||
|
||
ssd1306.init_screen(); | ||
|
||
board_kernel.kernel_loop(&platform, chip, Some(&platform.base.ipc), &main_loop_capability); | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.