STM32F429I-Discovery: Add support for external SST25 FLASH. From Ken Pettit

This commit is contained in:
Gregory Nutt
2013-11-28 08:21:15 -06:00
parent 3b7626236d
commit 946e927609
10 changed files with 1482 additions and 52 deletions
+72 -1
View File
@@ -3,7 +3,78 @@
# see misc/tools/kconfig-language.txt.
#
if ARCH_BOARD_STM32F429_DISCO
if ARCH_BOARD_STM32F429I_DISCO
config STM32F429I_DISCO_FLASH
bool "MTD driver for external 8Mbyte SST25 FLASH on SPI4"
default n
select MTD
select MTD_SST25XX
select MTD_SMART
select FS_SMARTFS
select STM32_SPI4
select MTD_BYTE_WRITE
---help---
Configures an MTD device for use with the onboard flash
config STM32F429I_DISCO_FLASH_MINOR
int "Minor number for the FLASH /dev/smart entry"
default 0
depends on STM32F429I_DISCO_FLASH
---help---
Sets the minor number for the FLASH MTD /dev entry
config STM32F429I_DISCO_FLASH_PART
bool "Enable partition support on FLASH"
default n
depends on STM32F429I_DISCO_FLASH
---help---
Enables creation of partitions on the FLASH
config STM32F429I_DISCO_FLASH_CONFIG_PART
bool "Create application config data partition on FLASH"
default y
depends on STM32F429I_DISCO_FLASH_PART
depends on PLATFORM_CONFIGDATA
---help---
Enables creation of a /dev/config partition on the FLASH
config STM32F429I_DISCO_FLASH_CONFIG_PART_NUMBER
int "Index number of config partition (in list below)"
default 0
depends on STM32F429I_DISCO_FLASH_CONFIG_PART
---help---
Specifies the index number of the config data partition
from the partition list.
config STM32F429I_DISCO_FLASH_PART_LIST
string "Flash partition size list"
default "4,8188"
depends on STM32F429I_DISCO_FLASH_PART
---help---
Comma separated list of partition sizes in KB.
config STM32F429I_DISCO_RAMMTD
bool "MTD driver for SMARTFS RAM disk"
default n
select MTD
select RAMMTD
---help---
Configures an MTD based RAM device for use with SMARTFS.
config STM32F429I_DISCO_RAMMTD_MINOR
int "Minor number for RAM /dev/smart entry"
default 1
depends on STM32F429I_DISCO_RAMMTD
---help---
Sets the minor number for the RAM MTD /dev entry
config STM32F429I_DISCO_RAMMTD_SIZE
int "Size in KB of the RAM device to create"
default 32
depends on STM32F429I_DISCO_RAMMTD
---help---
Sets the size of static RAM allocation for the SMART RAM device
config PM_BUTTONS
bool "PM Button support"
+24
View File
@@ -816,6 +816,30 @@ Where <subdir> is one of the following:
nsh> umount /mnt/stuff
extflash:
---------
This is another NSH example. If differs from other 'nsh' configurations
in that this configuration defines an external 8 MByte SPI FLASH (the
SST25VF064C part from Silicon Storage Technology, Inc.) which must be
be connected to the Discovery board's SPI4 pins on the expansion pins.
Additionally, this demo uses UART1 for the console
NOTES:
1. This configuration assumes an SST25VF064C 8Mbyte SPI FLASH is
connected to SPI4 on the following Discovery board Pins:
SCK: Port PE2 Board Connector P1, Pin 15
MOSI: Port PE6 Board Connector P1, Pin 11
MISO: Port PE5 Board Connector P1, Pin 14
CS: Port PE4 Board Connector P1, Pin 13
2. This configuration does have UART1 output enabled and set up as
the system logging device. To use this UART, you must add an
external RS-232 line driver to the UART1 pins of the DISCO board
on PA9 and PA10 of connector P1.
ostest:
------
This configuration directory, performs a simple OS test using
+110
View File
@@ -0,0 +1,110 @@
############################################################################
# configs/stm32f429i-disco/usbnsh/Make.defs
#
# Copyright (C) 2013 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}/.config
include ${TOPDIR}/tools/Config.mk
include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs
LDSCRIPT = ld.script
ifeq ($(WINTOOL),y)
# Windows-native toolchains
DIRLINK = $(TOPDIR)/tools/copydir.sh
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}"
MAXOPTIMIZATION = -O2
else
# Linux/Cygwin-native toolchain
MKDEP = $(TOPDIR)/tools/mkdeps.sh
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
endif
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E
LD = $(CROSSDEV)ld
AR = $(ARCROSSDEV)ar rcs
NM = $(ARCROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
else
ARCHOPTIMIZATION = $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
endif
ARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fno-rtti
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow
ARCHWARNINGSXX = -Wall -Wshadow
ARCHDEFINES =
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048
OBJEXT = .o
LIBEXT = .a
EXEEXT =
ifneq ($(CROSSDEV),arm-nuttx-elf-)
LDFLAGS += -nostartfiles -nodefaultlibs
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g
endif
HOSTCC = gcc
HOSTINCLUDES = -I.
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe
HOSTLDFLAGS =
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,77 @@
#!/bin/bash
# configs/stm32f429i-disco/usbnsh/setenv.sh
#
# Copyright (C) 2013 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.
#
if [ "$_" = "$0" ] ; then
echo "You must source this script, not run it!" 1>&2
exit 1
fi
WD=`pwd`
if [ ! -x "setenv.sh" ]; then
echo "This script must be executed from the top-level NuttX build directory"
exit 1
fi
if [ -z "${PATH_ORIG}" ]; then
export PATH_ORIG="${PATH}"
fi
# This is the Cygwin path to the location where I installed the RIDE
# toolchain under windows. You will also have to edit this if you install
# the RIDE toolchain in any other location
#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/Raisonance/Ride/arm-gcc/bin"
# This is the Cygwin path to the location where I installed the CodeSourcery
# toolchain under windows. You will also have to edit this if you install
# the CodeSourcery toolchain in any other location
#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/CodeSourcery/Sourcery G++ Lite/bin"
# These are the Cygwin paths to the locations where I installed the Atollic
# toolchain under windows. You will also have to edit this if you install
# the Atollic toolchain in any other location. /usr/bin is added before
# the Atollic bin path because there is are binaries named gcc.exe and g++.exe
# at those locations as well.
#export TOOLCHAIN_BIN="/usr/bin:/cygdrive/c/Program Files (x86)/Atollic/TrueSTUDIO for ARM Pro 2.3.0/ARMTools/bin"
#export TOOLCHAIN_BIN="/usr/bin:/cygdrive/c/Program Files (x86)/Atollic/TrueSTUDIO for STMicroelectronics STM32 Lite 2.3.0/ARMTools/bin"
# This is the Cygwin path to the location where I build the buildroot
# toolchain.
#export TOOLCHAIN_BIN="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin"
export TOOLCHAIN_BIN="/home/ken/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin"
# Add the path to the toolchain to the PATH varialble
export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}"
echo "PATH : ${PATH}"
+19 -3
View File
@@ -220,9 +220,15 @@
/* SPI - There is a MEMS device on SPI1 using these pins: */
#define GPIO_SPI1_MISO GPIO_SPI1_MISO_1
#define GPIO_SPI1_MOSI GPIO_SPI1_MOSI_1
#define GPIO_SPI1_SCK GPIO_SPI1_SCK_1
#define GPIO_SPI5_MISO GPIO_SPI5_MISO_1
#define GPIO_SPI5_MOSI GPIO_SPI5_MOSI_1
#define GPIO_SPI5_SCK GPIO_SPI5_SCK_1
/* SPI - External SPI flash may be connected on SPI4: */
#define GPIO_SPI4_MISO GPIO_SPI4_MISO_1
#define GPIO_SPI4_MOSI GPIO_SPI4_MOSI_1
#define GPIO_SPI4_SCK GPIO_SPI4_SCK_1
/* Timer Inputs/Outputs (see the README.txt file for options) */
@@ -232,6 +238,16 @@
#define GPIO_TIM8_CH1IN GPIO_TIM8_CH1IN_1
#define GPIO_TIM8_CH2IN GPIO_TIM8_CH2IN_1
/* LCD
*
* The STM32F429I-DISCO board contains an onboard TFT LCD connected to the
* LTDC interface of the uC. The LCD is 240x320 pixels. Define the parameters
* of the LCD and the interface here.
*/
#define BOARD_LTDC_WIDTH 240
#define BOARD_LTDC_HEIGHT 320
/************************************************************************************
* Public Data
************************************************************************************/
@@ -90,7 +90,15 @@
/* SPI chip selects */
#define GPIO_CS_MEMS (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN3)
GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN1)
#define GPIO_CS_LCD (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN2)
#define GPIO_LCD_DC (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN13)
#define GPIO_LCD_ENABLE (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN10)
#define GPIO_CS_SST25 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN4)
/* USB OTG HS
*
+2 -1
View File
@@ -75,7 +75,8 @@ void stm32_boardinitialize(void)
* stm32_spiinitialize() has been brought into the link.
*/
#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3)
#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3) ||\
defined(CONFIG_STM32_SPI4) || defined(CONFIG_STM32_SPI5)
if (stm32_spiinitialize)
{
stm32_spiinitialize();
+140 -2
View File
@@ -45,15 +45,26 @@
#include <debug.h>
#include <errno.h>
#ifdef CONFIG_STM32_SDIO
# include <nuttx/sdio.h>
#include <nuttx/kmalloc.h>
#ifdef CONFIG_STM32_SPI4
# include <nuttx/mmcsd.h>
#endif
#ifdef CONFIG_MTD_SST25XX
# include <nuttx/mtd/mtd.h>
#endif
#ifdef CONFIG_SYSTEM_USBMONITOR
# include <apps/usbmonitor.h>
#endif
#ifdef CONFIG_STM32F429I_DISCO_FLASH_CONFIG_PART
#ifdef CONFIG_PLATFORM_CONFIGDATA
# include <nuttx/configdata.h>
#endif
#endif
#ifdef CONFIG_STM32_OTGFS2
# include "stm32_usbhost.h"
#endif
@@ -138,6 +149,133 @@ int nsh_archinitialize(void)
#if defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR)
int ret;
#endif
#if defined(CONFIG_STM32_SPI5) || defined(CONFIG_STM32_SPI4)
FAR struct spi_dev_s *spi;
FAR struct mtd_dev_s *mtd;
#endif
/* Configure SPI-based devices */
#ifdef CONFIG_STM32_SPI4
/* Get the SPI port */
message("nsh_archinitialize: Initializing SPI port 4\n");
spi = up_spiinitialize(4);
if (!spi)
{
message("nsh_archinitialize: Failed to initialize SPI port 4\n");
return -ENODEV;
}
message("nsh_archinitialize: Successfully initialized SPI port 4\n");
/* Now bind the SPI interface to the SST25F064 SPI FLASH driver. This
* is a FLASH device that has been added external to the board (i.e.
* the board does not ship from STM with any on-board FLASH.
*/
#if defined(CONFIG_MTD) && defined(CONFIG_MTD_SST25XX)
message("nsh_archinitialize: Bind SPI to the SPI flash driver\n");
mtd = sst25xx_initialize(spi);
if (!mtd)
{
message("nsh_archinitialize: Failed to bind SPI port 4 to the SPI FLASH driver\n");
}
else
{
message("nsh_archinitialize: Successfully bound SPI port 4 to the SPI FLASH driver\n");
#ifdef CONFIG_STM32F429I_DISCO_FLASH_PART
{
int partno;
int partsize;
int partoffset;
const char *partstring = CONFIG_STM32F429I_DISCO_FLASH_PART_LIST;
const char *ptr;
FAR struct mtd_dev_s *mtd_part;
char partname[4];
/* Now create a partition on the FLASH device */
partno = 0;
ptr = partstring;
partoffset = 0;
while (*ptr != '\0')
{
/* Get the partition size */
partsize = atoi(ptr);
mtd_part = mtd_partition(mtd, partoffset, (partsize>>2) * 16);
partoffset += (partsize >> 2) * 16;
#ifdef CONFIG_STM32F429I_DISCO_FLASH_CONFIG_PART
/* Test if this is the config partition */
if (CONFIG_STM32F429I_DISCO_FLASH_CONFIG_PART_NUMBER == partno)
{
/* Register the partition as the config device */
mtdconfig_register(mtd_part);
}
else
#endif
{
/* Now initialize a SMART Flash block device and bind it
* to the MTD device.
*/
#if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS)
sprintf(partname, "p%d", partno);
smart_initialize(CONFIG_STM32F429I_DISCO_FLASH_MINOR, mtd_part, partname);
#endif
}
/* Update the pointer to point to the next size in the list */
while ((*ptr >= '0') && (*ptr <= '9'))
{
ptr++;
}
if (*ptr == ',')
{
ptr++;
}
/* Increment the part number */
partno++;
}
}
#else /* CONFIG_STM32F429I_DISCO_FLASH_PART */
/* Configure the device with no partition support */
smart_initialize(CONFIG_STM32F429I_DISCO_FLASH_MINOR, mtd, NULL);
#endif /* CONFIG_STM32F429I_DISCO_FLASH_PART */
}
#endif /* CONFIG_MTD */
#endif /* CONFIG_STM32_SPI4 */
/* Create a RAM MTD device if configured */
#if defined(CONFIG_RAMMTD) && defined(CONFIG_STM32F429I_DISCO_RAMMTD)
{
uint8_t *start = (uint8_t *) kmalloc(CONFIG_STM32F429I_DISCO_RAMMTD_SIZE * 1024);
mtd = rammtd_initialize(start, CONFIG_STM32F429I_DISCO_RAMMTD_SIZE * 1024);
mtd->ioctl(mtd, MTDIOC_BULKERASE, 0);
/* Now initialize a SMART Flash block device and bind it to the MTD device */
#if defined(CONFIG_MTD_SMART) && defined(CONFIG_FS_SMARTFS)
smart_initialize(CONFIG_STM32F429I_DISCO_RAMMTD_MINOR, mtd, NULL);
#endif
}
#endif /* CONFIG_RAMMTD && CONFIG_STM32F429I_DISCO_RAMMTD */
#ifdef HAVE_USBHOST
/* Initialize USB host operation. stm32_usbhost_initialize() starts a thread
+80 -44
View File
@@ -53,7 +53,8 @@
#include "stm32.h"
#include "stm32f429i-disco-internal.h"
#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3)
#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3) ||\
defined(CONFIG_STM32_SPI4) || defined(CONFIG_STM32_SPI5)
/************************************************************************************
* Definitions
@@ -89,28 +90,25 @@
* Name: stm32_spiinitialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the stm32fr29i-disco board.
* Called to configure SPI chip select GPIO pins for the stm32f429i-disco board.
*
************************************************************************************/
void weak_function stm32_spiinitialize(void)
{
#ifdef CONFIG_STM32_SPI1
#ifdef CONFIG_STM32_SPI5
(void)stm32_configgpio(GPIO_CS_MEMS); /* MEMS chip select */
(void)stm32_configgpio(GPIO_CS_LCD); /* LCD chip select */
(void)stm32_configgpio(GPIO_LCD_DC); /* LCD Data/Command select */
(void)stm32_configgpio(GPIO_LCD_ENABLE); /* LCD enable select */
#endif
#if defined(CONFIG_LCD_UG2864AMBAG01) || defined(CONFIG_LCD_UG2864HSWEG01)
(void)stm32_configgpio(GPIO_OLED_CS); /* OLED chip select */
# if defined(CONFIG_LCD_UG2864AMBAG01)
(void)stm32_configgpio(GPIO_OLED_A0); /* OLED Command/Data */
# endif
# if defined(CONFIG_LCD_UG2864HSWEG01)
(void)stm32_configgpio(GPIO_OLED_DC); /* OLED Command/Data */
# endif
#if defined(CONFIG_STM32_SPI4) && defined(CONFIG_MTD_SST25XX)
(void)stm32_configgpio(GPIO_CS_SST25); /* SST25 FLASH chip select */
#endif
}
/****************************************************************************
* Name: stm32_spi1/2/3select and stm32_spi1/2/3status
* Name: stm32_spi1/2/3/4/5select and stm32_spi1/2/3/4/5status
*
* Description:
* The external functions, stm32_spi1/2/3select and stm32_spi1/2/3status must be
@@ -138,17 +136,6 @@ void weak_function stm32_spiinitialize(void)
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 defined(CONFIG_LCD_UG2864AMBAG01) || defined(CONFIG_LCD_UG2864HSWEG01)
if (devid == SPIDEV_DISPLAY)
{
stm32_gpiowrite(GPIO_OLED_CS, !selected);
}
else
#endif
{
stm32_gpiowrite(GPIO_CS_MEMS, !selected);
}
}
uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
@@ -181,6 +168,47 @@ uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
}
#endif
#ifdef CONFIG_STM32_SPI4
void stm32_spi4select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
#if defined(CONFIG_MTD_SST25XX)
if (devid == SPIDEV_FLASH)
{
stm32_gpiowrite(GPIO_CS_SST25, !selected);
}
#endif
}
uint8_t stm32_spi4status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
return 0;
}
#endif
#ifdef CONFIG_STM32_SPI5
void stm32_spi5select(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 defined(CONFIG_STM32_LTDC)
if (devid == SPIDEV_DISPLAY)
{
stm32_gpiowrite(GPIO_CS_LCD, !selected);
}
else
#endif
{
stm32_gpiowrite(GPIO_CS_MEMS, !selected);
}
}
uint8_t stm32_spi5status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
return 0;
}
#endif
/****************************************************************************
* Name: stm32_spi1cmddata
*
@@ -208,27 +236,6 @@ uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
#ifdef CONFIG_STM32_SPI1
int stm32_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
{
#if defined(CONFIG_LCD_UG2864AMBAG01) || defined(CONFIG_LCD_UG2864HSWEG01)
if (devid == SPIDEV_DISPLAY)
{
/* "This is the Data/Command control pad which determines whether the
* data bits are data or a command.
*
* A0 = "H": the inputs at D0 to D7 are treated as display data.
* A0 = "L": the inputs at D0 to D7 are transferred to the command
* registers."
*/
# if defined(CONFIG_LCD_UG2864AMBAG01)
(void)stm32_gpiowrite(GPIO_OLED_A0, !cmd);
# endif
# if defined(CONFIG_LCD_UG2864HSWEG01)
(void)stm32_gpiowrite(GPIO_OLED_DC, !cmd);
# endif
return OK;
}
#endif
return -ENODEV;
}
#endif
@@ -246,6 +253,35 @@ int stm32_spi3cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
return -ENODEV;
}
#endif
#ifdef CONFIG_STM32_SPI4
int stm32_spi4cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
{
return -ENODEV;
}
#endif
#ifdef CONFIG_STM32_SPI5
int stm32_spi5cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
{
#if defined(CONFIG_STM32_LTDC)
if (devid == SPIDEV_DISPLAY)
{
/* "This is the Data/Command control pad which determines whether the
* data bits are data or a command.
*/
# if defined(CONFIG_STM32_LTDC)
(void)stm32_gpiowrite(GPIO_LCD_DC, !cmd);
# endif
return OK;
}
#endif
return -ENODEV;
}
#endif
#endif /* CONFIG_SPI_CMDDATA */
#endif /* CONFIG_STM32_SPI1 || CONFIG_STM32_SPI2 */