-
Notifications
You must be signed in to change notification settings - Fork 3k
[NUC472/M453] Support USB device #3365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7f4881f
[NUC472/M453] Support USB device
ccli8 8c0948d
[NUC472/M453] Integrate with Travis CI
ccli8 fc16917
[NUC472/M453] Add license header for USBEndpoints_NUC472/M453.h
ccli8 fff8357
[NUC472] Fix compile error with Travis CI
ccli8 5fe2274
[NUC472/M453] Add target SPI pins into SPI SD test samples with Travi…
ccli8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
79 changes: 79 additions & 0 deletions
79
features/unsupported/USBDevice/USBDevice/USBEndpoints_M453.h
This file contains hidden or 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,79 @@ | ||
/* mbed Microcontroller Library | ||
* Copyright (c) 2015-2016 Nuvoton | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#define NU_MAX_EPX_BUFSIZE 4096 | ||
#define NU_EP2EPL(ep) ((ep) >> 1) | ||
#define NU_EP2EPH(ep) (((ep) >> 1) + 1) | ||
#define NU_EPL2EPH(ep) ((ep) + 1) | ||
#define NU_EPH2EPL(ep) ((ep) - 1) | ||
#define NU_EP_DIR_Pos 0 | ||
#define NU_EP_DIR_Msk (1 << NU_EP_DIR_Pos) | ||
#define NU_EP_DIR_OUT 0 | ||
#define NU_EP_DIR_IN 1 | ||
|
||
#define NU_EP_TYPE(ep) (((ep) & NU_EP_TYPE_Msk) >> NU_EP_TYPE_Pos) | ||
#define NU_EP_NUM(ep) (((ep) & NU_EP_NUM_Msk) >> NU_EP_NUM_Pos) | ||
#define NU_EP_DIR(ep) (((ep) & NU_EP_DIR_Msk) >> NU_EP_DIR_Pos) | ||
#define NU_EP_NUM_DIR(ep) ((NU_EP_NUM(ep) << 1) | NU_EP_DIR(ep)) | ||
|
||
#define NUMBER_OF_PHYSICAL_ENDPOINTS 8 | ||
#define EP0OUT (0) | ||
#define EP0IN (1) | ||
#define EP1OUT (2) | ||
#define EP1IN (3) | ||
#define EP2OUT (4) | ||
#define EP2IN (5) | ||
#define EP3OUT (6) | ||
#define EP3IN (7) | ||
#define EP4OUT (8) | ||
#define EP4IN (9) | ||
#define EP5OUT (10) | ||
#define EP5IN (11) | ||
#define EP6OUT (12) | ||
#define EP6IN (13) | ||
|
||
/* Maximum Packet sizes */ | ||
#define MAX_PACKET_SIZE_EP0 64 | ||
#define MAX_PACKET_SIZE_EP1 64 | ||
#define MAX_PACKET_SIZE_EP2 64 | ||
#define MAX_PACKET_SIZE_EP3 0x60 | ||
#define MAX_PACKET_SIZE_EP4 64 | ||
#define MAX_PACKET_SIZE_EP5 64 | ||
#define MAX_PACKET_SIZE_EP6 64 | ||
#define MAX_PACKET_SIZE_EP7 64 | ||
|
||
/* Generic endpoints - intended to be portable accross devices */ | ||
/* and be suitable for simple USB devices. */ | ||
|
||
/* Bulk endpoints */ | ||
#define EPBULK_OUT EP5OUT | ||
#define EPBULK_IN EP6IN | ||
#define EPBULK_OUT_callback EP5_OUT_callback | ||
#define EPBULK_IN_callback EP6_IN_callback | ||
/* Interrupt endpoints */ | ||
#define EPINT_OUT EP1OUT | ||
#define EPINT_IN EP2IN | ||
#define EPINT_OUT_callback EP1_OUT_callback | ||
#define EPINT_IN_callback EP2_IN_callback | ||
/* Isochronous endpoints */ | ||
#define EPISO_OUT EP3OUT | ||
#define EPISO_IN EP4IN | ||
#define EPISO_OUT_callback EP3_OUT_callback | ||
#define EPISO_IN_callback EP4_IN_callback | ||
|
||
#define MAX_PACKET_SIZE_EPBULK 64 | ||
#define MAX_PACKET_SIZE_EPINT 64 | ||
#define MAX_PACKET_SIZE_EPISO 1023 | ||
|
89 changes: 89 additions & 0 deletions
89
features/unsupported/USBDevice/USBDevice/USBEndpoints_NUC472.h
This file contains hidden or 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,89 @@ | ||
/* mbed Microcontroller Library | ||
* Copyright (c) 2015-2016 Nuvoton | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#define NU_MAX_EPX_BUFSIZE 4096 | ||
#define NU_EP2EPL(ep) ((ep) >> 1) | ||
#define NU_EP2EPH(ep) (((ep) >> 1) - 1) | ||
#define NU_EPX2EP(ep) ((ep == CEP) ? EP0OUT : ((ep) - EPA + EP1OUT)) | ||
#define NU_EPL2EPH(ep) ((ep) - 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here (alignment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix with another PR #3514. |
||
#define NU_EPH2EPL(ep) ((ep) + 1) | ||
#define NU_EP_DIR_Pos 0 | ||
#define NU_EP_DIR_Msk (1 << NU_EP_DIR_Pos) | ||
#define NU_EP_DIR_OUT 0 | ||
#define NU_EP_DIR_IN 1 | ||
|
||
#define NU_EP_TYPE(ep) (((ep) & NU_EP_TYPE_Msk) >> NU_EP_TYPE_Pos) | ||
#define NU_EP_NUM(ep) (((ep) & NU_EP_NUM_Msk) >> NU_EP_NUM_Pos) | ||
#define NU_EP_DIR(ep) (((ep) & NU_EP_DIR_Msk) >> NU_EP_DIR_Pos) | ||
#define NU_EP_NUM_DIR(ep) ((NU_EP_NUM(ep) << 1) | NU_EP_DIR(ep)) | ||
|
||
#define NUMBER_OF_PHYSICAL_ENDPOINTS 12 | ||
|
||
#define EP0OUT (0) | ||
#define EP0IN (1) | ||
#define EP1OUT (2) | ||
#define EP1IN (3) | ||
#define EP2OUT (4) | ||
#define EP2IN (5) | ||
#define EP3OUT (6) | ||
#define EP3IN (7) | ||
#define EP4OUT (8) | ||
#define EP4IN (9) | ||
#define EP5OUT (10) | ||
#define EP5IN (11) | ||
#define EP6OUT (12) | ||
#define EP6IN (13) | ||
|
||
/* Maximum Packet sizes */ | ||
#define MAX_PACKET_SIZE_EP0 64 | ||
#define MAX_PACKET_SIZE_EP1 64 | ||
#define MAX_PACKET_SIZE_EP2 64 | ||
#define MAX_PACKET_SIZE_EP3 0x60 | ||
#define MAX_PACKET_SIZE_EP4 64 | ||
#define MAX_PACKET_SIZE_EP5 64 | ||
#define MAX_PACKET_SIZE_EP6 64 | ||
#define MAX_PACKET_SIZE_EP7 64 | ||
#define MAX_PACKET_SIZE_EP8 64 | ||
#define MAX_PACKET_SIZE_EP9 64 | ||
#define MAX_PACKET_SIZE_EP10 64 | ||
#define MAX_PACKET_SIZE_EP11 64 | ||
|
||
/* Generic endpoints - intended to be portable accross devices */ | ||
/* and be suitable for simple USB devices. */ | ||
|
||
/* Bulk endpoints */ | ||
#define EPBULK_OUT EP5OUT | ||
#define EPBULK_IN EP6IN | ||
#define EPBULK_OUT_callback EP5_OUT_callback | ||
#define EPBULK_IN_callback EP6_IN_callback | ||
/* Interrupt endpoints */ | ||
#define EPINT_OUT EP1OUT | ||
#define EPINT_IN EP2IN | ||
#define EPINT_OUT_callback EP1_OUT_callback | ||
#define EPINT_IN_callback EP2_IN_callback | ||
/* Isochronous endpoints */ | ||
#define EPISO_OUT EP3OUT | ||
#define EPISO_IN EP4IN | ||
#define EPISO_OUT_callback EP3_OUT_callback | ||
#define EPISO_IN_callback EP4_IN_callback | ||
|
||
#define MAX_PACKET_SIZE_EPBULK 64 | ||
#define MAX_PACKET_SIZE_EPINT 64 | ||
#define MAX_PACKET_SIZE_EPISO 1023 | ||
|
||
#define USBD_GET_EP_MAX_PAYLOAD(ep) (*((__IO uint32_t *) ((uint32_t)&USBD->EPAMPS + (uint32_t)((ep)*0x28)))) | ||
#define USBD_GET_EP_DATA_COUNT(ep) ((*((__IO uint32_t *) ((uint32_t)&USBD->EPADATCNT + (uint32_t)((ep)*0x28)))) & 0xFFFFF) | ||
#define USBD_SET_EP_SHORT_PACKET(ep) (*((__IO uint32_t *) ((uint32_t)&USBD->EPARSPCTL + (uint32_t)((ep)*0x28))) = (*((__IO uint32_t *) ((uint32_t)&USBD->EPARSPCTL + (uint32_t)((ep)*0x28)))) & 0x10 | 0x40) | ||
#define USBD_GET_EP_INT_EN(ep) (*((__IO uint32_t *) ((uint32_t)&USBD->EPAINTEN + (uint32_t)((ep)*0x28)))) |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please fix the formatting in this file? the line 19 (there are more). Using tabs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix with another PR #3514.