Go to the source code of this file.
Functions | |
int | kb_gpio_init () |
int | kb_gpio_cleanup () |
void | kb_gpio_dir (unsigned gpio, unsigned dir) |
void | kb_gpio_set (unsigned gpio) |
void | kb_gpio_clear (unsigned gpio) |
int | kb_gpio_get (unsigned gpio) |
void | kb_gpio_function (unsigned gpio, unsigned function) |
int kb_gpio_cleanup | ( | ) |
void kb_gpio_clear | ( | unsigned | gpio | ) |
Clear a given GPIO. The GPIO must be first configured to ouput mode. If the GPIO is configured as input, it will be cleared when configured as ouput.
gpio | A gpio number between 0 and 84 |
Definition at line 204 of file kb_gpio.c.
References bit_set(), GPCR, KB_ERROR, KB_ERROR_INVALID, and MAXIO.
Referenced by kb_lrf_pwrOff(), main(), and resetio().
void kb_gpio_dir | ( | unsigned | gpio, | |
unsigned | dir | |||
) |
Configure the given GPIO as input or output. The GPIO function must be configured as well to use the pin as an IO.
gpio | A gpio number between 0 and 84 | |
dir | The direction 0:output 1:input |
Definition at line 171 of file kb_gpio.c.
References bit_clear(), bit_set(), GPDR, KB_ERROR, KB_ERROR_INVALID, and MAXIO.
Referenced by configio(), gpioinit(), kb_lrf_Init(), kb_pwm_activate(), kh3_init(), and main().
void kb_gpio_function | ( | unsigned | gpio, | |
unsigned | function | |||
) |
Configure the given GPIO pin function. Check first if the pin is freely available on the KoreBot.
gpio | A gpio number between 0 and 84 | |
function | 0:IO mode 1:Alternate function 1 2:Alternate function 2 3:Alternate function 3 |
Definition at line 148 of file kb_gpio.c.
References bit_clear(), bit_set(), GAFR, KB_ERROR, KB_ERROR_INVALID, and MAXIO.
Referenced by configio(), gpioinit(), kb_lrf_Init(), kb_pwm_activate(), kh3_init(), and main().
int kb_gpio_get | ( | unsigned | gpio | ) |
Get the current level for a given GPIO. It can be used regardless of the current GPIO configuration.
gpio | A gpio number between 0 and 84 |
Definition at line 223 of file kb_gpio.c.
References bit_test(), GPLR, KB_ERROR, KB_ERROR_INVALID, and MAXIO.
Referenced by braitenbergAvoidance(), kh3_ambiant_ir(), kh3_battery_voltage(), kh3_configure_os(), kh3_measure_us(), kh3_proximity_ir(), kh3_reset_tstamp(), kh3_revision(), readio(), and thread().
int kb_gpio_init | ( | ) |
Initialize the GPIO module. This function must be called before any other call the gpio functions.
Definition at line 104 of file kb_gpio.c.
References fd, GPIO_BASE, KB_ERROR, KB_ERROR_FILEOPEN, KB_ERROR_MMAP, map_base, MAP_MASK, MAP_SIZE, and MEMDEV.
Referenced by gpioinit(), kb_lrf_Init(), kb_pwm_init(), kh3_init(), and main().
void kb_gpio_set | ( | unsigned | gpio | ) |
Set a given GPIO. The GPIO must be first configured to ouput mode. If the GPIO is configured as input, it will be set when configured as ouput.
gpio | A gpio number between 0 and 84 |
Definition at line 189 of file kb_gpio.c.
References bit_set(), GPSR, KB_ERROR, KB_ERROR_INVALID, and MAXIO.
Referenced by kb_lrf_pwrOn(), main(), and setio().