forked from PAWPAW-Mirror/lib_xua
Final clean-up of HID -- NDP10x Interrupt integration.
This commit is contained in:
@@ -15,25 +15,21 @@
|
||||
#define HID_SIMULATE_INTERRUPTS 0
|
||||
#endif
|
||||
|
||||
#ifndef HID_SIMULATE_NDP10X
|
||||
#define HID_SIMULATE_NDP10X 0
|
||||
#endif
|
||||
|
||||
#ifndef NDP_ASSERT_HIGH
|
||||
#define NDP_ASSERT_HIGH 0
|
||||
#ifndef NDP_ASSERT_LEVEL
|
||||
#define NDP_ASSERT_LEVEL 0
|
||||
#endif
|
||||
|
||||
#if( 0 < HID_CONTROLS )
|
||||
|
||||
#if( 0 < NDP_ASSERT_HIGH )
|
||||
#define NDP100_ASSERT_LEVEL 1
|
||||
#define NDP100_DEASSERT_LEVEL 0
|
||||
#if( 0 < NDP_ASSERT_LEVEL )
|
||||
#define NDP10X_ASSERT_LEVEL 1
|
||||
#define NDP10X_DEASSERT_LEVEL 0
|
||||
#else
|
||||
#define NDP100_ASSERT_LEVEL 0
|
||||
#define NDP100_DEASSERT_LEVEL 1
|
||||
#define NDP10X_ASSERT_LEVEL 0
|
||||
#define NDP10X_DEASSERT_LEVEL 1
|
||||
#endif
|
||||
|
||||
#if(( 0 < HID_SIMULATE_INTERRUPTS ) || ( 0 < HID_SIMULATE_NDP10X ))
|
||||
#if( 0 < HID_SIMULATE_INTERRUPTS )
|
||||
#define HID_DEASSERT_COUNT 10000000
|
||||
#define HID_INTERRUPT_COUNT 1000000000
|
||||
#endif
|
||||
|
||||
@@ -5,46 +5,6 @@
|
||||
#include "user_hid.h"
|
||||
|
||||
#if( 0 < HID_CONTROLS )
|
||||
#if( 0 < HID_SIMULATE_NDP10X )
|
||||
|
||||
#define HID_REPORT_DATA 0x01
|
||||
|
||||
static unsigned char initialised = 0;
|
||||
|
||||
static unsigned int curr_time = 0;
|
||||
static unsigned int last_time = 0;
|
||||
static unsigned int tick_count = 0;
|
||||
|
||||
void UserReadHIDData( in port p_int, unsigned char hidData[ HID_DATA_SIZE ])
|
||||
{
|
||||
timer tmr;
|
||||
|
||||
if( !initialised ) {
|
||||
tmr :> last_time;
|
||||
initialised = 1;
|
||||
} else {
|
||||
tmr :> curr_time;
|
||||
tick_count += ( last_time < curr_time ) ? curr_time - last_time : curr_time + ( UINT_MAX - last_time );
|
||||
|
||||
if(( HID_INTERRUPT_COUNT <= tick_count ) && ( tick_count <= ( HID_INTERRUPT_COUNT + HID_DEASSERT_COUNT ))) {
|
||||
for( unsigned idx = 0; idx < HID_DATA_SIZE; ++idx ) {
|
||||
hidData[ idx ] = HID_REPORT_DATA;
|
||||
}
|
||||
} else {
|
||||
for( unsigned idx = 0; idx < HID_DATA_SIZE; ++idx ) {
|
||||
hidData[ idx ] = 0x00;
|
||||
}
|
||||
|
||||
if (( HID_INTERRUPT_COUNT + HID_DEASSERT_COUNT ) <= tick_count ) {
|
||||
tick_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
last_time = curr_time;
|
||||
}
|
||||
}
|
||||
#else /* ( 0 < HID_SIMULATE_NDP10X ) */
|
||||
|
||||
#define HID_REPORT_INTERRUPT_ASSERTED 0x01
|
||||
#define HID_REPORT_INTERRUPT_DEASSERTED 0x00
|
||||
|
||||
@@ -53,12 +13,11 @@ void UserReadHIDData( in port p_int, unsigned char hidData[ HID_DATA_SIZE ])
|
||||
unsigned curr_val;
|
||||
|
||||
p_int :> curr_val;
|
||||
hidData[ 0 ] = ( curr_val == NDP100_ASSERT_LEVEL ) ? HID_REPORT_INTERRUPT_ASSERTED : HID_REPORT_INTERRUPT_DEASSERTED;
|
||||
hidData[ 0 ] = ( curr_val == NDP10X_ASSERT_LEVEL ) ? HID_REPORT_INTERRUPT_ASSERTED : HID_REPORT_INTERRUPT_DEASSERTED;
|
||||
|
||||
for( unsigned idx = 1; idx < HID_DATA_SIZE; ++idx ) {
|
||||
hidData[ idx ] = 0U;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* ( 0 < HID_SIMULATE_NDP10X ) */
|
||||
#endif /* ( 0 < HID_CONTROLS ) */
|
||||
|
||||
Reference in New Issue
Block a user