Microchip® Advanced Software Framework

adp_interface_twi.c File Reference

ADP service implementation.

Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.

#include <compiler.h>
#include <system.h>
#include <asf.h>
#include <adp_interface.h>

Macros

#define EDBG_TWI   EDBG_I2C_MODULE
 
#define TIMEOUT   1000
 
#define TWI_EDBG_SLAVE_ADDR   0x28
 

Functions

enum status_code adp_interface_init (void)
 Initialize EDBG I2C communication for SAM0. More...
 
enum status_code adp_interface_read_response (uint8_t *rx_buf, uint16_t length)
 Read response on I2C from PC. More...
 
static enum status_code adp_interface_send (uint8_t *tx_buf, uint16_t length)
 
void adp_interface_transceive_procotol (uint8_t *tx_buf, uint16_t length, uint8_t *rx_buf)
 Sends and reads protocol packet data byte on I2C. More...
 

Variables

struct i2c_master_module i2c_master_instance
 

#define EDBG_TWI   EDBG_I2C_MODULE

Referenced by adp_interface_init().

#define TIMEOUT   1000
#define TWI_EDBG_SLAVE_ADDR   0x28

enum status_code adp_interface_init ( void  )
enum status_code adp_interface_read_response ( uint8_t *  rx_buf,
uint16_t  length 
)

Read response on I2C from PC.

return Status

Parameters
[in]rx_bufPointer to receive the data
[in]lengthThe length of the read data
[out]rx_bufPointer to store the received SPI character

References i2c_master_packet::address, i2c_master_packet::data, i2c_master_packet::data_length, i2c_master_instance, i2c_master_read_packet_wait(), rx_buf, status, STATUS_ERR_IO, and TWI_EDBG_SLAVE_ADDR.

Referenced by adp_interface_transceive_procotol().

static enum status_code adp_interface_send ( uint8_t *  tx_buf,
uint16_t  length 
)
static
void adp_interface_transceive_procotol ( uint8_t *  tx_buf,
uint16_t  length,
uint8_t *  rx_buf 
)

Sends and reads protocol packet data byte on I2C.

Parameters
[in]tx_bufPointer to send the protocol packet data
[in]lengthThe length of the send protocol packet data
[out]rx_bufPointer to store the received I2C character

References adp_interface_read_response(), and adp_interface_send().