Skip to content

Commit

Permalink
Add remaining PGA modes
Browse files Browse the repository at this point in the history
  • Loading branch information
stabler committed Jan 4, 2024
1 parent ff07d75 commit 861a3e7
Show file tree
Hide file tree
Showing 3 changed files with 490 additions and 138 deletions.
8 changes: 4 additions & 4 deletions examples/opamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use stm32g4xx_hal::adc::AdcClaim;
use stm32g4xx_hal::adc::ClockSource;
use stm32g4xx_hal::opamp::{InternalOutput, NonInvertingGain, PgaModeInternal};
use stm32g4xx_hal::opamp::{Gain, InternalOutput};
use stm32g4xx_hal::prelude::*;
use stm32g4xx_hal::pwr::PwrExt;

Expand Down Expand Up @@ -50,15 +50,15 @@ fn main() -> ! {
// Configure opamp1 with pa1 as non-inverting input and set gain to x2
let _opamp1 = opamp1.pga(
pa1,
PgaModeInternal::gain(NonInvertingGain::Gain2),
pa2, // Route output to pin pa2
Gain::Gain2,
);

// Configure op with pa7 as non-inverting input and set gain to x4
let opamp2 = opamp2.pga(
pa7,
PgaModeInternal::gain(NonInvertingGain::Gain4),
InternalOutput, // Do not route output to any external pin, use internal AD instead
Gain::Gain4,
);

// Lock opamp2. After the opamp is locked its registers cannot be written
Expand All @@ -85,7 +85,7 @@ fn main() -> ! {

#[allow(unreachable_code)]
{
let (_opamp1, _mode, _pin) = _opamp1.disable();
let (_opamp1, _pin) = _opamp1.disable();

loop {
delay.delay_ms(100);
Expand Down
2 changes: 1 addition & 1 deletion src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ macro_rules! adc_opamp {
fn channel() -> u8 { $chan }
}

impl<A, B> Channel<stm32::$adc> for opamp::Pga<$opamp, A, B, InternalOutput> {
impl<A> Channel<stm32::$adc> for opamp::Pga<$opamp, A, InternalOutput> {
type ID = u8;
fn channel() -> u8 { $chan }
}
Expand Down
Loading

0 comments on commit 861a3e7

Please sign in to comment.