Format code according to conventions (#16322)
This commit is contained in:
@@ -876,66 +876,66 @@ typedef struct {
|
||||
// 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.
|
||||
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 MSB(u16) (((U8 *)&(u16))[1]) //!< Most significant byte of \a u16.
|
||||
# define LSB(u16) (((U8 *)&(u16))[0]) //!< Least significant byte of \a u16.
|
||||
|
||||
# define MSH(u32) (((U16 *)&(u32))[1]) //!< Most significant half-word of \a u32.
|
||||
# define LSH(u32) (((U16 *)&(u32))[0]) //!< Least significant half-word of \a u32.
|
||||
# define MSB0W(u32) (((U8 *)&(u32))[3]) //!< Most significant byte of 1st rank of \a u32.
|
||||
# define MSB1W(u32) (((U8 *)&(u32))[2]) //!< Most significant byte of 2nd rank of \a u32.
|
||||
# define MSB2W(u32) (((U8 *)&(u32))[1]) //!< Most significant byte of 3rd rank of \a u32.
|
||||
# define MSB3W(u32) (((U8 *)&(u32))[0]) //!< Most significant byte of 4th rank of \a u32.
|
||||
# define LSB3W(u32) MSB0W(u32) //!< Least significant byte of 4th rank of \a u32.
|
||||
# define LSB2W(u32) MSB1W(u32) //!< Least significant byte of 3rd rank of \a u32.
|
||||
# define LSB1W(u32) MSB2W(u32) //!< Least significant byte of 2nd rank of \a u32.
|
||||
# define LSB0W(u32) MSB3W(u32) //!< Least significant byte of 1st rank of \a u32.
|
||||
# define MSH(u32) (((U16 *)&(u32))[1]) //!< Most significant half-word of \a u32.
|
||||
# define LSH(u32) (((U16 *)&(u32))[0]) //!< Least significant half-word of \a u32.
|
||||
# define MSB0W(u32) (((U8 *)&(u32))[3]) //!< Most significant byte of 1st rank of \a u32.
|
||||
# define MSB1W(u32) (((U8 *)&(u32))[2]) //!< Most significant byte of 2nd rank of \a u32.
|
||||
# define MSB2W(u32) (((U8 *)&(u32))[1]) //!< Most significant byte of 3rd rank of \a u32.
|
||||
# define MSB3W(u32) (((U8 *)&(u32))[0]) //!< Most significant byte of 4th rank of \a u32.
|
||||
# define LSB3W(u32) MSB0W(u32) //!< Least significant byte of 4th rank of \a u32.
|
||||
# define LSB2W(u32) MSB1W(u32) //!< Least significant byte of 3rd rank of \a u32.
|
||||
# define LSB1W(u32) MSB2W(u32) //!< Least significant byte of 2nd rank of \a u32.
|
||||
# define LSB0W(u32) MSB3W(u32) //!< Least significant byte of 1st rank of \a u32.
|
||||
|
||||
# define MSW(u64) (((U32 *)&(u64))[1]) //!< Most significant word of \a u64.
|
||||
# define LSW(u64) (((U32 *)&(u64))[0]) //!< Least significant word of \a u64.
|
||||
# define MSH0(u64) (((U16 *)&(u64))[3]) //!< Most significant half-word of 1st rank of \a u64.
|
||||
# define MSH1(u64) (((U16 *)&(u64))[2]) //!< Most significant half-word of 2nd rank of \a u64.
|
||||
# define MSH2(u64) (((U16 *)&(u64))[1]) //!< Most significant half-word of 3rd rank of \a u64.
|
||||
# define MSH3(u64) (((U16 *)&(u64))[0]) //!< Most significant half-word of 4th rank of \a u64.
|
||||
# define LSH3(u64) MSH0(u64) //!< Least significant half-word of 4th rank of \a u64.
|
||||
# define LSH2(u64) MSH1(u64) //!< Least significant half-word of 3rd rank of \a u64.
|
||||
# define LSH1(u64) MSH2(u64) //!< Least significant half-word of 2nd rank of \a u64.
|
||||
# define LSH0(u64) MSH3(u64) //!< Least significant half-word of 1st rank of \a u64.
|
||||
# define MSB0D(u64) (((U8 *)&(u64))[7]) //!< Most significant byte of 1st rank of \a u64.
|
||||
# define MSB1D(u64) (((U8 *)&(u64))[6]) //!< Most significant byte of 2nd rank of \a u64.
|
||||
# define MSB2D(u64) (((U8 *)&(u64))[5]) //!< Most significant byte of 3rd rank of \a u64.
|
||||
# define MSB3D(u64) (((U8 *)&(u64))[4]) //!< Most significant byte of 4th rank of \a u64.
|
||||
# define MSB4D(u64) (((U8 *)&(u64))[3]) //!< Most significant byte of 5th rank of \a u64.
|
||||
# define MSB5D(u64) (((U8 *)&(u64))[2]) //!< Most significant byte of 6th rank of \a u64.
|
||||
# define MSB6D(u64) (((U8 *)&(u64))[1]) //!< Most significant byte of 7th rank of \a u64.
|
||||
# define MSB7D(u64) (((U8 *)&(u64))[0]) //!< Most significant byte of 8th rank of \a u64.
|
||||
# define LSB7D(u64) MSB0D(u64) //!< Least significant byte of 8th rank of \a u64.
|
||||
# define LSB6D(u64) MSB1D(u64) //!< Least significant byte of 7th rank of \a u64.
|
||||
# define LSB5D(u64) MSB2D(u64) //!< Least significant byte of 6th rank of \a u64.
|
||||
# define LSB4D(u64) MSB3D(u64) //!< Least significant byte of 5th rank of \a u64.
|
||||
# define LSB3D(u64) MSB4D(u64) //!< Least significant byte of 4th rank of \a u64.
|
||||
# define LSB2D(u64) MSB5D(u64) //!< Least significant byte of 3rd rank of \a u64.
|
||||
# define LSB1D(u64) MSB6D(u64) //!< Least significant byte of 2nd rank of \a u64.
|
||||
# define LSB0D(u64) MSB7D(u64) //!< Least significant byte of 1st rank of \a u64.
|
||||
# define MSW(u64) (((U32 *)&(u64))[1]) //!< Most significant word of \a u64.
|
||||
# define LSW(u64) (((U32 *)&(u64))[0]) //!< Least significant word of \a u64.
|
||||
# define MSH0(u64) (((U16 *)&(u64))[3]) //!< Most significant half-word of 1st rank of \a u64.
|
||||
# define MSH1(u64) (((U16 *)&(u64))[2]) //!< Most significant half-word of 2nd rank of \a u64.
|
||||
# define MSH2(u64) (((U16 *)&(u64))[1]) //!< Most significant half-word of 3rd rank of \a u64.
|
||||
# define MSH3(u64) (((U16 *)&(u64))[0]) //!< Most significant half-word of 4th rank of \a u64.
|
||||
# define LSH3(u64) MSH0(u64) //!< Least significant half-word of 4th rank of \a u64.
|
||||
# define LSH2(u64) MSH1(u64) //!< Least significant half-word of 3rd rank of \a u64.
|
||||
# define LSH1(u64) MSH2(u64) //!< Least significant half-word of 2nd rank of \a u64.
|
||||
# define LSH0(u64) MSH3(u64) //!< Least significant half-word of 1st rank of \a u64.
|
||||
# define MSB0D(u64) (((U8 *)&(u64))[7]) //!< Most significant byte of 1st rank of \a u64.
|
||||
# define MSB1D(u64) (((U8 *)&(u64))[6]) //!< Most significant byte of 2nd rank of \a u64.
|
||||
# define MSB2D(u64) (((U8 *)&(u64))[5]) //!< Most significant byte of 3rd rank of \a u64.
|
||||
# define MSB3D(u64) (((U8 *)&(u64))[4]) //!< Most significant byte of 4th rank of \a u64.
|
||||
# define MSB4D(u64) (((U8 *)&(u64))[3]) //!< Most significant byte of 5th rank of \a u64.
|
||||
# define MSB5D(u64) (((U8 *)&(u64))[2]) //!< Most significant byte of 6th rank of \a u64.
|
||||
# define MSB6D(u64) (((U8 *)&(u64))[1]) //!< Most significant byte of 7th rank of \a u64.
|
||||
# define MSB7D(u64) (((U8 *)&(u64))[0]) //!< Most significant byte of 8th rank of \a u64.
|
||||
# define LSB7D(u64) MSB0D(u64) //!< Least significant byte of 8th rank of \a u64.
|
||||
# define LSB6D(u64) MSB1D(u64) //!< Least significant byte of 7th rank of \a u64.
|
||||
# define LSB5D(u64) MSB2D(u64) //!< Least significant byte of 6th rank of \a u64.
|
||||
# define LSB4D(u64) MSB3D(u64) //!< Least significant byte of 5th rank of \a u64.
|
||||
# define LSB3D(u64) MSB4D(u64) //!< Least significant byte of 4th rank of \a u64.
|
||||
# define LSB2D(u64) MSB5D(u64) //!< Least significant byte of 3rd rank of \a u64.
|
||||
# define LSB1D(u64) MSB6D(u64) //!< Least significant byte of 2nd rank of \a u64.
|
||||
# define LSB0D(u64) MSB7D(u64) //!< Least significant byte of 1st rank of \a u64.
|
||||
|
||||
# define LSB0(u32) LSB0W(u32) //!< Least significant byte of 1st rank of \a u32.
|
||||
# define LSB1(u32) LSB1W(u32) //!< Least significant byte of 2nd rank of \a u32.
|
||||
# define LSB2(u32) LSB2W(u32) //!< Least significant byte of 3rd rank of \a u32.
|
||||
# define LSB3(u32) LSB3W(u32) //!< Least significant byte of 4th rank of \a u32.
|
||||
# define MSB3(u32) MSB3W(u32) //!< Most significant byte of 4th rank of \a u32.
|
||||
# define MSB2(u32) MSB2W(u32) //!< Most significant byte of 3rd rank of \a u32.
|
||||
# define MSB1(u32) MSB1W(u32) //!< Most significant byte of 2nd rank of \a u32.
|
||||
# define MSB0(u32) MSB0W(u32) //!< Most significant byte of 1st rank of \a u32.
|
||||
# define LSB0(u32) LSB0W(u32) //!< Least significant byte of 1st rank of \a u32.
|
||||
# define LSB1(u32) LSB1W(u32) //!< Least significant byte of 2nd rank of \a u32.
|
||||
# define LSB2(u32) LSB2W(u32) //!< Least significant byte of 3rd rank of \a u32.
|
||||
# define LSB3(u32) LSB3W(u32) //!< Least significant byte of 4th rank of \a u32.
|
||||
# define MSB3(u32) MSB3W(u32) //!< Most significant byte of 4th rank of \a u32.
|
||||
# define MSB2(u32) MSB2W(u32) //!< Most significant byte of 3rd rank of \a u32.
|
||||
# define MSB1(u32) MSB1W(u32) //!< Most significant byte of 2nd rank of \a u32.
|
||||
# define MSB0(u32) MSB0W(u32) //!< Most significant byte of 1st rank of \a u32.
|
||||
|
||||
# if defined(__ICCARM__)
|
||||
# define SHORTENUM __packed
|
||||
@@ -1031,7 +1031,9 @@ 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) {
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
#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_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)
|
||||
@@ -161,4 +161,4 @@
|
||||
#include "usb_main.h"
|
||||
#include "ui.h"
|
||||
|
||||
#endif // _CONF_USB_H_
|
||||
#endif // _CONF_USB_H_
|
||||
|
||||
@@ -25,15 +25,25 @@ 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();
|
||||
}
|
||||
|
||||
volatile bool main_b_kbd_enable = false;
|
||||
bool main_kbd_enable(void) {
|
||||
@@ -41,7 +51,9 @@ bool main_kbd_enable(void) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void main_kbd_disable(void) { main_b_kbd_enable = false; }
|
||||
void main_kbd_disable(void) {
|
||||
main_b_kbd_enable = false;
|
||||
}
|
||||
|
||||
#ifdef NKRO_ENABLE
|
||||
volatile bool main_b_nkro_enable = false;
|
||||
@@ -50,7 +62,9 @@ bool main_nkro_enable(void) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void main_nkro_disable(void) { main_b_nkro_enable = false; }
|
||||
void main_nkro_disable(void) {
|
||||
main_b_nkro_enable = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
@@ -60,7 +74,9 @@ bool main_exk_enable(void) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void main_exk_disable(void) { main_b_exk_enable = false; }
|
||||
void main_exk_disable(void) {
|
||||
main_b_exk_enable = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONSOLE_ENABLE
|
||||
@@ -70,7 +86,9 @@ bool main_con_enable(void) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void main_con_disable(void) { main_b_con_enable = false; }
|
||||
void main_con_disable(void) {
|
||||
main_b_con_enable = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOUSE_ENABLE
|
||||
@@ -80,7 +98,9 @@ bool main_mou_enable(void) {
|
||||
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_ENABLE
|
||||
@@ -90,7 +110,11 @@ bool main_raw_enable(void) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void main_raw_disable(void) { main_b_raw_enable = false; }
|
||||
void main_raw_disable(void) {
|
||||
main_b_raw_enable = false;
|
||||
}
|
||||
|
||||
void main_raw_receive(uint8_t *buffer, uint8_t len) { raw_hid_receive(buffer, len); }
|
||||
void main_raw_receive(uint8_t *buffer, uint8_t len) {
|
||||
raw_hid_receive(buffer, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -124,20 +124,20 @@ typedef enum status_code status_code_genare_t;
|
||||
*/
|
||||
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
|
||||
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
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
#include "udi.h"
|
||||
#include "udc.h"
|
||||
|
||||
#define BOOTLOADER_SERIAL_MAX_SIZE 20 // DO NOT MODIFY!
|
||||
#define BOOTLOADER_SERIAL_MAX_SIZE 20 // DO NOT MODIFY!
|
||||
|
||||
/**
|
||||
* \ingroup udc_group
|
||||
@@ -132,13 +132,13 @@ uint8_t bootloader_serial_number[BOOTLOADER_SERIAL_MAX_SIZE + 1] = "";
|
||||
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
|
||||
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
|
||||
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) {
|
||||
@@ -149,7 +149,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
|
||||
@@ -157,9 +157,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
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ static const uint8_t *udc_get_string_serial_name(void) {
|
||||
*/
|
||||
#ifndef BOOTLOADER_SERIAL_MAX_SIZE
|
||||
# define BOOTLOADER_SERIAL_MAX_SIZE 0
|
||||
#endif // BOOTLOADER_SERIAL_MAX_SIZE
|
||||
#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)];
|
||||
@@ -178,14 +178,18 @@ COMPILER_WORD_ALIGNED
|
||||
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)
|
||||
/**
|
||||
@@ -209,15 +213,15 @@ static usb_conf_desc_t UDC_DESC_STORAGE *udc_next_desc_in_iface(usb_conf_desc_t
|
||||
// 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);
|
||||
}
|
||||
return NULL; // No specific descriptor found
|
||||
return NULL; // No specific descriptor found
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -251,13 +255,13 @@ static bool udc_update_iface_desc(uint8_t iface_num, uint8_t setting_num) {
|
||||
// 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
|
||||
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);
|
||||
}
|
||||
return false; // Interface not found
|
||||
return false; // Interface not found
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -343,7 +347,9 @@ 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
|
||||
*/
|
||||
@@ -510,7 +516,7 @@ static bool udc_req_std_dev_set_feature(void) {
|
||||
udd_g_ctrlreq.callback = udd_test_mode_packet;
|
||||
return true;
|
||||
|
||||
case USB_DEV_TEST_MODE_FORCE_ENABLE: // Only for downstream facing hub ports
|
||||
case USB_DEV_TEST_MODE_FORCE_ENABLE: // Only for downstream facing hub ports
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -544,7 +550,9 @@ 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
|
||||
@@ -763,7 +771,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
|
||||
@@ -796,10 +804,10 @@ static bool udc_req_std_iface_get_setting(void) {
|
||||
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
|
||||
@@ -832,10 +840,10 @@ 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;
|
||||
@@ -859,7 +867,7 @@ 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()) {
|
||||
@@ -953,7 +961,7 @@ static bool udc_req_iface(void) {
|
||||
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;
|
||||
@@ -987,7 +995,7 @@ static bool udc_req_ep(void) {
|
||||
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;
|
||||
@@ -1027,7 +1035,7 @@ bool udc_process_setup(void) {
|
||||
|
||||
if (Udd_setup_is_in()) {
|
||||
if (udd_g_ctrlreq.req.wLength == 0) {
|
||||
return false; // Error from USB host
|
||||
return false; // Error from USB host
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1055,7 +1063,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
|
||||
|
||||
@@ -172,7 +172,9 @@ 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
|
||||
*/
|
||||
@@ -189,19 +191,25 @@ 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
|
||||
@@ -245,4 +253,4 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _UDC_H_
|
||||
#endif // _UDC_H_
|
||||
|
||||
@@ -129,4 +129,4 @@ extern UDC_DESC_STORAGE udc_config_t udc_config;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // _UDC_DESC_H_
|
||||
#endif // _UDC_DESC_H_
|
||||
|
||||
@@ -381,4 +381,4 @@ extern void udc_sof_notify(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // _UDD_H_
|
||||
#endif // _UDD_H_
|
||||
|
||||
@@ -130,4 +130,4 @@ typedef struct {
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // _UDI_H_
|
||||
#endif // _UDI_H_
|
||||
|
||||
@@ -386,7 +386,7 @@ bool udi_cdc_comm_setup(void) {
|
||||
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
|
||||
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;
|
||||
@@ -400,7 +400,7 @@ bool udi_cdc_comm_setup(void) {
|
||||
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
|
||||
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);
|
||||
@@ -417,15 +417,15 @@ bool udi_cdc_comm_setup(void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return false; // request Not supported
|
||||
return false; // request Not supported
|
||||
}
|
||||
|
||||
bool udi_cdc_data_setup(void) {
|
||||
return false; // request Not supported
|
||||
return false; // request Not supported
|
||||
}
|
||||
|
||||
uint8_t udi_cdc_getsetting(void) {
|
||||
return 0; // CDC don't have multiple alternate setting
|
||||
return 0; // CDC don't have multiple alternate setting
|
||||
}
|
||||
|
||||
void udi_cdc_data_sof_notify(void) {
|
||||
@@ -476,7 +476,7 @@ static void udi_cdc_line_coding_received(void) {
|
||||
|
||||
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
|
||||
port = 0;
|
||||
@@ -514,7 +514,7 @@ static void udi_cdc_ctrl_state_change(uint8_t port, bool b_set, le16_t bit_mask)
|
||||
}
|
||||
|
||||
static void udi_cdc_ctrl_state_notify(uint8_t port, 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
|
||||
|
||||
@@ -562,7 +562,7 @@ 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
|
||||
uint32_t irqflags; // irqflags_t
|
||||
uint8_t buf_sel_trans;
|
||||
udd_ep_id_t ep;
|
||||
|
||||
@@ -685,7 +685,7 @@ static void udi_cdc_data_sent(udd_ep_status_t status, iram_size_t n, udd_ep_id_t
|
||||
}
|
||||
|
||||
static void udi_cdc_tx_send(uint8_t port) {
|
||||
uint32_t irqflags; // irqflags_t
|
||||
uint32_t irqflags; // irqflags_t
|
||||
uint8_t buf_sel_trans;
|
||||
bool b_short_packet;
|
||||
udd_ep_id_t ep;
|
||||
@@ -696,15 +696,15 @@ static void udi_cdc_tx_send(uint8_t port) {
|
||||
//#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 {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -743,7 +743,7 @@ static void udi_cdc_tx_send(uint8_t port) {
|
||||
udi_cdc_tx_sof_num[port] = udd_get_frame_number();
|
||||
}
|
||||
} else {
|
||||
udi_cdc_tx_sof_num[port] = 0; // Force next transfer without wait SOF
|
||||
udi_cdc_tx_sof_num[port] = 0; // Force next transfer without wait SOF
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -768,28 +768,48 @@ static void udi_cdc_tx_send(uint8_t port) {
|
||||
//---------------------------------------------
|
||||
//------- 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
|
||||
uint32_t irqflags; // irqflags_t
|
||||
uint16_t pos;
|
||||
iram_size_t nb_received;
|
||||
|
||||
@@ -807,14 +827,20 @@ iram_size_t udi_cdc_multi_get_nb_received_data(uint8_t port) {
|
||||
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
|
||||
uint32_t irqflags; // irqflags_t
|
||||
int rx_data = 0;
|
||||
bool b_databit_9;
|
||||
uint16_t pos;
|
||||
@@ -859,10 +885,12 @@ 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
|
||||
uint32_t irqflags; // irqflags_t
|
||||
uint8_t * ptr_buf = (uint8_t *)buf;
|
||||
iram_size_t copy_nb;
|
||||
uint16_t pos;
|
||||
@@ -912,7 +940,7 @@ static iram_size_t udi_cdc_multi_read_no_polling(uint8_t port, void *buf, iram_s
|
||||
iram_size_t nb_avail_data;
|
||||
uint16_t pos;
|
||||
uint8_t buf_sel;
|
||||
uint32_t irqflags; // irqflags_t
|
||||
uint32_t irqflags; // irqflags_t
|
||||
|
||||
//#if UDI_CDC_PORT_NB == 1 // To optimize code
|
||||
port = 0;
|
||||
@@ -952,12 +980,16 @@ static iram_size_t udi_cdc_multi_read_no_polling(uint8_t port, void *buf, iram_s
|
||||
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
|
||||
uint32_t irqflags; // irqflags_t
|
||||
iram_size_t buf_sel_nb, retval;
|
||||
uint8_t buf_sel;
|
||||
|
||||
@@ -986,14 +1018,20 @@ iram_size_t udi_cdc_multi_get_free_tx_buffer(uint8_t port) {
|
||||
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
|
||||
uint32_t irqflags; // irqflags_t
|
||||
bool b_databit_9;
|
||||
uint8_t buf_sel;
|
||||
|
||||
@@ -1030,10 +1068,12 @@ 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
|
||||
uint32_t irqflags; // irqflags_t
|
||||
uint8_t buf_sel;
|
||||
uint16_t buf_nb;
|
||||
iram_size_t copy_nb;
|
||||
@@ -1083,7 +1123,9 @@ udi_cdc_write_buf_loop_wait:
|
||||
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
|
||||
@@ -1121,10 +1163,10 @@ uint32_t CDC_print(char *printbuf) {
|
||||
char printbuf[CDC_PRINTBUF_SIZE];
|
||||
|
||||
int CDC_printf(const char *_Format, ...) {
|
||||
va_list va; // Variable argument list variable
|
||||
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);
|
||||
|
||||
@@ -1146,18 +1188,18 @@ uint32_t CDC_input_buf(inbuf_t inbuf, uint32_t inbuf_size) {
|
||||
|
||||
if (RXChar) {
|
||||
switch (RXChar) {
|
||||
case '\t': // tab - repeat last
|
||||
case '\t': // tab - repeat last
|
||||
inbuf.count = inbuf.lastcount;
|
||||
inbuf.buf[inbuf.count + 1] = 0;
|
||||
CDC_print(inbuf.buf);
|
||||
break;
|
||||
case '\r': // enter
|
||||
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");
|
||||
@@ -1181,7 +1223,9 @@ uint32_t CDC_input_buf(inbuf_t inbuf, uint32_t inbuf_size) {
|
||||
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;
|
||||
@@ -1190,19 +1234,27 @@ void CDC_init(void) {
|
||||
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;
|
||||
@@ -1210,6 +1262,6 @@ void CDC_init(void) {
|
||||
printbuf[0] = 0;
|
||||
}
|
||||
|
||||
#endif // CDC line 62
|
||||
#endif // CDC line 62
|
||||
|
||||
//@}
|
||||
|
||||
@@ -346,7 +346,7 @@ typedef struct {
|
||||
char buf[CDC_INBUF_SIZE];
|
||||
} inbuf_t;
|
||||
|
||||
#else // VIRTSER_ENABLE
|
||||
#else // VIRTSER_ENABLE
|
||||
|
||||
// keep these to accommodate calls if remaining
|
||||
# define CDC_PRINTBUF_SIZE 1
|
||||
@@ -362,7 +362,7 @@ typedef struct {
|
||||
|
||||
extern inbuf_t inbuf;
|
||||
|
||||
#endif // VIRTSER_ENABLE
|
||||
#endif // VIRTSER_ENABLE
|
||||
|
||||
uint32_t CDC_print(char* printbuf);
|
||||
int CDC_printf(const char* _Format, ...);
|
||||
@@ -373,4 +373,4 @@ void CDC_init(void);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _UDI_CDC_H_
|
||||
#endif // _UDI_CDC_H_
|
||||
|
||||
@@ -59,9 +59,9 @@
|
||||
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)
|
||||
@@ -69,4 +69,4 @@ extern "C" {
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // _UDI_CDC_CONF_H_
|
||||
#endif // _UDI_CDC_CONF_H_
|
||||
|
||||
@@ -220,7 +220,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# 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_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
|
||||
@@ -370,7 +370,7 @@ extern udi_hid_exk_report_t udi_hid_exk_report;
|
||||
|
||||
COMPILER_PACK_RESET()
|
||||
|
||||
#endif // EXTRAKEY_ENABLE
|
||||
#endif // EXTRAKEY_ENABLE
|
||||
|
||||
// **********************************************************************
|
||||
// NKRO Descriptor structure and content
|
||||
@@ -433,7 +433,7 @@ extern uint8_t udi_hid_nkro_report[UDI_HID_NKRO_REPORT_SIZE];
|
||||
|
||||
COMPILER_PACK_RESET()
|
||||
|
||||
#endif // NKRO_ENABLE
|
||||
#endif // NKRO_ENABLE
|
||||
|
||||
// **********************************************************************
|
||||
// MOU Descriptor structure and content
|
||||
@@ -449,7 +449,7 @@ typedef struct {
|
||||
} 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;
|
||||
|
||||
// clang-format off
|
||||
@@ -488,12 +488,12 @@ typedef struct {
|
||||
// clang-format on
|
||||
|
||||
// report buffer
|
||||
# define UDI_HID_MOU_REPORT_SIZE 5 // MOU PDS
|
||||
# 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 // MOUSE_ENABLE
|
||||
#endif // MOUSE_ENABLE
|
||||
|
||||
// **********************************************************************
|
||||
// RAW Descriptor structure and content
|
||||
@@ -565,7 +565,7 @@ extern uint8_t udi_hid_raw_report[UDI_HID_RAW_REPORT_SIZE];
|
||||
|
||||
COMPILER_PACK_RESET()
|
||||
|
||||
#endif // RAW_ENABLE
|
||||
#endif // RAW_ENABLE
|
||||
|
||||
// **********************************************************************
|
||||
// CON Descriptor structure and content
|
||||
@@ -637,7 +637,7 @@ extern uint8_t udi_hid_con_report[UDI_HID_CON_REPORT_SIZE];
|
||||
|
||||
COMPILER_PACK_RESET()
|
||||
|
||||
#endif // CONSOLE_ENABLE
|
||||
#endif // CONSOLE_ENABLE
|
||||
|
||||
// **********************************************************************
|
||||
// CDC Descriptor structure and content
|
||||
@@ -780,7 +780,7 @@ typedef struct {
|
||||
|
||||
COMPILER_PACK_RESET()
|
||||
|
||||
#endif // VIRTSER_ENABLE
|
||||
#endif // VIRTSER_ENABLE
|
||||
|
||||
// **********************************************************************
|
||||
// CONFIGURATION Descriptor structure and content
|
||||
@@ -815,4 +815,4 @@ typedef struct {
|
||||
|
||||
COMPILER_PACK_RESET()
|
||||
|
||||
#endif //_UDI_DEVICE_CONF_H_
|
||||
#endif //_UDI_DEVICE_CONF_H_
|
||||
|
||||
@@ -28,4 +28,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define CDC_NOTIFICATION_EPSIZE 8
|
||||
#define CDC_EPSIZE 16
|
||||
|
||||
#endif //_UDI_DEVICE_EPSIZE_H_
|
||||
#endif //_UDI_DEVICE_EPSIZE_H_
|
||||
|
||||
@@ -110,7 +110,7 @@ bool udi_hid_setup(uint8_t *rate, uint8_t *protocol, uint8_t *report_desc, bool
|
||||
}
|
||||
}
|
||||
}
|
||||
return false; // Request not supported
|
||||
return false; // Request not supported
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
|
||||
@@ -82,4 +82,4 @@ bool udi_hid_setup(uint8_t *rate, uint8_t *protocol, uint8_t *report_desc, bool
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // _UDI_HID_H_
|
||||
#endif // _UDI_HID_H_
|
||||
|
||||
@@ -94,42 +94,42 @@ 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, 0x01, // Usage Page (Generic Desktop)
|
||||
0x09, 0x06, // Usage (Keyboard)
|
||||
0xA1, 0x01, // Collection (Application)
|
||||
// Modifiers (8 bits)
|
||||
0x05, 0x07, // Usage Page (Keyboard)
|
||||
0x19, 0xE0, // Usage Minimum (Keyboard Left Control)
|
||||
0x29, 0xE7, // Usage Maximum (Keyboard Right GUI)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x25, 0x01, // Logical Maximum (1)
|
||||
0x95, 0x08, // Report Count (8)
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x81, 0x02, // Input (Data, Variable, Absolute)
|
||||
0x05, 0x07, // Usage Page (Keyboard)
|
||||
0x19, 0xE0, // Usage Minimum (Keyboard Left Control)
|
||||
0x29, 0xE7, // Usage Maximum (Keyboard Right GUI)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x25, 0x01, // Logical Maximum (1)
|
||||
0x95, 0x08, // Report Count (8)
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x81, 0x02, // Input (Data, Variable, Absolute)
|
||||
// Reserved (1 byte)
|
||||
0x81, 0x01, // Input (Constant)
|
||||
0x81, 0x01, // Input (Constant)
|
||||
// Keycodes (6 bytes)
|
||||
0x19, 0x00, // Usage Minimum (0)
|
||||
0x29, 0xFF, // Usage Maximum (255)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x25, 0xFF, // Logical Maximum (255)
|
||||
0x95, 0x06, // Report Count (6)
|
||||
0x75, 0x08, // Report Size (8)
|
||||
0x81, 0x00, // Input (Data, Array, Absolute)
|
||||
0x19, 0x00, // Usage Minimum (0)
|
||||
0x29, 0xFF, // Usage Maximum (255)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x25, 0xFF, // Logical Maximum (255)
|
||||
0x95, 0x06, // Report Count (6)
|
||||
0x75, 0x08, // Report Size (8)
|
||||
0x81, 0x00, // Input (Data, Array, Absolute)
|
||||
|
||||
// Status LEDs (5 bits)
|
||||
0x05, 0x08, // Usage Page (LED)
|
||||
0x19, 0x01, // Usage Minimum (Num Lock)
|
||||
0x29, 0x05, // Usage Maximum (Kana)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x25, 0x01, // Logical Maximum (1)
|
||||
0x95, 0x05, // Report Count (5)
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x91, 0x02, // Output (Data, Variable, Absolute)
|
||||
0x05, 0x08, // Usage Page (LED)
|
||||
0x19, 0x01, // Usage Minimum (Num Lock)
|
||||
0x29, 0x05, // Usage Maximum (Kana)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x25, 0x01, // Logical Maximum (1)
|
||||
0x95, 0x05, // Report Count (5)
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x91, 0x02, // Output (Data, Variable, Absolute)
|
||||
// LED padding (3 bits)
|
||||
0x95, 0x03, // Report Count (3)
|
||||
0x91, 0x01, // Output (Constant)
|
||||
0xC0 // End Collection
|
||||
0x95, 0x03, // Report Count (3)
|
||||
0x91, 0x01, // Output (Constant)
|
||||
0xC0 // End Collection
|
||||
}};
|
||||
|
||||
static bool udi_hid_kbd_setreport(void);
|
||||
@@ -148,11 +148,17 @@ bool udi_hid_kbd_enable(void) {
|
||||
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)) {
|
||||
@@ -234,41 +240,41 @@ 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)
|
||||
0x05, 0x01, // Usage Page (Generic Desktop)
|
||||
0x09, 0x06, // Usage (Keyboard)
|
||||
0xA1, 0x01, // Collection (Application)
|
||||
|
||||
// Modifiers (8 bits)
|
||||
0x05, 0x07, // Usage Page (Keyboard/Keypad)
|
||||
0x19, 0xE0, // Usage Minimum (Keyboard Left Control)
|
||||
0x29, 0xE7, // Usage Maximum (Keyboard Right GUI)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x25, 0x01, // Logical Maximum (1)
|
||||
0x95, 0x08, // Report Count (8)
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x81, 0x02, // Input (Data, Variable, Absolute)
|
||||
0x05, 0x07, // Usage Page (Keyboard/Keypad)
|
||||
0x19, 0xE0, // Usage Minimum (Keyboard Left Control)
|
||||
0x29, 0xE7, // Usage Maximum (Keyboard Right GUI)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x25, 0x01, // Logical Maximum (1)
|
||||
0x95, 0x08, // Report Count (8)
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x81, 0x02, // Input (Data, Variable, Absolute)
|
||||
// Keycodes
|
||||
0x05, 0x07, // Usage Page (Keyboard/Keypad)
|
||||
0x19, 0x00, // Usage Minimum (0)
|
||||
0x29, 0xF7, // Usage Maximum (247)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x25, 0x01, // Logical Maximum (1)
|
||||
0x95, 0xF8, // Report Count (248)
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield)
|
||||
0x05, 0x07, // Usage Page (Keyboard/Keypad)
|
||||
0x19, 0x00, // Usage Minimum (0)
|
||||
0x29, 0xF7, // Usage Maximum (247)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x25, 0x01, // Logical Maximum (1)
|
||||
0x95, 0xF8, // Report Count (248)
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x81, 0x02, // Input (Data, Variable, Absolute, Bitfield)
|
||||
|
||||
// Status LEDs (5 bits)
|
||||
0x05, 0x08, // Usage Page (LED)
|
||||
0x19, 0x01, // Usage Minimum (Num Lock)
|
||||
0x29, 0x05, // Usage Maximum (Kana)
|
||||
0x95, 0x05, // Report Count (5)
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x91, 0x02, // Output (Data, Variable, Absolute)
|
||||
0x05, 0x08, // Usage Page (LED)
|
||||
0x19, 0x01, // Usage Minimum (Num Lock)
|
||||
0x29, 0x05, // Usage Maximum (Kana)
|
||||
0x95, 0x05, // Report Count (5)
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x91, 0x02, // Output (Data, Variable, Absolute)
|
||||
// LED padding (3 bits)
|
||||
0x95, 0x01, // Report Count (1)
|
||||
0x75, 0x03, // Report Size (3)
|
||||
0x91, 0x03, // Output (Constant)
|
||||
0xC0 // End Collection
|
||||
0x95, 0x01, // Report Count (1)
|
||||
0x75, 0x03, // Report Size (3)
|
||||
0x91, 0x03, // Output (Constant)
|
||||
0xC0 // End Collection
|
||||
}};
|
||||
|
||||
static bool udi_hid_nkro_setreport(void);
|
||||
@@ -285,18 +291,24 @@ bool udi_hid_nkro_enable(void) {
|
||||
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)) {
|
||||
// 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.callback = udi_hid_nkro_setreport_valid; // must call routine to transform setreport to LED state
|
||||
udd_g_ctrlreq.payload_size = 1;
|
||||
return true;
|
||||
}
|
||||
@@ -333,7 +345,7 @@ static void udi_hid_nkro_setreport_valid(void) {
|
||||
// UDI_HID_NKRO_CHANGE_LED(udi_hid_nkro_report_set);
|
||||
}
|
||||
|
||||
#endif // NKRO_ENABLE
|
||||
#endif // NKRO_ENABLE
|
||||
|
||||
//********************************************************************************************
|
||||
// EXK (extra-keys) SYS-CTRL Keyboard
|
||||
|
||||
@@ -71,7 +71,7 @@ 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_ENABLE
|
||||
#endif // NKRO_ENABLE
|
||||
|
||||
//********************************************************************************************
|
||||
// SYS-CTRL interface
|
||||
@@ -81,7 +81,7 @@ 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 // EXTRAKEY_ENABLE
|
||||
#endif // EXTRAKEY_ENABLE
|
||||
|
||||
//********************************************************************************************
|
||||
// CON Console
|
||||
@@ -92,7 +92,7 @@ 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 // CONSOLE_ENABLE
|
||||
#endif // CONSOLE_ENABLE
|
||||
|
||||
//********************************************************************************************
|
||||
// MOU Mouse
|
||||
@@ -101,7 +101,7 @@ bool udi_hid_con_send_report(void);
|
||||
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 // MOUSE_ENABLE
|
||||
#endif // MOUSE_ENABLE
|
||||
|
||||
//********************************************************************************************
|
||||
// RAW Raw
|
||||
@@ -110,7 +110,7 @@ bool udi_hid_mou_send_report(void);
|
||||
extern UDC_DESC_STORAGE udi_api_t udi_api_hid_raw;
|
||||
bool udi_hid_raw_send_report(void);
|
||||
bool udi_hid_raw_receive_report(void);
|
||||
#endif // RAW_ENABLE
|
||||
#endif // RAW_ENABLE
|
||||
|
||||
//@}
|
||||
|
||||
@@ -118,4 +118,4 @@ bool udi_hid_raw_receive_report(void);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _UDC_HID_KBD_H_
|
||||
#endif // _UDC_HID_KBD_H_
|
||||
|
||||
@@ -57,4 +57,4 @@
|
||||
|
||||
#include "udi_hid_kbd.h"
|
||||
|
||||
#endif // _UDI_HID_KBD_CONF_H_
|
||||
#endif // _UDI_HID_KBD_CONF_H_
|
||||
|
||||
@@ -78,17 +78,17 @@ UDC_DESC_STORAGE usb_dev_desc_t udc_device_desc = {.bLength = sizeof(usb
|
||||
#ifdef USB_DEVICE_MANUFACTURE_NAME
|
||||
.iManufacturer = 1,
|
||||
#else
|
||||
.iManufacturer = 0, // No manufacture string
|
||||
.iManufacturer = 0, // No manufacture string
|
||||
#endif
|
||||
#ifdef USB_DEVICE_PRODUCT_NAME
|
||||
.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,
|
||||
#else
|
||||
.iSerialNumber = 0, // No serial string
|
||||
.iSerialNumber = 0, // No serial string
|
||||
#endif
|
||||
.bNumConfigurations = 1};
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
# 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"
|
||||
|
||||
|
||||
@@ -73,4 +73,4 @@ void ui_process(uint16_t framenumber);
|
||||
*/
|
||||
void ui_kbd_led(uint8_t value);
|
||||
|
||||
#endif // _UI_H_
|
||||
#endif // _UI_H_
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
#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>
|
||||
@@ -319,7 +319,7 @@ enum status_code usb_device_endpoint_enable_callback(struct usb_module *module_i
|
||||
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;
|
||||
@@ -329,7 +329,7 @@ enum status_code usb_device_endpoint_enable_callback(struct usb_module *module_i
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -377,7 +377,7 @@ enum status_code usb_device_endpoint_disable_callback(struct usb_module *module_
|
||||
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].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;
|
||||
@@ -387,7 +387,7 @@ enum status_code usb_device_endpoint_disable_callback(struct usb_module *module_
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -903,11 +903,17 @@ void USB_0_Handler(void) {
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
@@ -974,10 +980,10 @@ enum status_code usb_init(struct usb_module *module_inst, Usb *const hw, struct
|
||||
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
|
||||
@@ -996,7 +1002,7 @@ enum status_code usb_init(struct usb_module *module_inst, Usb *const hw, struct
|
||||
while (posc->DFLLSYNC.bit.DFLLCTRLB)
|
||||
;
|
||||
posc->DFLLCTRLB.bit.CCDIS = 1;
|
||||
posc->DFLLMUL.bit.MUL = 0xbb80; // 4800 x 1KHz
|
||||
posc->DFLLMUL.bit.MUL = 0xbb80; // 4800 x 1KHz
|
||||
while (posc->DFLLSYNC.bit.DFLLMUL)
|
||||
;
|
||||
posc->DFLLCTRLA.bit.ENABLE = 1;
|
||||
|
||||
@@ -319,14 +319,18 @@ enum status_code usb_init(struct usb_module *module_inst, Usb *const hw, struct
|
||||
*
|
||||
* \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
|
||||
@@ -348,7 +352,9 @@ 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
|
||||
@@ -356,7 +362,9 @@ static inline uint8_t usb_device_get_address(struct usb_module *module_inst) { r
|
||||
* \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
|
||||
@@ -364,7 +372,9 @@ 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
|
||||
@@ -372,14 +382,18 @@ 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
|
||||
@@ -387,7 +401,9 @@ 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
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
#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_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
|
||||
//! @}
|
||||
@@ -186,4 +186,4 @@
|
||||
|
||||
//! @}
|
||||
|
||||
#endif // _USB_ATMEL_H_
|
||||
#endif // _USB_ATMEL_H_
|
||||
|
||||
@@ -127,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 */
|
||||
@@ -363,11 +363,17 @@ 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) {
|
||||
struct usb_device_endpoint_config config_ep;
|
||||
@@ -436,7 +442,9 @@ bool udd_ep_alloc(udd_ep_id_t ep, uint8_t bmAttributes, uint16_t MaxEndpointSize
|
||||
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) {
|
||||
uint8_t ep_num = ep & USB_EP_ADDR_MASK;
|
||||
@@ -591,9 +599,13 @@ 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
|
||||
@@ -913,7 +925,7 @@ static void _usb_device_lpm_suspend(struct usb_module *module_inst, void *pointe
|
||||
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
|
||||
udd_sleep_mode(UDD_STATE_SUSPEND_LPM); // Enter in LPM SUSPEND mode
|
||||
udd_sleep_mode(UDD_STATE_SUSPEND_LPM); // Enter in LPM SUSPEND mode
|
||||
if ((*lpm_wakeup_enable)) {
|
||||
UDC_REMOTEWAKEUP_LPM_ENABLE();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ 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;
|
||||
|
||||
@@ -51,10 +51,10 @@ void USB_Hub_init(void) {
|
||||
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+
|
||||
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
|
||||
@@ -78,7 +78,7 @@ void USB_Hub_init(void) {
|
||||
DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLCTRLB_4);
|
||||
}
|
||||
posc->DFLLCTRLB.bit.CCDIS = 1;
|
||||
posc->DFLLMUL.bit.MUL = 0xBB80; // 4800 x 1KHz
|
||||
posc->DFLLMUL.bit.MUL = 0xBB80; // 4800 x 1KHz
|
||||
while (posc->DFLLSYNC.bit.DFLLMUL) {
|
||||
DBGC(DC_USB2422_INIT_OSC_SYNC_DFLLMUL);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ void USB_Hub_init(void) {
|
||||
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.CTRLB.bit.SPDCONF = 0; // full speed
|
||||
pusb->DEVICE.CTRLA.bit.MODE = 0;
|
||||
pusb->DEVICE.CTRLA.bit.ENABLE = 1;
|
||||
while (pusb->DEVICE.SYNCBUSY.bit.ENABLE) {
|
||||
@@ -111,8 +111,8 @@ void USB_Hub_init(void) {
|
||||
|
||||
USB2422_init();
|
||||
|
||||
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);
|
||||
@@ -122,7 +122,7 @@ void USB_Hub_init(void) {
|
||||
usb_extra_manual = 0;
|
||||
usb_gcr_auto = 1;
|
||||
|
||||
#endif // MD_BOOTLOADER
|
||||
#endif // MD_BOOTLOADER
|
||||
|
||||
DBGC(DC_USB2422_INIT_COMPLETE);
|
||||
}
|
||||
@@ -131,10 +131,10 @@ 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
|
||||
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);
|
||||
@@ -150,7 +150,9 @@ void USB_configure(void) {
|
||||
DBGC(DC_USB_CONFIGURE_COMPLETE);
|
||||
}
|
||||
|
||||
uint16_t USB_active(void) { return USB2422_active(); }
|
||||
uint16_t USB_active(void) {
|
||||
return USB2422_active();
|
||||
}
|
||||
|
||||
void USB_set_host_by_voltage(void) {
|
||||
// UP is upstream device (HOST)
|
||||
@@ -162,13 +164,13 @@ void USB_set_host_by_voltage(void) {
|
||||
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();
|
||||
|
||||
@@ -185,33 +187,33 @@ void USB_set_host_by_voltage(void) {
|
||||
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
|
||||
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
|
||||
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();
|
||||
|
||||
@@ -220,7 +222,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();
|
||||
@@ -241,7 +243,7 @@ uint8_t USB_Hub_Port_Detect_Init(void) {
|
||||
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) {
|
||||
@@ -249,7 +251,7 @@ uint8_t USB_Hub_Port_Detect_Init(void) {
|
||||
} else {
|
||||
DBG_LED_OFF;
|
||||
}
|
||||
} else if (v_con_2 > v_con_1) // Values updated from USB_set_host_by_voltage();
|
||||
} 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) {
|
||||
@@ -321,7 +323,7 @@ void USB_HandleExtraDevice(void) {
|
||||
// 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) {
|
||||
@@ -337,4 +339,4 @@ void USB_HandleExtraDevice(void) {
|
||||
USB_ExtraSetState(USB_EXTRA_STATE_DISABLED);
|
||||
}
|
||||
|
||||
#endif // MD_BOOTLOADER
|
||||
#endif // MD_BOOTLOADER
|
||||
|
||||
@@ -48,4 +48,4 @@ uint16_t adc_get(uint8_t muxpos);
|
||||
void USB_HandleExtraDevice(void);
|
||||
void USB_ExtraSetState(uint8_t state);
|
||||
|
||||
#endif //_USB2422_H_
|
||||
#endif //_USB2422_H_
|
||||
|
||||
@@ -71,31 +71,31 @@ void main_kbd_disable(void);
|
||||
extern volatile bool main_b_nkro_enable;
|
||||
bool main_nkro_enable(void);
|
||||
void main_nkro_disable(void);
|
||||
#endif // NKRO_ENABLE
|
||||
#endif // NKRO_ENABLE
|
||||
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
extern volatile bool main_b_exk_enable;
|
||||
bool main_exk_enable(void);
|
||||
void main_exk_disable(void);
|
||||
#endif // EXTRAKEY_ENABLE
|
||||
#endif // EXTRAKEY_ENABLE
|
||||
|
||||
#ifdef CONSOLE_ENABLE
|
||||
extern volatile bool main_b_con_enable;
|
||||
bool main_con_enable(void);
|
||||
void main_con_disable(void);
|
||||
#endif // CONSOLE_ENABLE
|
||||
#endif // CONSOLE_ENABLE
|
||||
|
||||
#ifdef MOUSE_ENABLE
|
||||
extern volatile bool main_b_mou_enable;
|
||||
bool main_mou_enable(void);
|
||||
void main_mou_disable(void);
|
||||
#endif // MOUSE_ENABLE
|
||||
#endif // MOUSE_ENABLE
|
||||
|
||||
#ifdef RAW_ENABLE
|
||||
extern volatile bool main_b_raw_enable;
|
||||
bool main_raw_enable(void);
|
||||
void main_raw_disable(void);
|
||||
void main_raw_receive(uint8_t *buffer, uint8_t len);
|
||||
#endif // RAW_ENABLE
|
||||
#endif // RAW_ENABLE
|
||||
|
||||
#endif // _MAIN_H_
|
||||
#endif // _MAIN_H_
|
||||
|
||||
@@ -63,8 +63,8 @@
|
||||
*/
|
||||
|
||||
//! 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)
|
||||
*/
|
||||
@@ -85,26 +85,26 @@
|
||||
/**
|
||||
* \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)
|
||||
@@ -149,8 +149,8 @@ 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_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
|
||||
@@ -261,7 +261,7 @@ enum usb_ep_type {
|
||||
* \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)
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -396,14 +396,14 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -420,25 +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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,41 +50,41 @@
|
||||
|
||||
#ifdef VIRTSER_ENABLE
|
||||
|
||||
# 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_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_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_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_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_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 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
|
||||
@@ -144,17 +144,17 @@ typedef struct {
|
||||
# pragma pack(pop)
|
||||
|
||||
enum cdc_char_format {
|
||||
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_1 = 0, //!< 1 stop bit
|
||||
CDC_STOP_BITS_1_5 = 1, //!< 1.5 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_SPACE = 4, //!< Parity forced to 1 (mark)
|
||||
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 {
|
||||
@@ -187,4 +187,4 @@ typedef struct {
|
||||
|
||||
#endif
|
||||
|
||||
#endif // _USB_PROTOCOL_CDC_H_
|
||||
#endif // _USB_PROTOCOL_CDC_H_
|
||||
|
||||
@@ -121,13 +121,13 @@ 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()
|
||||
@@ -151,45 +151,45 @@ COMPILER_PACK_RESET()
|
||||
|
||||
//! \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_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
|
||||
//! @}
|
||||
//! @}
|
||||
35 // Turkish-F
|
||||
//! @}
|
||||
//! @}
|
||||
//! @}
|
||||
|
||||
//! \name HID KEYS values
|
||||
@@ -237,12 +237,12 @@ COMPILER_PACK_RESET()
|
||||
#define HID_SPACEBAR 44
|
||||
#define HID_UNDERSCORE 45
|
||||
#define HID_PLUS 46
|
||||
#define HID_OPEN_BRACKET 47 // {
|
||||
#define HID_CLOSE_BRACKET 48 // }
|
||||
#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_ASH 50 // # ~
|
||||
#define HID_COLON 51 // ; :
|
||||
#define HID_QUOTE 52 // ' "
|
||||
#define HID_TILDE 53
|
||||
#define HID_COMMA 54
|
||||
#define HID_DOT 55
|
||||
@@ -314,4 +314,4 @@ COMPILER_PACK_RESET()
|
||||
#define HID_LED_KANA (1 << 4)
|
||||
//! @}
|
||||
|
||||
#endif // _USB_PROTOCOL_HID_H_
|
||||
#endif // _USB_PROTOCOL_HID_H_
|
||||
|
||||
@@ -11,17 +11,17 @@ char digit(int d, int radix) {
|
||||
}
|
||||
|
||||
int UTIL_ltoa_radix(int64_t value, char *dest, int radix) {
|
||||
int64_t original = value; // save original value
|
||||
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);
|
||||
buf[--c] = digit(d, radix);
|
||||
@@ -30,14 +30,20 @@ int UTIL_ltoa_radix(int64_t value, char *dest, int radix) {
|
||||
|
||||
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_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_utoa(uint32_t value, char *dest) {
|
||||
return UTIL_ltoa_radix((int64_t)value, dest, 10);
|
||||
}
|
||||
|
||||
@@ -6,4 +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_
|
||||
|
||||
Reference in New Issue
Block a user