forked from hathach/tinyusb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
720 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2019 Microchip Technology Inc. | ||
* Copyright (c) 2018, hathach (tinyusb.org) | ||
* Copyright (c) 2024, Duet3D | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
* This file is part of the TinyUSB stack. | ||
*/ | ||
#ifndef _COMMON_USB_DEFS_H_ | ||
#define _COMMON_USB_DEFS_H_ | ||
|
||
#include <stdint.h> | ||
|
||
#include "common/tusb_types.h" | ||
#include "common/tusb_common.h" | ||
#include "common_usb_regs.h" | ||
|
||
#define PEP_GET_FIFO_PTR(ep, scale) (((TU_XSTRCAT(TU_STRCAT(uint, scale),_t) (*)[0x8000 / ((scale) / 8)])FIFO_RAM_ADDR)[(ep)]) | ||
#define DMA_TRANS_MAX 0x10000 | ||
#define PIPE_MAX_PACKET_SIZE 1024 | ||
|
||
|
||
TU_ATTR_ALWAYS_INLINE static inline void hw_enter_critical(volatile uint32_t *atomic) | ||
{ | ||
*atomic = __get_PRIMASK(); | ||
__disable_irq(); | ||
__DMB(); | ||
} | ||
|
||
TU_ATTR_ALWAYS_INLINE static inline void hw_exit_critical(volatile uint32_t *atomic) | ||
{ | ||
__DMB(); | ||
__set_PRIMASK(*atomic); | ||
} | ||
|
||
TU_ATTR_ALWAYS_INLINE static inline void hw_cache_invalidate(uint32_t *addr, int32_t size) | ||
{ | ||
if (SCB->CCR & SCB_CCR_DC_Msk) | ||
{ | ||
SCB_CleanInvalidateDCache_by_Addr(addr, size); | ||
} | ||
else | ||
{ | ||
__DSB(); | ||
__ISB(); | ||
} | ||
} | ||
|
||
TU_ATTR_ALWAYS_INLINE static inline tusb_speed_t hw_port_speed_get(void) | ||
{ | ||
switch (USB_REG->SR & SR_SPEED) | ||
{ | ||
case SR_SPEED_FULL_SPEED: | ||
default: | ||
return TUSB_SPEED_FULL; | ||
case SR_SPEED_HIGH_SPEED: | ||
return TUSB_SPEED_HIGH; | ||
case SR_SPEED_LOW_SPEED: | ||
return TUSB_SPEED_LOW; | ||
}; | ||
} | ||
|
||
#endif |
Oops, something went wrong.