Add a version of UserReadHIDData() which uses a signal on a port to set the Voice Command bit in the HID Report data.

This commit preserves the ability to simulate the NDP100 entirely, i.e. without using a port for input.
This commit is contained in:
Michael Banther
2019-09-30 16:14:16 +01:00
parent 660b483d1e
commit e1b72c47bc
2 changed files with 51 additions and 2 deletions

View File

@@ -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]);

View File

@@ -4,8 +4,9 @@
#include <xs1.h>
#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 ) */