This module contains NMC1000 bus wrapper APIs implementation.
Copyright (c) 2016-2021 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 | 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 | 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 (void *pvinit) |
sint8 | nm_bus_ioctl (uint8 u8Cmd, void *pvParameter) |
sint8 | nm_spi_rw (uint8 *pu8Mosi, uint8 *pu8Miso, uint16 u16Sz) |
Variables | |
tstrNmBusCapabilities | egstrNmBusCapabilities |
static Pdc * | g_p_spim_pdc |
Pointer to Pdc data structure. More... | |
Pio * | p_pio |
PIO instance used by CS. More... | |
#define NM_BUS_MAX_TRX_SZ 4096 |
#define SPI_ASSERT_CS | ( | ) | do {p_pio->PIO_CODR = 1 << (CONF_WINC_SPI_CS_GPIO & 0x1F);}while(0) |
Referenced by nm_spi_rw().
#define SPI_DEASSERT_CS | ( | ) | do {p_pio->PIO_SODR = 1 << (CONF_WINC_SPI_CS_GPIO & 0x1F);}while(0) |
Referenced by nm_bus_init(), and nm_spi_rw().
#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.
References M2M_SUCCESS.
Referenced by nm_bus_iface_deinit().
sint8 nm_bus_init | ( | void * | pvinit | ) |
References CONF_WINC_SPI, CONF_WINC_SPI_CLK_FLAGS, CONF_WINC_SPI_CLK_GPIO, CONF_WINC_SPI_CLOCK, CONF_WINC_SPI_CS_FLAGS, CONF_WINC_SPI_CS_GPIO, CONF_WINC_SPI_DLYBCT, CONF_WINC_SPI_DLYBS, CONF_WINC_SPI_MISO_FLAGS, CONF_WINC_SPI_MISO_GPIO, CONF_WINC_SPI_MOSI_FLAGS, CONF_WINC_SPI_MOSI_GPIO, CONF_WINC_SPI_NPCS, CONF_WINC_SPI_PHA, CONF_WINC_SPI_POL, g_p_spim_pdc, gpio_configure_pin, M2M_SUCCESS, nm_bsp_reset(), nm_bsp_sleep(), pdc_disable_transfer(), SPI_DEASSERT_CS, spi_disable(), spi_disable_mode_fault_detect(), spi_enable(), spi_enable_clock(), spi_get_pdc_base(), spi_reset(), spi_set_baudrate_div(), spi_set_bits_per_transfer(), spi_set_clock_phase(), spi_set_clock_polarity(), spi_set_fixed_peripheral_select(), spi_set_master_mode(), spi_set_peripheral_chip_select_value(), spi_set_transfer_delay(), and sysclk_get_cpu_hz().
Referenced by nm_bus_iface_init().
References M2M_ERR, NM_BUS_IOCTL_R, NM_BUS_IOCTL_RW, NM_BUS_IOCTL_W, NM_BUS_IOCTL_W_SPECIAL, nm_spi_rw(), tstrNmI2cDefault::pu8Buf, tstrNmI2cSpecial::pu8Buf1, tstrNmI2cSpecial::pu8Buf2, tstrNmSpiRw::pu8InBuf, tstrNmSpiRw::pu8OutBuf, tstrNmI2cDefault::u16Sz, tstrNmSpiRw::u16Sz, tstrNmI2cSpecial::u16Sz1, and tstrNmI2cSpecial::u16Sz2.
References CONF_WINC_SPI, CONF_WINC_SPI_CS_GPIO, g_p_spim_pdc, M2M_ERR_BUS_FAIL, M2M_SUCCESS, NULL, p_pio, pdc_rx_init(), pdc_tx_init(), PIO_DELTA, SPI_ASSERT_CS, SPI_DEASSERT_CS, spi_read(), spi_write(), pdc_packet::ul_addr, and pdc_packet::ul_size.
Referenced by nm_bus_ioctl(), nmi_spi_read(), nmi_spi_write(), and nmi_spi_writeread().
tstrNmBusCapabilities egstrNmBusCapabilities |
Referenced by nm_read_block(), and nm_write_block().
|
static |
Pointer to Pdc data structure.
Referenced by nm_bus_init(), and nm_spi_rw().
Pio* p_pio |
PIO instance used by CS.
Referenced by nm_spi_rw(), 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(), and pio_toggle_pin().