mirror of
https://github.com/JorjBauer/aiie.git
synced 2024-11-22 15:31:41 +00:00
testing USB host
This commit is contained in:
parent
5702fc8ccd
commit
cf8fbd80f4
40
teensy/teensy-usb.cpp
Normal file
40
teensy/teensy-usb.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include <Arduino.h>
|
||||
#include <USBHost_t36.h>
|
||||
#include "teensy-usb.h"
|
||||
|
||||
USBHost myusb;
|
||||
USBHub hub1(myusb);
|
||||
USBHub hub2(myusb);
|
||||
USBHub hub3(myusb);
|
||||
KeyboardController keyboard1(myusb);
|
||||
KeyboardController keyboard2(myusb);
|
||||
|
||||
TeensyUSB::TeensyUSB()
|
||||
{
|
||||
}
|
||||
|
||||
TeensyUSB::~TeensyUSB()
|
||||
{
|
||||
}
|
||||
|
||||
void TeensyUSB::init()
|
||||
{
|
||||
myusb.begin();
|
||||
}
|
||||
|
||||
void TeensyUSB::attachKeypress(keyboardCallback cb)
|
||||
{
|
||||
keyboard1.attachPress(cb);
|
||||
keyboard2.attachPress(cb);
|
||||
}
|
||||
|
||||
void TeensyUSB::attachKeyrelease(keyboardCallback cb)
|
||||
{
|
||||
keyboard1.attachRelease(cb);
|
||||
keyboard2.attachRelease(cb);
|
||||
}
|
||||
|
||||
void TeensyUSB::maintain()
|
||||
{
|
||||
myusb.Task();
|
||||
}
|
21
teensy/teensy-usb.h
Normal file
21
teensy/teensy-usb.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef __TEENSY_USB
|
||||
#define __TEENSY_USB
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <USBHost_t36.h>
|
||||
|
||||
typedef void (*keyboardCallback)(int unicode);
|
||||
|
||||
class TeensyUSB {
|
||||
public:
|
||||
TeensyUSB();
|
||||
~TeensyUSB();
|
||||
|
||||
void init();
|
||||
void attachKeypress(keyboardCallback cb);
|
||||
void attachKeyrelease(keyboardCallback cb);
|
||||
|
||||
void maintain();
|
||||
};
|
||||
|
||||
#endif
|
@ -10,6 +10,7 @@
|
||||
#include "teensy-speaker.h"
|
||||
#include "teensy-paddles.h"
|
||||
#include "teensy-filemanager.h"
|
||||
#include "teensy-usb.h"
|
||||
#include "appleui.h"
|
||||
#include "teensy-prefs.h"
|
||||
#include "teensy-println.h"
|
||||
@ -35,6 +36,22 @@ BIOS bios;
|
||||
|
||||
static time_t getTeensy3Time() { return Teensy3Clock.get(); }
|
||||
|
||||
TeensyUSB usb;
|
||||
|
||||
void onKeypress(int unicode)
|
||||
{
|
||||
Serial.print("onKeypress:");
|
||||
Serial.println(unicode);
|
||||
// vmkeyboard->keyDepressed(keypad.key[i].kchar);
|
||||
}
|
||||
|
||||
void onKeyrelease(int unicode)
|
||||
{
|
||||
Serial.print("onKeyrelease: ");
|
||||
Serial.println(unicode);
|
||||
// vmkeyboard->keyReleased(keypad.key[i].kchar);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(230400);
|
||||
@ -104,6 +121,11 @@ void setup()
|
||||
println(" cpu");
|
||||
g_cpu = new Cpu();
|
||||
|
||||
println(" usb");
|
||||
usb.init();
|
||||
usb.attachKeypress(onKeypress);
|
||||
usb.attachKeyrelease(onKeyrelease);
|
||||
|
||||
Serial.print("Free RAM: ");
|
||||
println(FreeRamEstimate());
|
||||
|
||||
@ -277,6 +299,7 @@ void loop()
|
||||
}
|
||||
|
||||
g_keyboard->maintainKeyboard();
|
||||
usb.maintain();
|
||||
|
||||
//debugLCDState = !debugLCDState;
|
||||
//digitalWrite(57, debugLCDState);
|
||||
|
Loading…
Reference in New Issue
Block a user