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

optional interrupts and more #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Vigeant
Copy link

@Vigeant Vigeant commented Jan 23, 2025

Thanks for the driver man. You saved me a ton of time. I made some changes to make interupt optional as all I have going to my adc1015 is i2c.

Feel free to refuse or heavily tweak this PR as I did add an include for FreeRTOS which works in my project but not sure its done right.

Added the ability to use or not interrupts for all conversions. streamlined the logic that checks for end of conversion for all functions. replaced the custom delay function with the freertos one. We could make this optional but when running on freertos, its better to use vTaskDelay to yield the processor.

Also, should consider blocking on a mutex instead of busy waiting when using interupts as it would also allow yielding the processor until the mutex is released by the isr.

Added the ability to use or not interrupts for all conversions.
streamlined the logic that checks for end of conversion for all functions.
replaced the custom delay function with the freertos one. We could make this optional but when running on freertos, its better to use vTaskDelay to yield the processor.
@mauriciobarroso
Copy link
Owner

mauriciobarroso commented Jan 23, 2025

Hi @Vigeant Sorry for the delay in updating the driver, I've been using the new ESP-IDF i2c driver for a while now, but I forgot to push it. I just updated it, it also works with interrupts, which is the way I use it. Anyway, I'll keep an eye on your work and your suggestions to improve this driver, thanks a lot!

To initialize the driver in interrupt mode use the next code

esp_err_t ret;
ads101x_t ads1015;

ret = ads101x_init(&ads1015, ADS101X_MODEL_5, int_pin, i2c_bus_handle, ADS101X_I2C_ADDRESS);

if (ret != ESP_OK) {
	return ESP_FAIL;
}

ads101x_set_gain(&ads1015, ADS101X_GAIN_ONE);
ads101x_set_data_rate(&ads1015, ADS101X_DATA_RATE_3300SPS);

@Vigeant
Copy link
Author

Vigeant commented Jan 23, 2025 via email

@Vigeant
Copy link
Author

Vigeant commented Jan 23, 2025 via email

@mauriciobarroso
Copy link
Owner

@Vigeant Sorry, you're right, I didn't realize I still had that remnant of my own i2c bus driver. I've already corrected it, thanks for noticing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants