Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / STM32L476RG-NUCLEO64 / module.h @ 27286ba5

History | View | Annotate | Download (5.977 KB)

1 27d0378b Simon Welzel
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3 8543d0d9 Thomas Schöpping
Copyright (C) 2016..2019  Thomas Schöpping et al.
4 27d0378b Simon Welzel

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
/**
20
 * @file
21
 * @brief   Structures and constant for the PowerManagement module.
22
 *
23
 * @addtogroup powermanagement_module
24
 * @{
25
 */
26
27
#ifndef _AMIROOS_MODULE_H_
28
#define _AMIROOS_MODULE_H_
29
30 8543d0d9 Thomas Schöpping
#include <amiroos.h>
31
32 27d0378b Simon Welzel
/*===========================================================================*/
33
/**
34
 * @name Module specific functions
35
 * @{
36
 */
37
/*===========================================================================*/
38
39
/** @} */
40
41
/*===========================================================================*/
42
/**
43
 * @name ChibiOS/HAL configuration
44
 * @{
45
 */
46
/*===========================================================================*/
47
48
/**
49 8543d0d9 Thomas Schöpping
 * @brief   Serial driver of the programmer interface.
50 27d0378b Simon Welzel
 */
51 8543d0d9 Thomas Schöpping
#define MODULE_HAL_PROGIF                       SD2
52 27d0378b Simon Welzel
53
/**
54 8543d0d9 Thomas Schöpping
 * @brief   Configuration for the programmer serial interface driver.
55 27d0378b Simon Welzel
 */
56 8543d0d9 Thomas Schöpping
extern SerialConfig moduleHalProgIfConfig;
57 27d0378b Simon Welzel
58
/**
59 1678f270 Simon Welzel
 * @brief   I2C driver to access multiplexer, proximity sensors 5 to 8, power monitors for VSYS4.2, VIO 5.0 and VDD, EEPROM, touch sensor, and fuel gauge (front battery).
60
 */
61 8543d0d9 Thomas Schöpping
#define MODULE_HAL_I2C_MPU6050                  I2CD3
62 1678f270 Simon Welzel
63
/**
64
 * @brief   Configuration for the multiplexer, proximity sensors 1 to 4, power monitors for VIO1.8 and VIO 3.3, and fuel gauge (rear battery) I2C driver.
65
 */
66
extern I2CConfig moduleHalI2cMpu6050Config;
67
68
/**
69 27d0378b Simon Welzel
 * @brief   Real-Time Clock driver.
70
 */
71
#define MODULE_HAL_RTC                          RTCD1
72
73
/** @} */
74
75
/*===========================================================================*/
76
/**
77
 * @name GPIO definitions
78
 * @{
79
 */
80
/*===========================================================================*/
81
82
/**
83
 * @brief   LED output signal GPIO.
84
 */
85
extern ROMCONST apalControlGpio_t moduleGpioLed;
86
87
/**
88 8543d0d9 Thomas Schöpping
 * @brief   User button input signal.
89 27d0378b Simon Welzel
 */
90 8543d0d9 Thomas Schöpping
extern ROMCONST apalControlGpio_t moduleGpioUserButton;
91 27d0378b Simon Welzel
92 8543d0d9 Thomas Schöpping
/** @} */
93 27d0378b Simon Welzel
94 8543d0d9 Thomas Schöpping
/*===========================================================================*/
95 27d0378b Simon Welzel
/**
96 8543d0d9 Thomas Schöpping
 * @name AMiRo-OS core configurations
97
 * @{
98 27d0378b Simon Welzel
 */
99 8543d0d9 Thomas Schöpping
/*===========================================================================*/
100 27d0378b Simon Welzel
101
/**
102 8543d0d9 Thomas Schöpping
 * @brief   Event flag to be set on a USER_BUTTON interrupt.
103 27d0378b Simon Welzel
 */
104 8543d0d9 Thomas Schöpping
#define MODULE_OS_IOEVENTFLAGS_USERBUTTON       AOS_IOEVENT_FLAG(GPIOC_BUTTON)
105 27d0378b Simon Welzel
106 8543d0d9 Thomas Schöpping
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
107 27d0378b Simon Welzel
/**
108 8543d0d9 Thomas Schöpping
 * @brief   Shell prompt text.
109 27d0378b Simon Welzel
 */
110 8543d0d9 Thomas Schöpping
extern ROMCONST char* moduleShellPrompt;
111
#endif
112 27d0378b Simon Welzel
113
/**
114 8543d0d9 Thomas Schöpping
 * @brief   Interrupt initialization macro.
115
 * @note    SSSP related interrupt signals are already initialized in 'aos_system.c'.
116 27d0378b Simon Welzel
 */
117 8543d0d9 Thomas Schöpping
#define MODULE_INIT_INTERRUPTS() {                                            \
118
  /* user button */                                                           \
119
  palSetPadCallback(moduleGpioUserButton.gpio->port, moduleGpioUserButton.gpio->pad, _intCallback, &moduleGpioUserButton.gpio->pad);  \
120
  palEnablePadEvent(moduleGpioUserButton.gpio->port, moduleGpioUserButton.gpio->pad, APAL2CH_EDGE(moduleGpioUserButton.meta.edge));   \
121
}
122 27d0378b Simon Welzel
123
/**
124 8543d0d9 Thomas Schöpping
 * @brief   Unit test initialization hook.
125 27d0378b Simon Welzel
 */
126 8543d0d9 Thomas Schöpping
#define MODULE_INIT_TESTS() {                                                 \
127
  /* add unit-test shell commands */                                          \
128
  aosShellAddCommand(&aos.shell, &moduleUtAlldMpu6050.shellcmd);              \
129
}
130 27d0378b Simon Welzel
131
/**
132 8543d0d9 Thomas Schöpping
 * @brief   Periphery communication interfaces initialization hook.
133 27d0378b Simon Welzel
 */
134 8543d0d9 Thomas Schöpping
#define MODULE_INIT_PERIPHERY_COMM() {                                        \
135
  /* serial driver */                                                         \
136
  sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig);                        \
137
}
138 27d0378b Simon Welzel
139
/**
140 8543d0d9 Thomas Schöpping
 * @brief   Periphery communication interface deinitialization hook.
141 27d0378b Simon Welzel
 */
142 8543d0d9 Thomas Schöpping
#define MODULE_SHUTDOWN_PERIPHERY_COMM() {                                    \
143
}
144 27d0378b Simon Welzel
145
/**
146 8543d0d9 Thomas Schöpping
 * @brief   HOOK to toggle the LEDs when the user button is pressed.
147 27d0378b Simon Welzel
 */
148 8543d0d9 Thomas Schöpping
#define MODULE_MAIN_LOOP_IO_EVENT(eventflags) {                    \
149
  if (eventflags & MODULE_OS_IOEVENTFLAGS_USERBUTTON) {                       \
150
    apalControlGpioState_t buttonstate;                                       \
151
    apalControlGpioGet(&moduleGpioUserButton, &buttonstate);                  \
152
    apalControlGpioSet(&moduleGpioLed, buttonstate);                          \
153
  }                                                                           \
154
}
155 27d0378b Simon Welzel
156
/** @} */
157
158
/*===========================================================================*/
159
/**
160 8543d0d9 Thomas Schöpping
 * @name Startup Shutdown Synchronization Protocol (SSSP)
161 27d0378b Simon Welzel
 * @{
162
 */
163
/*===========================================================================*/
164
165 8543d0d9 Thomas Schöpping
/** @} */
166 27d0378b Simon Welzel
167 8543d0d9 Thomas Schöpping
/*===========================================================================*/
168 27d0378b Simon Welzel
/**
169 8543d0d9 Thomas Schöpping
 * @name Low-level drivers
170
 * @{
171 27d0378b Simon Welzel
 */
172 8543d0d9 Thomas Schöpping
/*===========================================================================*/
173 27d0378b Simon Welzel
174 8543d0d9 Thomas Schöpping
//#include <alld_mpu6050.h>
175 27d0378b Simon Welzel
176
/**
177 8543d0d9 Thomas Schöpping
 * @brief   Accelerometer (MPU6050) driver.
178 1678f270 Simon Welzel
 */
179 8543d0d9 Thomas Schöpping
//extern MPU6050Driver moduleLldMpu6050;
180 1678f270 Simon Welzel
181 8543d0d9 Thomas Schöpping
/** @} */
182 1678f270 Simon Welzel
183 8543d0d9 Thomas Schöpping
/*===========================================================================*/
184 1678f270 Simon Welzel
/**
185 8543d0d9 Thomas Schöpping
 * @name Unit tests (UT)
186
 * @{
187 1678f270 Simon Welzel
 */
188 8543d0d9 Thomas Schöpping
/*===========================================================================*/
189
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
190 1678f270 Simon Welzel
191
#include <ut_alld_mpu6050.h>
192
193
/**
194
 * @brief   MPU6050 unit test object.
195
 */
196
extern aos_unittest_t moduleUtAlldMpu6050;
197
198 8543d0d9 Thomas Schöpping
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
199
200
/** @} */
201
202 27d0378b Simon Welzel
#endif /* _AMIROOS_MODULE_H_ */
203
204
/** @} */