Make SW3 send the scancode of 'A' to the host.
This commit is contained in:
+3
-24
@@ -1,3 +1,4 @@
|
|||||||
|
#include "fsl_gpio.h"
|
||||||
#include "usb_device_config.h"
|
#include "usb_device_config.h"
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
#include "usb_device.h"
|
#include "usb_device.h"
|
||||||
@@ -13,31 +14,9 @@ static usb_device_hid_keyboard_struct_t UsbKeyboardDevice;
|
|||||||
|
|
||||||
static usb_status_t UsbKeyboardAction(void)
|
static usb_status_t UsbKeyboardAction(void)
|
||||||
{
|
{
|
||||||
static int x = 0U;
|
|
||||||
enum {
|
|
||||||
DOWN,
|
|
||||||
UP
|
|
||||||
};
|
|
||||||
static uint8_t dir = DOWN;
|
|
||||||
|
|
||||||
UsbKeyboardDevice.buffer[2] = 0x00U;
|
UsbKeyboardDevice.buffer[2] = 0x00U;
|
||||||
switch (dir) {
|
if (!GPIO_ReadPinInput(GPIOB, 17U)) {
|
||||||
case DOWN:
|
UsbKeyboardDevice.buffer[2] = KEY_A;
|
||||||
x++;
|
|
||||||
if (x > 200U) {
|
|
||||||
dir++;
|
|
||||||
UsbKeyboardDevice.buffer[2] = KEY_PAGEUP;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case UP:
|
|
||||||
x--;
|
|
||||||
if (x < 1U) {
|
|
||||||
dir = DOWN;
|
|
||||||
UsbKeyboardDevice.buffer[2] = KEY_PAGEDOWN;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return USB_DeviceHidSend(UsbCompositeDevice.keyboardHandle, USB_KEYBOARD_ENDPOINT_ID,
|
return USB_DeviceHidSend(UsbCompositeDevice.keyboardHandle, USB_KEYBOARD_ENDPOINT_ID,
|
||||||
UsbKeyboardDevice.buffer, USB_KEYBOARD_REPORT_LENGTH);
|
UsbKeyboardDevice.buffer, USB_KEYBOARD_REPORT_LENGTH);
|
||||||
|
|||||||
@@ -31,19 +31,17 @@
|
|||||||
#include "fsl_common.h"
|
#include "fsl_common.h"
|
||||||
#include "fsl_port.h"
|
#include "fsl_port.h"
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Code
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
/* Function Name : BOARD_InitPins */
|
|
||||||
void BOARD_InitPins(void)
|
void BOARD_InitPins(void)
|
||||||
{
|
{
|
||||||
/* Initialize UART1 pins below */
|
// Set up UART1 for OpenSDA.
|
||||||
/* Ungate the port clock */
|
|
||||||
CLOCK_EnableClock(kCLOCK_PortE);
|
CLOCK_EnableClock(kCLOCK_PortE);
|
||||||
|
|
||||||
/* Affects PORTE_PCR0 register */
|
|
||||||
PORT_SetPinMux(PORTE, 0u, kPORT_MuxAlt3);
|
PORT_SetPinMux(PORTE, 0u, kPORT_MuxAlt3);
|
||||||
/* Affects PORTE_PCR1 register */
|
|
||||||
PORT_SetPinMux(PORTE, 1u, kPORT_MuxAlt3);
|
PORT_SetPinMux(PORTE, 1u, kPORT_MuxAlt3);
|
||||||
|
|
||||||
|
// Set up SW3.
|
||||||
|
CLOCK_EnableClock(kCLOCK_PortB);
|
||||||
|
port_pin_config_t switchConfig = {0};
|
||||||
|
switchConfig.pullSelect = kPORT_PullUp;
|
||||||
|
switchConfig.mux = kPORT_MuxAsGpio;
|
||||||
|
PORT_SetPinConfig(PORTB, 17U, &switchConfig);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user