From d32235d0f03901167605ee7c118b7737af500fef Mon Sep 17 00:00:00 2001 From: Michael Banther Date: Tue, 1 Oct 2019 11:57:54 +0100 Subject: [PATCH] Final clean-up of HID -- NDP10x Interrupt integration. --- lib_xua/src/core/user/user_hid.h | 20 ++++++-------- lib_xua/src/core/user/user_hid.xc | 43 +------------------------------ 2 files changed, 9 insertions(+), 54 deletions(-) diff --git a/lib_xua/src/core/user/user_hid.h b/lib_xua/src/core/user/user_hid.h index edf4ebda..ca0fcf93 100644 --- a/lib_xua/src/core/user/user_hid.h +++ b/lib_xua/src/core/user/user_hid.h @@ -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 diff --git a/lib_xua/src/core/user/user_hid.xc b/lib_xua/src/core/user/user_hid.xc index 79d4cb76..d10960cf 100644 --- a/lib_xua/src/core/user/user_hid.xc +++ b/lib_xua/src/core/user/user_hid.xc @@ -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 ) */