summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/kinetis/kinetis_internal.h
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-08-05 19:33:13 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-08-05 19:33:13 +0000
commit8f0b435a518c39a6141bbf888aa4bcd879808d44 (patch)
treefbb26e9e98d595d4ecae4c372b920b29638b4fd6 /nuttx/arch/arm/src/kinetis/kinetis_internal.h
parent995855bd907c315e68b5a7865a065c6afa6512b6 (diff)
downloadpx4-nuttx-8f0b435a518c39a6141bbf888aa4bcd879808d44.tar.gz
px4-nuttx-8f0b435a518c39a6141bbf888aa4bcd879808d44.tar.bz2
px4-nuttx-8f0b435a518c39a6141bbf888aa4bcd879808d44.zip
Add directory structure to support the port to the Kinesis KwikStik-K40
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3845 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/kinetis/kinetis_internal.h')
-rwxr-xr-xnuttx/arch/arm/src/kinetis/kinetis_internal.h447
1 files changed, 447 insertions, 0 deletions
diff --git a/nuttx/arch/arm/src/kinetis/kinetis_internal.h b/nuttx/arch/arm/src/kinetis/kinetis_internal.h
new file mode 100755
index 000000000..a23a3c89a
--- /dev/null
+++ b/nuttx/arch/arm/src/kinetis/kinetis_internal.h
@@ -0,0 +1,447 @@
+/************************************************************************************
+ * arch/arm/src/kinetis/kinetis_internal.h
+ *
+ * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_KINETIS_KINETIS_INTERNAL_H
+#define __ARCH_ARM_SRC_KINETIS_KINETIS_INTERNAL_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "up_internal.h"
+#include "chip.h"
+
+/************************************************************************************
+ * Definitions
+ ************************************************************************************/
+
+/* Configuration ********************************************************************/
+
+/* Bit-encoded input to kinetis_configgpio() ******************************************/
+#warning "Missing logic"
+
+/************************************************************************************
+ * Public Types
+ ************************************************************************************/
+
+typedef FAR void *DMA_HANDLE;
+typedef void (*dma_callback_t)(DMA_HANDLE handle, void *arg, int result);
+
+/* The following is used for sampling DMA registers when CONFIG DEBUG_DMA is selected */
+
+#ifdef CONFIG_DEBUG_DMA
+struct kinetis_dmaglobalregs_s
+{
+#warning "Missing logic"
+ /* Global Registers */
+};
+
+struct kinetis_dmachanregs_s
+{
+#warning "Missing logic"
+ /* Channel Registers */
+};
+
+struct kinetis_dmaregs_s
+{
+ /* Global Registers */
+
+ struct kinetis_dmaglobalregs_s gbl;
+
+ /* Channel Registers */
+
+ struct kinetis_dmachanregs_s ch;
+};
+#endif
+
+/************************************************************************************
+ * Inline Functions
+ ************************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+/************************************************************************************
+ * Public Data
+ ************************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C" {
+#else
+#define EXTERN extern
+#endif
+
+/************************************************************************************
+ * Public Function Prototypes
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: kinetis_clockconfig
+ *
+ * Description:
+ * Called to initialize the KINETIS. This does whatever setup is needed to put the
+ * MCU in a usable state. This includes the initialization of clocking using the
+ * settings in board.h.
+ *
+ ************************************************************************************/
+
+EXTERN void kinetis_clockconfig(void);
+
+/************************************************************************************
+ * Name: kinetis_lowsetup
+ *
+ * Description:
+ * Called at the very beginning of _start. Performs low level initialization
+ * including setup of the console UART. This UART done early so that the serial
+ * console is available for debugging very early in the boot sequence.
+ *
+ ************************************************************************************/
+
+EXTERN void kinetis_lowsetup(void);
+
+/************************************************************************************
+ * Name: kinetis_gpioirqinitialize
+ *
+ * Description:
+ * Initialize logic to support a second level of interrupt decoding for GPIO pins.
+ *
+ ************************************************************************************/
+
+#ifdef CONFIG_GPIO_IRQ
+EXTERN void kinetis_gpioirqinitialize(void);
+#else
+# define kinetis_gpioirqinitialize()
+#endif
+
+/************************************************************************************
+ * Name: kinetis_configgpio
+ *
+ * Description:
+ * Configure a GPIO pin based on bit-encoded description of the pin.
+ *
+ ************************************************************************************/
+
+EXTERN int kinetis_configgpio(uint16_t cfgset);
+
+/************************************************************************************
+ * Name: kinetis_gpiowrite
+ *
+ * Description:
+ * Write one or zero to the selected GPIO pin
+ *
+ ************************************************************************************/
+
+EXTERN void kinetis_gpiowrite(uint16_t pinset, bool value);
+
+/************************************************************************************
+ * Name: kinetis_gpioread
+ *
+ * Description:
+ * Read one or zero from the selected GPIO pin
+ *
+ ************************************************************************************/
+
+EXTERN bool kinetis_gpioread(uint16_t pinset);
+
+/************************************************************************************
+ * Name: kinetis_gpioirqenable
+ *
+ * Description:
+ * Enable the interrupt for specified GPIO IRQ
+ *
+ ************************************************************************************/
+
+#ifdef CONFIG_GPIO_IRQ
+EXTERN void kinetis_gpioirqenable(int irq);
+#else
+# define kinetis_gpioirqenable(irq)
+#endif
+
+/************************************************************************************
+ * Name: kinetis_gpioirqdisable
+ *
+ * Description:
+ * Disable the interrupt for specified GPIO IRQ
+ *
+ ************************************************************************************/
+
+#ifdef CONFIG_GPIO_IRQ
+EXTERN void kinetis_gpioirqdisable(int irq);
+#else
+# define kinetis_gpioirqdisable(irq)
+#endif
+
+/************************************************************************************
+ * Function: kinetis_dumpgpio
+ *
+ * Description:
+ * Dump all GPIO registers associated with the base address of the provided pinset.
+ *
+ ************************************************************************************/
+
+#ifdef CONFIG_DEBUG_GPIO
+EXTERN int kinetis_dumpgpio(uint16_t pinset, const char *msg);
+#else
+# define kinetis_dumpgpio(p,m)
+#endif
+
+/************************************************************************************
+ * Name: kinetis_clrpend
+ *
+ * Description:
+ * Clear a pending interrupt at the NVIC. This does not seem to be required
+ * for most interrupts.
+ *
+ ************************************************************************************/
+
+EXTERN void kinetis_clrpend(int irq);
+
+/************************************************************************************
+ * Name: kinetis_spi/ssp0/ssp1select, kinetis_spi/ssp0/ssp1status, and
+ * kinetis_spi/ssp0/ssp1cmddata
+ *
+ * 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.h). All other methods
+ * including up_spiinitialize()) are provided by common Kinetis logic. To use
+ * this common SPI logic on your board:
+ *
+ * 1. Provide logic in kinetis_boardinitialize() to configure SPI/SSP chip select
+ * pins.
+ * 2. Provide kinetis_spi/ssp0/ssp1select() and kinetis_spi/ssp0/ssp1status() 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
+ * kinetis_spi/ssp0/ssp1cmddata() 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 up_spiinitialize() in your low level application
+ * initialization logic
+ * 4. The handle returned by up_spiinitialize() 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).
+ *
+ ************************************************************************************/
+
+struct spi_dev_s;
+enum spi_dev_e;
+
+#ifdef CONFIG_KINETIS_SPI
+EXTERN void kinetis_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
+EXTERN uint8_t kinetis_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+EXTERN int kinetis_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+#endif
+#endif
+#ifdef CONFIG_KINETIS_SSP0
+EXTERN void kinetis_ssp0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
+EXTERN uint8_t kinetis_ssp0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+EXTERN int kinetis_ssp0cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+#endif
+#endif
+#ifdef CONFIG_KINETIS_SSP1
+EXTERN void kinetis_ssp1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
+EXTERN uint8_t kinetis_ssp1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+EXTERN int kinetis_ssp1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+#endif
+#endif
+
+/****************************************************************************
+ * Name: ssp_flush
+ *
+ * Description:
+ * Flush and discard any words left in the RX fifo. This can be called
+ * from ssp0/1select after a device is deselected (if you worry about such
+ * things).
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+struct spi_dev_s;
+#ifdef CONFIG_KINETIS_SPI
+EXTERN void spi_flush(FAR struct spi_dev_s *dev);
+#endif
+#if defined(CONFIG_KINETIS_SSP0) || defined(CONFIG_KINETIS_SSP1)
+EXTERN void ssp_flush(FAR struct spi_dev_s *dev);
+#endif
+
+/****************************************************************************
+ * Name: kinetis_dmainitialize
+ *
+ * Description:
+ * Initialize the GPDMA subsystem.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_KINETIS_GPDMA
+EXTERN void kinetis_dmainitilaize(void);
+#endif
+
+/****************************************************************************
+ * Name: kinetis_dmachannel
+ *
+ * Description:
+ * Allocate a DMA channel. This function sets aside a DMA channel and
+ * gives the caller exclusive access to the DMA channel.
+ *
+ * Returned Value:
+ * One success, this function returns a non-NULL, void* DMA channel
+ * handle. NULL is returned on any failure. This function can fail only
+ * if no DMA channel is available.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_KINETIS_GPDMA
+EXTERN DMA_HANDLE kinetis_dmachannel(void);
+#endif
+
+/****************************************************************************
+ * Name: kinetis_dmafree
+ *
+ * Description:
+ * Release a DMA channel. NOTE: The 'handle' used in this argument must
+ * NEVER be used again until kinetis_dmachannel() is called again to re-gain
+ * a valid handle.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_KINETIS_GPDMA
+EXTERN void kinetis_dmafree(DMA_HANDLE handle);
+#endif
+
+/****************************************************************************
+ * Name: kinetis_dmasetup
+ *
+ * Description:
+ * Configure DMA for one transfer.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_KINETIS_GPDMA
+EXTERN int kinetis_dmarxsetup(DMA_HANDLE handle,
+ uint32_t control, uint32_t config,
+ uint32_t srcaddr, uint32_t destaddr,
+ size_t nbytes);
+#endif
+
+/****************************************************************************
+ * Name: kinetis_dmastart
+ *
+ * Description:
+ * Start the DMA transfer
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_KINETIS_GPDMA
+EXTERN int kinetis_dmastart(DMA_HANDLE handle, dma_callback_t callback, void *arg);
+#endif
+
+/****************************************************************************
+ * Name: kinetis_dmastop
+ *
+ * Description:
+ * Cancel the DMA. After kinetis_dmastop() is called, the DMA channel is
+ * reset and kinetis_dmasetup() must be called before kinetis_dmastart() can be
+ * called again
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_KINETIS_GPDMA
+EXTERN void kinetis_dmastop(DMA_HANDLE handle);
+#endif
+
+/****************************************************************************
+ * Name: kinetis_dmasample
+ *
+ * Description:
+ * Sample DMA register contents
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_KINETIS_GPDMA
+#ifdef CONFIG_DEBUG_DMA
+EXTERN void kinetis_dmasample(DMA_HANDLE handle, struct kinetis_dmaregs_s *regs);
+#else
+# define kinetis_dmasample(handle,regs)
+#endif
+#endif
+
+/****************************************************************************
+ * Name: kinetis_dmadump
+ *
+ * Description:
+ * Dump previously sampled DMA register contents
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_KINETIS_GPDMA
+#ifdef CONFIG_DEBUG_DMA
+EXTERN void kinetis_dmadump(DMA_HANDLE handle, const struct kinetis_dmaregs_s *regs,
+ const char *msg);
+#else
+# define kinetis_dmadump(handle,regs,msg)
+#endif
+#endif
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __ARCH_ARM_SRC_KINETIS_KINETIS_INTERNAL_H */