add board_buttons API and refractor device keyboard app
This commit is contained in:
@@ -127,29 +127,28 @@ OSAL_TASK_FUNCTION( keyboardd_app_task ) (void* p_task_para)
|
||||
{
|
||||
OSAL_TASK_LOOP_BEGIN
|
||||
|
||||
if (tusbd_is_configured(0) && (keyboardd_report_count++ < 5) )
|
||||
osal_task_delay(100);
|
||||
|
||||
if ( tusbd_is_configured(0) )
|
||||
{
|
||||
if (!tusbd_hid_keyboard_is_busy(0))
|
||||
static uint32_t button_mask = 0;
|
||||
|
||||
uint32_t new_button_mask = board_buttons();
|
||||
|
||||
//------------- Key pressed -------------//
|
||||
if ( (button_mask != new_button_mask) && !tusbd_hid_keyboard_is_busy(0) )
|
||||
{
|
||||
//------------- Key pressed -------------//
|
||||
keyboard_report.keycode[0] = 0x04;
|
||||
button_mask = new_button_mask;
|
||||
|
||||
for (uint8_t i=0; i<6; i++)
|
||||
{ // demo support up to 6 buttons, button0 = 'a', button1 = 'b', etc ...
|
||||
keyboard_report.keycode[i] = BIT_TEST_(button_mask, i) ? (0x04+i) : 0;
|
||||
}
|
||||
|
||||
tusbd_hid_keyboard_send(0, &keyboard_report );
|
||||
|
||||
while( tusbd_hid_keyboard_is_busy(0) )
|
||||
{ // delay for transfer complete
|
||||
osal_task_delay(10);
|
||||
}
|
||||
|
||||
//------------- Key released -------------//
|
||||
if (!tusbd_hid_keyboard_is_busy(0))
|
||||
{
|
||||
keyboard_report.keycode[0] = 0x00;
|
||||
tusbd_hid_keyboard_send(0, &keyboard_report );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
osal_task_delay(1000);
|
||||
|
||||
OSAL_TASK_LOOP_END
|
||||
}
|
||||
|
||||
@@ -82,11 +82,11 @@
|
||||
#define TUSB_CFG_DEVICE_FULLSPEED 1 // TODO refractor, remove
|
||||
|
||||
//------------- CLASS -------------//
|
||||
#define TUSB_CFG_DEVICE_HID_KEYBOARD 0
|
||||
#define TUSB_CFG_DEVICE_HID_KEYBOARD 1
|
||||
#define TUSB_CFG_DEVICE_HID_MOUSE 0
|
||||
#define TUSB_CFG_DEVICE_HID_GENERIC 0
|
||||
#define TUSB_CFG_DEVICE_MSC 0
|
||||
#define TUSB_CFG_DEVICE_CDC 1
|
||||
#define TUSB_CFG_DEVICE_CDC 0
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// COMMON CONFIGURATION
|
||||
@@ -99,12 +99,10 @@
|
||||
#define TUSB_CFG_OS_TICKS_PER_SECOND 1000
|
||||
|
||||
#ifdef __CODE_RED // compiled with lpcxpresso
|
||||
#if (TUSB_CFG_MCU == MCU_LPC11UXX) || (TUSB_CFG_MCU == MCU_LPC13UXX)
|
||||
#if (TUSB_CFG_MCU == MCU_LPC11UXX) || (TUSB_CFG_MCU == MCU_LPC13UXX) || (TUSB_CFG_MCU == MCU_LPC175X_6X)
|
||||
#define TUSB_RAM_SECTION ".data.$RAM2"
|
||||
#elif (TUSB_CFG_MCU == MCU_LPC43XX)
|
||||
#define TUSB_RAM_SECTION ".data.$RAM3"
|
||||
#elif (TUSB_CFG_MCU == MCU_LPC175X_6X)
|
||||
#define TUSB_RAM_SECTION ".data.$RAM2"
|
||||
#else
|
||||
#error Please define USB RAM section
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user