summaryrefslogtreecommitdiff
path: root/nuttx/configs/olimex-strp711/src
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-05-01 19:52:50 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-05-01 19:52:50 +0000
commit0a6c1fff8a08287f4053eeef680e4f13123f9b80 (patch)
tree87bbdd2f039df307bedc8da2abf10cd3191a2d18 /nuttx/configs/olimex-strp711/src
parent48bbe68916ccaf0d2fa050e945bf650384ca624f (diff)
downloadpx4-nuttx-0a6c1fff8a08287f4053eeef680e4f13123f9b80.tar.gz
px4-nuttx-0a6c1fff8a08287f4053eeef680e4f13123f9b80.tar.bz2
px4-nuttx-0a6c1fff8a08287f4053eeef680e4f13123f9b80.zip
Add up_enc28j60.c
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2643 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/configs/olimex-strp711/src')
-rw-r--r--nuttx/configs/olimex-strp711/src/Makefile5
-rwxr-xr-xnuttx/configs/olimex-strp711/src/up_enc28j60.c128
-rw-r--r--nuttx/configs/olimex-strp711/src/up_nsh.c2
3 files changed, 133 insertions, 2 deletions
diff --git a/nuttx/configs/olimex-strp711/src/Makefile b/nuttx/configs/olimex-strp711/src/Makefile
index 6d61f5a0c..722d60b7c 100644
--- a/nuttx/configs/olimex-strp711/src/Makefile
+++ b/nuttx/configs/olimex-strp711/src/Makefile
@@ -1,7 +1,7 @@
############################################################################
# configs/olimex-strp711/src/Makefile
#
-# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+# Copyright (C) 2007-2008, 2010 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# Redistribution and use in source and binary forms, with or without
@@ -51,6 +51,9 @@ CSRCS = up_spi.c up_leds.c up_buttons.c
ifeq ($(CONFIG_EXAMPLES_NSH_ARCHINIT),y)
CSRCS += up_nsh.c
endif
+ifeq ($(CONFIG_NET_ENC28J60),y)
+CSRCS += up_enc28j60.c
+endif
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
diff --git a/nuttx/configs/olimex-strp711/src/up_enc28j60.c b/nuttx/configs/olimex-strp711/src/up_enc28j60.c
new file mode 100755
index 000000000..4bccb572f
--- /dev/null
+++ b/nuttx/configs/olimex-strp711/src/up_enc28j60.c
@@ -0,0 +1,128 @@
+/****************************************************************************
+ * configs/olimex-strp711/src/up_enc28j60.c
+ *
+ * Copyright (C) 2010 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdio.h>
+#include <debug.h>
+
+#include <nuttx/spi.h>
+#include <nuttx/enc28j60.h>
+
+#include <arch/board/board.h>
+
+#include "chip.h"
+#include "up_arch.h"
+#include "up_internal.h"
+
+#ifdef CONFIG_NET_ENC28J60
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/* Configuration ************************************************************/
+
+#ifndef CONFIG_STR71X_BSPI1
+# error "Need CONFIG_STR71X_BSP1 in the configuration"
+#endif
+
+/* SPI Assumptions **********************************************************/
+
+#define ENC28J60_SPI_PORTNO 1 /* On SPI1 */
+#define ENC28J60_DEVNO 0 /* Only one ENC28J60 */
+#define ENC28J60_IRQ 0 /* NEEDED!!!!!!!!!!!!!!!! */
+
+/* Debug ********************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_netinitialize
+ ****************************************************************************/
+
+void up_netinitialize(void)
+{
+ FAR struct spi_dev_s *spi;
+ int ret;
+
+ /* Get the SPI port */
+
+ nvdbg("up_netinitialize: Initializing SPI port %d\n", ENC28J60_SPI_PORTNO);
+
+ spi = up_spiinitialize(ENC28J60_SPI_PORTNO);
+ if (!spi)
+ {
+ ndbg("up_netinitialize: Failed to initialize SPI port %d\n",
+ ENC28J60_SPI_PORTNO);
+ return;
+ }
+
+ nvdbg("up_netinitialize: Successfully initialized SPI port %d\n",
+ ENC28J60_SPI_PORTNO);
+
+ /* Bind the SPI port to the ENC28J60 driver */
+
+ nvdbg("up_netinitialize: Binding SPI port %d to ENC28J60 device %d\n",
+ ENC28J60_SPI_PORTNO, ENC28J60_DEVNO);
+
+#warning "Need to implement IRQ interrupt before we can use this"
+ ret = enc_initialize(spi, ENC28J60_DEVNO, ENC28J60_IRQ);
+ if (ret < 0)
+ {
+ ndbg("up_netinitialize: Failed to bind SPI port %d ENC28J60 device %d: %d\n",
+ ENC28J60_SPI_PORTNO, ENC28J60_DEVNO, ret);
+ return;
+ }
+
+ nvdbg("up_netinitialize: Successfuly bound SPI port %d ENC28J60 device %d\n",
+ ENC28J60_SPI_PORTNO, ENC28J60_DEVNO);
+}
+#endif /* CONFIG_NET_ENC28J60 */
diff --git a/nuttx/configs/olimex-strp711/src/up_nsh.c b/nuttx/configs/olimex-strp711/src/up_nsh.c
index 586989579..cff3129db 100644
--- a/nuttx/configs/olimex-strp711/src/up_nsh.c
+++ b/nuttx/configs/olimex-strp711/src/up_nsh.c
@@ -2,7 +2,7 @@
* config/olimex-strp711/src/up_nsh.c
* arch/arm/src/board/up_nsh.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