Expose a lot of NeopixelLights innards (and add the red led to that) to facilitate debugging
This commit is contained in:
parent
724a621bc1
commit
b67339abe0
1 changed files with 8 additions and 6 deletions
|
@ -12,7 +12,7 @@ use atsamd21g18a::{
|
||||||
Peripherals
|
Peripherals
|
||||||
};
|
};
|
||||||
use core::u8;
|
use core::u8;
|
||||||
use embedded_hal::digital::v2::OutputPin;
|
pub use embedded_hal::digital::v2::OutputPin;
|
||||||
use hal::{
|
use hal::{
|
||||||
clock::GenericClockController,
|
clock::GenericClockController,
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,7 @@ use lights::{
|
||||||
Lights
|
Lights
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn boot() -> NeopixelLights<impl OutputPin, impl OutputPin> {
|
pub fn boot() -> NeopixelLights<impl OutputPin<Error = ()>, impl OutputPin<Error = ()>, impl OutputPin<Error = ()>> {
|
||||||
let mut peripherals = Peripherals::take().unwrap();
|
let mut peripherals = Peripherals::take().unwrap();
|
||||||
let _clock = GenericClockController::with_internal_32kosc(
|
let _clock = GenericClockController::with_internal_32kosc(
|
||||||
peripherals.GCLK,
|
peripherals.GCLK,
|
||||||
|
@ -35,6 +35,7 @@ pub fn boot() -> NeopixelLights<impl OutputPin, impl OutputPin> {
|
||||||
NeopixelLights {
|
NeopixelLights {
|
||||||
out: pins.d7.into_push_pull_output(&mut pins.port),
|
out: pins.d7.into_push_pull_output(&mut pins.port),
|
||||||
high_out: pins.d5.into_push_pull_output(&mut pins.port),
|
high_out: pins.d5.into_push_pull_output(&mut pins.port),
|
||||||
|
red_led: pins.d13.into_open_drain_output(&mut pins.port),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,9 +47,10 @@ const ZERO_LOW_CYCLES: u32 = 29; // about 580ns
|
||||||
const ONE_LOW_CYCLES: u32 = 11; // about 220ns
|
const ONE_LOW_CYCLES: u32 = 11; // about 220ns
|
||||||
const LATCH_CYCLES: u32 = 15000; // about 300us
|
const LATCH_CYCLES: u32 = 15000; // about 300us
|
||||||
|
|
||||||
pub struct NeopixelLights<T: OutputPin, U: OutputPin> {
|
pub struct NeopixelLights<T: OutputPin, U: OutputPin, V: OutputPin> {
|
||||||
out: T,
|
pub out: T,
|
||||||
high_out: U
|
pub high_out: U,
|
||||||
|
pub red_led: V
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: OutputPin, U: OutputPin> NeopixelLights<T, U> {
|
impl<T: OutputPin, U: OutputPin> NeopixelLights<T, U> {
|
||||||
|
@ -63,7 +65,7 @@ impl<T: OutputPin, U: OutputPin> NeopixelLights<T, U> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn byte(&mut self, byte: u8) {
|
pub fn byte(&mut self, byte: u8) {
|
||||||
self.write(byte & 0x80 != 0);
|
self.write(byte & 0x80 != 0);
|
||||||
self.write(byte & 0x40 != 0);
|
self.write(byte & 0x40 != 0);
|
||||||
self.write(byte & 0x20 != 0);
|
self.write(byte & 0x20 != 0);
|
||||||
|
|
Loading…
Reference in a new issue