diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-03-29 21:14:34 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-03-29 21:14:34 +0000 |
commit | 4e6d82c8bfe16012a6667492d4cc6df016cd18b6 (patch) | |
tree | e7142ad67adc1f905fd558b641b9fd3878cfe6db /nuttx/include | |
parent | b33699953a9b9e817fb3719578639c19dcfc5c3a (diff) | |
download | px4-nuttx-4e6d82c8bfe16012a6667492d4cc6df016cd18b6.tar.gz px4-nuttx-4e6d82c8bfe16012a6667492d4cc6df016cd18b6.tar.bz2 px4-nuttx-4e6d82c8bfe16012a6667492d4cc6df016cd18b6.zip |
Add SPI method to set SCLK mode
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1669 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/include')
-rw-r--r-- | nuttx/include/nuttx/spi.h | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/nuttx/include/nuttx/spi.h b/nuttx/include/nuttx/spi.h index e07ca6123..57da34304 100644 --- a/nuttx/include/nuttx/spi.h +++ b/nuttx/include/nuttx/spi.h @@ -1,7 +1,7 @@ /**************************************************************************** - * drivers/usbdev/spi.h + * include/nuttx/spi.h * - * Copyright(C) 2008 Gregory Nutt. All rights reserved. + * Copyright(C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -88,6 +88,23 @@ #define SPI_SETFREQUENCY(d,f) ((d)->ops->setfrequency(d,f)) /**************************************************************************** + * Name: SPI_SETMODE + * + * Description: + * Set the SPI mode. Optional. See enum spi_mode_e for mode definitions + * + * Input Parameters: + * dev - Device-specific state data + * mode - The SPI mode requested + * + * Returned Value: + * none + * + ****************************************************************************/ + +#define SPI_SETMODE(d,m) ((d)->ops->mode(d,m)) + +/**************************************************************************** * Name: SPI_STATUS * * Description: @@ -198,21 +215,32 @@ typedef void (*mediachange_t)(void *arg); * which is selected or de-seleted. */ -enum spidev_e +enum spi_dev_e { SPIDEV_NONE = 0, /* Not a valid value */ SPIDEV_MMCSD, /* Select SPI MMC/SD device */ SPIDEV_ETHERNET /* Select SPI ethernet device */ }; +/* Certain SPI devices may required differnt clocking modes */ + +enum spi_mode_e +{ + SPIDEV_MODE0 = 0, /* CPOL=0 CHPHA=0 */ + SPIDEV_MODE1, /* CPOL=0 CHPHA=1 */ + SPIDEV_MODE2, /* CPOL=1 CHPHA=0 */ + SPIDEV_MODE3 /* CPOL=1 CHPHA=1 */ +}; + /* The SPI vtable */ struct spi_dev_s; struct spi_ops_s { - void (*select)(FAR struct spi_dev_s *dev, enum spidev_e devid, boolean selected); + void (*select)(FAR struct spi_dev_s *dev, enum spi_dev_e devid, boolean selected); uint32 (*setfrequency)(FAR struct spi_dev_s *dev, uint32 frequency); - ubyte (*status)(FAR struct spi_dev_s *dev, enum spidev_e devid); + void (*setmode)(FAR struct spi_dev_s *dev, enum spi_mode_e mode); + ubyte (*status)(FAR struct spi_dev_s *dev, enum spi_dev_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); |