3131#include "common-hal/pwmio/PWMOut.h"
3232#include "shared-bindings/pwmio/PWMOut.h"
3333#include "shared-bindings/microcontroller/Processor.h"
34- #include "shared_timers.h"
3534#include "timer_handler.h"
3635
3736#include "atmel_start_pins.h"
@@ -61,25 +60,9 @@ uint8_t tcc_channels[5]; // Set by pwmout_reset() to {0xc0, 0xf0, 0xf8, 0xfc,
6160
6261
6362void common_hal_pwmio_pwmout_never_reset (pwmio_pwmout_obj_t * self ) {
64- timer_never_reset (self -> timer -> index , self -> timer -> is_tc );
65-
6663 never_reset_pin_number (self -> pin -> number );
6764}
6865
69- void pwmout_reset (void ) {
70- // Reset all timers
71- for (int i = 0 ; i < TCC_INST_NUM ; i ++ ) {
72- target_tcc_frequencies [i ] = 0 ;
73- tcc_refcount [i ] = 0 ;
74- }
75- for (int i = 0 ; i < TCC_INST_NUM ; i ++ ) {
76- if (!timer_ok_to_reset (i , false)) {
77- continue ;
78- }
79- tcc_channels [i ] = 0xff << tcc_cc_num [i ];
80- }
81- }
82-
8366static uint8_t tcc_channel (const pin_timer_t * t ) {
8467 // For the SAMD51 this hardcodes the use of OTMX == 0x0, the output matrix mapping, which uses
8568 // SAMD21-style modulo mapping.
@@ -97,7 +80,6 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,
9780 uint16_t duty ,
9881 uint32_t frequency ,
9982 bool variable_frequency ) {
100- self -> pin = pin ;
10183 self -> variable_frequency = variable_frequency ;
10284 self -> duty_cycle = duty ;
10385
@@ -242,6 +224,7 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,
242224 }
243225
244226 self -> timer = timer ;
227+ self -> pin = pin ;
245228
246229 gpio_set_pin_function (pin -> number , GPIO_PIN_FUNCTION_E + mux_position );
247230
@@ -257,7 +240,6 @@ void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t *self) {
257240 if (common_hal_pwmio_pwmout_deinited (self )) {
258241 return ;
259242 }
260- timer_reset_ok (self -> timer -> index , self -> timer -> is_tc );
261243 const pin_timer_t * t = self -> timer ;
262244 if (t -> is_tc ) {
263245 Tc * tc = tc_insts [t -> index ];
0 commit comments