More logic for the MX3 Wildfire board
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5123 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
6d900ffa25
commit
941e056e99
@ -28,10 +28,10 @@ PIN NAME SIGNAL NOTES
|
||||
1 PE2 PE2-C-RCLK Camera (P9)
|
||||
2 PE3 PE3-USB-M USB2.0
|
||||
3 PE4 PE4-BEEP LS1 Bell
|
||||
4 PE5
|
||||
4 PE5 (no name) 10Mbps ENC28J60 Interrupt
|
||||
5 PE6
|
||||
6 VBAT BT1 Battery (BT1)
|
||||
7 PC13 PD13_LCD_LIGHT 2.4" TFT + Touchscreen
|
||||
7 PC13 Header 7X2
|
||||
8 PC14 PC14/OSC32-IN Y2 32.768KHz
|
||||
9 PC15 PC15/OSC32-OUT Y2 32.768KHz
|
||||
10 VSS_5 DGND
|
||||
@ -449,10 +449,10 @@ The LEDs are used to encode OS-related events as follows:
|
||||
#define LED_IRQSENABLED 2 /* OFF ON OFF */
|
||||
#define LED_STACKCREATED 3 /* OFF OFF OFF */
|
||||
|
||||
#define LED_INIRQ 4 /* NC NC ON (momentary) */
|
||||
#define LED_SIGNAL 5 /* NC NC ON (momentary) */
|
||||
#define LED_ASSERTION 6 /* NC NC ON (momentary) */
|
||||
#define LED_PANIC 7 /* NC NC ON (2Hz flashing) */
|
||||
#define LED_INIRQ 4 /* NC NC ON (momentary) */
|
||||
#define LED_SIGNAL 5 /* NC NC ON (momentary) */
|
||||
#define LED_ASSERTION 6 /* NC NC ON (momentary) */
|
||||
#define LED_PANIC 7 /* NC NC ON (2Hz flashing) */
|
||||
#undef LED_IDLE /* Sleep mode indication not supported */
|
||||
|
||||
RTC
|
||||
|
@ -149,17 +149,17 @@
|
||||
* used by the NuttX port unless CONFIG_ARCH_LEDS is defined. In that case, the
|
||||
* usage by the board port is defined in include/board.h and src/up_autoleds.c.
|
||||
* The LEDs are used to encode OS-related events as follows:
|
||||
*.
|
||||
*/
|
||||
/* LED1 LED2 LED3 */
|
||||
#define LED_STARTED 0 /* OFF OFF OFF */
|
||||
#define LED_HEAPALLOCATE 1 /* ON OFF OFF */
|
||||
#define LED_IRQSENABLED 2 /* OFF ON OFF */
|
||||
#define LED_STACKCREATED 3 /* OFF OFF OFF */
|
||||
|
||||
#define LED_INIRQ 4 /* NC NC ON (momentary) */
|
||||
#define LED_SIGNAL 5 /* NC NC ON (momentary) */
|
||||
#define LED_ASSERTION 6 /* NC NC ON (momentary) */
|
||||
#define LED_PANIC 7 /* NC NC ON (2Hz flashing) */
|
||||
#define LED_INIRQ 4 /* NC NC ON (momentary) */
|
||||
#define LED_SIGNAL 4 /* NC NC ON (momentary) */
|
||||
#define LED_ASSERTION 4 /* NC NC ON (momentary) */
|
||||
#define LED_PANIC 4 /* NC NC ON (2Hz flashing) */
|
||||
#undef LED_IDLE /* Sleep mode indication not supported */
|
||||
|
||||
/* The M3 Wildfire supports several two user buttons: KEY1 and KEY2 */
|
||||
@ -194,7 +194,6 @@
|
||||
* 32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 92 PB6 PB6-I2C1-SCL 2.4" TFT + Touchscreen, AT24C02
|
||||
* 93 PB7 PB7-I2C1-SDA 2.4" TFT + Touchscreen, AT24C02
|
||||
* 7 PC13 PD13_LCD_LIGHT 2.4" TFT + Touchscreen
|
||||
* 81 PD0 PD0-FSMC_D2 2.4" TFT + Touchscreen
|
||||
* 82 PD1 PD1-FSMC_D3 2.4" TFT + Touchscreen
|
||||
* 85 PD4 PD4-FSMC_NOE 2.4" TFT + Touchscreen
|
||||
@ -207,7 +206,7 @@
|
||||
* 60 PD13 PD13-LCD/LIGHT 2.4" TFT + Touchscreen
|
||||
* 61 PD14 PD14-FSMC_D0 2.4" TFT + Touchscreen
|
||||
* 62 PD15 PD15-FSMC_D1 2.4" TFT + Touchscreen
|
||||
* 98 PE1 PE1-FSMC_NBL1 2.4" TFT + Touchscreen
|
||||
* 98 PE1 PE1-FSMC_NBL1 2.4" TFT + Touchscreen, 10Mbit EN28J60 Reset
|
||||
* 38 PE7 PE7-FSMC_D4 2.4" TFT + Touchscreen
|
||||
* 39 PE8 PE8-FSMC_D5 2.4" TFT + Touchscreen
|
||||
* 40 PE9 PE9-FSMC_D6 2.4" TFT + Touchscreen
|
||||
@ -271,6 +270,22 @@
|
||||
# errror "USART2 requires CONFIG_STM32_USART2_REMAP=n"
|
||||
#endif
|
||||
|
||||
/* 2MBit SPI FLASH
|
||||
*
|
||||
* --- ------ -------------- -------------------------------------------------------------------
|
||||
* PIN NAME SIGNAL NOTES
|
||||
* --- ------ -------------- -------------------------------------------------------------------
|
||||
*
|
||||
* 29 PA4 PA4-SPI1-NSS 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 30 PA5 PA5-SPI1-SCK 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 31 PA6 PA6-SPI1-MISO 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_STM32_SPI1) && defined(CONFIG_STM32_SPI1_REMAP)
|
||||
# error "SPI1 requires CONFIG_STM32_SPI1_REMAP=n"
|
||||
#endif
|
||||
|
||||
/* ENC28J60
|
||||
*
|
||||
* --- ------ -------------- -------------------------------------------------------------------
|
||||
@ -278,6 +293,11 @@
|
||||
* --- ------ -------------- -------------------------------------------------------------------
|
||||
*
|
||||
* 29 PA4 PA4-SPI1-NSS 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 30 PA5 PA5-SPI1-SCK 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 31 PA6 PA6-SPI1-MISO 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 98 PE1 PE1-FSMC_NBL1 2.4" TFT + Touchscreen, 10Mbit EN28J60 Reset
|
||||
* 4 PE5 (no name) 10Mbps ENC28J60 Interrupt
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_STM32_SPI1) && defined(CONFIG_STM32_SPI1_REMAP)
|
||||
|
127
configs/fire-stm32v2/src/Makefile
Normal file
127
configs/fire-stm32v2/src/Makefile
Normal file
@ -0,0 +1,127 @@
|
||||
############################################################################
|
||||
# configs/fire-stm32v2/src/Makefile
|
||||
#
|
||||
# Copyright (C) 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
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/Make.defs
|
||||
|
||||
CFLAGS += -I$(TOPDIR)/sched
|
||||
|
||||
ASRCS =
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
|
||||
CSRCS = up_boot.c up_spi.c up_usbdev.c
|
||||
|
||||
ifeq ($(CONFIG_STM32_FSMC),y)
|
||||
CSRCS += up_lcd.c up_selectlcd.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_HAVE_CXX),y)
|
||||
CSRCS += up_cxxinitialize.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_LEDS),y)
|
||||
CSRCS += up_autoleds.c
|
||||
else
|
||||
CSRCS += up_userleds.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NET_ENC28J60),y)
|
||||
CSRCS += up_enc28j60.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_BUTTONS),y)
|
||||
CSRCS += up_buttons.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NSH_ARCHINIT),y)
|
||||
CSRCS += up_nsh.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USBMSC),y)
|
||||
CSRCS += up_usbmsc.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USBDEV_COMPOSITE),y)
|
||||
CSRCS += up_composite.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CAN),y)
|
||||
CSRCS += up_can.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WATCHDOG),y)
|
||||
CSRCS += up_watchdog.c
|
||||
endif
|
||||
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src
|
||||
ifeq ($(WINTOOL),y)
|
||||
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}" \
|
||||
-I "${shell cygpath -w $(ARCH_SRCDIR)/common}" \
|
||||
-I "${shell cygpath -w $(ARCH_SRCDIR)/armv7-m}"
|
||||
else
|
||||
CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common -I$(ARCH_SRCDIR)/armv7-m
|
||||
endif
|
||||
|
||||
all: libboard$(LIBEXT)
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS) $(LINKOBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
libboard$(LIBEXT): $(OBJS)
|
||||
@( for obj in $(OBJS) ; do \
|
||||
$(call ARCHIVE, $@, $${obj}); \
|
||||
done ; )
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
@rm -f libboard$(LIBEXT) *~ .*.swp
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
@rm -f Make.dep .depend
|
||||
|
||||
-include Make.dep
|
@ -113,7 +113,6 @@
|
||||
* 32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 92 PB6 PB6-I2C1-SCL 2.4" TFT + Touchscreen, AT24C02
|
||||
* 93 PB7 PB7-I2C1-SDA 2.4" TFT + Touchscreen, AT24C02
|
||||
* 7 PC13 PD13_LCD_LIGHT 2.4" TFT + Touchscreen
|
||||
* 81 PD0 PD0-FSMC_D2 2.4" TFT + Touchscreen
|
||||
* 82 PD1 PD1-FSMC_D3 2.4" TFT + Touchscreen
|
||||
* 85 PD4 PD4-FSMC_NOE 2.4" TFT + Touchscreen
|
||||
@ -139,7 +138,9 @@
|
||||
*/
|
||||
|
||||
#define GPIO_LCD_BACKLIGHT (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN13)
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN13)
|
||||
|
||||
/* GPIO_LCD_CS - Is there some kind of chip select for SPI1? */
|
||||
|
||||
/* LEDs
|
||||
*
|
||||
@ -174,9 +175,71 @@
|
||||
#define NUM_IRQBUTTONS (MAX_IRQBUTTON - MIN_IRQBUTTON + 1)
|
||||
|
||||
#define GPIO_BTN_KEY1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||
GPIO_PORTB|GPIO_PIN0)
|
||||
GPIO_EXTI|GPIO_PORTB|GPIO_PIN0)
|
||||
#define GPIO_BTN_KEY2 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||
GPIO_PORTB|GPIO_PIN1)
|
||||
GPIO_EXTI|GPIO_PORTB|GPIO_PIN1)
|
||||
|
||||
/* 2MBit SPI FLASH
|
||||
*
|
||||
* --- ------ -------------- -------------------------------------------------------------------
|
||||
* PIN NAME SIGNAL NOTES
|
||||
* --- ------ -------------- -------------------------------------------------------------------
|
||||
*
|
||||
* 29 PA4 PA4-SPI1-NSS 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 30 PA5 PA5-SPI1-SCK 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 31 PA6 PA6-SPI1-MISO 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NET_ENC28J60
|
||||
# define GPIO_ENC28J60_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
|
||||
GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4)
|
||||
#endif
|
||||
|
||||
/* ENC28J60
|
||||
*
|
||||
* --- ------ -------------- -------------------------------------------------------------------
|
||||
* PIN NAME SIGNAL NOTES
|
||||
* --- ------ -------------- -------------------------------------------------------------------
|
||||
*
|
||||
* 29 PA4 PA4-SPI1-NSS 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 30 PA5 PA5-SPI1-SCK 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 31 PA6 PA6-SPI1-MISO 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 98 PE1 PE1-FSMC_NBL1 2.4" TFT + Touchscreen, 10Mbit EN28J60 Reset
|
||||
* 4 PE5 (no name) 10Mbps ENC28J60 Interrupt
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_STM32_FSMC) && defined(CONFIG_NET_ENC28J60)
|
||||
# warning "TFT LCD and ENCJ2860 shared PE1"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_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|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN1)
|
||||
# define GPIO_ENC28J60_INTR (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||
GPIO_EXTI|GPIO_PORTE|GPIO_PIN5)
|
||||
#endif
|
||||
|
||||
/* MP3
|
||||
*
|
||||
* --- ------ -------------- -------------------------------------------------------------------
|
||||
* PIN NAME SIGNAL NOTES
|
||||
* --- ------ -------------- -------------------------------------------------------------------
|
||||
*
|
||||
* 48 PB11 PB11-MP3-RST MP3
|
||||
* 51 PB12 PB12-SPI2-NSS MP3
|
||||
* 52 PB13 PB13-SPI2-SCK MP3
|
||||
* 53 PB14 PB14-SPI2-MISO MP3
|
||||
* 54 PB15 PB15-SPI2-MOSI MP3
|
||||
* 63 PC6 PC6-MP3-XDCS MP3
|
||||
* 64 PC7 PC7-MP3-DREQ MP3
|
||||
*/
|
||||
|
||||
#define GPIO_MP3_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
|
||||
GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN6)
|
||||
|
||||
/************************************************************************************
|
||||
* Public Types
|
||||
|
386
configs/fire-stm32v2/src/up_autoleds.c
Normal file
386
configs/fire-stm32v2/src/up_autoleds.c
Normal file
@ -0,0 +1,386 @@
|
||||
/****************************************************************************
|
||||
* configs/fire-stm32v2/src/up_autoleds.c
|
||||
* arch/arm/src/board/up_autoleds.c
|
||||
*
|
||||
* Copyright (C) 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
|
||||
* 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 <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#include <nuttx/power/pm.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
#include "stm32_internal.h"
|
||||
#include "fire-internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Enables debug output from this file (needs CONFIG_DEBUG with
|
||||
* CONFIG_DEBUG_VERBOSE too)
|
||||
*/
|
||||
|
||||
#undef LED_DEBUG /* Define to enable debug */
|
||||
|
||||
#ifdef LED_DEBUG
|
||||
# define leddbg lldbg
|
||||
# define ledvdbg llvdbg
|
||||
#else
|
||||
# define leddbg(x...)
|
||||
# define ledvdbg(x...)
|
||||
#endif
|
||||
|
||||
/* The following definitions map the encoded LED setting to GPIO settings.
|
||||
*
|
||||
* OFFBITS ONBITS
|
||||
* CLR SET CLR SET
|
||||
* 210 210 210 210
|
||||
*/
|
||||
|
||||
#define FIRE_LED1 (1 << 0)
|
||||
#define FIRE_LED2 (1 << 1)
|
||||
#define FIRE_LED3 (1 << 2)
|
||||
|
||||
#define ON_SETBITS_SHIFT (0)
|
||||
#define ON_CLRBITS_SHIFT (3)
|
||||
#define OFF_SETBITS_SHIFT (6)
|
||||
#define OFF_CLRBITS_SHIFT (9)
|
||||
|
||||
#define ON_BITS(v) ((v) & 0x3f)
|
||||
#define OFF_BITS(v) (((v) >> 6) & 0x03f)
|
||||
#define SETBITS(b) ((b) & 0x07)
|
||||
#define CLRBITS(b) (((b) >> 3) & 0x07)
|
||||
|
||||
#define ON_SETBITS(v) (SETBITS(ON_BITS(v))
|
||||
#define ON_CLRBITS(v) (CLRBITS(ON_BITS(v))
|
||||
#define OFF_SETBITS(v) (SETBITS(OFF_BITS(v))
|
||||
#define OFF_CLRBITS(v) (CLRBITS(OFF_BITS(v))
|
||||
|
||||
/* ON OFF
|
||||
* -------------------------- -- ------------------ -----------------
|
||||
* LED1 LED2 LED3 LED1 LED2 LED3
|
||||
* -------------------------- -- ------ ----- ----- ----- ----- -----
|
||||
* LED_STARTED 0 OFF OFF OFF OFF OFF OFF
|
||||
* LED_HEAPALLOCATE 1 ON OFF OFF OFF OFF OFF
|
||||
* LED_IRQSENABLED 2 OFF ON OFF ON OFF OFF
|
||||
* LED_STACKCREATED 3 OFF OFF OFF OFF ON OFF
|
||||
*
|
||||
* LED_INIRQ 4 NC NC ON NC NC OFF
|
||||
* LED_SIGNAL 4 NC NC ON NC NC OFF
|
||||
* LED_ASSERTION 4 NC NC ON NC NC OFF
|
||||
* LED_PANIC 4 NC NC ON NC NC OFF
|
||||
* -------------------------- -- ------ ----- ----- ----- ----- -----
|
||||
*/
|
||||
|
||||
#define LED_STARTED_ON_SETBITS (0)
|
||||
#define LED_STARTED_ON_CLRBITS ((FIRE_LED1|FIRE_LED2|FIRE_LED3) << ON_CLRBITS_SHIFT)
|
||||
#define LED_STARTED_OFF_SETBITS LED_STARTED_ON_SETBITS
|
||||
#define LED_STARTED_OFF_CLRBITS LED_STARTED_ON_CLRBITS
|
||||
|
||||
#define LED_HEAPALLOCATE_ON_SETBITS ((FIRE_LED1) << ON_SETBITS_SHIFT)
|
||||
#define LED_HEAPALLOCATE_ON_CLRBITS ((FIRE_LED2|FIRE_LED3) << ON_CLRBITS_SHIFT)
|
||||
#define LED_HEAPALLOCATE_OFF_SETBITS LED_STARTED_ON_SETBITS
|
||||
#define LED_HEAPALLOCATE_OFF_CLRBITS LED_STARTED_ON_CLRBITS
|
||||
|
||||
#define LED_IRQSENABLED_ON_SETBITS ((FIRE_LED2) << ON_SETBITS_SHIFT)
|
||||
#define LED_IRQSENABLED_ON_CLRBITS ((FIRE_LED1|FIRE_LED3) << ON_CLRBITS_SHIFT)
|
||||
#define LED_IRQSENABLED_OFF_SETBITS LED_HEAPALLOCATE_ON_SETBITS
|
||||
#define LED_IRQSENABLED_OFF_CLRBITS LED_HEAPALLOCATE_ON_CLRBITS
|
||||
|
||||
#define LED_STACKCREATED_ON_SETBITS (0)
|
||||
#define LED_STACKCREATED_ON_CLRBITS ((FIRE_LED1|FIRE_LED2|FIRE_LED3) << ON_CLRBITS_SHIFT)
|
||||
#define LED_STACKCREATED_OFF_SETBITS LED_IRQSENABLED_ON_SETBITS
|
||||
#define LED_STACKCREATED_OFF_CLRBITS LED_IRQSENABLED_ON_CLRBITS
|
||||
|
||||
#define LED_FLASH_ON_SETBITS ((FIRE_LED3) << ON_SETBITS_SHIFT)
|
||||
#define LED_FLASH_ON_CLRBITS ((0) << ON_CLRBITS_SHIFT)
|
||||
#define LED_FLASH_OFF_SETBITS ((0) << OFF_SETBITS_SHIFT)
|
||||
#define LED_FLASH_OFF_CLRBITS ((FIRE_LED3) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
/**************************************************************************************
|
||||
* Private Function Protototypes
|
||||
**************************************************************************************/
|
||||
|
||||
/* LED State Controls */
|
||||
|
||||
static inline void led_clrbits(unsigned int clrbits);
|
||||
static inline void led_setbits(unsigned int setbits);
|
||||
static void led_setonoff(unsigned int bits);
|
||||
|
||||
/* LED Power Management */
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static void led_pm_notify(struct pm_callback_s *cb, enum pm_state_e pmstate);
|
||||
static int led_pm_prepare(struct pm_callback_s *cb, enum pm_state_e pmstate);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const uint16_t g_ledbits[8] =
|
||||
{
|
||||
(LED_STARTED_ON_SETBITS | LED_STARTED_ON_CLRBITS |
|
||||
LED_STARTED_OFF_SETBITS | LED_STARTED_OFF_CLRBITS),
|
||||
|
||||
(LED_HEAPALLOCATE_ON_SETBITS | LED_HEAPALLOCATE_ON_CLRBITS |
|
||||
LED_HEAPALLOCATE_OFF_SETBITS | LED_HEAPALLOCATE_OFF_CLRBITS),
|
||||
|
||||
(LED_IRQSENABLED_ON_SETBITS | LED_IRQSENABLED_ON_CLRBITS |
|
||||
LED_IRQSENABLED_OFF_SETBITS | LED_IRQSENABLED_OFF_CLRBITS),
|
||||
|
||||
(LED_STACKCREATED_ON_SETBITS | LED_STACKCREATED_ON_CLRBITS |
|
||||
LED_STACKCREATED_OFF_SETBITS | LED_STACKCREATED_OFF_CLRBITS),
|
||||
|
||||
(LED_FLASH_ON_SETBITS | LED_FLASH_ON_CLRBITS |
|
||||
LED_FLASH_OFF_SETBITS | LED_FLASH_OFF_CLRBITS)
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static struct pm_callback_s g_ledscb =
|
||||
{
|
||||
.notify = led_pm_notify,
|
||||
.prepare = led_pm_prepare,
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: led_clrbits
|
||||
*
|
||||
* Description:
|
||||
* Clear all LEDs to the bit encoded state
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline void led_clrbits(unsigned int clrbits)
|
||||
{
|
||||
if ((clrbits & FIRE_LED1) != 0)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LED1, false);
|
||||
}
|
||||
|
||||
if ((clrbits & FIRE_LED2) != 0)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LED2, false);
|
||||
}
|
||||
|
||||
if ((clrbits & FIRE_LED3) != 0)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LED3, false);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: led_setbits
|
||||
*
|
||||
* Description:
|
||||
* Set all LEDs to the bit encoded state
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline void led_setbits(unsigned int setbits)
|
||||
{
|
||||
if ((setbits & FIRE_LED1) != 0)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LED1, true);
|
||||
}
|
||||
|
||||
if ((setbits & FIRE_LED2) != 0)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LED2, true);
|
||||
}
|
||||
|
||||
if ((setbits & FIRE_LED3) != 0)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LED3, true);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: led_setonoff
|
||||
*
|
||||
* Description:
|
||||
* Set/clear all LEDs to the bit encoded state
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void led_setonoff(unsigned int bits)
|
||||
{
|
||||
led_clrbits(CLRBITS(bits));
|
||||
led_setbits(SETBITS(bits));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: led_pm_notify
|
||||
*
|
||||
* Description:
|
||||
* Notify the driver of new power state. This callback is called after
|
||||
* all drivers have had the opportunity to prepare for the new power state.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static void led_pm_notify(struct pm_callback_s *cb , enum pm_state_e pmstate)
|
||||
{
|
||||
switch (pmstate)
|
||||
{
|
||||
case(PM_NORMAL):
|
||||
{
|
||||
/* Restore normal LEDs operation */
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case(PM_IDLE):
|
||||
{
|
||||
/* Entering IDLE mode - Turn leds off */
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case(PM_STANDBY):
|
||||
{
|
||||
/* Entering STANDBY mode - Logic for PM_STANDBY goes here */
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case(PM_SLEEP):
|
||||
{
|
||||
/* Entering SLEEP mode - Logic for PM_SLEEP goes here */
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
/* Should not get here */
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: led_pm_prepare
|
||||
*
|
||||
* Description:
|
||||
* Request the driver to prepare for a new power state. This is a warning
|
||||
* that the system is about to enter into a new power state. The driver
|
||||
* should begin whatever operations that may be required to enter power
|
||||
* state. The driver may abort the state change mode by returning a
|
||||
* non-zero value from the callback function.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int led_pm_prepare(struct pm_callback_s *cb , enum pm_state_e pmstate)
|
||||
{
|
||||
/* No preparation to change power modes is required by the LEDs driver.
|
||||
* We always accept the state change by returning OK.
|
||||
*/
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_ledinit
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
void up_ledinit(void)
|
||||
{
|
||||
/* Configure LED1-4 GPIOs for output */
|
||||
|
||||
stm32_configgpio(GPIO_LED1);
|
||||
stm32_configgpio(GPIO_LED2);
|
||||
stm32_configgpio(GPIO_LED3);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_ledon
|
||||
****************************************************************************/
|
||||
|
||||
void up_ledon(int led)
|
||||
{
|
||||
led_setonoff(ON_BITS(g_ledbits[led]));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_ledoff
|
||||
****************************************************************************/
|
||||
|
||||
void up_ledoff(int led)
|
||||
{
|
||||
led_setonoff(OFF_BITS(g_ledbits[led]));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_ledpminitialize
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
void up_ledpminitialize(void)
|
||||
{
|
||||
/* Register to receive power management callbacks */
|
||||
|
||||
int ret = pm_register(&g_ledscb);
|
||||
if (ret != OK)
|
||||
{
|
||||
up_ledon(LED_ASSERTION);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_PM */
|
||||
|
||||
#endif /* CONFIG_ARCH_LEDS */
|
102
configs/fire-stm32v2/src/up_boot.c
Normal file
102
configs/fire-stm32v2/src/up_boot.c
Normal file
@ -0,0 +1,102 @@
|
||||
/************************************************************************************
|
||||
* configs/fire-stm32v2/src/up_boot.c
|
||||
* arch/arm/src/board/up_boot.c
|
||||
*
|
||||
* Copyright (C) 2009, 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
|
||||
* 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 <debug.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "fire-internal.h"
|
||||
|
||||
/************************************************************************************
|
||||
* Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_boardinitialize
|
||||
*
|
||||
* Description:
|
||||
* All STM32 architectures must provide the following entry point. This entry point
|
||||
* is called early in the intitialization -- after all memory has been configured
|
||||
* and mapped but before any devices have been initialized.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
void stm32_boardinitialize(void)
|
||||
{
|
||||
/* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function
|
||||
* stm32_spiinitialize() has been brought into the link.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2)
|
||||
if (stm32_spiinitialize)
|
||||
{
|
||||
stm32_spiinitialize();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize USB is 1) USBDEV is selected, 2) the USB controller is not
|
||||
* disabled, and 3) the weak function stm32_usbinitialize() has been brought
|
||||
* into the build.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_USBDEV) && defined(CONFIG_STM32_USB)
|
||||
if (stm32_usbinitialize)
|
||||
{
|
||||
stm32_usbinitialize();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Configure on-board LEDs if LED support has been selected. */
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
up_ledinit();
|
||||
#endif
|
||||
}
|
161
configs/fire-stm32v2/src/up_buttons.c
Normal file
161
configs/fire-stm32v2/src/up_buttons.c
Normal file
@ -0,0 +1,161 @@
|
||||
/****************************************************************************
|
||||
* configs/fire-stm32v2/src/up_buttons.c
|
||||
*
|
||||
* Copyright (C) 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
|
||||
* 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 <arch/board/board.h>
|
||||
#include "fire-internal.h"
|
||||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
/* Pin configuration for each Shenzhou button. This array is indexed by
|
||||
* the BUTTON_* definitions in board.h
|
||||
*/
|
||||
|
||||
static const uint16_t g_buttons[NUM_BUTTONS] =
|
||||
{
|
||||
GPIO_BTN_KEY1, GPIO_BTN_KEY1
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_buttoninit
|
||||
*
|
||||
* Description:
|
||||
* up_buttoninit() must be called to initialize button resources. After
|
||||
* that, up_buttons() may be called to collect the current state of all
|
||||
* buttons or up_irqbutton() may be called to register button interrupt
|
||||
* handlers.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_buttoninit(void)
|
||||
{
|
||||
/* Configure the GPIO pins as inputs. NOTE that EXTI interrupts are
|
||||
* configured for some pins but NOT used in this file
|
||||
*/
|
||||
|
||||
stm32_configgpio(GPIO_BTN_KEY1);
|
||||
stm32_configgpio(GPIO_BTN_KEY2);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_buttons
|
||||
****************************************************************************/
|
||||
|
||||
uint8_t up_buttons(void)
|
||||
{
|
||||
uint8_t ret = 0;
|
||||
|
||||
/* Check that state of each key. A LOW value means that the key is pressed, */
|
||||
|
||||
if (!stm32_gpioread(GPIO_BTN_KEY1))
|
||||
{
|
||||
ret |= BUTTON_KEY1_BIT;
|
||||
}
|
||||
|
||||
if (!stm32_gpioread(GPIO_BTN_KEY2))
|
||||
{
|
||||
ret |= BUTTON_KEY2_BIT;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Button support.
|
||||
*
|
||||
* Description:
|
||||
* up_buttoninit() must be called to initialize button resources. After
|
||||
* that, up_buttons() may be called to collect the current state of all
|
||||
* buttons or up_irqbutton() may be called to register button interrupt
|
||||
* handlers.
|
||||
*
|
||||
* After up_buttoninit() has been called, up_buttons() may be called to
|
||||
* collect the state of all buttons. up_buttons() returns an 8-bit bit set
|
||||
* with each bit associated with a button. See the BUTTON_*_BIT and JOYSTICK_*_BIT
|
||||
* definitions in board.h for the meaning of each bit.
|
||||
*
|
||||
* up_irqbutton() may be called to register an interrupt handler that will
|
||||
* be called when a button is depressed or released. The ID value is a
|
||||
* button enumeration value that uniquely identifies a button resource. See the
|
||||
* BUTTON_* and JOYSTICK_* definitions in board.h for the meaning of enumeration
|
||||
* value. The previous interrupt handler address is returned (so that it may
|
||||
* restored, if so desired).
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t up_irqbutton(int id, xcpt_t irqhandler)
|
||||
{
|
||||
uint16_t gpio;
|
||||
|
||||
if (id == BUTTON_KEY1)
|
||||
{
|
||||
gpio = GPIO_KEY1;
|
||||
}
|
||||
else if (id == BUTTON_KEY2)
|
||||
{
|
||||
gpio = GPIO_KEY2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return stm32_gpiosetevent(gpio, true, true, true, irqhandler);
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_ARCH_BUTTONS */
|
210
configs/fire-stm32v2/src/up_enc28j60.c
Normal file
210
configs/fire-stm32v2/src/up_enc28j60.c
Normal file
@ -0,0 +1,210 @@
|
||||
/****************************************************************************
|
||||
* configs/fire-stm32v2/src/up_enc28j60.c
|
||||
*
|
||||
* Copyright (C) 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
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* 2MBit SPI FLASH OR ENC28J60
|
||||
*
|
||||
* --- ------ -------------- -----------------------------------------------------
|
||||
* PIN NAME SIGNAL NOTES
|
||||
* --- ------ -------------- -----------------------------------------------------
|
||||
*
|
||||
* 29 PA4 PA4-SPI1-NSS 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 30 PA5 PA5-SPI1-SCK 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 31 PA6 PA6-SPI1-MISO 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/spi.h>
|
||||
#include <nuttx/net/enc28j60.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
#include "fire_internal.h"
|
||||
|
||||
#ifdef CONFIG_NET_ENC28J60
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
/* ENC28J60
|
||||
*
|
||||
* --- ------ -------------- -----------------------------------------------------
|
||||
* PIN NAME SIGNAL NOTES
|
||||
* --- ------ -------------- -----------------------------------------------------
|
||||
*
|
||||
* 29 PA4 PA4-SPI1-NSS 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 30 PA5 PA5-SPI1-SCK 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 31 PA6 PA6-SPI1-MISO 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 98 PE1 PE1-FSMC_NBL1 2.4" TFT + Touchscreen, 10Mbit EN28J60 Reset
|
||||
* 4 PE5 (no name) 10Mbps ENC28J60 Interrupt
|
||||
*/
|
||||
|
||||
/* ENC28J60 is on SPI1 */
|
||||
|
||||
#ifndef CONFIG_STM32_SPI1
|
||||
# error "Need CONFIG_STM32_SPI1 in the configuration"
|
||||
#endif
|
||||
|
||||
/* SPI Assumptions **********************************************************/
|
||||
|
||||
#define ENC28J60_SPI_PORTNO 1 /* On SPI1 */
|
||||
#define ENC28J60_DEVNO 0 /* Only one ENC28J60 */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct stm32_lower_s
|
||||
{
|
||||
const struct enc_lower_s lower; /* Low-level MCU interface */
|
||||
xcpt_t handler; /* ENC28J60 interrupt handler */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* 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);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* The ENC28J60 normal provides interrupts to the MCU via a GPIO pin. The
|
||||
* following structure provides an MCU-independent mechanixm for controlling
|
||||
* the ENC28J60 GPIO interrupt.
|
||||
*/
|
||||
|
||||
static const struct enc_lower_s g_enclower =
|
||||
{
|
||||
{
|
||||
.attach = up_attach,
|
||||
.enable = up_enable,
|
||||
.disable = up_disable
|
||||
}
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: struct enc_lower_s methods
|
||||
****************************************************************************/
|
||||
|
||||
static int up_attach(FAR 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;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static void up_enable(FAR 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);
|
||||
}
|
||||
|
||||
static void up_disable(FAR struct enc_lower_s *lower)
|
||||
{
|
||||
(void)stm32_gpiosetevent(GPIO_ENC28J60_INTR, true, true, true, NULL);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_netinitialize
|
||||
****************************************************************************/
|
||||
|
||||
void up_netinitialize(void)
|
||||
{
|
||||
FAR struct spi_dev_s *spi;
|
||||
uint16_t reg16;
|
||||
int ret;
|
||||
|
||||
/* Assumptions:
|
||||
* 1) ENC28J60 pins were configured in up_spi.c early in the boot-up phase.
|
||||
* 2) Clocking for the SPI1 peripheral was also provided earlier in boot-up.
|
||||
*/
|
||||
|
||||
spi = up_spiinitialize(ENC28J60_SPI_PORTNO);
|
||||
if (!spi)
|
||||
{
|
||||
nlldbg("Failed to initialize SPI port %d\n", ENC28J60_SPI_PORTNO);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Take ENC28J60 out of reset (active low)*/
|
||||
|
||||
stm32_gpiowrite(GPIO_ENC28J60_RESET, true);
|
||||
|
||||
/* Bind the SPI port to the ENC28J60 driver */
|
||||
|
||||
ret = enc_initialize(spi, ENC28J60_DEVNO, &g_enclower);
|
||||
if (ret < 0)
|
||||
{
|
||||
nlldbg("Failed to bind SPI port %d ENC28J60 device %d: %d\n",
|
||||
ENC28J60_SPI_PORTNO, ENC28J60_DEVNO, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
nllvdbg("Bound SPI port %d to ENC28J60 device %d\n",
|
||||
ENC28J60_SPI_PORTNO, ENC28J60_DEVNO);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET_ENC28J60 */
|
210
configs/fire-stm32v2/src/up_selectlcd.c
Normal file
210
configs/fire-stm32v2/src/up_selectlcd.c
Normal file
@ -0,0 +1,210 @@
|
||||
/************************************************************************************
|
||||
* configs/fire-stm32v2/src/up_selectlcd.c
|
||||
* arch/arm/src/board/up_selectlcd.c
|
||||
*
|
||||
* Copyright (C) 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
|
||||
* 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 <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
|
||||
#include "stm32_fsmc.h"
|
||||
#include "stm32_gpio.h"
|
||||
#include "stm32_internal.h"
|
||||
#include "fire-internal.h"
|
||||
|
||||
#ifdef CONFIG_STM32_FSMC
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
#ifndef CONFIG_STM32_FSMC
|
||||
# warning "FSMC is not enabled"
|
||||
#endif
|
||||
|
||||
#if STM32_NGPIO_PORTS < 6
|
||||
# error "Required GPIO ports not enabled"
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
|
||||
/* 2.4" TFT + Touchscreen. FSMC Bank1
|
||||
*
|
||||
* --- ------ -------------- -------------------------------------------------------------------
|
||||
* PIN NAME SIGNAL NOTES
|
||||
* --- ------ -------------- -------------------------------------------------------------------
|
||||
*
|
||||
* 30 PA5 PA5-SPI1-SCK 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 31 PA6 PA6-SPI1-MISO 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
|
||||
* 92 PB6 PB6-I2C1-SCL 2.4" TFT + Touchscreen, AT24C02
|
||||
* 93 PB7 PB7-I2C1-SDA 2.4" TFT + Touchscreen, AT24C02
|
||||
* 81 PD0 PD0-FSMC_D2 2.4" TFT + Touchscreen
|
||||
* 82 PD1 PD1-FSMC_D3 2.4" TFT + Touchscreen
|
||||
* 85 PD4 PD4-FSMC_NOE 2.4" TFT + Touchscreen
|
||||
* 86 PD5 PD5-FSMC_NWE 2.4" TFT + Touchscreen
|
||||
* 88 PD7 PD7-FSMC_NE1 2.4" TFT + Touchscreen
|
||||
* 55 PD8 PD8-FSMC_D13 2.4" TFT + Touchscreen
|
||||
* 56 PD9 PD9-FSMC_D14 2.4" TFT + Touchscreen
|
||||
* 57 PD10 PD10-FSMC_D15 2.4" TFT + Touchscreen
|
||||
* 58 PD11 PD11-FSMC_A16 2.4" TFT + Touchscreen
|
||||
* 60 PD13 PD13-LCD/LIGHT 2.4" TFT + Touchscreen
|
||||
* 61 PD14 PD14-FSMC_D0 2.4" TFT + Touchscreen
|
||||
* 62 PD15 PD15-FSMC_D1 2.4" TFT + Touchscreen
|
||||
* 98 PE1 PE1-FSMC_NBL1 2.4" TFT + Touchscreen
|
||||
* 38 PE7 PE7-FSMC_D4 2.4" TFT + Touchscreen
|
||||
* 39 PE8 PE8-FSMC_D5 2.4" TFT + Touchscreen
|
||||
* 40 PE9 PE9-FSMC_D6 2.4" TFT + Touchscreen
|
||||
* 41 PE10 PE10-FSMC_D7 2.4" TFT + Touchscreen
|
||||
* 42 PE11 PE11-FSMC_D8 2.4" TFT + Touchscreen
|
||||
* 43 PE12 PE12-FSMC_D9 2.4" TFT + Touchscreen
|
||||
* 44 PE13 PE13-FSMC_D10 2.4" TFT + Touchscreen
|
||||
* 45 PE14 PE14-FSMC_D11 2.4" TFT + Touchscreen
|
||||
* 46 PE15 PE15-FSMC_D12 2.4" TFT + Touchscreen
|
||||
*
|
||||
* NOTE: SPI and I2C pin configuration is controlled in the SPI and I2C drivers, respectively.
|
||||
*/
|
||||
|
||||
static const uint16_t g_lcdconfig[NCOMMON_CONFIG] =
|
||||
{
|
||||
/* Address Lines: A16 only */
|
||||
|
||||
GPIO_NPS_A16,
|
||||
|
||||
/* Data Lines: D0... D15 */
|
||||
|
||||
GPIO_NPS_D0, GPIO_NPS_D1, GPIO_NPS_D2, GPIO_NPS_D3,
|
||||
GPIO_NPS_D4, GPIO_NPS_D5, GPIO_NPS_D6, GPIO_NPS_D7,
|
||||
GPIO_NPS_D8, GPIO_NPS_D9, GPIO_NPS_D10, GPIO_NPS_D11,
|
||||
GPIO_NPS_D12, GPIO_NPS_D13, GPIO_NPS_D14, GPIO_NPS_D15,
|
||||
|
||||
/* NOE, NWE, NE1, NBL1 */
|
||||
|
||||
GPIO_NPS_NOE, GPIO_NPS_NWE, GPIO_NPS_NE1, GPIO_NPS_NBL1,
|
||||
|
||||
/* Backlight GPIO */
|
||||
|
||||
GPIO_LCD_BACKLIGHT
|
||||
};
|
||||
#define NLCD_CONFIG (sizeof(g_lcdconfig) / sizeof(uint16_t))
|
||||
|
||||
/************************************************************************************
|
||||
* Private Data
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_enablefsmc
|
||||
*
|
||||
* Description:
|
||||
* Enable clocking to the FSMC module
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
static inline void stm32_enablefsmc(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
/* Enable AHB clocking to the FSMC */
|
||||
|
||||
regval = getreg32( STM32_RCC_AHBENR);
|
||||
regval |= RCC_AHBENR_FSMCEN;
|
||||
putreg32(regval, STM32_RCC_AHBENR);
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_selectlcd
|
||||
*
|
||||
* Description:
|
||||
* Initialize to the LCD pin configuration.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
void stm32_selectlcd(void)
|
||||
{
|
||||
irqstate_t flags;
|
||||
int i;
|
||||
|
||||
/* Configure LCD GPIO pis */
|
||||
|
||||
flags = irqsave();
|
||||
for (i = 0; i < NLCD_GPIOS; i++)
|
||||
{
|
||||
stm32_configgpio(g_lcdconfig[i]);
|
||||
}
|
||||
|
||||
/* Enable AHB clocking to the FSMC */
|
||||
|
||||
stm32_enablefsmc();
|
||||
|
||||
/* Bank1 NOR/SRAM control register configuration */
|
||||
|
||||
putreg32(FSMC_BCR_SRAM | FSMC_BCR_MWID16 | FSMC_BCR_WREN, STM32_FSMC_BCR1);
|
||||
|
||||
/* Bank1 NOR/SRAM timing register configuration */
|
||||
|
||||
putreg32(FSMC_BTR_ADDSET(1)|FSMC_BTR_ADDHLD(0)|FSMC_BTR_DATAST(2)|FSMC_BTR_BUSTRUN(0)|
|
||||
FSMC_BTR_CLKDIV(0)|FSMC_BTR_DATLAT(0)|FSMC_BTR_ACCMODA, STM32_FSMC_BTR1);
|
||||
|
||||
putreg32(0xffffffff, STM32_FSMC_BWTR4);
|
||||
|
||||
/* Enable the bank by setting the MBKEN bit */
|
||||
|
||||
putreg32(FSMC_BCR_MBKEN | FSMC_BCR_SRAM | FSMC_BCR_MWID16 | FSMC_BCR_WREN, STM32_FSMC_BCR1);
|
||||
irqrestore(flags);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_STM32_FSMC */
|
||||
|
||||
|
215
configs/fire-stm32v2/src/up_spi.c
Normal file
215
configs/fire-stm32v2/src/up_spi.c
Normal file
@ -0,0 +1,215 @@
|
||||
/************************************************************************************
|
||||
* configs/stm3210e_eval/src/up_spi.c
|
||||
* arch/arm/src/board/up_spi.c
|
||||
*
|
||||
* Copyright (C) 2009 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
|
||||
* 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 <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/spi.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "chip.h"
|
||||
#include "stm32_internal.h"
|
||||
#include "stm3210e-internal.h"
|
||||
|
||||
#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2)
|
||||
|
||||
/************************************************************************************
|
||||
* Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Enables debug output from this file (needs CONFIG_DEBUG too) */
|
||||
|
||||
#undef SPI_DEBUG /* Define to enable debug */
|
||||
#undef SPI_VERBOSE /* Define to enable verbose debug */
|
||||
|
||||
#ifdef SPI_DEBUG
|
||||
# define spidbg lldbg
|
||||
# ifdef SPI_VERBOSE
|
||||
# define spivdbg lldbg
|
||||
# else
|
||||
# define spivdbg(x...)
|
||||
# endif
|
||||
#else
|
||||
# undef SPI_VERBOSE
|
||||
# define spidbg(x...)
|
||||
# define spivdbg(x...)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32_spiinitialize
|
||||
*
|
||||
* Description:
|
||||
* Called to configure SPI chip select GPIO pins for the STM3210E-EVAL board.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
void weak_function stm32_spiinitialize(void)
|
||||
{
|
||||
/* NOTE: Clocking for SPI1 and/or SPI2 was already provided in stm32_rcc.c.
|
||||
* Configurations of SPI pins is performed in stm32_spi.c.
|
||||
* Here, we only initialize chip select pins unique to the board
|
||||
* architecture.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_STM32_SPI1
|
||||
/* Configure the TFT/Touchscreen CS GPIO */
|
||||
|
||||
#if 0 /* Need to study this */
|
||||
stm32_configgpio(GPIO_LCD_CS);
|
||||
#endif
|
||||
|
||||
/* Configure the TFT/Touchscreen and ENC28J60 or SPI-based FLASH PIOs */
|
||||
|
||||
/* Configure ENC28J60 SPI1 CS (also RESET and interrupt pins) */
|
||||
|
||||
#ifdef CONFIG_NET_ENC28J60
|
||||
stm32_configgpio(GPIO_ENC28J60_CS);
|
||||
stm32_configgpio(GPIO_ENC28J60_RESET);
|
||||
stm32_configgpio(GPIO_ENC28J60_INTR);
|
||||
#else
|
||||
|
||||
/* Configure FLASH SPI1 CS */
|
||||
|
||||
stm32_configgpio(GPIO_FLASH_CS);
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_STM32_SPI1 */
|
||||
|
||||
#ifdef CONFIG_STM32_SPI2
|
||||
/* Configure the MP3 SPI2 CS GPIO */
|
||||
|
||||
stm32_configgpio(GPIO_MP3_CS);
|
||||
|
||||
#endif /* CONFIG_STM32_SPI2 */
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_spi1/2/3select and stm32_spi1/2/3status
|
||||
*
|
||||
* Description:
|
||||
* The external functions, stm32_spi1/2/3select and stm32_spi1/2/3status must be
|
||||
* provided by board-specific logic. They are implementations of the select
|
||||
* and status methods of the SPI interface defined by struct spi_ops_s (see
|
||||
* include/nuttx/spi.h). All other methods (including up_spiinitialize())
|
||||
* are provided by common STM32 logic. To use this common SPI logic on your
|
||||
* board:
|
||||
*
|
||||
* 1. Provide logic in stm32_boardinitialize() to configure SPI chip select
|
||||
* pins.
|
||||
* 2. Provide stm32_spi1/2/3select() and stm32_spi1/2/3status() functions in your
|
||||
* board-specific logic. These functions will perform chip selection and
|
||||
* status operations using GPIOs in the way your board is configured.
|
||||
* 3. Add a calls to up_spiinitialize() in your low level application
|
||||
* initialization logic
|
||||
* 4. The handle returned by up_spiinitialize() may then be used to bind the
|
||||
* SPI driver to higher level logic (e.g., calling
|
||||
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
|
||||
* the SPI MMC/SD driver).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32_SPI1
|
||||
void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||
{
|
||||
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
|
||||
#if 0 /* Need to study this */
|
||||
if (devid == SPIDEV_FLASH)
|
||||
{
|
||||
/* Set the GPIO low to select and high to de-select */
|
||||
|
||||
stm32_gpiowrite(GPIO_FLASH_CS, !selected);
|
||||
}
|
||||
else
|
||||
#ifdef CONFIG_NET_ENC28J60
|
||||
if (devid == SPIDEV_ETHERNET)
|
||||
{
|
||||
/* Set the GPIO low to select and high to de-select */
|
||||
|
||||
stm32_gpiowrite(GPIO_ENC28J60_CS, !selected);
|
||||
}
|
||||
#else
|
||||
if (devid == SPIDEV_FLASH)
|
||||
{
|
||||
/* Set the GPIO low to select and high to de-select */
|
||||
|
||||
stm32_gpiowrite(GPIO_FLASH_CS, !selected);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
{
|
||||
return SPI_STATUS_PRESENT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_SPI2
|
||||
void stm32_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
|
||||
{
|
||||
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
|
||||
if (devid == SPIDEV_AUDIO)
|
||||
{
|
||||
/* Set the GPIO low to select and high to de-select */
|
||||
|
||||
stm32_gpiowrite(GPIO_MP3_CS, !selected);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
{
|
||||
return SPI_STATUS_PRESENT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_STM32_SPI1 || CONFIG_STM32_SPI2 */
|
129
configs/fire-stm32v2/src/up_userleds.c
Normal file
129
configs/fire-stm32v2/src/up_userleds.c
Normal file
@ -0,0 +1,129 @@
|
||||
/****************************************************************************
|
||||
* configs/fire-stm32v2/src/up_userleds.c
|
||||
* arch/arm/src/board/up_userleds.c
|
||||
*
|
||||
* Copyright (C) 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
|
||||
* 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 <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
#include "stm32_internal.h"
|
||||
#include "fire-internal.h"
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Enables debug output from this file (needs CONFIG_DEBUG with
|
||||
* CONFIG_DEBUG_VERBOSE too)
|
||||
*/
|
||||
|
||||
#undef LED_DEBUG /* Define to enable debug */
|
||||
|
||||
#ifdef LED_DEBUG
|
||||
# define leddbg lldbg
|
||||
# define ledvdbg llvdbg
|
||||
#else
|
||||
# define leddbg(x...)
|
||||
# define ledvdbg(x...)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
/* This array maps an LED number to GPIO pin configuration */
|
||||
|
||||
static uint32_t g_ledcfg[BOARD_NLEDS] =
|
||||
{
|
||||
GPIO_LED1, GPIO_LED2, GPIO_LED3
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_ledinit
|
||||
****************************************************************************/
|
||||
|
||||
void stm32_ledinit(void)
|
||||
{
|
||||
/* Configure LED1-4 GPIOs for output */
|
||||
|
||||
stm32_configgpio(GPIO_LED1);
|
||||
stm32_configgpio(GPIO_LED2);
|
||||
stm32_configgpio(GPIO_LED3);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_setled
|
||||
****************************************************************************/
|
||||
|
||||
void stm32_setled(int led, bool ledon)
|
||||
{
|
||||
if ((unsigned)led < BOARD_NLEDS)
|
||||
{
|
||||
stm32_gpiowrite(g_ledcfg[led], ledon);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_setleds
|
||||
****************************************************************************/
|
||||
|
||||
void stm32_setleds(uint8_t ledset)
|
||||
{
|
||||
stm32_gpiowrite(BOARD_LED1, (ledset & BOARD_LED1_BIT) == 0);
|
||||
stm32_gpiowrite(BOARD_LED2, (ledset & BOARD_LED2_BIT) == 0);
|
||||
stm32_gpiowrite(BOARD_LED3, (ledset & BOARD_LED3_BIT) == 0);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_ARCH_LEDS */
|
@ -150,14 +150,53 @@
|
||||
# define ENC_GPIO0_NETRST (1 << 4) /* Reset (P0.4) */
|
||||
# define ENC_GPIO0_NETINT (1 << 6) /* Interrupt (P0.6) */
|
||||
|
||||
/****************************************************************************
|
||||
* 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);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* The ENC28J60 normal provides interrupts to the MCU via a GPIO pin. The
|
||||
* following structure provides an MCU-independent mechanixm for controlling
|
||||
* the ENC28J60 GPIO interrupt.
|
||||
*/
|
||||
|
||||
static const struct enc_lower_s g_enclower =
|
||||
{
|
||||
.attach = up_attach,
|
||||
.enable = up_enable,
|
||||
.disable = up_disable
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: struct enc_lower_s methods
|
||||
****************************************************************************/
|
||||
|
||||
static int up_attach(FAR struct enc_lower_s *lower, xcpt_t handler)
|
||||
{
|
||||
return irq_attach(ENC28J60_IRQ, handler)
|
||||
}
|
||||
|
||||
static void up_enable(FAR struct enc_lower_s *lower)
|
||||
{
|
||||
up_enable_irq(ENC28J60_IRQ);
|
||||
}
|
||||
|
||||
static void up_disable(FAR struct enc_lower_s *lower)
|
||||
{
|
||||
up_disable_irq(ENC28J60_IRQ);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -198,7 +237,7 @@ void up_netinitialize(void)
|
||||
|
||||
/* Bind the SPI port to the ENC28J60 driver */
|
||||
|
||||
ret = enc_initialize(spi, ENC28J60_DEVNO, ENC28J60_IRQ);
|
||||
ret = enc_initialize(spi, ENC28J60_DEVNO, &g_enclower);
|
||||
if (ret < 0)
|
||||
{
|
||||
nlldbg("Failed to bind SPI port %d ENC28J60 device %d: %d\n",
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* configs/shenzhou/src/up_buttons.c
|
||||
*
|
||||
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -138,11 +138,11 @@ void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool sele
|
||||
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
|
||||
if (devid == SPIDEV_FLASH)
|
||||
{
|
||||
/* Set the GPIO low to select and high to de-select */
|
||||
{
|
||||
/* Set the GPIO low to select and high to de-select */
|
||||
|
||||
stm32_gpiowrite(GPIO_FLASH_CS, !selected);
|
||||
}
|
||||
stm32_gpiowrite(GPIO_FLASH_CS, !selected);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
||||
|
Loading…
Reference in New Issue
Block a user