Hi!
I would like to "emulate" a DS2502 using a Teensy2++, but I have trouble doing it. I've searched and did not found any documented experiences using T2++ as an 1-Wire slave device, but I've found a good looking 1-Wire Slave library here https://github.com/neuoy/OneWireArduinoSlave. The functionality looks good and it is also interrupt based, which is nice.
The problem that it does not work with the T2++, and my guess is that there is some error in the interrupt / pin configuration. Debugging this is far out of my knowledge, could anybody help me?
Here is my sketch:
It gives a few warnings, but compiles. I guess it never enters the loop, because there is nothing received by the serial monitor.
Any help is appreciated!
I would like to "emulate" a DS2502 using a Teensy2++, but I have trouble doing it. I've searched and did not found any documented experiences using T2++ as an 1-Wire slave device, but I've found a good looking 1-Wire Slave library here https://github.com/neuoy/OneWireArduinoSlave. The functionality looks good and it is also interrupt based, which is nice.
The problem that it does not work with the T2++, and my guess is that there is some error in the interrupt / pin configuration. Debugging this is far out of my knowledge, could anybody help me?
Here is my sketch:
Code:
#include "LowLevel.h"
#include "OneWireSlave.h"
//Pin oneWireData(0);
Pin oneWireData(2);
// This is the ROM the arduino will respond to, make sure it doesn't conflict with another device
const byte owROM[7] = { 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 };
enum DeviceState
{
DS_WaitingReset,
DS_WaitingCommand,
};
volatile DeviceState state = DS_WaitingReset;
// This function will be called each time the OneWire library has an event to notify (reset, error, byte received)
void owReceive(OneWireSlave::ReceiveEvent evt, byte data);
void setup()
{
Serial.begin(9600);
// Setup the OneWire library
OWSlave.setReceiveCallback(&owReceive);
OWSlave.begin(owROM, oneWireData.getPinNumber());
//OWSlave.begin(owROM, 0);
}
void loop()
{
Serial.write("Blink");
delay(5000);
}
void owReceive(OneWireSlave::ReceiveEvent evt, byte data)
{
switch (evt)
{
case OneWireSlave::RE_Byte:
Serial.print("BYTE RECIEVED:");
Serial.println(data, HEX);
break;
case OneWireSlave::RE_Reset:
Serial.println("RESET RECIEVED");
state = DS_WaitingCommand;
break;
case OneWireSlave::RE_Error:
Serial.println("ERROR RECIEVED");
state = DS_WaitingReset;
break;
}
}
It gives a few warnings, but compiles. I guess it never enters the loop, because there is nothing received by the serial monitor.
Any help is appreciated!