@@ -13,10 +13,8 @@ use defmt_rtt as _;
13
13
#[ rtic:: app( device = stm32f4xx_hal:: pac, dispatchers = [ EXTI1 ] ) ]
14
14
mod app {
15
15
use stm32f4xx_hal:: gpio:: { Edge , Input , Output , PB4 , PB5 , PC13 } ;
16
- use stm32f4xx_hal:: timer:: PwmChannel ;
17
- use stm32f4xx_hal:: {
18
- pac, pac:: TIM2 , prelude:: * , timer:: MonoTimerUs , watchdog:: IndependentWatchdog ,
19
- } ;
16
+ use stm32f4xx_hal:: timer:: { Channel3 , MonoTimerUs , PwmChannel } ;
17
+ use stm32f4xx_hal:: { pac, pac:: TIM2 , prelude:: * , watchdog:: IndependentWatchdog } ;
20
18
use tb6612fng:: { DriveCommand , Motor } ;
21
19
22
20
#[ monotonic( binds = TIM5 , default = true ) ]
@@ -51,7 +49,7 @@ mod app {
51
49
let motor_pwm = ctx
52
50
. device
53
51
. TIM2
54
- . pwm_hz ( gpiob. pb10 . into_alternate ( ) , 100 . kHz ( ) , & clocks)
52
+ . pwm_hz ( Channel3 :: new ( gpiob. pb10 ) , 100 . kHz ( ) , & clocks)
55
53
. split ( ) ;
56
54
let mut motor = Motor :: new ( motor_in1, motor_in2, motor_pwm) ;
57
55
motor. drive_backwards ( 0 ) . expect ( "" ) ;
@@ -84,15 +82,15 @@ mod app {
84
82
}
85
83
86
84
/// Feed the watchdog to avoid hardware reset.
87
- #[ task( priority= 1 , local= [ watchdog] ) ]
85
+ #[ task( priority = 1 , local = [ watchdog] ) ]
88
86
fn periodic ( ctx : periodic:: Context ) {
89
87
defmt:: trace!( "feeding the watchdog!" ) ;
90
88
ctx. local . watchdog . feed ( ) ;
91
89
periodic:: spawn_after ( 100 . millis ( ) ) . ok ( ) ;
92
90
}
93
91
94
92
/// Increase/decrease the motor speed every 100ms by 1% (iterates from 100% forward to 100% backwards)
95
- #[ task( priority= 1 , local= [ motor_ramp_direction] , shared= [ motor] ) ]
93
+ #[ task( priority = 1 , local = [ motor_ramp_direction] , shared = [ motor] ) ]
96
94
fn update_motor_speed ( mut ctx : update_motor_speed:: Context ) {
97
95
ctx. shared . motor . lock ( |motor| {
98
96
let motor_ramp_direction = ctx. local . motor_ramp_direction ;
0 commit comments