Updates/fixes related to ENC28J60, Kconfigs, and fire-stm32v2

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5128 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-09-11 16:50:16 +00:00
parent 340ca85bb8
commit f71398870b
13 changed files with 87 additions and 140 deletions

View File

@ -950,7 +950,7 @@ defconfig -- This is a configuration file similar to the Linux
ENC28J60 Ethernet Driver Configuration Settings:
CONFIG_NET_ENC28J60 - Enabled ENC28J60 support
CONFIG_ENC28J60 - Enabled ENC28J60 support
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

View File

@ -256,14 +256,14 @@
* PIN NAME SIGNAL NOTES
* --- ------ -------------- -------------------------------------------------------------------
*
* 68 PA9 PA9-US1-TX MAX3232, DB9 D8, Requires CONFIG_STM32_USART1_REMAP
* 69 PA10 PA10-US1-RX MAX3232, DB9 D8, Requires CONFIG_STM32_USART1_REMAP
* 68 PA9 PA9-US1-TX MAX3232, DB9 D8, Requires !CONFIG_STM32_USART1_REMAP
* 69 PA10 PA10-US1-RX MAX3232, DB9 D8, Requires !CONFIG_STM32_USART1_REMAP
* 25 PA2 PA2-US2-TX MAX3232, DB9 D7, Requires !CONFIG_STM32_USART2_REMAP
* 26 PA3 PA3-US2-RX MAX3232, DB9 D7, Requires !CONFIG_STM32_USART2_REMAP
*/
#if defined(CONFIG_STM32_USART1) && !defined(CONFIG_STM32_USART1_REMAP)
# errror "USART1 requires CONFIG_STM32_USART1_REMAP=y"
#if defined(CONFIG_STM32_USART1) && defined(CONFIG_STM32_USART1_REMAP)
# errror "USART1 requires CONFIG_STM32_USART1_REMAP=n"
#endif
#if defined(CONFIG_STM32_USART2) && defined(CONFIG_STM32_USART2_REMAP)

View File

@ -131,7 +131,7 @@ CONFIG_STM32_I2C1=y
# CONFIG_STM32_IWDG is not set
CONFIG_STM32_PWR=y
CONFIG_STM32_SDIO=y
# CONFIG_STM32_SPI1 is not set
CONFIG_STM32_SPI1=y
# CONFIG_STM32_SPI2 is not set
# CONFIG_STM32_SPI4 is not set
# CONFIG_STM32_TIM1 is not set
@ -149,12 +149,14 @@ CONFIG_STM32_USART2=y
# CONFIG_STM32_UART5 is not set
CONFIG_STM32_USB=y
# CONFIG_STM32_WWDG is not set
CONFIG_STM32_SPI=y
#
# Alternate Pin Mapping
#
CONFIG_STM32_USART1_REMAP=y
# CONFIG_STM32_USART1_REMAP is not set
# CONFIG_STM32_USART2_REMAP is not set
# CONFIG_STM32_SPI1_REMAP is not set
# CONFIG_STM32_I2C1_REMAP is not set
# CONFIG_STM32_JTAG_DISABLE is not set
CONFIG_STM32_JTAG_FULL_ENABLE=y
@ -163,6 +165,12 @@ CONFIG_STM32_JTAG_FULL_ENABLE=y
# CONFIG_STM32_FORCEPOWER is not set
# CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG is not set
#
# SPI Configuration
#
# CONFIG_STM32_SPI_INTERRUPTS is not set
# CONFIG_STM32_SPI_DMA is not set
#
# SDIO Configuration
#
@ -300,71 +308,27 @@ CONFIG_DEV_NULL=y
# CONFIG_DEV_ZERO is not set
# CONFIG_LOOP is not set
# CONFIG_RAMDISK is not set
#
# CAN Driver Options
#
# CONFIG_CAN is not set
#
# PWM Driver Options
#
# CONFIG_PWM is not set
#
# I2C Driver Options
#
CONFIG_I2C=y
# CONFIG_I2C_SLAVE is not set
CONFIG_I2C_TRANSFER=y
# CONFIG_I2C_WRITEREAD is not set
CONFIG_I2C_POLLED=y
# CONFIG_I2C_TRACE is not set
#
# SPI Driver Options
#
CONFIG_SPI=y
# CONFIG_SPI_OWNBUS is not set
CONFIG_SPI_EXCHANGE=y
CONFIG_SPI_CMDDATA=y
#
# RTC Driver Options
#
# CONFIG_SPI_CMDDATA is not set
CONFIG_RTC=y
# CONFIG_RTC_DATETIME is not set
# CONFIG_RTC_HIRES is not set
# CONFIG_RTC_ALARM is not set
#
# Watchdog Driver Options
#
# CONFIG_WATCHDOG is not set
#
# Analog Driver Options
#
# CONFIG_ANALOG is not set
#
# Block-to-Character Driver Support
#
# CONFIG_BCH is not set
#
# Input device Driver Options
#
# CONFIG_INPUT is not set
#
# LCD Driver Options
#
# CONFIG_LCD is not set
#
# MMCSD Driver Options
#
CONFIG_MMCSD=y
CONFIG_MMCSD_NSLOTS=1
# CONFIG_MMCSD_READONLY is not set
@ -375,42 +339,23 @@ CONFIG_MMCSD_SPI=y
CONFIG_MMCSD_SPICLOCK=20000000
CONFIG_MMCSD_SDIO=y
# CONFIG_SDIO_MUXBUS is not set
#
# I2C Driver Options
#
# CONFIG_MTD is not set
#
# Network Device Driver Options
#
# CONFIG_NETDEVICES is not set
CONFIG_NETDEVICES=y
# CONFIG_NET_DM90x0 is not set
CONFIG_ENC28J60=y
CONFIG_ENC28J60_NINTERFACES=1
CONFIG_ENC28J60_SPIMODE=2
CONFIG_ENC28J60_FREQUENCY=20000000
# CONFIG_ENC28J60_STATS is not set
# CONFIG_ENC28J60_HALFDUPPLEX is not set
# CONFIG_NET_E1000 is not set
# CONFIG_NET_SLIP is not set
#
# Pipe Options
#
# CONFIG_NET_VNET is not set
# CONFIG_PIPES is not set
#
# Power Management Options
#
# CONFIG_PM is not set
# CONFIG_POWER is not set
#
# Sensor Driver Options
#
# CONFIG_SENSORS is not set
#
# Osmocom-bb Sercomm Driver Options
#
# CONFIG_SERCOMM_CONSOLE is not set
#
# Serial Driver Options
#
CONFIG_SERIAL=y
# CONFIG_LOWLEVEL_CONSOLE is not set
# CONFIG_16550_UART is not set
@ -441,10 +386,6 @@ CONFIG_USART2_BAUD=115200
CONFIG_USART2_BITS=8
CONFIG_USART2_PARITY=0
CONFIG_USART2_2STOP=0
#
# USB Device Driver Options
#
CONFIG_USBDEV=y
# CONFIG_USBDEV_COMPOSITE is not set
# CONFIG_USBDEV_ISOCHRONOUS is not set
@ -468,15 +409,7 @@ CONFIG_USBMSC_PRODUCTID=0x5342
CONFIG_USBMSC_PRODUCTSTR="USBdev Storage"
CONFIG_USBMSC_VERSIONNO=0x0399
CONFIG_USBMSC_REMOVABLE=y
#
# USB Host Driver Options
#
# CONFIG_USBHOST is not set
#
# Wireless Device Driver Options
#
# CONFIG_WIRELESS is not set
#
@ -495,7 +428,7 @@ CONFIG_NET=y
# CONFIG_NET_NOINTS is not set
# CONFIG_NET_MULTIBUFFER is not set
# CONFIG_NET_IPv6 is not set
CONFIG_NSOCKET_DESCRIPTORS=0
CONFIG_NSOCKET_DESCRIPTORS=16
CONFIG_NET_NACTIVESOCKETS=16
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_BUFSIZE=562
@ -512,7 +445,7 @@ CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NET_UDP_CONNS=8
CONFIG_NET_BROADCAST=y
CONFIG_NET_ICMP=y
# CONFIG_NET_ICMP_PING is not set
CONFIG_NET_ICMP_PING=y
# CONFIG_NET_PINGADDRCONF is not set
# CONFIG_NET_IGMP is not set
CONFIG_NET_STATISTICS=y
@ -532,6 +465,7 @@ CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
CONFIG_FAT_MAXFNAME=32
# CONFIG_FS_FATTIME is not set
# CONFIG_FAT_DMAMEMORY is not set
# CONFIG_FS_RAMMAP is not set
# CONFIG_NFS is not set
# CONFIG_FS_NXFFS is not set

View File

@ -56,7 +56,7 @@ else
CSRCS += up_userleds.c
endif
ifeq ($(CONFIG_NET_ENC28J60),y)
ifeq ($(CONFIG_ENC28J60),y)
CSRCS += up_enc28j60.c
endif

View File

@ -191,7 +191,7 @@
* 32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
*/
#ifndef CONFIG_NET_ENC28J60
#ifndef CONFIG_ENC28J60
# define GPIO_ENC28J60_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4)
#endif
@ -210,11 +210,11 @@
* 4 PE5 (no name) 10Mbps ENC28J60 Interrupt
*/
#if defined(CONFIG_STM32_FSMC) && defined(CONFIG_NET_ENC28J60)
#if defined(CONFIG_STM32_FSMC) && defined(CONFIG_ENC28J60)
# warning "TFT LCD and ENCJ2860 shared PE1"
#endif
#ifdef CONFIG_NET_ENC28J60
#ifdef CONFIG_ENC28J60
# define GPIO_ENC28J60_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4)
# define GPIO_ENC28J60_RESET (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\

View File

@ -193,7 +193,8 @@ static struct pm_callback_s g_ledscb =
* Name: led_clrbits
*
* Description:
* Clear all LEDs to the bit encoded state
* Clear all LEDs to the bit encoded state. The LEDs are pulled up and,
* hence, active low.
*
****************************************************************************/
@ -201,17 +202,17 @@ static inline void led_clrbits(unsigned int clrbits)
{
if ((clrbits & FIRE_LED1) != 0)
{
stm32_gpiowrite(GPIO_LED1, false);
stm32_gpiowrite(GPIO_LED1, true);
}
if ((clrbits & FIRE_LED2) != 0)
{
stm32_gpiowrite(GPIO_LED2, false);
stm32_gpiowrite(GPIO_LED2, true);
}
if ((clrbits & FIRE_LED3) != 0)
{
stm32_gpiowrite(GPIO_LED3, false);
stm32_gpiowrite(GPIO_LED3, true);
}
}
@ -219,7 +220,8 @@ static inline void led_clrbits(unsigned int clrbits)
* Name: led_setbits
*
* Description:
* Set all LEDs to the bit encoded state
* Set all LEDs to the bit encoded state. The LEDs are pulled up and,
* hence, active low.
*
****************************************************************************/
@ -227,17 +229,17 @@ static inline void led_setbits(unsigned int setbits)
{
if ((setbits & FIRE_LED1) != 0)
{
stm32_gpiowrite(GPIO_LED1, true);
stm32_gpiowrite(GPIO_LED1, false);
}
if ((setbits & FIRE_LED2) != 0)
{
stm32_gpiowrite(GPIO_LED2, true);
stm32_gpiowrite(GPIO_LED2, false);
}
if ((setbits & FIRE_LED3) != 0)
{
stm32_gpiowrite(GPIO_LED3, true);
stm32_gpiowrite(GPIO_LED3, false);
}
}

View File

@ -63,9 +63,9 @@
#include "chip.h"
#include "up_arch.h"
#include "up_internal.h"
#include "fire_internal.h"
#include "fire-internal.h"
#ifdef CONFIG_NET_ENC28J60
#ifdef CONFIG_ENC28J60
/****************************************************************************
* Definitions
@ -110,9 +110,9 @@ struct stm32_lower_s
* Private Function Prototypes
****************************************************************************/
static int up_attach(FAR struct enc_lower_s *lower, xcpt_t handler);
static void up_enable(FAR struct enc_lower_s *lower);
static void up_disable(FAR struct enc_lower_s *lower);
static int up_attach(FAR const struct enc_lower_s *lower, xcpt_t handler);
static void up_enable(FAR const struct enc_lower_s *lower);
static void up_disable(FAR const struct enc_lower_s *lower);
/****************************************************************************
* Private Data
@ -123,13 +123,15 @@ static void up_disable(FAR struct enc_lower_s *lower);
* the ENC28J60 GPIO interrupt.
*/
static const struct enc_lower_s g_enclower =
static struct stm32_lower_s g_enclower =
{
.lower =
{
.attach = up_attach,
.enable = up_enable,
.disable = up_disable
}
},
.handler = NULL,
};
/****************************************************************************
@ -140,25 +142,25 @@ static const struct enc_lower_s g_enclower =
* Name: struct enc_lower_s methods
****************************************************************************/
static int up_attach(FAR struct enc_lower_s *lower, xcpt_t handler)
static int up_attach(FAR const struct enc_lower_s *lower, xcpt_t handler)
{
FAR struct stm32_lower_s *priv = (FAR struct stm32_lower_s *)lower;
/* Just save the handler for use when the interrupt is enabled */
priv-handler = handler;
priv->handler = handler;
return OK;
}
static void up_enable(FAR struct enc_lower_s *lower)
static void up_enable(FAR const struct enc_lower_s *lower)
{
FAR struct stm32_lower_s *priv = (FAR struct stm32_lower_s *)lower;
DEBUGASSERT(priv->handler);
(void)stm32_gpiosetevent(GPIO_ENC28J60_INTR, true, true, true, priv-handler);
(void)stm32_gpiosetevent(GPIO_ENC28J60_INTR, true, true, true, priv->handler);
}
static void up_disable(FAR struct enc_lower_s *lower)
static void up_disable(FAR const struct enc_lower_s *lower)
{
(void)stm32_gpiosetevent(GPIO_ENC28J60_INTR, true, true, true, NULL);
}
@ -174,7 +176,6 @@ static void up_disable(FAR struct enc_lower_s *lower)
void up_netinitialize(void)
{
FAR struct spi_dev_s *spi;
uint16_t reg16;
int ret;
/* Assumptions:
@ -195,7 +196,7 @@ void up_netinitialize(void)
/* Bind the SPI port to the ENC28J60 driver */
ret = enc_initialize(spi, ENC28J60_DEVNO, &g_enclower);
ret = enc_initialize(spi, &g_enclower.lower, ENC28J60_DEVNO);
if (ret < 0)
{
nlldbg("Failed to bind SPI port %d ENC28J60 device %d: %d\n",
@ -207,4 +208,4 @@ void up_netinitialize(void)
ENC28J60_SPI_PORTNO, ENC28J60_DEVNO);
}
#endif /* CONFIG_NET_ENC28J60 */
#endif /* CONFIG_ENC28J60 */

View File

@ -111,7 +111,7 @@ void weak_function stm32_spiinitialize(void)
/* Configure ENC28J60 SPI1 CS (also RESET and interrupt pins) */
#ifdef CONFIG_NET_ENC28J60
#ifdef CONFIG_ENC28J60
stm32_configgpio(GPIO_ENC28J60_CS);
stm32_configgpio(GPIO_ENC28J60_RESET);
stm32_configgpio(GPIO_ENC28J60_INTR);
@ -171,7 +171,7 @@ void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool sele
}
else
#endif
#ifdef CONFIG_NET_ENC28J60
#ifdef CONFIG_ENC28J60
if (devid == SPIDEV_ETHERNET)
{
/* Set the GPIO low to select and high to de-select */

View File

@ -105,18 +105,28 @@ void stm32_ledinit(void)
/****************************************************************************
* Name: stm32_setled
*
* Description:
* Set one LED to the 'ledon' state. The LEDs are pulled up and, hence,
* active low.
*
****************************************************************************/
void stm32_setled(int led, bool ledon)
{
if ((unsigned)led < BOARD_NLEDS)
{
stm32_gpiowrite(g_ledcfg[led], ledon);
stm32_gpiowrite(g_ledcfg[led], !ledon);
}
}
/****************************************************************************
* Name: stm32_setleds
*
* Description:
* Set each LED to the bit encoded state. The LEDs are pulled up and,
* hence, active low.
*
****************************************************************************/
void stm32_setleds(uint8_t ledset)

View File

@ -2,7 +2,7 @@
# configs/olimes-strp711/nettest/defconfig
#
# Copyright (C) 2010 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@ -235,7 +235,7 @@ CONFIG_FS_ROMFS=n
#
# ENC28J60 configuration
#
CONFIG_NET_ENC28J60=y
CONFIG_ENC28J60=y
#CONFIG_ENC28J60_SPIMODE
CONFIG_ENC28J60_FREQUENCY=20000000
CONFIG_ENC28J60_NINTERFACES=1

View File

@ -1,8 +1,8 @@
############################################################################
# configs/olimex-strp711/src/Makefile
#
# Copyright (C) 2007-2008, 2010 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
# Copyright (C) 2007-2008, 2010, 2012 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@ -51,7 +51,7 @@ CSRCS = up_spi.c up_leds.c up_buttons.c
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += up_nsh.c
endif
ifeq ($(CONFIG_NET_ENC28J60),y)
ifeq ($(CONFIG_ENC28J60),y)
CSRCS += up_enc28j60.c
endif
COBJS = $(CSRCS:.c=$(OBJEXT))

View File

@ -95,7 +95,7 @@
#include "up_internal.h"
#include "str71x_internal.h"
#ifdef CONFIG_NET_ENC28J60
#ifdef CONFIG_ENC28J60
/****************************************************************************
* Definitions
@ -182,17 +182,17 @@ static const struct enc_lower_s g_enclower =
* Name: struct enc_lower_s methods
****************************************************************************/
static int up_attach(FAR struct enc_lower_s *lower, xcpt_t handler)
static int up_attach(FAR const struct enc_lower_s *lower, xcpt_t handler)
{
return irq_attach(ENC28J60_IRQ, handler)
}
static void up_enable(FAR struct enc_lower_s *lower)
static void up_enable(FAR const struct enc_lower_s *lower)
{
up_enable_irq(ENC28J60_IRQ);
}
static void up_disable(FAR struct enc_lower_s *lower)
static void up_disable(FAR const struct enc_lower_s *lower)
{
up_disable_irq(ENC28J60_IRQ);
}
@ -237,7 +237,7 @@ void up_netinitialize(void)
/* Bind the SPI port to the ENC28J60 driver */
ret = enc_initialize(spi, ENC28J60_DEVNO, &g_enclower);
ret = enc_initialize(spi, &g_enclower, ENC28J60_DEVNO);
if (ret < 0)
{
nlldbg("Failed to bind SPI port %d ENC28J60 device %d: %d\n",
@ -248,4 +248,4 @@ void up_netinitialize(void)
nllvdbg("Bound SPI port %d to ENC28J60 device %d\n",
ENC28J60_SPI_PORTNO, ENC28J60_DEVNO);
}
#endif /* CONFIG_NET_ENC28J60 */
#endif /* CONFIG_ENC28J60 */

View File

@ -1,8 +1,8 @@
/****************************************************************************
* config/olimex-strp711/src/up_spi.c
*
* Copyright (C) 2008-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* Copyright (C) 2008-2010,2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -155,7 +155,7 @@
* P0.4/S1.MISO P0.4 output 6 5 NET RST
*/
#ifdef CONFIG_NET_ENC28J60
#ifdef CONFIG_ENC28J60
/* UART3, I2C cannot be used with SPI0. The GPIOs selected for the ENC28J60
* interrupt conflict with BSPI1
@ -981,7 +981,7 @@ FAR struct spi_dev_s *up_spiinitialize(int port)
* reset (also active low)
*/
#ifdef CONFIG_NET_ENC28J60
#ifdef CONFIG_ENC28J60
reg16 = getreg16(STR71X_GPIO0_PD);
reg16 |= (ENC_GPIO0_CS | ENC_GPIO0_NETRST);
putreg16(reg16, STR71X_GPIO0_PD);