|
@ -55,7 +55,8 @@ static event_t events[N_EVENTS]; |
|
|
#define DEBUG_WRITE(a) |
|
|
#define DEBUG_WRITE(a) |
|
|
#endif /* DEBUG */ |
|
|
#endif /* DEBUG */ |
|
|
|
|
|
|
|
|
int led = LED; |
|
|
uint8_t led = LED; |
|
|
|
|
|
uint8_t state; |
|
|
// Metro
|
|
|
// Metro
|
|
|
Metro METRO_CAN = Metro(METRO_CAN_tick); |
|
|
Metro METRO_CAN = Metro(METRO_CAN_tick); |
|
|
Metro METRO_OW_read = Metro(METRO_OW_read_tick); |
|
|
Metro METRO_OW_read = Metro(METRO_OW_read_tick); |
|
@ -69,8 +70,6 @@ uint8_t readout,trig_event,event_idx,tmp; |
|
|
OneWire OW_1(OW_pin); |
|
|
OneWire OW_1(OW_pin); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static CAN_message_t txmsg,rxmsg; |
|
|
static CAN_message_t txmsg,rxmsg; |
|
|
static uint8_t hex[17] = "0123456789abcdef"; |
|
|
static uint8_t hex[17] = "0123456789abcdef"; |
|
|
|
|
|
|
|
@ -118,6 +117,11 @@ uint8_t read_DS2406(uint8_t* addr) { |
|
|
#endif /* DEBUG */ |
|
|
#endif /* DEBUG */ |
|
|
return tmp; |
|
|
return tmp; |
|
|
} |
|
|
} |
|
|
|
|
|
uint8_t toggle_Pin(uint8_t pin){ |
|
|
|
|
|
digitalWrite(pin, !digitalRead(pin)); |
|
|
|
|
|
return digitalRead(pin); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// -------------------------------------------------------------
|
|
|
// -------------------------------------------------------------
|
|
|
void setup(void) |
|
|
void setup(void) |
|
|
{ |
|
|
{ |
|
@ -142,9 +146,11 @@ void setup(void) |
|
|
events[0].telegram.buf[1] = 0xAD; |
|
|
events[0].telegram.buf[1] = 0xAD; |
|
|
events[1].id =0x02; |
|
|
events[1].id =0x02; |
|
|
events[1].telegram.id = 0x0204BEEF; |
|
|
events[1].telegram.id = 0x0204BEEF; |
|
|
events[1].telegram.len = 2; |
|
|
events[1].telegram.len = 4; |
|
|
events[1].telegram.buf[0] = 0xBE; |
|
|
events[1].telegram.buf[0] = 0xDE; |
|
|
events[1].telegram.buf[1] = 0xEF; |
|
|
events[1].telegram.buf[1] = 0xAD; |
|
|
|
|
|
events[1].telegram.buf[2] = 0xBE; |
|
|
|
|
|
events[1].telegram.buf[3] = 0xEF; |
|
|
|
|
|
|
|
|
//{ 0x02040608, 2, { 0xbe, 0xef }}};
|
|
|
//{ 0x02040608, 2, { 0xbe, 0xef }}};
|
|
|
|
|
|
|
|
@ -241,17 +247,34 @@ void loop(void) |
|
|
// if frames were received, print the count
|
|
|
// if frames were received, print the count
|
|
|
if ( rxCount ) { |
|
|
if ( rxCount ) { |
|
|
//#if DEBUG
|
|
|
//#if DEBUG
|
|
|
Serial.write('='); |
|
|
// Serial.write('=');
|
|
|
Serial.print(rxCount); |
|
|
// Serial.print(rxCount);
|
|
|
Serial.print(",Hello="); |
|
|
Serial.print("GOT="); |
|
|
Serial.print(rxmsg.id,HEX); |
|
|
Serial.print(rxmsg.id,HEX); |
|
|
//#endif
|
|
|
for (uint8_t i=0; i<rxmsg.len; i++){ |
|
|
|
|
|
Serial.print(":"); |
|
|
|
|
|
Serial.print(rxmsg.buf[i],HEX); |
|
|
|
|
|
} |
|
|
|
|
|
Serial.print("\n"); |
|
|
|
|
|
if (rxmsg.id ==0x0102DEAD) { |
|
|
|
|
|
state=toggle_Pin(led); |
|
|
|
|
|
txmsg.id=0xDEADBEEF; |
|
|
|
|
|
txmsg.len=2; |
|
|
|
|
|
txmsg.buf[0]=led; |
|
|
|
|
|
txmsg.buf[1]=state; |
|
|
|
|
|
} |
|
|
|
|
|
//#endif
|
|
|
rxCount = 0; |
|
|
rxCount = 0; |
|
|
} |
|
|
} |
|
|
txTimer = 100;//milliseconds
|
|
|
txTimer = 100;//milliseconds
|
|
|
if (txmsg.len != 0){ |
|
|
if (txmsg.len != 0){ |
|
|
Serial.print("Sending to CAN"); |
|
|
Serial.print("PUT="); |
|
|
Serial.print(txmsg.id,HEX); |
|
|
Serial.print(txmsg.id,HEX); |
|
|
|
|
|
for (uint8_t i=0; i<txmsg.len; i++){ |
|
|
|
|
|
Serial.print(":"); |
|
|
|
|
|
Serial.print(txmsg.buf[i],HEX); |
|
|
|
|
|
} |
|
|
|
|
|
Serial.print("\n"); |
|
|
CANbus.write(txmsg); |
|
|
CANbus.write(txmsg); |
|
|
txmsg.buf[0]++; |
|
|
txmsg.buf[0]++; |
|
|
txmsg.len = 0; |
|
|
txmsg.len = 0; |
|
|