Show Posts
Pages: [1]
1  Using Arduino / Project Guidance / Re: How to Handle Multiple SPI Slaves With USB Host Shield on Arduino? on: October 13, 2012, 01:14:17 pm
Thanx To Kristian Lauszus for solving This Problem...
2  Using Arduino / Project Guidance / Re: How to Handle Multiple SPI Slaves With USB Host Shield on Arduino? on: October 13, 2012, 01:11:10 pm
Problem Solved...

Using Usb Host Shield, We can connect more than one SPI slaves on Arduino.
This is the sample code for communicating with other SPI slave by SelaveSelect2 (SS2) on Pin 6

Code:
#include <avr/pgmspace.h>
#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 <hidboot.h>
#include <printhex.h>
#include <message.h>
#include <hexdump.h>
#include <parsetools.h>
#include "SPI.h"
#define SS2 6

class MouseRptParser : public MouseReportParser
{
protected:
virtual void OnMouseMove (MOUSEINFO *mi);
virtual void OnLeftButtonUp (MOUSEINFO *mi);
virtual void OnLeftButtonDown (MOUSEINFO *mi);
virtual void OnRightButtonUp (MOUSEINFO *mi);
virtual void OnRightButtonDown (MOUSEINFO *mi);
virtual void OnMiddleButtonUp (MOUSEINFO *mi);
virtual void OnMiddleButtonDown (MOUSEINFO *mi);
};
void MouseRptParser::OnMouseMove(MOUSEINFO *mi)
{
    Serial.print("dx=");
    Serial.print(mi->dX, DEC);
    Serial.print(" dy=");
    Serial.println(mi->dY, DEC);
};
void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi)
{
    Serial.println("L Butt Up");
};
void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi)
{
    Serial.println("L Butt Dn");
   
   
    digitalWrite(SS2,LOW); // Use any pin except 10,11,12 or 13
    SPI.transfer('1');
    digitalWrite(SS2,HIGH);


};
void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi)
{
    Serial.println("R Butt Up");
};
void MouseRptParser::OnRightButtonDown (MOUSEINFO *mi)
{
    Serial.println("R Butt Dn");
    digitalWrite(SS2,LOW); // Use any pin except 10,11,12 or 13
    SPI.transfer('0');
    digitalWrite(SS2,HIGH);
};
void MouseRptParser::OnMiddleButtonUp (MOUSEINFO *mi)
{
    Serial.println("M Butt Up");
};
void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi)
{
    Serial.println("M Butt Dn");
};

USB     Usb;
USBHub     Hub(&Usb);
HIDBoot<HID_PROTOCOL_MOUSE>    Mouse(&Usb);

uint32_t next_time;

MouseRptParser                               Prs;

void setup()
{
    pinMode(SS2,OUTPUT);
    digitalWrite(SS2,HIGH);
    Serial.begin( 115200 );
    Serial.println("Start");

    if (Usb.Init() == -1)
        Serial.println("OSC did not start.");
     
    delay( 200 );
 
    next_time = millis() + 5000;
 
    Mouse.SetReportParser(0,(HIDReportParser*)&Prs);
   
    SPI.begin();
    SPCR = 0x51;
}

void loop()
{
  Usb.Task();
}

3  Using Arduino / Project Guidance / Re: How to Handle Multiple SPI Slaves With USB Host Shield on Arduino? on: October 13, 2012, 01:32:51 am
I have the USB Host Shield From Sparkfun. It dsnt have ICSP Header.. SO Any Alternate Solution?

4  Using Arduino / Project Guidance / Re: How to Handle Multiple SPI Slaves With USB Host Shield on Arduino? on: October 11, 2012, 01:36:12 pm
Sory for the uggly Code.. By The Way, the 2nd device(SPI Slave) is another Arduino on BreadBoard.
5  Using Arduino / Project Guidance / Re: How to Handle Multiple SPI Slaves With USB Host Shield on Arduino? on: October 10, 2012, 08:28:29 am
The Sketch i am using is... But Nothing Happening On 2nd Slave Device. No Data Receiving..

#include <avr/pgmspace.h>
#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 <hidboot.h>
#include <printhex.h>
#include <message.h>
#include <hexdump.h>
#include <parsetools.h>
#include "SPI.h"

#define SS2 A5


class MouseRptParser : public MouseReportParser
{
protected:
   virtual void OnMouseMove   (MOUSEINFO *mi);
   virtual void OnLeftButtonUp   (MOUSEINFO *mi);
   virtual void OnLeftButtonDown   (MOUSEINFO *mi);
   virtual void OnRightButtonUp   (MOUSEINFO *mi);
   virtual void OnRightButtonDown   (MOUSEINFO *mi);
   virtual void OnMiddleButtonUp   (MOUSEINFO *mi);
   virtual void OnMiddleButtonDown   (MOUSEINFO *mi);
};
void MouseRptParser::OnMouseMove(MOUSEINFO *mi)   
{
    Serial.print("dx=");
    Serial.print(mi->dX, DEC);
    Serial.print(" dy=");
    Serial.println(mi->dY, DEC);
};
void MouseRptParser::OnLeftButtonUp   (MOUSEINFO *mi)   
{
    Serial.println("L Butt Up");
};
void MouseRptParser::OnLeftButtonDown   (MOUSEINFO *mi)
{
    Serial.println("L Butt Dn");   
};
void MouseRptParser::OnRightButtonUp   (MOUSEINFO *mi)
{
    Serial.println("R Butt Up");
};
void MouseRptParser::OnRightButtonDown   (MOUSEINFO *mi)
{
    Serial.println("R Butt Dn");       
};
void MouseRptParser::OnMiddleButtonUp   (MOUSEINFO *mi)
{
    Serial.println("M Butt Up");
};
void MouseRptParser::OnMiddleButtonDown   (MOUSEINFO *mi)
{
    Serial.println("M Butt Dn");
};

USB     Usb;
USBHub     Hub(&Usb);
HIDBoot<HID_PROTOCOL_MOUSE>    Mouse(&Usb);

uint32_t next_time;

MouseRptParser                               Prs;



void setup()
{
    pinMode(SS2, OUTPUT);
    //digitalWrite(SS2,LOW);
   
    Serial.begin( 115200 );
    Serial.println("Start");

    if (Usb.Init() == -1)
        Serial.println("OSC did not start.");
     
    delay( 200 );
 
    next_time = millis() + 5000;
 
    Mouse.SetReportParser(0,(HIDReportParser*)&Prs);
}

void loop()
{
  // Disable Default SS Pin Of USB Host Shield:
  digitalWrite(SS,HIGH);
 
  // Enable 2nd Slave:
    digitalWrite(SS2,LOW);
    //  send value via SPI To 2nd Slave:
    SPI.transfer('1');
   
    // Disable 2nd Slave
    digitalWrite(SS2,HIGH);
   
    // Enable USB Host Shield Again
    digitalWrite(SS,LOW);
 
 
  ///////////////////////////////////// 
  Usb.Task(); 
  ////////////////////////////////////
 
 
 
  // Disable Default SS Pin Of USB Host Shield:
  digitalWrite(SS,HIGH);
 
  // Enable 2nd Slave:
    digitalWrite(SS2,LOW);
    //  send value via SPI To 2nd Slave:
    SPI.transfer('1');
   
    // Disable 2nd Slave
    digitalWrite(SS2,HIGH);
   
    // Enable USB Host Shield Again
    digitalWrite(SS,LOW);
}


6  Using Arduino / Project Guidance / Re: How to Handle Multiple SPI Slaves With USB Host Shield on Arduino? on: October 10, 2012, 08:21:44 am
The SPI bus can be shared but each device on the bus must have it's own SS signal/pin. The host shield uses pin 10 as SS, so any shield with a SPI device using another SS pin should work without changes. If the other shield uses the same SS pin you might have to cut the pin an re-wire it or a go-between shield (which does more ore less the same).

I am using another SS pin which is A5 pin. But Nothing Happend With that 2nd Slave Device..
7  Using Arduino / Project Guidance / Re: adruino and pc wifi connection on: October 10, 2012, 07:31:42 am
Your Question is not clear.. Where to connect Wifi? With PC or With Arduino?
8  Using Arduino / Project Guidance / How to Handle Multiple SPI Slaves With USB Host Shield on Arduino? on: October 10, 2012, 07:28:10 am
Hello Guys..
I have Arduino UNO and A USB Host Shield From Sparkfun..
The Problem is that when we attach USB Host Shield with Arduino UNO, it grabs/reserves the SPI pins..
This creates a new problem that i cant attach another Slave to SPI Port..
I Have Tried to select multiple slaves but failed..
Any Suggestion about how to handle multiple SPI Slaves by attaching USB Host Shield With Arduino?
9  Development / Other Hardware Development / Re: QFM-TRX1-24G - Has anyone made a library for this $6 2.4GHz? on: September 21, 2012, 10:13:37 am
I have wrien a library for this purpose..

https://github.com/yasiralijaved/Arduino-CC2500-Library
Pages: [1]