KalbeAbbas
Published © MIT

Introduction to XinaBox xChip AH01(ATECC508A) with Zerynth

Learn how to use XinaBox xChip AH01 (ATECC508A) – SHA-256 Hardware Encryption – using xChip CW02 with Zerynth.

BeginnerFull instructions provided6 minutes695
Introduction to XinaBox xChip AH01(ATECC508A) with Zerynth

Things used in this project

Hardware components

AH01
XinaBox AH01
×1
CW02
XinaBox CW02
×1
IP01
XinaBox IP01
×1
XC10
XinaBox XC10
×1

Software apps and online services

Zerynth Studio
Zerynth Studio

Story

Read more

Code

main.py

Python
import streams
from xinabox.ah01 import ah01

PORT = I2C0
CLOCK = 100000

streams.serial()
crypto = ah01.ATECC508A(PORT, clk=CLOCK)


def bytes_hex(data):
    """ Return hex string representation of bytes/bytearray object. """
    res = "0x"
    for byte in data:
        res += "%02X" % byte

    return res


def info_cmd_test():
 """ Send an info command and check the result, which is a chip constant. """
    expected = bytes([0x00, 0x00, 0x50, 0x00]) #Expected response
    response = crypto.info_cmd('revision')
    if response == expected:
        print("Success. Device replied correctly.")
    else:
        print("Response from device not matching:")
        print(bytes_hex(response)) #Hex response prints on the console 


while True:
    try:
        info_cmd_test()
    except Exception as err:
        print(err)
    sleep(1000)

Credits

KalbeAbbas

KalbeAbbas

25 projects • 20 followers
An enthusiastic and dedicated Electronic engineer graduated from SSUET Karachi, Pakistan. Loves to discover Embedded electronics projects.
Thanks to XinaBox.

Comments