Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / NUCLEO-L476RG / module.c @ e375d633

History | View | Annotate | Download (6.011 KB)

1 27d0378b Simon Welzel
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3 96621a83 Thomas Schöpping
Copyright (C) 2016..2020  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 126ace3c Thomas Schöpping
 * @brief   Structures and constant for the NUCLEO-L476RG module.
22 27d0378b Simon Welzel
 *
23 126ace3c Thomas Schöpping
 * @addtogroup NUCLEO-L476RG_module
24 27d0378b Simon Welzel
 * @{
25
 */
26
27 126ace3c Thomas Schöpping
#include <amiroos.h>
28 27d0378b Simon Welzel
29
/*===========================================================================*/
30
/**
31
 * @name Module specific functions
32
 * @{
33
 */
34
/*===========================================================================*/
35
36
/** @} */
37
38
/*===========================================================================*/
39
/**
40
 * @name ChibiOS/HAL configuration
41
 * @{
42
 */
43
/*===========================================================================*/
44
45
SerialConfig moduleHalProgIfConfig = {
46
  /* bit rate */ 115200,
47
  /* CR1      */ 0,
48
  /* CR1      */ 0,
49
  /* CR1      */ 0,
50
};
51
52 db6bd9f8 Thomas Schöpping
I2CConfig moduleHalI2cConfig = {
53
  /* timing reg */ 0, // configured later in MODULE_INIT_PERIPHERY_IF hook
54 126ace3c Thomas Schöpping
  /* CR1        */ 0,
55
  /* CR2        */ 0,
56
};
57
58 27d0378b Simon Welzel
/** @} */
59
60 8543d0d9 Thomas Schöpping
/*===========================================================================*/
61
/**
62
 * @name GPIO definitions
63
 * @{
64
 */
65
/*===========================================================================*/
66
67
/**
68 a0301104 Thomas Schöpping
 * @brief   LED output signal GPIO.
69 8543d0d9 Thomas Schöpping
 */
70
static apalGpio_t _gpioLed = {
71 3106e8cc Thomas Schöpping
  /* line */ LINE_LED_GREEN,
72 8543d0d9 Thomas Schöpping
};
73
ROMCONST apalControlGpio_t moduleGpioLed = {
74
  /* GPIO */ &_gpioLed,
75
  /* meta */ {
76
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
77
    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
78
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
79
  },
80
};
81
82
/**
83
 * @brief   User button input signal GPIO.
84
 */
85
static apalGpio_t _gpioUserButton = {
86 3106e8cc Thomas Schöpping
  /* line */ LINE_BUTTON,
87 8543d0d9 Thomas Schöpping
};
88
ROMCONST apalControlGpio_t moduleGpioUserButton = {
89
  /* GPIO */ &_gpioUserButton,
90
  /* meta */ {
91
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
92 83e94d4b Thomas Schöpping
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
93 8543d0d9 Thomas Schöpping
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
94
  },
95
};
96
97
/** @} */
98 27d0378b Simon Welzel
99
/*===========================================================================*/
100
/**
101
 * @name AMiRo-OS core configurations
102
 * @{
103
 */
104
/*===========================================================================*/
105
106 cda14729 Thomas Schöpping
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__)
107 a0301104 Thomas Schöpping
ROMCONST char* moduleShellPrompt = "NUCLEO-L476RG";
108 cda14729 Thomas Schöpping
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) */
109 27d0378b Simon Welzel
110 8543d0d9 Thomas Schöpping
/** @} */
111 27d0378b Simon Welzel
112 8543d0d9 Thomas Schöpping
/*===========================================================================*/
113
/**
114
 * @name Startup Shutdown Synchronization Protocol (SSSP)
115
 * @{
116
 */
117
/*===========================================================================*/
118
119
/** @} */
120
121
/*===========================================================================*/
122
/**
123
 * @name Low-level drivers
124
 * @{
125
 */
126
/*===========================================================================*/
127
128 4c72a54c Thomas Schöpping
LEDDriver moduleLldLed = {
129
  /* LED enable Gpio */ &moduleGpioLed,
130
};
131
132
ButtonDriver moduleLldUserButton = {
133
  /* Button Gpio  */ &moduleGpioUserButton,
134
};
135
136
#if (BOARD_MPU6050_CONNECTED == true)
137 126ace3c Thomas Schöpping
138
MPU6050Driver moduleLldMpu6050 = {
139 db6bd9f8 Thomas Schöpping
  /* I2C Driver       */ &MODULE_HAL_I2C,
140 126ace3c Thomas Schöpping
  /* I²C address      */ MPU6050_LLD_I2C_ADDR_FIXED,
141
};
142
143 4c72a54c Thomas Schöpping
#endif /* (BOARD_MPU6050_CONNECTED == true) */
144 126ace3c Thomas Schöpping
145 8543d0d9 Thomas Schöpping
/** @} */
146
147
/*===========================================================================*/
148
/**
149 4c72a54c Thomas Schöpping
 * @name Tests
150 8543d0d9 Thomas Schöpping
 * @{
151
 */
152
/*===========================================================================*/
153
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
154 1678f270 Simon Welzel
155 4c72a54c Thomas Schöpping
/*
156
 * LED
157
 */
158
#include <module_test_LED.h>
159
static int _testLedShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
160
{
161
  return moduleTestLedShellCb(stream, argc, argv, NULL);
162
}
163
AOS_SHELL_COMMAND(moduleTestLedShellCmd, "test:LED", _testLedShellCmdCb);
164
165
/*
166
 * User button
167
 */
168
#include <module_test_button.h>
169
static int _testButtonShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
170
{
171
  return moduleTestButtonShellCb(stream, argc, argv, NULL);
172
}
173
AOS_SHELL_COMMAND(moduleTestButtonShellCmd, "test:button", _testButtonShellCmdCb);
174
175
#if (BOARD_MPU6050_CONNECTED == true) || defined(__DOXYGEN__)
176
177
/*
178
 * MPU6050 (accelerometer & gyroscope)
179
 */
180
#include <module_test_MPU6050.h>
181
static int _testMpu6050ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
182
{
183
  return moduleTestMpu6050ShellCb(stream, argc, argv, NULL);
184
}
185
AOS_SHELL_COMMAND(moduleTestMpu6050ShellCmd, "test:IMU", _testMpu6050ShellCmdCb);
186
187
#endif /* (BOARD_MPU6050_CONNECTED == true) */
188 126ace3c Thomas Schöpping
189 4c72a54c Thomas Schöpping
/*
190
 * entire module
191
 */
192
static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
193 126ace3c Thomas Schöpping
{
194
  (void)argc;
195
  (void)argv;
196
197 4c72a54c Thomas Schöpping
  int status = AOS_OK;
198
  char* targv[AMIROOS_CFG_SHELL_MAXARGS] = {NULL};
199
  aos_testresult_t result_test = {0, 0};
200
  aos_testresult_t result_total = {0, 0};
201
202
  /* LED */
203
  status |= moduleTestLedShellCb(stream, 0, targv, &result_test);
204
  result_total = aosTestResultAdd(result_total, result_test);
205
206
  /* User button */
207
  status |= moduleTestButtonShellCb(stream, 0, targv, &result_test);
208
  result_total = aosTestResultAdd(result_total, result_test);
209
210
  /* MPU6050 (accelerometer & gyroscope) */
211
#if (BOARD_MPU6050_CONNECTED == true)
212
  status |= moduleTestMpu6050ShellCb(stream, 0, targv, &result_test);
213
  result_total = aosTestResultAdd(result_total, result_test);
214
#endif /* (BOARD_MPU6050_CONNECTED == true) */
215
216
  // print total result
217
  chprintf(stream, "\n");
218
  aosTestResultPrintSummary(stream, &result_total, "entire module");
219
220
  return status;
221
}
222
AOS_SHELL_COMMAND(moduleTestAllShellCmd, "test:all", _testAllShellCmdCb);
223 126ace3c Thomas Schöpping
224 7de0cc90 Thomas Schöpping
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
225 8543d0d9 Thomas Schöpping
226
/** @} */
227 27d0378b Simon Welzel
/** @} */