Add up_enc28j60.c
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2643 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
a831ff8459
commit
2244ee5177
@ -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
|
||||
|
@ -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)
|
||||
|
128
configs/olimex-strp711/src/up_enc28j60.c
Executable file
128
configs/olimex-strp711/src/up_enc28j60.c
Executable file
@ -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 */
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
****************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user