Dieter Graef / Mbed 2 deprecated DISCO-F746NG_USB_Host

Dependencies:   USBHost_DISCO-F746NG mbed

Committer:
DieterGraef
Date:
Mon Jun 13 17:22:08 2016 +0000
Revision:
0:af2040964256
Child:
2:ca1b5b911ba8
USB Host for STM32F746 Discovery. At the moment only either the fast or the high speed port can be used

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DieterGraef 0:af2040964256 1 #include "mbed.h"
DieterGraef 0:af2040964256 2 #include "rtos.h"
DieterGraef 0:af2040964256 3 #include "USBHostMouseKeyboard.h"
DieterGraef 0:af2040964256 4 #define FastSpeedInterface 0
DieterGraef 0:af2040964256 5 #define HighSpeedInterface 1
DieterGraef 0:af2040964256 6 DigitalOut led(LED1);
DieterGraef 0:af2040964256 7
DieterGraef 0:af2040964256 8 void onMouseEventdev(uint8_t buttons, int8_t x, int8_t y, int8_t z) {
DieterGraef 0:af2040964256 9 printf("m: %d, x: %d, y: %d, z: %d\r\n", buttons, x, y, z);
DieterGraef 0:af2040964256 10 }
DieterGraef 0:af2040964256 11
DieterGraef 0:af2040964256 12 void onKeydev(uint8_t key) {
DieterGraef 0:af2040964256 13 printf("Key: %c\r\n", key);
DieterGraef 0:af2040964256 14 }
DieterGraef 0:af2040964256 15
DieterGraef 0:af2040964256 16
DieterGraef 0:af2040964256 17 void mouse_task(void const *) {
DieterGraef 0:af2040964256 18 // At the moment only one Interface can be used for the Host due to the use of
DieterGraef 0:af2040964256 19 // USBHostMouseKb dev(FastSpeedInterface);
DieterGraef 0:af2040964256 20 USBHostMouseKb dev(HighSpeedInterface);
DieterGraef 0:af2040964256 21 while(1) {
DieterGraef 0:af2040964256 22 // try to connect
DieterGraef 0:af2040964256 23 while(!dev.connect())
DieterGraef 0:af2040964256 24 Thread::wait(500);
DieterGraef 0:af2040964256 25
DieterGraef 0:af2040964256 26 // when connected, attach handler
DieterGraef 0:af2040964256 27 dev.attachMouseEvent(onMouseEventdev);
DieterGraef 0:af2040964256 28 dev.attachKb(onKeydev);
DieterGraef 0:af2040964256 29
DieterGraef 0:af2040964256 30 while(1)
DieterGraef 0:af2040964256 31 {
DieterGraef 0:af2040964256 32 dev.poll();
DieterGraef 0:af2040964256 33 Thread::wait(50);
DieterGraef 0:af2040964256 34 }
DieterGraef 0:af2040964256 35
DieterGraef 0:af2040964256 36 }
DieterGraef 0:af2040964256 37 }
DieterGraef 0:af2040964256 38
DieterGraef 0:af2040964256 39 int main() {
DieterGraef 0:af2040964256 40 Thread mouseTask(mouse_task, NULL, osPriorityNormal, 256 * 4);
DieterGraef 0:af2040964256 41 while(1) {
DieterGraef 0:af2040964256 42 led=!led;
DieterGraef 0:af2040964256 43 Thread::wait(500);
DieterGraef 0:af2040964256 44 }
DieterGraef 0:af2040964256 45 }
DieterGraef 0:af2040964256 46