ADK terminal demos added

This commit is contained in:
Oleg Mazurov 2011-09-10 20:13:18 -06:00
parent 96d506bf24
commit f1a569f18c
3 changed files with 121 additions and 1 deletions

10
Usb.h
View file

@ -18,6 +18,10 @@ e-mail : support@circuitsathome.com
#ifndef _usb_h_ #ifndef _usb_h_
#define _usb_h_ #define _usb_h_
//#define BOARD_BLACK_WIDDOW
#define USB_METHODS_INLINE #define USB_METHODS_INLINE
#include <inttypes.h> #include <inttypes.h>
@ -37,8 +41,12 @@ e-mail : support@circuitsathome.com
/* shield pins. First parameter - SS pin, second parameter - INT pin */ /* 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 typedef MAX3421e<P10, P9> MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560
#endif
#define USBTRACE(s) (Serial.print((s))) #define USBTRACE(s) (Serial.print((s)))
#define USBTRACE2(s,r) (Serial.print((s)), Serial.println((r),HEX)) #define USBTRACE2(s,r) (Serial.print((s)), Serial.println((r),HEX))

View 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 );
}

View 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 );
}