Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[beken-72xx] Improve ddev ADC support #220

Merged
merged 2 commits into from
Jan 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions cores/beken-72xx/arduino/src/wiring_analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,21 @@ uint16_t analogReadVoltage(pin_size_t pinNumber) {
adc.pData = adcData;
adc.data_buff_size = 1;
handle = ddev_open(SARADC_DEV_NAME, &status, (uint32_t)&adc);
if (status)
if (handle == -1) {
kuba2k2 marked this conversation as resolved.
Show resolved Hide resolved
return 0;
}

if (status != SARADC_SUCCESS) {
ddev_close(handle);
kuba2k2 marked this conversation as resolved.
Show resolved Hide resolved
return 0;
}

// wait for data
while (!adc.has_data || adc.current_sample_data_cnt < 1) {
delay(1);
}
ddev_control(handle, SARADC_CMD_RUN_OR_STOP_ADC, (void *)false);
uint8_t run_stop = 0; // stop
kuba2k2 marked this conversation as resolved.
Show resolved Hide resolved
ddev_control(handle, SARADC_CMD_RUN_OR_STOP_ADC, &run_stop);
ddev_close(handle);
return adcData[0];
}
Expand Down
Loading