beacon_tsop
[aversive.git] / projects / microb2010 / tests / beacon_tsop / pwm_config.h
1 /*  
2  *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)
3  * 
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  *  Revision : $Id: pwm_config.h,v 1.2.6.3 2007-09-06 08:18:22 zer0 Exp $
19  *
20  */
21
22 /* Droids-corp, Eirbot, Microb Technology 2005 - Zer0
23  * Config for PWM
24  */
25 /** \file pwm_config.h
26     \brief Module to operate all PWM outputs
27
28     \test not tested
29  
30 */
31
32
33 #ifndef _PWM_CONFIG_
34 #define _PWM_CONFIG_
35
36 #define _PWM_CONFIG_VERSION_ 2
37
38 /* Which PWM are enabled ? */
39 //#define PWM0_ENABLED
40 #define PWM1A_ENABLED
41 //#define PWM1B_ENABLED
42 //#define PWM1C_ENABLED
43 //#define PWM2_ENABLED
44 //#define PWM3A_ENABLED
45 //#define PWM3B_ENABLED
46 //#define PWM3C_ENABLED
47
48
49 /** max value for PWM entry, default 12 bits > 4095 */
50 #define PWM_SIGNIFICANT_BITS 12
51
52 // timer configs (not all possibilities can be used at this time)
53 #define TIMER0_MODE     TIMER_8_MODE_PWM
54 #define TIMER0_PRESCALE TIMER0_PRESCALER_DIV_64
55
56 #define TIMER1_MODE     TIMER_16_MODE_PWM_10
57 #define TIMER1_PRESCALE TIMER1_PRESCALER_DIV_8
58
59 #define TIMER2_MODE     TIMER_8_MODE_PWM
60 #define TIMER2_PRESCALE TIMER1_PRESCALER_DIV_64
61
62 #define TIMER3_MODE     TIMER_16_MODE_PWM_10
63 #define TIMER3_PRESCALE TIMER3_PRESCALER_DIV_8
64
65
66
67
68 /** config for pwm and signs
69
70 The pwm mode is defined as follows :
71 you can add flags like the ones who follow : 
72
73 PWM_NORMAL            : normal pwm, just to put a value if nothing else is needed
74 PWM_REVERSE           : invert pwm output, not sign
75
76 PWM_SIGNED            : activate the sign output on a port (see config)
77 PWM_SIGN_INVERTED     : invert sign output
78 PWM_SPECIAL_SIGN_MODE : if defined, the pwm is always near 0 for low values, 
79                         else negative low values are near 100%
80
81
82 the values of PWMxx_SIGN_PORT and PWMxx_SIGN_BIT are simply ignored if the PWM is not signed
83
84
85 if you need for example a PWM1A with special sign mode you configure like this : 
86
87 #define PWM1A_MODE       (PWM_SIGNED | PWM_SPECIAL_SIGN_MODE)
88 #define PWM1A_SIGN_PORT  PORTB
89 #define PWM1A_SIGN_BIT   2
90
91 */
92
93
94
95 // example for signed pwm1A
96 #define PWM1A_MODE       (PWM_SIGNED)
97 #define PWM1A_SIGN_PORT  PORTB
98 #define PWM1A_SIGN_BIT   2
99
100
101
102
103
104 /** 
105 PWM synchronization.
106
107 this makes the PWMs synchronized.
108 just activate the timers you want to synchronize
109
110 to synch PWMs you need to enshure that the timers have same prescales. This is verified.
111 you need also to enshure that the PWM mode is the same, this is NOT verified !!
112 especially, for syncing 8 and 16 bit timers, the PWM mode should be 8 bit.
113
114
115 side effect : on some controllers prescalers are shared, so unwanted prescalers can be reset.
116
117 This feature is not 100% shure for the moment, but has been tested on M32 and M128
118 */
119
120 //#define TIMER0_SYNCH
121 //#define TIMER1_SYNCH
122 //#define TIMER2_SYNCH
123 //#define TIMER3_SYNCH
124
125
126
127 #endif
128