add ballboard commands on mainboard
[aversive.git] / modules / hardware / pwm / pwm.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.h,v 1.7.4.7 2008-04-06 17:33:57 zer0 Exp $
19  *
20  */
21
22 /* Droids-corp, Eirbot, Microb Technology 2005 - Zer0
23  * Implementation for PWM
24  */
25 /** \file pwm.h
26  *  \brief Interface for the PWM module.
27  *
28  *  \todo Test the module.
29  *
30  *  \test No tests for the moment.
31  *
32  * This module provides functions for using a pwm 
33  */
34
35 #ifndef _PWM_H_
36 #define _PWM_H_
37
38 #include <aversive.h>
39 #include <aversive/timers.h>
40 #include <aversive/parts.h>
41 #include <pwm_config.h>
42
43
44
45 /** PWM signs & sign ligne inversion */
46 #define PWM_NORMAL                           0x00 
47 #define PWM_REVERSE                          0x01
48 #define PWM_SIGN_INVERTED                    0x02
49 #define PWM_SIGNED                           0x04
50 #define PWM_SPECIAL_SIGN_MODE                0x08
51
52 /** value to be used for limiting inputs */
53 #define PWM_MAX ((1<< PWM_SIGNIFICANT_BITS)-1)
54 #define PWM_MIN (-PWM_MAX)
55
56
57  /** global functions*/
58 extern void pwm_init(void);
59
60 /** apply a PWM.
61  * \param data is a pointer that is casted in (uint8_t) to
62  *        specify the number of the PWM.
63  * \param value is the value of the pwm.
64  */
65 extern void pwm_set(void * data, int32_t value); 
66
67
68 #if (defined PWM1A_NUM) && (defined PWM1A_ENABLED)
69 extern void pwm_init_1A(void);
70 extern void pwm_set_1A(int16_t value);
71 #endif // (defined PWM1A_NUM) && (defined PWM1A_ENABLED)
72
73 #if (defined PWM1B_NUM) && (defined PWM1B_ENABLED)
74 extern void pwm_init_1B(void);
75 extern void pwm_set_1B(int16_t value);
76 #endif // (defined PWM1B_NUM) && (defined PWM1B_ENABLED)
77
78 #if (defined PWM1C_NUM) && (defined PWM1C_ENABLED)
79 extern void pwm_init_1C(void);
80 extern void pwm_set_1C(int16_t value);
81 #endif // (defined PWM1C_NUM) && (defined PWM1C_ENABLED)
82
83 #if (defined PWM2_NUM) && (defined PWM2_ENABLED)
84 extern void pwm_init_2(void);
85 extern void pwm_set_2(int16_t value);
86 #endif // (defined PWM2_NUM) && (defined PWM2_ENABLED)
87
88 #if (defined PWM3A_NUM) && (defined PWM3A_ENABLED)
89 extern void pwm_init_3A(void);
90 extern void pwm_set_3A(int16_t value);
91 #endif // (defined PWM3A_NUM) && (defined PWM3A_ENABLED)
92
93 #if (defined PWM3B_NUM) && (defined PWM3B_ENABLED)
94 extern void pwm_init_3B(void);
95 extern void pwm_set_3B(int16_t value);
96 #endif // (defined PWM3B_NUM) && (defined PWM3B_ENABLED)
97
98 #if (defined PWM3C_NUM) && (defined PWM3C_ENABLED)
99 extern void pwm_init_3C(void);
100 extern void pwm_set_3C(int16_t value);
101 #endif // (defined PWM3C_NUM) && (defined PWM3C_ENABLED)
102
103
104 #endif // _PWM_H_