OpenCores
URL https://opencores.org/ocsvn/gecko3/gecko3/trunk

Subversion Repositories gecko3

[/] [gecko3/] [trunk/] [GECKO3COM/] [gecko3com-fw/] [firmware/] [include/] [spi.h] - Diff between revs 9 and 32

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 9 Rev 32
Line 25... Line 25...
 *************************************************************
 *************************************************************
 *  \brief SPI bus functions
 *  \brief SPI bus functions
 *
 *
 *  \details Library to communicate with SPI devices
 *  \details Library to communicate with SPI devices
 *
 *
 *  \author  GNU Radio guys
 *  \author  GNU Radio team
 *
 *
 *  \note to use this SPI library you have to define the following
 *  \note to use this SPI library you have to define the following
 *        keywords in your pinmapping header file. For GECKO3COM
 *        keywords in your pinmapping header file. For GECKO3COM
 *        this is the "gecko3com_regs.h" file. \n
 *        this is the "gecko3com_regs.h" file. \n
 *        \li SPI_PORT, SPI signals are connected to this port
 *        \li SPI_PORT, SPI signals are connected to this port
Line 52... Line 52...
 
 
 
 
/*
/*
 * SPI_FMT_* goes in wIndexL
 * SPI_FMT_* goes in wIndexL
 */
 */
#define bmSPI_FORMAT             0x80
#define bmSPI_FORMAT             0x80   /**< bitmask to work on the format */
#  define       bmSPI_FORMAT_LSB 0x80   /**< least signficant bit first */
#  define       bmSPI_FORMAT_LSB 0x80   /**< least signficant bit first */
#  define       bmSPI_FORMAT_MSB 0x00   /**< most significant bit first */
#  define       bmSPI_FORMAT_MSB 0x00   /**< most significant bit first */
#define bmSPI_HEADER             0x60
#define bmSPI_HEADER             0x60   /**< bits to select the header bytes */
#  define       bmSPI_HEADER_0   0x00   /**< 0 header bytes */
#  define       bmSPI_HEADER_0   0x00   /**< 0 header bytes */
#  define       bmSPI_HEADER_1   0x20   /**< 1 header byte */
#  define       bmSPI_HEADER_1   0x20   /**< 1 header byte */
#  define       bmSPI_HEADER_2   0x40   /**< 2 header bytes */
#  define       bmSPI_HEADER_2   0x40   /**< 2 header bytes */
 
 
 
 
/** one time call to init SPI subsystem */
/** one time call to init SPI subsystem */
void init_spi (void);
void init_spi (void);
 
 
/** \brief basic function to read data from the SPI bus
/** \brief basic function to read data from the SPI bus
 * \param[in] unsigned char header_hi, high byte of the header to send
 * \param[in]  header_hi high byte of the header to send
 * \param[in[ unsigned char header_lo, low byte of the header to send
 * \param[in]  header_lo low byte of the header to send
 * \param[in] unsigned char enables, bitmask with the correct device selected
 * \param[in]  enables bitmask with the correct device selected
 * \param[in] unsigned char format, bitmask byte to select byte order
 * \param[in]  format bitmask byte to select byte order
 *            and number of header bytes
 *            and number of header bytes
 * \param[out]*buf pointer to a buffer to write the received data in it
 * \param[out]*buf pointer to a buffer to write the received data in it
 * \param[in] unsigned char len, number of bytes to be read from bus
 * \param[in]  len number of bytes to be read from bus
 *
 *
 * \return returns non-zero if successful, else 0 */
 * \return returns non-zero if successful, else 0 */
unsigned char
unsigned char
spi_read (unsigned char header_hi, unsigned char header_lo,
spi_read (unsigned char header_hi, unsigned char header_lo,
          unsigned char enables, unsigned char format,
          unsigned char enables, unsigned char format,
          xdata unsigned char *buf, unsigned char len);
          xdata unsigned char *buf, unsigned char len);
 
 
/** \brief basic function to write data to the SPI bus
/** \brief basic function to write data to the SPI bus
 * \param[in] unsigned char header_hi, high byte of the header to send
 * \param[in] header_hi high byte of the header to send
 * \param[in[ unsigned char header_lo, low byte of the header to send
 * \param[in] header_lo low byte of the header to send
 * \param[in] unsigned char enables, bitmask with the correct device selected
 * \param[in] enables bitmask with the correct device selected
 * \param[in] unsigned char format, bitmask byte to select byte order
 * \param[in] format bitmask byte to select byte order
 *            and number of header bytes
 *            and number of header bytes
 * \param[in]*buf pointer to a buffer which holds the data to send
 * \param[in]*buf pointer to a buffer which holds the data to send
 * \param[in] unsigned char len, number of bytes to be written to the bus
 * \param[in] len number of bytes to be written to the bus
 *
 *
 * \return returns non-zero if successful, else 0 */
 * \return returns non-zero if successful, else 0 */
unsigned char
unsigned char
spi_write (unsigned char header_hi, unsigned char header_lo,
spi_write (unsigned char header_hi, unsigned char header_lo,
           unsigned char enables, unsigned char format,
           unsigned char enables, unsigned char format,

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.