Code changes to remove a bunch of compiler warnings

replace/8f584ab8a8c821382b3382c56580ede74bf87cfc
Silvano Seva 2020-11-24 17:27:30 +01:00
rodzic 7a6f39ad26
commit 9ba2c79425
4 zmienionych plików z 16 dodań i 8 usunięć

Wyświetl plik

@ -59,8 +59,7 @@ enum keys
KEY_F9 = (1 << 27), /* Function button (device specific) */
KEY_F10 = (1 << 28), /* Function button (device specific) */
KEY_F11 = (1 << 29), /* Function button (device specific) */
KEY_F12 = (1 << 30), /* Function button (device specific) */
KEY_F13 = (1 << 31) /* Function button (device specific) */
KEY_F12 = (1 << 30) /* Function button (device specific) */
};
/**

Wyświetl plik

@ -29,6 +29,15 @@
#include "usb_core.h"
#include "usb_bsp.h"
/* Workaround to suppress -Wattributes warning */
struct __attribute__((packed, aligned(1))) T_UINT32_WRITE { uint32_t v; };
#define __UNALIGNED_UINT32_WRITE(addr, val) \
(void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
struct __attribute__((packed, aligned(1))) T_UINT32_READ { uint32_t v; };
#define __UNALIGNED_UINT32_READ(addr) \
(((const struct T_UINT32_READ *)(const void *)(addr))->v)
/** @addtogroup USB_OTG_DRIVER
* @{
@ -180,7 +189,7 @@ USB_OTG_STS USB_OTG_WritePacket(USB_OTG_CORE_HANDLE *pdev,
fifo = pdev->regs.DFIFO[ch_ep_num];
for (i = 0; i < count32b; i++, src+=4)
{
USB_OTG_WRITE_REG32( fifo, *((__packed uint32_t *)src) );
USB_OTG_WRITE_REG32( fifo, __UNALIGNED_UINT32_READ(src) );
}
}
return status;
@ -205,7 +214,7 @@ void *USB_OTG_ReadPacket(USB_OTG_CORE_HANDLE *pdev,
for ( i = 0; i < count32b; i++, dest += 4 )
{
*(__packed uint32_t *)dest = USB_OTG_READ_REG32(fifo);
__UNALIGNED_UINT32_WRITE(dest, USB_OTG_READ_REG32(fifo));
}
return ((void *)dest);

Wyświetl plik

@ -59,10 +59,10 @@ typedef struct _USBD_DCD_INT
uint8_t (* Resume) (USB_OTG_CORE_HANDLE *pdev);
uint8_t (* IsoINIncomplete) (USB_OTG_CORE_HANDLE *pdev);
uint8_t (* IsoOUTIncomplete) (USB_OTG_CORE_HANDLE *pdev);
#ifdef VBUS_SENSING_ENABLED
uint8_t (* DevConnected) (USB_OTG_CORE_HANDLE *pdev);
uint8_t (* DevDisconnected) (USB_OTG_CORE_HANDLE *pdev);
#endif
}USBD_DCD_INT_cb_TypeDef;
extern USBD_DCD_INT_cb_TypeDef *USBD_DCD_INT_fops;

Wyświetl plik

@ -826,7 +826,7 @@ void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len)
unicode[idx++] = *len;
unicode[idx++] = USB_DESC_TYPE_STRING;
while (*desc != NULL)
while (*desc != 0)
{
unicode[idx++] = *desc++;
unicode[idx++] = 0x00;
@ -844,7 +844,7 @@ static uint8_t USBD_GetLen(uint8_t *buf)
{
uint8_t len = 0;
while (*buf != NULL)
while (*buf != 0)
{
len++;
buf++;