Go to the source code of this file.
Defines | |
#define | MAP_SIZE 4096UL |
#define | MAP_MASK (MAP_SIZE - 1) |
#define | MEMDEV "/dev/mem" |
#define | MAXPWM 2 |
#define | PWM0 16 |
#define | PWM1 17 |
#define | reg_val(reg) *((unsigned long *)reg) |
Functions | |
static void | bit_set_pwm0 (unsigned long addr, unsigned gpio) |
static void | bit_clear_pwm0 (unsigned long addr, unsigned gpio) |
static int | bit_test_pwm0 (unsigned long addr, unsigned gpio) |
static void | reg_set_pwm0 (unsigned long addr, unsigned long value) |
static long int | get_reg_pwm0 (unsigned long addr) |
static void | bit_set_pwm1 (unsigned long addr, unsigned gpio) |
static void | bit_clear_pwm1 (unsigned long addr, unsigned gpio) |
static int | bit_test_pwm1 (unsigned long addr, unsigned gpio) |
static void | reg_set_pwm1 (unsigned long addr, unsigned long value) |
static long int | get_reg_pwm1 (unsigned long addr) |
static void | bit_set_clk (unsigned long addr, unsigned gpio) |
static void | bit_clear_clk (unsigned long addr, unsigned gpio) |
int | kb_clk_init () |
int | kb_pwm0_init () |
int | kb_pwm1_init () |
int | kb_pwm_init () |
int | kb_pwm_cleanup () |
int | kb_pwm_activate (unsigned pwm) |
int | kb_pwm_desactivate (unsigned pwm) |
int | kb_pwm_config (unsigned pwm, unsigned pwm_sd, unsigned prescale) |
int | kb_pwm_duty (unsigned pwm, unsigned FDcycle, unsigned Dcycle) |
int | kb_pwm_period (unsigned pwm, unsigned pwm_period) |
Variables | |
static void * | map_base_pwm0 |
static void * | map_base_pwm1 |
static void * | map_base_clk |
static int | fd_pwm0 |
static int | fd_pwm1 |
static int | fd_clk |
Support for KoreBot General Purpose IO.
Definition in file kb_pwm.c.
#define PWM0 16 |
#define PWM1 17 |
static void bit_clear_clk | ( | unsigned long | addr, | |
unsigned | gpio | |||
) | [static] |
Definition at line 180 of file kb_pwm.c.
References map_base_clk, MAP_MASK, and reg_val.
Referenced by kb_pwm_desactivate().
static void bit_clear_pwm0 | ( | unsigned long | addr, | |
unsigned | gpio | |||
) | [static] |
static void bit_clear_pwm1 | ( | unsigned long | addr, | |
unsigned | gpio | |||
) | [static] |
static void bit_set_clk | ( | unsigned long | addr, | |
unsigned | gpio | |||
) | [static] |
Definition at line 168 of file kb_pwm.c.
References map_base_clk, MAP_MASK, and reg_val.
Referenced by kb_pwm_activate().
static void bit_set_pwm0 | ( | unsigned long | addr, | |
unsigned | gpio | |||
) | [static] |
static void bit_set_pwm1 | ( | unsigned long | addr, | |
unsigned | gpio | |||
) | [static] |
static int bit_test_pwm0 | ( | unsigned long | addr, | |
unsigned | gpio | |||
) | [static] |
static int bit_test_pwm1 | ( | unsigned long | addr, | |
unsigned | gpio | |||
) | [static] |
static long int get_reg_pwm0 | ( | unsigned long | addr | ) | [static] |
static long int get_reg_pwm1 | ( | unsigned long | addr | ) | [static] |
int kb_clk_init | ( | ) |
Initialize the CLK module. This function must be called before any other call the pwm functions.
Definition at line 199 of file kb_pwm.c.
References CLK_BASE, fd_clk, KB_ERROR, KB_ERROR_FILEOPEN, KB_ERROR_MMAP, map_base_clk, MAP_MASK, MAP_SIZE, and MEMDEV.
Referenced by kb_pwm_init().
int kb_pwm0_init | ( | ) |
Initialize the PWM0 module. This function must be called before any other call the pwm functions.
Definition at line 230 of file kb_pwm.c.
References fd_pwm0, KB_ERROR, KB_ERROR_FILEOPEN, KB_ERROR_MMAP, map_base_pwm0, MAP_MASK, MAP_SIZE, MEMDEV, and PWM0_BASE.
Referenced by kb_pwm_init().
int kb_pwm1_init | ( | ) |
Initialize the PWM1 module. This function must be called before any other call the pwm functions.
Definition at line 258 of file kb_pwm.c.
References fd_pwm1, KB_ERROR, KB_ERROR_FILEOPEN, KB_ERROR_MMAP, map_base_pwm1, MAP_MASK, MAP_SIZE, MEMDEV, and PWM1_BASE.
Referenced by kb_pwm_init().
int kb_pwm_activate | ( | unsigned | pwm | ) |
Configure the given IO as an PWM. The GPIO will be configure as an output.
pwm | A pwm number between 0 and 1 |
Definition at line 317 of file kb_pwm.c.
References bit_set_clk(), CKEN, KB_ERROR, KB_ERROR_INVALID, kb_gpio_dir(), kb_gpio_function(), MAXPWM, PWM0, and PWM1.
Referenced by main(), and pwm_on().
int kb_pwm_cleanup | ( | ) |
Cleanup the PWM module. Must be called to free the module ressources.
Definition at line 301 of file kb_pwm.c.
References fd_pwm0, fd_pwm1, KB_ERROR, KB_ERROR_MMAP, map_base_pwm0, map_base_pwm1, and MAP_SIZE.
int kb_pwm_config | ( | unsigned | pwm, | |
unsigned | pwm_sd, | |||
unsigned | prescale | |||
) |
Configure the control register of the given PWM.
pwm | A pwm number between 0 and 1 | |
pwm_sd | Choose the shutdown method | |
prescale | Determines the frequency of the PWM module clock (old PSCLK_PWMn = 3.6864 MHz / (PWM_CTRL[PRESCALE] + 1)) (PSCLK_PWMn = 13.0 MHz / (PWM_CTRL[PRESCALE] + 1)) |
Definition at line 390 of file kb_pwm.c.
References KB_ERROR, KB_ERROR_INVALID, MAXPWM, PWM_CTRL0, PWM_CTRL1, reg_set_pwm0(), and reg_set_pwm1().
Referenced by pwm_config().
int kb_pwm_desactivate | ( | unsigned | pwm | ) |
Desactivate the PWM.
pwm | A pwm number between 0 and 1 |
Definition at line 363 of file kb_pwm.c.
References bit_clear_clk(), CKEN, KB_ERROR, KB_ERROR_INVALID, and MAXPWM.
Referenced by pwm_off().
int kb_pwm_duty | ( | unsigned | pwm, | |
unsigned | FDcycle, | |||
unsigned | Dcycle | |||
) |
Configure the duty cycle of the given PWM.
pwm | A pwm number between 0 and 1 | |
FDcycle | Full Duty Cycle | |
Dcycle | Duty Cycle of PWMn clock |
Definition at line 429 of file kb_pwm.c.
References KB_ERROR, KB_ERROR_INVALID, MAXPWM, PWM_PWDUTY0, PWM_PWDUTY1, reg_set_pwm0(), and reg_set_pwm1().
Referenced by main(), and pwm_ratio().
int kb_pwm_init | ( | ) |
Initialize the two PWM module. This function must be called before any other call the pwm functions.
Definition at line 289 of file kb_pwm.c.
References kb_clk_init(), kb_gpio_init(), kb_pwm0_init(), and kb_pwm1_init().
Referenced by main().
int kb_pwm_period | ( | unsigned | pwm, | |
unsigned | pwm_period | |||
) |
Configure the frequency of the given PWM.
pwm | A pwm number between 0 and 1 | |
pwm_period | Period of given PWM |
Definition at line 468 of file kb_pwm.c.
References KB_ERROR, KB_ERROR_INVALID, MAXPWM, PWM_PERVAL0, PWM_PERVAL1, reg_set_pwm0(), and reg_set_pwm1().
Referenced by main(), and pwm_freq().
static void reg_set_pwm0 | ( | unsigned long | addr, | |
unsigned long | value | |||
) | [static] |
Definition at line 89 of file kb_pwm.c.
References map_base_pwm0, MAP_MASK, and reg_val.
Referenced by kb_pwm_config(), kb_pwm_duty(), and kb_pwm_period().
static void reg_set_pwm1 | ( | unsigned long | addr, | |
unsigned long | value | |||
) | [static] |
Definition at line 147 of file kb_pwm.c.
References map_base_pwm1, MAP_MASK, and reg_val.
Referenced by kb_pwm_config(), kb_pwm_duty(), and kb_pwm_period().
int fd_clk [static] |
int fd_pwm0 [static] |
int fd_pwm1 [static] |
void* map_base_clk [static] |
Definition at line 45 of file kb_pwm.c.
Referenced by bit_clear_clk(), bit_set_clk(), and kb_clk_init().
void* map_base_pwm0 [static] |
Definition at line 42 of file kb_pwm.c.
Referenced by bit_clear_pwm0(), bit_set_pwm0(), bit_test_pwm0(), get_reg_pwm0(), kb_pwm0_init(), kb_pwm_cleanup(), and reg_set_pwm0().
void* map_base_pwm1 [static] |
Definition at line 43 of file kb_pwm.c.
Referenced by bit_clear_pwm1(), bit_set_pwm1(), bit_test_pwm1(), get_reg_pwm1(), kb_pwm1_init(), kb_pwm_cleanup(), and reg_set_pwm1().