Fix include issues
This commit is contained in:
parent
8a94f25181
commit
5f33c542b4
|
@ -42,13 +42,15 @@
|
||||||
//DAC is shared between both channels.
|
//DAC is shared between both channels.
|
||||||
//TODO: store as struct with channel info, automatically turn it off if unused
|
//TODO: store as struct with channel info, automatically turn it off if unused
|
||||||
//on both channels for power save?
|
//on both channels for power save?
|
||||||
|
#if defined(HAS_DAC)
|
||||||
DAC_HandleTypeDef handle;
|
DAC_HandleTypeDef handle;
|
||||||
|
#endif
|
||||||
|
|
||||||
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self,
|
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self,
|
||||||
const mcu_pin_obj_t *pin) {
|
const mcu_pin_obj_t *pin) {
|
||||||
#if !defined(HAS_DAC)
|
#if !defined(HAS_DAC)
|
||||||
mp_raise_ValueError(translate("No DAC on chip"));
|
mp_raise_ValueError(translate("No DAC on chip"));
|
||||||
#endif
|
#else
|
||||||
if (pin == &pin_PA04) {
|
if (pin == &pin_PA04) {
|
||||||
self->channel = DAC_CHANNEL_1;
|
self->channel = DAC_CHANNEL_1;
|
||||||
} else if (pin == &pin_PA05) {
|
} else if (pin == &pin_PA05) {
|
||||||
|
@ -83,6 +85,7 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self,
|
||||||
self->pin = pin;
|
self->pin = pin;
|
||||||
self->deinited = false;
|
self->deinited = false;
|
||||||
claim_pin(pin);
|
claim_pin(pin);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
|
bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
|
||||||
|
@ -90,19 +93,25 @@ bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
|
void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
|
||||||
|
#if defined(HAS_DAC)
|
||||||
reset_pin_number(self->pin->port,self->pin->number);
|
reset_pin_number(self->pin->port,self->pin->number);
|
||||||
self->pin = mp_const_none;
|
self->pin = mp_const_none;
|
||||||
self->deinited = true;
|
self->deinited = true;
|
||||||
//TODO: if both are de-inited, should we turn off the DAC?
|
//TODO: if both are de-inited, should we turn off the DAC?
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self,
|
void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self,
|
||||||
uint16_t value) {
|
uint16_t value) {
|
||||||
|
#if defined(HAS_DAC)
|
||||||
HAL_DAC_SetValue(&handle, self->channel, DAC_ALIGN_12B_R, value >> 4);
|
HAL_DAC_SetValue(&handle, self->channel, DAC_ALIGN_12B_R, value >> 4);
|
||||||
HAL_DAC_Start(&handle, self->channel);
|
HAL_DAC_Start(&handle, self->channel);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void analogout_reset(void) {
|
void analogout_reset(void) {
|
||||||
|
#if defined(HAS_DAC)
|
||||||
__HAL_RCC_DAC_CLK_DISABLE();
|
__HAL_RCC_DAC_CLK_DISABLE();
|
||||||
HAL_DAC_DeInit(&handle);
|
HAL_DAC_DeInit(&handle);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,9 @@
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
|
#if defined(HAS_DAC)
|
||||||
DAC_ChannelConfTypeDef ch_handle;
|
DAC_ChannelConfTypeDef ch_handle;
|
||||||
|
#endif
|
||||||
const mcu_pin_obj_t * pin;
|
const mcu_pin_obj_t * pin;
|
||||||
uint8_t channel;
|
uint8_t channel;
|
||||||
bool deinited;
|
bool deinited;
|
||||||
|
|
|
@ -22,8 +22,11 @@ CIRCUITPY_MICROCONTROLLER = 1
|
||||||
CIRCUITPY_BUSIO = 1
|
CIRCUITPY_BUSIO = 1
|
||||||
CIRCUITPY_TIME = 1
|
CIRCUITPY_TIME = 1
|
||||||
CIRCUITPY_OS = 1
|
CIRCUITPY_OS = 1
|
||||||
CIRCUITPY_STRUCT = 1
|
CIRCUITPY_STORAGE = 1
|
||||||
CIRCUITPY_MATH = 1
|
CIRCUITPY_RANDOM = 1
|
||||||
|
CIRCUITPY_USB_HID = 1
|
||||||
|
CIRCUITPY_USB_MIDI = 1
|
||||||
|
|
||||||
|
|
||||||
#ifeq ($(MCU_SUB_VARIANT), stm32f412zx)
|
#ifeq ($(MCU_SUB_VARIANT), stm32f412zx)
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue