71 lines
2.1 KiB
C
71 lines
2.1 KiB
C
|
#ifndef pwm_timer_h
|
||
|
#define pwm_timer_h
|
||
|
|
||
|
/**
|
||
|
* \file pwm_timer.h
|
||
|
* \brief Controls the actual PWM-output.
|
||
|
* \author Thomas Stegemann
|
||
|
* \version $Id: pwm_timer.h,v 1.1 2006/09/26 18:18:27 rschaten Exp $
|
||
|
*
|
||
|
* License: See documentation.
|
||
|
*
|
||
|
* - read and process the pwm_Channels_Message from the messageQueue (written
|
||
|
* by pwm_Channels)
|
||
|
* - use a timed interrupt to switch the led at a specified processor cycle
|
||
|
* - init starts the processing and the timer
|
||
|
* - idle is called by the pwm_Channels when the internal buffer is full
|
||
|
* - at every pwm_timer cycle the leds can be switched in up to four steps
|
||
|
* every step defines which leds are switched on/off and up to which
|
||
|
* processor cycle the status is hold so the brightness for the three leds
|
||
|
* can be switched independently
|
||
|
* - example:
|
||
|
* - start with all leds for 10 cycles:
|
||
|
* \code
|
||
|
* step[0]= {10, 1|2|4};
|
||
|
* \endcode
|
||
|
* - switch off the red led for further 10 cycles
|
||
|
* \code
|
||
|
* step[1]= {20, 2|4};
|
||
|
* \endcode
|
||
|
* - switch off the green led for further 10 cycles
|
||
|
* \code
|
||
|
* step[2]= {30, 4};
|
||
|
* \endcode
|
||
|
* - switch off all leds for the remaining time
|
||
|
* \code
|
||
|
* step[3]= {pwm_Timer_Cycles_Max, 0};
|
||
|
* \endcode
|
||
|
*/
|
||
|
|
||
|
#include "pwm_channels.h"
|
||
|
|
||
|
/** 8-bit-field to contain the state of the channels. */
|
||
|
typedef uint8_t pwm_Channels_Bitfield;
|
||
|
|
||
|
/** Value to count the steps in one channel. */
|
||
|
typedef uint8_t pwm_Channels_StepCounter;
|
||
|
|
||
|
/** Contains a number of controller-cycles. */
|
||
|
typedef uint16_t pwm_Timer_Cycles;
|
||
|
|
||
|
/** Definition of the maximum number of steps. */
|
||
|
enum{pwm_Channels_StepCounter_Max= CHANNELS + 1};
|
||
|
|
||
|
/** Structure to contain one step. */
|
||
|
typedef struct S_pwm_Channels_Step {
|
||
|
pwm_Timer_Cycles cycle; /**< Number of cycles to complete this step. */
|
||
|
pwm_Channels_Bitfield field; /**< The state of all channels. */
|
||
|
} pwm_Channels_Step;
|
||
|
|
||
|
/** Structure to contain an array of steps. */
|
||
|
typedef struct S_pwm_Channels_Message {
|
||
|
pwm_Channels_Step step[pwm_Channels_StepCounter_Max]; /**< Array of steps. */
|
||
|
} pwm_Channels_Message;
|
||
|
|
||
|
void pwm_Timer_init(void);
|
||
|
void pwm_Timer_cleanup(void);
|
||
|
void pwm_Timer_idle(void);
|
||
|
|
||
|
#endif
|
||
|
|