Revision 3940ba8a periphery-lld/periphAL.h

View differences:

periphery-lld/periphAL.h
19 19
#ifndef AMIROOS_PERIPHAL_H
20 20
#define AMIROOS_PERIPHAL_H
21 21

  
22
#include <amiro-lld.h>
23

  
22 24
/*============================================================================*/
23 25
/* VERSION                                                                    */
24 26
/*============================================================================*/
......
39 41
/* DEPENDENCIES                                                               */
40 42
/*============================================================================*/
41 43

  
42
#include <periphALtypes.h>
43 44
#include <hal.h>
44
#include <aos_debug.h>
45 45

  
46 46
/*============================================================================*/
47 47
/* GENERAL                                                                    */
......
55 55
static inline void usleep(apalTime_t us)
56 56
{
57 57
  // check if the specified time can be represented by the system
58
  aosDbgCheck(us <= chTimeI2US(TIME_INFINITE));
58
  chDbgCheck(us <= chTimeI2US(TIME_INFINITE));
59 59

  
60
  const sysinterval_t si = chTimeUS2I(us);
60
  const sysinterval_t interval = chTimeUS2I(us);
61 61
  // TIME_IMMEDIATE makes no sense and would even cause system halt
62
  if (si != TIME_IMMEDIATE) {
63
    chThdSleep(si);
62
  if (interval != TIME_IMMEDIATE) {
63
    chThdSleep(interval);
64 64
  }
65 65
  return;
66 66
}
......
89 89
 */
90 90
static inline apalExitStatus_t apalGpioRead(apalGpio_t* gpio, apalGpioState_t* const val)
91 91
{
92
  aosDbgCheck(gpio != NULL);
93
  aosDbgCheck(val != NULL);
92
  chDbgCheck(gpio != NULL);
93
  chDbgCheck(val != NULL);
94 94

  
95 95
  *val = (palReadPad(gpio->port, gpio->pad) == PAL_HIGH) ? APAL_GPIO_HIGH : APAL_GPIO_LOW;
96 96
  return APAL_STATUS_OK;
......
106 106
 */
107 107
static inline apalExitStatus_t apalGpioWrite(apalGpio_t* gpio, const apalGpioState_t val)
108 108
{
109
  aosDbgCheck(gpio != NULL);
109
  chDbgCheck(gpio != NULL);
110 110

  
111 111
  // palWritePad() is not guaranteed to be atomic, thus the scheduler is locked.
112 112
  syssts_t sysstatus = chSysGetStatusAndLockX();
......
124 124
 */
125 125
static inline apalExitStatus_t apalGpioToggle(apalGpio_t* gpio)
126 126
{
127
  aosDbgCheck(gpio != NULL);
127
  chDbgCheck(gpio != NULL);
128 128

  
129 129
  // palWritePad() is not guaranteed to be atomic, thus the scheduler is locked.
130 130
  syssts_t sysstatus = chSysGetStatusAndLockX();
......
143 143
 */
144 144
static inline apalExitStatus_t apalControlGpioGet(const apalControlGpio_t* const cgpio, apalControlGpioState_t* const val)
145 145
{
146
  aosDbgCheck(cgpio != NULL);
147
  aosDbgCheck(cgpio->gpio != NULL);
148
  aosDbgCheck(val != NULL);
146
  chDbgCheck(cgpio != NULL);
147
  chDbgCheck(cgpio->gpio != NULL);
148
  chDbgCheck(val != NULL);
149 149

  
150 150
  *val = ((palReadPad(cgpio->gpio->port, cgpio->gpio->pad) == PAL_HIGH) ^ (cgpio->meta.active == APAL_GPIO_ACTIVE_HIGH)) ? APAL_GPIO_OFF : APAL_GPIO_ON;
151 151
  return APAL_STATUS_OK;
......
161 161
 */
162 162
static inline apalExitStatus_t apalControlGpioSet(const apalControlGpio_t* const cgpio, const apalControlGpioState_t val)
163 163
{
164
  aosDbgCheck(cgpio != NULL);
165
  aosDbgCheck(cgpio->gpio != NULL);
166
  aosDbgCheck(cgpio->meta.direction == APAL_GPIO_DIRECTION_OUTPUT || cgpio->meta.direction == APAL_GPIO_DIRECTION_BIDIRECTIONAL);
164
  chDbgCheck(cgpio != NULL);
165
  chDbgCheck(cgpio->gpio != NULL);
166
  chDbgCheck(cgpio->meta.direction == APAL_GPIO_DIRECTION_OUTPUT || cgpio->meta.direction == APAL_GPIO_DIRECTION_BIDIRECTIONAL);
167 167

  
168 168
  // palWritePad() is not guaranteed to be atomic, thus the scheduler is locked.
169 169
  syssts_t sysstatus = chSysGetStatusAndLockX();
......
204 204
 */
205 205
static inline apalExitStatus_t apalPWMSet(apalPWMDriver_t* pwm, const apalPWMchannel_t channel, const apalPWMwidth_t width)
206 206
{
207
  aosDbgCheck(pwm != NULL);
207
  chDbgCheck(pwm != NULL);
208 208

  
209 209
  pwmEnableChannel(pwm, (pwmchannel_t)channel, pwm->period * ((float)width / (float)APAL_PWM_WIDTH_MAX) + 0.5f);
210 210
  return APAL_STATUS_OK;
......
220 220
 */
221 221
static inline apalExitStatus_t apalPWMGetFrequency(apalPWMDriver_t* pwm, apalPWMfrequency_t* const frequency)
222 222
{
223
  aosDbgCheck(pwm != NULL);
224
  aosDbgCheck(frequency != NULL);
223
  chDbgCheck(pwm != NULL);
224
  chDbgCheck(frequency != NULL);
225 225

  
226 226
  *frequency = pwm->config->frequency;
227 227
  return APAL_STATUS_OK;
......
237 237
 */
238 238
static inline apalExitStatus_t apalPWMGetPeriod(apalPWMDriver_t* pwm, apalPWMperiod_t* const period)
239 239
{
240
  aosDbgCheck(pwm != NULL);
241
  aosDbgCheck(period != NULL);
240
  chDbgCheck(pwm != NULL);
241
  chDbgCheck(period != NULL);
242 242

  
243 243
  *period = pwm->period;
244 244
  return APAL_STATUS_OK;
......
267 267
 */
268 268
static inline apalExitStatus_t apalQEIGetDirection(apalQEIDriver_t* qei, apalQEIDirection_t* const direction)
269 269
{
270
  aosDbgCheck(qei != NULL);
271
  aosDbgCheck(direction != NULL);
270
  chDbgCheck(qei != NULL);
271
  chDbgCheck(direction != NULL);
272 272

  
273 273
  *direction = (qei_lld_get_direction(qei)) ? APAL_QEI_DIRECTION_DOWN : APAL_QEI_DIRECTION_UP;
274 274

  
......
285 285
 */
286 286
static inline apalExitStatus_t apalQEIGetPosition(apalQEIDriver_t* qei, apalQEICount_t* const position)
287 287
{
288
  aosDbgCheck(qei != NULL);
289
  aosDbgCheck(position != NULL);
288
  chDbgCheck(qei != NULL);
289
  chDbgCheck(position != NULL);
290 290

  
291 291
  *position = qei_lld_get_position(qei);
292 292

  
......
303 303
 */
304 304
static inline apalExitStatus_t apalQEIGetRange(apalQEIDriver_t* qei, apalQEICount_t* const range)
305 305
{
306
  aosDbgCheck(qei != NULL);
307
  aosDbgCheck(range != NULL);
306
  chDbgCheck(qei != NULL);
307
  chDbgCheck(range != NULL);
308 308

  
309 309
  *range = qei_lld_get_range(qei);
310 310

  
......
339 339
 */
340 340
static inline apalExitStatus_t apalI2CMasterTransmit(apalI2CDriver_t* i2cd, const apalI2Caddr_t addr, const uint8_t* const txbuf, const size_t txbytes, uint8_t* const rxbuf, const size_t rxbytes, const apalTime_t timeout)
341 341
{
342
  aosDbgCheck(i2cd != NULL);
342
  chDbgCheck(i2cd != NULL);
343 343

  
344 344
#if (I2C_USE_MUTUAL_EXCLUSION == TRUE)
345 345
  // check whether the I2C driver was locked externally
......
401 401
 */
402 402
static inline apalExitStatus_t apalI2CMasterReceive(apalI2CDriver_t* i2cd, const apalI2Caddr_t addr, uint8_t* const rxbuf, const size_t rxbytes, const apalTime_t timeout)
403 403
{
404
  aosDbgCheck(i2cd != NULL);
404
  chDbgCheck(i2cd != NULL);
405 405

  
406 406
#if (I2C_USE_MUTUAL_EXCLUSION == TRUE)
407 407
  // check whether the I2C driver was locked externally
......
475 475
 */
476 476
static inline apalExitStatus_t apalSPIExchange(apalSPIDriver_t* spid, const uint8_t* const txData , uint8_t* const rxData, const size_t length)
477 477
{
478
  aosDbgCheck(spid != NULL);
478
  chDbgCheck(spid != NULL);
479 479

  
480 480
#if (SPI_USE_MUTUAL_EXCLUSION)
481 481
  // check whether the SPI driver was locked externally
......
509 509
 */
510 510
static inline apalExitStatus_t apalSPIReceive(apalSPIDriver_t* spid, uint8_t* const data, const size_t length)
511 511
{
512
  aosDbgCheck(spid != NULL);
512
  chDbgCheck(spid != NULL);
513 513

  
514 514
#if (SPI_USE_MUTUAL_EXCLUSION)
515 515
  // check whether the SPI driver was locked externally
......
543 543
 */
544 544
static inline apalExitStatus_t apalSPITransmit(apalSPIDriver_t* spid, const uint8_t* const data, const size_t length)
545 545
{
546
  aosDbgCheck(spid != NULL);
546
  chDbgCheck(spid != NULL);
547 547

  
548 548
#if (SPI_USE_MUTUAL_EXCLUSION)
549 549
  // check whether the SPI driver was locked externally
......
579 579
 */
580 580
static inline apalExitStatus_t apalSPITransmitAndReceive(apalSPIDriver_t* spid, const uint8_t* const txData , uint8_t* const rxData, const size_t txLength, const size_t rxLength)
581 581
{
582
  aosDbgCheck(spid != NULL);
582
  chDbgCheck(spid != NULL);
583 583

  
584 584
#if (SPI_USE_MUTUAL_EXCLUSION)
585 585
  // check whether the SPI driver was locked externally
......
614 614
 *
615 615
 * @param[in] c   The condition to check.
616 616
 */
617
#define apalDbgAssert(c)              aosDbgAssert(c)
617
#define apalDbgAssert(c)              chDbgAssert(c, "")
618 618

  
619 619

  
620 620
/**

Also available in: Unified diff