Files
firmware/right/src/usb_interfaces/usb_interface_media_keyboard.h
Kristian Sloth Lauszus e12e219b4e Various fixes and improvements (#96)
* Global variables shared between an interrupt and the main code should be volatile

See: https://www.embedded.com/electronics-blogs/beginner-s-corner/4023801/Introduction-to-the-Volatile-Keyword

* There is no reason to change the active report if it has not changed

* Declare local functions and variables static

This both helps the compiler and the programmer
2018-03-11 19:19:15 +01:00

45 lines
1.3 KiB
C

#ifndef __USB_INTERFACE_MEDIA_KEYBOARD_H__
#define __USB_INTERFACE_MEDIA_KEYBOARD_H__
// Includes:
#include "fsl_common.h"
#include "usb_api.h"
#include "usb_descriptors/usb_descriptor_media_keyboard_report.h"
// Macros:
#define USB_MEDIA_KEYBOARD_INTERFACE_INDEX 2
#define USB_MEDIA_KEYBOARD_INTERFACE_COUNT 1
#define USB_MEDIA_KEYBOARD_ENDPOINT_INDEX 4
#define USB_MEDIA_KEYBOARD_ENDPOINT_COUNT 1
#define USB_MEDIA_KEYBOARD_INTERRUPT_IN_PACKET_SIZE 8
#define USB_MEDIA_KEYBOARD_INTERRUPT_IN_INTERVAL 4
#define USB_MEDIA_KEYBOARD_REPORT_LENGTH 8
// Typedefs:
typedef struct {
uint16_t scancodes[USB_MEDIA_KEYBOARD_MAX_KEYS];
} ATTR_PACKED usb_media_keyboard_report_t;
// Variables:
extern volatile bool IsUsbMediaKeyboardReportSent;
extern uint32_t UsbMediaKeyboardActionCounter;
extern usb_media_keyboard_report_t* ActiveUsbMediaKeyboardReport;
// Functions:
usb_status_t UsbMediaKeyboardCallback(class_handle_t handle, uint32_t event, void *param);
usb_status_t UsbMediaKeyboardSetConfiguration(class_handle_t handle, uint8_t configuration);
usb_status_t UsbMediaKeyboardSetInterface(class_handle_t handle, uint8_t interface, uint8_t alternateSetting);
void ResetActiveUsbMediaKeyboardReport(void);
void SwitchActiveUsbMediaKeyboardReport(void);
#endif