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 <asf.h>
#include "adp_interface.h"

Macros

#define TIMEOUT   1000
 
#define TWI_EDBG_SLAVE_ADDR   0x28
 
Embedded debugger TWI interface definitions
#define EDBG_TWI_MODULE   TWI0
 

Functions

enum status_code adp_interface_init (void)
 Initialize EDBG TWI interface for SAM4S. More...
 
enum status_code adp_interface_read_response (uint8_t *data, uint16_t length)
 Read data on TWI. More...
 
static enum status_code adp_interface_send (uint8_t *tx_buf, uint16_t length)
 Send data on TWI. More...
 
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...
 

#define EDBG_TWI_MODULE   TWI0
#define TIMEOUT   1000
#define TWI_EDBG_SLAVE_ADDR   0x28

enum status_code adp_interface_init ( void  )

Initialize EDBG TWI interface for SAM4S.

References EDBG_TWI_MODULE, twi_options::speed, sysclk_init(), TWI_EDBG_SLAVE_ADDR, and twi_master_setup().

enum status_code adp_interface_read_response ( uint8_t *  data,
uint16_t  length 
)

Read data on TWI.

Parameters
[out]dataPointer to place received data
[in]lengthNumber of bytes to receive

References twi_packet::buffer, twi_packet::chip, data, EDBG_TWI_MODULE, ERR_IO_ERROR, twi_packet::length, status, TWI_EDBG_SLAVE_ADDR, and twi_master_read().

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

Send data on TWI.

Parameters
[in]dataPointer to data to send
[in]lengthNumber of bytes to send

References twi_packet::chip, EDBG_TWI_MODULE, TWI_EDBG_SLAVE_ADDR, twi_master_write(), and tx_buf.

Referenced by adp_interface_transceive_procotol().

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().