Hello vlsi team,
I am using VS1005 developer board,
I am using ReadTimeCount() function value to create debounce delay !
1.) i want to know what value does it return ?
2.) Is it in millisecond ?
3.) If not then please share any provision to make it in milliseconds !
Thankyou !
readtimecount()
Re: readtimecount()
From audio.h:vinayslone wrote: ↑Tue 2020-12-22 9:21Hello vlsi team,
I am using VS1005 developer board,
I am using ReadTimeCount() function value to create debounce delay !
1.) i want to know what value does it return ?
2.) Is it in millisecond ?
Code: Select all
/** Return time since startup in TIMER_TICKS (milliseconds). */
u_int32 ReadTimeCount(void);
3.) If not then please share any provision to make it in milliseconds !
Code: Select all
#define NUMBER_OF_BUTTONS 10
u_int16 buttons[NUMBER_OF_BUTTONS] = { 0x00, 0x01, 0x02, /* GPIO0_0..2 */ 0x10, 0x11 /* GPIO1_0..1*/
}, prevState, unProcessedButtons;
void readButtons() {
u_int16 i, *pin = buttons, bit = 1;
for(i = 0; i < NUMBER_OF_BUTTONS; i++) {
u_int16 state = GpioReadPin(*pin++);
if(state && ! (prevState & bit)) {
Forbid();
unProcessedButtons |= bit; /* rising edge sensitive */
Permit();
}
if (state) prevState |= bit;
else prevState &= ~bit;
bit <<= 1;
}
}
void proc() {
u_int16 i, bit = 1;
for (i = 0; i < NUMBER_OF_BUTTONS; i++) {
if (unProcessedButtons & bit) {
DoSomething();
Forbid();
unProcessedButtons &= ~bit; /* Now it's processed */
Permit();
}
bit <<= 1;
}
}
and then in main ui loop I would make something like proc() to process. Please keep stack and cpu time usage small cyclic task context. The unProcessedButtons variable is the only shared resource between the tasks.