amiro-lld / periphALtypes.h @ d6728c5b
History | View | Annotate | Download (6.73 KB)
1 |
/*
|
---|---|
2 |
AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous Mini Robot (AMiRo) platform.
|
3 |
Copyright (C) 2016..2018 Thomas Schöpping et al.
|
4 |
|
5 |
This program is free software: you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License as published by
|
7 |
the Free Software Foundation, either version 3 of the License, or
|
8 |
(at your option) any later version.
|
9 |
|
10 |
This program is distributed in the hope that it will be useful,
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
GNU General Public License for more details.
|
14 |
|
15 |
You should have received a copy of the GNU General Public License
|
16 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17 |
*/
|
18 |
|
19 |
#ifndef _AMIROLLD_PERIPHALTYPES_H_
|
20 |
#define _AMIROLLD_PERIPHALTYPES_H_
|
21 |
|
22 |
/*============================================================================*/
|
23 |
/* DEPENDENCIES */
|
24 |
/*============================================================================*/
|
25 |
|
26 |
#include <stdint.h> |
27 |
|
28 |
/*============================================================================*/
|
29 |
/* GENERAL */
|
30 |
/*============================================================================*/
|
31 |
|
32 |
/**
|
33 |
* @brief Time measurement type (in microseconds).
|
34 |
*/
|
35 |
typedef uint32_t apalTime_t;
|
36 |
|
37 |
/**
|
38 |
* @brief Status values used as return value for all (or most) function calls.
|
39 |
* @note The status can be used as mask of flags.
|
40 |
*/
|
41 |
typedef enum { |
42 |
APAL_STATUS_OK = 0x00u, /**< success, no error occurred */ |
43 |
APAL_STATUS_SUCCESS = 0x00u, /**< success, no error occurred */ |
44 |
APAL_STATUS_ERROR = 0x01u, /**< failed, some unspecified error occured */ |
45 |
APAL_STATUS_FAILURE = 0x01u, /**< failed, some unspecified error occured */ |
46 |
APAL_STATUS_TIMEOUT = 0x02u, /**< failed, timeout occurred */ |
47 |
APAL_STATUS_INVALIDARGUMENTS = 0x04u, /**< failed, invalid arguments */ |
48 |
APAL_STATUS_UNAVAILABLE = 0x08u, /**< failed, function unavailable */ |
49 |
APAL_STATUS_WARNING = 0x10u, /**< success, but the result is probably not as expected */ |
50 |
} apalExitStatus_t; |
51 |
|
52 |
/*============================================================================*/
|
53 |
/* GPIO */
|
54 |
/*============================================================================*/
|
55 |
|
56 |
/**
|
57 |
* @brief Forward declaration.
|
58 |
* @details Struct must be defined in 'periphAL.h'.
|
59 |
*/
|
60 |
typedef struct apalGpio_t apalGpio_t; |
61 |
|
62 |
/**
|
63 |
* @brief Status values to read/write a GPIO port.
|
64 |
*/
|
65 |
typedef enum { |
66 |
APAL_GPIO_LOW = 0, /**< logical low state */ |
67 |
APAL_GPIO_HIGH = 1, /**< logical high state */ |
68 |
} apalGpioState_t; |
69 |
|
70 |
/**
|
71 |
* @brief Status values to turn a control GPIO 'on' and 'off'.
|
72 |
*/
|
73 |
typedef enum { |
74 |
APAL_GPIO_OFF = 0, /**< logical 'turned off' state */ |
75 |
APAL_GPIO_ON = 1, /**< logical 'turned on' state */ |
76 |
} apalControlGpioState_t; |
77 |
|
78 |
/**
|
79 |
* @brief Polarity state of the control GPIO.
|
80 |
*/
|
81 |
typedef enum { |
82 |
APAL_GPIO_ACTIVE_LOW = 0x00, /**< A logically low state is defined as 'on'. */ |
83 |
APAL_GPIO_ACTIVE_HIGH = 0x01, /**< A locically high state is defined as 'on'. */ |
84 |
} apalGpioActive_t; |
85 |
|
86 |
/**
|
87 |
* @brief Informative signal edge for input control GPIOs.
|
88 |
*/
|
89 |
typedef enum { |
90 |
APAL_GPIO_EDGE_NONE = 0x00, /**< No edge indicates an interrupt. */ |
91 |
APAL_GPIO_EDGE_RISING = 0x01, /**< Rising edges indicate an interrupt. */ |
92 |
APAL_GPIO_EDGE_FALLING = 0x02, /**< Falling edges indicate an interrupt. */ |
93 |
APAL_GPIO_EDGE_BOTH = 0x03, /**< Both rising and falling edges indicate an interrupt. */ |
94 |
} apalGpioEdge_t; |
95 |
|
96 |
/**
|
97 |
* @brief Signal direction for the control GPIO.
|
98 |
*/
|
99 |
typedef enum { |
100 |
APAL_GPIO_DIRECTION_UNDEFINED = 0x00, /**< Signal direction is undefined. */ |
101 |
APAL_GPIO_DIRECTION_INPUT = 0x01, /**< Signal direction is input only. */ |
102 |
APAL_GPIO_DIRECTION_OUTPUT = 0x02, /**< Signal direction is output only */ |
103 |
APAL_GPIO_DIRECTION_BIDIRECTIONAL = 0x03, /**< Signal direction is bidirectional. */ |
104 |
} apalGpioDirection_t; |
105 |
|
106 |
/**
|
107 |
* @brief Control GPIO meta information
|
108 |
*/
|
109 |
typedef struct { |
110 |
apalGpioActive_t active : 1; /**< Active state of the GPIO */ |
111 |
apalGpioEdge_t edge : 2; /**< Edge configuration for according signals */ |
112 |
apalGpioDirection_t direction : 2; /**< Direction configuration for according signals */ |
113 |
} apalGpioMeta_t; |
114 |
|
115 |
/**
|
116 |
* @brief Control GPIO type.
|
117 |
*/
|
118 |
typedef struct { |
119 |
apalGpio_t* gpio; /**< The GPIO to use. */
|
120 |
apalGpioMeta_t meta; /**< Meta information about the GPIO. */
|
121 |
} apalControlGpio_t; |
122 |
|
123 |
/*============================================================================*/
|
124 |
/* PWM */
|
125 |
/*============================================================================*/
|
126 |
|
127 |
/**
|
128 |
* @brief PWM channel type.
|
129 |
*/
|
130 |
typedef uint8_t apalPWMchannel_t;
|
131 |
|
132 |
/**
|
133 |
* @brief PWM width type.
|
134 |
*/
|
135 |
typedef uint16_t apalPWMwidth_t;
|
136 |
|
137 |
/**
|
138 |
* @brief PWM frequency type.
|
139 |
*/
|
140 |
typedef uint32_t apalPWMfrequency_t;
|
141 |
|
142 |
/**
|
143 |
* @brief PWM period time.
|
144 |
*/
|
145 |
typedef uint32_t apalPWMperiod_t;
|
146 |
|
147 |
/**
|
148 |
* @brief PWM width limits and special values.
|
149 |
*/
|
150 |
typedef enum { |
151 |
APAL_PWM_WIDTH_OFF = 0x0000u, /**< PWM off */ |
152 |
APAL_PWM_WIDTH_MIN = 0x0000u, /**< PWM minimum width */ |
153 |
APAL_PWM_WIDTH_MAX = 0xFFFFu, /**< PWM maximum width */ |
154 |
} apalPWMWidthLimit_t; |
155 |
|
156 |
/*============================================================================*/
|
157 |
/* QEI */
|
158 |
/*============================================================================*/
|
159 |
|
160 |
/**
|
161 |
* @brief QEI counter type.
|
162 |
*/
|
163 |
typedef uint32_t apalQEICount_t;
|
164 |
|
165 |
/**
|
166 |
* @brief Direction of the QEI.
|
167 |
*/
|
168 |
typedef enum { |
169 |
APAL_QEI_DIRECTION_UP = 0, /**< QEI counted up */ |
170 |
APAL_QEI_DIRECTION_DOWN = 1, /**< QEI counted down */ |
171 |
} apalQEIDirection_t; |
172 |
|
173 |
/*============================================================================*/
|
174 |
/* I2C */
|
175 |
/*============================================================================*/
|
176 |
|
177 |
/**
|
178 |
* @brief I2C address type.
|
179 |
*/
|
180 |
typedef uint16_t apalI2Caddr_t;
|
181 |
|
182 |
/*============================================================================*/
|
183 |
/* SPI */
|
184 |
/*============================================================================*/
|
185 |
|
186 |
|
187 |
#endif /* _AMIROLLD_PERIPHALTYPES_H_ */ |