aboutsummaryrefslogtreecommitdiff
path: root/lib/gpio.c
diff options
context:
space:
mode:
authorUwe Hermann2010-12-17 06:04:28 +0100
committerUwe Hermann2010-12-17 06:04:28 +0100
commiteebbd508fc0a8d570c12c1c89b5e33dc16de4c80 (patch)
treed2755daf7ee78620687017987287f8656c9fb7e4 /lib/gpio.c
parent9539f3bf06633a178e8f9eaebbcf350c21f90619 (diff)
TIM1 GPIO remapping + gpio_port_config_lock().
Thanks to Philip Court <philip@greenstage.co.nz> for the patch.
Diffstat (limited to 'lib/gpio.c')
-rw-r--r--lib/gpio.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/gpio.c b/lib/gpio.c
index abf47cf..747977d 100644
--- a/lib/gpio.c
+++ b/lib/gpio.c
@@ -106,3 +106,17 @@ void gpio_port_write(u32 gpioport, u16 data)
{
GPIO_ODR(gpioport) = data;
}
+
+void gpio_port_config_lock(u32 gpioport, u16 gpios)
+{
+ u32 reg32;
+
+ /* Special "Lock Key Writing Sequence", see datasheet. */
+ GPIO_LCKR(gpioport) = GPIO_LCKK | gpios; /* Set LCKK. */
+ GPIO_LCKR(gpioport) = ~GPIO_LCKK & gpios; /* Clear LCKK. */
+ GPIO_LCKR(gpioport) = GPIO_LCKK | gpios; /* Set LCKK. */
+ reg32 = GPIO_LCKR(gpioport); /* Read LCKK. */
+ reg32 = GPIO_LCKR(gpioport); /* Read LCKK again. */
+
+ /* If (reg32 & GPIO_LCKK) is true, the lock is now active. */
+}