diff --git a/lib_xua/src/core/user/user_hid.h b/lib_xua/src/core/user/user_hid.h index 9c135744..edf4ebda 100644 --- a/lib_xua/src/core/user/user_hid.h +++ b/lib_xua/src/core/user/user_hid.h @@ -11,5 +11,34 @@ #define HID_DATA_SIZE 1 +#ifndef HID_SIMULATE_INTERRUPTS +#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 +#endif + +#if( 0 < HID_CONTROLS ) + +#if( 0 < NDP_ASSERT_HIGH ) +#define NDP100_ASSERT_LEVEL 1 +#define NDP100_DEASSERT_LEVEL 0 +#else +#define NDP100_ASSERT_LEVEL 0 +#define NDP100_DEASSERT_LEVEL 1 +#endif + +#if(( 0 < HID_SIMULATE_INTERRUPTS ) || ( 0 < HID_SIMULATE_NDP10X )) +#define HID_DEASSERT_COUNT 10000000 +#define HID_INTERRUPT_COUNT 1000000000 +#endif + +#endif /* ( 0 < HID_CONTROLS ) */ + void UserReadHIDData(in port p_int, unsigned char hidData[HID_DATA_SIZE]); diff --git a/lib_xua/src/core/user/user_hid.xc b/lib_xua/src/core/user/user_hid.xc index 1306a892..79d4cb76 100644 --- a/lib_xua/src/core/user/user_hid.xc +++ b/lib_xua/src/core/user/user_hid.xc @@ -4,8 +4,9 @@ #include #include "user_hid.h" -#define HID_DEASSERT_COUNT 10000000 -#define HID_INTERRUPT_COUNT 1000000000 +#if( 0 < HID_CONTROLS ) +#if( 0 < HID_SIMULATE_NDP10X ) + #define HID_REPORT_DATA 0x01 static unsigned char initialised = 0; @@ -42,3 +43,22 @@ void UserReadHIDData( in port p_int, unsigned char hidData[ HID_DATA_SIZE ]) last_time = curr_time; } } +#else /* ( 0 < HID_SIMULATE_NDP10X ) */ + +#define HID_REPORT_INTERRUPT_ASSERTED 0x01 +#define HID_REPORT_INTERRUPT_DEASSERTED 0x00 + +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; + + for( unsigned idx = 1; idx < HID_DATA_SIZE; ++idx ) { + hidData[ idx ] = 0U; + } +} + +#endif /* ( 0 < HID_SIMULATE_NDP10X ) */ +#endif /* ( 0 < HID_CONTROLS ) */