|
1 |
| -use atsamd_hal::adc::Adc; |
| 1 | +use atsamd_hal::adc::AdcBuilder; |
| 2 | +use atsamd_hal::adc::{Accumulation, Adc, Prescaler, Resolution}; |
2 | 3 | use atsamd_hal::clock::GenericClockController;
|
3 | 4 | use atsamd_hal::pac::gclk::pchctrl::Genselect::Gclk11;
|
4 | 5 | use atsamd_hal::pac::{Adc1, Mclk};
|
@@ -56,18 +57,28 @@ pub struct LightSensor {
|
56 | 57 | pub pd1: LightSensorAdcReset,
|
57 | 58 | }
|
58 | 59 |
|
59 |
| -// impl LightSensor { |
60 |
| -// /// Initialize Pd1 as an ADC input, and return a Tuple containing the ADC |
61 |
| -// /// peripheral and the configured pin. |
62 |
| -// pub fn init( |
63 |
| -// self, |
64 |
| -// adc: Adc1, |
65 |
| -// clocks: &mut GenericClockController, |
66 |
| -// mclk: &mut Mclk, |
67 |
| -// ) -> (Adc<Adc1>, LightSensorAdc) { |
68 |
| -// todo!() |
69 |
| -// // let adc1 = Adc::adc1(adc, mclk, clocks, Gclk11); |
70 |
| -// |
71 |
| -// // (adc1, self.pd1.into()) |
72 |
| -// } |
73 |
| -// } |
| 60 | +impl LightSensor { |
| 61 | + /// Initialize Pd1 as an ADC input, and return a Tuple containing the ADC |
| 62 | + /// peripheral and the configured pin. |
| 63 | + pub fn init( |
| 64 | + self, |
| 65 | + adc: Adc1, |
| 66 | + clocks: &mut GenericClockController, |
| 67 | + mclk: &mut Mclk, |
| 68 | + ) -> (Adc<atsamd_hal::adc::Adc1>, LightSensorAdc) { |
| 69 | + |
| 70 | + todo!() |
| 71 | + // let adc1 = Adc::adc1(adc, mclk, clocks, Gclk11); |
| 72 | + |
| 73 | + // let mut adc = AdcBuilder::new(Accumulation::single(atsamd_hal::adc::AdcResolution::_12)) |
| 74 | + // .with_clock_cycles_per_sample(5) |
| 75 | + // // Overruns if clock divider < 32 in debug mode |
| 76 | + // .with_clock_divider(Prescaler::Div32) |
| 77 | + // .with_vref(atsamd_hal::adc::Reference::Arefa) |
| 78 | + // .enable(adc, apb_adc0, &pclk_adc0) |
| 79 | + // .unwrap(); |
| 80 | + // let mut adc_pin = pins.a0.into_alternate(); |
| 81 | + |
| 82 | + // (adc1, self.pd1.into()) |
| 83 | + } |
| 84 | +} |
0 commit comments