Skip to content

Commit 5b7f906

Browse files
committed
cores: arduino: zephyrCommon.cpp: fix struct initialization warnings
Replace {0} with {} for port_callback, set dac_channel_cfg::internal explicitly, and expand adc_sequence initialization to make default values explicit and avoid C++ initializer warnings. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
1 parent c5c264f commit 5b7f906

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

cores/arduino/zephyrCommon.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct gpio_port_callback {
106106
struct arduino_callback handlers[max_ngpios];
107107
gpio_port_pins_t pins;
108108
const struct device *dev;
109-
} port_callback[port_num] = {0};
109+
} port_callback[port_num] = {};
110110

111111
struct gpio_port_callback *find_gpio_port_callback(const struct device *dev) {
112112
for (size_t i = 0; i < ARRAY_SIZE(port_callback); i++) {
@@ -210,6 +210,7 @@ static const struct device *const dac_dev = DEVICE_DT_GET(DAC_NODE);
210210
.channel_id = DT_PROP_BY_IDX(n, p, i), \
211211
.resolution = DAC_RESOLUTION, \
212212
.buffered = true, \
213+
.internal = false, \
213214
},
214215

215216
#if DT_PROP_LEN_OR(DT_PATH(zephyr_user), dac_channels, 0) > 0
@@ -559,7 +560,16 @@ int analogReadResolution() {
559560
int analogRead(pin_size_t pinNumber) {
560561
int err;
561562
uint16_t buf;
562-
struct adc_sequence seq = {.buffer = &buf, .buffer_size = sizeof(buf)};
563+
struct adc_sequence seq = {.options = nullptr,
564+
.channels = 0,
565+
.buffer = &buf,
566+
.buffer_size = sizeof(buf),
567+
#if defined(CONFIG_ADC_SEQUENCE_PRIORITY)
568+
.priority = 0,
569+
#endif
570+
.resolution = 0,
571+
.oversampling = 0,
572+
.calibrate = false};
563573
size_t idx = analog_pin_index(pinNumber);
564574

565575
if (idx >= ARRAY_SIZE(arduino_adc)) {

0 commit comments

Comments
 (0)