Hi can anyone please help me with Arduino UNO rev. 3 with ATSHA204 (microcontroller=ATMEGA328p)?
First I list my code and then the problem underneath. I am using the atmel library for the ATSHA204. I am using Atmel Studio 6.1 (beta).
// include necessary libraries from Arduino and Atmel for ATMEGA328p
#include <Arduino.h>
#include <Wire.h>
#include <Wire.cpp>
#include <twi.h>
#include <twi.c>
#include <sha204_lib_return_codes.h>
#include <timer_utilities.h>
#include <timer_utilities.c>
#include <sha204_physical.h>
#include <i2c_phys.h>
#include <i2c_phys.c>
#include <sha204_i2c.c>
#include <sha204_comm.h>
#include <sha204_comm.c>
// result of functions
volatile uint8_t ret_code;
// counter for response array
volatile uint8_t i;
// e.g. 4 bytes
static uint8_t response[SHA204_RSP_SIZE_MIN];
void setup() {
// open Arduino for serial output
Serial.begin(9600);
// Make Arduino a Master on the I2C bus
Wire.begin();
// Make ATSHA204 a slave on the I2C bus
sha204p_init();
// initialize response array
for (i = 0; i < sizeof(response); i++)
response[i] = 0;
// re-sync comm
ret_code=sha204p_resync(sizeof(response),&response[0]);
// force it to sleep
ret_code=sha204p_sleep();
Serial.println("Result of Sleep Command:");
Serial.println(ret_code,HEX);
// wake it up
// 0 out response array
for (i = 0; i < sizeof(response); i++)
response[i] = 0;
// wake command
ret_code=sha204c_wakeup(&response[0]);
Serial.println("Result of Wakeup Command:");
Serial.println(ret_code,HEX);
// we are done
Serial.end();
}
void loop() {
}
Here are results in Arduino serial monitor
First my sleep command fails (returns comm failure F0)
Next my wakeup command does not fail but returns this: E7 which means:
"Not an error while the Command layer is polling for a command response.
I should be geting 0x00 success message instead