Freedom-KL25Z: Add board specific code to interface with ADXL345 driver. From Alan Carvalho de Assis

This commit is contained in:
Gregory Nutt 2014-12-16 07:48:22 -06:00
parent a9774a3171
commit b0d219b090
5 changed files with 30 additions and 2 deletions

View File

@ -211,10 +211,16 @@
#define PIN_SPI1_MOSI (PIN_SPI0_MOSI_7 | PIN_ALT2_PULLUP)
/* These pins are used by CC3000 module */
#define GPIO_WIFI_EN (GPIO_OUTPUT | GPIO_OUTPUT_ZER0 | PIN_PORTC | PIN12)
#define GPIO_WIFI_IRQ (GPIO_INPUT | PIN_PORTA | PIN16)
#define GPIO_WIFI_CS (GPIO_OUTPUT | GPIO_OUTPUT_ONE | PIN_PORTE | PIN1)
/* Interrupt pin used by ADXL345 */
#define GPIO_ADXL345_INT1 (GPIO_INPUT | PIN_PORTA | PIN_INT_RISING | PIN4)
#define GPIO_ADXL345_CS (GPIO_OUTPUT | GPIO_OUTPUT_ONE | PIN_PORTD | PIN0)
/************************************************************************************
* Public Data
************************************************************************************/

View File

@ -71,7 +71,7 @@ CSRCS += kl_usb.c
endif
ifeq ($(CONFIG_PWM),y)
CSRCS += up_pwm.c
CSRCS += kl_pwm.c
endif
ifeq ($(CONFIG_QENCODER),y)
@ -86,6 +86,10 @@ ifeq ($(CONFIG_NSH_LIBRARY),y)
CSRCS += kl_nsh.c
endif
ifeq ($(CONFIG_INPUT_ADXL345),y)
CSRCS += kl_adxl345.c
endif
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)

View File

@ -70,6 +70,15 @@
int nsh_archinitialize(void)
{
#if defined(CONFIG_INPUT_ADXL345)
int ret;
ret = adxl345_archinitialize(0);
if (ret < 0)
{
dbg("ERROR: adxl345_archinitialize failed: %d\n", ret);
}
#endif
return OK;
}

View File

@ -1,5 +1,5 @@
/************************************************************************************
* configs/freedom-kl25z/src/up_pwm.c
* configs/freedom-kl25z/src/kl_pwm.c
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>

View File

@ -94,6 +94,7 @@ void weak_function kl_spiinitialize(void)
/* Configure SPI0 chip selects */
#ifdef CONFIG_KL_SPI0
kl_configgpio(GPIO_ADXL345_CS);
#endif
/* Configure SPI1 chip selects */
@ -161,6 +162,14 @@ void kl_spi0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
{
spivdbg("devid: %d CS: %s\n",
(int)devid, selected ? "assert" : "de-assert");
if (devid == SPIDEV_GSENSOR)
{
/* Active low */
kl_gpiowrite(GPIO_ADXL345_CS, !selected);
}
}
#endif