Replace SET_DEBUG_BUFFER_UINT* macros with SetDebugBufferUint* functions for improved type safety and readability.
This commit is contained in:
@@ -3,15 +3,16 @@
|
||||
#include "usb_protocol_handler.h"
|
||||
#include "slave_scheduler.h"
|
||||
#include "i2c_watchdog.h"
|
||||
#include "buffer.h"
|
||||
|
||||
uint8_t DebugBuffer[USB_GENERIC_HID_OUT_BUFFER_LENGTH];
|
||||
|
||||
void UsbCommand_GetDebugBuffer(void)
|
||||
{
|
||||
SET_DEBUG_BUFFER_UINT32(1, I2C_Watchdog);
|
||||
SET_DEBUG_BUFFER_UINT32(5, I2cSlaveScheduler_Counter);
|
||||
SET_DEBUG_BUFFER_UINT32(9, I2cWatchdog_WatchCounter);
|
||||
SET_DEBUG_BUFFER_UINT32(13, I2cWatchdog_RecoveryCounter);
|
||||
SetDebugBufferUint32(1, I2C_Watchdog);
|
||||
SetDebugBufferUint32(5, I2cSlaveScheduler_Counter);
|
||||
SetDebugBufferUint32(9, I2cWatchdog_WatchCounter);
|
||||
SetDebugBufferUint32(13, I2cWatchdog_RecoveryCounter);
|
||||
|
||||
memcpy(GenericHidOutBuffer, DebugBuffer, USB_GENERIC_HID_OUT_BUFFER_LENGTH);
|
||||
|
||||
@@ -21,3 +22,18 @@ void UsbCommand_GetDebugBuffer(void)
|
||||
*(uint32_t*)(GenericHidOutBuffer+1) = ticks;
|
||||
*/
|
||||
}
|
||||
|
||||
void SetDebugBufferUint8(uint32_t offset, uint8_t value)
|
||||
{
|
||||
SetBufferUint8(DebugBuffer, offset, value);
|
||||
}
|
||||
|
||||
void SetDebugBufferUint16(uint32_t offset, uint16_t value)
|
||||
{
|
||||
SetBufferUint16(DebugBuffer, offset, value);
|
||||
}
|
||||
|
||||
void SetDebugBufferUint32(uint32_t offset, uint32_t value)
|
||||
{
|
||||
SetBufferUint32(DebugBuffer, offset, value);
|
||||
}
|
||||
|
||||
@@ -5,12 +5,6 @@
|
||||
|
||||
#include "usb_interfaces/usb_interface_generic_hid.h"
|
||||
|
||||
// Macros:
|
||||
|
||||
#define SET_DEBUG_BUFFER_UINT8(offset, value) (*(uint8_t*)(DebugBuffer+(offset)) = (value))
|
||||
#define SET_DEBUG_BUFFER_UINT16(offset, value) (*(uint16_t*)(DebugBuffer+(offset)) = (value))
|
||||
#define SET_DEBUG_BUFFER_UINT32(offset, value) (*(uint32_t*)(DebugBuffer+(offset)) = (value))
|
||||
|
||||
// Variables:
|
||||
|
||||
extern uint8_t DebugBuffer[USB_GENERIC_HID_OUT_BUFFER_LENGTH];
|
||||
@@ -19,4 +13,8 @@
|
||||
|
||||
void UsbCommand_GetDebugBuffer(void);
|
||||
|
||||
void SetDebugBufferUint8(uint32_t offset, uint8_t value);
|
||||
void SetDebugBufferUint16(uint32_t offset, uint16_t value);
|
||||
void SetDebugBufferUint32(uint32_t offset, uint32_t value);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "i2c.h"
|
||||
#include "peripherals/reset_button.h"
|
||||
#include "key_action.h"
|
||||
#include "buffer.h"
|
||||
#include "usb_commands/usb_command_get_debug_buffer.h"
|
||||
|
||||
static usb_device_endpoint_struct_t UsbMouseEndpoints[USB_MOUSE_ENDPOINT_COUNT] = {{
|
||||
@@ -65,8 +66,8 @@ static volatile usb_status_t usbMouseAction(void)
|
||||
{
|
||||
count3++;
|
||||
usb_mouse_report_t *mouseReport = getInactiveUsbMouseReport();
|
||||
SET_DEBUG_BUFFER_UINT32(29, mouseReport->x);
|
||||
SET_DEBUG_BUFFER_UINT32(31, mouseReport->y);
|
||||
SetDebugBufferUint16(29, mouseReport->x);
|
||||
SetDebugBufferUint16(31, mouseReport->y);
|
||||
IsUsbMouseReportSent = true;
|
||||
return USB_DeviceHidSend(UsbCompositeDevice.mouseHandle, USB_MOUSE_ENDPOINT_INDEX,
|
||||
(uint8_t*)mouseReport, USB_MOUSE_REPORT_LENGTH);
|
||||
@@ -74,9 +75,9 @@ static volatile usb_status_t usbMouseAction(void)
|
||||
|
||||
usb_status_t UsbMouseCallback(class_handle_t handle, uint32_t event, void *param)
|
||||
{
|
||||
SET_DEBUG_BUFFER_UINT32(17, count1);
|
||||
SET_DEBUG_BUFFER_UINT32(21, count2);
|
||||
SET_DEBUG_BUFFER_UINT32(25, count3);
|
||||
SetDebugBufferUint32(17, count1);
|
||||
SetDebugBufferUint32(21, count2);
|
||||
SetDebugBufferUint32(25, count3);
|
||||
|
||||
count1++;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user