configs/omnibusf4: Add MAX7546 support.
This commit is contained in:
parent
a31fc4c5b6
commit
324d51eaae
@ -31,6 +31,8 @@ CONFIG_DEV_GPIO=y
|
||||
CONFIG_DEV_URANDOM=y
|
||||
CONFIG_DEV_ZERO=y
|
||||
CONFIG_DISABLE_POLL=y
|
||||
CONFIG_DRIVERS_VIDEO=y
|
||||
CONFIG_EXAMPLES_DFU=y
|
||||
CONFIG_EXAMPLES_HELLO=y
|
||||
CONFIG_EXAMPLES_HELLOXX=y
|
||||
CONFIG_EXAMPLES_LEDS=y
|
||||
@ -97,6 +99,7 @@ CONFIG_STM32_PWM_MULTICHAN=y
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_SPI1=y
|
||||
CONFIG_STM32_SPI2=y
|
||||
CONFIG_STM32_SPI3=y
|
||||
CONFIG_STM32_TIM10=y
|
||||
CONFIG_STM32_TIM12=y
|
||||
CONFIG_STM32_TIM1=y
|
||||
@ -133,4 +136,5 @@ CONFIG_USBDEV_MAXPOWER=500
|
||||
CONFIG_USERLED=y
|
||||
CONFIG_USERLED_LOWER=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
CONFIG_VIDEO_MAX7456=y
|
||||
CONFIG_WQUEUE_NOTIFIER=y
|
||||
|
@ -45,6 +45,10 @@ ifeq ($(CONFIG_SENSORS_MPU60X0),y)
|
||||
CSRCS += stm32_mpu6000.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_VIDEO_MAX7456),y)
|
||||
CSRCS += stm32_max7456.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SCHED_CRITMONITOR),y)
|
||||
CSRCS += stm32_critmon.c
|
||||
endif
|
||||
|
@ -74,6 +74,12 @@
|
||||
GPIO_OPENDRAIN | GPIO_PORTC | GPIO_PIN4)
|
||||
#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 ***************************************************************/
|
||||
|
||||
/* PC5 OTG_FS_VBUS VBUS sensing */
|
||||
|
@ -78,6 +78,22 @@
|
||||
# include "stm32_rtc.h"
|
||||
#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
|
||||
****************************************************************************/
|
||||
@ -216,7 +232,6 @@ int stm32_bringup(void)
|
||||
#ifdef CONFIG_SENSORS_MPU60X0
|
||||
/* Initialize the MPU6000 device. */
|
||||
|
||||
int stm32_mpu6000_initialize(void);
|
||||
ret = stm32_mpu6000_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -224,6 +239,17 @@ int stm32_bringup(void)
|
||||
}
|
||||
#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
|
||||
/* Register the LED driver */
|
||||
|
||||
|
106
configs/omnibusf4/src/stm32_max7456.c
Normal file
106
configs/omnibusf4/src/stm32_max7456.c
Normal 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);
|
||||
}
|
@ -55,7 +55,8 @@
|
||||
|
||||
#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
|
||||
@ -72,12 +73,15 @@
|
||||
void weak_function stm32_spidev_initialize(void)
|
||||
{
|
||||
#ifdef CONFIG_STM32_SPI1
|
||||
stm32_configgpio(GPIO_CS_MPU6000);
|
||||
stm32_configgpio(GPIO_EXTI_MPU6000);
|
||||
stm32_configgpio(GPIO_CS_MPU6000);
|
||||
stm32_configgpio(GPIO_EXTI_MPU6000);
|
||||
#endif
|
||||
#ifdef CONFIG_STM32_SPI3
|
||||
stm32_configgpio(GPIO_CS_MAX7456);
|
||||
#endif
|
||||
#if defined(CONFIG_MMCSD_SPI)
|
||||
(void)stm32_configgpio(GPIO_MMCSD_NCD); /* SD_DET */
|
||||
(void)stm32_configgpio(GPIO_MMCSD_NSS); /* CS */
|
||||
(void)stm32_configgpio(GPIO_MMCSD_NCD); /* SD_DET */
|
||||
(void)stm32_configgpio(GPIO_MMCSD_NSS); /* CS */
|
||||
#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)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
#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,
|
||||
bool selected)
|
||||
{
|
||||
/* Note: I don't know what is on SPI3 yet. */
|
||||
|
||||
spiinfo("devid: %d %s\n",
|
||||
(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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user