convenience functions for efm32 gpio

also, the whole gpio header file is now a big doxygen group, structuring
the convenience functions and the register/value definitions
This commit is contained in:
chrysn
2012-03-01 02:09:02 +01:00
parent a747e887bd
commit 541fded753
4 changed files with 249 additions and 90 deletions

View File

@@ -30,7 +30,7 @@ CFLAGS = -Os -g -Wall -Wextra -I../../../include -fno-common \
-ffunction-sections -fdata-sections -MD -D$(FAMILY)
# ARFLAGS = rcsv
ARFLAGS = rcs
OBJS = vector.o devicerevision.o
OBJS = vector.o devicerevision.o gpio.o
VPATH += ../

View File

@@ -0,0 +1,23 @@
#include <libopencm3/efm32/tinygecko/gpio.h>
void gpio_set_mode(u32 gpioport, u8 mode, u16 gpios)
{
u8 i;
u32 modemaskl = 0, modesetl = 0, modemaskh = 0, modeseth = 0;
for (i = 0; i < 8; ++i)
{
if (gpios & (1<<i)) {
modemaskl |= GPIO_MODE_MASK << (i*4);
modesetl |= mode << (i*4);
}
if (gpios & (0x100<<i)) {
modemaskh |= GPIO_MODE_MASK << (i*4);
modeseth |= mode << (i*4);
}
}
GPIO_Px_MODEL(gpioport) &= ~modemaskl;
GPIO_Px_MODEL(gpioport) |= modesetl;
GPIO_Px_MODEH(gpioport) &= ~modemaskh;
GPIO_Px_MODEH(gpioport) |= modeseth;
}