Replace uint8_t with u8 et al, fix whitespace.
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
|
||||
struct _usbd_device _usbd_device;
|
||||
|
||||
uint8_t usbd_control_buffer[128] __attribute__((weak));
|
||||
u8 usbd_control_buffer[128] __attribute__((weak));
|
||||
|
||||
/** Main initialization entry point.
|
||||
*
|
||||
@@ -77,7 +77,7 @@ void usbd_register_resume_callback(void (*callback)(void))
|
||||
_usbd_device.user_callback_resume = callback;
|
||||
}
|
||||
|
||||
void usbd_set_control_buffer_size(uint16_t size)
|
||||
void usbd_set_control_buffer_size(u16 size)
|
||||
{
|
||||
_usbd_device.ctrl_buf_len = size;
|
||||
}
|
||||
|
||||
@@ -29,15 +29,15 @@ static struct usb_control_state {
|
||||
|
||||
struct usb_setup_data req;
|
||||
|
||||
uint8_t *ctrl_buf;
|
||||
uint16_t ctrl_len;
|
||||
u8 *ctrl_buf;
|
||||
u16 ctrl_len;
|
||||
|
||||
void (*complete)(struct usb_setup_data *req);
|
||||
} control_state;
|
||||
|
||||
/** Register application callback function for handling of usb control
|
||||
* request. */
|
||||
int usbd_register_control_callback(uint8_t type, uint8_t type_mask,
|
||||
int usbd_register_control_callback(u8 type, u8 type_mask,
|
||||
usbd_control_callback callback)
|
||||
{
|
||||
int i;
|
||||
@@ -76,10 +76,10 @@ static void usb_control_send_chunk(void)
|
||||
|
||||
static int usb_control_recv_chunk(void)
|
||||
{
|
||||
uint16_t packetsize = MIN(_usbd_device.desc->bMaxPacketSize0,
|
||||
u16 packetsize = MIN(_usbd_device.desc->bMaxPacketSize0,
|
||||
control_state.req.wLength -
|
||||
control_state.ctrl_len);
|
||||
uint16_t size = usbd_ep_read_packet(0,
|
||||
u16 size = usbd_ep_read_packet(0,
|
||||
control_state.ctrl_buf + control_state.ctrl_len,
|
||||
packetsize);
|
||||
|
||||
@@ -156,7 +156,7 @@ static void usb_control_setup_write(struct usb_setup_data *req)
|
||||
else control_state.state = LAST_DATA_OUT;
|
||||
}
|
||||
|
||||
void _usbd_control_setup(uint8_t ea)
|
||||
void _usbd_control_setup(u8 ea)
|
||||
{
|
||||
struct usb_setup_data *req = &control_state.req;
|
||||
(void)ea;
|
||||
@@ -177,7 +177,7 @@ void _usbd_control_setup(uint8_t ea)
|
||||
}
|
||||
}
|
||||
|
||||
void _usbd_control_out(uint8_t ea)
|
||||
void _usbd_control_out(u8 ea)
|
||||
{
|
||||
(void)ea;
|
||||
|
||||
@@ -221,7 +221,7 @@ void _usbd_control_out(uint8_t ea)
|
||||
}
|
||||
}
|
||||
|
||||
void _usbd_control_in(uint8_t ea)
|
||||
void _usbd_control_in(u8 ea)
|
||||
{
|
||||
(void)ea;
|
||||
switch(control_state.state) {
|
||||
|
||||
@@ -153,10 +153,10 @@ u8 usbd_ep_stall_get(u8 addr)
|
||||
* @param len Number of bytes to copy.
|
||||
*/
|
||||
static inline void
|
||||
usb_copy_to_pm(volatile void *vPM, const void *buf, uint16_t len)
|
||||
usb_copy_to_pm(volatile void *vPM, const void *buf, u16 len)
|
||||
{
|
||||
const uint16_t *lbuf = buf;
|
||||
volatile uint16_t *PM = vPM;
|
||||
const u16 *lbuf = buf;
|
||||
volatile u16 *PM = vPM;
|
||||
|
||||
for(len = (len + 1) >> 1; len; PM += 2, lbuf++, len--)
|
||||
*PM = *lbuf;
|
||||
@@ -182,16 +182,16 @@ u16 usbd_ep_write_packet(u8 addr, const void *buf, u16 len)
|
||||
* @param len Number of bytes to copy.
|
||||
*/
|
||||
static inline void
|
||||
usb_copy_from_pm(void *buf, const volatile void *vPM, uint16_t len)
|
||||
usb_copy_from_pm(void *buf, const volatile void *vPM, u16 len)
|
||||
{
|
||||
uint16_t *lbuf = buf;
|
||||
const volatile uint16_t *PM = vPM;
|
||||
uint8_t odd = len & 1;
|
||||
u16 *lbuf = buf;
|
||||
const volatile u16 *PM = vPM;
|
||||
u8 odd = len & 1;
|
||||
|
||||
for(len >>= 1; len; PM += 2, lbuf++, len--)
|
||||
*lbuf = *PM;
|
||||
|
||||
if(odd) *(uint8_t*)lbuf = *(uint8_t*)PM;
|
||||
if(odd) *(u8*)lbuf = *(u8*)PM;
|
||||
}
|
||||
|
||||
u16 usbd_ep_read_packet(u8 addr, void *buf, u16 len)
|
||||
|
||||
@@ -30,13 +30,13 @@ extern struct _usbd_device {
|
||||
const struct usb_config_descriptor *config;
|
||||
const char **strings;
|
||||
|
||||
uint8_t *ctrl_buf; /**< Internal buffer used for control transfers */
|
||||
uint16_t ctrl_buf_len;
|
||||
u8 *ctrl_buf; /**< Internal buffer used for control transfers */
|
||||
u16 ctrl_buf_len;
|
||||
|
||||
uint8_t current_address;
|
||||
uint8_t current_config;
|
||||
u8 current_address;
|
||||
u8 current_config;
|
||||
|
||||
uint16_t pm_top; /**< Top of allocated endpoint buffer memory */
|
||||
u16 pm_top; /**< Top of allocated endpoint buffer memory */
|
||||
|
||||
/* User callback functions for various USB events */
|
||||
void (*user_callback_reset)(void);
|
||||
@@ -45,14 +45,14 @@ extern struct _usbd_device {
|
||||
|
||||
struct user_control_callback {
|
||||
usbd_control_callback cb;
|
||||
uint8_t type;
|
||||
uint8_t type_mask;
|
||||
u8 type;
|
||||
u8 type_mask;
|
||||
} user_control_callback[MAX_USER_CONTROL_CALLBACK];
|
||||
|
||||
void (*user_callback_ctr[8][3])(uint8_t ea);
|
||||
void (*user_callback_ctr[8][3])(u8 ea);
|
||||
|
||||
/* User callback function for some standard USB function hooks */
|
||||
void (*user_callback_set_config)(uint16_t wValue);
|
||||
void (*user_callback_set_config)(u16 wValue);
|
||||
} _usbd_device;
|
||||
|
||||
enum _usbd_transaction {
|
||||
@@ -61,18 +61,18 @@ enum _usbd_transaction {
|
||||
USB_TRANSACTION_SETUP,
|
||||
};
|
||||
|
||||
void _usbd_control_in(uint8_t ea);
|
||||
void _usbd_control_out(uint8_t ea);
|
||||
void _usbd_control_setup(uint8_t ea);
|
||||
void _usbd_control_in(u8 ea);
|
||||
void _usbd_control_out(u8 ea);
|
||||
void _usbd_control_setup(u8 ea);
|
||||
|
||||
int _usbd_standard_request(struct usb_setup_data *req,
|
||||
uint8_t **buf, uint16_t *len);
|
||||
u8 **buf, u16 *len);
|
||||
|
||||
void _usbd_reset(void);
|
||||
|
||||
/* Functions provided by the hardware abstraction */
|
||||
void _usbd_hw_init(void);
|
||||
void _usbd_hw_set_address(uint8_t addr);
|
||||
void _usbd_hw_set_address(u8 addr);
|
||||
void _usbd_hw_endpoints_reset(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,18 +21,18 @@
|
||||
#include <usb/usbd.h>
|
||||
#include "usb_private.h"
|
||||
|
||||
void usbd_register_set_config_callback(void (*callback)(uint16_t wValue))
|
||||
void usbd_register_set_config_callback(void (*callback)(u16 wValue))
|
||||
{
|
||||
_usbd_device.user_callback_set_config = callback;
|
||||
}
|
||||
|
||||
static uint16_t
|
||||
build_config_descriptor(uint8_t index, uint8_t *buf, uint16_t len)
|
||||
static u16
|
||||
build_config_descriptor(u8 index, u8 *buf, u16 len)
|
||||
{
|
||||
uint8_t *tmpbuf = buf;
|
||||
u8 *tmpbuf = buf;
|
||||
const struct usb_config_descriptor *cfg = &_usbd_device.config[index];
|
||||
uint16_t count, total = 0, totallen = 0;
|
||||
uint16_t i, j, k;
|
||||
u16 count, total = 0, totallen = 0;
|
||||
u16 i, j, k;
|
||||
|
||||
memcpy(buf, cfg, count = MIN(len, cfg->bLength));
|
||||
buf += count; len -= count; total += count; totallen += cfg->bLength;
|
||||
@@ -64,19 +64,19 @@ build_config_descriptor(uint8_t index, uint8_t *buf, uint16_t len)
|
||||
}
|
||||
|
||||
/* Fill in wTotalLength */
|
||||
*(uint16_t*)(tmpbuf+2) = totallen;
|
||||
*(u16*)(tmpbuf+2) = totallen;
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
static int usb_standard_get_descriptor(struct usb_setup_data *req,
|
||||
uint8_t **buf, uint16_t *len)
|
||||
u8 **buf, u16 *len)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch(req->wValue >> 8) {
|
||||
case USB_DT_DEVICE:
|
||||
*buf = (uint8_t *)_usbd_device.desc;
|
||||
*buf = (u8 *)_usbd_device.desc;
|
||||
*len = MIN(*len, _usbd_device.desc->bLength);
|
||||
return 1;
|
||||
|
||||
@@ -97,7 +97,7 @@ static int usb_standard_get_descriptor(struct usb_setup_data *req,
|
||||
* 2 + 2;
|
||||
sd->bDescriptorType = USB_DT_STRING;
|
||||
|
||||
*buf = (uint8_t *)sd;
|
||||
*buf = (u8 *)sd;
|
||||
*len = MIN(*len, sd->bLength);
|
||||
|
||||
for(i = 0; i < (*len / 2) - 1; i++)
|
||||
@@ -115,7 +115,7 @@ static int usb_standard_get_descriptor(struct usb_setup_data *req,
|
||||
}
|
||||
|
||||
static int usb_standard_set_address(struct usb_setup_data *req,
|
||||
uint8_t **buf, uint16_t *len)
|
||||
u8 **buf, u16 *len)
|
||||
{
|
||||
(void)req;
|
||||
(void)buf;
|
||||
@@ -130,7 +130,7 @@ static int usb_standard_set_address(struct usb_setup_data *req,
|
||||
}
|
||||
|
||||
static int usb_standard_set_configuration(struct usb_setup_data *req,
|
||||
uint8_t **buf, uint16_t *len)
|
||||
u8 **buf, u16 *len)
|
||||
{
|
||||
(void)req;
|
||||
(void)buf;
|
||||
@@ -151,7 +151,7 @@ static int usb_standard_set_configuration(struct usb_setup_data *req,
|
||||
}
|
||||
|
||||
static int usb_standard_get_configuration(struct usb_setup_data *req,
|
||||
uint8_t **buf, uint16_t *len)
|
||||
u8 **buf, u16 *len)
|
||||
{
|
||||
(void)req;
|
||||
|
||||
@@ -162,7 +162,7 @@ static int usb_standard_get_configuration(struct usb_setup_data *req,
|
||||
}
|
||||
|
||||
static int usb_standard_set_interface(struct usb_setup_data *req,
|
||||
uint8_t **buf, uint16_t *len)
|
||||
u8 **buf, u16 *len)
|
||||
{
|
||||
(void)req;
|
||||
(void)buf;
|
||||
@@ -175,7 +175,7 @@ static int usb_standard_set_interface(struct usb_setup_data *req,
|
||||
}
|
||||
|
||||
static int usb_standard_get_interface(struct usb_setup_data *req,
|
||||
uint8_t **buf, uint16_t *len)
|
||||
u8 **buf, u16 *len)
|
||||
{
|
||||
(void)req;
|
||||
(void)buf;
|
||||
@@ -188,7 +188,7 @@ static int usb_standard_get_interface(struct usb_setup_data *req,
|
||||
}
|
||||
|
||||
static int usb_standard_device_get_status(struct usb_setup_data *req,
|
||||
uint8_t **buf, uint16_t *len)
|
||||
u8 **buf, u16 *len)
|
||||
{
|
||||
(void)req;
|
||||
/* bit 0: self powered */
|
||||
@@ -201,7 +201,7 @@ static int usb_standard_device_get_status(struct usb_setup_data *req,
|
||||
}
|
||||
|
||||
static int usb_standard_interface_get_status(struct usb_setup_data *req,
|
||||
uint8_t **buf, uint16_t *len)
|
||||
u8 **buf, u16 *len)
|
||||
{
|
||||
(void)req;
|
||||
/* not defined */
|
||||
@@ -214,7 +214,7 @@ static int usb_standard_interface_get_status(struct usb_setup_data *req,
|
||||
}
|
||||
|
||||
static int usb_standard_endpoint_get_status(struct usb_setup_data *req,
|
||||
uint8_t **buf, uint16_t *len)
|
||||
u8 **buf, u16 *len)
|
||||
{
|
||||
(void)req;
|
||||
|
||||
@@ -226,7 +226,7 @@ static int usb_standard_endpoint_get_status(struct usb_setup_data *req,
|
||||
}
|
||||
|
||||
static int usb_standard_endpoint_stall(struct usb_setup_data *req,
|
||||
uint8_t **buf, uint16_t *len)
|
||||
u8 **buf, u16 *len)
|
||||
{
|
||||
(void)buf;
|
||||
(void)len;
|
||||
@@ -237,7 +237,7 @@ static int usb_standard_endpoint_stall(struct usb_setup_data *req,
|
||||
}
|
||||
|
||||
static int usb_standard_endpoint_unstall(struct usb_setup_data *req,
|
||||
uint8_t **buf, uint16_t *len)
|
||||
u8 **buf, u16 *len)
|
||||
{
|
||||
(void)buf;
|
||||
(void)len;
|
||||
@@ -247,11 +247,11 @@ static int usb_standard_endpoint_unstall(struct usb_setup_data *req,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _usbd_standard_request_device(struct usb_setup_data *req, uint8_t **buf,
|
||||
uint16_t *len)
|
||||
int _usbd_standard_request_device(struct usb_setup_data *req, u8 **buf,
|
||||
u16 *len)
|
||||
{
|
||||
int (*command)(struct usb_setup_data *req, uint8_t **buf,
|
||||
uint16_t *len) = NULL;
|
||||
int (*command)(struct usb_setup_data *req, u8 **buf,
|
||||
u16 *len) = NULL;
|
||||
|
||||
switch(req->bRequest) {
|
||||
case USB_REQ_CLEAR_FEATURE:
|
||||
@@ -292,11 +292,11 @@ int _usbd_standard_request_device(struct usb_setup_data *req, uint8_t **buf,
|
||||
return command(req, buf, len);
|
||||
}
|
||||
|
||||
int _usbd_standard_request_interface(struct usb_setup_data *req, uint8_t **buf,
|
||||
uint16_t *len)
|
||||
int _usbd_standard_request_interface(struct usb_setup_data *req, u8 **buf,
|
||||
u16 *len)
|
||||
{
|
||||
int (*command)(struct usb_setup_data *req, uint8_t **buf,
|
||||
uint16_t *len) = NULL;
|
||||
int (*command)(struct usb_setup_data *req, u8 **buf,
|
||||
u16 *len) = NULL;
|
||||
|
||||
switch(req->bRequest) {
|
||||
case USB_REQ_CLEAR_FEATURE:
|
||||
@@ -319,11 +319,11 @@ int _usbd_standard_request_interface(struct usb_setup_data *req, uint8_t **buf,
|
||||
return command(req, buf, len);
|
||||
}
|
||||
|
||||
int _usbd_standard_request_endpoint(struct usb_setup_data *req, uint8_t **buf,
|
||||
uint16_t *len)
|
||||
int _usbd_standard_request_endpoint(struct usb_setup_data *req, u8 **buf,
|
||||
u16 *len)
|
||||
{
|
||||
int (*command)(struct usb_setup_data *req, uint8_t **buf,
|
||||
uint16_t *len) = NULL;
|
||||
int (*command)(struct usb_setup_data *req, u8 **buf,
|
||||
u16 *len) = NULL;
|
||||
|
||||
switch(req->bRequest) {
|
||||
case USB_REQ_CLEAR_FEATURE:
|
||||
@@ -351,8 +351,8 @@ int _usbd_standard_request_endpoint(struct usb_setup_data *req, uint8_t **buf,
|
||||
return command(req, buf, len);
|
||||
}
|
||||
|
||||
int _usbd_standard_request(struct usb_setup_data *req, uint8_t **buf,
|
||||
uint16_t *len)
|
||||
int _usbd_standard_request(struct usb_setup_data *req, u8 **buf,
|
||||
u16 *len)
|
||||
{
|
||||
/* FIXME: have class/vendor requests as well */
|
||||
if((req->bmRequestType & USB_REQ_TYPE_TYPE) != USB_REQ_TYPE_STANDARD)
|
||||
|
||||
Reference in New Issue
Block a user