Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@4:9bc07cce9fe6, 2015-08-01 (annotated)
- Committer:
- captaingoujon
- Date:
- Sat Aug 01 15:58:36 2015 +0000
- Branch:
- dev-USB
- Revision:
- 4:9bc07cce9fe6
- Parent:
- 2:c95d2291d1db
- Child:
- 13:da74d044f6a8
USBSerial example with interrupts
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| captaingoujon | 0:27c53e093a59 | 1 | #include "mbed.h" |
| captaingoujon | 4:9bc07cce9fe6 | 2 | #include "USBSerial.h" |
| captaingoujon | 4:9bc07cce9fe6 | 3 | |
| captaingoujon | 4:9bc07cce9fe6 | 4 | DigitalOut myled(LED1); |
| captaingoujon | 4:9bc07cce9fe6 | 5 | InterruptIn usbPower(PA_9); |
| captaingoujon | 4:9bc07cce9fe6 | 6 | USBSerial pcSerial(0x1f00,0x2012,0x001,false); |
| captaingoujon | 4:9bc07cce9fe6 | 7 | |
| captaingoujon | 4:9bc07cce9fe6 | 8 | void usbConnectISR(){ |
| captaingoujon | 4:9bc07cce9fe6 | 9 | myled=1; |
| captaingoujon | 4:9bc07cce9fe6 | 10 | } |
| captaingoujon | 4:9bc07cce9fe6 | 11 | void usbDisconnectISR(){ |
| captaingoujon | 4:9bc07cce9fe6 | 12 | myled=0; |
| captaingoujon | 4:9bc07cce9fe6 | 13 | } |
| captaingoujon | 0:27c53e093a59 | 14 | |
| captaingoujon | 0:27c53e093a59 | 15 | int main(){ |
| captaingoujon | 2:c95d2291d1db | 16 | //USB Development branch |
| captaingoujon | 4:9bc07cce9fe6 | 17 | usbPower.rise(usbConnectISR); |
| captaingoujon | 4:9bc07cce9fe6 | 18 | usbPower.fall(usbDisconnectISR); |
| captaingoujon | 4:9bc07cce9fe6 | 19 | usbPower.enable_irq(); |
| captaingoujon | 4:9bc07cce9fe6 | 20 | |
| captaingoujon | 4:9bc07cce9fe6 | 21 | pcSerial.printf("USB PORT SERIAL"); |
| captaingoujon | 4:9bc07cce9fe6 | 22 | while(1){ |
| captaingoujon | 4:9bc07cce9fe6 | 23 | if(pcSerial.readable()){ |
| captaingoujon | 4:9bc07cce9fe6 | 24 | pcSerial.putc(pcSerial.getc()); |
| captaingoujon | 4:9bc07cce9fe6 | 25 | } |
| captaingoujon | 4:9bc07cce9fe6 | 26 | } |
| captaingoujon | 4:9bc07cce9fe6 | 27 | } |

