Skip to content

[Docs] ADC and Timer API Update (+some docs fixes) #7906

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

Merged
merged 5 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Last timer refactored API + gpio small fix
  • Loading branch information
P-R-O-C-H-Y committed Mar 17, 2023
commit a54accf01929a9511e6f730fba3235244e99e0ff
2 changes: 1 addition & 1 deletion docs/source/api/gpio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ The GPIO peripheral on the ESP32 supports interruptions.
attachInterrupt
***************

The function ``attachInterruptArg`` is used to attach the interrupt to the defined pin.
The function ``attachInterrupt`` is used to attach the interrupt to the defined pin.

.. code-block:: arduino

Expand Down
116 changes: 64 additions & 52 deletions docs/source/api/timer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ This function is used to configure the timer. After successful setup the timer w

.. code-block:: arduino

hw_timer_t timerBegin(uint32_t resolution, bool countUp);
hw_timer_t * timerBegin(uint32_t frequency);

* ``resolution`` select timer resolution in Hz. Sets how quickly the timer counter is “ticking”.
* ``countUp`` select timer direction. Sets if the counter should be incrementing or decrementing.
* ``frequency`` select timer frequency in Hz. Sets how quickly the timer counter is “ticking”.

This function will return ``timer`` handle if configuration is successful.
This function will return ``timer`` structure if configuration is successful.
If ``NULL`` is returned, error occurs and the timer was not configured.

timerEnd
Expand All @@ -43,32 +42,9 @@ This function is used to end timer.

.. code-block:: arduino

void timerEnd(hw_timer_t timer);
void timerEnd(hw_timer_t * timer);

* ``timer`` timer handle.

timerAttachInterrupt
********************

This function is used to attach interrupt to timer.

.. code-block:: arduino

void timerAttachInterrupt(hw_timer_t timer, void (*fn)(void));

* ``timer`` timer handle.
* ``fn`` funtion to be called when interrupt is triggered.

timerDetachInterrupt
********************

This function is used to detach interrupt from timer.

.. code-block:: arduino

void timerDetachInterrupt(hw_timer_t timer);

* ``timer`` timer handle.
* ``timer`` timer struct.

timerStart
**********
Expand All @@ -77,9 +53,9 @@ This function is used to start counter of the timer.

.. code-block:: arduino

void timerStart(hw_timer_t timer);
void timerStart(hw_timer_t * timer);

* ``timer`` timer handle.
* ``timer`` timer struct.

timerStop
*********
Expand All @@ -88,9 +64,9 @@ This function is used to stop counter of the timer.

.. code-block:: arduino

void timerStop(hw_timer_t timer);
void timerStop(hw_timer_t * timer);

* ``timer`` timer handle.
* ``timer`` timer struct.

timerRestart
************
Expand All @@ -99,9 +75,9 @@ This function is used to restart counter of the timer.

.. code-block:: arduino

void timerRestart(hw_timer_t timer);
void timerRestart(hw_timer_t * timer);

* ``timer`` timer handle.
* ``timer`` timer struct.

timerWrite
**********
Expand All @@ -110,9 +86,9 @@ This function is used to set counter value of the timer.

.. code-block:: arduino

void timerWrite(hw_timer_t timer, uint64_t val);
void timerWrite(hw_timer_t * timer, uint64_t val);

* ``timer`` timer handle.
* ``timer`` timer struct.
* ``val`` counter value to be set.

timerRead
Expand All @@ -122,9 +98,9 @@ This function is used to read counter value of the timer.

.. code-block:: arduino

uint64_t timerRead(hw_timer_t timer);
uint64_t timerRead(hw_timer_t * timer);

* ``timer`` timer handle.
* ``timer`` timer struct.

This function will return ``counter value`` of the timer.

Expand All @@ -135,9 +111,9 @@ This function is used to read counter value in microseconds of the timer.

.. code-block:: arduino

uint64_t timerReadMicros(hw_timer_t timer);
uint64_t timerReadMicros(hw_timer_t * timer);

* ``timer`` timer handle.
* ``timer`` timer struct.

This function will return ``counter value`` of the timer in microseconds.

Expand All @@ -148,9 +124,9 @@ This function is used to read counter value in miliseconds of the timer.

.. code-block:: arduino

uint64_t timerReadMilis(hw_timer_t timer);
uint64_t timerReadMilis(hw_timer_t * timer);

* ``timer`` timer handle.
* ``timer`` timer struct.

This function will return ``counter value`` of the timer in miliseconds.

Expand All @@ -161,35 +137,71 @@ This function is used to read counter value in seconds of the timer.

.. code-block:: arduino

double timerReadSeconds(hw_timer_t timer);
double timerReadSeconds(hw_timer_t * timer);

* ``timer`` timer handle.
* ``timer`` timer struct.

This function will return ``counter value`` of the timer in seconds.

timerGetResolution
******************
timerGetFrequency
*****************

This function is used to get resolution in Hz of the timer.

.. code-block:: arduino

uint16_t timerGetResolution(hw_timer_t timer);
uint16_t timerGetFrequency(hw_timer_t * timer);

* ``timer`` timer handle.
* ``timer`` timer struct.

This function will return ``resolution`` in Hz of the timer.
This function will return ``frequency`` in Hz of the timer.

timerAttachInterrupt
********************

This function is used to attach interrupt to timer.

.. code-block:: arduino

void timerAttachInterrupt(hw_timer_t * timer, void (*userFunc)(void));

* ``timer`` timer struct.
* ``userFunc`` funtion to be called when interrupt is triggered.

timerAttachInterruptArg
***********************

This function is used to attach interrupt to timer using arguments.

.. code-block:: arduino

void timerAttachInterruptArg(hw_timer_t * timer, void (*userFunc)(void*), void * arg);

* ``timer`` timer struct.
* ``userFunc`` funtion to be called when interrupt is triggered.
* ``arg`` pointer to the interrupt arguments.

timerDetachInterrupt
********************

This function is used to detach interrupt from timer.

.. code-block:: arduino

void timerDetachInterrupt(hw_timer_t * timer);

* ``timer`` timer struct.

timerAlarmWrite
***************

This function is used to configure alarm value and autoreload of the timer. Alarm is automaticaly enabled.

.. code-block:: arduino

void timerAlarmWrite(hw_timer_t timer, uint64_t alarm_value, bool autoreload, uint64_t reload_count);
void timerAlarmWrite(hw_timer_t * timer, uint64_t alarm_value, bool autoreload, uint64_t reload_count);

* ``timer`` timer handle.
* ``timer`` timer struct.
* ``alarm_value`` alarm value to generate event.
* ``autoreload`` enabled/disabled autorealod.
* ``reload_count`` number of autoreloads (0 = unlimited). Has no effect if autorealod is disabled.
Expand Down