diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-05-01 19:52:50 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-05-01 19:52:50 +0000 |
commit | 0a6c1fff8a08287f4053eeef680e4f13123f9b80 (patch) | |
tree | 87bbdd2f039df307bedc8da2abf10cd3191a2d18 /nuttx/configs/olimex-strp711 | |
parent | 48bbe68916ccaf0d2fa050e945bf650384ca624f (diff) | |
download | px4-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')
-rwxr-xr-x | nuttx/configs/olimex-strp711/nettest/defconfig | 2 | ||||
-rw-r--r-- | nuttx/configs/olimex-strp711/src/Makefile | 5 | ||||
-rwxr-xr-x | nuttx/configs/olimex-strp711/src/up_enc28j60.c | 128 | ||||
-rw-r--r-- | nuttx/configs/olimex-strp711/src/up_nsh.c | 2 |
4 files changed, 134 insertions, 3 deletions
diff --git a/nuttx/configs/olimex-strp711/nettest/defconfig b/nuttx/configs/olimex-strp711/nettest/defconfig index 6187d5efe..9088ec8f7 100755 --- a/nuttx/configs/olimex-strp711/nettest/defconfig +++ b/nuttx/configs/olimex-strp711/nettest/defconfig @@ -116,7 +116,7 @@ CONFIG_STR71X_UART3=n CONFIG_STR71X_USB=n CONFIG_STR71X_CAN=n CONFIG_STR71X_BSPI0=n -CONFIG_STR71X_BSPI1=n +CONFIG_STR71X_BSPI1=y CONFIG_STR71X_HDLC=n CONFIG_STR71X_XTI=n CONFIG_STR71X_GPIO0=y 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 |