Revision 70dd091e

View differences:

periphery-lld/AMiRo-LLD
1
Subproject commit e637a5101e3bb1e0a082aa7d532c253af2263221
1
Subproject commit bb7c53481afaa76d993538c5e2b2eae430cfb441
periphery-lld/periphAL.h
536 536
typedef SPIDriver apalSPIDriver_t;
537 537

  
538 538
/**
539
 * @brief SPI confguration type.
540
 */
541
typedef SPIConfig apalSPIConfig_t;
542

  
543
/**
544
 * @brief Reconfigure an SPI driver.
545
 *
546
 * @param[in] spid    The SPI driver to be reconfigured.
547
 * @param[in] config  Configuration to apply.
548
 *
549
 * @return The status indicates whether the function call was succesful.
550
 */
551
static inline apalExitStatus_t apalSPIReconfigure(apalSPIDriver_t* spid, const apalSPIConfig_t* config)
552
{
553
  apalDbgAssert(spid != NULL);
554
  apalDbgAssert(config != NULL);
555

  
556
#if (SPI_USE_MUTUAL_EXCLUSION == TRUE)
557
  // check whether the SPI driver was locked externally
558
  const bool spid_locked_external = spid->mutex.owner == currp;
559
  if (!spid_locked_external) {
560
    spiAcquireBus(spid);
561
  }
562
#endif /* (SPI_USE_MUTUAL_EXCLUSION == TRUE) */
563

  
564
  spiStop(spid);
565
  spiStart(spid, config);
566

  
567
#if (SPI_USE_MUTUAL_EXCLUSION == TRUE)
568
  if (!spid_locked_external) {
569
    spiReleaseBus(spid);
570
  }
571
#endif /* (SPI_USE_MUTUAL_EXCLUSION == TRUE) */
572

  
573
  return APAL_STATUS_OK;
574
}
575

  
576
/**
539 577
 * @brief Transmit and receive data from SPI
540 578
 *
541 579
 * @param[in]   spid      The SPI driver to use.

Also available in: Unified diff