#include "core/pio.h"
+/***************************************************************************** */
+/* General Purpose Input/Output */
+/***************************************************************************** */
+/* General Purpose Input/Output (GPIO) */
+struct lpc_gpio
+{
+ volatile uint8_t bval[32]; /* 0x0000 - 0x001C : Pin value of each pin on a byte for quick access */
+ uint32_t reserved_0[1016];
+ volatile uint32_t wval[32]; /* 0x1000 - 0x1074 : Pin value of each pin on a 32bits word for quick access */
+ uint32_t reserved_1[992];
+ volatile uint32_t data_dir; /* 0x2000 : Data direction Register (R/W) */
+ uint32_t reserved_2[31];
+ volatile uint32_t mask; /* 0x2080 : Pin mask, affects data, out, set, clear and invert */
+ uint32_t reserved_3[31];
+ volatile uint32_t val; /* 0x2100 : Port data Register (R/W) */
+ uint32_t reserved_4[31];
+ volatile uint32_t mval; /* 0x2180 : Port masked data Register (R/W) */
+ uint32_t reserved_5[31];
+ volatile uint32_t set; /* 0x2200 : Port output set Register (-/W) */
+ uint32_t reserved_6[31];
+ volatile uint32_t clear; /* 0x2280 : Port output clear Register (-/W) */
+ uint32_t reserved_7[31];
+ volatile uint32_t toggle; /* 0x2300 : Port output invert Register (-/W) */
+ uint32_t reserved_8[31];
+ volatile uint32_t dir_set; /* 0x2380 : Port direction set (set as output) Register (-/W) */
+ uint32_t reserved_9[31];
+ volatile uint32_t dir_clear; /* 0x2400 : Port direction clear (set as input) Register (-/W) */
+ uint32_t reserved_10[31];
+ volatile uint32_t dir_toggle; /* 0x2480 : Port direction toggle Register (-/W) */
+};
+#define LPC_GPIO_0 ((struct lpc_gpio *) LPC_GPIO_BASE)
+#define LPC_GPIO_REGS(x) ((struct lpc_gpio *) (LPC_GPIO_BASE))
+
+
+
/***************************************************************************** */
/* Public access to GPIO setup */
gpio_port->toggle = (1 << gpio.pin);\
}
+static inline uint32_t gpio_read(const struct pio gpio)
+{
+ struct lpc_gpio* gpio_port = LPC_GPIO_REGS(0);
+ return (gpio_port->val & (1 << gpio.pin));
+}
+
/* GPIO Configuration
* This function calls the config_pio() function for the gpio with the given
-/***************************************************************************** */
-/* General Purpose Input/Output */
-/***************************************************************************** */
-/* General Purpose Input/Output (GPIO) */
-struct lpc_gpio
-{
- volatile uint8_t bval[32]; /* 0x0000 - 0x001C : Pin value of each pin on a byte for quick access */
- uint32_t reserved_0[1016];
- volatile uint32_t wval[32]; /* 0x1000 - 0x1074 : Pin value of each pin on a 32bits word for quick access */
- uint32_t reserved_1[992];
- volatile uint32_t data_dir; /* 0x2000 : Data direction Register (R/W) */
- uint32_t reserved_2[31];
- volatile uint32_t mask; /* 0x2080 : Pin mask, affects data, out, set, clear and invert */
- uint32_t reserved_3[31];
- volatile uint32_t val; /* 0x2100 : Port data Register (R/W) */
- uint32_t reserved_4[31];
- volatile uint32_t mval; /* 0x2180 : Port masked data Register (R/W) */
- uint32_t reserved_5[31];
- volatile uint32_t set; /* 0x2200 : Port output set Register (-/W) */
- uint32_t reserved_6[31];
- volatile uint32_t clear; /* 0x2280 : Port output clear Register (-/W) */
- uint32_t reserved_7[31];
- volatile uint32_t toggle; /* 0x2300 : Port output invert Register (-/W) */
- uint32_t reserved_8[31];
- volatile uint32_t dir_set; /* 0x2380 : Port direction set (set as output) Register (-/W) */
- uint32_t reserved_9[31];
- volatile uint32_t dir_clear; /* 0x2400 : Port direction clear (set as input) Register (-/W) */
- uint32_t reserved_10[31];
- volatile uint32_t dir_toggle; /* 0x2480 : Port direction toggle Register (-/W) */
-};
-#define LPC_GPIO_0 ((struct lpc_gpio *) LPC_GPIO_BASE)
-#define LPC_GPIO_REGS(x) ((struct lpc_gpio *) (LPC_GPIO_BASE))
-
-
-
-
-
/***************************************************************************** */
/* Pin interrupts and patern interrupts */
/***************************************************************************** */