~configs/xmc4500-relax: Add support to MAX6675 on XMC4500-Relax board. drivers/sensors/max6675.c: Increases SPI frequency from 400Khz to 4MHz.

This commit is contained in:
Alan Carvalho de Assis 2018-06-16 13:48:19 -06:00 committed by Gregory Nutt
parent 61a026dedd
commit 5fb988bdc8
6 changed files with 54 additions and 3 deletions

View File

@ -162,3 +162,24 @@ Configurations
Application Configuration:
CONFIG_NSH_BUILTIN_APPS=y : Enable starting apps from NSH command line
SPI
===
Using MAX6675 Thermocouple
--------------------------
There is a board support to use a MAX6675 connected to SPI2. In other to use
it you need to enable these options:
CONFIG_XMC4_USIC=y
CONFIG_XMC4_USCI_UART=y
CONFIG_XMC4_USCI_SPI=y
CONFIG_XMC4_SPI2=y
CONFIG_XMC4_USIC1=y
CONFIG_XMC4_USIC1_CHAN0_ISSPI=y
CONFIG_XMC4_USIC1_CHAN1_ISUART=y
CONFIG_UART3_SERIAL_CONSOLE=y
CONFIG_SENSORS_MAX6675=y
These are the used SPI pins: SCLK = P0.11, MISO = P0.4 and CS = P0.2

View File

@ -52,6 +52,10 @@ ifeq ($(CONFIG_XMC4_USCI_SPI),y)
CSRCS += xmc4_spi.c
endif
ifeq ($(CONFIG_SENSORS_MAX6675),y)
CSRCS += xmc4_max6675.c
endif
ifeq ($(CONFIG_LIB_BOARDCTL),y)
CSRCS += xmc4_appinit.c
endif

View File

@ -76,6 +76,12 @@
#define GPIO_BUTTON2 (GPIO_INPUT | GPIO_PINCTRL_SOFTWARE | \
GPIO_PORT1 | GPIO_PIN15)
/* SPIs Chip select */
#define GPIO_CS_MAX6675 (GPIO_OUTPUT | GPIO_OUTPUT_PUSHPULL | \
GPIO_PADA1P_STRONGSOFT | GPIO_PINCTRL_SOFTWARE | \
GPIO_OUTPUT_SET | GPIO_PORT0 | GPIO_PIN2)
/****************************************************************************
* Public Types
****************************************************************************/

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <debug.h>
/****************************************************************************
* Pre-processor Definitions
@ -63,5 +64,15 @@
int xmc4_bringup(void)
{
return OK;
int ret = OK;
#ifdef CONFIG_SENSORS_MAX6675
ret = xmc4_max6675initialize("/dev/temp0");
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: stm32_max6675initialize failed: %d\n", ret);
}
#endif
return ret;
}

View File

@ -75,7 +75,8 @@ void weak_function xmc4_spidev_initialize(void)
/* Configure SPI2 chip selects */
#ifdef CONFIG_XMC4_SPI2
#ifdef CONFIG_XMC4_SPI2 && defined(CONFIG_SENSORS_MAX6675)
(void)xmc4_gpio_config(GPIO_CS_MAX6675);
#endif
/* Configure SPI3 chip selects */
@ -161,6 +162,14 @@ void xmc4_spi2select(FAR struct spi_dev_s *dev, uint32_t devid,
{
spiinfo("devid: %d CS: %s\n",
(int)devid, selected ? "assert" : "de-assert");
#if defined(CONFIG_SENSORS_MAX6675)
if (devid == SPIDEV_TEMPERATURE(0))
{
xmc4_gpio_write(GPIO_CS_MAX6675, !selected);
}
#endif
}
#endif

View File

@ -127,7 +127,7 @@ static void max6675_lock(FAR struct spi_dev_s *spi)
SPI_SETMODE(spi, SPIDEV_MODE0);
SPI_SETBITS(spi, 8);
(void)SPI_HWFEATURES(spi, 0);
SPI_SETFREQUENCY(spi, 400000);
SPI_SETFREQUENCY(spi, 4000000);
}
/****************************************************************************