summaryrefslogtreecommitdiff
path: root/nuttx/arch/z80/src
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-05-15 01:15:52 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-05-15 01:15:52 +0000
commitabcc509bf98d1a87b05ee17dffa700ffaacaf30b (patch)
tree645b3e63abbf7dc0d84436c404fcce1050c8c047 /nuttx/arch/z80/src
parentc6c6c52fdb8e2fe474563b71437d80f4d3c67e59 (diff)
downloadpx4-nuttx-abcc509bf98d1a87b05ee17dffa700ffaacaf30b.tar.gz
px4-nuttx-abcc509bf98d1a87b05ee17dffa700ffaacaf30b.tar.bz2
px4-nuttx-abcc509bf98d1a87b05ee17dffa700ffaacaf30b.zip
In progress changes for OLED display work
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2669 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/z80/src')
-rwxr-xr-xnuttx/arch/z80/src/ez80/ez80_spi.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/nuttx/arch/z80/src/ez80/ez80_spi.c b/nuttx/arch/z80/src/ez80/ez80_spi.c
index 6c5f7f2aa..22cfd789c 100755
--- a/nuttx/arch/z80/src/ez80/ez80_spi.c
+++ b/nuttx/arch/z80/src/ez80/ez80_spi.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/z80/src/ez80/ez80_spi.c
*
- * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -67,6 +67,9 @@
* Private Function Prototypes
****************************************************************************/
+#ifndef CONFIG_SPI_OWNBUS
+static int spi_lock(FAR struct spi_dev_s *dev, bool lock);
+#endif
static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev,
uint32_t frequency);
static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode);
@@ -82,7 +85,9 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR uint8_t *buffer,
static const struct spi_ops_s g_spiops =
{
- 0, /* lock() method not yet implemented */
+#ifndef CONFIG_SPI_OWNBUS
+ spi_lock,
+#endif
ez80_spiselect, /* Provided externally by board logic */
spi_setfrequency,
spi_setmode,
@@ -110,6 +115,36 @@ static struct spi_dev_s g_spidev = { &g_spiops };
****************************************************************************/
/****************************************************************************
+ * Name: spi_lock
+ *
+ * Description:
+ * On SPI busses where there are multiple devices, it will be necessary to
+ * lock SPI to have exclusive access to the busses for a sequence of
+ * transfers. The bus should be locked before the chip is selected. After
+ * locking the SPI bus, the caller should then also call the setfrequency,
+ * setbits, and setmode methods to make sure that the SPI is properly
+ * configured for the device. If the SPI buss is being shared, then it
+ * may have been left in an incompatible state.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * lock - true: Lock spi bus, false: unlock SPI bus
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifndef CONFIG_SPI_OWNBUS
+static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
+{
+ /* Not implemented */
+
+ return -ENOSYS;
+}
+#endif
+
+/****************************************************************************
* Name: spi_setfrequency
*
* Description: