Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (6.011 KB)

1
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2020  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
/**
20
 * @file
21
 * @brief   Structures and constant for the NUCLEO-L476RG module.
22
 *
23
 * @addtogroup NUCLEO-L476RG_module
24
 * @{
25
 */
26

    
27
#include <amiroos.h>
28

    
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
I2CConfig moduleHalI2cConfig = {
53
  /* timing reg */ 0, // configured later in MODULE_INIT_PERIPHERY_IF hook
54
  /* CR1        */ 0,
55
  /* CR2        */ 0,
56
};
57

    
58
/** @} */
59

    
60
/*===========================================================================*/
61
/**
62
 * @name GPIO definitions
63
 * @{
64
 */
65
/*===========================================================================*/
66

    
67
/**
68
 * @brief   LED output signal GPIO.
69
 */
70
static apalGpio_t _gpioLed = {
71
  /* line */ LINE_LED_GREEN,
72
};
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
  /* line */ LINE_BUTTON,
87
};
88
ROMCONST apalControlGpio_t moduleGpioUserButton = {
89
  /* GPIO */ &_gpioUserButton,
90
  /* meta */ {
91
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
92
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
93
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
94
  },
95
};
96

    
97
/** @} */
98

    
99
/*===========================================================================*/
100
/**
101
 * @name AMiRo-OS core configurations
102
 * @{
103
 */
104
/*===========================================================================*/
105

    
106
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__)
107
ROMCONST char* moduleShellPrompt = "NUCLEO-L476RG";
108
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) */
109

    
110
/** @} */
111

    
112
/*===========================================================================*/
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
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

    
138
MPU6050Driver moduleLldMpu6050 = {
139
  /* I2C Driver       */ &MODULE_HAL_I2C,
140
  /* I²C address      */ MPU6050_LLD_I2C_ADDR_FIXED,
141
};
142

    
143
#endif /* (BOARD_MPU6050_CONNECTED == true) */
144

    
145
/** @} */
146

    
147
/*===========================================================================*/
148
/**
149
 * @name Tests
150
 * @{
151
 */
152
/*===========================================================================*/
153
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
154

    
155
/*
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

    
189
/*
190
 * entire module
191
 */
192
static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
193
{
194
  (void)argc;
195
  (void)argv;
196

    
197
  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

    
224
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
225

    
226
/** @} */
227
/** @} */