configs/stm32f103-minimum: Add board support for MAX7219 LED Matrix controller
This commit is contained in:
parent
829e6520e3
commit
ab9e059735
@ -101,6 +101,10 @@ ifeq ($(CONFIG_SENSORS_HCSR04),y)
|
|||||||
CSRCS += stm32_hcsr04.c
|
CSRCS += stm32_hcsr04.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_LCD_MAX7219),y)
|
||||||
|
CSRCS += stm32_max7219.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_LCD_ST7567),y)
|
ifeq ($(CONFIG_LCD_ST7567),y)
|
||||||
CSRCS += stm32_lcd.c
|
CSRCS += stm32_lcd.c
|
||||||
endif
|
endif
|
||||||
|
127
configs/stm32f103-minimum/src/stm32_max7219.c
Normal file
127
configs/stm32f103-minimum/src/stm32_max7219.c
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* config/stm32f103-minimum/src/stm32_max7219.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 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 <stdio.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <debug.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/board.h>
|
||||||
|
#include <nuttx/spi/spi.h>
|
||||||
|
#include <nuttx/lcd/lcd.h>
|
||||||
|
#include <nuttx/lcd/max7219.h>
|
||||||
|
|
||||||
|
#include "stm32_gpio.h"
|
||||||
|
#include "stm32_spi.h"
|
||||||
|
#include "stm32f103_minimum.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_NX_LCDDRIVER
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define LCD_SPI_PORTNO 1 /* On SPI1 */
|
||||||
|
|
||||||
|
#ifndef CONFIG_LCD_CONTRAST
|
||||||
|
# define CONFIG_LCD_CONTRAST 60
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
FAR struct spi_dev_s *g_spidev;
|
||||||
|
FAR struct lcd_dev_s *g_lcddev;
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_lcd_initialize
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int board_lcd_initialize(void)
|
||||||
|
{
|
||||||
|
g_spidev = stm32_spibus_initialize(LCD_SPI_PORTNO);
|
||||||
|
|
||||||
|
if (!g_spidev)
|
||||||
|
{
|
||||||
|
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_lcd_getdev
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
FAR struct lcd_dev_s *board_lcd_getdev(int lcddev)
|
||||||
|
{
|
||||||
|
g_lcddev = max7219_initialize(g_spidev, lcddev);
|
||||||
|
if (!g_lcddev)
|
||||||
|
{
|
||||||
|
lcderr("ERROR: Failed to bind SPI port 1 to LCD %d: %d\n", lcddev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lcdinfo("SPI port 1 bound to LCD %d\n", lcddev);
|
||||||
|
|
||||||
|
return g_lcddev;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_lcd_uninitialize
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void board_lcd_uninitialize(void)
|
||||||
|
{
|
||||||
|
/* TO-FIX */
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_NX_LCDDRIVER */
|
@ -86,6 +86,10 @@ void stm32_spidev_initialize(void)
|
|||||||
(void)stm32_configgpio(GPIO_CS_MFRC522); /* MFRC522 chip select */
|
(void)stm32_configgpio(GPIO_CS_MFRC522); /* MFRC522 chip select */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_LCD_MAX7219
|
||||||
|
(void)stm32_configgpio(STM32_LCD_CS); /* MAX7219 chip select */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_LCD_ST7567
|
#ifdef CONFIG_LCD_ST7567
|
||||||
(void)stm32_configgpio(STM32_LCD_CS); /* ST7567 chip select */
|
(void)stm32_configgpio(STM32_LCD_CS); /* ST7567 chip select */
|
||||||
#endif
|
#endif
|
||||||
@ -146,6 +150,13 @@ void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_LCD_MAX7219
|
||||||
|
if (devid == SPIDEV_DISPLAY(0))
|
||||||
|
{
|
||||||
|
stm32_gpiowrite(STM32_LCD_CS, !selected);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_LCD_PCD8544
|
#ifdef CONFIG_LCD_PCD8544
|
||||||
if (devid == SPIDEV_DISPLAY(0))
|
if (devid == SPIDEV_DISPLAY(0))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user