summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/lpc313x/lpc313x_internal.h
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-09-11 02:53:07 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-09-11 02:53:07 +0000
commit49df4c8bc3e19225c22f34b1290be89c2518e184 (patch)
tree0c3f791872d113fcfa17c56b4119a809fd9690bb /nuttx/arch/arm/src/lpc313x/lpc313x_internal.h
parent1088be447cd6113169d3646182680a87213d68b8 (diff)
downloadpx4-nuttx-49df4c8bc3e19225c22f34b1290be89c2518e184.tar.gz
px4-nuttx-49df4c8bc3e19225c22f34b1290be89c2518e184.tar.bz2
px4-nuttx-49df4c8bc3e19225c22f34b1290be89c2518e184.zip
Add support for SPI NOR chip select
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2938 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/lpc313x/lpc313x_internal.h')
-rwxr-xr-xnuttx/arch/arm/src/lpc313x/lpc313x_internal.h108
1 files changed, 65 insertions, 43 deletions
diff --git a/nuttx/arch/arm/src/lpc313x/lpc313x_internal.h b/nuttx/arch/arm/src/lpc313x/lpc313x_internal.h
index 47d7ca82a..ab8e3caf9 100755
--- a/nuttx/arch/arm/src/lpc313x/lpc313x_internal.h
+++ b/nuttx/arch/arm/src/lpc313x/lpc313x_internal.h
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/lpc313x/lpc313x_internal.h
*
- * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -47,7 +47,9 @@
#include <stdbool.h>
#include "up_internal.h"
+#include "up_arch.h"
#include "chip.h"
+#include "lpc313x_ioconfig.h"
/************************************************************************************
* Definitions
@@ -80,72 +82,92 @@ extern "C" {
#endif
/************************************************************************************
- * Public Function Prototypes
+ * Inline Functions
************************************************************************************/
-/************************************************************************************
- * Name: lpc313x_lowsetup
- *
- * Description:
- * Called early in up_boot. Performs chip-common low level initialization.
- *
- ************************************************************************************/
+/* Configure a pin as an input */
-EXTERN void lpc313x_lowsetup(void);
+static inline void gpio_configinput(uint32_t ioconfig, uint32_t bit)
+{
+ uint32_t regaddr;
-/************************************************************************************
- * Name: lpc313x_clockconfig
- *
- * Description:
- * Called to change to new clock based on settings in board.h
- *
- ************************************************************************************/
+ regaddr = ioconfig + LPC313X_IOCONFIG_MODE0RESET_OFFSET;
+ putreg32(bit, regaddr);
-EXTERN void lpc313x_clockconfig(void);
+ regaddr = ioconfig + LPC313X_IOCONFIG_MODE1RESET_OFFSET;
+ putreg32(bit, regaddr);
+}
-/************************************************************************************
- * Name: lpc313x_configgpio
- *
- * Description:
- * Configure a GPIO pin based on bit-encoded description of the pin.
- *
- ************************************************************************************/
+/* Return the current state of an input GPIO pin */
+
+static inline bool lpc313x_gpioread(uint32_t ioconfig, uint32_t bit)
+{
+ uint32_t regaddr = ioconfig + LPC313X_IOCONFIG_PINS_OFFSET;
+ return (getreg32(regaddr) & bit) != 0;
+}
+
+/* Configure the pin so that it is driven by the device */
-EXTERN int lpc313x_configgpio(uint32_t cfgset);
+static inline void gpio_configdev(uint32_t ioconfig, uint32_t bit)
+{
+ uint32_t regaddr;
+
+ regaddr = ioconfig + LPC313X_IOCONFIG_MODE1RESET_OFFSET;
+ putreg32(bit, regaddr);
+
+ regaddr = ioconfig + LPC313X_IOCONFIG_MODE0SET_OFFSET;
+ putreg32(bit, regaddr);
+}
+
+/* Configure a pin as a low output */
+
+static inline void gpio_outputlow(uint32_t ioconfig, uint32_t bit)
+{
+ uint32_t regaddr;
+
+ regaddr = ioconfig + LPC313X_IOCONFIG_MODE1SET_OFFSET;
+ putreg32(bit, regaddr);
+
+ regaddr = ioconfig + LPC313X_IOCONFIG_MODE0RESET_OFFSET;
+ putreg32(bit, regaddr);
+}
+
+/* Configure a pin as a high output */
+
+static inline void gpio_outputhigh(uint32_t ioconfig, uint32_t bit)
+{
+ uint32_t regaddr;
+
+ regaddr = ioconfig + LPC313X_IOCONFIG_MODE1SET_OFFSET;
+ putreg32(bit, regaddr);
+
+ regaddr = ioconfig + LPC313X_IOCONFIG_MODE0SET_OFFSET;
+ putreg32(bit, regaddr);
+}
/************************************************************************************
- * Name: lpc313x_gpiowrite
- *
- * Description:
- * Write one or zero to the selected GPIO pin
- *
+ * Public Function Prototypes
************************************************************************************/
-EXTERN void lpc313x_gpiowrite(uint32_t pinset, bool value);
-
/************************************************************************************
- * Name: lpc313x_gpioread
+ * Name: lpc313x_lowsetup
*
* Description:
- * Read one or zero from the selected GPIO pin
+ * Called early in up_boot. Performs chip-common low level initialization.
*
************************************************************************************/
-EXTERN bool lpc313x_gpioread(uint32_t pinset);
+EXTERN void lpc313x_lowsetup(void);
/************************************************************************************
- * Function: lpc313x_dumpgpio
+ * Name: lpc313x_clockconfig
*
* Description:
- * Dump all GPIO registers associated with the provided base address
+ * Called to change to new clock based on settings in board.h
*
************************************************************************************/
-#ifdef CONFIG_DEBUG
-EXTERN int lpc313x_dumpgpio(uint32_t pinset, const char *msg);
-#else
-# define lpc313x_dumpgpio(p,m)
-#endif
+EXTERN void lpc313x_clockconfig(void);
/************************************************************************************
* Name: lpc313x_spiselect and lpc313x_spistatus