Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / STM32F407G-DISC1 / module.h @ 1a8fb642

History | View | Annotate | Download (6.674 KB)

1 07ff44a7 Thomas Schöpping
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3 84f0ce9e Thomas Schöpping
Copyright (C) 2016..2019  Thomas Schöpping et al.
4 07ff44a7 Thomas Schöpping

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 a0301104 Thomas Schöpping
 * @brief   Structures and constant for the STM32F4Discovery module.
22 07ff44a7 Thomas Schöpping
 *
23 a0301104 Thomas Schöpping
 * @addtogroup STM32F4Discovery_module
24 07ff44a7 Thomas Schöpping
 * @{
25
 */
26
27 6ff06bbf Thomas Schöpping
#ifndef AMIROOS_MODULE_H
28
#define AMIROOS_MODULE_H
29 07ff44a7 Thomas Schöpping
30 e2d7143f Thomas Schöpping
#include <amiroos.h>
31
32 07ff44a7 Thomas Schöpping
/*===========================================================================*/
33
/**
34
 * @name Module specific functions
35
 * @{
36
 */
37
/*===========================================================================*/
38
39
/*
40
 * @brief Makro to store data in the core coupled memory (ccm).
41
 *        Example:
42
 *        int compute_buffer[128] CCM_RAM;
43
 *
44
 * @note The ccm is not connected to any bus system.
45
 */
46
#define CCM_RAM                                 __attribute__((section(".ram4"), aligned(4)))
47
48
/*
49
 * @brief Makro to store data in the ethernet memory (eth).
50
 *        Example:
51
 *        int dma_buffer[128] ETH_RAM;
52
 *
53
 * @note The eth is a dedicated memory block with its own DMA controller.
54
 */
55
#define ETH_RAM                                 __attribute__((section(".ram2"), aligned(4)))
56
57
/*
58
 * @brief Makro to store data in the backup memory (bckp).
59
 *        Example:
60
 *        int backup_buffer[128] BCKP_RAM;
61
 *
62
 * @note The eth is a dedicated memory block with its own DMA controller.
63
 */
64
#define BCKP_RAM                                __attribute__((section(".ram5"), aligned(4)))
65
66
/** @} */
67
68
/*===========================================================================*/
69
/**
70
 * @name ChibiOS/HAL configuration
71
 * @{
72
 */
73
/*===========================================================================*/
74
75
/**
76
 * @brief   Serial driver of the programmer interface.
77
 */
78
#define MODULE_HAL_PROGIF                       SD2
79
80
/**
81
 * @brief   Configuration for the programmer serial interface driver.
82
 */
83
extern SerialConfig moduleHalProgIfConfig;
84
85
/**
86
 * @brief   Real-Time Clock driver.
87
 */
88
#define MODULE_HAL_RTC                          RTCD1
89
90
/** @} */
91
92
/*===========================================================================*/
93
/**
94
 * @name GPIO definitions
95
 * @{
96
 */
97
/*===========================================================================*/
98
99
/**
100
 * @brief   Red LED output signal.
101
 */
102
extern ROMCONST apalControlGpio_t moduleGpioLedRed;
103
104
/**
105
 * @brief   Green LED output signal.
106
 */
107
extern ROMCONST apalControlGpio_t moduleGpioLedGreen;
108
109
/**
110
 * @brief   Blue LED output signal.
111
 */
112
extern ROMCONST apalControlGpio_t moduleGpioLedBlue;
113
114
/**
115
 * @brief   Orange LED output signal.
116
 */
117
extern ROMCONST apalControlGpio_t moduleGpioLedOrange;
118
119
/**
120
 * @brief   User button input signal.
121
 */
122
extern ROMCONST apalControlGpio_t moduleGpioUserButton;
123
124
/** @} */
125
126
/*===========================================================================*/
127
/**
128
 * @name AMiRo-OS core configurations
129
 * @{
130
 */
131
/*===========================================================================*/
132
133
/**
134
 * @brief   Event flag to be set on a USER_BUTTON interrupt.
135
 */
136 1a8fb642 Thomas Schöpping
#define MODULE_OS_GPIOEVENTFLAG_USERBUTTON      AOS_GPIOEVENT_FLAG(PAL_PAD(LINE_BUTTON))
137 07ff44a7 Thomas Schöpping
138 47e89ebf Thomas Schöpping
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__)
139 07ff44a7 Thomas Schöpping
/**
140
 * @brief   Shell prompt text.
141
 */
142
extern ROMCONST char* moduleShellPrompt;
143 47e89ebf Thomas Schöpping
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) */
144 07ff44a7 Thomas Schöpping
145
/**
146
 * @brief   Interrupt initialization macro.
147
 * @note    SSSP related interrupt signals are already initialized in 'aos_system.c'.
148
 */
149
#define MODULE_INIT_INTERRUPTS() {                                            \
150
  /* user button */                                                           \
151 1a8fb642 Thomas Schöpping
  palSetLineCallback(moduleGpioUserButton.gpio->line, aosSysGetStdGpioCallback(), &moduleGpioUserButton.gpio->line);  \
152 56dc4779 Thomas Schöpping
  palEnableLineEvent(moduleGpioUserButton.gpio->line, APAL2CH_EDGE(moduleGpioUserButton.meta.edge));                  \
153 07ff44a7 Thomas Schöpping
}
154
155
/**
156 1a8fb642 Thomas Schöpping
 * @brief   Test initialization hook.
157 07ff44a7 Thomas Schöpping
 */
158
#define MODULE_INIT_TESTS() {                                                 \
159 1a8fb642 Thomas Schöpping
  /* add test commands to shell */                                            \
160 07ff44a7 Thomas Schöpping
}
161
162
/**
163
 * @brief   Periphery communication interfaces initialization hook.
164
 */
165 4c72a54c Thomas Schöpping
#define MODULE_INIT_PERIPHERY_IF() {                                          \
166 07ff44a7 Thomas Schöpping
  /* serial driver */                                                         \
167
  sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig);                        \
168
}
169
170
/**
171
 * @brief   Periphery communication interface deinitialization hook.
172
 */
173 4c72a54c Thomas Schöpping
#define MODULE_SHUTDOWN_PERIPHERY_IF() {                                      \
174 1a8fb642 Thomas Schöpping
  /* don't stop the serial driver so messages can still be printed */         \
175 07ff44a7 Thomas Schöpping
}
176
177
/**
178
 * @brief   HOOK to toggle the LEDs when the user button is pressed.
179
 */
180 1a8fb642 Thomas Schöpping
#define MODULE_MAIN_LOOP_GPIOEVENT(eventflags) {                              \
181
  if (eventflags & MODULE_OS_GPIOEVENTFLAG_USERBUTTON) {                      \
182 c9cecdb6 Thomas Schöpping
    apalControlGpioState_t buttonstate;                                       \
183
    apalControlGpioGet(&moduleGpioUserButton, &buttonstate);                  \
184
    apalControlGpioSet(&moduleGpioLedRed, buttonstate);                       \
185
    apalControlGpioSet(&moduleGpioLedGreen, buttonstate);                     \
186
    apalControlGpioSet(&moduleGpioLedBlue, buttonstate);                      \
187
    apalControlGpioSet(&moduleGpioLedOrange, buttonstate);                    \
188 07ff44a7 Thomas Schöpping
  }                                                                           \
189
}
190
191
/** @} */
192
193
/*===========================================================================*/
194
/**
195
 * @name Startup Shutdown Synchronization Protocol (SSSP)
196
 * @{
197
 */
198
/*===========================================================================*/
199
200
/** @} */
201
202
/*===========================================================================*/
203
/**
204
 * @name Low-level drivers
205
 * @{
206
 */
207
/*===========================================================================*/
208
209
/** @} */
210
211
/*===========================================================================*/
212
/**
213 4c72a54c Thomas Schöpping
 * @name Tests
214 07ff44a7 Thomas Schöpping
 * @{
215
 */
216
/*===========================================================================*/
217
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
218
219 7de0cc90 Thomas Schöpping
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
220 07ff44a7 Thomas Schöpping
221
/** @} */
222
223 6ff06bbf Thomas Schöpping
#endif /* AMIROOS_MODULE_H */
224 07ff44a7 Thomas Schöpping
225
/** @} */