Skip to content

Commit 021df5d

Browse files
committed
nrf: Cleanup AnalogOut and throw an exception in constructor
The nRF MCUs do not support analog output. Throwing an exception in the constructor will stop users from creating an instance of the AnalogOut class. In the future we can ifdef-out the whole class so it is not available in the module at all.
1 parent 6c5cb01 commit 021df5d

File tree

2 files changed

+4
-36
lines changed

2 files changed

+4
-36
lines changed

ports/nrf/common-hal/analogio/AnalogOut.c

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,43 +34,17 @@
3434

3535

3636
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self, const mcu_pin_obj_t *pin) {
37-
// if (pin->pin != PIN_PA02) {
38-
// mp_raise_ValueError("AnalogOut not supported on given pin");
39-
// return;
40-
// }
41-
// struct dac_config config_dac;
42-
// dac_get_config_defaults(&config_dac);
43-
// config_dac.reference = DAC_REFERENCE_AVCC;
44-
// enum status_code status = dac_init(&self->dac_instance, DAC, &config_dac);
45-
// if (status != STATUS_OK) {
46-
// mp_raise_OSError(MP_EIO);
47-
// return;
48-
// }
49-
// claim_pin(pin);
50-
//
51-
// struct dac_chan_config config_analogout_chan;
52-
// dac_chan_get_config_defaults(&config_analogout_chan);
53-
// dac_chan_set_config(&self->dac_instance, DAC_CHANNEL_0, &config_analogout_chan);
54-
// dac_chan_enable(&self->dac_instance, DAC_CHANNEL_0);
55-
//
56-
// dac_enable(&self->dac_instance);
37+
mp_raise_RuntimeError("AnalogOut functionality not supported");
5738
}
5839

5940
bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
60-
return self->deinited;
41+
return true;
6142
}
6243

6344
void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
64-
// if (common_hal_analogio_analogout_deinited(self)) {
65-
// return;
66-
// }
67-
// dac_disable(&self->dac_instance);
68-
// dac_chan_disable(&self->dac_instance, DAC_CHANNEL_0);
69-
// reset_pin(PIN_PA02);
70-
// self->deinited = true;
45+
7146
}
7247

7348
void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self, uint16_t value) {
74-
// Input is 16 bit but we only support 10 bit so we shift the input.
75-
// dac_chan_write(&self->dac_instance, DAC_CHANNEL_0, value >> 6);
49+
7650
}

ports/nrf/common-hal/analogio/AnalogOut.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,10 @@
2727
#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_ANALOGIO_ANALOGOUT_H
2828
#define MICROPY_INCLUDED_NRF_COMMON_HAL_ANALOGIO_ANALOGOUT_H
2929

30-
#include "common-hal/microcontroller/Pin.h"
31-
32-
//#include "asf/sam0/drivers/dac/dac.h"
33-
3430
#include "py/obj.h"
3531

3632
typedef struct {
3733
mp_obj_base_t base;
38-
// struct dac_module dac_instance;
39-
bool deinited;
4034
} analogio_analogout_obj_t;
4135

4236
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_ANALOGIO_ANALOGOUT_H

0 commit comments

Comments
 (0)