Merge pull request #14 from tannewt/discarded_qualifiers

A few more updates
This commit is contained in:
hathach 2018-11-24 14:43:31 +07:00 committed by GitHub
commit 3bb53273cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 23 deletions

View File

@ -418,7 +418,8 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * p_reque
if (p_request->bRequest == TUSB_REQ_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT)
{
usbd_control_xfer(rhport, p_request, p_hid->desc_report, p_hid->desc_len);
// Cast away the const on p_hid->desc_report because we know it won't be modified.
usbd_control_xfer(rhport, p_request, (void *)p_hid->desc_report, p_hid->desc_len);
}else
{
return false; // stall unsupported request

View File

@ -43,6 +43,8 @@
#ifndef _TUSB_OSAL_NONE_H_
#define _TUSB_OSAL_NONE_H_
#include "tusb_hal.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -135,14 +137,14 @@ static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef)
static inline bool osal_queue_send(osal_queue_t const queue_hdl, void const * data, bool in_isr)
{
(void) in_isr;
// if (!in_isr) tusb_hal_int_disable_all();
bool rc = tu_fifo_write( (tu_fifo_t*) queue_hdl, data);
// if (!in_isr) tusb_hal_int_enable_all();
return rc;
if (!in_isr) {
tusb_hal_int_disable_all();
}
bool success = tu_fifo_write( (tu_fifo_t*) queue_hdl, data);
if (!in_isr) {
tusb_hal_int_enable_all();
}
return success;
}
static inline void osal_queue_reset(osal_queue_t const queue_hdl)
@ -152,18 +154,11 @@ static inline void osal_queue_reset(osal_queue_t const queue_hdl)
// tusb_hal_int_enable_all();
}
static inline bool osal_queue_receive(osal_queue_t const queue_hdl, void* data)
{
// osal none return immediately without blocking
// extern void tusb_hal_int_disable(uint8_t rhport);
// extern void tusb_hal_int_enable(uint8_t rhport);
// tusb_hal_int_disable(0);
bool rc = tu_fifo_read(queue_hdl, data);
// tusb_hal_int_enable(0);
return rc;
static inline bool osal_queue_receive(osal_queue_t const queue_hdl, void* data) {
tusb_hal_int_disable_all();
bool success = tu_fifo_read(queue_hdl, data);
tusb_hal_int_enable_all();
return success;
}
#ifdef __cplusplus

View File

@ -71,10 +71,19 @@ static void bus_reset(void) {
*------------------------------------------------------------------*/
bool dcd_init (uint8_t rhport)
{
// Reset to get in a clean state.
USB->DEVICE.CTRLA.bit.SWRST = true;
while (USB->DEVICE.SYNCBUSY.bit.SWRST == 0) {
}
while (USB->DEVICE.SYNCBUSY.bit.SWRST == 1) {}
(void) rhport;
USB->DEVICE.DESCADD.reg = (uint32_t) &sram_registers;
USB->DEVICE.CTRLB.reg = USB_DEVICE_CTRLB_SPDCONF_FS;
USB->DEVICE.CTRLA.reg = USB_CTRLA_MODE_DEVICE | USB_CTRLA_ENABLE;
USB->DEVICE.CTRLA.reg = USB_CTRLA_MODE_DEVICE | USB_CTRLA_ENABLE | USB_CTRLA_RUNSTDBY;
while (USB->DEVICE.SYNCBUSY.bit.ENABLE == 1) {}
USB->DEVICE.INTENSET.reg = USB_DEVICE_INTENSET_SOF | USB_DEVICE_INTENSET_EORST;
return true;
@ -155,6 +164,12 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
UsbDeviceDescBank* bank = &sram_registers[epnum][dir];
UsbDeviceEndpoint* ep = &USB->DEVICE.DeviceEndpoint[epnum];
// A setup token can occur immediately after an OUT STATUS packet so make sure we have a valid
// buffer for the control endpoint.
if (epnum == 0 && dir == 0 && buffer == NULL) {
buffer = _setup_packet;
}
bank->ADDR.reg = (uint32_t) buffer;
if ( dir == TUSB_DIR_OUT )
{

View File

@ -72,9 +72,17 @@ static void bus_reset(void) {
bool dcd_init (uint8_t rhport)
{
(void) rhport;
// Reset to get in a clean state.
USB->DEVICE.CTRLA.bit.SWRST = true;
while (USB->DEVICE.SYNCBUSY.bit.SWRST == 0) {
}
while (USB->DEVICE.SYNCBUSY.bit.SWRST == 1) {}
USB->DEVICE.DESCADD.reg = (uint32_t) &sram_registers;
USB->DEVICE.CTRLB.reg = USB_DEVICE_CTRLB_SPDCONF_FS;
USB->DEVICE.CTRLA.reg = USB_CTRLA_MODE_DEVICE | USB_CTRLA_ENABLE;
USB->DEVICE.CTRLA.reg = USB_CTRLA_MODE_DEVICE | USB_CTRLA_ENABLE | USB_CTRLA_RUNSTDBY;
while (USB->DEVICE.SYNCBUSY.bit.ENABLE == 1) {}
USB->DEVICE.INTENSET.reg = USB_DEVICE_INTENSET_SOF | USB_DEVICE_INTENSET_EORST;
return true;
@ -155,6 +163,12 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
UsbDeviceDescBank* bank = &sram_registers[epnum][dir];
UsbDeviceEndpoint* ep = &USB->DEVICE.DeviceEndpoint[epnum];
// A setup token can occur immediately after an OUT STATUS packet so make sure we have a valid
// buffer for the control endpoint.
if (epnum == 0 && dir == 0 && buffer == NULL) {
buffer = _setup_packet;
}
bank->ADDR.reg = (uint32_t) buffer;
if ( dir == TUSB_DIR_OUT )
{