Microchip® Advanced Software Framework

adp_interface_spi.c File Reference

ADP SPI interface implementation.

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

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

Macros

#define SPI_BAUDRATE   1500000
 
#define SPI_CHIP_SEL   SPI_NPCS3_PA5_GPIO
 
#define SPI_DEVICE_ID   3
 
Embedded debugger SPI interface definitions
#define EDBG_SPI_MODULE   SPI
 

Functions

enum status_code adp_interface_init (void)
 Initialize EDBG SPI communication for SAM. More...
 
enum status_code adp_interface_read_response (uint8_t *rx_buf, uint16_t length)
 Read response on SPI from PC. More...
 
static void adp_interface_send_start (void)
 Send SPI start condition. More...
 
static void adp_interface_send_stop (void)
 Send SPI stop condition. More...
 
static void adp_interface_transceive (uint8_t *tx_data, uint8_t *rx_data, uint16_t length)
 Sends and reads data byte on SPI. 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 SPI. More...
 

Variables

struct spi_device SPI_DEVICE
 

#define SPI_BAUDRATE   1500000

Referenced by adp_interface_init().

#define SPI_CHIP_SEL   SPI_NPCS3_PA5_GPIO
#define SPI_DEVICE_ID   3

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

Read response on SPI 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 adp_interface_send_start(), adp_interface_send_stop(), EDBG_SPI_MODULE, spi_read_packet(), and status.

Referenced by adp_interface_transceive_procotol().

static void adp_interface_send_start ( void  )
static

Send SPI start condition.

References EDBG_SPI_MODULE, and spi_select_device().

Referenced by adp_interface_read_response(), and adp_interface_transceive_procotol().

static void adp_interface_send_stop ( void  )
static

Send SPI stop condition.

References EDBG_SPI_MODULE, and spi_deselect_device().

Referenced by adp_interface_read_response(), and adp_interface_transceive_procotol().

static void adp_interface_transceive ( uint8_t *  tx_data,
uint8_t *  rx_data,
uint16_t  length 
)
static

Sends and reads data byte on SPI.

Parameters
[in]dataData byte to send
[in]tx_dataSPI character to transmit
[out]rx_dataPointer to store the received SPI character

References EDBG_SPI_MODULE, and spi_transceive_packet().

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 SPI.

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 SPI character

References adp_interface_send_start(), adp_interface_send_stop(), and adp_interface_transceive().

struct spi_device SPI_DEVICE
Initial value:
= {
}
#define SPI_DEVICE_ID
Definition: adp_interface_spi.c:48