1
0
Fork 0

Format code according to conventions (#16419)

This commit is contained in:
QMK Bot 2022-02-21 09:44:27 -08:00 committed by GitHub
parent 3290377918
commit 2f0dc0fb6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 320 additions and 329 deletions

View file

@ -125,11 +125,10 @@ uint8_t ps2_host_recv_response(void) {
// Command may take 25ms/20ms at most([5]p.46, [3]p.21)
// 250 * 100us(wait for start bit in ps2_host_recv)
uint8_t data = 0;
uint8_t try
= 250;
uint8_t try = 250;
do {
data = ps2_host_recv();
} while (try --&&ps2_error);
} while (try-- && ps2_error);
return data;
}

View file

@ -834,8 +834,7 @@ void register_code(uint8_t code) {
}
#endif
else if
IS_KEY(code) {
else if IS_KEY (code) {
// TODO: should push command_proc out of this block?
if (command_proc(code)) return;
@ -865,21 +864,19 @@ void register_code(uint8_t code) {
add_key(code);
send_keyboard_report();
}
}
else if
IS_MOD(code) {
} else if IS_MOD (code) {
add_mods(MOD_BIT(code));
send_keyboard_report();
}
#ifdef EXTRAKEY_ENABLE
else if
IS_SYSTEM(code) { host_system_send(KEYCODE2SYSTEM(code)); }
else if
IS_CONSUMER(code) { host_consumer_send(KEYCODE2CONSUMER(code)); }
else if IS_SYSTEM (code) {
host_system_send(KEYCODE2SYSTEM(code));
} else if IS_CONSUMER (code) {
host_consumer_send(KEYCODE2CONSUMER(code));
}
#endif
#ifdef MOUSEKEY_ENABLE
else if
IS_MOUSEKEY(code) {
else if IS_MOUSEKEY (code) {
mousekey_on(code);
mousekey_send();
}
@ -927,23 +924,19 @@ void unregister_code(uint8_t code) {
}
#endif
else if
IS_KEY(code) {
else if IS_KEY (code) {
del_key(code);
send_keyboard_report();
}
else if
IS_MOD(code) {
} else if IS_MOD (code) {
del_mods(MOD_BIT(code));
send_keyboard_report();
} else if IS_SYSTEM (code) {
host_system_send(0);
} else if IS_CONSUMER (code) {
host_consumer_send(0);
}
else if
IS_SYSTEM(code) { host_system_send(0); }
else if
IS_CONSUMER(code) { host_consumer_send(0); }
#ifdef MOUSEKEY_ENABLE
else if
IS_MOUSEKEY(code) {
else if IS_MOUSEKEY (code) {
mousekey_off(code);
mousekey_send();
}

View file

@ -43,7 +43,7 @@
*/
#ifndef UTILS_COMPILER_H_INCLUDED
# define UTILS_COMPILER_H_INCLUDED
#define UTILS_COMPILER_H_INCLUDED
/**
* \defgroup group_sam0_utils Compiler abstraction layer and code utilities
@ -54,17 +54,17 @@
* @{
*/
# if (defined __ICCARM__)
#if (defined __ICCARM__)
# include <intrinsics.h>
# endif
#endif
# include <stddef.h>
#include <stddef.h>
//#include <parts.h>
//#include <status_codes.h>
//#include <preprocessor.h>
//#include <io.h>
# ifndef __ASSEMBLY__
#ifndef __ASSEMBLY__
# include <stdio.h>
# include <stdbool.h>
@ -347,22 +347,22 @@ typedef struct {
/** @} */
# endif /* #ifndef __ASSEMBLY__ */
#endif /* #ifndef __ASSEMBLY__ */
/** \name Usual Constants
* @{ */
// kmod #define DISABLE 0
// kmod #define ENABLE 1
# ifndef __cplusplus
#ifndef __cplusplus
# if !defined(__bool_true_false_are_defined)
# define false 0
# define true 1
# endif
# endif
#endif
/** @} */
# ifndef __ASSEMBLY__
#ifndef __ASSEMBLY__
/** \name Optimization Control
* @{ */
@ -828,8 +828,8 @@ typedef struct {
*/
# define div_ceil(a, b) (((a) + (b)-1) / (b))
# endif /* #ifndef __ASSEMBLY__ */
# ifdef __ICCARM__
#endif /* #ifndef __ASSEMBLY__ */
#ifdef __ICCARM__
/** \name Compiler Keywords
*
* Port of some keywords from GCC to IAR Embedded Workbench.
@ -842,35 +842,35 @@ typedef struct {
/** @} */
# endif
#endif
# define FUNC_PTR void *
#define FUNC_PTR void *
/**
* \def unused
* \brief Marking \a v as a unused parameter or value.
*/
# define unused(v) \
#define unused(v) \
do { \
(void)(v); \
} while (0)
/* Define RAMFUNC attribute */
# if defined(__CC_ARM) /* Keil uVision 4 */
#if defined(__CC_ARM) /* Keil uVision 4 */
# define RAMFUNC __attribute__((section(".ramfunc")))
# elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */
#elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */
# define RAMFUNC __ramfunc
# elif defined(__GNUC__) /* GCC CS3 2009q3-68 */
#elif defined(__GNUC__) /* GCC CS3 2009q3-68 */
# define RAMFUNC __attribute__((section(".ramfunc")))
# endif
#endif
/* Define OPTIMIZE_HIGH attribute */
# if defined(__CC_ARM) /* Keil uVision 4 */
#if defined(__CC_ARM) /* Keil uVision 4 */
# define OPTIMIZE_HIGH _Pragma("O3")
# elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */
#elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */
# define OPTIMIZE_HIGH _Pragma("optimize=high")
# elif defined(__GNUC__) /* GCC CS3 2009q3-68 */
#elif defined(__GNUC__) /* GCC CS3 2009q3-68 */
# define OPTIMIZE_HIGH __attribute__((optimize("s")))
# endif
#endif
// kmod #define PASS 0
// kmod #define FAIL 1
// kmod #define LOW 0
@ -887,101 +887,101 @@ typedef uint64_t U64; //!< 64-bit unsigned integer.
typedef float F32; //!< 32-bit floating-point number.
typedef double F64; //!< 64-bit floating-point number.
# define MSB(u16) (((U8 *)&(u16))[1]) //!< Most significant byte of \a u16.
# define LSB(u16) (((U8 *)&(u16))[0]) //!< Least significant byte of \a u16.
#define MSB(u16) (((U8 *)&(u16))[1]) //!< Most significant byte of \a u16.
#define LSB(u16) (((U8 *)&(u16))[0]) //!< Least significant byte of \a u16.
# define MSH(u32) (((U16 *)&(u32))[1]) //!< Most significant half-word of \a u32.
# define LSH(u32) (((U16 *)&(u32))[0]) //!< Least significant half-word of \a u32.
# define MSB0W(u32) (((U8 *)&(u32))[3]) //!< Most significant byte of 1st rank of \a u32.
# define MSB1W(u32) (((U8 *)&(u32))[2]) //!< Most significant byte of 2nd rank of \a u32.
# define MSB2W(u32) (((U8 *)&(u32))[1]) //!< Most significant byte of 3rd rank of \a u32.
# define MSB3W(u32) (((U8 *)&(u32))[0]) //!< Most significant byte of 4th rank of \a u32.
# define LSB3W(u32) MSB0W(u32) //!< Least significant byte of 4th rank of \a u32.
# define LSB2W(u32) MSB1W(u32) //!< Least significant byte of 3rd rank of \a u32.
# define LSB1W(u32) MSB2W(u32) //!< Least significant byte of 2nd rank of \a u32.
# define LSB0W(u32) MSB3W(u32) //!< Least significant byte of 1st rank of \a u32.
#define MSH(u32) (((U16 *)&(u32))[1]) //!< Most significant half-word of \a u32.
#define LSH(u32) (((U16 *)&(u32))[0]) //!< Least significant half-word of \a u32.
#define MSB0W(u32) (((U8 *)&(u32))[3]) //!< Most significant byte of 1st rank of \a u32.
#define MSB1W(u32) (((U8 *)&(u32))[2]) //!< Most significant byte of 2nd rank of \a u32.
#define MSB2W(u32) (((U8 *)&(u32))[1]) //!< Most significant byte of 3rd rank of \a u32.
#define MSB3W(u32) (((U8 *)&(u32))[0]) //!< Most significant byte of 4th rank of \a u32.
#define LSB3W(u32) MSB0W(u32) //!< Least significant byte of 4th rank of \a u32.
#define LSB2W(u32) MSB1W(u32) //!< Least significant byte of 3rd rank of \a u32.
#define LSB1W(u32) MSB2W(u32) //!< Least significant byte of 2nd rank of \a u32.
#define LSB0W(u32) MSB3W(u32) //!< Least significant byte of 1st rank of \a u32.
# define MSW(u64) (((U32 *)&(u64))[1]) //!< Most significant word of \a u64.
# define LSW(u64) (((U32 *)&(u64))[0]) //!< Least significant word of \a u64.
# define MSH0(u64) (((U16 *)&(u64))[3]) //!< Most significant half-word of 1st rank of \a u64.
# define MSH1(u64) (((U16 *)&(u64))[2]) //!< Most significant half-word of 2nd rank of \a u64.
# define MSH2(u64) (((U16 *)&(u64))[1]) //!< Most significant half-word of 3rd rank of \a u64.
# define MSH3(u64) (((U16 *)&(u64))[0]) //!< Most significant half-word of 4th rank of \a u64.
# define LSH3(u64) MSH0(u64) //!< Least significant half-word of 4th rank of \a u64.
# define LSH2(u64) MSH1(u64) //!< Least significant half-word of 3rd rank of \a u64.
# define LSH1(u64) MSH2(u64) //!< Least significant half-word of 2nd rank of \a u64.
# define LSH0(u64) MSH3(u64) //!< Least significant half-word of 1st rank of \a u64.
# define MSB0D(u64) (((U8 *)&(u64))[7]) //!< Most significant byte of 1st rank of \a u64.
# define MSB1D(u64) (((U8 *)&(u64))[6]) //!< Most significant byte of 2nd rank of \a u64.
# define MSB2D(u64) (((U8 *)&(u64))[5]) //!< Most significant byte of 3rd rank of \a u64.
# define MSB3D(u64) (((U8 *)&(u64))[4]) //!< Most significant byte of 4th rank of \a u64.
# define MSB4D(u64) (((U8 *)&(u64))[3]) //!< Most significant byte of 5th rank of \a u64.
# define MSB5D(u64) (((U8 *)&(u64))[2]) //!< Most significant byte of 6th rank of \a u64.
# define MSB6D(u64) (((U8 *)&(u64))[1]) //!< Most significant byte of 7th rank of \a u64.
# define MSB7D(u64) (((U8 *)&(u64))[0]) //!< Most significant byte of 8th rank of \a u64.
# define LSB7D(u64) MSB0D(u64) //!< Least significant byte of 8th rank of \a u64.
# define LSB6D(u64) MSB1D(u64) //!< Least significant byte of 7th rank of \a u64.
# define LSB5D(u64) MSB2D(u64) //!< Least significant byte of 6th rank of \a u64.
# define LSB4D(u64) MSB3D(u64) //!< Least significant byte of 5th rank of \a u64.
# define LSB3D(u64) MSB4D(u64) //!< Least significant byte of 4th rank of \a u64.
# define LSB2D(u64) MSB5D(u64) //!< Least significant byte of 3rd rank of \a u64.
# define LSB1D(u64) MSB6D(u64) //!< Least significant byte of 2nd rank of \a u64.
# define LSB0D(u64) MSB7D(u64) //!< Least significant byte of 1st rank of \a u64.
#define MSW(u64) (((U32 *)&(u64))[1]) //!< Most significant word of \a u64.
#define LSW(u64) (((U32 *)&(u64))[0]) //!< Least significant word of \a u64.
#define MSH0(u64) (((U16 *)&(u64))[3]) //!< Most significant half-word of 1st rank of \a u64.
#define MSH1(u64) (((U16 *)&(u64))[2]) //!< Most significant half-word of 2nd rank of \a u64.
#define MSH2(u64) (((U16 *)&(u64))[1]) //!< Most significant half-word of 3rd rank of \a u64.
#define MSH3(u64) (((U16 *)&(u64))[0]) //!< Most significant half-word of 4th rank of \a u64.
#define LSH3(u64) MSH0(u64) //!< Least significant half-word of 4th rank of \a u64.
#define LSH2(u64) MSH1(u64) //!< Least significant half-word of 3rd rank of \a u64.
#define LSH1(u64) MSH2(u64) //!< Least significant half-word of 2nd rank of \a u64.
#define LSH0(u64) MSH3(u64) //!< Least significant half-word of 1st rank of \a u64.
#define MSB0D(u64) (((U8 *)&(u64))[7]) //!< Most significant byte of 1st rank of \a u64.
#define MSB1D(u64) (((U8 *)&(u64))[6]) //!< Most significant byte of 2nd rank of \a u64.
#define MSB2D(u64) (((U8 *)&(u64))[5]) //!< Most significant byte of 3rd rank of \a u64.
#define MSB3D(u64) (((U8 *)&(u64))[4]) //!< Most significant byte of 4th rank of \a u64.
#define MSB4D(u64) (((U8 *)&(u64))[3]) //!< Most significant byte of 5th rank of \a u64.
#define MSB5D(u64) (((U8 *)&(u64))[2]) //!< Most significant byte of 6th rank of \a u64.
#define MSB6D(u64) (((U8 *)&(u64))[1]) //!< Most significant byte of 7th rank of \a u64.
#define MSB7D(u64) (((U8 *)&(u64))[0]) //!< Most significant byte of 8th rank of \a u64.
#define LSB7D(u64) MSB0D(u64) //!< Least significant byte of 8th rank of \a u64.
#define LSB6D(u64) MSB1D(u64) //!< Least significant byte of 7th rank of \a u64.
#define LSB5D(u64) MSB2D(u64) //!< Least significant byte of 6th rank of \a u64.
#define LSB4D(u64) MSB3D(u64) //!< Least significant byte of 5th rank of \a u64.
#define LSB3D(u64) MSB4D(u64) //!< Least significant byte of 4th rank of \a u64.
#define LSB2D(u64) MSB5D(u64) //!< Least significant byte of 3rd rank of \a u64.
#define LSB1D(u64) MSB6D(u64) //!< Least significant byte of 2nd rank of \a u64.
#define LSB0D(u64) MSB7D(u64) //!< Least significant byte of 1st rank of \a u64.
# define LSB0(u32) LSB0W(u32) //!< Least significant byte of 1st rank of \a u32.
# define LSB1(u32) LSB1W(u32) //!< Least significant byte of 2nd rank of \a u32.
# define LSB2(u32) LSB2W(u32) //!< Least significant byte of 3rd rank of \a u32.
# define LSB3(u32) LSB3W(u32) //!< Least significant byte of 4th rank of \a u32.
# define MSB3(u32) MSB3W(u32) //!< Most significant byte of 4th rank of \a u32.
# define MSB2(u32) MSB2W(u32) //!< Most significant byte of 3rd rank of \a u32.
# define MSB1(u32) MSB1W(u32) //!< Most significant byte of 2nd rank of \a u32.
# define MSB0(u32) MSB0W(u32) //!< Most significant byte of 1st rank of \a u32.
#define LSB0(u32) LSB0W(u32) //!< Least significant byte of 1st rank of \a u32.
#define LSB1(u32) LSB1W(u32) //!< Least significant byte of 2nd rank of \a u32.
#define LSB2(u32) LSB2W(u32) //!< Least significant byte of 3rd rank of \a u32.
#define LSB3(u32) LSB3W(u32) //!< Least significant byte of 4th rank of \a u32.
#define MSB3(u32) MSB3W(u32) //!< Most significant byte of 4th rank of \a u32.
#define MSB2(u32) MSB2W(u32) //!< Most significant byte of 3rd rank of \a u32.
#define MSB1(u32) MSB1W(u32) //!< Most significant byte of 2nd rank of \a u32.
#define MSB0(u32) MSB0W(u32) //!< Most significant byte of 1st rank of \a u32.
# if defined(__ICCARM__)
#if defined(__ICCARM__)
# define SHORTENUM __packed
# elif defined(__GNUC__)
#elif defined(__GNUC__)
# define SHORTENUM __attribute__((packed))
# endif
#endif
/* No operation */
# if defined(__ICCARM__)
#if defined(__ICCARM__)
# define nop() __no_operation()
# elif defined(__GNUC__)
#elif defined(__GNUC__)
# define nop() (__NOP())
# endif
#endif
# define FLASH_DECLARE(x) const x
# define FLASH_EXTERN(x) extern const x
# define PGM_READ_BYTE(x) *(x)
# define PGM_READ_WORD(x) *(x)
# define MEMCPY_ENDIAN memcpy
# define PGM_READ_BLOCK(dst, src, len) memcpy((dst), (src), (len))
#define FLASH_DECLARE(x) const x
#define FLASH_EXTERN(x) extern const x
#define PGM_READ_BYTE(x) *(x)
#define PGM_READ_WORD(x) *(x)
#define MEMCPY_ENDIAN memcpy
#define PGM_READ_BLOCK(dst, src, len) memcpy((dst), (src), (len))
/*Defines the Flash Storage for the request and response of MAC*/
# define CMD_ID_OCTET (0)
#define CMD_ID_OCTET (0)
/* Converting of values from CPU endian to little endian. */
# define CPU_ENDIAN_TO_LE16(x) (x)
# define CPU_ENDIAN_TO_LE32(x) (x)
# define CPU_ENDIAN_TO_LE64(x) (x)
#define CPU_ENDIAN_TO_LE16(x) (x)
#define CPU_ENDIAN_TO_LE32(x) (x)
#define CPU_ENDIAN_TO_LE64(x) (x)
/* Converting of values from little endian to CPU endian. */
# define LE16_TO_CPU_ENDIAN(x) (x)
# define LE32_TO_CPU_ENDIAN(x) (x)
# define LE64_TO_CPU_ENDIAN(x) (x)
#define LE16_TO_CPU_ENDIAN(x) (x)
#define LE32_TO_CPU_ENDIAN(x) (x)
#define LE64_TO_CPU_ENDIAN(x) (x)
/* Converting of constants from little endian to CPU endian. */
# define CLE16_TO_CPU_ENDIAN(x) (x)
# define CLE32_TO_CPU_ENDIAN(x) (x)
# define CLE64_TO_CPU_ENDIAN(x) (x)
#define CLE16_TO_CPU_ENDIAN(x) (x)
#define CLE32_TO_CPU_ENDIAN(x) (x)
#define CLE64_TO_CPU_ENDIAN(x) (x)
/* Converting of constants from CPU endian to little endian. */
# define CCPU_ENDIAN_TO_LE16(x) (x)
# define CCPU_ENDIAN_TO_LE32(x) (x)
# define CCPU_ENDIAN_TO_LE64(x) (x)
#define CCPU_ENDIAN_TO_LE16(x) (x)
#define CCPU_ENDIAN_TO_LE32(x) (x)
#define CCPU_ENDIAN_TO_LE64(x) (x)
# define ADDR_COPY_DST_SRC_16(dst, src) ((dst) = (src))
# define ADDR_COPY_DST_SRC_64(dst, src) ((dst) = (src))
#define ADDR_COPY_DST_SRC_16(dst, src) ((dst) = (src))
#define ADDR_COPY_DST_SRC_64(dst, src) ((dst) = (src))
/**
* @brief Converts a 64-Bit value into a 8 Byte array

View file

@ -596,11 +596,10 @@ void udd_set_address(uint8_t address) { usb_device_set_address(&usb_device, addr
uint8_t udd_getaddress(void) { return usb_device_get_address(&usb_device); }
void udd_send_remotewakeup(void) {
uint32_t try
= 5;
uint32_t try = 5;
udd_wait_clock_ready();
udd_sleep_mode(UDD_STATE_IDLE);
while (2 != usb_get_state_machine_status(&usb_device) && try --) {
while (2 != usb_get_state_machine_status(&usb_device) && try--) {
usb_device_send_remote_wake_up(&usb_device);
}
}