diff --git a/right/hid_keyboard.c b/right/hid_keyboard.c index 2404bbe..6063fa6 100644 --- a/right/hid_keyboard.c +++ b/right/hid_keyboard.c @@ -1,3 +1,4 @@ +#include "fsl_gpio.h" #include "usb_device_config.h" #include "usb.h" #include "usb_device.h" @@ -13,31 +14,9 @@ static usb_device_hid_keyboard_struct_t UsbKeyboardDevice; static usb_status_t UsbKeyboardAction(void) { - static int x = 0U; - enum { - DOWN, - UP - }; - static uint8_t dir = DOWN; - UsbKeyboardDevice.buffer[2] = 0x00U; - switch (dir) { - case DOWN: - 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; + if (!GPIO_ReadPinInput(GPIOB, 17U)) { + UsbKeyboardDevice.buffer[2] = KEY_A; } return USB_DeviceHidSend(UsbCompositeDevice.keyboardHandle, USB_KEYBOARD_ENDPOINT_ID, UsbKeyboardDevice.buffer, USB_KEYBOARD_REPORT_LENGTH); diff --git a/right/include/board/pin_mux.c b/right/include/board/pin_mux.c index 78c117f..d17ad84 100644 --- a/right/include/board/pin_mux.c +++ b/right/include/board/pin_mux.c @@ -31,19 +31,17 @@ #include "fsl_common.h" #include "fsl_port.h" -/******************************************************************************* - * Code - ******************************************************************************/ - -/* Function Name : BOARD_InitPins */ void BOARD_InitPins(void) { - /* Initialize UART1 pins below */ - /* Ungate the port clock */ + // Set up UART1 for OpenSDA. CLOCK_EnableClock(kCLOCK_PortE); - - /* Affects PORTE_PCR0 register */ PORT_SetPinMux(PORTE, 0u, kPORT_MuxAlt3); - /* Affects PORTE_PCR1 register */ 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); }