summaryrefslogtreecommitdiff
path: root/tmk_core/protocol/arm_atsam/usb
diff options
context:
space:
mode:
authorskullY <skullydazed@gmail.com>2019-08-30 11:19:03 -0700
committerFlorian Didron <fdidron@users.noreply.github.com>2019-09-17 11:39:43 +0900
commitf8fe33acfac01064112fd2b5da680abfb5190b97 (patch)
treefcf75ef930800a948e5a3ba015d6759889f2284d /tmk_core/protocol/arm_atsam/usb
parentc339d670684674165b422a0168bfd2016ff2e6ef (diff)
clang-format changes
Diffstat (limited to 'tmk_core/protocol/arm_atsam/usb')
-rw-r--r--tmk_core/protocol/arm_atsam/usb/compiler.h934
-rw-r--r--tmk_core/protocol/arm_atsam/usb/conf_usb.h73
-rw-r--r--tmk_core/protocol/arm_atsam/usb/main_usb.c74
-rw-r--r--tmk_core/protocol/arm_atsam/usb/status_codes.h98
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udc.c651
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udc.h26
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udc_desc.h29
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udd.h40
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi.h96
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_cdc.c857
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_cdc.h58
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_cdc_conf.h16
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_device_conf.h654
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_device_epsize.h21
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_hid.c82
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_hid.h4
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c789
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h48
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_conf.h2
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_desc.c108
-rw-r--r--tmk_core/protocol/arm_atsam/usb/ui.c39
-rw-r--r--tmk_core/protocol/arm_atsam/usb/ui.h2
-rw-r--r--tmk_core/protocol/arm_atsam/usb/usb.c345
-rw-r--r--tmk_core/protocol/arm_atsam/usb/usb.h110
-rw-r--r--tmk_core/protocol/arm_atsam/usb/usb2422.c366
-rw-r--r--tmk_core/protocol/arm_atsam/usb/usb2422.h384
-rw-r--r--tmk_core/protocol/arm_atsam/usb/usb_atmel.h181
-rw-r--r--tmk_core/protocol/arm_atsam/usb/usb_device_udd.c386
-rw-r--r--tmk_core/protocol/arm_atsam/usb/usb_main.h51
-rw-r--r--tmk_core/protocol/arm_atsam/usb/usb_protocol.h252
-rw-r--r--tmk_core/protocol/arm_atsam/usb/usb_protocol_cdc.h215
-rw-r--r--tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h383
-rw-r--r--tmk_core/protocol/arm_atsam/usb/usb_util.c54
-rw-r--r--tmk_core/protocol/arm_atsam/usb/usb_util.h3
34 files changed, 3200 insertions, 4231 deletions
diff --git a/tmk_core/protocol/arm_atsam/usb/compiler.h b/tmk_core/protocol/arm_atsam/usb/compiler.h
index b2ccfd73ed..6ba2322340 100644
--- a/tmk_core/protocol/arm_atsam/usb/compiler.h
+++ b/tmk_core/protocol/arm_atsam/usb/compiler.h
@@ -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,38 +54,38 @@
* @{
*/
-#if (defined __ICCARM__)
-# include <intrinsics.h>
-#endif
+# if (defined __ICCARM__)
+# include <intrinsics.h>
+# 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>
-#include <stdint.h>
-#include <stdlib.h>
+# include <stdio.h>
+# include <stdbool.h>
+# include <stdint.h>
+# include <stdlib.h>
/**
* \def UNUSED
* \brief Marking \a v as a unused parameter or value.
*/
-#define UNUSED(v) (void)(v)
+# define UNUSED(v) (void)(v)
/**
* \def barrier
* \brief Memory barrier
*/
-#ifdef __GNUC__
-# define barrier() asm volatile("" ::: "memory")
-#else
-# define barrier() asm ("")
-#endif
+# ifdef __GNUC__
+# define barrier() asm volatile("" ::: "memory")
+# else
+# define barrier() asm("")
+# endif
/**
* \brief Emit the compiler pragma \a arg.
@@ -93,38 +93,37 @@
* \param[in] arg The pragma directive as it would appear after \e \#pragma
* (i.e. not stringified).
*/
-#define COMPILER_PRAGMA(arg) _Pragma(#arg)
+# define COMPILER_PRAGMA(arg) _Pragma(# arg)
/**
* \def COMPILER_PACK_SET(alignment)
* \brief Set maximum alignment for subsequent struct and union definitions to \a alignment.
*/
-#define COMPILER_PACK_SET(alignment) COMPILER_PRAGMA(pack(alignment))
+# define COMPILER_PACK_SET(alignment) COMPILER_PRAGMA(pack(alignment))
/**
* \def COMPILER_PACK_RESET()
* \brief Set default alignment for subsequent struct and union definitions.
*/
-#define COMPILER_PACK_RESET() COMPILER_PRAGMA(pack())
-
+# define COMPILER_PACK_RESET() COMPILER_PRAGMA(pack())
/**
* \brief Set aligned boundary.
*/
-#if (defined __GNUC__) || (defined __CC_ARM)
-# define COMPILER_ALIGNED(a) __attribute__((__aligned__(a)))
-#elif (defined __ICCARM__)
-# define COMPILER_ALIGNED(a) COMPILER_PRAGMA(data_alignment = a)
-#endif
+# if (defined __GNUC__) || (defined __CC_ARM)
+# define COMPILER_ALIGNED(a) __attribute__((__aligned__(a)))
+# elif (defined __ICCARM__)
+# define COMPILER_ALIGNED(a) COMPILER_PRAGMA(data_alignment = a)
+# endif
/**
* \brief Set word-aligned boundary.
*/
-#if (defined __GNUC__) || defined(__CC_ARM)
-#define COMPILER_WORD_ALIGNED __attribute__((__aligned__(4)))
-#elif (defined __ICCARM__)
-#define COMPILER_WORD_ALIGNED COMPILER_PRAGMA(data_alignment = 4)
-#endif
+# if (defined __GNUC__) || defined(__CC_ARM)
+# define COMPILER_WORD_ALIGNED __attribute__((__aligned__(4)))
+# elif (defined __ICCARM__)
+# define COMPILER_WORD_ALIGNED COMPILER_PRAGMA(data_alignment = 4)
+# endif
/**
* \def __always_inline
@@ -134,15 +133,15 @@
* heuristics and inline the function no matter how big it thinks it
* becomes.
*/
-#if !defined(__always_inline)
-#if defined(__CC_ARM)
-# define __always_inline __forceinline
-#elif (defined __GNUC__)
-# define __always_inline __attribute__((__always_inline__))
-#elif (defined __ICCARM__)
-# define __always_inline _Pragma("inline=forced")
-#endif
-#endif
+# if !defined(__always_inline)
+# if defined(__CC_ARM)
+# define __always_inline __forceinline
+# elif (defined __GNUC__)
+# define __always_inline __attribute__((__always_inline__))
+# elif (defined __ICCARM__)
+# define __always_inline _Pragma("inline=forced")
+# endif
+# endif
/**
* \def __no_inline
@@ -152,14 +151,13 @@
* heuristics and not inline the function no matter how small it thinks it
* becomes.
*/
-#if defined(__CC_ARM)
-# define __no_inline __attribute__((noinline))
-#elif (defined __GNUC__)
-# define __no_inline __attribute__((noinline))
-#elif (defined __ICCARM__)
-# define __no_inline _Pragma("inline=never")
-#endif
-
+# if defined(__CC_ARM)
+# define __no_inline __attribute__((noinline))
+# elif (defined __GNUC__)
+# define __no_inline __attribute__((noinline))
+# elif (defined __ICCARM__)
+# define __no_inline _Pragma("inline=never")
+# endif
/** \brief This macro is used to test fatal errors.
*
@@ -170,212 +168,201 @@
*
* \param[in] expr Expression to evaluate and supposed to be nonzero.
*/
-#if defined(_ASSERT_ENABLE_)
-# if defined(TEST_SUITE_DEFINE_ASSERT_MACRO)
-# include "unit_test/suite.h"
-# else
-# undef TEST_SUITE_DEFINE_ASSERT_MACRO
-# define Assert(expr) \
- {\
- if (!(expr)) asm("BKPT #0");\
- }
-# endif
-#else
-# define Assert(expr) ((void) 0)
-#endif
+# if defined(_ASSERT_ENABLE_)
+# if defined(TEST_SUITE_DEFINE_ASSERT_MACRO)
+# include "unit_test/suite.h"
+# else
+# undef TEST_SUITE_DEFINE_ASSERT_MACRO
+# define Assert(expr) \
+ { \
+ if (!(expr)) asm("BKPT #0"); \
+ }
+# endif
+# else
+# define Assert(expr) ((void)0)
+# endif
/* Define WEAK attribute */
-#if defined ( __CC_ARM )
-# define WEAK __attribute__ ((weak))
-#elif defined ( __ICCARM__ )
-# define WEAK __weak
-#elif defined ( __GNUC__ )
-# define WEAK __attribute__ ((weak))
-#endif
+# if defined(__CC_ARM)
+# define WEAK __attribute__((weak))
+# elif defined(__ICCARM__)
+# define WEAK __weak
+# elif defined(__GNUC__)
+# define WEAK __attribute__((weak))
+# endif
/* Define NO_INIT attribute */
-#if defined ( __CC_ARM )
-# define NO_INIT __attribute__((zero_init))
-#elif defined ( __ICCARM__ )
-# define NO_INIT __no_init
-#elif defined ( __GNUC__ )
-# define NO_INIT __attribute__((section(".no_init")))
-#endif
+# if defined(__CC_ARM)
+# define NO_INIT __attribute__((zero_init))
+# elif defined(__ICCARM__)
+# define NO_INIT __no_init
+# elif defined(__GNUC__)
+# define NO_INIT __attribute__((section(".no_init")))
+# endif
//#include "interrupt.h"
/** \name Usual Types
* @{ */
-#ifndef __cplusplus
-# if !defined(__bool_true_false_are_defined)
-typedef unsigned char bool;
-# endif
-#endif
-typedef uint16_t le16_t;
-typedef uint16_t be16_t;
-typedef uint32_t le32_t;
-typedef uint32_t be32_t;
-typedef uint32_t iram_size_t;
+# ifndef __cplusplus
+# if !defined(__bool_true_false_are_defined)
+typedef unsigned char bool;
+# endif
+# endif
+typedef uint16_t le16_t;
+typedef uint16_t be16_t;
+typedef uint32_t le32_t;
+typedef uint32_t be32_t;
+typedef uint32_t iram_size_t;
/** @} */
/** \name Aliasing Aggregate Types
* @{ */
/** 16-bit union. */
-typedef union
-{
- int16_t s16;
- uint16_t u16;
- int8_t s8[2];
- uint8_t u8[2];
+typedef union {
+ int16_t s16;
+ uint16_t u16;
+ int8_t s8[2];
+ uint8_t u8[2];
} Union16;
/** 32-bit union. */
-typedef union
-{
- int32_t s32;
- uint32_t u32;
- int16_t s16[2];
- uint16_t u16[2];
- int8_t s8[4];
- uint8_t u8[4];
+typedef union {
+ int32_t s32;
+ uint32_t u32;
+ int16_t s16[2];
+ uint16_t u16[2];
+ int8_t s8[4];
+ uint8_t u8[4];
} Union32;
/** 64-bit union. */
-typedef union
-{
- int64_t s64;
- uint64_t u64;
- int32_t s32[2];
- uint32_t u32[2];
- int16_t s16[4];
- uint16_t u16[4];
- int8_t s8[8];
- uint8_t u8[8];
+typedef union {
+ int64_t s64;
+ uint64_t u64;
+ int32_t s32[2];
+ uint32_t u32[2];
+ int16_t s16[4];
+ uint16_t u16[4];
+ int8_t s8[8];
+ uint8_t u8[8];
} Union64;
/** Union of pointers to 64-, 32-, 16- and 8-bit unsigned integers. */
-typedef union
-{
- int64_t *s64ptr;
- uint64_t *u64ptr;
- int32_t *s32ptr;
- uint32_t *u32ptr;
- int16_t *s16ptr;
- uint16_t *u16ptr;
- int8_t *s8ptr;
- uint8_t *u8ptr;
+typedef union {
+ int64_t * s64ptr;
+ uint64_t *u64ptr;
+ int32_t * s32ptr;
+ uint32_t *u32ptr;
+ int16_t * s16ptr;
+ uint16_t *u16ptr;
+ int8_t * s8ptr;
+ uint8_t * u8ptr;
} UnionPtr;
/** Union of pointers to volatile 64-, 32-, 16- and 8-bit unsigned integers. */
-typedef union
-{
- volatile int64_t *s64ptr;
- volatile uint64_t *u64ptr;
- volatile int32_t *s32ptr;
- volatile uint32_t *u32ptr;
- volatile int16_t *s16ptr;
- volatile uint16_t *u16ptr;
- volatile int8_t *s8ptr;
- volatile uint8_t *u8ptr;
+typedef union {
+ volatile int64_t * s64ptr;
+ volatile uint64_t *u64ptr;
+ volatile int32_t * s32ptr;
+ volatile uint32_t *u32ptr;
+ volatile int16_t * s16ptr;
+ volatile uint16_t *u16ptr;
+ volatile int8_t * s8ptr;
+ volatile uint8_t * u8ptr;
} UnionVPtr;
/** Union of pointers to constant 64-, 32-, 16- and 8-bit unsigned integers. */
-typedef union
-{
- const int64_t *s64ptr;
- const uint64_t *u64ptr;
- const int32_t *s32ptr;
- const uint32_t *u32ptr;
- const int16_t *s16ptr;
- const uint16_t *u16ptr;
- const int8_t *s8ptr;
- const uint8_t *u8ptr;
+typedef union {
+ const int64_t * s64ptr;
+ const uint64_t *u64ptr;
+ const int32_t * s32ptr;
+ const uint32_t *u32ptr;
+ const int16_t * s16ptr;
+ const uint16_t *u16ptr;
+ const int8_t * s8ptr;
+ const uint8_t * u8ptr;
} UnionCPtr;
/** Union of pointers to constant volatile 64-, 32-, 16- and 8-bit unsigned integers. */
-typedef union
-{
- const volatile int64_t *s64ptr;
- const volatile uint64_t *u64ptr;
- const volatile int32_t *s32ptr;
- const volatile uint32_t *u32ptr;
- const volatile int16_t *s16ptr;
- const volatile uint16_t *u16ptr;
- const volatile int8_t *s8ptr;
- const volatile uint8_t *u8ptr;
+typedef union {
+ const volatile int64_t * s64ptr;
+ const volatile uint64_t *u64ptr;
+ const volatile int32_t * s32ptr;
+ const volatile uint32_t *u32ptr;
+ const volatile int16_t * s16ptr;
+ const volatile uint16_t *u16ptr;
+ const volatile int8_t * s8ptr;
+ const volatile uint8_t * u8ptr;
} UnionCVPtr;
/** Structure of pointers to 64-, 32-, 16- and 8-bit unsigned integers. */
-typedef struct
-{
- int64_t *s64ptr;
- uint64_t *u64ptr;
- int32_t *s32ptr;
- uint32_t *u32ptr;
- int16_t *s16ptr;
- uint16_t *u16ptr;
- int8_t *s8ptr;
- uint8_t *u8ptr;
+typedef struct {
+ int64_t * s64ptr;
+ uint64_t *u64ptr;
+ int32_t * s32ptr;
+ uint32_t *u32ptr;
+ int16_t * s16ptr;
+ uint16_t *u16ptr;
+ int8_t * s8ptr;
+ uint8_t * u8ptr;
} StructPtr;
/** Structure of pointers to volatile 64-, 32-, 16- and 8-bit unsigned integers. */
-typedef struct
-{
- volatile int64_t *s64ptr;
- volatile uint64_t *u64ptr;
- volatile int32_t *s32ptr;
- volatile uint32_t *u32ptr;
- volatile int16_t *s16ptr;
- volatile uint16_t *u16ptr;
- volatile int8_t *s8ptr;
- volatile uint8_t *u8ptr;
+typedef struct {
+ volatile int64_t * s64ptr;
+ volatile uint64_t *u64ptr;
+ volatile int32_t * s32ptr;
+ volatile uint32_t *u32ptr;
+ volatile int16_t * s16ptr;
+ volatile uint16_t *u16ptr;
+ volatile int8_t * s8ptr;
+ volatile uint8_t * u8ptr;
} StructVPtr;
/** Structure of pointers to constant 64-, 32-, 16- and 8-bit unsigned integers. */
-typedef struct
-{
- const int64_t *s64ptr;
- const uint64_t *u64ptr;
- const int32_t *s32ptr;
- const uint32_t *u32ptr;
- const int16_t *s16ptr;
- const uint16_t *u16ptr;
- const int8_t *s8ptr;
- const uint8_t *u8ptr;
+typedef struct {
+ const int64_t * s64ptr;
+ const uint64_t *u64ptr;
+ const int32_t * s32ptr;
+ const uint32_t *u32ptr;
+ const int16_t * s16ptr;
+ const uint16_t *u16ptr;
+ const int8_t * s8ptr;
+ const uint8_t * u8ptr;
} StructCPtr;
/** Structure of pointers to constant volatile 64-, 32-, 16- and 8-bit unsigned integers. */
-typedef struct
-{
- const volatile int64_t *s64ptr;
- const volatile uint64_t *u64ptr;
- const volatile int32_t *s32ptr;
- const volatile uint32_t *u32ptr;
- const volatile int16_t *s16ptr;
- const volatile uint16_t *u16ptr;
- const volatile int8_t *s8ptr;
- const volatile uint8_t *u8ptr;
+typedef struct {
+ const volatile int64_t * s64ptr;
+ const volatile uint64_t *u64ptr;
+ const volatile int32_t * s32ptr;
+ const volatile uint32_t *u32ptr;
+ const volatile int16_t * s16ptr;
+ const volatile uint16_t *u16ptr;
+ const volatile int8_t * s8ptr;
+ const volatile uint8_t * u8ptr;
} StructCVPtr;
/** @} */
-#endif /* #ifndef __ASSEMBLY__ */
+# endif /* #ifndef __ASSEMBLY__ */
/** \name Usual Constants
* @{ */
-//kmod #define DISABLE 0
-//kmod #define ENABLE 1
-
-#ifndef __cplusplus
-# if !defined(__bool_true_false_are_defined)
-# define false 0
-# define true 1
-# endif
-#endif
+// kmod #define DISABLE 0
+// kmod #define ENABLE 1
+
+# ifndef __cplusplus
+# if !defined(__bool_true_false_are_defined)
+# define false 0
+# define true 1
+# endif
+# endif
/** @} */
-#ifndef __ASSEMBLY__
+# ifndef __ASSEMBLY__
/** \name Optimization Control
* @{ */
@@ -384,17 +371,17 @@ typedef struct
* \def likely(exp)
* \brief The expression \a exp is likely to be true
*/
-#if !defined(likely) || defined(__DOXYGEN__)
-# define likely(exp) (exp)
-#endif
+# if !defined(likely) || defined(__DOXYGEN__)
+# define likely(exp) (exp)
+# endif
/**
* \def unlikely(exp)
* \brief The expression \a exp is unlikely to be true
*/
-#if !defined(unlikely) || defined(__DOXYGEN__)
-# define unlikely(exp) (exp)
-#endif
+# if !defined(unlikely) || defined(__DOXYGEN__)
+# define unlikely(exp) (exp)
+# endif
/**
* \def is_constant(exp)
@@ -404,11 +391,11 @@ typedef struct
*
* \return true if \a exp is constant, false otherwise.
*/
-#if (defined __GNUC__) || (defined __CC_ARM)
-# define is_constant(exp) __builtin_constant_p(exp)
-#else
-# define is_constant(exp) (0)
-#endif
+# if (defined __GNUC__) || (defined __CC_ARM)
+# define is_constant(exp) __builtin_constant_p(exp)
+# else
+# define is_constant(exp) (0)
+# endif
/** @} */
@@ -422,7 +409,7 @@ typedef struct
*
* \return Read bits.
*/
-#define Rd_bits( value, mask) ((value) & (mask))
+# define Rd_bits(value, mask) ((value) & (mask))
/** \brief Writes the bits of a C lvalue specified by a given bit-mask.
*
@@ -432,8 +419,7 @@ typedef struct
*
* \return Resulting value with written bits.
*/
-#define Wr_bits(lvalue, mask, bits) ((lvalue) = ((lvalue) & ~(mask)) |\
- ((bits ) & (mask)))
+# define Wr_bits(lvalue, mask, bits) ((lvalue) = ((lvalue) & ~(mask)) | ((bits) & (mask)))
/** \brief Tests the bits of a value specified by a given bit-mask.
*
@@ -442,7 +428,7 @@ typedef struct
*
* \return \c 1 if at least one of the tested bits is set, else \c 0.
*/
-#define Tst_bits( value, mask) (Rd_bits(value, mask) != 0)
+# define Tst_bits(value, mask) (Rd_bits(value, mask) != 0)
/** \brief Clears the bits of a C lvalue specified by a given bit-mask.
*
@@ -451,7 +437,7 @@ typedef struct
*
* \return Resulting value with cleared bits.
*/
-#define Clr_bits(lvalue, mask) ((lvalue) &= ~(mask))
+# define Clr_bits(lvalue, mask) ((lvalue) &= ~(mask))
/** \brief Sets the bits of a C lvalue specified by a given bit-mask.
*
@@ -460,7 +446,7 @@ typedef struct
*
* \return Resulting value with set bits.
*/
-#define Set_bits(lvalue, mask) ((lvalue) |= (mask))
+# define Set_bits(lvalue, mask) ((lvalue) |= (mask))
/** \brief Toggles the bits of a C lvalue specified by a given bit-mask.
*
@@ -469,7 +455,7 @@ typedef struct
*
* \return Resulting value with toggled bits.
*/
-#define Tgl_bits(lvalue, mask) ((lvalue) ^= (mask))
+# define Tgl_bits(lvalue, mask) ((lvalue) ^= (mask))
/** \brief Reads the bit-field of a value specified by a given bit-mask.
*
@@ -478,7 +464,7 @@ typedef struct
*
* \return Read bit-field.
*/
-#define Rd_bitfield( value, mask) (Rd_bits( value, mask) >> ctz(mask))
+# define Rd_bitfield(value, mask) (Rd_bits(value, mask) >> ctz(mask))
/** \brief Writes the bit-field of a C lvalue specified by a given bit-mask.
*
@@ -488,11 +474,10 @@ typedef struct
*
* \return Resulting value with written bit-field.
*/
-#define Wr_bitfield(lvalue, mask, bitfield) (Wr_bits(lvalue, mask, (uint32_t)(bitfield) << ctz(mask)))
+# define Wr_bitfield(lvalue, mask, bitfield) (Wr_bits(lvalue, mask, (uint32_t)(bitfield) << ctz(mask)))
/** @} */
-
/** \name Zero-Bit Counting
*
* Under GCC, __builtin_clz and __builtin_ctz behave like macros when
@@ -513,43 +498,11 @@ typedef struct
*
* \return The count of leading zero bits in \a u.
*/
-#if (defined __GNUC__) || (defined __CC_ARM)
-# define clz(u) ((u) ? __builtin_clz(u) : 32)
-#else
-# define clz(u) (((u) == 0) ? 32 : \
- ((u) & (1ul << 31)) ? 0 : \
- ((u) & (1ul << 30)) ? 1 : \
- ((u) & (1ul << 29)) ? 2 : \
- ((u) & (1ul << 28)) ? 3 : \
- ((u) & (1ul << 27)) ? 4 : \
- ((u) & (1ul << 26)) ? 5 : \
- ((u) & (1ul << 25)) ? 6 : \
- ((u) & (1ul << 24)) ? 7 : \
- ((u) & (1ul << 23)) ? 8 : \
- ((u) & (1ul << 22)) ? 9 : \
- ((u) & (1ul << 21)) ? 10 : \
- ((u) & (1ul << 20)) ? 11 : \
- ((u) & (1ul << 19)) ? 12 : \
- ((u) & (1ul << 18)) ? 13 : \
- ((u) & (1ul << 17)) ? 14 : \
- ((u) & (1ul << 16)) ? 15 : \
- ((u) & (1ul << 15)) ? 16 : \
- ((u) & (1ul << 14)) ? 17 : \
- ((u) & (1ul << 13)) ? 18 : \
- ((u) & (1ul << 12)) ? 19 : \
- ((u) & (1ul << 11)) ? 20 : \
- ((u) & (1ul << 10)) ? 21 : \
- ((u) & (1ul << 9)) ? 22 : \
- ((u) & (1ul << 8)) ? 23 : \
- ((u) & (1ul << 7)) ? 24 : \
- ((u) & (1ul << 6)) ? 25 : \
- ((u) & (1ul << 5)) ? 26 : \
- ((u) & (1ul << 4)) ? 27 : \
- ((u) & (1ul << 3)) ? 28 : \
- ((u) & (1ul << 2)) ? 29 : \
- ((u) & (1ul << 1)) ? 30 : \
- 31)
-#endif
+# if (defined __GNUC__) || (defined __CC_ARM)
+# define clz(u) ((u) ? __builtin_clz(u) : 32)
+# else
+# define clz(u) (((u) == 0) ? 32 : ((u) & (1ul << 31)) ? 0 : ((u) & (1ul << 30)) ? 1 : ((u) & (1ul << 29)) ? 2 : ((u) & (1ul << 28)) ? 3 : ((u) & (1ul << 27)) ? 4 : ((u) & (1ul << 26)) ? 5 : ((u) & (1ul << 25)) ? 6 : ((u) & (1ul << 24)) ? 7 : ((u) & (1ul << 23)) ? 8 : ((u) & (1ul << 22)) ? 9 : ((u) & (1ul << 21)) ? 10 : ((u) & (1ul << 20)) ? 11 : ((u) & (1ul << 19)) ? 12 : ((u) & (1ul << 18)) ? 13 : ((u) & (1ul << 17)) ? 14 : ((u) & (1ul << 16)) ? 15 : ((u) & (1ul << 15)) ? 16 : ((u) & (1ul << 14)) ? 17 : ((u) & (1ul << 13)) ? 18 : ((u) & (1ul << 12)) ? 19 : ((u) & (1ul << 11)) ? 20 : ((u) & (1ul << 10)) ? 21 : ((u) & (1ul << 9)) ? 22 : ((u) & (1ul << 8)) ? 23 : ((u) & (1ul << 7)) ? 24 : ((u) & (1ul << 6)) ? 25 : ((u) & (1ul << 5)) ? 26 : ((u) & (1ul << 4)) ? 27 : ((u) & (1ul << 3)) ? 28 : ((u) & (1ul << 2)) ? 29 : ((u) & (1ul << 1)) ? 30 : 31)
+# endif
/** \brief Counts the trailing zero bits of the given value considered as a 32-bit integer.
*
@@ -557,47 +510,14 @@ typedef struct
*
* \return The count of trailing zero bits in \a u.
*/
-#if (defined __GNUC__) || (defined __CC_ARM)
-# define ctz(u) ((u) ? __builtin_ctz(u) : 32)
-#else
-# define ctz(u) ((u) & (1ul << 0) ? 0 : \
- (u) & (1ul << 1) ? 1 : \
- (u) & (1ul << 2) ? 2 : \
- (u) & (1ul << 3) ? 3 : \
- (u) & (1ul << 4) ? 4 : \
- (u) & (1ul << 5) ? 5 : \
- (u) & (1ul << 6) ? 6 : \
- (u) & (1ul << 7) ? 7 : \
- (u) & (1ul << 8) ? 8 : \
- (u) & (1ul << 9) ? 9 : \
- (u) & (1ul << 10) ? 10 : \
- (u) & (1ul << 11) ? 11 : \
- (u) & (1ul << 12) ? 12 : \
- (u) & (1ul << 13) ? 13 : \
- (u) & (1ul << 14) ? 14 : \
- (u) & (1ul << 15) ? 15 : \
- (u) & (1ul << 16) ? 16 : \
- (u) & (1ul << 17) ? 17 : \
- (u) & (1ul << 18) ? 18 : \
- (u) & (1ul << 19) ? 19 : \
- (u) & (1ul << 20) ? 20 : \
- (u) & (1ul << 21) ? 21 : \
- (u) & (1ul << 22) ? 22 : \
- (u) & (1ul << 23) ? 23 : \
- (u) & (1ul << 24) ? 24 : \
- (u) & (1ul << 25) ? 25 : \
- (u) & (1ul << 26) ? 26 : \
- (u) & (1ul << 27) ? 27 : \
- (u) & (1ul << 28) ? 28 : \
- (u) & (1ul << 29) ? 29 : \
- (u) & (1ul << 30) ? 30 : \
- (u) & (1ul << 31) ? 31 : \
- 32)
-#endif
+# if (defined __GNUC__) || (defined __CC_ARM)
+# define ctz(u) ((u) ? __builtin_ctz(u) : 32)
+# else
+# define ctz(u) ((u) & (1ul << 0) ? 0 : (u) & (1ul << 1) ? 1 : (u) & (1ul << 2) ? 2 : (u) & (1ul << 3) ? 3 : (u) & (1ul << 4) ? 4 : (u) & (1ul << 5) ? 5 : (u) & (1ul << 6) ? 6 : (u) & (1ul << 7) ? 7 : (u) & (1ul << 8) ? 8 : (u) & (1ul << 9) ? 9 : (u) & (1ul << 10) ? 10 : (u) & (1ul << 11) ? 11 : (u) & (1ul << 12) ? 12 : (u) & (1ul << 13) ? 13 : (u) & (1ul << 14) ? 14 : (u) & (1ul << 15) ? 15 : (u) & (1ul << 16) ? 16 : (u) & (1ul << 17) ? 17 : (u) & (1ul << 18) ? 18 : (u) & (1ul << 19) ? 19 : (u) & (1ul << 20) ? 20 : (u) & (1ul << 21) ? 21 : (u) & (1ul << 22) ? 22 : (u) & (1ul << 23) ? 23 : (u) & (1ul << 24) ? 24 : (u) & (1ul << 25) ? 25 : (u) & (1ul << 26) ? 26 : (u) & (1ul << 27) ? 27 : (u) & (1ul << 28) ? 28 : (u) & (1ul << 29) ? 29 : (u) & (1ul << 30) ? 30 : (u) & (1ul << 31) ? 31 : 32)
+# endif
/** @} */
-
/** \name Bit Reversing
* @{ */
@@ -607,7 +527,7 @@ typedef struct
*
* \return Value resulting from \a u8 with reversed bits.
*/
-#define bit_reverse8(u8) ((U8)(bit_reverse32((U8)(u8)) >> 24))
+# define bit_reverse8(u8) ((U8)(bit_reverse32((U8)(u8)) >> 24))
/** \brief Reverses the bits of \a u16.
*
@@ -615,7 +535,7 @@ typedef struct
*
* \return Value resulting from \a u16 with reversed bits.
*/
-#define bit_reverse16(u16) ((uint16_t)(bit_reverse32((uint16_t)(u16)) >> 16))
+# define bit_reverse16(u16) ((uint16_t)(bit_reverse32((uint16_t)(u16)) >> 16))
/** \brief Reverses the bits of \a u32.
*
@@ -623,7 +543,7 @@ typedef struct
*
* \return Value resulting from \a u32 with reversed bits.
*/
-#define bit_reverse32(u32) __RBIT(u32)
+# define bit_reverse32(u32) __RBIT(u32)
/** \brief Reverses the bits of \a u64.
*
@@ -631,12 +551,10 @@ typedef struct
*
* \return Value resulting from \a u64 with reversed bits.
*/
-#define bit_reverse64(u64) ((uint64_t)(((uint64_t)bit_reverse32((uint64_t)(u64) >> 32)) |\
- ((uint64_t)bit_reverse32((uint64_t)(u64)) << 32)))
+# define bit_reverse64(u64) ((uint64_t)(((uint64_t)bit_reverse32((uint64_t)(u64) >> 32)) | ((uint64_t)bit_reverse32((uint64_t)(u64)) << 32)))
/** @} */
-
/** \name Alignment
* @{ */
@@ -647,7 +565,7 @@ typedef struct
*
* \return \c 1 if the number \a val is aligned with the \a n boundary, else \c 0.
*/
-#define Test_align(val, n) (!Tst_bits( val, (n) - 1 ) )
+# define Test_align(val, n) (!Tst_bits(val, (n)-1))
/** \brief Gets alignment of the number \a val with respect to the \a n boundary.
*
@@ -656,7 +574,7 @@ typedef struct
*
* \return Alignment of the number \a val with respect to the \a n boundary.
*/
-#define Get_align(val, n) ( Rd_bits( val, (n) - 1 ) )
+# define Get_align(val, n) (Rd_bits(val, (n)-1))
/** \brief Sets alignment of the lvalue number \a lval to \a alg with respect to the \a n boundary.
*
@@ -666,7 +584,7 @@ typedef struct
*
* \return New value of \a lval resulting from its alignment set to \a alg with respect to the \a n boundary.
*/
-#define Set_align(lval, n, alg) ( Wr_bits(lval, (n) - 1, alg) )
+# define Set_align(lval, n, alg) (Wr_bits(lval, (n)-1, alg))
/** \brief Aligns the number \a val with the upper \a n boundary.
*
@@ -675,7 +593,7 @@ typedef struct
*
* \return Value resulting from the number \a val aligned with the upper \a n boundary.
*/
-#define Align_up( val, n) (((val) + ((n) - 1)) & ~((n) - 1))
+# define Align_up(val, n) (((val) + ((n)-1)) & ~((n)-1))
/** \brief Aligns the number \a val with the lower \a n boundary.
*
@@ -684,11 +602,10 @@ typedef struct
*
* \return Value resulting from the number \a val aligned with the lower \a n boundary.
*/
-#define Align_down(val, n) ( (val) & ~((n) - 1))
+# define Align_down(val, n) ((val) & ~((n)-1))
/** @} */
-
/** \name Mathematics
*
* The same considerations as for clz and ctz apply here but GCC does not
@@ -710,9 +627,9 @@ typedef struct
*
* \note More optimized if only used with values known at compile time.
*/
-#define Abs(a) (((a) < 0 ) ? -(a) : (a))
+# define Abs(a) (((a) < 0) ? -(a) : (a))
-#ifndef __cplusplus
+# ifndef __cplusplus
/** \brief Takes the minimal value of \a a and \a b.
*
* \param[in] a Input value.
@@ -722,7 +639,7 @@ typedef struct
*
* \note More optimized if only used with values known at compile time.
*/
-#define Min(a, b) (((a) < (b)) ? (a) : (b))
+# define Min(a, b) (((a) < (b)) ? (a) : (b))
/** \brief Takes the maximal value of \a a and \a b.
*
@@ -733,7 +650,7 @@ typedef struct
*
* \note More optimized if only used with values known at compile time.
*/
-#define Max(a, b) (((a) > (b)) ? (a) : (b))
+# define Max(a, b) (((a) > (b)) ? (a) : (b))
/** \brief Takes the minimal value of \a a and \a b.
*
@@ -744,7 +661,7 @@ typedef struct
*
* \note More optimized if only used with values unknown at compile time.
*/
-#define min(a, b) Min(a, b)
+# define min(a, b) Min(a, b)
/** \brief Takes the maximal value of \a a and \a b.
*
@@ -755,12 +672,11 @@ typedef struct
*
* \note More optimized if only used with values unknown at compile time.
*/
-#define max(a, b) Max(a, b)
-#endif
+# define max(a, b) Max(a, b)
+# endif
/** @} */
-
/** \brief Calls the routine at address \a addr.
*
* It generates a long call opcode.
@@ -772,38 +688,36 @@ typedef struct
*
* \note It may be used as a long jump opcode in some special cases.
*/
-#define Long_call(addr) ((*(void (*)(void))(addr))())
-
+# define Long_call(addr) ((*(void (*)(void))(addr))())
/** \name MCU Endianism Handling
* ARM is MCU little endian.
*
* @{ */
-#define BE16(x) swap16(x)
-#define LE16(x) (x)
-
-#define le16_to_cpu(x) (x)
-#define cpu_to_le16(x) (x)
-#define LE16_TO_CPU(x) (x)
-#define CPU_TO_LE16(x) (x)
-
-#define be16_to_cpu(x) swap16(x)
-#define cpu_to_be16(x) swap16(x)
-#define BE16_TO_CPU(x) swap16(x)
-#define CPU_TO_BE16(x) swap16(x)
-
-#define le32_to_cpu(x) (x)
-#define cpu_to_le32(x) (x)
-#define LE32_TO_CPU(x) (x)
-#define CPU_TO_LE32(x) (x)
-
-#define be32_to_cpu(x) swap32(x)
-#define cpu_to_be32(x) swap32(x)
-#define BE32_TO_CPU(x) swap32(x)
-#define CPU_TO_BE32(x) swap32(x)
+# define BE16(x) swap16(x)
+# define LE16(x) (x)
+
+# define le16_to_cpu(x) (x)
+# define cpu_to_le16(x) (x)
+# define LE16_TO_CPU(x) (x)
+# define CPU_TO_LE16(x) (x)
+
+# define be16_to_cpu(x) swap16(x)
+# define cpu_to_be16(x) swap16(x)
+# define BE16_TO_CPU(x) swap16(x)
+# define CPU_TO_BE16(x) swap16(x)
+
+# define le32_to_cpu(x) (x)
+# define cpu_to_le32(x) (x)
+# define LE32_TO_CPU(x) (x)
+# define CPU_TO_LE32(x) (x)
+
+# define be32_to_cpu(x) swap32(x)
+# define cpu_to_be32(x) swap32(x)
+# define BE32_TO_CPU(x) swap32(x)
+# define CPU_TO_BE32(x) swap32(x)
/** @} */
-
/** \name Endianism Conversion
*
* The same considerations as for clz and ctz apply here but GCC's
@@ -824,8 +738,7 @@ typedef struct
*
* \note More optimized if only used with values known at compile time.
*/
-#define Swap16(u16) ((uint16_t)(((uint16_t)(u16) >> 8) |\
- ((uint16_t)(u16) << 8)))
+# define Swap16(u16) ((uint16_t)(((uint16_t)(u16) >> 8) | ((uint16_t)(u16) << 8)))
/** \brief Toggles the endianism of \a u32 (by swapping its bytes).
*
@@ -835,8 +748,7 @@ typedef struct
*
* \note More optimized if only used with values known at compile time.
*/
-#define Swap32(u32) ((uint32_t)(((uint32_t)Swap16((uint32_t)(u32) >> 16)) |\
- ((uint32_t)Swap16((uint32_t)(u32)) << 16)))
+# define Swap32(u32) ((uint32_t)(((uint32_t)Swap16((uint32_t)(u32) >> 16)) | ((uint32_t)Swap16((uint32_t)(u32)) << 16)))
/** \brief Toggles the endianism of \a u64 (by swapping its bytes).
*
@@ -846,8 +758,7 @@ typedef struct
*
* \note More optimized if only used with values known at compile time.
*/
-#define Swap64(u64) ((uint64_t)(((uint64_t)Swap32((uint64_t)(u64) >> 32)) |\
- ((uint64_t)Swap32((uint64_t)(u64)) << 32)))
+# define Swap64(u64) ((uint64_t)(((uint64_t)Swap32((uint64_t)(u64) >> 32)) | ((uint64_t)Swap32((uint64_t)(u64)) << 32)))
/** \brief Toggles the endianism of \a u16 (by swapping its bytes).
*
@@ -857,7 +768,7 @@ typedef struct
*
* \note More optimized if only used with values unknown at compile time.
*/
-#define swap16(u16) Swap16(u16)
+# define swap16(u16) Swap16(u16)
/** \brief Toggles the endianism of \a u32 (by swapping its bytes).
*
@@ -867,11 +778,11 @@ typedef struct
*
* \note More optimized if only used with values unknown at compile time.
*/
-#if (defined __GNUC__)
-# define swap32(u32) ((uint32_t)__builtin_bswap32((uint32_t)(u32)))
-#else
-# define swap32(u32) Swap32(u32)
-#endif
+# if (defined __GNUC__)
+# define swap32(u32) ((uint32_t)__builtin_bswap32((uint32_t)(u32)))
+# else
+# define swap32(u32) Swap32(u32)
+# endif
/** \brief Toggles the endianism of \a u64 (by swapping its bytes).
*
@@ -881,30 +792,28 @@ typedef struct
*
* \note More optimized if only used with values unknown at compile time.
*/
-#if (defined __GNUC__)
-# define swap64(u64) ((uint64_t)__builtin_bswap64((uint64_t)(u64)))
-#else
-# define swap64(u64) ((uint64_t)(((uint64_t)swap32((uint64_t)(u64) >> 32)) |\
- ((uint64_t)swap32((uint64_t)(u64)) << 32)))
-#endif
+# if (defined __GNUC__)
+# define swap64(u64) ((uint64_t)__builtin_bswap64((uint64_t)(u64)))
+# else
+# define swap64(u64) ((uint64_t)(((uint64_t)swap32((uint64_t)(u64) >> 32)) | ((uint64_t)swap32((uint64_t)(u64)) << 32)))
+# endif
/** @} */
-
/** \name Target Abstraction
*
* @{ */
-#define _GLOBEXT_ extern /**< extern storage-class specifier. */
-#define _CONST_TYPE_ const /**< const type qualifier. */
-#define _MEM_TYPE_SLOW_ /**< Slow memory type. */
-#define _MEM_TYPE_MEDFAST_ /**< Fairly fast memory type. */
-#define _MEM_TYPE_FAST_ /**< Fast memory type. */
+# define _GLOBEXT_ extern /**< extern storage-class specifier. */
+# define _CONST_TYPE_ const /**< const type qualifier. */
+# define _MEM_TYPE_SLOW_ /**< Slow memory type. */
+# define _MEM_TYPE_MEDFAST_ /**< Fairly fast memory type. */
+# define _MEM_TYPE_FAST_ /**< Fast memory type. */
-#define memcmp_ram2ram memcmp /**< Target-specific memcmp of RAM to RAM. */
-#define memcmp_code2ram memcmp /**< Target-specific memcmp of RAM to NVRAM. */
-#define memcpy_ram2ram memcpy /**< Target-specific memcpy from RAM to RAM. */
-#define memcpy_code2ram memcpy /**< Target-specific memcpy from NVRAM to RAM. */
+# define memcmp_ram2ram memcmp /**< Target-specific memcmp of RAM to RAM. */
+# define memcmp_code2ram memcmp /**< Target-specific memcmp of RAM to NVRAM. */
+# define memcpy_ram2ram memcpy /**< Target-specific memcpy from RAM to RAM. */
+# define memcpy_code2ram memcpy /**< Target-specific memcpy from NVRAM to RAM. */
/** @} */
@@ -917,159 +826,162 @@ typedef struct
*
* \return (\a a / \a b) rounded up to the nearest integer.
*/
-#define div_ceil(a, b) (((a) + (b) - 1) / (b))
+# 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.
*
* @{ */
-#define __asm__ asm
-#define __inline__ inline
-#define __volatile__
+# define __asm__ asm
+# define __inline__ inline
+# define __volatile__
/** @} */
-#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) do { (void)(v); } while(0)
+# define unused(v) \
+ do { \
+ (void)(v); \
+ } while (0)
/* Define RAMFUNC attribute */
-#if defined ( __CC_ARM ) /* Keil uVision 4 */
-# define RAMFUNC __attribute__ ((section(".ramfunc")))
-#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
-# define RAMFUNC __ramfunc
-#elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */
-# define RAMFUNC __attribute__ ((section(".ramfunc")))
-#endif
+# if defined(__CC_ARM) /* Keil uVision 4 */
+# define RAMFUNC __attribute__((section(".ramfunc")))
+# elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */
+# define RAMFUNC __ramfunc
+# elif defined(__GNUC__) /* GCC CS3 2009q3-68 */
+# define RAMFUNC __attribute__((section(".ramfunc")))
+# endif
/* Define OPTIMIZE_HIGH attribute */
-#if defined ( __CC_ARM ) /* Keil uVision 4 */
-# define OPTIMIZE_HIGH _Pragma("O3")
-#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
-# define OPTIMIZE_HIGH _Pragma("optimize=high")
-#elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */
-# define OPTIMIZE_HIGH __attribute__((optimize("s")))
-#endif
-//kmod #define PASS 0
-//kmod #define FAIL 1
-//kmod #define LOW 0
-//kmod #define HIGH 1
-
-typedef int8_t S8 ; //!< 8-bit signed integer.
-typedef uint8_t U8 ; //!< 8-bit unsigned integer.
-typedef int16_t S16; //!< 16-bit signed integer.
-typedef uint16_t U16; //!< 16-bit unsigned integer.
-typedef int32_t S32; //!< 32-bit signed integer.
-typedef uint32_t U32; //!< 32-bit unsigned integer.
-typedef int64_t S64; //!< 64-bit signed integer.
-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 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 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__)
-#define SHORTENUM __packed
-#elif defined(__GNUC__)
-#define SHORTENUM __attribute__((packed))
-#endif
+# if defined(__CC_ARM) /* Keil uVision 4 */
+# define OPTIMIZE_HIGH _Pragma("O3")
+# elif defined(__ICCARM__) /* IAR Ewarm 5.41+ */
+# define OPTIMIZE_HIGH _Pragma("optimize=high")
+# elif defined(__GNUC__) /* GCC CS3 2009q3-68 */
+# define OPTIMIZE_HIGH __attribute__((optimize("s")))
+# endif
+// kmod #define PASS 0
+// kmod #define FAIL 1
+// kmod #define LOW 0
+// kmod #define HIGH 1
+
+typedef int8_t S8; //!< 8-bit signed integer.
+typedef uint8_t U8; //!< 8-bit unsigned integer.
+typedef int16_t S16; //!< 16-bit signed integer.
+typedef uint16_t U16; //!< 16-bit unsigned integer.
+typedef int32_t S32; //!< 32-bit signed integer.
+typedef uint32_t U32; //!< 32-bit unsigned integer.
+typedef int64_t S64; //!< 64-bit signed integer.
+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 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 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__)
+# define SHORTENUM __packed
+# elif defined(__GNUC__)
+# define SHORTENUM __attribute__((packed))
+# endif
/* No operation */
-#if defined(__ICCARM__)
-#define nop() __no_operation()
-#elif defined(__GNUC__)
-#define nop() (__NOP())
-#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))
+# if defined(__ICCARM__)
+# define nop() __no_operation()
+# elif defined(__GNUC__)
+# define nop() (__NOP())
+# 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))
/*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
@@ -1078,14 +990,12 @@ typedef double F64; //!< 64-bit floating-point number.
* @param[out] data Pointer to the 8 Byte array to be updated with 64-Bit value
* @ingroup apiPalApi
*/
-static inline void convert_64_bit_to_byte_array(uint64_t value, uint8_t *data)
-{
+static inline void convert_64_bit_to_byte_array(uint64_t value, uint8_t *data) {
uint8_t index = 0;
- while (index < 8)
- {
+ while (index < 8) {
data[index++] = value & 0xFF;
- value = value >> 8;
+ value = value >> 8;
}
}
@@ -1096,22 +1006,19 @@ static inline void convert_64_bit_to_byte_array(uint64_t value, uint8_t *data)
* @param[out] data Pointer to the 2 Byte array to be updated with 16-Bit value
* @ingroup apiPalApi
*/
-static inline void convert_16_bit_to_byte_array(uint16_t value, uint8_t *data)
-{
+static inline void convert_16_bit_to_byte_array(uint16_t value, uint8_t *data) {
data[0] = value & 0xFF;
data[1] = (value >> 8) & 0xFF;
}
/* Converts a 16-Bit value into a 2 Byte array */
-static inline void convert_spec_16_bit_to_byte_array(uint16_t value, uint8_t *data)
-{
+static inline void convert_spec_16_bit_to_byte_array(uint16_t value, uint8_t *data) {
data[0] = value & 0xFF;
data[1] = (value >> 8) & 0xFF;
}
/* Converts a 16-Bit value into a 2 Byte array */
-static inline void convert_16_bit_to_byte_address(uint16_t value, uint8_t *data)
-{
+static inline void convert_16_bit_to_byte_address(uint16_t value, uint8_t *data) {
data[0] = value & 0xFF;
data[1] = (value >> 8) & 0xFF;
}
@@ -1124,24 +1031,18 @@ static inline void convert_16_bit_to_byte_address(uint16_t value, uint8_t *data)
* @return 16-Bit value
* @ingroup apiPalApi
*/
-static inline uint16_t convert_byte_array_to_16_bit(uint8_t *data)
-{
- return (data[0] | ((uint16_t)data[1] << 8));
-}
+static inline uint16_t convert_byte_array_to_16_bit(uint8_t *data) { return (data[0] | ((uint16_t)data[1] << 8)); }
/* Converts a 4 Byte array into a 32-Bit value */
-static inline uint32_t convert_byte_array_to_32_bit(uint8_t *data)
-{
- union
- {
+static inline uint32_t convert_byte_array_to_32_bit(uint8_t *data) {
+ union {
uint32_t u32;
- uint8_t u8[4];
+ uint8_t u8[4];
} long_addr;
uint8_t index;
- for (index = 0; index < 4; index++)
- {
+ for (index = 0; index < 4; index++) {
long_addr.u8[index] = *data++;
}
@@ -1156,18 +1057,15 @@ static inline uint32_t convert_byte_array_to_32_bit(uint8_t *data)
* @return 64-Bit value
* @ingroup apiPalApi
*/
-static inline uint64_t convert_byte_array_to_64_bit(uint8_t *data)
-{
- union
- {
+static inline uint64_t convert_byte_array_to_64_bit(uint8_t *data) {
+ union {
uint64_t u64;
- uint8_t u8[8];
+ uint8_t u8[8];
} long_addr;
uint8_t index;
- for (index = 0; index < 8; index++)
- {
+ for (index = 0; index < 8; index++) {
long_addr.u8[index] = *data++;
}
diff --git a/tmk_core/protocol/arm_atsam/usb/conf_usb.h b/tmk_core/protocol/arm_atsam/usb/conf_usb.h
index c91caffe02..f23c2a80dd 100644
--- a/tmk_core/protocol/arm_atsam/usb/conf_usb.h
+++ b/tmk_core/protocol/arm_atsam/usb/conf_usb.h
@@ -50,29 +50,29 @@
#include "compiler.h"
#include "udi_device_conf.h"
-#define UDI_CDC_DEFAULT_RATE 115200
-#define UDI_CDC_DEFAULT_STOPBITS CDC_STOP_BITS_1
-#define UDI_CDC_DEFAULT_PARITY CDC_PAR_NONE
-#define UDI_CDC_DEFAULT_DATABITS 8
+#define UDI_CDC_DEFAULT_RATE 115200
+#define UDI_CDC_DEFAULT_STOPBITS CDC_STOP_BITS_1
+#define UDI_CDC_DEFAULT_PARITY CDC_PAR_NONE
+#define UDI_CDC_DEFAULT_DATABITS 8
//! Device definition (mandatory)
-#define USB_DEVICE_VENDOR_ID VENDOR_ID
-#define USB_DEVICE_PRODUCT_ID PRODUCT_ID
-#define USB_DEVICE_VERSION DEVICE_VER
-#define USB_DEVICE_POWER 500 // Consumption on Vbus line (mA)
-#define USB_DEVICE_ATTR (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_BUS_POWERED)
+#define USB_DEVICE_VENDOR_ID VENDOR_ID
+#define USB_DEVICE_PRODUCT_ID PRODUCT_ID
+#define USB_DEVICE_VERSION DEVICE_VER
+#define USB_DEVICE_POWER 500 // Consumption on Vbus line (mA)
+#define USB_DEVICE_ATTR (USB_CONFIG_ATTR_REMOTE_WAKEUP | USB_CONFIG_ATTR_BUS_POWERED)
// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_BUS_POWERED)
// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_SELF_POWERED)
// (USB_CONFIG_ATTR_SELF_POWERED)
// (USB_CONFIG_ATTR_BUS_POWERED)
//! USB Device string definitions (Optional)
-#define USB_DEVICE_MANUFACTURE_NAME MANUFACTURER
-#define USB_DEVICE_PRODUCT_NAME PRODUCT
-#define USB_DEVICE_SERIAL_NAME SERIAL_NUM
+#define USB_DEVICE_MANUFACTURE_NAME MANUFACTURER
+#define USB_DEVICE_PRODUCT_NAME PRODUCT
+#define USB_DEVICE_SERIAL_NAME SERIAL_NUM
-//Comment out USB_DEVICE_SERIAL_USE_BOOTLOADER_SERIAL to prevent ROM lookup of factory programmed serial number
-#define USB_DEVICE_SERIAL_USE_BOOTLOADER_SERIAL
+// Comment out USB_DEVICE_SERIAL_USE_BOOTLOADER_SERIAL to prevent ROM lookup of factory programmed serial number
+#define USB_DEVICE_SERIAL_USE_BOOTLOADER_SERIAL
/**
* Device speeds support
@@ -82,9 +82,9 @@
//#define USB_DEVICE_LOW_SPEED
//! To authorize the High speed
-#if (UC3A3||UC3A4)
+#if (UC3A3 || UC3A4)
//#define USB_DEVICE_HS_SUPPORT
-#elif (SAM3XA||SAM3U)
+#elif (SAM3XA || SAM3U)
//#define USB_DEVICE_HS_SUPPORT
#endif
//@}
@@ -93,13 +93,13 @@
* USB Device Callbacks definitions (Optional)
* @{
*/
-#define UDC_VBUS_EVENT(b_vbus_high)
-#define UDC_SOF_EVENT() main_sof_action()
-#define UDC_SUSPEND_EVENT() main_suspend_action()
-#define UDC_RESUME_EVENT() main_resume_action()
+#define UDC_VBUS_EVENT(b_vbus_high)
+#define UDC_SOF_EVENT() main_sof_action()
+#define UDC_SUSPEND_EVENT() main_suspend_action()
+#define UDC_RESUME_EVENT() main_resume_action()
//! Mandatory when USB_DEVICE_ATTR authorizes remote wakeup feature
-#define UDC_REMOTEWAKEUP_ENABLE() main_remotewakeup_enable()
-#define UDC_REMOTEWAKEUP_DISABLE() main_remotewakeup_disable()
+#define UDC_REMOTEWAKEUP_ENABLE() main_remotewakeup_enable()
+#define UDC_REMOTEWAKEUP_DISABLE() main_remotewakeup_disable()
//! When a extra string descriptor must be supported
//! other than manufacturer, product and serial string
// #define UDC_GET_EXTRA_STRING()
@@ -107,7 +107,6 @@
//@}
-
/**
* USB Interface Configuration
* @{
@@ -118,42 +117,40 @@
*/
//! Interface callback definition
#ifdef KBD
-#define UDI_HID_KBD_ENABLE_EXT() main_kbd_enable()
-#define UDI_HID_KBD_DISABLE_EXT() main_kbd_disable()
+# define UDI_HID_KBD_ENABLE_EXT() main_kbd_enable()
+# define UDI_HID_KBD_DISABLE_EXT() main_kbd_disable()
//#define UDI_HID_KBD_CHANGE_LED(value) ui_kbd_led(value)
#endif
#ifdef NKRO
-#define UDI_HID_NKRO_ENABLE_EXT() main_nkro_enable()
-#define UDI_HID_NKRO_DISABLE_EXT() main_nkro_disable()
+# define UDI_HID_NKRO_ENABLE_EXT() main_nkro_enable()
+# define UDI_HID_NKRO_DISABLE_EXT() main_nkro_disable()
//#define UDI_HID_NKRO_CHANGE_LED(value) ui_kbd_led(value)
#endif
#ifdef EXK
-#define UDI_HID_EXK_ENABLE_EXT() main_exk_enable()
-#define UDI_HID_EXK_DISABLE_EXT() main_exk_disable()
+# define UDI_HID_EXK_ENABLE_EXT() main_exk_enable()
+# define UDI_HID_EXK_DISABLE_EXT() main_exk_disable()
#endif
#ifdef CON
-#define UDI_HID_CON_ENABLE_EXT() main_con_enable()
-#define UDI_HID_CON_DISABLE_EXT() main_con_disable()
+# define UDI_HID_CON_ENABLE_EXT() main_con_enable()
+# define UDI_HID_CON_DISABLE_EXT() main_con_disable()
#endif
#ifdef MOU
-#define UDI_HID_MOU_ENABLE_EXT() main_mou_enable()
-#define UDI_HID_MOU_DISABLE_EXT() main_mou_disable()
+# define UDI_HID_MOU_ENABLE_EXT() main_mou_enable()
+# define UDI_HID_MOU_DISABLE_EXT() main_mou_disable()
#endif
#ifdef RAW
-#define UDI_HID_RAW_ENABLE_EXT() main_raw_enable()
-#define UDI_HID_RAW_DISABLE_EXT() main_raw_disable()
+# define UDI_HID_RAW_ENABLE_EXT() main_raw_enable()
+# define UDI_HID_RAW_DISABLE_EXT() main_raw_disable()
#endif
-
//@}
//@}
-
/**
* USB Device Driver Configuration
* @{
@@ -165,4 +162,4 @@
#include "usb_main.h"
#include "ui.h"
-#endif // _CONF_USB_H_
+#endif // _CONF_USB_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/main_usb.c b/tmk_core/protocol/arm_atsam/usb/main_usb.c
index 0f676ab639..82ab123fd0 100644
--- a/tmk_core/protocol/arm_atsam/usb/main_usb.c
+++ b/tmk_core/protocol/arm_atsam/usb/main_usb.c
@@ -21,112 +21,72 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
uint8_t keyboard_protocol = 1;
-void main_suspend_action(void)
-{
- ui_powerdown();
-}
+void main_suspend_action(void) { ui_powerdown(); }
-void main_resume_action(void)
-{
- ui_wakeup();
-}
+void main_resume_action(void) { ui_wakeup(); }
-void main_sof_action(void)
-{
- ui_process(udd_get_frame_number());
-}
+void main_sof_action(void) { ui_process(udd_get_frame_number()); }
-void main_remotewakeup_enable(void)
-{
- ui_wakeup_enable();
-}
+void main_remotewakeup_enable(void) { ui_wakeup_enable(); }
-void main_remotewakeup_disable(void)
-{
- ui_wakeup_disable();
-}
+void main_remotewakeup_disable(void) { ui_wakeup_disable(); }
#ifdef KBD
volatile bool main_b_kbd_enable = false;
-bool main_kbd_enable(void)
-{
+bool main_kbd_enable(void) {
main_b_kbd_enable = true;
return true;
}
-void main_kbd_disable(void)
-{
- main_b_kbd_enable = false;
-}
+void main_kbd_disable(void) { main_b_kbd_enable = false; }
#endif
#ifdef NKRO
volatile bool main_b_nkro_enable = false;
-bool main_nkro_enable(void)
-{
+bool main_nkro_enable(void) {
main_b_nkro_enable = true;
return true;
}
-void main_nkro_disable(void)
-{
- main_b_nkro_enable = false;
-}
+void main_nkro_disable(void) { main_b_nkro_enable = false; }
#endif
#ifdef EXK
volatile bool main_b_exk_enable = false;
-bool main_exk_enable(void)
-{
+bool main_exk_enable(void) {
main_b_exk_enable = true;
return true;
}
-void main_exk_disable(void)
-{
- main_b_exk_enable = false;
-}
+void main_exk_disable(void) { main_b_exk_enable = false; }
#endif
#ifdef CON
volatile bool main_b_con_enable = false;
-bool main_con_enable(void)
-{
+bool main_con_enable(void) {
main_b_con_enable = true;
return true;
}
-void main_con_disable(void)
-{
- main_b_con_enable = false;
-}
+void main_con_disable(void) { main_b_con_enable = false; }
#endif
#ifdef MOU
volatile bool main_b_mou_enable = false;
-bool main_mou_enable(void)
-{
+bool main_mou_enable(void) {
main_b_mou_enable = true;
return true;
}
-void main_mou_disable(void)
-{
- main_b_mou_enable = false;
-}
+void main_mou_disable(void) { main_b_mou_enable = false; }
#endif
#ifdef RAW
volatile bool main_b_raw_enable = false;
-bool main_raw_enable(void)
-{
+bool main_raw_enable(void) {
main_b_raw_enable = true;
return true;
}
-void main_raw_disable(void)
-{
- main_b_raw_enable = false;
-}
+void main_raw_disable(void) { main_b_raw_enable = false; }
#endif
-
diff --git a/tmk_core/protocol/arm_atsam/usb/status_codes.h b/tmk_core/protocol/arm_atsam/usb/status_codes.h
index f56d2faed1..a7a1230be0 100644
--- a/tmk_core/protocol/arm_atsam/usb/status_codes.h
+++ b/tmk_core/protocol/arm_atsam/usb/status_codes.h
@@ -61,18 +61,18 @@
*/
/** Mask to retrieve the error category of a status code. */
-#define STATUS_CATEGORY_MASK 0xF0
+#define STATUS_CATEGORY_MASK 0xF0
/** Mask to retrieve the error code within the category of a status code. */
-#define STATUS_ERROR_MASK 0x0F
+#define STATUS_ERROR_MASK 0x0F
/** Status code error categories. */
enum status_categories {
- STATUS_CATEGORY_OK = 0x00,
- STATUS_CATEGORY_COMMON = 0x10,
- STATUS_CATEGORY_ANALOG = 0x30,
- STATUS_CATEGORY_COM = 0x40,
- STATUS_CATEGORY_IO = 0x50,
+ STATUS_CATEGORY_OK = 0x00,
+ STATUS_CATEGORY_COMMON = 0x10,
+ STATUS_CATEGORY_ANALOG = 0x30,
+ STATUS_CATEGORY_COM = 0x40,
+ STATUS_CATEGORY_IO = 0x50,
};
/**
@@ -85,37 +85,37 @@ enum status_categories {
* at the same time.
*/
enum status_code {
- STATUS_OK = STATUS_CATEGORY_OK | 0x00,
- STATUS_VALID_DATA = STATUS_CATEGORY_OK | 0x01,
- STATUS_NO_CHANGE = STATUS_CATEGORY_OK | 0x02,
- STATUS_ABORTED = STATUS_CATEGORY_OK | 0x04,
- STATUS_BUSY = STATUS_CATEGORY_OK | 0x05,
- STATUS_SUSPEND = STATUS_CATEGORY_OK | 0x06,
-
- STATUS_ERR_IO = STATUS_CATEGORY_COMMON | 0x00,
- STATUS_ERR_REQ_FLUSHED = STATUS_CATEGORY_COMMON | 0x01,
- STATUS_ERR_TIMEOUT = STATUS_CATEGORY_COMMON | 0x02,
- STATUS_ERR_BAD_DATA = STATUS_CATEGORY_COMMON | 0x03,
- STATUS_ERR_NOT_FOUND = STATUS_CATEGORY_COMMON | 0x04,
- STATUS_ERR_UNSUPPORTED_DEV = STATUS_CATEGORY_COMMON | 0x05,
- STATUS_ERR_NO_MEMORY = STATUS_CATEGORY_COMMON | 0x06,
- STATUS_ERR_INVALID_ARG = STATUS_CATEGORY_COMMON | 0x07,
- STATUS_ERR_BAD_ADDRESS = STATUS_CATEGORY_COMMON | 0x08,
- STATUS_ERR_BAD_FORMAT = STATUS_CATEGORY_COMMON | 0x0A,
- STATUS_ERR_BAD_FRQ = STATUS_CATEGORY_COMMON | 0x0B,
- STATUS_ERR_DENIED = STATUS_CATEGORY_COMMON | 0x0c,
- STATUS_ERR_ALREADY_INITIALIZED = STATUS_CATEGORY_COMMON | 0x0d,
- STATUS_ERR_OVERFLOW = STATUS_CATEGORY_COMMON | 0x0e,
- STATUS_ERR_NOT_INITIALIZED = STATUS_CATEGORY_COMMON | 0x0f,
+ STATUS_OK = STATUS_CATEGORY_OK | 0x00,
+ STATUS_VALID_DATA = STATUS_CATEGORY_OK | 0x01,
+ STATUS_NO_CHANGE = STATUS_CATEGORY_OK | 0x02,
+ STATUS_ABORTED = STATUS_CATEGORY_OK | 0x04,
+ STATUS_BUSY = STATUS_CATEGORY_OK | 0x05,
+ STATUS_SUSPEND = STATUS_CATEGORY_OK | 0x06,
+
+ STATUS_ERR_IO = STATUS_CATEGORY_COMMON | 0x00,
+ STATUS_ERR_REQ_FLUSHED = STATUS_CATEGORY_COMMON | 0x01,
+ STATUS_ERR_TIMEOUT = STATUS_CATEGORY_COMMON | 0x02,
+ STATUS_ERR_BAD_DATA = STATUS_CATEGORY_COMMON | 0x03,
+ STATUS_ERR_NOT_FOUND = STATUS_CATEGORY_COMMON | 0x04,
+ STATUS_ERR_UNSUPPORTED_DEV = STATUS_CATEGORY_COMMON | 0x05,
+ STATUS_ERR_NO_MEMORY = STATUS_CATEGORY_COMMON | 0x06,
+ STATUS_ERR_INVALID_ARG = STATUS_CATEGORY_COMMON | 0x07,
+ STATUS_ERR_BAD_ADDRESS = STATUS_CATEGORY_COMMON | 0x08,
+ STATUS_ERR_BAD_FORMAT = STATUS_CATEGORY_COMMON | 0x0A,
+ STATUS_ERR_BAD_FRQ = STATUS_CATEGORY_COMMON | 0x0B,
+ STATUS_ERR_DENIED = STATUS_CATEGORY_COMMON | 0x0c,
+ STATUS_ERR_ALREADY_INITIALIZED = STATUS_CATEGORY_COMMON | 0x0d,
+ STATUS_ERR_OVERFLOW = STATUS_CATEGORY_COMMON | 0x0e,
+ STATUS_ERR_NOT_INITIALIZED = STATUS_CATEGORY_COMMON | 0x0f,
STATUS_ERR_SAMPLERATE_UNAVAILABLE = STATUS_CATEGORY_ANALOG | 0x00,
STATUS_ERR_RESOLUTION_UNAVAILABLE = STATUS_CATEGORY_ANALOG | 0x01,
- STATUS_ERR_BAUDRATE_UNAVAILABLE = STATUS_CATEGORY_COM | 0x00,
- STATUS_ERR_PACKET_COLLISION = STATUS_CATEGORY_COM | 0x01,
- STATUS_ERR_PROTOCOL = STATUS_CATEGORY_COM | 0x02,
+ STATUS_ERR_BAUDRATE_UNAVAILABLE = STATUS_CATEGORY_COM | 0x00,
+ STATUS_ERR_PACKET_COLLISION = STATUS_CATEGORY_COM | 0x01,
+ STATUS_ERR_PROTOCOL = STATUS_CATEGORY_COM | 0x02,
- STATUS_ERR_PIN_MUX_INVALID = STATUS_CATEGORY_IO | 0x00,
+ STATUS_ERR_PIN_MUX_INVALID = STATUS_CATEGORY_IO | 0x00,
};
typedef enum status_code status_code_genare_t;
@@ -123,21 +123,21 @@ typedef enum status_code status_code_genare_t;
Status codes used by MAC stack.
*/
enum status_code_wireless {
- //STATUS_OK = 0, //!< Success
- ERR_IO_ERROR = -1, //!< I/O error
- ERR_FLUSHED = -2, //!< Request flushed from queue
- ERR_TIMEOUT = -3, //!< Operation timed out
- ERR_BAD_DATA = -4, //!< Data integrity check failed
- ERR_PROTOCOL = -5, //!< Protocol error
- ERR_UNSUPPORTED_DEV = -6, //!< Unsupported device
- ERR_NO_MEMORY = -7, //!< Insufficient memory
- ERR_INVALID_ARG = -8, //!< Invalid argument
- ERR_BAD_ADDRESS = -9, //!< Bad address
- ERR_BUSY = -10, //!< Resource is busy
- ERR_BAD_FORMAT = -11, //!< Data format not recognized
- ERR_NO_TIMER = -12, //!< No timer available
- ERR_TIMER_ALREADY_RUNNING = -13, //!< Timer already running
- ERR_TIMER_NOT_RUNNING = -14, //!< Timer not running
+ // STATUS_OK = 0, //!< Success
+ ERR_IO_ERROR = -1, //!< I/O error
+ ERR_FLUSHED = -2, //!< Request flushed from queue
+ ERR_TIMEOUT = -3, //!< Operation timed out
+ ERR_BAD_DATA = -4, //!< Data integrity check failed
+ ERR_PROTOCOL = -5, //!< Protocol error
+ ERR_UNSUPPORTED_DEV = -6, //!< Unsupported device
+ ERR_NO_MEMORY = -7, //!< Insufficient memory
+ ERR_INVALID_ARG = -8, //!< Invalid argument
+ ERR_BAD_ADDRESS = -9, //!< Bad address
+ ERR_BUSY = -10, //!< Resource is busy
+ ERR_BAD_FORMAT = -11, //!< Data format not recognized
+ ERR_NO_TIMER = -12, //!< No timer available
+ ERR_TIMER_ALREADY_RUNNING = -13, //!< Timer already running
+ ERR_TIMER_NOT_RUNNING = -14, //!< Timer not running
/**
* \brief Operation in progress
@@ -148,7 +148,7 @@ enum status_code_wireless {
* \note Drivers should never return this status code to any
* callers. It is strictly for internal use.
*/
- OPERATION_IN_PROGRESS = -128,
+ OPERATION_IN_PROGRESS = -128,
};
typedef enum status_code_wireless status_code_t;
diff --git a/tmk_core/protocol/arm_atsam/usb/udc.c b/tmk_core/protocol/arm_atsam/usb/udc.c
index 12444d3059..d04e9b7b28 100644
--- a/tmk_core/protocol/arm_atsam/usb/udc.c
+++ b/tmk_core/protocol/arm_atsam/usb/udc.c
@@ -83,7 +83,6 @@ static usb_iface_desc_t UDC_DESC_STORAGE *udc_ptr_iface;
//! @}
-
//! \name Internal structure to store the USB device main strings
//! @{
@@ -91,11 +90,7 @@ static usb_iface_desc_t UDC_DESC_STORAGE *udc_ptr_iface;
* \brief Language ID of USB device (US ID by default)
*/
COMPILER_WORD_ALIGNED
-static UDC_DESC_STORAGE usb_str_lgid_desc_t udc_string_desc_languageid = {
- .desc.bLength = sizeof(usb_str_lgid_desc_t),
- .desc.bDescriptorType = USB_DT_STRING,
- .string = {LE16(USB_LANGID_EN_US)}
-};
+static UDC_DESC_STORAGE usb_str_lgid_desc_t udc_string_desc_languageid = {.desc.bLength = sizeof(usb_str_lgid_desc_t), .desc.bDescriptorType = USB_DT_STRING, .string = {LE16(USB_LANGID_EN_US)}};
/**
* \brief USB device manufacture name storage
@@ -104,9 +99,9 @@ static UDC_DESC_STORAGE usb_str_lgid_desc_t udc_string_desc_languageid = {
*/
#ifdef USB_DEVICE_MANUFACTURE_NAME
static uint8_t udc_string_manufacturer_name[] = USB_DEVICE_MANUFACTURE_NAME;
-#define USB_DEVICE_MANUFACTURE_NAME_SIZE (sizeof(udc_string_manufacturer_name)-1)
+# define USB_DEVICE_MANUFACTURE_NAME_SIZE (sizeof(udc_string_manufacturer_name) - 1)
#else
-#define USB_DEVICE_MANUFACTURE_NAME_SIZE 0
+# define USB_DEVICE_MANUFACTURE_NAME_SIZE 0
#endif
/**
@@ -116,37 +111,34 @@ static uint8_t udc_string_manufacturer_name[] = USB_DEVICE_MANUFACTURE_NAME;
*/
#ifdef USB_DEVICE_PRODUCT_NAME
static uint8_t udc_string_product_name[] = USB_DEVICE_PRODUCT_NAME;
-#define USB_DEVICE_PRODUCT_NAME_SIZE (sizeof(udc_string_product_name)-1)
+# define USB_DEVICE_PRODUCT_NAME_SIZE (sizeof(udc_string_product_name) - 1)
#else
-#define USB_DEVICE_PRODUCT_NAME_SIZE 0
+# define USB_DEVICE_PRODUCT_NAME_SIZE 0
#endif
#if defined USB_DEVICE_SERIAL_NAME
-#define USB_DEVICE_SERIAL_NAME_SIZE (sizeof(USB_DEVICE_SERIAL_NAME)-1)
+# define USB_DEVICE_SERIAL_NAME_SIZE (sizeof(USB_DEVICE_SERIAL_NAME) - 1)
#else
-#define USB_DEVICE_SERIAL_NAME_SIZE 0
+# define USB_DEVICE_SERIAL_NAME_SIZE 0
#endif
-uint8_t usb_device_serial_name_size = 0;
+uint8_t usb_device_serial_name_size = 0;
#if defined USB_DEVICE_SERIAL_USE_BOOTLOADER_SERIAL
-uint8_t bootloader_serial_number[BOOTLOADER_SERIAL_MAX_SIZE+1]="";
+uint8_t bootloader_serial_number[BOOTLOADER_SERIAL_MAX_SIZE + 1] = "";
#endif
-static const uint8_t *udc_get_string_serial_name(void)
-{
-#if defined USB_DEVICE_SERIAL_USE_BOOTLOADER_SERIAL
- uint32_t serial_ptrloc = (uint32_t)&_srom - 4;
- uint32_t serial_address = *(uint32_t *)serial_ptrloc; //Address of bootloader's serial number if available
+static const uint8_t *udc_get_string_serial_name(void) {
+#if defined USB_DEVICE_SERIAL_USE_BOOTLOADER_SERIAL
+ uint32_t serial_ptrloc = (uint32_t)&_srom - 4;
+ uint32_t serial_address = *(uint32_t *)serial_ptrloc; // Address of bootloader's serial number if available
- if (serial_address != 0xFFFFFFFF && serial_address < serial_ptrloc) //Check for factory programmed serial address
+ if (serial_address != 0xFFFFFFFF && serial_address < serial_ptrloc) // Check for factory programmed serial address
{
- if ((serial_address & 0xFF) % 4 == 0) //Check alignment
+ if ((serial_address & 0xFF) % 4 == 0) // Check alignment
{
- uint16_t *serial_use = (uint16_t *)(serial_address); //Point to address of string in rom
- uint8_t serial_length = 0;
+ uint16_t *serial_use = (uint16_t *)(serial_address); // Point to address of string in rom
+ uint8_t serial_length = 0;
- while ((*(serial_use + serial_length) > 32 && *(serial_use + serial_length) < 127) &&
- serial_length < BOOTLOADER_SERIAL_MAX_SIZE)
- {
+ while ((*(serial_use + serial_length) > 32 && *(serial_use + serial_length) < 127) && serial_length < BOOTLOADER_SERIAL_MAX_SIZE) {
bootloader_serial_number[serial_length] = *(serial_use + serial_length) & 0xFF;
serial_length++;
}
@@ -154,7 +146,7 @@ static const uint8_t *udc_get_string_serial_name(void)
usb_device_serial_name_size = serial_length;
- return bootloader_serial_number; //Use serial programmed into bootloader rom
+ return bootloader_serial_number; // Use serial programmed into bootloader rom
}
}
#endif
@@ -162,9 +154,9 @@ static const uint8_t *udc_get_string_serial_name(void)
usb_device_serial_name_size = USB_DEVICE_SERIAL_NAME_SIZE;
#if defined USB_DEVICE_SERIAL_NAME
- return (const uint8_t *)USB_DEVICE_SERIAL_NAME; //Use serial supplied by keyboard's config.h
+ return (const uint8_t *)USB_DEVICE_SERIAL_NAME; // Use serial supplied by keyboard's config.h
#else
- return 0; //No serial supplied
+ return 0; // No serial supplied
#endif
}
@@ -173,38 +165,26 @@ static const uint8_t *udc_get_string_serial_name(void)
* Structure used to transfer ASCII strings to USB String descriptor structure.
*/
#ifndef BOOTLOADER_SERIAL_MAX_SIZE
-#define BOOTLOADER_SERIAL_MAX_SIZE 0
-#endif //BOOTLOADER_SERIAL_MAX_SIZE
+# define BOOTLOADER_SERIAL_MAX_SIZE 0
+#endif // BOOTLOADER_SERIAL_MAX_SIZE
struct udc_string_desc_t {
usb_str_desc_t header;
- le16_t string[Max(Max(Max(USB_DEVICE_MANUFACTURE_NAME_SIZE, \
- USB_DEVICE_PRODUCT_NAME_SIZE), USB_DEVICE_SERIAL_NAME_SIZE), \
- BOOTLOADER_SERIAL_MAX_SIZE)];
+ le16_t string[Max(Max(Max(USB_DEVICE_MANUFACTURE_NAME_SIZE, USB_DEVICE_PRODUCT_NAME_SIZE), USB_DEVICE_SERIAL_NAME_SIZE), BOOTLOADER_SERIAL_MAX_SIZE)];
};
COMPILER_WORD_ALIGNED
-static UDC_DESC_STORAGE struct udc_string_desc_t udc_string_desc = {
- .header.bDescriptorType = USB_DT_STRING
-};
+static UDC_DESC_STORAGE struct udc_string_desc_t udc_string_desc = {.header.bDescriptorType = USB_DT_STRING};
//! @}
-usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void)
-{
- return udc_ptr_iface;
-}
+usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void) { return udc_ptr_iface; }
/**
* \brief Returns a value to check the end of USB Configuration descriptor
*
* \return address after the last byte of USB Configuration descriptor
*/
-static usb_conf_desc_t UDC_DESC_STORAGE *udc_get_eof_conf(void)
-{
- return (UDC_DESC_STORAGE usb_conf_desc_t *) ((uint8_t *)
- udc_ptr_conf->desc +
- le16_to_cpu(udc_ptr_conf->desc->wTotalLength));
-}
+static usb_conf_desc_t UDC_DESC_STORAGE *udc_get_eof_conf(void) { return (UDC_DESC_STORAGE usb_conf_desc_t *)((uint8_t *)udc_ptr_conf->desc + le16_to_cpu(udc_ptr_conf->desc->wTotalLength)); }
-#if (0!=USB_DEVICE_MAX_EP)
+#if (0 != USB_DEVICE_MAX_EP)
/**
* \brief Search specific descriptor in global interface descriptor
*
@@ -215,30 +195,26 @@ static usb_conf_desc_t UDC_DESC_STORAGE *udc_get_eof_conf(void)
* \return address of specific descriptor found
* \return NULL if it is the end of global interface descriptor
*/
-static usb_conf_desc_t UDC_DESC_STORAGE *udc_next_desc_in_iface(usb_conf_desc_t
- UDC_DESC_STORAGE * desc, uint8_t desc_id)
-{
+static usb_conf_desc_t UDC_DESC_STORAGE *udc_next_desc_in_iface(usb_conf_desc_t UDC_DESC_STORAGE *desc, uint8_t desc_id) {
usb_conf_desc_t UDC_DESC_STORAGE *ptr_eof_desc;
ptr_eof_desc = udc_get_eof_conf();
// Go to next descriptor
- desc = (UDC_DESC_STORAGE usb_conf_desc_t *) ((uint8_t *) desc +
- desc->bLength);
+ desc = (UDC_DESC_STORAGE usb_conf_desc_t *)((uint8_t *)desc + desc->bLength);
// Check the end of configuration descriptor
while (ptr_eof_desc > desc) {
// If new interface descriptor is found,
// then it is the end of the current global interface descriptor
if (USB_DT_INTERFACE == desc->bDescriptorType) {
- break; // End of global interface descriptor
+ break; // End of global interface descriptor
}
if (desc_id == desc->bDescriptorType) {
- return desc; // Specific descriptor found
+ return desc; // Specific descriptor found
}
// Go to next descriptor
- desc = (UDC_DESC_STORAGE usb_conf_desc_t *) ((uint8_t *) desc +
- desc->bLength);
+ desc = (UDC_DESC_STORAGE usb_conf_desc_t *)((uint8_t *)desc + desc->bLength);
}
- return NULL; // No specific descriptor found
+ return NULL; // No specific descriptor found
}
#endif
@@ -251,8 +227,7 @@ static usb_conf_desc_t UDC_DESC_STORAGE *udc_next_desc_in_iface(usb_conf_desc_t
*
* \return 1 if found or 0 if not found
*/
-static bool udc_update_iface_desc(uint8_t iface_num, uint8_t setting_num)
-{
+static bool udc_update_iface_desc(uint8_t iface_num, uint8_t setting_num) {
usb_conf_desc_t UDC_DESC_STORAGE *ptr_end_desc;
if (0 == udc_num_configuration) {
@@ -264,28 +239,22 @@ static bool udc_update_iface_desc(uint8_t iface_num, uint8_t setting_num)
}
// Start at the beginning of configuration descriptor
- udc_ptr_iface = (UDC_DESC_STORAGE usb_iface_desc_t *)
- udc_ptr_conf->desc;
+ udc_ptr_iface = (UDC_DESC_STORAGE usb_iface_desc_t *)udc_ptr_conf->desc;
// Check the end of configuration descriptor
ptr_end_desc = udc_get_eof_conf();
- while (ptr_end_desc >
- (UDC_DESC_STORAGE usb_conf_desc_t *) udc_ptr_iface) {
+ while (ptr_end_desc > (UDC_DESC_STORAGE usb_conf_desc_t *)udc_ptr_iface) {
if (USB_DT_INTERFACE == udc_ptr_iface->bDescriptorType) {
// A interface descriptor is found
// Check interface and alternate setting number
- if ((iface_num == udc_ptr_iface->bInterfaceNumber) &&
- (setting_num ==
- udc_ptr_iface->bAlternateSetting)) {
- return true; // Interface found
+ if ((iface_num == udc_ptr_iface->bInterfaceNumber) && (setting_num == udc_ptr_iface->bAlternateSetting)) {
+ return true; // Interface found
}
}
// Go to next descriptor
- udc_ptr_iface = (UDC_DESC_STORAGE usb_iface_desc_t *) (
- (uint8_t *) udc_ptr_iface +
- udc_ptr_iface->bLength);
+ udc_ptr_iface = (UDC_DESC_STORAGE usb_iface_desc_t *)((uint8_t *)udc_ptr_iface + udc_ptr_iface->bLength);
}
- return false; // Interface not found
+ return false; // Interface not found
}
/**
@@ -296,8 +265,7 @@ static bool udc_update_iface_desc(uint8_t iface_num, uint8_t setting_num)
*
* \return 1 if it is done or 0 if interface is not found
*/
-static bool udc_iface_disable(uint8_t iface_num)
-{
+static bool udc_iface_disable(uint8_t iface_num) {
udi_api_t UDC_DESC_STORAGE *udi_api;
// Select first alternate setting of the interface
@@ -309,7 +277,7 @@ static bool udc_iface_disable(uint8_t iface_num)
// Select the interface with the current alternate setting
udi_api = udc_ptr_conf->udi_apis[iface_num];
-#if (0!=USB_DEVICE_MAX_EP)
+#if (0 != USB_DEVICE_MAX_EP)
if (!udc_update_iface_desc(iface_num, udi_api->getsetting())) {
return false;
}
@@ -317,13 +285,10 @@ static bool udc_iface_disable(uint8_t iface_num)
// Start at the beginning of interface descriptor
{
usb_ep_desc_t UDC_DESC_STORAGE *ep_desc;
- ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *) udc_ptr_iface;
+ ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *)udc_ptr_iface;
while (1) {
// Search Endpoint descriptor included in global interface descriptor
- ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *)
- udc_next_desc_in_iface((UDC_DESC_STORAGE
- usb_conf_desc_t *)
- ep_desc, USB_DT_ENDPOINT);
+ ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *)udc_next_desc_in_iface((UDC_DESC_STORAGE usb_conf_desc_t *)ep_desc, USB_DT_ENDPOINT);
if (NULL == ep_desc) {
break;
}
@@ -348,31 +313,23 @@ static bool udc_iface_disable(uint8_t iface_num)
*
* \return 1 if it is done or 0 if interface is not found
*/
-static bool udc_iface_enable(uint8_t iface_num, uint8_t setting_num)
-{
+static bool udc_iface_enable(uint8_t iface_num, uint8_t setting_num) {
// Select the interface descriptor
if (!udc_update_iface_desc(iface_num, setting_num)) {
return false;
}
-#if (0!=USB_DEVICE_MAX_EP)
+#if (0 != USB_DEVICE_MAX_EP)
usb_ep_desc_t UDC_DESC_STORAGE *ep_desc;
// Start at the beginning of the global interface descriptor
- ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *) udc_ptr_iface;
+ ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *)udc_ptr_iface;
while (1) {
// Search Endpoint descriptor included in the global interface descriptor
- ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *)
- udc_next_desc_in_iface((UDC_DESC_STORAGE
- usb_conf_desc_t *) ep_desc,
- USB_DT_ENDPOINT);
- if (NULL == ep_desc)
- break;
+ ep_desc = (UDC_DESC_STORAGE usb_ep_desc_t *)udc_next_desc_in_iface((UDC_DESC_STORAGE usb_conf_desc_t *)ep_desc, USB_DT_ENDPOINT);
+ if (NULL == ep_desc) break;
// Alloc the endpoint used by the interface
- if (!udd_ep_alloc(ep_desc->bEndpointAddress,
- ep_desc->bmAttributes,
- le16_to_cpu
- (ep_desc->wMaxPacketSize))) {
+ if (!udd_ep_alloc(ep_desc->bEndpointAddress, ep_desc->bmAttributes, le16_to_cpu(ep_desc->wMaxPacketSize))) {
return false;
}
}
@@ -383,15 +340,11 @@ static bool udc_iface_enable(uint8_t iface_num, uint8_t setting_num)
/*! \brief Start the USB Device stack
*/
-void udc_start(void)
-{
- udd_enable();
-}
+void udc_start(void) { udd_enable(); }
/*! \brief Stop the USB Device stack
*/
-void udc_stop(void)
-{
+void udc_stop(void) {
udd_disable();
udc_reset();
}
@@ -400,20 +353,16 @@ void udc_stop(void)
* \brief Reset the current configuration of the USB device,
* This routines can be called by UDD when a RESET on the USB line occurs.
*/
-void udc_reset(void)
-{
+void udc_reset(void) {
uint8_t iface_num;
if (udc_num_configuration) {
- for (iface_num = 0;
- iface_num < udc_ptr_conf->desc->bNumInterfaces;
- iface_num++) {
+ for (iface_num = 0; iface_num < udc_ptr_conf->desc->bNumInterfaces; iface_num++) {
udc_iface_disable(iface_num);
}
}
udc_num_configuration = 0;
-#if (USB_CONFIG_ATTR_REMOTE_WAKEUP \
- == (USB_DEVICE_ATTR & USB_CONFIG_ATTR_REMOTE_WAKEUP))
+#if (USB_CONFIG_ATTR_REMOTE_WAKEUP == (USB_DEVICE_ATTR & USB_CONFIG_ATTR_REMOTE_WAKEUP))
if (CPU_TO_LE16(USB_DEV_STATUS_REMOTEWAKEUP) & udc_device_status) {
// Remote wakeup is enabled then disable it
UDC_REMOTEWAKEUP_DISABLE();
@@ -421,20 +370,17 @@ void udc_reset(void)
#endif
udc_device_status =
#if (USB_DEVICE_ATTR & USB_CONFIG_ATTR_SELF_POWERED)
- CPU_TO_LE16(USB_DEV_STATUS_SELF_POWERED);
+ CPU_TO_LE16(USB_DEV_STATUS_SELF_POWERED);
#else
- CPU_TO_LE16(USB_DEV_STATUS_BUS_POWERED);
+ CPU_TO_LE16(USB_DEV_STATUS_BUS_POWERED);
#endif
}
-void udc_sof_notify(void)
-{
+void udc_sof_notify(void) {
uint8_t iface_num;
if (udc_num_configuration) {
- for (iface_num = 0;
- iface_num < udc_ptr_conf->desc->bNumInterfaces;
- iface_num++) {
+ for (iface_num = 0; iface_num < udc_ptr_conf->desc->bNumInterfaces; iface_num++) {
if (udc_ptr_conf->udi_apis[iface_num]->sof_notify != NULL) {
udc_ptr_conf->udi_apis[iface_num]->sof_notify();
}
@@ -447,36 +393,31 @@ void udc_sof_notify(void)
*
* \return true if success
*/
-static bool udc_req_std_dev_get_status(void)
-{
+static bool udc_req_std_dev_get_status(void) {
if (udd_g_ctrlreq.req.wLength != sizeof(udc_device_status)) {
return false;
}
- udd_set_setup_payload( (uint8_t *) & udc_device_status,
- sizeof(udc_device_status));
+ udd_set_setup_payload((uint8_t *)&udc_device_status, sizeof(udc_device_status));
return true;
}
-#if (0!=USB_DEVICE_MAX_EP)
+#if (0 != USB_DEVICE_MAX_EP)
/**
* \brief Standard endpoint request to get endpoint status
*
* \return true if success
*/
-static bool udc_req_std_ep_get_status(void)
-{
+static bool udc_req_std_ep_get_status(void) {
static le16_t udc_ep_status;
if (udd_g_ctrlreq.req.wLength != sizeof(udc_ep_status)) {
return false;
}
- udc_ep_status = udd_ep_is_halted(udd_g_ctrlreq.req.
- wIndex & 0xFF) ? CPU_TO_LE16(USB_EP_STATUS_HALTED) : 0;
+ udc_ep_status = udd_ep_is_halted(udd_g_ctrlreq.req.wIndex & 0xFF) ? CPU_TO_LE16(USB_EP_STATUS_HALTED) : 0;
- udd_set_setup_payload( (uint8_t *) & udc_ep_status,
- sizeof(udc_ep_status));
+ udd_set_setup_payload((uint8_t *)&udc_ep_status, sizeof(udc_ep_status));
return true;
}
#endif
@@ -486,16 +427,14 @@ static bool udc_req_std_ep_get_status(void)
*
* \return true if success
*/
-static bool udc_req_std_dev_clear_feature(void)
-{
+static bool udc_req_std_dev_clear_feature(void) {
if (udd_g_ctrlreq.req.wLength) {
return false;
}
if (udd_g_ctrlreq.req.wValue == USB_DEV_FEATURE_REMOTE_WAKEUP) {
udc_device_status &= CPU_TO_LE16(~(uint32_t)USB_DEV_STATUS_REMOTEWAKEUP);
-#if (USB_CONFIG_ATTR_REMOTE_WAKEUP \
- == (USB_DEVICE_ATTR & USB_CONFIG_ATTR_REMOTE_WAKEUP))
+#if (USB_CONFIG_ATTR_REMOTE_WAKEUP == (USB_DEVICE_ATTR & USB_CONFIG_ATTR_REMOTE_WAKEUP))
UDC_REMOTEWAKEUP_DISABLE();
#endif
return true;
@@ -503,14 +442,13 @@ static bool udc_req_std_dev_clear_feature(void)
return false;
}
-#if (0!=USB_DEVICE_MAX_EP)
+#if (0 != USB_DEVICE_MAX_EP)
/**
* \brief Standard endpoint request to clear endpoint feature
*
* \return true if success
*/
-static bool udc_req_std_ep_clear_feature(void)
-{
+static bool udc_req_std_ep_clear_feature(void) {
if (udd_g_ctrlreq.req.wLength) {
return false;
}
@@ -527,59 +465,56 @@ static bool udc_req_std_ep_clear_feature(void)
*
* \return true if success
*/
-static bool udc_req_std_dev_set_feature(void)
-{
+static bool udc_req_std_dev_set_feature(void) {
if (udd_g_ctrlreq.req.wLength) {
return false;
}
switch (udd_g_ctrlreq.req.wValue) {
-
- case USB_DEV_FEATURE_REMOTE_WAKEUP:
-#if (USB_CONFIG_ATTR_REMOTE_WAKEUP \
- == (USB_DEVICE_ATTR & USB_CONFIG_ATTR_REMOTE_WAKEUP))
- udc_device_status |= CPU_TO_LE16(USB_DEV_STATUS_REMOTEWAKEUP);
- UDC_REMOTEWAKEUP_ENABLE();
- return true;
+ case USB_DEV_FEATURE_REMOTE_WAKEUP:
+#if (USB_CONFIG_ATTR_REMOTE_WAKEUP == (USB_DEVICE_ATTR & USB_CONFIG_ATTR_REMOTE_WAKEUP))
+ udc_device_status |= CPU_TO_LE16(USB_DEV_STATUS_REMOTEWAKEUP);
+ UDC_REMOTEWAKEUP_ENABLE();
+ return true;
#else
- return false;
+ return false;
#endif
#ifdef USB_DEVICE_HS_SUPPORT
- case USB_DEV_FEATURE_TEST_MODE:
- if (!udd_is_high_speed()) {
- break;
- }
- if (udd_g_ctrlreq.req.wIndex & 0xff) {
+ case USB_DEV_FEATURE_TEST_MODE:
+ if (!udd_is_high_speed()) {
+ break;
+ }
+ if (udd_g_ctrlreq.req.wIndex & 0xff) {
+ break;
+ }
+ // Unconfigure the device, terminating all ongoing requests
+ udc_reset();
+ switch ((udd_g_ctrlreq.req.wIndex >> 8) & 0xFF) {
+ case USB_DEV_TEST_MODE_J:
+ udd_g_ctrlreq.callback = udd_test_mode_j;
+ return true;
+
+ case USB_DEV_TEST_MODE_K:
+ udd_g_ctrlreq.callback = udd_test_mode_k;
+ return true;
+
+ case USB_DEV_TEST_MODE_SE0_NAK:
+ udd_g_ctrlreq.callback = udd_test_mode_se0_nak;
+ return true;
+
+ case USB_DEV_TEST_MODE_PACKET:
+ udd_g_ctrlreq.callback = udd_test_mode_packet;
+ return true;
+
+ case USB_DEV_TEST_MODE_FORCE_ENABLE: // Only for downstream facing hub ports
+ default:
+ break;
+ }
break;
- }
- // Unconfigure the device, terminating all ongoing requests
- udc_reset();
- switch ((udd_g_ctrlreq.req.wIndex >> 8) & 0xFF) {
- case USB_DEV_TEST_MODE_J:
- udd_g_ctrlreq.callback = udd_test_mode_j;
- return true;
-
- case USB_DEV_TEST_MODE_K:
- udd_g_ctrlreq.callback = udd_test_mode_k;
- return true;
-
- case USB_DEV_TEST_MODE_SE0_NAK:
- udd_g_ctrlreq.callback = udd_test_mode_se0_nak;
- return true;
-
- case USB_DEV_TEST_MODE_PACKET:
- udd_g_ctrlreq.callback = udd_test_mode_packet;
- return true;
-
- case USB_DEV_TEST_MODE_FORCE_ENABLE: // Only for downstream facing hub ports
+#endif
default:
break;
- }
- break;
-#endif
- default:
- break;
}
return false;
}
@@ -589,9 +524,8 @@ static bool udc_req_std_dev_set_feature(void)
*
* \return true if success
*/
-#if (0!=USB_DEVICE_MAX_EP)
-static bool udc_req_std_ep_set_feature(void)
-{
+#if (0 != USB_DEVICE_MAX_EP)
+static bool udc_req_std_ep_set_feature(void) {
if (udd_g_ctrlreq.req.wLength) {
return false;
}
@@ -607,18 +541,14 @@ static bool udc_req_std_ep_set_feature(void)
* \brief Change the address of device
* Callback called at the end of request set address
*/
-static void udc_valid_address(void)
-{
- udd_set_address(udd_g_ctrlreq.req.wValue & 0x7F);
-}
+static void udc_valid_address(void) { udd_set_address(udd_g_ctrlreq.req.wValue & 0x7F); }
/**
* \brief Standard device request to set device address
*
* \return true if success
*/
-static bool udc_req_std_dev_set_address(void)
-{
+static bool udc_req_std_dev_set_address(void) {
if (udd_g_ctrlreq.req.wLength) {
return false;
}
@@ -634,53 +564,49 @@ static bool udc_req_std_dev_set_address(void)
*
* \return true if success
*/
-static bool udc_req_std_dev_get_str_desc(void)
-{
- uint8_t i;
+static bool udc_req_std_dev_get_str_desc(void) {
+ uint8_t i;
const uint8_t *str;
- uint8_t str_length = 0;
+ uint8_t str_length = 0;
// Link payload pointer to the string corresponding at request
switch (udd_g_ctrlreq.req.wValue & 0xff) {
- case 0:
- udd_set_setup_payload((uint8_t *) &udc_string_desc_languageid,
- sizeof(udc_string_desc_languageid));
- break;
+ case 0:
+ udd_set_setup_payload((uint8_t *)&udc_string_desc_languageid, sizeof(udc_string_desc_languageid));
+ break;
#ifdef USB_DEVICE_MANUFACTURE_NAME
- case 1:
- str_length = USB_DEVICE_MANUFACTURE_NAME_SIZE;
- str = udc_string_manufacturer_name;
- break;
+ case 1:
+ str_length = USB_DEVICE_MANUFACTURE_NAME_SIZE;
+ str = udc_string_manufacturer_name;
+ break;
#endif
#ifdef USB_DEVICE_PRODUCT_NAME
- case 2:
- str_length = USB_DEVICE_PRODUCT_NAME_SIZE;
- str = udc_string_product_name;
- break;
+ case 2:
+ str_length = USB_DEVICE_PRODUCT_NAME_SIZE;
+ str = udc_string_product_name;
+ break;
#endif
- case 3:
- str = udc_get_string_serial_name();
- str_length = usb_device_serial_name_size;
- break;
- default:
-#ifdef UDC_GET_EXTRA_STRING
- if (UDC_GET_EXTRA_STRING()) {
+ case 3:
+ str = udc_get_string_serial_name();
+ str_length = usb_device_serial_name_size;
break;
- }
+ default:
+#ifdef UDC_GET_EXTRA_STRING
+ if (UDC_GET_EXTRA_STRING()) {
+ break;
+ }
#endif
- return false;
+ return false;
}
if (str_length) {
- for(i = 0; i < str_length; i++) {
+ for (i = 0; i < str_length; i++) {
udc_string_desc.string[i] = cpu_to_le16((le16_t)str[i]);
}
- udc_string_desc.header.bLength = 2 + (str_length) * 2;
- udd_set_setup_payload(
- (uint8_t *) &udc_string_desc,
- udc_string_desc.header.bLength);
+ udc_string_desc.header.bLength = 2 + (str_length)*2;
+ udd_set_setup_payload((uint8_t *)&udc_string_desc, udc_string_desc.header.bLength);
}
return true;
@@ -691,106 +617,89 @@ static bool udc_req_std_dev_get_str_desc(void)
*
* \return true if success
*/
-static bool udc_req_std_dev_get_descriptor(void)
-{
+static bool udc_req_std_dev_get_descriptor(void) {
uint8_t conf_num;
conf_num = udd_g_ctrlreq.req.wValue & 0xff;
// Check descriptor ID
- switch ((uint8_t) (udd_g_ctrlreq.req.wValue >> 8)) {
- case USB_DT_DEVICE:
- // Device descriptor requested
+ switch ((uint8_t)(udd_g_ctrlreq.req.wValue >> 8)) {
+ case USB_DT_DEVICE:
+ // Device descriptor requested
#ifdef USB_DEVICE_HS_SUPPORT
- if (!udd_is_high_speed()) {
- udd_set_setup_payload(
- (uint8_t *) udc_config.confdev_hs,
- udc_config.confdev_hs->bLength);
- } else
+ if (!udd_is_high_speed()) {
+ udd_set_setup_payload((uint8_t *)udc_config.confdev_hs, udc_config.confdev_hs->bLength);
+ } else
#endif
- {
- udd_set_setup_payload(
- (uint8_t *) udc_config.confdev_lsfs,
- udc_config.confdev_lsfs->bLength);
- }
- break;
+ {
+ udd_set_setup_payload((uint8_t *)udc_config.confdev_lsfs, udc_config.confdev_lsfs->bLength);
+ }
+ break;
- case USB_DT_CONFIGURATION:
- // Configuration descriptor requested
+ case USB_DT_CONFIGURATION:
+ // Configuration descriptor requested
#ifdef USB_DEVICE_HS_SUPPORT
- if (udd_is_high_speed()) {
- // HS descriptor
- if (conf_num >= udc_config.confdev_hs->bNumConfigurations) {
- return false;
- }
- udd_set_setup_payload(
- (uint8_t *)udc_config.conf_hs[conf_num].desc,
- le16_to_cpu(udc_config.conf_hs[conf_num].desc->wTotalLength));
- } else
+ if (udd_is_high_speed()) {
+ // HS descriptor
+ if (conf_num >= udc_config.confdev_hs->bNumConfigurations) {
+ return false;
+ }
+ udd_set_setup_payload((uint8_t *)udc_config.conf_hs[conf_num].desc, le16_to_cpu(udc_config.conf_hs[conf_num].desc->wTotalLength));
+ } else
#endif
- {
- // FS descriptor
- if (conf_num >= udc_config.confdev_lsfs->bNumConfigurations) {
- return false;
+ {
+ // FS descriptor
+ if (conf_num >= udc_config.confdev_lsfs->bNumConfigurations) {
+ return false;
+ }
+ udd_set_setup_payload((uint8_t *)udc_config.conf_lsfs[conf_num].desc, le16_to_cpu(udc_config.conf_lsfs[conf_num].desc->wTotalLength));
}
- udd_set_setup_payload(
- (uint8_t *)udc_config.conf_lsfs[conf_num].desc,
- le16_to_cpu(udc_config.conf_lsfs[conf_num].desc->wTotalLength));
- }
- ((usb_conf_desc_t *) udd_g_ctrlreq.payload)->bDescriptorType =
- USB_DT_CONFIGURATION;
- break;
+ ((usb_conf_desc_t *)udd_g_ctrlreq.payload)->bDescriptorType = USB_DT_CONFIGURATION;
+ break;
#ifdef USB_DEVICE_HS_SUPPORT
- case USB_DT_DEVICE_QUALIFIER:
- // Device qualifier descriptor requested
- udd_set_setup_payload( (uint8_t *) udc_config.qualifier,
- udc_config.qualifier->bLength);
- break;
-
- case USB_DT_OTHER_SPEED_CONFIGURATION:
- // Other configuration descriptor requested
- if (!udd_is_high_speed()) {
- // HS descriptor
- if (conf_num >= udc_config.confdev_hs->bNumConfigurations) {
- return false;
+ case USB_DT_DEVICE_QUALIFIER:
+ // Device qualifier descriptor requested
+ udd_set_setup_payload((uint8_t *)udc_config.qualifier, udc_config.qualifier->bLength);
+ break;
+
+ case USB_DT_OTHER_SPEED_CONFIGURATION:
+ // Other configuration descriptor requested
+ if (!udd_is_high_speed()) {
+ // HS descriptor
+ if (conf_num >= udc_config.confdev_hs->bNumConfigurations) {
+ return false;
+ }
+ udd_set_setup_payload((uint8_t *)udc_config.conf_hs[conf_num].desc, le16_to_cpu(udc_config.conf_hs[conf_num].desc->wTotalLength));
+ } else {
+ // FS descriptor
+ if (conf_num >= udc_config.confdev_lsfs->bNumConfigurations) {
+ return false;
+ }
+ udd_set_setup_payload((uint8_t *)udc_config.conf_lsfs[conf_num].desc, le16_to_cpu(udc_config.conf_lsfs[conf_num].desc->wTotalLength));
}
- udd_set_setup_payload(
- (uint8_t *)udc_config.conf_hs[conf_num].desc,
- le16_to_cpu(udc_config.conf_hs[conf_num].desc->wTotalLength));
- } else {
- // FS descriptor
- if (conf_num >= udc_config.confdev_lsfs->bNumConfigurations) {
+ ((usb_conf_desc_t *)udd_g_ctrlreq.payload)->bDescriptorType = USB_DT_OTHER_SPEED_CONFIGURATION;
+ break;
+#endif
+
+ case USB_DT_BOS:
+ // Device BOS descriptor requested
+ if (udc_config.conf_bos == NULL) {
return false;
}
- udd_set_setup_payload(
- (uint8_t *)udc_config.conf_lsfs[conf_num].desc,
- le16_to_cpu(udc_config.conf_lsfs[conf_num].desc->wTotalLength));
- }
- ((usb_conf_desc_t *) udd_g_ctrlreq.payload)->bDescriptorType =
- USB_DT_OTHER_SPEED_CONFIGURATION;
- break;
-#endif
+ udd_set_setup_payload((uint8_t *)udc_config.conf_bos, udc_config.conf_bos->wTotalLength);
+ break;
- case USB_DT_BOS:
- // Device BOS descriptor requested
- if (udc_config.conf_bos == NULL) {
- return false;
- }
- udd_set_setup_payload( (uint8_t *) udc_config.conf_bos,
- udc_config.conf_bos->wTotalLength);
- break;
+ case USB_DT_STRING:
+ // String descriptor requested
+ if (!udc_req_std_dev_get_str_desc()) {
+ return false;
+ }
+ break;
- case USB_DT_STRING:
- // String descriptor requested
- if (!udc_req_std_dev_get_str_desc()) {
+ default:
+ // Unknown descriptor requested
return false;
- }
- break;
-
- default:
- // Unknown descriptor requested
- return false;
}
// if the descriptor is larger than length requested, then reduce it
if (udd_g_ctrlreq.req.wLength < udd_g_ctrlreq.payload_size) {
@@ -804,13 +713,12 @@ static bool udc_req_std_dev_get_descriptor(void)
*
* \return true if success
*/
-static bool udc_req_std_dev_get_configuration(void)
-{
+static bool udc_req_std_dev_get_configuration(void) {
if (udd_g_ctrlreq.req.wLength != 1) {
return false;
}
- udd_set_setup_payload(&udc_num_configuration,1);
+ udd_set_setup_payload(&udc_num_configuration, 1);
return true;
}
@@ -819,8 +727,7 @@ static bool udc_req_std_dev_get_configuration(void)
*
* \return true if success
*/
-static bool udc_req_std_dev_set_configuration(void)
-{
+static bool udc_req_std_dev_set_configuration(void) {
uint8_t iface_num;
// Check request length
@@ -835,16 +742,14 @@ static bool udc_req_std_dev_set_configuration(void)
#ifdef USB_DEVICE_HS_SUPPORT
if (udd_is_high_speed()) {
// HS descriptor
- if ((udd_g_ctrlreq.req.wValue & 0xFF) >
- udc_config.confdev_hs->bNumConfigurations) {
+ if ((udd_g_ctrlreq.req.wValue & 0xFF) > udc_config.confdev_hs->bNumConfigurations) {
return false;
}
} else
#endif
{
// FS descriptor
- if ((udd_g_ctrlreq.req.wValue & 0xFF) >
- udc_config.confdev_lsfs->bNumConfigurations) {
+ if ((udd_g_ctrlreq.req.wValue & 0xFF) > udc_config.confdev_lsfs->bNumConfigurations) {
return false;
}
}
@@ -855,7 +760,7 @@ static bool udc_req_std_dev_set_configuration(void)
// Enable new configuration
udc_num_configuration = udd_g_ctrlreq.req.wValue & 0xFF;
if (udc_num_configuration == 0) {
- return true; // Default empty configuration requested
+ return true; // Default empty configuration requested
}
// Update pointer of the configuration descriptor
#ifdef USB_DEVICE_HS_SUPPORT
@@ -869,8 +774,7 @@ static bool udc_req_std_dev_set_configuration(void)
udc_ptr_conf = &udc_config.conf_lsfs[udc_num_configuration - 1];
}
// Enable all interfaces of the selected configuration
- for (iface_num = 0; iface_num < udc_ptr_conf->desc->bNumInterfaces;
- iface_num++) {
+ for (iface_num = 0; iface_num < udc_ptr_conf->desc->bNumInterfaces; iface_num++) {
if (!udc_iface_enable(iface_num, 0)) {
return false;
}
@@ -884,16 +788,15 @@ static bool udc_req_std_dev_set_configuration(void)
*
* \return true if success
*/
-static bool udc_req_std_iface_get_setting(void)
-{
- uint8_t iface_num;
+static bool udc_req_std_iface_get_setting(void) {
+ uint8_t iface_num;
udi_api_t UDC_DESC_STORAGE *udi_api;
if (udd_g_ctrlreq.req.wLength != 1) {
- return false; // Error in request
+ return false; // Error in request
}
if (!udc_num_configuration) {
- return false; // The device is not is configured state yet
+ return false; // The device is not is configured state yet
}
// Check the interface number included in the request
@@ -908,11 +811,11 @@ static bool udc_req_std_iface_get_setting(void)
return false;
}
// Get alternate setting from UDI
- udi_api = udc_ptr_conf->udi_apis[iface_num];
+ udi_api = udc_ptr_conf->udi_apis[iface_num];
udc_iface_setting = udi_api->getsetting();
// Link value to payload pointer of request
- udd_set_setup_payload(&udc_iface_setting,1);
+ udd_set_setup_payload(&udc_iface_setting, 1);
return true;
}
@@ -922,18 +825,17 @@ static bool udc_req_std_iface_get_setting(void)
*
* \return true if success
*/
-static bool udc_req_std_iface_set_setting(void)
-{
+static bool udc_req_std_iface_set_setting(void) {
uint8_t iface_num, setting_num;
if (udd_g_ctrlreq.req.wLength) {
- return false; // Error in request
+ return false; // Error in request
}
if (!udc_num_configuration) {
- return false; // The device is not is configured state yet
+ return false; // The device is not is configured state yet
}
- iface_num = udd_g_ctrlreq.req.wIndex & 0xFF;
+ iface_num = udd_g_ctrlreq.req.wIndex & 0xFF;
setting_num = udd_g_ctrlreq.req.wValue & 0xFF;
// Disable current setting
@@ -950,45 +852,44 @@ static bool udc_req_std_iface_set_setting(void)
*
* \return true if the request is supported
*/
-static bool udc_reqstd(void)
-{
+static bool udc_reqstd(void) {
if (Udd_setup_is_in()) {
// GET Standard Requests
if (udd_g_ctrlreq.req.wLength == 0) {
- return false; // Error for USB host
+ return false; // Error for USB host
}
if (USB_REQ_RECIP_DEVICE == Udd_setup_recipient()) {
// Standard Get Device request
switch (udd_g_ctrlreq.req.bRequest) {
- case USB_REQ_GET_STATUS:
- return udc_req_std_dev_get_status();
- case USB_REQ_GET_DESCRIPTOR:
- return udc_req_std_dev_get_descriptor();
- case USB_REQ_GET_CONFIGURATION:
- return udc_req_std_dev_get_configuration();
- default:
- break;
+ case USB_REQ_GET_STATUS:
+ return udc_req_std_dev_get_status();
+ case USB_REQ_GET_DESCRIPTOR:
+ return udc_req_std_dev_get_descriptor();
+ case USB_REQ_GET_CONFIGURATION:
+ return udc_req_std_dev_get_configuration();
+ default:
+ break;
}
}
if (USB_REQ_RECIP_INTERFACE == Udd_setup_recipient()) {
// Standard Get Interface request
switch (udd_g_ctrlreq.req.bRequest) {
- case USB_REQ_GET_INTERFACE:
- return udc_req_std_iface_get_setting();
- default:
- break;
+ case USB_REQ_GET_INTERFACE:
+ return udc_req_std_iface_get_setting();
+ default:
+ break;
}
}
-#if (0!=USB_DEVICE_MAX_EP)
+#if (0 != USB_DEVICE_MAX_EP)
if (USB_REQ_RECIP_ENDPOINT == Udd_setup_recipient()) {
// Standard Get Endpoint request
switch (udd_g_ctrlreq.req.bRequest) {
- case USB_REQ_GET_STATUS:
- return udc_req_std_ep_get_status();
- default:
- break;
+ case USB_REQ_GET_STATUS:
+ return udc_req_std_ep_get_status();
+ default:
+ break;
}
}
#endif
@@ -997,41 +898,41 @@ static bool udc_reqstd(void)
if (USB_REQ_RECIP_DEVICE == Udd_setup_recipient()) {
// Standard Set Device request
switch (udd_g_ctrlreq.req.bRequest) {
- case USB_REQ_SET_ADDRESS:
- return udc_req_std_dev_set_address();
- case USB_REQ_CLEAR_FEATURE:
- return udc_req_std_dev_clear_feature();
- case USB_REQ_SET_FEATURE:
- return udc_req_std_dev_set_feature();
- case USB_REQ_SET_CONFIGURATION:
- return udc_req_std_dev_set_configuration();
- case USB_REQ_SET_DESCRIPTOR:
- /* Not supported (defined as optional by the USB 2.0 spec) */
- break;
- default:
- break;
+ case USB_REQ_SET_ADDRESS:
+ return udc_req_std_dev_set_address();
+ case USB_REQ_CLEAR_FEATURE:
+ return udc_req_std_dev_clear_feature();
+ case USB_REQ_SET_FEATURE:
+ return udc_req_std_dev_set_feature();
+ case USB_REQ_SET_CONFIGURATION:
+ return udc_req_std_dev_set_configuration();
+ case USB_REQ_SET_DESCRIPTOR:
+ /* Not supported (defined as optional by the USB 2.0 spec) */
+ break;
+ default:
+ break;
}
}
if (USB_REQ_RECIP_INTERFACE == Udd_setup_recipient()) {
// Standard Set Interface request
switch (udd_g_ctrlreq.req.bRequest) {
- case USB_REQ_SET_INTERFACE:
- return udc_req_std_iface_set_setting();
- default:
- break;
+ case USB_REQ_SET_INTERFACE:
+ return udc_req_std_iface_set_setting();
+ default:
+ break;
}
}
-#if (0!=USB_DEVICE_MAX_EP)
+#if (0 != USB_DEVICE_MAX_EP)
if (USB_REQ_RECIP_ENDPOINT == Udd_setup_recipient()) {
// Standard Set Endpoint request
switch (udd_g_ctrlreq.req.bRequest) {
- case USB_REQ_CLEAR_FEATURE:
- return udc_req_std_ep_clear_feature();
- case USB_REQ_SET_FEATURE:
- return udc_req_std_ep_set_feature();
- default:
- break;
+ case USB_REQ_CLEAR_FEATURE:
+ return udc_req_std_ep_clear_feature();
+ case USB_REQ_SET_FEATURE:
+ return udc_req_std_ep_set_feature();
+ default:
+ break;
}
}
#endif
@@ -1044,13 +945,12 @@ static bool udc_reqstd(void)
*
* \return true if the request is supported
*/
-static bool udc_req_iface(void)
-{
- uint8_t iface_num;
+static bool udc_req_iface(void) {
+ uint8_t iface_num;
udi_api_t UDC_DESC_STORAGE *udi_api;
if (0 == udc_num_configuration) {
- return false; // The device is not is configured state yet
+ return false; // The device is not is configured state yet
}
// Check interface number
iface_num = udd_g_ctrlreq.req.wIndex & 0xFF;
@@ -1079,18 +979,16 @@ static bool udc_req_iface(void)
*
* \return true if the request is supported
*/
-static bool udc_req_ep(void)
-{
- uint8_t iface_num;
+static bool udc_req_ep(void) {
+ uint8_t iface_num;
udi_api_t UDC_DESC_STORAGE *udi_api;
if (0 == udc_num_configuration) {
- return false; // The device is not is configured state yet
+ return false; // The device is not is configured state yet
}
// Send this request on all enabled interfaces
iface_num = udd_g_ctrlreq.req.wIndex & 0xFF;
- for (iface_num = 0; iface_num < udc_ptr_conf->desc->bNumInterfaces;
- iface_num++) {
+ for (iface_num = 0; iface_num < udc_ptr_conf->desc->bNumInterfaces; iface_num++) {
// Select the interface with the current alternate setting
udi_api = udc_ptr_conf->udi_apis[iface_num];
if (!udc_update_iface_desc(iface_num, udi_api->getsetting())) {
@@ -1118,16 +1016,15 @@ static bool udc_req_ep(void)
*
* \return true if the request is supported, else the request is stalled by UDD
*/
-bool udc_process_setup(void)
-{
+bool udc_process_setup(void) {
// By default no data (receive/send) and no callbacks registered
- udd_g_ctrlreq.payload_size = 0;
- udd_g_ctrlreq.callback = NULL;
+ udd_g_ctrlreq.payload_size = 0;
+ udd_g_ctrlreq.callback = NULL;
udd_g_ctrlreq.over_under_run = NULL;
if (Udd_setup_is_in()) {
if (udd_g_ctrlreq.req.wLength == 0) {
- return false; // Error from USB host
+ return false; // Error from USB host
}
}
@@ -1155,7 +1052,7 @@ bool udc_process_setup(void)
// Here SETUP request unknown by UDC and UDIs
#ifdef USB_DEVICE_SPECIFIC_REQUEST
// Try to decode it in specific callback
- return USB_DEVICE_SPECIFIC_REQUEST(); // Ex: Vendor request,...
+ return USB_DEVICE_SPECIFIC_REQUEST(); // Ex: Vendor request,...
#else
return false;
#endif
diff --git a/tmk_core/protocol/arm_atsam/usb/udc.h b/tmk_core/protocol/arm_atsam/usb/udc.h
index 33335d1869..8d33307d3c 100644
--- a/tmk_core/protocol/arm_atsam/usb/udc.h
+++ b/tmk_core/protocol/arm_atsam/usb/udc.h
@@ -53,11 +53,11 @@
#include "udd.h"
#if USB_DEVICE_VENDOR_ID == 0
-# error USB_DEVICE_VENDOR_ID cannot be equal to 0
+# error USB_DEVICE_VENDOR_ID cannot be equal to 0
#endif
#if USB_DEVICE_PRODUCT_ID == 0
-# error USB_DEVICE_PRODUCT_ID cannot be equal to 0
+# error USB_DEVICE_PRODUCT_ID cannot be equal to 0
#endif
#ifdef __cplusplus
@@ -172,10 +172,7 @@ extern "C" {
}
\endcode
*/
-static inline bool udc_include_vbus_monitoring(void)
-{
- return udd_include_vbus_monitoring();
-}
+static inline bool udc_include_vbus_monitoring(void) { return udd_include_vbus_monitoring(); }
/*! \brief Start the USB Device stack
*/
@@ -192,28 +189,19 @@ void udc_stop(void);
* then it will attach device when an acceptable Vbus
* level from the host is detected.
*/
-static inline void udc_attach(void)
-{
- udd_attach();
-}
+static inline void udc_attach(void) { udd_attach(); }
/**
* \brief Detaches the device from the bus
*
* The driver must remove pull-up on USB line D- or D+.
*/
-static inline void udc_detach(void)
-{
- udd_detach();
-}
+static inline void udc_detach(void) { udd_detach(); }
/*! \brief The USB driver sends a resume signal called \e "Upstream Resume"
* This is authorized only when the remote wakeup feature is enabled by host.
*/
-inline void udc_remotewakeup(void)
-{
- udd_send_remotewakeup();
-}
+inline void udc_remotewakeup(void) { udd_send_remotewakeup(); }
/**
* \brief Returns a pointer on the current interface descriptor
@@ -257,4 +245,4 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void);
}
#endif
-#endif // _UDC_H_
+#endif // _UDC_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/udc_desc.h b/tmk_core/protocol/arm_atsam/usb/udc_desc.h
index 9cab03dcb3..39ea153b40 100644
--- a/tmk_core/protocol/arm_atsam/usb/udc_desc.h
+++ b/tmk_core/protocol/arm_atsam/usb/udc_desc.h
@@ -77,23 +77,21 @@ extern "C" {
*
* For Mega application used "code".
*/
-#define UDC_DESC_STORAGE
- // Descriptor storage in internal RAM
+#define UDC_DESC_STORAGE
+// Descriptor storage in internal RAM
#if (defined UDC_DATA_USE_HRAM_SUPPORT)
-#if defined(__GNUC__)
-#define UDC_DATA(x) COMPILER_WORD_ALIGNED __attribute__((__section__(".data_hram0")))
-#define UDC_BSS(x) COMPILER_ALIGNED(x) __attribute__((__section__(".bss_hram0")))
-#elif defined(__ICCAVR32__)
-#define UDC_DATA(x) COMPILER_ALIGNED(x) __data32
-#define UDC_BSS(x) COMPILER_ALIGNED(x) __data32
-#endif
+# if defined(__GNUC__)
+# define UDC_DATA(x) COMPILER_WORD_ALIGNED __attribute__((__section__(".data_hram0")))
+# define UDC_BSS(x) COMPILER_ALIGNED(x) __attribute__((__section__(".bss_hram0")))
+# elif defined(__ICCAVR32__)
+# define UDC_DATA(x) COMPILER_ALIGNED(x) __data32
+# define UDC_BSS(x) COMPILER_ALIGNED(x) __data32
+# endif
#else
-#define UDC_DATA(x) COMPILER_ALIGNED(x)
-#define UDC_BSS(x) COMPILER_ALIGNED(x)
+# define UDC_DATA(x) COMPILER_ALIGNED(x)
+# define UDC_BSS(x) COMPILER_ALIGNED(x)
#endif
-
-
/**
* \brief Configuration descriptor and UDI link for one USB speed
*/
@@ -101,10 +99,9 @@ typedef struct {
//! USB configuration descriptor
usb_conf_desc_t UDC_DESC_STORAGE *desc;
//! Array of UDI API pointer
- udi_api_t UDC_DESC_STORAGE *UDC_DESC_STORAGE * udi_apis;
+ udi_api_t UDC_DESC_STORAGE *UDC_DESC_STORAGE *udi_apis;
} udc_config_speed_t;
-
/**
* \brief All information about the USB Device
*/
@@ -132,4 +129,4 @@ extern UDC_DESC_STORAGE udc_config_t udc_config;
#ifdef __cplusplus
}
#endif
-#endif // _UDC_DESC_H_
+#endif // _UDC_DESC_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/udd.h b/tmk_core/protocol/arm_atsam/usb/udd.h
index b580e58479..805b761a77 100644
--- a/tmk_core/protocol/arm_atsam/usb/udd.h
+++ b/tmk_core/protocol/arm_atsam/usb/udd.h
@@ -71,7 +71,7 @@ typedef uint8_t udd_ep_id_t;
//! \brief Endpoint transfer status
//! Returned in parameters of callback register via udd_ep_run routine.
typedef enum {
- UDD_EP_TRANSFER_OK = 0,
+ UDD_EP_TRANSFER_OK = 0,
UDD_EP_TRANSFER_ABORT = 1,
} udd_ep_status_t;
@@ -94,36 +94,32 @@ typedef struct {
uint16_t payload_size;
//! Callback called after reception of ZLP from setup request
- void (*callback) (void);
+ void (*callback)(void);
//! Callback called when the buffer given (.payload) is full or empty.
//! This one return false to abort data transfer, or true with a new buffer in .payload.
- bool(*over_under_run) (void);
+ bool (*over_under_run)(void);
} udd_ctrl_request_t;
extern udd_ctrl_request_t udd_g_ctrlreq;
//! Return true if the setup request \a udd_g_ctrlreq indicates IN data transfer
-#define Udd_setup_is_in() \
- (USB_REQ_DIR_IN == (udd_g_ctrlreq.req.bmRequestType & USB_REQ_DIR_MASK))
+#define Udd_setup_is_in() (USB_REQ_DIR_IN == (udd_g_ctrlreq.req.bmRequestType & USB_REQ_DIR_MASK))
//! Return true if the setup request \a udd_g_ctrlreq indicates OUT data transfer
-#define Udd_setup_is_out() \
- (USB_REQ_DIR_OUT == (udd_g_ctrlreq.req.bmRequestType & USB_REQ_DIR_MASK))
+#define Udd_setup_is_out() (USB_REQ_DIR_OUT == (udd_g_ctrlreq.req.bmRequestType & USB_REQ_DIR_MASK))
//! Return the type of the SETUP request \a udd_g_ctrlreq. \see usb_reqtype.
-#define Udd_setup_type() \
- (udd_g_ctrlreq.req.bmRequestType & USB_REQ_TYPE_MASK)
+#define Udd_setup_type() (udd_g_ctrlreq.req.bmRequestType & USB_REQ_TYPE_MASK)
//! Return the recipient of the SETUP request \a udd_g_ctrlreq. \see usb_recipient
-#define Udd_setup_recipient() \
- (udd_g_ctrlreq.req.bmRequestType & USB_REQ_RECIP_MASK)
+#define Udd_setup_recipient() (udd_g_ctrlreq.req.bmRequestType & USB_REQ_RECIP_MASK)
/**
* \brief End of halt callback function type.
* Registered by routine udd_ep_wait_stall_clear()
* Callback called when endpoint stall is cleared.
*/
-typedef void (*udd_callback_halt_cleared_t) (void);
+typedef void (*udd_callback_halt_cleared_t)(void);
/**
* \brief End of transfer callback function type.
@@ -134,8 +130,7 @@ typedef void (*udd_callback_halt_cleared_t) (void);
* \param status UDD_EP_TRANSFER_ABORT, if transfer is aborted
* \param n number of data transfered
*/
-typedef void (*udd_callback_trans_t) (udd_ep_status_t status,
- iram_size_t nb_transfered, udd_ep_id_t ep);
+typedef void (*udd_callback_trans_t)(udd_ep_status_t status, iram_size_t nb_transfered, udd_ep_id_t ep);
/**
* \brief Authorizes the VBUS event
@@ -216,8 +211,7 @@ void udd_send_remotewakeup(void);
* \param payload Pointer on payload
* \param payload_size Size of payload
*/
-void udd_set_setup_payload( uint8_t *payload, uint16_t payload_size );
-
+void udd_set_setup_payload(uint8_t *payload, uint16_t payload_size);
/**
* \name Endpoint Management
@@ -239,8 +233,7 @@ void udd_set_setup_payload( uint8_t *payload, uint16_t payload_size );
*
* \return \c 1 if the endpoint is enabled, otherwise \c 0.
*/
-bool udd_ep_alloc(udd_ep_id_t ep, uint8_t bmAttributes,
- uint16_t MaxEndpointSize);
+bool udd_ep_alloc(udd_ep_id_t ep, uint8_t bmAttributes, uint16_t MaxEndpointSize);
/**
* \brief Disables an endpoint
@@ -294,8 +287,7 @@ bool udd_ep_clear_halt(udd_ep_id_t ep);
*
* \return \c 1 if the register is accepted, otherwise \c 0.
*/
-bool udd_ep_wait_stall_clear(udd_ep_id_t ep,
- udd_callback_halt_cleared_t callback);
+bool udd_ep_wait_stall_clear(udd_ep_id_t ep, udd_callback_halt_cleared_t callback);
/**
* \brief Allows to receive or send data on an endpoint
@@ -321,9 +313,7 @@ bool udd_ep_wait_stall_clear(udd_ep_id_t ep,
*
* \return \c 1 if function was successfully done, otherwise \c 0.
*/
-bool udd_ep_run(udd_ep_id_t ep, bool b_shortpacket,
- uint8_t *buf, iram_size_t buf_size,
- udd_callback_trans_t callback);
+bool udd_ep_run(udd_ep_id_t ep, bool b_shortpacket, uint8_t *buf, iram_size_t buf_size, udd_callback_trans_t callback);
/**
* \brief Aborts transfer on going on endpoint
*
@@ -339,7 +329,6 @@ void udd_ep_abort(udd_ep_id_t ep);
//@}
-
/**
* \name High speed test mode management
*
@@ -352,7 +341,6 @@ void udd_test_mode_se0_nak(void);
void udd_test_mode_packet(void);
//@}
-
/**
* \name UDC callbacks to provide for UDD
*
@@ -393,4 +381,4 @@ extern void udc_sof_notify(void);
#ifdef __cplusplus
}
#endif
-#endif // _UDD_H_
+#endif // _UDD_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/udi.h b/tmk_core/protocol/arm_atsam/usb/udi.h
index 9e4d4baf7f..89942cce4d 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi.h
+++ b/tmk_core/protocol/arm_atsam/usb/udi.h
@@ -72,57 +72,57 @@ extern "C" {
* selected by UDC.
*/
typedef struct {
- /**
- * \brief Enable the interface.
- *
- * This function is called when the host selects a configuration
- * to which this interface belongs through a Set Configuration
- * request, and when the host selects an alternate setting of
- * this interface through a Set Interface request.
- *
- * \return \c 1 if function was successfully done, otherwise \c 0.
- */
- bool(*enable) (void);
+ /**
+ * \brief Enable the interface.
+ *
+ * This function is called when the host selects a configuration
+ * to which this interface belongs through a Set Configuration
+ * request, and when the host selects an alternate setting of
+ * this interface through a Set Interface request.
+ *
+ * \return \c 1 if function was successfully done, otherwise \c 0.
+ */
+ bool (*enable)(void);
- /**
- * \brief Disable the interface.
- *
- * This function is called when this interface is currently
- * active, and
- * - the host selects any configuration through a Set
- * Configuration request, or
- * - the host issues a USB reset, or
- * - the device is detached from the host (i.e. Vbus is no
- * longer present)
- */
- void (*disable) (void);
+ /**
+ * \brief Disable the interface.
+ *
+ * This function is called when this interface is currently
+ * active, and
+ * - the host selects any configuration through a Set
+ * Configuration request, or
+ * - the host issues a USB reset, or
+ * - the device is detached from the host (i.e. Vbus is no
+ * longer present)
+ */
+ void (*disable)(void);
- /**
- * \brief Handle a control request directed at an interface.
- *
- * This function is called when this interface is currently
- * active and the host sends a SETUP request
- * with this interface as the recipient.
- *
- * Use udd_g_ctrlreq to decode and response to SETUP request.
- *
- * \return \c 1 if this interface supports the SETUP request, otherwise \c 0.
- */
- bool(*setup) (void);
+ /**
+ * \brief Handle a control request directed at an interface.
+ *
+ * This function is called when this interface is currently
+ * active and the host sends a SETUP request
+ * with this interface as the recipient.
+ *
+ * Use udd_g_ctrlreq to decode and response to SETUP request.
+ *
+ * \return \c 1 if this interface supports the SETUP request, otherwise \c 0.
+ */
+ bool (*setup)(void);
- /**
- * \brief Returns the current setting of the selected interface.
- *
- * This function is called when UDC when know alternate setting of selected interface.
- *
- * \return alternate setting of selected interface
- */
- uint8_t(*getsetting) (void);
+ /**
+ * \brief Returns the current setting of the selected interface.
+ *
+ * This function is called when UDC when know alternate setting of selected interface.
+ *
+ * \return alternate setting of selected interface
+ */
+ uint8_t (*getsetting)(void);
- /**
- * \brief To signal that a SOF is occurred
- */
- void(*sof_notify) (void);
+ /**
+ * \brief To signal that a SOF is occurred
+ */
+ void (*sof_notify)(void);
} udi_api_t;
//@}
@@ -130,4 +130,4 @@ typedef struct {
#ifdef __cplusplus
}
#endif
-#endif // _UDI_H_
+#endif // _UDI_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_cdc.c b/tmk_core/protocol/arm_atsam/usb/udi_cdc.c
index ffe3526db5..8271f3b97f 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_cdc.c
+++ b/tmk_core/protocol/arm_atsam/usb/udi_cdc.c
@@ -59,27 +59,27 @@
#ifdef CDC
-#ifdef UDI_CDC_LOW_RATE
-# ifdef USB_DEVICE_HS_SUPPORT
-# define UDI_CDC_TX_BUFFERS (UDI_CDC_DATA_EPS_HS_SIZE)
-# define UDI_CDC_RX_BUFFERS (UDI_CDC_DATA_EPS_HS_SIZE)
-# else
-# define UDI_CDC_TX_BUFFERS (UDI_CDC_DATA_EPS_FS_SIZE)
-# define UDI_CDC_RX_BUFFERS (UDI_CDC_DATA_EPS_FS_SIZE)
-# endif
-#else
-# ifdef USB_DEVICE_HS_SUPPORT
-# define UDI_CDC_TX_BUFFERS (UDI_CDC_DATA_EPS_HS_SIZE)
-# define UDI_CDC_RX_BUFFERS (UDI_CDC_DATA_EPS_HS_SIZE)
-# else
-# define UDI_CDC_TX_BUFFERS (5*UDI_CDC_DATA_EPS_FS_SIZE)
-# define UDI_CDC_RX_BUFFERS (5*UDI_CDC_DATA_EPS_FS_SIZE)
-# endif
-#endif
-
-#ifndef UDI_CDC_TX_EMPTY_NOTIFY
-# define UDI_CDC_TX_EMPTY_NOTIFY(port)
-#endif
+# ifdef UDI_CDC_LOW_RATE
+# ifdef USB_DEVICE_HS_SUPPORT
+# define UDI_CDC_TX_BUFFERS (UDI_CDC_DATA_EPS_HS_SIZE)
+# define UDI_CDC_RX_BUFFERS (UDI_CDC_DATA_EPS_HS_SIZE)
+# else
+# define UDI_CDC_TX_BUFFERS (UDI_CDC_DATA_EPS_FS_SIZE)
+# define UDI_CDC_RX_BUFFERS (UDI_CDC_DATA_EPS_FS_SIZE)
+# endif
+# else
+# ifdef USB_DEVICE_HS_SUPPORT
+# define UDI_CDC_TX_BUFFERS (UDI_CDC_DATA_EPS_HS_SIZE)
+# define UDI_CDC_RX_BUFFERS (UDI_CDC_DATA_EPS_HS_SIZE)
+# else
+# define UDI_CDC_TX_BUFFERS (5 * UDI_CDC_DATA_EPS_FS_SIZE)
+# define UDI_CDC_RX_BUFFERS (5 * UDI_CDC_DATA_EPS_FS_SIZE)
+# endif
+# endif
+
+# ifndef UDI_CDC_TX_EMPTY_NOTIFY
+# define UDI_CDC_TX_EMPTY_NOTIFY(port)
+# endif
/**
* \ingroup udi_cdc_group
@@ -89,25 +89,19 @@
*
* @{
*/
-bool udi_cdc_comm_enable(void);
-void udi_cdc_comm_disable(void);
-bool udi_cdc_comm_setup(void);
-bool udi_cdc_data_enable(void);
-void udi_cdc_data_disable(void);
-bool udi_cdc_data_setup(void);
-uint8_t udi_cdc_getsetting(void);
-void udi_cdc_data_sof_notify(void);
-UDC_DESC_STORAGE udi_api_t udi_api_cdc_comm = {
- .enable = udi_cdc_comm_enable,
- .disable = udi_cdc_comm_disable,
- .setup = udi_cdc_comm_setup,
- .getsetting = udi_cdc_getsetting,
- .sof_notify = NULL
-};
+bool udi_cdc_comm_enable(void);
+void udi_cdc_comm_disable(void);
+bool udi_cdc_comm_setup(void);
+bool udi_cdc_data_enable(void);
+void udi_cdc_data_disable(void);
+bool udi_cdc_data_setup(void);
+uint8_t udi_cdc_getsetting(void);
+void udi_cdc_data_sof_notify(void);
+UDC_DESC_STORAGE udi_api_t udi_api_cdc_comm = {.enable = udi_cdc_comm_enable, .disable = udi_cdc_comm_disable, .setup = udi_cdc_comm_setup, .getsetting = udi_cdc_getsetting, .sof_notify = NULL};
UDC_DESC_STORAGE udi_api_t udi_api_cdc_data = {
- .enable = udi_cdc_data_enable,
- .disable = udi_cdc_data_disable,
- .setup = udi_cdc_data_setup,
+ .enable = udi_cdc_data_enable,
+ .disable = udi_cdc_data_disable,
+ .setup = udi_cdc_data_setup,
.getsetting = udi_cdc_getsetting,
.sof_notify = udi_cdc_data_sof_notify,
};
@@ -226,9 +220,9 @@ static void udi_cdc_tx_send(uint8_t port);
*/
//@{
COMPILER_WORD_ALIGNED
-static usb_cdc_line_coding_t udi_cdc_line_coding[UDI_CDC_PORT_NB];
-static bool udi_cdc_serial_state_msg_ongoing[UDI_CDC_PORT_NB];
-static volatile le16_t udi_cdc_state[UDI_CDC_PORT_NB];
+static usb_cdc_line_coding_t udi_cdc_line_coding[UDI_CDC_PORT_NB];
+static bool udi_cdc_serial_state_msg_ongoing[UDI_CDC_PORT_NB];
+static volatile le16_t udi_cdc_state[UDI_CDC_PORT_NB];
COMPILER_WORD_ALIGNED static usb_cdc_notify_serial_state_t uid_cdc_state_msg[UDI_CDC_PORT_NB];
//! Status of CDC COMM interfaces
@@ -243,7 +237,7 @@ static volatile uint8_t udi_cdc_nb_comm_enabled = 0;
//! Status of CDC DATA interfaces
static volatile uint8_t udi_cdc_nb_data_enabled = 0;
-static volatile bool udi_cdc_data_running = false;
+static volatile bool udi_cdc_data_running = false;
//! Buffer to receive data
COMPILER_WORD_ALIGNED static uint8_t udi_cdc_rx_buf[UDI_CDC_PORT_NB][2][UDI_CDC_RX_BUFFERS];
//! Data available in RX buffers
@@ -256,7 +250,7 @@ static volatile uint16_t udi_cdc_rx_pos[UDI_CDC_PORT_NB];
static volatile bool udi_cdc_rx_trans_ongoing[UDI_CDC_PORT_NB];
//! Define a transfer halted
-#define UDI_CDC_TRANS_HALTED 2
+# define UDI_CDC_TRANS_HALTED 2
//! Buffer to send data
COMPILER_WORD_ALIGNED static uint8_t udi_cdc_tx_buf[UDI_CDC_PORT_NB][2][UDI_CDC_TX_BUFFERS];
@@ -273,29 +267,26 @@ static volatile bool udi_cdc_tx_both_buf_to_send[UDI_CDC_PORT_NB];
//@}
-bool udi_cdc_comm_enable(void)
-{
+bool udi_cdc_comm_enable(void) {
uint8_t port;
uint8_t iface_comm_num;
-//#if UDI_CDC_PORT_NB == 1 // To optimize code
- port = 0;
+ //#if UDI_CDC_PORT_NB == 1 // To optimize code
+ port = 0;
udi_cdc_nb_comm_enabled = 0;
-//#else
-// if (udi_cdc_nb_comm_enabled > UDI_CDC_PORT_NB) {
-// udi_cdc_nb_comm_enabled = 0;
-// }
-// port = udi_cdc_nb_comm_enabled;
-//#endif
+ //#else
+ // if (udi_cdc_nb_comm_enabled > UDI_CDC_PORT_NB) {
+ // udi_cdc_nb_comm_enabled = 0;
+ // }
+ // port = udi_cdc_nb_comm_enabled;
+ //#endif
// Initialize control signal management
udi_cdc_state[port] = CPU_TO_LE16(0);
- uid_cdc_state_msg[port].header.bmRequestType =
- USB_REQ_DIR_IN | USB_REQ_TYPE_CLASS |
- USB_REQ_RECIP_INTERFACE;
+ uid_cdc_state_msg[port].header.bmRequestType = USB_REQ_DIR_IN | USB_REQ_TYPE_CLASS | USB_REQ_RECIP_INTERFACE;
uid_cdc_state_msg[port].header.bNotification = USB_REQ_CDC_NOTIFY_SERIAL_STATE;
- uid_cdc_state_msg[port].header.wValue = LE16(0);
+ uid_cdc_state_msg[port].header.wValue = LE16(0);
/*
switch (port) {
@@ -312,55 +303,54 @@ bool udi_cdc_comm_enable(void)
*/
iface_comm_num = UDI_CDC_COMM_IFACE_NUMBER_0;
- uid_cdc_state_msg[port].header.wIndex = LE16(iface_comm_num);
+ uid_cdc_state_msg[port].header.wIndex = LE16(iface_comm_num);
uid_cdc_state_msg[port].header.wLength = LE16(2);
- uid_cdc_state_msg[port].value = CPU_TO_LE16(0);
+ uid_cdc_state_msg[port].value = CPU_TO_LE16(0);
- udi_cdc_line_coding[port].dwDTERate = CPU_TO_LE32(UDI_CDC_DEFAULT_RATE);
+ udi_cdc_line_coding[port].dwDTERate = CPU_TO_LE32(UDI_CDC_DEFAULT_RATE);
udi_cdc_line_coding[port].bCharFormat = UDI_CDC_DEFAULT_STOPBITS;
udi_cdc_line_coding[port].bParityType = UDI_CDC_DEFAULT_PARITY;
- udi_cdc_line_coding[port].bDataBits = UDI_CDC_DEFAULT_DATABITS;
+ udi_cdc_line_coding[port].bDataBits = UDI_CDC_DEFAULT_DATABITS;
// Call application callback
// to initialize memories or indicate that interface is enabled
-#if 0
+# if 0
UDI_CDC_SET_CODING_EXT(port,(&udi_cdc_line_coding[port]));
if (!UDI_CDC_ENABLE_EXT(port)) {
return false;
}
-#endif
+# endif
udi_cdc_nb_comm_enabled++;
return true;
}
-bool udi_cdc_data_enable(void)
-{
+bool udi_cdc_data_enable(void) {
uint8_t port;
-//#if UDI_CDC_PORT_NB == 1 // To optimize code
- port = 0;
+ //#if UDI_CDC_PORT_NB == 1 // To optimize code
+ port = 0;
udi_cdc_nb_data_enabled = 0;
-//#else
-// if (udi_cdc_nb_data_enabled > UDI_CDC_PORT_NB) {
-// udi_cdc_nb_data_enabled = 0;
-// }
-// port = udi_cdc_nb_data_enabled;
-//#endif
+ //#else
+ // if (udi_cdc_nb_data_enabled > UDI_CDC_PORT_NB) {
+ // udi_cdc_nb_data_enabled = 0;
+ // }
+ // port = udi_cdc_nb_data_enabled;
+ //#endif
// Initialize TX management
- udi_cdc_tx_trans_ongoing[port] = false;
+ udi_cdc_tx_trans_ongoing[port] = false;
udi_cdc_tx_both_buf_to_send[port] = false;
- udi_cdc_tx_buf_sel[port] = 0;
- udi_cdc_tx_buf_nb[port][0] = 0;
- udi_cdc_tx_buf_nb[port][1] = 0;
- udi_cdc_tx_sof_num[port] = 0;
+ udi_cdc_tx_buf_sel[port] = 0;
+ udi_cdc_tx_buf_nb[port][0] = 0;
+ udi_cdc_tx_buf_nb[port][1] = 0;
+ udi_cdc_tx_sof_num[port] = 0;
udi_cdc_tx_send(port);
// Initialize RX management
udi_cdc_rx_trans_ongoing[port] = false;
- udi_cdc_rx_buf_sel[port] = 0;
- udi_cdc_rx_buf_nb[port][0] = 0;
- udi_cdc_rx_buf_nb[port][1] = 0;
- udi_cdc_rx_pos[port] = 0;
+ udi_cdc_rx_buf_sel[port] = 0;
+ udi_cdc_rx_buf_nb[port][0] = 0;
+ udi_cdc_rx_buf_nb[port][1] = 0;
+ udi_cdc_rx_pos[port] = 0;
if (!udi_cdc_rx_start(port)) {
return false;
}
@@ -371,25 +361,22 @@ bool udi_cdc_data_enable(void)
return true;
}
-void udi_cdc_comm_disable(void)
-{
+void udi_cdc_comm_disable(void) {
Assert(udi_cdc_nb_comm_enabled != 0);
udi_cdc_nb_comm_enabled--;
}
-void udi_cdc_data_disable(void)
-{
-// uint8_t port;
+void udi_cdc_data_disable(void) {
+ // uint8_t port;
Assert(udi_cdc_nb_data_enabled != 0);
udi_cdc_nb_data_enabled--;
-// port = udi_cdc_nb_data_enabled;
-// UDI_CDC_DISABLE_EXT(port);
+ // port = udi_cdc_nb_data_enabled;
+ // UDI_CDC_DISABLE_EXT(port);
udi_cdc_data_running = false;
}
-bool udi_cdc_comm_setup(void)
-{
+bool udi_cdc_comm_setup(void) {
uint8_t port = udi_cdc_setup_to_port();
if (Udd_setup_is_in()) {
@@ -397,17 +384,12 @@ bool udi_cdc_comm_setup(void)
if (Udd_setup_type() == USB_REQ_TYPE_CLASS) {
// Requests Class Interface Get
switch (udd_g_ctrlreq.req.bRequest) {
- case USB_REQ_CDC_GET_LINE_CODING:
- // Get configuration of CDC line
- if (sizeof(usb_cdc_line_coding_t) !=
- udd_g_ctrlreq.req.wLength)
- return false; // Error for USB host
- udd_g_ctrlreq.payload =
- (uint8_t *) &
- udi_cdc_line_coding[port];
- udd_g_ctrlreq.payload_size =
- sizeof(usb_cdc_line_coding_t);
- return true;
+ case USB_REQ_CDC_GET_LINE_CODING:
+ // Get configuration of CDC line
+ if (sizeof(usb_cdc_line_coding_t) != udd_g_ctrlreq.req.wLength) return false; // Error for USB host
+ udd_g_ctrlreq.payload = (uint8_t *)&udi_cdc_line_coding[port];
+ udd_g_ctrlreq.payload_size = sizeof(usb_cdc_line_coding_t);
+ return true;
}
}
}
@@ -416,46 +398,37 @@ bool udi_cdc_comm_setup(void)
if (Udd_setup_type() == USB_REQ_TYPE_CLASS) {
// Requests Class Interface Set
switch (udd_g_ctrlreq.req.bRequest) {
- case USB_REQ_CDC_SET_LINE_CODING:
- // Change configuration of CDC line
- if (sizeof(usb_cdc_line_coding_t) !=
- udd_g_ctrlreq.req.wLength)
- return false; // Error for USB host
- udd_g_ctrlreq.callback =
- udi_cdc_line_coding_received;
- udd_g_ctrlreq.payload =
- (uint8_t *) &
- udi_cdc_line_coding[port];
- udd_g_ctrlreq.payload_size =
- sizeof(usb_cdc_line_coding_t);
- return true;
- case USB_REQ_CDC_SET_CONTROL_LINE_STATE:
- // According cdc spec 1.1 chapter 6.2.14
-// UDI_CDC_SET_DTR_EXT(port, (0 !=
-// (udd_g_ctrlreq.req.wValue
-// & CDC_CTRL_SIGNAL_DTE_PRESENT)));
-// UDI_CDC_SET_RTS_EXT(port, (0 !=
-// (udd_g_ctrlreq.req.wValue
-// & CDC_CTRL_SIGNAL_ACTIVATE_CARRIER)));
- return true;
+ case USB_REQ_CDC_SET_LINE_CODING:
+ // Change configuration of CDC line
+ if (sizeof(usb_cdc_line_coding_t) != udd_g_ctrlreq.req.wLength) return false; // Error for USB host
+ udd_g_ctrlreq.callback = udi_cdc_line_coding_received;
+ udd_g_ctrlreq.payload = (uint8_t *)&udi_cdc_line_coding[port];
+ udd_g_ctrlreq.payload_size = sizeof(usb_cdc_line_coding_t);
+ return true;
+ case USB_REQ_CDC_SET_CONTROL_LINE_STATE:
+ // According cdc spec 1.1 chapter 6.2.14
+ // UDI_CDC_SET_DTR_EXT(port, (0 !=
+ // (udd_g_ctrlreq.req.wValue
+ // & CDC_CTRL_SIGNAL_DTE_PRESENT)));
+ // UDI_CDC_SET_RTS_EXT(port, (0 !=
+ // (udd_g_ctrlreq.req.wValue
+ // & CDC_CTRL_SIGNAL_ACTIVATE_CARRIER)));
+ return true;
}
}
}
return false; // request Not supported
}
-bool udi_cdc_data_setup(void)
-{
+bool udi_cdc_data_setup(void) {
return false; // request Not supported
}
-uint8_t udi_cdc_getsetting(void)
-{
- return 0; // CDC don't have multiple alternate setting
+uint8_t udi_cdc_getsetting(void) {
+ return 0; // CDC don't have multiple alternate setting
}
-void udi_cdc_data_sof_notify(void)
-{
+void udi_cdc_data_sof_notify(void) {
static uint8_t port_notify = 0;
// A call of udi_cdc_data_sof_notify() is done for each port
@@ -470,12 +443,10 @@ void udi_cdc_data_sof_notify(void)
*/
}
-
//-------------------------------------------------
//------- Internal routines to control serial line
-static uint8_t udi_cdc_setup_to_port(void)
-{
+static uint8_t udi_cdc_setup_to_port(void) {
uint8_t port;
/*
@@ -496,35 +467,32 @@ static uint8_t udi_cdc_setup_to_port(void)
return port;
}
-static void udi_cdc_line_coding_received(void)
-{
+static void udi_cdc_line_coding_received(void) {
uint8_t port = udi_cdc_setup_to_port();
UNUSED(port);
-// UDI_CDC_SET_CODING_EXT(port, (&udi_cdc_line_coding[port]));
+ // UDI_CDC_SET_CODING_EXT(port, (&udi_cdc_line_coding[port]));
}
-static void udi_cdc_ctrl_state_change(uint8_t port, bool b_set, le16_t bit_mask)
-{
+static void udi_cdc_ctrl_state_change(uint8_t port, bool b_set, le16_t bit_mask) {
udd_ep_id_t ep_comm;
- uint32_t irqflags; //irqflags_t
-
+ uint32_t irqflags; // irqflags_t
-//#if UDI_CDC_PORT_NB == 1 // To optimize code
+ //#if UDI_CDC_PORT_NB == 1 // To optimize code
port = 0;
-//#endif
+ //#endif
// Update state
- irqflags = __get_PRIMASK();
- __disable_irq();
- __DMB();
+ irqflags = __get_PRIMASK();
+ __disable_irq();
+ __DMB();
if (b_set) {
udi_cdc_state[port] |= bit_mask;
} else {
udi_cdc_state[port] &= ~(unsigned)bit_mask;
}
__DMB();
- __set_PRIMASK(irqflags);
+ __set_PRIMASK(irqflags);
/*
// Send it if possible and state changed
@@ -545,31 +513,21 @@ static void udi_cdc_ctrl_state_change(uint8_t port, bool b_set, le16_t bit_mask)
udi_cdc_ctrl_state_notify(port, ep_comm);
}
-
-static void udi_cdc_ctrl_state_notify(uint8_t port, udd_ep_id_t ep)
-{
-#if UDI_CDC_PORT_NB == 1 // To optimize code
+static void udi_cdc_ctrl_state_notify(uint8_t port, udd_ep_id_t ep) {
+# if UDI_CDC_PORT_NB == 1 // To optimize code
port = 0;
-#endif
+# endif
// Send it if possible and state changed
- if ((!udi_cdc_serial_state_msg_ongoing[port])
- && (udi_cdc_state[port] != uid_cdc_state_msg[port].value)) {
+ if ((!udi_cdc_serial_state_msg_ongoing[port]) && (udi_cdc_state[port] != uid_cdc_state_msg[port].value)) {
// Fill notification message
uid_cdc_state_msg[port].value = udi_cdc_state[port];
// Send notification message
- udi_cdc_serial_state_msg_ongoing[port] =
- udd_ep_run(ep,
- false,
- (uint8_t *) & uid_cdc_state_msg[port],
- sizeof(uid_cdc_state_msg[0]),
- udi_cdc_serial_state_msg_sent);
+ udi_cdc_serial_state_msg_ongoing[port] = udd_ep_run(ep, false, (uint8_t *)&uid_cdc_state_msg[port], sizeof(uid_cdc_state_msg[0]), udi_cdc_serial_state_msg_sent);
}
}
-
-static void udi_cdc_serial_state_msg_sent(udd_ep_status_t status, iram_size_t n, udd_ep_id_t ep)
-{
+static void udi_cdc_serial_state_msg_sent(udd_ep_status_t status, iram_size_t n, udd_ep_id_t ep) {
uint8_t port;
UNUSED(n);
UNUSED(status);
@@ -594,14 +552,8 @@ static void udi_cdc_serial_state_msg_sent(udd_ep_status_t status, iram_size_t n,
// For the irregular signals like break, the incoming ring signal,
// or the overrun error state, this will reset their values to zero
// and again will not send another notification until their state changes.
- udi_cdc_state[port] &= ~(CDC_SERIAL_STATE_BREAK |
- CDC_SERIAL_STATE_RING |
- CDC_SERIAL_STATE_FRAMING |
- CDC_SERIAL_STATE_PARITY | CDC_SERIAL_STATE_OVERRUN);
- uid_cdc_state_msg[port].value &= ~(CDC_SERIAL_STATE_BREAK |
- CDC_SERIAL_STATE_RING |
- CDC_SERIAL_STATE_FRAMING |
- CDC_SERIAL_STATE_PARITY | CDC_SERIAL_STATE_OVERRUN);
+ udi_cdc_state[port] &= ~(CDC_SERIAL_STATE_BREAK | CDC_SERIAL_STATE_RING | CDC_SERIAL_STATE_FRAMING | CDC_SERIAL_STATE_PARITY | CDC_SERIAL_STATE_OVERRUN);
+ uid_cdc_state_msg[port].value &= ~(CDC_SERIAL_STATE_BREAK | CDC_SERIAL_STATE_RING | CDC_SERIAL_STATE_FRAMING | CDC_SERIAL_STATE_PARITY | CDC_SERIAL_STATE_OVERRUN);
// Send it if possible and state changed
udi_cdc_ctrl_state_notify(port, ep);
}
@@ -609,39 +561,37 @@ static void udi_cdc_serial_state_msg_sent(udd_ep_status_t status, iram_size_t n,
//-------------------------------------------------
//------- Internal routines to process data transfer
-static bool udi_cdc_rx_start(uint8_t port)
-{
- uint32_t irqflags; //irqflags_t
- uint8_t buf_sel_trans;
+static bool udi_cdc_rx_start(uint8_t port) {
+ uint32_t irqflags; // irqflags_t
+ uint8_t buf_sel_trans;
udd_ep_id_t ep;
-//#if UDI_CDC_PORT_NB == 1 // To optimize code
+ //#if UDI_CDC_PORT_NB == 1 // To optimize code
port = 0;
-//#endif
+ //#endif
irqflags = __get_PRIMASK();
- __disable_irq();
- __DMB();
+ __disable_irq();
+ __DMB();
buf_sel_trans = udi_cdc_rx_buf_sel[port];
- if (udi_cdc_rx_trans_ongoing[port] ||
- (udi_cdc_rx_pos[port] < udi_cdc_rx_buf_nb[port][buf_sel_trans])) {
+ if (udi_cdc_rx_trans_ongoing[port] || (udi_cdc_rx_pos[port] < udi_cdc_rx_buf_nb[port][buf_sel_trans])) {
// Transfer already on-going or current buffer no empty
- __DMB();
- __set_PRIMASK(irqflags);
+ __DMB();
+ __set_PRIMASK(irqflags);
return false;
}
// Change current buffer
- udi_cdc_rx_pos[port] = 0;
- udi_cdc_rx_buf_sel[port] = (buf_sel_trans==0)?1:0;
+ udi_cdc_rx_pos[port] = 0;
+ udi_cdc_rx_buf_sel[port] = (buf_sel_trans == 0) ? 1 : 0;
// Start transfer on RX
udi_cdc_rx_trans_ongoing[port] = true;
- __DMB();
- __set_PRIMASK(irqflags);
+ __DMB();
+ __set_PRIMASK(irqflags);
if (udi_cdc_multi_is_rx_ready(port)) {
-// UDI_CDC_RX_NOTIFY(port);
+ // UDI_CDC_RX_NOTIFY(port);
}
/*
@@ -660,15 +610,10 @@ static bool udi_cdc_rx_start(uint8_t port)
*/
ep = UDI_CDC_DATA_EP_OUT_0;
- return udd_ep_run(ep,
- true,
- udi_cdc_rx_buf[port][buf_sel_trans],
- UDI_CDC_RX_BUFFERS,
- udi_cdc_data_received);
+ return udd_ep_run(ep, true, udi_cdc_rx_buf[port][buf_sel_trans], UDI_CDC_RX_BUFFERS, udi_cdc_data_received);
}
-static void udi_cdc_data_received(udd_ep_status_t status, iram_size_t n, udd_ep_id_t ep)
-{
+static void udi_cdc_data_received(udd_ep_status_t status, iram_size_t n, udd_ep_id_t ep) {
uint8_t buf_sel_trans;
uint8_t port;
@@ -692,24 +637,19 @@ static void udi_cdc_data_received(udd_ep_status_t status, iram_size_t n, udd_ep_
return;
}
- buf_sel_trans = (udi_cdc_rx_buf_sel[port]==0)?1:0;
+ buf_sel_trans = (udi_cdc_rx_buf_sel[port] == 0) ? 1 : 0;
if (!n) {
- udd_ep_run( ep,
- true,
- udi_cdc_rx_buf[port][buf_sel_trans],
- UDI_CDC_RX_BUFFERS,
- udi_cdc_data_received);
+ udd_ep_run(ep, true, udi_cdc_rx_buf[port][buf_sel_trans], UDI_CDC_RX_BUFFERS, udi_cdc_data_received);
return;
}
udi_cdc_rx_buf_nb[port][buf_sel_trans] = n;
- udi_cdc_rx_trans_ongoing[port] = false;
+ udi_cdc_rx_trans_ongoing[port] = false;
udi_cdc_rx_start(port);
}
-static void udi_cdc_data_sent(udd_ep_status_t status, iram_size_t n, udd_ep_id_t ep)
-{
+static void udi_cdc_data_sent(udd_ep_status_t status, iram_size_t n, udd_ep_id_t ep) {
uint8_t port;
UNUSED(n);
@@ -733,9 +673,9 @@ static void udi_cdc_data_sent(udd_ep_status_t status, iram_size_t n, udd_ep_id_t
return;
}
- udi_cdc_tx_buf_nb[port][(udi_cdc_tx_buf_sel[port]==0)?1:0] = 0;
- udi_cdc_tx_both_buf_to_send[port] = false;
- udi_cdc_tx_trans_ongoing[port] = false;
+ udi_cdc_tx_buf_nb[port][(udi_cdc_tx_buf_sel[port] == 0) ? 1 : 0] = 0;
+ udi_cdc_tx_both_buf_to_send[port] = false;
+ udi_cdc_tx_trans_ongoing[port] = false;
if (n != 0) {
UDI_CDC_TX_EMPTY_NOTIFY(port);
@@ -744,41 +684,39 @@ static void udi_cdc_data_sent(udd_ep_status_t status, iram_size_t n, udd_ep_id_t
udi_cdc_tx_send(port);
}
-static void udi_cdc_tx_send(uint8_t port)
-{
- uint32_t irqflags; //irqflags_t
- uint8_t buf_sel_trans;
- bool b_short_packet;
- udd_ep_id_t ep;
+static void udi_cdc_tx_send(uint8_t port) {
+ uint32_t irqflags; // irqflags_t
+ uint8_t buf_sel_trans;
+ bool b_short_packet;
+ udd_ep_id_t ep;
static uint16_t sof_zlp_counter = 0;
-//#if UDI_CDC_PORT_NB == 1 // To optimize code
+ //#if UDI_CDC_PORT_NB == 1 // To optimize code
port = 0;
-//#endif
+ //#endif
if (udi_cdc_tx_trans_ongoing[port]) {
- return; // Already on going or wait next SOF to send next data
+ return; // Already on going or wait next SOF to send next data
}
if (udd_is_high_speed()) {
if (udi_cdc_tx_sof_num[port] == udd_get_micro_frame_number()) {
- return; // Wait next SOF to send next data
+ return; // Wait next SOF to send next data
}
- }else{
+ } else {
if (udi_cdc_tx_sof_num[port] == udd_get_frame_number()) {
- return; // Wait next SOF to send next data
+ return; // Wait next SOF to send next data
}
}
irqflags = __get_PRIMASK();
- __disable_irq();
- __DMB();
+ __disable_irq();
+ __DMB();
buf_sel_trans = udi_cdc_tx_buf_sel[port];
if (udi_cdc_tx_buf_nb[port][buf_sel_trans] == 0) {
sof_zlp_counter++;
- if (((!udd_is_high_speed()) && (sof_zlp_counter < 100))
- || (udd_is_high_speed() && (sof_zlp_counter < 800))) {
- __DMB();
- __set_PRIMASK(irqflags);
+ if (((!udd_is_high_speed()) && (sof_zlp_counter < 100)) || (udd_is_high_speed() && (sof_zlp_counter < 800))) {
+ __DMB();
+ __set_PRIMASK(irqflags);
return;
}
}
@@ -787,25 +725,25 @@ static void udi_cdc_tx_send(uint8_t port)
if (!udi_cdc_tx_both_buf_to_send[port]) {
// Send current Buffer
// and switch the current buffer
- udi_cdc_tx_buf_sel[port] = (buf_sel_trans==0)?1:0;
- }else{
+ udi_cdc_tx_buf_sel[port] = (buf_sel_trans == 0) ? 1 : 0;
+ } else {
// Send the other Buffer
// and no switch the current buffer
- buf_sel_trans = (buf_sel_trans==0)?1:0;
+ buf_sel_trans = (buf_sel_trans == 0) ? 1 : 0;
}
udi_cdc_tx_trans_ongoing[port] = true;
- __DMB();
- __set_PRIMASK(irqflags);
+ __DMB();
+ __set_PRIMASK(irqflags);
b_short_packet = (udi_cdc_tx_buf_nb[port][buf_sel_trans] != UDI_CDC_TX_BUFFERS);
if (b_short_packet) {
if (udd_is_high_speed()) {
udi_cdc_tx_sof_num[port] = udd_get_micro_frame_number();
- }else{
+ } else {
udi_cdc_tx_sof_num[port] = udd_get_frame_number();
}
- }else{
- udi_cdc_tx_sof_num[port] = 0; // Force next transfer without wait SOF
+ } else {
+ udi_cdc_tx_sof_num[port] = 0; // Force next transfer without wait SOF
}
/*
@@ -824,126 +762,81 @@ static void udi_cdc_tx_send(uint8_t port)
*/
ep = UDI_CDC_DATA_EP_IN_0;
- udd_ep_run( ep,
- b_short_packet,
- udi_cdc_tx_buf[port][buf_sel_trans],
- udi_cdc_tx_buf_nb[port][buf_sel_trans],
- udi_cdc_data_sent);
+ udd_ep_run(ep, b_short_packet, udi_cdc_tx_buf[port][buf_sel_trans], udi_cdc_tx_buf_nb[port][buf_sel_trans], udi_cdc_data_sent);
}
//---------------------------------------------
//------- Application interface
-void udi_cdc_ctrl_signal_dcd(bool b_set)
-{
- udi_cdc_ctrl_state_change(0, b_set, CDC_SERIAL_STATE_DCD);
-}
+void udi_cdc_ctrl_signal_dcd(bool b_set) { udi_cdc_ctrl_state_change(0, b_set, CDC_SERIAL_STATE_DCD); }
-void udi_cdc_ctrl_signal_dsr(bool b_set)
-{
- udi_cdc_ctrl_state_change(0, b_set, CDC_SERIAL_STATE_DSR);
-}
+void udi_cdc_ctrl_signal_dsr(bool b_set) { udi_cdc_ctrl_state_change(0, b_set, CDC_SERIAL_STATE_DSR); }
-void udi_cdc_signal_framing_error(void)
-{
- udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_FRAMING);
-}
+void udi_cdc_signal_framing_error(void) { udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_FRAMING); }
-void udi_cdc_signal_parity_error(void)
-{
- udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_PARITY);
-}
+void udi_cdc_signal_parity_error(void) { udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_PARITY); }
-void udi_cdc_signal_overrun(void)
-{
- udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_OVERRUN);
-}
+void udi_cdc_signal_overrun(void) { udi_cdc_ctrl_state_change(0, true, CDC_SERIAL_STATE_OVERRUN); }
-void udi_cdc_multi_ctrl_signal_dcd(uint8_t port, bool b_set)
-{
- udi_cdc_ctrl_state_change(port, b_set, CDC_SERIAL_STATE_DCD);
-}
+void udi_cdc_multi_ctrl_signal_dcd(uint8_t port, bool b_set) { udi_cdc_ctrl_state_change(port, b_set, CDC_SERIAL_STATE_DCD); }
-void udi_cdc_multi_ctrl_signal_dsr(uint8_t port, bool b_set)
-{
- udi_cdc_ctrl_state_change(port, b_set, CDC_SERIAL_STATE_DSR);
-}
+void udi_cdc_multi_ctrl_signal_dsr(uint8_t port, bool b_set) { udi_cdc_ctrl_state_change(port, b_set, CDC_SERIAL_STATE_DSR); }
-void udi_cdc_multi_signal_framing_error(uint8_t port)
-{
- udi_cdc_ctrl_state_change(port, true, CDC_SERIAL_STATE_FRAMING);
-}
+void udi_cdc_multi_signal_framing_error(uint8_t port) { udi_cdc_ctrl_state_change(port, true, CDC_SERIAL_STATE_FRAMING); }
-void udi_cdc_multi_signal_parity_error(uint8_t port)
-{
- udi_cdc_ctrl_state_change(port, true, CDC_SERIAL_STATE_PARITY);
-}
+void udi_cdc_multi_signal_parity_error(uint8_t port) { udi_cdc_ctrl_state_change(port, true, CDC_SERIAL_STATE_PARITY); }
-void udi_cdc_multi_signal_overrun(uint8_t port)
-{
- udi_cdc_ctrl_state_change(port, true, CDC_SERIAL_STATE_OVERRUN);
-}
+void udi_cdc_multi_signal_overrun(uint8_t port) { udi_cdc_ctrl_state_change(port, true, CDC_SERIAL_STATE_OVERRUN); }
-iram_size_t udi_cdc_multi_get_nb_received_data(uint8_t port)
-{
- uint32_t irqflags; //irqflags_t
- uint16_t pos;
+iram_size_t udi_cdc_multi_get_nb_received_data(uint8_t port) {
+ uint32_t irqflags; // irqflags_t
+ uint16_t pos;
iram_size_t nb_received;
-//#if UDI_CDC_PORT_NB == 1 // To optimize code
+ //#if UDI_CDC_PORT_NB == 1 // To optimize code
port = 0;
-//#endif
+ //#endif
irqflags = __get_PRIMASK();
- __disable_irq();
- __DMB();
- pos = udi_cdc_rx_pos[port];
+ __disable_irq();
+ __DMB();
+ pos = udi_cdc_rx_pos[port];
nb_received = udi_cdc_rx_buf_nb[port][udi_cdc_rx_buf_sel[port]] - pos;
__DMB();
- __set_PRIMASK(irqflags);
+ __set_PRIMASK(irqflags);
return nb_received;
}
-iram_size_t udi_cdc_get_nb_received_data(void)
-{
- return udi_cdc_multi_get_nb_received_data(0);
-}
+iram_size_t udi_cdc_get_nb_received_data(void) { return udi_cdc_multi_get_nb_received_data(0); }
-bool udi_cdc_multi_is_rx_ready(uint8_t port)
-{
- return (udi_cdc_multi_get_nb_received_data(port) > 0);
-}
+bool udi_cdc_multi_is_rx_ready(uint8_t port) { return (udi_cdc_multi_get_nb_received_data(port) > 0); }
-bool udi_cdc_is_rx_ready(void)
-{
- return udi_cdc_multi_is_rx_ready(0);
-}
+bool udi_cdc_is_rx_ready(void) { return udi_cdc_multi_is_rx_ready(0); }
-int udi_cdc_multi_getc(uint8_t port)
-{
- uint32_t irqflags; //irqflags_t
- int rx_data = 0;
- bool b_databit_9;
+int udi_cdc_multi_getc(uint8_t port) {
+ uint32_t irqflags; // irqflags_t
+ int rx_data = 0;
+ bool b_databit_9;
uint16_t pos;
- uint8_t buf_sel;
- bool again;
+ uint8_t buf_sel;
+ bool again;
-//#if UDI_CDC_PORT_NB == 1 // To optimize code
+ //#if UDI_CDC_PORT_NB == 1 // To optimize code
port = 0;
-//#endif
+ //#endif
b_databit_9 = (9 == udi_cdc_line_coding[port].bDataBits);
udi_cdc_getc_process_one_byte:
// Check available data
irqflags = __get_PRIMASK();
- __disable_irq();
- __DMB();
- pos = udi_cdc_rx_pos[port];
+ __disable_irq();
+ __DMB();
+ pos = udi_cdc_rx_pos[port];
buf_sel = udi_cdc_rx_buf_sel[port];
- again = pos >= udi_cdc_rx_buf_nb[port][buf_sel];
+ again = pos >= udi_cdc_rx_buf_nb[port][buf_sel];
__DMB();
- __set_PRIMASK(irqflags);
+ __set_PRIMASK(irqflags);
while (again) {
if (!udi_cdc_data_running) {
return 0;
@@ -953,46 +846,43 @@ udi_cdc_getc_process_one_byte:
// Read data
rx_data |= udi_cdc_rx_buf[port][buf_sel][pos];
- udi_cdc_rx_pos[port] = pos+1;
+ udi_cdc_rx_pos[port] = pos + 1;
udi_cdc_rx_start(port);
if (b_databit_9) {
// Receive MSB
b_databit_9 = false;
- rx_data = rx_data << 8;
+ rx_data = rx_data << 8;
goto udi_cdc_getc_process_one_byte;
}
return rx_data;
}
-int udi_cdc_getc(void)
-{
- return udi_cdc_multi_getc(0);
-}
+int udi_cdc_getc(void) { return udi_cdc_multi_getc(0); }
-iram_size_t udi_cdc_multi_read_buf(uint8_t port, void* buf, iram_size_t size)
-{
- uint32_t irqflags; //irqflags_t
- uint8_t *ptr_buf = (uint8_t *)buf;
+iram_size_t udi_cdc_multi_read_buf(uint8_t port, void *buf, iram_size_t size) {
+ uint32_t irqflags; // irqflags_t
+ uint8_t * ptr_buf = (uint8_t *)buf;
iram_size_t copy_nb;
- uint16_t pos;
- uint8_t buf_sel;
- bool again;
+ uint16_t pos;
+ uint8_t buf_sel;
+ bool again;
-//#if UDI_CDC_PORT_NB == 1 // To optimize code
+ //#if UDI_CDC_PORT_NB == 1 // To optimize code
port = 0;
-//#endif
+ //#endif
udi_cdc_read_buf_loop_wait:
// Check available data
irqflags = __get_PRIMASK();
- __disable_irq();
- __DMB(); pos = udi_cdc_rx_pos[port];
+ __disable_irq();
+ __DMB();
+ pos = udi_cdc_rx_pos[port];
buf_sel = udi_cdc_rx_buf_sel[port];
- again = pos >= udi_cdc_rx_buf_nb[port][buf_sel];
+ again = pos >= udi_cdc_rx_buf_nb[port][buf_sel];
__DMB();
- __set_PRIMASK(irqflags);
+ __set_PRIMASK(irqflags);
while (again) {
if (!udi_cdc_data_running) {
return size;
@@ -1002,7 +892,7 @@ udi_cdc_read_buf_loop_wait:
// Read data
copy_nb = udi_cdc_rx_buf_nb[port][buf_sel] - pos;
- if (copy_nb>size) {
+ if (copy_nb > size) {
copy_nb = size;
}
memcpy(ptr_buf, &udi_cdc_rx_buf[port][buf_sel][pos], copy_nb);
@@ -1017,118 +907,99 @@ udi_cdc_read_buf_loop_wait:
return 0;
}
-static iram_size_t udi_cdc_multi_read_no_polling(uint8_t port, void* buf, iram_size_t size)
-{
- uint8_t *ptr_buf = (uint8_t *)buf;
+static iram_size_t udi_cdc_multi_read_no_polling(uint8_t port, void *buf, iram_size_t size) {
+ uint8_t * ptr_buf = (uint8_t *)buf;
iram_size_t nb_avail_data;
- uint16_t pos;
- uint8_t buf_sel;
- uint32_t irqflags; //irqflags_t
+ uint16_t pos;
+ uint8_t buf_sel;
+ uint32_t irqflags; // irqflags_t
-//#if UDI_CDC_PORT_NB == 1 // To optimize code
+ //#if UDI_CDC_PORT_NB == 1 // To optimize code
port = 0;
-//#endif
+ //#endif
- //Data interface not started... exit
+ // Data interface not started... exit
if (!udi_cdc_data_running) {
return 0;
}
- //Get number of available data
+ // Get number of available data
// Check available data
irqflags = __get_PRIMASK();
- __disable_irq();
- __DMB();
- pos = udi_cdc_rx_pos[port];
- buf_sel = udi_cdc_rx_buf_sel[port];
+ __disable_irq();
+ __DMB();
+ pos = udi_cdc_rx_pos[port];
+ buf_sel = udi_cdc_rx_buf_sel[port];
nb_avail_data = udi_cdc_rx_buf_nb[port][buf_sel] - pos;
__DMB();
- __set_PRIMASK(irqflags);
- //If the buffer contains less than the requested number of data,
- //adjust read size
- if(nb_avail_data<size) {
+ __set_PRIMASK(irqflags);
+ // If the buffer contains less than the requested number of data,
+ // adjust read size
+ if (nb_avail_data < size) {
size = nb_avail_data;
}
- if(size>0) {
+ if (size > 0) {
memcpy(ptr_buf, &udi_cdc_rx_buf[port][buf_sel][pos], size);
- irqflags = __get_PRIMASK();
- __disable_irq();
- __DMB();
+ irqflags = __get_PRIMASK();
+ __disable_irq();
+ __DMB();
udi_cdc_rx_pos[port] += size;
- __DMB();
- __set_PRIMASK(irqflags);
+ __DMB();
+ __set_PRIMASK(irqflags);
ptr_buf += size;
udi_cdc_rx_start(port);
}
- return(nb_avail_data);
+ return (nb_avail_data);
}
-iram_size_t udi_cdc_read_no_polling(void* buf, iram_size_t size)
-{
- return udi_cdc_multi_read_no_polling(0, buf, size);
-}
+iram_size_t udi_cdc_read_no_polling(void *buf, iram_size_t size) { return udi_cdc_multi_read_no_polling(0, buf, size); }
-iram_size_t udi_cdc_read_buf(void* buf, iram_size_t size)
-{
- return udi_cdc_multi_read_buf(0, buf, size);
-}
+iram_size_t udi_cdc_read_buf(void *buf, iram_size_t size) { return udi_cdc_multi_read_buf(0, buf, size); }
-iram_size_t udi_cdc_multi_get_free_tx_buffer(uint8_t port)
-{
- uint32_t irqflags; //irqflags_t
+iram_size_t udi_cdc_multi_get_free_tx_buffer(uint8_t port) {
+ uint32_t irqflags; // irqflags_t
iram_size_t buf_sel_nb, retval;
- uint8_t buf_sel;
+ uint8_t buf_sel;
-//#if UDI_CDC_PORT_NB == 1 // To optimize code
+ //#if UDI_CDC_PORT_NB == 1 // To optimize code
port = 0;
-//#endif
+ //#endif
irqflags = __get_PRIMASK();
- __disable_irq();
- __DMB();
- buf_sel = udi_cdc_tx_buf_sel[port];
+ __disable_irq();
+ __DMB();
+ buf_sel = udi_cdc_tx_buf_sel[port];
buf_sel_nb = udi_cdc_tx_buf_nb[port][buf_sel];
if (buf_sel_nb == UDI_CDC_TX_BUFFERS) {
- if ((!udi_cdc_tx_trans_ongoing[port])
- && (!udi_cdc_tx_both_buf_to_send[port])) {
+ if ((!udi_cdc_tx_trans_ongoing[port]) && (!udi_cdc_tx_both_buf_to_send[port])) {
/* One buffer is full, but the other buffer is not used.
* (not used = transfer on-going)
* then move to the other buffer to store data */
udi_cdc_tx_both_buf_to_send[port] = true;
- udi_cdc_tx_buf_sel[port] = (buf_sel == 0)? 1 : 0;
- buf_sel_nb = 0;
+ udi_cdc_tx_buf_sel[port] = (buf_sel == 0) ? 1 : 0;
+ buf_sel_nb = 0;
}
}
retval = UDI_CDC_TX_BUFFERS - buf_sel_nb;
__DMB();
- __set_PRIMASK(irqflags);
+ __set_PRIMASK(irqflags);
return retval;
}
-iram_size_t udi_cdc_get_free_tx_buffer(void)
-{
- return udi_cdc_multi_get_free_tx_buffer(0);
-}
+iram_size_t udi_cdc_get_free_tx_buffer(void) { return udi_cdc_multi_get_free_tx_buffer(0); }
-bool udi_cdc_multi_is_tx_ready(uint8_t port)
-{
- return (udi_cdc_multi_get_free_tx_buffer(port) != 0);
-}
+bool udi_cdc_multi_is_tx_ready(uint8_t port) { return (udi_cdc_multi_get_free_tx_buffer(port) != 0); }
-bool udi_cdc_is_tx_ready(void)
-{
- return udi_cdc_multi_is_tx_ready(0);
-}
+bool udi_cdc_is_tx_ready(void) { return udi_cdc_multi_is_tx_ready(0); }
-int udi_cdc_multi_putc(uint8_t port, int value)
-{
- uint32_t irqflags; //irqflags_t
- bool b_databit_9;
- uint8_t buf_sel;
+int udi_cdc_multi_putc(uint8_t port, int value) {
+ uint32_t irqflags; // irqflags_t
+ bool b_databit_9;
+ uint8_t buf_sel;
-//#if UDI_CDC_PORT_NB == 1 // To optimize code
+ //#if UDI_CDC_PORT_NB == 1 // To optimize code
port = 0;
-//#endif
+ //#endif
b_databit_9 = (9 == udi_cdc_line_coding[port].bDataBits);
@@ -1143,44 +1014,40 @@ udi_cdc_putc_process_one_byte:
// Write value
irqflags = __get_PRIMASK();
- __disable_irq();
- __DMB();
- buf_sel = udi_cdc_tx_buf_sel[port];
+ __disable_irq();
+ __DMB();
+ buf_sel = udi_cdc_tx_buf_sel[port];
udi_cdc_tx_buf[port][buf_sel][udi_cdc_tx_buf_nb[port][buf_sel]++] = value;
- __DMB();
- __set_PRIMASK(irqflags);
+ __DMB();
+ __set_PRIMASK(irqflags);
if (b_databit_9) {
// Send MSB
b_databit_9 = false;
- value = value >> 8;
+ value = value >> 8;
goto udi_cdc_putc_process_one_byte;
}
return true;
}
-int udi_cdc_putc(int value)
-{
- return udi_cdc_multi_putc(0, value);
-}
+int udi_cdc_putc(int value) { return udi_cdc_multi_putc(0, value); }
-iram_size_t udi_cdc_multi_write_buf(uint8_t port, const void* buf, iram_size_t size)
-{
- uint32_t irqflags; //irqflags_t
- uint8_t buf_sel;
- uint16_t buf_nb;
+iram_size_t udi_cdc_multi_write_buf(uint8_t port, const void *buf, iram_size_t size) {
+ uint32_t irqflags; // irqflags_t
+ uint8_t buf_sel;
+ uint16_t buf_nb;
iram_size_t copy_nb;
- uint8_t *ptr_buf = (uint8_t *)buf;
+ uint8_t * ptr_buf = (uint8_t *)buf;
-//#if UDI_CDC_PORT_NB == 1 // To optimize code
+ //#if UDI_CDC_PORT_NB == 1 // To optimize code
port = 0;
-//#endif
+ //#endif
if (9 == udi_cdc_line_coding[port].bDataBits) {
- size *=2;
+ size *= 2;
}
- udi_cdc_write_buf_loop_wait:
+udi_cdc_write_buf_loop_wait:
// Check available space
if (!udi_cdc_multi_is_tx_ready(port)) {
@@ -1195,7 +1062,7 @@ iram_size_t udi_cdc_multi_write_buf(uint8_t port, const void* buf, iram_size_t s
__disable_irq();
__DMB();
buf_sel = udi_cdc_tx_buf_sel[port];
- buf_nb = udi_cdc_tx_buf_nb[port][buf_sel];
+ buf_nb = udi_cdc_tx_buf_nb[port][buf_sel];
copy_nb = UDI_CDC_TX_BUFFERS - buf_nb;
if (copy_nb > size) {
copy_nb = size;
@@ -1216,43 +1083,36 @@ iram_size_t udi_cdc_multi_write_buf(uint8_t port, const void* buf, iram_size_t s
return 0;
}
-iram_size_t udi_cdc_write_buf(const void* buf, iram_size_t size)
-{
- return udi_cdc_multi_write_buf(0, buf, size);
-}
+iram_size_t udi_cdc_write_buf(const void *buf, iram_size_t size) { return udi_cdc_multi_write_buf(0, buf, size); }
-#define MAX_PRINT 256
-#define CDC_SEND_INTERVAL 2
+# define MAX_PRINT 256
+# define CDC_SEND_INTERVAL 2
uint32_t cdc_tx_send_time_next;
-void CDC_send(void)
-{
- while (timer_read64() < cdc_tx_send_time_next);
+void CDC_send(void) {
+ while (timer_read64() < cdc_tx_send_time_next)
+ ;
udi_cdc_tx_send(0);
cdc_tx_send_time_next = timer_read64() + CDC_SEND_INTERVAL;
}
-uint32_t CDC_print(char *printbuf)
-{
- uint32_t count=0;
- char *buf = printbuf;
- char c;
+uint32_t CDC_print(char *printbuf) {
+ uint32_t count = 0;
+ char * buf = printbuf;
+ char c;
if (timer_read64() < 5000) return 0;
- while ((c = *buf++) != 0 && !(count >= MAX_PRINT))
- {
+ while ((c = *buf++) != 0 && !(count >= MAX_PRINT)) {
count++;
if (!udi_cdc_is_tx_ready()) return 0;
udi_cdc_putc(c);
- if (count >= UDI_CDC_TX_BUFFERS)
- {
+ if (count >= UDI_CDC_TX_BUFFERS) {
count = 0;
CDC_send();
}
}
- if (count)
- {
+ if (count) {
CDC_send();
}
return 1;
@@ -1260,12 +1120,11 @@ uint32_t CDC_print(char *printbuf)
char printbuf[CDC_PRINTBUF_SIZE];
-int CDC_printf(const char *_Format, ...)
-{
- va_list va; //Variable argument list variable
- int result;
+int CDC_printf(const char *_Format, ...) {
+ va_list va; // Variable argument list variable
+ int result;
- va_start(va, _Format); //Initialize the variable argument list
+ va_start(va, _Format); // Initialize the variable argument list
result = vsnprintf(printbuf, CDC_PRINTBUF_SIZE, _Format, va);
va_end(va);
@@ -1274,107 +1133,83 @@ int CDC_printf(const char *_Format, ...)
return result;
}
-//global "inbuf" if desired
+// global "inbuf" if desired
inbuf_t inbuf;
-uint32_t CDC_input_buf(inbuf_t inbuf, uint32_t inbuf_size)
-{
+uint32_t CDC_input_buf(inbuf_t inbuf, uint32_t inbuf_size) {
int RXChar;
int entered = 0;
if (!udi_cdc_is_rx_ready()) return 0;
udi_cdc_get_nb_received_data();
- RXChar = udi_cdc_getc();
-
- if (RXChar)
- {
- switch (RXChar)
- {
- case '\t': //tab - repeat last
- inbuf.count=inbuf.lastcount;
- inbuf.buf[inbuf.count+1] = 0;
+ RXChar = udi_cdc_getc();
+
+ if (RXChar) {
+ switch (RXChar) {
+ case '\t': // tab - repeat last
+ inbuf.count = inbuf.lastcount;
+ inbuf.buf[inbuf.count + 1] = 0;
CDC_print(inbuf.buf);
break;
- case '\r': //enter
- inbuf.buf[inbuf.count]=0;
- inbuf.lastcount = inbuf.count;
- inbuf.count = 0;
- entered = 1;
+ case '\r': // enter
+ inbuf.buf[inbuf.count] = 0;
+ inbuf.lastcount = inbuf.count;
+ inbuf.count = 0;
+ entered = 1;
break;
- case '\b': //backspace
+ case '\b': // backspace
if (inbuf.count > 0) {
inbuf.count -= 1;
CDC_print("\b \b\0");
- }
- else
+ } else
CDC_print("\a\0");
break;
- default:
- if ((RXChar >= 32) && (RXChar <= 126))
- {
- if (inbuf.count < inbuf_size-1)
- {
- inbuf.buf[inbuf.count] = RXChar;
- inbuf.buf[inbuf.count+1] = 0;
- CDC_print(&inbuf.buf[inbuf.count]);
- inbuf.count += 1;
+ default:
+ if ((RXChar >= 32) && (RXChar <= 126)) {
+ if (inbuf.count < inbuf_size - 1) {
+ inbuf.buf[inbuf.count] = RXChar;
+ inbuf.buf[inbuf.count + 1] = 0;
+ CDC_print(&inbuf.buf[inbuf.count]);
+ inbuf.count += 1;
+ } else
+ CDC_print("\a\0");
}
- else
- CDC_print("\a\0");
- }
- break;
+ break;
}
RXChar = 0;
}
return entered;
}
-uint32_t CDC_input()
-{
- return CDC_input_buf(inbuf, CDC_INBUF_SIZE);
-}
+uint32_t CDC_input() { return CDC_input_buf(inbuf, CDC_INBUF_SIZE); }
-void CDC_init(void)
-{
- inbuf.count = 0;
- inbuf.lastcount = 0;
- printbuf[0] = 0;
+void CDC_init(void) {
+ inbuf.count = 0;
+ inbuf.lastcount = 0;
+ printbuf[0] = 0;
cdc_tx_send_time_next = timer_read64() + CDC_SEND_INTERVAL;
}
-#else //CDC line 62
+#else // CDC line 62
char printbuf[CDC_PRINTBUF_SIZE];
-void CDC_send(void)
-{
- return;
-}
+void CDC_send(void) { return; }
-uint32_t CDC_print(char *printbuf)
-{
- return 0;
-}
+uint32_t CDC_print(char *printbuf) { return 0; }
-int CDC_printf(const char *_Format, ...)
-{
- return 0;
-}
+int CDC_printf(const char *_Format, ...) { return 0; }
inbuf_t inbuf;
-uint32_t CDC_input(void)
-{
- return 0;
-}
+uint32_t CDC_input(void) { return 0; }
-void CDC_init(void)
-{
- inbuf.count = 0;
+void CDC_init(void) {
+ inbuf.count = 0;
inbuf.lastcount = 0;
- printbuf[0]=0;
+ printbuf[0] = 0;
}
-#endif //CDC line 62
+#endif // CDC line 62
//@}
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_cdc.h b/tmk_core/protocol/arm_atsam/usb/udi_cdc.h
index 86077ce53b..9135bab546 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_cdc.h
+++ b/tmk_core/protocol/arm_atsam/usb/udi_cdc.h
@@ -49,24 +49,24 @@
#ifdef CDC
-#include "conf_usb.h"
-#include "usb_protocol.h"
-#include "usb_protocol_cdc.h"
-#include "udd.h"
-#include "udc_desc.h"
-#include "udi.h"
+# include "conf_usb.h"
+# include "usb_protocol.h"
+# include "usb_protocol_cdc.h"
+# include "udd.h"
+# include "udc_desc.h"
+# include "udi.h"
// Check the number of port
-#ifndef UDI_CDC_PORT_NB
-# define UDI_CDC_PORT_NB 1
-#endif
-#if (UDI_CDC_PORT_NB > 1)
-# error UDI_CDC_PORT_NB must be at most 1
-#endif
-
-#ifdef __cplusplus
+# ifndef UDI_CDC_PORT_NB
+# define UDI_CDC_PORT_NB 1
+# endif
+# if (UDI_CDC_PORT_NB > 1)
+# error UDI_CDC_PORT_NB must be at most 1
+# endif
+
+# ifdef __cplusplus
extern "C" {
-#endif
+# endif
/**
* \addtogroup udi_cdc_group_udc
@@ -82,9 +82,9 @@ extern UDC_DESC_STORAGE udi_api_t udi_api_cdc_data;
//#define CDC_RX_SIZE 64
//! CDC communication endpoints size for all speeds
-#define UDI_CDC_COMM_EP_SIZE CDC_ACM_SIZE
+# define UDI_CDC_COMM_EP_SIZE CDC_ACM_SIZE
//! CDC data endpoints size for FS speed (8B, 16B, 32B, 64B)
-#define UDI_CDC_DATA_EPS_FS_SIZE CDC_RX_SIZE
+# define UDI_CDC_DATA_EPS_FS_SIZE CDC_RX_SIZE
//@}
@@ -335,42 +335,42 @@ int udi_cdc_multi_putc(uint8_t port, int value);
iram_size_t udi_cdc_multi_write_buf(uint8_t port, const void* buf, iram_size_t size);
//@}
-#define CDC_PRINTBUF_SIZE 256
+# define CDC_PRINTBUF_SIZE 256
extern char printbuf[CDC_PRINTBUF_SIZE];
-#define CDC_INBUF_SIZE 256
+# define CDC_INBUF_SIZE 256
typedef struct {
uint32_t count;
uint32_t lastcount;
- char buf[CDC_INBUF_SIZE];
+ char buf[CDC_INBUF_SIZE];
} inbuf_t;
-#else //CDC
+#else // CDC
// keep these to accommodate calls if remaining
-#define CDC_PRINTBUF_SIZE 1
+# define CDC_PRINTBUF_SIZE 1
extern char printbuf[CDC_PRINTBUF_SIZE];
-#define CDC_INBUF_SIZE 1
+# define CDC_INBUF_SIZE 1
typedef struct {
uint32_t count;
uint32_t lastcount;
- char buf[CDC_INBUF_SIZE];
+ char buf[CDC_INBUF_SIZE];
} inbuf_t;
extern inbuf_t inbuf;
-#endif //CDC
+#endif // CDC
-uint32_t CDC_print(char *printbuf);
-int CDC_printf(const char *_Format, ...);
+uint32_t CDC_print(char* printbuf);
+int CDC_printf(const char* _Format, ...);
uint32_t CDC_input(void);
-void CDC_init(void);
+void CDC_init(void);
#ifdef __cplusplus
}
#endif
-#endif // _UDI_CDC_H_
+#endif // _UDI_CDC_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_cdc_conf.h b/tmk_core/protocol/arm_atsam/usb/udi_cdc_conf.h
index 2db61fab54..e079512492 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_cdc_conf.h
+++ b/tmk_core/protocol/arm_atsam/usb/udi_cdc_conf.h
@@ -51,22 +51,22 @@
#include "conf_usb.h"
#include "udi_device_conf.h"
-#ifndef UDI_CDC_PORT_NB
-#define UDI_CDC_PORT_NB 1
+#ifndef UDI_CDC_PORT_NB
+# define UDI_CDC_PORT_NB 1
#endif
#ifdef __cplusplus
extern "C" {
#endif
-#define UDI_CDC_DATA_EP_IN_0 ((CDC_TX_ENDPOINT) | (USB_EP_DIR_IN)) //TX
-#define UDI_CDC_DATA_EP_OUT_0 ((CDC_RX_ENDPOINT) | (USB_EP_DIR_OUT)) // RX
-#define UDI_CDC_COMM_EP_0 ((CDC_ACM_ENDPOINT) | (USB_EP_DIR_IN)) // Notify endpoint
+#define UDI_CDC_DATA_EP_IN_0 ((CDC_TX_ENDPOINT) | (USB_EP_DIR_IN)) // TX
+#define UDI_CDC_DATA_EP_OUT_0 ((CDC_RX_ENDPOINT) | (USB_EP_DIR_OUT)) // RX
+#define UDI_CDC_COMM_EP_0 ((CDC_ACM_ENDPOINT) | (USB_EP_DIR_IN)) // Notify endpoint
-#define UDI_CDC_COMM_IFACE_NUMBER_0 (CDC_STATUS_INTERFACE)
-#define UDI_CDC_DATA_IFACE_NUMBER_0 (CDC_DATA_INTERFACE)
+#define UDI_CDC_COMM_IFACE_NUMBER_0 (CDC_STATUS_INTERFACE)
+#define UDI_CDC_DATA_IFACE_NUMBER_0 (CDC_DATA_INTERFACE)
#ifdef __cplusplus
}
#endif
-#endif // _UDI_CDC_CONF_H_
+#endif // _UDI_CDC_CONF_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h
index 1e82b9eccb..f22f5003ab 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h
+++ b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h
@@ -31,27 +31,27 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define MOUSE_ENABLE //rules.mk
#ifdef MOUSE_ENABLE
-#define MOU
+# define MOU
#endif
//#define EXTRAKEY_ENABLE //rules.mk
#ifdef EXTRAKEY_ENABLE
-#define EXK
+# define EXK
#endif
//#define RAW_ENABLE //rules.mk
#ifdef RAW_ENABLE
-#define RAW
+# define RAW
#endif
//#define CONSOLE_ENABLE //rules.mk
#ifdef CONSOLE_ENABLE
-#define CON
+# define CON
#endif
//#define NKRO_ENABLE //rules.mk
#ifdef NKRO_ENABLE
-#define NKRO
+# define NKRO
#endif
//#define MIDI_ENABLE //deferred implementation
@@ -61,229 +61,227 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define VIRTSER_ENABLE //rules.mk
#ifdef VIRTSER_ENABLE
-#define CDC
-//because CDC uses IAD (interface association descriptor
-//per USB Interface Association Descriptor Device Class Code and Use Model 7/23/2003 Rev 1.0)
-#undef DEVICE_CLASS
-#define DEVICE_CLASS 0xEF
-#undef DEVICE_SUBCLASS
-#define DEVICE_SUBCLASS 0x02
-#undef DEVICE_PROTOCOL
-#define DEVICE_PROTOCOL 0x01
+# define CDC
+// because CDC uses IAD (interface association descriptor
+// per USB Interface Association Descriptor Device Class Code and Use Model 7/23/2003 Rev 1.0)
+# undef DEVICE_CLASS
+# define DEVICE_CLASS 0xEF
+# undef DEVICE_SUBCLASS
+# define DEVICE_SUBCLASS 0x02
+# undef DEVICE_PROTOCOL
+# define DEVICE_PROTOCOL 0x01
#endif
/* number of interfaces */
-#define NEXT_INTERFACE_0 0
+#define NEXT_INTERFACE_0 0
#ifdef KBD
-#define KEYBOARD_INTERFACE NEXT_INTERFACE_0
-#define NEXT_INTERFACE_1 (KEYBOARD_INTERFACE + 1)
-#define UDI_HID_KBD_IFACE_NUMBER KEYBOARD_INTERFACE
+# define KEYBOARD_INTERFACE NEXT_INTERFACE_0
+# define NEXT_INTERFACE_1 (KEYBOARD_INTERFACE + 1)
+# define UDI_HID_KBD_IFACE_NUMBER KEYBOARD_INTERFACE
#else
-#define NEXT_INTERFACE_1 NEXT_INTERFACE_0
+# define NEXT_INTERFACE_1 NEXT_INTERFACE_0
#endif
// It is important that the Raw HID interface is at a constant
// interface number, to support Linux/OSX platforms and chrome.hid
// If Raw HID is enabled, let it be always 1.
#ifdef RAW
-#define RAW_INTERFACE NEXT_INTERFACE_1
-#define NEXT_INTERFACE_2 (RAW_INTERFACE + 1)
+# define RAW_INTERFACE NEXT_INTERFACE_1
+# define NEXT_INTERFACE_2 (RAW_INTERFACE + 1)
#else
-#define NEXT_INTERFACE_2 NEXT_INTERFACE_1
+# define NEXT_INTERFACE_2 NEXT_INTERFACE_1
#endif
#ifdef MOU
-#define MOUSE_INTERFACE NEXT_INTERFACE_2
-#define UDI_HID_MOU_IFACE_NUMBER MOUSE_INTERFACE
-#define NEXT_INTERFACE_3 (MOUSE_INTERFACE + 1)
+# define MOUSE_INTERFACE NEXT_INTERFACE_2
+# define UDI_HID_MOU_IFACE_NUMBER MOUSE_INTERFACE
+# define NEXT_INTERFACE_3 (MOUSE_INTERFACE + 1)
#else
-#define NEXT_INTERFACE_3 NEXT_INTERFACE_2
+# define NEXT_INTERFACE_3 NEXT_INTERFACE_2
#endif
#ifdef EXK
-#define EXTRAKEY_INTERFACE NEXT_INTERFACE_3
-#define NEXT_INTERFACE_4 (EXTRAKEY_INTERFACE + 1)
-#define UDI_HID_EXK_IFACE_NUMBER EXTRAKEY_INTERFACE
+# define EXTRAKEY_INTERFACE NEXT_INTERFACE_3
+# define NEXT_INTERFACE_4 (EXTRAKEY_INTERFACE + 1)
+# define UDI_HID_EXK_IFACE_NUMBER EXTRAKEY_INTERFACE
#else
-#define NEXT_INTERFACE_4 NEXT_INTERFACE_3
+# define NEXT_INTERFACE_4 NEXT_INTERFACE_3
#endif
#ifdef CON
-#define CON_INTERFACE NEXT_INTERFACE_4
-#define NEXT_INTERFACE_5 (CON_INTERFACE + 1)
-#define UDI_HID_CON_IFACE_NUMBER CON_INTERFACE
+# define CON_INTERFACE NEXT_INTERFACE_4
+# define NEXT_INTERFACE_5 (CON_INTERFACE + 1)
+# define UDI_HID_CON_IFACE_NUMBER CON_INTERFACE
#else
-#define NEXT_INTERFACE_5 NEXT_INTERFACE_4
+# define NEXT_INTERFACE_5 NEXT_INTERFACE_4
#endif
#ifdef NKRO
-#define NKRO_INTERFACE NEXT_INTERFACE_5
-#define NEXT_INTERFACE_6 (NKRO_INTERFACE + 1)
-#define UDI_HID_NKRO_IFACE_NUMBER NKRO_INTERFACE
+# define NKRO_INTERFACE NEXT_INTERFACE_5
+# define NEXT_INTERFACE_6 (NKRO_INTERFACE + 1)
+# define UDI_HID_NKRO_IFACE_NUMBER NKRO_INTERFACE
#else
-#define NEXT_INTERFACE_6 NEXT_INTERFACE_5
+# define NEXT_INTERFACE_6 NEXT_INTERFACE_5
#endif
#ifdef MIDI
-#define AC_INTERFACE NEXT_INTERFACE_6
-#define AS_INTERFACE (AC_INTERFACE + 1)
-#define NEXT_INTERFACE_7 (AS_INTERFACE + 1)
+# define AC_INTERFACE NEXT_INTERFACE_6
+# define AS_INTERFACE (AC_INTERFACE + 1)
+# define NEXT_INTERFACE_7 (AS_INTERFACE + 1)
#else
-#define NEXT_INTERFACE_7 NEXT_INTERFACE_6
+# define NEXT_INTERFACE_7 NEXT_INTERFACE_6
#endif
#ifdef CDC
-#define CCI_INTERFACE NEXT_INTERFACE_7
-#define CDI_INTERFACE (CCI_INTERFACE + 1)
-#define NEXT_INTERFACE_8 (CDI_INTERFACE + 1)
-#define CDC_STATUS_INTERFACE CCI_INTERFACE
-#define CDC_DATA_INTERFACE CDI_INTERFACE
+# define CCI_INTERFACE NEXT_INTERFACE_7
+# define CDI_INTERFACE (CCI_INTERFACE + 1)
+# define NEXT_INTERFACE_8 (CDI_INTERFACE + 1)
+# define CDC_STATUS_INTERFACE CCI_INTERFACE
+# define CDC_DATA_INTERFACE CDI_INTERFACE
#else
-#define NEXT_INTERFACE_8 NEXT_INTERFACE_7
+# define NEXT_INTERFACE_8 NEXT_INTERFACE_7
#endif
/* nubmer of interfaces */
-#define TOTAL_INTERFACES NEXT_INTERFACE_8
-#define USB_DEVICE_NB_INTERFACE TOTAL_INTERFACES
-
+#define TOTAL_INTERFACES NEXT_INTERFACE_8
+#define USB_DEVICE_NB_INTERFACE TOTAL_INTERFACES
// **********************************************************************
// Endopoint number and size
// **********************************************************************
-#define USB_DEVICE_EP_CTRL_SIZE 8
+#define USB_DEVICE_EP_CTRL_SIZE 8
-#define NEXT_IN_EPNUM_0 1
-#define NEXT_OUT_EPNUM_0 1
+#define NEXT_IN_EPNUM_0 1
+#define NEXT_OUT_EPNUM_0 1
#ifdef KBD
-#define KEYBOARD_IN_EPNUM NEXT_IN_EPNUM_0
-#define UDI_HID_KBD_EP_IN KEYBOARD_IN_EPNUM
-#define NEXT_IN_EPNUM_1 (KEYBOARD_IN_EPNUM + 1)
-#define UDI_HID_KBD_EP_SIZE KEYBOARD_EPSIZE
-#define KBD_POLLING_INTERVAL 10
-#ifndef UDI_HID_KBD_STRING_ID
-#define UDI_HID_KBD_STRING_ID 0
-#endif
+# define KEYBOARD_IN_EPNUM NEXT_IN_EPNUM_0
+# define UDI_HID_KBD_EP_IN KEYBOARD_IN_EPNUM
+# define NEXT_IN_EPNUM_1 (KEYBOARD_IN_EPNUM + 1)
+# define UDI_HID_KBD_EP_SIZE KEYBOARD_EPSIZE
+# define KBD_POLLING_INTERVAL 10
+# ifndef UDI_HID_KBD_STRING_ID
+# define UDI_HID_KBD_STRING_ID 0
+# endif
#else
-#define NEXT_IN_EPNUM_1 NEXT_IN_EPNUM_0
+# define NEXT_IN_EPNUM_1 NEXT_IN_EPNUM_0
#endif
#ifdef MOU
-#define MOUSE_IN_EPNUM NEXT_IN_EPNUM_1
-#define NEXT_IN_EPNUM_2 (MOUSE_IN_EPNUM + 1)
-#define UDI_HID_MOU_EP_IN MOUSE_IN_EPNUM
-#define UDI_HID_MOU_EP_SIZE MOUSE_EPSIZE
-#define MOU_POLLING_INTERVAL 10
-#ifndef UDI_HID_MOU_STRING_ID
-#define UDI_HID_MOU_STRING_ID 0
-#endif
+# define MOUSE_IN_EPNUM NEXT_IN_EPNUM_1
+# define NEXT_IN_EPNUM_2 (MOUSE_IN_EPNUM + 1)
+# define UDI_HID_MOU_EP_IN MOUSE_IN_EPNUM
+# define UDI_HID_MOU_EP_SIZE MOUSE_EPSIZE
+# define MOU_POLLING_INTERVAL 10
+# ifndef UDI_HID_MOU_STRING_ID
+# define UDI_HID_MOU_STRING_ID 0
+# endif
#else
-#define NEXT_IN_EPNUM_2 NEXT_IN_EPNUM_1
+# define NEXT_IN_EPNUM_2 NEXT_IN_EPNUM_1
#endif
#ifdef EXK
-#define EXTRAKEY_IN_EPNUM NEXT_IN_EPNUM_2
-#define UDI_HID_EXK_EP_IN EXTRAKEY_IN_EPNUM
-#define NEXT_IN_EPNUM_3 (EXTRAKEY_IN_EPNUM + 1)
-#define UDI_HID_EXK_EP_SIZE EXTRAKEY_EPSIZE
-#define EXTRAKEY_POLLING_INTERVAL 10
-#ifndef UDI_HID_EXK_STRING_ID
-#define UDI_HID_EXK_STRING_ID 0
-#endif
+# define EXTRAKEY_IN_EPNUM NEXT_IN_EPNUM_2
+# define UDI_HID_EXK_EP_IN EXTRAKEY_IN_EPNUM
+# define NEXT_IN_EPNUM_3 (EXTRAKEY_IN_EPNUM + 1)
+# define UDI_HID_EXK_EP_SIZE EXTRAKEY_EPSIZE
+# define EXTRAKEY_POLLING_INTERVAL 10
+# ifndef UDI_HID_EXK_STRING_ID
+# define UDI_HID_EXK_STRING_ID 0
+# endif
#else
-#define NEXT_IN_EPNUM_3 NEXT_IN_EPNUM_2
+# define NEXT_IN_EPNUM_3 NEXT_IN_EPNUM_2
#endif
#ifdef RAW
-#define RAW_IN_EPNUM NEXT_IN_EPNUM_3
-#define UDI_HID_RAW_EP_IN RAW_IN_EPNUM
-#define NEXT_IN_EPNUM_4 (RAW_IN_EPNUM + 1)
-#define RAW_OUT_EPNUM NEXT_OUT_EPNUM_0
-#define UDI_HID_RAW_EP_OUT RAW_OUT_EPNUM
-#define NEXT_OUT_EPNUM_1 (RAW_OUT_EPNUM + 1)
-#define RAW_POLLING_INTERVAL 1
-#ifndef UDI_HID_RAW_STRING_ID
-#define UDI_HID_RAW_STRING_ID 0
-#endif
+# define RAW_IN_EPNUM NEXT_IN_EPNUM_3
+# define UDI_HID_RAW_EP_IN RAW_IN_EPNUM
+# define NEXT_IN_EPNUM_4 (RAW_IN_EPNUM + 1)
+# define RAW_OUT_EPNUM NEXT_OUT_EPNUM_0
+# define UDI_HID_RAW_EP_OUT RAW_OUT_EPNUM
+# define NEXT_OUT_EPNUM_1 (RAW_OUT_EPNUM + 1)
+# define RAW_POLLING_INTERVAL 1
+# ifndef UDI_HID_RAW_STRING_ID
+# define UDI_HID_RAW_STRING_ID 0
+# endif
#else
-#define NEXT_IN_EPNUM_4 NEXT_IN_EPNUM_3
-#define NEXT_OUT_EPNUM_1 NEXT_OUT_EPNUM_0
+# define NEXT_IN_EPNUM_4 NEXT_IN_EPNUM_3
+# define NEXT_OUT_EPNUM_1 NEXT_OUT_EPNUM_0
#endif
#ifdef CON
-#define CON_IN_EPNUM NEXT_IN_EPNUM_4
-#define UDI_HID_CON_EP_IN CON_IN_EPNUM
-#define NEXT_IN_EPNUM_5 (CON_IN_EPNUM + 1)
-#define CON_OUT_EPNUM NEXT_OUT_EPNUM_1
-#define UDI_HID_CON_EP_OUT CON_OUT_EPNUM
-#define NEXT_OUT_EPNUM_2 (CON_OUT_EPNUM + 1)
-#define CON_POLLING_INTERVAL 1
-#ifndef UDI_HID_CON_STRING_ID
-#define UDI_HID_CON_STRING_ID 0
-#endif
+# define CON_IN_EPNUM NEXT_IN_EPNUM_4
+# define UDI_HID_CON_EP_IN CON_IN_EPNUM
+# define NEXT_IN_EPNUM_5 (CON_IN_EPNUM + 1)
+# define CON_OUT_EPNUM NEXT_OUT_EPNUM_1
+# define UDI_HID_CON_EP_OUT CON_OUT_EPNUM
+# define NEXT_OUT_EPNUM_2 (CON_OUT_EPNUM + 1)
+# define CON_POLLING_INTERVAL 1
+# ifndef UDI_HID_CON_STRING_ID
+# define UDI_HID_CON_STRING_ID 0
+# endif
#else
-#define NEXT_IN_EPNUM_5 NEXT_IN_EPNUM_4
-#define NEXT_OUT_EPNUM_2 NEXT_OUT_EPNUM_1
+# define NEXT_IN_EPNUM_5 NEXT_IN_EPNUM_4
+# define NEXT_OUT_EPNUM_2 NEXT_OUT_EPNUM_1
#endif
#ifdef NKRO
-#define NKRO_IN_EPNUM NEXT_IN_EPNUM_5
-#define UDI_HID_NKRO_EP_IN NKRO_IN_EPNUM
-#define NEXT_IN_EPNUM_6 (NKRO_IN_EPNUM + 1)
-#define UDI_HID_NKRO_EP_SIZE NKRO_EPSIZE
-#define NKRO_POLLING_INTERVAL 1
-#ifndef UDI_HID_NKRO_STRING_ID
-#define UDI_HID_NKRO_STRING_ID 0
-#endif
+# define NKRO_IN_EPNUM NEXT_IN_EPNUM_5
+# define UDI_HID_NKRO_EP_IN NKRO_IN_EPNUM
+# define NEXT_IN_EPNUM_6 (NKRO_IN_EPNUM + 1)
+# define UDI_HID_NKRO_EP_SIZE NKRO_EPSIZE
+# define NKRO_POLLING_INTERVAL 1
+# ifndef UDI_HID_NKRO_STRING_ID
+# define UDI_HID_NKRO_STRING_ID 0
+# endif
#else
-#define NEXT_IN_EPNUM_6 NEXT_IN_EPNUM_5
+# define NEXT_IN_EPNUM_6 NEXT_IN_EPNUM_5
#endif
#ifdef MIDI
-#define MIDI_STREAM_IN_EPNUM NEXT_IN_EPNUM_6
-#define NEXT_IN_EPNUM_7 (MIDI_STREAM_IN_EPNUM + 1)
-#define MIDI_STREAM_OUT_EPNUM NEXT_OUT_EPNUM_2
-#define NEXT_OUT_EPNUM_3 (MIDI_STREAM_OUT_EPNUM + 1)
-#define MIDI_POLLING_INTERVAL 5
+# define MIDI_STREAM_IN_EPNUM NEXT_IN_EPNUM_6
+# define NEXT_IN_EPNUM_7 (MIDI_STREAM_IN_EPNUM + 1)
+# define MIDI_STREAM_OUT_EPNUM NEXT_OUT_EPNUM_2
+# define NEXT_OUT_EPNUM_3 (MIDI_STREAM_OUT_EPNUM + 1)
+# define MIDI_POLLING_INTERVAL 5
#else
-#define NEXT_IN_EPNUM_7 NEXT_IN_EPNUM_6
-#define NEXT_OUT_EPNUM_3 NEXT_OUT_EPNUM_2
+# define NEXT_IN_EPNUM_7 NEXT_IN_EPNUM_6
+# define NEXT_OUT_EPNUM_3 NEXT_OUT_EPNUM_2
#endif
#ifdef CDC
-#define CDC_NOTIFICATION_EPNUM NEXT_IN_EPNUM_7
-#define CDC_ACM_ENDPOINT CDC_NOTIFICATION_EPNUM
-#define CDC_TX_ENDPOINT (CDC_NOTIFICATION_EPNUM + 1)
-#define NEXT_IN_EPNUM_8 (CDC_TX_ENDPOINT + 1)
-
-#define CDC_OUT_EPNUM NEXT_OUT_EPNUM_3
-#define CDC_RX_ENDPOINT CDC_OUT_EPNUM
-#define NEXT_OUT_EPNUM_4 (CDC_OUT_EPNUM + 1)
-
-#define CDC_ACM_SIZE CDC_NOTIFICATION_EPSIZE
-#define CDC_RX_SIZE CDC_EPSIZE //KFSMOD was 64
-#define CDC_TX_SIZE CDC_RX_SIZE
-#define CDC_ACM_POLLING_INTERVAL 255
-#define CDC_EP_INTERVAL_STATUS CDC_ACM_POLLING_INTERVAL
-#define CDC_DATA_POLLING_INTERVAL 5
-#define CDC_EP_INTERVAL_DATA CDC_DATA_POLLING_INTERVAL
-#define CDC_STATUS_NAME L"Virtual Serial Port - Status"
-#define CDC_DATA_NAME L"Virtual Serial Port - Data"
+# define CDC_NOTIFICATION_EPNUM NEXT_IN_EPNUM_7
+# define CDC_ACM_ENDPOINT CDC_NOTIFICATION_EPNUM
+# define CDC_TX_ENDPOINT (CDC_NOTIFICATION_EPNUM + 1)
+# define NEXT_IN_EPNUM_8 (CDC_TX_ENDPOINT + 1)
+
+# define CDC_OUT_EPNUM NEXT_OUT_EPNUM_3
+# define CDC_RX_ENDPOINT CDC_OUT_EPNUM
+# define NEXT_OUT_EPNUM_4 (CDC_OUT_EPNUM + 1)
+
+# define CDC_ACM_SIZE CDC_NOTIFICATION_EPSIZE
+# define CDC_RX_SIZE CDC_EPSIZE // KFSMOD was 64
+# define CDC_TX_SIZE CDC_RX_SIZE
+# define CDC_ACM_POLLING_INTERVAL 255
+# define CDC_EP_INTERVAL_STATUS CDC_ACM_POLLING_INTERVAL
+# define CDC_DATA_POLLING_INTERVAL 5
+# define CDC_EP_INTERVAL_DATA CDC_DATA_POLLING_INTERVAL
+# define CDC_STATUS_NAME L"Virtual Serial Port - Status"
+# define CDC_DATA_NAME L"Virtual Serial Port - Data"
#else
-#define NEXT_IN_EPNUM_8 NEXT_IN_EPNUM_7
-#define NEXT_OUT_EPNUM_4 NEXT_OUT_EPNUM_3
+# define NEXT_IN_EPNUM_8 NEXT_IN_EPNUM_7
+# define NEXT_OUT_EPNUM_4 NEXT_OUT_EPNUM_3
#endif
-#define TOTAL_OUT_EP NEXT_OUT_EPNUM_4
-#define TOTAL_IN_EP NEXT_IN_EPNUM_8
-#define USB_DEVICE_MAX_EP (max(NEXT_OUT_EPNUM_4, NEXT_IN_EPNUM_8))
+#define TOTAL_OUT_EP NEXT_OUT_EPNUM_4
+#define TOTAL_IN_EP NEXT_IN_EPNUM_8
+#define USB_DEVICE_MAX_EP (max(NEXT_OUT_EPNUM_4, NEXT_IN_EPNUM_8))
#if USB_DEVICE_MAX_EP > 8
-#error "There are not enough available endpoints to support all functions. Remove some in the rules.mk file.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO, MIDI, VIRTSER)"
+# error "There are not enough available endpoints to support all functions. Remove some in the rules.mk file.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO, MIDI, VIRTSER)"
#endif
-
// **********************************************************************
// KBD Descriptor structure and content
// **********************************************************************
@@ -292,50 +290,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
COMPILER_PACK_SET(1)
typedef struct {
- usb_iface_desc_t iface;
+ usb_iface_desc_t iface;
usb_hid_descriptor_t hid;
- usb_ep_desc_t ep;
+ usb_ep_desc_t ep;
} udi_hid_kbd_desc_t;
typedef struct {
uint8_t array[59];
} udi_hid_kbd_report_desc_t;
-#define UDI_HID_KBD_DESC {\
- .iface.bLength = sizeof(usb_iface_desc_t),\
- .iface.bDescriptorType = USB_DT_INTERFACE,\
- .iface.bInterfaceNumber = UDI_HID_KBD_IFACE_NUMBER,\
- .iface.bAlternateSetting = 0,\
- .iface.bNumEndpoints = 1,\
- .iface.bInterfaceClass = HID_CLASS,\
- .iface.bInterfaceSubClass = HID_SUB_CLASS_BOOT,\
- .iface.bInterfaceProtocol = HID_PROTOCOL_KEYBOARD,\
- .iface.iInterface = UDI_HID_KBD_STRING_ID,\
- .hid.bLength = sizeof(usb_hid_descriptor_t),\
- .hid.bDescriptorType = USB_DT_HID,\
- .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
- .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
- .hid.bNumDescriptors = USB_HID_NUM_DESC,\
- .hid.bRDescriptorType = USB_DT_HID_REPORT,\
- .hid.wDescriptorLength = LE16(sizeof(udi_hid_kbd_report_desc_t)),\
- .ep.bLength = sizeof(usb_ep_desc_t),\
- .ep.bDescriptorType = USB_DT_ENDPOINT,\
- .ep.bEndpointAddress = UDI_HID_KBD_EP_IN | USB_EP_DIR_IN,\
- .ep.bmAttributes = USB_EP_TYPE_INTERRUPT,\
- .ep.wMaxPacketSize = LE16(UDI_HID_KBD_EP_SIZE),\
- .ep.bInterval = KBD_POLLING_INTERVAL,\
-}
-
-//set report buffer (from host)
+# define UDI_HID_KBD_DESC \
+ { .iface.bLength = sizeof(usb_iface_desc_t), .iface.bDescriptorType = USB_DT_INTERFACE, .iface.bInterfaceNumber = UDI_HID_KBD_IFACE_NUMBER, .iface.bAlternateSetting = 0, .iface.bNumEndpoints = 1, .iface.bInterfaceClass = HID_CLASS, .iface.bInterfaceSubClass = HID_SUB_CLASS_BOOT, .iface.bInterfaceProtocol = HID_PROTOCOL_KEYBOARD, .iface.iInterface = UDI_HID_KBD_STRING_ID, .hid.bLength = sizeof(usb_hid_descriptor_t), .hid.bDescriptorType = USB_DT_HID, .hid.bcdHID = LE16(USB_HID_BDC_V1_11), .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE, .hid.bNumDescriptors = USB_HID_NUM_DESC, .hid.bRDescriptorType = USB_DT_HID_REPORT, .hid.wDescriptorLength = LE16(sizeof(udi_hid_kbd_report_desc_t)), .ep.bLength = sizeof(usb_ep_desc_t), .ep.bDescriptorType = USB_DT_ENDPOINT, .ep.bEndpointAddress = UDI_HID_KBD_EP_IN | USB_EP_DIR_IN, .ep.bmAttributes = USB_EP_TYPE_INTERRUPT, .ep.wMaxPacketSize = LE16(UDI_HID_KBD_EP_SIZE), .ep.bInterval = KBD_POLLING_INTERVAL, }
+
+// set report buffer (from host)
extern uint8_t udi_hid_kbd_report_set;
-//report buffer (to host)
-#define UDI_HID_KBD_REPORT_SIZE 8
+// report buffer (to host)
+# define UDI_HID_KBD_REPORT_SIZE 8
extern uint8_t udi_hid_kbd_report[UDI_HID_KBD_REPORT_SIZE];
COMPILER_PACK_RESET()
-#endif //KBD
+#endif // KBD
// **********************************************************************
// EXK Descriptor structure and content
@@ -345,59 +321,37 @@ COMPILER_PACK_RESET()
COMPILER_PACK_SET(1)
typedef struct {
- usb_iface_desc_t iface;
+ usb_iface_desc_t iface;
usb_hid_descriptor_t hid;
- usb_ep_desc_t ep;
+ usb_ep_desc_t ep;
} udi_hid_exk_desc_t;
typedef struct {
uint8_t array[54];
} udi_hid_exk_report_desc_t;
-#define UDI_HID_EXK_DESC {\
- .iface.bLength = sizeof(usb_iface_desc_t),\
- .iface.bDescriptorType = USB_DT_INTERFACE,\
- .iface.bInterfaceNumber = UDI_HID_EXK_IFACE_NUMBER,\
- .iface.bAlternateSetting = 0,\
- .iface.bNumEndpoints = 1,\
- .iface.bInterfaceClass = HID_CLASS,\
- .iface.bInterfaceSubClass = HID_SUB_CLASS_BOOT,\
- .iface.bInterfaceProtocol = HID_PROTOCOL_GENERIC,\
- .iface.iInterface = UDI_HID_EXK_STRING_ID,\
- .hid.bLength = sizeof(usb_hid_descriptor_t),\
- .hid.bDescriptorType = USB_DT_HID,\
- .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
- .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
- .hid.bNumDescriptors = USB_HID_NUM_DESC,\
- .hid.bRDescriptorType = USB_DT_HID_REPORT,\
- .hid.wDescriptorLength = LE16(sizeof(udi_hid_exk_report_desc_t)),\
- .ep.bLength = sizeof(usb_ep_desc_t),\
- .ep.bDescriptorType = USB_DT_ENDPOINT,\
- .ep.bEndpointAddress = UDI_HID_EXK_EP_IN | USB_EP_DIR_IN,\
- .ep.bmAttributes = USB_EP_TYPE_INTERRUPT,\
- .ep.wMaxPacketSize = LE16(UDI_HID_EXK_EP_SIZE),\
- .ep.bInterval = EXTRAKEY_POLLING_INTERVAL,\
-}
-
-//set report buffer (from host)
+# define UDI_HID_EXK_DESC \
+ { .iface.bLength = sizeof(usb_iface_desc_t), .iface.bDescriptorType = USB_DT_INTERFACE, .iface.bInterfaceNumber = UDI_HID_EXK_IFACE_NUMBER, .iface.bAlternateSetting = 0, .iface.bNumEndpoints = 1, .iface.bInterfaceClass = HID_CLASS, .iface.bInterfaceSubClass = HID_SUB_CLASS_BOOT, .iface.bInterfaceProtocol = HID_PROTOCOL_GENERIC, .iface.iInterface = UDI_HID_EXK_STRING_ID, .hid.bLength = sizeof(usb_hid_descriptor_t), .hid.bDescriptorType = USB_DT_HID, .hid.bcdHID = LE16(USB_HID_BDC_V1_11), .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE, .hid.bNumDescriptors = USB_HID_NUM_DESC, .hid.bRDescriptorType = USB_DT_HID_REPORT, .hid.wDescriptorLength = LE16(sizeof(udi_hid_exk_report_desc_t)), .ep.bLength = sizeof(usb_ep_desc_t), .ep.bDescriptorType = USB_DT_ENDPOINT, .ep.bEndpointAddress = UDI_HID_EXK_EP_IN | USB_EP_DIR_IN, .ep.bmAttributes = USB_EP_TYPE_INTERRUPT, .ep.wMaxPacketSize = LE16(UDI_HID_EXK_EP_SIZE), .ep.bInterval = EXTRAKEY_POLLING_INTERVAL, }
+
+// set report buffer (from host)
extern uint8_t udi_hid_exk_report_set;
-//report buffer
-#define UDI_HID_EXK_REPORT_SIZE 3
+// report buffer
+# define UDI_HID_EXK_REPORT_SIZE 3
typedef union {
- struct {
- uint8_t report_id;
- uint16_t report_data;
- } desc;
- uint8_t raw[UDI_HID_EXK_REPORT_SIZE];
+ struct {
+ uint8_t report_id;
+ uint16_t report_data;
+ } desc;
+ uint8_t raw[UDI_HID_EXK_REPORT_SIZE];
} udi_hid_exk_report_t;
extern udi_hid_exk_report_t udi_hid_exk_report;
COMPILER_PACK_RESET()
-#endif //EXK
+#endif // EXK
// **********************************************************************
// NKRO Descriptor structure and content
@@ -407,50 +361,28 @@ COMPILER_PACK_RESET()
COMPILER_PACK_SET(1)
typedef struct {
- usb_iface_desc_t iface;
+ usb_iface_desc_t iface;
usb_hid_descriptor_t hid;
- usb_ep_desc_t ep;
+ usb_ep_desc_t ep;
} udi_hid_nkro_desc_t;
typedef struct {
uint8_t array[57];
} udi_hid_nkro_report_desc_t;
-#define UDI_HID_NKRO_DESC {\
- .iface.bLength = sizeof(usb_iface_desc_t),\
- .iface.bDescriptorType = USB_DT_INTERFACE,\
- .iface.bInterfaceNumber = UDI_HID_NKRO_IFACE_NUMBER,\
- .iface.bAlternateSetting = 0,\
- .iface.bNumEndpoints = 1,\
- .iface.bInterfaceClass = HID_CLASS,\
- .iface.bInterfaceSubClass = HID_SUB_CLASS_NOBOOT,\
- .iface.bInterfaceProtocol = HID_PROTOCOL_KEYBOARD,\
- .iface.iInterface = UDI_HID_NKRO_STRING_ID,\
- .hid.bLength = sizeof(usb_hid_descriptor_t),\
- .hid.bDescriptorType = USB_DT_HID,\
- .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
- .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
- .hid.bNumDescriptors = USB_HID_NUM_DESC,\
- .hid.bRDescriptorType = USB_DT_HID_REPORT,\
- .hid.wDescriptorLength = LE16(sizeof(udi_hid_nkro_report_desc_t)),\
- .ep.bLength = sizeof(usb_ep_desc_t),\
- .ep.bDescriptorType = USB_DT_ENDPOINT,\
- .ep.bEndpointAddress = UDI_HID_NKRO_EP_IN | USB_EP_DIR_IN,\
- .ep.bmAttributes = USB_EP_TYPE_INTERRUPT,\
- .ep.wMaxPacketSize = LE16(UDI_HID_NKRO_EP_SIZE),\
- .ep.bInterval = NKRO_POLLING_INTERVAL,\
-}
-
-//set report buffer
+# define UDI_HID_NKRO_DESC \
+ { .iface.bLength = sizeof(usb_iface_desc_t), .iface.bDescriptorType = USB_DT_INTERFACE, .iface.bInterfaceNumber = UDI_HID_NKRO_IFACE_NUMBER, .iface.bAlternateSetting = 0, .iface.bNumEndpoints = 1, .iface.bInterfaceClass = HID_CLASS, .iface.bInterfaceSubClass = HID_SUB_CLASS_NOBOOT, .iface.bInterfaceProtocol = HID_PROTOCOL_KEYBOARD, .iface.iInterface = UDI_HID_NKRO_STRING_ID, .hid.bLength = sizeof(usb_hid_descriptor_t), .hid.bDescriptorType = USB_DT_HID, .hid.bcdHID = LE16(USB_HID_BDC_V1_11), .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE, .hid.bNumDescriptors = USB_HID_NUM_DESC, .hid.bRDescriptorType = USB_DT_HID_REPORT, .hid.wDescriptorLength = LE16(sizeof(udi_hid_nkro_report_desc_t)), .ep.bLength = sizeof(usb_ep_desc_t), .ep.bDescriptorType = USB_DT_ENDPOINT, .ep.bEndpointAddress = UDI_HID_NKRO_EP_IN | USB_EP_DIR_IN, .ep.bmAttributes = USB_EP_TYPE_INTERRUPT, .ep.wMaxPacketSize = LE16(UDI_HID_NKRO_EP_SIZE), .ep.bInterval = NKRO_POLLING_INTERVAL, }
+
+// set report buffer
extern uint8_t udi_hid_nkro_report_set;
-//report buffer
-#define UDI_HID_NKRO_REPORT_SIZE 32
+// report buffer
+# define UDI_HID_NKRO_REPORT_SIZE 32
extern uint8_t udi_hid_nkro_report[UDI_HID_NKRO_REPORT_SIZE];
COMPILER_PACK_RESET()
-#endif //NKRO
+#endif // NKRO
// **********************************************************************
// MOU Descriptor structure and content
@@ -460,49 +392,27 @@ COMPILER_PACK_RESET()
COMPILER_PACK_SET(1)
typedef struct {
- usb_iface_desc_t iface;
+ usb_iface_desc_t iface;
usb_hid_descriptor_t hid;
- usb_ep_desc_t ep;
+ usb_ep_desc_t ep;
} udi_hid_mou_desc_t;
typedef struct {
- uint8_t array[77];//MOU PDS
+ uint8_t array[77]; // MOU PDS
} udi_hid_mou_report_desc_t;
-#define UDI_HID_MOU_DESC {\
- .iface.bLength = sizeof(usb_iface_desc_t),\
- .iface.bDescriptorType = USB_DT_INTERFACE,\
- .iface.bInterfaceNumber = MOUSE_INTERFACE,\
- .iface.bAlternateSetting = 0,\
- .iface.bNumEndpoints = 1,\
- .iface.bInterfaceClass = HID_CLASS,\
- .iface.bInterfaceSubClass = HID_SUB_CLASS_BOOT,\
- .iface.bInterfaceProtocol = HID_PROTOCOL_MOUSE,\
- .iface.iInterface = UDI_HID_MOU_STRING_ID,\
- .hid.bLength = sizeof(usb_hid_descriptor_t),\
- .hid.bDescriptorType = USB_DT_HID,\
- .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
- .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
- .hid.bNumDescriptors = USB_HID_NUM_DESC,\
- .hid.bRDescriptorType = USB_DT_HID_REPORT,\
- .hid.wDescriptorLength = LE16(sizeof(udi_hid_mou_report_desc_t)),\
- .ep.bLength = sizeof(usb_ep_desc_t),\
- .ep.bDescriptorType = USB_DT_ENDPOINT,\
- .ep.bEndpointAddress = UDI_HID_MOU_EP_IN | USB_EP_DIR_IN,\
- .ep.bmAttributes = USB_EP_TYPE_INTERRUPT,\
- .ep.wMaxPacketSize = LE16(UDI_HID_MOU_EP_SIZE),\
- .ep.bInterval = MOU_POLLING_INTERVAL,\
-}
-
-//no set report buffer
-
-//report buffer
-#define UDI_HID_MOU_REPORT_SIZE 5 //MOU PDS
+# define UDI_HID_MOU_DESC \
+ { .iface.bLength = sizeof(usb_iface_desc_t), .iface.bDescriptorType = USB_DT_INTERFACE, .iface.bInterfaceNumber = MOUSE_INTERFACE, .iface.bAlternateSetting = 0, .iface.bNumEndpoints = 1, .iface.bInterfaceClass = HID_CLASS, .iface.bInterfaceSubClass = HID_SUB_CLASS_BOOT, .iface.bInterfaceProtocol = HID_PROTOCOL_MOUSE, .iface.iInterface = UDI_HID_MOU_STRING_ID, .hid.bLength = sizeof(usb_hid_descriptor_t), .hid.bDescriptorType = USB_DT_HID, .hid.bcdHID = LE16(USB_HID_BDC_V1_11), .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE, .hid.bNumDescriptors = USB_HID_NUM_DESC, .hid.bRDescriptorType = USB_DT_HID_REPORT, .hid.wDescriptorLength = LE16(sizeof(udi_hid_mou_report_desc_t)), .ep.bLength = sizeof(usb_ep_desc_t), .ep.bDescriptorType = USB_DT_ENDPOINT, .ep.bEndpointAddress = UDI_HID_MOU_EP_IN | USB_EP_DIR_IN, .ep.bmAttributes = USB_EP_TYPE_INTERRUPT, .ep.wMaxPacketSize = LE16(UDI_HID_MOU_EP_SIZE), .ep.bInterval = MOU_POLLING_INTERVAL, }
+
+// no set report buffer
+
+// report buffer
+# define UDI_HID_MOU_REPORT_SIZE 5 // MOU PDS
extern uint8_t udi_hid_mou_report[UDI_HID_MOU_REPORT_SIZE];
COMPILER_PACK_RESET()
-#endif //MOU
+#endif // MOU
// **********************************************************************
// RAW Descriptor structure and content
@@ -512,57 +422,32 @@ COMPILER_PACK_RESET()
COMPILER_PACK_SET(1)
typedef struct {
- usb_iface_desc_t iface;
+ usb_iface_desc_t iface;
usb_hid_descriptor_t hid;
- usb_ep_desc_t ep_out;
- usb_ep_desc_t ep_in;
+ usb_ep_desc_t ep_out;
+ usb_ep_desc_t ep_in;
} udi_hid_raw_desc_t;
typedef struct {
uint8_t array[27];
} udi_hid_raw_report_desc_t;
-#define UDI_HID_RAW_DESC {\
- .iface.bLength = sizeof(usb_iface_desc_t),\
- .iface.bDescriptorType = USB_DT_INTERFACE,\
- .iface.bInterfaceNumber = RAW_INTERFACE,\
- .iface.bAlternateSetting = 0,\
- .iface.bNumEndpoints = 2,\
- .iface.bInterfaceClass = HID_CLASS,\
- .iface.bInterfaceSubClass = HID_SUB_CLASS_NOBOOT,\
- .iface.bInterfaceProtocol = HID_SUB_CLASS_NOBOOT,\
- .iface.iInterface = UDI_HID_RAW_STRING_ID,\
- .hid.bLength = sizeof(usb_hid_descriptor_t),\
- .hid.bDescriptorType = USB_DT_HID,\
- .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
- .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
- .hid.bNumDescriptors = USB_HID_NUM_DESC,\
- .hid.bRDescriptorType = USB_DT_HID_REPORT,\
- .hid.wDescriptorLength = LE16(sizeof(udi_hid_raw_report_desc_t)),\
- .ep_out.bLength = sizeof(usb_ep_desc_t),\
- .ep_out.bDescriptorType = USB_DT_ENDPOINT,\
- .ep_out.bEndpointAddress = UDI_HID_RAW_EP_OUT | USB_EP_DIR_OUT,\
- .ep_out.bmAttributes = USB_EP_TYPE_INTERRUPT,\
- .ep_out.wMaxPacketSize = LE16(RAW_EPSIZE),\
- .ep_out.bInterval = RAW_POLLING_INTERVAL,\
- .ep_in.bLength = sizeof(usb_ep_desc_t),\
- .ep_in.bDescriptorType = USB_DT_ENDPOINT,\
- .ep_in.bEndpointAddress = UDI_HID_RAW_EP_IN | USB_EP_DIR_IN,\
- .ep_in.bmAttributes = USB_EP_TYPE_INTERRUPT,\
- .ep_in.wMaxPacketSize = LE16(RAW_EPSIZE),\
- .ep_in.bInterval = RAW_POLLING_INTERVAL,\
-}
-
-#define UDI_HID_RAW_REPORT_SIZE RAW_EPSIZE
+# define UDI_HID_RAW_DESC \
+ { \
+ .iface.bLength = sizeof(usb_iface_desc_t), .iface.bDescriptorType = USB_DT_INTERFACE, .iface.bInterfaceNumber = RAW_INTERFACE, .iface.bAlternateSetting = 0, .iface.bNumEndpoints = 2, .iface.bInterfaceClass = HID_CLASS, .iface.bInterfaceSubClass = HID_SUB_CLASS_NOBOOT, .iface.bInterfaceProtocol = HID_SUB_CLASS_NOBOOT, .iface.iInterface = UDI_HID_RAW_STRING_ID, .hid.bLength = sizeof(usb_hid_descriptor_t), .hid.bDescriptorType = USB_DT_HID, .hid.bcdHID = LE16(USB_HID_BDC_V1_11), .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE, .hid.bNumDescriptors = USB_HID_NUM_DESC, .hid.bRDescriptorType = USB_DT_HID_REPORT, .hid.wDescriptorLength = LE16(sizeof(udi_hid_raw_report_desc_t)), .ep_out.bLength = sizeof(usb_ep_desc_t), .ep_out.bDescriptorType = USB_DT_ENDPOINT, .ep_out.bEndpointAddress = UDI_HID_RAW_EP_OUT | USB_EP_DIR_OUT, .ep_out.bmAttributes = USB_EP_TYPE_INTERRUPT, .ep_out.wMaxPacketSize = LE16(RAW_EPSIZE), .ep_out.bInterval = RAW_POLLING_INTERVAL, \
+ .ep_in.bLength = sizeof(usb_ep_desc_t), .ep_in.bDescriptorType = USB_DT_ENDPOINT, .ep_in.bEndpointAddress = UDI_HID_RAW_EP_IN | USB_EP_DIR_IN, .ep_in.bmAttributes = USB_EP_TYPE_INTERRUPT, .ep_in.wMaxPacketSize = LE16(RAW_EPSIZE), .ep_in.bInterval = RAW_POLLING_INTERVAL, \
+ }
+
+# define UDI_HID_RAW_REPORT_SIZE RAW_EPSIZE
extern uint8_t udi_hid_raw_report_set[UDI_HID_RAW_REPORT_SIZE];
-//report buffer
+// report buffer
extern uint8_t udi_hid_raw_report[UDI_HID_RAW_REPORT_SIZE];
COMPILER_PACK_RESET()
-#endif //RAW
+#endif // RAW
// **********************************************************************
// CON Descriptor structure and content
@@ -572,57 +457,32 @@ COMPILER_PACK_RESET()
COMPILER_PACK_SET(1)
typedef struct {
- usb_iface_desc_t iface;
+ usb_iface_desc_t iface;
usb_hid_descriptor_t hid;
- usb_ep_desc_t ep_out;
- usb_ep_desc_t ep_in;
+ usb_ep_desc_t ep_out;
+ usb_ep_desc_t ep_in;
} udi_hid_con_desc_t;
typedef struct {
uint8_t array[34];
} udi_hid_con_report_desc_t;
-#define UDI_HID_CON_DESC {\
- .iface.bLength = sizeof(usb_iface_desc_t),\
- .iface.bDescriptorType = USB_DT_INTERFACE,\
- .iface.bInterfaceNumber = UDI_HID_CON_IFACE_NUMBER,\
- .iface.bAlternateSetting = 0,\
- .iface.bNumEndpoints = 2,\
- .iface.bInterfaceClass = HID_CLASS,\
- .iface.bInterfaceSubClass = HID_SUB_CLASS_NOBOOT,\
- .iface.bInterfaceProtocol = HID_SUB_CLASS_NOBOOT,\
- .iface.iInterface = UDI_HID_CON_STRING_ID,\
- .hid.bLength = sizeof(usb_hid_descriptor_t),\
- .hid.bDescriptorType = USB_DT_HID,\
- .hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
- .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
- .hid.bNumDescriptors = USB_HID_NUM_DESC,\
- .hid.bRDescriptorType = USB_DT_HID_REPORT,\
- .hid.wDescriptorLength = LE16(sizeof(udi_hid_con_report_desc_t)),\
- .ep_out.bLength = sizeof(usb_ep_desc_t),\
- .ep_out.bDescriptorType = USB_DT_ENDPOINT,\
- .ep_out.bEndpointAddress = UDI_HID_CON_EP_OUT | USB_EP_DIR_OUT,\
- .ep_out.bmAttributes = USB_EP_TYPE_INTERRUPT,\
- .ep_out.wMaxPacketSize = LE16(CONSOLE_EPSIZE),\
- .ep_out.bInterval = CON_POLLING_INTERVAL,\
- .ep_in.bLength = sizeof(usb_ep_desc_t),\
- .ep_in.bDescriptorType = USB_DT_ENDPOINT,\
- .ep_in.bEndpointAddress = UDI_HID_CON_EP_IN | USB_EP_DIR_IN,\
- .ep_in.bmAttributes = USB_EP_TYPE_INTERRUPT,\
- .ep_in.wMaxPacketSize = LE16(CONSOLE_EPSIZE),\
- .ep_in.bInterval = CON_POLLING_INTERVAL,\
-}
-
-#define UDI_HID_CON_REPORT_SIZE CONSOLE_EPSIZE
+# define UDI_HID_CON_DESC \
+ { \
+ .iface.bLength = sizeof(usb_iface_desc_t), .iface.bDescriptorType = USB_DT_INTERFACE, .iface.bInterfaceNumber = UDI_HID_CON_IFACE_NUMBER, .iface.bAlternateSetting = 0, .iface.bNumEndpoints = 2, .iface.bInterfaceClass = HID_CLASS, .iface.bInterfaceSubClass = HID_SUB_CLASS_NOBOOT, .iface.bInterfaceProtocol = HID_SUB_CLASS_NOBOOT, .iface.iInterface = UDI_HID_CON_STRING_ID, .hid.bLength = sizeof(usb_hid_descriptor_t), .hid.bDescriptorType = USB_DT_HID, .hid.bcdHID = LE16(USB_HID_BDC_V1_11), .hid.bCountryCode = USB_HID_NO_COUNTRY_CODE, .hid.bNumDescriptors = USB_HID_NUM_DESC, .hid.bRDescriptorType = USB_DT_HID_REPORT, .hid.wDescriptorLength = LE16(sizeof(udi_hid_con_report_desc_t)), .ep_out.bLength = sizeof(usb_ep_desc_t), .ep_out.bDescriptorType = USB_DT_ENDPOINT, .ep_out.bEndpointAddress = UDI_HID_CON_EP_OUT | USB_EP_DIR_OUT, .ep_out.bmAttributes = USB_EP_TYPE_INTERRUPT, .ep_out.wMaxPacketSize = LE16(CONSOLE_EPSIZE), .ep_out.bInterval = CON_POLLING_INTERVAL, \
+ .ep_in.bLength = sizeof(usb_ep_desc_t), .ep_in.bDescriptorType = USB_DT_ENDPOINT, .ep_in.bEndpointAddress = UDI_HID_CON_EP_IN | USB_EP_DIR_IN, .ep_in.bmAttributes = USB_EP_TYPE_INTERRUPT, .ep_in.wMaxPacketSize = LE16(CONSOLE_EPSIZE), .ep_in.bInterval = CON_POLLING_INTERVAL, \
+ }
+
+# define UDI_HID_CON_REPORT_SIZE CONSOLE_EPSIZE
extern uint8_t udi_hid_con_report_set[UDI_HID_CON_REPORT_SIZE];
-//report buffer
+// report buffer
extern uint8_t udi_hid_con_report[UDI_HID_CON_REPORT_SIZE];
COMPILER_PACK_RESET()
-#endif //CON
+#endif // CON
// **********************************************************************
// CDC Descriptor structure and content
@@ -662,86 +522,28 @@ typedef struct {
} usb_cdc_union_desc_t;
typedef struct {
- usb_association_desc_t iaface;
- usb_iface_desc_t iface_c;
- usb_cdc_hdr_desc_t fd;
+ usb_association_desc_t iaface;
+ usb_iface_desc_t iface_c;
+ usb_cdc_hdr_desc_t fd;
usb_cdc_call_mgmt_desc_t mfd;
- usb_cdc_acm_desc_t acmd;
- usb_cdc_union_desc_t ufd;
- usb_ep_desc_t ep_c;
- usb_iface_desc_t iface_d;
- usb_ep_desc_t ep_tx;
- usb_ep_desc_t ep_rx;
+ usb_cdc_acm_desc_t acmd;
+ usb_cdc_union_desc_t ufd;
+ usb_ep_desc_t ep_c;
+ usb_iface_desc_t iface_d;
+ usb_ep_desc_t ep_tx;
+ usb_ep_desc_t ep_rx;
} udi_cdc_desc_t;
-#define CDC_DESCRIPTOR {\
- .iaface.bLength = sizeof(usb_association_desc_t),\
- .iaface.bDescriptorType = USB_DT_IAD,\
- .iaface.bFirstInterface = CDC_STATUS_INTERFACE,\
- .iaface.bInterfaceCount = 2,\
- .iaface.bFunctionClass = CDC_CLASS_DEVICE,\
- .iaface.bFunctionSubClass = CDC_SUBCLASS_ACM,\
- .iaface.bFunctionProtocol = CDC_PROTOCOL_V25TER,\
- .iaface.iFunction = 0,\
- .iface_c.bLength = sizeof(usb_iface_desc_t),\
- .iface_c.bDescriptorType = USB_DT_INTERFACE,\
- .iface_c.bInterfaceNumber = CDC_STATUS_INTERFACE,\
- .iface_c.bAlternateSetting = 0,\
- .iface_c.bNumEndpoints = 1,\
- .iface_c.bInterfaceClass = 0x02,\
- .iface_c.bInterfaceSubClass = 0x02,\
- .iface_c.bInterfaceProtocol = CDC_PROTOCOL_V25TER,\
- .iface_c.iInterface = 0,\
- .fd.bFunctionLength = sizeof(usb_cdc_hdr_desc_t),\
- .fd.bDescriptorType = CDC_CS_INTERFACE,\
- .fd.bDescriptorSubtype = CDC_SCS_HEADER,\
- .fd.bcdCDC = 0x0110,\
- .mfd.bFunctionLength = sizeof(usb_cdc_call_mgmt_desc_t),\
- .mfd.bDescriptorType = CDC_CS_INTERFACE,\
- .mfd.bDescriptorSubtype = CDC_SCS_CALL_MGMT,\
- .mfd.bmCapabilities = CDC_CALL_MGMT_SUPPORTED,\
- .mfd.bDataInterface = CDC_DATA_INTERFACE,\
- .acmd.bFunctionLength = sizeof(usb_cdc_acm_desc_t),\
- .acmd.bDescriptorType = CDC_CS_INTERFACE,\
- .acmd.bDescriptorSubtype = CDC_SCS_ACM,\
- .acmd.bmCapabilities = CDC_ACM_SUPPORT_LINE_REQUESTS,\
- .ufd.bFunctionLength = sizeof(usb_cdc_union_desc_t),\
- .ufd.bDescriptorType = CDC_CS_INTERFACE,\
- .ufd.bDescriptorSubtype = CDC_SCS_UNION,\
- .ufd.bMasterInterface = CDC_STATUS_INTERFACE,\
- .ufd.bSlaveInterface0 = CDC_DATA_INTERFACE,\
- .ep_c.bLength = sizeof(usb_ep_desc_t),\
- .ep_c.bDescriptorType = USB_DT_ENDPOINT,\
- .ep_c.bEndpointAddress = CDC_ACM_ENDPOINT | USB_EP_DIR_IN,\
- .ep_c.bmAttributes = USB_EP_TYPE_INTERRUPT,\
- .ep_c.wMaxPacketSize = LE16(CDC_ACM_SIZE),\
- .ep_c.bInterval = CDC_EP_INTERVAL_STATUS,\
- .iface_d.bLength = sizeof(usb_iface_desc_t),\
- .iface_d.bDescriptorType = USB_DT_INTERFACE,\
- .iface_d.bInterfaceNumber = CDC_DATA_INTERFACE,\
- .iface_d.bAlternateSetting = 0,\
- .iface_d.bNumEndpoints = 2,\
- .iface_d.bInterfaceClass = CDC_CLASS_DATA,\
- .iface_d.bInterfaceSubClass = 0,\
- .iface_d.bInterfaceProtocol = 0,\
- .iface_d.iInterface = 0,\
- .ep_rx.bLength = sizeof(usb_ep_desc_t),\
- .ep_rx.bDescriptorType = USB_DT_ENDPOINT,\
- .ep_rx.bEndpointAddress = CDC_RX_ENDPOINT | USB_EP_DIR_OUT,\
- .ep_rx.bmAttributes = USB_EP_TYPE_BULK,\
- .ep_rx.wMaxPacketSize = LE16(CDC_RX_SIZE),\
- .ep_rx.bInterval = CDC_EP_INTERVAL_DATA,\
- .ep_tx.bLength = sizeof(usb_ep_desc_t),\
- .ep_tx.bDescriptorType = USB_DT_ENDPOINT,\
- .ep_tx.bEndpointAddress = CDC_TX_ENDPOINT | USB_EP_DIR_IN,\
- .ep_tx.bmAttributes = USB_EP_TYPE_BULK,\
- .ep_tx.wMaxPacketSize = LE16(CDC_TX_SIZE),\
- .ep_tx.bInterval = CDC_EP_INTERVAL_DATA,\
-}
+# define CDC_DESCRIPTOR \
+ { \
+ .iaface.bLength = sizeof(usb_association_desc_t), .iaface.bDescriptorType = USB_DT_IAD, .iaface.bFirstInterface = CDC_STATUS_INTERFACE, .iaface.bInterfaceCount = 2, .iaface.bFunctionClass = CDC_CLASS_DEVICE, .iaface.bFunctionSubClass = CDC_SUBCLASS_ACM, .iaface.bFunctionProtocol = CDC_PROTOCOL_V25TER, .iaface.iFunction = 0, .iface_c.bLength = sizeof(usb_iface_desc_t), .iface_c.bDescriptorType = USB_DT_INTERFACE, .iface_c.bInterfaceNumber = CDC_STATUS_INTERFACE, .iface_c.bAlternateSetting = 0, .iface_c.bNumEndpoints = 1, .iface_c.bInterfaceClass = 0x02, .iface_c.bInterfaceSubClass = 0x02, .iface_c.bInterfaceProtocol = CDC_PROTOCOL_V25TER, .iface_c.iInterface = 0, .fd.bFunctionLength = sizeof(usb_cdc_hdr_desc_t), .fd.bDescriptorType = CDC_CS_INTERFACE, .fd.bDescriptorSubtype = CDC_SCS_HEADER, .fd.bcdCDC = 0x0110, .mfd.bFunctionLength = sizeof(usb_cdc_call_mgmt_desc_t), .mfd.bDescriptorType = CDC_CS_INTERFACE, .mfd.bDescriptorSubtype = CDC_SCS_CALL_MGMT, \
+ .mfd.bmCapabilities = CDC_CALL_MGMT_SUPPORTED, .mfd.bDataInterface = CDC_DATA_INTERFACE, .acmd.bFunctionLength = sizeof(usb_cdc_acm_desc_t), .acmd.bDescriptorType = CDC_CS_INTERFACE, .acmd.bDescriptorSubtype = CDC_SCS_ACM, .acmd.bmCapabilities = CDC_ACM_SUPPORT_LINE_REQUESTS, .ufd.bFunctionLength = sizeof(usb_cdc_union_desc_t), .ufd.bDescriptorType = CDC_CS_INTERFACE, .ufd.bDescriptorSubtype = CDC_SCS_UNION, .ufd.bMasterInterface = CDC_STATUS_INTERFACE, .ufd.bSlaveInterface0 = CDC_DATA_INTERFACE, .ep_c.bLength = sizeof(usb_ep_desc_t), .ep_c.bDescriptorType = USB_DT_ENDPOINT, .ep_c.bEndpointAddress = CDC_ACM_ENDPOINT | USB_EP_DIR_IN, .ep_c.bmAttributes = USB_EP_TYPE_INTERRUPT, .ep_c.wMaxPacketSize = LE16(CDC_ACM_SIZE), .ep_c.bInterval = CDC_EP_INTERVAL_STATUS, .iface_d.bLength = sizeof(usb_iface_desc_t), .iface_d.bDescriptorType = USB_DT_INTERFACE, .iface_d.bInterfaceNumber = CDC_DATA_INTERFACE, .iface_d.bAlternateSetting = 0, .iface_d.bNumEndpoints = 2, \
+ .iface_d.bInterfaceClass = CDC_CLASS_DATA, .iface_d.bInterfaceSubClass = 0, .iface_d.bInterfaceProtocol = 0, .iface_d.iInterface = 0, .ep_rx.bLength = sizeof(usb_ep_desc_t), .ep_rx.bDescriptorType = USB_DT_ENDPOINT, .ep_rx.bEndpointAddress = CDC_RX_ENDPOINT | USB_EP_DIR_OUT, .ep_rx.bmAttributes = USB_EP_TYPE_BULK, .ep_rx.wMaxPacketSize = LE16(CDC_RX_SIZE), .ep_rx.bInterval = CDC_EP_INTERVAL_DATA, .ep_tx.bLength = sizeof(usb_ep_desc_t), .ep_tx.bDescriptorType = USB_DT_ENDPOINT, .ep_tx.bEndpointAddress = CDC_TX_ENDPOINT | USB_EP_DIR_IN, .ep_tx.bmAttributes = USB_EP_TYPE_BULK, .ep_tx.wMaxPacketSize = LE16(CDC_TX_SIZE), .ep_tx.bInterval = CDC_EP_INTERVAL_DATA, \
+ }
COMPILER_PACK_RESET()
-#endif //CDC
+#endif // CDC
// **********************************************************************
// CONFIGURATION Descriptor structure and content
@@ -778,4 +580,4 @@ typedef struct {
COMPILER_PACK_RESET()
-#endif //_UDI_DEVICE_CONF_H_
+#endif //_UDI_DEVICE_CONF_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_device_epsize.h b/tmk_core/protocol/arm_atsam/usb/udi_device_epsize.h
index 96d03c2869..65339bffec 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_device_epsize.h
+++ b/tmk_core/protocol/arm_atsam/usb/udi_device_epsize.h
@@ -18,15 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef _UDI_DEVICE_EPSIZE_H_
#define _UDI_DEVICE_EPSIZE_H_
-#define KEYBOARD_EPSIZE 8
-#define MOUSE_EPSIZE 8
-#define EXTRAKEY_EPSIZE 8
-#define RAW_EPSIZE 64
-#define CONSOLE_EPSIZE 32
-#define NKRO_EPSIZE 32
-#define MIDI_STREAM_EPSIZE 64
-#define CDC_NOTIFICATION_EPSIZE 8
-#define CDC_EPSIZE 16
-
-#endif //_UDI_DEVICE_EPSIZE_H_
+#define KEYBOARD_EPSIZE 8
+#define MOUSE_EPSIZE 8
+#define EXTRAKEY_EPSIZE 8
+#define RAW_EPSIZE 64
+#define CONSOLE_EPSIZE 32
+#define NKRO_EPSIZE 32
+#define MIDI_STREAM_EPSIZE 64
+#define CDC_NOTIFICATION_EPSIZE 8
+#define CDC_EPSIZE 16
+#endif //_UDI_DEVICE_EPSIZE_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid.c b/tmk_core/protocol/arm_atsam/usb/udi_hid.c
index 131b7a0ece..b0bdcc6932 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_hid.c
+++ b/tmk_core/protocol/arm_atsam/usb/udi_hid.c
@@ -50,7 +50,6 @@
#include "udc.h"
#include "udi_hid.h"
-
/**
* \ingroup udi_hid_group
* \defgroup udi_hid_group_internal Implementation of HID common library
@@ -64,34 +63,31 @@
*/
static bool udi_hid_reqstdifaceget_descriptor(uint8_t *report_desc);
-bool udi_hid_setup( uint8_t *rate, uint8_t *protocol, uint8_t *report_desc, bool (*setup_report)(void) )
-{
+bool udi_hid_setup(uint8_t *rate, uint8_t *protocol, uint8_t *report_desc, bool (*setup_report)(void)) {
if (Udd_setup_is_in()) {
// Requests Interface GET
if (Udd_setup_type() == USB_REQ_TYPE_STANDARD) {
// Requests Standard Interface Get
switch (udd_g_ctrlreq.req.bRequest) {
-
- case USB_REQ_GET_DESCRIPTOR:
- return udi_hid_reqstdifaceget_descriptor(report_desc);
+ case USB_REQ_GET_DESCRIPTOR:
+ return udi_hid_reqstdifaceget_descriptor(report_desc);
}
}
if (Udd_setup_type() == USB_REQ_TYPE_CLASS) {
// Requests Class Interface Get
switch (udd_g_ctrlreq.req.bRequest) {
-
- case USB_REQ_HID_GET_REPORT:
- return setup_report();
-
- case USB_REQ_HID_GET_IDLE:
- udd_g_ctrlreq.payload = rate;
- udd_g_ctrlreq.payload_size = 1;
- return true;
-
- case USB_REQ_HID_GET_PROTOCOL:
- udd_g_ctrlreq.payload = protocol;
- udd_g_ctrlreq.payload_size = 1;
- return true;
+ case USB_REQ_HID_GET_REPORT:
+ return setup_report();
+
+ case USB_REQ_HID_GET_IDLE:
+ udd_g_ctrlreq.payload = rate;
+ udd_g_ctrlreq.payload_size = 1;
+ return true;
+
+ case USB_REQ_HID_GET_PROTOCOL:
+ udd_g_ctrlreq.payload = protocol;
+ udd_g_ctrlreq.payload_size = 1;
+ return true;
}
}
}
@@ -100,60 +96,50 @@ bool udi_hid_setup( uint8_t *rate, uint8_t *protocol, uint8_t *report_desc, bool
if (Udd_setup_type() == USB_REQ_TYPE_CLASS) {
// Requests Class Interface Set
switch (udd_g_ctrlreq.req.bRequest) {
+ case USB_REQ_HID_SET_REPORT:
+ return setup_report();
- case USB_REQ_HID_SET_REPORT:
- return setup_report();
-
- case USB_REQ_HID_SET_IDLE:
- *rate = udd_g_ctrlreq.req.wValue >> 8;
- return true;
+ case USB_REQ_HID_SET_IDLE:
+ *rate = udd_g_ctrlreq.req.wValue >> 8;
+ return true;
- case USB_REQ_HID_SET_PROTOCOL:
- if (0 != udd_g_ctrlreq.req.wLength)
- return false;
- *protocol = udd_g_ctrlreq.req.wValue;
- return true;
+ case USB_REQ_HID_SET_PROTOCOL:
+ if (0 != udd_g_ctrlreq.req.wLength) return false;
+ *protocol = udd_g_ctrlreq.req.wValue;
+ return true;
}
}
}
- return false; // Request not supported
+ return false; // Request not supported
}
//---------------------------------------------
//------- Internal routines
-static bool udi_hid_reqstdifaceget_descriptor(uint8_t *report_desc)
-{
+static bool udi_hid_reqstdifaceget_descriptor(uint8_t *report_desc) {
usb_hid_descriptor_t UDC_DESC_STORAGE *ptr_hid_desc;
// Get the USB descriptor which is located after the interface descriptor
// This descriptor must be the HID descriptor
- ptr_hid_desc = (usb_hid_descriptor_t UDC_DESC_STORAGE *) ((uint8_t *)
- udc_get_interface_desc() + sizeof(usb_iface_desc_t));
- if (USB_DT_HID != ptr_hid_desc->bDescriptorType)
- return false;
+ ptr_hid_desc = (usb_hid_descriptor_t UDC_DESC_STORAGE *)((uint8_t *)udc_get_interface_desc() + sizeof(usb_iface_desc_t));
+ if (USB_DT_HID != ptr_hid_desc->bDescriptorType) return false;
// The SETUP request can ask for:
// - an USB_DT_HID descriptor
// - or USB_DT_HID_REPORT descriptor
// - or USB_DT_HID_PHYSICAL descriptor
- if (USB_DT_HID == (uint8_t) (udd_g_ctrlreq.req.wValue >> 8)) {
+ if (USB_DT_HID == (uint8_t)(udd_g_ctrlreq.req.wValue >> 8)) {
// USB_DT_HID descriptor requested then send it
- udd_g_ctrlreq.payload = (uint8_t *) ptr_hid_desc;
- udd_g_ctrlreq.payload_size =
- min(udd_g_ctrlreq.req.wLength,
- ptr_hid_desc->bLength);
+ udd_g_ctrlreq.payload = (uint8_t *)ptr_hid_desc;
+ udd_g_ctrlreq.payload_size = min(udd_g_ctrlreq.req.wLength, ptr_hid_desc->bLength);
return true;
}
// The HID_X descriptor requested must correspond to report type
// included in the HID descriptor
- if (ptr_hid_desc->bRDescriptorType ==
- (uint8_t) (udd_g_ctrlreq.req.wValue >> 8)) {
+ if (ptr_hid_desc->bRDescriptorType == (uint8_t)(udd_g_ctrlreq.req.wValue >> 8)) {
// Send HID Report descriptor given by high level
- udd_g_ctrlreq.payload = report_desc;
- udd_g_ctrlreq.payload_size =
- min(udd_g_ctrlreq.req.wLength,
- le16_to_cpu(ptr_hid_desc->wDescriptorLength));
+ udd_g_ctrlreq.payload = report_desc;
+ udd_g_ctrlreq.payload_size = min(udd_g_ctrlreq.req.wLength, le16_to_cpu(ptr_hid_desc->wDescriptorLength));
return true;
}
return false;
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid.h b/tmk_core/protocol/arm_atsam/usb/udi_hid.h
index 0edb09c1c3..6fd2cabd4c 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_hid.h
+++ b/tmk_core/protocol/arm_atsam/usb/udi_hid.h
@@ -75,11 +75,11 @@ extern "C" {
*
* \return \c 1 if function was successfully done, otherwise \c 0.
*/
-bool udi_hid_setup( uint8_t *rate, uint8_t *protocol, uint8_t *report_desc, bool (*setup_report)(void) );
+bool udi_hid_setup(uint8_t *rate, uint8_t *protocol, uint8_t *report_desc, bool (*setup_report)(void));
//@}
#ifdef __cplusplus
}
#endif
-#endif // _UDI_HID_H_
+#endif // _UDI_HID_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
index c263ac4aa1..c3952d50c8 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
+++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
@@ -61,15 +61,15 @@
//***************************************************************************
#ifdef KBD
-bool udi_hid_kbd_enable(void);
-void udi_hid_kbd_disable(void);
-bool udi_hid_kbd_setup(void);
+bool udi_hid_kbd_enable(void);
+void udi_hid_kbd_disable(void);
+bool udi_hid_kbd_setup(void);
uint8_t udi_hid_kbd_getsetting(void);
UDC_DESC_STORAGE udi_api_t udi_api_hid_kbd = {
- .enable = (bool(*)(void))udi_hid_kbd_enable,
- .disable = (void (*)(void))udi_hid_kbd_disable,
- .setup = (bool(*)(void))udi_hid_kbd_setup,
+ .enable = (bool (*)(void))udi_hid_kbd_enable,
+ .disable = (void (*)(void))udi_hid_kbd_disable,
+ .setup = (bool (*)(void))udi_hid_kbd_setup,
.getsetting = (uint8_t(*)(void))udi_hid_kbd_getsetting,
.sof_notify = NULL,
};
@@ -94,40 +94,38 @@ COMPILER_WORD_ALIGNED
static uint8_t udi_hid_kbd_report_trans[UDI_HID_KBD_REPORT_SIZE];
COMPILER_WORD_ALIGNED
-UDC_DESC_STORAGE udi_hid_kbd_report_desc_t udi_hid_kbd_report_desc = {
- {
- 0x05, 0x01, // Usage Page (Generic Desktop)
- 0x09, 0x06, // Usage (Keyboard)
- 0xA1, 0x01, // Collection (Application)
- 0x05, 0x07, // Usage Page (Keyboard)
- 0x19, 0xE0, // Usage Minimum (224)
- 0x29, 0xE7, // Usage Maximum (231)
- 0x15, 0x00, // Logical Minimum (0)
- 0x25, 0x01, // Logical Maximum (1)
- 0x75, 0x01, // Report Size (1)
- 0x95, 0x08, // Report Count (8)
- 0x81, 0x02, // Input (Data, Variable, Absolute)
- 0x81, 0x01, // Input (Constant)
- 0x19, 0x00, // Usage Minimum (0)
- 0x29, 0x65, // Usage Maximum (101)
- 0x15, 0x00, // Logical Minimum (0)
- 0x25, 0x65, // Logical Maximum (101)
- 0x75, 0x08, // Report Size (8)
- 0x95, 0x06, // Report Count (6)
- 0x81, 0x00, // Input (Data, Array)
- 0x05, 0x08, // Usage Page (LED)
- 0x19, 0x01, // Usage Minimum (1)
- 0x29, 0x05, // Usage Maximum (5)
- 0x15, 0x00, // Logical Minimum (0)
- 0x25, 0x01, // Logical Maximum (1)
- 0x75, 0x01, // Report Size (1)
- 0x95, 0x05, // Report Count (5)
- 0x91, 0x02, // Output (Data, Variable, Absolute)
- 0x95, 0x03, // Report Count (3)
- 0x91, 0x01, // Output (Constant)
- 0xC0 // End Collection
- }
-};
+UDC_DESC_STORAGE udi_hid_kbd_report_desc_t udi_hid_kbd_report_desc = {{
+ 0x05, 0x01, // Usage Page (Generic Desktop)
+ 0x09, 0x06, // Usage (Keyboard)
+ 0xA1, 0x01, // Collection (Application)
+ 0x05, 0x07, // Usage Page (Keyboard)
+ 0x19, 0xE0, // Usage Minimum (224)
+ 0x29, 0xE7, // Usage Maximum (231)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x25, 0x01, // Logical Maximum (1)
+ 0x75, 0x01, // Report Size (1)
+ 0x95, 0x08, // Report Count (8)
+ 0x81, 0x02, // Input (Data, Variable, Absolute)
+ 0x81, 0x01, // Input (Constant)
+ 0x19, 0x00, // Usage Minimum (0)
+ 0x29, 0xFF, // Usage Maximum (255)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x25, 0xFF, // Logical Maximum (255)
+ 0x75, 0x08, // Report Size (8)
+ 0x95, 0x06, // Report Count (6)
+ 0x81, 0x00, // Input (Data, Array)
+ 0x05, 0x08, // Usage Page (LED)
+ 0x19, 0x01, // Usage Minimum (1)
+ 0x29, 0x05, // Usage Maximum (5)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x25, 0x01, // Logical Maximum (1)
+ 0x75, 0x01, // Report Size (1)
+ 0x95, 0x05, // Report Count (5)
+ 0x91, 0x02, // Output (Data, Variable, Absolute)
+ 0x95, 0x03, // Report Count (3)
+ 0x91, 0x01, // Output (Constant)
+ 0xC0 // End Collection
+}};
static bool udi_hid_kbd_setreport(void);
@@ -135,51 +133,34 @@ static void udi_hid_kbd_report_sent(udd_ep_status_t status, iram_size_t nb_sent,
static void udi_hid_kbd_setreport_valid(void);
-bool udi_hid_kbd_enable(void)
-{
+bool udi_hid_kbd_enable(void) {
// Initialize internal values
- udi_hid_kbd_rate = 0;
- udi_hid_kbd_protocol = 0;
+ udi_hid_kbd_rate = 0;
+ udi_hid_kbd_protocol = 0;
udi_hid_kbd_b_report_trans_ongoing = false;
memset(udi_hid_kbd_report, 0, UDI_HID_KBD_REPORT_SIZE);
udi_hid_kbd_b_report_valid = false;
return UDI_HID_KBD_ENABLE_EXT();
}
-void udi_hid_kbd_disable(void)
-{
- UDI_HID_KBD_DISABLE_EXT();
-}
+void udi_hid_kbd_disable(void) { UDI_HID_KBD_DISABLE_EXT(); }
-bool udi_hid_kbd_setup(void)
-{
- return udi_hid_setup(&udi_hid_kbd_rate,
- &udi_hid_kbd_protocol,
- (uint8_t *) &udi_hid_kbd_report_desc,
- udi_hid_kbd_setreport);
-}
+bool udi_hid_kbd_setup(void) { return udi_hid_setup(&udi_hid_kbd_rate, &udi_hid_kbd_protocol, (uint8_t *)&udi_hid_kbd_report_desc, udi_hid_kbd_setreport); }
-uint8_t udi_hid_kbd_getsetting(void)
-{
- return 0;
-}
+uint8_t udi_hid_kbd_getsetting(void) { return 0; }
-static bool udi_hid_kbd_setreport(void)
-{
- if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8))
- && (0 == (0xFF & udd_g_ctrlreq.req.wValue))
- && (1 == udd_g_ctrlreq.req.wLength)) {
+static bool udi_hid_kbd_setreport(void) {
+ if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8)) && (0 == (0xFF & udd_g_ctrlreq.req.wValue)) && (1 == udd_g_ctrlreq.req.wLength)) {
// Report OUT type on report ID 0 from USB Host
- udd_g_ctrlreq.payload = &udi_hid_kbd_report_set;
- udd_g_ctrlreq.callback = udi_hid_kbd_setreport_valid;
+ udd_g_ctrlreq.payload = &udi_hid_kbd_report_set;
+ udd_g_ctrlreq.callback = udi_hid_kbd_setreport_valid;
udd_g_ctrlreq.payload_size = 1;
return true;
}
return false;
}
-bool udi_hid_kbd_send_report(void)
-{
+bool udi_hid_kbd_send_report(void) {
if (!main_b_kbd_enable) {
return false;
}
@@ -189,19 +170,13 @@ bool udi_hid_kbd_send_report(void)
}
memcpy(udi_hid_kbd_report_trans, udi_hid_kbd_report, UDI_HID_KBD_REPORT_SIZE);
- udi_hid_kbd_b_report_valid = false;
- udi_hid_kbd_b_report_trans_ongoing =
- udd_ep_run(UDI_HID_KBD_EP_IN | USB_EP_DIR_IN,
- false,
- udi_hid_kbd_report_trans,
- UDI_HID_KBD_REPORT_SIZE,
- udi_hid_kbd_report_sent);
+ udi_hid_kbd_b_report_valid = false;
+ udi_hid_kbd_b_report_trans_ongoing = udd_ep_run(UDI_HID_KBD_EP_IN | USB_EP_DIR_IN, false, udi_hid_kbd_report_trans, UDI_HID_KBD_REPORT_SIZE, udi_hid_kbd_report_sent);
return udi_hid_kbd_b_report_trans_ongoing;
}
-static void udi_hid_kbd_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep)
-{
+static void udi_hid_kbd_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep) {
UNUSED(status);
UNUSED(nb_sent);
UNUSED(ep);
@@ -211,27 +186,26 @@ static void udi_hid_kbd_report_sent(udd_ep_status_t status, iram_size_t nb_sent,
}
}
-static void udi_hid_kbd_setreport_valid(void)
-{
- //UDI_HID_KBD_CHANGE_LED(udi_hid_kbd_report_set);
+static void udi_hid_kbd_setreport_valid(void) {
+ // UDI_HID_KBD_CHANGE_LED(udi_hid_kbd_report_set);
}
-#endif //KBD
+#endif // KBD
//********************************************************************************************
// NKRO Keyboard
//********************************************************************************************
#ifdef NKRO
-bool udi_hid_nkro_enable(void);
-void udi_hid_nkro_disable(void);
-bool udi_hid_nkro_setup(void);
+bool udi_hid_nkro_enable(void);
+void udi_hid_nkro_disable(void);
+bool udi_hid_nkro_setup(void);
uint8_t udi_hid_nkro_getsetting(void);
UDC_DESC_STORAGE udi_api_t udi_api_hid_nkro = {
- .enable = (bool(*)(void))udi_hid_nkro_enable,
- .disable = (void (*)(void))udi_hid_nkro_disable,
- .setup = (bool(*)(void))udi_hid_nkro_setup,
+ .enable = (bool (*)(void))udi_hid_nkro_enable,
+ .disable = (void (*)(void))udi_hid_nkro_disable,
+ .setup = (bool (*)(void))udi_hid_nkro_setup,
.getsetting = (uint8_t(*)(void))udi_hid_nkro_getsetting,
.sof_notify = NULL,
};
@@ -256,98 +230,79 @@ COMPILER_WORD_ALIGNED
static uint8_t udi_hid_nkro_report_trans[UDI_HID_NKRO_REPORT_SIZE];
COMPILER_WORD_ALIGNED
-UDC_DESC_STORAGE udi_hid_nkro_report_desc_t udi_hid_nkro_report_desc = {
- {
- 0x05, 0x01, // Usage Page (Generic Desktop),
- 0x09, 0x06, // Usage (Keyboard),
- 0xA1, 0x01, // Collection (Application) - Keyboard,
-
- //Mods
- 0x75, 0x01, // Report Size (1),
- 0x95, 0x08, // Report Count (8),
- 0x15, 0x00, // Logical Minimum (0),
- 0x25, 0x01, // Logical Maximum (1),
- 0x05, 0x07, // Usage Page (Key Codes),
- 0x19, 0xE0, // Usage Minimum (224),
- 0x29, 0xE7, // Usage Maximum (231),
- 0x81, 0x02, // Input (Data, Variable, Absolute),
-
- //LED Report
- 0x75, 0x01, // Report Size (1),
- 0x95, 0x05, // Report Count (5),
- 0x05, 0x08, // Usage Page (LEDs),
- 0x19, 0x01, // Usage Minimum (1),
- 0x29, 0x05, // Usage Maximum (5),
- 0x91, 0x02, // Output (Data, Variable, Absolute),
-
- //LED Report Padding
- 0x75, 0x03, // Report Size (3),
- 0x95, 0x01, // Report Count (1),
- 0x91, 0x03, // Output (Constant),
-
- //Main keys
- 0x75, 0x01, // Report Size (1),
- 0x95, 0xF8, // Report Count (248),
- 0x15, 0x00, // Logical Minimum (0),
- 0x25, 0x01, // Logical Maximum (1),
- 0x05, 0x07, // Usage Page (Key Codes),
- 0x19, 0x00, // Usage Minimum (0),
- 0x29, 0xF7, // Usage Maximum (247),
- 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield),
- 0xc0, // End Collection - Keyboard
- }
-};
+UDC_DESC_STORAGE udi_hid_nkro_report_desc_t udi_hid_nkro_report_desc = {{
+ 0x05, 0x01, // Usage Page (Generic Desktop),
+ 0x09, 0x06, // Usage (Keyboard),
+ 0xA1, 0x01, // Collection (Application) - Keyboard,
+
+ // Mods
+ 0x75, 0x01, // Report Size (1),
+ 0x95, 0x08, // Report Count (8),
+ 0x15, 0x00, // Logical Minimum (0),
+ 0x25, 0x01, // Logical Maximum (1),
+ 0x05, 0x07, // Usage Page (Key Codes),
+ 0x19, 0xE0, // Usage Minimum (224),
+ 0x29, 0xE7, // Usage Maximum (231),
+ 0x81, 0x02, // Input (Data, Variable, Absolute),
+
+ // LED Report
+ 0x75, 0x01, // Report Size (1),
+ 0x95, 0x05, // Report Count (5),
+ 0x05, 0x08, // Usage Page (LEDs),
+ 0x19, 0x01, // Usage Minimum (1),
+ 0x29, 0x05, // Usage Maximum (5),
+ 0x91, 0x02, // Output (Data, Variable, Absolute),
+
+ // LED Report Padding
+ 0x75, 0x03, // Report Size (3),
+ 0x95, 0x01, // Report Count (1),
+ 0x91, 0x03, // Output (Constant),
+
+ // Main keys
+ 0x75, 0x01, // Report Size (1),
+ 0x95, 0xF8, // Report Count (248),
+ 0x15, 0x00, // Logical Minimum (0),
+ 0x25, 0x01, // Logical Maximum (1),
+ 0x05, 0x07, // Usage Page (Key Codes),
+ 0x19, 0x00, // Usage Minimum (0),
+ 0x29, 0xF7, // Usage Maximum (247),
+ 0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield),
+ 0xc0, // End Collection - Keyboard
+}};
static bool udi_hid_nkro_setreport(void);
static void udi_hid_nkro_setreport_valid(void);
static void udi_hid_nkro_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep);
-bool udi_hid_nkro_enable(void)
-{
+bool udi_hid_nkro_enable(void) {
// Initialize internal values
- udi_hid_nkro_rate = 0;
- udi_hid_nkro_protocol = 0;
+ udi_hid_nkro_rate = 0;
+ udi_hid_nkro_protocol = 0;
udi_hid_nkro_b_report_trans_ongoing = false;
memset(udi_hid_nkro_report, 0, UDI_HID_NKRO_REPORT_SIZE);
udi_hid_nkro_b_report_valid = false;
return UDI_HID_NKRO_ENABLE_EXT();
}
-void udi_hid_nkro_disable(void)
-{
- UDI_HID_NKRO_DISABLE_EXT();
-}
+void udi_hid_nkro_disable(void) { UDI_HID_NKRO_DISABLE_EXT(); }
-bool udi_hid_nkro_setup(void)
-{
- return udi_hid_setup(&udi_hid_nkro_rate,
- &udi_hid_nkro_protocol,
- (uint8_t *) &udi_hid_nkro_report_desc,
- udi_hid_nkro_setreport);
-}
+bool udi_hid_nkro_setup(void) { return udi_hid_setup(&udi_hid_nkro_rate, &udi_hid_nkro_protocol, (uint8_t *)&udi_hid_nkro_report_desc, udi_hid_nkro_setreport); }
-uint8_t udi_hid_nkro_getsetting(void)
-{
- return 0;
-}
+uint8_t udi_hid_nkro_getsetting(void) { return 0; }
-//keyboard receives LED report here
-static bool udi_hid_nkro_setreport(void)
-{
- if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8))
- && (0 == (0xFF & udd_g_ctrlreq.req.wValue))
- && (1 == udd_g_ctrlreq.req.wLength)) {
+// keyboard receives LED report here
+static bool udi_hid_nkro_setreport(void) {
+ if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8)) && (0 == (0xFF & udd_g_ctrlreq.req.wValue)) && (1 == udd_g_ctrlreq.req.wLength)) {
// Report OUT type on report ID 0 from USB Host
- udd_g_ctrlreq.payload = &udi_hid_nkro_report_set;
- udd_g_ctrlreq.callback = udi_hid_nkro_setreport_valid; //must call routine to transform setreport to LED state
+ udd_g_ctrlreq.payload = &udi_hid_nkro_report_set;
+ udd_g_ctrlreq.callback = udi_hid_nkro_setreport_valid; // must call routine to transform setreport to LED state
udd_g_ctrlreq.payload_size = 1;
return true;
}
return false;
}
-bool udi_hid_nkro_send_report(void)
-{
+bool udi_hid_nkro_send_report(void) {
if (!main_b_nkro_enable) {
return false;
}
@@ -357,19 +312,13 @@ bool udi_hid_nkro_send_report(void)
}
memcpy(udi_hid_nkro_report_trans, udi_hid_nkro_report, UDI_HID_NKRO_REPORT_SIZE);
- udi_hid_nkro_b_report_valid = false;
- udi_hid_nkro_b_report_trans_ongoing =
- udd_ep_run(UDI_HID_NKRO_EP_IN | USB_EP_DIR_IN,
- false,
- udi_hid_nkro_report_trans,
- UDI_HID_NKRO_REPORT_SIZE,
- udi_hid_nkro_report_sent);
+ udi_hid_nkro_b_report_valid = false;
+ udi_hid_nkro_b_report_trans_ongoing = udd_ep_run(UDI_HID_NKRO_EP_IN | USB_EP_DIR_IN, false, udi_hid_nkro_report_trans, UDI_HID_NKRO_REPORT_SIZE, udi_hid_nkro_report_sent);
return udi_hid_nkro_b_report_trans_ongoing;
}
-static void udi_hid_nkro_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep)
-{
+static void udi_hid_nkro_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep) {
UNUSED(status);
UNUSED(nb_sent);
UNUSED(ep);
@@ -379,27 +328,26 @@ static void udi_hid_nkro_report_sent(udd_ep_status_t status, iram_size_t nb_sent
}
}
-static void udi_hid_nkro_setreport_valid(void)
-{
- //UDI_HID_NKRO_CHANGE_LED(udi_hid_nkro_report_set);
+static void udi_hid_nkro_setreport_valid(void) {
+ // UDI_HID_NKRO_CHANGE_LED(udi_hid_nkro_report_set);
}
-#endif //NKRO
+#endif // NKRO
//********************************************************************************************
// EXK (extra-keys) SYS-CTRL Keyboard
//********************************************************************************************
#ifdef EXK
-bool udi_hid_exk_enable(void);
-void udi_hid_exk_disable(void);
-bool udi_hid_exk_setup(void);
+bool udi_hid_exk_enable(void);
+void udi_hid_exk_disable(void);
+bool udi_hid_exk_setup(void);
uint8_t udi_hid_exk_getsetting(void);
UDC_DESC_STORAGE udi_api_t udi_api_hid_exk = {
- .enable = (bool(*)(void))udi_hid_exk_enable,
- .disable = (void (*)(void))udi_hid_exk_disable,
- .setup = (bool(*)(void))udi_hid_exk_setup,
+ .enable = (bool (*)(void))udi_hid_exk_enable,
+ .disable = (void (*)(void))udi_hid_exk_disable,
+ .setup = (bool (*)(void))udi_hid_exk_setup,
.getsetting = (uint8_t(*)(void))udi_hid_exk_getsetting,
.sof_notify = NULL,
};
@@ -424,39 +372,37 @@ COMPILER_WORD_ALIGNED
static uint8_t udi_hid_exk_report_trans[UDI_HID_EXK_REPORT_SIZE];
COMPILER_WORD_ALIGNED
-UDC_DESC_STORAGE udi_hid_exk_report_desc_t udi_hid_exk_report_desc = {
- {
- // System Control Collection (8 bits)
-
- 0x05, 0x01, // Usage Page (Generic Desktop),
- 0x09, 0x80, // Usage (System Control),
- 0xA1, 0x01, // Collection (Application),
- 0x85, REPORT_ID_SYSTEM, // Report ID (2) (System),
- 0x16, 0x01, 0x00, // Logical Minimum (1),
- 0x26, 0x03, 0x00, // Logical Maximum (3),
- 0x1A, 0x81, 0x00, // Usage Minimum (81) (System Power Down),
- 0x2A, 0x83, 0x00, // Usage Maximum (83) (System Wake Up),
- 0x75, 0x10, // Report Size (16),
- 0x95, 0x01, // Report Count (1),
- 0x81, 0x00, // Input (Data, Array),
- 0xC0, // End Collection - System Control
-
- // Consumer Control Collection - Media Keys (16 bits)
-
- 0x05, 0x0C, // Usage Page (Consumer),
- 0x09, 0x01, // Usage (Consumer Control),
- 0xA1, 0x01, // Collection (Application),
- 0x85, REPORT_ID_CONSUMER, // Report ID (3) (Consumer),
- 0x16, 0x01, 0x00, // Logical Minimum (1),
- 0x26, 0x9C, 0x02, // Logical Maximum (668),
- 0x1A, 0x01, 0x00, // Usage Minimum (1),
- 0x2A, 0x9C, 0x02, // Usage Maximum (668),
- 0x75, 0x10, // Report Size (16),
- 0x95, 0x01, // Report Count (1),
- 0x81, 0x00, // Input (Data, Array),
- 0xC0, // End Collection - Consumer Control
- }
-};
+UDC_DESC_STORAGE udi_hid_exk_report_desc_t udi_hid_exk_report_desc = {{
+ // System Control Collection (8 bits)
+
+ 0x05, 0x01, // Usage Page (Generic Desktop),
+ 0x09, 0x80, // Usage (System Control),
+ 0xA1, 0x01, // Collection (Application),
+ 0x85, REPORT_ID_SYSTEM, // Report ID (2) (System),
+ 0x16, 0x01, 0x00, // Logical Minimum (1),
+ 0x26, 0x03, 0x00, // Logical Maximum (3),
+ 0x1A, 0x81, 0x00, // Usage Minimum (81) (System Power Down),
+ 0x2A, 0x83, 0x00, // Usage Maximum (83) (System Wake Up),
+ 0x75, 0x10, // Report Size (16),
+ 0x95, 0x01, // Report Count (1),
+ 0x81, 0x00, // Input (Data, Array),
+ 0xC0, // End Collection - System Control
+
+ // Consumer Control Collection - Media Keys (16 bits)
+
+ 0x05, 0x0C, // Usage Page (Consumer),
+ 0x09, 0x01, // Usage (Consumer Control),
+ 0xA1, 0x01, // Collection (Application),
+ 0x85, REPORT_ID_CONSUMER, // Report ID (3) (Consumer),
+ 0x16, 0x01, 0x00, // Logical Minimum (1),
+ 0x26, 0x9C, 0x02, // Logical Maximum (668),
+ 0x1A, 0x01, 0x00, // Usage Minimum (1),
+ 0x2A, 0x9C, 0x02, // Usage Maximum (668),
+ 0x75, 0x10, // Report Size (16),
+ 0x95, 0x01, // Report Count (1),
+ 0x81, 0x00, // Input (Data, Array),
+ 0xC0, // End Collection - Consumer Control
+}};
static bool udi_hid_exk_setreport(void);
@@ -464,51 +410,34 @@ static void udi_hid_exk_report_sent(udd_ep_status_t status, iram_size_t nb_sent,
static void udi_hid_exk_setreport_valid(void);
-bool udi_hid_exk_enable(void)
-{
+bool udi_hid_exk_enable(void) {
// Initialize internal values
- udi_hid_exk_rate = 0;
- udi_hid_exk_protocol = 0;
+ udi_hid_exk_rate = 0;
+ udi_hid_exk_protocol = 0;
udi_hid_exk_b_report_trans_ongoing = false;
memset(udi_hid_exk_report.raw, 0, UDI_HID_EXK_REPORT_SIZE);
udi_hid_exk_b_report_valid = false;
return UDI_HID_EXK_ENABLE_EXT();
}
-void udi_hid_exk_disable(void)
-{
- UDI_HID_EXK_DISABLE_EXT();
-}
+void udi_hid_exk_disable(void) { UDI_HID_EXK_DISABLE_EXT(); }
-bool udi_hid_exk_setup(void)
-{
- return udi_hid_setup(&udi_hid_exk_rate,
- &udi_hid_exk_protocol,
- (uint8_t *) &udi_hid_exk_report_desc,
- udi_hid_exk_setreport);
-}
+bool udi_hid_exk_setup(void) { return udi_hid_setup(&udi_hid_exk_rate, &udi_hid_exk_protocol, (uint8_t *)&udi_hid_exk_report_desc, udi_hid_exk_setreport); }
-uint8_t udi_hid_exk_getsetting(void)
-{
- return 0;
-}
+uint8_t udi_hid_exk_getsetting(void) { return 0; }
-static bool udi_hid_exk_setreport(void)
-{
- if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8))
- && (0 == (0xFF & udd_g_ctrlreq.req.wValue))
- && (1 == udd_g_ctrlreq.req.wLength)) {
+static bool udi_hid_exk_setreport(void) {
+ if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8)) && (0 == (0xFF & udd_g_ctrlreq.req.wValue)) && (1 == udd_g_ctrlreq.req.wLength)) {
// Report OUT type on report ID 0 from USB Host
- udd_g_ctrlreq.payload = &udi_hid_exk_report_set;
- udd_g_ctrlreq.callback = udi_hid_exk_setreport_valid;
+ udd_g_ctrlreq.payload = &udi_hid_exk_report_set;
+ udd_g_ctrlreq.callback = udi_hid_exk_setreport_valid;
udd_g_ctrlreq.payload_size = 1;
return true;
}
return false;
}
-bool udi_hid_exk_send_report(void)
-{
+bool udi_hid_exk_send_report(void) {
if (!main_b_exk_enable) {
return false;
}
@@ -518,19 +447,13 @@ bool udi_hid_exk_send_report(void)
}
memcpy(udi_hid_exk_report_trans, udi_hid_exk_report.raw, UDI_HID_EXK_REPORT_SIZE);
- udi_hid_exk_b_report_valid = false;
- udi_hid_exk_b_report_trans_ongoing =
- udd_ep_run(UDI_HID_EXK_EP_IN | USB_EP_DIR_IN,
- false,
- udi_hid_exk_report_trans,
- UDI_HID_EXK_REPORT_SIZE,
- udi_hid_exk_report_sent);
+ udi_hid_exk_b_report_valid = false;
+ udi_hid_exk_b_report_trans_ongoing = udd_ep_run(UDI_HID_EXK_EP_IN | USB_EP_DIR_IN, false, udi_hid_exk_report_trans, UDI_HID_EXK_REPORT_SIZE, udi_hid_exk_report_sent);
return udi_hid_exk_b_report_trans_ongoing;
}
-static void udi_hid_exk_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep)
-{
+static void udi_hid_exk_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep) {
UNUSED(status);
UNUSED(nb_sent);
UNUSED(ep);
@@ -540,27 +463,24 @@ static void udi_hid_exk_report_sent(udd_ep_status_t status, iram_size_t nb_sent,
}
}
-static void udi_hid_exk_setreport_valid(void)
-{
+static void udi_hid_exk_setreport_valid(void) {}
-}
-
-#endif //EXK
+#endif // EXK
//********************************************************************************************
// MOU Mouse
//********************************************************************************************
#ifdef MOU
-bool udi_hid_mou_enable(void);
-void udi_hid_mou_disable(void);
-bool udi_hid_mou_setup(void);
+bool udi_hid_mou_enable(void);
+void udi_hid_mou_disable(void);
+bool udi_hid_mou_setup(void);
uint8_t udi_hid_mou_getsetting(void);
UDC_DESC_STORAGE udi_api_t udi_api_hid_mou = {
- .enable = (bool(*)(void))udi_hid_mou_enable,
- .disable = (void (*)(void))udi_hid_mou_disable,
- .setup = (bool(*)(void))udi_hid_mou_setup,
+ .enable = (bool (*)(void))udi_hid_mou_enable,
+ .disable = (void (*)(void))udi_hid_mou_disable,
+ .setup = (bool (*)(void))udi_hid_mou_setup,
.getsetting = (uint8_t(*)(void))udi_hid_mou_getsetting,
.sof_notify = NULL,
};
@@ -571,8 +491,8 @@ static uint8_t udi_hid_mou_rate;
COMPILER_WORD_ALIGNED
static uint8_t udi_hid_mou_protocol;
-//COMPILER_WORD_ALIGNED
-//uint8_t udi_hid_mou_report_set; //No set report
+// COMPILER_WORD_ALIGNED
+// uint8_t udi_hid_mou_report_set; //No set report
bool udi_hid_mou_b_report_valid;
@@ -585,87 +505,71 @@ COMPILER_WORD_ALIGNED
static uint8_t udi_hid_mou_report_trans[UDI_HID_MOU_REPORT_SIZE];
COMPILER_WORD_ALIGNED
-UDC_DESC_STORAGE udi_hid_mou_report_desc_t udi_hid_mou_report_desc = {
- {
- 0x05, 0x01, // Usage Page (Generic Desktop),
- 0x09, 0x02, // Usage (Mouse),
- 0xA1, 0x01, // Collection (Application),
- 0x09, 0x01, // Usage (Pointer),
- 0xA1, 0x00, // Collection (Physical),
- 0x05, 0x09, // Usage Page (Buttons),
- 0x19, 0x01, // Usage Minimum (01),
- 0x29, 0x05, // Usage Maximun (05),
- 0x15, 0x00, // Logical Minimum (0),
- 0x25, 0x01, // Logical Maximum (1),
- 0x95, 0x05, // Report Count (5),
- 0x75, 0x01, // Report Size (1),
- 0x81, 0x02, // Input (Data, Variable, Absolute), ;5 button bits
- 0x95, 0x01, // Report Count (1),
- 0x75, 0x03, // Report Size (3),
- 0x81, 0x01, // Input (Constant), ;3 bit padding,
-
- 0x05, 0x01, // Usage Page (Generic Desktop),
- 0x09, 0x30, // Usage (X),
- 0x09, 0x31, // Usage (Y),
- 0x15, 0x81, // Logical Minimum (-127),
- 0x25, 0x7F, // Logical Maximum (127),
- 0x95, 0x02, // Report Count (2),
- 0x75, 0x08, // Report Size (8),
- 0x81, 0x06, // Input (Data, Variable, Relative), ;2 position bytes (X & Y),
-
- 0x09, 0x38, // Usage (Wheel),
- 0x15, 0x81, // Logical Minimum (-127),
- 0x25, 0x7F, // Logical Maximum (127),
- 0x95, 0x01, // Report Count (1),
- 0x75, 0x08, // Report Size (8),
- 0x81, 0x06, // Input (Data, Variable, Relative),
-
- 0x05, 0x0C, // Usage Page (Consumer),
- 0x0A, 0x38, 0x02, // Usage (AC Pan (Horizontal wheel)),
- 0x15, 0x81, // Logical Minimum (-127),
- 0x25, 0x7F, // Logical Maximum (127),
- 0x95, 0x01, // Report Count (1),
- 0x75, 0x08, // Report Size (8),
- 0x81, 0x06, // Input (Data, Variable, Relative),
-
- 0xC0, // End Collection,
- 0xC0, // End Collection
- }
-};
+UDC_DESC_STORAGE udi_hid_mou_report_desc_t udi_hid_mou_report_desc = {{
+ 0x05, 0x01, // Usage Page (Generic Desktop),
+ 0x09, 0x02, // Usage (Mouse),
+ 0xA1, 0x01, // Collection (Application),
+ 0x09, 0x01, // Usage (Pointer),
+ 0xA1, 0x00, // Collection (Physical),
+ 0x05, 0x09, // Usage Page (Buttons),
+ 0x19, 0x01, // Usage Minimum (01),
+ 0x29, 0x05, // Usage Maximun (05),
+ 0x15, 0x00, // Logical Minimum (0),
+ 0x25, 0x01, // Logical Maximum (1),
+ 0x95, 0x05, // Report Count (5),
+ 0x75, 0x01, // Report Size (1),
+ 0x81, 0x02, // Input (Data, Variable, Absolute), ;5 button bits
+ 0x95, 0x01, // Report Count (1),
+ 0x75, 0x03, // Report Size (3),
+ 0x81, 0x01, // Input (Constant), ;3 bit padding,
+
+ 0x05, 0x01, // Usage Page (Generic Desktop),
+ 0x09, 0x30, // Usage (X),
+ 0x09, 0x31, // Usage (Y),
+ 0x15, 0x81, // Logical Minimum (-127),
+ 0x25, 0x7F, // Logical Maximum (127),
+ 0x95, 0x02, // Report Count (2),
+ 0x75, 0x08, // Report Size (8),
+ 0x81, 0x06, // Input (Data, Variable, Relative), ;2 position bytes (X & Y),
+
+ 0x09, 0x38, // Usage (Wheel),
+ 0x15, 0x81, // Logical Minimum (-127),
+ 0x25, 0x7F, // Logical Maximum (127),
+ 0x95, 0x01, // Report Count (1),
+ 0x75, 0x08, // Report Size (8),
+ 0x81, 0x06, // Input (Data, Variable, Relative),
+
+ 0x05, 0x0C, // Usage Page (Consumer),
+ 0x0A, 0x38, 0x02, // Usage (AC Pan (Horizontal wheel)),
+ 0x15, 0x81, // Logical Minimum (-127),
+ 0x25, 0x7F, // Logical Maximum (127),
+ 0x95, 0x01, // Report Count (1),
+ 0x75, 0x08, // Report Size (8),
+ 0x81, 0x06, // Input (Data, Variable, Relative),
+
+ 0xC0, // End Collection,
+ 0xC0, // End Collection
+}};
static void udi_hid_mou_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep);
-bool udi_hid_mou_enable(void)
-{
+bool udi_hid_mou_enable(void) {
// Initialize internal values
- udi_hid_mou_rate = 0;
- udi_hid_mou_protocol = 0;
+ udi_hid_mou_rate = 0;
+ udi_hid_mou_protocol = 0;
udi_hid_mou_b_report_trans_ongoing = false;
memset(udi_hid_mou_report, 0, UDI_HID_MOU_REPORT_SIZE);
udi_hid_mou_b_report_valid = false;
return UDI_HID_MOU_ENABLE_EXT();
}
-void udi_hid_mou_disable(void)
-{
- UDI_HID_MOU_DISABLE_EXT();
-}
+void udi_hid_mou_disable(void) { UDI_HID_MOU_DISABLE_EXT(); }
-bool udi_hid_mou_setup(void)
-{
- return udi_hid_setup(&udi_hid_mou_rate,
- &udi_hid_mou_protocol,
- (uint8_t *) &udi_hid_mou_report_desc,
- NULL);
-}
+bool udi_hid_mou_setup(void) { return udi_hid_setup(&udi_hid_mou_rate, &udi_hid_mou_protocol, (uint8_t *)&udi_hid_mou_report_desc, NULL); }
-uint8_t udi_hid_mou_getsetting(void)
-{
- return 0;
-}
+uint8_t udi_hid_mou_getsetting(void) { return 0; }
-bool udi_hid_mou_send_report(void)
-{
+bool udi_hid_mou_send_report(void) {
if (!main_b_mou_enable) {
return false;
}
@@ -675,19 +579,13 @@ bool udi_hid_mou_send_report(void)
}
memcpy(udi_hid_mou_report_trans, udi_hid_mou_report, UDI_HID_MOU_REPORT_SIZE);
- udi_hid_mou_b_report_valid = false;
- udi_hid_mou_b_report_trans_ongoing =
- udd_ep_run(UDI_HID_MOU_EP_IN | USB_EP_DIR_IN,
- false,
- udi_hid_mou_report_trans,
- UDI_HID_MOU_REPORT_SIZE,
- udi_hid_mou_report_sent);
+ udi_hid_mou_b_report_valid = false;
+ udi_hid_mou_b_report_trans_ongoing = udd_ep_run(UDI_HID_MOU_EP_IN | USB_EP_DIR_IN, false, udi_hid_mou_report_trans, UDI_HID_MOU_REPORT_SIZE, udi_hid_mou_report_sent);
return udi_hid_mou_b_report_trans_ongoing;
}
-static void udi_hid_mou_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep)
-{
+static void udi_hid_mou_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep) {
UNUSED(status);
UNUSED(nb_sent);
UNUSED(ep);
@@ -697,22 +595,22 @@ static void udi_hid_mou_report_sent(udd_ep_status_t status, iram_size_t nb_sent,
}
}
-#endif //MOU
+#endif // MOU
//********************************************************************************************
// RAW
//********************************************************************************************
#ifdef RAW
-bool udi_hid_raw_enable(void);
-void udi_hid_raw_disable(void);
-bool udi_hid_raw_setup(void);
+bool udi_hid_raw_enable(void);
+void udi_hid_raw_disable(void);
+bool udi_hid_raw_setup(void);
uint8_t udi_hid_raw_getsetting(void);
UDC_DESC_STORAGE udi_api_t udi_api_hid_raw = {
- .enable = (bool(*)(void))udi_hid_raw_enable,
- .disable = (void (*)(void))udi_hid_raw_disable,
- .setup = (bool(*)(void))udi_hid_raw_setup,
+ .enable = (bool (*)(void))udi_hid_raw_enable,
+ .disable = (void (*)(void))udi_hid_raw_disable,
+ .setup = (bool (*)(void))udi_hid_raw_setup,
.getsetting = (uint8_t(*)(void))udi_hid_raw_getsetting,
.sof_notify = NULL,
};
@@ -737,76 +635,56 @@ COMPILER_WORD_ALIGNED
static uint8_t udi_hid_raw_report_trans[UDI_HID_RAW_REPORT_SIZE];
COMPILER_WORD_ALIGNED
-UDC_DESC_STORAGE udi_hid_raw_report_desc_t udi_hid_raw_report_desc = {
- {
- 0x06, // Usage Page (Vendor Defined)
- 0xFF, 0xFF,
- 0x0A, // Usage (Mouse)
- 0xFF, 0xFF,
- 0xA1, 0x01, // Collection (Application)
- 0x75, 0x08, // Report Size (8)
- 0x15, 0x00, // Logical Minimum (0)
- 0x25, 0xFF, // Logical Maximum (255)
- 0x95, 0x40, // Report Count
- 0x09, 0x01, // Usage (Input)
- 0x81, 0x02, // Input (Data
- 0x95, 0x40, // Report Count
- 0x09, 0x02, // Usage (Output)
- 0x91, 0x02, // Output (Data
- 0xC0, // End Collection - Consumer Control
- }
-};
+UDC_DESC_STORAGE udi_hid_raw_report_desc_t udi_hid_raw_report_desc = {{
+ 0x06, // Usage Page (Vendor Defined)
+ 0xFF, 0xFF,
+ 0x0A, // Usage (Mouse)
+ 0xFF, 0xFF, 0xA1, 0x01, // Collection (Application)
+ 0x75, 0x08, // Report Size (8)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x25, 0xFF, // Logical Maximum (255)
+ 0x95, 0x40, // Report Count
+ 0x09, 0x01, // Usage (Input)
+ 0x81, 0x02, // Input (Data
+ 0x95, 0x40, // Report Count
+ 0x09, 0x02, // Usage (Output)
+ 0x91, 0x02, // Output (Data
+ 0xC0, // End Collection - Consumer Control
+}};
static bool udi_hid_raw_setreport(void);
static void udi_hid_raw_setreport_valid(void);
static void udi_hid_raw_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep);
-bool udi_hid_raw_enable(void)
-{
+bool udi_hid_raw_enable(void) {
// Initialize internal values
- udi_hid_raw_rate = 0;
- udi_hid_raw_protocol = 0;
+ udi_hid_raw_rate = 0;
+ udi_hid_raw_protocol = 0;
udi_hid_raw_b_report_trans_ongoing = false;
memset(udi_hid_raw_report, 0, UDI_HID_RAW_REPORT_SIZE);
udi_hid_raw_b_report_valid = false;
return UDI_HID_RAW_ENABLE_EXT();
}
-void udi_hid_raw_disable(void)
-{
- UDI_HID_RAW_DISABLE_EXT();
-}
+void udi_hid_raw_disable(void) { UDI_HID_RAW_DISABLE_EXT(); }
-bool udi_hid_raw_setup(void)
-{
- return udi_hid_setup(&udi_hid_raw_rate,
- &udi_hid_raw_protocol,
- (uint8_t *) &udi_hid_raw_report_desc,
- udi_hid_raw_setreport);
-}
+bool udi_hid_raw_setup(void) { return udi_hid_setup(&udi_hid_raw_rate, &udi_hid_raw_protocol, (uint8_t *)&udi_hid_raw_report_desc, udi_hid_raw_setreport); }
-uint8_t udi_hid_raw_getsetting(void)
-{
- return 0;
-}
+uint8_t udi_hid_raw_getsetting(void) { return 0; }
-static bool udi_hid_raw_setreport(void)
-{
- if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8))
- && (0 == (0xFF & udd_g_ctrlreq.req.wValue))
- && (UDI_HID_RAW_REPORT_SIZE == udd_g_ctrlreq.req.wLength)) {
+static bool udi_hid_raw_setreport(void) {
+ if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8)) && (0 == (0xFF & udd_g_ctrlreq.req.wValue)) && (UDI_HID_RAW_REPORT_SIZE == udd_g_ctrlreq.req.wLength)) {
// Report OUT type on report ID 0 from USB Host
- udd_g_ctrlreq.payload = udi_hid_raw_report_set;
- udd_g_ctrlreq.callback = udi_hid_raw_setreport_valid; //must call routine to transform setreport to LED state
+ udd_g_ctrlreq.payload = udi_hid_raw_report_set;
+ udd_g_ctrlreq.callback = udi_hid_raw_setreport_valid; // must call routine to transform setreport to LED state
udd_g_ctrlreq.payload_size = UDI_HID_RAW_REPORT_SIZE;
return true;
}
return false;
}
-bool udi_hid_raw_send_report(void)
-{
+bool udi_hid_raw_send_report(void) {
if (!main_b_raw_enable) {
return false;
}
@@ -815,20 +693,14 @@ bool udi_hid_raw_send_report(void)
return false;
}
- memcpy(udi_hid_raw_report_trans, udi_hid_raw_report,UDI_HID_RAW_REPORT_SIZE);
- udi_hid_raw_b_report_valid = false;
- udi_hid_raw_b_report_trans_ongoing =
- udd_ep_run(UDI_HID_RAW_EP_IN | USB_EP_DIR_IN,
- false,
- udi_hid_raw_report_trans,
- UDI_HID_RAW_REPORT_SIZE,
- udi_hid_raw_report_sent);
+ memcpy(udi_hid_raw_report_trans, udi_hid_raw_report, UDI_HID_RAW_REPORT_SIZE);
+ udi_hid_raw_b_report_valid = false;
+ udi_hid_raw_b_report_trans_ongoing = udd_ep_run(UDI_HID_RAW_EP_IN | USB_EP_DIR_IN, false, udi_hid_raw_report_trans, UDI_HID_RAW_REPORT_SIZE, udi_hid_raw_report_sent);
return udi_hid_raw_b_report_trans_ongoing;
}
-static void udi_hid_raw_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep)
-{
+static void udi_hid_raw_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep) {
UNUSED(status);
UNUSED(nb_sent);
UNUSED(ep);
@@ -838,27 +710,24 @@ static void udi_hid_raw_report_sent(udd_ep_status_t status, iram_size_t nb_sent,
}
}
-static void udi_hid_raw_setreport_valid(void)
-{
+static void udi_hid_raw_setreport_valid(void) {}
-}
-
-#endif //RAW
+#endif // RAW
//********************************************************************************************
// CON
//********************************************************************************************
#ifdef CON
-bool udi_hid_con_enable(void);
-void udi_hid_con_disable(void);
-bool udi_hid_con_setup(void);
+bool udi_hid_con_enable(void);
+void udi_hid_con_disable(void);
+bool udi_hid_con_setup(void);
uint8_t udi_hid_con_getsetting(void);
UDC_DESC_STORAGE udi_api_t udi_api_hid_con = {
- .enable = (bool(*)(void))udi_hid_con_enable,
- .disable = (void (*)(void))udi_hid_con_disable,
- .setup = (bool(*)(void))udi_hid_con_setup,
+ .enable = (bool (*)(void))udi_hid_con_enable,
+ .disable = (void (*)(void))udi_hid_con_disable,
+ .setup = (bool (*)(void))udi_hid_con_setup,
.getsetting = (uint8_t(*)(void))udi_hid_con_getsetting,
.sof_notify = NULL,
};
@@ -883,76 +752,57 @@ COMPILER_WORD_ALIGNED
static uint8_t udi_hid_con_report_trans[UDI_HID_CON_REPORT_SIZE];
COMPILER_WORD_ALIGNED
-UDC_DESC_STORAGE udi_hid_con_report_desc_t udi_hid_con_report_desc = {
- {
- 0x06, 0x31, 0xFF, // Vendor Page (PJRC Teensy compatible)
- 0x09, 0x74, // Vendor Usage (PJRC Teensy compatible)
- 0xA1, 0x01, // Collection (Application)
- 0x09, 0x75, // Usage (Vendor)
- 0x15, 0x00, // Logical Minimum (0x00)
- 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF)
- 0x95, CONSOLE_EPSIZE, // Report Count
- 0x75, 0x08, // Report Size (8)
- 0x81, 0x02, // Input (Data)
- 0x09, 0x76, // Usage (Vendor)
- 0x15, 0x00, // Logical Minimum (0x00)
- 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF)
- 0x95, CONSOLE_EPSIZE, // Report Count
- 0x75, 0x08, // Report Size (8)
- 0x91, 0x02, // Output (Data)
- 0xC0, // End Collection
- }
-};
+UDC_DESC_STORAGE udi_hid_con_report_desc_t udi_hid_con_report_desc = {{
+ 0x06, 0x31, 0xFF, // Vendor Page (PJRC Teensy compatible)
+ 0x09, 0x74, // Vendor Usage (PJRC Teensy compatible)
+ 0xA1, 0x01, // Collection (Application)
+ 0x09, 0x75, // Usage (Vendor)
+ 0x15, 0x00, // Logical Minimum (0x00)
+ 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF)
+ 0x95, CONSOLE_EPSIZE, // Report Count
+ 0x75, 0x08, // Report Size (8)
+ 0x81, 0x02, // Input (Data)
+ 0x09, 0x76, // Usage (Vendor)
+ 0x15, 0x00, // Logical Minimum (0x00)
+ 0x26, 0xFF, 0x00, // Logical Maximum (0x00FF)
+ 0x95, CONSOLE_EPSIZE, // Report Count
+ 0x75, 0x08, // Report Size (8)
+ 0x91, 0x02, // Output (Data)
+ 0xC0, // End Collection
+}};
static bool udi_hid_con_setreport(void);
static void udi_hid_con_setreport_valid(void);
static void udi_hid_con_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep);
-bool udi_hid_con_enable(void)
-{
+bool udi_hid_con_enable(void) {
// Initialize internal values
- udi_hid_con_rate = 0;
- udi_hid_con_protocol = 0;
+ udi_hid_con_rate = 0;
+ udi_hid_con_protocol = 0;
udi_hid_con_b_report_trans_ongoing = false;
memset(udi_hid_con_report, 0, UDI_HID_CON_REPORT_SIZE);
udi_hid_con_b_report_valid = false;
return UDI_HID_CON_ENABLE_EXT();
}
-void udi_hid_con_disable(void)
-{
- UDI_HID_CON_DISABLE_EXT();
-}
+void udi_hid_con_disable(void) { UDI_HID_CON_DISABLE_EXT(); }
-bool udi_hid_con_setup(void)
-{
- return udi_hid_setup(&udi_hid_con_rate,
- &udi_hid_con_protocol,
- (uint8_t *) &udi_hid_con_report_desc,
- udi_hid_con_setreport);
-}
+bool udi_hid_con_setup(void) { return udi_hid_setup(&udi_hid_con_rate, &udi_hid_con_protocol, (uint8_t *)&udi_hid_con_report_desc, udi_hid_con_setreport); }
-uint8_t udi_hid_con_getsetting(void)
-{
- return 0;
-}
+uint8_t udi_hid_con_getsetting(void) { return 0; }
-static bool udi_hid_con_setreport(void)
-{
- if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8))
- && (0 == (0xFF & udd_g_ctrlreq.req.wValue))
- && (UDI_HID_CON_REPORT_SIZE == udd_g_ctrlreq.req.wLength)) {
- udd_g_ctrlreq.payload = udi_hid_con_report_set;
- udd_g_ctrlreq.callback = udi_hid_con_setreport_valid;
+static bool udi_hid_con_setreport(void) {
+ if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8)) && (0 == (0xFF & udd_g_ctrlreq.req.wValue)) && (UDI_HID_CON_REPORT_SIZE == udd_g_ctrlreq.req.wLength)) {
+ udd_g_ctrlreq.payload = udi_hid_con_report_set;
+ udd_g_ctrlreq.callback = udi_hid_con_setreport_valid;
udd_g_ctrlreq.payload_size = UDI_HID_CON_REPORT_SIZE;
return true;
}
return false;
}
-bool udi_hid_con_send_report(void)
-{
+bool udi_hid_con_send_report(void) {
if (!main_b_con_enable) {
return false;
}
@@ -961,20 +811,14 @@ bool udi_hid_con_send_report(void)
return false;
}
- memcpy(udi_hid_con_report_trans, udi_hid_con_report,UDI_HID_CON_REPORT_SIZE);
- udi_hid_con_b_report_valid = false;
- udi_hid_con_b_report_trans_ongoing =
- udd_ep_run(UDI_HID_CON_EP_IN | USB_EP_DIR_IN,
- false,
- udi_hid_con_report_trans,
- UDI_HID_CON_REPORT_SIZE,
- udi_hid_con_report_sent);
+ memcpy(udi_hid_con_report_trans, udi_hid_con_report, UDI_HID_CON_REPORT_SIZE);
+ udi_hid_con_b_report_valid = false;
+ udi_hid_con_b_report_trans_ongoing = udd_ep_run(UDI_HID_CON_EP_IN | USB_EP_DIR_IN, false, udi_hid_con_report_trans, UDI_HID_CON_REPORT_SIZE, udi_hid_con_report_sent);
return udi_hid_con_b_report_trans_ongoing;
}
-static void udi_hid_con_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep)
-{
+static void udi_hid_con_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep) {
UNUSED(status);
UNUSED(nb_sent);
UNUSED(ep);
@@ -984,9 +828,6 @@ static void udi_hid_con_report_sent(udd_ep_status_t status, iram_size_t nb_sent,
}
}
-static void udi_hid_con_setreport_valid(void)
-{
-
-}
+static void udi_hid_con_setreport_valid(void) {}
-#endif //CON
+#endif // CON
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h
index e442919a9b..82b1cbfe07 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h
+++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h
@@ -59,59 +59,59 @@ extern "C" {
//******************************************************************************
#ifdef KBD
extern UDC_DESC_STORAGE udi_api_t udi_api_hid_kbd;
-extern bool udi_hid_kbd_b_report_valid;
-extern volatile bool udi_hid_kbd_b_report_trans_ongoing;
-extern uint8_t udi_hid_kbd_report_set;
-bool udi_hid_kbd_send_report(void);
-#endif //KBD
+extern bool udi_hid_kbd_b_report_valid;
+extern volatile bool udi_hid_kbd_b_report_trans_ongoing;
+extern uint8_t udi_hid_kbd_report_set;
+bool udi_hid_kbd_send_report(void);
+#endif // KBD
//********************************************************************************************
// NKRO Keyboard
//********************************************************************************************
#ifdef NKRO
extern UDC_DESC_STORAGE udi_api_t udi_api_hid_nkro;
-extern bool udi_hid_nkro_b_report_valid;
-extern volatile bool udi_hid_nkro_b_report_trans_ongoing;
-bool udi_hid_nkro_send_report(void);
-#endif //NKRO
+extern bool udi_hid_nkro_b_report_valid;
+extern volatile bool udi_hid_nkro_b_report_trans_ongoing;
+bool udi_hid_nkro_send_report(void);
+#endif // NKRO
//********************************************************************************************
// SYS-CTRL interface
//********************************************************************************************
#ifdef EXK
extern UDC_DESC_STORAGE udi_api_t udi_api_hid_exk;
-extern bool udi_hid_exk_b_report_valid;
-extern uint8_t udi_hid_exk_report_set;
-bool udi_hid_exk_send_report(void);
-#endif //EXK
+extern bool udi_hid_exk_b_report_valid;
+extern uint8_t udi_hid_exk_report_set;
+bool udi_hid_exk_send_report(void);
+#endif // EXK
//********************************************************************************************
// CON Console
//********************************************************************************************
#ifdef CON
extern UDC_DESC_STORAGE udi_api_t udi_api_hid_con;
-extern bool udi_hid_con_b_report_valid;
-extern uint8_t udi_hid_con_report_set[UDI_HID_CON_REPORT_SIZE];
-extern volatile bool udi_hid_con_b_report_trans_ongoing;
-bool udi_hid_con_send_report(void);
-#endif //CON
+extern bool udi_hid_con_b_report_valid;
+extern uint8_t udi_hid_con_report_set[UDI_HID_CON_REPORT_SIZE];
+extern volatile bool udi_hid_con_b_report_trans_ongoing;
+bool udi_hid_con_send_report(void);
+#endif // CON
//********************************************************************************************
// MOU Mouse
//********************************************************************************************
#ifdef MOU
extern UDC_DESC_STORAGE udi_api_t udi_api_hid_mou;
-extern bool udi_hid_mou_b_report_valid;
-bool udi_hid_mou_send_report(void);
-#endif //MOU
+extern bool udi_hid_mou_b_report_valid;
+bool udi_hid_mou_send_report(void);
+#endif // MOU
//********************************************************************************************
// RAW Raw
//********************************************************************************************
#ifdef RAW
extern UDC_DESC_STORAGE udi_api_t udi_api_hid_raw;
-bool udi_hid_raw_send_report(void);
-#endif //RAW
+bool udi_hid_raw_send_report(void);
+#endif // RAW
//@}
@@ -119,4 +119,4 @@ bool udi_hid_raw_send_report(void);
}
#endif
-#endif // _UDC_HID_KBD_H_
+#endif // _UDC_HID_KBD_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_conf.h b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_conf.h
index db5db17ed5..ec73252b69 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_conf.h
+++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_conf.h
@@ -57,4 +57,4 @@
#include "udi_hid_kbd.h"
-#endif // _UDI_HID_KBD_CONF_H_
+#endif // _UDI_HID_KBD_CONF_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_desc.c b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_desc.c
index 2d6e35e254..4e7deaaa38 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_desc.c
+++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd_desc.c
@@ -65,37 +65,35 @@
//! USB Device Descriptor
COMPILER_WORD_ALIGNED
-UDC_DESC_STORAGE usb_dev_desc_t udc_device_desc = {
- .bLength = sizeof(usb_dev_desc_t),
- .bDescriptorType = USB_DT_DEVICE,
- .bcdUSB = LE16(USB_V2_0),
- .bDeviceClass = DEVICE_CLASS,
- .bDeviceSubClass = DEVICE_SUBCLASS,
- .bDeviceProtocol = DEVICE_PROTOCOL,
- .bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE,
- .idVendor = LE16(USB_DEVICE_VENDOR_ID),
- .idProduct = LE16(USB_DEVICE_PRODUCT_ID),
- .bcdDevice = LE16(USB_DEVICE_VERSION),
+UDC_DESC_STORAGE usb_dev_desc_t udc_device_desc = {.bLength = sizeof(usb_dev_desc_t),
+ .bDescriptorType = USB_DT_DEVICE,
+ .bcdUSB = LE16(USB_V2_0),
+ .bDeviceClass = DEVICE_CLASS,
+ .bDeviceSubClass = DEVICE_SUBCLASS,
+ .bDeviceProtocol = DEVICE_PROTOCOL,
+ .bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE,
+ .idVendor = LE16(USB_DEVICE_VENDOR_ID),
+ .idProduct = LE16(USB_DEVICE_PRODUCT_ID),
+ .bcdDevice = LE16(USB_DEVICE_VERSION),
#ifdef USB_DEVICE_MANUFACTURE_NAME
- .iManufacturer = 1,
+ .iManufacturer = 1,
#else
- .iManufacturer = 0, // No manufacture string
+ .iManufacturer = 0, // No manufacture string
#endif
#ifdef USB_DEVICE_PRODUCT_NAME
- .iProduct = 2,
+ .iProduct = 2,
#else
- .iProduct = 0, // No product string
+ .iProduct = 0, // No product string
#endif
#if (defined USB_DEVICE_SERIAL_NAME || defined USB_DEVICE_GET_SERIAL_NAME_POINTER)
- .iSerialNumber = 3,
+ .iSerialNumber = 3,
#else
- .iSerialNumber = 0, // No serial string
+ .iSerialNumber = 0, // No serial string
#endif
- .bNumConfigurations = 1
-};
+ .bNumConfigurations = 1};
#if 0
-#ifdef USB_DEVICE_HS_SUPPORT
+# ifdef USB_DEVICE_HS_SUPPORT
//! USB Device Qualifier Descriptor for HS
COMPILER_WORD_ALIGNED
UDC_DESC_STORAGE usb_dev_qual_desc_t udc_device_qual = {
@@ -108,77 +106,77 @@ UDC_DESC_STORAGE usb_dev_qual_desc_t udc_device_qual = {
.bMaxPacketSize0 = USB_DEVICE_EP_CTRL_SIZE,
.bNumConfigurations = 1
};
-#endif
+# endif
#endif
//! USB Device Configuration Descriptor filled for FS and HS
COMPILER_WORD_ALIGNED
UDC_DESC_STORAGE udc_desc_t udc_desc = {
- .conf.bLength = sizeof(usb_conf_desc_t),
- .conf.bDescriptorType = USB_DT_CONFIGURATION,
- .conf.wTotalLength = LE16(sizeof(udc_desc_t)),
- .conf.bNumInterfaces = USB_DEVICE_NB_INTERFACE,
- .conf.bConfigurationValue = 1,
- .conf.iConfiguration = 0,
- .conf.bmAttributes = /* USB_CONFIG_ATTR_MUST_SET | */ USB_DEVICE_ATTR,
- .conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER),
+ .conf.bLength = sizeof(usb_conf_desc_t),
+ .conf.bDescriptorType = USB_DT_CONFIGURATION,
+ .conf.wTotalLength = LE16(sizeof(udc_desc_t)),
+ .conf.bNumInterfaces = USB_DEVICE_NB_INTERFACE,
+ .conf.bConfigurationValue = 1,
+ .conf.iConfiguration = 0,
+ .conf.bmAttributes = /* USB_CONFIG_ATTR_MUST_SET | */ USB_DEVICE_ATTR,
+ .conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER),
#ifdef KBD
- .hid_kbd = UDI_HID_KBD_DESC,
+ .hid_kbd = UDI_HID_KBD_DESC,
#endif
#ifdef RAW
- .hid_raw = UDI_HID_RAW_DESC,
+ .hid_raw = UDI_HID_RAW_DESC,
#endif
#ifdef MOU
- .hid_mou = UDI_HID_MOU_DESC,
+ .hid_mou = UDI_HID_MOU_DESC,
#endif
#ifdef EXK
- .hid_exk = UDI_HID_EXK_DESC,
+ .hid_exk = UDI_HID_EXK_DESC,
#endif
#ifdef CON
- .hid_con = UDI_HID_CON_DESC,
+ .hid_con = UDI_HID_CON_DESC,
#endif
#ifdef NKRO
- .hid_nkro = UDI_HID_NKRO_DESC,
+ .hid_nkro = UDI_HID_NKRO_DESC,
#endif
#ifdef CDC
- .cdc_serial = CDC_DESCRIPTOR,
+ .cdc_serial = CDC_DESCRIPTOR,
#endif
};
UDC_DESC_STORAGE udi_api_t *udi_apis[USB_DEVICE_NB_INTERFACE] = {
- #ifdef KBD
+#ifdef KBD
&udi_api_hid_kbd,
- #endif
- #ifdef RAW
+#endif
+#ifdef RAW
&udi_api_hid_raw,
- #endif
- #ifdef MOU
+#endif
+#ifdef MOU
&udi_api_hid_mou,
- #endif
- #ifdef EXK
+#endif
+#ifdef EXK
&udi_api_hid_exk,
- #endif
- #ifdef CON
+#endif
+#ifdef CON
&udi_api_hid_con,
- #endif
- #ifdef NKRO
+#endif
+#ifdef NKRO
&udi_api_hid_nkro,
- #endif
- #ifdef CDC
- &udi_api_cdc_comm, &udi_api_cdc_data,
- #endif
+#endif
+#ifdef CDC
+ &udi_api_cdc_comm, &udi_api_cdc_data,
+#endif
};
//! Add UDI with USB Descriptors FS & HS
-UDC_DESC_STORAGE udc_config_speed_t udc_config_fshs[1] = {{
- .desc = (usb_conf_desc_t UDC_DESC_STORAGE*)&udc_desc,
- .udi_apis = udi_apis,
+UDC_DESC_STORAGE udc_config_speed_t udc_config_fshs[1] = {{
+ .desc = (usb_conf_desc_t UDC_DESC_STORAGE *)&udc_desc,
+ .udi_apis = udi_apis,
}};
//! Add all information about USB Device in global structure for UDC
UDC_DESC_STORAGE udc_config_t udc_config = {
.confdev_lsfs = &udc_device_desc,
- .conf_lsfs = udc_config_fshs,
+ .conf_lsfs = udc_config_fshs,
};
//@}
diff --git a/tmk_core/protocol/arm_atsam/usb/ui.c b/tmk_core/protocol/arm_atsam/usb/ui.c
index 70a6191098..86c7edc94e 100644
--- a/tmk_core/protocol/arm_atsam/usb/ui.c
+++ b/tmk_core/protocol/arm_atsam/usb/ui.c
@@ -45,10 +45,10 @@
*/
#ifndef ARM_MATH_CM4
- #define ARM_MATH_CM4
+# define ARM_MATH_CM4
#endif
-#undef LITTLE_ENDIAN //redefined in samd51j18a.h
+#undef LITTLE_ENDIAN // redefined in samd51j18a.h
#include "samd51j18a.h"
#include "ui.h"
@@ -68,37 +68,16 @@ static void ui_wakeup_handler(void)
}
#endif
-void ui_init(void)
-{
+void ui_init(void) {}
-}
+void ui_powerdown(void) {}
-void ui_powerdown(void)
-{
+void ui_wakeup_enable(void) {}
-}
+void ui_wakeup_disable(void) {}
-void ui_wakeup_enable(void)
-{
+void ui_wakeup(void) {}
-}
+void ui_process(uint16_t framenumber) {}
-void ui_wakeup_disable(void)
-{
-
-}
-
-void ui_wakeup(void)
-{
-
-}
-
-void ui_process(uint16_t framenumber)
-{
-
-}
-
-void ui_kbd_led(uint8_t value)
-{
-
-}
+void ui_kbd_led(uint8_t value) {}
diff --git a/tmk_core/protocol/arm_atsam/usb/ui.h b/tmk_core/protocol/arm_atsam/usb/ui.h
index d1c767d457..f7bc652360 100644
--- a/tmk_core/protocol/arm_atsam/usb/ui.h
+++ b/tmk_core/protocol/arm_atsam/usb/ui.h
@@ -73,4 +73,4 @@ void ui_process(uint16_t framenumber);
*/
void ui_kbd_led(uint8_t value);
-#endif // _UI_H_
+#endif // _UI_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/usb.c b/tmk_core/protocol/arm_atsam/usb/usb.c
index d30d76dd11..b7393660b1 100644
--- a/tmk_core/protocol/arm_atsam/usb/usb.c
+++ b/tmk_core/protocol/arm_atsam/usb/usb.c
@@ -48,11 +48,11 @@
#define SAMD11 DEVICE_MODE_ONLY
#ifndef ARM_MATH_CM4
- #define ARM_MATH_CM4
+# define ARM_MATH_CM4
#endif
#include "compiler.h"
-#undef LITTLE_ENDIAN //redefined in samd51j18a.h
+#undef LITTLE_ENDIAN // redefined in samd51j18a.h
#include "samd51j18a.h"
#include <stdbool.h>
#include <string.h>
@@ -61,28 +61,28 @@
#include "usb.h"
/** Fields definition from a LPM TOKEN */
-#define USB_LPM_ATTRIBUT_BLINKSTATE_MASK (0xF << 0)
-#define USB_LPM_ATTRIBUT_HIRD_MASK (0xF << 4)
-#define USB_LPM_ATTRIBUT_REMOTEWAKE_MASK (1 << 8)
-#define USB_LPM_ATTRIBUT_BLINKSTATE(value) ((value & 0xF) << 0)
-#define USB_LPM_ATTRIBUT_HIRD(value) ((value & 0xF) << 4)
-#define USB_LPM_ATTRIBUT_REMOTEWAKE(value) ((value & 1) << 8)
-#define USB_LPM_ATTRIBUT_BLINKSTATE_L1 USB_LPM_ATTRIBUT_BLINKSTATE(1)
+#define USB_LPM_ATTRIBUT_BLINKSTATE_MASK (0xF << 0)
+#define USB_LPM_ATTRIBUT_HIRD_MASK (0xF << 4)
+#define USB_LPM_ATTRIBUT_REMOTEWAKE_MASK (1 << 8)
+#define USB_LPM_ATTRIBUT_BLINKSTATE(value) ((value & 0xF) << 0)
+#define USB_LPM_ATTRIBUT_HIRD(value) ((value & 0xF) << 4)
+#define USB_LPM_ATTRIBUT_REMOTEWAKE(value) ((value & 1) << 8)
+#define USB_LPM_ATTRIBUT_BLINKSTATE_L1 USB_LPM_ATTRIBUT_BLINKSTATE(1)
/**
* \brief Mask selecting the index part of an endpoint address
*/
-#define USB_EP_ADDR_MASK 0x0f
+#define USB_EP_ADDR_MASK 0x0f
/**
* \brief Endpoint transfer direction is IN
*/
-#define USB_EP_DIR_IN 0x80
+#define USB_EP_DIR_IN 0x80
/**
* \brief Endpoint transfer direction is OUT
*/
-#define USB_EP_DIR_OUT 0x00
+#define USB_EP_DIR_OUT 0x00
/**
* \name USB SRAM data containing pipe descriptor table
@@ -120,24 +120,13 @@ static struct usb_endpoint_callback_parameter ep_callback_para;
* \internal USB Device IRQ Mask Bits Map
*/
static const uint16_t _usb_device_irq_bits[USB_DEVICE_CALLBACK_N] = {
- USB_DEVICE_INTFLAG_SOF,
- USB_DEVICE_INTFLAG_EORST,
- USB_DEVICE_INTFLAG_WAKEUP | USB_DEVICE_INTFLAG_EORSM | USB_DEVICE_INTFLAG_UPRSM,
- USB_DEVICE_INTFLAG_RAMACER,
- USB_DEVICE_INTFLAG_SUSPEND,
- USB_DEVICE_INTFLAG_LPMNYET,
- USB_DEVICE_INTFLAG_LPMSUSP,
+ USB_DEVICE_INTFLAG_SOF, USB_DEVICE_INTFLAG_EORST, USB_DEVICE_INTFLAG_WAKEUP | USB_DEVICE_INTFLAG_EORSM | USB_DEVICE_INTFLAG_UPRSM, USB_DEVICE_INTFLAG_RAMACER, USB_DEVICE_INTFLAG_SUSPEND, USB_DEVICE_INTFLAG_LPMNYET, USB_DEVICE_INTFLAG_LPMSUSP,
};
/**
* \internal USB Device IRQ Mask Bits Map
*/
-static const uint8_t _usb_endpoint_irq_bits[USB_DEVICE_EP_CALLBACK_N] = {
- USB_DEVICE_EPINTFLAG_TRCPT_Msk,
- USB_DEVICE_EPINTFLAG_TRFAIL_Msk,
- USB_DEVICE_EPINTFLAG_RXSTP,
- USB_DEVICE_EPINTFLAG_STALL_Msk
-};
+static const uint8_t _usb_endpoint_irq_bits[USB_DEVICE_EP_CALLBACK_N] = {USB_DEVICE_EPINTFLAG_TRCPT_Msk, USB_DEVICE_EPINTFLAG_TRFAIL_Msk, USB_DEVICE_EPINTFLAG_RXSTP, USB_DEVICE_EPINTFLAG_STALL_Msk};
/**
* \brief Registers a USB device callback
@@ -155,10 +144,7 @@ static const uint8_t _usb_endpoint_irq_bits[USB_DEVICE_EP_CALLBACK_N] = {
* \return Status of the registration operation.
* \retval STATUS_OK The callback was registered successfully.
*/
-enum status_code usb_device_register_callback(struct usb_module *module_inst,
- enum usb_device_callback callback_type,
- usb_device_callback_t callback_func)
-{
+enum status_code usb_device_register_callback(struct usb_module *module_inst, enum usb_device_callback callback_type, usb_device_callback_t callback_func) {
/* Sanity check arguments */
Assert(module_inst);
Assert(callback_func);
@@ -184,9 +170,7 @@ enum status_code usb_device_register_callback(struct usb_module *module_inst,
* \return Status of the de-registration operation.
* \retval STATUS_OK The callback was unregistered successfully.
*/
-enum status_code usb_device_unregister_callback(struct usb_module *module_inst,
- enum usb_device_callback callback_type)
-{
+enum status_code usb_device_unregister_callback(struct usb_module *module_inst, enum usb_device_callback callback_type) {
/* Sanity check arguments */
Assert(module_inst);
@@ -211,9 +195,7 @@ enum status_code usb_device_unregister_callback(struct usb_module *module_inst,
* \return Status of the callback enable operation.
* \retval STATUS_OK The callback was enabled successfully.
*/
-enum status_code usb_device_enable_callback(struct usb_module *module_inst,
- enum usb_device_callback callback_type)
-{
+enum status_code usb_device_enable_callback(struct usb_module *module_inst, enum usb_device_callback callback_type) {
/* Sanity check arguments */
Assert(module_inst);
Assert(module_inst->hw);
@@ -240,9 +222,7 @@ enum status_code usb_device_enable_callback(struct usb_module *module_inst,
* \return Status of the callback disable operation.
* \retval STATUS_OK The callback was disabled successfully.
*/
-enum status_code usb_device_disable_callback(struct usb_module *module_inst,
- enum usb_device_callback callback_type)
-{
+enum status_code usb_device_disable_callback(struct usb_module *module_inst, enum usb_device_callback callback_type) {
/* Sanity check arguments */
Assert(module_inst);
Assert(module_inst->hw);
@@ -272,11 +252,7 @@ enum status_code usb_device_disable_callback(struct usb_module *module_inst,
* \return Status of the registration operation.
* \retval STATUS_OK The callback was registered successfully.
*/
-enum status_code usb_device_endpoint_register_callback(
- struct usb_module *module_inst, uint8_t ep_num,
- enum usb_device_endpoint_callback callback_type,
- usb_device_endpoint_callback_t callback_func)
-{
+enum status_code usb_device_endpoint_register_callback(struct usb_module *module_inst, uint8_t ep_num, enum usb_device_endpoint_callback callback_type, usb_device_endpoint_callback_t callback_func) {
/* Sanity check arguments */
Assert(module_inst);
Assert(ep_num < USB_EPT_NUM);
@@ -304,10 +280,7 @@ enum status_code usb_device_endpoint_register_callback(
* \return Status of the de-registration operation.
* \retval STATUS_OK The callback was unregistered successfully.
*/
-enum status_code usb_device_endpoint_unregister_callback(
- struct usb_module *module_inst, uint8_t ep_num,
- enum usb_device_endpoint_callback callback_type)
-{
+enum status_code usb_device_endpoint_unregister_callback(struct usb_module *module_inst, uint8_t ep_num, enum usb_device_endpoint_callback callback_type) {
/* Sanity check arguments */
Assert(module_inst);
Assert(ep_num < USB_EPT_NUM);
@@ -334,10 +307,7 @@ enum status_code usb_device_endpoint_unregister_callback(
* \return Status of the callback enable operation.
* \retval STATUS_OK The callback was enabled successfully.
*/
-enum status_code usb_device_endpoint_enable_callback(
- struct usb_module *module_inst, uint8_t ep,
- enum usb_device_endpoint_callback callback_type)
-{
+enum status_code usb_device_endpoint_enable_callback(struct usb_module *module_inst, uint8_t ep, enum usb_device_endpoint_callback callback_type) {
/* Sanity check arguments */
Assert(module_inst);
Assert(module_inst->hw);
@@ -349,7 +319,7 @@ enum status_code usb_device_endpoint_enable_callback(
module_inst->device_endpoint_enabled_callback_mask[ep_num] |= _usb_endpoint_irq_bits[callback_type];
if (callback_type == USB_DEVICE_ENDPOINT_CALLBACK_TRCPT) {
- if (ep_num == 0) { // control endpoint
+ if (ep_num == 0) { // control endpoint
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENSET.reg = USB_DEVICE_EPINTENSET_TRCPT0 | USB_DEVICE_EPINTENSET_TRCPT1;
} else if (ep & USB_EP_DIR_IN) {
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENSET.reg = USB_DEVICE_EPINTENSET_TRCPT1;
@@ -359,7 +329,7 @@ enum status_code usb_device_endpoint_enable_callback(
}
if (callback_type == USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL) {
- if (ep_num == 0) { // control endpoint
+ if (ep_num == 0) { // control endpoint
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENSET.reg = USB_DEVICE_EPINTENSET_TRFAIL0 | USB_DEVICE_EPINTENSET_TRFAIL1;
} else if (ep & USB_EP_DIR_IN) {
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENSET.reg = USB_DEVICE_EPINTENSET_TRFAIL1;
@@ -395,10 +365,7 @@ enum status_code usb_device_endpoint_enable_callback(
* \return Status of the callback disable operation.
* \retval STATUS_OK The callback was disabled successfully.
*/
-enum status_code usb_device_endpoint_disable_callback(
- struct usb_module *module_inst, uint8_t ep,
- enum usb_device_endpoint_callback callback_type)
-{
+enum status_code usb_device_endpoint_disable_callback(struct usb_module *module_inst, uint8_t ep, enum usb_device_endpoint_callback callback_type) {
/* Sanity check arguments */
Assert(module_inst);
Assert(module_inst->hw);
@@ -410,17 +377,17 @@ enum status_code usb_device_endpoint_disable_callback(
module_inst->device_endpoint_enabled_callback_mask[ep_num] &= ~_usb_endpoint_irq_bits[callback_type];
if (callback_type == USB_DEVICE_ENDPOINT_CALLBACK_TRCPT) {
- if (ep_num == 0) { // control endpoint
- module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRCPT0 | USB_DEVICE_EPINTENCLR_TRCPT1;
+ if (ep_num == 0) { // control endpoint
+ module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRCPT0 | USB_DEVICE_EPINTENCLR_TRCPT1;
} else if (ep & USB_EP_DIR_IN) {
- module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRCPT1;
+ module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRCPT1;
} else {
- module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRCPT0;
+ module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRCPT0;
}
}
if (callback_type == USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL) {
- if (ep_num == 0) { // control endpoint
+ if (ep_num == 0) { // control endpoint
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRFAIL0 | USB_DEVICE_EPINTENCLR_TRFAIL1;
} else if (ep & USB_EP_DIR_IN) {
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPINTENCLR.reg = USB_DEVICE_EPINTENCLR_TRFAIL1;
@@ -460,16 +427,15 @@ enum status_code usb_device_endpoint_disable_callback(
*
* \param[out] ep_config Configuration structure to initialize to default values
*/
-void usb_device_endpoint_get_config_defaults(struct usb_device_endpoint_config *ep_config)
-{
+void usb_device_endpoint_get_config_defaults(struct usb_device_endpoint_config *ep_config) {
/* Sanity check arguments */
Assert(ep_config);
/* Write default config to config struct */
ep_config->ep_address = 0;
- ep_config->ep_size = USB_ENDPOINT_8_BYTE;
- ep_config->auto_zlp = false;
- ep_config->ep_type = USB_DEVICE_ENDPOINT_TYPE_CONTROL;
+ ep_config->ep_size = USB_ENDPOINT_8_BYTE;
+ ep_config->auto_zlp = false;
+ ep_config->ep_type = USB_DEVICE_ENDPOINT_TYPE_CONTROL;
}
/**
@@ -486,25 +452,22 @@ void usb_device_endpoint_get_config_defaults(struct usb_device_endpoint_config *
* \retval STATUS_OK The device endpoint was configured successfully
* \retval STATUS_ERR_DENIED The endpoint address is already configured
*/
-enum status_code usb_device_endpoint_set_config(struct usb_module *module_inst,
- struct usb_device_endpoint_config *ep_config)
-{
+enum status_code usb_device_endpoint_set_config(struct usb_module *module_inst, struct usb_device_endpoint_config *ep_config) {
/* Sanity check arguments */
Assert(module_inst);
Assert(ep_config);
- uint8_t ep_num = ep_config->ep_address & USB_EP_ADDR_MASK;
+ uint8_t ep_num = ep_config->ep_address & USB_EP_ADDR_MASK;
uint8_t ep_bank = (ep_config->ep_address & USB_EP_DIR_IN) ? 1 : 0;
switch (ep_config->ep_type) {
case USB_DEVICE_ENDPOINT_TYPE_DISABLE:
- module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg = USB_DEVICE_EPCFG_EPTYPE0(0) | USB_DEVICE_EPCFG_EPTYPE1(0);
+ module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg = USB_DEVICE_EPCFG_EPTYPE0(0) | USB_DEVICE_EPCFG_EPTYPE1(0);
return STATUS_OK;
case USB_DEVICE_ENDPOINT_TYPE_CONTROL:
- if ((module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE0_Msk) == 0 && \
- (module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE1_Msk) == 0) {
- module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg = USB_DEVICE_EPCFG_EPTYPE0(1) | USB_DEVICE_EPCFG_EPTYPE1(1);
+ if ((module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE0_Msk) == 0 && (module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE1_Msk) == 0) {
+ module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg = USB_DEVICE_EPCFG_EPTYPE0(1) | USB_DEVICE_EPCFG_EPTYPE1(1);
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_BK0RDY;
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSCLR_BK1RDY;
} else {
@@ -523,14 +486,14 @@ enum status_code usb_device_endpoint_set_config(struct usb_module *module_inst,
case USB_DEVICE_ENDPOINT_TYPE_ISOCHRONOUS:
if (ep_bank) {
- if ((module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE1_Msk) == 0){
+ if ((module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE1_Msk) == 0) {
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg |= USB_DEVICE_EPCFG_EPTYPE1(2);
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSCLR_BK1RDY;
} else {
return STATUS_ERR_DENIED;
}
} else {
- if ((module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE0_Msk) == 0){
+ if ((module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE0_Msk) == 0) {
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg |= USB_DEVICE_EPCFG_EPTYPE0(2);
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_BK0RDY;
} else {
@@ -541,14 +504,14 @@ enum status_code usb_device_endpoint_set_config(struct usb_module *module_inst,
case USB_DEVICE_ENDPOINT_TYPE_BULK:
if (ep_bank) {
- if ((module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE1_Msk) == 0){
+ if ((module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE1_Msk) == 0) {
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg |= USB_DEVICE_EPCFG_EPTYPE1(3);
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSCLR_BK1RDY;
} else {
return STATUS_ERR_DENIED;
}
} else {
- if ((module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE0_Msk) == 0){
+ if ((module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE0_Msk) == 0) {
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg |= USB_DEVICE_EPCFG_EPTYPE0(3);
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_BK0RDY;
} else {
@@ -559,14 +522,14 @@ enum status_code usb_device_endpoint_set_config(struct usb_module *module_inst,
case USB_DEVICE_ENDPOINT_TYPE_INTERRUPT:
if (ep_bank) {
- if ((module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE1_Msk) == 0){
+ if ((module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE1_Msk) == 0) {
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg |= USB_DEVICE_EPCFG_EPTYPE1(4);
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSCLR_BK1RDY;
} else {
return STATUS_ERR_DENIED;
}
} else {
- if ((module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE0_Msk) == 0){
+ if ((module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg & USB_DEVICE_EPCFG_EPTYPE0_Msk) == 0) {
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPCFG.reg |= USB_DEVICE_EPCFG_EPTYPE0(4);
module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_BK0RDY;
} else {
@@ -583,7 +546,7 @@ enum status_code usb_device_endpoint_set_config(struct usb_module *module_inst,
if (true == ep_config->auto_zlp) {
usb_descriptor_table.usb_endpoint_table[ep_num].DeviceDescBank[ep_bank].PCKSIZE.reg |= USB_DEVICE_PCKSIZE_AUTO_ZLP;
- } else {
+ } else {
usb_descriptor_table.usb_endpoint_table[ep_num].DeviceDescBank[ep_bank].PCKSIZE.reg &= ~USB_DEVICE_PCKSIZE_AUTO_ZLP;
}
@@ -598,8 +561,7 @@ enum status_code usb_device_endpoint_set_config(struct usb_module *module_inst,
*
* \return \c true if endpoint is configured and ready to use
*/
-bool usb_device_endpoint_is_configured(struct usb_module *module_inst, uint8_t ep)
-{
+bool usb_device_endpoint_is_configured(struct usb_module *module_inst, uint8_t ep) {
uint8_t ep_num = ep & USB_EP_ADDR_MASK;
uint8_t flag;
@@ -611,15 +573,13 @@ bool usb_device_endpoint_is_configured(struct usb_module *module_inst, uint8_t e
return ((enum usb_device_endpoint_type)(flag) != USB_DEVICE_ENDPOINT_TYPE_DISABLE);
}
-
/**
* \brief Abort ongoing job on the endpoint
*
* \param module_inst Pointer to USB software instance struct
* \param ep Endpoint address
*/
-void usb_device_endpoint_abort_job(struct usb_module *module_inst, uint8_t ep)
-{
+void usb_device_endpoint_abort_job(struct usb_module *module_inst, uint8_t ep) {
uint8_t ep_num;
ep_num = ep & USB_EP_ADDR_MASK;
@@ -643,8 +603,7 @@ void usb_device_endpoint_abort_job(struct usb_module *module_inst, uint8_t ep)
*
* \return \c true if the endpoint is halted
*/
-bool usb_device_endpoint_is_halted(struct usb_module *module_inst, uint8_t ep)
-{
+bool usb_device_endpoint_is_halted(struct usb_module *module_inst, uint8_t ep) {
uint8_t ep_num = ep & USB_EP_ADDR_MASK;
if (ep & USB_EP_DIR_IN) {
@@ -660,8 +619,7 @@ bool usb_device_endpoint_is_halted(struct usb_module *module_inst, uint8_t ep)
* \param module_inst Pointer to USB software instance struct
* \param ep Endpoint address
*/
-void usb_device_endpoint_set_halt(struct usb_module *module_inst, uint8_t ep)
-{
+void usb_device_endpoint_set_halt(struct usb_module *module_inst, uint8_t ep) {
uint8_t ep_num = ep & USB_EP_ADDR_MASK;
// Stall endpoint
@@ -678,8 +636,7 @@ void usb_device_endpoint_set_halt(struct usb_module *module_inst, uint8_t ep)
* \param module_inst Pointer to USB software instance struct
* \param ep Endpoint address
*/
-void usb_device_endpoint_clear_halt(struct usb_module *module_inst, uint8_t ep)
-{
+void usb_device_endpoint_clear_halt(struct usb_module *module_inst, uint8_t ep) {
uint8_t ep_num = ep & USB_EP_ADDR_MASK;
if (ep & USB_EP_DIR_IN) {
@@ -717,9 +674,7 @@ void usb_device_endpoint_clear_halt(struct usb_module *module_inst, uint8_t ep)
* \retval STATUS_OK Job started successfully
* \retval STATUS_ERR_DENIED Endpoint is not ready
*/
-enum status_code usb_device_endpoint_write_buffer_job(struct usb_module *module_inst,uint8_t ep_num,
- uint8_t* pbuf, uint32_t buf_size)
-{
+enum status_code usb_device_endpoint_write_buffer_job(struct usb_module *module_inst, uint8_t ep_num, uint8_t *pbuf, uint32_t buf_size) {
/* Sanity check arguments */
Assert(module_inst);
Assert(module_inst->hw);
@@ -732,10 +687,10 @@ enum status_code usb_device_endpoint_write_buffer_job(struct usb_module *module_
};
/* get endpoint configuration from setting register */
- usb_descriptor_table.usb_endpoint_table[ep_num].DeviceDescBank[1].ADDR.reg = (uint32_t)pbuf;
+ usb_descriptor_table.usb_endpoint_table[ep_num].DeviceDescBank[1].ADDR.reg = (uint32_t)pbuf;
usb_descriptor_table.usb_endpoint_table[ep_num].DeviceDescBank[1].PCKSIZE.bit.MULTI_PACKET_SIZE = 0;
- usb_descriptor_table.usb_endpoint_table[ep_num].DeviceDescBank[1].PCKSIZE.bit.BYTE_COUNT = buf_size;
- module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_BK1RDY;
+ usb_descriptor_table.usb_endpoint_table[ep_num].DeviceDescBank[1].PCKSIZE.bit.BYTE_COUNT = buf_size;
+ module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_BK1RDY;
return STATUS_OK;
}
@@ -752,9 +707,7 @@ enum status_code usb_device_endpoint_write_buffer_job(struct usb_module *module_
* \retval STATUS_OK Job started successfully
* \retval STATUS_ERR_DENIED Endpoint is not ready
*/
-enum status_code usb_device_endpoint_read_buffer_job(struct usb_module *module_inst,uint8_t ep_num,
- uint8_t* pbuf, uint32_t buf_size)
-{
+enum status_code usb_device_endpoint_read_buffer_job(struct usb_module *module_inst, uint8_t ep_num, uint8_t *pbuf, uint32_t buf_size) {
/* Sanity check arguments */
Assert(module_inst);
Assert(module_inst->hw);
@@ -767,10 +720,10 @@ enum status_code usb_device_endpoint_read_buffer_job(struct usb_module *module_i
};
/* get endpoint configuration from setting register */
- usb_descriptor_table.usb_endpoint_table[ep_num].DeviceDescBank[0].ADDR.reg = (uint32_t)pbuf;
+ usb_descriptor_table.usb_endpoint_table[ep_num].DeviceDescBank[0].ADDR.reg = (uint32_t)pbuf;
usb_descriptor_table.usb_endpoint_table[ep_num].DeviceDescBank[0].PCKSIZE.bit.MULTI_PACKET_SIZE = buf_size;
- usb_descriptor_table.usb_endpoint_table[ep_num].DeviceDescBank[0].PCKSIZE.bit.BYTE_COUNT = 0;
- module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSCLR_BK0RDY;
+ usb_descriptor_table.usb_endpoint_table[ep_num].DeviceDescBank[0].PCKSIZE.bit.BYTE_COUNT = 0;
+ module_inst->hw->DEVICE.DeviceEndpoint[ep_num].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSCLR_BK0RDY;
return STATUS_OK;
}
@@ -785,24 +738,21 @@ enum status_code usb_device_endpoint_read_buffer_job(struct usb_module *module_i
* \retval STATUS_OK Job started successfully
* \retval STATUS_ERR_DENIED Endpoint is not ready
*/
-enum status_code usb_device_endpoint_setup_buffer_job(struct usb_module *module_inst,
- uint8_t* pbuf)
-{
+enum status_code usb_device_endpoint_setup_buffer_job(struct usb_module *module_inst, uint8_t *pbuf) {
/* Sanity check arguments */
Assert(module_inst);
Assert(module_inst->hw);
/* get endpoint configuration from setting register */
- usb_descriptor_table.usb_endpoint_table[0].DeviceDescBank[0].ADDR.reg = (uint32_t)pbuf;
+ usb_descriptor_table.usb_endpoint_table[0].DeviceDescBank[0].ADDR.reg = (uint32_t)pbuf;
usb_descriptor_table.usb_endpoint_table[0].DeviceDescBank[0].PCKSIZE.bit.MULTI_PACKET_SIZE = 8;
- usb_descriptor_table.usb_endpoint_table[0].DeviceDescBank[0].PCKSIZE.bit.BYTE_COUNT = 0;
- module_inst->hw->DEVICE.DeviceEndpoint[0].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSCLR_BK0RDY;
+ usb_descriptor_table.usb_endpoint_table[0].DeviceDescBank[0].PCKSIZE.bit.BYTE_COUNT = 0;
+ module_inst->hw->DEVICE.DeviceEndpoint[0].EPSTATUSCLR.reg = USB_DEVICE_EPSTATUSCLR_BK0RDY;
return STATUS_OK;
}
-static void _usb_device_interrupt_handler(void)
-{
+static void _usb_device_interrupt_handler(void) {
uint16_t ep_inst;
uint16_t flags, flags_run;
ep_inst = _usb_instances->hw->DEVICE.EPINTSMRY.reg;
@@ -812,21 +762,16 @@ static void _usb_device_interrupt_handler(void)
int i;
/* get interrupt flags */
- flags = _usb_instances->hw->DEVICE.INTFLAG.reg;
- flags_run = flags &
- _usb_instances->device_enabled_callback_mask &
- _usb_instances->device_registered_callback_mask;
+ flags = _usb_instances->hw->DEVICE.INTFLAG.reg;
+ flags_run = flags & _usb_instances->device_enabled_callback_mask & _usb_instances->device_registered_callback_mask;
- for (i = 0; i < USB_DEVICE_CALLBACK_N; i ++) {
+ for (i = 0; i < USB_DEVICE_CALLBACK_N; i++) {
if (flags & _usb_device_irq_bits[i]) {
- _usb_instances->hw->DEVICE.INTFLAG.reg =
- _usb_device_irq_bits[i];
+ _usb_instances->hw->DEVICE.INTFLAG.reg = _usb_device_irq_bits[i];
}
if (flags_run & _usb_device_irq_bits[i]) {
if (i == USB_DEVICE_CALLBACK_LPMSUSP) {
- device_callback_lpm_wakeup_enable =
- usb_descriptor_table.usb_endpoint_table[0].DeviceDescBank[0].EXTREG.bit.VARIABLE
- & USB_LPM_ATTRIBUT_REMOTEWAKE_MASK;
+ device_callback_lpm_wakeup_enable = usb_descriptor_table.usb_endpoint_table[0].DeviceDescBank[0].EXTREG.bit.VARIABLE & USB_LPM_ATTRIBUT_REMOTEWAKE_MASK;
}
(_usb_instances->device_callback[i])(_usb_instances, &device_callback_lpm_wakeup_enable);
}
@@ -836,25 +781,22 @@ static void _usb_device_interrupt_handler(void)
/* endpoint interrupt */
for (uint8_t i = 0; i < USB_EPT_NUM; i++) {
-
if (ep_inst & (1 << i)) {
- flags = _usb_instances->hw->DEVICE.DeviceEndpoint[i].EPINTFLAG.reg;
- flags_run = flags &
- _usb_instances->device_endpoint_enabled_callback_mask[i] &
- _usb_instances->device_endpoint_registered_callback_mask[i];
+ flags = _usb_instances->hw->DEVICE.DeviceEndpoint[i].EPINTFLAG.reg;
+ flags_run = flags & _usb_instances->device_endpoint_enabled_callback_mask[i] & _usb_instances->device_endpoint_registered_callback_mask[i];
// endpoint transfer stall interrupt
if (flags & USB_DEVICE_EPINTFLAG_STALL_Msk) {
if (_usb_instances->hw->DEVICE.DeviceEndpoint[i].EPINTFLAG.reg & USB_DEVICE_EPINTFLAG_STALL1) {
_usb_instances->hw->DEVICE.DeviceEndpoint[i].EPINTFLAG.reg = USB_DEVICE_EPINTFLAG_STALL1;
- ep_callback_para.endpoint_address = USB_EP_DIR_IN | i;
+ ep_callback_para.endpoint_address = USB_EP_DIR_IN | i;
} else if (_usb_instances->hw->DEVICE.DeviceEndpoint[i].EPINTFLAG.reg & USB_DEVICE_EPINTFLAG_STALL0) {
_usb_instances->hw->DEVICE.DeviceEndpoint[i].EPINTFLAG.reg = USB_DEVICE_EPINTFLAG_STALL0;
- ep_callback_para.endpoint_address = USB_EP_DIR_OUT | i;
+ ep_callback_para.endpoint_address = USB_EP_DIR_OUT | i;
}
if (flags_run & USB_DEVICE_EPINTFLAG_STALL_Msk) {
- (_usb_instances->device_endpoint_callback[i][USB_DEVICE_ENDPOINT_CALLBACK_STALL])(_usb_instances,&ep_callback_para);
+ (_usb_instances->device_endpoint_callback[i][USB_DEVICE_ENDPOINT_CALLBACK_STALL])(_usb_instances, &ep_callback_para);
}
return;
}
@@ -862,9 +804,9 @@ static void _usb_device_interrupt_handler(void)
// endpoint received setup interrupt
if (flags & USB_DEVICE_EPINTFLAG_RXSTP) {
_usb_instances->hw->DEVICE.DeviceEndpoint[i].EPINTFLAG.reg = USB_DEVICE_EPINTFLAG_RXSTP;
- if(_usb_instances->device_endpoint_enabled_callback_mask[i] & _usb_endpoint_irq_bits[USB_DEVICE_ENDPOINT_CALLBACK_RXSTP]) {
+ if (_usb_instances->device_endpoint_enabled_callback_mask[i] & _usb_endpoint_irq_bits[USB_DEVICE_ENDPOINT_CALLBACK_RXSTP]) {
ep_callback_para.received_bytes = (uint16_t)(usb_descriptor_table.usb_endpoint_table[i].DeviceDescBank[0].PCKSIZE.bit.BYTE_COUNT);
- (_usb_instances->device_endpoint_callback[i][USB_DEVICE_ENDPOINT_CALLBACK_RXSTP])(_usb_instances,&ep_callback_para);
+ (_usb_instances->device_endpoint_callback[i][USB_DEVICE_ENDPOINT_CALLBACK_RXSTP])(_usb_instances, &ep_callback_para);
}
return;
}
@@ -873,17 +815,17 @@ static void _usb_device_interrupt_handler(void)
if (flags & USB_DEVICE_EPINTFLAG_TRCPT_Msk) {
if (_usb_instances->hw->DEVICE.DeviceEndpoint[i].EPINTFLAG.reg & USB_DEVICE_EPINTFLAG_TRCPT1) {
_usb_instances->hw->DEVICE.DeviceEndpoint[i].EPINTFLAG.reg = USB_DEVICE_EPINTFLAG_TRCPT1;
- ep_callback_para.endpoint_address = USB_EP_DIR_IN | i;
- ep_callback_para.sent_bytes = (uint16_t)(usb_descriptor_table.usb_endpoint_table[i].DeviceDescBank[1].PCKSIZE.bit.BYTE_COUNT);
+ ep_callback_para.endpoint_address = USB_EP_DIR_IN | i;
+ ep_callback_para.sent_bytes = (uint16_t)(usb_descriptor_table.usb_endpoint_table[i].DeviceDescBank[1].PCKSIZE.bit.BYTE_COUNT);
} else if (_usb_instances->hw->DEVICE.DeviceEndpoint[i].EPINTFLAG.reg & USB_DEVICE_EPINTFLAG_TRCPT0) {
_usb_instances->hw->DEVICE.DeviceEndpoint[i].EPINTFLAG.reg = USB_DEVICE_EPINTFLAG_TRCPT0;
- ep_callback_para.endpoint_address = USB_EP_DIR_OUT | i;
- ep_callback_para.received_bytes = (uint16_t)(usb_descriptor_table.usb_endpoint_table[i].DeviceDescBank[0].PCKSIZE.bit.BYTE_COUNT);
- ep_callback_para.out_buffer_size = (uint16_t)(usb_descriptor_table.usb_endpoint_table[i].DeviceDescBank[0].PCKSIZE.bit.MULTI_PACKET_SIZE);
+ ep_callback_para.endpoint_address = USB_EP_DIR_OUT | i;
+ ep_callback_para.received_bytes = (uint16_t)(usb_descriptor_table.usb_endpoint_table[i].DeviceDescBank[0].PCKSIZE.bit.BYTE_COUNT);
+ ep_callback_para.out_buffer_size = (uint16_t)(usb_descriptor_table.usb_endpoint_table[i].DeviceDescBank[0].PCKSIZE.bit.MULTI_PACKET_SIZE);
}
- if(flags_run & USB_DEVICE_EPINTFLAG_TRCPT_Msk) {
- (_usb_instances->device_endpoint_callback[i][USB_DEVICE_ENDPOINT_CALLBACK_TRCPT])(_usb_instances,&ep_callback_para);
+ if (flags_run & USB_DEVICE_EPINTFLAG_TRCPT_Msk) {
+ (_usb_instances->device_endpoint_callback[i][USB_DEVICE_ENDPOINT_CALLBACK_TRCPT])(_usb_instances, &ep_callback_para);
}
return;
}
@@ -899,7 +841,7 @@ static void _usb_device_interrupt_handler(void)
if (_usb_instances->hw->DEVICE.DeviceEndpoint[i].EPINTFLAG.reg & USB_DEVICE_EPINTFLAG_TRCPT1) {
return;
}
- } else if(_usb_instances->hw->DEVICE.DeviceEndpoint[i].EPINTFLAG.reg & USB_DEVICE_EPINTFLAG_TRFAIL0) {
+ } else if (_usb_instances->hw->DEVICE.DeviceEndpoint[i].EPINTFLAG.reg & USB_DEVICE_EPINTFLAG_TRFAIL0) {
_usb_instances->hw->DEVICE.DeviceEndpoint[i].EPINTFLAG.reg = USB_DEVICE_EPINTFLAG_TRFAIL0;
if (usb_descriptor_table.usb_endpoint_table[i].DeviceDescBank[0].STATUS_BK.reg & USB_DEVICE_STATUS_BK_ERRORFLOW) {
usb_descriptor_table.usb_endpoint_table[i].DeviceDescBank[0].STATUS_BK.reg &= ~USB_DEVICE_STATUS_BK_ERRORFLOW;
@@ -910,8 +852,8 @@ static void _usb_device_interrupt_handler(void)
}
}
- if(flags_run & USB_DEVICE_EPINTFLAG_TRFAIL_Msk) {
- (_usb_instances->device_endpoint_callback[i][USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL])(_usb_instances,&ep_callback_para);
+ if (flags_run & USB_DEVICE_EPINTFLAG_TRFAIL_Msk) {
+ (_usb_instances->device_endpoint_callback[i][USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL])(_usb_instances, &ep_callback_para);
}
return;
}
@@ -925,13 +867,13 @@ static void _usb_device_interrupt_handler(void)
*
* \param module_inst pointer to USB module instance
*/
-void usb_enable(struct usb_module *module_inst)
-{
+void usb_enable(struct usb_module *module_inst) {
Assert(module_inst);
Assert(module_inst->hw);
module_inst->hw->DEVICE.CTRLA.reg |= USB_CTRLA_ENABLE;
- while (module_inst->hw->DEVICE.SYNCBUSY.reg == USB_SYNCBUSY_ENABLE);
+ while (module_inst->hw->DEVICE.SYNCBUSY.reg == USB_SYNCBUSY_ENABLE)
+ ;
}
/**
@@ -939,68 +881,56 @@ void usb_enable(struct usb_module *module_inst)
*
* \param module_inst pointer to USB module instance
*/
-void usb_disable(struct usb_module *module_inst)
-{
+void usb_disable(struct usb_module *module_inst) {
Assert(module_inst);
Assert(module_inst->hw);
module_inst->hw->DEVICE.INTENCLR.reg = USB_DEVICE_INTENCLR_MASK;
- module_inst->hw->DEVICE.INTFLAG.reg = USB_DEVICE_INTFLAG_MASK;
+ module_inst->hw->DEVICE.INTFLAG.reg = USB_DEVICE_INTFLAG_MASK;
module_inst->hw->DEVICE.CTRLA.reg &= ~USB_CTRLA_ENABLE;
- while (module_inst->hw->DEVICE.SYNCBUSY.reg == USB_SYNCBUSY_ENABLE);
+ while (module_inst->hw->DEVICE.SYNCBUSY.reg == USB_SYNCBUSY_ENABLE)
+ ;
}
/**
* \brief Interrupt handler for the USB module.
*/
-void USB_0_Handler(void)
-{
+void USB_0_Handler(void) {
if (_usb_instances->hw->DEVICE.CTRLA.bit.MODE) {
-
} else {
/*device mode ISR */
_usb_device_interrupt_handler();
}
}
-void USB_1_Handler(void)
-{
- _usb_device_interrupt_handler();
-}
+void USB_1_Handler(void) { _usb_device_interrupt_handler(); }
-void USB_2_Handler(void)
-{
- _usb_device_interrupt_handler();
-}
+void USB_2_Handler(void) { _usb_device_interrupt_handler(); }
-void USB_3_Handler(void)
-{
- _usb_device_interrupt_handler();
-}
+void USB_3_Handler(void) { _usb_device_interrupt_handler(); }
/**
* \brief Get the default USB module settings
*
* \param[out] module_config Configuration structure to initialize to default values
*/
-void usb_get_config_defaults(struct usb_config *module_config)
-{
+void usb_get_config_defaults(struct usb_config *module_config) {
Assert(module_config);
/* Sanity check arguments */
Assert(module_config);
/* Write default configuration to config struct */
module_config->select_host_mode = 0;
- module_config->run_in_standby = 1;
+ module_config->run_in_standby = 1;
module_config->source_generator = 0;
- module_config->speed_mode = USB_SPEED_FULL;
+ module_config->speed_mode = USB_SPEED_FULL;
}
-#define NVM_USB_PAD_TRANSN_POS 45
+#define NVM_USB_PAD_TRANSN_POS 45
#define NVM_USB_PAD_TRANSN_SIZE 5
-#define NVM_USB_PAD_TRANSP_POS 50
+#define NVM_USB_PAD_TRANSP_POS 50
#define NVM_USB_PAD_TRANSP_SIZE 5
-#define NVM_USB_PAD_TRIM_POS 55
+#define NVM_USB_PAD_TRIM_POS 55
#define NVM_USB_PAD_TRIM_SIZE 3
/**
@@ -1020,56 +950,61 @@ void usb_get_config_defaults(struct usb_config *module_config)
#define GCLK_USB 10
-enum status_code usb_init(struct usb_module *module_inst, Usb *const hw,
- struct usb_config *module_config)
-{
+enum status_code usb_init(struct usb_module *module_inst, Usb *const hw, struct usb_config *module_config) {
/* Sanity check arguments */
Assert(hw);
Assert(module_inst);
Assert(module_config);
- uint32_t i,j;
+ uint32_t i, j;
uint32_t pad_transn, pad_transp, pad_trim;
- Gclk *pgclk = GCLK;
- Mclk *pmclk = MCLK;
- Port *pport = PORT;
- Oscctrl *posc = OSCCTRL;
+ Gclk * pgclk = GCLK;
+ Mclk * pmclk = MCLK;
+ Port * pport = PORT;
+ Oscctrl *posc = OSCCTRL;
_usb_instances = module_inst;
/* Associate the software module instance with the hardware module */
module_inst->hw = hw;
- //setup peripheral and synchronous bus clocks to USB
- pmclk->AHBMASK.bit.USB_ = 1;
+ // setup peripheral and synchronous bus clocks to USB
+ pmclk->AHBMASK.bit.USB_ = 1;
pmclk->APBBMASK.bit.USB_ = 1;
/* Set up the USB DP/DN pins */
- pport->Group[0].PMUX[12].reg = 0x77; //PA24, PA25, function column H for USB D-, D+
+ pport->Group[0].PMUX[12].reg = 0x77; // PA24, PA25, function column H for USB D-, D+
pport->Group[0].PINCFG[24].bit.PMUXEN = 1;
pport->Group[0].PINCFG[25].bit.PMUXEN = 1;
- pport->Group[1].PMUX[11].bit.PMUXE = 7; //PB22, function column H for USB SOF_1KHz output
+ pport->Group[1].PMUX[11].bit.PMUXE = 7; // PB22, function column H for USB SOF_1KHz output
pport->Group[1].PINCFG[22].bit.PMUXEN = 1;
- //configure and enable DFLL for USB clock recovery mode at 48MHz
+ // configure and enable DFLL for USB clock recovery mode at 48MHz
posc->DFLLCTRLA.bit.ENABLE = 0;
- while (posc->DFLLSYNC.bit.ENABLE);
- while (posc->DFLLSYNC.bit.DFLLCTRLB);
+ while (posc->DFLLSYNC.bit.ENABLE)
+ ;
+ while (posc->DFLLSYNC.bit.DFLLCTRLB)
+ ;
posc->DFLLCTRLB.bit.USBCRM = 1;
- while (posc->DFLLSYNC.bit.DFLLCTRLB);
+ while (posc->DFLLSYNC.bit.DFLLCTRLB)
+ ;
posc->DFLLCTRLB.bit.MODE = 1;
- while (posc->DFLLSYNC.bit.DFLLCTRLB);
+ while (posc->DFLLSYNC.bit.DFLLCTRLB)
+ ;
posc->DFLLCTRLB.bit.QLDIS = 0;
- while (posc->DFLLSYNC.bit.DFLLCTRLB);
+ while (posc->DFLLSYNC.bit.DFLLCTRLB)
+ ;
posc->DFLLCTRLB.bit.CCDIS = 1;
- posc->DFLLMUL.bit.MUL = 0xbb80; //4800 x 1KHz
- while (posc->DFLLSYNC.bit.DFLLMUL);
+ posc->DFLLMUL.bit.MUL = 0xbb80; // 4800 x 1KHz
+ while (posc->DFLLSYNC.bit.DFLLMUL)
+ ;
posc->DFLLCTRLA.bit.ENABLE = 1;
- while (posc->DFLLSYNC.bit.ENABLE);
+ while (posc->DFLLSYNC.bit.ENABLE)
+ ;
/* Setup clock for module */
- pgclk->PCHCTRL[GCLK_USB].bit.GEN = 0;
+ pgclk->PCHCTRL[GCLK_USB].bit.GEN = 0;
pgclk->PCHCTRL[GCLK_USB].bit.CHEN = 1;
/* Reset */
@@ -1084,21 +1019,21 @@ enum status_code usb_init(struct usb_module *module_inst, Usb *const hw,
/* Load Pad Calibration */
- pad_transn = (USB_FUSES_TRANSN_ADDR >> USB_FUSES_TRANSN_Pos) & USB_FUSES_TRANSN_Msk;
+ pad_transn = (USB_FUSES_TRANSN_ADDR >> USB_FUSES_TRANSN_Pos) & USB_FUSES_TRANSN_Msk;
if (pad_transn == 0x1F) {
pad_transn = 5;
}
hw->DEVICE.PADCAL.bit.TRANSN = pad_transn;
- pad_transp = (USB_FUSES_TRANSP_ADDR >> USB_FUSES_TRANSP_Pos) & USB_FUSES_TRANSP_Msk;
+ pad_transp = (USB_FUSES_TRANSP_ADDR >> USB_FUSES_TRANSP_Pos) & USB_FUSES_TRANSP_Msk;
if (pad_transp == 0x1F) {
pad_transp = 29;
}
hw->DEVICE.PADCAL.bit.TRANSP = pad_transp;
- pad_trim = (USB_FUSES_TRIM_ADDR >> USB_FUSES_TRIM_Pos) & USB_FUSES_TRIM_Msk;
+ pad_trim = (USB_FUSES_TRIM_ADDR >> USB_FUSES_TRIM_Pos) & USB_FUSES_TRIM_Msk;
if (pad_trim == 0x07) {
pad_trim = 3;
}
@@ -1106,32 +1041,31 @@ enum status_code usb_init(struct usb_module *module_inst, Usb *const hw,
hw->DEVICE.PADCAL.bit.TRIM = pad_trim;
/* Set the configuration */
- hw->DEVICE.CTRLA.bit.MODE = module_config->select_host_mode;
+ hw->DEVICE.CTRLA.bit.MODE = module_config->select_host_mode;
hw->DEVICE.CTRLA.bit.RUNSTDBY = module_config->run_in_standby;
- hw->DEVICE.DESCADD.reg = (uint32_t)(&usb_descriptor_table.usb_endpoint_table[0]);
+ hw->DEVICE.DESCADD.reg = (uint32_t)(&usb_descriptor_table.usb_endpoint_table[0]);
if (USB_SPEED_FULL == module_config->speed_mode) {
module_inst->hw->DEVICE.CTRLB.bit.SPDCONF = USB_DEVICE_CTRLB_SPDCONF_FS_Val;
- } else if(USB_SPEED_LOW == module_config->speed_mode) {
+ } else if (USB_SPEED_LOW == module_config->speed_mode) {
module_inst->hw->DEVICE.CTRLB.bit.SPDCONF = USB_DEVICE_CTRLB_SPDCONF_LS_Val;
}
- memset((uint8_t *)(&usb_descriptor_table.usb_endpoint_table[0]), 0,
- sizeof(usb_descriptor_table.usb_endpoint_table));
+ memset((uint8_t *)(&usb_descriptor_table.usb_endpoint_table[0]), 0, sizeof(usb_descriptor_table.usb_endpoint_table));
/* device callback related */
for (i = 0; i < USB_DEVICE_CALLBACK_N; i++) {
module_inst->device_callback[i] = NULL;
}
for (i = 0; i < USB_EPT_NUM; i++) {
- for(j = 0; j < USB_DEVICE_EP_CALLBACK_N; j++) {
+ for (j = 0; j < USB_DEVICE_EP_CALLBACK_N; j++) {
module_inst->device_endpoint_callback[i][j] = NULL;
}
}
module_inst->device_registered_callback_mask = 0;
- module_inst->device_enabled_callback_mask = 0;
+ module_inst->device_enabled_callback_mask = 0;
for (j = 0; j < USB_EPT_NUM; j++) {
module_inst->device_endpoint_registered_callback_mask[j] = 0;
- module_inst->device_endpoint_enabled_callback_mask[j] = 0;
+ module_inst->device_endpoint_enabled_callback_mask[j] = 0;
}
/* Enable interrupts for this USB module */
@@ -1141,4 +1075,3 @@ enum status_code usb_init(struct usb_module *module_inst, Usb *const hw,
return STATUS_OK;
}
-
diff --git a/tmk_core/protocol/arm_atsam/usb/usb.h b/tmk_core/protocol/arm_atsam/usb/usb.h
index 9a452881a7..4c937ecdc9 100644
--- a/tmk_core/protocol/arm_atsam/usb/usb.h
+++ b/tmk_core/protocol/arm_atsam/usb/usb.h
@@ -233,8 +233,8 @@ typedef void (*usb_host_pipe_callback_t)(struct usb_module *module_inst, void *)
* \name Device Callback Functions Types
* @{
*/
-typedef void (*usb_device_callback_t)(struct usb_module *module_inst, void* pointer);
-typedef void (*usb_device_endpoint_callback_t)(struct usb_module *module_inst, void* pointer);
+typedef void (*usb_device_callback_t)(struct usb_module *module_inst, void *pointer);
+typedef void (*usb_device_endpoint_callback_t)(struct usb_module *module_inst, void *pointer);
/** @} */
/** USB configurations */
@@ -247,7 +247,7 @@ struct usb_config {
// enum gclk_generator source_generator;
uint8_t source_generator;
/** Speed mode */
- //enum usb_speed speed_mode;
+ // enum usb_speed speed_mode;
uint8_t speed_mode;
};
@@ -263,7 +263,7 @@ struct usb_module {
Usb *hw;
/** Array to store device related callback functions */
- usb_device_callback_t device_callback[USB_DEVICE_CALLBACK_N];
+ usb_device_callback_t device_callback[USB_DEVICE_CALLBACK_N];
usb_device_endpoint_callback_t device_endpoint_callback[USB_EPT_NUM][USB_DEVICE_EP_CALLBACK_N];
/** Bit mask for device callbacks registered */
uint16_t device_registered_callback_mask;
@@ -292,7 +292,7 @@ struct usb_endpoint_callback_parameter {
uint16_t received_bytes;
uint16_t sent_bytes;
uint16_t out_buffer_size;
- uint8_t endpoint_address;
+ uint8_t endpoint_address;
};
void usb_enable(struct usb_module *module_inst);
@@ -303,8 +303,7 @@ void usb_disable(struct usb_module *module_inst);
*
* \param module_inst Pointer to USB module instance
*/
-static inline uint8_t usb_get_state_machine_status(struct usb_module *module_inst)
-{
+static inline uint8_t usb_get_state_machine_status(struct usb_module *module_inst) {
/* Sanity check arguments */
Assert(module_inst);
Assert(module_inst->hw);
@@ -312,29 +311,22 @@ static inline uint8_t usb_get_state_machine_status(struct usb_module *module_ins
return module_inst->hw->DEVICE.FSMSTATUS.reg;
}
-void usb_get_config_defaults(struct usb_config *module_config);
-enum status_code usb_init(struct usb_module *module_inst, Usb *const hw,
- struct usb_config *module_config);
+void usb_get_config_defaults(struct usb_config *module_config);
+enum status_code usb_init(struct usb_module *module_inst, Usb *const hw, struct usb_config *module_config);
/**
* \brief Attach USB device to the bus
*
* \param module_inst Pointer to USB device module instance
*/
-static inline void usb_device_attach(struct usb_module *module_inst)
-{
- module_inst->hw->DEVICE.CTRLB.reg &= ~USB_DEVICE_CTRLB_DETACH;
-}
+static inline void usb_device_attach(struct usb_module *module_inst) { module_inst->hw->DEVICE.CTRLB.reg &= ~USB_DEVICE_CTRLB_DETACH; }
/**
* \brief Detach USB device from the bus
*
* \param module_inst Pointer to USB device module instance
*/
-static inline void usb_device_detach(struct usb_module *module_inst)
-{
- module_inst->hw->DEVICE.CTRLB.reg |= USB_DEVICE_CTRLB_DETACH;
-}
+static inline void usb_device_detach(struct usb_module *module_inst) { module_inst->hw->DEVICE.CTRLB.reg |= USB_DEVICE_CTRLB_DETACH; }
/**
* \brief Get the speed mode of USB device
@@ -342,8 +334,7 @@ static inline void usb_device_detach(struct usb_module *module_inst)
* \param module_inst Pointer to USB device module instance
* \return USB Speed mode (\ref usb_speed).
*/
-static inline enum usb_speed usb_device_get_speed(struct usb_module *module_inst)
-{
+static inline enum usb_speed usb_device_get_speed(struct usb_module *module_inst) {
if (!(module_inst->hw->DEVICE.STATUS.reg & USB_DEVICE_STATUS_SPEED_Msk)) {
return USB_SPEED_FULL;
} else {
@@ -357,10 +348,7 @@ static inline enum usb_speed usb_device_get_speed(struct usb_module *module_inst
* \param module_inst Pointer to USB device module instance
* \return USB device address value.
*/
-static inline uint8_t usb_device_get_address(struct usb_module *module_inst)
-{
- return ((uint8_t)(module_inst->hw->DEVICE.DADD.bit.DADD));
-}
+static inline uint8_t usb_device_get_address(struct usb_module *module_inst) { return ((uint8_t)(module_inst->hw->DEVICE.DADD.bit.DADD)); }
/**
* \brief Set the speed mode of USB device
@@ -368,10 +356,7 @@ static inline uint8_t usb_device_get_address(struct usb_module *module_inst)
* \param module_inst Pointer to USB device module instance
* \param address USB device address value
*/
-static inline void usb_device_set_address(struct usb_module *module_inst, uint8_t address)
-{
- module_inst->hw->DEVICE.DADD.reg = USB_DEVICE_DADD_ADDEN | address;
-}
+static inline void usb_device_set_address(struct usb_module *module_inst, uint8_t address) { module_inst->hw->DEVICE.DADD.reg = USB_DEVICE_DADD_ADDEN | address; }
/**
* \brief Get the frame number of USB device
@@ -379,10 +364,7 @@ static inline void usb_device_set_address(struct usb_module *module_inst, uint8_
* \param module_inst Pointer to USB device module instance
* \return USB device frame number value.
*/
-static inline uint16_t usb_device_get_frame_number(struct usb_module *module_inst)
-{
- return ((uint16_t)(module_inst->hw->DEVICE.FNUM.bit.FNUM));
-}
+static inline uint16_t usb_device_get_frame_number(struct usb_module *module_inst) { return ((uint16_t)(module_inst->hw->DEVICE.FNUM.bit.FNUM)); }
/**
* \brief Get the micro-frame number of USB device
@@ -390,20 +372,14 @@ static inline uint16_t usb_device_get_frame_number(struct usb_module *module_ins
* \param module_inst Pointer to USB device module instance
* \return USB device micro-frame number value.
*/
-static inline uint16_t usb_device_get_micro_frame_number(struct usb_module *module_inst)
-{
- return ((uint16_t)(module_inst->hw->DEVICE.FNUM.reg));
-}
+static inline uint16_t usb_device_get_micro_frame_number(struct usb_module *module_inst) { return ((uint16_t)(module_inst->hw->DEVICE.FNUM.reg)); }
/**
* \brief USB device send the resume wakeup
*
* \param module_inst Pointer to USB device module instance
*/
-static inline void usb_device_send_remote_wake_up(struct usb_module *module_inst)
-{
- module_inst->hw->DEVICE.CTRLB.reg |= USB_DEVICE_CTRLB_UPRSM;
-}
+static inline void usb_device_send_remote_wake_up(struct usb_module *module_inst) { module_inst->hw->DEVICE.CTRLB.reg |= USB_DEVICE_CTRLB_UPRSM; }
/**
* \brief USB device set the LPM mode
@@ -411,67 +387,45 @@ static inline void usb_device_send_remote_wake_up(struct usb_module *module_inst
* \param module_inst Pointer to USB device module instance
* \param lpm_mode LPM mode
*/
-static inline void usb_device_set_lpm_mode(struct usb_module *module_inst,
- enum usb_device_lpm_mode lpm_mode)
-{
- module_inst->hw->DEVICE.CTRLB.bit.LPMHDSK = lpm_mode;
-}
+static inline void usb_device_set_lpm_mode(struct usb_module *module_inst, enum usb_device_lpm_mode lpm_mode) { module_inst->hw->DEVICE.CTRLB.bit.LPMHDSK = lpm_mode; }
/**
* \name USB Device Callback Management
* @{
*/
-enum status_code usb_device_register_callback(struct usb_module *module_inst,
- enum usb_device_callback callback_type,
- usb_device_callback_t callback_func);
-enum status_code usb_device_unregister_callback(struct usb_module *module_inst,
- enum usb_device_callback callback_type);
-enum status_code usb_device_enable_callback(struct usb_module *module_inst,
- enum usb_device_callback callback_type);
-enum status_code usb_device_disable_callback(struct usb_module *module_inst,
- enum usb_device_callback callback_type);
+enum status_code usb_device_register_callback(struct usb_module *module_inst, enum usb_device_callback callback_type, usb_device_callback_t callback_func);
+enum status_code usb_device_unregister_callback(struct usb_module *module_inst, enum usb_device_callback callback_type);
+enum status_code usb_device_enable_callback(struct usb_module *module_inst, enum usb_device_callback callback_type);
+enum status_code usb_device_disable_callback(struct usb_module *module_inst, enum usb_device_callback callback_type);
/** @} */
/**
* \name USB Device Endpoint Configuration
* @{
*/
-void usb_device_endpoint_get_config_defaults(struct usb_device_endpoint_config *ep_config);
-enum status_code usb_device_endpoint_set_config(struct usb_module *module_inst,
- struct usb_device_endpoint_config *ep_config);
-bool usb_device_endpoint_is_configured(struct usb_module *module_inst, uint8_t ep);
+void usb_device_endpoint_get_config_defaults(struct usb_device_endpoint_config *ep_config);
+enum status_code usb_device_endpoint_set_config(struct usb_module *module_inst, struct usb_device_endpoint_config *ep_config);
+bool usb_device_endpoint_is_configured(struct usb_module *module_inst, uint8_t ep);
/** @} */
/**
* \name USB Device Endpoint Callback Management
* @{
*/
-enum status_code usb_device_endpoint_register_callback(
- struct usb_module *module_inst, uint8_t ep_num,
- enum usb_device_endpoint_callback callback_type,
- usb_device_endpoint_callback_t callback_func);
-enum status_code usb_device_endpoint_unregister_callback(
- struct usb_module *module_inst, uint8_t ep_num,
- enum usb_device_endpoint_callback callback_type);
-enum status_code usb_device_endpoint_enable_callback(
- struct usb_module *module_inst, uint8_t ep,
- enum usb_device_endpoint_callback callback_type);
-enum status_code usb_device_endpoint_disable_callback(
- struct usb_module *module_inst, uint8_t ep,
- enum usb_device_endpoint_callback callback_type);
+enum status_code usb_device_endpoint_register_callback(struct usb_module *module_inst, uint8_t ep_num, enum usb_device_endpoint_callback callback_type, usb_device_endpoint_callback_t callback_func);
+enum status_code usb_device_endpoint_unregister_callback(struct usb_module *module_inst, uint8_t ep_num, enum usb_device_endpoint_callback callback_type);
+enum status_code usb_device_endpoint_enable_callback(struct usb_module *module_inst, uint8_t ep, enum usb_device_endpoint_callback callback_type);
+enum status_code usb_device_endpoint_disable_callback(struct usb_module *module_inst, uint8_t ep, enum usb_device_endpoint_callback callback_type);
/** @} */
/**
* \name USB Device Endpoint Job Management
* @{
*/
-enum status_code usb_device_endpoint_write_buffer_job(struct usb_module *module_inst,uint8_t ep_num,
- uint8_t* pbuf, uint32_t buf_size);
-enum status_code usb_device_endpoint_read_buffer_job(struct usb_module *module_inst,uint8_t ep_num,
- uint8_t* pbuf, uint32_t buf_size);
-enum status_code usb_device_endpoint_setup_buffer_job(struct usb_module *module_inst,
- uint8_t* pbuf);
-void usb_device_endpoint_abort_job(struct usb_module *module_inst, uint8_t ep);
+enum status_code usb_device_endpoint_write_buffer_job(struct usb_module *module_inst, uint8_t ep_num, uint8_t *pbuf, uint32_t buf_size);
+enum status_code usb_device_endpoint_read_buffer_job(struct usb_module *module_inst, uint8_t ep_num, uint8_t *pbuf, uint32_t buf_size);
+enum status_code usb_device_endpoint_setup_buffer_job(struct usb_module *module_inst, uint8_t *pbuf);
+void usb_device_endpoint_abort_job(struct usb_module *module_inst, uint8_t ep);
/** @} */
/**
diff --git a/tmk_core/protocol/arm_atsam/usb/usb2422.c b/tmk_core/protocol/arm_atsam/usb/usb2422.c
index 76ec3aaaa7..a878cb6b7c 100644
--- a/tmk_core/protocol/arm_atsam/usb/usb2422.c
+++ b/tmk_core/protocol/arm_atsam/usb/usb2422.c
@@ -18,23 +18,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "arm_atsam_protocol.h"
#include <string.h>
-Usb2422 USB2422_shadow;
+Usb2422 USB2422_shadow;
unsigned char i2c0_buf[34];
-const uint16_t MFRNAME[] = { 'M','a','s','s','d','r','o','p',' ','I','n','c','.' }; //Massdrop Inc.
-const uint16_t PRDNAME[] = { 'M','a','s','s','d','r','o','p',' ','H','u','b' }; //Massdrop Hub
+const uint16_t MFRNAME[] = {'M', 'a', 's', 's', 'd', 'r', 'o', 'p', ' ', 'I', 'n', 'c', '.'}; // Massdrop Inc.
+const uint16_t PRDNAME[] = {'M', 'a', 's', 's', 'd', 'r', 'o', 'p', ' ', 'H', 'u', 'b'}; // Massdrop Hub
#ifndef MD_BOOTLOADER
-//Serial number reported stops before first found space character or at last found character
-const uint16_t SERNAME[] = { 'U','n','a','v','a','i','l','a','b','l','e' }; //Unavailable
+// Serial number reported stops before first found space character or at last found character
+const uint16_t SERNAME[] = {'U', 'n', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e'}; // Unavailable
#else
-//In production, this field is found, modified, and offset noted as the last 32-bit word in the bootloader space
-//The offset allows the application to use the factory programmed serial (which may differ from the physical serial label)
-//Serial number reported stops before first found space character or when max size is reached
-__attribute__((__aligned__(4)))
-const uint16_t SERNAME[BOOTLOADER_SERIAL_MAX_SIZE] = { 'M','D','H','U','B','B','O','O','T','L','0','0','0','0','0','0','0','0','0','0' };
-//NOTE: Serial replacer will not write a string longer than given here as a precaution, so give enough
+// In production, this field is found, modified, and offset noted as the last 32-bit word in the bootloader space
+// The offset allows the application to use the factory programmed serial (which may differ from the physical serial label)
+// Serial number reported stops before first found space character or when max size is reached
+__attribute__((__aligned__(4))) const uint16_t SERNAME[BOOTLOADER_SERIAL_MAX_SIZE] = {'M', 'D', 'H', 'U', 'B', 'B', 'O', 'O', 'T', 'L', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'};
+// NOTE: Serial replacer will not write a string longer than given here as a precaution, so give enough
// space as needed and adjust BOOTLOADER_SERIAL_MAX_SIZE to match amount given
-#endif //MD_BOOTLOADER
+#endif // MD_BOOTLOADER
uint8_t usb_host_port;
@@ -44,95 +43,116 @@ uint8_t usb_extra_state;
uint8_t usb_extra_manual;
uint8_t usb_gcr_auto;
-#endif //MD_BOOTLOADER
+#endif // MD_BOOTLOADER
uint16_t adc_extra;
-void USB_write2422_block(void)
-{
+void USB_write2422_block(void) {
unsigned char *dest = i2c0_buf;
unsigned char *src;
unsigned char *base = (unsigned char *)&USB2422_shadow;
DBGC(DC_USB_WRITE2422_BLOCK_BEGIN);
- for (src = base; src < base + 256; src += 32)
- {
+ for (src = base; src < base + 256; src += 32) {
dest[0] = src - base;
dest[1] = 32;
memcpy(&dest[2], src, 32);
i2c0_transmit(USB2422_ADDR, dest, 34, 50000);
SERCOM0->I2CM.CTRLB.bit.CMD = 0x03;
- while (SERCOM0->I2CM.SYNCBUSY.bit.SYSOP) { DBGC(DC_USB_WRITE2422_BLOCK_SYNC_SYSOP); }
+ while (SERCOM0->I2CM.SYNCBUSY.bit.SYSOP) {
+ DBGC(DC_USB_WRITE2422_BLOCK_SYNC_SYSOP);
+ }
wait_us(100);
}
DBGC(DC_USB_WRITE2422_BLOCK_COMPLETE);
}
-void USB2422_init(void)
-{
- Gclk *pgclk = GCLK;
- Mclk *pmclk = MCLK;
- Port *pport = PORT;
- Oscctrl *posc = OSCCTRL;
- Usb *pusb = USB;
+void USB2422_init(void) {
+ Gclk * pgclk = GCLK;
+ Mclk * pmclk = MCLK;
+ Port * pport = PORT;
+ Oscctrl *posc = OSCCTRL;
+ Usb * pusb = USB;
DBGC(DC_USB2422_INIT_BEGIN);
- while ((v_5v = adc_get(ADC_5V)) < ADC_5V_START_LEVEL) { DBGC(DC_USB2422_INIT_WAIT_5V_LOW); }
+ while ((v_5v = adc_get(ADC_5V)) < ADC_5V_START_LEVEL) {
+ DBGC(DC_USB2422_INIT_WAIT_5V_LOW);
+ }
- //setup peripheral and synchronous bus clocks to USB
- pgclk->PCHCTRL[10].bit.GEN = 0;
+ // setup peripheral and synchronous bus clocks to USB
+ pgclk->PCHCTRL[10].bit.GEN = 0;
pgclk->PCHCTRL[10].bit.CHEN = 1;
- pmclk->AHBMASK.bit.USB_ = 1;
- pmclk->APBBMASK.bit.USB_ = 1;
+ pmclk->AHBMASK.bit.USB_ = 1;
+ pmclk->APBBMASK.bit.USB_ = 1;
- //setup port pins for D-, D+, and SOF_1KHZ
- pport->Group[0].PMUX[12].reg = 0x77; //PA24, PA25, function column H for USB D-, D+
+ // setup port pins for D-, D+, and SOF_1KHZ
+ pport->Group[0].PMUX[12].reg = 0x77; // PA24, PA25, function column H for USB D-, D+
pport->Group[0].PINCFG[24].bit.PMUXEN = 1;
pport->Group[0].PINCFG[25].bit.PMUXEN = 1;
- pport->Group[1].PMUX[11].bit.PMUXE = 7; //PB22, function column H for USB SOF_1KHz output
+ pport->Group[1].PMUX[11].bit.PMUXE = 7; // PB22, function column H for USB SOF_1KHz output
pport->Group[1].PINCFG[22].bit.PMUXEN = 1;
- //configure and enable DFLL for USB clock recovery mode at 48MHz
+ // configure and enable DFLL for USB clock recovery mode at 48MHz
posc->DFLLCTRLA.bit.ENABLE = 0;
- while (posc->DFLLSYNC.bit.ENABLE) { DBGC(DC_USB2422_INIT_OSC_SYNC_DISABLING); }
- while (posc->DFLLSYNC.bit.DFLLCTRLB) { DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLCTRLB_1); }
+ while (posc->DFLLSYNC.bit.ENABLE) {
+ DBGC(DC_USB2422_INIT_OSC_SYNC_DISABLING);
+ }
+ while (posc->DFLLSYNC.bit.DFLLCTRLB) {
+ DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLCTRLB_1);
+ }
posc->DFLLCTRLB.bit.USBCRM = 1;
- while (posc->DFLLSYNC.bit.DFLLCTRLB) { DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLCTRLB_2); }
+ while (posc->DFLLSYNC.bit.DFLLCTRLB) {
+ DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLCTRLB_2);
+ }
posc->DFLLCTRLB.bit.MODE = 1;
- while (posc->DFLLSYNC.bit.DFLLCTRLB) { DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLCTRLB_3); }
+ while (posc->DFLLSYNC.bit.DFLLCTRLB) {
+ DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLCTRLB_3);
+ }
posc->DFLLCTRLB.bit.QLDIS = 0;
- while (posc->DFLLSYNC.bit.DFLLCTRLB) { DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLCTRLB_4); }
+ while (posc->DFLLSYNC.bit.DFLLCTRLB) {
+ DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLCTRLB_4);
+ }
posc->DFLLCTRLB.bit.CCDIS = 1;
- posc->DFLLMUL.bit.MUL = 0xBB80; //4800 x 1KHz
- while (posc->DFLLSYNC.bit.DFLLMUL) { DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLMUL); }
+ posc->DFLLMUL.bit.MUL = 0xBB80; // 4800 x 1KHz
+ while (posc->DFLLSYNC.bit.DFLLMUL) {
+ DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLMUL);
+ }
posc->DFLLCTRLA.bit.ENABLE = 1;
- while (posc->DFLLSYNC.bit.ENABLE) { DBGC(DC_USB2422_INIT_OSC_SYNC_ENABLING); }
+ while (posc->DFLLSYNC.bit.ENABLE) {
+ DBGC(DC_USB2422_INIT_OSC_SYNC_ENABLING);
+ }
pusb->DEVICE.CTRLA.bit.SWRST = 1;
- while (pusb->DEVICE.SYNCBUSY.bit.SWRST) { DBGC(DC_USB2422_INIT_USB_SYNC_SWRST); }
- while (pusb->DEVICE.CTRLA.bit.SWRST) { DBGC(DC_USB2422_INIT_USB_WAIT_SWRST); }
- //calibration from factory presets
+ while (pusb->DEVICE.SYNCBUSY.bit.SWRST) {
+ DBGC(DC_USB2422_INIT_USB_SYNC_SWRST);
+ }
+ while (pusb->DEVICE.CTRLA.bit.SWRST) {
+ DBGC(DC_USB2422_INIT_USB_WAIT_SWRST);
+ }
+ // calibration from factory presets
pusb->DEVICE.PADCAL.bit.TRANSN = (USB_FUSES_TRANSN_ADDR >> USB_FUSES_TRANSN_Pos) & USB_FUSES_TRANSN_Msk;
pusb->DEVICE.PADCAL.bit.TRANSP = (USB_FUSES_TRANSP_ADDR >> USB_FUSES_TRANSP_Pos) & USB_FUSES_TRANSP_Msk;
- pusb->DEVICE.PADCAL.bit.TRIM = (USB_FUSES_TRIM_ADDR >> USB_FUSES_TRIM_Pos) & USB_FUSES_TRIM_Msk;
- //device mode, enabled
- pusb->DEVICE.CTRLB.bit.SPDCONF = 0; //full speed
- pusb->DEVICE.CTRLA.bit.MODE = 0;
- pusb->DEVICE.CTRLA.bit.ENABLE = 1;
- while (pusb->DEVICE.SYNCBUSY.bit.ENABLE) { DBGC(DC_USB2422_INIT_USB_SYNC_ENABLING); }
+ pusb->DEVICE.PADCAL.bit.TRIM = (USB_FUSES_TRIM_ADDR >> USB_FUSES_TRIM_Pos) & USB_FUSES_TRIM_Msk;
+ // device mode, enabled
+ pusb->DEVICE.CTRLB.bit.SPDCONF = 0; // full speed
+ pusb->DEVICE.CTRLA.bit.MODE = 0;
+ pusb->DEVICE.CTRLA.bit.ENABLE = 1;
+ while (pusb->DEVICE.SYNCBUSY.bit.ENABLE) {
+ DBGC(DC_USB2422_INIT_USB_SYNC_ENABLING);
+ }
pusb->DEVICE.QOSCTRL.bit.DQOS = 2;
pusb->DEVICE.QOSCTRL.bit.CQOS = 2;
pport->Group[USB2422_HUB_ACTIVE_GROUP].PINCFG[USB2422_HUB_ACTIVE_PIN].bit.INEN = 1;
- i2c0_init(); //IC2 clk must be high at USB2422 reset release time to signal SMB configuration
+ i2c0_init(); // IC2 clk must be high at USB2422 reset release time to signal SMB configuration
- sr_exp_data.bit.HUB_CONNECT = 1; //connect signal
- sr_exp_data.bit.HUB_RESET_N = 1; //reset high
+ sr_exp_data.bit.HUB_CONNECT = 1; // connect signal
+ sr_exp_data.bit.HUB_RESET_N = 1; // reset high
SR_EXP_WriteData();
wait_us(100);
@@ -140,78 +160,74 @@ void USB2422_init(void)
#ifndef MD_BOOTLOADER
usb_extra_manual = 0;
- usb_gcr_auto = 1;
+ usb_gcr_auto = 1;
-#endif //MD_BOOTLOADER
+#endif // MD_BOOTLOADER
DBGC(DC_USB2422_INIT_COMPLETE);
}
-void USB_reset(void)
-{
+void USB_reset(void) {
DBGC(DC_USB_RESET_BEGIN);
- //pulse reset for at least 1 usec
- sr_exp_data.bit.HUB_RESET_N = 0; //reset low
+ // pulse reset for at least 1 usec
+ sr_exp_data.bit.HUB_RESET_N = 0; // reset low
SR_EXP_WriteData();
wait_us(2);
- sr_exp_data.bit.HUB_RESET_N = 1; //reset high to run
+ sr_exp_data.bit.HUB_RESET_N = 1; // reset high to run
SR_EXP_WriteData();
DBGC(DC_USB_RESET_COMPLETE);
}
-void USB_configure(void)
-{
+void USB_configure(void) {
Usb2422 *pusb2422 = &USB2422_shadow;
memset(pusb2422, 0, sizeof(Usb2422));
- uint16_t *serial_use = (uint16_t *)SERNAME; //Default to use SERNAME from this file
- uint8_t serial_length = sizeof(SERNAME) / sizeof(uint16_t); //Default to use SERNAME from this file
+ uint16_t *serial_use = (uint16_t *)SERNAME; // Default to use SERNAME from this file
+ uint8_t serial_length = sizeof(SERNAME) / sizeof(uint16_t); // Default to use SERNAME from this file
#ifndef MD_BOOTLOADER
uint32_t serial_ptrloc = (uint32_t)&_srom - 4;
-#else //MD_BOOTLOADER
+#else // MD_BOOTLOADER
uint32_t serial_ptrloc = (uint32_t)&_erom - 4;
-#endif //MD_BOOTLOADER
- uint32_t serial_address = *(uint32_t *)serial_ptrloc; //Address of bootloader's serial number if available
+#endif // MD_BOOTLOADER
+ uint32_t serial_address = *(uint32_t *)serial_ptrloc; // Address of bootloader's serial number if available
DBGC(DC_USB_CONFIGURE_BEGIN);
- if (serial_address != 0xFFFFFFFF && serial_address < serial_ptrloc) //Check for factory programmed serial address
+ if (serial_address != 0xFFFFFFFF && serial_address < serial_ptrloc) // Check for factory programmed serial address
{
- if ((serial_address & 0xFF) % 4 == 0) //Check alignment
+ if ((serial_address & 0xFF) % 4 == 0) // Check alignment
{
- serial_use = (uint16_t *)(serial_address);
+ serial_use = (uint16_t *)(serial_address);
serial_length = 0;
- while ((*(serial_use + serial_length) > 32 && *(serial_use + serial_length) < 127) &&
- serial_length < BOOTLOADER_SERIAL_MAX_SIZE)
- {
+ while ((*(serial_use + serial_length) > 32 && *(serial_use + serial_length) < 127) && serial_length < BOOTLOADER_SERIAL_MAX_SIZE) {
serial_length++;
DBGC(DC_USB_CONFIGURE_GET_SERIAL);
}
}
}
- //configure Usb2422 registers
- pusb2422->VID.reg = 0x04D8; // from Microchip 4/19/2018
- pusb2422->PID.reg = 0xEEC5; // from Microchip 4/19/2018 = Massdrop, Inc. USB Hub
- pusb2422->DID.reg = 0x0101; // BCD 01.01
- pusb2422->CFG1.bit.SELF_BUS_PWR = 1; // self powered for now
- pusb2422->CFG1.bit.HS_DISABLE = 1; // full or high speed
- //pusb2422->CFG2.bit.COMPOUND = 0; // compound device
- pusb2422->CFG3.bit.STRING_EN = 1; // strings enabled
- //pusb2422->NRD.bit.PORT2_NR = 0; // MCU is non-removable
- pusb2422->MAXPB.reg = 20; // 0mA
- pusb2422->HCMCB.reg = 20; // 0mA
+ // configure Usb2422 registers
+ pusb2422->VID.reg = 0x04D8; // from Microchip 4/19/2018
+ pusb2422->PID.reg = 0xEEC5; // from Microchip 4/19/2018 = Massdrop, Inc. USB Hub
+ pusb2422->DID.reg = 0x0101; // BCD 01.01
+ pusb2422->CFG1.bit.SELF_BUS_PWR = 1; // self powered for now
+ pusb2422->CFG1.bit.HS_DISABLE = 1; // full or high speed
+ // pusb2422->CFG2.bit.COMPOUND = 0; // compound device
+ pusb2422->CFG3.bit.STRING_EN = 1; // strings enabled
+ // pusb2422->NRD.bit.PORT2_NR = 0; // MCU is non-removable
+ pusb2422->MAXPB.reg = 20; // 0mA
+ pusb2422->HCMCB.reg = 20; // 0mA
pusb2422->MFRSL.reg = sizeof(MFRNAME) / sizeof(uint16_t);
pusb2422->PRDSL.reg = sizeof(PRDNAME) / sizeof(uint16_t);
pusb2422->SERSL.reg = serial_length;
memcpy(pusb2422->MFRSTR, MFRNAME, sizeof(MFRNAME));
memcpy(pusb2422->PRDSTR, PRDNAME, sizeof(PRDNAME));
memcpy(pusb2422->SERSTR, serial_use, serial_length * sizeof(uint16_t));
- //pusb2422->BOOSTUP.bit.BOOST=3; //upstream port
- //pusb2422->BOOSTDOWN.bit.BOOST1=0; // extra port
- //pusb2422->BOOSTDOWN.bit.BOOST2=2; //MCU is close
+ // pusb2422->BOOSTUP.bit.BOOST=3; //upstream port
+ // pusb2422->BOOSTDOWN.bit.BOOST1=0; // extra port
+ // pusb2422->BOOSTDOWN.bit.BOOST2=2; //MCU is close
pusb2422->STCD.bit.USB_ATTACH = 1;
USB_write2422_block();
@@ -220,35 +236,33 @@ void USB_configure(void)
DBGC(DC_USB_CONFIGURE_COMPLETE);
}
-uint16_t USB_active(void)
-{
- return (PORT->Group[USB2422_HUB_ACTIVE_GROUP].IN.reg & (1 << USB2422_HUB_ACTIVE_PIN)) != 0;
-}
+uint16_t USB_active(void) { return (PORT->Group[USB2422_HUB_ACTIVE_GROUP].IN.reg & (1 << USB2422_HUB_ACTIVE_PIN)) != 0; }
-void USB_set_host_by_voltage(void)
-{
- //UP is upstream device (HOST)
- //DN1 is downstream device (EXTRA)
- //DN2 is keyboard (KEYB)
+void USB_set_host_by_voltage(void) {
+ // UP is upstream device (HOST)
+ // DN1 is downstream device (EXTRA)
+ // DN2 is keyboard (KEYB)
DBGC(DC_USB_SET_HOST_BY_VOLTAGE_BEGIN);
usb_host_port = USB_HOST_PORT_UNKNOWN;
#ifndef MD_BOOTLOADER
usb_extra_state = USB_EXTRA_STATE_UNKNOWN;
-#endif //MD_BOOTLOADER
- sr_exp_data.bit.SRC_1 = 1; //USBC-1 available for test
- sr_exp_data.bit.SRC_2 = 1; //USBC-2 available for test
- sr_exp_data.bit.E_UP_N = 1; //HOST disable
- sr_exp_data.bit.E_DN1_N = 1; //EXTRA disable
- sr_exp_data.bit.E_VBUS_1 = 0; //USBC-1 disable full power I/O
- sr_exp_data.bit.E_VBUS_2 = 0; //USBC-2 disable full power I/O
+#endif // MD_BOOTLOADER
+ sr_exp_data.bit.SRC_1 = 1; // USBC-1 available for test
+ sr_exp_data.bit.SRC_2 = 1; // USBC-2 available for test
+ sr_exp_data.bit.E_UP_N = 1; // HOST disable
+ sr_exp_data.bit.E_DN1_N = 1; // EXTRA disable
+ sr_exp_data.bit.E_VBUS_1 = 0; // USBC-1 disable full power I/O
+ sr_exp_data.bit.E_VBUS_2 = 0; // USBC-2 disable full power I/O
SR_EXP_WriteData();
wait_ms(250);
- while ((v_5v = adc_get(ADC_5V)) < ADC_5V_START_LEVEL) { DBGC(DC_USB_SET_HOST_5V_LOW_WAITING); }
+ while ((v_5v = adc_get(ADC_5V)) < ADC_5V_START_LEVEL) {
+ DBGC(DC_USB_SET_HOST_5V_LOW_WAITING);
+ }
v_con_1 = adc_get(ADC_CON1);
v_con_2 = adc_get(ADC_CON2);
@@ -256,37 +270,34 @@ void USB_set_host_by_voltage(void)
v_con_1_boot = v_con_1;
v_con_2_boot = v_con_2;
- if (v_con_1 > v_con_2)
- {
- sr_exp_data.bit.S_UP = 0; //HOST to USBC-1
- sr_exp_data.bit.S_DN1 = 1; //EXTRA to USBC-2
- sr_exp_data.bit.SRC_1 = 1; //HOST on USBC-1
- sr_exp_data.bit.SRC_2 = 0; //EXTRA available on USBC-2
+ if (v_con_1 > v_con_2) {
+ sr_exp_data.bit.S_UP = 0; // HOST to USBC-1
+ sr_exp_data.bit.S_DN1 = 1; // EXTRA to USBC-2
+ sr_exp_data.bit.SRC_1 = 1; // HOST on USBC-1
+ sr_exp_data.bit.SRC_2 = 0; // EXTRA available on USBC-2
- sr_exp_data.bit.E_VBUS_1 = 1; //USBC-1 enable full power I/O
- sr_exp_data.bit.E_VBUS_2 = 0; //USBC-2 disable full power I/O
+ sr_exp_data.bit.E_VBUS_1 = 1; // USBC-1 enable full power I/O
+ sr_exp_data.bit.E_VBUS_2 = 0; // USBC-2 disable full power I/O
SR_EXP_WriteData();
- sr_exp_data.bit.E_UP_N = 0; //HOST enable
+ sr_exp_data.bit.E_UP_N = 0; // HOST enable
SR_EXP_WriteData();
usb_host_port = USB_HOST_PORT_1;
- }
- else
- {
- sr_exp_data.bit.S_UP = 1; //EXTRA to USBC-1
- sr_exp_data.bit.S_DN1 = 0; //HOST to USBC-2
- sr_exp_data.bit.SRC_1 = 0; //EXTRA available on USBC-1
- sr_exp_data.bit.SRC_2 = 1; //HOST on USBC-2
+ } else {
+ sr_exp_data.bit.S_UP = 1; // EXTRA to USBC-1
+ sr_exp_data.bit.S_DN1 = 0; // HOST to USBC-2
+ sr_exp_data.bit.SRC_1 = 0; // EXTRA available on USBC-1
+ sr_exp_data.bit.SRC_2 = 1; // HOST on USBC-2
- sr_exp_data.bit.E_VBUS_1 = 0; //USBC-1 disable full power I/O
- sr_exp_data.bit.E_VBUS_2 = 1; //USBC-2 enable full power I/O
+ sr_exp_data.bit.E_VBUS_1 = 0; // USBC-1 disable full power I/O
+ sr_exp_data.bit.E_VBUS_2 = 1; // USBC-2 enable full power I/O
SR_EXP_WriteData();
- sr_exp_data.bit.E_UP_N = 0; //HOST enable
+ sr_exp_data.bit.E_UP_N = 0; // HOST enable
SR_EXP_WriteData();
@@ -295,7 +306,7 @@ void USB_set_host_by_voltage(void)
#ifndef MD_BOOTLOADER
usb_extra_state = USB_EXTRA_STATE_DISABLED;
-#endif //MD_BOOTLOADER
+#endif // MD_BOOTLOADER
USB_reset();
USB_configure();
@@ -303,8 +314,7 @@ void USB_set_host_by_voltage(void)
DBGC(DC_USB_SET_HOST_BY_VOLTAGE_COMPLETE);
}
-uint8_t USB2422_Port_Detect_Init(void)
-{
+uint8_t USB2422_Port_Detect_Init(void) {
uint32_t port_detect_retry_ms;
uint32_t tmod;
@@ -314,26 +324,30 @@ uint8_t USB2422_Port_Detect_Init(void)
port_detect_retry_ms = timer_read64() + PORT_DETECT_RETRY_INTERVAL;
- while (!USB_active())
- {
+ while (!USB_active()) {
tmod = timer_read64() % PORT_DETECT_RETRY_INTERVAL;
- if (v_con_1 > v_con_2) //Values updated from USB_set_host_by_voltage();
+ if (v_con_1 > v_con_2) // Values updated from USB_set_host_by_voltage();
{
- //1 flash for port 1 detected
- if (tmod > 500 && tmod < 600) { DBG_LED_ON; }
- else { DBG_LED_OFF; }
- }
- else if (v_con_2 > v_con_1) //Values updated from USB_set_host_by_voltage();
+ // 1 flash for port 1 detected
+ if (tmod > 500 && tmod < 600) {
+ DBG_LED_ON;
+ } else {
+ DBG_LED_OFF;
+ }
+ } else if (v_con_2 > v_con_1) // Values updated from USB_set_host_by_voltage();
{
- //2 flash for port 2 detected
- if (tmod > 500 && tmod < 600) { DBG_LED_ON; }
- else if (tmod > 700 && tmod < 800) { DBG_LED_ON; }
- else { DBG_LED_OFF; }
+ // 2 flash for port 2 detected
+ if (tmod > 500 && tmod < 600) {
+ DBG_LED_ON;
+ } else if (tmod > 700 && tmod < 800) {
+ DBG_LED_ON;
+ } else {
+ DBG_LED_OFF;
+ }
}
- if (timer_read64() > port_detect_retry_ms)
- {
+ if (timer_read64() > port_detect_retry_ms) {
DBGC(DC_PORT_DETECT_INIT_FAILED);
return 0;
}
@@ -346,65 +360,67 @@ uint8_t USB2422_Port_Detect_Init(void)
#ifndef MD_BOOTLOADER
-void USB_ExtraSetState(uint8_t state)
-{
+void USB_ExtraSetState(uint8_t state) {
uint8_t state_save = state;
- if (state == USB_EXTRA_STATE_DISABLED_UNTIL_REPLUG)
- state = USB_EXTRA_STATE_DISABLED;
+ if (state == USB_EXTRA_STATE_DISABLED_UNTIL_REPLUG) state = USB_EXTRA_STATE_DISABLED;
- if (usb_host_port == USB_HOST_PORT_1) sr_exp_data.bit.E_VBUS_2 = state;
- else if (usb_host_port == USB_HOST_PORT_2) sr_exp_data.bit.E_VBUS_1 = state;
- else return;
+ if (usb_host_port == USB_HOST_PORT_1)
+ sr_exp_data.bit.E_VBUS_2 = state;
+ else if (usb_host_port == USB_HOST_PORT_2)
+ sr_exp_data.bit.E_VBUS_1 = state;
+ else
+ return;
sr_exp_data.bit.E_DN1_N = !state;
SR_EXP_WriteData();
usb_extra_state = state_save;
- if (usb_extra_state == USB_EXTRA_STATE_ENABLED) CDC_print("USB: Extra enabled\r\n");
- else if (usb_extra_state == USB_EXTRA_STATE_DISABLED)
- {
+ if (usb_extra_state == USB_EXTRA_STATE_ENABLED)
+ CDC_print("USB: Extra enabled\r\n");
+ else if (usb_extra_state == USB_EXTRA_STATE_DISABLED) {
CDC_print("USB: Extra disabled\r\n");
-#ifdef USE_MASSDROP_CONFIGURATOR
+# ifdef USE_MASSDROP_CONFIGURATOR
if (led_animation_breathing) gcr_breathe = gcr_desired;
-#endif
- }
- else if (usb_extra_state == USB_EXTRA_STATE_DISABLED_UNTIL_REPLUG) CDC_print("USB: Extra disabled until replug\r\n");
- else CDC_print("USB: Extra state unknown\r\n");
+# endif
+ } else if (usb_extra_state == USB_EXTRA_STATE_DISABLED_UNTIL_REPLUG)
+ CDC_print("USB: Extra disabled until replug\r\n");
+ else
+ CDC_print("USB: Extra state unknown\r\n");
}
-void USB_HandleExtraDevice(void)
-{
+void USB_HandleExtraDevice(void) {
uint16_t adcval;
- if (usb_host_port == USB_HOST_PORT_1) adcval = adc_get(ADC_CON2);
- else if (usb_host_port == USB_HOST_PORT_2) adcval = adc_get(ADC_CON1);
- else return;
+ if (usb_host_port == USB_HOST_PORT_1)
+ adcval = adc_get(ADC_CON2);
+ else if (usb_host_port == USB_HOST_PORT_2)
+ adcval = adc_get(ADC_CON1);
+ else
+ return;
adc_extra = adc_extra * 0.9 + adcval * 0.1;
- //Check for a forced disable state (such as overload prevention)
- if (usb_extra_state == USB_EXTRA_STATE_DISABLED_UNTIL_REPLUG)
- {
- //Detect unplug and reset state to disabled
+ // Check for a forced disable state (such as overload prevention)
+ if (usb_extra_state == USB_EXTRA_STATE_DISABLED_UNTIL_REPLUG) {
+ // Detect unplug and reset state to disabled
if (adc_extra > USB_EXTRA_ADC_THRESHOLD) usb_extra_state = USB_EXTRA_STATE_DISABLED;
- return; //Return even if unplug detected
+ return; // Return even if unplug detected
}
- if (usb_extra_manual)
- {
- if (usb_extra_state == USB_EXTRA_STATE_DISABLED)
- USB_ExtraSetState(USB_EXTRA_STATE_ENABLED);
+ if (usb_extra_manual) {
+ if (usb_extra_state == USB_EXTRA_STATE_DISABLED) USB_ExtraSetState(USB_EXTRA_STATE_ENABLED);
return;
}
- //dpf("a %i %i\r\n",adcval, adc_extra);
- if (usb_extra_state == USB_EXTRA_STATE_DISABLED && adc_extra < USB_EXTRA_ADC_THRESHOLD) USB_ExtraSetState(USB_EXTRA_STATE_ENABLED);
- else if (usb_extra_state == USB_EXTRA_STATE_ENABLED && adc_extra > USB_EXTRA_ADC_THRESHOLD) USB_ExtraSetState(USB_EXTRA_STATE_DISABLED);
+ // dpf("a %i %i\r\n",adcval, adc_extra);
+ if (usb_extra_state == USB_EXTRA_STATE_DISABLED && adc_extra < USB_EXTRA_ADC_THRESHOLD)
+ USB_ExtraSetState(USB_EXTRA_STATE_ENABLED);
+ else if (usb_extra_state == USB_EXTRA_STATE_ENABLED && adc_extra > USB_EXTRA_ADC_THRESHOLD)
+ USB_ExtraSetState(USB_EXTRA_STATE_DISABLED);
}
-#endif //MD_BOOTLOADER
-
+#endif // MD_BOOTLOADER
diff --git a/tmk_core/protocol/arm_atsam/usb/usb2422.h b/tmk_core/protocol/arm_atsam/usb/usb2422.h
index 85ad596a62..b4830b5bc8 100644
--- a/tmk_core/protocol/arm_atsam/usb/usb2422.h
+++ b/tmk_core/protocol/arm_atsam/usb/usb2422.h
@@ -18,226 +18,225 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef _USB2422_H_
#define _USB2422_H_
-#define REV_USB2422 0x100
+#define REV_USB2422 0x100
-#define USB2422_ADDR 0x58 //I2C device address, one instance
+#define USB2422_ADDR 0x58 // I2C device address, one instance
-#define USB2422_HUB_ACTIVE_GROUP 0 //PA
-#define USB2422_HUB_ACTIVE_PIN 18 //18
+#define USB2422_HUB_ACTIVE_GROUP 0 // PA
+#define USB2422_HUB_ACTIVE_PIN 18 // 18
/* -------- USB2422_VID : (USB2422L Offset: 0x00) (R/W 16) Vendor ID -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint16_t VID_LSB : 8;
- uint16_t VID_MSB : 8;
- } bit; /*!< Structure used for bit access */
- uint16_t reg; /*!< Type used for register access */
+ struct {
+ uint16_t VID_LSB : 8;
+ uint16_t VID_MSB : 8;
+ } bit; /*!< Structure used for bit access */
+ uint16_t reg; /*!< Type used for register access */
} USB2422_VID_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_PID : (USB2422L Offset: 0x02) (R/W 16) Product ID -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint16_t PID_LSB : 8;
- uint16_t PID_MSB : 8;
- } bit; /*!< Structure used for bit access */
- uint16_t reg; /*!< Type used for register access */
+ struct {
+ uint16_t PID_LSB : 8;
+ uint16_t PID_MSB : 8;
+ } bit; /*!< Structure used for bit access */
+ uint16_t reg; /*!< Type used for register access */
} USB2422_PID_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_DID : (USB2422L Offset: 0x04) (R/W 16) Device ID -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint16_t DID_LSB : 8;
- uint16_t DID_MSB : 8;
- } bit; /*!< Structure used for bit access */
- uint16_t reg; /*!< Type used for register access */
+ struct {
+ uint16_t DID_LSB : 8;
+ uint16_t DID_MSB : 8;
+ } bit; /*!< Structure used for bit access */
+ uint16_t reg; /*!< Type used for register access */
} USB2422_DID_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_CFG1 : (USB2422L Offset: 0x06) (R/W 8) Configuration Data Byte 1-------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t PORT_PWR : 1;
- uint8_t CURRENT_SNS : 2;
- uint8_t EOP_DISABLE : 1;
- uint8_t MTT_ENABLE : 1;
- uint8_t HS_DISABLE :1;
- uint8_t :1;
- uint8_t SELF_BUS_PWR : 1;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t PORT_PWR : 1;
+ uint8_t CURRENT_SNS : 2;
+ uint8_t EOP_DISABLE : 1;
+ uint8_t MTT_ENABLE : 1;
+ uint8_t HS_DISABLE : 1;
+ uint8_t : 1;
+ uint8_t SELF_BUS_PWR : 1;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_CFG1_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_CFG2 : (USB2422L Offset: 0x07) (R/W 8) Configuration Data Byte 2-------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t : 3;
- uint8_t COMPOUND : 1;
- uint8_t OC_TIMER :2;
- uint8_t :1;
- uint8_t DYNAMIC : 1;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t : 3;
+ uint8_t COMPOUND : 1;
+ uint8_t OC_TIMER : 2;
+ uint8_t : 1;
+ uint8_t DYNAMIC : 1;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_CFG2_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_CFG3 : (USB2422L Offset: 0x08) (R/W 16) Configuration Data Byte 3-------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t STRING_EN : 1;
- uint8_t :2;
- uint8_t PRTMAP_EN :1;
- uint8_t : 4;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t STRING_EN : 1;
+ uint8_t : 2;
+ uint8_t PRTMAP_EN : 1;
+ uint8_t : 4;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_CFG3_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_NRD : (USB2422L Offset: 0x09) (R/W 8) Non Removable Device -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t : 5;
- uint8_t PORT2_NR :1;
- uint8_t PORT1_NR :1;
- uint8_t : 1;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t : 5;
+ uint8_t PORT2_NR : 1;
+ uint8_t PORT1_NR : 1;
+ uint8_t : 1;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_NRD_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_PDS : (USB2422L Offset: 0x0A) (R/W 8) Port Diable for Self-Powered Operation -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t : 1;
- uint8_t PORT1_DIS :1;
- uint8_t PORT2_DIS :1;
- uint8_t : 5;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t : 1;
+ uint8_t PORT1_DIS : 1;
+ uint8_t PORT2_DIS : 1;
+ uint8_t : 5;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_PDS_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_PDB : (USB2422L Offset: 0x0B) (R/W 8) Port Diable for Bus-Powered Operation -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t : 1;
- uint8_t PORT1_DIS :1;
- uint8_t PORT2_DIS :1;
- uint8_t : 5;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t : 1;
+ uint8_t PORT1_DIS : 1;
+ uint8_t PORT2_DIS : 1;
+ uint8_t : 5;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_PDB_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_MAXPS : (USB2422L Offset: 0x0C) (R/W 8) Max Power for Self-Powered Operation -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t MAX_PWR_SP : 8;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t MAX_PWR_SP : 8;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_MAXPS_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_MAXPB : (USB2422L Offset: 0x0D) (R/W 8) Max Power for Bus-Powered Operation -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t MAX_PWR_BP : 8;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t MAX_PWR_BP : 8;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_MAXPB_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_HCMCS : (USB2422L Offset: 0x0E) (R/W 8) Hub Controller Max Current for Self-Powered Operation -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t HC_MAX_C_SP : 8;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t HC_MAX_C_SP : 8;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_HCMCS_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_HCMCB : (USB2422L Offset: 0x0F) (R/W 8) Hub Controller Max Current for Bus-Powered Operation -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t HC_MAX_C_BP : 8;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t HC_MAX_C_BP : 8;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_HCMCB_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_PWRT : (USB2422L Offset: 0x10) (R/W 8) Power On Time -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t POWER_ON_TIME : 8;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t POWER_ON_TIME : 8;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_PWRT_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_LANGID LSB : (USB2422L Offset: 0x11) (R/W 16) Language ID -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t LANGID_LSB : 8;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t LANGID_LSB : 8;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_LANGID_LSB_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_LANGID MSB : (USB2422L Offset: 0x12) (R/W 16) Language ID -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t LANGID_MSB : 8;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t LANGID_MSB : 8;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_LANGID_MSB_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
-
/* -------- USB2422_MFRSL : (USB2422L Offset: 0x13) (R/W 8) Manufacturer String Length -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t MFR_STR_LEN : 8;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t MFR_STR_LEN : 8;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_MFRSL_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_PRDSL : (USB2422L Offset: 0x14) (R/W 8) Product String Length -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t PRD_STR_LEN : 8;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t PRD_STR_LEN : 8;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_PRDSL_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_SERSL : (USB2422L Offset: 0x15) (R/W 8) Serial String Length -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t SER_STR_LEN : 8;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t SER_STR_LEN : 8;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_SERSL_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
@@ -259,60 +258,60 @@ typedef uint16_t USB2422_SERSTR_Type;
/* -------- USB2422_BCEN : (USB2422L Offset: 0xD0) (R/W 8) Battery Charging Enable -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t : 1;
- uint8_t PORT1_BCE :1;
- uint8_t PORT2_BCE :1;
- uint8_t : 5;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t : 1;
+ uint8_t PORT1_BCE : 1;
+ uint8_t PORT2_BCE : 1;
+ uint8_t : 5;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_BCEN_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_BOOSTUP : (USB2422L Offset: 0xF6) (R/W 8) Boost Upstream -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t BOOST :2;
- uint8_t : 6;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t BOOST : 2;
+ uint8_t : 6;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_BOOSTUP_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_BOOSTDOWN : (USB2422L Offset: 0xF8) (R/W 8) Boost Downstream -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t BOOST1 :2;
- uint8_t BOOST2 :2;
- uint8_t : 4;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t BOOST1 : 2;
+ uint8_t BOOST2 : 2;
+ uint8_t : 4;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_BOOSTDOWN_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_PRTSP : (USB2422L Offset: 0xFA) (R/W 8) Port Swap -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t : 1;
- uint8_t PORT1_SP :1;
- uint8_t PORT2_SP :1;
- uint8_t : 5;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t : 1;
+ uint8_t PORT1_SP : 1;
+ uint8_t PORT2_SP : 1;
+ uint8_t : 5;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_PRTSP_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* -------- USB2422_PRTR12 : (USB2422L Offset: 0xFB) (R/W 8) Port 1/2 Remap -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t PORT1_REMAP: 4;
- uint8_t PORT2_REMAP: 4;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t PORT1_REMAP : 4;
+ uint8_t PORT2_REMAP : 4;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_PRTR12_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
#define USB2422_PRTR12_DISABLE 0
@@ -324,81 +323,80 @@ typedef union {
/* -------- USB2422_STCD : (USB2422L Offset: 0xFF) (R/W 8) Status Command -------- */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef union {
- struct {
- uint8_t USB_ATTACH: 1;
- uint8_t RESET: 1;
- uint8_t INTF_PWRDN: 1;
- uint8_t : 5;
- } bit; /*!< Structure used for bit access */
- uint8_t reg; /*!< Type used for register access */
+ struct {
+ uint8_t USB_ATTACH : 1;
+ uint8_t RESET : 1;
+ uint8_t INTF_PWRDN : 1;
+ uint8_t : 5;
+ } bit; /*!< Structure used for bit access */
+ uint8_t reg; /*!< Type used for register access */
} USB2422_STCD_Type;
#endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/** \brief USB2422 device hardware registers */
#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
typedef struct {
- USB2422_VID_Type VID; /**< \brief Offset: 0x00*/
- USB2422_PID_Type PID; /**< \brief Offset: 0x02*/
- USB2422_DID_Type DID; /**< \brief Offset: 0x04*/
- USB2422_CFG1_Type CFG1; /**< \brief Offset: 0x06*/
- USB2422_CFG2_Type CFG2; /**< \brief Offset: 0x07*/
- USB2422_CFG3_Type CFG3; /**< \brief Offset: 0x08*/
- USB2422_NRD_Type NRD; /**< \brief Offset: 0x09*/
- USB2422_PDS_Type PDS; /**< \brief Offset: 0x0A*/
- USB2422_PDB_Type PDB; /**< \brief Offset: 0x0B*/
- USB2422_MAXPS_Type MAXPS; /**< \brief Offset: 0x0C*/
- USB2422_MAXPB_Type MAXPB; /**< \brief Offset: 0x0D*/
- USB2422_HCMCS_Type HCMCS; /**< \brief Offset: 0x0E*/
- USB2422_HCMCB_Type HCMCB; /**< \brief Offset: 0x0F*/
- USB2422_PWRT_Type PWRT; /**< \brief Offset: 0x10*/
- USB2422_LANGID_LSB_Type LANGID_LSB; /**< \brief Offset: 0x11*/
- USB2422_LANGID_MSB_Type LANGID_MSB; /**< \brief Offset: 0x12*/
- USB2422_MFRSL_Type MFRSL; /**< \brief Offset: 0x13*/
- USB2422_PRDSL_Type PRDSL; /**< \brief Offset: 0x14*/
- USB2422_SERSL_Type SERSL; /**< \brief Offset: 0x15*/
- USB2422_MFRSTR_Type MFRSTR[31]; /**< \brief Offset: 0x16*/
- USB2422_PRDSTR_Type PRDSTR[31]; /**< \brief Offset: 0x54*/
- USB2422_SERSTR_Type SERSTR[31]; /**< \brief Offset: 0x92*/
- USB2422_BCEN_Type BCEN; /**< \brief Offset: 0xD0*/
- uint8_t Reserved1[0x25];
- USB2422_BOOSTUP_Type BOOSTUP; /**< \brief Offset: 0xF6*/
- uint8_t Reserved2[0x1];
- USB2422_BOOSTDOWN_Type BOOSTDOWN; /**< \brief Offset: 0xF8*/
- uint8_t Reserved3[0x1];
- USB2422_PRTSP_Type PRTSP; /**< \brief Offset: 0xFA*/
- USB2422_PRTR12_Type PRTR12; /**< \brief Offset: 0xFB*/
- uint8_t Reserved4[0x3];
- USB2422_STCD_Type STCD; /**< \brief Offset: 0xFF*/
+ USB2422_VID_Type VID; /**< \brief Offset: 0x00*/
+ USB2422_PID_Type PID; /**< \brief Offset: 0x02*/
+ USB2422_DID_Type DID; /**< \brief Offset: 0x04*/
+ USB2422_CFG1_Type CFG1; /**< \brief Offset: 0x06*/
+ USB2422_CFG2_Type CFG2; /**< \brief Offset: 0x07*/
+ USB2422_CFG3_Type CFG3; /**< \brief Offset: 0x08*/
+ USB2422_NRD_Type NRD; /**< \brief Offset: 0x09*/
+ USB2422_PDS_Type PDS; /**< \brief Offset: 0x0A*/
+ USB2422_PDB_Type PDB; /**< \brief Offset: 0x0B*/
+ USB2422_MAXPS_Type MAXPS; /**< \brief Offset: 0x0C*/
+ USB2422_MAXPB_Type MAXPB; /**< \brief Offset: 0x0D*/
+ USB2422_HCMCS_Type HCMCS; /**< \brief Offset: 0x0E*/
+ USB2422_HCMCB_Type HCMCB; /**< \brief Offset: 0x0F*/
+ USB2422_PWRT_Type PWRT; /**< \brief Offset: 0x10*/
+ USB2422_LANGID_LSB_Type LANGID_LSB; /**< \brief Offset: 0x11*/
+ USB2422_LANGID_MSB_Type LANGID_MSB; /**< \brief Offset: 0x12*/
+ USB2422_MFRSL_Type MFRSL; /**< \brief Offset: 0x13*/
+ USB2422_PRDSL_Type PRDSL; /**< \brief Offset: 0x14*/
+ USB2422_SERSL_Type SERSL; /**< \brief Offset: 0x15*/
+ USB2422_MFRSTR_Type MFRSTR[31]; /**< \brief Offset: 0x16*/
+ USB2422_PRDSTR_Type PRDSTR[31]; /**< \brief Offset: 0x54*/
+ USB2422_SERSTR_Type SERSTR[31]; /**< \brief Offset: 0x92*/
+ USB2422_BCEN_Type BCEN; /**< \brief Offset: 0xD0*/
+ uint8_t Reserved1[0x25];
+ USB2422_BOOSTUP_Type BOOSTUP; /**< \brief Offset: 0xF6*/
+ uint8_t Reserved2[0x1];
+ USB2422_BOOSTDOWN_Type BOOSTDOWN; /**< \brief Offset: 0xF8*/
+ uint8_t Reserved3[0x1];
+ USB2422_PRTSP_Type PRTSP; /**< \brief Offset: 0xFA*/
+ USB2422_PRTR12_Type PRTR12; /**< \brief Offset: 0xFB*/
+ uint8_t Reserved4[0x3];
+ USB2422_STCD_Type STCD; /**< \brief Offset: 0xFF*/
} Usb2422;
#endif
-#define PORT_DETECT_RETRY_INTERVAL 2000
+#define PORT_DETECT_RETRY_INTERVAL 2000
-#define USB_EXTRA_ADC_THRESHOLD 900
+#define USB_EXTRA_ADC_THRESHOLD 900
-#define USB_EXTRA_STATE_DISABLED 0
-#define USB_EXTRA_STATE_ENABLED 1
-#define USB_EXTRA_STATE_UNKNOWN 2
-#define USB_EXTRA_STATE_DISABLED_UNTIL_REPLUG 3
+#define USB_EXTRA_STATE_DISABLED 0
+#define USB_EXTRA_STATE_ENABLED 1
+#define USB_EXTRA_STATE_UNKNOWN 2
+#define USB_EXTRA_STATE_DISABLED_UNTIL_REPLUG 3
-#define USB_HOST_PORT_1 0
-#define USB_HOST_PORT_2 1
-#define USB_HOST_PORT_UNKNOWN 2
+#define USB_HOST_PORT_1 0
+#define USB_HOST_PORT_2 1
+#define USB_HOST_PORT_UNKNOWN 2
extern uint8_t usb_host_port;
extern uint8_t usb_extra_state;
extern uint8_t usb_extra_manual;
extern uint8_t usb_gcr_auto;
-void USB2422_init(void);
-void USB_reset(void);
-void USB_configure(void);
+void USB2422_init(void);
+void USB_reset(void);
+void USB_configure(void);
uint16_t USB_active(void);
-void USB_set_host_by_voltage(void);
+void USB_set_host_by_voltage(void);
uint16_t adc_get(uint8_t muxpos);
-uint8_t USB2422_Port_Detect_Init(void);
-void USB_HandleExtraDevice(void);
-void USB_ExtraSetState(uint8_t state);
-
-#endif //_USB2422_H_
+uint8_t USB2422_Port_Detect_Init(void);
+void USB_HandleExtraDevice(void);
+void USB_ExtraSetState(uint8_t state);
+#endif //_USB2422_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_atmel.h b/tmk_core/protocol/arm_atsam/usb/usb_atmel.h
index 7febdc9ece..1cef703788 100644
--- a/tmk_core/protocol/arm_atsam/usb/usb_atmel.h
+++ b/tmk_core/protocol/arm_atsam/usb/usb_atmel.h
@@ -67,118 +67,118 @@
*/
//! \name Vendor Identifier assigned by USB org to ATMEL
-#define USB_VID_ATMEL 0x03EB
+#define USB_VID_ATMEL 0x03EB
//! \name Product Identifier assigned by ATMEL to AVR applications
//! @{
//! \name The range from 2000h to 20FFh is reserved to the old PID for C51, MEGA, and others.
//! @{
-#define USB_PID_ATMEL_MEGA_HIDGENERIC 0x2013
-#define USB_PID_ATMEL_MEGA_HIDKEYBOARD 0x2017
-#define USB_PID_ATMEL_MEGA_CDC 0x2018
-#define USB_PID_ATMEL_MEGA_AUDIO_IN 0x2019
-#define USB_PID_ATMEL_MEGA_MS 0x201A
-#define USB_PID_ATMEL_MEGA_AUDIO_IN_OUT 0x201B
-#define USB_PID_ATMEL_MEGA_HIDMOUSE 0x201C
-#define USB_PID_ATMEL_MEGA_HIDMOUSE_CERTIF_U4 0x201D
-#define USB_PID_ATMEL_MEGA_CDC_MULTI 0x201E
-#define USB_PID_ATMEL_MEGA_MS_HIDMS_HID_USBKEY 0x2022
-#define USB_PID_ATMEL_MEGA_MS_HIDMS_HID_STK525 0x2023
-#define USB_PID_ATMEL_MEGA_MS_2 0x2029
-#define USB_PID_ATMEL_MEGA_MS_HIDMS 0x202A
-#define USB_PID_ATMEL_MEGA_MS_3 0x2032
-#define USB_PID_ATMEL_MEGA_LIBUSB 0x2050
+#define USB_PID_ATMEL_MEGA_HIDGENERIC 0x2013
+#define USB_PID_ATMEL_MEGA_HIDKEYBOARD 0x2017
+#define USB_PID_ATMEL_MEGA_CDC 0x2018
+#define USB_PID_ATMEL_MEGA_AUDIO_IN 0x2019
+#define USB_PID_ATMEL_MEGA_MS 0x201A
+#define USB_PID_ATMEL_MEGA_AUDIO_IN_OUT 0x201B
+#define USB_PID_ATMEL_MEGA_HIDMOUSE 0x201C
+#define USB_PID_ATMEL_MEGA_HIDMOUSE_CERTIF_U4 0x201D
+#define USB_PID_ATMEL_MEGA_CDC_MULTI 0x201E
+#define USB_PID_ATMEL_MEGA_MS_HIDMS_HID_USBKEY 0x2022
+#define USB_PID_ATMEL_MEGA_MS_HIDMS_HID_STK525 0x2023
+#define USB_PID_ATMEL_MEGA_MS_2 0x2029
+#define USB_PID_ATMEL_MEGA_MS_HIDMS 0x202A
+#define USB_PID_ATMEL_MEGA_MS_3 0x2032
+#define USB_PID_ATMEL_MEGA_LIBUSB 0x2050
//! @}
//! \name The range 2100h to 21FFh is reserved to PIDs for AVR Tools.
//! @{
-#define USB_PID_ATMEL_XPLAINED 0x2122
-#define USB_PID_ATMEL_XMEGA_USB_ZIGBIT_2_4GHZ 0x214A
-#define USB_PID_ATMEL_XMEGA_USB_ZIGBIT_SUBGHZ 0x214B
+#define USB_PID_ATMEL_XPLAINED 0x2122
+#define USB_PID_ATMEL_XMEGA_USB_ZIGBIT_2_4GHZ 0x214A
+#define USB_PID_ATMEL_XMEGA_USB_ZIGBIT_SUBGHZ 0x214B
//! @}
//! \name The range 2300h to 23FFh is reserved to PIDs for demo from ASF1.7=>
//! @{
-#define USB_PID_ATMEL_UC3_ENUM 0x2300
-#define USB_PID_ATMEL_UC3_MS 0x2301
-#define USB_PID_ATMEL_UC3_MS_SDRAM_LOADER 0x2302
-#define USB_PID_ATMEL_UC3_EVK1100_CTRLPANEL 0x2303
-#define USB_PID_ATMEL_UC3_HID 0x2304
-#define USB_PID_ATMEL_UC3_EVK1101_CTRLPANEL_HID 0x2305
-#define USB_PID_ATMEL_UC3_EVK1101_CTRLPANEL_HID_MS 0x2306
-#define USB_PID_ATMEL_UC3_CDC 0x2307
-#define USB_PID_ATMEL_UC3_AUDIO_MICRO 0x2308
-#define USB_PID_ATMEL_UC3_CDC_DEBUG 0x2310 // Virtual Com (debug interface) on EVK11xx
-#define USB_PID_ATMEL_UC3_AUDIO_SPEAKER_MICRO 0x2311
-#define USB_PID_ATMEL_UC3_CDC_MSC 0x2312
+#define USB_PID_ATMEL_UC3_ENUM 0x2300
+#define USB_PID_ATMEL_UC3_MS 0x2301
+#define USB_PID_ATMEL_UC3_MS_SDRAM_LOADER 0x2302
+#define USB_PID_ATMEL_UC3_EVK1100_CTRLPANEL 0x2303
+#define USB_PID_ATMEL_UC3_HID 0x2304
+#define USB_PID_ATMEL_UC3_EVK1101_CTRLPANEL_HID 0x2305
+#define USB_PID_ATMEL_UC3_EVK1101_CTRLPANEL_HID_MS 0x2306
+#define USB_PID_ATMEL_UC3_CDC 0x2307
+#define USB_PID_ATMEL_UC3_AUDIO_MICRO 0x2308
+#define USB_PID_ATMEL_UC3_CDC_DEBUG 0x2310 // Virtual Com (debug interface) on EVK11xx
+#define USB_PID_ATMEL_UC3_AUDIO_SPEAKER_MICRO 0x2311
+#define USB_PID_ATMEL_UC3_CDC_MSC 0x2312
//! @}
//! \name The range 2400h to 24FFh is reserved to PIDs for ASF applications
//! @{
-#define USB_PID_ATMEL_ASF_HIDMOUSE 0x2400
-#define USB_PID_ATMEL_ASF_HIDKEYBOARD 0x2401
-#define USB_PID_ATMEL_ASF_HIDGENERIC 0x2402
-#define USB_PID_ATMEL_ASF_MSC 0x2403
-#define USB_PID_ATMEL_ASF_CDC 0x2404
-#define USB_PID_ATMEL_ASF_PHDC 0x2405
-#define USB_PID_ATMEL_ASF_HIDMTOUCH 0x2406
-#define USB_PID_ATMEL_ASF_MSC_HIDMOUSE 0x2420
-#define USB_PID_ATMEL_ASF_MSC_HIDS_CDC 0x2421
-#define USB_PID_ATMEL_ASF_MSC_HIDKEYBOARD 0x2422
-#define USB_PID_ATMEL_ASF_VENDOR_CLASS 0x2423
-#define USB_PID_ATMEL_ASF_MSC_CDC 0x2424
-#define USB_PID_ATMEL_ASF_TWO_CDC 0x2425
-#define USB_PID_ATMEL_ASF_SEVEN_CDC 0x2426
-#define USB_PID_ATMEL_ASF_XPLAIN_BC_POWERONLY 0x2430
-#define USB_PID_ATMEL_ASF_XPLAIN_BC_TERMINAL 0x2431
-#define USB_PID_ATMEL_ASF_XPLAIN_BC_TOUCH 0x2432
-#define USB_PID_ATMEL_ASF_AUDIO_SPEAKER 0x2433
-#define USB_PID_ATMEL_ASF_XMEGA_B1_XPLAINED 0x2434
+#define USB_PID_ATMEL_ASF_HIDMOUSE 0x2400
+#define USB_PID_ATMEL_ASF_HIDKEYBOARD 0x2401
+#define USB_PID_ATMEL_ASF_HIDGENERIC 0x2402
+#define USB_PID_ATMEL_ASF_MSC 0x2403
+#define USB_PID_ATMEL_ASF_CDC 0x2404
+#define USB_PID_ATMEL_ASF_PHDC 0x2405
+#define USB_PID_ATMEL_ASF_HIDMTOUCH 0x2406
+#define USB_PID_ATMEL_ASF_MSC_HIDMOUSE 0x2420
+#define USB_PID_ATMEL_ASF_MSC_HIDS_CDC 0x2421
+#define USB_PID_ATMEL_ASF_MSC_HIDKEYBOARD 0x2422
+#define USB_PID_ATMEL_ASF_VENDOR_CLASS 0x2423
+#define USB_PID_ATMEL_ASF_MSC_CDC 0x2424
+#define USB_PID_ATMEL_ASF_TWO_CDC 0x2425
+#define USB_PID_ATMEL_ASF_SEVEN_CDC 0x2426
+#define USB_PID_ATMEL_ASF_XPLAIN_BC_POWERONLY 0x2430
+#define USB_PID_ATMEL_ASF_XPLAIN_BC_TERMINAL 0x2431
+#define USB_PID_ATMEL_ASF_XPLAIN_BC_TOUCH 0x2432
+#define USB_PID_ATMEL_ASF_AUDIO_SPEAKER 0x2433
+#define USB_PID_ATMEL_ASF_XMEGA_B1_XPLAINED 0x2434
//! @}
//! \name The range 2F00h to 2FFFh is reserved to official PIDs for AVR bootloaders
//! Note, !!!! don't use this range for demos or examples !!!!
//! @{
-#define USB_PID_ATMEL_DFU_ATXMEGA64C3 0x2FD6
-#define USB_PID_ATMEL_DFU_ATXMEGA128C3 0x2FD7
-#define USB_PID_ATMEL_DFU_ATXMEGA16C4 0x2FD8
-#define USB_PID_ATMEL_DFU_ATXMEGA32C4 0x2FD9
-#define USB_PID_ATMEL_DFU_ATXMEGA256C3 0x2FDA
-#define USB_PID_ATMEL_DFU_ATXMEGA384C3 0x2FDB
-#define USB_PID_ATMEL_DFU_ATUCL3_L4 0x2FDC
-#define USB_PID_ATMEL_DFU_ATXMEGA64A4U 0x2FDD
-#define USB_PID_ATMEL_DFU_ATXMEGA128A4U 0x2FDE
-
-#define USB_PID_ATMEL_DFU_ATXMEGA64B3 0x2FDF
-#define USB_PID_ATMEL_DFU_ATXMEGA128B3 0x2FE0
-#define USB_PID_ATMEL_DFU_ATXMEGA64B1 0x2FE1
-#define USB_PID_ATMEL_DFU_ATXMEGA256A3BU 0x2FE2
-#define USB_PID_ATMEL_DFU_ATXMEGA16A4U 0x2FE3
-#define USB_PID_ATMEL_DFU_ATXMEGA32A4U 0x2FE4
-#define USB_PID_ATMEL_DFU_ATXMEGA64A3U 0x2FE5
-#define USB_PID_ATMEL_DFU_ATXMEGA128A3U 0x2FE6
-#define USB_PID_ATMEL_DFU_ATXMEGA192A3U 0x2FE7
-#define USB_PID_ATMEL_DFU_ATXMEGA64A1U 0x2FE8
-#define USB_PID_ATMEL_DFU_ATUC3D 0x2FE9
-#define USB_PID_ATMEL_DFU_ATXMEGA128B1 0x2FEA
-#define USB_PID_ATMEL_DFU_AT32UC3C 0x2FEB
-#define USB_PID_ATMEL_DFU_ATXMEGA256A3U 0x2FEC
-#define USB_PID_ATMEL_DFU_ATXMEGA128A1U 0x2FED
-#define USB_PID_ATMEL_DFU_ATMEGA8U2 0x2FEE
-#define USB_PID_ATMEL_DFU_ATMEGA16U2 0x2FEF
-#define USB_PID_ATMEL_DFU_ATMEGA32U2 0x2FF0
-#define USB_PID_ATMEL_DFU_AT32UC3A3 0x2FF1
-#define USB_PID_ATMEL_DFU_ATMEGA32U6 0x2FF2
-#define USB_PID_ATMEL_DFU_ATMEGA16U4 0x2FF3
-#define USB_PID_ATMEL_DFU_ATMEGA32U4 0x2FF4
-#define USB_PID_ATMEL_DFU_AT32AP7200 0x2FF5
-#define USB_PID_ATMEL_DFU_AT32UC3B 0x2FF6
-#define USB_PID_ATMEL_DFU_AT90USB82 0x2FF7
-#define USB_PID_ATMEL_DFU_AT32UC3A 0x2FF8
-#define USB_PID_ATMEL_DFU_AT90USB64 0x2FF9
-#define USB_PID_ATMEL_DFU_AT90USB162 0x2FFA
-#define USB_PID_ATMEL_DFU_AT90USB128 0x2FFB
+#define USB_PID_ATMEL_DFU_ATXMEGA64C3 0x2FD6
+#define USB_PID_ATMEL_DFU_ATXMEGA128C3 0x2FD7
+#define USB_PID_ATMEL_DFU_ATXMEGA16C4 0x2FD8
+#define USB_PID_ATMEL_DFU_ATXMEGA32C4 0x2FD9
+#define USB_PID_ATMEL_DFU_ATXMEGA256C3 0x2FDA
+#define USB_PID_ATMEL_DFU_ATXMEGA384C3 0x2FDB
+#define USB_PID_ATMEL_DFU_ATUCL3_L4 0x2FDC
+#define USB_PID_ATMEL_DFU_ATXMEGA64A4U 0x2FDD
+#define USB_PID_ATMEL_DFU_ATXMEGA128A4U 0x2FDE
+
+#define USB_PID_ATMEL_DFU_ATXMEGA64B3 0x2FDF
+#define USB_PID_ATMEL_DFU_ATXMEGA128B3 0x2FE0
+#define USB_PID_ATMEL_DFU_ATXMEGA64B1 0x2FE1
+#define USB_PID_ATMEL_DFU_ATXMEGA256A3BU 0x2FE2
+#define USB_PID_ATMEL_DFU_ATXMEGA16A4U 0x2FE3
+#define USB_PID_ATMEL_DFU_ATXMEGA32A4U 0x2FE4
+#define USB_PID_ATMEL_DFU_ATXMEGA64A3U 0x2FE5
+#define USB_PID_ATMEL_DFU_ATXMEGA128A3U 0x2FE6
+#define USB_PID_ATMEL_DFU_ATXMEGA192A3U 0x2FE7
+#define USB_PID_ATMEL_DFU_ATXMEGA64A1U 0x2FE8
+#define USB_PID_ATMEL_DFU_ATUC3D 0x2FE9
+#define USB_PID_ATMEL_DFU_ATXMEGA128B1 0x2FEA
+#define USB_PID_ATMEL_DFU_AT32UC3C 0x2FEB
+#define USB_PID_ATMEL_DFU_ATXMEGA256A3U 0x2FEC
+#define USB_PID_ATMEL_DFU_ATXMEGA128A1U 0x2FED
+#define USB_PID_ATMEL_DFU_ATMEGA8U2 0x2FEE
+#define USB_PID_ATMEL_DFU_ATMEGA16U2 0x2FEF
+#define USB_PID_ATMEL_DFU_ATMEGA32U2 0x2FF0
+#define USB_PID_ATMEL_DFU_AT32UC3A3 0x2FF1
+#define USB_PID_ATMEL_DFU_ATMEGA32U6 0x2FF2
+#define USB_PID_ATMEL_DFU_ATMEGA16U4 0x2FF3
+#define USB_PID_ATMEL_DFU_ATMEGA32U4 0x2FF4
+#define USB_PID_ATMEL_DFU_AT32AP7200 0x2FF5
+#define USB_PID_ATMEL_DFU_AT32UC3B 0x2FF6
+#define USB_PID_ATMEL_DFU_AT90USB82 0x2FF7
+#define USB_PID_ATMEL_DFU_AT32UC3A 0x2FF8
+#define USB_PID_ATMEL_DFU_AT90USB64 0x2FF9
+#define USB_PID_ATMEL_DFU_AT90USB162 0x2FFA
+#define USB_PID_ATMEL_DFU_AT90USB128 0x2FFB
// 2FFCh to 2FFFh used by C51 family products
//! @}
@@ -186,5 +186,4 @@
//! @}
-
-#endif // _USB_ATMEL_H_
+#endif // _USB_ATMEL_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_device_udd.c b/tmk_core/protocol/arm_atsam/usb/usb_device_udd.c
index b31256df7c..f138b42786 100644
--- a/tmk_core/protocol/arm_atsam/usb/usb_device_udd.c
+++ b/tmk_core/protocol/arm_atsam/usb/usb_device_udd.c
@@ -61,30 +61,30 @@
*/
// Check USB device configuration
#ifdef USB_DEVICE_HS_SUPPORT
-# error The High speed mode is not supported on this part, please remove USB_DEVICE_HS_SUPPORT in conf_usb.h
+# error The High speed mode is not supported on this part, please remove USB_DEVICE_HS_SUPPORT in conf_usb.h
#endif
-//Note: This driver is adapted for SAMD51
+// Note: This driver is adapted for SAMD51
#ifndef UDC_REMOTEWAKEUP_LPM_ENABLE
-#define UDC_REMOTEWAKEUP_LPM_ENABLE()
+# define UDC_REMOTEWAKEUP_LPM_ENABLE()
#endif
#ifndef UDC_REMOTEWAKEUP_LPM_DISABLE
-#define UDC_REMOTEWAKEUP_LPM_DISABLE()
+# define UDC_REMOTEWAKEUP_LPM_DISABLE()
#endif
#ifndef UDC_SUSPEND_LPM_EVENT
-#define UDC_SUSPEND_LPM_EVENT()
+# define UDC_SUSPEND_LPM_EVENT()
#endif
/* for debug text */
#ifdef USB_DEBUG
-# define dbg_print printf
+# define dbg_print printf
#else
-# define dbg_print(...)
+# define dbg_print(...)
#endif
/** Maximum size of a transfer in multi-packet mode */
-#define UDD_ENDPOINT_MAX_TRANS ((8*1024)-1)
+#define UDD_ENDPOINT_MAX_TRANS ((8 * 1024) - 1)
/** USB software device instance structure */
struct usb_module usb_device;
@@ -97,10 +97,7 @@ struct usb_module usb_device;
#define UDD_CLOCK_GEN 0
-static inline void udd_wait_clock_ready(void)
-{
-
-}
+static inline void udd_wait_clock_ready(void) {}
/**
* \name Power management
@@ -130,12 +127,12 @@ uint8_t udd_ctrl_buffer[USB_DEVICE_EP_CTRL_SIZE];
/** Bit definitions about endpoint control state machine for udd_ep_control_state */
typedef enum {
- UDD_EPCTRL_SETUP = 0, //!< Wait a SETUP packet
- UDD_EPCTRL_DATA_OUT = 1, //!< Wait a OUT data packet
- UDD_EPCTRL_DATA_IN = 2, //!< Wait a IN data packet
- UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP = 3, //!< Wait a IN ZLP packet
- UDD_EPCTRL_HANDSHAKE_WAIT_OUT_ZLP = 4, //!< Wait a OUT ZLP packet
- UDD_EPCTRL_STALL_REQ = 5, //!< STALL enabled on IN & OUT packet
+ UDD_EPCTRL_SETUP = 0, //!< Wait a SETUP packet
+ UDD_EPCTRL_DATA_OUT = 1, //!< Wait a OUT data packet
+ UDD_EPCTRL_DATA_IN = 2, //!< Wait a IN data packet
+ UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP = 3, //!< Wait a IN ZLP packet
+ UDD_EPCTRL_HANDSHAKE_WAIT_OUT_ZLP = 4, //!< Wait a OUT ZLP packet
+ UDD_EPCTRL_STALL_REQ = 5, //!< STALL enabled on IN & OUT packet
} udd_ctrl_ep_state_t;
/** Global variable to give and record information of the set up request management */
@@ -200,11 +197,11 @@ typedef struct {
//! Endpoint size
uint16_t ep_size;
//! A job is registered on this endpoint
- uint8_t busy:1;
+ uint8_t busy : 1;
//! A short packet is requested for this job on endpoint IN
- uint8_t b_shortpacket:1;
+ uint8_t b_shortpacket : 1;
//! The cache buffer is currently used on endpoint OUT
- uint8_t b_use_out_cache_buffer:1;
+ uint8_t b_use_out_cache_buffer : 1;
} udd_ep_job_t;
/** Array to register a job on bulk/interrupt/isochronous endpoint */
@@ -217,8 +214,7 @@ static udd_ep_job_t udd_ep_job[2 * USB_DEVICE_MAX_EP];
* \param[in] ep Endpoint Address
* \retval pointer to an udd_ep_job_t structure instance
*/
-static udd_ep_job_t* udd_ep_get_job(udd_ep_id_t ep)
-{
+static udd_ep_job_t *udd_ep_get_job(udd_ep_id_t ep) {
if ((ep == 0) || (ep == 0x80)) {
return NULL;
} else {
@@ -230,17 +226,16 @@ static udd_ep_job_t* udd_ep_get_job(udd_ep_id_t ep)
* \brief Endpoint IN process, continue to send packets or zero length packet
* \param[in] pointer Pointer to the endpoint transfer status parameter struct from driver layer.
*/
-static void udd_ep_trans_in_next(void* pointer)
-{
- struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter*)pointer;
- udd_ep_id_t ep = ep_callback_para->endpoint_address;
- uint16_t ep_size, nb_trans;
- uint16_t next_trans;
- udd_ep_id_t ep_num;
- udd_ep_job_t *ptr_job;
+static void udd_ep_trans_in_next(void *pointer) {
+ struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter *)pointer;
+ udd_ep_id_t ep = ep_callback_para->endpoint_address;
+ uint16_t ep_size, nb_trans;
+ uint16_t next_trans;
+ udd_ep_id_t ep_num;
+ udd_ep_job_t * ptr_job;
ptr_job = udd_ep_get_job(ep);
- ep_num = ep & USB_EP_ADDR_MASK;
+ ep_num = ep & USB_EP_ADDR_MASK;
ep_size = ptr_job->ep_size;
/* Update number of data transferred */
@@ -251,13 +246,13 @@ static void udd_ep_trans_in_next(void* pointer)
if (ptr_job->nb_trans != ptr_job->buf_size) {
next_trans = ptr_job->buf_size - ptr_job->nb_trans;
if (UDD_ENDPOINT_MAX_TRANS < next_trans) {
- /* The USB hardware support a maximum
- * transfer size of UDD_ENDPOINT_MAX_TRANS Bytes */
- next_trans = UDD_ENDPOINT_MAX_TRANS -(UDD_ENDPOINT_MAX_TRANS % ep_size);
+ /* The USB hardware support a maximum
+ * transfer size of UDD_ENDPOINT_MAX_TRANS Bytes */
+ next_trans = UDD_ENDPOINT_MAX_TRANS - (UDD_ENDPOINT_MAX_TRANS % ep_size);
}
/* Need ZLP, if requested and last packet is not a short packet */
ptr_job->b_shortpacket = ptr_job->b_shortpacket && (0 == (next_trans % ep_size));
- usb_device_endpoint_write_buffer_job(&usb_device,ep_num,&ptr_job->buf[ptr_job->nb_trans],next_trans);
+ usb_device_endpoint_write_buffer_job(&usb_device, ep_num, &ptr_job->buf[ptr_job->nb_trans], next_trans);
return;
}
@@ -265,7 +260,7 @@ static void udd_ep_trans_in_next(void* pointer)
if (ptr_job->b_shortpacket) {
ptr_job->b_shortpacket = false;
/* Start new transfer */
- usb_device_endpoint_write_buffer_job(&usb_device,ep_num,&ptr_job->buf[ptr_job->nb_trans],0);
+ usb_device_endpoint_write_buffer_job(&usb_device, ep_num, &ptr_job->buf[ptr_job->nb_trans], 0);
return;
}
@@ -280,17 +275,16 @@ static void udd_ep_trans_in_next(void* pointer)
* \brief Endpoint OUT process, continue to receive packets or zero length packet
* \param[in] pointer Pointer to the endpoint transfer status parameter struct from driver layer.
*/
-static void udd_ep_trans_out_next(void* pointer)
-{
- struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter*)pointer;
- udd_ep_id_t ep = ep_callback_para->endpoint_address;
- uint16_t ep_size, nb_trans;
- uint16_t next_trans;
- udd_ep_id_t ep_num;
- udd_ep_job_t *ptr_job;
+static void udd_ep_trans_out_next(void *pointer) {
+ struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter *)pointer;
+ udd_ep_id_t ep = ep_callback_para->endpoint_address;
+ uint16_t ep_size, nb_trans;
+ uint16_t next_trans;
+ udd_ep_id_t ep_num;
+ udd_ep_job_t * ptr_job;
ptr_job = udd_ep_get_job(ep);
- ep_num = ep & USB_EP_ADDR_MASK;
+ ep_num = ep & USB_EP_ADDR_MASK;
ep_size = ptr_job->ep_size;
/* Update number of data transferred */
@@ -312,9 +306,9 @@ static void udd_ep_trans_out_next(void* pointer)
if ((nb_trans == ep_callback_para->out_buffer_size) && (ptr_job->nb_trans != ptr_job->buf_size)) {
next_trans = ptr_job->buf_size - ptr_job->nb_trans;
if (UDD_ENDPOINT_MAX_TRANS < next_trans) {
- /* The USB hardware support a maximum transfer size
- * of UDD_ENDPOINT_MAX_TRANS Bytes */
- next_trans = UDD_ENDPOINT_MAX_TRANS - (UDD_ENDPOINT_MAX_TRANS % ep_size);
+ /* The USB hardware support a maximum transfer size
+ * of UDD_ENDPOINT_MAX_TRANS Bytes */
+ next_trans = UDD_ENDPOINT_MAX_TRANS - (UDD_ENDPOINT_MAX_TRANS % ep_size);
} else {
next_trans -= next_trans % ep_size;
}
@@ -322,9 +316,9 @@ static void udd_ep_trans_out_next(void* pointer)
if (next_trans < ep_size) {
/* Use the cache buffer for Bulk or Interrupt size endpoint */
ptr_job->b_use_out_cache_buffer = true;
- usb_device_endpoint_read_buffer_job(&usb_device,ep_num,udd_ep_out_cache_buffer[ep_num - 1],ep_size);
+ usb_device_endpoint_read_buffer_job(&usb_device, ep_num, udd_ep_out_cache_buffer[ep_num - 1], ep_size);
} else {
- usb_device_endpoint_read_buffer_job(&usb_device,ep_num,&ptr_job->buf[ptr_job->nb_trans],next_trans);
+ usb_device_endpoint_read_buffer_job(&usb_device, ep_num, &ptr_job->buf[ptr_job->nb_trans], next_trans);
}
return;
}
@@ -341,10 +335,9 @@ static void udd_ep_trans_out_next(void* pointer)
* \param[in] module_inst Pointer to USB module instance
* \param[in] pointer Pointer to the endpoint transfer status parameter struct from driver layer.
*/
-static void udd_ep_transfer_process(struct usb_module *module_inst, void* pointer)
-{
- struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter*)pointer;
- udd_ep_id_t ep = ep_callback_para->endpoint_address;
+static void udd_ep_transfer_process(struct usb_module *module_inst, void *pointer) {
+ struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter *)pointer;
+ udd_ep_id_t ep = ep_callback_para->endpoint_address;
if (ep & USB_EP_DIR_IN) {
udd_ep_trans_in_next(pointer);
@@ -353,8 +346,7 @@ static void udd_ep_transfer_process(struct usb_module *module_inst, void* pointe
}
}
-void udd_ep_abort(udd_ep_id_t ep)
-{
+void udd_ep_abort(udd_ep_id_t ep) {
udd_ep_job_t *ptr_job;
usb_device_endpoint_abort_job(&usb_device, ep);
@@ -371,23 +363,13 @@ void udd_ep_abort(udd_ep_id_t ep)
}
}
-bool udd_is_high_speed(void)
-{
- return false;
-}
+bool udd_is_high_speed(void) { return false; }
-uint16_t udd_get_frame_number(void)
-{
- return usb_device_get_frame_number(&usb_device);
-}
+uint16_t udd_get_frame_number(void) { return usb_device_get_frame_number(&usb_device); }
-uint16_t udd_get_micro_frame_number(void)
-{
- return usb_device_get_micro_frame_number(&usb_device);
-}
+uint16_t udd_get_micro_frame_number(void) { return usb_device_get_micro_frame_number(&usb_device); }
-void udd_ep_free(udd_ep_id_t ep)
-{
+void udd_ep_free(udd_ep_id_t ep) {
struct usb_device_endpoint_config config_ep;
usb_device_endpoint_get_config_defaults(&config_ep);
@@ -395,45 +377,44 @@ void udd_ep_free(udd_ep_id_t ep)
udd_ep_abort(ep);
config_ep.ep_address = ep;
- config_ep.ep_type = USB_DEVICE_ENDPOINT_TYPE_DISABLE;
+ config_ep.ep_type = USB_DEVICE_ENDPOINT_TYPE_DISABLE;
usb_device_endpoint_set_config(&usb_device, &config_ep);
- usb_device_endpoint_unregister_callback(&usb_device,ep_num,USB_DEVICE_ENDPOINT_CALLBACK_TRCPT);
- usb_device_endpoint_disable_callback(&usb_device,ep,USB_DEVICE_ENDPOINT_CALLBACK_TRCPT);
+ usb_device_endpoint_unregister_callback(&usb_device, ep_num, USB_DEVICE_ENDPOINT_CALLBACK_TRCPT);
+ usb_device_endpoint_disable_callback(&usb_device, ep, USB_DEVICE_ENDPOINT_CALLBACK_TRCPT);
}
-bool udd_ep_alloc(udd_ep_id_t ep, uint8_t bmAttributes, uint16_t MaxEndpointSize)
-{
+bool udd_ep_alloc(udd_ep_id_t ep, uint8_t bmAttributes, uint16_t MaxEndpointSize) {
struct usb_device_endpoint_config config_ep;
usb_device_endpoint_get_config_defaults(&config_ep);
config_ep.ep_address = ep;
- if(MaxEndpointSize <= 8) {
+ if (MaxEndpointSize <= 8) {
config_ep.ep_size = USB_ENDPOINT_8_BYTE;
- } else if(MaxEndpointSize <= 16) {
+ } else if (MaxEndpointSize <= 16) {
config_ep.ep_size = USB_ENDPOINT_16_BYTE;
- } else if(MaxEndpointSize <= 32) {
+ } else if (MaxEndpointSize <= 32) {
config_ep.ep_size = USB_ENDPOINT_32_BYTE;
- } else if(MaxEndpointSize <= 64) {
+ } else if (MaxEndpointSize <= 64) {
config_ep.ep_size = USB_ENDPOINT_64_BYTE;
- } else if(MaxEndpointSize <= 128) {
+ } else if (MaxEndpointSize <= 128) {
config_ep.ep_size = USB_ENDPOINT_128_BYTE;
- } else if(MaxEndpointSize <= 256) {
+ } else if (MaxEndpointSize <= 256) {
config_ep.ep_size = USB_ENDPOINT_256_BYTE;
- } else if(MaxEndpointSize <= 512) {
+ } else if (MaxEndpointSize <= 512) {
config_ep.ep_size = USB_ENDPOINT_512_BYTE;
- } else if(MaxEndpointSize <= 1023) {
+ } else if (MaxEndpointSize <= 1023) {
config_ep.ep_size = USB_ENDPOINT_1023_BYTE;
} else {
return false;
}
udd_ep_job_t *ptr_job = udd_ep_get_job(ep);
- ptr_job->ep_size = MaxEndpointSize;
+ ptr_job->ep_size = MaxEndpointSize;
bmAttributes = bmAttributes & USB_EP_TYPE_MASK;
/* Check endpoint type */
- if(USB_EP_TYPE_ISOCHRONOUS == bmAttributes) {
+ if (USB_EP_TYPE_ISOCHRONOUS == bmAttributes) {
config_ep.ep_type = USB_DEVICE_ENDPOINT_TYPE_ISOCHRONOUS;
} else if (USB_EP_TYPE_BULK == bmAttributes) {
config_ep.ep_type = USB_DEVICE_ENDPOINT_TYPE_BULK;
@@ -448,20 +429,16 @@ bool udd_ep_alloc(udd_ep_id_t ep, uint8_t bmAttributes, uint16_t MaxEndpointSize
if (STATUS_OK != usb_device_endpoint_set_config(&usb_device, &config_ep)) {
return false;
}
- usb_device_endpoint_register_callback(&usb_device,ep_num,USB_DEVICE_ENDPOINT_CALLBACK_TRCPT,udd_ep_transfer_process);
- usb_device_endpoint_enable_callback(&usb_device,ep,USB_DEVICE_ENDPOINT_CALLBACK_TRCPT);
- usb_device_endpoint_enable_callback(&usb_device,ep,USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL);
+ usb_device_endpoint_register_callback(&usb_device, ep_num, USB_DEVICE_ENDPOINT_CALLBACK_TRCPT, udd_ep_transfer_process);
+ usb_device_endpoint_enable_callback(&usb_device, ep, USB_DEVICE_ENDPOINT_CALLBACK_TRCPT);
+ usb_device_endpoint_enable_callback(&usb_device, ep, USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL);
return true;
}
-bool udd_ep_is_halted(udd_ep_id_t ep)
-{
- return usb_device_endpoint_is_halted(&usb_device, ep);
-}
+bool udd_ep_is_halted(udd_ep_id_t ep) { return usb_device_endpoint_is_halted(&usb_device, ep); }
-bool udd_ep_set_halt(udd_ep_id_t ep)
-{
+bool udd_ep_set_halt(udd_ep_id_t ep) {
uint8_t ep_num = ep & USB_EP_ADDR_MASK;
if (USB_DEVICE_MAX_EP < ep_num) {
@@ -474,10 +451,9 @@ bool udd_ep_set_halt(udd_ep_id_t ep)
return true;
}
-bool udd_ep_clear_halt(udd_ep_id_t ep)
-{
+bool udd_ep_clear_halt(udd_ep_id_t ep) {
udd_ep_job_t *ptr_job;
- uint8_t ep_num = ep & USB_EP_ADDR_MASK;
+ uint8_t ep_num = ep & USB_EP_ADDR_MASK;
if (USB_DEVICE_MAX_EP < ep_num) {
return false;
@@ -495,9 +471,8 @@ bool udd_ep_clear_halt(udd_ep_id_t ep)
return true;
}
-bool udd_ep_wait_stall_clear(udd_ep_id_t ep, udd_callback_halt_cleared_t callback)
-{
- udd_ep_id_t ep_num;
+bool udd_ep_wait_stall_clear(udd_ep_id_t ep, udd_callback_halt_cleared_t callback) {
+ udd_ep_id_t ep_num;
udd_ep_job_t *ptr_job;
ep_num = ep & USB_EP_ADDR_MASK;
@@ -513,7 +488,7 @@ bool udd_ep_wait_stall_clear(udd_ep_id_t ep, udd_callback_halt_cleared_t callbac
/* Wait clear halt endpoint */
if (usb_device_endpoint_is_halted(&usb_device, ep)) {
/* Endpoint halted then registers the callback */
- ptr_job->busy = true;
+ ptr_job->busy = true;
ptr_job->call_nohalt = callback;
return true;
} else if (usb_device_endpoint_is_configured(&usb_device, ep)) {
@@ -527,19 +502,17 @@ bool udd_ep_wait_stall_clear(udd_ep_id_t ep, udd_callback_halt_cleared_t callbac
/**
* \brief Control Endpoint stall sending data
*/
-static void udd_ctrl_stall_data(void)
-{
+static void udd_ctrl_stall_data(void) {
udd_ep_control_state = UDD_EPCTRL_STALL_REQ;
usb_device_endpoint_set_halt(&usb_device, USB_EP_DIR_IN);
usb_device_endpoint_clear_halt(&usb_device, USB_EP_DIR_OUT);
}
-bool udd_ep_run(udd_ep_id_t ep, bool b_shortpacket, uint8_t *buf, iram_size_t buf_size, udd_callback_trans_t callback)
-{
- udd_ep_id_t ep_num;
+bool udd_ep_run(udd_ep_id_t ep, bool b_shortpacket, uint8_t *buf, iram_size_t buf_size, udd_callback_trans_t callback) {
+ udd_ep_id_t ep_num;
udd_ep_job_t *ptr_job;
- uint32_t irqflags;
+ uint32_t irqflags;
ep_num = ep & USB_EP_ADDR_MASK;
@@ -564,11 +537,11 @@ bool udd_ep_run(udd_ep_id_t ep, bool b_shortpacket, uint8_t *buf, iram_size_t bu
__set_PRIMASK(irqflags);
/* No job running, set up a new one */
- ptr_job->buf = buf;
- ptr_job->buf_size = buf_size;
- ptr_job->nb_trans = 0;
- ptr_job->call_trans = callback;
- ptr_job->b_shortpacket = b_shortpacket;
+ ptr_job->buf = buf;
+ ptr_job->buf_size = buf_size;
+ ptr_job->nb_trans = 0;
+ ptr_job->call_trans = callback;
+ ptr_job->b_shortpacket = b_shortpacket;
ptr_job->b_use_out_cache_buffer = false;
/* Initialize value to simulate a empty transfer */
@@ -580,10 +553,10 @@ bool udd_ep_run(udd_ep_id_t ep, bool b_shortpacket, uint8_t *buf, iram_size_t bu
if (UDD_ENDPOINT_MAX_TRANS < next_trans) {
next_trans = UDD_ENDPOINT_MAX_TRANS - (UDD_ENDPOINT_MAX_TRANS % ptr_job->ep_size);
}
- ptr_job->b_shortpacket = ptr_job->b_shortpacket && (0 == (next_trans % ptr_job->ep_size));
+ ptr_job->b_shortpacket = ptr_job->b_shortpacket && (0 == (next_trans % ptr_job->ep_size));
} else if (true == ptr_job->b_shortpacket) {
ptr_job->b_shortpacket = false; /* avoid to send zero length packet again */
- next_trans = 0;
+ next_trans = 0;
} else {
ptr_job->busy = false;
if (NULL != ptr_job->call_trans) {
@@ -591,30 +564,22 @@ bool udd_ep_run(udd_ep_id_t ep, bool b_shortpacket, uint8_t *buf, iram_size_t bu
}
return true;
}
- return (STATUS_OK ==
- usb_device_endpoint_write_buffer_job(&usb_device,
- ep_num,&ptr_job->buf[0],next_trans));
+ return (STATUS_OK == usb_device_endpoint_write_buffer_job(&usb_device, ep_num, &ptr_job->buf[0], next_trans));
} else {
if (0 != ptr_job->buf_size) {
next_trans = ptr_job->buf_size;
if (UDD_ENDPOINT_MAX_TRANS < next_trans) {
/* The USB hardware support a maximum transfer size
* of UDD_ENDPOINT_MAX_TRANS Bytes */
- next_trans = UDD_ENDPOINT_MAX_TRANS -
- (UDD_ENDPOINT_MAX_TRANS % ptr_job->ep_size);
+ next_trans = UDD_ENDPOINT_MAX_TRANS - (UDD_ENDPOINT_MAX_TRANS % ptr_job->ep_size);
} else {
next_trans -= next_trans % ptr_job->ep_size;
}
if (next_trans < ptr_job->ep_size) {
ptr_job->b_use_out_cache_buffer = true;
- return (STATUS_OK ==
- usb_device_endpoint_read_buffer_job(&usb_device, ep_num,
- udd_ep_out_cache_buffer[ep_num - 1],
- ptr_job->ep_size));
+ return (STATUS_OK == usb_device_endpoint_read_buffer_job(&usb_device, ep_num, udd_ep_out_cache_buffer[ep_num - 1], ptr_job->ep_size));
} else {
- return (STATUS_OK ==
- usb_device_endpoint_read_buffer_job(&usb_device, ep_num,
- &ptr_job->buf[0],next_trans));
+ return (STATUS_OK == usb_device_endpoint_read_buffer_job(&usb_device, ep_num, &ptr_job->buf[0], next_trans));
}
} else {
ptr_job->busy = false;
@@ -626,61 +591,51 @@ bool udd_ep_run(udd_ep_id_t ep, bool b_shortpacket, uint8_t *buf, iram_size_t bu
}
}
-void udd_set_address(uint8_t address)
-{
- usb_device_set_address(&usb_device,address);
-}
+void udd_set_address(uint8_t address) { usb_device_set_address(&usb_device, address); }
-uint8_t udd_getaddress(void)
-{
- return usb_device_get_address(&usb_device);
-}
+uint8_t udd_getaddress(void) { return usb_device_get_address(&usb_device); }
-void udd_send_remotewakeup(void)
-{
- uint32_t try = 5;
+void udd_send_remotewakeup(void) {
+ 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);
}
}
-void udd_set_setup_payload( uint8_t *payload, uint16_t payload_size )
-{
- udd_g_ctrlreq.payload = payload;
+void udd_set_setup_payload(uint8_t *payload, uint16_t payload_size) {
+ udd_g_ctrlreq.payload = payload;
udd_g_ctrlreq.payload_size = payload_size;
}
/**
* \brief Control Endpoint translate the data in buffer into Device Request Struct
*/
-static void udd_ctrl_fetch_ram(void)
-{
+static void udd_ctrl_fetch_ram(void) {
udd_g_ctrlreq.req.bmRequestType = udd_ctrl_buffer[0];
- udd_g_ctrlreq.req.bRequest = udd_ctrl_buffer[1];
- udd_g_ctrlreq.req.wValue = ((uint16_t)(udd_ctrl_buffer[3]) << 8) + udd_ctrl_buffer[2];
- udd_g_ctrlreq.req.wIndex = ((uint16_t)(udd_ctrl_buffer[5]) << 8) + udd_ctrl_buffer[4];
- udd_g_ctrlreq.req.wLength = ((uint16_t)(udd_ctrl_buffer[7]) << 8) + udd_ctrl_buffer[6];
+ udd_g_ctrlreq.req.bRequest = udd_ctrl_buffer[1];
+ udd_g_ctrlreq.req.wValue = ((uint16_t)(udd_ctrl_buffer[3]) << 8) + udd_ctrl_buffer[2];
+ udd_g_ctrlreq.req.wIndex = ((uint16_t)(udd_ctrl_buffer[5]) << 8) + udd_ctrl_buffer[4];
+ udd_g_ctrlreq.req.wLength = ((uint16_t)(udd_ctrl_buffer[7]) << 8) + udd_ctrl_buffer[6];
}
/**
* \brief Control Endpoint send out zero length packet
*/
-static void udd_ctrl_send_zlp_in(void)
-{
+static void udd_ctrl_send_zlp_in(void) {
udd_ep_control_state = UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP;
- usb_device_endpoint_setup_buffer_job(&usb_device,udd_ctrl_buffer);
- usb_device_endpoint_write_buffer_job(&usb_device,0,udd_g_ctrlreq.payload,0);
+ usb_device_endpoint_setup_buffer_job(&usb_device, udd_ctrl_buffer);
+ usb_device_endpoint_write_buffer_job(&usb_device, 0, udd_g_ctrlreq.payload, 0);
}
/**
* \brief Process control endpoint IN transaction
*/
-static void udd_ctrl_in_sent(void)
-{
+static void udd_ctrl_in_sent(void) {
static bool b_shortpacket = false;
- uint16_t nb_remain;
+ uint16_t nb_remain;
nb_remain = udd_g_ctrlreq.payload_size - udd_ctrl_payload_nb_trans;
@@ -691,7 +646,7 @@ static void udd_ctrl_in_sent(void)
/* All data requested are transferred or a short packet has been sent, then it is the end of data phase.
* Generate an OUT ZLP for handshake phase */
udd_ep_control_state = UDD_EPCTRL_HANDSHAKE_WAIT_OUT_ZLP;
- usb_device_endpoint_setup_buffer_job(&usb_device,udd_ctrl_buffer);
+ usb_device_endpoint_setup_buffer_job(&usb_device, udd_ctrl_buffer);
return;
}
/* Need of new buffer because the data phase is not complete */
@@ -701,20 +656,20 @@ static void udd_ctrl_in_sent(void)
} else {
/* A new payload buffer is given */
udd_ctrl_payload_nb_trans = 0;
- nb_remain = udd_g_ctrlreq.payload_size;
+ nb_remain = udd_g_ctrlreq.payload_size;
}
}
/* Continue transfer and send next data */
if (nb_remain >= USB_DEVICE_EP_CTRL_SIZE) {
- nb_remain = USB_DEVICE_EP_CTRL_SIZE;
+ nb_remain = USB_DEVICE_EP_CTRL_SIZE;
b_shortpacket = false;
} else {
b_shortpacket = true;
}
/* Link payload buffer directly on USB hardware */
- usb_device_endpoint_write_buffer_job(&usb_device,0,udd_g_ctrlreq.payload + udd_ctrl_payload_nb_trans,nb_remain);
+ usb_device_endpoint_write_buffer_job(&usb_device, 0, udd_g_ctrlreq.payload + udd_ctrl_payload_nb_trans, nb_remain);
udd_ctrl_payload_nb_trans += nb_remain;
}
@@ -723,9 +678,8 @@ static void udd_ctrl_in_sent(void)
* \brief Process control endpoint OUT transaction
* \param[in] pointer Pointer to the endpoint transfer status parameter struct from driver layer.
*/
-static void udd_ctrl_out_received(void* pointer)
-{
- struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter*)pointer;
+static void udd_ctrl_out_received(void *pointer) {
+ struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter *)pointer;
uint16_t nb_data;
nb_data = ep_callback_para->received_bytes; /* Read data received during OUT phase */
@@ -735,11 +689,10 @@ static void udd_ctrl_out_received(void* pointer)
nb_data = udd_g_ctrlreq.payload_size - udd_ctrl_payload_nb_trans;
}
- memcpy((uint8_t *) (udd_g_ctrlreq.payload + udd_ctrl_payload_nb_trans), udd_ctrl_buffer, nb_data);
+ memcpy((uint8_t *)(udd_g_ctrlreq.payload + udd_ctrl_payload_nb_trans), udd_ctrl_buffer, nb_data);
udd_ctrl_payload_nb_trans += nb_data;
- if ((USB_DEVICE_EP_CTRL_SIZE != nb_data) || \
- (udd_g_ctrlreq.req.wLength <= (udd_ctrl_prev_payload_nb_trans + udd_ctrl_payload_nb_trans))) {
+ if ((USB_DEVICE_EP_CTRL_SIZE != nb_data) || (udd_g_ctrlreq.req.wLength <= (udd_ctrl_prev_payload_nb_trans + udd_ctrl_payload_nb_trans))) {
/* End of reception because it is a short packet
* or all data are transferred */
@@ -786,7 +739,7 @@ static void udd_ctrl_out_received(void* pointer)
/* Reinitialize reception on payload buffer */
udd_ctrl_payload_nb_trans = 0;
}
- usb_device_endpoint_read_buffer_job(&usb_device,0,udd_ctrl_buffer,USB_DEVICE_EP_CTRL_SIZE);
+ usb_device_endpoint_read_buffer_job(&usb_device, 0, udd_ctrl_buffer, USB_DEVICE_EP_CTRL_SIZE);
}
/**
@@ -795,9 +748,8 @@ static void udd_ctrl_out_received(void* pointer)
* \param[in] module_inst pointer to USB module instance
* \param[in] pointer Pointer to the endpoint transfer status parameter struct from driver layer.
*/
-static void _usb_ep0_on_setup(struct usb_module *module_inst, void* pointer)
-{
- struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter*)pointer;
+static void _usb_ep0_on_setup(struct usb_module *module_inst, void *pointer) {
+ struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter *)pointer;
if (UDD_EPCTRL_SETUP != udd_ep_control_state) {
if (NULL != udd_g_ctrlreq.callback) {
@@ -805,7 +757,7 @@ static void _usb_ep0_on_setup(struct usb_module *module_inst, void* pointer)
}
udd_ep_control_state = UDD_EPCTRL_SETUP;
}
- if ( 8 != ep_callback_para->received_bytes) {
+ if (8 != ep_callback_para->received_bytes) {
udd_ctrl_stall_data();
return;
} else {
@@ -815,20 +767,20 @@ static void _usb_ep0_on_setup(struct usb_module *module_inst, void* pointer)
return;
} else if (Udd_setup_is_in()) {
udd_ctrl_prev_payload_nb_trans = 0;
- udd_ctrl_payload_nb_trans = 0;
- udd_ep_control_state = UDD_EPCTRL_DATA_IN;
- usb_device_endpoint_read_buffer_job(&usb_device,0,udd_ctrl_buffer,USB_DEVICE_EP_CTRL_SIZE);
+ udd_ctrl_payload_nb_trans = 0;
+ udd_ep_control_state = UDD_EPCTRL_DATA_IN;
+ usb_device_endpoint_read_buffer_job(&usb_device, 0, udd_ctrl_buffer, USB_DEVICE_EP_CTRL_SIZE);
udd_ctrl_in_sent();
} else {
- if(0 == udd_g_ctrlreq.req.wLength) {
+ if (0 == udd_g_ctrlreq.req.wLength) {
udd_ctrl_send_zlp_in();
return;
} else {
udd_ctrl_prev_payload_nb_trans = 0;
- udd_ctrl_payload_nb_trans = 0;
- udd_ep_control_state = UDD_EPCTRL_DATA_OUT;
+ udd_ctrl_payload_nb_trans = 0;
+ udd_ep_control_state = UDD_EPCTRL_DATA_OUT;
/* Initialize buffer size and enable OUT bank */
- usb_device_endpoint_read_buffer_job(&usb_device,0,udd_ctrl_buffer,USB_DEVICE_EP_CTRL_SIZE);
+ usb_device_endpoint_read_buffer_job(&usb_device, 0, udd_ctrl_buffer, USB_DEVICE_EP_CTRL_SIZE);
}
}
}
@@ -838,9 +790,8 @@ static void _usb_ep0_on_setup(struct usb_module *module_inst, void* pointer)
* \brief Control Endpoint Process when underflow condition has occurred
* \param[in] pointer Pointer to the endpoint transfer status parameter struct from driver layer.
*/
-static void udd_ctrl_underflow(void* pointer)
-{
- struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter*)pointer;
+static void udd_ctrl_underflow(void *pointer) {
+ struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter *)pointer;
if (UDD_EPCTRL_DATA_OUT == udd_ep_control_state) {
/* Host want to stop OUT transaction
@@ -857,9 +808,8 @@ static void udd_ctrl_underflow(void* pointer)
* \brief Control Endpoint Process when overflow condition has occurred
* \param[in] pointer Pointer to the endpoint transfer status parameter struct from driver layer.
*/
-static void udd_ctrl_overflow(void* pointer)
-{
- struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter*)pointer;
+static void udd_ctrl_overflow(void *pointer) {
+ struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter *)pointer;
if (UDD_EPCTRL_DATA_IN == udd_ep_control_state) {
/* Host want to stop IN transaction
@@ -878,11 +828,10 @@ static void udd_ctrl_overflow(void* pointer)
* \param[in] module_inst Pointer to USB module instance
* \param[in] pointer Pointer to the endpoint transfer status parameter struct from driver layer.
*/
-static void _usb_ep0_on_tansfer_fail(struct usb_module *module_inst, void* pointer)
-{
- struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter*)pointer;
+static void _usb_ep0_on_tansfer_fail(struct usb_module *module_inst, void *pointer) {
+ struct usb_endpoint_callback_parameter *ep_callback_para = (struct usb_endpoint_callback_parameter *)pointer;
- if(ep_callback_para->endpoint_address & USB_EP_DIR_IN) {
+ if (ep_callback_para->endpoint_address & USB_EP_DIR_IN) {
udd_ctrl_underflow(pointer);
} else {
udd_ctrl_overflow(pointer);
@@ -895,9 +844,8 @@ static void _usb_ep0_on_tansfer_fail(struct usb_module *module_inst, void* point
* \param[in] module_inst Pointer to USB module instance
* \param[in] pointer Pointer to the endpoint transfer status parameter struct from driver layer.
*/
-static void _usb_ep0_on_tansfer_ok(struct usb_module *module_inst, void *pointer)
-{
- if (UDD_EPCTRL_DATA_OUT == udd_ep_control_state) { /* handshake Out for status stage */
+static void _usb_ep0_on_tansfer_ok(struct usb_module *module_inst, void *pointer) {
+ if (UDD_EPCTRL_DATA_OUT == udd_ep_control_state) { /* handshake Out for status stage */
udd_ctrl_out_received(pointer);
} else if (UDD_EPCTRL_DATA_IN == udd_ep_control_state) { /* handshake In for status stage */
udd_ctrl_in_sent();
@@ -913,25 +861,24 @@ static void _usb_ep0_on_tansfer_ok(struct usb_module *module_inst, void *pointer
* \brief Enable Control Endpoint
* \param[in] module_inst Pointer to USB module instance
*/
-static void udd_ctrl_ep_enable(struct usb_module *module_inst)
-{
+static void udd_ctrl_ep_enable(struct usb_module *module_inst) {
/* USB Device Endpoint0 Configuration */
struct usb_device_endpoint_config config_ep0;
usb_device_endpoint_get_config_defaults(&config_ep0);
config_ep0.ep_size = (enum usb_endpoint_size)(32 - clz(((uint32_t)Min(Max(USB_DEVICE_EP_CTRL_SIZE, 8), 1024) << 1) - 1) - 1 - 3);
- usb_device_endpoint_set_config(module_inst,&config_ep0);
+ usb_device_endpoint_set_config(module_inst, &config_ep0);
- usb_device_endpoint_setup_buffer_job(module_inst,udd_ctrl_buffer);
+ usb_device_endpoint_setup_buffer_job(module_inst, udd_ctrl_buffer);
- usb_device_endpoint_register_callback(module_inst,0,USB_DEVICE_ENDPOINT_CALLBACK_RXSTP, _usb_ep0_on_setup );
- usb_device_endpoint_register_callback(module_inst,0,USB_DEVICE_ENDPOINT_CALLBACK_TRCPT,_usb_ep0_on_tansfer_ok );
- usb_device_endpoint_register_callback(module_inst,0,USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL,_usb_ep0_on_tansfer_fail );
- usb_device_endpoint_enable_callback(module_inst,0,USB_DEVICE_ENDPOINT_CALLBACK_RXSTP);
- usb_device_endpoint_enable_callback(module_inst,0,USB_DEVICE_ENDPOINT_CALLBACK_TRCPT);
- usb_device_endpoint_enable_callback(module_inst,0,USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL);
+ usb_device_endpoint_register_callback(module_inst, 0, USB_DEVICE_ENDPOINT_CALLBACK_RXSTP, _usb_ep0_on_setup);
+ usb_device_endpoint_register_callback(module_inst, 0, USB_DEVICE_ENDPOINT_CALLBACK_TRCPT, _usb_ep0_on_tansfer_ok);
+ usb_device_endpoint_register_callback(module_inst, 0, USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL, _usb_ep0_on_tansfer_fail);
+ usb_device_endpoint_enable_callback(module_inst, 0, USB_DEVICE_ENDPOINT_CALLBACK_RXSTP);
+ usb_device_endpoint_enable_callback(module_inst, 0, USB_DEVICE_ENDPOINT_CALLBACK_TRCPT);
+ usb_device_endpoint_enable_callback(module_inst, 0, USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL);
-#ifdef USB_DEVICE_LPM_SUPPORT
+#ifdef USB_DEVICE_LPM_SUPPORT
// Enable LPM feature
usb_device_set_lpm_mode(module_inst, USB_DEVICE_LPM_ACK);
#endif
@@ -945,8 +892,7 @@ static void udd_ctrl_ep_enable(struct usb_module *module_inst)
* \param[in] module_inst Pointer to USB module instance
* \param[in] pointer Pointer to the callback parameter from driver layer.
*/
-static void _usb_on_suspend(struct usb_module *module_inst, void *pointer)
-{
+static void _usb_on_suspend(struct usb_module *module_inst, void *pointer) {
usb_device_disable_callback(&usb_device, USB_DEVICE_CALLBACK_SUSPEND);
usb_device_enable_callback(&usb_device, USB_DEVICE_CALLBACK_WAKEUP);
udd_sleep_mode(UDD_STATE_SUSPEND);
@@ -955,9 +901,8 @@ static void _usb_on_suspend(struct usb_module *module_inst, void *pointer)
#endif
}
-#ifdef USB_DEVICE_LPM_SUPPORT
-static void _usb_device_lpm_suspend(struct usb_module *module_inst, void *pointer)
-{
+#ifdef USB_DEVICE_LPM_SUPPORT
+static void _usb_device_lpm_suspend(struct usb_module *module_inst, void *pointer) {
dbg_print("LPM_SUSP\n");
uint32_t *lpm_wakeup_enable;
@@ -967,7 +912,7 @@ static void _usb_device_lpm_suspend(struct usb_module *module_inst, void *pointe
usb_device_disable_callback(&usb_device, USB_DEVICE_CALLBACK_SUSPEND);
usb_device_enable_callback(&usb_device, USB_DEVICE_CALLBACK_WAKEUP);
-//#warning Here the sleep mode must be choose to have a DFLL startup time < bmAttribut.HIRD
+ //#warning Here the sleep mode must be choose to have a DFLL startup time < bmAttribut.HIRD
udd_sleep_mode(UDD_STATE_SUSPEND_LPM); // Enter in LPM SUSPEND mode
if ((*lpm_wakeup_enable)) {
UDC_REMOTEWAKEUP_LPM_ENABLE();
@@ -985,8 +930,7 @@ static void _usb_device_lpm_suspend(struct usb_module *module_inst, void *pointe
* \param[in] module_inst Pointer to USB module instance
* \param[in] pointer Pointer to the callback parameter from driver layer.
*/
-static void _usb_on_sof_notify(struct usb_module *module_inst, void *pointer)
-{
+static void _usb_on_sof_notify(struct usb_module *module_inst, void *pointer) {
udc_sof_notify();
#ifdef UDC_SOF_EVENT
UDC_SOF_EVENT();
@@ -999,11 +943,10 @@ static void _usb_on_sof_notify(struct usb_module *module_inst, void *pointer)
* \param[in] module_inst Pointer to USB module instance
* \param[in] pointer Pointer to the callback parameter from driver layer.
*/
-static void _usb_on_bus_reset(struct usb_module *module_inst, void *pointer)
-{
+static void _usb_on_bus_reset(struct usb_module *module_inst, void *pointer) {
// Reset USB Device Stack Core
udc_reset();
- usb_device_set_address(module_inst,0);
+ usb_device_set_address(module_inst, 0);
udd_ctrl_ep_enable(module_inst);
}
@@ -1013,13 +956,12 @@ static void _usb_on_bus_reset(struct usb_module *module_inst, void *pointer)
* \param[in] module_inst Pointer to USB module instance
* \param[in] pointer Pointer to the callback parameter from driver layer.
*/
-static void _usb_on_wakeup(struct usb_module *module_inst, void *pointer)
-{
+static void _usb_on_wakeup(struct usb_module *module_inst, void *pointer) {
udd_wait_clock_ready();
usb_device_disable_callback(&usb_device, USB_DEVICE_CALLBACK_WAKEUP);
usb_device_enable_callback(&usb_device, USB_DEVICE_CALLBACK_SUSPEND);
-#ifdef USB_DEVICE_LPM_SUPPORT
+#ifdef USB_DEVICE_LPM_SUPPORT
usb_device_register_callback(&usb_device, USB_DEVICE_CALLBACK_LPMSUSP, _usb_device_lpm_suspend);
usb_device_enable_callback(&usb_device, USB_DEVICE_CALLBACK_LPMSUSP);
#endif
@@ -1029,14 +971,12 @@ static void _usb_on_wakeup(struct usb_module *module_inst, void *pointer)
#endif
}
-void udd_detach(void)
-{
+void udd_detach(void) {
usb_device_detach(&usb_device);
udd_sleep_mode(UDD_STATE_SUSPEND);
}
-void udd_attach(void)
-{
+void udd_attach(void) {
udd_sleep_mode(UDD_STATE_IDLE);
usb_device_attach(&usb_device);
@@ -1049,14 +989,13 @@ void udd_attach(void)
usb_device_enable_callback(&usb_device, USB_DEVICE_CALLBACK_SOF);
usb_device_enable_callback(&usb_device, USB_DEVICE_CALLBACK_RESET);
usb_device_enable_callback(&usb_device, USB_DEVICE_CALLBACK_WAKEUP);
-#ifdef USB_DEVICE_LPM_SUPPORT
+#ifdef USB_DEVICE_LPM_SUPPORT
usb_device_register_callback(&usb_device, USB_DEVICE_CALLBACK_LPMSUSP, _usb_device_lpm_suspend);
usb_device_enable_callback(&usb_device, USB_DEVICE_CALLBACK_LPMSUSP);
#endif
}
-void udd_enable(void)
-{
+void udd_enable(void) {
uint32_t irqflags;
/* To avoid USB interrupt before end of initialization */
@@ -1088,8 +1027,7 @@ void udd_enable(void)
__set_PRIMASK(irqflags);
}
-void udd_disable(void)
-{
+void udd_disable(void) {
udd_detach();
udd_sleep_mode(UDD_STATE_OFF);
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_main.h b/tmk_core/protocol/arm_atsam/usb/usb_main.h
index 76ced474dc..e1ffa3e184 100644
--- a/tmk_core/protocol/arm_atsam/usb/usb_main.h
+++ b/tmk_core/protocol/arm_atsam/usb/usb_main.h
@@ -47,57 +47,56 @@
#ifndef _MAIN_H_
#define _MAIN_H_
-//Enters the application in low power mode
-//Callback called when USB host sets USB line in suspend state
+// Enters the application in low power mode
+// Callback called when USB host sets USB line in suspend state
void main_suspend_action(void);
-//Called by UDD when the USB line exit of suspend state
+// Called by UDD when the USB line exit of suspend state
void main_resume_action(void);
-//Called when a start of frame is received on USB line
+// Called when a start of frame is received on USB line
void main_sof_action(void);
-//Called by UDC when USB Host request to enable remote wakeup
+// Called by UDC when USB Host request to enable remote wakeup
void main_remotewakeup_enable(void);
-//Called by UDC when USB Host request to disable remote wakeup
+// Called by UDC when USB Host request to disable remote wakeup
void main_remotewakeup_disable(void);
-
#ifdef KBD
extern volatile bool main_b_kbd_enable;
-bool main_kbd_enable(void);
-void main_kbd_disable(void);
-#endif //KBD
+bool main_kbd_enable(void);
+void main_kbd_disable(void);
+#endif // KBD
#ifdef NKRO
extern volatile bool main_b_nkro_enable;
-bool main_nkro_enable(void);
-void main_nkro_disable(void);
-#endif //NKRO
+bool main_nkro_enable(void);
+void main_nkro_disable(void);
+#endif // NKRO
#ifdef EXK
extern volatile bool main_b_exk_enable;
-bool main_exk_enable(void);
-void main_exk_disable(void);
-#endif //EXK
+bool main_exk_enable(void);
+void main_exk_disable(void);
+#endif // EXK
#ifdef CON
extern volatile bool main_b_con_enable;
-bool main_con_enable(void);
-void main_con_disable(void);
-#endif //CON
+bool main_con_enable(void);
+void main_con_disable(void);
+#endif // CON
#ifdef MOU
extern volatile bool main_b_mou_enable;
-bool main_mou_enable(void);
-void main_mou_disable(void);
-#endif //MOU
+bool main_mou_enable(void);
+void main_mou_disable(void);
+#endif // MOU
#ifdef RAW
extern volatile bool main_b_raw_enable;
-bool main_raw_enable(void);
-void main_raw_disable(void);
-#endif //RAW
+bool main_raw_enable(void);
+void main_raw_disable(void);
+#endif // RAW
-#endif // _MAIN_H_
+#endif // _MAIN_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_protocol.h b/tmk_core/protocol/arm_atsam/usb/usb_protocol.h
index 892a7d3a5a..54d023a6ee 100644
--- a/tmk_core/protocol/arm_atsam/usb/usb_protocol.h
+++ b/tmk_core/protocol/arm_atsam/usb/usb_protocol.h
@@ -63,83 +63,77 @@
*/
//! Value for field bcdUSB
-#define USB_V2_0 0x0200 //!< USB Specification version 2.00
-#define USB_V2_1 0x0201 //!< USB Specification version 2.01
+#define USB_V2_0 0x0200 //!< USB Specification version 2.00
+#define USB_V2_1 0x0201 //!< USB Specification version 2.01
/*! \name Generic definitions (Class, subclass and protocol)
*/
//! @{
-#define NO_CLASS 0x00
-#define CLASS_VENDOR_SPECIFIC 0xFF
-#define NO_SUBCLASS 0x00
-#define NO_PROTOCOL 0x00
+#define NO_CLASS 0x00
+#define CLASS_VENDOR_SPECIFIC 0xFF
+#define NO_SUBCLASS 0x00
+#define NO_PROTOCOL 0x00
//! @}
//! \name IAD (Interface Association Descriptor) constants
//! @{
-#define CLASS_IAD 0xEF
-#define SUB_CLASS_IAD 0x02
-#define PROTOCOL_IAD 0x01
+#define CLASS_IAD 0xEF
+#define SUB_CLASS_IAD 0x02
+#define PROTOCOL_IAD 0x01
//! @}
/**
* \brief USB request data transfer direction (bmRequestType)
*/
-#define USB_REQ_DIR_OUT (0<<7) //!< Host to device
-#define USB_REQ_DIR_IN (1<<7) //!< Device to host
-#define USB_REQ_DIR_MASK (1<<7) //!< Mask
+#define USB_REQ_DIR_OUT (0 << 7) //!< Host to device
+#define USB_REQ_DIR_IN (1 << 7) //!< Device to host
+#define USB_REQ_DIR_MASK (1 << 7) //!< Mask
/**
* \brief USB request types (bmRequestType)
*/
-#define USB_REQ_TYPE_STANDARD (0<<5) //!< Standard request
-#define USB_REQ_TYPE_CLASS (1<<5) //!< Class-specific request
-#define USB_REQ_TYPE_VENDOR (2<<5) //!< Vendor-specific request
-#define USB_REQ_TYPE_MASK (3<<5) //!< Mask
+#define USB_REQ_TYPE_STANDARD (0 << 5) //!< Standard request
+#define USB_REQ_TYPE_CLASS (1 << 5) //!< Class-specific request
+#define USB_REQ_TYPE_VENDOR (2 << 5) //!< Vendor-specific request
+#define USB_REQ_TYPE_MASK (3 << 5) //!< Mask
/**
* \brief USB recipient codes (bmRequestType)
*/
-#define USB_REQ_RECIP_DEVICE (0<<0) //!< Recipient device
-#define USB_REQ_RECIP_INTERFACE (1<<0) //!< Recipient interface
-#define USB_REQ_RECIP_ENDPOINT (2<<0) //!< Recipient endpoint
-#define USB_REQ_RECIP_OTHER (3<<0) //!< Recipient other
-#define USB_REQ_RECIP_MASK (0x1F) //!< Mask
+#define USB_REQ_RECIP_DEVICE (0 << 0) //!< Recipient device
+#define USB_REQ_RECIP_INTERFACE (1 << 0) //!< Recipient interface
+#define USB_REQ_RECIP_ENDPOINT (2 << 0) //!< Recipient endpoint
+#define USB_REQ_RECIP_OTHER (3 << 0) //!< Recipient other
+#define USB_REQ_RECIP_MASK (0x1F) //!< Mask
/**
* \brief Standard USB requests (bRequest)
*/
enum usb_reqid {
- USB_REQ_GET_STATUS = 0,
- USB_REQ_CLEAR_FEATURE = 1,
- USB_REQ_SET_FEATURE = 3,
- USB_REQ_SET_ADDRESS = 5,
- USB_REQ_GET_DESCRIPTOR = 6,
- USB_REQ_SET_DESCRIPTOR = 7,
+ USB_REQ_GET_STATUS = 0,
+ USB_REQ_CLEAR_FEATURE = 1,
+ USB_REQ_SET_FEATURE = 3,
+ USB_REQ_SET_ADDRESS = 5,
+ USB_REQ_GET_DESCRIPTOR = 6,
+ USB_REQ_SET_DESCRIPTOR = 7,
USB_REQ_GET_CONFIGURATION = 8,
USB_REQ_SET_CONFIGURATION = 9,
- USB_REQ_GET_INTERFACE = 10,
- USB_REQ_SET_INTERFACE = 11,
- USB_REQ_SYNCH_FRAME = 12,
+ USB_REQ_GET_INTERFACE = 10,
+ USB_REQ_SET_INTERFACE = 11,
+ USB_REQ_SYNCH_FRAME = 12,
};
/**
* \brief Standard USB device status flags
*
*/
-enum usb_device_status {
- USB_DEV_STATUS_BUS_POWERED = 0,
- USB_DEV_STATUS_SELF_POWERED = 1,
- USB_DEV_STATUS_REMOTEWAKEUP = 2
-};
+enum usb_device_status { USB_DEV_STATUS_BUS_POWERED = 0, USB_DEV_STATUS_SELF_POWERED = 1, USB_DEV_STATUS_REMOTEWAKEUP = 2 };
/**
* \brief Standard USB Interface status flags
*
*/
-enum usb_interface_status {
- USB_IFACE_STATUS_RESERVED = 0
-};
+enum usb_interface_status { USB_IFACE_STATUS_RESERVED = 0 };
/**
* \brief Standard USB endpoint status flags
@@ -155,10 +149,10 @@ enum usb_endpoint_status {
* \note valid for SetFeature request.
*/
enum usb_device_feature {
- USB_DEV_FEATURE_REMOTE_WAKEUP = 1, //!< Remote wakeup enabled
- USB_DEV_FEATURE_TEST_MODE = 2, //!< USB test mode
- USB_DEV_FEATURE_OTG_B_HNP_ENABLE = 3,
- USB_DEV_FEATURE_OTG_A_HNP_SUPPORT = 4,
+ USB_DEV_FEATURE_REMOTE_WAKEUP = 1, //!< Remote wakeup enabled
+ USB_DEV_FEATURE_TEST_MODE = 2, //!< USB test mode
+ USB_DEV_FEATURE_OTG_B_HNP_ENABLE = 3,
+ USB_DEV_FEATURE_OTG_A_HNP_SUPPORT = 4,
USB_DEV_FEATURE_OTG_A_ALT_HNP_SUPPORT = 5
};
@@ -168,10 +162,10 @@ enum usb_device_feature {
* \note valid for USB_DEV_FEATURE_TEST_MODE request.
*/
enum usb_device_hs_test_mode {
- USB_DEV_TEST_MODE_J = 1,
- USB_DEV_TEST_MODE_K = 2,
- USB_DEV_TEST_MODE_SE0_NAK = 3,
- USB_DEV_TEST_MODE_PACKET = 4,
+ USB_DEV_TEST_MODE_J = 1,
+ USB_DEV_TEST_MODE_K = 2,
+ USB_DEV_TEST_MODE_SE0_NAK = 3,
+ USB_DEV_TEST_MODE_PACKET = 4,
USB_DEV_TEST_MODE_FORCE_ENABLE = 5,
};
@@ -186,10 +180,10 @@ enum usb_endpoint_feature {
* \brief Standard USB Test Mode Selectors
*/
enum usb_test_mode_selector {
- USB_TEST_J = 0x01,
- USB_TEST_K = 0x02,
- USB_TEST_SE0_NAK = 0x03,
- USB_TEST_PACKET = 0x04,
+ USB_TEST_J = 0x01,
+ USB_TEST_K = 0x02,
+ USB_TEST_SE0_NAK = 0x03,
+ USB_TEST_PACKET = 0x04,
USB_TEST_FORCE_ENABLE = 0x05,
};
@@ -197,18 +191,18 @@ enum usb_test_mode_selector {
* \brief Standard USB descriptor types
*/
enum usb_descriptor_type {
- USB_DT_DEVICE = 1,
- USB_DT_CONFIGURATION = 2,
- USB_DT_STRING = 3,
- USB_DT_INTERFACE = 4,
- USB_DT_ENDPOINT = 5,
- USB_DT_DEVICE_QUALIFIER = 6,
+ USB_DT_DEVICE = 1,
+ USB_DT_CONFIGURATION = 2,
+ USB_DT_STRING = 3,
+ USB_DT_INTERFACE = 4,
+ USB_DT_ENDPOINT = 5,
+ USB_DT_DEVICE_QUALIFIER = 6,
USB_DT_OTHER_SPEED_CONFIGURATION = 7,
- USB_DT_INTERFACE_POWER = 8,
- USB_DT_OTG = 9,
- USB_DT_IAD = 0x0B,
- USB_DT_BOS = 0x0F,
- USB_DT_DEVICE_CAPABILITY = 0x10,
+ USB_DT_INTERFACE_POWER = 8,
+ USB_DT_OTG = 9,
+ USB_DT_IAD = 0x0B,
+ USB_DT_BOS = 0x0F,
+ USB_DT_DEVICE_CAPABILITY = 0x10,
};
/**
@@ -223,57 +217,57 @@ enum usb_capability_type {
* To fill bmAttributes field of usb_capa_ext_desc_t structure.
*/
enum usb_capability_extension_attr {
- USB_DC_EXT_LPM = 0x00000002,
+ USB_DC_EXT_LPM = 0x00000002,
};
-#define HIRD_50_US 0
-#define HIRD_125_US 1
-#define HIRD_200_US 2
-#define HIRD_275_US 3
-#define HIRD_350_US 4
-#define HIRD_425_US 5
-#define HIRD_500_US 6
-#define HIRD_575_US 7
-#define HIRD_650_US 8
-#define HIRD_725_US 9
-#define HIRD_800_US 10
-#define HIRD_875_US 11
-#define HIRD_950_US 12
-#define HIRD_1025_US 13
-#define HIRD_1100_US 14
-#define HIRD_1175_US 15
+#define HIRD_50_US 0
+#define HIRD_125_US 1
+#define HIRD_200_US 2
+#define HIRD_275_US 3
+#define HIRD_350_US 4
+#define HIRD_425_US 5
+#define HIRD_500_US 6
+#define HIRD_575_US 7
+#define HIRD_650_US 8
+#define HIRD_725_US 9
+#define HIRD_800_US 10
+#define HIRD_875_US 11
+#define HIRD_950_US 12
+#define HIRD_1025_US 13
+#define HIRD_1100_US 14
+#define HIRD_1175_US 15
/** Fields definition from a LPM TOKEN */
-#define USB_LPM_ATTRIBUT_BLINKSTATE_MASK (0xF << 0)
-#define USB_LPM_ATTRIBUT_FIRD_MASK (0xF << 4)
-#define USB_LPM_ATTRIBUT_REMOTEWAKE_MASK (1 << 8)
-#define USB_LPM_ATTRIBUT_BLINKSTATE(value) ((value & 0xF) << 0)
-#define USB_LPM_ATTRIBUT_FIRD(value) ((value & 0xF) << 4)
-#define USB_LPM_ATTRIBUT_REMOTEWAKE(value) ((value & 1) << 8)
-#define USB_LPM_ATTRIBUT_BLINKSTATE_L1 USB_LPM_ATTRIBUT_BLINKSTATE(1)
+#define USB_LPM_ATTRIBUT_BLINKSTATE_MASK (0xF << 0)
+#define USB_LPM_ATTRIBUT_FIRD_MASK (0xF << 4)
+#define USB_LPM_ATTRIBUT_REMOTEWAKE_MASK (1 << 8)
+#define USB_LPM_ATTRIBUT_BLINKSTATE(value) ((value & 0xF) << 0)
+#define USB_LPM_ATTRIBUT_FIRD(value) ((value & 0xF) << 4)
+#define USB_LPM_ATTRIBUT_REMOTEWAKE(value) ((value & 1) << 8)
+#define USB_LPM_ATTRIBUT_BLINKSTATE_L1 USB_LPM_ATTRIBUT_BLINKSTATE(1)
/**
* \brief Standard USB endpoint transfer types
*/
enum usb_ep_type {
- USB_EP_TYPE_CONTROL = 0x00,
+ USB_EP_TYPE_CONTROL = 0x00,
USB_EP_TYPE_ISOCHRONOUS = 0x01,
- USB_EP_TYPE_BULK = 0x02,
- USB_EP_TYPE_INTERRUPT = 0x03,
- USB_EP_TYPE_MASK = 0x03,
+ USB_EP_TYPE_BULK = 0x02,
+ USB_EP_TYPE_INTERRUPT = 0x03,
+ USB_EP_TYPE_MASK = 0x03,
};
/**
* \brief Standard USB language IDs for string descriptors
*/
enum usb_langid {
- USB_LANGID_EN_US = 0x0409, //!< English (United States)
+ USB_LANGID_EN_US = 0x0409, //!< English (United States)
};
/**
* \brief Mask selecting the index part of an endpoint address
*/
-#define USB_EP_ADDR_MASK 0x0f
+#define USB_EP_ADDR_MASK 0x0f
//! \brief USB address identifier
typedef uint8_t usb_add_t;
@@ -281,12 +275,12 @@ typedef uint8_t usb_add_t;
/**
* \brief Endpoint transfer direction is IN
*/
-#define USB_EP_DIR_IN 0x80
+#define USB_EP_DIR_IN 0x80
/**
* \brief Endpoint transfer direction is OUT
*/
-#define USB_EP_DIR_OUT 0x00
+#define USB_EP_DIR_OUT 0x00
//! \brief Endpoint identifier
typedef uint8_t usb_ep_t;
@@ -297,7 +291,7 @@ typedef uint8_t usb_ep_t;
* The maximum length of a USB descriptor is limited by the 8-bit
* bLength field.
*/
-#define USB_MAX_DESC_LEN 255
+#define USB_MAX_DESC_LEN 255
/*
* 2-byte alignment requested for all USB structures.
@@ -312,9 +306,9 @@ COMPILER_PACK_SET(1)
typedef struct {
uint8_t bmRequestType;
uint8_t bRequest;
- le16_t wValue;
- le16_t wIndex;
- le16_t wLength;
+ le16_t wValue;
+ le16_t wIndex;
+ le16_t wLength;
} usb_setup_req_t;
/**
@@ -323,14 +317,14 @@ typedef struct {
typedef struct {
uint8_t bLength;
uint8_t bDescriptorType;
- le16_t bcdUSB;
+ le16_t bcdUSB;
uint8_t bDeviceClass;
uint8_t bDeviceSubClass;
uint8_t bDeviceProtocol;
uint8_t bMaxPacketSize0;
- le16_t idVendor;
- le16_t idProduct;
- le16_t bcdDevice;
+ le16_t idVendor;
+ le16_t idProduct;
+ le16_t bcdDevice;
uint8_t iManufacturer;
uint8_t iProduct;
uint8_t iSerialNumber;
@@ -348,7 +342,7 @@ typedef struct {
typedef struct {
uint8_t bLength;
uint8_t bDescriptorType;
- le16_t bcdUSB;
+ le16_t bcdUSB;
uint8_t bDeviceClass;
uint8_t bDeviceSubClass;
uint8_t bDeviceProtocol;
@@ -376,7 +370,6 @@ typedef struct {
uint8_t bNumDeviceCaps;
} usb_dev_bos_desc_t;
-
/**
* \brief USB Device Capabilities - USB 2.0 Extension Descriptor structure
*
@@ -395,7 +388,7 @@ typedef struct {
* The BOS descriptor and capabilities descriptors for LPM.
*/
typedef struct {
- usb_dev_bos_desc_t bos;
+ usb_dev_bos_desc_t bos;
usb_dev_capa_ext_desc_t capa_ext;
} usb_dev_lpm_desc_t;
@@ -403,24 +396,23 @@ typedef struct {
* \brief Standard USB Interface Association Descriptor structure
*/
typedef struct {
- uint8_t bLength; //!< size of this descriptor in bytes
- uint8_t bDescriptorType; //!< INTERFACE descriptor type
- uint8_t bFirstInterface; //!< Number of interface
- uint8_t bInterfaceCount; //!< value to select alternate setting
- uint8_t bFunctionClass; //!< Class code assigned by the USB
- uint8_t bFunctionSubClass;//!< Sub-class code assigned by the USB
- uint8_t bFunctionProtocol;//!< Protocol code assigned by the USB
- uint8_t iFunction; //!< Index of string descriptor
+ uint8_t bLength; //!< size of this descriptor in bytes
+ uint8_t bDescriptorType; //!< INTERFACE descriptor type
+ uint8_t bFirstInterface; //!< Number of interface
+ uint8_t bInterfaceCount; //!< value to select alternate setting
+ uint8_t bFunctionClass; //!< Class code assigned by the USB
+ uint8_t bFunctionSubClass; //!< Sub-class code assigned by the USB
+ uint8_t bFunctionProtocol; //!< Protocol code assigned by the USB
+ uint8_t iFunction; //!< Index of string descriptor
} usb_association_desc_t;
-
/**
* \brief Standard USB configuration descriptor structure
*/
typedef struct {
uint8_t bLength;
uint8_t bDescriptorType;
- le16_t wTotalLength;
+ le16_t wTotalLength;
uint8_t bNumInterfaces;
uint8_t bConfigurationValue;
uint8_t iConfiguration;
@@ -428,26 +420,25 @@ typedef struct {
uint8_t bMaxPower;
} usb_conf_desc_t;
+#define USB_CONFIG_ATTR_MUST_SET (1 << 7) //!< Must always be set
+#define USB_CONFIG_ATTR_BUS_POWERED (0 << 6) //!< Bus-powered
+#define USB_CONFIG_ATTR_SELF_POWERED (1 << 6) //!< Self-powered
+#define USB_CONFIG_ATTR_REMOTE_WAKEUP (1 << 5) //!< remote wakeup supported
-#define USB_CONFIG_ATTR_MUST_SET (1 << 7) //!< Must always be set
-#define USB_CONFIG_ATTR_BUS_POWERED (0 << 6) //!< Bus-powered
-#define USB_CONFIG_ATTR_SELF_POWERED (1 << 6) //!< Self-powered
-#define USB_CONFIG_ATTR_REMOTE_WAKEUP (1 << 5) //!< remote wakeup supported
-
-#define USB_CONFIG_MAX_POWER(ma) (((ma) + 1) / 2) //!< Max power in mA
+#define USB_CONFIG_MAX_POWER(ma) (((ma) + 1) / 2) //!< Max power in mA
/**
* \brief Standard USB association descriptor structure
*/
typedef struct {
- uint8_t bLength; //!< Size of this descriptor in bytes
- uint8_t bDescriptorType; //!< Interface descriptor type
- uint8_t bFirstInterface; //!< Number of interface
- uint8_t bInterfaceCount; //!< value to select alternate setting
- uint8_t bFunctionClass; //!< Class code assigned by the USB
- uint8_t bFunctionSubClass; //!< Sub-class code assigned by the USB
- uint8_t bFunctionProtocol; //!< Protocol code assigned by the USB
- uint8_t iFunction; //!< Index of string descriptor
+ uint8_t bLength; //!< Size of this descriptor in bytes
+ uint8_t bDescriptorType; //!< Interface descriptor type
+ uint8_t bFirstInterface; //!< Number of interface
+ uint8_t bInterfaceCount; //!< value to select alternate setting
+ uint8_t bFunctionClass; //!< Class code assigned by the USB
+ uint8_t bFunctionSubClass; //!< Sub-class code assigned by the USB
+ uint8_t bFunctionProtocol; //!< Protocol code assigned by the USB
+ uint8_t iFunction; //!< Index of string descriptor
} usb_iad_desc_t;
/**
@@ -473,11 +464,10 @@ typedef struct {
uint8_t bDescriptorType;
uint8_t bEndpointAddress;
uint8_t bmAttributes;
- le16_t wMaxPacketSize;
+ le16_t wMaxPacketSize;
uint8_t bInterval;
} usb_ep_desc_t;
-
/**
* \brief A standard USB string descriptor structure
*/
@@ -488,7 +478,7 @@ typedef struct {
typedef struct {
usb_str_desc_t desc;
- le16_t string[1];
+ le16_t string[1];
} usb_str_lgid_desc_t;
COMPILER_PACK_RESET()
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_protocol_cdc.h b/tmk_core/protocol/arm_atsam/usb/usb_protocol_cdc.h
index 479f25d4e3..aa639a6e5d 100644
--- a/tmk_core/protocol/arm_atsam/usb/usb_protocol_cdc.h
+++ b/tmk_core/protocol/arm_atsam/usb/usb_protocol_cdc.h
@@ -50,144 +50,141 @@
#ifdef CDC
-#define CDC_CLASS_DEVICE 0x02 //!< USB Communication Device Class
-#define CDC_CLASS_COMM 0x02 //!< CDC Communication Class Interface
-#define CDC_CLASS_DATA 0x0A //!< CDC Data Class Interface
-
-#define CDC_SUBCLASS_DLCM 0x01 //!< Direct Line Control Model
-#define CDC_SUBCLASS_ACM 0x02 //!< Abstract Control Model
-#define CDC_SUBCLASS_TCM 0x03 //!< Telephone Control Model
-#define CDC_SUBCLASS_MCCM 0x04 //!< Multi-Channel Control Model
-#define CDC_SUBCLASS_CCM 0x05 //!< CAPI Control Model
-#define CDC_SUBCLASS_ETH 0x06 //!< Ethernet Networking Control Model
-#define CDC_SUBCLASS_ATM 0x07 //!< ATM Networking Control Model
-
-#define CDC_PROTOCOL_V25TER 0x01 //!< Common AT commands
-
-#define CDC_PROTOCOL_I430 0x30 //!< ISDN BRI
-#define CDC_PROTOCOL_HDLC 0x31 //!< HDLC
-#define CDC_PROTOCOL_TRANS 0x32 //!< Transparent
-#define CDC_PROTOCOL_Q921M 0x50 //!< Q.921 management protocol
-#define CDC_PROTOCOL_Q921 0x51 //!< Q.931 [sic] Data link protocol
-#define CDC_PROTOCOL_Q921TM 0x52 //!< Q.921 TEI-multiplexor
-#define CDC_PROTOCOL_V42BIS 0x90 //!< Data compression procedures
-#define CDC_PROTOCOL_Q931 0x91 //!< Euro-ISDN protocol control
-#define CDC_PROTOCOL_V120 0x92 //!< V.24 rate adaption to ISDN
-#define CDC_PROTOCOL_CAPI20 0x93 //!< CAPI Commands
-#define CDC_PROTOCOL_HOST 0xFD //!< Host based driver
-
-#define CDC_PROTOCOL_PUFD 0xFE
-
-#define CDC_CS_INTERFACE 0x24 //!< Interface Functional Descriptor
-#define CDC_CS_ENDPOINT 0x25 //!< Endpoint Functional Descriptor
-
-#define CDC_SCS_HEADER 0x00 //!< Header Functional Descriptor
-#define CDC_SCS_CALL_MGMT 0x01 //!< Call Management
-#define CDC_SCS_ACM 0x02 //!< Abstract Control Management
-#define CDC_SCS_UNION 0x06 //!< Union Functional Descriptor
-
-#define USB_REQ_CDC_SEND_ENCAPSULATED_COMMAND 0x00
-#define USB_REQ_CDC_GET_ENCAPSULATED_RESPONSE 0x01
-#define USB_REQ_CDC_SET_COMM_FEATURE 0x02
-#define USB_REQ_CDC_GET_COMM_FEATURE 0x03
-#define USB_REQ_CDC_CLEAR_COMM_FEATURE 0x04
-#define USB_REQ_CDC_SET_AUX_LINE_STATE 0x10
-#define USB_REQ_CDC_SET_HOOK_STATE 0x11
-#define USB_REQ_CDC_PULSE_SETUP 0x12
-#define USB_REQ_CDC_SEND_PULSE 0x13
-#define USB_REQ_CDC_SET_PULSE_TIME 0x14
-#define USB_REQ_CDC_RING_AUX_JACK 0x15
-#define USB_REQ_CDC_SET_LINE_CODING 0x20
-#define USB_REQ_CDC_GET_LINE_CODING 0x21
-#define USB_REQ_CDC_SET_CONTROL_LINE_STATE 0x22
-#define USB_REQ_CDC_SEND_BREAK 0x23
-#define USB_REQ_CDC_SET_RINGER_PARMS 0x30
-#define USB_REQ_CDC_GET_RINGER_PARMS 0x31
-#define USB_REQ_CDC_SET_OPERATION_PARMS 0x32
-#define USB_REQ_CDC_GET_OPERATION_PARMS 0x33
-#define USB_REQ_CDC_SET_LINE_PARMS 0x34
-#define USB_REQ_CDC_GET_LINE_PARMS 0x35
-#define USB_REQ_CDC_DIAL_DIGITS 0x36
-#define USB_REQ_CDC_SET_UNIT_PARAMETER 0x37
-#define USB_REQ_CDC_GET_UNIT_PARAMETER 0x38
-#define USB_REQ_CDC_CLEAR_UNIT_PARAMETER 0x39
-#define USB_REQ_CDC_GET_PROFILE 0x3A
-#define USB_REQ_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
-#define USB_REQ_CDC_SET_ETHERNET_POWER_MANAGEMENT_PATTERNFILTER 0x41
-#define USB_REQ_CDC_GET_ETHERNET_POWER_MANAGEMENT_PATTERNFILTER 0x42
-#define USB_REQ_CDC_SET_ETHERNET_PACKET_FILTER 0x43
-#define USB_REQ_CDC_GET_ETHERNET_STATISTIC 0x44
-#define USB_REQ_CDC_SET_ATM_DATA_FORMAT 0x50
-#define USB_REQ_CDC_GET_ATM_DEVICE_STATISTICS 0x51
-#define USB_REQ_CDC_SET_ATM_DEFAULT_VC 0x52
-#define USB_REQ_CDC_GET_ATM_VC_STATISTICS 0x53
+# define CDC_CLASS_DEVICE 0x02 //!< USB Communication Device Class
+# define CDC_CLASS_COMM 0x02 //!< CDC Communication Class Interface
+# define CDC_CLASS_DATA 0x0A //!< CDC Data Class Interface
+
+# define CDC_SUBCLASS_DLCM 0x01 //!< Direct Line Control Model
+# define CDC_SUBCLASS_ACM 0x02 //!< Abstract Control Model
+# define CDC_SUBCLASS_TCM 0x03 //!< Telephone Control Model
+# define CDC_SUBCLASS_MCCM 0x04 //!< Multi-Channel Control Model
+# define CDC_SUBCLASS_CCM 0x05 //!< CAPI Control Model
+# define CDC_SUBCLASS_ETH 0x06 //!< Ethernet Networking Control Model
+# define CDC_SUBCLASS_ATM 0x07 //!< ATM Networking Control Model
+
+# define CDC_PROTOCOL_V25TER 0x01 //!< Common AT commands
+
+# define CDC_PROTOCOL_I430 0x30 //!< ISDN BRI
+# define CDC_PROTOCOL_HDLC 0x31 //!< HDLC
+# define CDC_PROTOCOL_TRANS 0x32 //!< Transparent
+# define CDC_PROTOCOL_Q921M 0x50 //!< Q.921 management protocol
+# define CDC_PROTOCOL_Q921 0x51 //!< Q.931 [sic] Data link protocol
+# define CDC_PROTOCOL_Q921TM 0x52 //!< Q.921 TEI-multiplexor
+# define CDC_PROTOCOL_V42BIS 0x90 //!< Data compression procedures
+# define CDC_PROTOCOL_Q931 0x91 //!< Euro-ISDN protocol control
+# define CDC_PROTOCOL_V120 0x92 //!< V.24 rate adaption to ISDN
+# define CDC_PROTOCOL_CAPI20 0x93 //!< CAPI Commands
+# define CDC_PROTOCOL_HOST 0xFD //!< Host based driver
+
+# define CDC_PROTOCOL_PUFD 0xFE
+
+# define CDC_CS_INTERFACE 0x24 //!< Interface Functional Descriptor
+# define CDC_CS_ENDPOINT 0x25 //!< Endpoint Functional Descriptor
+
+# define CDC_SCS_HEADER 0x00 //!< Header Functional Descriptor
+# define CDC_SCS_CALL_MGMT 0x01 //!< Call Management
+# define CDC_SCS_ACM 0x02 //!< Abstract Control Management
+# define CDC_SCS_UNION 0x06 //!< Union Functional Descriptor
+
+# define USB_REQ_CDC_SEND_ENCAPSULATED_COMMAND 0x00
+# define USB_REQ_CDC_GET_ENCAPSULATED_RESPONSE 0x01
+# define USB_REQ_CDC_SET_COMM_FEATURE 0x02
+# define USB_REQ_CDC_GET_COMM_FEATURE 0x03
+# define USB_REQ_CDC_CLEAR_COMM_FEATURE 0x04
+# define USB_REQ_CDC_SET_AUX_LINE_STATE 0x10
+# define USB_REQ_CDC_SET_HOOK_STATE 0x11
+# define USB_REQ_CDC_PULSE_SETUP 0x12
+# define USB_REQ_CDC_SEND_PULSE 0x13
+# define USB_REQ_CDC_SET_PULSE_TIME 0x14
+# define USB_REQ_CDC_RING_AUX_JACK 0x15
+# define USB_REQ_CDC_SET_LINE_CODING 0x20
+# define USB_REQ_CDC_GET_LINE_CODING 0x21
+# define USB_REQ_CDC_SET_CONTROL_LINE_STATE 0x22
+# define USB_REQ_CDC_SEND_BREAK 0x23
+# define USB_REQ_CDC_SET_RINGER_PARMS 0x30
+# define USB_REQ_CDC_GET_RINGER_PARMS 0x31
+# define USB_REQ_CDC_SET_OPERATION_PARMS 0x32
+# define USB_REQ_CDC_GET_OPERATION_PARMS 0x33
+# define USB_REQ_CDC_SET_LINE_PARMS 0x34
+# define USB_REQ_CDC_GET_LINE_PARMS 0x35
+# define USB_REQ_CDC_DIAL_DIGITS 0x36
+# define USB_REQ_CDC_SET_UNIT_PARAMETER 0x37
+# define USB_REQ_CDC_GET_UNIT_PARAMETER 0x38
+# define USB_REQ_CDC_CLEAR_UNIT_PARAMETER 0x39
+# define USB_REQ_CDC_GET_PROFILE 0x3A
+# define USB_REQ_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
+# define USB_REQ_CDC_SET_ETHERNET_POWER_MANAGEMENT_PATTERNFILTER 0x41
+# define USB_REQ_CDC_GET_ETHERNET_POWER_MANAGEMENT_PATTERNFILTER 0x42
+# define USB_REQ_CDC_SET_ETHERNET_PACKET_FILTER 0x43
+# define USB_REQ_CDC_GET_ETHERNET_STATISTIC 0x44
+# define USB_REQ_CDC_SET_ATM_DATA_FORMAT 0x50
+# define USB_REQ_CDC_GET_ATM_DEVICE_STATISTICS 0x51
+# define USB_REQ_CDC_SET_ATM_DEFAULT_VC 0x52
+# define USB_REQ_CDC_GET_ATM_VC_STATISTICS 0x53
// Added bNotification codes according cdc spec 1.1 chapter 6.3
-#define USB_REQ_CDC_NOTIFY_RING_DETECT 0x09
-#define USB_REQ_CDC_NOTIFY_SERIAL_STATE 0x20
-#define USB_REQ_CDC_NOTIFY_CALL_STATE_CHANGE 0x28
-#define USB_REQ_CDC_NOTIFY_LINE_STATE_CHANGE 0x29
-
-
-#define CDC_CALL_MGMT_SUPPORTED (1 << 0)
-#define CDC_CALL_MGMT_OVER_DCI (1 << 1)
-#define CDC_ACM_SUPPORT_FEATURE_REQUESTS (1 << 0)
-#define CDC_ACM_SUPPORT_LINE_REQUESTS (1 << 1)
-#define CDC_ACM_SUPPORT_SENDBREAK_REQUESTS (1 << 2)
-#define CDC_ACM_SUPPORT_NOTIFY_REQUESTS (1 << 3)
-
-#pragma pack(push,1)
+# define USB_REQ_CDC_NOTIFY_RING_DETECT 0x09
+# define USB_REQ_CDC_NOTIFY_SERIAL_STATE 0x20
+# define USB_REQ_CDC_NOTIFY_CALL_STATE_CHANGE 0x28
+# define USB_REQ_CDC_NOTIFY_LINE_STATE_CHANGE 0x29
+
+# define CDC_CALL_MGMT_SUPPORTED (1 << 0)
+# define CDC_CALL_MGMT_OVER_DCI (1 << 1)
+# define CDC_ACM_SUPPORT_FEATURE_REQUESTS (1 << 0)
+# define CDC_ACM_SUPPORT_LINE_REQUESTS (1 << 1)
+# define CDC_ACM_SUPPORT_SENDBREAK_REQUESTS (1 << 2)
+# define CDC_ACM_SUPPORT_NOTIFY_REQUESTS (1 << 3)
+
+# pragma pack(push, 1)
typedef struct {
- le32_t dwDTERate;
+ le32_t dwDTERate;
uint8_t bCharFormat;
uint8_t bParityType;
uint8_t bDataBits;
} usb_cdc_line_coding_t;
-#pragma pack(pop)
+# pragma pack(pop)
enum cdc_char_format {
- CDC_STOP_BITS_1 = 0, //!< 1 stop bit
+ CDC_STOP_BITS_1 = 0, //!< 1 stop bit
CDC_STOP_BITS_1_5 = 1, //!< 1.5 stop bits
- CDC_STOP_BITS_2 = 2, //!< 2 stop bits
+ CDC_STOP_BITS_2 = 2, //!< 2 stop bits
};
enum cdc_parity {
- CDC_PAR_NONE = 0, //!< No parity
- CDC_PAR_ODD = 1, //!< Odd parity
- CDC_PAR_EVEN = 2, //!< Even parity
- CDC_PAR_MARK = 3, //!< Parity forced to 0 (space)
+ CDC_PAR_NONE = 0, //!< No parity
+ CDC_PAR_ODD = 1, //!< Odd parity
+ CDC_PAR_EVEN = 2, //!< Even parity
+ CDC_PAR_MARK = 3, //!< Parity forced to 0 (space)
CDC_PAR_SPACE = 4, //!< Parity forced to 1 (mark)
};
-
typedef struct {
uint16_t value;
} usb_cdc_control_signal_t;
-#define CDC_CTRL_SIGNAL_ACTIVATE_CARRIER (1 << 1)
-#define CDC_CTRL_SIGNAL_DTE_PRESENT (1 << 0)
-
+# define CDC_CTRL_SIGNAL_ACTIVATE_CARRIER (1 << 1)
+# define CDC_CTRL_SIGNAL_DTE_PRESENT (1 << 0)
typedef struct {
uint8_t bmRequestType;
uint8_t bNotification;
- le16_t wValue;
- le16_t wIndex;
- le16_t wLength;
+ le16_t wValue;
+ le16_t wIndex;
+ le16_t wLength;
} usb_cdc_notify_msg_t;
typedef struct {
usb_cdc_notify_msg_t header;
- le16_t value;
+ le16_t value;
} usb_cdc_notify_serial_state_t;
-#define CDC_SERIAL_STATE_DCD CPU_TO_LE16((1<<0))
-#define CDC_SERIAL_STATE_DSR CPU_TO_LE16((1<<1))
-#define CDC_SERIAL_STATE_BREAK CPU_TO_LE16((1<<2))
-#define CDC_SERIAL_STATE_RING CPU_TO_LE16((1<<3))
-#define CDC_SERIAL_STATE_FRAMING CPU_TO_LE16((1<<4))
-#define CDC_SERIAL_STATE_PARITY CPU_TO_LE16((1<<5))
-#define CDC_SERIAL_STATE_OVERRUN CPU_TO_LE16((1<<6))
+# define CDC_SERIAL_STATE_DCD CPU_TO_LE16((1 << 0))
+# define CDC_SERIAL_STATE_DSR CPU_TO_LE16((1 << 1))
+# define CDC_SERIAL_STATE_BREAK CPU_TO_LE16((1 << 2))
+# define CDC_SERIAL_STATE_RING CPU_TO_LE16((1 << 3))
+# define CDC_SERIAL_STATE_FRAMING CPU_TO_LE16((1 << 4))
+# define CDC_SERIAL_STATE_PARITY CPU_TO_LE16((1 << 5))
+# define CDC_SERIAL_STATE_OVERRUN CPU_TO_LE16((1 << 6))
#endif
-#endif // _USB_PROTOCOL_CDC_H_
+#endif // _USB_PROTOCOL_CDC_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h b/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h
index c482e9c069..2f8a39bdd8 100644
--- a/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h
+++ b/tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h
@@ -58,64 +58,62 @@
//! \name Possible Class value
//@{
-#define HID_CLASS 0x03
+#define HID_CLASS 0x03
//@}
//! \name Possible SubClass value
//@{
//! Interface subclass NO support BOOT protocol
-#define HID_SUB_CLASS_NOBOOT 0x00
+#define HID_SUB_CLASS_NOBOOT 0x00
//! Interface subclass support BOOT protocol
-#define HID_SUB_CLASS_BOOT 0x01
+#define HID_SUB_CLASS_BOOT 0x01
//@}
//! \name Possible protocol value
//@{
//! Protocol generic standard
-#define HID_PROTOCOL_GENERIC 0x00
+#define HID_PROTOCOL_GENERIC 0x00
//! Protocol keyboard standard
-#define HID_PROTOCOL_KEYBOARD 0x01
+#define HID_PROTOCOL_KEYBOARD 0x01
//! Protocol mouse standard
-#define HID_PROTOCOL_MOUSE 0x02
+#define HID_PROTOCOL_MOUSE 0x02
//@}
-
//! \brief Hid USB requests (bRequest)
enum usb_reqid_hid {
- USB_REQ_HID_GET_REPORT = 0x01,
- USB_REQ_HID_GET_IDLE = 0x02,
+ USB_REQ_HID_GET_REPORT = 0x01,
+ USB_REQ_HID_GET_IDLE = 0x02,
USB_REQ_HID_GET_PROTOCOL = 0x03,
- USB_REQ_HID_SET_REPORT = 0x09,
- USB_REQ_HID_SET_IDLE = 0x0A,
+ USB_REQ_HID_SET_REPORT = 0x09,
+ USB_REQ_HID_SET_IDLE = 0x0A,
USB_REQ_HID_SET_PROTOCOL = 0x0B,
};
//! \brief HID USB descriptor types
enum usb_descriptor_type_hid {
- USB_DT_HID = 0x21,
- USB_DT_HID_REPORT = 0x22,
+ USB_DT_HID = 0x21,
+ USB_DT_HID_REPORT = 0x22,
USB_DT_HID_PHYSICAL = 0x23,
};
//! \brief HID Type for report descriptor
enum usb_hid_item_report_type {
- USB_HID_ITEM_REPORT_TYPE_MAIN = 0,
+ USB_HID_ITEM_REPORT_TYPE_MAIN = 0,
USB_HID_ITEM_REPORT_TYPE_GLOBAL = 1,
- USB_HID_ITEM_REPORT_TYPE_LOCAL = 2,
- USB_HID_ITEM_REPORT_TYPE_LONG = 3,
+ USB_HID_ITEM_REPORT_TYPE_LOCAL = 2,
+ USB_HID_ITEM_REPORT_TYPE_LONG = 3,
};
//! \brief HID report type
enum usb_hid_report_type {
- USB_HID_REPORT_TYPE_INPUT = 1,
- USB_HID_REPORT_TYPE_OUTPUT = 2,
+ USB_HID_REPORT_TYPE_INPUT = 1,
+ USB_HID_REPORT_TYPE_OUTPUT = 2,
USB_HID_REPORT_TYPE_FEATURE = 3,
};
-
//! \brief HID protocol
enum usb_hid_protocol {
- USB_HID_PROCOTOL_BOOT = 0,
+ USB_HID_PROCOTOL_BOOT = 0,
USB_HID_PROCOTOL_REPORT = 1,
};
@@ -123,197 +121,196 @@ COMPILER_PACK_SET(1)
//! \brief HID Descriptor
typedef struct {
- uint8_t bLength; //!< Size of this descriptor in bytes
- uint8_t bDescriptorType; //!< HID descriptor type
- le16_t bcdHID; //!< Binary Coded Decimal Spec. release
- uint8_t bCountryCode; //!< Hardware target country
- uint8_t bNumDescriptors; //!< Number of HID class descriptors to follow
- uint8_t bRDescriptorType; //!< Report descriptor type
- le16_t wDescriptorLength; //!< Total length of Report descriptor
+ uint8_t bLength; //!< Size of this descriptor in bytes
+ uint8_t bDescriptorType; //!< HID descriptor type
+ le16_t bcdHID; //!< Binary Coded Decimal Spec. release
+ uint8_t bCountryCode; //!< Hardware target country
+ uint8_t bNumDescriptors; //!< Number of HID class descriptors to follow
+ uint8_t bRDescriptorType; //!< Report descriptor type
+ le16_t wDescriptorLength; //!< Total length of Report descriptor
} usb_hid_descriptor_t;
COMPILER_PACK_RESET()
- //! \name HID Report type
- //! Used by SETUP_HID_GET_REPORT & SETUP_HID_SET_REPORT
- //! @{
-#define REPORT_TYPE_INPUT 0x01
-#define REPORT_TYPE_OUTPUT 0x02
-#define REPORT_TYPE_FEATURE 0x03
- //! @}
+//! \name HID Report type
+//! Used by SETUP_HID_GET_REPORT & SETUP_HID_SET_REPORT
+//! @{
+#define REPORT_TYPE_INPUT 0x01
+#define REPORT_TYPE_OUTPUT 0x02
+#define REPORT_TYPE_FEATURE 0x03
+//! @}
- //! \name Constants of field DESCRIPTOR_HID
- //! @{
+//! \name Constants of field DESCRIPTOR_HID
+//! @{
//! Numeric expression identifying the HID Class
//! Specification release (here V1.11)
-#define USB_HID_BDC_V1_11 0x0111
+#define USB_HID_BDC_V1_11 0x0111
//! Numeric expression specifying the number of class descriptors
//! Note: Always at least one i.e. Report descriptor.
-#define USB_HID_NUM_DESC 0x01
+#define USB_HID_NUM_DESC 0x01
- //! \name Country code
- //! @{
-#define USB_HID_NO_COUNTRY_CODE 0 // Not Supported
-#define USB_HID_COUNTRY_ARABIC 1 // Arabic
-#define USB_HID_COUNTRY_BELGIAN 2 // Belgian
-#define USB_HID_COUNTRY_CANADIAN_BILINGUAL 3 // Canadian-Bilingual
-#define USB_HID_COUNTRY_CANADIAN_FRENCH 4 // Canadian-French
-#define USB_HID_COUNTRY_CZECH_REPUBLIC 5 // Czech Republic
-#define USB_HID_COUNTRY_DANISH 6 // Danish
-#define USB_HID_COUNTRY_FINNISH 7 // Finnish
-#define USB_HID_COUNTRY_FRENCH 8 // French
-#define USB_HID_COUNTRY_GERMAN 9 // German
-#define USB_HID_COUNTRY_GREEK 10 // Greek
-#define USB_HID_COUNTRY_HEBREW 11 // Hebrew
-#define USB_HID_COUNTRY_HUNGARY 12 // Hungary
-#define USB_HID_COUNTRY_INTERNATIONAL_ISO 13 // International (ISO)
-#define USB_HID_COUNTRY_ITALIAN 14 // Italian
-#define USB_HID_COUNTRY_JAPAN_KATAKANA 15 // Japan (Katakana)
-#define USB_HID_COUNTRY_KOREAN 16 // Korean
-#define USB_HID_COUNTRY_LATIN_AMERICAN 17 // Latin American
-#define USB_HID_COUNTRY_NETHERLANDS_DUTCH 18 // Netherlands/Dutch
-#define USB_HID_COUNTRY_NORWEGIAN 19 // Norwegian
-#define USB_HID_COUNTRY_PERSIAN_FARSI 20 // Persian (Farsi)
-#define USB_HID_COUNTRY_POLAND 21 // Poland
-#define USB_HID_COUNTRY_PORTUGUESE 22 // Portuguese
-#define USB_HID_COUNTRY_RUSSIA 23 // Russia
-#define USB_HID_COUNTRY_SLOVAKIA 24 // Slovakia
-#define USB_HID_COUNTRY_SPANISH 25 // Spanish
-#define USB_HID_COUNTRY_SWEDISH 26 // Swedish
-#define USB_HID_COUNTRY_SWISS_FRENCH 27 // Swiss/French
-#define USB_HID_COUNTRY_SWISS_GERMAN 28 // Swiss/German
-#define USB_HID_COUNTRY_SWITZERLAND 29 // Switzerland
-#define USB_HID_COUNTRY_TAIWAN 30 // Taiwan
-#define USB_HID_COUNTRY_TURKISH_Q 31 // Turkish-Q
-#define USB_HID_COUNTRY_UK 32 // UK
-#define USB_HID_COUNTRY_US 33 // US
-#define USB_HID_COUNTRY_YUGOSLAVIA 34 // Yugoslavia
-#define USB_HID_COUNTRY_TURKISH_F 35 // Turkish-F
- //! @}
- //! @}
+//! \name Country code
+//! @{
+#define USB_HID_NO_COUNTRY_CODE 0 // Not Supported
+#define USB_HID_COUNTRY_ARABIC 1 // Arabic
+#define USB_HID_COUNTRY_BELGIAN 2 // Belgian
+#define USB_HID_COUNTRY_CANADIAN_BILINGUAL 3 // Canadian-Bilingual
+#define USB_HID_COUNTRY_CANADIAN_FRENCH 4 // Canadian-French
+#define USB_HID_COUNTRY_CZECH_REPUBLIC 5 // Czech Republic
+#define USB_HID_COUNTRY_DANISH 6 // Danish
+#define USB_HID_COUNTRY_FINNISH 7 // Finnish
+#define USB_HID_COUNTRY_FRENCH 8 // French
+#define USB_HID_COUNTRY_GERMAN 9 // German
+#define USB_HID_COUNTRY_GREEK 10 // Greek
+#define USB_HID_COUNTRY_HEBREW 11 // Hebrew
+#define USB_HID_COUNTRY_HUNGARY 12 // Hungary
+#define USB_HID_COUNTRY_INTERNATIONAL_ISO 13 // International (ISO)
+#define USB_HID_COUNTRY_ITALIAN 14 // Italian
+#define USB_HID_COUNTRY_JAPAN_KATAKANA 15 // Japan (Katakana)
+#define USB_HID_COUNTRY_KOREAN 16 // Korean
+#define USB_HID_COUNTRY_LATIN_AMERICAN 17 // Latin American
+#define USB_HID_COUNTRY_NETHERLANDS_DUTCH 18 // Netherlands/Dutch
+#define USB_HID_COUNTRY_NORWEGIAN 19 // Norwegian
+#define USB_HID_COUNTRY_PERSIAN_FARSI 20 // Persian (Farsi)
+#define USB_HID_COUNTRY_POLAND 21 // Poland
+#define USB_HID_COUNTRY_PORTUGUESE 22 // Portuguese
+#define USB_HID_COUNTRY_RUSSIA 23 // Russia
+#define USB_HID_COUNTRY_SLOVAKIA 24 // Slovakia
+#define USB_HID_COUNTRY_SPANISH 25 // Spanish
+#define USB_HID_COUNTRY_SWEDISH 26 // Swedish
+#define USB_HID_COUNTRY_SWISS_FRENCH 27 // Swiss/French
+#define USB_HID_COUNTRY_SWISS_GERMAN 28 // Swiss/German
+#define USB_HID_COUNTRY_SWITZERLAND 29 // Switzerland
+#define USB_HID_COUNTRY_TAIWAN 30 // Taiwan
+#define USB_HID_COUNTRY_TURKISH_Q 31 // Turkish-Q
+#define USB_HID_COUNTRY_UK 32 // UK
+#define USB_HID_COUNTRY_US 33 // US
+#define USB_HID_COUNTRY_YUGOSLAVIA 34 // Yugoslavia
+#define USB_HID_COUNTRY_TURKISH_F 35 // Turkish-F
+ //! @}
+ //! @}
//! @}
-
//! \name HID KEYS values
//! @{
-#define HID_A 0x04
-#define HID_B 0x05
-#define HID_C 0x06
-#define HID_D 0x07
-#define HID_E 0x08
-#define HID_F 0x09
-#define HID_G 0x0A
-#define HID_H 0x0B
-#define HID_I 0x0C
-#define HID_J 0x0D
-#define HID_K 0x0E
-#define HID_L 0x0F
-#define HID_M 0x10
-#define HID_N 0x11
-#define HID_O 0x12
-#define HID_P 0x13
-#define HID_Q 0x14
-#define HID_R 0x15
-#define HID_S 0x16
-#define HID_T 0x17
-#define HID_U 0x18
-#define HID_V 0x19
-#define HID_W 0x1A
-#define HID_X 0x1B
-#define HID_Y 0x1C
-#define HID_Z 0x1D
-#define HID_1 30
-#define HID_2 31
-#define HID_3 32
-#define HID_4 33
-#define HID_5 34
-#define HID_6 35
-#define HID_7 36
-#define HID_8 37
-#define HID_9 38
-#define HID_0 39
-#define HID_ENTER 40
-#define HID_ESCAPE 41
-#define HID_BACKSPACE 42
-#define HID_TAB 43
-#define HID_SPACEBAR 44
-#define HID_UNDERSCORE 45
-#define HID_PLUS 46
-#define HID_OPEN_BRACKET 47 // {
-#define HID_CLOSE_BRACKET 48 // }
-#define HID_BACKSLASH 49
-#define HID_ASH 50 // # ~
-#define HID_COLON 51 // ; :
-#define HID_QUOTE 52 // ' "
-#define HID_TILDE 53
-#define HID_COMMA 54
-#define HID_DOT 55
-#define HID_SLASH 56
-#define HID_CAPS_LOCK 57
-#define HID_F1 58
-#define HID_F2 59
-#define HID_F3 60
-#define HID_F4 61
-#define HID_F5 62
-#define HID_F6 63
-#define HID_F7 64
-#define HID_F8 65
-#define HID_F9 66
-#define HID_F10 67
-#define HID_F11 68
-#define HID_F12 69
-#define HID_PRINTSCREEN 70
-#define HID_SCROLL_LOCK 71
-#define HID_PAUSE 72
-#define HID_INSERT 73
-#define HID_HOME 74
-#define HID_PAGEUP 75
-#define HID_DELETE 76
-#define HID_END 77
-#define HID_PAGEDOWN 78
-#define HID_RIGHT 79
-#define HID_LEFT 80
-#define HID_DOWN 81
-#define HID_UP 82
-#define HID_KEYPAD_NUM_LOCK 83
-#define HID_KEYPAD_DIVIDE 84
-#define HID_KEYPAD_AT 85
-#define HID_KEYPAD_MULTIPLY 85
-#define HID_KEYPAD_MINUS 86
-#define HID_KEYPAD_PLUS 87
-#define HID_KEYPAD_ENTER 88
-#define HID_KEYPAD_1 89
-#define HID_KEYPAD_2 90
-#define HID_KEYPAD_3 91
-#define HID_KEYPAD_4 92
-#define HID_KEYPAD_5 93
-#define HID_KEYPAD_6 94
-#define HID_KEYPAD_7 95
-#define HID_KEYPAD_8 96
-#define HID_KEYPAD_9 97
-#define HID_KEYPAD_0 98
+#define HID_A 0x04
+#define HID_B 0x05
+#define HID_C 0x06
+#define HID_D 0x07
+#define HID_E 0x08
+#define HID_F 0x09
+#define HID_G 0x0A
+#define HID_H 0x0B
+#define HID_I 0x0C
+#define HID_J 0x0D
+#define HID_K 0x0E
+#define HID_L 0x0F
+#define HID_M 0x10
+#define HID_N 0x11
+#define HID_O 0x12
+#define HID_P 0x13
+#define HID_Q 0x14
+#define HID_R 0x15
+#define HID_S 0x16
+#define HID_T 0x17
+#define HID_U 0x18
+#define HID_V 0x19
+#define HID_W 0x1A
+#define HID_X 0x1B
+#define HID_Y 0x1C
+#define HID_Z 0x1D
+#define HID_1 30
+#define HID_2 31
+#define HID_3 32
+#define HID_4 33
+#define HID_5 34
+#define HID_6 35
+#define HID_7 36
+#define HID_8 37
+#define HID_9 38
+#define HID_0 39
+#define HID_ENTER 40
+#define HID_ESCAPE 41
+#define HID_BACKSPACE 42
+#define HID_TAB 43
+#define HID_SPACEBAR 44
+#define HID_UNDERSCORE 45
+#define HID_PLUS 46
+#define HID_OPEN_BRACKET 47 // {
+#define HID_CLOSE_BRACKET 48 // }
+#define HID_BACKSLASH 49
+#define HID_ASH 50 // # ~
+#define HID_COLON 51 // ; :
+#define HID_QUOTE 52 // ' "
+#define HID_TILDE 53
+#define HID_COMMA 54
+#define HID_DOT 55
+#define HID_SLASH 56
+#define HID_CAPS_LOCK 57
+#define HID_F1 58
+#define HID_F2 59
+#define HID_F3 60
+#define HID_F4 61
+#define HID_F5 62
+#define HID_F6 63
+#define HID_F7 64
+#define HID_F8 65
+#define HID_F9 66
+#define HID_F10 67
+#define HID_F11 68
+#define HID_F12 69
+#define HID_PRINTSCREEN 70
+#define HID_SCROLL_LOCK 71
+#define HID_PAUSE 72
+#define HID_INSERT 73
+#define HID_HOME 74
+#define HID_PAGEUP 75
+#define HID_DELETE 76
+#define HID_END 77
+#define HID_PAGEDOWN 78
+#define HID_RIGHT 79
+#define HID_LEFT 80
+#define HID_DOWN 81
+#define HID_UP 82
+#define HID_KEYPAD_NUM_LOCK 83
+#define HID_KEYPAD_DIVIDE 84
+#define HID_KEYPAD_AT 85
+#define HID_KEYPAD_MULTIPLY 85
+#define HID_KEYPAD_MINUS 86
+#define HID_KEYPAD_PLUS 87
+#define HID_KEYPAD_ENTER 88
+#define HID_KEYPAD_1 89
+#define HID_KEYPAD_2 90
+#define HID_KEYPAD_3 91
+#define HID_KEYPAD_4 92
+#define HID_KEYPAD_5 93
+#define HID_KEYPAD_6 94
+#define HID_KEYPAD_7 95
+#define HID_KEYPAD_8 96
+#define HID_KEYPAD_9 97
+#define HID_KEYPAD_0 98
- //! \name HID modifier values
- //! @{
-#define HID_MODIFIER_NONE 0x00
-#define HID_MODIFIER_LEFT_CTRL 0x01
-#define HID_MODIFIER_LEFT_SHIFT 0x02
-#define HID_MODIFIER_LEFT_ALT 0x04
-#define HID_MODIFIER_LEFT_UI 0x08
-#define HID_MODIFIER_RIGHT_CTRL 0x10
-#define HID_MODIFIER_RIGHT_SHIFT 0x20
-#define HID_MODIFIER_RIGHT_ALT 0x40
-#define HID_MODIFIER_RIGHT_UI 0x80
- //! @}
+//! \name HID modifier values
+//! @{
+#define HID_MODIFIER_NONE 0x00
+#define HID_MODIFIER_LEFT_CTRL 0x01
+#define HID_MODIFIER_LEFT_SHIFT 0x02
+#define HID_MODIFIER_LEFT_ALT 0x04
+#define HID_MODIFIER_LEFT_UI 0x08
+#define HID_MODIFIER_RIGHT_CTRL 0x10
+#define HID_MODIFIER_RIGHT_SHIFT 0x20
+#define HID_MODIFIER_RIGHT_ALT 0x40
+#define HID_MODIFIER_RIGHT_UI 0x80
+//! @}
//! @}
//! \name HID KEYS values
//! @{
-#define HID_LED_NUM_LOCK (1<<0)
-#define HID_LED_CAPS_LOCK (1<<1)
-#define HID_LED_SCROLL_LOCK (1<<2)
-#define HID_LED_COMPOSE (1<<3)
-#define HID_LED_KANA (1<<4)
+#define HID_LED_NUM_LOCK (1 << 0)
+#define HID_LED_CAPS_LOCK (1 << 1)
+#define HID_LED_SCROLL_LOCK (1 << 2)
+#define HID_LED_COMPOSE (1 << 3)
+#define HID_LED_KANA (1 << 4)
//! @}
-#endif // _USB_PROTOCOL_HID_H_
+#endif // _USB_PROTOCOL_HID_H_
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_util.c b/tmk_core/protocol/arm_atsam/usb/usb_util.c
index 58b349362e..a682c00b58 100644
--- a/tmk_core/protocol/arm_atsam/usb/usb_util.c
+++ b/tmk_core/protocol/arm_atsam/usb/usb_util.c
@@ -2,58 +2,42 @@
#include "string.h"
#include "usb_util.h"
-char digit(int d, int radix)
-{
- if (d < 10)
- {
+char digit(int d, int radix) {
+ if (d < 10) {
return d + '0';
- }
- else
- {
+ } else {
return d - 10 + 'A';
}
}
-int UTIL_ltoa_radix(int64_t value, char *dest, int radix)
-{
- int64_t original = value; //save original value
- char buf[25] = "";
- int c = sizeof(buf)-1;
- int last = c;
- int d;
- int size;
+int UTIL_ltoa_radix(int64_t value, char *dest, int radix) {
+ int64_t original = value; // save original value
+ char buf[25] = "";
+ int c = sizeof(buf) - 1;
+ int last = c;
+ int d;
+ int size;
- if (value < 0) //if it's negative, take the absolute value
+ if (value < 0) // if it's negative, take the absolute value
value = -value;
- do //write least significant digit of value that's left
+ do // write least significant digit of value that's left
{
- d = (value % radix);
+ d = (value % radix);
buf[--c] = digit(d, radix);
value /= radix;
} while (value);
- if (original < 0)
- buf[--c] = '-';
+ if (original < 0) buf[--c] = '-';
- size = last - c + 1; //includes null at end
+ size = last - c + 1; // includes null at end
memcpy(dest, &buf[c], last - c + 1);
- return (size - 1); //without null termination
+ return (size - 1); // without null termination
}
-int UTIL_ltoa(int64_t value, char *dest)
-{
- return UTIL_ltoa_radix(value, dest, 10);
-}
+int UTIL_ltoa(int64_t value, char *dest) { return UTIL_ltoa_radix(value, dest, 10); }
-int UTIL_itoa(int value, char *dest)
-{
- return UTIL_ltoa_radix((int64_t)value, dest, 10);
-}
-
-int UTIL_utoa(uint32_t value, char *dest)
-{
- return UTIL_ltoa_radix((int64_t)value, dest, 10);
-}
+int UTIL_itoa(int value, char *dest) { return UTIL_ltoa_radix((int64_t)value, dest, 10); }
+int UTIL_utoa(uint32_t value, char *dest) { return UTIL_ltoa_radix((int64_t)value, dest, 10); }
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_util.h b/tmk_core/protocol/arm_atsam/usb/usb_util.h
index 2134d5d279..3bad2c26f2 100644
--- a/tmk_core/protocol/arm_atsam/usb/usb_util.h
+++ b/tmk_core/protocol/arm_atsam/usb/usb_util.h
@@ -6,5 +6,4 @@ int UTIL_ltoa(int64_t value, char *dest);
int UTIL_itoa(int value, char *dest);
int UTIL_utoa(uint32_t value, char *dest);
-#endif //_USB_UTIL_H_
-
+#endif //_USB_UTIL_H_