diff --git a/configs/olimex-strp711/nettest/defconfig b/configs/olimex-strp711/nettest/defconfig index 6187d5efe37dd7b9292943d6012fa040ab45bedf..9088ec8f763ddab414928d3982b6775dbc057316 100755 --- a/configs/olimex-strp711/nettest/defconfig +++ b/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/configs/olimex-strp711/src/Makefile b/configs/olimex-strp711/src/Makefile index 6d61f5a0c383a8cba35f8818b8c409c42b1736e4..722d60b7c54c86c03c7b6a02361b88fa8bb7893c 100644 --- a/configs/olimex-strp711/src/Makefile +++ b/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/configs/olimex-strp711/src/up_enc28j60.c b/configs/olimex-strp711/src/up_enc28j60.c new file mode 100755 index 0000000000000000000000000000000000000000..4bccb572fa9a57f506293a3186287320fe7a9a69 --- /dev/null +++ b/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/configs/olimex-strp711/src/up_nsh.c b/configs/olimex-strp711/src/up_nsh.c index 586989579030214282a11ba7c76f48544f4067e5..cff3129dbbbb5c3553f8a7fdd2e8cbaec1a3f8f8 100644 --- a/configs/olimex-strp711/src/up_nsh.c +++ b/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 diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c index 3e3d59112f510ac55a62733a7ef89d36785b7833..f988bace374e14d01d94634c7f2b8660c6479f93 100755 --- a/drivers/net/enc28j60.c +++ b/drivers/net/enc28j60.c @@ -72,8 +72,7 @@ /* Configuration ************************************************************/ -/* All SPI settings can be specifed in the configuration. If not, some - * defaults will be provided. +/* ENC28J60 Configuration Settings: * * CONFIG_NET_ENC28J60 - Enabled ENC28J60 support * CONFIG_ENC28J60_OWNBUS - Set if the ENC28J60 is the only active device on @@ -84,7 +83,7 @@ * CONFIG_ENC28J60_NINTERFACES - Specifies the number of physical ENC28J60 * devices that will be supported. * CONFIG_ENC28J60_STATS - Collect network statistics - * CONFOG_ENC28J60_HALFDUPPLEX - Default is full duplex + * CONFIG_ENC28J60_HALFDUPPLEX - Default is full duplex */ /* The ENC28J60 spec says that is supports SPI mode 0,0 only. However, diff --git a/include/nuttx/enc28j60.h b/include/nuttx/enc28j60.h index 52fcb4f8d80e32f7c21180485a89f21527b7015f..efa4ed65246d269d03ecdd3baeded6599f7f4430 100755 --- a/include/nuttx/enc28j60.h +++ b/include/nuttx/enc28j60.h @@ -43,6 +43,24 @@ #include <stdint.h> #include <stdbool.h> +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* ENC28J60 Configuration Settings: + * + * CONFIG_NET_ENC28J60 - Enabled ENC28J60 support + * CONFIG_ENC28J60_OWNBUS - Set if the ENC28J60 is the only active device on + * the SPI bus. No locking or SPI configuration will be performed. All + * transfers will be performed from the ENC2J60 interrupt handler. + * CONFIG_ENC28J60_SPIMODE - Controls the SPI mode + * CONFIG_ENC28J60_FREQUENCY - Define to use a different bus frequency + * CONFIG_ENC28J60_NINTERFACES - Specifies the number of physical ENC28J60 + * devices that will be supported. + * CONFIG_ENC28J60_STATS - Collect network statistics + * CONFIG_ENC28J60_HALFDUPPLEX - Default is full duplex + */ + /**************************************************************************** * Public Types ****************************************************************************/