Revision 1e5f7648 periphery-lld/periphAL.h

View differences:

periphery-lld/periphAL.h
56 56
static inline void usleep(apalTime_t us)
57 57
{
58 58
  // check if the specified time can be represented by the system
59
  aosDbgCheck(us <= TIME_I2US(TIME_INFINITE));
59
  aosDbgCheck(us <= chTimeI2US(TIME_INFINITE));
60 60

  
61
  const systime_t st = TIME_US2I(us);
61
  const sysinterval_t si = chTimeUS2I(us);
62 62
  // TIME_IMMEDIATE makes no sense and would even cause system halt
63
  if (st != TIME_IMMEDIATE) {
64
    chThdSleep(st);
63
  if (si != TIME_IMMEDIATE) {
64
    chThdSleep(si);
65 65
  }
66 66
  return;
67 67
}
......
76 76
 * @brief GPIO driver type.
77 77
 */
78 78
struct apalGpio_t {
79
  /*
80
   * Workaround, since GPIOv2 (STM32F4XX) uses a different type than GPIOv1 (STM32F1XX).
81
   */
82
  #if defined(STM32F4XX)
83
  stm32_gpio_t* port;
84
  #elif defined(STM32F1XX)
85
  GPIO_TypeDef* port;
86
  #else
87
  void* port;
88
  #endif
89

  
90
  uint8_t pad;
79
  ioportid_t port;
80
  iopadid_t pad;
91 81
} PACKED_VAR;
92 82

  
93 83
/**
......
183 173
  return APAL_STATUS_OK;
184 174
}
185 175

  
186
#endif
187

  
188
#if HAL_USE_PAL || defined(__DOXYGEN__)
189

  
190 176
/**
191
 * @brief   Converts an apalGpioEdge_t to an ChibiOS EXT edge.
177
 * @brief   Converts an apalGpioEdge_t to an ChibiOS PAL edge.
192 178
 */
193
#define APAL2CH_EDGE(edge)                                        \
194
  ((edge == APAL_GPIO_EDGE_RISING) ? PAL_EVENT_MODE_RISING_EDGE :    \
195
    (edge == APAL_GPIO_EDGE_FALLING) ? PAL_EVENT_MODE_FALLING_EDGE : \
179
#define APAL2CH_EDGE(edge)                                            \
180
  ((edge == APAL_GPIO_EDGE_RISING) ? PAL_EVENT_MODE_RISING_EDGE :     \
181
    (edge == APAL_GPIO_EDGE_FALLING) ? PAL_EVENT_MODE_FALLING_EDGE :  \
196 182
     (edge == APAL_GPIO_EDGE_BOTH) ? PAL_EVENT_MODE_BOTH_EDGES : 0)
197 183

  
198 184
#endif
......
360 346
  i2cAcquireBus(i2cd);
361 347
#endif
362 348

  
349
#pragma GCC diagnostic push
350
#pragma GCC diagnostic ignored "-Wtype-limits"
363 351
#if defined(STM32F1XX_I2C)
364 352
  // Due to a hardware limitation, for STM32F1 platform the minimum number of bytes that can be received is two.
365 353
  msg_t status = MSG_OK;
......
373 361
#else
374 362
  const msg_t status = i2cMasterTransmitTimeout(i2cd, addr, txbuf, txbytes, rxbuf, rxbytes, ((timeout >= TIME_INFINITE) ? TIME_INFINITE : TIME_US2I(timeout)) );
375 363
#endif
364
#pragma GCC diagnostic pop
376 365

  
377 366
#if (I2C_USE_MUTUAL_EXCLUSION == TRUE)
378 367
  i2cReleaseBus(i2cd);
......
413 402
  i2cAcquireBus(i2cd);
414 403
#endif
415 404

  
405
#pragma GCC diagnostic push
406
#pragma GCC diagnostic ignored "-Wtype-limits"
416 407
#if defined(STM32F1XX_I2C)
417 408
  // Due to a hardware limitation, for STM32F1 platform the minimum number of bytes that can be received is two.
418 409
  msg_t status = MSG_OK;
......
426 417
#else
427 418
  const msg_t status = i2cMasterReceiveTimeout(i2cd, addr, rxbuf, rxbytes, ((timeout >= TIME_INFINITE) ? TIME_INFINITE : TIME_US2I(timeout)) );
428 419
#endif
420
#pragma GCC diagnostic pop
429 421

  
430 422
#if (I2C_USE_MUTUAL_EXCLUSION == TRUE)
431 423
  i2cReleaseBus(i2cd);

Also available in: Unified diff