Skip to content

optional interrupts and more - #2

Open
Vigeant wants to merge 2 commits into
mauriciobarroso:mainfrom
Vigeant:adding-optional-interrupts
Open

optional interrupts and more#2
Vigeant wants to merge 2 commits into
mauriciobarroso:mainfrom
Vigeant:adding-optional-interrupts

Conversation

@Vigeant

@Vigeant Vigeant commented Jan 23, 2025

Copy link
Copy Markdown

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

mauriciobarroso commented Jan 23, 2025

Copy link
Copy Markdown
Owner

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

Vigeant commented Jan 23, 2025 via email

Copy link
Copy Markdown
Author

@Vigeant

Vigeant commented Jan 23, 2025 via email

Copy link
Copy Markdown
Author

@mauriciobarroso

Copy link
Copy Markdown
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