Revision deaaa47e

View differences:

modules/NUCLEO-F103RB/alldconf.h
43 43
 */
44 44
#define AMIROLLD_CFG_TIME_SIZE          32
45 45

  
46
#define AMIROLLD_CFG_DW1000              1
47

  
46 48
#endif /* ALLDCONF_H */
47 49

  
48 50
/** @} */
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
87
  #define AMIROOS_CFG_MAIN_LOOP_IOEVENT_MASK    (MODULE_OS_IOEVENTFLAGS_DW1000_IRQn | MODULE_OS_IOEVENTFLAGS_USERBUTTON)
88 88
#else
89 89
  #define AMIROOS_CFG_MAIN_LOOP_IOEVENT_MASK    OS_CFG_MAIN_LOOP_IOEVENT_MASK
90 90
#endif
modules/NUCLEO-F103RB/halconf.h
172 172
 * @brief   Enables the SPI subsystem.
173 173
 */
174 174
#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
175
#define HAL_USE_SPI                         FALSE
175
#define HAL_USE_SPI                         TRUE   
176 176
#endif
177 177

  
178 178
/**
modules/NUCLEO-F103RB/mcuconf.h
168 168
 * SPI driver system settings.
169 169
 */
170 170
#define STM32_SPI_USE_SPI1                  FALSE
171
#define STM32_SPI_USE_SPI2                  FALSE
171
#define STM32_SPI_USE_SPI2                  TRUE
172 172
#define STM32_SPI_USE_SPI3                  FALSE
173 173
#define STM32_SPI_SPI1_DMA_PRIORITY         1
174 174
#define STM32_SPI_SPI2_DMA_PRIORITY         1
modules/NUCLEO-F103RB/module.c
49 49
  /* CR1      */ 0,
50 50
};
51 51

  
52
#ifdef AMIROLLD_CFG_DW1000
53

  
54
/*! SPI (high and low speed) configuration for DW1000 */
55
SPIConfig moduleHalSpiUwbHsConfig = {
56
  /* circular buffer mode        */ false,
57
  /* callback function pointer   */ NULL,
58
  /* chip select line port       */ GPIOB,
59
  /* chip select line pad number */ GPIOB_PIN12,
60
  /* CR1                         */ 0,
61
  /* CR2                         */ 0,
62
};
63

  
64
SPIConfig moduleHalSpiUwbLsConfig = {
65
  /* circular buffer mode        */ false,
66
  /* callback function pointer   */ NULL,
67
  /* chip select line port       */ GPIOB,
68
  /* chip select line pad number */ GPIOB_PIN12,
69
  /* CR1                         */ SPI_CR1_BR_1 | SPI_CR1_BR_0,
70
  /* CR2                         */ 0,
71
};
72

  
73
#endif
74

  
52 75
/** @} */
53 76

  
54 77
/*===========================================================================*/
......
74 97
  },
75 98
};
76 99

  
100
#ifdef AMIROLLD_CFG_DW1000
101

  
102
/**
103
 * @brief   DW1000 reset output signal GPIO.
104
 */
105
static apalGpio_t _gpioDw1000Reset = {
106
  /* port */ GPIOA,
107
  /* pad  */ GPIOA_ARD_A0,   // PIN0
108
};
109
ROMCONST apalControlGpio_t moduleGpioDw1000Reset = {
110
  /* GPIO */ &_gpioDw1000Reset,
111
  /* meta */ {
112
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
113
    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
114
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
115
  },
116
};
117

  
118

  
119
/**
120
 * @brief   DW1000 interrrupt input signal GPIO.
121
 */
122
static apalGpio_t _gpioDw1000Irqn = {
123
  /* port */ GPIOB,
124
  /* pad  */ GPIOB_ARD_D6,  // GPIOB_PIN10
125
};
126
ROMCONST apalControlGpio_t moduleGpioDw1000Irqn = {
127
  /* GPIO */ &_gpioDw1000Irqn,
128
  /* meta */ {
129
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
130
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
131
    /* interrupt edge */ APAL_GPIO_EDGE_RISING,
132
  },
133
};
134

  
135

  
136
/**
137
 * @brief   DW1000 SPI chip select output signal GPIO.
138
 */
139
static apalGpio_t _gpioSpiChipSelect = {
140
  /* port */ GPIOB,
141
  /* pad  */ GPIOB_PIN12,  // GPIOB_PIN10
142
};
143
ROMCONST apalControlGpio_t moduleGpioSpiChipSelect = {
144
  /* GPIO */ &_gpioSpiChipSelect,
145
  /* meta */ {
146
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
147
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
148
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
149
  },
150
};
151

  
152
#endif /* AMIROLLD_CFG_DW1000 */
153

  
77 154
/**
78 155
 * @brief   User button input signal GPIO.
79 156
 */
......
112 189
 */
113 190
/*===========================================================================*/
114 191

  
192

  
193
/*===========================================================================*/
194
/**
195
 * @name Hardware specific wrappers Functions
196
 * @{
197
 */
198
/*===========================================================================*/
199

  
200
#ifdef AMIROLLD_CFG_DW1000
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

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

  
220

  
221
/*! @brief TODO: Manual implementation of SPI configuration. Somehow, it is necessary in NUCLEO-F103RB  */
222
void dw1000_spi_init(void){
223
  palSetPadMode(GPIOB, GPIOB_PIN13, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
224
  palSetPadMode(GPIOB, GPIOB_PIN14, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
225
  palSetPadMode(GPIOB, GPIOB_PIN15, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
226
  palSetPadMode(moduleGpioSpiChipSelect.gpio->port, moduleGpioSpiChipSelect.gpio->pad, PAL_MODE_OUTPUT_PUSHPULL);
227
  apalGpioWrite(moduleGpioSpiChipSelect.gpio, APAL_GPIO_LOW);
228
}
229

  
230
#endif /* AMIROLLD_CFG_DW1000 */
115 231
/** @} */
116 232

  
117 233
/*===========================================================================*/
......
121 237
 */
122 238
/*===========================================================================*/
123 239

  
240
#ifdef AMIROLLD_CFG_DW1000
241

  
242
DW1000Driver moduleLldDw1000 = {
243
  /* SPI driver         */ &MODULE_HAL_SPI_UWB,
244
  /* ext interrupt      */ &moduleGpioDw1000Irqn,
245
  /* RESET DW1000       */ &moduleGpioDw1000Reset,
246
};
247

  
248
#endif /* AMIROLLD_CFG_DW1000 */
124 249
/** @} */
125 250

  
126 251
/*===========================================================================*/
......
131 256
/*===========================================================================*/
132 257
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
133 258

  
259
#ifdef AMIROLLD_CFG_DW1000
260

  
261
/*
262
 * UwB Driver (DW1000)
263
 */
264
static int _utShellCmdCb_Dw1000(BaseSequentialStream* stream, int argc, char* argv[])
265
{
266
  (void)argc;
267
  (void)argv;
268
  aosUtRun(stream, &moduleUtAlldDw1000, NULL);
269
  return AOS_OK;
270
}
271
aos_unittest_t moduleUtAlldDw1000 = {
272
  /* info           */ "DW1000",
273
  /* name           */ "UWB System",
274
  /* test function  */ utAlldDw1000Func,
275
  /* shell command  */ {
276
    /* name     */ "unittest:Uwb",
277
    /* callback */ _utShellCmdCb_Dw1000,
278
    /* next     */ NULL,
279
  },
280
  /* data           */ &moduleLldDw1000,
281
};
282
#endif /* AMIROLLD_CFG_DW1000 */
283

  
134 284
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
135 285

  
136 286
/** @} */
modules/NUCLEO-F103RB/module.h
36 36
 */
37 37
/*===========================================================================*/
38 38

  
39
#ifdef AMIROLLD_CFG_DW1000
40

  
41
#ifdef __cplusplus
42
extern "C" {
43
#endif
44

  
45
apalGpioState_t port_CheckEXT_IRQ(void) ;
46

  
47
void dw1000_spi_init(void);
48

  
49
void process_deca_irq(void);
50

  
51

  
52
#ifdef __cplusplus
53
}
54
#endif
55

  
56
#endif /* AMIROLLD_CFG_DW1000 */
57

  
58

  
39 59
/** @} */
40 60

  
41 61
/*===========================================================================*/
......
60 80
 */
61 81
#define MODULE_HAL_RTC                          RTCD1
62 82

  
83

  
84
#ifdef AMIROLLD_CFG_DW1000
85

  
86
/**
87
 * @brief   SPI interface driver for the motion sensors (gyroscope and accelerometer).
88
 */
89
#define MODULE_HAL_SPI_UWB                      SPID2
90

  
91

  
92
/**
93
 * @brief   Configuration for the SPI interface driver to communicate with the LED driver.
94
 */
95
extern SPIConfig moduleHalSpiUwbHsConfig;
96

  
97
/**
98
 * @brief   Configuration for the SPI interface driver to communicate with the wireless transceiver.
99
 */
100
extern SPIConfig moduleHalSpiUwbLsConfig;
101

  
102
#endif /* AMIROLLD_CFG_DW1000 */
103

  
63 104
/** @} */
64 105

  
106

  
65 107
/*===========================================================================*/
66 108
/**
67 109
 * @name GPIO definitions
......
74 116
 */
75 117
extern ROMCONST apalControlGpio_t moduleGpioLed;
76 118

  
119
#ifdef AMIROLLD_CFG_DW1000
120
/**
121
 * @brief   DW1000 reset output signal
122
 * @note    the reset pin should be drived as low by MCU to activate.
123
 *          Then, put back the reset pin as input to MCU (tri-state float on the air
124
 *          is not supported in AMiRo)
125
 */
126
extern ROMCONST apalControlGpio_t moduleGpioDw1000Reset;
127

  
128
/**
129
 * @brief   DW1000 interrupt IRQn input signal.
130
 */
131
extern ROMCONST apalControlGpio_t moduleGpioDw1000Irqn;
132

  
133
/**
134
 * @brief   DW1000 SPI chip select  output signal.
135
 */
136
extern ROMCONST apalControlGpio_t moduleGpioSpiChipSelect ;
137

  
138
#endif /* AMIROLLD_CFG_DW1000 */
139

  
77 140
/**
78 141
 * @brief   User button input signal.
79 142
 */
......
89 152
/*===========================================================================*/
90 153

  
91 154
/**
155
 * @brief   Event flag to be call dwt_isr() interrupt.
156
 */
157
#define MODULE_OS_IOEVENTFLAGS_DW1000_IRQn      AOS_IOEVENT_FLAG(GPIOB_ARD_D6)
158

  
159
/**
92 160
 * @brief   Event flag to be set on a USER_BUTTON interrupt.
93 161
 */
94 162
#define MODULE_OS_IOEVENTFLAGS_USERBUTTON       AOS_IOEVENT_FLAG(GPIOC_BUTTON)
95 163

  
164

  
96 165
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
97 166
/**
98 167
 * @brief   Shell prompt text.
......
100 169
extern ROMCONST char* moduleShellPrompt;
101 170
#endif
102 171

  
172

  
103 173
/**
104 174
 * @brief   Interrupt initialization macro.
105 175
 * @note    SSSP related interrupt signals are already initialized in 'aos_system.c'.
......
108 178
  /* user button */                                                           \
109 179
  palSetPadCallback(moduleGpioUserButton.gpio->port, moduleGpioUserButton.gpio->pad, _intCallback, &moduleGpioUserButton.gpio->pad);  \
110 180
  palEnablePadEvent(moduleGpioUserButton.gpio->port, moduleGpioUserButton.gpio->pad, APAL2CH_EDGE(moduleGpioUserButton.meta.edge));   \
181
  MODULE_INIT_INTERRUPTS_DW1000();                                            \
111 182
}
183
#ifdef AMIROLLD_CFG_DW1000
184
  #define MODULE_INIT_INTERRUPTS_DW1000() {                                   \
185
    palSetPadCallback(moduleGpioDw1000Irqn.gpio->port, moduleGpioDw1000Irqn.gpio->pad, _intCallback, &moduleGpioDw1000Irqn.gpio->pad);  \
186
    palEnablePadEvent(moduleGpioDw1000Irqn.gpio->port, moduleGpioDw1000Irqn.gpio->pad, APAL2CH_EDGE(moduleGpioDw1000Irqn.meta.edge));   \
187
  }
188
#else
189
  #define MODULE_INIT_INTERRUPTS_DW1000() {                                  \
190
  }
191
#endif /* AMIROLLD_CFG_DW1000 */
192

  
112 193

  
113 194
/**
114 195
 * @brief   Unit test initialization hook.
115 196
 */
116 197
#define MODULE_INIT_TESTS() {                                                 \
117 198
  /* add unit-test shell commands */                                          \
199
  MODULE_INIT_TESTS_DW1000();                                                 \
118 200
}
201
#ifdef AMIROLLD_CFG_DW1000
202
  #define MODULE_INIT_TESTS_DW1000() {                                        \
203
    aosShellAddCommand(&aos.shell, &moduleUtAlldDw1000.shellcmd);             \
204
  }
205
#else
206
  #define MODULE_INIT_TESTS_DW1000() {                                         \
207
  }
208
#endif /* AMIROLLD_CFG_DW1000 */
209

  
119 210

  
120 211
/**
121 212
 * @brief   Periphery communication interfaces initialization hook.
......
123 214
#define MODULE_INIT_PERIPHERY_COMM() {                                        \
124 215
  /* serial driver */                                                         \
125 216
  sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig);                        \
217
  MODULE_INIT_PERIPHERY_COMM_DW1000();                                        \
126 218
}
219
#ifdef AMIROLLD_CFG_DW1000
220
  #define MODULE_INIT_PERIPHERY_COMM_DW1000() {                               \
221
    /* SPI init */                                                            \
222
    dw1000_spi_init();                                                        \
223
    spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUwbLsConfig);                  \
224
  }
225
#else
226
  #define MODULE_INIT_PERIPHERY_COMM_DW1000() {                               \
227
  }
228
#endif /* AMIROLLD_CFG_DW1000 */
229

  
127 230

  
128 231
/**
129 232
 * @brief   Periphery communication interface deinitialization hook.
130 233
 */
131 234
#define MODULE_SHUTDOWN_PERIPHERY_COMM() {                                    \
235
  MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000();                                    \
236
}
237
#ifdef AMIROLLD_CFG_DW1000
238
#define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() {                             \
239
  /* SPI */                                                                   \
240
  spiStop(&MODULE_HAL_SPI_UWB);                                               \
132 241
}
242
#else
243
  #define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() {                           \
244
  }
245
#endif /* AMIROLLD_CFG_DW1000 */
133 246

  
134 247
/**
135
 * @brief   HOOK to toggle the LEDs when the user button is pressed.
248
 * @brief   HOOK to call process_deca_irq() func when the dw1000 interrupt pin is activated.
136 249
 */
137
#define MODULE_MAIN_LOOP_IO_EVENT(eventflags) {                               \
250
#define MODULE_MAIN_LOOP_IO_EVENT(eventflags) {		                          \
138 251
  if (eventflags & MODULE_OS_IOEVENTFLAGS_USERBUTTON) {                       \
139 252
    apalControlGpioState_t buttonstate;                                       \
140 253
    apalControlGpioGet(&moduleGpioUserButton, &buttonstate);                  \
141 254
    apalControlGpioSet(&moduleGpioLed, buttonstate);                          \
142 255
  }                                                                           \
256
  MODULE_MAIN_LOOP_IO_EVENT_DW1000();                                         \
143 257
}
258
#ifdef AMIROLLD_CFG_DW1000
259
  #define MODULE_MAIN_LOOP_IO_EVENT_DW1000() {                                \
260
    if(eventflags & MODULE_OS_IOEVENTFLAGS_DW1000_IRQn) {		              \
261
      /*apalGpioToggle(moduleGpioLedGreen.gpio); // just for debug  */        \
262
      process_deca_irq();                                                     \
263
    }	                                                                      \
264
  }
265
#else
266
  #define MODULE_MAIN_LOOP_IO_EVENT_DW1000() {                                \
267
  }
268
#endif  /* AMIROLLD_CFG_DW1000 */
144 269

  
145 270
/** @} */
146 271

  
......
159 284
 * @{
160 285
 */
161 286
/*===========================================================================*/
287
#ifdef AMIROLLD_CFG_DW1000
288
#include <alld_DW1000.h>
289

  
290
extern DW1000Driver moduleLldDw1000;
291

  
292
#endif /* AMIROLLD_CFG_DW1000 */
162 293

  
163 294
/** @} */
164 295

  
......
170 301
/*===========================================================================*/
171 302
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
172 303

  
304
#if defined(AMIROLLD_CFG_DW1000) && (AMIROLLD_CFG_DW1000 == 1)
305
#include<ut_alld_dw1000_v1.h>
306

  
307
/**
308
 * @brief   DW1000 unit test object.
309
 */
310
extern aos_unittest_t moduleUtAlldDw1000;
311

  
312
#endif /* defined(AMIROLLD_CFG_DW1000) && (AMIROLLD_CFG_DW1000 == 1) */
313

  
173 314
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
174 315

  
175 316
/** @} */

Also available in: Unified diff