Page MenuHomec4science

pwm.h
No OneTemporary

File Metadata

Created
Sun, Dec 1, 03:41
/*
* File: pwm.h
* Author: tuleu
*
* Created on September 13, 2012, 2:24 PM
*/
#ifndef PWM_H
#define PWM_H
#include <p33Fxxxx.h>
enum pwm_device_t {
PWM_1_1,
PWM_1_2,
PWM_1_3,
PWM_2_1
};
typedef enum pwm_device_t pwm_device_t;
struct pwm_t {
volatile unsigned int * DC;
volatile unsigned int * TCON;
volatile unsigned int * CON1;
volatile unsigned int * TPER;
unsigned char pin;
};
typedef struct pwm_t pwm_t;
void pwm_init(pwm_t * pwm, pwm_device_t device);
#define pwm_set_cycle(pwm,value) \
do{ \
*(pwm.TPER) = value; \
}while(0)
#define pwm_set_value(pwm,value) \
do{ \
*(pwm.DC) = value; \
}while(0)
#endif /* PWM_H */

Event Timeline