Revision e05848a6

View differences:

kernel/ChibiOS
1
Subproject commit 3a1b71ebdcf2687385f1b327feef0de7ccacb1f4
1
Subproject commit 27227574f700b45e9a476af8dbae3fedbdfb8871
modules/LightRing_1-0/alldconf.h
58 58
 */
59 59
#define AMIROLLD_CFG_USE_TPS2051BDBV
60 60

  
61
/**
62
 * @brief   Enable flag for the DW1000.
63
 */
64
#define AMIROLLD_CFG_USE_DW1000
65

  
61 66
#endif /* _ALLDCONF_H_ */
62 67

  
63 68
/** @} */
modules/LightRing_1-0/module.c
16 16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17
*/
18 18

  
19
/**
20
 * @file    
21
 * @brief   Structures and constant for the LightRing module.
22
 *
23
 * @addtogroup lightring_module
24
 * @{
25
 */
26

  
27 19
#include "module.h"
28 20

  
29 21
#include <amiroos.h>
......
35 27
 */
36 28
/*===========================================================================*/
37 29

  
30

  
38 31
/** @} */
39 32

  
40 33
/*===========================================================================*/
......
71 64
  /* CR2                         */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN,
72 65
};
73 66

  
74
SPIConfig moduleHalSpiWlConfig = {
67
SPIConfig moduleHalSpiUWBConfig = {
75 68
  /* circular buffer mode        */ false,
76 69
  /* callback function pointer   */ NULL,
77 70
  /* chip select line port       */ GPIOB,
78 71
  /* chip select line pad number */ GPIOB_WL_SS_N,
79
  /* CR1                         */ SPI_CR1_BR_0,
72
  /* CR1                         */ SPI_CR1_BR_0 | SPI_CR1_BR_1,
80 73
  /* CR2                         */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN,
81 74
};
82 75

  
......
151 144
  },
152 145
};
153 146

  
147
//INFO WL_GDO2,WL_GDO0 /  -> UWB EXTI config.
148

  
154 149
/**
155 150
 * @brief   WL_GDO2 input signal GPIO.
156 151
 */
......
278 273
  /* laser overcurrent GPIO */ &moduleGpioLaserOc,
279 274
};
280 275

  
276

  
277
DW1000Driver moduleLldDW1000 = {
278
  /* SPI driver */ &MODULE_HAL_SPI_UWB,
279
  /* EXTI GPIO  */ &_gpioWlGdo2,
280
  /* RESET GPIO */ &_gpioWlGdo2,
281

  
282
};
283

  
281 284
/** @} */
282 285

  
283 286
/*===========================================================================*/
......
352 355
  /* data           */ &moduleLldPowerSwitchLaser,
353 356
};
354 357

  
358
/* UWB Module */
359
static int _utShellCmdCb_Dw1000(BaseSequentialStream* stream, int argc, char* argv[])
360
{
361
  (void)argc;
362
  (void)argv;
363
  aosUtRun(stream,&moduleUtAlldDw1000, NULL);
364
  return AOS_OK;
365
}
366
aos_unittest_t moduleUtAlldDw1000 = {
367
  /* info           */ "DW1000",
368
  /* name           */ "UWB Module",
369
  /* test function  */ utAlldDw1000Func,
370
  /* shell command  */ {
371
    /* name     */ "unittest:UWB",
372
    /* callback */ _utShellCmdCb_Dw1000,
373
    /* next     */ NULL,
374
  },
375
  /* data           */ &moduleLldDW1000,
376
};
377

  
355 378
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
356 379

  
357 380
/** @} */
358
/** @} */
modules/LightRing_1-0/module.h
16 16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17
*/
18 18

  
19
/**
20
 * @file    
21
 * @brief   Structures and constant for the LightRing module.
22
 *
23
 * @addtogroup lightring_module
24
 * @{
25
 */
26

  
27 19
#ifndef _AMIROOS_MODULE_H_
28 20
#define _AMIROOS_MODULE_H_
29 21

  
......
34 26
 */
35 27
/*===========================================================================*/
36 28

  
29
static void _alld_dw1000_callback(void* args);
30

  
37 31
/** @} */
38 32

  
39 33
/*===========================================================================*/
......
80 74
#define MODULE_HAL_SPI_LIGHT                    SPID1
81 75

  
82 76
/**
83
 * @brief   Configuration for the SPI interface driver to communicate with the LED driver.
77
 * @brief   SPI interface driver for UWB Module.
84 78
 */
85
extern SPIConfig moduleHalSpiLightConfig;
79
#define MODULE_HAL_SPI_UWB                      SPID2
86 80

  
87 81
/**
88
 * @brief   SPI interface driver for the wireless transceiver.
82
 * @brief   Configuration for the SPI interface driver to communicate with the LED driver.
89 83
 */
90
#define MODULE_HAL_SPI_WL                       SPID2
84
extern SPIConfig moduleHalSpiLightConfig;
91 85

  
92 86
/**
93
 * @brief   Configuration for the SPI interface driver to communicate with the wireless transceiver.
87
 * @brief   Configuration for the SPI interface driver to communicate with the LED driver.
94 88
 */
95
extern SPIConfig moduleHalSpiWlConfig;
89
extern SPIConfig moduleHalSpiUWBConfig;
96 90

  
97 91
/**
98 92
 * @brief   Real-Time Clock driver.
......
200 194
extern const char* moduleShellPrompt;
201 195
#endif
202 196

  
197

  
198

  
199

  
203 200
/**
204 201
 * @brief   Interrupt initialization macro.
205 202
 * @note    SSSP related interrupt signals are already initialized in 'aos_system.c'.
......
209 206
  palSetPadCallback(moduleGpioLaserOc.gpio->port, moduleGpioLaserOc.gpio->pad, _intCallback, &moduleGpioLaserOc.gpio->pad); \
210 207
  palEnablePadEvent(moduleGpioLaserOc.gpio->port, moduleGpioLaserOc.gpio->pad, APAL2CH_EDGE(moduleGpioLaserOc.meta.edge));  \
211 208
  /* WL_GDO2 */                                                               \
212
  palSetPadCallback(moduleGpioWlGdo2.gpio->port, moduleGpioWlGdo2.gpio->pad, _intCallback, &moduleGpioWlGdo2.gpio->pad);  \
209
  palSetPadCallback(moduleGpioWlGdo2.gpio->port, moduleGpioWlGdo2.gpio->pad, _alld_dw1000_callback, &moduleGpioWlGdo2.gpio->pad);  \
213 210
  palEnablePadEvent(moduleGpioWlGdo2.gpio->port, moduleGpioWlGdo2.gpio->pad, APAL2CH_EDGE(moduleGpioWlGdo2.meta.edge));   \
214 211
  /* WL_GDO0 */                                                               \
215
  palSetPadCallback(moduleGpioWlGdo0.gpio->port, moduleGpioWlGdo0.gpio->pad, _intCallback, &moduleGpioWlGdo0.gpio->pad);  \
212
  palSetPadCallback(moduleGpioWlGdo0.gpio->port, moduleGpioWlGdo0.gpio->pad, _alld_dw1000_callback, &moduleGpioWlGdo0.gpio->pad);  \
216 213
  /*palEnablePadEvent(moduleGpioWlGdo0.gpio->port, moduleGpioWlGdo0.gpio->pad, APAL2CH_EDGE(moduleGpioWlGdo0.meta.edge)); // this is broken for some reason*/   \
217 214
}
218 215

  
......
224 221
  aosShellAddCommand(&aos.shell, &moduleUtAlldAt24c01bn.shellcmd);            \
225 222
  aosShellAddCommand(&aos.shell, &moduleUtAlldTlc5947.shellcmd);              \
226 223
  aosShellAddCommand(&aos.shell, &moduleUtAlldTps2051bdbv.shellcmd);          \
224
  aosShellAddCommand(&aos.shell, &moduleUtAlldDw1000.shellcmd);                \
227 225
}
228 226

  
229 227
/**
......
238 236
  i2cStart(&MODULE_HAL_I2C_EEPROM, &moduleHalI2cEepromConfig);                \
239 237
  /* SPI */                                                                   \
240 238
  spiStart(&MODULE_HAL_SPI_LIGHT, &moduleHalSpiLightConfig);                  \
241
  spiStart(&MODULE_HAL_SPI_WL, &moduleHalSpiWlConfig);                        \
239
  spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUWBConfig);                      \
242 240
}
243 241

  
244 242
/**
......
247 245
#define MODULE_SHUTDOWN_PERIPHERY_COMM() {                                    \
248 246
  /* SPI */                                                                   \
249 247
  spiStop(&MODULE_HAL_SPI_LIGHT);                                             \
250
  spiStop(&MODULE_HAL_SPI_WL);                                                \
248
  spiStop(&MODULE_HAL_SPI_UWB);                                               \
251 249
  /* I2C */                                                                   \
252 250
  i2cStop(&MODULE_HAL_I2C_EEPROM);                                            \
253 251
  /* don't stop the serial driver so messages can still be printed */         \
......
303 301
#include <alld_at24c01bn-sh-b.h>
304 302
#include <alld_tlc5947.h>
305 303
#include <alld_tps2051bdbv.h>
304
#include <alld_dw1000.h>
306 305

  
307 306
/**
308 307
 * @brief   EEPROM driver.
......
319 318
 */
320 319
extern TPS2051BDriver moduleLldPowerSwitchLaser;
321 320

  
321
/**
322
 * @brief   DW1000 driver for UWB.
323
 */
324
extern DW1000Driver moduleLldDW1000;
325

  
326

  
327

  
328

  
329
/*! ------------------------------------------------------------------------------------------------------------------
330
 * Function: _alld_dw1000_callback()
331
 *
332
 * Low level abstract function to handle 'reset' adn 'irq' interrupt from DW1000
333
 * Expects arg to be of iopadid_t* type, used to distinguish between irq or reset signal
334
 */
335
static void _alld_dw1000_callback(void* args) {
336

  
337
    aosDbgCheck(true);
338

  
339

  
340
    chSysLockFromISR();
341
    if ((*(iopadid_t*) args) == moduleLldDW1000.gpio_reset->pad)
342
    {
343
        // dw1000 external indicate reset done
344
    }
345
    else if ((*(iopadid_t*) args) == moduleLldDW1000.gpio_exti->pad)
346
    {
347
        dwt_isr();
348
    }
349
    else
350
    {
351
        return;
352
    }
353
    chSysUnlockFromISR();
354

  
355
}
356

  
357

  
322 358
/** @} */
323 359

  
324 360
/*===========================================================================*/
......
331 367
#include <ut_alld_at24c01bn-sh-b.h>
332 368
#include <ut_alld_tlc5947.h>
333 369
#include <ut_alld_tps2051bdbv.h>
370
#include <ut_alld_dw1000.h>
334 371

  
335 372
/**
336 373
 * @brief   EEPROM unit test object.
......
347 384
 */
348 385
extern aos_unittest_t moduleUtAlldTps2051bdbv;
349 386

  
387
/**
388
 * @brief   DW1000 unit test object.
389
 */
390
extern aos_unittest_t moduleUtAlldDw1000;
391

  
392

  
350 393
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
351 394

  
352 395
/** @} */
353 396

  
354 397
#endif /* _AMIROOS_MODULE_H_ */
355

  
356
/** @} */
os/core/src/aos_iostream.c
132 132
static msg_t _channelctl(void *instance, unsigned int operation, void *arg)
133 133
{
134 134
  if (((AosIOChannel*)instance)->flags & AOS_IOCHANNEL_OUTPUT_ENABLE) {
135
    return chnControl(((AosIOChannel*)instance)->asyncchannel, operation, arg);
135
    return chnControl(((AosIOChannel*)instance)->asyncchannel, operation, arg));
136 136
  } else {
137 137
    return MSG_OK;
138 138
  }
os/unittests/periphery-lld/inc/ut_alld_dw1000.h
1
/*
2
AMiRo-OS is an operating system designed 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 _AMIROOS_UT_DW1000_LLD_HPP_
20
#define _AMIROOS_UT_DW1000_LLD_HPP_
21

  
22
#include <aos_unittest.h>
23
#include <amiro-lld.h>
24

  
25
#if ((AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_DW1000)) || defined(__DOXYGEN__)
26

  
27
#include <alld_dw1000.h>
28
//#include <deca_instance.h>
29

  
30
#ifdef __cplusplus
31
extern "C" {
32
#endif
33
  aos_utresult_t utAlldDw1000Func(BaseSequentialStream* stream, aos_unittest_t* ut);
34
#ifdef __cplusplus
35
}
36
#endif
37

  
38
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_DW1000) */
39

  
40
#endif /* _AMIROOS_UT_DW1000_LLD_HPP_ */
os/unittests/periphery-lld/module.h
1
/*
2
AMiRo-OS is an operating system designed 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 _AMIROOS_MODULE_H_
20
#define _AMIROOS_MODULE_H_
21

  
22
/*===========================================================================*/
23
/**
24
 * @name Module specific functions
25
 * @{
26
 */
27
/*===========================================================================*/
28

  
29
static void _alld_dw1000_callback(void* args);
30

  
31
/** @} */
32

  
33
/*===========================================================================*/
34
/**
35
 * @name ChibiOS/HAL configuration
36
 * @{
37
 */
38
/*===========================================================================*/
39
#include <hal.h>
40

  
41
/**
42
 * @brief   CAN driver to use.
43
 */
44
#define MODULE_HAL_CAN                          CAND1
45

  
46
/**
47
 * @brief   Configuration for the CAN driver.
48
 */
49
extern CANConfig moduleHalCanConfig;
50

  
51
/**
52
 * @brief   I2C driver to access the EEPROM.
53
 */
54
#define MODULE_HAL_I2C_EEPROM                   I2CD2
55

  
56
/**
57
 * @brief   Configuration for the EEPROM I2C driver.
58
 */
59
extern I2CConfig moduleHalI2cEepromConfig;
60

  
61
/**
62
 * @brief   Serial driver of the programmer interface.
63
 */
64
#define MODULE_HAL_PROGIF                       SD1
65

  
66
/**
67
 * @brief   Configuration for the programmer serial interface driver.
68
 */
69
extern SerialConfig moduleHalProgIfConfig;
70

  
71
/**
72
 * @brief   SPI interface driver for the motion sensors (gyroscope and accelerometer).
73
 */
74
#define MODULE_HAL_SPI_LIGHT                    SPID1
75

  
76
/**
77
 * @brief   SPI interface driver for UWB Module.
78
 */
79
#define MODULE_HAL_SPI_UWB                      SPID2
80

  
81
/**
82
 * @brief   Configuration for the SPI interface driver to communicate with the LED driver.
83
 */
84
extern SPIConfig moduleHalSpiLightConfig;
85

  
86
/**
87
 * @brief   Configuration for the SPI interface driver to communicate with the LED driver.
88
 */
89
extern SPIConfig moduleHalSpiUWBConfig;
90

  
91
/**
92
 * @brief   Real-Time Clock driver.
93
 */
94
#define MODULE_HAL_RTC                          RTCD1
95

  
96
/** @} */
97

  
98
/*===========================================================================*/
99
/**
100
 * @name GPIO definitions
101
 * @{
102
 */
103
/*===========================================================================*/
104
#include <amiro-lld.h>
105

  
106
/**
107
 * @brief   LIGHT_BANK output signal GPIO.
108
 */
109
extern apalControlGpio_t moduleGpioLightBlank;
110

  
111
/**
112
 * @brief   LASER_EN output signal GPIO.
113
 */
114
extern apalControlGpio_t moduleGpioLaserEn;
115

  
116
/**
117
 * @brief   LASER_OC input signal GPIO.
118
 */
119
extern apalControlGpio_t moduleGpioLaserOc;
120

  
121
/**
122
 * @brief   SYS_UART_DN bidirectional signal GPIO.
123
 */
124
extern apalControlGpio_t moduleGpioSysUartDn;
125

  
126
/**
127
 * @brief   WL_GDO2 input signal GPIO.
128
 */
129
extern apalControlGpio_t moduleGpioWlGdo2;
130

  
131
/**
132
 * @brief   WL_GDO0 input signal GPIO.
133
 */
134
extern apalControlGpio_t moduleGpioWlGdo0;
135

  
136
/**
137
 * @brief   LIGHT_XLAT output signal GPIO.
138
 */
139
extern apalControlGpio_t moduleGpioLightXlat;
140

  
141
/**
142
 * @brief   SYS_PD bidirectional signal GPIO.
143
 */
144
extern apalControlGpio_t moduleGpioSysPd;
145

  
146
/**
147
 * @brief   SYS_SYNC bidirectional signal GPIO.
148
 */
149
extern apalControlGpio_t moduleGpioSysSync;
150

  
151
/** @} */
152

  
153
/*===========================================================================*/
154
/**
155
 * @name AMiRo-OS core configurations
156
 * @{
157
 */
158
/*===========================================================================*/
159

  
160
/**
161
 * @brief   Event flag to be set on a LASER_OC interrupt.
162
 */
163
#define MODULE_OS_IOEVENTFLAGS_LASEROC          ((eventflags_t)1 << GPIOB_LASER_OC_N)
164

  
165
/**
166
 * @brief   Event flag to be set on a SYS_UART_DN interrupt.
167
 */
168
#define MODULE_OS_IOEVENTFLAGS_SYSUARTDN        ((eventflags_t)1 << GPIOB_SYS_UART_DN)
169

  
170
/**
171
 * @brief   Event flag to be set on a WL_GDO2 interrupt.
172
 */
173
#define MODULE_OS_IOEVENTFLAGS_WLGDO2           ((eventflags_t)1 << GPIOB_WL_GDO2)
174

  
175
/**
176
 * @brief   Event flag to be set on a WL_GDO0 interrupt.
177
 */
178
#define MODULE_OS_IOEVENTFLAGS_WLGDO0           ((eventflags_t)1 << GPIOB_WL_GDO0)
179

  
180
/**
181
 * @brief   Event flag to be set on a SYS_PD interrupt.
182
 */
183
#define MODULE_OS_IOEVENTFLAGS_SYSPD            ((eventflags_t)1 << GPIOC_SYS_PD_N)
184

  
185
/**
186
 * @brief   Event flag to be set on a SYS_SYNC interrupt.
187
 */
188
#define MODULE_OS_IOEVENTFLAGS_SYSSYNC          ((eventflags_t)1 << GPIOD_SYS_INT_N)
189

  
190
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__)
191
/**
192
 * @brief   Shell prompt text.
193
 */
194
extern const char* moduleShellPrompt;
195
#endif
196

  
197

  
198

  
199

  
200
/**
201
 * @brief   Interrupt initialization macro.
202
 * @note    SSSP related interrupt signals are already initialized in 'aos_system.c'.
203
 */
204
#define MODULE_INIT_INTERRUPTS() {                                            \
205
  /* LASER_OC */                                                              \
206
  palSetPadCallback(moduleGpioLaserOc.gpio->port, moduleGpioLaserOc.gpio->pad, _intCallback, &moduleGpioLaserOc.gpio->pad); \
207
  palEnablePadEvent(moduleGpioLaserOc.gpio->port, moduleGpioLaserOc.gpio->pad, APAL2CH_EDGE(moduleGpioLaserOc.meta.edge));  \
208
  /* WL_GDO2 */                                                               \
209
  palSetPadCallback(moduleGpioWlGdo2.gpio->port, moduleGpioWlGdo2.gpio->pad, _alld_dw1000_callback, &moduleGpioWlGdo2.gpio->pad);  \
210
  palEnablePadEvent(moduleGpioWlGdo2.gpio->port, moduleGpioWlGdo2.gpio->pad, APAL2CH_EDGE(moduleGpioWlGdo2.meta.edge));   \
211
  /* WL_GDO0 */                                                               \
212
  palSetPadCallback(moduleGpioWlGdo0.gpio->port, moduleGpioWlGdo0.gpio->pad, _alld_dw1000_callback, &moduleGpioWlGdo0.gpio->pad);  \
213
  /*palEnablePadEvent(moduleGpioWlGdo0.gpio->port, moduleGpioWlGdo0.gpio->pad, APAL2CH_EDGE(moduleGpioWlGdo0.meta.edge)); // this is broken for some reason*/   \
214
}
215

  
216
/**
217
 * @brief   Unit test initialization hook.
218
 */
219
#define MODULE_INIT_TESTS() {                                                 \
220
  /* add unit-test shell commands */                                          \
221
  aosShellAddCommand(&aos.shell, &moduleUtAlldAt24c01bn.shellcmd);            \
222
  aosShellAddCommand(&aos.shell, &moduleUtAlldTlc5947.shellcmd);              \
223
  aosShellAddCommand(&aos.shell, &moduleUtAlldTps2051bdbv.shellcmd);          \
224
  aosShellAddCommand(&aos.shell, &moduleUtAlldDw1000.shellcmd);                \
225
}
226

  
227
/**
228
 * @brief   Periphery communication interfaces initialization hook.
229
 */
230
#define MODULE_INIT_PERIPHERY_COMM() {                                        \
231
  /* serial driver */                                                         \
232
  sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig);                        \
233
  /* I2C */                                                                   \
234
  moduleHalI2cEepromConfig.clock_speed = (AT24C01BN_LLD_I2C_MAXFREQUENCY < moduleHalI2cEepromConfig.clock_speed) ? AT24C01BN_LLD_I2C_MAXFREQUENCY : moduleHalI2cEepromConfig.clock_speed; \
235
  moduleHalI2cEepromConfig.duty_cycle = (moduleHalI2cEepromConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2;  \
236
  i2cStart(&MODULE_HAL_I2C_EEPROM, &moduleHalI2cEepromConfig);                \
237
  /* SPI */                                                                   \
238
  spiStart(&MODULE_HAL_SPI_LIGHT, &moduleHalSpiLightConfig);                  \
239
  spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUWBConfig);                      \
240
}
241

  
242
/**
243
 * @brief   Periphery communication interface deinitialization hook.
244
 */
245
#define MODULE_SHUTDOWN_PERIPHERY_COMM() {                                    \
246
  /* SPI */                                                                   \
247
  spiStop(&MODULE_HAL_SPI_LIGHT);                                             \
248
  spiStop(&MODULE_HAL_SPI_UWB);                                               \
249
  /* I2C */                                                                   \
250
  i2cStop(&MODULE_HAL_I2C_EEPROM);                                            \
251
  /* don't stop the serial driver so messages can still be printed */         \
252
}
253

  
254
/** @} */
255

  
256
/*===========================================================================*/
257
/**
258
 * @name Startup Shutdown Synchronization Protocol (SSSP)
259
 * @{
260
 */
261
/*===========================================================================*/
262

  
263
/**
264
 * @brief   PD signal GPIO.
265
 */
266
#define moduleSsspGpioPd                        moduleGpioSysPd
267

  
268
/**
269
 * @brief   SYNC signal GPIO.
270
 */
271
#define moduleSsspGpioSync                      moduleGpioSysSync
272

  
273
/**
274
 * @brief   DN signal GPIO.
275
 */
276
#define moduleSsspGpioDn                        moduleGpioSysUartDn
277

  
278
/**
279
 * @brief   Event flags for PD signal events.
280
 */
281
#define MODULE_SSSP_EVENTFLAGS_PD               MODULE_OS_IOEVENTFLAGS_SYSPD
282

  
283
/**
284
 * @brief   Event flags for SYNC signal events.
285
 */
286
#define MODULE_SSSP_EVENTFLAGS_SYNC             MODULE_OS_IOEVENTFLAGS_SYSSYNC
287

  
288
/**
289
 * @brief   Event flags for DN signal events.
290
 */
291
#define MODULE_SSSP_EVENTFLAGS_DN               MODULE_OS_IOEVENTFLAGS_SYSUARTDN
292

  
293
/** @} */
294

  
295
/*===========================================================================*/
296
/**
297
 * @name Low-level drivers
298
 * @{
299
 */
300
/*===========================================================================*/
301
#include <alld_at24c01bn-sh-b.h>
302
#include <alld_tlc5947.h>
303
#include <alld_tps2051bdbv.h>
304
#include <alld_dw1000.h>
305

  
306
/**
307
 * @brief   EEPROM driver.
308
 */
309
extern AT24C01BNDriver moduleLldEeprom;
310

  
311
/**
312
 * @brief   LED PWM driver.
313
 */
314
extern TLC5947Driver moduleLldLedPwm;
315

  
316
/**
317
 * @brief   Power switch driver for the laser supply power.
318
 */
319
extern TPS2051BDriver moduleLldPowerSwitchLaser;
320

  
321
/**
322
 * @brief   DW1000 driver for UWB.
323
 */
324
extern DW1000Driver moduleLldDW1000;
325

  
326

  
327

  
328

  
329
/*! ------------------------------------------------------------------------------------------------------------------
330
 * Function: _alld_dw1000_callback()
331
 *
332
 * Low level abstract function to handle 'reset' adn 'irq' interrupt from DW1000
333
 * Expects arg to be of iopadid_t* type, used to distinguish between irq or reset signal
334
 */
335
static void _alld_dw1000_callback(void* args) {
336

  
337
    aosDbgCheck(true);
338

  
339

  
340
    chSysLockFromISR();
341
    if ((*(iopadid_t*) args) == moduleLldDW1000.gpio_reset->pad)
342
    {
343
        // dw1000 external indicate reset done
344
    }
345
    else if ((*(iopadid_t*) args) == moduleLldDW1000.gpio_exti->pad)
346
    {
347
        dwt_isr();
348
    }
349
    else
350
    {
351
        return;
352
    }
353
    chSysUnlockFromISR();
354

  
355
}
356

  
357

  
358
/** @} */
359

  
360
/*===========================================================================*/
361
/**
362
 * @name Unit tests (UT)
363
 * @{
364
 */
365
/*===========================================================================*/
366
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
367
#include <ut_alld_at24c01bn-sh-b.h>
368
#include <ut_alld_tlc5947.h>
369
#include <ut_alld_tps2051bdbv.h>
370
#include <ut_alld_dw1000.h>
371

  
372
/**
373
 * @brief   EEPROM unit test object.
374
 */
375
extern aos_unittest_t moduleUtAlldAt24c01bn;
376

  
377
/**
378
 * @brief   LED PWM driver unit test object.
379
 */
380
extern aos_unittest_t moduleUtAlldTlc5947;
381

  
382
/**
383
 * @brief   Current-limited power switch (Laser output)
384
 */
385
extern aos_unittest_t moduleUtAlldTps2051bdbv;
386

  
387
/**
388
 * @brief   DW1000 unit test object.
389
 */
390
extern aos_unittest_t moduleUtAlldDw1000;
391

  
392

  
393
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
394

  
395
/** @} */
396

  
397
#endif /* _AMIROOS_MODULE_H_ */
os/unittests/periphery-lld/src/ut_alld_dw1000.c
1
/*
2
AMiRo-OS is an operating system designed 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
#include <ut_alld_dw1000.h>
20

  
21
#if ((AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_DW1000)) || defined(__DOXYGEN__)
22

  
23
#include <aos_debug.h>
24
#include <chprintf.h>
25
#include <aos_thread.h>
26
// No unit testing! -> Contains the Deca Demo Application
27
#include <deca_instance.h>
28
#include <alld_dw1000.h>
29
#include <alld_dw1000_regs.h>
30
#include <math.h>
31

  
32

  
33
aos_utresult_t utAlldDw1000Func(BaseSequentialStream* stream, aos_unittest_t* ut) {
34

  
35
    aosDbgCheck(ut->data != NULL);
36

  
37
    aos_utresult_t result = {0, 0};
38

  
39
    chprintf(stream, "init DW1000...\n");
40
    dwt_initialise(DWT_LOADUCODE, (DW1000Driver*) ut->data);
41
    chprintf(stream, "device ID should be: 0xDECA0130\nget device ID...\n");
42
    uint32_t actual_deviceId = dwt_readdevid();
43
    chprintf(stream, "actual device ID is: 0x%x\n", actual_deviceId);
44
    aosThdMSleep(1);
45

  
46
    if (actual_deviceId == DWT_DEVICE_ID){
47
      aosUtPassed(stream, &result);
48
    } else {
49
      aosUtFailed(stream, &result);
50
    }
51

  
52
    /*chprintf(stream, "write-read test...\n");
53
    uint32_t testvalue = 0x0A;
54
    uint16_t panid = 0x00;
55

  
56
    dwt_readfromdevice(PANADR_ID, PANADR_PAN_ID_OFFSET, 2, (uint8_t*) &panid);
57
    chprintf(stream, "value PANADR register before write: %x\n", panid);
58
    chprintf(stream, "write 0x%x to PANADR register...\n", testvalue);
59
    dwt_setpanid(testvalue);
60
    dwt_readfromdevice(PANADR_ID, PANADR_PAN_ID_OFFSET, 2, (uint8_t*) &panid);
61

  
62
    chprintf(stream, "PANADR register is now: 0x%x\n", panid);
63

  
64
    if (panid == testvalue){
65
      aosUtPassed(stream, &result);
66
    } else {
67
      aosUtFailed(stream, &result);
68
    }
69
*/
70

  
71
    dwt_setleds(0x03);
72

  
73
    // RUN DECA-DEMO
74

  
75
    instanceConfig_t chConfig;
76
    chConfig.channelNumber = 2;            // channel
77
    chConfig.preambleCode = 4;             // preambleCode
78
    chConfig.pulseRepFreq = DWT_PRF_16M;   // prf
79
    chConfig.dataRate = DWT_BR_6M8;        // datarate
80
    chConfig.preambleLen = DWT_PLEN_128;   // preambleLength
81
    chConfig.pacSize = DWT_PAC8;           // pacSize
82
    chConfig.nsSFD = 0;                    // non-standard SFD
83
    chConfig.sfdTO = (129 + 8 - 8);        // SFD timeout
84

  
85
    sfConfig_t sfConfig;
86
    sfConfig.slotDuration_ms = (10);        //slot duration in milliseconds (NOTE: the ranging exchange must be able to complete in this time
87
                                            //e.g. tag sends a poll, 4 anchors send responses and tag sends the final + processing time
88
    sfConfig.numSlots = (10);               //number of slots in the superframe (8 tag slots and 2 used for anchor to anchor ranging),
89
    sfConfig.sfPeriod_ms = (10*10);         //in ms => 100 ms frame means 10 Hz location rate
90
    sfConfig.tagPeriod_ms = (10*10);        //tag period in ms (sleep time + ranging time)
91
    sfConfig.pollTxToFinalTxDly_us = (2500); //poll to final delay in microseconds (needs to be adjusted according to lengths of ranging frames)
92

  
93
    //TODO Disable EXTI IRQ
94
    //port_DisableEXT_IRQ();
95

  
96
    // inittestapplication
97
    // dwt_softreset(); // already done in instance_init()
98

  
99
    // Set this instance mode (tag/anchor)
100
    (void) instance_init(TAG, (DW1000Driver*) ut->data);
101
    //int err = instance_init(TAG, (DW1000Driver*) ut->data);
102
    (void) instance_readdeviceid();
103
    //uint32_t deca_dev_id = instance_readdeviceid();
104

  
105
    // TAG ID 0
106
    instance_set_16bit_address(0);
107
    // simulate DECA config Mode 2 (DIP 1100000)
108
    instance_config(&chConfig, &sfConfig) ;
109

  
110
    //TODO Enable EXTI IRQ
111
    //port_EnableEXT_IRQ();
112

  
113
    // Start Ranging
114

  
115
    chprintf(stream, "start ranging...\n");
116

  
117

  
118
    while(1) {
119
        //int n = 0;
120
        instance_data_t* inst = instance_get_local_structure_ptr(0);
121

  
122
        int monitor_local = inst->monitor ;
123
        int txdiff = (chVTGetSystemTimeX() - inst->timeofTx);
124

  
125
        tag_run();
126
        //if delayed TX scheduled but did not happen after expected time then it has failed... (has to be < slot period)
127
        //if anchor just go into RX and wait for next message from tags/anchors
128
        //if tag handle as a timeout
129
        if( (monitor_local == 1) && ( txdiff > inst->slotDuration_ms) )  {
130
            inst->wait4ack = 0;
131
            tag_process_rx_timeout(inst);
132
            inst->monitor = 0;
133
        }
134
    }
135

  
136
    (void) instance_newrange();
137
    //int rx = instance_newrange();
138

  
139
    return result;
140
}
141

  
142
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_DW1000) */
os/unittests/unittests.mk
50 50
                $(UNITTESTS_DIR)periphery-lld/src/ut_alld_tps2051bdbv.c \
51 51
                $(UNITTESTS_DIR)periphery-lld/src/ut_alld_tps62113.c \
52 52
                $(UNITTESTS_DIR)periphery-lld/src/ut_alld_tps62113_ina219.c \
53
                $(UNITTESTS_DIR)periphery-lld/src/ut_alld_vcnl4020.c
53
                $(UNITTESTS_DIR)periphery-lld/src/ut_alld_vcnl4020.c \
54
                $(UNITTESTS_DIR)periphery-lld/src/ut_alld_dw1000.c
54 55

  
periphery-lld/AMiRo-LLD
1
Subproject commit a4251761c52d6fe349a7e616adf5b4c4b42dfe93
1
Subproject commit cf1f756b0cb3a504a95343b00c436d93b82ef1a2

Also available in: Unified diff