File ns_spi.h
FileList > includes-api > ns_spi.h
Go to the source code of this file
Generic SPI driver. More...
#include "am_bsp.h"
#include "am_mcu_apollo.h"
#include "am_util.h"
Classes
Type | Name |
---|---|
struct | ns_spi_cfg |
Public Types
Type | Name |
---|---|
typedef void(* | ns_spi_cb |
typedef struct ns_spi_cfg | ns_spi_config_t |
enum | ns_spi_status_e |
Public Functions
Type | Name |
---|---|
uint32_t | ns_spi_interface_init (ns_spi_config_t * cfg, uint32_t speed, am_hal_iom_spi_mode_e mode) Initialize the SPI interface. |
uint32_t | ns_spi_read (ns_spi_config_t * cfg, const void * buf, uint32_t bufLen, uint64_t reg, uint32_t regLen, uint32_t csPin) Read from a SPI device. The SPI device is selected by the csPin parameter. |
uint32_t | ns_spi_read_dma (ns_spi_config_t * cfg, const void * buf, uint32_t bufLen, uint64_t reg, uint32_t regLen, uint32_t csPin) Issure DMA read, the cfg->callback will be called when the transfer is complete. |
uint32_t | ns_spi_transfer (ns_spi_config_t * cfg, const void * txBuf, const void * rxBuf, uint32_t size, uint32_t csPin) Transfer data to/from a SPI device. The SPI device is selected by the csPin parameter. |
uint32_t | ns_spi_write (ns_spi_config_t * cfg, const void * buf, uint32_t bufLen, uint64_t reg, uint32_t regLen, uint32_t csPin) Write to a SPI device. The SPI device is selected by the csPin parameter. |
Detailed Description
Author:
Adam Page
Version:
0.1
Date:
2022-08-26
Copyright:
Copyright (c) 2022
Public Types Documentation
typedef ns_spi_cb
typedef void(* ns_spi_cb) (struct ns_spi_cfg *);
typedef ns_spi_config_t
typedef struct ns_spi_cfg ns_spi_config_t;
enum ns_spi_status_e
enum ns_spi_status_e {
NS_SPI_STATUS_SUCCESS = 0,
NS_SPI_STATUS_ERROR = 1
};
Public Functions Documentation
function ns_spi_interface_init
Initialize the SPI interface.
uint32_t ns_spi_interface_init (
ns_spi_config_t * cfg,
uint32_t speed,
am_hal_iom_spi_mode_e mode
)
Parameters:
cfg
SPI Configurationspeed
Bus speed in Hzmode
SPI mode (CPOL, CPHA)
Returns:
uint32_t
function ns_spi_read
Read from a SPI device. The SPI device is selected by the csPin parameter.
uint32_t ns_spi_read (
ns_spi_config_t * cfg,
const void * buf,
uint32_t bufLen,
uint64_t reg,
uint32_t regLen,
uint32_t csPin
)
Parameters:
cfg
SPI Configurationbuf
Buffer to read intobufLen
Buffer lengthreg
Register to read fromregLen
Register lengthcsPin
CS pin number
Returns:
uint32_t
function ns_spi_read_dma
Issure DMA read, the cfg->callback will be called when the transfer is complete.
uint32_t ns_spi_read_dma (
ns_spi_config_t * cfg,
const void * buf,
uint32_t bufLen,
uint64_t reg,
uint32_t regLen,
uint32_t csPin
)
Parameters:
cfg
buf
bufLen
reg
regLen
csPin
Returns:
uint32_t
function ns_spi_transfer
Transfer data to/from a SPI device. The SPI device is selected by the csPin parameter.
uint32_t ns_spi_transfer (
ns_spi_config_t * cfg,
const void * txBuf,
const void * rxBuf,
uint32_t size,
uint32_t csPin
)
Parameters:
cfg
SPI ConfigurationtxBuf
Transmit bufferrxBuf
Receive buffersize
Size of the transfercsPin
CS pin number
Returns:
uint32_t
function ns_spi_write
Write to a SPI device. The SPI device is selected by the csPin parameter.
uint32_t ns_spi_write (
ns_spi_config_t * cfg,
const void * buf,
uint32_t bufLen,
uint64_t reg,
uint32_t regLen,
uint32_t csPin
)
Parameters:
cfg
SPI Configurationbuf
Buffer to write frombufLen
Buffer lengthreg
Register to write toregLen
Register lengthcsPin
CS pin number
Returns:
uint32_t
The documentation for this class was generated from the following file neuralSPOT/neuralspot/ns-spi/includes-api/ns_spi.h