Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove wildcard imports #1077

Merged
merged 2 commits into from Jul 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions arch/cortex-m0/src/lib.rs
Expand Up @@ -6,9 +6,7 @@ extern crate kernel;

// Re-export the base generic cortex-m functions here as they are
// valid on cortex-m0.
pub mod support {
pub use cortexm::support::*;
}
pub use cortexm::support;

pub use cortexm::nvic;

Expand Down
4 changes: 1 addition & 3 deletions arch/cortex-m3/src/lib.rs
Expand Up @@ -8,9 +8,7 @@ extern crate cortexm;

// Re-export the base generic cortex-m functions here as they are
// valid on cortex-m3.
pub mod support {
pub use cortexm::support::*;
}
pub use cortexm::support;

pub use cortexm::nvic;
pub use cortexm::scb;
Expand Down
4 changes: 1 addition & 3 deletions arch/cortex-m4/src/lib.rs
Expand Up @@ -14,9 +14,7 @@ pub mod mpu;

// Re-export the base generic cortex-m functions here as they are
// valid on cortex-m4.
pub mod support {
pub use cortexm::support::*;
}
pub use cortexm::support;

pub use cortexm::nvic;
pub use cortexm::scb;
Expand Down
2 changes: 1 addition & 1 deletion boards/ek-tm4c1294xl/src/io.rs
@@ -1,4 +1,4 @@
use core::fmt::*;
use core::fmt::Write;
use core::panic::PanicInfo;
use core::str;
use cortexm4;
Expand Down
2 changes: 1 addition & 1 deletion boards/hail/src/io.rs
@@ -1,4 +1,4 @@
use core::fmt::*;
use core::fmt::Write;
use core::panic::PanicInfo;
use core::str;
use cortexm4;
Expand Down
26 changes: 11 additions & 15 deletions boards/imix/src/i2c_dummy.rs
Expand Up @@ -76,28 +76,26 @@ static mut ACCEL_CLIENT: AccelClient = AccelClient {

impl hil::i2c::I2CHwMasterClient for AccelClient {
fn command_complete(&self, buffer: &'static mut [u8], error: hil::i2c::Error) {
use self::AccelClientState::*;

let dev = unsafe { &mut i2c::I2C2 };

match self.state.get() {
ReadingWhoami => {
AccelClientState::ReadingWhoami => {
debug!("WHOAMI Register 0x{:x} ({})", buffer[0], error);
debug!("Activating Sensor...");
buffer[0] = 0x2A as u8; // CTRL_REG1
buffer[1] = 1; // Bit 1 sets `active`
dev.write(0x1e, buffer, 2);
self.state.set(Activating);
self.state.set(AccelClientState::Activating);
}
Activating => {
AccelClientState::Activating => {
debug!("Sensor Activated ({})", error);
buffer[0] = 0x01 as u8; // X-MSB register
// Reading 6 bytes will increment the register pointer through
// X-MSB, X-LSB, Y-MSB, Y-LSB, Z-MSB, Z-LSB
dev.write_read(0x1e, buffer, 1, 6);
self.state.set(ReadingAccelData);
self.state.set(AccelClientState::ReadingAccelData);
}
ReadingAccelData => {
AccelClientState::ReadingAccelData => {
let x = (((buffer[0] as u16) << 8) | buffer[1] as u16) as usize;
let y = (((buffer[2] as u16) << 8) | buffer[3] as u16) as usize;
let z = (((buffer[4] as u16) << 8) | buffer[5] as u16) as usize;
Expand All @@ -118,9 +116,9 @@ impl hil::i2c::I2CHwMasterClient for AccelClient {
// Reading 6 bytes will increment the register pointer through
// X-MSB, X-LSB, Y-MSB, Y-LSB, Z-MSB, Z-LSB
dev.write_read(0x1e, buffer, 1, 6);
self.state.set(ReadingAccelData);
self.state.set(AccelClientState::ReadingAccelData);
}
Deactivating => {
AccelClientState::Deactivating => {
debug!("Sensor deactivated ({})", error);
debug!("Reading Accel's WHOAMI...");
buffer[0] = 0x0D as u8; // 0x0D == WHOAMI register
Expand Down Expand Up @@ -167,24 +165,22 @@ static mut LI_CLIENT: LiClient = LiClient {

impl hil::i2c::I2CHwMasterClient for LiClient {
fn command_complete(&self, buffer: &'static mut [u8], error: hil::i2c::Error) {
use self::LiClientState::*;

let dev = unsafe { &mut i2c::I2C2 };

match self.state.get() {
Enabling => {
LiClientState::Enabling => {
debug!("Reading Lumminance Registers ({})", error);
buffer[0] = 0x02 as u8;
buffer[0] = 0;
dev.write_read(0x44, buffer, 1, 2);
self.state.set(ReadingLI);
self.state.set(LiClientState::ReadingLI);
}
ReadingLI => {
LiClientState::ReadingLI => {
let intensity = ((buffer[1] as usize) << 8) | buffer[0] as usize;
debug!("Light Intensity: {}% ({})", (intensity * 100) >> 16, error);
buffer[0] = 0x02 as u8;
dev.write_read(0x44, buffer, 1, 2);
self.state.set(ReadingLI);
self.state.set(LiClientState::ReadingLI);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion boards/imix/src/io.rs
@@ -1,4 +1,4 @@
use core::fmt::*;
use core::fmt::Write;
use core::panic::PanicInfo;
use cortexm4;
use kernel::debug;
Expand Down
2 changes: 1 addition & 1 deletion capsules/examples/traitobj_list.rs
Expand Up @@ -16,7 +16,7 @@
//! manager.report();
//! ```

use kernel::common::list::*;
use kernel::common::list::{List, ListLink, ListNode};

pub trait Funky<'a> {
fn name(&self) -> &'static str;
Expand Down
4 changes: 3 additions & 1 deletion capsules/src/ieee802154/framer.rs
Expand Up @@ -76,7 +76,9 @@ use kernel::common::cells::MapCell;
use kernel::hil::radio;
use kernel::hil::symmetric_encryption::{AES128CCM, CCMClient};
use kernel::ReturnCode;
use net::ieee802154::*;
use net::ieee802154::{
FrameType, FrameVersion, Header, KeyId, MacAddress, PanID, Security, SecurityLevel,
};
use net::stream::SResult;
use net::stream::{encode_bytes, encode_u32, encode_u8};

Expand Down
3 changes: 2 additions & 1 deletion capsules/src/ieee802154/mod.rs
Expand Up @@ -6,4 +6,5 @@ pub mod xmac;

mod driver;

pub use self::driver::*;
pub use self::driver::RadioDriver;
pub use self::driver::DRIVER_NUM;
2 changes: 1 addition & 1 deletion capsules/src/ieee802154/virtual_mac.rs
Expand Up @@ -31,7 +31,7 @@ use ieee802154::{device, framer};
use kernel::common::cells::MapCell;
use kernel::common::{List, ListLink, ListNode};
use kernel::ReturnCode;
use net::ieee802154::*;
use net::ieee802154::{Header, KeyId, MacAddress, PanID, SecurityLevel};

/// IEE 802.15.4 MAC device muxer that keeps a list of MAC users and sequences
/// any pending transmission requests. Any received frames from the underlying
Expand Down
2 changes: 1 addition & 1 deletion capsules/src/ieee802154/xmac.rs
Expand Up @@ -83,7 +83,7 @@ use kernel::hil::radio;
use kernel::hil::rng::{self, RNG};
use kernel::hil::time::{self, Alarm, Frequency, Time};
use kernel::ReturnCode;
use net::ieee802154::*;
use net::ieee802154::{FrameType, FrameVersion, Header, MacAddress, PanID};

// Time the radio will remain awake listening for packets before sleeping.
// Observing the RF233, receive callbacks for preambles are generated only after
Expand Down
24 changes: 10 additions & 14 deletions capsules/src/net/ieee802154.rs
Expand Up @@ -369,18 +369,17 @@ impl HeaderIE<'a> {

pub fn encode(&self, buf: &mut [u8]) -> SResult {
// Append the content field of the IE first
use self::HeaderIE::*;
let mut off = 2;
let element_id: u8 = match *self {
Undissected {
HeaderIE::Undissected {
element_id,
content,
} => {
off = enc_consume!(buf, off; encode_bytes, content);
element_id
}
Termination1 => 0x7e,
Termination2 => 0x7f,
HeaderIE::Termination1 => 0x7e,
HeaderIE::Termination2 => 0x7f,
};

// Write the two octets that begin each header IE
Expand All @@ -405,11 +404,10 @@ impl HeaderIE<'a> {
stream_len_cond!(buf, off + content_len);
let content = &buf[off..off + content_len];

use self::HeaderIE::*;
let ie = match element_id {
0x7e => Termination1,
0x7f => Termination2,
element_id => Undissected {
0x7e => HeaderIE::Termination1,
0x7f => HeaderIE::Termination2,
element_id => HeaderIE::Undissected {
element_id: element_id,
content: content,
},
Expand Down Expand Up @@ -441,14 +439,13 @@ impl PayloadIE<'a> {

pub fn encode(&self, buf: &mut [u8]) -> SResult {
// Append the content field of the IE first
use self::PayloadIE::*;
let mut off = 2;
let group_id: u8 = match *self {
Undissected { group_id, content } => {
PayloadIE::Undissected { group_id, content } => {
off = enc_consume!(buf, off; encode_bytes, content);
group_id
}
Termination => 0xf,
PayloadIE::Termination => 0xf,
};

// Write the two octets that begin each payload IE
Expand All @@ -474,10 +471,9 @@ impl PayloadIE<'a> {
stream_len_cond!(buf, off + content_len);
let content = &buf[off..off + content_len];

use self::PayloadIE::*;
let ie = match element_id {
0xf => Termination,
group_id => Undissected {
0xf => PayloadIE::Termination,
group_id => PayloadIE::Undissected {
group_id: group_id,
content: content,
},
Expand Down
35 changes: 28 additions & 7 deletions capsules/src/rf233.rs
Expand Up @@ -23,7 +23,25 @@ use kernel::hil::gpio;
use kernel::hil::radio;
use kernel::hil::spi;
use kernel::ReturnCode;
use rf233_const::*;
use rf233_const::{ExternalState, InteruptFlags, RF233BusCommand, RF233Register, RF233TrxCmd};
// n.b. This is a fairly "C"-like interface presently. Ideally it should move
// over to the Tock register interface eventually, but this code does work as
// written. Do not follow this as an example when implementing new code.
use rf233_const::CSMA_SEED_1;
use rf233_const::SHORT_ADDR_0;
use rf233_const::SHORT_ADDR_1;
use rf233_const::TRX_CTRL_1;
use rf233_const::TRX_CTRL_2;
use rf233_const::XAH_CTRL_0;
use rf233_const::XAH_CTRL_1;
use rf233_const::IRQ_MASK;
use rf233_const::PHY_CC_CCA_MODE_CS_OR_ED;
use rf233_const::PHY_CHANNEL;
use rf233_const::PHY_RSSI_RX_CRC_VALID;
use rf233_const::PHY_TX_PWR;
use rf233_const::TRX_RPC;
use rf233_const::TRX_TRAC_CHANNEL_ACCESS_FAILURE;
use rf233_const::TRX_TRAC_MASK;

const INTERRUPT_ID: usize = 0x2154;

Expand Down Expand Up @@ -263,8 +281,9 @@ fn power_to_setting(power: i8) -> u8 {
}
}

fn interrupt_included(mask: u8, interrupt: u8) -> bool {
(mask & interrupt) == interrupt
fn interrupt_included(mask: u8, interrupt: InteruptFlags) -> bool {
let int = interrupt as u8;
(mask & int) == int
}

impl<S: spi::SpiMasterDevice> spi::SpiMasterClient for RF233<'a, S> {
Expand Down Expand Up @@ -329,15 +348,15 @@ impl<S: spi::SpiMasterDevice> spi::SpiMasterClient for RF233<'a, S> {
// If we're going to sleep, ignore the interrupt and continue
if state != InternalState::SLEEP_TRX_OFF && state != InternalState::SLEEP {
if state == InternalState::ON_PLL_WAITING {
if interrupt_included(interrupt, IRQ_0_PLL_LOCK) {
if interrupt_included(interrupt, InteruptFlags::IRQ_0_PLL_LOCK) {
self.state.set(InternalState::ON_PLL_SET);
}
} else if state == InternalState::TX_TRANSMITTING
&& interrupt_included(interrupt, IRQ_3_TRX_END)
&& interrupt_included(interrupt, InteruptFlags::IRQ_3_TRX_END)
{
self.state.set(InternalState::TX_DONE);
}
if interrupt_included(interrupt, IRQ_2_RX_START) {
if interrupt_included(interrupt, InteruptFlags::IRQ_2_RX_START) {
// Start of frame
self.receiving.set(true);
self.state.set(InternalState::RX);
Expand All @@ -349,7 +368,9 @@ impl<S: spi::SpiMasterDevice> spi::SpiMasterClient for RF233<'a, S> {
// 1. we have a receive buffer: copy it out
// 2. no receive buffer, but transmission pending: send
// 3. no receive buffer, no transmission: return to waiting
if (interrupt_included(interrupt, IRQ_3_TRX_END) && self.receiving.get()) {
if (interrupt_included(interrupt, InteruptFlags::IRQ_3_TRX_END)
&& self.receiving.get())
{
self.receiving.set(false);
if self.rx_buf.is_some() {
self.state.set(InternalState::RX_START_READING);
Expand Down
19 changes: 11 additions & 8 deletions capsules/src/rf233_const.rs
Expand Up @@ -112,14 +112,17 @@ pub const SHORT_ADDR_0: u8 = 0x11;
pub const SHORT_ADDR_1: u8 = 0x22;

// Interrupt flags.
pub const IRQ_7_BAT_LOW: u8 = 0x80;
pub const IRQ_6_TRX_UR: u8 = 0x40;
pub const IRQ_5_AMI: u8 = 0x20;
pub const IRQ_4_CCA_ED_DONE: u8 = 0x10;
pub const IRQ_3_TRX_END: u8 = 0x08;
pub const IRQ_2_RX_START: u8 = 0x04;
pub const IRQ_1_PLL_UNLOCK: u8 = 0x02;
pub const IRQ_0_PLL_LOCK: u8 = 0x01;
#[repr(u8)]
pub enum InteruptFlags {
IRQ_7_BAT_LOW = 0x80,
IRQ_6_TRX_UR = 0x40,
IRQ_5_AMI = 0x20,
IRQ_4_CCA_ED_DONE = 0x10,
IRQ_3_TRX_END = 0x08,
IRQ_2_RX_START = 0x04,
IRQ_1_PLL_UNLOCK = 0x02,
IRQ_0_PLL_LOCK = 0x01,
}

// The commands issued over SPI (first 2-3 bits).
#[derive(PartialEq, Copy, Clone, Debug)]
Expand Down