@@ -192,10 +192,16 @@ impl<'d, T: AnyInstance> Adc<'d, T> {
192192 #[ cfg( any( adc_v1, adc_c0, adc_l0, adc_v2, adc_g4, adc_v4, adc_u5, adc_wba) ) ]
193193 channel. setup ( ) ;
194194
195- #[ cfg( not ( adc_v4 ) ) ]
195+ #[ cfg( any ( adc_v2 , adc_v3 , adc_g0 , adc_h7rs , adc_u0 , adc_u5 , adc_wba , adc_c0 ) ) ]
196196 T :: enable ( ) ;
197197 T :: configure_sequence ( [ ( ( channel. channel ( ) , channel. is_differential ( ) ) , sample_time) ] . into_iter ( ) ) ;
198198
199+ // On chips with differential channels, enable after configure_sequence to allow setting differential channels
200+ //
201+ // TODO: If hardware allows, enable after configure_sequence on all chips
202+ #[ cfg( any( adc_g4, adc_h5) ) ]
203+ T :: enable ( ) ;
204+
199205 T :: convert ( )
200206 }
201207
@@ -229,10 +235,10 @@ impl<'d, T: AnyInstance> Adc<'d, T> {
229235 /// Note: This is not very efficient as the ADC needs to be reconfigured for each read. Use
230236 /// `into_ring_buffered`, `into_ring_buffered_and_injected`
231237 ///
232- /// In STM32C0, channels bigger than 14 cannot be read using sequencer, so you have to use
233- /// either blocking reads or use the mechanism to read in HW order (CHSELRMOD=0).
234- ///
235- /// In addtion, on STM320, this method will panic if the channels are not passed in order
238+ /// Note: Depending on hardware limitations, this method may require channels to be passed
239+ /// in order or require the sequence to have the same sample time for all channnels, depending
240+ /// on the number and properties of the channels in the sequence. This method will panic if
241+ /// the hardware cannot deliver the requested configuration.
236242 pub async fn read (
237243 & mut self ,
238244 rx_dma : embassy_hal_internal:: Peri < ' _ , impl RxDma < T > > ,
@@ -249,14 +255,20 @@ impl<'d, T: AnyInstance> Adc<'d, T> {
249255 "Asynchronous read sequence cannot be more than 16 in length"
250256 ) ;
251257
252- // Ensure no conversions are ongoing and ADC is enabled.
258+ // Ensure no conversions are ongoing
253259 T :: stop ( ) ;
260+ #[ cfg( any( adc_g0, adc_v3, adc_h7rs, adc_u0, adc_v4, adc_u5, adc_wba, adc_c0) ) ]
254261 T :: enable ( ) ;
255262
256263 T :: configure_sequence (
257264 sequence. map ( |( channel, sample_time) | ( ( channel. channel , channel. is_differential ) , sample_time) ) ,
258265 ) ;
259266
267+ // On chips with differential channels, enable after configure_sequence to allow setting differential channels
268+ //
269+ // TODO: If hardware allows, enable after configure_sequence on all chips
270+ #[ cfg( any( adc_g4, adc_h5) ) ]
271+ T :: enable ( ) ;
260272 T :: configure_dma ( ConversionMode :: Singular ) ;
261273
262274 let request = rx_dma. request ( ) ;
@@ -294,6 +306,11 @@ impl<'d, T: AnyInstance> Adc<'d, T> {
294306 ///
295307 /// # Returns
296308 /// A `RingBufferedAdc<'a, T>` instance configured for continuous DMA-based sampling.
309+ ///
310+ /// Note: Depending on hardware limitations, this method may require channels to be passed
311+ /// in order or require the sequence to have the same sample time for all channnels, depending
312+ /// on the number and properties of the channels in the sequence. This method will panic if
313+ /// the hardware cannot deliver the requested configuration.
297314 pub fn into_ring_buffered < ' a > (
298315 self ,
299316 dma : embassy_hal_internal:: Peri < ' a , impl RxDma < T > > ,
@@ -307,15 +324,20 @@ impl<'d, T: AnyInstance> Adc<'d, T> {
307324 sequence. len( ) <= 16 ,
308325 "Asynchronous read sequence cannot be more than 16 in length"
309326 ) ;
310- // reset conversions and enable the adc
327+ // Ensure no conversions are ongoing
311328 T :: stop ( ) ;
329+ #[ cfg( any( adc_g0, adc_v3, adc_h7rs, adc_u0, adc_v4, adc_u5, adc_wba, adc_c0) ) ]
312330 T :: enable ( ) ;
313331
314- //adc side setup
315332 T :: configure_sequence (
316333 sequence. map ( |( channel, sample_time) | ( ( channel. channel , channel. is_differential ) , sample_time) ) ,
317334 ) ;
318335
336+ // On chips with differential channels, enable after configure_sequence to allow setting differential channels
337+ //
338+ // TODO: If hardware allows, enable after configure_sequence on all chips
339+ #[ cfg( any( adc_g4, adc_h5) ) ]
340+ T :: enable ( ) ;
319341 T :: configure_dma ( ConversionMode :: Repeated ( mode) ) ;
320342
321343 core:: mem:: forget ( self ) ;
0 commit comments