Microchip® Advanced Software Framework

nm_bus_wrapper_same70.c File Reference

This module contains NMC1000 bus wrapper APIs implementation.

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

#include <stdio.h>
#include "bsp/include/nm_bsp.h"
#include "common/include/nm_common.h"
#include "bus_wrapper/include/nm_bus_wrapper.h"
#include "asf.h"
#include "conf_winc.h"

Macros

#define NM_BUS_MAX_TRX_SZ   4096
 
#define SPI0_XDMAC_RX_CH_NUM   2
 
#define SPI0_XDMAC_TX_CH_NUM   1
 XDMAC channel HW Interface number for SPI0,refer to datasheet. More...
 
#define SPI_ASSERT_CS()   do {p_pio->PIO_CODR = 1 << (CONF_WINC_SPI_CS_GPIO & 0x1F);}while(0)
 
#define SPI_DEASSERT_CS()   do {p_pio->PIO_SODR = 1 << (CONF_WINC_SPI_CS_GPIO & 0x1F);}while(0)
 
#define XDMAC_RX_CH   1
 
#define XDMAC_TX_CH   0
 XDMAC channel used in this example. More...
 
#define xSPI_ASSERT_CS()   {gpio_set_pin_low(CONF_WINC_SPI_CS_GPIO);}
 
#define xSPI_DEASSERT_CS()   {gpio_set_pin_high(CONF_WINC_SPI_CS_GPIO);}
 

Functions

sint8 nm_bus_deinit (void)
 De-initialize the bus wrapper. More...
 
sint8 nm_bus_init (uint8_t *pvinit, uint32 req_serial_number)
 
sint8 nm_bus_ioctl (uint8 u8Cmd, void *pvParameter)
 
static sint8 spi_rw (uint8 *pu8Mosi, uint8 *pu8Miso, uint16 u16Sz)
 
static sint8 spi_xdmac_configure (Spi *const pspi, uint8 *u8Mosi, uint8 *u8Miso, uint16 pu16Sz)
 
sint8 spi_xdmac_init ()
 
void XDMAC_Handler (void)
 

Variables

uint16_t check [100]
 XDMAC interrupt handler. More...
 
uint8_t dummy [1500]
 
tstrNmBusCapabilities egstrNmBusCapabilities
 
Pio * p_pio
 configure xdmac for spi and ready to transfer/receive. More...
 
Pio * p_pio_cs
 PIO instance used by CS. More...
 
volatile uint8_t rx_irq_complete
 
volatile uint8_t tx_irq_complete
 
volatile uint8_t xdma_irq_complete = 0
 
static xdmac_channel_config_t xdmac_rx_cfg
 
static xdmac_channel_config_t xdmac_tx_cfg
 XDMAC channel configuration. More...
 

#define NM_BUS_MAX_TRX_SZ   4096
#define SPI0_XDMAC_RX_CH_NUM   2

Referenced by spi_xdmac_init().

#define SPI0_XDMAC_TX_CH_NUM   1

XDMAC channel HW Interface number for SPI0,refer to datasheet.

Referenced by spi_xdmac_init().

#define SPI_ASSERT_CS ( )    do {p_pio->PIO_CODR = 1 << (CONF_WINC_SPI_CS_GPIO & 0x1F);}while(0)

Referenced by spi_rw(), and spi_xdmac_configure().

#define SPI_DEASSERT_CS ( )    do {p_pio->PIO_SODR = 1 << (CONF_WINC_SPI_CS_GPIO & 0x1F);}while(0)
#define XDMAC_RX_CH   1
#define XDMAC_TX_CH   0

XDMAC channel used in this example.

Referenced by spi_xdmac_configure(), spi_xdmac_init(), and XDMAC_Handler().

#define xSPI_ASSERT_CS ( )    {gpio_set_pin_low(CONF_WINC_SPI_CS_GPIO);}
#define xSPI_DEASSERT_CS ( )    {gpio_set_pin_high(CONF_WINC_SPI_CS_GPIO);}

nm_bus_deinit ( void  )

De-initialize the bus wrapper.

Returns
ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure

References CONF_WINC_SPI, CONF_WINC_SPI_CLK_GPIO, CONF_WINC_SPI_CS_GPIO, CONF_WINC_SPI_MISO_GPIO, CONF_WINC_SPI_MOSI_GPIO, IOPORT_DIR_INPUT, ioport_set_pin_dir(), M2M_SUCCESS, and spi_disable().

Referenced by nm_bus_iface_deinit().

static sint8 spi_rw ( uint8 pu8Mosi,
uint8 pu8Miso,
uint16  u16Sz 
)
static

uint16_t check[100]

XDMAC interrupt handler.

uint8_t dummy[1500]

Referenced by spi_xdmac_configure().

tstrNmBusCapabilities egstrNmBusCapabilities
Initial value:
=
{
}
#define NM_BUS_MAX_TRX_SZ
Definition: nm_bus_wrapper_same70.c:49

Referenced by nm_read_block(), and nm_write_block().

Pio* p_pio

configure xdmac for spi and ready to transfer/receive.

Parameters
pspiBase address of the SPI

Referenced by pio_configure_pin(), pio_disable_pin_interrupt(), pio_enable_pin_interrupt(), pio_get_pin_group(), pio_get_pin_value(), pio_set_pin_high(), pio_set_pin_low(), pio_toggle_pin(), and spi_rw().

Pio* p_pio_cs

PIO instance used by CS.

Referenced by nm_bus_init().

volatile uint8_t rx_irq_complete
volatile uint8_t tx_irq_complete
volatile uint8_t xdma_irq_complete = 0

Referenced by XDMAC_Handler().

xdmac_channel_config_t xdmac_rx_cfg
static
xdmac_channel_config_t xdmac_tx_cfg
static

XDMAC channel configuration.