Clean up types
This commit is contained in:
parent
111c5f7200
commit
28977cd128
2
main.c
2
main.c
|
@ -72,7 +72,7 @@ int main(void) {
|
||||||
/* Send any available data to the NFC CDC */
|
/* Send any available data to the NFC CDC */
|
||||||
if (!ringbuffer_empty(uart_to_usb_buf)) {
|
if (!ringbuffer_empty(uart_to_usb_buf)) {
|
||||||
unsigned len = ringbuffer_peek(uart_to_usb_buf, &buf[0], sizeof buf);
|
unsigned len = ringbuffer_peek(uart_to_usb_buf, &buf[0], sizeof buf);
|
||||||
if(usb_write_cdcacm(ACM_NFC, buf, len, 1)) {
|
if(usb_write_cdcacm(ACM_NFC, &buf[0], len, 1)) {
|
||||||
ringbuffer_skip(uart_to_usb_buf, len);
|
ringbuffer_skip(uart_to_usb_buf, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,8 @@ unsigned ringbuffer_level(ringbuffer *buf) {
|
||||||
return size - tail + head;
|
return size - tail + head;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned ringbuffer_add(ringbuffer *buf, uint8_t *dat, unsigned len) {
|
unsigned ringbuffer_add(ringbuffer *buf, void *dat_, unsigned len) {
|
||||||
|
uint8_t *dat = dat_;
|
||||||
unsigned rem = ringbuffer_free(buf);
|
unsigned rem = ringbuffer_free(buf);
|
||||||
unsigned head = buf->head;
|
unsigned head = buf->head;
|
||||||
unsigned written = 0;
|
unsigned written = 0;
|
||||||
|
@ -55,7 +56,8 @@ unsigned ringbuffer_empty(ringbuffer *buf) {
|
||||||
return buf->head == buf->tail;
|
return buf->head == buf->tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned ringbuffer_peek(ringbuffer *buf, uint8_t *dst, unsigned len) {
|
unsigned ringbuffer_peek(ringbuffer *buf, void *dst_, unsigned len) {
|
||||||
|
uint8_t *dst = dst_;
|
||||||
unsigned level = ringbuffer_level(buf);
|
unsigned level = ringbuffer_level(buf);
|
||||||
unsigned size = buf->size;
|
unsigned size = buf->size;
|
||||||
unsigned tail = buf->tail;
|
unsigned tail = buf->tail;
|
||||||
|
@ -78,7 +80,7 @@ void ringbuffer_skip(ringbuffer *buf, unsigned len) {
|
||||||
buf->tail = (buf->tail + len) % (buf->size);
|
buf->tail = (buf->tail + len) % (buf->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned ringbuffer_get(ringbuffer *buf, uint8_t *dst, unsigned len) {
|
unsigned ringbuffer_get(ringbuffer *buf, void *dst, unsigned len) {
|
||||||
len = ringbuffer_peek(buf, dst, len);
|
len = ringbuffer_peek(buf, dst, len);
|
||||||
ringbuffer_skip(buf, len);
|
ringbuffer_skip(buf, len);
|
||||||
return len;
|
return len;
|
||||||
|
|
|
@ -26,10 +26,10 @@ unsigned ringbuffer_level(ringbuffer *buf);
|
||||||
|
|
||||||
unsigned ringbuffer_empty(ringbuffer *buf);
|
unsigned ringbuffer_empty(ringbuffer *buf);
|
||||||
|
|
||||||
unsigned ringbuffer_add(ringbuffer *buf, uint8_t *dat, unsigned len);
|
unsigned ringbuffer_add(ringbuffer *buf, void *dat, unsigned len);
|
||||||
|
|
||||||
unsigned ringbuffer_get(ringbuffer *buf, uint8_t *dst, unsigned len);
|
unsigned ringbuffer_get(ringbuffer *buf, void *dst, unsigned len);
|
||||||
unsigned ringbuffer_peek(ringbuffer *buf, uint8_t *dst, unsigned len);
|
unsigned ringbuffer_peek(ringbuffer *buf, void *dst, unsigned len);
|
||||||
void ringbuffer_skip(ringbuffer *buf, unsigned len);
|
void ringbuffer_skip(ringbuffer *buf, unsigned len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
2
usb.c
2
usb.c
|
@ -148,7 +148,7 @@ static void cdcacm_data_rx_cb(usbd_device *usbd_dev, uint8_t ep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int usb_write_cdcacm(uint8_t acm, uint8_t *data, size_t len, int tries) {
|
int usb_write_cdcacm(uint8_t acm, void *data, size_t len, int tries) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (usbd_ep_write_packet(g_usbd_dev, (1 + 2 * acm) | 0x80, data, len) == 0 && ++i < tries)
|
while (usbd_ep_write_packet(g_usbd_dev, (1 + 2 * acm) | 0x80, data, len) == 0 && ++i < tries)
|
||||||
;
|
;
|
||||||
|
|
2
usb.h
2
usb.h
|
@ -6,7 +6,7 @@
|
||||||
extern usbd_device *g_usbd_dev;
|
extern usbd_device *g_usbd_dev;
|
||||||
|
|
||||||
void usb_setup(void);
|
void usb_setup(void);
|
||||||
int usb_write_cdcacm(uint8_t acm, uint8_t *data, size_t len, int tries);
|
int usb_write_cdcacm(uint8_t acm, void *data, size_t len, int tries);
|
||||||
|
|
||||||
#define ACM_NFC 1
|
#define ACM_NFC 1
|
||||||
#define ACM_COMM 0
|
#define ACM_COMM 0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user