Microchip® Advanced Software Framework

adp_interface_spi.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"

Functions

enum status_code adp_interface_init (void)
 Initialize EDBG SPI communication for SAM0. 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_module edbg_spi
 
struct spi_slave_inst slave
 

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, spi_read_buffer_wait(), and status.

static void adp_interface_send_start ( void  )
static

Send SPI start condition.

References edbg_spi, slave, and spi_select_slave().

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, slave, and spi_select_slave().

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, and spi_transceive_buffer_wait().

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_slave_inst slave