Add enum argument to SPI status method

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1667 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2009-03-29 18:53:20 +00:00
parent 04f44cd858
commit f7f7c531e0
4 changed files with 37 additions and 25 deletions

View File

@ -4,8 +4,6 @@
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* This logic emulates the Prolific PL2303 serial/USB converter
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -90,7 +88,7 @@
static void spi_select(FAR struct spi_dev_s *dev, enum spidev_e devid, boolean selected);
static uint32 spi_setfrequency(FAR struct spi_dev_s *dev, uint32 frequency);
static ubyte spi_status(FAR struct spi_dev_s *dev);
static ubyte spi_status(FAR struct spi_dev_s *dev, enum spidev_e devid);
static ubyte spi_sndbyte(FAR struct spi_dev_s *dev, ubyte ch);
static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const ubyte *buffer, size_t buflen);
static void spi_recvblock(FAR struct spi_dev_s *dev, FAR ubyte *buffer, size_t buflen);
@ -183,7 +181,8 @@ static void spi_select(FAR struct spi_dev_s *dev, enum spidev_e devid, boolean s
* Set the SPI frequency.
*
* Input Parameters:
* frequency: The SPI frequency requested
* dev - Device-specific state data
* frequency - The SPI frequency requested
*
* Returned Value:
* Returns the actual frequency selected
@ -215,14 +214,15 @@ static uint32 spi_setfrequency(FAR struct spi_dev_s *dev, uint32 frequency)
* Get SPI/MMC status
*
* Input Parameters:
* None
* dev - Device-specific state data
* devid - Identifies the device to report status on
*
* Returned Value:
* Returns a bitset of status values (see SPI_STATUS_* defines
*
****************************************************************************/
static ubyte spi_status(FAR struct spi_dev_s *dev)
static ubyte spi_status(FAR struct spi_dev_s *dev, enum spidev_e devid)
{
/* I don't think there is anyway to determine these things on the mcu123.com
* board.
@ -238,7 +238,8 @@ static ubyte spi_status(FAR struct spi_dev_s *dev)
* Send one byte on SPI
*
* Input Parameters:
* ch - the byte to send
* dev - Device-specific state data
* ch - The byte to send
*
* Returned Value:
* response
@ -271,6 +272,7 @@ static ubyte spi_sndbyte(FAR struct spi_dev_s *dev, ubyte ch)
* Send a block of data on SPI
*
* Input Parameters:
* dev - Device-specific state data
* buffer - A pointer to the buffer of data to be sent
* buflen - the length of data to send from the buffer
*
@ -335,6 +337,7 @@ static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const ubyte *buffer, siz
* Revice a block of data from SPI
*
* Input Parameters:
* dev - Device-specific state data
* buffer - A pointer to the buffer in which to recieve data
* buflen - the length of data that can be received in the buffer
*

View File

@ -1,11 +1,9 @@
/****************************************************************************
* config/olimex-strp711/src/up_spi.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* This logic emulates the Prolific PL2303 serial/USB converter
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -267,7 +265,7 @@ static inline void spi_putreg(FAR struct str71x_spidev_s *priv, ubyte offset,
static void spi_select(FAR struct spi_dev_s *dev, enum spidev_e devid, boolean selected);
static uint32 spi_setfrequency(FAR struct spi_dev_s *dev, uint32 frequency);
static ubyte spi_status(FAR struct spi_dev_s *dev);
static ubyte spi_status(FAR struct spi_dev_s *dev, enum spidev_e devid);
static ubyte spi_sndbyte(FAR struct spi_dev_s *dev, ubyte ch);
static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const ubyte *buffer, size_t buflen);
static void spi_recvblock(FAR struct spi_dev_s *dev, FAR ubyte *buffer, size_t buflen);
@ -431,7 +429,8 @@ static void spi_select(FAR struct spi_dev_s *dev, enum spidev_e devid, boolean s
* Set the SPI frequency.
*
* Input Parameters:
* frequency: The SPI frequency requested
* dev - Device-specific state data
* frequency - The SPI frequency requested
*
* Returned Value:
* Returns the actual frequency selected
@ -492,14 +491,15 @@ static uint32 spi_setfrequency(FAR struct spi_dev_s *dev, uint32 frequency)
* Get SPI/MMC status
*
* Input Parameters:
* None
* dev - Device-specific state data
* devid - Identifies the device to report status on
*
* Returned Value:
* Returns a bitset of status values (see SPI_STATUS_* defines
*
****************************************************************************/
static ubyte spi_status(FAR struct spi_dev_s *dev)
static ubyte spi_status(FAR struct spi_dev_s *dev, enum spidev_e devid)
{
ubyte ret = 0;
uint16 reg16 = getreg16(STR71X_GPIO1_PD);
@ -524,7 +524,8 @@ static ubyte spi_status(FAR struct spi_dev_s *dev)
* Send one byte on SPI
*
* Input Parameters:
* ch - the byte to send
* dev - Device-specific state data
* ch - The byte to send
*
* Returned Value:
* response
@ -567,6 +568,7 @@ static ubyte spi_sndbyte(FAR struct spi_dev_s *dev, ubyte ch)
* Send a block of data on SPI
*
* Input Parameters:
* dev - Device-specific state data
* buffer - A pointer to the buffer of data to be sent
* buflen - the length of data to send from the buffer
*
@ -634,6 +636,7 @@ static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const ubyte *buffer, siz
* Revice a block of data from SPI
*
* Input Parameters:
* dev - Device-specific state data
* buffer - A pointer to the buffer in which to recieve data
* buflen - the length of data that can be received in the buffer
*

View File

@ -576,7 +576,7 @@ static void mmcsd_checkwrprotect(FAR struct mmcsd_slot_s *slot, ubyte *csd)
* reports temporary write protect.
*/
if ((SPI_STATUS(spi) & SPI_STATUS_WRPROTECTED) != 0 ||
if ((SPI_STATUS(spi, SPIDEV_MMCSD) & SPI_STATUS_WRPROTECTED) != 0 ||
MMCSD_CSD_PERMWRITEPROTECT(csd) ||
MMCSD_CSD_TMPWRITEPROTECT(csd))
{
@ -1116,7 +1116,7 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot)
* interface
*/
if ((SPI_STATUS(spi) & SPI_STATUS_PRESENT) == 0)
if ((SPI_STATUS(spi, SPIDEV_MMCSD) & SPI_STATUS_PRESENT) == 0)
{
fdbg("No card present\n");
slot->state |= MMCSD_SLOTSTATUS_NODISK;
@ -1296,7 +1296,7 @@ static void mmcsd_mediachanged(void *arg)
/* Check if media was removed or inserted */
slot->state &= ~(MMCSD_SLOTSTATUS_NODISK|MMCSD_SLOTSTATUS_NOTREADY|MMCSD_SLOTSTATUS_MEDIACHGD);
if ((SPI_STATUS(spi) & SPI_STATUS_PRESENT) == 0)
if ((SPI_STATUS(spi, SPIDEV_MMCSD) & SPI_STATUS_PRESENT) == 0)
{
/* Media is not present */

View File

@ -77,7 +77,8 @@
* Set the SPI frequency. Required.
*
* Input Parameters:
* frequency: The SPI frequency requested
* dev - Device-specific state data
* frequency - The SPI frequency requested
*
* Returned Value:
* Returns the actual frequency selected
@ -93,15 +94,16 @@
* Get SPI/MMC status. Optional.
*
* Input Parameters:
* None
* dev - Device-specific state data
* devid - Identifies the device to report status on
*
* Returned Value:
* Returns a bitset of status values (see SPI_STATUS_* defines
*
****************************************************************************/
#define SPI_STATUS(d) \
((d)->ops->status ? (d)->ops->status(d) : SPI_STATUS_PRESENT)
#define SPI_STATUS(d,id) \
((d)->ops->status ? (d)->ops->status(d, id) : SPI_STATUS_PRESENT)
/* SPI status bits -- Some dedicated for SPI MMC/SD support and may have no
* relationship to SPI other than needed by the SPI MMC/SD interface
@ -117,7 +119,8 @@
* Send one byte on SPI. Required.
*
* Input Parameters:
* ch - the byte to send
* dev - Device-specific state data
* ch - The byte to send
*
* Returned Value:
* None
@ -133,6 +136,7 @@
* Send a block of data on SPI. Required.
*
* Input Parameters:
* dev - Device-specific state data
* buffer - A pointer to the buffer of data to be sent
* buflen - the length of data to send from the buffer
*
@ -150,6 +154,7 @@
* Revice a block of data from SPI. Required.
*
* Input Parameters:
* dev - Device-specific state data
* buffer - A pointer to the buffer in which to recieve data
* buflen - the length of data that can be received in the buffer
*
@ -169,8 +174,9 @@
* Optional
*
* Input Parameters:
* dev - Device-specific state data
* callback - The funtion to call on the media change
* arg - A caller provided value to return with the callback
* arg - A caller provided value to return with the callback
*
* Returned Value:
* 0 on success; negated errno on failure.
@ -206,7 +212,7 @@ struct spi_ops_s
{
void (*select)(FAR struct spi_dev_s *dev, enum spidev_e devid, boolean selected);
uint32 (*setfrequency)(FAR struct spi_dev_s *dev, uint32 frequency);
ubyte (*status)(FAR struct spi_dev_s *dev);
ubyte (*status)(FAR struct spi_dev_s *dev, enum spidev_e devid);
ubyte (*sndbyte)(FAR struct spi_dev_s *dev, ubyte ch);
void (*sndblock)(FAR struct spi_dev_s *dev, FAR const ubyte *buffer, size_t buflen);
void (*recvblock)(FAR struct spi_dev_s *dev, FAR ubyte *buffer, size_t buflen);