Esempio n. 1
0
uint8_t spi_active(spi_t *obj)
{
    switch(obj->spi.dmaOptionsTX.dmaUsageState) {
        case DMA_USAGE_TEMPORARY_ALLOCATED:
            return true;
        case DMA_USAGE_ALLOCATED:
            /* Check whether the allocated DMA channel is active */
            return(DMA_ChannelEnabled(obj->spi.dmaOptionsTX.dmaChannel) || DMA_ChannelEnabled(obj->spi.dmaOptionsRX.dmaChannel));
        default:
            /* Check whether interrupt for spi is enabled */
            return (obj->spi.spi->IEN & (USART_IEN_RXDATAV | USART_IEN_TXBL)) ? true : false;
    }
}
Esempio n. 2
0
/***************************************************************************//**
 * @brief
 *  Check if a transfer is running.
 *
 * @param[in] channelId
 *  The channel Id of the transfer to check.
 *
 * @param[out] active
 *  True if transfer is running, false otherwise.
 *
 * @return
 *  @ref ECODE_EMDRV_DMADRV_OK on success. On failure an appropriate
 *  DMADRV @ref Ecode_t is returned.
 ******************************************************************************/
Ecode_t DMADRV_TransferActive( unsigned int channelId, bool *active )
{
  if ( !initialized )
  {
    return ECODE_EMDRV_DMADRV_NOT_INITIALIZED;
  }

  if ( ( channelId > EMDRV_DMADRV_DMA_CH_COUNT )
       || ( active == NULL ) )
  {
    return ECODE_EMDRV_DMADRV_PARAM_ERROR;
  }

  if ( chTable[ channelId ].allocated == false )
  {
    return ECODE_EMDRV_DMADRV_CH_NOT_ALLOCATED;
  }

#if defined( EMDRV_DMADRV_UDMA )
  if ( DMA_ChannelEnabled( channelId ) )
#elif defined( EMDRV_DMADRV_LDMA )
  if ( LDMA->CHEN & ( 1 << channelId ) )
#endif
  {
    *active = true;
  }
  else
  {
    *active = false;
  }

  return ECODE_EMDRV_DMADRV_OK;
}