diff --git a/configs/freedom-kl25z/include/board.h b/configs/freedom-kl25z/include/board.h index 61ee317b87..1c9b33e1af 100644 --- a/configs/freedom-kl25z/include/board.h +++ b/configs/freedom-kl25z/include/board.h @@ -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 ************************************************************************************/ diff --git a/configs/freedom-kl25z/src/Makefile b/configs/freedom-kl25z/src/Makefile index 6592a86e73..f9fffab870 100644 --- a/configs/freedom-kl25z/src/Makefile +++ b/configs/freedom-kl25z/src/Makefile @@ -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) diff --git a/configs/freedom-kl25z/src/kl_nsh.c b/configs/freedom-kl25z/src/kl_nsh.c index c5476f55cc..f17f523072 100644 --- a/configs/freedom-kl25z/src/kl_nsh.c +++ b/configs/freedom-kl25z/src/kl_nsh.c @@ -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; } diff --git a/configs/freedom-kl25z/src/up_pwm.c b/configs/freedom-kl25z/src/kl_pwm.c similarity index 99% rename from configs/freedom-kl25z/src/up_pwm.c rename to configs/freedom-kl25z/src/kl_pwm.c index ffe9089011..1fbb07c320 100644 --- a/configs/freedom-kl25z/src/up_pwm.c +++ b/configs/freedom-kl25z/src/kl_pwm.c @@ -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 diff --git a/configs/freedom-kl25z/src/kl_spi.c b/configs/freedom-kl25z/src/kl_spi.c index 9d7a194a55..35d5989886 100644 --- a/configs/freedom-kl25z/src/kl_spi.c +++ b/configs/freedom-kl25z/src/kl_spi.c @@ -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