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:
@@ -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 += ../
|
||||
|
||||
|
||||
23
lib/efm32/tinygecko/gpio.c
Normal file
23
lib/efm32/tinygecko/gpio.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user