@@ -63,17 +63,25 @@ macro_rules! timer0_8bit_impl {
6363 ) => {
6464 paste! {
6565 avr_hal_generic:: impl_simple_pwm! {
66- /// Use `$peripheral` for PWM (pins `$pin`,)
66+ # [ doc = concat! ( " Use `" , stringify! ( $peripheral) , " ` for PWM." ) ]
6767 ///
6868 /// # Example
69- /// ```
70- /// let mut timer0 = Timer0Pwm::new(dp.$peripheral, Prescaler::Prescale64);
69+ /// ```no_run
70+ #[ doc = concat!( "use attiny_hal::" , stringify!( $hal) , " as hal;" ) ]
71+ /// use hal::simple_pwm::{IntoPwmPin,Timer0Pwm,Prescaler};
7172 ///
72- /// let mut d0 = pins.d0.into_output().into_pwm(&mut timer0);
73- /// let mut d1 = pins.d1.into_output().into_pwm(&mut timer0);
73+ /// let dp = hal::Peripherals::take().unwrap();
74+ /// let pins = hal::pins!(dp);
75+ #[ doc = concat!( "let mut timer0 = " , stringify!( $timer) , "::new(dp." , stringify!( $peripheral) , ", Prescaler::Prescale64);" ) ]
7476 ///
75- /// d0.set_duty(128);
76- /// d0.enable();
77+ $(
78+ #[ doc = paste!{ concat!(
79+ "let mut " , stringify!( [ < $pin: lower >] ) , " = pins." , stringify!( [ < $pin: lower >] ) , ".into_output().into_pwm(&mut timer0);\n " ,
80+ stringify!( [ < $pin: lower >] ) , ".set_duty(128);\n " ,
81+ stringify!( [ < $pin: lower >] ) , ".enable();\n " ,
82+ "\n " ,
83+ ) } ]
84+ ) +
7785 /// ```
7886 pub struct $timer {
7987 timer: crate :: $hal:: pac:: $peripheral,
@@ -125,16 +133,25 @@ macro_rules! timer1_8bit_separate_prescale {
125133 ) => {
126134 paste! {
127135 avr_hal_generic:: impl_simple_pwm! {
128- /// Use `$peripheral` for PWM (pins `$pin`,)
136+ # [ doc = concat! ( " Use `" , stringify! ( $peripheral) , " ` for PWM." ) ]
129137 ///
130138 /// # Example
131- /// ```
132- /// let mut timer1 = Timer1Pwm::new(dp.TC1, Prescaler::Prescale64);
139+ /// ```no_run
140+ #[ doc = concat!( "use attiny_hal::" , stringify!( $hal) , " as hal;" ) ]
141+ /// use hal::simple_pwm::{IntoPwmPin,Timer1Pwm,Prescaler};
133142 ///
134- /// let mut d4 = pins.d4.into_output().into_pwm(&mut timer1);
143+ /// let dp = hal::Peripherals::take().unwrap();
144+ /// let pins = hal::pins!(dp);
145+ #[ doc = concat!( "let mut timer1 = " , stringify!( $timer) , "::new(dp." , stringify!( $peripheral) , ", Prescaler::Prescale64);" ) ]
135146 ///
136- /// d4.set_duty(128);
137- /// d4.enable();
147+ $(
148+ #[ doc = paste!{ concat!(
149+ "let mut " , stringify!( [ < $pin: lower >] ) , " = pins." , stringify!( [ < $pin: lower >] ) , ".into_output().into_pwm(&mut timer1);\n " ,
150+ stringify!( [ < $pin: lower >] ) , ".set_duty(128);\n " ,
151+ stringify!( [ < $pin: lower >] ) , ".enable();\n " ,
152+ "\n " ,
153+ ) } ]
154+ ) +
138155 /// ```
139156 pub struct $timer {
140157 timer: crate :: $hal:: pac:: $peripheral,
@@ -187,16 +204,25 @@ macro_rules! timer1_16bit_impl {
187204 ) => {
188205 paste! {
189206 avr_hal_generic:: impl_simple_pwm! {
190- /// Use `$peripheral` for PWM (pins `$pin`,)
207+ # [ doc = concat! ( " Use `" , stringify! ( $peripheral) , " ` for PWM." ) ]
191208 ///
192209 /// # Example
193- /// ```
194- /// let mut timer1 = Timer1Pwm::new(dp.TC1, Prescaler::Prescale64);
210+ /// ```no_run
211+ #[ doc = concat!( "use attiny_hal::" , stringify!( $hal) , " as hal;" ) ]
212+ /// use hal::simple_pwm::{IntoPwmPin,Timer1Pwm,Prescaler};
195213 ///
196- /// let mut d4 = pins.d4.into_output().into_pwm(&mut timer1);
214+ /// let dp = hal::Peripherals::take().unwrap();
215+ /// let pins = hal::pins!(dp);
216+ #[ doc = concat!( "let mut timer1 = " , stringify!( $timer) , "::new(dp." , stringify!( $peripheral) , ", Prescaler::Prescale64);" ) ]
197217 ///
198- /// d4.set_duty(128);
199- /// d4.enable();
218+ $(
219+ #[ doc = paste!{ concat!(
220+ "let mut " , stringify!( [ < $pin: lower >] ) , " = pins." , stringify!( [ < $pin: lower >] ) , ".into_output().into_pwm(&mut timer1);\n " ,
221+ stringify!( [ < $pin: lower >] ) , ".set_duty(128);\n " ,
222+ stringify!( [ < $pin: lower >] ) , ".enable();\n " ,
223+ "\n " ,
224+ ) } ]
225+ ) +
200226 /// ```
201227 pub struct $timer {
202228 timer: crate :: $hal:: pac:: $peripheral,
0 commit comments