Skip to content

Commit e7c5165

Browse files
authored
Merge pull request #4994 from bobthechemist/atmel-samd-analogio-deinit
added pin object to analogout
2 parents 6188301 + 35030fb commit e7c5165

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

ports/atmel-samd/common-hal/analogio/AnalogOut.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self,
7575
}
7676

7777
self->channel = channel;
78+
self->pin = pin;
7879

7980
#ifdef SAM_D5X_E5X
8081
hri_mclk_set_APBDMASK_DAC_bit(MCLK);
@@ -129,7 +130,9 @@ void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
129130
return;
130131
}
131132
dac_sync_disable_channel(&self->descriptor, self->channel);
132-
reset_pin_number(PIN_PA02);
133+
reset_pin_number(self->pin->number);
134+
self->pin = NULL;
135+
133136
// Only deinit the DAC on the SAMD51 if both outputs are free.
134137
#ifdef SAM_D5X_E5X
135138
if (common_hal_mcu_pin_is_free(&pin_PA02) && common_hal_mcu_pin_is_free(&pin_PA05)) {

ports/atmel-samd/common-hal/analogio/AnalogOut.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
typedef struct {
3737
mp_obj_base_t base;
38+
const mcu_pin_obj_t *pin;
3839
struct dac_sync_descriptor descriptor;
3940
uint8_t channel;
4041
bool deinited;

0 commit comments

Comments
 (0)