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

Nano33 apds9960 #2091

Merged
merged 25 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b951c12
Finish APDS9960 implementation
arjundeopujari Jul 3, 2020
57fcb07
nano33: add apds9960 to board file
bradjc Jul 6, 2020
5d7be2d
debugging, add id get
bradjc Jul 6, 2020
667a6da
Add persistence to apds-9960
arjundeopujari Jul 17, 2020
4f6d9b1
APDS-9960 Driver: Add proximity gain setter and remove endless interr…
arjundeopujari Jul 20, 2020
82a8fbe
Add take_measurement() to hil proximity interface
arjundeopujari Jul 28, 2020
aa0f213
Take out HIGH_THRESH and LOW_THRESH
arjundeopujari Aug 3, 2020
03c0d80
Implement proximity.rs
arjundeopujari Aug 4, 2020
c4e425a
Add callbacks to proximityGain() and interruptthresholds commands
arjundeopujari Aug 4, 2020
5355e4b
Change Driver::NUM::Proximity
arjundeopujari Aug 8, 2020
d44b634
Change user proximity interface
arjundeopujari Aug 15, 2020
8a5dd23
Clean up proximity.rs logic
arjundeopujari Aug 16, 2020
9b099d4
Nano33ble main.rs: Add init and code for the apds9960 proximity sensor
arjundeopujari Aug 18, 2020
52a1e37
Clean up code
arjundeopujari Aug 31, 2020
41e55d5
Fix apds9960.take_measurement()
arjundeopujari Aug 31, 2020
e64830e
Delete superfluous debug statements
arjundeopujari Aug 31, 2020
b05f71c
cargo fmt
arjundeopujari Aug 31, 2020
cc23a83
Address review feedback
arjundeopujari Sep 20, 2020
5d760b8
Address review comments (2/2) and cargo fmt
arjundeopujari Sep 21, 2020
b37445a
Address Review Comments: nano33ble
arjundeopujari Sep 24, 2020
5703fd2
Address merge issues
arjundeopujari Sep 25, 2020
79357c3
Merge branch 'master' into nano33-apds9960
arjundeopujari Sep 25, 2020
f11f18a
apds9960: Add lifetime specifiers to gpio
arjundeopujari Sep 25, 2020
e8a9584
Address ci-job-clippy error
arjundeopujari Sep 26, 2020
3975ede
Remove unused attribute
arjundeopujari Sep 26, 2020
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
63 changes: 63 additions & 0 deletions boards/nano33ble/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ use kernel::capabilities;
use kernel::common::dynamic_deferred_call::{DynamicDeferredCall, DynamicDeferredCallClientState};
use kernel::component::Component;
use kernel::hil::gpio::ActivationMode::ActiveLow;
use kernel::hil::gpio::Configure;
use kernel::hil::gpio::Interrupt;
use kernel::hil::gpio::Output;
use kernel::hil::i2c::I2CMaster;
use kernel::hil::usb::Client;
use kernel::mpu::MPU;
use kernel::Chip;
Expand Down Expand Up @@ -40,6 +44,16 @@ const GPIO_D10: Pin = Pin::P1_02;
const _UART_TX_PIN: Pin = Pin::P1_03;
const _UART_RX_PIN: Pin = Pin::P1_10;

/// I2C pins for all of the sensors.
const I2C_SDA_PIN: Pin = Pin::P0_14;
const I2C_SCL_PIN: Pin = Pin::P0_15;

/// GPIO tied to the VCC of the I2C pullup resistors.
const I2C_PULLUP_PIN: Pin = Pin::P1_00;

/// Interrupt pin for the APDS9960 sensor.
const APDS9960_PIN: Pin = Pin::P0_19;

/// UART Writer for panic!()s.
pub mod io;

Expand Down Expand Up @@ -68,6 +82,7 @@ pub struct Platform {
// >,
// ieee802154_radio: &'static capsules::ieee802154::RadioDriver<'static>,
console: &'static capsules::console::Console<'static>,
proximity: &'static capsules::proximity::ProximitySensor<'static>,
gpio: &'static capsules::gpio::GPIO<'static, nrf52::gpio::GPIOPin>,
led: &'static capsules::led::LED<'static, nrf52::gpio::GPIOPin>,
rng: &'static capsules::rng::RngDriver<'static>,
Expand All @@ -85,6 +100,7 @@ impl kernel::Platform for Platform {
{
match driver_num {
capsules::console::DRIVER_NUM => f(Some(self.console)),
capsules::proximity::DRIVER_NUM => f(Some(self.proximity)),
capsules::gpio::DRIVER_NUM => f(Some(self.gpio)),
capsules::alarm::DRIVER_NUM => f(Some(self.alarm)),
capsules::led::DRIVER_NUM => f(Some(self.led)),
Expand Down Expand Up @@ -227,6 +243,50 @@ pub unsafe fn reset_handler() {

let rng = components::rng::RngComponent::new(board_kernel, &nrf52::trng::TRNG).finalize(());

//--------------------------------------------------------------------------
// SENSORS
//--------------------------------------------------------------------------

let sensors_i2c_bus = static_init!(
capsules::virtual_i2c::MuxI2C<'static>,
capsules::virtual_i2c::MuxI2C::new(&nrf52840::i2c::TWIM0, None, dynamic_deferred_caller)
);
nrf52840::i2c::TWIM0.configure(
nrf52840::pinmux::Pinmux::new(I2C_SCL_PIN as u32),
nrf52840::pinmux::Pinmux::new(I2C_SDA_PIN as u32),
);
nrf52840::i2c::TWIM0.set_master_client(sensors_i2c_bus);

&nrf52840::gpio::PORT[I2C_PULLUP_PIN].make_output();
&nrf52840::gpio::PORT[I2C_PULLUP_PIN].set();

let apds9960_i2c = static_init!(
capsules::virtual_i2c::I2CDevice,
capsules::virtual_i2c::I2CDevice::new(sensors_i2c_bus, 0x39 << 1)
);

let apds9960 = static_init!(
capsules::apds9960::APDS9960<'static>,
capsules::apds9960::APDS9960::new(
apds9960_i2c,
&nrf52840::gpio::PORT[APDS9960_PIN],
&mut capsules::apds9960::BUFFER
)
);
apds9960_i2c.set_client(apds9960);
nrf52840::gpio::PORT[APDS9960_PIN].set_client(apds9960);

let grant_cap = create_capability!(capabilities::MemoryAllocationCapability);

let proximity = static_init!(
capsules::proximity::ProximitySensor<'static>,
capsules::proximity::ProximitySensor::new(apds9960, board_kernel.create_grant(&grant_cap))
);

kernel::hil::sensors::ProximityDriver::set_client(apds9960, proximity);

// apds9960.take_measurement();

ppannuto marked this conversation as resolved.
Show resolved Hide resolved
//--------------------------------------------------------------------------
// WIRELESS
//--------------------------------------------------------------------------
Expand Down Expand Up @@ -254,6 +314,7 @@ pub unsafe fn reset_handler() {
// ble_radio: ble_radio,
// ieee802154_radio: ieee802154_radio,
console: console,
proximity: proximity,
led: led,
gpio: gpio,
rng: rng,
Expand All @@ -273,6 +334,8 @@ pub unsafe fn reset_handler() {

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

// apds9960.take_measurement();

ppannuto marked this conversation as resolved.
Show resolved Hide resolved
//--------------------------------------------------------------------------
// PROCESSES AND MAIN LOOP
//--------------------------------------------------------------------------
Expand Down