Add nuttx to the system framework, which is 10.1.0

This commit is contained in:
TangYiwen123
2021-06-09 14:34:06 +08:00
parent 804bd57aa0
commit b907bfab1c
5000 changed files with 1621317 additions and 0 deletions
@@ -0,0 +1,7 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
if ARCH_BOARD_FREEDOM_KL25Z
endif
@@ -0,0 +1,361 @@
README.txt
==========
This is the README file for the port of NuttX to the Freescale Freedom KL25Z
board. This board has the MKL25Z128 chip with a built-in SDA debugger.
Contents
========
- Development Environment
- GNU Toolchain Options
- NuttX Buildroot Toolchain
- LEDs
- Serial Console
- mbed
- Freedom KL25Z-specific Configuration Options
- Configurations
Development Environment
=======================
Either Linux or Cygwin under Windows can be used for the development environment.
The source has been built only using the GNU toolchain (see below). Other
toolchains will likely cause problems.
GNU Toolchain Options
=====================
As of this writing, all testing has been performed using the NuttX buildroot
toolchain described below. I have also verified the build using the
CodeSourcery GCC toolchain for windows. Most any contemporary EABI GCC
toolchain should work will a little tinkering.
NuttX Buildroot Toolchain
=========================
A GNU GCC-based toolchain is assumed. The PATH environment variable should
be modified to point to the correct path to the Cortex-M0 GCC toolchain (if
different from the default in your PATH variable).
If you have no Cortex-M0 toolchain, one can be downloaded from the NuttX
Bitbucket download site (https://bitbucket.org/nuttx/buildroot/downloads/).
This GNU toolchain builds and executes in the Linux or Cygwin environment.
1. You must have already configured NuttX in <some-dir>/nuttx.
tools/configure.sh freedom-kl25z:<sub-dir>
2. Download the latest buildroot package into <some-dir>
3. unpack the buildroot tarball. The resulting directory may
have versioning information on it like buildroot-x.y.z. If so,
rename <some-dir>/buildroot-x.y.z to <some-dir>/buildroot.
4. cd <some-dir>/buildroot
5. cp boards/cortexm0-eabi-defconfig-4.6.3 .config
6. make oldconfig
7. make
8. Make sure that the PATH variable includes the path to the newly built
binaries.
See the file boards/README.txt in the buildroot source tree. That has more
details PLUS some special instructions that you will need to follow if you are
building a Cortex-M0 toolchain for Cygwin under Windows.
LEDs
====
The Freedom KL25Z has a single RGB LED driven by the KL25Z as follows:
------------- --------
RGB LED KL25Z128
------------- --------
Red Cathode PTB18
Green Cathode PTB19
Blue Cathode PTD1
NOTE: PTD1 is also connected to the I/O header on J2 pin 10 (also known as D13).
If CONFIG_ARCH_LEDs is defined, then NuttX will control the LED on board the
Freedom KL25Z. The following definitions describe how NuttX controls the LEDs:
SYMBOL Meaning LED state
Initially all LED is OFF
------------------- ----------------------- --------------------------
LED_STARTED NuttX has been started R=OFF G=OFF B=OFF
LED_HEAPALLOCATE Heap has been allocated (no change)
LED_IRQSENABLED Interrupts enabled (no change)
LED_STACKCREATED Idle stack created R=OFF G=OFF B=ON
LED_INIRQ In an interrupt (no change)
LED_SIGNAL In a signal handler (no change)
LED_ASSERTION An assertion failed (no change)
LED_PANIC The system has crashed R=FLASHING G=OFF B=OFF
LED_IDLE K25Z1XX is in sleep mode (Optional, not used)
Serial Console
==============
As with most NuttX configurations, the Freedom KL25Z configurations
depend on having a serial console to interact with the software. The
Freedom KL25Z, however, has no on-board RS-232 drivers so will be
necessary to connect the Freedom KL25Z UART pins to an external
RS-232 driver board or TTL-to-Serial USB adaptor.
By default UART0 is used as the serial console on this boards. The UART0
is configured to work with the OpenSDA USB CDC/ACM port:
------ ------------------------------- -----------------------------
PIN PIN FUNCTIONS BOARD SIGNALS
------ ------------------------------- -----------------------------
Pin 27 PTA1/TSI0_CH2/UART0_RX/FTM2_CH0 UART1_RX_TGTMCU and D0 (PTA1)
Pin 28 PTA2/TSI0_CH3/UART0_TX/FTM2_CH1 UART1_TX_TGTMCU and D1 (PTA2)
But the UART0 Tx/Rx signals are also available on J1:
---------------- ---------
UART0 SIGNAL J1 pin
---------------- ---------
UART0_RX (PTA1) J1, pin 2
UART0_TX (PTA2) J1, pin 4
Ground is available on J2 pin 14. 3.3V is available on J3 and J4.
mbed
====
The Freedom KL25Z includes a built-in SDA debugger. An alternative
to the SDA bootloader is this boot loader from mbed:
http://mbed.org/handbook/mbed-FRDM-KL25Z-Getting-Started
http://mbed.org/handbook/Firmware-FRDM-KL25Z
Using the mbed loader:
1. Connect the KL25Z to the host PC using the USB connector labeled
SDA.
2. A new file system will appear called MBED; open it with Windows
Explorer (assuming that you are using Windows).
3. Drag and drop nuttx.bin into the MBED window. This will load the
nuttx.bin binary into the KL25Z. The MBED window will close
then re-open and the KL25Z will be running the new code.
Using the Freescale SDA debugger is essentially the same. That
debugger will also accept .hex file.
Freedom KL25Z-specific Configuration Options
============================================
CONFIG_ARCH - Identifies the arch/ subdirectory. This should
be set to:
CONFIG_ARCH=arm
CONFIG_ARCH_family - For use in C code:
CONFIG_ARCH_ARM=y
CONFIG_ARCH_architecture - For use in C code:
CONFIG_ARCH_CORTEXM0=y
CONFIG_ARCH_CHIP - Identifies the arch/*/chip subdirectory
CONFIG_ARCH_CHIP=kl
CONFIG_ARCH_CHIP_name - For use in C code to identify the exact
chip:
CONFIG_ARCH_CHIP_MKL25Z128=y
CONFIG_ARCH_BOARD - Identifies the boards/ subdirectory and
hence, the board that supports the particular chip or SoC.
CONFIG_ARCH_BOARD=freedom-kl25z (for the Freescale FRDM-KL25Z development board)
CONFIG_ARCH_BOARD_name - For use in C code
CONFIG_ARCH_BOARD_FREEDOM_K25Z128=y
CONFIG_ARCH_LOOPSPERMSEC - Must be calibrated for correct operation
of delay loops
CONFIG_ENDIAN_BIG - define if big endian (default is little
endian)
CONFIG_RAM_SIZE - Describes the installed DRAM (SRAM in this case):
CONFIG_RAM_SIZE=16384 (16Kb)
CONFIG_RAM_START - The start address of installed DRAM
CONFIG_RAM_START=0x20000000
CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to boards that
have LEDs
CONFIG_ARCH_INTERRUPTSTACK - This architecture supports an interrupt
stack. If defined, this symbol is the size of the interrupt
stack in bytes. If not defined, the user task stacks will be
used during interrupt handling.
CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to board architecture.
Individual subsystems can be enabled as follows. These settings are for
all of the K25Z100/120 line and may not be available for the MKL25Z128
in particular:
AHB
---
CONFIG_KL_PDMA Peripheral DMA
CONFIG_KL_FMC Flash memory
CONFIG_KL_EBI External bus interface
APB1
----
CONFIG_KL_WDT Watchdog timer
CONFIG_KL_RTC Real time clock (RTC)
CONFIG_KL_TMR0 Timer0
CONFIG_KL_TMR1 Timer1
CONFIG_KL_I2C0 I2C interface
CONFIG_KL_SPI0 SPI0 master/slave
CONFIG_KL_SPI1 SPI1 master/slave
CONFIG_KL_PWM0 PWM0
CONFIG_KL_PWM1 PWM1
CONFIG_KL_PWM2 PWM2
CONFIG_KL_PWM3 PWM3
CONFIG_KL_UART0 UART0
CONFIG_KL_USBD USB 2.0 FS device controller
CONFIG_KL_ACMP Analog comparator
CONFIG_KL_ADC Analog-digital-converter (ADC)
APB2
---
CONFIG_KL_PS2 PS/2 interface
CONFIG_KL_TIMR2 Timer2
CONFIG_KL_TIMR3 Timer3
CONFIG_KL_I2C1 I2C1 interface
CONFIG_KL_SPI2 SPI2 master/slave
CONFIG_KL_SPI3 SPI3 master/slave
CONFIG_KL_PWM4 PWM4
CONFIG_KL_PWM5 PWM5
CONFIG_KL_PWM6 PWM6
CONFIG_KL_PWM7 PWM7
CONFIG_KL_UART1 UART1
CONFIG_KL_UART2 UART2
CONFIG_KL_I2S I2S interface
K25Z1XX specific device driver settings
CONFIG_UARTn_SERIAL_CONSOLE - Selects the UARTn (n=0,1,2) for the
console and ttys0.
CONFIG_UARTn_RXBUFSIZE - Characters are buffered as received.
This specific the size of the receive buffer for UARTn.
CONFIG_UARTn_TXBUFSIZE - Characters are buffered before
being sent. This specific the size of the transmit buffer
for UARTn.
CONFIG_UARTn_BAUD - The configure BAUD of UARTn,
CONFIG_UARTn_BITS - The number of bits. Must be 5, 6, 7, or 8.
CONFIG_UARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity
CONFIG_UARTn_2STOP - Two stop bits
Configurations
==============
Each FREEDOM-KL25Z configuration is maintained in a sub-directory and
can be selected as follow:
tools/configure.sh freedom-kl25z:<subdir>
If this is a Windows native build, then configure.bat should be used
instead of configure.sh:
configure.bat freedom-kl25z\<subdir>
Where <subdir> is one of the following:
nsh:
---
Configures the NuttShell (nsh) located at apps/examples/nsh. The
Configuration enables the serial interface on UART0. Support for
builtin applications is disabled.
NOTES:
1. This configuration uses the mconf-based configuration tool. To
change this configuration using that tool, you should:
a. Build and install the kconfig-mconf tool. See nuttx/README.txt
see additional README.txt files in the NuttX tools repository.
b. Execute 'make menuconfig' in nuttx/ in order to start the
reconfiguration process.
2. By default, this configuration uses the ARM EABI toolchain
for Windows and builds under Cygwin (or probably MSYS). That
can easily be reconfigured, of course.
CONFIG_HOST_WINDOWS=y : Builds under Windows
CONFIG_WINDOWS_CYGWIN=y : Using Cygwin
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows
3. Serial Console. A serial console is necessary to interrupt with
NSH. The serial console is configured on UART0 which is available
on J1:
---------------- ---------
UART0 SIGNAL J1 pin
---------------- ---------
UART0_RX (PTA1) J1, pin 2
UART0_TX (PTA2) J1, pin 4
Ground is available on J2 pin 14. 3.3V is available on J3 and J4.
It is possible to configure NSH to use a USB serial console instead
of an RS-232 serial console. However, that configuration has not
been impelmented as of this writing.
4. Memory Usage. The size command gives us the static memory usage.
This is what I get:
$ size nuttx
text data bss dec hex filename
35037 106 1092 36235 8d8b nuttx
And we can get the runtime memory usage from the NSH free command:
NuttShell (NSH) NuttX-6.25
nsh> free
total used free largest
Mem: 14160 3944 10216 10216
nsh>
Summary:
- This slightly tuned NSH example uses 34.2KB of FLASH leaving 93.8KB
of FLASH (72%) free from additional application development.
I did not do all of the arithmetic, but it appears to me that of this
34+KB of FLASH usage, probably 20-30% of the FLASH is used by libgcc!
libgcc has gotten very fat!
- Static SRAM usage is about 1.2KB (<4%).
- At run time, 10.0KB of SRAM (62%) is still available for additional
applications. Most of the memory used at runtime is allocated I/O
buffers and the stack for the NSH main thread (1.5KB).
There is probably enough free memory to support 3 or 4 application
threads in addition to NSH.
5. This configurations has support for NSH built-in applications. However,
in the default configuration no built-in applications are enabled.
@@ -0,0 +1,66 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_NSH_DISABLEBG is not set
# CONFIG_NSH_DISABLE_CMP is not set
# CONFIG_NSH_DISABLE_EXEC is not set
# CONFIG_NSH_DISABLE_EXIT is not set
# CONFIG_NSH_DISABLE_HEXDUMP is not set
# CONFIG_NSH_DISABLE_PS is not set
# CONFIG_NSH_DISABLE_XD is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="freedom-kl25z"
CONFIG_ARCH_BOARD_FREEDOM_KL25Z=y
CONFIG_ARCH_CHIP="kl"
CONFIG_ARCH_CHIP_KL=y
CONFIG_ARCH_CHIP_MKL25Z128=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARD_LOOPSPERMSEC=2988
CONFIG_BUILTIN=y
CONFIG_DEFAULT_SMALL=y
CONFIG_DISABLE_MOUNTPOINT=y
CONFIG_DISABLE_MQUEUE=y
CONFIG_EXAMPLES_PWM=y
CONFIG_KL_TPM0=y
CONFIG_KL_TPM0_PWM=y
CONFIG_KL_UART0=y
CONFIG_LIB_BOARDCTL=y
CONFIG_MAX_TASKS=8
CONFIG_MM_SMALL=y
CONFIG_MOTOROLA_SREC=y
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_DISABLE_CD=y
CONFIG_NSH_DISABLE_CP=y
CONFIG_NSH_DISABLE_MKDIR=y
CONFIG_NSH_DISABLE_MOUNT=y
CONFIG_NSH_DISABLE_RM=y
CONFIG_NSH_DISABLE_RMDIR=y
CONFIG_NSH_DISABLE_UMOUNT=y
CONFIG_NSH_FILEIOSIZE=64
CONFIG_NSH_LINELEN=80
CONFIG_NUNGET_CHARS=0
CONFIG_PREALLOC_TIMERS=0
CONFIG_PTHREAD_STACK_DEFAULT=1536
CONFIG_PWM=y
CONFIG_RAM_SIZE=16384
CONFIG_RAM_START=0x1FFFF000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=26
CONFIG_START_MONTH=2
CONFIG_START_YEAR=2013
CONFIG_STDIO_DISABLE_BUFFERING=y
CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=1536
CONFIG_TLS_NELEM=0
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USERMAIN_STACKSIZE=1536
CONFIG_USER_ENTRYPOINT="nsh_main"
@@ -0,0 +1,267 @@
/****************************************************************************
* boards/arm/kl/freedom-kl25z/include/board.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_KL_FREEDOM_KL25Z_INCLUDE_BOARD_H
#define __BOARDS_ARM_KL_FREEDOM_KL25Z_INCLUDE_BOARD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Clocking *****************************************************************/
/* The Kwikstik-K40 has a 4MHz crystal on board */
#undef BOARD_EXTCLOCK /* Crystal */
#define BOARD_XTAL_FREQ 8000000 /* 8MHz crystal frequency (REFCLK) */
#define BOARD_XTAL32_FREQ 32768 /* 32KHz RTC Oscillator */
/* PLL Configuration.
*
* PLL Input frequency: PLLIN = REFCLK / PRDIV0 = 8MHz / 2 = 4MHz
* PLL Output frequency: PLLOUT = PLLIN * VDIV0 = 4Mhz * 24 = 96MHz
* MCGPLLCLK Frequency: MCGPLLCLK = 96MHz
*/
#define BOARD_PRDIV0 2 /* PLL External Reference Divider */
#define BOARD_VDIV0 24 /* PLL VCO Divider (frequency multiplier) */
#define BOARD_PLLIN_FREQ (BOARD_XTAL_FREQ / BOARD_PRDIV0)
#define BOARD_PLLOUT_FREQ (BOARD_PLLIN_FREQ * BOARD_VDIV0)
#define BOARD_MCGPLLCLK_FREQ BOARD_PLLOUT_FREQ
/* MCGOUTCLK: MCG output of either IRC, MCGFLLCLK, MCGPLLCLK, or MCG's
* external reference clock that sources the core, system, bus, and
* flash clock.
*
* MCGOUTCLK = MCGPLLCLK = 96MHz
*/
#define BOARD_MCGOUTCLK_FREQ BOARD_MCGPLLCLK_FREQ
/* SIM CLKDIV1 dividers.
*
* Core/system clock
* MCGOUTCLK divided by OUTDIV1, clocks the ARM Cortex-M0+ core
*
* Bus clock
* System clock divided by OUTDIV4, clocks the bus slaves and peripherals.
*/
#define BOARD_OUTDIV1 2 /* Core/system = MCGOUTCLK / 2, 48MHz */
#define BOARD_OUTDIV4 2 /* Bus clock = System clock / 2, 24MHz */
#define BOARD_CORECLK_FREQ (BOARD_MCGOUTCLK_FREQ / BOARD_OUTDIV1)
#define BOARD_BUSCLK_FREQ (BOARD_CORECLK_FREQ / BOARD_OUTDIV4)
/* SDHC clocking ************************************************************/
/* SDCLK configurations corresponding to various modes of operation.
* Formula is:
*
* SDCLK frequency = (base clock) / (prescaler * divisor)
*
* The SDHC module is always configure configured so that the core clock is
* the base clock.
*/
/* Identification mode: 400KHz = 96MHz / ( 16 * 15) */
#define BOARD_SDHC_IDMODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV16
#define BOARD_SDHC_IDMODE_DIVISOR SDHC_SYSCTL_DVS_DIV(15)
/* MMC normal mode: 16MHz = 96MHz / (2 * 3) */
#define BOARD_SDHC_MMCMODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
#define BOARD_SDHC_MMCMODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
/* SD normal mode (1-bit): 16MHz = 96MHz / (2 * 3) */
#define BOARD_SDHC_SD1MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
#define BOARD_SDHC_SD1MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
/* SD normal mode (4-bit): 24MHz = 96MHz / (2 * 2) (with DMA)
* SD normal mode (4-bit): 16MHz = 96MHz / (2 * 3) (no DMA)
*/
#ifdef CONFIG_SDIO_DMA
# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(2)
#else
/* # define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2 */
/* # define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3) */
# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV16
# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(15)
#endif
/* PWM Configuration */
/* TPM0 Channels */
#define GPIO_TPM0_CH0OUT PIN_TPM0_CH0_3 /* PIN_TPM0_CH0_1 */
#define GPIO_TPM0_CH1OUT PIN_TPM0_CH1_1
#define GPIO_TPM0_CH2OUT PIN_TPM0_CH2_1
#define GPIO_TPM0_CH3OUT PIN_TPM0_CH3_1
#define GPIO_TPM0_CH4OUT PIN_TPM0_CH4_1
#define GPIO_TPM0_CH5OUT PIN_TPM0_CH5_1
/* TPM1 Channels */
#define GPIO_TPM1_CH0OUT PIN_TPM1_CH0_1
#define GPIO_TPM1_CH1OUT PIN_TPM1_CH1_1
/* TPM2 Channels */
#define GPIO_TPM2_CH0OUT PIN_TPM2_CH0_1
#define GPIO_TPM2_CH1OUT PIN_TPM2_CH1_1
/* LED definitions **********************************************************/
/* The Freedom KL25Z has a single RGB LED driven by the KL25Z as follows:
*
* ------------- --------
* RGB LED KL25Z128
* ------------- --------
* Red Cathode PTB18
* Green Cathode PTB19
* Blue Cathode PTD1
*
* NOTE:
* PTD1 is also connected to the I/O header on J2 pin 10
* (also known as D13).
*
* If CONFIG_ARCH_LEDs is defined, then NuttX will control the LED on board
* the Freedom KL25Z.
* The following definitions describe how NuttX controls the LEDs:
*
* SYMBOL Meaning LED state
* Initially all LED is OFF
* ------------------- ----------------------- --------------------------
* LED_STARTED NuttX has been started R=OFF G=OFF B=OFF
* LED_HEAPALLOCATE Heap has been allocated (no change)
* LED_IRQSENABLED Interrupts enabled (no change)
* LED_STACKCREATED Idle stack created R=OFF G=OFF B=ON
* LED_INIRQ In an interrupt (no change)
* LED_SIGNAL In a signal handler (no change)
* LED_ASSERTION An assertion failed (no change)
* LED_PANIC The system has crashed R=FLASHING G=OFF B=OFF
* LED_IDLE K25Z1XX is in sleep mode (Optional, not used)
*/
#define LED_STARTED 0
#define LED_HEAPALLOCATE 1
#define LED_IRQSENABLED 2
#define LED_STACKCREATED 3
#define LED_INIRQ 4
#define LED_SIGNAL 5
#define LED_ASSERTION 6
#define LED_PANIC 7
/* Button definitions *******************************************************/
/* The Freedom KL25Z board has no standard GPIO contact buttons */
/* Alternative pin resolution ***********************************************/
/* If there are alternative configurations for various pins in the
* k25z128_pinmux.h header file, those alternative pins will be labeled with
* a suffix like _1, _2, etc. The logic in this file must select the correct
* pin configuration for the board by defining a pin configuration
* (with no suffix) that maps to the correct alternative.
*/
/* SPI0 Pinout
* ===========
*
* SCK = PTD1 (D13 at connector J2 pin 12 of Freedom Board)
* MISO = PTD3 (D12 at connector J2 pin 10 of Freedom Board)
* MOSI = PTD2 (D11 at connector J2 pin 8 of Freedom Board)
*/
#define PIN_SPI0_SCK (PIN_SPI0_SCK_3 | PIN_ALT2_PULLUP)
#define PIN_SPI0_MISO (PIN_SPI0_MISO_6 | PIN_ALT2_PULLUP)
#define PIN_SPI0_MOSI (PIN_SPI0_MOSI_5 | PIN_ALT2_PULLUP)
#define PIN_SPI1_SCK (PIN_SPI1_SCK_2 | PIN_ALT2_PULLUP)
#define PIN_SPI1_MISO (PIN_SPI1_MISO_3 | PIN_ALT2_PULLUP)
#define PIN_SPI1_MOSI (PIN_SPI0_MOSI_7 | PIN_ALT2_PULLUP)
/* Interrupt pin used by ADXL345
*
* CS = PTD0 (D10 at connector J2 pin 6 of Freedom Board)
* INT1 = PTA16 (at connector J2 pin 9 of Freedom Board)
*/
#define GPIO_ADXL345_INT1 (GPIO_INPUT | PIN_PORTA | PIN_INT_RISING | PIN16)
#define GPIO_ADXL345_CS (GPIO_OUTPUT | GPIO_OUTPUT_ONE | PIN_PORTD | PIN0)
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: kl_tsi_initialize
*
* Description:
* Initialize the TSI hardware and interface for the sliders on board the
* Freedom KL25Z board.
* Register a character driver at /dev/tsi that may be used to read from
* each sensor.
*
****************************************************************************/
#ifdef CONFIG_KL_TSI
void kl_tsi_initialize(void);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_KL_FREEDOM_KL25Z_INCLUDE_BOARD_H */
@@ -0,0 +1,63 @@
############################################################################
# boards/arm/kl/freedom-kl25z/scripts/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/.config
include $(TOPDIR)/tools/Config.mk
include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs
LDSCRIPT = freedom-kl25z.ld
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
else
ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
endif
ARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048
ifneq ($(CROSSDEV),arm-nuttx-elf-)
LDFLAGS += -nostartfiles -nodefaultlibs
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g
endif
@@ -0,0 +1,121 @@
/****************************************************************************
* boards/arm/kl/freedom-kl25z/scripts/freedom-kl25z.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* The MKL25Z128 has 128Kb of FLASH beginning at address 0x00000000 and
* 16Kb of SRAM at address 0x1ffff000.
*/
MEMORY
{
vectflash (rx) : ORIGIN = 0x00000000, LENGTH = 0x00c0
cfmprotect (rx) : ORIGIN = 0x00000400, LENGTH = 0x10
progflash (rx) : ORIGIN = 0x00000410, LENGTH = 128K - 0x410
datasram (rwx) : ORIGIN = 0x1ffff000, LENGTH = 16K
}
OUTPUT_ARCH(arm)
EXTERN(_vectors)
EXTERN(_cfmconfig)
ENTRY(_stext)
SECTIONS
{
.vectors : {
_svectors = ABSOLUTE(.);
*(.vectors)
_evectors = ABSOLUTE(.);
} > vectflash
.cfmprotect : {
*(.cfmconfig)
} > cfmprotect
.text : {
_stext = ABSOLUTE(.);
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > progflash
.init_section : {
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > progflash
.ARM.extab : {
*(.ARM.extab*)
} > progflash
.ARM.exidx : {
__exidx_start = ABSOLUTE(.);
*(.ARM.exidx*)
__exidx_end = ABSOLUTE(.);
} > progflash
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
. = ALIGN(4);
_edata = ABSOLUTE(.);
} > datasram AT > progflash
_eronly = LOADADDR(.data);
.ramfunc ALIGN(4): {
_sramfuncs = ABSOLUTE(.);
*(.ramfunc .ramfunc.*)
_eramfuncs = ABSOLUTE(.);
} > datasram AT > progflash
_framfuncs = LOADADDR(.ramfunc);
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_ebss = ABSOLUTE(.);
} > datasram
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}
@@ -0,0 +1,65 @@
############################################################################
# boards/arm/kl/freedom-kl25z/src/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/Make.defs
CSRCS = kl_boardinitialize.c
ifeq ($(CONFIG_LIB_BOARDCTL),y)
CSRCS += kl_appinit.c
endif
ifeq ($(CONFIG_KL_TSI),y)
CSRCS += kl_tsi.c
endif
ifeq ($(CONFIG_KL_SPI0),y)
CSRCS += kl_spi.c
else
ifeq ($(CONFIG_KL_SPI1),y)
CSRCS += kl_spi.c
endif
endif
ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += kl_led.c
endif
ifeq ($(CONFIG_KL_USBOTG),y)
CSRCS += kl_usb.c
endif
ifeq ($(CONFIG_PWM),y)
CSRCS += kl_pwm.c
endif
ifeq ($(CONFIG_SENSORS_QENCODER),y)
CSRCS += kl_qencoder.c
endif
ifeq ($(CONFIG_WATCHDOG),y)
CSRCS += kl_watchdog.c
endif
ifeq ($(CONFIG_SENSORS_ADXL345),y)
CSRCS += kl_adxl345.c
endif
include $(TOPDIR)/boards/Board.mk
@@ -0,0 +1,143 @@
/****************************************************************************
* boards/arm/kl/freedom-kl25z/src/freedom-kl25z.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_KL_FREEDOM_KL25Z_SRC_FREEDOM_KL25Z_H
#define __BOARDS_ARM_KL_FREEDOM_KL25Z_SRC_FREEDOM_KL25Z_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Freedom KL25Z GPIOs ******************************************************/
/* The Freedom KL25Z has a single RGB LED driven by the KL25Z as follows:
*
* ------------- --------
* RGB LED KL25Z128
* ------------- --------
* Red Cathode PTB18
* Green Cathode PTB19
* Blue Cathode PTD1
*
* NOTE:
* PTD1 is also connected to the I/O header on J2 pin 10 (also known as D13).
*
* If CONFIG_ARCH_LEDs is defined, then NuttX will control the LED on board
* the Freedom KL25Z.
* The following definitions describe how NuttX controls the LEDs:
*
* SYMBOL Meaning LED state
* Initially all LED is OFF
* ------------------- ----------------------- --------------------------
* LED_STARTED NuttX has been started
* LED_HEAPALLOCATE Heap has been allocated
* LED_IRQSENABLED Interrupts enabled
* LED_STACKCREATED Idle stack created
* LED_INIRQ In an interrupt
* LED_SIGNAL In a signal handler
* LED_ASSERTION An assertion failed
* LED_PANIC The system has crashed
* LED_IDLE K25Z1XX is in sleep mode (Optional, not used)
*/
#define GPIO_LED_R (GPIO_OUTPUT | GPIO_OUTPUT_ONE | PIN_PORTB | PIN18)
#define GPIO_LED_G (GPIO_OUTPUT | GPIO_OUTPUT_ONE | PIN_PORTB | PIN19)
#define GPIO_LED_B (GPIO_OUTPUT | GPIO_OUTPUT_ONE | PIN_PORTD | PIN1)
/* Button definitions *******************************************************/
/* The Freedom KL25Z has no buttons */
/* Chip selects *************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Functions Definitions
****************************************************************************/
/****************************************************************************
* Name: kl_spidev_initialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the Freedom KL25Z
* board.
*
****************************************************************************/
void weak_function kl_spidev_initialize(void);
/****************************************************************************
* Name: kl_usbinitialize
*
* Description:
* Called from kl_usbinitialize very early in inialization to setup
* USB-related GPIO pins for the Freedom KL25Z board.
*
****************************************************************************/
#ifdef CONFIG_STM32_USB
void weak_function kl_usbinitialize(void);
#endif
/****************************************************************************
* Name: kl_led_initialize
*
* Description:
* Initialize the on-board LED
*
****************************************************************************/
#ifdef CONFIG_ARCH_LEDS
void kl_led_initialize(void);
#endif
/****************************************************************************
* Name: kl_pwm_setup
*
* Description:
* Initialize PWM and register the PWM device.
*
****************************************************************************/
#ifdef CONFIG_PWM
int kl_pwm_setup(void);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_KL_FREEDOM_KL25Z_SRC_FREEDOM_KL25Z_H */
@@ -0,0 +1,297 @@
/****************************************************************************
* boards/arm/kl/freedom-kl25z/src/kl_adxl345.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/spi/spi.h>
#include <nuttx/sensors/adxl345.h>
#include <nuttx/irq.h>
#include "freedom-kl25z.h"
#include "kl_gpio.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifdef CONFIG_SENSORS_ADXL345
#ifndef CONFIG_KL_SPI0
# error "ADXL345 support requires CONFIG_KL_SPI0"
#endif
#ifndef CONFIG_ADXL345_SPI
# error "Only the ADXL345 SPI interface is supported"
#endif
#ifdef CONFIG_ADXL345_I2C
# error "Only the ADXL345 SPI interface is supported"
#endif
#ifndef CONFIG_ADXL345_FREQUENCY
# define CONFIG_ADXL345_FREQUENCY 500000
#endif
#ifndef CONFIG_ADXL345_SPIDEV
# define CONFIG_ADXL345_SPIDEV 0
#endif
#if CONFIG_ADXL345_SPIDEV != 0
# error "CONFIG_ADXL345_SPIDEV must be zero"
#endif
#ifndef CONFIG_ADXL345_DEVMINOR
# define CONFIG_ADXL345_DEVMINOR 0
#endif
/****************************************************************************
* Private Types
****************************************************************************/
struct kl_adxl345config_s
{
/* Configuration structure as seen by the ADXL345 driver */
struct adxl345_config_s config;
/* Additional private definitions only known to this driver */
ADXL345_HANDLE handle; /* The ADXL345 driver handle */
adxl345_handler_t handler; /* The ADXL345 interrupt handler */
FAR void *arg; /* Argument to pass to the interrupt handler */
};
/****************************************************************************
* Static Function Prototypes
****************************************************************************/
/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks
* to isolate the ADXL345 driver from differences in GPIO interrupt handling
* by varying boards and MCUs.
*
* attach - Attach the ADXL345 interrupt handler to the GPIO interrupt
* enable - Enable or disable the GPIO interrupt
* clear - Acknowledge/clear any pending GPIO interrupt
*/
static int adxl345_attach(FAR struct adxl345_config_s *state,
adxl345_handler_t handler, FAR void *arg);
static void adxl345_enable(FAR struct adxl345_config_s *state, bool enable);
static void adxl345_clear(FAR struct adxl345_config_s *state);
/****************************************************************************
* Private Data
****************************************************************************/
/* A reference to a structure of this type must be passed to the ADXL345
* driver. This structure provides information about the configuration
* of the ADXL345 and provides some board-specific hooks.
*
* Memory for this structure is provided by the caller. It is not copied
* by the driver and is presumed to persist while the driver is active. The
* memory must be writable because, under certain circumstances, the driver
* may modify frequency or X plate resistance values.
*/
static struct kl_adxl345config_s g_adxl345config =
{
.config =
{
#ifdef CONFIG_ADXL345_I2C
.address = ADXL345_ADDR1,
#endif
.frequency = CONFIG_ADXL345_FREQUENCY,
.attach = adxl345_attach,
.enable = adxl345_enable,
.clear = adxl345_clear,
},
};
/****************************************************************************
* Private Functions
****************************************************************************/
/* This is the ADXL345 Interrupt handler */
int adxl345_interrupt(int irq, FAR void *context)
{
/* Verify that we have a handler attached */
if (g_adxl345config.handler)
{
/* Yes.. forward with interrupt along with its argument */
g_adxl345config.handler(&g_adxl345config.config, g_adxl345config.arg);
}
return OK;
}
/* IRQ/GPIO access callbacks. These operations all hidden behind
* callbacks to isolate the ADXL345 driver from differences in GPIO
* interrupt handling by varying boards and MCUs.
*
* attach - Attach the ADXL345 interrupt handler to the GPIO interrupt
* enable - Enable or disable the GPIO interrupt
* clear - Acknowledge/clear any pending GPIO interrupt
*/
static int adxl345_attach(FAR struct adxl345_config_s *state,
adxl345_handler_t handler, FAR void *arg)
{
FAR struct kl_adxl345config_s *priv =
(FAR struct kl_adxl345config_s *)state;
sninfo("Saving handler %p\n", handler);
DEBUGASSERT(priv);
/* Just save the handler and its argument. We will use it when interrupts
* are enabled
*/
priv->handler = handler;
priv->arg = arg;
return OK;
}
static void adxl345_enable(FAR struct adxl345_config_s *state, bool enable)
{
FAR struct kl_adxl345config_s *priv =
(FAR struct kl_adxl345config_s *)state;
irqstate_t flags;
/* Attach and enable, or detach and disable. Enabling and disabling GPIO
* interrupts is a multi-step process so the safest thing is to keep
* interrupts disabled during the reconfiguration.
*/
flags = enter_critical_section();
if (enable)
{
/* Configure the interrupt using the SAVED handler */
kl_configgpio(GPIO_ADXL345_INT1);
kl_gpioirqattach(GPIO_ADXL345_INT1, adxl345_interrupt, NULL);
kl_gpioirqenable(GPIO_ADXL345_INT1);
}
else
{
/* Configure the interrupt with a NULL handler to disable it */
kl_gpioirqattach(GPIO_ADXL345_INT1, NULL, NULL);
kl_gpioirqdisable(GPIO_ADXL345_INT1);
}
leave_critical_section(flags);
}
static void adxl345_clear(FAR struct adxl345_config_s *state)
{
/* Does nothing */
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: adxl345_archinitialize
*
* Description:
* Each board that supports an adxl345 device must provide this function.
* This function is called by application-specific, setup logic to
* configure the accelerometer device. This function will register the
* driver as /dev/accelN where N is the minor device number.
*
* Input Parameters:
* minor - The input device minor number
*
* Returned Value:
* Zero is returned on success. Otherwise, a negated errno value is
* returned to indicate the nature of the failure.
*
****************************************************************************/
int adxl345_archinitialize(int minor)
{
FAR struct spi_dev_s *dev;
int ret;
sninfo("minor %d\n", minor);
DEBUGASSERT(minor == 0);
/* Check if we are already initialized */
if (!g_adxl345config.handle)
{
sninfo("Initializing\n");
/* Configure the ADXL345 interrupt pin as an input */
kl_configgpio(GPIO_ADXL345_INT1);
/* Get an instance of the I2C interface */
dev = kl_spibus_initialize(CONFIG_ADXL345_SPIDEV);
if (!dev)
{
snerr("ERROR: Failed to initialize SPI bus %d\n",
CONFIG_ADXL345_SPIDEV);
return -ENODEV;
}
/* Instantiate the ADXL345 driver */
g_adxl345config.handle =
adxl345_instantiate(dev,
(FAR struct adxl345_config_s *)&g_adxl345config);
if (!g_adxl345config.handle)
{
snerr("ERROR: Failed to instantiate the ADXL345 driver\n");
return -ENODEV;
}
/* Initialize and register the ADXL345 driver */
ret = adxl345_register(g_adxl345config.handle,
CONFIG_ADXL345_DEVMINOR);
if (ret < 0)
{
snerr("ERROR: Failed to register ADXL345 driver: %d\n", ret);
return ret;
}
}
return OK;
}
#endif /* CONFIG_SENSORS_ADXL345 */
@@ -0,0 +1,90 @@
/****************************************************************************
* boards/arm/kl/freedom-kl25z/src/kl_appinit.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdio.h>
#include <syslog.h>
#include <nuttx/board.h>
#include "freedom-kl25z.h"
#ifdef CONFIG_LIB_BOARDCTL
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_app_initialize
*
* Description:
* Perform architecture specific initialization
*
* Input Parameters:
* arg - The boardctl() argument is passed to the board_app_initialize()
* implementation without modification. The argument has no
* meaning to NuttX; the meaning of the argument is a contract
* between the board-specific initialization logic and the
* matching application logic. The value could be such things as a
* mode enumeration value, a set of DIP switch switch settings, a
* pointer to configuration data read from a file or serial FLASH,
* or whatever you would like to do with it. Every implementation
* should accept zero/NULL as a default configuration.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure to indicate the nature of the failure.
*
****************************************************************************/
int board_app_initialize(uintptr_t arg)
{
int ret;
#if defined(CONFIG_SENSORS_ADXL345)
ret = adxl345_archinitialize(0);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: adxl345_archinitialize failed: %d\n", ret);
}
#endif
#ifdef CONFIG_PWM
/* Initialize PWM and register the PWM device. */
ret = kl_pwm_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: k64_pwm_setup() failed: %d\n", ret);
}
#endif
UNUSED(ret);
return OK;
}
#endif /* CONFIG_LIB_BOARDCTL */
@@ -0,0 +1,116 @@
/****************************************************************************
* boards/arm/kl/freedom-kl25z/src/kl_boardinitialize.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "arm_arch.h"
#include "freedom-kl25z.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kl_boardinitialize
*
* Description:
* All K25Z architectures must provide the following entry point.
* This entry point is called early in the initialization -- after all
* memory has been configured and mapped but before any devices have been
* initialized.
*
****************************************************************************/
void kl_boardinitialize(void)
{
/* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak
* function kl_spidev_initialize() has been brought into the link.
*/
#if defined(CONFIG_KL_SPI0) || defined(CONFIG_KL_SPI1)
if (kl_spidev_initialize)
{
kl_spidev_initialize();
}
#endif
/* Initialize USB if the 1) USB device controller is in the configuration
* and 2) disabled, and 3) the weak function kl_usbinitialize() has been
* brought into the build. Presumably either CONFIG_USBHOST or
* CONFIG_USBDEV is also selected.
*/
#ifdef CONFIG_KL_USBOTG
if (kl_usbinitialize)
{
kl_usbinitialize();
}
#endif
/* Configure on-board LED if LED support has been selected. */
#ifdef CONFIG_ARCH_LEDS
kl_led_initialize();
#endif
}
/****************************************************************************
* Name: board_late_initialize
*
* Description:
* If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional
* initialization call will be performed in the boot-up sequence to a
* function called board_late_initialize(). board_late_initialize() will be
* called immediately after up_intitialize() is called and just before the
* initial application is started. This additional initialization phase
* may be used, for example, to initialize board-specific device drivers.
*
****************************************************************************/
#ifdef CONFIG_BOARD_LATE_INITIALIZE
void board_late_initialize(void)
{
/* Perform NSH initialization here instead of from the NSH. This
* alternative NSH initialization is necessary when NSH is ran in
* user-space but the initialization function must run in kernel space.
*/
#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_LIB_BOARDCTL)
board_app_initialize(0);
#endif
}
#endif
@@ -0,0 +1,132 @@
/****************************************************************************
* boards/arm/kl/freedom-kl25z/src/kl_led.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* The Freedom KL25Z has a single RGB LED driven by the KL25Z as follows:
*
* ------------- --------
* RGB LED KL25Z128
* ------------- --------
* Red Cathode PTB18
* Green Cathode PTB19
* Blue Cathode PTD1
*
* If CONFIG_ARCH_LEDs is defined, then NuttX will control the LED on board
* the Freedom KL25Z.
* The following definitions describe how NuttX controls the LEDs:
*
* SYMBOL Meaning LED state
* Initially all LED is OFF
* ------------------- ----------------------- --------------------------
* LED_STARTED NuttX has been started R=OFF G=OFF B=OFF
* LED_HEAPALLOCATE Heap has been allocated (no change)
* LED_IRQSENABLED Interrupts enabled (no change)
* LED_STACKCREATED Idle stack created R=OFF G=OFF B=ON
* LED_INIRQ In an interrupt (no change)
* LED_SIGNAL In a signal handler (no change)
* LED_ASSERTION An assertion failed (no change)
* LED_PANIC The system has crashed R=FLASHING G=OFF B=OFF
* LED_IDLE K25Z1XX is in sleep mode (Optional, not used)
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "chip.h"
#include "kl_gpio.h"
#include "freedom-kl25z.h"
#ifdef CONFIG_ARCH_LEDS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Dump GPIO registers */
#ifdef CONFIG_DEBUG_LEDS_INFO
# define led_dumpgpio(m) kl_dumpgpio(GPIO_LED_B, m)
#else
# define led_dumpgpio(m)
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kl_led_initialize
*
* Description:
* Initialize the on-board LED
*
****************************************************************************/
void kl_led_initialize(void)
{
kl_configgpio(GPIO_LED_R);
kl_configgpio(GPIO_LED_G);
kl_configgpio(GPIO_LED_B);
}
/****************************************************************************
* Name: board_autoled_on
****************************************************************************/
void board_autoled_on(int led)
{
if (led == LED_STACKCREATED)
{
kl_gpiowrite(GPIO_LED_R, true);
kl_gpiowrite(GPIO_LED_G, true);
kl_gpiowrite(GPIO_LED_B, false);
}
else if (led == LED_PANIC)
{
kl_gpiowrite(GPIO_LED_R, false);
kl_gpiowrite(GPIO_LED_G, true);
kl_gpiowrite(GPIO_LED_B, true);
}
}
/****************************************************************************
* Name: board_autoled_off
****************************************************************************/
void board_autoled_off(int led)
{
if (led == LED_PANIC)
{
kl_gpiowrite(GPIO_LED_R, true);
kl_gpiowrite(GPIO_LED_G, true);
kl_gpiowrite(GPIO_LED_B, true);
}
}
#endif /* CONFIG_ARCH_LEDS */
@@ -0,0 +1,107 @@
/****************************************************************************
* boards/arm/kl/freedom-kl25z/src/kl_pwm.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/timers/pwm.h>
#include <arch/board/board.h>
#include "chip.h"
#include "arm_arch.h"
#include "kl_pwm.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* PWM
*
* The Kinetis Freedom board provides a LED on GPIO.
*/
#ifdef CONFIG_PWM
extern struct pwm_lowerhalf_s *kl_pwminitialize(int timer);
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kl_pwm_setup
*
* Description:
* Initialize PWM and register the PWM device.
*
****************************************************************************/
int kl_pwm_setup(void)
{
static bool initialized = false;
struct pwm_lowerhalf_s *pwm;
int ret;
/* Have we already initialized? */
if (!initialized)
{
/* Call kl_pwminitialize() to get an instance of the PWM interface */
pwm = kl_pwminitialize(0);
if (!pwm)
{
aerr("ERROR: Failed to get the KL25 PWM lower half\n");
return -ENODEV;
}
/* Register the PWM driver at "/dev/pwm0" */
ret = pwm_register("/dev/pwm0", pwm);
if (ret < 0)
{
aerr("ERROR: pwm_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
}
return OK;
}
#endif /* CONFIG_PWM */
@@ -0,0 +1,209 @@
/****************************************************************************
* boards/arm/kl/freedom-kl25z/src/kl_spi.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/spi/spi.h>
#include "kl_gpio.h"
#include "kl_spi.h"
#include "freedom-kl25z.h"
#if defined(CONFIG_KL_SPI0) || defined(CONFIG_KL_SPI1)
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kl_spidev_initialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the FRDM-KL25Z board.
*
****************************************************************************/
void weak_function kl_spidev_initialize(void)
{
/* Configure SPI0 chip selects */
#ifdef CONFIG_KL_SPI0
# ifdef CONFIG_ADXL345_SPI
kl_configgpio(GPIO_ADXL345_CS);
#endif
#endif
/* Configure SPI1 chip selects */
#ifdef CONFIG_KL_SPI1
#endif
}
/****************************************************************************
* Name: kl_spi[n]select, kl_spi[n]status, and kl_spi[n]cmddata
*
* Description:
* These external functions must be provided by board-specific logic. They
* are implementations of the select, status, and cmddata methods of the
* SPI interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h).
* All other methods including kl_spibus_initialize()) are provided by
* common Kinetis logic. To use this common SPI logic on your board:
*
* 1. Provide logic in kl_boardinitialize() to configure SPI chip select
* pins.
* 2. Provide kl_spi[n]select() and kl_spi[n]status() functions
* in your board-specific logic. These functions will perform chip
* selection and status operations using GPIOs in the way your board
* is configured.
* 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
* kl_spi[n]cmddata() functions in your board-specific logic. These
* functions will perform cmd/data selection operations using GPIOs in
* the way your board is configured.
* 3. Add a call to kl_spibus_initialize() in your low level application
* initialization logic
* 4. The handle returned by kl_spibus_initialize() may then be used to
* bind the SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver).
*
****************************************************************************/
/****************************************************************************
* Name: kl_spi[n]select
*
* Description:
* PIO chip select pins may be programmed by the board specific logic in
* one of two different ways. First, the pins may be programmed as SPI
* peripherals. In that case, the pins are completely controlled by the
* SPI driver. This method still needs to be provided, but it may be only
* a stub.
*
* An alternative way to program the PIO chip select pins is as a normal
* GPIO output. In that case, the automatic control of the CS pins is
* bypassed and this function must provide control of the chip select.
* NOTE: In this case, the GPIO output pin does *not* have to be the
* same as the NPCS pin normal associated with the chip select number.
*
* Input Parameters:
* devid - Identifies the (logical) device
* selected - TRUE:Select the device, FALSE:De-select the device
*
* Returned Value:
* None
*
****************************************************************************/
#ifdef CONFIG_KL_SPI0
void kl_spi0select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n",
(int)devid, selected ? "assert" : "de-assert");
#ifdef CONFIG_ADXL345_SPI
if (devid == SPIDEV_ACCELEROMETER(0))
{
/* Active low */
kl_gpiowrite(GPIO_ADXL345_CS, !selected);
}
#endif
}
#endif
#ifdef CONFIG_KL_SPI1
void kl_spi1select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n",
(int)devid, selected ? "assert" : "de-assert");
}
#endif
/****************************************************************************
* Name: kl_spi[n]status
*
* Description:
* Return status information associated with the SPI device.
*
* Input Parameters:
* devid - Identifies the (logical) device
*
* Returned Value:
* Bit-encoded SPI status (see include/nuttx/spi/spi.h.
*
****************************************************************************/
#ifdef CONFIG_KL_SPI0
uint8_t kl_spi0status(FAR struct spi_dev_s *dev, uint32_t devid)
{
return 0;
}
#endif
#ifdef CONFIG_KL_SPI1
uint8_t kl_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
{
return 0;
}
#endif
/****************************************************************************
* Name: kl_spi[n]cmddata
*
* Description:
* Some SPI interfaces, particularly with LCDs, and an auxiliary 9th data
* input that determines where the other 8 data bits represent command or
* data. These interfaces control that CMD/DATA GPIO output
*
* Input Parameters:
* devid - Identifies the (logical) device
* cmd - Determines where command or data should be selected.
*
* Returned Value:
* Bit-encoded SPI status (see include/nuttx/spi/spi.h.
*
****************************************************************************/
#ifdef CONFIG_SPI_CMDDATA
#ifdef CONFIG_KL_SPI0
int kl_spi0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
return 0;
}
#endif
#ifdef CONFIG_KL_SPI1
int kl_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
return 0;
}
#endif
#endif
#endif /* CONFIG_KL_SPI */
@@ -0,0 +1,251 @@
/****************************************************************************
* boards/arm/kl/freedom-kl25z/src/kl_tsi.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* Reference:
* https://community.freescale.com/community/
* the-embedded-beat/blog/2012/10/15/
* using-the-touch-interface-on-the-freescale-freedom-development-platform
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/fs/fs.h>
#include "arm_arch.h"
#include "kl_gpio.h"
#include "hardware/kl_tsi.h"
#include "hardware/kl_pinmux.h"
#include "hardware/kl_sim.h"
#ifdef CONFIG_KL_TSI
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* The touchpad on the Freedom KL25Z board connects to the MCU via:
*
* PTB16 TWI0_CH9
* PTB17 TSI0_CH10
*/
#define NSENSORS 2
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static void tsi_calibrate(void);
static ssize_t tsi_read(FAR struct file *filep,
FAR char *buffer, size_t buflen);
/****************************************************************************
* Private Data
****************************************************************************/
static uint16_t g_defcap[NSENSORS]; /* Default capacitance for each sensor */
static uint16_t g_currdelta = 0; /* Current delta for the current button */
static uint8_t g_channel = 0; /* Current g_channel */
/* Channel assigned to each sensor */
static uint8_t const g_chsensor[NSENSORS] =
{
9, 10
};
/* Character driver operations */
static const struct file_operations tsi_ops =
{
0, /* open */
0, /* close */
tsi_read, /* read */
0, /* write */
0, /* seek */
0, /* ioctl */
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: tsi_calibrate
****************************************************************************/
static void tsi_calibrate(void)
{
uint32_t regval;
int i;
for (i = 0; i < NSENSORS; i++)
{
/* Clear end of scan flag */
regval = getreg32(KL_TSI_GENCS);
regval |= TSI_GENCS_EOSF;
putreg32(regval, KL_TSI_GENCS);
/* Scan the next electrode */
regval = TSI_DATA_TSICH(g_chsensor[i]);
putreg32(regval, KL_TSI_DATA);
regval |= TSI_DATA_SWTS;
putreg32(regval, KL_TSI_DATA);
/* Wait until the conversion is done */
while (!(getreg32(KL_TSI_GENCS) & TSI_GENCS_EOSF));
g_defcap[i] = getreg32(KL_TSI_DATA) & TSI_DATA_TSICNT_MASK;
iinfo("Sensor %d = %d\n", i + 1, g_defcap[i]);
}
}
/****************************************************************************
* Name: tsi_read
****************************************************************************/
static ssize_t tsi_read(FAR struct file *filep, FAR char *buf, size_t buflen)
{
static int deltacap = 0;
uint32_t regval;
if (buf == NULL || buflen < 1)
{
/* Well... nothing to do */
return -EINVAL;
}
deltacap = 0;
/* Clear end of scan flag */
regval = getreg32(KL_TSI_GENCS);
regval |= TSI_GENCS_EOSF;
putreg32(regval, KL_TSI_GENCS);
/* Scan the next electrode */
regval = TSI_DATA_TSICH(g_chsensor[g_channel]);
putreg32(regval, KL_TSI_DATA);
regval |= TSI_DATA_SWTS;
putreg32(regval, KL_TSI_DATA);
/* Wait until the conversion is done */
while (!(getreg32(KL_TSI_GENCS) & TSI_GENCS_EOSF));
/* Compute delta using calibration reference counts */
deltacap = getreg32(KL_TSI_DATA) & TSI_DATA_TSICNT_MASK;
deltacap -= g_defcap[g_channel];
if (deltacap < 0)
{
deltacap = 0;
}
g_currdelta = (uint16_t)deltacap;
iinfo("Delta for g_channel %d = %d\n", g_channel, g_currdelta);
buf[0] = g_currdelta & 0xff;
buf[1] = (g_currdelta & 0xff00) >> 8;
buf[2] = g_channel;
/* Increment the channel index to sample the next sensor on the next timer
* that read() is called.
*/
g_channel++;
if (g_channel >= NSENSORS)
{
g_channel = 0;
}
return 3;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kl_tsi_initialize
*
* Description:
* Initialize the TSI hardware and interface for the sliders on board the
* Freedom KL25Z board. Register a character driver at /dev/tsi that may
* be used to read from each sensor.
*
****************************************************************************/
void kl_tsi_initialize(void)
{
uint32_t regval;
/* Enable access to the TSI module */
regval = getreg32(KL_SIM_SCGC5);
regval |= SIM_SCGC5_TSI;
putreg32(regval, KL_SIM_SCGC5);
/* Configure PINs used on TSI */
kl_configgpio(PIN_TSI0_CH9);
kl_configgpio(PIN_TSI0_CH10);
/* Configure TSI parameter */
regval = getreg32(KL_TSI_GENCS);
regval |= TSI_GENCS_MODE_CAPSENSING | TSI_GENCS_REFCHRG_8UA |
TSI_GENCS_DVOLT_1p03V | TSI_GENCS_EXTCHRG_64A |
TSI_GENCS_PS_DIV16 | TSI_GENCS_NSCN_TIMES(12) | TSI_GENCS_STPE;
putreg32(regval, KL_TSI_GENCS);
/* Only after setting TSI we should enable it */
regval = getreg32(KL_TSI_GENCS);
regval |= TSI_GENCS_TSIEN;
putreg32(regval, KL_TSI_GENCS);
/* Calibrate it before to use */
tsi_calibrate();
/* And finally register the TSI character driver */
register_driver("/dev/tsi", &tsi_ops, 0444, NULL);
}
#endif /* CONFIG_KL_TSI */
@@ -0,0 +1,7 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
if ARCH_BOARD_FREEDOM_KL26Z
endif
@@ -0,0 +1,339 @@
README.txt
==========
This is the README file for the port of NuttX to the Freescale Freedom KL26Z
board. This board has the MKL26Z128 chip with a built-in SDA debugger.
Contents
========
- Development Environment
- GNU Toolchain Options
- NuttX Buildroot Toolchain
- LEDs
- Serial Console
- mbed
- Freedom KL26Z-specific Configuration Options
- Configurations
Development Environment
=======================
Either Linux or Cygwin under Windows can be used for the development environment.
The source has been built only using the GNU toolchain (see below). Other
toolchains will likely cause problems.
GNU Toolchain Options
=====================
As of this writing, all testing has been performed using the NuttX buildroot
toolchain described below. I have also verified the build using the
CodeSourcery GCC toolchain for windows. Most any contemporary EABI GCC
toolchain should work will a little tinkering.
NuttX Buildroot Toolchain
=========================
A GNU GCC-based toolchain is assumed. The PATH environment variable should
be modified to point to the correct path to the Cortex-M0 GCC toolchain (if
different from the default in your PATH variable).
If you have no Cortex-M0 toolchain, one can be downloaded from the NuttX
Bitbucket download site (https://bitbucket.org/nuttx/buildroot/downloads/).
This GNU toolchain builds and executes in the Linux or Cygwin environment.
1. You must have already configured NuttX in <some-dir>/nuttx.
tools/configure.sh freedom-kl26z:<sub-dir>
2. Download the latest buildroot package into <some-dir>
3. unpack the buildroot tarball. The resulting directory may
have versioning information on it like buildroot-x.y.z. If so,
rename <some-dir>/buildroot-x.y.z to <some-dir>/buildroot.
4. cd <some-dir>/buildroot
5. cp boards/cortexm0-eabi-defconfig-4.6.3 .config
6. make oldconfig
7. make
8. Make sure that the PATH variable includes the path to the newly built
binaries.
See the file boards/README.txt in the buildroot source tree. That has more
details PLUS some special instructions that you will need to follow if you are
building a Cortex-M0 toolchain for Cygwin under Windows.
LEDs
====
The Freedom KL26Z has a single RGB LED driven by the KL26Z as follows:
------------- --------
RGB LED KL26Z128
------------- --------
Red Cathode PTE29
Green Cathode PTE31
Blue Cathode PTD5
NOTE: PTD5 is also connected to the I/O header on J2 pin 12 (also known as D13).
If CONFIG_ARCH_LEDs is defined, then NuttX will control the LED on board the
Freedom KL26Z. The following definitions describe how NuttX controls the LEDs:
SYMBOL Meaning LED state
Initially all LED is OFF
------------------- ----------------------- --------------------------
LED_STARTED NuttX has been started R=OFF G=OFF B=OFF
LED_HEAPALLOCATE Heap has been allocated (no change)
LED_IRQSENABLED Interrupts enabled (no change)
LED_STACKCREATED Idle stack created R=OFF G=OFF B=ON
LED_INIRQ In an interrupt (no change)
LED_SIGNAL In a signal handler (no change)
LED_ASSERTION An assertion failed (no change)
LED_PANIC The system has crashed R=FLASHING G=OFF B=OFF
LED_IDLE K26Z1XX is in sleep mode (Optional, not used)
Serial Console
==============
As with most NuttX configurations, the Freedom KL26Z configurations
depend on having a serial console to interact with the software. The
Freedom KL26Z, however, has no on-board RS-232 drivers so will be
necessary to connect the Freedom KL26Z UART pins to an external
RS-232 driver board or TTL-to-Serial USB adaptor.
By default UART0 is used as the serial console on this boards. The UART0
is configured to work with the OpenSDA USB CDC/ACM port:
------ ------------------------------- -----------------------------
PIN PIN FUNCTIONS BOARD SIGNALS
------ ------------------------------- -----------------------------
Pin 27 PTA1/TSI0_CH2/UART0_RX/FTM2_CH0 UART1_RX_TGTMCU and D0 (PTA1)
Pin 28 PTA2/TSI0_CH3/UART0_TX/FTM2_CH1 UART1_TX_TGTMCU and D1 (PTA2)
But the UART0 Tx/Rx signals are also available on J1:
---------------- ---------
UART0 SIGNAL J1 pin
---------------- ---------
UART0_RX (PTA1) J1, pin 2
UART0_TX (PTA2) J1, pin 4
Ground is available on J2 pin 14. 3.3V is available on J3 and J4.
Freedom KL26Z-specific Configuration Options
============================================
CONFIG_ARCH - Identifies the arch/ subdirectory. This should
be set to:
CONFIG_ARCH=arm
CONFIG_ARCH_family - For use in C code:
CONFIG_ARCH_ARM=y
CONFIG_ARCH_architecture - For use in C code:
CONFIG_ARCH_CORTEXM0=y
CONFIG_ARCH_CHIP - Identifies the arch/*/chip subdirectory
CONFIG_ARCH_CHIP=kl
CONFIG_ARCH_CHIP_name - For use in C code to identify the exact
chip:
CONFIG_ARCH_CHIP_MKL26Z128=y
CONFIG_ARCH_BOARD - Identifies the boards/ subdirectory and
hence, the board that supports the particular chip or SoC.
CONFIG_ARCH_BOARD=freedom-kl26z (for the Freescale FRDM-KL26Z development board)
CONFIG_ARCH_BOARD_name - For use in C code
CONFIG_ARCH_BOARD_FREEDOM_K26Z128=y
CONFIG_ARCH_LOOPSPERMSEC - Must be calibrated for correct operation
of delay loops
CONFIG_ENDIAN_BIG - define if big endian (default is little
endian)
CONFIG_RAM_SIZE - Describes the installed DRAM (SRAM in this case):
CONFIG_RAM_SIZE=16384 (16Kb)
CONFIG_RAM_START - The start address of installed DRAM
CONFIG_RAM_START=0x20000000
CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to boards that
have LEDs
CONFIG_ARCH_INTERRUPTSTACK - This architecture supports an interrupt
stack. If defined, this symbol is the size of the interrupt
stack in bytes. If not defined, the user task stacks will be
used during interrupt handling.
CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to board architecture.
Individual subsystems can be enabled as follows. These settings are for
all of the K25Z100/120 line and may not be available for the MKL26Z128
in particular:
AHB
---
CONFIG_KL_PDMA Peripheral DMA
CONFIG_KL_FMC Flash memory
CONFIG_KL_EBI External bus interface
APB1
----
CONFIG_KL_WDT Watchdog timer
CONFIG_KL_RTC Real time clock (RTC)
CONFIG_KL_TMR0 Timer0
CONFIG_KL_TMR1 Timer1
CONFIG_KL_I2C0 I2C interface
CONFIG_KL_SPI0 SPI0 master/slave
CONFIG_KL_SPI1 SPI1 master/slave
CONFIG_KL_PWM0 PWM0
CONFIG_KL_PWM1 PWM1
CONFIG_KL_PWM2 PWM2
CONFIG_KL_PWM3 PWM3
CONFIG_KL_UART0 UART0
CONFIG_KL_USBD USB 2.0 FS device controller
CONFIG_KL_ACMP Analog comparator
CONFIG_KL_ADC Analog-digital-converter (ADC)
APB2
---
CONFIG_KL_PS2 PS/2 interface
CONFIG_KL_TIMR2 Timer2
CONFIG_KL_TIMR3 Timer3
CONFIG_KL_I2C1 I2C1 interface
CONFIG_KL_SPI2 SPI2 master/slave
CONFIG_KL_SPI3 SPI3 master/slave
CONFIG_KL_PWM4 PWM4
CONFIG_KL_PWM5 PWM5
CONFIG_KL_PWM6 PWM6
CONFIG_KL_PWM7 PWM7
CONFIG_KL_UART1 UART1
CONFIG_KL_UART2 UART2
CONFIG_KL_I2S I2S interface
K26Z1XX specific device driver settings
CONFIG_UARTn_SERIAL_CONSOLE - Selects the UARTn (n=0,1,2) for the
console and ttys0.
CONFIG_UARTn_RXBUFSIZE - Characters are buffered as received.
This specific the size of the receive buffer for UARTn.
CONFIG_UARTn_TXBUFSIZE - Characters are buffered before
being sent. This specific the size of the transmit buffer
for UARTn.
CONFIG_UARTn_BAUD - The configure BAUD of UARTn,
CONFIG_UARTn_BITS - The number of bits. Must be 5, 6, 7, or 8.
CONFIG_UARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity
CONFIG_UARTn_2STOP - Two stop bits
Configurations
==============
Each FREEDOM-KL26Z configuration is maintained in a sub-directory and
can be selected as follow:
tools/configure.sh freedom-kl26z:<subdir>
If this is a Windows native build, then configure.bat should be used
instead of configure.sh:
configure.bat freedom-kl26z\<subdir>
Where <subdir> is one of the following:
nsh:
---
Configures the NuttShell (nsh) located at apps/examples/nsh. The
Configuration enables the serial interface on UART0. Support for
builtin applications is disabled.
NOTES:
1. This configuration uses the mconf-based configuration tool. To
change this configuration using that tool, you should:
a. Build and install the kconfig-mconf tool. See nuttx/README.txt
see additional README.txt files in the NuttX tools repository.
b. Execute 'make menuconfig' in nuttx/ in order to start the
reconfiguration process.
2. By default, this configuration uses the ARM EABI toolchain
for Windows and builds under Cygwin (or probably MSYS). That
can easily be reconfigured, of course.
CONFIG_HOST_WINDOWS=y : Builds under Windows
CONFIG_WINDOWS_CYGWIN=y : Using Cygwin
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows
3. Serial Console. A serial console is necessary to interrupt with
NSH. The serial console is configured on UART0 which is available
on J1:
---------------- ---------
UART0 SIGNAL J1 pin
---------------- ---------
UART0_RX (PTA1) J1, pin 2
UART0_TX (PTA2) J1, pin 4
Ground is available on J2 pin 14. 3.3V is available on J3 and J4.
It is possible to configure NSH to use a USB serial console instead
of an RS-232 serial console. However, that configuration has not
been impelmented as of this writing.
4. Memory Usage. The size command gives us the static memory usage.
This is what I get:
$ size nuttx
text data bss dec hex filename
35037 106 1092 36235 8d8b nuttx
And we can get the runtime memory usage from the NSH free command:
NuttShell (NSH) NuttX-6.25
nsh> free
total used free largest
Mem: 14160 3944 10216 10216
nsh>
Summary:
- This slightly tuned NSH example uses 34.2KB of FLASH leaving 93.8KB
of FLASH (72%) free from additional application development.
I did not do all of the arithmetic, but it appears to me that of this
34+KB of FLASH usage, probably 20-30% of the FLASH is used by libgcc!
libgcc has gotten very fat!
- Static SRAM usage is about 1.2KB (<4%).
- At run time, 10.0KB of SRAM (62%) is still available for additional
applications. Most of the memory used at runtime is allocated I/O
buffers and the stack for the NSH main thread (1.5KB).
There is probably enough free memory to support 3 or 4 application
threads in addition to NSH.
5. This configurations has support for NSH built-in applications. However,
in the default configuration no built-in applications are enabled.
@@ -0,0 +1,66 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_NSH_DISABLEBG is not set
# CONFIG_NSH_DISABLE_CMP is not set
# CONFIG_NSH_DISABLE_EXEC is not set
# CONFIG_NSH_DISABLE_EXIT is not set
# CONFIG_NSH_DISABLE_HEXDUMP is not set
# CONFIG_NSH_DISABLE_PS is not set
# CONFIG_NSH_DISABLE_XD is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="freedom-kl26z"
CONFIG_ARCH_BOARD_FREEDOM_KL26Z=y
CONFIG_ARCH_CHIP="kl"
CONFIG_ARCH_CHIP_KL=y
CONFIG_ARCH_CHIP_MKL26Z128=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARD_LOOPSPERMSEC=2988
CONFIG_BUILTIN=y
CONFIG_DEFAULT_SMALL=y
CONFIG_DISABLE_MOUNTPOINT=y
CONFIG_DISABLE_MQUEUE=y
CONFIG_EXAMPLES_PWM=y
CONFIG_KL_TPM0=y
CONFIG_KL_TPM0_PWM=y
CONFIG_KL_UART0=y
CONFIG_LIB_BOARDCTL=y
CONFIG_MAX_TASKS=8
CONFIG_MM_SMALL=y
CONFIG_MOTOROLA_SREC=y
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_DISABLE_CD=y
CONFIG_NSH_DISABLE_CP=y
CONFIG_NSH_DISABLE_MKDIR=y
CONFIG_NSH_DISABLE_MOUNT=y
CONFIG_NSH_DISABLE_RM=y
CONFIG_NSH_DISABLE_RMDIR=y
CONFIG_NSH_DISABLE_UMOUNT=y
CONFIG_NSH_FILEIOSIZE=64
CONFIG_NSH_LINELEN=80
CONFIG_NUNGET_CHARS=0
CONFIG_PREALLOC_TIMERS=0
CONFIG_PTHREAD_STACK_DEFAULT=1536
CONFIG_PWM=y
CONFIG_RAM_SIZE=16384
CONFIG_RAM_START=0x1FFFF000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=26
CONFIG_START_MONTH=2
CONFIG_START_YEAR=2013
CONFIG_STDIO_DISABLE_BUFFERING=y
CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=1536
CONFIG_TLS_NELEM=0
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USERMAIN_STACKSIZE=1536
CONFIG_USER_ENTRYPOINT="nsh_main"
@@ -0,0 +1,257 @@
/****************************************************************************
* boards/arm/kl/freedom-kl26z/include/board.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_KL_FREEDOM_KL26Z_INCLUDE_BOARD_H
#define __BOARDS_ARM_KL_FREEDOM_KL26Z_INCLUDE_BOARD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Clocking *****************************************************************/
/* The KL26Z has an 8MHz crystal on board */
#undef BOARD_EXTCLOCK /* Crystal */
#define BOARD_XTAL_FREQ 8000000 /* 8MHz crystal frequency (REFCLK) */
#define BOARD_XTAL32_FREQ 32768 /* 32KHz RTC Oscillator */
/* PLL Configuration.
*
* PLL Input frequency: PLLIN = REFCLK / PRDIV0 = 8MHz / 2 = 4MHz
* PLL Output frequency: PLLOUT = PLLIN * VDIV0 = 4Mhz * 24 = 96MHz
* MCGPLLCLK Frequency: MCGPLLCLK = 96MHz
*/
#define BOARD_PRDIV0 2 /* PLL External Reference Divider */
#define BOARD_VDIV0 24 /* PLL VCO Divider (frequency multiplier) */
#define BOARD_PLLIN_FREQ (BOARD_XTAL_FREQ / BOARD_PRDIV0)
#define BOARD_PLLOUT_FREQ (BOARD_PLLIN_FREQ * BOARD_VDIV0)
#define BOARD_MCGPLLCLK_FREQ BOARD_PLLOUT_FREQ
/* MCGOUTCLK:
* MCG output of either IRC, MCGFLLCLK, MCGPLLCLK, or MCG's external
* reference clock that sources the core, system, bus, and flash clock.
*
* MCGOUTCLK = MCGPLLCLK = 96MHz
*/
#define BOARD_MCGOUTCLK_FREQ BOARD_MCGPLLCLK_FREQ
/* SIM CLKDIV1 dividers.
*
* Core/system clock
* MCGOUTCLK divided by OUTDIV1, clocks the ARM Cortex-M0+ core
*
* Bus clock
* System clock divided by OUTDIV4, clocks the bus slaves and peripherals.
*/
#define BOARD_OUTDIV1 2 /* Core/system = MCGOUTCLK / 2, 48MHz */
#define BOARD_OUTDIV4 2 /* Bus clock = System clock / 2, 24MHz */
#define BOARD_CORECLK_FREQ (BOARD_MCGOUTCLK_FREQ / BOARD_OUTDIV1)
#define BOARD_BUSCLK_FREQ (BOARD_CORECLK_FREQ / BOARD_OUTDIV4)
/* SDHC clocking ************************************************************/
/* SDCLK configurations corresponding to various modes of operation.
* Formula is:
*
* SDCLK frequency = (base clock) / (prescaler * divisor)
*
* The SDHC module is always configure configured so that the core clock is
* the base clock.
*/
/* Identification mode: 400KHz = 96MHz / ( 16 * 15) */
#define BOARD_SDHC_IDMODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV16
#define BOARD_SDHC_IDMODE_DIVISOR SDHC_SYSCTL_DVS_DIV(15)
/* MMC normal mode: 16MHz = 96MHz / (2 * 3) */
#define BOARD_SDHC_MMCMODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
#define BOARD_SDHC_MMCMODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
/* SD normal mode (1-bit): 16MHz = 96MHz / (2 * 3) */
#define BOARD_SDHC_SD1MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
#define BOARD_SDHC_SD1MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
/* SD normal mode (4-bit): 24MHz = 96MHz / (2 * 2) (with DMA)
* SD normal mode (4-bit): 16MHz = 96MHz / (2 * 3) (no DMA)
*/
#ifdef CONFIG_SDIO_DMA
# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(2)
#else
/* # define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2 */
/* # define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3) */
# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV16
# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(15)
#endif
/* PWM Configuration */
/* TPM0 Channels */
#define GPIO_TPM0_CH0OUT PIN_TPM0_CH0_3 //PIN_TPM0_CH0_1
#define GPIO_TPM0_CH1OUT PIN_TPM0_CH1_1
#define GPIO_TPM0_CH2OUT PIN_TPM0_CH2_1
#define GPIO_TPM0_CH3OUT PIN_TPM0_CH3_1
#define GPIO_TPM0_CH4OUT PIN_TPM0_CH4_1
#define GPIO_TPM0_CH5OUT PIN_TPM0_CH5_1
/* TPM1 Channels */
#define GPIO_TPM1_CH0OUT PIN_TPM1_CH0_1
#define GPIO_TPM1_CH1OUT PIN_TPM1_CH1_1
/* TPM2 Channels */
#define GPIO_TPM2_CH0OUT PIN_TPM2_CH0_1
#define GPIO_TPM2_CH1OUT PIN_TPM2_CH1_1
/* LED definitions **********************************************************/
/* The Freedom KL26Z has a single RGB LED driven by the KL26Z as follows:
*
* ------------- --------
* RGB LED KL26Z128
* ------------- --------
* Red Cathode PTBE29
* Green Cathode PTE31
* Blue Cathode PTD5
*
* NOTE:
* PTD5 is also connected to the I/O header on J2 pin 12 (also known as D13).
*
* If CONFIG_ARCH_LEDs is defined, then NuttX will control the LED on board
* the Freedom KL26Z.
* The following definitions describe how NuttX controls the LEDs:
*
* SYMBOL Meaning LED state
* Initially all LED is OFF
* ------------------- ----------------------- --------------------------
* LED_STARTED NuttX has been started R=OFF G=OFF B=OFF
* LED_HEAPALLOCATE Heap has been allocated (no change)
* LED_IRQSENABLED Interrupts enabled (no change)
* LED_STACKCREATED Idle stack created R=OFF G=OFF B=ON
* LED_INIRQ In an interrupt (no change)
* LED_SIGNAL In a signal handler (no change)
* LED_ASSERTION An assertion failed (no change)
* LED_PANIC The system has crashed R=FLASHING G=OFF B=OFF
* LED_IDLE K26Z1XX is in sleep mode (Optional, not used)
*/
#define LED_STARTED 0
#define LED_HEAPALLOCATE 1
#define LED_IRQSENABLED 2
#define LED_STACKCREATED 3
#define LED_INIRQ 4
#define LED_SIGNAL 5
#define LED_ASSERTION 6
#define LED_PANIC 7
/* Button definitions *******************************************************/
/* The Freedom KL26Z board has no standard GPIO contact buttons */
/* Alternative pin resolution ***********************************************/
/* If there are alternative configurations for various pins in the
* k26z128_pinmux.h header file, those alternative pins will be labeled with
* a suffix like _1, _2, etc.
* The logic in this file must select the correct pin configuration for the
* board by defining a pin configuration (with no suffix) that maps to the
* correct alternative.
*/
/* SPI0 Pinout
* ===========
*
* SCK = PTD1 (D13 at connector J2 pin 12 of Freedom Board)
* MISO = PTD3 (D12 at connector J2 pin 10 of Freedom Board)
* MOSI = PTD2 (D11 at connector J2 pin 8 of Freedom Board)
*/
#define PIN_SPI0_SCK (PIN_SPI0_SCK_3 | PIN_ALT2_PULLUP)
#define PIN_SPI0_MISO (PIN_SPI0_MISO_6 | PIN_ALT2_PULLUP)
#define PIN_SPI0_MOSI (PIN_SPI0_MOSI_5 | PIN_ALT2_PULLUP)
#define PIN_SPI1_SCK (PIN_SPI1_SCK_2 | PIN_ALT2_PULLUP)
#define PIN_SPI1_MISO (PIN_SPI1_MISO_3 | PIN_ALT2_PULLUP)
#define PIN_SPI1_MOSI (PIN_SPI0_MOSI_7 | PIN_ALT2_PULLUP)
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: kl_tsi_initialize
*
* Description:
* Initialize the TSI hardware and interface for the sliders on board the
* Freedom KL26Z board. Register a character driver at /dev/tsi that may
* be used to read from each sensor.
*
****************************************************************************/
#ifdef CONFIG_KL_TSI
void kl_tsi_initialize(void);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_KL_FREEDOM_KL26Z_INCLUDE_BOARD_H */
@@ -0,0 +1,63 @@
############################################################################
# boards/arm/kl/freedom-kl26z/scripts/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/.config
include $(TOPDIR)/tools/Config.mk
include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs
LDSCRIPT = freedom-kl26z.ld
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
else
ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
endif
ARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048
ifneq ($(CROSSDEV),arm-nuttx-elf-)
LDFLAGS += -nostartfiles -nodefaultlibs
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g
endif
@@ -0,0 +1,121 @@
/****************************************************************************
* boards/arm/kl/freedom-kl26z/scripts/freedom-kl26z.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* The MKL26Z128 has 128Kb of FLASH beginning at address 0x00000000 and
* 16Kb of SRAM at address 0x1ffff000.
*/
MEMORY
{
vectflash (rx) : ORIGIN = 0x00000000, LENGTH = 0x00c0
cfmprotect (rx) : ORIGIN = 0x00000400, LENGTH = 0x10
progflash (rx) : ORIGIN = 0x00000410, LENGTH = 128K - 0x410
datasram (rwx) : ORIGIN = 0x1ffff000, LENGTH = 16K
}
OUTPUT_ARCH(arm)
EXTERN(_vectors)
EXTERN(_cfmconfig)
ENTRY(_stext)
SECTIONS
{
.vectors : {
_svectors = ABSOLUTE(.);
*(.vectors)
_evectors = ABSOLUTE(.);
} > vectflash
.cfmprotect : {
*(.cfmconfig)
} > cfmprotect
.text : {
_stext = ABSOLUTE(.);
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > progflash
.init_section : {
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > progflash
.ARM.extab : {
*(.ARM.extab*)
} > progflash
.ARM.exidx : {
__exidx_start = ABSOLUTE(.);
*(.ARM.exidx*)
__exidx_end = ABSOLUTE(.);
} > progflash
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
. = ALIGN(4);
_edata = ABSOLUTE(.);
} > datasram AT > progflash
_eronly = LOADADDR(.data);
.ramfunc ALIGN(4): {
_sramfuncs = ABSOLUTE(.);
*(.ramfunc .ramfunc.*)
_eramfuncs = ABSOLUTE(.);
} > datasram AT > progflash
_framfuncs = LOADADDR(.ramfunc);
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_ebss = ABSOLUTE(.);
} > datasram
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}
@@ -0,0 +1,49 @@
############################################################################
# boards/arm/kl/freedom-kl26z/src/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/Make.defs
CSRCS = kl_boardinitialize.c
ifeq ($(CONFIG_LIB_BOARDCTL),y)
CSRCS += kl_appinit.c
endif
ifeq ($(CONFIG_KL_TSI),y)
CSRCS += kl_tsi.c
endif
ifeq ($(CONFIG_KL_SPI0),y)
CSRCS += kl_spi.c
else
ifeq ($(CONFIG_KL_SPI1),y)
CSRCS += kl_spi.c
endif
endif
ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += kl_led.c
endif
ifeq ($(CONFIG_PWM),y)
CSRCS += kl_pwm.c
endif
include $(TOPDIR)/boards/Board.mk
@@ -0,0 +1,143 @@
/****************************************************************************
* boards/arm/kl/freedom-kl26z/src/freedom-kl26z.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_KL_FREEDOM_KL26Z_SRC_FREEDOM_KL26Z_H
#define __BOARDS_ARM_KL_FREEDOM_KL26Z_SRC_FREEDOM_KL26Z_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Freedom KL26Z GPIOs ******************************************************/
/* The Freedom KL26Z has a single RGB LED driven by the KL26Z as follows:
*
* ------------- --------
* RGB LED KL26Z128
* ------------- --------
* Red Cathode PTE29
* Green Cathode PTE31
* Blue Cathode PTD5
*
* NOTE:
* PTD5 is also connected to the I/O header on J2 pin 12 (also known as D13).
*
* If CONFIG_ARCH_LEDs is defined, then NuttX will control the LED on board
* the Freedom KL26Z.
* The following definitions describe how NuttX controls the LEDs:
*
* SYMBOL Meaning LED state
* Initially all LED is OFF
* ------------------- ----------------------- --------------------------
* LED_STARTED NuttX has been started
* LED_HEAPALLOCATE Heap has been allocated
* LED_IRQSENABLED Interrupts enabled
* LED_STACKCREATED Idle stack created
* LED_INIRQ In an interrupt
* LED_SIGNAL In a signal handler
* LED_ASSERTION An assertion failed
* LED_PANIC The system has crashed
* LED_IDLE K26Z1XX is in sleep mode (Optional, not used)
*/
#define GPIO_LED_R (GPIO_OUTPUT | GPIO_OUTPUT_ONE | PIN_PORTE | PIN29)
#define GPIO_LED_G (GPIO_OUTPUT | GPIO_OUTPUT_ONE | PIN_PORTE | PIN31)
#define GPIO_LED_B (GPIO_OUTPUT | GPIO_OUTPUT_ONE | PIN_PORTD | PIN5)
/* Button definitions *******************************************************/
/* The Freedom KL26Z has no buttons */
/* Chip selects *************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Functions Definitions
****************************************************************************/
/****************************************************************************
* Name: kl_spidev_initialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the Freedom KL26Z
* board.
*
****************************************************************************/
void weak_function kl_spidev_initialize(void);
/****************************************************************************
* Name: kl_usbinitialize
*
* Description:
* Called from kl_usbinitialize very early in inialization to setup
* USB-related GPIO pins for the Freedom KL26Z board.
*
****************************************************************************/
#ifdef CONFIG_STM32_USB
void weak_function kl_usbinitialize(void);
#endif
/****************************************************************************
* Name: kl_led_initialize
*
* Description:
* Initialize the on-board LED
*
****************************************************************************/
#ifdef CONFIG_ARCH_LEDS
void kl_led_initialize(void);
#endif
/****************************************************************************
* Name: kl_pwm_setup
*
* Description:
* Initialize PWM and register the PWM device.
*
****************************************************************************/
#ifdef CONFIG_PWM
int kl_pwm_setup(void);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_KL_FREEDOM_KL26Z_SRC_FREEDOM_KL26Z_H */
@@ -0,0 +1,81 @@
/****************************************************************************
* boards/arm/kl/freedom-kl26z/src/kl_appinit.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <syslog.h>
#include <nuttx/board.h>
#include "freedom-kl26z.h"
#ifdef CONFIG_LIB_BOARDCTL
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_app_initialize
*
* Description:
* Perform architecture specific initialization
*
* Input Parameters:
* arg - The boardctl() argument is passed to the board_app_initialize()
* implementation without modification. The argument has no
* meaning to NuttX; the meaning of the argument is a contract
* between the board-specific initialization logic and the
* matching application logic. The value could be such things as a
* mode enumeration value, a set of DIP switch switch settings, a
* pointer to configuration data read from a file or serial FLASH,
* or whatever you would like to do with it. Every implementation
* should accept zero/NULL as a default configuration.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure to indicate the nature of the failure.
*
****************************************************************************/
int board_app_initialize(uintptr_t arg)
{
int ret;
#ifdef CONFIG_PWM
/* Initialize PWM and register the PWM device. */
ret = kl_pwm_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: kl_pwm_setup() failed: %d\n", ret);
}
#endif
UNUSED(ret);
return OK;
}
#endif /* CONFIG_LIB_BOARDCTL */
@@ -0,0 +1,109 @@
/****************************************************************************
* boards/arm/kl/freedom-kl26z/src/kl_boardinitialize.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "arm_arch.h"
#include "freedom-kl26z.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kl_boardinitialize
*
* Description:
* All K25Z architectures must provide the following entry point.
* This entry point is called early in the initialization -- after all
* memory has been configured and mapped but before any devices have been
* initialized.
*
****************************************************************************/
void kl_boardinitialize(void)
{
/* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak
* function kl_spidev_initialize() has been brought into the link.
*/
#if defined(CONFIG_KL_SPI0) || defined(CONFIG_KL_SPI1)
if (kl_spidev_initialize)
{
kl_spidev_initialize();
}
#endif
/* Initialize USB if the 1) USB device controller is in the configuration
* and 2) disabled, and 3) the weak function kl_usbinitialize() has been
* brought into the build. Presumably either CONFIG_USBHOST or
* CONFIG_USBDEV is also selected.
*/
#ifdef CONFIG_KL_USBOTG
if (kl_usbinitialize)
{
kl_usbinitialize();
}
#endif
/* Configure on-board LED if LED support has been selected. */
#ifdef CONFIG_ARCH_LEDS
kl_led_initialize();
#endif
}
/****************************************************************************
* Name: board_late_initialize
*
* Description:
* If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional
* initialization call will be performed in the boot-up sequence to a
* function called board_late_initialize(). board_late_initialize() will
* be called immediately after up_intitialize() is called and just before
* the initial application is started. This additional initialization
* phase may be used, for example, to initialize board-specific device
* drivers.
*
****************************************************************************/
#ifdef CONFIG_BOARD_LATE_INITIALIZE
void board_late_initialize(void)
{
/* Perform NSH initialization here instead of from the NSH. This
* alternative NSH initialization is necessary when NSH is ran in
* user-space but the initialization function must run in kernel space.
*/
#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_LIB_BOARDCTL)
board_app_initialize(0);
#endif
}
#endif
@@ -0,0 +1,132 @@
/****************************************************************************
* boards/arm/kl/freedom-kl26z/src/kl_led.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* The Freedom KL26Z has a single RGB LED driven by the KL26Z as follows:
*
* ------------- --------
* RGB LED KL26Z128
* ------------- --------
* Red Cathode PTE29
* Green Cathode PTE31
* Blue Cathode PTD5
*
* If CONFIG_ARCH_LEDs is defined, then NuttX will control the LED on board
* the Freedom KL26Z.
* The following definitions describe how NuttX controls the LEDs:
*
* SYMBOL Meaning LED state
* Initially all LED is OFF
* ------------------- ----------------------- --------------------------
* LED_STARTED NuttX has been started R=OFF G=OFF B=OFF
* LED_HEAPALLOCATE Heap has been allocated (no change)
* LED_IRQSENABLED Interrupts enabled (no change)
* LED_STACKCREATED Idle stack created R=OFF G=OFF B=ON
* LED_INIRQ In an interrupt (no change)
* LED_SIGNAL In a signal handler (no change)
* LED_ASSERTION An assertion failed (no change)
* LED_PANIC The system has crashed R=FLASHING G=OFF B=OFF
* LED_IDLE K26Z1XX is in sleep mode (Optional, not used)
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "chip.h"
#include "kl_gpio.h"
#include "freedom-kl26z.h"
#ifdef CONFIG_ARCH_LEDS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Dump GPIO registers */
#ifdef CONFIG_DEBUG_LEDS_INFO
# define led_dumpgpio(m) kl_dumpgpio(GPIO_LED_B, m)
#else
# define led_dumpgpio(m)
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kl_led_initialize
*
* Description:
* Initialize the on-board LED
*
****************************************************************************/
void kl_led_initialize(void)
{
kl_configgpio(GPIO_LED_R);
kl_configgpio(GPIO_LED_G);
kl_configgpio(GPIO_LED_B);
}
/****************************************************************************
* Name: board_autoled_on
****************************************************************************/
void board_autoled_on(int led)
{
if (led == LED_STACKCREATED)
{
kl_gpiowrite(GPIO_LED_R, true);
kl_gpiowrite(GPIO_LED_G, true);
kl_gpiowrite(GPIO_LED_B, false);
}
else if (led == LED_PANIC)
{
kl_gpiowrite(GPIO_LED_R, false);
kl_gpiowrite(GPIO_LED_G, true);
kl_gpiowrite(GPIO_LED_B, true);
}
}
/****************************************************************************
* Name: board_autoled_off
****************************************************************************/
void board_autoled_off(int led)
{
if (led == LED_PANIC)
{
kl_gpiowrite(GPIO_LED_R, true);
kl_gpiowrite(GPIO_LED_G, true);
kl_gpiowrite(GPIO_LED_B, true);
}
}
#endif /* CONFIG_ARCH_LEDS */
@@ -0,0 +1,103 @@
/****************************************************************************
* boards/arm/kl/freedom-kl26z/src/kl_pwm.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/timers/pwm.h>
#include <arch/board/board.h>
#include "chip.h"
#include "arm_arch.h"
#include "kl_pwm.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* PWM
*
* The Kinetis Freedom board provides a LED on GPIO.
*/
#ifdef CONFIG_PWM
extern struct pwm_lowerhalf_s *kl_pwminitialize(int timer);
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kl_pwm_setup
*
* Description:
* Initialize PWM and register the PWM device.
*
****************************************************************************/
int kl_pwm_setup(void)
{
static bool initialized = false;
struct pwm_lowerhalf_s *pwm;
int ret;
/* Have we already initialized? */
if (!initialized)
{
/* Call kl_pwminitialize() to get an instance of the PWM interface */
pwm = kl_pwminitialize(0);
if (!pwm)
{
aerr("ERROR: Failed to get the KL26 PWM lower half\n");
return -ENODEV;
}
/* Register the PWM driver at "/dev/pwm0" */
ret = pwm_register("/dev/pwm0", pwm);
if (ret < 0)
{
aerr("ERROR: pwm_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
}
return OK;
}
#endif /* CONFIG_PWM */
@@ -0,0 +1,197 @@
/****************************************************************************
* boards/arm/kl/freedom-kl26z/src/kl_spi.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/spi/spi.h>
#include "kl_gpio.h"
#include "kl_spi.h"
#include "freedom-kl26z.h"
#if defined(CONFIG_KL_SPI0) || defined(CONFIG_KL_SPI1)
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kl_spidev_initialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the FRDM-KL26Z
* board.
*
****************************************************************************/
void weak_function kl_spidev_initialize(void)
{
/* Configure SPI0 chip selects */
#ifdef CONFIG_KL_SPI0
#endif
/* Configure SPI1 chip selects */
#ifdef CONFIG_KL_SPI1
#endif
}
/****************************************************************************
* Name: kl_spi[n]select, kl_spi[n]status, and kl_spi[n]cmddata
*
* Description:
* These external functions must be provided by board-specific logic. They
* are implementations of the select, status, and cmddata methods of the
* SPI interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h).
* All other methods including kl_spibus_initialize()) are provided by
* common Kinetis logic. To use this common SPI logic on your board:
*
* 1. Provide logic in kl_boardinitialize() to configure SPI chip select
* pins.
* 2. Provide kl_spi[n]select() and kl_spi[n]status() functions
* in your board-specific logic. These functions will perform chip
* selection and status operations using GPIOs in the way your board
* is configured.
* 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
* kl_spi[n]cmddata() functions in your board-specific logic. These
* functions will perform cmd/data selection operations using GPIOs in
* the way your board is configured.
* 3. Add a call to kl_spibus_initialize() in your low level application
* initialization logic
* 4. The handle returned by kl_spibus_initialize() may then be used to
* bind the SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver).
*
****************************************************************************/
/****************************************************************************
* Name: kl_spi[n]select
*
* Description:
* PIO chip select pins may be programmed by the board specific logic in
* one of two different ways. First, the pins may be programmed as SPI
* peripherals. In that case, the pins are completely controlled by the
* SPI driver. This method still needs to be provided, but it may be only
* a stub.
*
* An alternative way to program the PIO chip select pins is as a normal
* GPIO output. In that case, the automatic control of the CS pins is
* bypassed and this function must provide control of the chip select.
* NOTE: In this case, the GPIO output pin does *not* have to be the
* same as the NPCS pin normal associated with the chip select number.
*
* Input Parameters:
* devid - Identifies the (logical) device
* selected - TRUE:Select the device, FALSE:De-select the device
*
* Returned Value:
* None
*
****************************************************************************/
#ifdef CONFIG_KL_SPI0
void kl_spi0select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n",
(int)devid, selected ? "assert" : "de-assert");
}
#endif
#ifdef CONFIG_KL_SPI1
void kl_spi1select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n",
(int)devid, selected ? "assert" : "de-assert");
}
#endif
/****************************************************************************
* Name: kl_spi[n]status
*
* Description:
* Return status information associated with the SPI device.
*
* Input Parameters:
* devid - Identifies the (logical) device
*
* Returned Value:
* Bit-encoded SPI status (see include/nuttx/spi/spi.h.
*
****************************************************************************/
#ifdef CONFIG_KL_SPI0
uint8_t kl_spi0status(FAR struct spi_dev_s *dev, uint32_t devid)
{
return 0;
}
#endif
#ifdef CONFIG_KL_SPI1
uint8_t kl_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
{
return 0;
}
#endif
/****************************************************************************
* Name: kl_spi[n]cmddata
*
* Description:
* Some SPI interfaces, particularly with LCDs, and an auxiliary 9th data
* input that determines where the other 8 data bits represent command or
* data. These interfaces control that CMD/DATA GPIO output
*
* Input Parameters:
* devid - Identifies the (logical) device
* cmd - Determines where command or data should be selected.
*
* Returned Value:
* Bit-encoded SPI status (see include/nuttx/spi/spi.h.
*
****************************************************************************/
#ifdef CONFIG_SPI_CMDDATA
#ifdef CONFIG_KL_SPI0
int kl_spi0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
return 0;
}
#endif
#ifdef CONFIG_KL_SPI1
int kl_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
return 0;
}
#endif
#endif
#endif /* CONFIG_KL_SPI */
@@ -0,0 +1,252 @@
/****************************************************************************
* boards/arm/kl/freedom-kl26z/src/kl_tsi.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* Reference:
* https://community.freescale.com/community/
* the-embedded-beat/blog/2012/10/15/
* using-the-touch-interface-on-the-freescale-freedom-development-platform
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/fs/fs.h>
#include "arm_arch.h"
#include "kl_gpio.h"
#include "hardware/kl_tsi.h"
#include "hardware/kl_pinmux.h"
#include "hardware/kl_sim.h"
#ifdef CONFIG_KL_TSI
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* The touchpad on the Freedom KL26Z board connects to the MCU via:
*
* PTB16 TWI0_CH9
* PTB17 TSI0_CH10
*/
#define NSENSORS 2
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static void tsi_calibrate(void);
static ssize_t tsi_read(FAR struct file *filep,
FAR char *buffer, size_t buflen);
/****************************************************************************
* Private Data
****************************************************************************/
static uint16_t g_defcap[NSENSORS]; /* Default capacitance for each sensor */
static uint16_t g_currdelta = 0; /* Current delta for the current button */
static uint8_t g_channel = 0; /* Current g_channel */
/* Channel assigned to each sensor */
static uint8_t const g_chsensor[NSENSORS] =
{
9,
10
};
/* Character driver operations */
static const struct file_operations tsi_ops =
{
0, /* open */
0, /* close */
tsi_read, /* read */
0, /* write */
0, /* seek */
0, /* ioctl */
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: tsi_calibrate
****************************************************************************/
static void tsi_calibrate(void)
{
uint32_t regval;
int i;
for (i = 0; i < NSENSORS; i++)
{
/* Clear end of scan flag */
regval = getreg32(KL_TSI_GENCS);
regval |= TSI_GENCS_EOSF;
putreg32(regval, KL_TSI_GENCS);
/* Scan the next electrode */
regval = TSI_DATA_TSICH(g_chsensor[i]);
putreg32(regval, KL_TSI_DATA);
regval |= TSI_DATA_SWTS;
putreg32(regval, KL_TSI_DATA);
/* Wait until the conversion is done */
while (!(getreg32(KL_TSI_GENCS) & TSI_GENCS_EOSF));
g_defcap[i] = getreg32(KL_TSI_DATA) & TSI_DATA_TSICNT_MASK;
iinfo("Sensor %d = %d\n", i + 1, g_defcap[i]);
}
}
/****************************************************************************
* Name: tsi_read
****************************************************************************/
static ssize_t tsi_read(FAR struct file *filep, FAR char *buf, size_t buflen)
{
static int deltacap = 0;
uint32_t regval;
if (buf == NULL || buflen < 1)
{
/* Well... nothing to do */
return -EINVAL;
}
deltacap = 0;
/* Clear end of scan flag */
regval = getreg32(KL_TSI_GENCS);
regval |= TSI_GENCS_EOSF;
putreg32(regval, KL_TSI_GENCS);
/* Scan the next electrode */
regval = TSI_DATA_TSICH(g_chsensor[g_channel]);
putreg32(regval, KL_TSI_DATA);
regval |= TSI_DATA_SWTS;
putreg32(regval, KL_TSI_DATA);
/* Wait until the conversion is done */
while (!(getreg32(KL_TSI_GENCS) & TSI_GENCS_EOSF));
/* Compute delta using calibration reference counts */
deltacap = getreg32(KL_TSI_DATA) & TSI_DATA_TSICNT_MASK;
deltacap -= g_defcap[g_channel];
if (deltacap < 0)
{
deltacap = 0;
}
g_currdelta = (uint16_t)deltacap;
iinfo("Delta for g_channel %d = %d\n", g_channel, g_currdelta);
buf[0] = g_currdelta & 0xff;
buf[1] = (g_currdelta & 0xff00) >> 8;
buf[2] = g_channel;
/* Increment the channel index to sample the next sensor on the next timer
* that read() is called.
*/
g_channel++;
if (g_channel >= NSENSORS)
{
g_channel = 0;
}
return 3;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kl_tsi_initialize
*
* Description:
* Initialize the TSI hardware and interface for the sliders on board the
* Freedom KL26Z board. Register a character driver at /dev/tsi that may
* be used to read from each sensor.
*
****************************************************************************/
void kl_tsi_initialize(void)
{
uint32_t regval;
/* Enable access to the TSI module */
regval = getreg32(KL_SIM_SCGC5);
regval |= SIM_SCGC5_TSI;
putreg32(regval, KL_SIM_SCGC5);
/* Configure PINs used on TSI */
kl_configgpio(PIN_TSI0_CH9);
kl_configgpio(PIN_TSI0_CH10);
/* Configure TSI parameter */
regval = getreg32(KL_TSI_GENCS);
regval |= TSI_GENCS_MODE_CAPSENSING | TSI_GENCS_REFCHRG_8UA |
TSI_GENCS_DVOLT_1p03V | TSI_GENCS_EXTCHRG_64A |
TSI_GENCS_PS_DIV16 | TSI_GENCS_NSCN_TIMES(12) | TSI_GENCS_STPE;
putreg32(regval, KL_TSI_GENCS);
/* Only after setting TSI we should enable it */
regval = getreg32(KL_TSI_GENCS);
regval |= TSI_GENCS_TSIEN;
putreg32(regval, KL_TSI_GENCS);
/* Calibrate it before to use */
tsi_calibrate();
/* And finally register the TSI character driver */
register_driver("/dev/tsi", &tsi_ops, 0444, NULL);
}
#endif /* CONFIG_KL_TSI */
@@ -0,0 +1,7 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
if ARCH_BOARD_TEENSY_LC
endif
@@ -0,0 +1,34 @@
Teensy LC README
================
This is the README file for NuttX on the PJRC Teensy LC. The Teensy LC
is a DIP style breakout board for the MKL25Z64 and comes with a USB
based bootloader. Contributed by Michael Hope.
Development Environment
=======================
All testing was done with the GNU ARM Embedded 4.9 toolchain on
Linux. See https://developer.arm.com/open-source/gnu-toolchain/gnu-rm to download.
Once you've configured and built NuttX, flash the resulting
nuttx.hex file to the board using the Teensy Loader Application.
LEDs
====
The Teensy LC has a single LED. If CONFIG_ARCH_LEDS is defined, then
NuttX will update the LED as the board boots. The summary is:
* LED off: board booting
* LED on: initial stack created
* LED flashing: panic.
See `include/board.h` for details.
Serial Console
==============
The serial console is mapped to UART0 and appears on pins 0 (RX) and
1 (TX). Consider using a 3.3 V USB to serial adapter such as the
Sparkfun #9717 FTDI cable.
@@ -0,0 +1,78 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_DISABLE_POSIX_TIMERS is not set
# CONFIG_NSH_DISABLEBG is not set
# CONFIG_NSH_DISABLE_CMP is not set
# CONFIG_NSH_DISABLE_EXEC is not set
# CONFIG_NSH_DISABLE_EXIT is not set
# CONFIG_NSH_DISABLE_HEXDUMP is not set
# CONFIG_NSH_DISABLE_PS is not set
# CONFIG_NSH_DISABLE_XD is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="teensy-lc"
CONFIG_ARCH_BOARD_TEENSY_LC=y
CONFIG_ARCH_CHIP="kl"
CONFIG_ARCH_CHIP_KL=y
CONFIG_ARCH_CHIP_MKL25Z64=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARD_LOOPSPERMSEC=2988
CONFIG_BUILTIN=y
CONFIG_C99_BOOL8=y
CONFIG_DEBUG_CUSTOMOPT=y
CONFIG_DEBUG_OPTLEVEL="-Os"
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEFAULT_SMALL=y
CONFIG_DISABLE_MOUNTPOINT=y
CONFIG_DISABLE_MQUEUE=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_INTELHEX_BINARY=y
CONFIG_KL_I2C0=y
CONFIG_KL_I2C1=y
CONFIG_KL_SPI0=y
CONFIG_KL_SPI1=y
CONFIG_KL_TPM0=y
CONFIG_KL_TPM0_PWM=y
CONFIG_KL_TPM1=y
CONFIG_KL_TPM1_PWM=y
CONFIG_KL_TPM2=y
CONFIG_KL_TPM2_PWM=y
CONFIG_KL_UART0=y
CONFIG_LIB_BOARDCTL=y
CONFIG_MAX_TASKS=8
CONFIG_MM_SMALL=y
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_DISABLE_CD=y
CONFIG_NSH_DISABLE_CP=y
CONFIG_NSH_DISABLE_MKDIR=y
CONFIG_NSH_DISABLE_MOUNT=y
CONFIG_NSH_DISABLE_RM=y
CONFIG_NSH_DISABLE_RMDIR=y
CONFIG_NSH_DISABLE_UMOUNT=y
CONFIG_NSH_FILEIOSIZE=64
CONFIG_NSH_LINELEN=80
CONFIG_NUNGET_CHARS=0
CONFIG_PREALLOC_TIMERS=0
CONFIG_PTHREAD_STACK_DEFAULT=1536
CONFIG_PWM=y
CONFIG_RAM_SIZE=8192
CONFIG_RAM_START=0x1FFFF800
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_STACK_COLORATION=y
CONFIG_START_YEAR=2015
CONFIG_STDIO_DISABLE_BUFFERING=y
CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=1536
CONFIG_TLS_NELEM=0
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USERMAIN_STACKSIZE=1536
CONFIG_USER_ENTRYPOINT="nsh_main"
@@ -0,0 +1,133 @@
/****************************************************************************
* boards/arm/kl/teensy-lc/include/board.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_KL_TEENSY_LC_INCLUDE_BOARD_H
#define __BOARDS_ARM_KL_TEENSY_LC_INCLUDE_BOARD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Clocking *****************************************************************/
/* The board has a 16MHz crystal. */
#undef BOARD_EXTCLOCK /* Crystal */
#define BOARD_XTAL_FREQ 16000000 /* 16 MHz crystal frequency (REFCLK) */
/* PLL Configuration.
*
* PLL Input frequency: PLLIN = REFCLK / PRDIV0 = 16MHz / 4 = 4 MHz
* PLL Output frequency: PLLOUT = PLLIN * VDIV0 = 4Mhz * 24 = 96 MHz
* MCGPLLCLK Frequency: MCGPLLCLK = 96MHz
*/
#define BOARD_PRDIV0 4 /* PLL External Reference Divider */
#define BOARD_VDIV0 24 /* PLL VCO Divider (frequency multiplier) */
#define BOARD_PLLIN_FREQ (BOARD_XTAL_FREQ / BOARD_PRDIV0)
#define BOARD_PLLOUT_FREQ (BOARD_PLLIN_FREQ * BOARD_VDIV0)
#define BOARD_MCGPLLCLK_FREQ BOARD_PLLOUT_FREQ
/* MCGOUTCLK:
* MCG output of either IRC, MCGFLLCLK, MCGPLLCLK, or MCG's external
* reference clock that sources the core, system, bus, and flash clock.
*
* MCGOUTCLK = MCGPLLCLK = 96MHz
*/
#define BOARD_MCGOUTCLK_FREQ BOARD_MCGPLLCLK_FREQ
/* SIM CLKDIV1 dividers.
*
* Core/system clock
* MCGOUTCLK divided by OUTDIV1, clocks the ARM Cortex-M0+ core
*
* Bus clock
* System clock divided by OUTDIV4, clocks the bus slaves and peripherals.
*/
#define BOARD_OUTDIV1 2 /* Core/system = MCGOUTCLK / 2 = 48 MHz */
#define BOARD_OUTDIV4 2 /* Bus clock = System clock / 2 = 24 MHz */
#define BOARD_CORECLK_FREQ (BOARD_MCGOUTCLK_FREQ / BOARD_OUTDIV1)
#define BOARD_BUSCLK_FREQ (BOARD_CORECLK_FREQ / BOARD_OUTDIV4)
/* PWM Configuration */
/* TPM0 Channels */
#define GPIO_TPM0_CH0OUT PIN_TPM0_CH0_2 // Pin 22: PTC1
#define GPIO_TPM0_CH1OUT PIN_TPM0_CH1_2 // Pin 23: PTC2
#define GPIO_TPM0_CH2OUT PIN_TPM0_CH2_2 // Pin 9: PTC3
#define GPIO_TPM0_CH3OUT PIN_TPM0_CH3_1 // Pin 10: PTC4
#define GPIO_TPM0_CH4OUT PIN_TPM0_CH4_2 // Pin 6: PTD4
#define GPIO_TPM0_CH5OUT PIN_TPM0_CH5_3 // Pin 20: PTD5
/* TPM1 Channels */
#define GPIO_TPM1_CH0OUT PIN_TPM1_CH0_2 // Pin 16: PTB0
#define GPIO_TPM1_CH1OUT PIN_TPM1_CH1_2 // Pin 17: PTB1
/* TPM2 Channels */
#define GPIO_TPM2_CH0OUT PIN_TPM2_CH0_1 // Pin 3: PTA1
#define GPIO_TPM2_CH1OUT PIN_TPM2_CH1_1 // Pin 4: PTA2
/* LED definitions **********************************************************/
/* The Teensy LC has a single LED. */
#define LED_STARTED 0 /* LED off */
#define LED_HEAPALLOCATE 0 /* LED off */
#define LED_IRQSENABLED 0 /* LED off */
#define LED_STACKCREATED 1 /* LED on */
#define LED_INIRQ 2 /* LED no change */
#define LED_SIGNAL 2 /* LED no change */
#define LED_ASSERTION 2 /* LED no change */
#define LED_PANIC 3 /* LED flashing */
/* SPI0 Pinout
* ===========
*
*/
/* Note that the Teensy maps SCK0 to pin 13 which conflicts with the
* LED. Use pin 14 instead.
*/
#define PIN_SPI0_SCK (PIN_SPI0_SCK_3 | PIN_ALT2_PULLUP) // Pin 14: PTD1
#define PIN_SPI0_MISO (PIN_SPI0_MISO_4 | PIN_ALT2_PULLUP) // Pin 12: PTC7
#define PIN_SPI0_MOSI (PIN_SPI0_MOSI_3 | PIN_ALT2_PULLUP) // Pin 11: PTC6
#define PIN_SPI1_SCK (PIN_SPI1_SCK_2 | PIN_ALT2_PULLUP) // Pin 20: PTD5
#define PIN_SPI1_MISO (PIN_SPI1_MISO_2 | PIN_ALT2_PULLUP) // Pin 1: PTB17
#define PIN_SPI1_MOSI (PIN_SPI0_MOSI_1 | PIN_ALT2_PULLUP) // Pin 0: PTB16
#endif /* __BOARDS_ARM_KL_TEENSY_LC_INCLUDE_BOARD_H */
@@ -0,0 +1,63 @@
############################################################################
# boards/arm/kl/teensy-lc/scripts/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/.config
include $(TOPDIR)/tools/Config.mk
include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs
LDSCRIPT = teensy-lc.ld
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
else
ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
endif
ARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048
ifneq ($(CROSSDEV),arm-nuttx-elf-)
LDFLAGS += -nostartfiles -nodefaultlibs
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g
endif
@@ -0,0 +1,121 @@
/****************************************************************************
* boards/arm/kl/teensy-lc/scripts/teensy-lc.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* The Teensy LC has 64kB of flash and 8 kB of RAM. 2 kB of flash is */
/* reserved for the bootloader.
*/
MEMORY
{
vectflash (rx) : ORIGIN = 0x00000000, LENGTH = 0x00c0
cfmprotect (rx) : ORIGIN = 0x00000400, LENGTH = 0x10
progflash (rx) : ORIGIN = 0x00000410, LENGTH = 64K - 2K - 0x410
datasram (rwx) : ORIGIN = 0x1ffff800, LENGTH = 8K
}
OUTPUT_ARCH(arm)
EXTERN(_vectors)
EXTERN(_cfmconfig)
ENTRY(_stext)
SECTIONS
{
.vectors : {
_svectors = ABSOLUTE(.);
*(.vectors)
_evectors = ABSOLUTE(.);
} > vectflash
.cfmprotect : {
*(.cfmconfig)
} > cfmprotect
.text : {
_stext = ABSOLUTE(.);
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > progflash
.init_section : {
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > progflash
.ARM.extab : {
*(.ARM.extab*)
} > progflash
.ARM.exidx : {
__exidx_start = ABSOLUTE(.);
*(.ARM.exidx*)
__exidx_end = ABSOLUTE(.);
} > progflash
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
. = ALIGN(4);
_edata = ABSOLUTE(.);
} > datasram AT > progflash
_eronly = LOADADDR(.data);
.ramfunc ALIGN(4): {
_sramfuncs = ABSOLUTE(.);
*(.ramfunc .ramfunc.*)
_eramfuncs = ABSOLUTE(.);
} > datasram AT > progflash
_framfuncs = LOADADDR(.ramfunc);
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_ebss = ABSOLUTE(.);
} > datasram
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}
@@ -0,0 +1,45 @@
############################################################################
# boards/arm/kl/teensy-lc/src/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/Make.defs
CSRCS = kl_boardinitialize.c
ifeq ($(CONFIG_LIB_BOARDCTL),y)
CSRCS += kl_appinit.c
endif
ifeq ($(CONFIG_KL_SPI0),y)
CSRCS += kl_spi.c
else
ifeq ($(CONFIG_KL_SPI1),y)
CSRCS += kl_spi.c
endif
endif
ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += kl_led.c
endif
ifeq ($(CONFIG_PWM),y)
CSRCS += kl_pwm.c
endif
include $(TOPDIR)/boards/Board.mk
@@ -0,0 +1,84 @@
/****************************************************************************
* boards/arm/kl/teensy-lc/src/kl_appinit.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdio.h>
#include <syslog.h>
#include <nuttx/board.h>
#include "teensy-lc.h"
#ifdef CONFIG_LIB_BOARDCTL
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_app_initialize
*
* Description:
* Perform application specific initialization. This function is never
* called directly from application code, but only indirectly via the
* (non-standard) boardctl() interface using the command BOARDIOC_INIT.
*
* Input Parameters:
* arg - The boardctl() argument is passed to the board_app_initialize()
* implementation without modification. The argument has no
* meaning to NuttX; the meaning of the argument is a contract
* between the board-specific initialization logic and the
* matching application logic. The value could be such things as a
* mode enumeration value, a set of DIP switch switch settings, a
* pointer to configuration data read from a file or serial FLASH,
* or whatever you would like to do with it. Every implementation
* should accept zero/NULL as a default configuration.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure to indicate the nature of the failure.
*
****************************************************************************/
int board_app_initialize(uintptr_t arg)
{
int ret;
#ifdef CONFIG_PWM
/* Initialize PWM and register the PWM device. */
ret = kl_pwm_setup();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: kl_pwm_setup() failed: %d\n", ret);
}
#endif
UNUSED(ret);
return OK;
}
#endif /* CONFIG_LIB_BOARDCTL */
@@ -0,0 +1,129 @@
/****************************************************************************
* boards/arm/kl/teensy-lc/src/kl_boardinitialize.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "chip.h"
#include "kl_gpio.h"
#include "hardware/kl_pinmux.h"
#include "arm_arch.h"
#include "teensy-lc.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kl_boardinitialize
*
* Description:
* All K25Z architectures must provide the following entry point.
* This entry point is called early in the initialization -- after all
* memory has been configured and mapped but before any devices have been
* initialized.
*
****************************************************************************/
void kl_boardinitialize(void)
{
#if defined(CONFIG_KL_UART0)
/* Remap UART0 to the standard pins. */
kl_configgpio(PIN_PORTA | PIN2);
kl_configgpio(PIN_PORTA | PIN1);
kl_configgpio(PIN_UART0_RX_3);
kl_configgpio(PIN_UART0_TX_3);
#endif
/* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak
* function kl_spidev_initialize() has been brought into the link.
*/
#if defined(CONFIG_KL_SPI0) || defined(CONFIG_KL_SPI1)
if (kl_spidev_initialize)
{
kl_spidev_initialize();
}
#endif
/* Initialize USB if the 1) USB device controller is in the configuration
* and 2) disabled, and 3) the weak function kl_usbinitialize() has been
* brought into the build. Presumably either CONFIG_USBHOST or
* CONFIG_USBDEV is also selected.
*/
#ifdef CONFIG_KL_USBOTG
if (kl_usbinitialize)
{
kl_usbinitialize();
}
#endif
/* Configure on-board LED if LED support has been selected. */
#ifdef CONFIG_ARCH_LEDS
kl_led_initialize();
#endif
}
/****************************************************************************
* Name: board_late_initialize
*
* Description:
* If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional
* initialization call will be performed in the boot-up sequence to a
* function called board_late_initialize(). board_late_initialize() will
* be called immediately after up_intitialize() is called and just before
* the initial application is started.
* This additional initialization phase may be used, for example, to
* initialize board-specific device drivers.
*
****************************************************************************/
#ifdef CONFIG_BOARD_LATE_INITIALIZE
void board_late_initialize(void)
{
/* Perform NSH initialization here instead of from the NSH.
* This alternative NSH initialization is necessary when NSH is ran in
* user-space but the initialization function must run in kernel space.
*/
#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_LIB_BOARDCTL)
board_app_initialize(0);
#endif
}
#endif
@@ -0,0 +1,81 @@
/****************************************************************************
* boards/arm/kl/teensy-lc/src/kl_led.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "chip.h"
#include "kl_gpio.h"
#include "teensy-lc.h"
#ifdef CONFIG_ARCH_LEDS
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kl_led_initialize
*
* Description:
* Initialize the on-board LED
*
****************************************************************************/
void kl_led_initialize(void)
{
kl_configgpio(GPIO_LED);
}
/****************************************************************************
* Name: board_autoled_on
****************************************************************************/
void board_autoled_on(int led)
{
if (led != 0)
{
kl_gpiowrite(GPIO_LED, true);
}
}
/****************************************************************************
* Name: board_autoled_off
****************************************************************************/
void board_autoled_off(int led)
{
if (led == 3)
{
kl_gpiowrite(GPIO_LED, false);
}
}
#endif /* CONFIG_ARCH_LEDS */
@@ -0,0 +1,103 @@
/****************************************************************************
* boards/arm/kl/teensy-lc/src/kl_pwm.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/timers/pwm.h>
#include <arch/board/board.h>
#include "chip.h"
#include "arm_arch.h"
#include "kl_pwm.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* PWM
*
* The Kinetis Freedom board provides a LED on GPIO.
*/
#ifdef CONFIG_PWM
extern struct pwm_lowerhalf_s *kl_pwminitialize(int timer);
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kl_pwm_setup
*
* Description:
* Initialize PWM and register the PWM device.
*
****************************************************************************/
int kl_pwm_setup(void)
{
static bool initialized = false;
struct pwm_lowerhalf_s *pwm;
int ret;
/* Have we already initialized? */
if (!initialized)
{
/* Call kl_pwminitialize() to get an instance of the PWM interface */
pwm = kl_pwminitialize(0);
if (!pwm)
{
aerr("ERROR: Failed to get the KL25 PWM lower half\n");
return -ENODEV;
}
/* Register the PWM driver at "/dev/pwm0" */
ret = pwm_register("/dev/pwm0", pwm);
if (ret < 0)
{
aerr("ERROR: pwm_register failed: %d\n", ret);
return ret;
}
/* Now we are initialized */
initialized = true;
}
return OK;
}
#endif /* CONFIG_PWM */
@@ -0,0 +1,197 @@
/****************************************************************************
* boards/arm/kl/teensy-lc/src/kl_spi.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/spi/spi.h>
#include "kl_gpio.h"
#include "kl_spi.h"
#include "teensy-lc.h"
#if defined(CONFIG_KL_SPI0) || defined(CONFIG_KL_SPI1)
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: kl_spidev_initialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the FRDM-KL25Z
* board.
*
****************************************************************************/
void weak_function kl_spidev_initialize(void)
{
/* Configure SPI0 chip selects */
#ifdef CONFIG_KL_SPI0
#endif
/* Configure SPI1 chip selects */
#ifdef CONFIG_KL_SPI1
#endif
}
/****************************************************************************
* Name: kl_spi[n]select, kl_spi[n]status, and kl_spi[n]cmddata
*
* Description:
* These external functions must be provided by board-specific logic. They
* are implementations of the select, status, and cmddata methods of the
* SPI interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h).
* All other methods including kl_spibus_initialize()) are provided by
* common Kinetis logic. To use this common SPI logic on your board:
*
* 1. Provide logic in kl_boardinitialize() to configure SPI chip select
* pins.
* 2. Provide kl_spi[n]select() and kl_spi[n]status() functions
* in your board-specific logic. These functions will perform chip
* selection and status operations using GPIOs in the way your board
* is configured.
* 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
* kl_spi[n]cmddata() functions in your board-specific logic. These
* functions will perform cmd/data selection operations using GPIOs in
* the way your board is configured.
* 3. Add a call to kl_spibus_initialize() in your low level application
* initialization logic
* 4. The handle returned by kl_spibus_initialize() may then be used to
* bind the SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver).
*
****************************************************************************/
/****************************************************************************
* Name: kl_spi[n]select
*
* Description:
* PIO chip select pins may be programmed by the board specific logic in
* one of two different ways. First, the pins may be programmed as SPI
* peripherals. In that case, the pins are completely controlled by the
* SPI driver. This method still needs to be provided, but it may be only
* a stub.
*
* An alternative way to program the PIO chip select pins is as a normal
* GPIO output. In that case, the automatic control of the CS pins is
* bypassed and this function must provide control of the chip select.
* NOTE: In this case, the GPIO output pin does *not* have to be the
* same as the NPCS pin normal associated with the chip select number.
*
* Input Parameters:
* devid - Identifies the (logical) device
* selected - TRUE:Select the device, FALSE:De-select the device
*
* Returned Value:
* None
*
****************************************************************************/
#ifdef CONFIG_KL_SPI0
void kl_spi0select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n",
(int)devid, selected ? "assert" : "de-assert");
}
#endif
#ifdef CONFIG_KL_SPI1
void kl_spi1select(FAR struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n",
(int)devid, selected ? "assert" : "de-assert");
}
#endif
/****************************************************************************
* Name: kl_spi[n]status
*
* Description:
* Return status information associated with the SPI device.
*
* Input Parameters:
* devid - Identifies the (logical) device
*
* Returned Value:
* Bit-encoded SPI status (see include/nuttx/spi/spi.h.
*
****************************************************************************/
#ifdef CONFIG_KL_SPI0
uint8_t kl_spi0status(FAR struct spi_dev_s *dev, uint32_t devid)
{
return 0;
}
#endif
#ifdef CONFIG_KL_SPI1
uint8_t kl_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
{
return 0;
}
#endif
/****************************************************************************
* Name: kl_spi[n]cmddata
*
* Description:
* Some SPI interfaces, particularly with LCDs, and an auxiliary 9th data
* input that determines where the other 8 data bits represent command or
* data. These interfaces control that CMD/DATA GPIO output
*
* Input Parameters:
* devid - Identifies the (logical) device
* cmd - Determines where command or data should be selected.
*
* Returned Value:
* Bit-encoded SPI status (see include/nuttx/spi/spi.h.
*
****************************************************************************/
#ifdef CONFIG_SPI_CMDDATA
#ifdef CONFIG_KL_SPI0
int kl_spi0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
return 0;
}
#endif
#ifdef CONFIG_KL_SPI1
int kl_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
return 0;
}
#endif
#endif
#endif /* CONFIG_KL_SPI */
@@ -0,0 +1,94 @@
/****************************************************************************
* boards/arm/kl/teensy-lc/src/teensy-lc.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_KL_TEENSY_LC_SRC_TEENSY_LC_H
#define __BOARDS_ARM_KL_TEENSY_LC_SRC_TEENSY_LC_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#define GPIO_LED (GPIO_OUTPUT | GPIO_OUTPUT_ONE | PIN_PORTC | PIN5)
/* Button definitions *******************************************************/
/* Chip selects *************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Functions Definitions
****************************************************************************/
/****************************************************************************
* Name: kl_spidev_initialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the Freedom KL25Z
* board.
*
****************************************************************************/
void weak_function kl_spidev_initialize(void);
/****************************************************************************
* Name: kl_pwm_setup
*
* Description:
* Initialize PWM and register the PWM device.
*
****************************************************************************/
#ifdef CONFIG_PWM
int kl_pwm_setup(void);
#endif
/****************************************************************************
* Name: kl_led_initialize
*
* Description:
* Initialize the on-board LED
*
****************************************************************************/
#ifdef CONFIG_ARCH_LEDS
void kl_led_initialize(void);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_KL_TEENSY_LC_SRC_TEENSY_LC_H */