Skip to content

Commit 5f33c54

Browse files
committed
Fix include issues
1 parent 8a94f25 commit 5f33c54

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@
4242
//DAC is shared between both channels.
4343
//TODO: store as struct with channel info, automatically turn it off if unused
4444
//on both channels for power save?
45+
#if defined(HAS_DAC)
4546
DAC_HandleTypeDef handle;
47+
#endif
4648

4749
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self,
4850
const mcu_pin_obj_t *pin) {
4951
#if !defined(HAS_DAC)
5052
mp_raise_ValueError(translate("No DAC on chip"));
51-
#endif
53+
#else
5254
if (pin == &pin_PA04) {
5355
self->channel = DAC_CHANNEL_1;
5456
} else if (pin == &pin_PA05) {
@@ -83,26 +85,33 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self,
8385
self->pin = pin;
8486
self->deinited = false;
8587
claim_pin(pin);
88+
#endif
8689
}
8790

8891
bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
8992
return self->deinited;
9093
}
9194

9295
void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
96+
#if defined(HAS_DAC)
9397
reset_pin_number(self->pin->port,self->pin->number);
9498
self->pin = mp_const_none;
9599
self->deinited = true;
96100
//TODO: if both are de-inited, should we turn off the DAC?
101+
#endif
97102
}
98103

99104
void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self,
100105
uint16_t value) {
106+
#if defined(HAS_DAC)
101107
HAL_DAC_SetValue(&handle, self->channel, DAC_ALIGN_12B_R, value >> 4);
102108
HAL_DAC_Start(&handle, self->channel);
109+
#endif
103110
}
104111

105112
void analogout_reset(void) {
113+
#if defined(HAS_DAC)
106114
__HAL_RCC_DAC_CLK_DISABLE();
107115
HAL_DAC_DeInit(&handle);
116+
#endif
108117
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636

3737
typedef struct {
3838
mp_obj_base_t base;
39+
#if defined(HAS_DAC)
3940
DAC_ChannelConfTypeDef ch_handle;
41+
#endif
4042
const mcu_pin_obj_t * pin;
4143
uint8_t channel;
4244
bool deinited;

ports/stm32f4/mpconfigport.mk

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ CIRCUITPY_MICROCONTROLLER = 1
2222
CIRCUITPY_BUSIO = 1
2323
CIRCUITPY_TIME = 1
2424
CIRCUITPY_OS = 1
25-
CIRCUITPY_STRUCT = 1
26-
CIRCUITPY_MATH = 1
25+
CIRCUITPY_STORAGE = 1
26+
CIRCUITPY_RANDOM = 1
27+
CIRCUITPY_USB_HID = 1
28+
CIRCUITPY_USB_MIDI = 1
29+
2730

2831
#ifeq ($(MCU_SUB_VARIANT), stm32f412zx)
2932
#endif

0 commit comments

Comments
 (0)