USB Audio Design Guide
v o i d U s e r R e a d H I D B u t t o n s ( u n s i g n e d c h a r h i d D a t a [])
{
/* V a r i a b l e s for b u t t o n s a & b and s w i t c h sw */
u n s i g n e d a , b , sw , tmp ;
p _ s w : > tmp ;
/* B u t t o n s are a c t i v e low */
tmp = ~ tmp ;
a = ( tmp & ( P _ G P I _ B U T A _ M A S K ) ) > > P _ G P I _ B U T A _ S H I F T ;
b = ( tmp & ( P _ G P I _ B U T B _ M A S K ) ) > > P _ G P I _ B U T B _ S H I F T ;
sw = ( tmp & ( P _ G P I _ S W 1 _ M A S K ) ) > > P _ G P I _ S W 1 _ S H I F T ;
if ( sw )
{
/* A s s i g n b u t t o n s A and B to Vol Up / D o w n */
h i d D a t a [0] = ( a < < H I D _ C O N T R O L _ V O L U P _ S H I F T ) | ( b < <
>
H I D _ C O N T R O L _ V O L D N _ S H I F T ) ;
}
e l s e
{
/* A s s i g n b u t t o n s A and B to p l a y for s i n g l e tap , n e x t / p r e v for
>
d o u b l e tap */
if ( b )
{
m u l t i c o n t r o l _ c o u n t ++;
w a i t _ c o u n t e r = 0;
l a s t A = 0;
}
e l s e if ( a )
{
m u l t i c o n t r o l _ c o u n t ++;
w a i t _ c o u n t e r = 0;
l a s t A = 1;
}
e l s e
{
if ( m u l t i c o n t r o l _ c o u n t > T H R E S H )
{
s t a t e ++;
}
w a i t _ c o u n t e r ++;
if ( w a i t _ c o u n t e r > M U L T I P R E S S _ W A I T )
{
if ( s t a t e == S T A T E _ P L A Y )
{
h i d D a t a [0] = (1 < < H I D _ C O N T R O L _ P L A Y P A U S E _ S H I F T )
>
;
}
e l s e if ( s t a t e == S T A T E _ N E X T P R E V )
{
if ( l a s t A )
h i d D a t a [0] = (1 < < H I D _ C O N T R O L _ P R E V _ S H I F T ) ;
e l s e
h i d D a t a [0] = (1 < < H I D _ C O N T R O L _ N E X T _ S H I F T ) ;
}
s t a t e = S T A T E _ I D L E ;
}
m u l t i c o n t r o l _ c o u n t = 0;
}
}
}
XM0088546.1
Содержание xCORE-200 Multi-channel Audio board
Страница 6: ...1 Overview XM0088546 1...