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
This commit is contained in:
Kristian Sloth Lauszus
2018-03-11 19:19:15 +01:00
committed by László Monda
parent 1742437f8b
commit e12e219b4e
17 changed files with 69 additions and 52 deletions

View File

@@ -3,9 +3,9 @@
uint32_t UsbMediaKeyboardActionCounter;
static usb_media_keyboard_report_t usbMediaKeyboardReports[2];
usb_media_keyboard_report_t* ActiveUsbMediaKeyboardReport = usbMediaKeyboardReports;
bool IsUsbMediaKeyboardReportSent = false;
volatile bool IsUsbMediaKeyboardReportSent = false;
usb_media_keyboard_report_t* getInactiveUsbMediaKeyboardReport(void)
static usb_media_keyboard_report_t* getInactiveUsbMediaKeyboardReport(void)
{
return ActiveUsbMediaKeyboardReport == usbMediaKeyboardReports ? usbMediaKeyboardReports+1 : usbMediaKeyboardReports;
}