This library is included in the Arc32 core. This core can be installed through the Arduino IDEs , where the package is named "Intel Curie Boards".
This library allows to use Timer functions on Arduino and Genuino 101 boards. With this library you can add and manage events based on timer functions. The timer is set up with a number of microseconds and every time this number is reached, a counter is incremented and an interrupt, if set, is asserted. This means that you may program recurring interrupts setting up their frequency. This library supports also PWM signal generation with 1024 steps of resolution and a period that can be set up in microseconds.
To use this library:
1#include <CurieTimerOne.h>
start()
Starts the timer function, sets the interval at which the timer ticks and also sets the interrupt callback function.
1CurieTimerOne.start(int timerPeriodUsec, userCallBack)
timerPeriodUsec: the number of microseconds that are the period of time at which the timer ticks and generates an interrupt
userCallBack: the function that is called when an interrupt is asserted
none
restart()
Restarts the timer function, sets the counter to zeroand sets the interval at which the timer ticks.
1CurieTimerOne.restart(int timerPeriodUsec)
timerPeriodUsec: the number of microseconds that are the period of time at which the timer ticks and generates an interrupt
none
kill()
Disables the timer and puts it back in the power up default state
1CurieTimerOne.kill()
none
none
attachInterrupt()
Attaches the interrupt to the call back function
1CurieTimerOne.attachInterrupt(userCallBack)
userCallBack: the function that is called when an interrupt is asserted
none
detachInterrupt()
Detaches the interrupt from the call back function; this doesn't disable the interrupt, it just inhibit the call of the call back function. the interrupt count is still increased at each interrupt.
1CurieTimerOne.detachInterrupt()
none
none
readTickCount()
Returns the count of the interrupts asserted since the timer activation or the last reset.
1CurieTimerOne.readTickCount()
none
an integer containing the number of interrupts counted since the last start/reset.
rdRstTickCount()
Reads and resets the number of timer interrupts counted so far.
1CurieTimerOne.rdRstTickCount()
none
The number of interrupts generated since the start or the last reset.
pause()
Pauses the timer suspending the interrupt generation. While the timer is paused, the count does not increase and no interrupt is asserted.
1CurieTimerOne.pause()
none
none
resume()
Resumes the timer restarting from where it was left after a pause() .
1CurieTimerOne.resume()
none
none
pwmStart()
This function generates a PWM signal on any digital pin with frequency and duty cycle specified as arguments. The timer is consumed once PWM is set, stopping any interrupt generation that was set up as timer.
1CurieTimerOne.pwmStart(int outputPin, int dutyRange, unsigned int periodUsec)2or3CurieTimerOne.pwmStart(int outputPin, double dutyPercentage, unsigned int periodUsec)
outputPin: is the digital pin on which we want to generate the pwm signal.
dutyRange: is the value expressed as an integer from 0 to 1023, where a 50% duty cycle is 512 and 255 equals 24.9% of duty cycle.
dutyPercentage: is the value expressed as a floating point percentage. This function manages only one decimal position.
periodUsec: is the length of the PWM waveform period, expressed in microseconds. To convert this value to hertz, use this formula: Hz=(periodUsec/1000000)
none
pwmStop()
This function ends the software generation of PWM. Puts the timer back to default, de-asserts the selected port and sets its level to LOW.
1CurieTimerOne.pwmStop()
none
none