mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
ADK terminal demos added
This commit is contained in:
parent
96d506bf24
commit
f1a569f18c
3 changed files with 121 additions and 1 deletions
10
Usb.h
10
Usb.h
|
@ -18,6 +18,10 @@ e-mail : support@circuitsathome.com
|
|||
#ifndef _usb_h_
|
||||
#define _usb_h_
|
||||
|
||||
|
||||
//#define BOARD_BLACK_WIDDOW
|
||||
|
||||
|
||||
#define USB_METHODS_INLINE
|
||||
|
||||
#include <inttypes.h>
|
||||
|
@ -37,8 +41,12 @@ e-mail : support@circuitsathome.com
|
|||
|
||||
|
||||
/* shield pins. First parameter - SS pin, second parameter - INT pin */
|
||||
//typedef MAX3421e<P6, P3> MAX3421E; // Black Widow
|
||||
|
||||
#ifdef BOARD_BLACK_WIDDOW
|
||||
typedef MAX3421e<P6, P3> MAX3421E; // Black Widow
|
||||
#else
|
||||
typedef MAX3421e<P10, P9> MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560
|
||||
#endif
|
||||
|
||||
#define USBTRACE(s) (Serial.print((s)))
|
||||
#define USBTRACE2(s,r) (Serial.print((s)), Serial.println((r),HEX))
|
||||
|
|
63
examples/adk/term_test/term_test.pde
Normal file
63
examples/adk/term_test/term_test.pde
Normal file
|
@ -0,0 +1,63 @@
|
|||
#include <avrpins.h>
|
||||
#include <max3421e.h>
|
||||
#include <usbhost.h>
|
||||
#include <usb_ch9.h>
|
||||
#include <Usb.h>
|
||||
#include <usbhub.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <address.h>
|
||||
|
||||
#include <adk.h>
|
||||
|
||||
USB Usb;
|
||||
|
||||
ADK adk(&Usb,"Circuits@Home, ltd.",
|
||||
"USB Host Shield",
|
||||
"Arduino Terminal for Android",
|
||||
"1.0",
|
||||
"http://www.circuitsathome.com",
|
||||
"0000000000000001");
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println("\r\nADK demo start");
|
||||
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.println("OSCOKIRQ failed to assert");
|
||||
while(1); //halt
|
||||
}//if (Usb.Init() == -1...
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
uint8_t rcode;
|
||||
uint8_t msg[64] = { 0x00 };
|
||||
const char* recv = "Received: ";
|
||||
|
||||
Usb.Task();
|
||||
|
||||
if( adk.isReady() == false ) {
|
||||
return;
|
||||
}
|
||||
uint16_t len = 64;
|
||||
|
||||
rcode = adk.RcvData(&len, msg);
|
||||
if( rcode & ( rcode != hrNAK )) {
|
||||
USBTRACE2("Data rcv. :", rcode );
|
||||
}
|
||||
if(len > 0) {
|
||||
USBTRACE("\r\nData Packet.");
|
||||
|
||||
for( uint8_t i = 0; i < len; i++ ) {
|
||||
Serial.print(msg[i]);
|
||||
}
|
||||
/* sending back what was received */
|
||||
rcode = adk.SndData( strlen( recv ), (uint8_t *)recv );
|
||||
rcode = adk.SndData( strlen(( char * )msg ), msg );
|
||||
|
||||
}//if( len > 0 )...
|
||||
|
||||
delay( 1000 );
|
||||
}
|
||||
|
49
examples/adk/term_time/term_time.pde
Normal file
49
examples/adk/term_time/term_time.pde
Normal file
|
@ -0,0 +1,49 @@
|
|||
#include <avrpins.h>
|
||||
#include <max3421e.h>
|
||||
#include <usbhost.h>
|
||||
#include <usb_ch9.h>
|
||||
#include <Usb.h>
|
||||
#include <usbhub.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <address.h>
|
||||
|
||||
#include <adk.h>
|
||||
|
||||
USB Usb;
|
||||
|
||||
ADK adk(&Usb,"Circuits@Home, ltd.",
|
||||
"USB Host Shield",
|
||||
"Arduino Terminal for Android",
|
||||
"1.0",
|
||||
"http://www.circuitsathome.com",
|
||||
"0000000000000001");
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println("\r\nADK demo start");
|
||||
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.println("OSCOKIRQ failed to assert");
|
||||
while(1); //halt
|
||||
}//if (Usb.Init() == -1...
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
uint8_t buf[ 12 ] = { 0 }; //buffer to convert unsigned long to ASCII
|
||||
const char* sec_ela = " seconds elapsed\r";
|
||||
uint8_t rcode;
|
||||
|
||||
Usb.Task();
|
||||
if( adk.isReady() == false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
ultoa( millis()/1000, (char *)buf, 10 );
|
||||
|
||||
rcode = adk.SndData( strlen((char *)buf), buf );
|
||||
rcode = adk.SndData( strlen( sec_ela), (uint8_t *)sec_ela );
|
||||
|
||||
delay( 1000 );
|
||||
}
|
Loading…
Reference in a new issue