Merge pull request #196 from mbanth/feature/configurable_hid

Support configurable HID
This commit is contained in:
Michael Banther
2021-06-22 16:36:39 +01:00
committed by GitHub
6 changed files with 162 additions and 48 deletions

View File

@@ -1,6 +1,12 @@
lib_xua Change Log
==================
2.0.0
-----
* CHANGED: HID event ID from list to bit and byte location in HID Report
* CHANGED: Interface to UserHIDRecordEvent()
1.3.0
-----

View File

@@ -1,4 +1,4 @@
VERSION = 1.3.0
VERSION = 2.0.0
DEPENDENT_MODULES = lib_logging(>=3.0.0) \
lib_xassert(>=4.0.0) \

View File

@@ -5,47 +5,17 @@
#define __USER_HID_H__
/**
* \brief HID event identifiers
* \brief HID event
*
* This enumeration defines a constant value for each HID event.
* It defines one value for each of the four GPI pins supported in the standard voice products.
* It defines a further 28 values for generic events.
* This struct identifies the location within the HID Report for an event and
* The value to report for that location.
* It assumes only single bit flags within the HID Report.
*/
typedef enum hidEventId_t {
HID_EVENT_ID_EVT0 = 0,
HID_EVENT_ID_EVT1,
HID_EVENT_ID_EVT2,
HID_EVENT_ID_EVT3,
HID_EVENT_ID_EVT4,
HID_EVENT_ID_EVT5,
HID_EVENT_ID_EVT6,
HID_EVENT_ID_EVT7,
HID_EVENT_ID_EVT8,
HID_EVENT_ID_EVT9,
HID_EVENT_ID_EVT10,
HID_EVENT_ID_EVT11,
HID_EVENT_ID_EVT12,
HID_EVENT_ID_EVT13,
HID_EVENT_ID_EVT14,
HID_EVENT_ID_EVT15,
HID_EVENT_ID_EVT16,
HID_EVENT_ID_EVT17,
HID_EVENT_ID_EVT18,
HID_EVENT_ID_EVT19,
HID_EVENT_ID_EVT20,
HID_EVENT_ID_EVT21,
HID_EVENT_ID_EVT22,
HID_EVENT_ID_EVT23,
HID_EVENT_ID_EVT24,
HID_EVENT_ID_EVT25,
HID_EVENT_ID_EVT26,
HID_EVENT_ID_EVT27,
HID_EVENT_ID_EVT28,
HID_EVENT_ID_EVT29,
HID_EVENT_ID_EVT30,
HID_EVENT_ID_EVT31,
HID_EVENT_ID_INVALID = 0xffffffff,
} hidEventId_t;
typedef struct hidEvent_t {
unsigned bit;
unsigned byte;
unsigned value;
} hidEvent_t;
#define HID_MAX_DATA_BYTES 4
@@ -70,15 +40,15 @@ void UserHIDInit( void );
/**
* \brief Record that a HID event has occurred
*
* \param{in} hidEventId The identifier of an event which has occurred.
* Each event corresponds to bit in the HID Report:
* Events 0- 7 to bits 0-7 of byte 0,
* Events 8-15 to bits 0-7 of byte 1, etc.
* \param{in} hidEventData A Boolean indicating the state of the event:
* Zero = deasserted,
* Any other value = asserted.
* \param{in} hidEvent A list of events which have occurred.
* Each element specifies a bit and byte in the HID Report and the value for it.
* \param{in} hidEventCnt The length of the \a hidEvent list.
*
* \returns A Boolean flag indicating the status of the operation
* \retval False No recording of the event(s) occurred
* \retval True Recording of the event(s) occurred
*/
void UserHIDRecordEvent( const hidEventId_t hidEventId, const unsigned hidEventData );
unsigned UserHIDRecordEvent( const hidEvent_t hidEvent[], const unsigned hidEventCnt );
#endif /* ( 0 < HID_CONTROLS ) */
#endif /* __USER_HID_H__ */

View File

@@ -16,6 +16,8 @@
#ifndef _HID_REPORT_DESCRIPTOR_
#define _HID_REPORT_DESCRIPTOR_
#include <stddef.h>
#define HID_REPORT_ITEM_HDR_SIZE_MASK ( 0x03 )
#define HID_REPORT_ITEM_HDR_SIZE_SHIFT ( 0 )

View File

@@ -0,0 +1,104 @@
cmake_minimum_required(VERSION 3.13)
set(XMOS_TOOLS_PATH $ENV{XMOS_TOOL_PATH}/bin)
#**********************
# Setup XMOS toolchain
#**********************
if(NOT DEFINED ENV{XUA_PATH})
message(FATAL_ERROR "XUA_PATH environment variable not defined")
# some more commands
endif()
include("$ENV{XUA_PATH}/cmake_utils/xmos_toolchain.cmake")
#**********************
# Project
#**********************
# Disable in-source build.
#if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
# message(FATAL_ERROR "In-source build is not allowed! Please specify a build folder.\n\tex:cmake -B build")
#endif()
## Define project
project(xua_unit_tests VERSION 0.1.0)
## Enable languages for project
enable_language(CXX XC C ASM)
message(STATUS "CAME HERE")
add_custom_target("runners" ALL)
add_custom_command(
TARGET runners
COMMAND python generate_unity_runners.py
COMMENT "generate unity runners"
)
message(STATUS "CAME HERE 1")
file( GLOB APP_SOURCES src/test*.xc )
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
foreach( testsourcefile ${APP_SOURCES} )
get_filename_component(ITEM_NAME ${testsourcefile} NAME_WE)
message(STATUS "item_name " ${ITEM_NAME})
add_executable(${ITEM_NAME})
set(APP_COMPILER_FLAGS
"-O2"
"-g"
"-Wall"
"-report"
"-fxscope"
"-target=XCORE-AI-EXPLORER"
"${CMAKE_CURRENT_SOURCE_DIR}/config.xscope"
"-DUNITY_SUPPORT_64"
"-DUNITY_INCLUDE_DOUBLE"
)
set_source_files_properties(
"runners/${ITEM_NAME}/${ITEM_NAME}_Runner.c"
PROPERTIES GENERATED TRUE
)
set(APP_SRCS
${testsourcefile}
"runners/${ITEM_NAME}/${ITEM_NAME}_Runner.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../Unity/src/unity.c"
)
set(APP_INCLUDES
"src"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../Unity/src"
)
set(APP_DEPENDENT_MODULES
"lib_xua(>=2.0.0)"
"lib_logging(>=3.0.0)"
"lib_xassert(>=4.0.0)"
"lib_xud(>=2.0.0)"
"lib_spdif(>=4.0.0)"
"lib_mic_array(>=4.0.0)"
)
include("$ENV{XUA_PATH}/cmake_utils/xua.cmake")
set_target_properties(${ITEM_NAME} PROPERTIES OUTPUT_NAME ${ITEM_NAME}.xe)
target_compile_options(${ITEM_NAME} PRIVATE ${APP_COMPILER_FLAGS})
target_include_directories(${ITEM_NAME}
PRIVATE ${APP_INCLUDES}
PRIVATE ${XUA_INCLUDES_ALL}
)
target_sources(${ITEM_NAME}
PRIVATE ${APP_SRCS}
PRIVATE ${XUA_SRCS_ALL}
)
add_dependencies(${ITEM_NAME} runners)
target_link_options(${ITEM_NAME} PRIVATE ${APP_COMPILER_FLAGS})
## Set any additional flags only for C++
set(CMAKE_CXX_FLAGS "-std=c++11")
endforeach( testsourcefile ${APP_SOURCES} )
message(STATUS ${APP_SOURCES})
message(STATUS "CAME HERE 2")
## Register the application
#XMOS_REGISTER_APP()

View File

@@ -0,0 +1,32 @@
# xua_unit_tests test application
This example builds the xua_unit_tests application for XCORE AI
## Prerequisites for building
[XMOS Toolchain 15.0.3](https://www.xmos.com/software/tools/) or newer.
Install [CMake](https://cmake.org/download/) version 3.13 or newer.
## Building for xCORE
Set environment variable for lib_xua path:
> export XUA_PATH=<path to lib_xua>
cd to lib_xua/tests/xua_unit_tests
Run cmake and build
> cmake .
> make
## Run on hardware
Ensure your XCORE AI EXPLORER board is powered up and connected to the XTAG debugger.
Make sure the input.wav file is copied into the build directory
> pytest -n 1
You should see the tests collected by pytest pass