Go to the source code of this file.
Defines | |
#define | MAP_SIZE 4096UL |
#define | MAP_MASK (MAP_SIZE - 1) |
#define | MEMDEV "/dev/mem" |
#define | MAXIO 84 |
#define | MAXPWM 2 |
#define | reg_val(reg) *((unsigned long *)reg) |
Functions | |
static void | bit_set (unsigned long addr, unsigned gpio) |
static void | bit_clear (unsigned long addr, unsigned gpio) |
static int | bit_test (unsigned long addr, unsigned gpio) |
static void | reg_set (unsigned long addr, unsigned long value) |
static long int | get_reg (unsigned long addr) |
int | kb_gpio_init () |
int | kb_gpio_cleanup () |
int | kb_gpio_mode () |
void | kb_gpio_function (unsigned gpio, unsigned function) |
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) |
Variables | |
static void * | map_base |
static int | fd |
Support for KoreBot General Purpose IO.
Definition in file kb_gpio.c.
#define MAP_MASK (MAP_SIZE - 1) |
Definition at line 30 of file kb_gpio.c.
Referenced by bit_clear(), bit_clear_clk(), bit_clear_pwm0(), bit_clear_pwm1(), bit_set(), bit_set_clk(), bit_set_pwm0(), bit_set_pwm1(), bit_test(), bit_test_pwm0(), bit_test_pwm1(), get_reg(), get_reg_pwm0(), get_reg_pwm1(), kb_clk_init(), kb_gpio_init(), kb_pwm0_init(), kb_pwm1_init(), reg_set(), reg_set_pwm0(), and reg_set_pwm1().
#define MAP_SIZE 4096UL |
Definition at line 29 of file kb_gpio.c.
Referenced by kb_clk_init(), kb_gpio_cleanup(), kb_gpio_init(), kb_pwm0_init(), kb_pwm1_init(), and kb_pwm_cleanup().
#define MAXIO 84 |
Definition at line 33 of file kb_gpio.c.
Referenced by kb_gpio_clear(), kb_gpio_dir(), kb_gpio_function(), kb_gpio_get(), and kb_gpio_set().
#define MAXPWM 2 |
Definition at line 34 of file kb_gpio.c.
Referenced by kb_pwm_activate(), kb_pwm_config(), kb_pwm_desactivate(), kb_pwm_duty(), and kb_pwm_period().
#define MEMDEV "/dev/mem" |
Definition at line 32 of file kb_gpio.c.
Referenced by kb_clk_init(), kb_gpio_init(), kb_pwm0_init(), and kb_pwm1_init().
#define reg_val | ( | reg | ) | *((unsigned long *)reg) |
Definition at line 36 of file kb_gpio.c.
Referenced by bit_clear(), bit_clear_clk(), bit_clear_pwm0(), bit_clear_pwm1(), bit_set(), bit_set_clk(), bit_set_pwm0(), bit_set_pwm1(), bit_test(), bit_test_pwm0(), bit_test_pwm1(), get_reg(), get_reg_pwm0(), get_reg_pwm1(), reg_set(), reg_set_pwm0(), and reg_set_pwm1().
static void bit_clear | ( | unsigned long | addr, | |
unsigned | gpio | |||
) | [static] |
Definition at line 53 of file kb_gpio.c.
References map_base, MAP_MASK, and reg_val.
Referenced by kb_gpio_dir(), and kb_gpio_function().
static void bit_set | ( | unsigned long | addr, | |
unsigned | gpio | |||
) | [static] |
Definition at line 41 of file kb_gpio.c.
References map_base, MAP_MASK, and reg_val.
Referenced by kb_gpio_clear(), kb_gpio_dir(), kb_gpio_function(), and kb_gpio_set().
static int bit_test | ( | unsigned long | addr, | |
unsigned | gpio | |||
) | [static] |
static long int get_reg | ( | unsigned long | addr | ) | [static] |
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().
static void reg_set | ( | unsigned long | addr, | |
unsigned long | value | |||
) | [static] |
int fd [static] |
Definition at line 39 of file kb_gpio.c.
Referenced by askposition(), c634_open(), gotogoal(), help(), kb_gpio_cleanup(), kb_gpio_init(), knet_rs232_open(), main(), quit(), reset(), start(), stop(), and thread().
void* map_base [static] |
Definition at line 38 of file kb_gpio.c.
Referenced by bit_clear(), bit_set(), bit_test(), get_reg(), kb_gpio_cleanup(), kb_gpio_init(), and reg_set().