Revision 8d4d058e

View differences:

modules/NUCLEO-F103RB/Makefile
142 142

  
143 143
# Periphery LLDs.
144 144
AMIROOS_PERIPHERYLLD_INC += $(AMIROLLD)/drivers/LED/v1 \
145
                            $(AMIROLLD)/drivers/button/v1
146
#                            $(AMIROLLD)/drivers/DW1000/v1
145
                            $(AMIROLLD)/drivers/button/v1\
146
                            $(AMIROLLD)/drivers/DW1000/v1
147 147

  
148 148
# Tests.
149 149
AMIROOS_TEST_INC += $(AMIROOS_TEST_DIR)periphery-lld/button_v1 \
150
                    $(AMIROOS_TEST_DIR)periphery-lld/LED_v1
151
#                    $(AMIROOS_TEST_DIR)periphery-lld/DW1000_v1
150
                    $(AMIROOS_TEST_DIR)periphery-lld/LED_v1\
151
                    $(AMIROOS_TEST_DIR)periphery-lld/DW1000_v1
152 152

  
153 153
# Module specific inclusion directories
154 154
MODULE_INC = $(MODULEDIR) \
modules/NUCLEO-F103RB/aosconf.h
84 84
 * @note    Any mandatory events (e.g. for SSSP) are enabled implicitely despite this configuration.
85 85
 */
86 86
#if !defined(OS_CFG_MAIN_LOOP_IOEVENT_MASK)
87
  #define AMIROOS_CFG_MAIN_LOOP_IOEVENT_MASK    MODULE_OS_IOEVENTFLAGS_USERBUTTON
88
//  #define AMIROOS_CFG_MAIN_LOOP_IOEVENT_MASK    (MODULE_OS_IOEVENTFLAGS_DW1000_IRQn | MODULE_OS_IOEVENTFLAGS_USERBUTTON)
87
  #define AMIROOS_CFG_MAIN_LOOP_IOEVENT_MASK    (MODULE_OS_IOEVENTFLAGS_DW1000_IRQn | MODULE_OS_IOEVENTFLAGS_USERBUTTON)
88
//  #define AMIROOS_CFG_MAIN_LOOP_IOEVENT_MASK    MODULE_OS_IOEVENTFLAGS_USERBUTTON
89 89
#else /* !defined(OS_CFG_MAIN_LOOP_IOEVENT_MASK) */
90 90
  #define AMIROOS_CFG_MAIN_LOOP_IOEVENT_MASK    OS_CFG_MAIN_LOOP_IOEVENT_MASK
91 91
#endif /* !defined(OS_CFG_MAIN_LOOP_IOEVENT_MASK) */
modules/NUCLEO-F103RB/module.c
50 50
};
51 51

  
52 52
#if (BOARD_DW1000_CONNECTED == true)
53

  
54 53
/*! SPI (high and low speed) configuration for DW1000 */
55 54
SPIConfig moduleHalSpiUwbHsConfig = {
56 55
  /* circular buffer mode        */ false,
......
69 68
  /* CR1                         */ SPI_CR1_BR_1 | SPI_CR1_BR_0,
70 69
  /* CR2                         */ 0,
71 70
};
72

  
73 71
#endif /* (BOARD_DW1000_CONNECTED == true) */
74 72

  
75 73
/** @} */
......
97 95
};
98 96

  
99 97
#if (BOARD_DW1000_CONNECTED == true)
100

  
101 98
/**
102 99
 * @brief   DW1000 reset output signal GPIO.
103 100
 */
104 101
static apalGpio_t _gpioDw1000Reset = {
105
  /* line */ PAL_LINE(GPIOA, GPIOA_ARD_A0),
102
  /* line */ LINE_ARD_D15, //PAL_LINE(GPIOA, GPIOA_ARD_A0)
106 103
};
107 104
ROMCONST apalControlGpio_t moduleGpioDw1000Reset = {
108 105
  /* GPIO */ &_gpioDw1000Reset,
......
118 115
 * @brief   DW1000 interrrupt input signal GPIO.
119 116
 */
120 117
static apalGpio_t _gpioDw1000Irqn = {
121
  /* line */ PAL_LINE(GPIOB, GPIOB_ARD_D6),
118
  /* line */ LINE_ARD_D14,  // PAL_LINE(GPIOB, GPIOB_ARD_D6)
122 119
};
123 120
ROMCONST apalControlGpio_t moduleGpioDw1000Irqn = {
124 121
  /* GPIO */ &_gpioDw1000Irqn,
......
144 141
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
145 142
  },
146 143
};
147

  
148 144
#endif /* (BOARD_DW1000_CONNECTED == true) */
149 145

  
150 146
/**
......
194 190
/*===========================================================================*/
195 191

  
196 192
#if (BOARD_DW1000_CONNECTED == true)
197

  
198 193
/*! @brief TODO: Manual implementation of SPI configuration. Somehow, it is necessary in NUCLEO-F103RB  */
199 194
void dw1000_spi_init(void){
200 195
  palSetPadMode(GPIOB, GPIOB_PIN13, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
......
204 199
  apalGpioWrite(moduleGpioSpiChipSelect.gpio, APAL_GPIO_LOW);
205 200
}
206 201

  
202
/*! @brief entry point to the IRQn event in DW1000 module
203
 *
204
 * */
205
void process_deca_irq(void){
206
  do{
207
    dwt_isr();
208
   //while IRS line active (ARM can only do edge sensitive interrupts)
209
  }while(port_CheckEXT_IRQ() == 1);
210
}
211

  
212
/*! @brief Check the current value of GPIO pin and return the value */
213
apalGpioState_t port_CheckEXT_IRQ(void) {
214
  apalGpioState_t  val;
215
  apalGpioRead(moduleGpioDw1000Irqn.gpio, &val);
216
  return val;
217
}
218

  
219
/*! @brief Manually set the chip select pin of the SPI */
220
void set_SPI_chip_select(void){
221
  apalGpioWrite(moduleGpioSpiChipSelect.gpio, APAL_GPIO_HIGH);
222
}
223

  
224
/*! @brief Manually reset the chip select pin of the SPI */
225
void clear_SPI_chip_select(void){
226
  apalGpioWrite(moduleGpioSpiChipSelect.gpio, APAL_GPIO_LOW);
227
}
228

  
229
/*! @brief Change the SPI speed configuration on the fly */
230
void setHighSpeed_SPI(bool speedValue, DW1000Driver* drv){
231

  
232
  spiStop(drv->spid);
233

  
234
  if (speedValue == FALSE){
235
    spiStart(drv->spid, &moduleHalSpiUwbLsConfig);  // low speed spi configuration
236
  }
237
  else{
238
    spiStart(drv->spid, &moduleHalSpiUwbHsConfig); // high speed spi configuration
239
  }
240
}
207 241
#endif /* (BOARD_DW1000_CONNECTED == true) */
208 242
/** @} */
209 243

  
......
223 257
};
224 258

  
225 259
#if (BOARD_DW1000_CONNECTED == true)
226

  
227 260
DW1000Driver moduleLldDw1000 = {
228 261
  /* SPI driver         */ &MODULE_HAL_SPI_UWB,
229 262
  /* ext interrupt      */ &moduleGpioDw1000Irqn,
230 263
  /* RESET DW1000       */ &moduleGpioDw1000Reset,
231 264
};
232

  
233 265
#endif /* (BOARD_DW1000_CONNECTED == true) */
234 266

  
235 267
/** @} */
......
263 295
AOS_SHELL_COMMAND(moduleTestButtonShellCmd, "test:button", _testButtonShellCmdCb);
264 296

  
265 297
#if (BOARD_DW1000_CONNECTED == true) || defined(__DOXYGEN__)
266

  
267 298
/*
268 299
 * UwB Driver (DW1000)
269 300
 */
270
static int _utShellCmdCb_Dw1000(BaseSequentialStream* stream, int argc, char* argv[])
301
#include <module_test_DW1000.h>
302
static int _testDw1000ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
271 303
{
272
  (void)argc;
273
  (void)argv;
274
  aosUtRun(stream, &moduleUtAlldDw1000, NULL);
275
  return AOS_OK;
304
  return moduleTestDw1000ShellCb(stream, argc, argv, NULL);
276 305
}
277
aos_unittest_t moduleUtAlldDw1000 = {
278
  /* info           */ "DW1000",
279
  /* name           */ "UWB System",
280
  /* test function  */ utAlldDw1000Func,
281
  /* shell command  */ {
282
    /* name     */ "unittest:Uwb",
283
    /* callback */ _utShellCmdCb_Dw1000,
284
    /* next     */ NULL,
285
  },
286
  /* data           */ &moduleLldDw1000,
287
};
306
AOS_SHELL_COMMAND(moduleTestDw1000ShellCmd, "test:DW1000", _testDw1000ShellCmdCb);
288 307
#endif /* (BOARD_DW1000_CONNECTED == true) */
289 308

  
290 309
/*
......
308 327
  status |= moduleTestButtonShellCb(stream, 0, targv, &result_test);
309 328
  result_total = aosTestResultAdd(result_total, result_test);
310 329

  
330
#if (BOARD_DW1000_CONNECTED == true) || defined(__DOXYGEN__)
311 331
  /* DW1000 */
312
  //TODO
332
  status |= moduleTestDw1000ShellCb(stream, 0, targv, &result_test);
333
  result_total = aosTestResultAdd(result_total, result_test);
334
#endif /* (BOARD_DW1000_CONNECTED == true) */
313 335

  
314 336
  // print total result
315 337
  chprintf(stream, "\n");
modules/NUCLEO-F103RB/module.h
36 36
 */
37 37
/*===========================================================================*/
38 38

  
39
#if (BOARD_DW1000_CONNECTED == true)
40

  
41 39
#if defined(__cplusplus)
42 40
extern "C" {
43 41
#endif /* defined(__cplusplus) */
44 42

  
43
#if (BOARD_DW1000_CONNECTED == true)
45 44
void dw1000_spi_init(void);
45
void process_deca_irq(void);
46
apalGpioState_t port_CheckEXT_IRQ(void) ;
47
#endif /* (BOARD_DW1000_CONNECTED == true) */
48

  
49
void set_SPI_chip_select(void);
50
void clear_SPI_chip_select(void);
46 51

  
47 52
#if defined(__cplusplus)
48 53
}
49 54
#endif /* defined(__cplusplus) */
50 55

  
51
#endif /* (BOARD_DW1000_CONNECTED == true) */
56

  
52 57

  
53 58

  
54 59
/** @} */
......
76 81
#define MODULE_HAL_RTC                          RTCD1
77 82

  
78 83
#if (BOARD_DW1000_CONNECTED == true)
79

  
80 84
/**
81 85
 * @brief   SPI interface driver for the motion sensors (gyroscope and accelerometer).
82 86
 */
......
91 95
 * @brief   Configuration for the SPI interface driver to communicate with the wireless transceiver.
92 96
 */
93 97
extern SPIConfig moduleHalSpiUwbLsConfig;
94

  
95 98
#endif /* (BOARD_DW1000_CONNECTED == true) */
96 99

  
97 100
/** @} */
......
108 111
 */
109 112
extern ROMCONST apalControlGpio_t moduleGpioLed;
110 113

  
111
#if (BOARD_DW1000_CONNECTED == true)
112

  
114
//#if (BOARD_DW1000_CONNECTED == true)
113 115
/**
114 116
 * @brief   DW1000 reset output signal
115 117
 * @note    the reset pin should be drived as low by MCU to activate.
......
127 129
 * @brief   DW1000 SPI chip select  output signal.
128 130
 */
129 131
extern ROMCONST apalControlGpio_t moduleGpioSpiChipSelect ;
130

  
131
#endif /* (BOARD_DW1000_CONNECTED == true) */
132
//#endif /* (BOARD_DW1000_CONNECTED == true) */
132 133

  
133 134
/**
134 135
 * @brief   User button input signal.
......
144 145
 */
145 146
/*===========================================================================*/
146 147

  
147
#if (BOARD_DW1000_CONNECTED == true)
148

  
148
//#if (BOARD_DW1000_CONNECTED == true)
149 149
/**
150 150
 * @brief   Event flag to be call dwt_isr() interrupt.
151 151
 */
152
#define MODULE_OS_IOEVENTFLAGS_DW1000_IRQn      AOS_IOEVENT_FLAG(PAL_PAD(LINE_ARD_D6))
153

  
154
#endif /* (BOARD_DW1000_CONNECTED == true) */
152
#define MODULE_OS_IOEVENTFLAGS_DW1000_IRQn      AOS_IOEVENT_FLAG(PAL_PAD(LINE_ARD_D14))
153
//#endif /* (BOARD_DW1000_CONNECTED == true) */
155 154

  
156 155
/**
157 156
 * @brief   Event flag to be set on a USER_BUTTON interrupt.
......
259 258
   */
260 259
  #define MODULE_MAIN_LOOP_IO_EVENT_DW1000() {                                \
261 260
    if(eventflags & MODULE_OS_IOEVENTFLAGS_DW1000_IRQn) {                     \
262
      /*apalGpioToggle(moduleGpioLedGreen.gpio); // just for debug  */        \
261
      /*apalGpioToggle(moduleGpioLed.gpio);*/ /* just for debug*/             \
263 262
      process_deca_irq();                                                     \
264 263
    }                                                                         \
265 264
  }
......
298 297
 */
299 298
extern ButtonDriver moduleLldUserButton;
300 299

  
301
#if (BOARD_DW1000_CONNECTED == true)
302 300

  
301
/**
302
 * @brief   DW1000 driver.
303
 */
303 304
#include <alld_DW1000.h>
305
void setHighSpeed_SPI(bool speedValue, DW1000Driver* drv);
304 306

  
307
#if (BOARD_DW1000_CONNECTED == true)
305 308
extern DW1000Driver moduleLldDw1000;
306

  
307 309
#endif /* (BOARD_DW1000_CONNECTED == true) */
308 310

  
309 311
/** @} */
......
327 329
extern aos_shellcommand_t moduleTestButtonShellCmd;
328 330

  
329 331
#if (BOARD_DW1000_CONNECTED == true)
330

  
331 332
/**
332 333
 * @brief   DW1000 (UWB transmitter) test command.
333 334
 */
334 335
extern aos_shellcommand_t moduleTestDw1000ShellCmd;
335

  
336 336
#endif /* (BOARD_DW1000_CONNECTED == true) */
337 337

  
338 338
/**
modules/NUCLEO-F103RB/test/DW1000/module_test_DW1000.c
1
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2019  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 <amiroos.h>
20

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

  
23

  
24
#include <module_test_DW1000.h>
25
#include <aos_test_DW1000.h>
26

  
27
/******************************************************************************/
28
/* LOCAL DEFINITIONS                                                          */
29
/******************************************************************************/
30

  
31
/******************************************************************************/
32
/* EXPORTED VARIABLES                                                         */
33
/******************************************************************************/
34

  
35
/******************************************************************************/
36
/* LOCAL TYPES                                                                */
37
/******************************************************************************/
38

  
39
/******************************************************************************/
40
/* LOCAL VARIABLES                                                            */
41
/******************************************************************************/
42

  
43
static aos_test_dw1000data_t _data = {
44
  /* UWB data     */ &moduleLldDw1000,
45
  /* event source */ &aos.events.io,
46
  /* event flags  */ MODULE_OS_IOEVENTFLAGS_DW1000_IRQn,
47
};
48

  
49
static AOS_TEST(_test, "DW1000", NULL, moduleTestDw1000ShellCb, aosTestDw1000Func, &_data);
50

  
51
/******************************************************************************/
52
/* LOCAL FUNCTIONS                                                            */
53
/******************************************************************************/
54

  
55
/******************************************************************************/
56
/* EXPORTED FUNCTIONS                                                         */
57
/******************************************************************************/
58

  
59
int moduleTestDw1000ShellCb(BaseSequentialStream* stream, int argc, char* argv[], aos_testresult_t* result)
60
{
61
  (void)argc;
62
  (void)argv;
63

  
64
  if (result != NULL) {
65
    *result = aosTestRun(stream, &_test, NULL);
66
  } else {
67
    aosTestRun(stream, &_test, NULL);
68
  }
69

  
70
  return AOS_OK;
71
}
72

  
73
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
modules/NUCLEO-F103RB/test/DW1000/module_test_DW1000.h
1
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2019  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
#ifndef MODULE_TEST_DW1000_H
21
#define MODULE_TEST_DW1000_H
22

  
23
#include <amiroos.h>
24

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

  
27
/******************************************************************************/
28
/* CONSTANTS                                                                  */
29
/******************************************************************************/
30

  
31
/******************************************************************************/
32
/* SETTINGS                                                                   */
33
/******************************************************************************/
34

  
35
/******************************************************************************/
36
/* CHECKS                                                                     */
37
/******************************************************************************/
38

  
39
/******************************************************************************/
40
/* DATA STRUCTURES AND TYPES                                                  */
41
/******************************************************************************/
42

  
43
/******************************************************************************/
44
/* MACROS                                                                     */
45
/******************************************************************************/
46

  
47
/******************************************************************************/
48
/* EXTERN DECLARATIONS                                                        */
49
/******************************************************************************/
50

  
51
#if defined(__cplusplus)
52
extern "C" {
53
#endif /* defined(__cplusplus) */
54
  int moduleTestDw1000ShellCb(BaseSequentialStream* stream, int argc, char* argv[], aos_testresult_t* result);
55
#if defined(__cplusplus)
56
}
57
#endif /* defined(__cplusplus) */
58

  
59
/******************************************************************************/
60
/* INLINE FUNCTIONS                                                           */
61
/******************************************************************************/
62

  
63
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
64

  
65
#endif /* MODULE_TEST_DW1000_H */
66

  
test/periphery-lld/DW1000_v1/aos_test_DW1000.c
34 34
/* LOCAL DEFINITIONS                                                          */
35 35
/******************************************************************************/
36 36

  
37
//#define TEST_SNIPPETS_DW1000   // switch between test and demo apps
37
#define TEST_SNIPPETS_DW1000   // switch between test and demo apps
38 38

  
39 39
#define SWS1_SHF_MODE 0x02  //short frame mode (6.81M)
40 40
#define SWS1_CH5_MODE 0x04  //channel 5 mode
......
68 68
/* LOCAL FUNCTIONS                                                            */
69 69
/******************************************************************************/
70 70

  
71
/*! @brief Change the SPI speed configuration on the fly */
72
void setHighSpeed_SPI(bool speedValue, DW1000Driver* drv){
73

  
74
  spiStop(drv->spid);
75

  
76
  if (speedValue == FALSE){
77
    spiStart(drv->spid, &moduleHalSpiUwbLsConfig);  // low speed spi configuration
78
  }
79
  else{
80
    spiStart(drv->spid, &moduleHalSpiUwbHsConfig); // high speed spi configuration
81
  }
82
}
83

  
84
/*! @brief entry point to the IRQn event in DW1000 module
85
 *
86
 * */
87
void process_deca_irq(void){
88
  do{
89
    dwt_isr();
90
    //while IRS line active (ARM can only do edge sensitive interrupts)
91
  }while(port_CheckEXT_IRQ() == 1);
92
}
93

  
94
/*! @brief Check the current value of GPIO pin and return the value */
95
apalGpioState_t port_CheckEXT_IRQ(void) {
96
  apalGpioState_t  val;
97
  apalGpioRead(moduleGpioDw1000Irqn.gpio, &val);
98
  return val;
99
}
100

  
101
/*! @brief Manually set the chip select pin of the SPI */
102
void set_SPI_chip_select(void){
103
  apalGpioWrite(moduleGpioSpiChipSelect.gpio, APAL_GPIO_HIGH);
104
}
105

  
106
/*! @brief Manually reset the chip select pin of the SPI */
107
void clear_SPI_chip_select(void){
108
  apalGpioWrite(moduleGpioSpiChipSelect.gpio, APAL_GPIO_LOW);
109
}
110

  
111 71
/*! @brief Manually reset the DW1000 module  */
112 72
void reset_DW1000(void){
113 73

  
......
248 208
/******************************************************************************/
249 209

  
250 210

  
251
aos_testresult_t aosTestDw1000Func(BaseSequentialStream* stream, aos_test_t* test) {
211
aos_testresult_t aosTestDw1000Func(BaseSequentialStream* stream, const aos_test_t* test) {
212

  
213
  aosDbgCheck(test->data != NULL &&
214
      ((aos_test_dw1000data_t*)test->data)->driver != NULL &&
215
      ((aos_test_dw1000data_t*)test->data)->evtsource != NULL);
252 216

  
253
  aosDbgCheck(test->data != NULL && ((aos_test_dw1000data_t*)test->data)->driver != NULL);
254 217

  
255 218
  aos_testresult_t result = {0, 0};
256 219

  
......
393 356
  /*! Run the localization system demo app as a thread */
394 357
  while(1){
395 358
    instance_run();
396
//    aosThdUSleep(10);
359
//    aosThdUSleep(100);
397 360
  }
398 361

  
399 362
#endif  /* defined(TEST_SNIPPETS_DW1000) */
test/periphery-lld/DW1000_v1/aos_test_DW1000.h
50 50
   */
51 51
  DW1000Driver* driver;
52 52

  
53
  /**
54
   * @brief   Event source to listen to.
55
   */
56
  event_source_t* evtsource;
57

  
58
  /**
59
   * @brief   Event flags to watch.
60
   */
61
  eventflags_t evtflags;
62

  
53 63
} aos_test_dw1000data_t;
54 64

  
55 65
/******************************************************************************/
......
63 73
#if defined(__cplusplus)
64 74
extern "C" {
65 75
#endif /* defined(__cplusplus) */
66
  aos_testresult_t aosTestDw1000Func(BaseSequentialStream* stream, aos_test_t* test);
76
  aos_testresult_t aosTestDw1000Func(BaseSequentialStream* stream, const aos_test_t* test);
67 77

  
68 78
  extern uint8_t s1switch;
69 79
  extern int instance_anchaddr;
......
75 85
  int32_t inittestapplication(uint8_t s1switch, DW1000Driver* drv);
76 86
  int decarangingmode(uint8_t s1switch);
77 87
  void addressconfigure(uint8_t s1switch, uint8_t mode);
78
  void set_SPI_chip_select(void);
79
  void clear_SPI_chip_select(void);
80 88
  void reset_DW1000(void);
81
  void setHighSpeed_SPI(bool speedValue, DW1000Driver* drv);
82
  apalGpioState_t port_CheckEXT_IRQ(void) ;
83
  void process_deca_irq(void);
84 89

  
85 90
#if defined(__cplusplus)
86 91
}

Also available in: Unified diff