add tests for PWM

This commit is contained in:
Howard Mao
2016-10-26 11:56:59 -07:00
parent 905c9a14f6
commit 310db2c579
8 changed files with 2274 additions and 0 deletions

22
tests/pwm.c Normal file
View File

@@ -0,0 +1,22 @@
#define PWM_PERIOD 0x2000
#define PWM_DUTY 0x2008
#define PWM_ENABLE 0x2010
static inline void write_reg(unsigned long addr, unsigned long data)
{
volatile unsigned long *ptr = (volatile unsigned long *) addr;
*ptr = data;
}
static inline unsigned long read_reg(unsigned long addr)
{
volatile unsigned long *ptr = (volatile unsigned long *) addr;
return *ptr;
}
int main(void)
{
write_reg(PWM_PERIOD, 20);
write_reg(PWM_DUTY, 5);
write_reg(PWM_ENABLE, 1);
}