mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-25 10:43:44 +00:00
Merge pull request #14 from tannewt/discarded_qualifiers
A few more updates
This commit is contained in:
commit
3bb53273cd
@ -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)
|
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
|
}else
|
||||||
{
|
{
|
||||||
return false; // stall unsupported request
|
return false; // stall unsupported request
|
||||||
|
@ -43,6 +43,8 @@
|
|||||||
#ifndef _TUSB_OSAL_NONE_H_
|
#ifndef _TUSB_OSAL_NONE_H_
|
||||||
#define _TUSB_OSAL_NONE_H_
|
#define _TUSB_OSAL_NONE_H_
|
||||||
|
|
||||||
|
#include "tusb_hal.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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)
|
static inline bool osal_queue_send(osal_queue_t const queue_hdl, void const * data, bool in_isr)
|
||||||
{
|
{
|
||||||
(void) in_isr;
|
if (!in_isr) {
|
||||||
// if (!in_isr) tusb_hal_int_disable_all();
|
tusb_hal_int_disable_all();
|
||||||
|
}
|
||||||
bool rc = tu_fifo_write( (tu_fifo_t*) queue_hdl, data);
|
bool success = tu_fifo_write( (tu_fifo_t*) queue_hdl, data);
|
||||||
|
if (!in_isr) {
|
||||||
// if (!in_isr) tusb_hal_int_enable_all();
|
tusb_hal_int_enable_all();
|
||||||
|
}
|
||||||
return rc;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void osal_queue_reset(osal_queue_t const queue_hdl)
|
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();
|
// tusb_hal_int_enable_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool osal_queue_receive(osal_queue_t const queue_hdl, void* data) {
|
||||||
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);
|
||||||
// osal none return immediately without blocking
|
tusb_hal_int_enable_all();
|
||||||
// extern void tusb_hal_int_disable(uint8_t rhport);
|
return success;
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -71,10 +71,19 @@ static void bus_reset(void) {
|
|||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
bool dcd_init (uint8_t rhport)
|
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;
|
(void) rhport;
|
||||||
USB->DEVICE.DESCADD.reg = (uint32_t) &sram_registers;
|
USB->DEVICE.DESCADD.reg = (uint32_t) &sram_registers;
|
||||||
USB->DEVICE.CTRLB.reg = USB_DEVICE_CTRLB_SPDCONF_FS;
|
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;
|
USB->DEVICE.INTENSET.reg = USB_DEVICE_INTENSET_SOF | USB_DEVICE_INTENSET_EORST;
|
||||||
|
|
||||||
return true;
|
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];
|
UsbDeviceDescBank* bank = &sram_registers[epnum][dir];
|
||||||
UsbDeviceEndpoint* ep = &USB->DEVICE.DeviceEndpoint[epnum];
|
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;
|
bank->ADDR.reg = (uint32_t) buffer;
|
||||||
if ( dir == TUSB_DIR_OUT )
|
if ( dir == TUSB_DIR_OUT )
|
||||||
{
|
{
|
||||||
|
@ -72,9 +72,17 @@ static void bus_reset(void) {
|
|||||||
bool dcd_init (uint8_t rhport)
|
bool dcd_init (uint8_t rhport)
|
||||||
{
|
{
|
||||||
(void) 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.DESCADD.reg = (uint32_t) &sram_registers;
|
||||||
USB->DEVICE.CTRLB.reg = USB_DEVICE_CTRLB_SPDCONF_FS;
|
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;
|
USB->DEVICE.INTENSET.reg = USB_DEVICE_INTENSET_SOF | USB_DEVICE_INTENSET_EORST;
|
||||||
|
|
||||||
return true;
|
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];
|
UsbDeviceDescBank* bank = &sram_registers[epnum][dir];
|
||||||
UsbDeviceEndpoint* ep = &USB->DEVICE.DeviceEndpoint[epnum];
|
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;
|
bank->ADDR.reg = (uint32_t) buffer;
|
||||||
if ( dir == TUSB_DIR_OUT )
|
if ( dir == TUSB_DIR_OUT )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user