Author Topic: DigiUSB & SoftwareSerial  (Read 6987 times)

Trakkasure

  • Newbie
  • *
  • Posts: 28
DigiUSB & SoftwareSerial
« on: January 25, 2013, 09:33:31 pm »

Is there any way to use DigiUSB and SoftwareSerial at the same time? (They seem to use the same interrupts)



DigisparkUSB/usbdrvasm.S.o: In function `__vector_2':
(.text+0x58): multiple definition of `__vector_2'
SoftwareSerial/SoftwareSerial.cpp.o:/Users/myersbrandon/Applications/DigiSpark.app/Contents/Resources/Java/libraries/SoftwareSerial/SoftwareSerial.cpp:329: first defined here


This is the modified blinkLED from RadioBlock examples
Code: [Select]
#include <TinyWireM.h>                  // I2C Master lib for ATTinys which use USI - comment this out to use with standard arduinos
#include <LiquidCrystal_I2C.h>          // for LCD w/ GPIO MODIFIED for the ATtiny85
#include <DigiUSB.h>
#include <SoftwareSerial.h>
#include <RadioBlock.h>


#define GPIO_ADDR     0x27             // (PCA8574A A0-A2 @5V) typ. A0-A3 Gnd 0x20 / 0x38 for A - 0x27 is the address of the Digispark LCD modules.
int currentLine = 0;
boolean clearOnNext = 0;
boolean backlight = 1;


LiquidCrystal_I2C lcd(GPIO_ADDR,16,2);  // set address & 16 chars / 2 lines


//Pins connected to RadioBlock pins 1/2/3/4
RadioBlockSerialInterface interface = RadioBlockSerialInterface(-1,-1,1,5);


uint8_t payload[] = {2};


void setup()
{
  DigiUSB.begin();
  TinyWireM.begin();                    // initialize I2C lib - comment this out to use with standard arduinos
  lcd.init();                           // initialize the lcd
  lcd.backlight();                      // Print a message to the LCD.
  lcd.setCursor(0, currentLine);
  interface.begin(); 
  DigiUSB.println("Starting...");
}


void loop() // run over and over
{
  interface.setLED(true);
  delay(500);
  interface.setLED(false);
  delay(1500);
  interface.toggleLED();
 
  if (interface.readPacket(1000)) {
    if (interface.getResponse().getErrorCode() == APP_STATUS_SUCESS){
      DigiUSB.println("Party");
    } else {
     DigiUSB.println("I failed");
    }
     DigiUSB.print("Len: ");
     DigiUSB.print(interface.getResponse().getPacketLength(), DEC);
     DigiUSB.print(", Command: ");
     DigiUSB.print(interface.getResponse().getCommandId(), HEX);
     DigiUSB.print(", CRC: ");
     DigiUSB.print(interface.getResponse().getCrc(), HEX);
     DigiUSB.println("");
  }


 
}

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: DigiUSB & SoftwareSerial
« Reply #1 on: January 26, 2013, 02:18:59 am »
The Attiny85 is pretty limited in the number of timers, interrupts, etc - in addition DigiUSB is still very much a first release, much like Arduino was when it first came about, there is no doubt much work to be done to make things more plug and play. DigiUSB is high on our list for improvement and we'll also be offering rewards for others to contribute to its improvement. All that said software serial and bit banging USB at the same time is asking a whole lot technically from a little chip, so while it may be possible it will certainly have some limitations.


In the meantime if you feel adventurous look at the DigiUSB code and the V-USB project, which has tons of example projects with the attiny85 and is what all of this is based on.