32 #define BCM2708_PERI_BASE 0x20000000 33 #define CLOCK_BASE (BCM2708_PERI_BASE + 0x101000) 34 #define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) 35 #define PWM_BASE (BCM2708_PERI_BASE + 0x20C000) 38 #define GPIO_SET0 *(gpio+7) 39 #define GPIO_SET1 *(gpio+8) 41 #define GPIO_CLR0 *(gpio+10) 42 #define GPIO_CLR1 *(gpio+11) 44 #define PWMCLK_CNTL *(clk+40) 45 #define PWMCLK_DIV *(clk+41) 47 #define PWM_CONTROL *pwm 48 #define PWM_STATUS *(pwm+1) 49 #define PWM0_RANGE *(pwm+4) 50 #define PWM1_RANGE *(pwm+8) 51 #define PWM0_DATA *(pwm+5) 52 #define PWM1_DATA *(pwm+9) 55 #define PWM1_MS_MODE 0x8000 56 #define PWM1_USEFIFO 0x2000 57 #define PWM1_REVPOLAR 0x1000 58 #define PWM1_OFFSTATE 0x0800 59 #define PWM1_REPEATFF 0x0400 60 #define PWM1_SERIAL 0x0200 61 #define PWM1_ENABLE 0x0100 63 #define PWM0_MS_MODE 0x0080 64 #define PWM0_USEFIFO 0x0020 65 #define PWM0_REVPOLAR 0x0010 66 #define PWM0_OFFSTATE 0x0008 67 #define PWM0_REPEATFF 0x0004 68 #define PWM0_SERIAL 0x0002 69 #define PWM0_ENABLE 0x0001 71 #define PWM_CLRFIFO 0x0040 74 #define PWMS_BUSERR 0x0100 78 #define PAGE_SIZE (4*1024) 79 #define BLOCK_SIZE (4*1024) 83 #define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3)) 84 #define OUT_GPIO(g) *(gpio+((g)/10)) |= (1<<(((g)%10)*3)) 85 #define SET_GPIO_ALT(g,a) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3)) 87 #define GPIO_SET0 *(gpio+7) 88 #define GPIO_SET1 *(gpio+8) 90 #define GPIO_CLR0 *(gpio+10) 91 #define GPIO_CLR1 *(gpio+11) 92 #define GPIO_PULL *(gpio+37) 93 #define GPIO_PULLCLK0 *(gpio+38) 102 volatile unsigned int *gpio;
103 volatile unsigned int *pwm;
104 volatile unsigned int *clk;
void pwm_mode(unsigned int mode)
Sets mode for the PWM peripheral.
int pwm_init()
Initialises the PWM peripheral.
void pwm_release()
Releases the PWM peripheral and unmaps the memory.
void pwm_value(unsigned int value)
Sets PWM value.