Skip to content

Commit 06b2fed

Browse files
committed
improve macro readability
1 parent 4ce7a4c commit 06b2fed

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
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)
45+
#if HAS_DAC
4646
DAC_HandleTypeDef handle;
4747
#endif
4848

4949
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self,
5050
const mcu_pin_obj_t *pin) {
51-
#if !defined(HAS_DAC)
51+
#if !(HAS_DAC)
5252
mp_raise_ValueError(translate("No DAC on chip"));
5353
#else
5454
if (pin == &pin_PA04) {
@@ -93,7 +93,7 @@ bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
9393
}
9494

9595
void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
96-
#if defined(HAS_DAC)
96+
#if HAS_DAC
9797
reset_pin_number(self->pin->port,self->pin->number);
9898
self->pin = mp_const_none;
9999
self->deinited = true;
@@ -103,14 +103,14 @@ void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
103103

104104
void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self,
105105
uint16_t value) {
106-
#if defined(HAS_DAC)
106+
#if HAS_DAC
107107
HAL_DAC_SetValue(&handle, self->channel, DAC_ALIGN_12B_R, value >> 4);
108108
HAL_DAC_Start(&handle, self->channel);
109109
#endif
110110
}
111111

112112
void analogout_reset(void) {
113-
#if defined(HAS_DAC)
113+
#if HAS_DAC
114114
__HAL_RCC_DAC_CLK_DISABLE();
115115
HAL_DAC_DeInit(&handle);
116116
#endif

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
typedef struct {
3838
mp_obj_base_t base;
39-
#if defined(HAS_DAC)
39+
#if HAS_DAC
4040
DAC_ChannelConfTypeDef ch_handle;
4141
#endif
4242
const mcu_pin_obj_t * pin;

ports/stm32f4/peripherals/stm32f4/periph.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,19 @@ typedef struct {
102102
//Starter Lines
103103

104104
#ifdef STM32F411xE
105+
#define HAS_DAC 0
105106
#include "stm32f411xe/periph.h"
106107
#endif
107108

108109
#ifdef STM32F412Zx
110+
#define HAS_DAC 0
109111
#include "stm32f412zx/periph.h"
110112
#endif
111113

112114
//Foundation Lines
113115

114116
#ifdef STM32F405xx
115-
#define HAS_DAC
117+
#define HAS_DAC 1
116118
#include "stm32f405xx/periph.h"
117119
#endif
118120

0 commit comments

Comments
 (0)