#adc #driver #embedded-hal-async #precision #gain #channel #24-bit

cs1237

An embedded_hal_async driver for the CS1237 precision 24-bit ADC

7 releases

0.3.1 Dec 8, 2024
0.3.0 Dec 8, 2024
0.2.2 Dec 4, 2024
0.2.0 Nov 30, 2024
0.1.1 Nov 30, 2024

#327 in Hardware support

Download history 169/week @ 2024-11-25 244/week @ 2024-12-02 108/week @ 2024-12-09

521 downloads per month

MPL-2.0 license

14KB
256 lines

CHIPSEA CS1237 ADC Driver

An embedded_hal_async driver for the CS1237 precision 24-bit ADC.


lib.rs:

CHIPSEA CS1237 ADC Driver

An embedded_hal_async driver for the CS1237 ADC.

Example Usage

use embassy_time::Delay;
use cs1237::{Cs1237, Gain, SamplesPerSecond, Channel, DEFAULT_BUS_FREQUENCY_HZ};
use cs1237::stm32::MetaPin;
use embassy_stm32::{gpio::{Output, Level, Speed}, Peripherals, peripherals};

async fn read_adc_value(p: Peripherals) {
  let clk_pin = Output::new(p.PA0, Level::Low, Speed::VeryHigh);
  let data_pin = MetaPin::new(p.PA1, p.EXTI1);

  let mut adc: Cs1237<Output<'static, peripherals::PA0>, MetaPin<'static, peripherals::PA1>, Delay, DEFAULT_BUS_FREQUENCY_HZ> = Cs1237::try_new(
    clk_pin,
    data_pin,
    Delay,
    Gain::G1,
    SamplesPerSecond::SPS10,
    Channel::Temperature
  ).await.unwrap();

  let _value = adc.read().await.unwrap();
}

License

This crate is licensed under the Mozilla Public License 2.0 (MPL-2.0). See the LICENSE file for more details.

Dependencies

~1–27MB
~879K SLoC