Revision 7de0cc90 periphery-lld/periphAL.h

View differences:

periphery-lld/periphAL.h
50 50

  
51 51
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__)
52 52

  
53
#ifdef __cplusplus
53
#if defined(__cplusplus)
54 54
extern "C" {
55
#endif
55
#endif /* defined(__cplusplus) */
56 56
  void _apalDbgAssertMsg(const bool c, const char* fmt, ...);
57 57
  void apalDbgPrintf(const char* fmt, ...);
58
#ifdef __cplusplus
58
#if defined(__cplusplus)
59 59
}
60
#endif
60
#endif /* defined(__cplusplus) */
61 61

  
62 62
/**
63 63
 * @brief Assert function to check a given condition.
......
67 67
#define apalDbgAssert(c)                                                      \
68 68
  _apalDbgAssertMsg(c, "%s(%u): apalDbgAssert failed", __FILE__, __LINE__);
69 69

  
70
#else /* AMIROOS_CFG_DBG != true */
70
#else /* (AMIROOS_CFG_DBG != true) */
71 71

  
72 72
#define apalDbgAssert(constition)
73 73
#define apalDbgAssertMsg(condition, fmt, ...)
74 74
#define apalDbgPrintf(fmt, ...)
75 75

  
76
#endif /* AMIROOS_CFG_DBG */
76
#endif /* (AMIROOS_CFG_DBG == true) */
77 77

  
78 78
/*============================================================================*/
79 79
/* GENERAL                                                                    */
......
101 101
/* GPIO                                                                       */
102 102
/*============================================================================*/
103 103

  
104
#if HAL_USE_PAL || defined (__DOXYGEN__)
104
#if (HAL_USE_PAL == TRUE) || defined (__DOXYGEN__)
105 105

  
106 106
/**
107 107
 * @brief GPIO driver type.
......
212 212
    (edge == APAL_GPIO_EDGE_FALLING) ? PAL_EVENT_MODE_FALLING_EDGE :  \
213 213
     (edge == APAL_GPIO_EDGE_BOTH) ? PAL_EVENT_MODE_BOTH_EDGES : 0)
214 214

  
215
#endif /* HAL_USE_PAL */
215
#endif /* (HAL_USE_PAL == TRUE) */
216 216

  
217 217
/*============================================================================*/
218 218
/* PWM                                                                        */
219 219
/*============================================================================*/
220 220

  
221
#if HAL_USE_PWM || defined (__DOXYGEN__)
221
#if (HAL_USE_PWM == TRUE) || defined (__DOXYGEN__)
222 222

  
223 223
/**
224 224
 * @brief PWM driver type.
......
276 276
  return APAL_STATUS_OK;
277 277
}
278 278

  
279
#endif /* HAL_USE_PWM */
279
#endif /* (HAL_USE_PWM == TRUE) */
280 280

  
281 281
/*============================================================================*/
282 282
/* QEI                                                                        */
283 283
/*============================================================================*/
284 284

  
285
#if HAL_USE_QEI || defined (__DOXYGEN__)
285
#if (HAL_USE_QEI == TRUE) || defined (__DOXYGEN__)
286 286

  
287 287
/**
288 288
 * @brief QEI driver type.
......
343 343
  return APAL_STATUS_OK;
344 344
}
345 345

  
346
#endif /* HAL_USE_QEI */
346
#endif /* (HAL_USE_QEI == TRUE) */
347 347

  
348 348
/*============================================================================*/
349 349
/* I2C                                                                        */
350 350
/*============================================================================*/
351 351

  
352
#if HAL_USE_I2C || defined(__DOXYGEN__)
352
#if (HAL_USE_I2C == TRUE) || defined(__DOXYGEN__)
353 353

  
354 354
/**
355 355
 * @brief I2C driver type.
......
379 379
  if (!i2cd_locked_external) {
380 380
    i2cAcquireBus(i2cd);
381 381
  }
382
#endif
382
#endif /* (I2C_USE_MUTUAL_EXCLUSION == TRUE) */
383 383

  
384 384
#pragma GCC diagnostic push
385 385
#pragma GCC diagnostic ignored "-Wtype-limits"
......
393 393
  } else {
394 394
    status = i2cMasterTransmitTimeout(i2cd, addr, txbuf, txbytes, rxbuf, rxbytes, ((timeout >= TIME_INFINITE) ? TIME_INFINITE : TIME_US2I(timeout)) );
395 395
  }
396
#else
396
#else /* defined(STM32F1XX_I2C) */
397 397
  const msg_t status = i2cMasterTransmitTimeout(i2cd, addr, txbuf, txbytes, rxbuf, rxbytes, ((timeout >= TIME_INFINITE) ? TIME_INFINITE : TIME_US2I(timeout)) );
398
#endif
398
#endif /* defined(STM32F1XX_I2C) */
399 399
#pragma GCC diagnostic pop
400 400

  
401 401
#if (I2C_USE_MUTUAL_EXCLUSION == TRUE)
402 402
  if (!i2cd_locked_external) {
403 403
    i2cReleaseBus(i2cd);
404 404
  }
405
#endif
405
#endif /* (I2C_USE_MUTUAL_EXCLUSION == TRUE) */
406 406

  
407 407
  switch (status)
408 408
  {
409 409
    case MSG_OK:
410 410
#if defined(STM32F1XX_I2C)
411 411
      return (rxbytes != 1) ? APAL_STATUS_OK : APAL_STATUS_WARNING;
412
#else
412
#else /* defined(STM32F1XX_I2C) */
413 413
      return APAL_STATUS_OK;
414
#endif
414
#endif /* defined(STM32F1XX_I2C) */
415 415
    case MSG_TIMEOUT:
416 416
      return APAL_STATUS_TIMEOUT;
417 417
    case MSG_RESET:
......
441 441
  if (!i2cd_locked_external) {
442 442
    i2cAcquireBus(i2cd);
443 443
  }
444
#endif
444
#endif /* (I2C_USE_MUTUAL_EXCLUSION == TRUE) */
445 445

  
446 446
#pragma GCC diagnostic push
447 447
#pragma GCC diagnostic ignored "-Wtype-limits"
......
455 455
  } else {
456 456
    status = i2cMasterReceiveTimeout(i2cd, addr, rxbuf, rxbytes, ((timeout >= TIME_INFINITE) ? TIME_INFINITE : TIME_US2I(timeout)) );
457 457
  }
458
#else
458
#else /* defined(STM32F1XX_I2C) */
459 459
  const msg_t status = i2cMasterReceiveTimeout(i2cd, addr, rxbuf, rxbytes, ((timeout >= TIME_INFINITE) ? TIME_INFINITE : TIME_US2I(timeout)) );
460
#endif
460
#endif /* defined(STM32F1XX_I2C) */
461 461
#pragma GCC diagnostic pop
462 462

  
463 463
#if (I2C_USE_MUTUAL_EXCLUSION == TRUE)
464 464
  if (!i2cd_locked_external) {
465 465
    i2cReleaseBus(i2cd);
466 466
  }
467
#endif
467
#endif /* (I2C_USE_MUTUAL_EXCLUSION == TRUE) */
468 468

  
469 469
  switch (status)
470 470
  {
471 471
    case MSG_OK:
472 472
#if defined(STM32F1XX_I2C)
473 473
      return (rxbytes != 1) ? APAL_STATUS_OK : APAL_STATUS_WARNING;
474
#else
474
#else /* defined(STM32F1XX_I2C) */
475 475
      return APAL_STATUS_OK;
476
#endif
476
#endif /* defined(STM32F1XX_I2C) */
477 477
    case MSG_TIMEOUT:
478 478
      return APAL_STATUS_TIMEOUT;
479 479
    case MSG_RESET:
......
482 482
  }
483 483
}
484 484

  
485
#endif /* HAL_USE_I2C */
485
#endif /* (HAL_USE_I2C == TRUE) */
486 486

  
487 487
/*============================================================================*/
488 488
/* SPI                                                                        */
489 489
/*============================================================================*/
490 490

  
491
#if HAL_USE_SPI || defined(__DOXYGEN__)
491
#if (HAL_USE_SPI == TRUE) || defined(__DOXYGEN__)
492 492

  
493 493
/**
494 494
 * @brief SPI driver type.
......
509 509
{
510 510
  apalDbgAssert(spid != NULL);
511 511

  
512
#if (SPI_USE_MUTUAL_EXCLUSION)
512
#if (SPI_USE_MUTUAL_EXCLUSION == TRUE)
513 513
  // check whether the SPI driver was locked externally
514 514
  const bool spid_locked_external = spid->mutex.owner == currp;
515 515
  if (!spid_locked_external) {
516 516
    spiAcquireBus(spid);
517 517
  }
518
#endif
518
#endif /* (SPI_USE_MUTUAL_EXCLUSION == TRUE) */
519 519

  
520 520
  spiSelect(spid);
521 521
  spiExchange(spid, length, txData, rxData);
522 522
  spiUnselect(spid);
523 523

  
524
#if (SPI_USE_MUTUAL_EXCLUSION)
524
#if (SPI_USE_MUTUAL_EXCLUSION == TRUE)
525 525
  if (!spid_locked_external) {
526 526
    spiReleaseBus(spid);
527 527
  }
528
#endif
528
#endif /* (SPI_USE_MUTUAL_EXCLUSION == TRUE) */
529 529

  
530 530
  return APAL_STATUS_OK;
531 531
}
......
543 543
{
544 544
  apalDbgAssert(spid != NULL);
545 545

  
546
#if (SPI_USE_MUTUAL_EXCLUSION)
546
#if (SPI_USE_MUTUAL_EXCLUSION == TRUE)
547 547
  // check whether the SPI driver was locked externally
548 548
  const bool spid_locked_external = spid->mutex.owner == currp;
549 549
  if (!spid_locked_external) {
550 550
    spiAcquireBus(spid);
551 551
  }
552
#endif
552
#endif /* (SPI_USE_MUTUAL_EXCLUSION == TRUE) */
553 553

  
554 554
  spiSelect(spid);
555 555
  spiReceive(spid, length, data);
556 556
  spiUnselect(spid);
557 557

  
558
#if (SPI_USE_MUTUAL_EXCLUSION)
558
#if (SPI_USE_MUTUAL_EXCLUSION == TRUE)
559 559
  if (!spid_locked_external) {
560 560
    spiReleaseBus(spid);
561 561
  }
562
#endif
562
#endif /* (SPI_USE_MUTUAL_EXCLUSION == TRUE) */
563 563

  
564 564
  return APAL_STATUS_OK;
565 565
}
......
577 577
{
578 578
  apalDbgAssert(spid != NULL);
579 579

  
580
#if (SPI_USE_MUTUAL_EXCLUSION)
580
#if (SPI_USE_MUTUAL_EXCLUSION == TRUE)
581 581
  // check whether the SPI driver was locked externally
582 582
  const bool spid_locked_external = spid->mutex.owner == currp;
583 583
  if (!spid_locked_external) {
584 584
    spiAcquireBus(spid);
585 585
  }
586
#endif
586
#endif /* (SPI_USE_MUTUAL_EXCLUSION == TRUE) */
587 587

  
588 588
  spiSelect(spid);
589 589
  spiSend(spid, length, data);
590 590
  spiUnselect(spid);
591 591

  
592
#if (SPI_USE_MUTUAL_EXCLUSION)
592
#if (SPI_USE_MUTUAL_EXCLUSION == TRUE)
593 593
  if (!spid_locked_external) {
594 594
    spiReleaseBus(spid);
595 595
  }
596
#endif
596
#endif /* (SPI_USE_MUTUAL_EXCLUSION == TRUE) */
597 597

  
598 598
  return APAL_STATUS_OK;
599 599
}
......
613 613
{
614 614
  apalDbgAssert(spid != NULL);
615 615

  
616
#if (SPI_USE_MUTUAL_EXCLUSION)
616
#if (SPI_USE_MUTUAL_EXCLUSION == TRUE)
617 617
  // check whether the SPI driver was locked externally
618 618
  const bool spid_locked_external = spid->mutex.owner == currp;
619 619
  if (!spid_locked_external) {
620 620
    spiAcquireBus(spid);
621 621
  }
622
#endif
622
#endif /* (SPI_USE_MUTUAL_EXCLUSION == TRUE) */
623 623

  
624 624
  spiSelect(spid);
625 625
  spiSend(spid, txLength, txData);
626 626
  spiReceive(spid, rxLength, rxData);
627 627
  spiUnselect(spid);
628 628

  
629
#if (SPI_USE_MUTUAL_EXCLUSION)
629
#if (SPI_USE_MUTUAL_EXCLUSION == TRUE)
630 630
  if (!spid_locked_external) {
631 631
    spiReleaseBus(spid);
632 632
  }
633
#endif
633
#endif /* (SPI_USE_MUTUAL_EXCLUSION == TRUE) */
634 634

  
635 635
  return APAL_STATUS_OK;
636 636
}
637 637

  
638
#endif /* HAL_USE_SPI */
638
#endif /* (HAL_USE_SPI == TRUE) */
639 639

  
640 640
#endif /* AMIROOS_PERIPHAL_H */

Also available in: Unified diff