ATSHA204 i2c encryption chip

Hello I'm trying to get the ATSHA204 encryption chip working on the m0 or due board. I'm coming up with Errors. I thought it might be a chip problem. So i tried the i2c scanner and it did work with the address of

Scanning...
I2C device found at address 0x64 !
done

So the chip is working with no problem. Next i tried to see if i can use a uno board because i only have one uno board and it's on another project of mine. That compiles with no problem and even works. So that lead me to believe the Library is not for a 32 bit board. I tried to look all over online and the only libraries i found besides the one i have are for one Wire chip of this same thing. Every library i found all use a digital pin.

Has anyone else seen this problem or has a library that can work with a 32 bit? I can not find anything and i need to really program this chip. Can someone please help me?

Joseph

So that lead me to believe the Library is not for a 32 bit board.

Which library would that be?

Hello AWOL i thought i posted that link in her. My fault the link for the library is here.

This is the error I'm getting.

Arduino: 1.8.5 (Windows 10), Board: "Arduino M0 Pro (Programming Port)"

In file included from C:\Users\my\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.20\cores\arduino/delay.h:23:0,

                 from C:\Users\my\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.20\cores\arduino/Arduino.h:81,

                 from C:\Users\my\Documents\Arduino\libraries\arduino_sha204-master\SHA204SWI.cpp:17:

C:\Users\my\Documents\Arduino\libraries\arduino_sha204-master\SHA204SWI.cpp: In constructor 'SHA204SWI::SHA204SWI(uint8_t)':

C:\Users\my\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.20\variants\arduino_mzero/variant.h:62:82: error: invalid conversion from 'PortGroup*' to 'uint8_t {aka unsigned char}' [-fpermissive]

 #define digitalPinToPort(P)        ( &(PORT->Group[g_APinDescription[P].ulPort]) )

                                                                                  ^

C:\Users\my\Documents\Arduino\libraries\arduino_sha204-master\SHA204SWI.cpp:33:17: note: in expansion of macro 'digitalPinToPort'

  uint8_t port = digitalPinToPort(pin); // temoporarily used to get the next three registers

                 ^

C:\Users\my\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.20\variants\arduino_mzero/variant.h:67:44: error: base operand of '->' is not a pointer

 #define portModeRegister(port)     ( &(port->DIR.reg) )

                                            ^

C:\Users\my\Documents\Arduino\libraries\arduino_sha204-master\SHA204SWI.cpp:36:20: note: in expansion of macro 'portModeRegister'

  device_port_DDR = portModeRegister(port);

                    ^

C:\Users\my\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.20\variants\arduino_mzero/variant.h:65:44: error: base operand of '->' is not a pointer

 #define portOutputRegister(port)   ( &(port->OUT.reg) )

                                            ^

C:\Users\my\Documents\Arduino\libraries\arduino_sha204-master\SHA204SWI.cpp:38:20: note: in expansion of macro 'portOutputRegister'

  device_port_OUT = portOutputRegister(port);

                    ^

C:\Users\my\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.20\variants\arduino_mzero/variant.h:66:44: error: base operand of '->' is not a pointer

 #define portInputRegister(port)    ( &(port->IN.reg) )

                                            ^

C:\Users\my\Documents\Arduino\libraries\arduino_sha204-master\SHA204SWI.cpp:40:19: note: in expansion of macro 'portInputRegister'

  device_port_IN = portInputRegister(port);

                   ^

exit status 1
Error compiling for board Arduino M0 Pro (Programming Port).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

josephchrzempiec:
Hello I'm trying to get the ATSHA204 encryption chip working on the m0 or due board. I'm coming up with Errors. I thought it might be a chip problem.

How could it possibly be a chip problem? The errors you posted in Reply #3 are compiler errors. Your code didn't even download to the target processor, let alone attempt to talk with the encryption chip.

Hello it is not the chip. Becuase it compil3s fine if on a avr like unos boards or megas. But if i put a due or a m0 pro board that is when i get the error. The chip works fine on a uno board but i only have one for as nother peoject. My m0 and due is what i have to use.

josephchrzempiec:
Becuase it compil3s fine if on a avr like unos boards or megas.

What is it? You haven't posted any code.

Hello I'm sorry for that i totally forgot to add the code. I'm using a sample code that came with the library. I changed nothing on it.

[pre]/*
Copyright 2013 Nusku Networks

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include <SHA204.h>
#include <SHA204Definitions.h>

// Uncomment this block for SWI testing
//#include <SHA204SWI.h>
//const int sha204Pin = 7;
//SHA204SWI sha204dev(sha204Pin);

// Uncomment this block for I2C testing
#include <Wire.h>
#include <SHA204I2C.h>
SHA204I2C sha204dev;

void setup() {
 Serial.begin(9600);
 while (!Serial);

 // Only start I2C if Wire.h is included
 #ifdef TwoWire_h
 Serial.println("Starting I2C");
 Wire.begin();
 sha204dev.init(); // Be sure to wake up device right as I2C goes up otherwise you'll have NACK issues
 #endif
Serial.println(millis());
for (int i=0; i<12; i++) {
 Serial.println("Sleep!");
 //sha204dev.sleep();
 delay(3000);
 Serial.println("Wake!");
 wakeupExample();
 Serial.println("----------");
 //Serial.println("Testing Chip");
 //Serial.println();
 //Serial.println("Sending a Wakup Command. Response should be:\r\n4 11 33 43:");
 //Serial.println("Response is:");
 //wakeupExample();
 //delay(500);
 Serial.println();
 Serial.println("Asking the SHA204's serial number. Response should be:");
 Serial.println("1 23 x x x x x x x EE");
 Serial.println("Response is:");
 serialNumberExample();
 //Serial.println();
 //Serial.println("Sending a MAC Challenge. Response should be:");
 //Serial.println("23 6 67 0 4F 28 4D 6E 98 62 4 F4 60 A3 E8 75 8A 59 85 A6 79 96 C4 8A 88 46 43 4E B3 DB 58 A4 FB E5 73");
 //Serial.println("Response is:");
 //macChallengeExample();
}
Serial.println(millis());
Serial.println("Done!");
}

void loop() {
}

byte wakeupExample() {
 uint8_t response[SHA204_RSP_SIZE_MIN];
 byte returnValue;
 
 returnValue = sha204dev.resync(4, &response[0]);
 for (int i=0; i<SHA204_RSP_SIZE_MIN; i++) {
 Serial.print(response[i], HEX);
 Serial.print(" ");
 }
 Serial.println();
 
 return returnValue;
}

byte serialNumberExample() {
 uint8_t serialNumber[9];
 byte returnValue;
 
 returnValue = sha204dev.serialNumber(serialNumber);
 for (int i=0; i<9; i++) {
 Serial.print(serialNumber[i], HEX);
 Serial.print(" ");
 }
 Serial.println();
 
 Serial.println("-------"); 
 
 return returnValue;
}

byte macChallengeExample() {
 uint8_t command[MAC_COUNT_LONG];
 uint8_t response[MAC_RSP_SIZE];

 const uint8_t challenge[MAC_CHALLENGE_SIZE] = {
 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
 };

 uint8_t ret_code = sha204dev.execute(SHA204_MAC, 0, 0, MAC_CHALLENGE_SIZE, 
 (uint8_t *) challenge, 0, NULL, 0, NULL, sizeof(command), &command[0], 
 sizeof(response), &response[0]);

 for (int i=0; i<SHA204_RSP_SIZE_MAX; i++) {
 Serial.print(response[i], HEX);
 Serial.print(' ');
 }
 Serial.println();
 
 return ret_code;
}

Try removing the files 'SHA204SWI.h' and 'SHA204SWI.cpp' from the folder containing the rest of the SHA204 library.

EDIT:
Quit the Arduino IDE before removing the files, then restart it.

Hello I'm out of town at my dads he is in the Hospital with cancer. I did have my laptop with the sketch and library on it. I removed the file and tried to do a compile, It did compiled with no problem. I will test the code with the security chip when i get back home. Thank you.