Skip to content

Commit 21baee7

Browse files
author
Yihui Xiong
committed
Merge remote-tracking branch 'upstream/master'
2 parents 602f8a0 + 40e87d0 commit 21baee7

File tree

4 files changed

+130
-82
lines changed

4 files changed

+130
-82
lines changed

README.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,27 @@ Documentation
2020
* [mbed library internals](http://mbed.org/handbook/mbed-library-internals)
2121
* [Adding a new target microcontroller](http://mbed.org/handbook/mbed-SDK-porting)
2222

23-
Supported Microcontrollers
24-
--------------------------
23+
Supported Microcontrollers and Boards
24+
-------------------------------------
2525
NXP:
26-
* [LPC1768](http://mbed.org/platforms/mbed-LPC1768/) (Cortex-M3)
27-
* [LPC1768](http://mbed.org/platforms/u-blox-C027/) (Cortex-M3)
28-
* [LPC11U24](http://mbed.org/platforms/mbed-LPC11U24/) (Cortex-M0)
29-
* [LPC11U35](http://mbed.org/platforms/EA-LPC11U35/) (Cortex-M0)
30-
* LPC2368 (ARM7TDMI-S)
26+
* [mbed LPC1768](http://mbed.org/platforms/mbed-LPC1768/) (Cortex-M3)
27+
* [u-blox C027 LPC1768](http://mbed.org/platforms/u-blox-C027/) (Cortex-M3)
28+
* [mbed LPC11U24](http://mbed.org/platforms/mbed-LPC11U24/) (Cortex-M0)
29+
* [EA LPC11U35](http://mbed.org/platforms/EA-LPC11U35/) (Cortex-M0)
30+
* mbed LPC2368 (ARM7TDMI-S)
3131
* LPC810 (Cortex-M0+)
3232
* [LPC812](http://mbed.org/platforms/NXP-LPC800-MAX/) (Cortex-M0+)
33-
* [LPC4088](http://mbed.org/platforms/EA-LPC4088/) (Cortex-M4)
33+
* [EA LPC4088](http://mbed.org/platforms/EA-LPC4088/) (Cortex-M4)
3434
* LPC4330 (Cortex-M4 + Cortex-M0)
3535
* [LPC1347](http://mbed.org/platforms/DipCortex-M3/) (Cortex-M3)
3636
* [LPC1114](http://mbed.org/platforms/LPC1114FN28/) (Cortex-M0)
3737
* LPC11C24 (Cortex-M0)
38+
* [LPC1549](https://mbed.org/platforms/LPCXpresso1549/) (Cortex-M3)
3839

3940
Freescale:
40-
* KL05Z (Cortex-M0+)
41-
* [KL25Z](http://mbed.org/platforms/KL25Z/) (Cortex-M0+)
42-
* [KL46Z](https://mbed.org/platforms/FRDM-KL46Z/) (Cortex-M0+)
41+
* [FRDM-KL05Z](https://mbed.org/platforms/FRDM-KL05Z/) (Cortex-M0+)
42+
* [FRDM-KL25Z](http://mbed.org/platforms/KL25Z/) (Cortex-M0+)
43+
* [FRDM-KL46Z](https://mbed.org/platforms/FRDM-KL46Z/) (Cortex-M0+)
4344

4445
STMicroelectronics:
4546
* [Nucleo-F103RB](https://mbed.org/platforms/ST-Nucleo-F103RB/) (Cortex-M3)
@@ -48,6 +49,9 @@ STMicroelectronics:
4849
* [Nucleo-F401RE](https://mbed.org/platforms/ST-Nucleo-F401RE/) (Cortex-M4)
4950
* STM32F407 (Cortex-M4)
5051

52+
Nordic:
53+
* [nRF51822-mKIT](https://mbed.org/platforms/Nordic-nRF51822/) (Cortex-M0)
54+
5155
Supported Toolchains and IDEs
5256
-----------------------------
5357
* GCC ARM: [GNU Tools for ARM Embedded Processors](https://launchpad.net/gcc-arm-embedded/4.7/4.7-2012-q4-major)

libraries/USBDevice/USBDevice/USBEndpoints.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ typedef enum {
4141
#include "USBEndpoints_LPC17_LPC23.h"
4242
#elif defined(TARGET_LPC11UXX) || defined(TARGET_LPC1347)
4343
#include "USBEndpoints_LPC11U.h"
44-
#elif defined(TARGET_KL25Z)
44+
#elif defined(TARGET_KL25Z) | defined(TARGET_KL46Z) | defined(TARGET_K20D5M)
4545
#include "USBEndpoints_KL25Z.h"
4646
#elif defined (TARGET_STM32F4XX)
4747
#include "USBEndpoints_STM32F4.h"

libraries/USBDevice/USBDevice/USBHAL_KL25Z.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1717
*/
1818

19-
#if defined(TARGET_KL25Z)
19+
#if defined(TARGET_KL25Z) | defined(TARGET_KL46Z) | defined(TARGET_K20D5M)
2020

2121
#include "USBHAL.h"
2222

@@ -59,7 +59,7 @@ typedef struct BDT {
5959
uint8_t dummy; // RSVD: BD[8:15]
6060
uint16_t byte_count; // BD[16:32]
6161
uint32_t address; // Addr
62-
} BDT;
62+
} BDT;
6363

6464

6565
// there are:
@@ -82,10 +82,10 @@ uint32_t USBHAL::endpointReadcore(uint8_t endpoint, uint8_t *buffer) {
8282
return 0;
8383
}
8484

85-
USBHAL::USBHAL(void) {
85+
USBHAL::USBHAL(void) {
8686
// Disable IRQ
8787
NVIC_DisableIRQ(USB0_IRQn);
88-
88+
8989
// fill in callback array
9090
epCallback[0] = &USBHAL::EP1_OUT_callback;
9191
epCallback[1] = &USBHAL::EP1_IN_callback;
@@ -117,24 +117,24 @@ USBHAL::USBHAL(void) {
117117
epCallback[27] = &USBHAL::EP14_IN_callback;
118118
epCallback[28] = &USBHAL::EP15_OUT_callback;
119119
epCallback[29] = &USBHAL::EP15_IN_callback;
120-
121-
120+
121+
122122
// choose usb src as PLL
123123
SIM->SOPT2 |= (SIM_SOPT2_USBSRC_MASK | SIM_SOPT2_PLLFLLSEL_MASK);
124-
124+
125125
// enable OTG clock
126126
SIM->SCGC4 |= SIM_SCGC4_USBOTG_MASK;
127127

128128
// Attach IRQ
129129
instance = this;
130130
NVIC_SetVector(USB0_IRQn, (uint32_t)&_usbisr);
131131
NVIC_EnableIRQ(USB0_IRQn);
132-
132+
133133
// USB Module Configuration
134134
// Reset USB Module
135135
USB0->USBTRC0 |= USB_USBTRC0_USBRESET_MASK;
136136
while(USB0->USBTRC0 & USB_USBTRC0_USBRESET_MASK);
137-
137+
138138
// Set BDT Base Register
139139
USB0->BDTPAGE1=(uint8_t)((uint32_t)bdt>>8);
140140
USB0->BDTPAGE2=(uint8_t)((uint32_t)bdt>>16);
@@ -144,14 +144,14 @@ USBHAL::USBHAL(void) {
144144
USB0->ISTAT = 0xff;
145145

146146
// USB Interrupt Enablers
147-
USB0->INTEN |= USB_INTEN_TOKDNEEN_MASK |
148-
USB_INTEN_SOFTOKEN_MASK |
147+
USB0->INTEN |= USB_INTEN_TOKDNEEN_MASK |
148+
USB_INTEN_SOFTOKEN_MASK |
149149
USB_INTEN_ERROREN_MASK |
150150
USB_INTEN_USBRSTEN_MASK;
151-
152-
// Disable weak pull downs
153-
USB0->USBCTRL &= ~(USB_USBCTRL_PDE_MASK | USB_USBCTRL_SUSP_MASK);
154-
151+
152+
// Disable weak pull downs
153+
USB0->USBCTRL &= ~(USB_USBCTRL_PDE_MASK | USB_USBCTRL_SUSP_MASK);
154+
155155
USB0->USBTRC0 |= 0x40;
156156
}
157157

@@ -296,9 +296,9 @@ EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t * buffer, uint32_
296296
uint32_t n, sz, idx, setup = 0;
297297
uint8_t not_iso;
298298
uint8_t * ep_buf;
299-
299+
300300
uint32_t log_endpoint = PHY_TO_LOG(endpoint);
301-
301+
302302
if (endpoint > NUMBER_OF_PHYSICAL_ENDPOINTS - 1) {
303303
return EP_INVALID;
304304
}
@@ -335,7 +335,7 @@ EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t * buffer, uint32_
335335
if (((Data1 >> endpoint) & 1) == ((bdt[idx].info >> 6) & 1)) {
336336
if (setup && (buffer[6] == 0)) // if no setup data stage,
337337
Data1 &= ~1UL; // set DATA0
338-
else
338+
else
339339
Data1 ^= (1 << endpoint);
340340
}
341341

@@ -345,7 +345,7 @@ EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t * buffer, uint32_
345345
else {
346346
bdt[idx].info = BD_DTS_MASK | BD_OWN_MASK;
347347
}
348-
348+
349349
USB0->CTL &= ~USB_CTL_TXSUSPENDTOKENBUSY_MASK;
350350
*bytesRead = sz;
351351

@@ -368,27 +368,27 @@ EP_STATUS USBHAL::endpointWrite(uint8_t endpoint, uint8_t *data, uint32_t size)
368368

369369
idx = EP_BDT_IDX(PHY_TO_LOG(endpoint), TX, 0);
370370
bdt[idx].byte_count = size;
371-
372-
371+
372+
373373
// non iso endpoint
374374
if (USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT & USB_ENDPT_EPHSHK_MASK) {
375375
ep_buf = endpoint_buffer[idx];
376376
} else {
377377
ep_buf = endpoint_buffer_iso[2];
378378
}
379-
379+
380380
for (n = 0; n < size; n++) {
381381
ep_buf[n] = data[n];
382382
}
383-
383+
384384
if ((Data1 >> endpoint) & 1) {
385385
bdt[idx].info = BD_OWN_MASK | BD_DTS_MASK;
386386
} else {
387387
bdt[idx].info = BD_OWN_MASK | BD_DTS_MASK | BD_DATA01_MASK;
388388
}
389-
389+
390390
Data1 ^= (1 << endpoint);
391-
391+
392392
return EP_PENDING;
393393
}
394394

@@ -429,7 +429,7 @@ void USBHAL::usbisr(void) {
429429
uint8_t istat = USB0->ISTAT;
430430

431431
// reset interrupt
432-
if (istat & USB_ISTAT_USBRST_MASK) {
432+
if (istat & USB_ISTAT_USBRST_MASK) {
433433
// disable all endpt
434434
for(i = 0; i < 16; i++) {
435435
USB0->ENDPOINT[i].ENDPT = 0x00;
@@ -457,11 +457,11 @@ void USBHAL::usbisr(void) {
457457

458458
// SOF interrupt
459459
if (istat & USB_ISTAT_SOFTOK_MASK) {
460-
USB0->ISTAT = USB_ISTAT_SOFTOK_MASK;
460+
USB0->ISTAT = USB_ISTAT_SOFTOK_MASK;
461461
// SOF event, read frame number
462462
SOF(frameNumber());
463463
}
464-
464+
465465
// stall interrupt
466466
if (istat & 1<<7) {
467467
if (USB0->ENDPOINT[0].ENDPT & USB_ENDPT_EPSTALL_MASK)
@@ -483,7 +483,7 @@ void USBHAL::usbisr(void) {
483483

484484
// EP0 SETUP event (SETUP data received)
485485
EP0setupCallback();
486-
486+
487487
} else {
488488
// OUT packet
489489
if (TOK_PID((EP_BDT_IDX(num, dir, ev_odd))) == OUT_TOKEN) {
@@ -517,11 +517,11 @@ void USBHAL::usbisr(void) {
517517

518518
USB0->ISTAT = USB_ISTAT_TOKDNE_MASK;
519519
}
520-
520+
521521
// sleep interrupt
522522
if (istat & 1<<4) {
523523
USB0->ISTAT |= USB_ISTAT_SLEEP_MASK;
524-
}
524+
}
525525

526526
// error interrupt
527527
if (istat & USB_ISTAT_ERROR_MASK) {

0 commit comments

Comments
 (0)