add amp_en control
This commit is contained in:
parent
1c2823eb1b
commit
8ea4b4401e
2 changed files with 33 additions and 2 deletions
|
|
@ -44,6 +44,27 @@ use crate::app::sequencer::{DynamicSequence, SequenceEntry};
|
|||
|
||||
static LED0_SEQ: [u8; 8] = [0u8, 25u8, 50u8, 75u8, 100u8, 75u8, 50u8, 25u8];
|
||||
|
||||
pub struct Amplifier {
|
||||
amp_en: Output<'static>,
|
||||
}
|
||||
|
||||
impl Amplifier {
|
||||
pub fn new(amp_en: Output<'static>) -> Self {
|
||||
let mut amp = Self { amp_en };
|
||||
amp.disable();
|
||||
amp
|
||||
}
|
||||
pub fn enable(&mut self) {
|
||||
self.amp_en.set_low();
|
||||
}
|
||||
pub fn disable(&mut self) {
|
||||
self.amp_en.set_high();
|
||||
}
|
||||
pub fn enabled(&self) -> bool {
|
||||
!self.amp_en.is_set_high()
|
||||
}
|
||||
}
|
||||
|
||||
use hal::adc::Adc;
|
||||
use hal::peripherals::{ADC1, PD4};
|
||||
|
||||
|
|
@ -271,7 +292,7 @@ fn app_main(mut p: hal::Peripherals) -> ! {
|
|||
let extra_io_2 = p.PD3;
|
||||
|
||||
let mut amp_en_output = Output::new(amp_en, Level::Low, Default::default());
|
||||
amp_en_output.set_low();
|
||||
let amp = Amplifier::new(amp_en_output);
|
||||
|
||||
// set up interrupts
|
||||
unsafe { system::init_gpio_irq(sense_coin_pin.pin(), sense_coin_pin.port(), true, false) };
|
||||
|
|
@ -335,7 +356,11 @@ fn app_main(mut p: hal::Peripherals) -> ! {
|
|||
audio: &SEQUENCE_LIST,
|
||||
};
|
||||
|
||||
let app_interfaces = Interfaces { pwm_core, adc_core };
|
||||
let app_interfaces = Interfaces {
|
||||
pwm_core,
|
||||
adc_core,
|
||||
amp,
|
||||
};
|
||||
|
||||
let mut app = App::new(app_config, app_services, app_sequences, app_interfaces);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue