configs/omnibusf4: Add MAX7546 support.

This commit is contained in:
Bill Gatliff 2019-03-24 07:03:42 -06:00 committed by Gregory Nutt
parent a31fc4c5b6
commit 324d51eaae
6 changed files with 161 additions and 9 deletions

View File

@ -31,6 +31,8 @@ CONFIG_DEV_GPIO=y
CONFIG_DEV_URANDOM=y CONFIG_DEV_URANDOM=y
CONFIG_DEV_ZERO=y CONFIG_DEV_ZERO=y
CONFIG_DISABLE_POLL=y CONFIG_DISABLE_POLL=y
CONFIG_DRIVERS_VIDEO=y
CONFIG_EXAMPLES_DFU=y
CONFIG_EXAMPLES_HELLO=y CONFIG_EXAMPLES_HELLO=y
CONFIG_EXAMPLES_HELLOXX=y CONFIG_EXAMPLES_HELLOXX=y
CONFIG_EXAMPLES_LEDS=y CONFIG_EXAMPLES_LEDS=y
@ -97,6 +99,7 @@ CONFIG_STM32_PWM_MULTICHAN=y
CONFIG_STM32_PWR=y CONFIG_STM32_PWR=y
CONFIG_STM32_SPI1=y CONFIG_STM32_SPI1=y
CONFIG_STM32_SPI2=y CONFIG_STM32_SPI2=y
CONFIG_STM32_SPI3=y
CONFIG_STM32_TIM10=y CONFIG_STM32_TIM10=y
CONFIG_STM32_TIM12=y CONFIG_STM32_TIM12=y
CONFIG_STM32_TIM1=y CONFIG_STM32_TIM1=y
@ -133,4 +136,5 @@ CONFIG_USBDEV_MAXPOWER=500
CONFIG_USERLED=y CONFIG_USERLED=y
CONFIG_USERLED_LOWER=y CONFIG_USERLED_LOWER=y
CONFIG_USER_ENTRYPOINT="nsh_main" CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_VIDEO_MAX7456=y
CONFIG_WQUEUE_NOTIFIER=y CONFIG_WQUEUE_NOTIFIER=y

View File

@ -45,6 +45,10 @@ ifeq ($(CONFIG_SENSORS_MPU60X0),y)
CSRCS += stm32_mpu6000.c CSRCS += stm32_mpu6000.c
endif endif
ifeq ($(CONFIG_VIDEO_MAX7456),y)
CSRCS += stm32_max7456.c
endif
ifeq ($(CONFIG_SCHED_CRITMONITOR),y) ifeq ($(CONFIG_SCHED_CRITMONITOR),y)
CSRCS += stm32_critmon.c CSRCS += stm32_critmon.c
endif endif

View File

@ -74,6 +74,12 @@
GPIO_OPENDRAIN | GPIO_PORTC | GPIO_PIN4) GPIO_OPENDRAIN | GPIO_PORTC | GPIO_PIN4)
#define DEVNODE_MPU6000 "/dev/imu0" #define DEVNODE_MPU6000 "/dev/imu0"
#define SPIPORT_MAX7456 3
#define SPIMINOR_MAX7456 0
#define GPIO_CS_MAX7456 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
GPIO_OUTPUT_SET | GPIO_PORTA | GPIO_PIN15)
#define DEVNODE_MAX7456 "/dev/osd0"
/* USB OTG FS ***************************************************************/ /* USB OTG FS ***************************************************************/
/* PC5 OTG_FS_VBUS VBUS sensing */ /* PC5 OTG_FS_VBUS VBUS sensing */

View File

@ -78,6 +78,22 @@
# include "stm32_rtc.h" # include "stm32_rtc.h"
#endif #endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef CONFIG_SENSORS_MPU60X0
/* Initialize the MPU6000 device. */
int stm32_mpu6000_initialize(void);
#endif
#ifdef CONFIG_VIDEO_MAX7456
/* Initialize the MAX7456 OSD device. */
int stm32_max7456_initialize(void);
#endif
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@ -216,7 +232,6 @@ int stm32_bringup(void)
#ifdef CONFIG_SENSORS_MPU60X0 #ifdef CONFIG_SENSORS_MPU60X0
/* Initialize the MPU6000 device. */ /* Initialize the MPU6000 device. */
int stm32_mpu6000_initialize(void);
ret = stm32_mpu6000_initialize(); ret = stm32_mpu6000_initialize();
if (ret < 0) if (ret < 0)
{ {
@ -224,6 +239,17 @@ int stm32_bringup(void)
} }
#endif #endif
#ifdef CONFIG_VIDEO_MAX7456
/* Initialize the MAX7456 OSD device. */
ret = stm32_max7456_initialize();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: stm32_max7456_initialize() failed: %d\n", ret);
}
#endif
#ifdef CONFIG_USERLED #ifdef CONFIG_USERLED
/* Register the LED driver */ /* Register the LED driver */

View File

@ -0,0 +1,106 @@
/****************************************************************************
* configs/omnibusf4/src/stm32_max7456.c
*
* Copyright (C) 2019 Bill Gatliff. All rights reserved.
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
* Author: Bill Gatliff <bgat@billgatliff.com>
* 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 <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spi/spi.h>
#include <nuttx/video/max7456.h>
#include "stm32_gpio.h"
#include "stm32_spi.h"
#include "omnibusf4.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_max7456_initialize
*
* Description:
*
* Initialize and register Omnibus F4's MAX7456 OSD chip. The wiring
* isn't configurable, but we use macros anyway because some of the
* values are referred to in more than one place. And also, because
* that's generally what NuttX does.
*
* In particular, the slave-select pin is defined by us, but
* controlled elsewhere as part of the SPI machinery. This is an odd
* thing in our case because nothing else is using the SPI port, but
* that's not the general presentation so I'm staying consistent
* with the pattern.
*
****************************************************************************/
int stm32_max7456_initialize(void)
{
int port = SPIPORT_MAX7456;
int minor = SPIMINOR_MAX7456;
int cs = GPIO_CS_MAX7456;
stm32_configgpio(GPIO_CS_MAX7456);
struct mx7_config_s config =
{
.spi_devid = minor,
};
UNUSED(cs);
/* Get the spi bus instance. */
struct spi_dev_s *spi = stm32_spibus_initialize(port);
if (spi == NULL)
{
return -ENODEV;
}
config.spi = spi;
/* Register the chip with the device driver. */
return max7456_register(DEVNODE_MAX7456, &config);
}

View File

@ -55,7 +55,8 @@
#include "omnibusf4.h" #include "omnibusf4.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)
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@ -72,12 +73,15 @@
void weak_function stm32_spidev_initialize(void) void weak_function stm32_spidev_initialize(void)
{ {
#ifdef CONFIG_STM32_SPI1 #ifdef CONFIG_STM32_SPI1
stm32_configgpio(GPIO_CS_MPU6000); stm32_configgpio(GPIO_CS_MPU6000);
stm32_configgpio(GPIO_EXTI_MPU6000); stm32_configgpio(GPIO_EXTI_MPU6000);
#endif
#ifdef CONFIG_STM32_SPI3
stm32_configgpio(GPIO_CS_MAX7456);
#endif #endif
#if defined(CONFIG_MMCSD_SPI) #if defined(CONFIG_MMCSD_SPI)
(void)stm32_configgpio(GPIO_MMCSD_NCD); /* SD_DET */ (void)stm32_configgpio(GPIO_MMCSD_NCD); /* SD_DET */
(void)stm32_configgpio(GPIO_MMCSD_NSS); /* CS */ (void)stm32_configgpio(GPIO_MMCSD_NSS); /* CS */
#endif #endif
} }
@ -120,7 +124,7 @@ void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid,
} }
uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
{ {
return 0; return 0;
} }
#endif #endif
@ -147,10 +151,12 @@ uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, uint32_t devid)
void stm32_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, void stm32_spi3select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected) bool selected)
{ {
/* Note: I don't know what is on SPI3 yet. */
spiinfo("devid: %d %s\n", spiinfo("devid: %d %s\n",
(int)devid, selected ? "assert" : "de-assert"); (int)devid, selected ? "assert" : "de-assert");
/* Note: MAX7456 CS is active-low. */
stm32_gpiowrite(GPIO_CS_MAX7456, selected ? 0 : 1);
} }
uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, uint32_t devid) uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, uint32_t devid)
{ {