CryptoAuthLib
Microchip CryptoAuthentication Library
hal_pic32mz2048efm_i2c.c File Reference

ATCA Hardware abstraction layer for PIC32MZ2048. More...

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "atca_hal.h"
#include "atca_device.h"
#include "hal/hal_pic32mz2048efm_i2c.h"
#include "driver/i2c/drv_i2c.h"
#include "system_definitions.h"
#include "driver/i2c/src/drv_i2c_local.h"

Functions

ATCA_STATUS hal_i2c_discover_devices (int bus_num, ATCAIfaceCfg cfg[], int *found)
 discover any CryptoAuth devices on a given logical bus number More...
 
ATCA_STATUS hal_i2c_discover_buses (int i2c_buses[], int max_buses)
 discover i2c buses available for this hardware this maintains a list of logical to physical bus mappings freeing the application of the a-priori knowledge More...
 
ATCA_STATUS hal_i2c_init (void *hal, ATCAIfaceCfg *cfg)
 initialize an I2C interface using given config More...
 
ATCA_STATUS hal_i2c_post_init (ATCAIface iface)
 HAL implementation of I2C post init. More...
 
ATCA_STATUS hal_i2c_send (ATCAIface iface, uint8_t *txdata, int txlength)
 
ATCA_STATUS hal_i2c_receive (ATCAIface iface, uint8_t *rxdata, uint16_t *rxlength)
 HAL implementation of I2C receive function. More...
 
ATCA_STATUS hal_i2c_wake (ATCAIface iface)
 wake up CryptoAuth device using I2C bus More...
 
ATCA_STATUS hal_i2c_idle (ATCAIface iface)
 idle CryptoAuth device using I2C bus More...
 
ATCA_STATUS hal_i2c_sleep (ATCAIface iface)
 sleep CryptoAuth device using I2C bus More...
 
ATCA_STATUS hal_i2c_release (void *hal_data)
 manages reference count on given bus and releases resource if no more refences exist More...
 

Variables

DRV_HANDLE drvI2CMasterHandle
 
DRV_HANDLE drvI2CMasterHandle1
 
DRV_I2C_BUFFER_HANDLE write_bufHandle
 
DRV_I2C_BUFFER_HANDLE read_bufHandle
 
uint32_t Debug_count = 0
 HAL implementation of I2C send over ASF. More...
 
uint32_t bytes_transferred = 0
 

Detailed Description

ATCA Hardware abstraction layer for PIC32MZ2048.

Function Documentation

◆ hal_i2c_discover_buses()

ATCA_STATUS hal_i2c_discover_buses ( int  i2c_buses[],
int  max_buses 
)

discover i2c buses available for this hardware this maintains a list of logical to physical bus mappings freeing the application of the a-priori knowledge

Parameters
[in]i2c_busesan array of logical bus numbers
[in]max_busesmaximum number of buses the app wants to attempt to discover
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_i2c_discover_devices()

ATCA_STATUS hal_i2c_discover_devices ( int  bus_num,
ATCAIfaceCfg  cfg[],
int *  found 
)

discover any CryptoAuth devices on a given logical bus number

Parameters
[in]bus_numlogical bus number on which to look for CryptoAuth devices
[out]cfgpointer to head of an array of interface config structures which get filled in by this method
[out]foundnumber of devices found on this bus
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_i2c_idle()

ATCA_STATUS hal_i2c_idle ( ATCAIface  iface)

idle CryptoAuth device using I2C bus

Parameters
[in]ifaceinterface to logical device to idle
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_i2c_init()

ATCA_STATUS hal_i2c_init ( void *  hal,
ATCAIfaceCfg cfg 
)

initialize an I2C interface using given config

Parameters
[in]halopaque ptr to HAL data
[in]cfginterface configuration
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_i2c_post_init()

ATCA_STATUS hal_i2c_post_init ( ATCAIface  iface)

HAL implementation of I2C post init.

Parameters
[in]ifaceinstance
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_i2c_receive()

ATCA_STATUS hal_i2c_receive ( ATCAIface  iface,
uint8_t *  rxdata,
uint16_t *  rxlength 
)

HAL implementation of I2C receive function.

Parameters
[in]ifaceDevice to interact with.
[out]rxdataData received will be returned here.
[in,out]rxlengthAs input, the size of the rxdata buffer. As output, the number of bytes received.
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_i2c_release()

ATCA_STATUS hal_i2c_release ( void *  hal_data)

manages reference count on given bus and releases resource if no more refences exist

Parameters
[in]hal_dataopaque pointer to hal data structure - known only to the HAL implementation
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_i2c_send()

ATCA_STATUS hal_i2c_send ( ATCAIface  iface,
uint8_t *  txdata,
int  txlength 
)

◆ hal_i2c_sleep()

ATCA_STATUS hal_i2c_sleep ( ATCAIface  iface)

sleep CryptoAuth device using I2C bus

Parameters
[in]ifaceinterface to logical device to sleep
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ hal_i2c_wake()

ATCA_STATUS hal_i2c_wake ( ATCAIface  iface)

wake up CryptoAuth device using I2C bus

Parameters
[in]ifaceinterface to logical device to wakeup
Returns
ATCA_SUCCESS on success, otherwise an error code.

Variable Documentation

◆ bytes_transferred

uint32_t bytes_transferred = 0

◆ Debug_count

uint32_t Debug_count = 0

HAL implementation of I2C send over ASF.

Parameters
[in]ifaceinstance
[in]txdatapointer to space to bytes to send
[in]txlengthnumber of bytes to send
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ drvI2CMasterHandle

DRV_HANDLE drvI2CMasterHandle

◆ drvI2CMasterHandle1

DRV_HANDLE drvI2CMasterHandle1

◆ read_bufHandle

DRV_I2C_BUFFER_HANDLE read_bufHandle

◆ write_bufHandle

DRV_I2C_BUFFER_HANDLE write_bufHandle