-
Notifications
You must be signed in to change notification settings - Fork 0
/
pwm-led.h
40 lines (31 loc) · 1.05 KB
/
pwm-led.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef PWM_LED_H
#define PWM_LED_H
// Include necessary libraries
#include <stdint.h>
//registers for pwm
#define PWM_BASE 0x03060000
#define PWM_GROUP 0x2000
#define PERIOD2 0x014
#define HLPERIDO2 0x010
#define PCOUNT2 0x058
#define PWM_START 0x044
#define PWM_DONE 0x048
#define PWM_UPDATE 0x04C
#define PWM_MODE 0x040
#define PWM_OE 0x0D0
#define base PWM_BASE+PWM_GROUP
#define CLK_BASE 0x03002000
#define CLK_PWM 0x120
//settings for pwm
#define freq 100 // 100 is the calcualted for 800kHz calulated frequency, It seem that I have to go way lower for a 1.25us period.
#define Hduty 65 //65 is the claculated duty cycle for .7us high time to write a 1
#define Lduty 10 //10 % is the claculated duty cycle for .35us high time to write a 0
#define count 1//30 pulses
#define start 0b0100
#define pwm_mode (1<<10) // set the pmode to to pulse 1<<num+8 and set the polarity to control the high period 1<<2
#define pwmoe 0b0100
// Function prototypes
void setup_pwm();
void address_led(uint8_t green, uint8_t red, uint8_t blue);
void pwm_cleanup();
#endif