コード例 #1
0
ファイル: SPI_SD.c プロジェクト: SeismicPi/SeismicPi
/* ===================================================================*/
LDD_TError SPI_SD_SelectConfiguration(LDD_TDeviceData *DeviceDataPtr, uint8_t ChipSelect, uint8_t AttributeSet)
{
  /* Clock configuration test - this test can be disabled by setting the "Ignore clock configuration test"
     property to the "yes" value in the "Configuration inspector" */
  if (!((SPI_SD_TDeviceDataPtr)DeviceDataPtr)->EnMode) { /* Is the device disabled in the actual speed CPU mode? */
    return ERR_SPEED;                  /* If yes then error */
  }
  (void)ChipSelect;                    /* Parameter is not used, suppress unused argument warning */
  if (AttributeSet >= SPI_SD_CONFIGURATION_COUNT) { /* Is Attribute set index out of range? */
    return ERR_PARAM_ATTRIBUTE_SET;    /* Yes, return ERR_PARAM */
  }
  if ((((SPI_SD_TDeviceDataPtr)DeviceDataPtr)->InpDataNumReq != 0x00U) || (((SPI_SD_TDeviceDataPtr)DeviceDataPtr)->OutDataNumReq != 0x00U)) { /* Is the previous receive operation pending? */
    return ERR_BUSY;                   /* If yes then error */
  }
  ((SPI_SD_TDeviceDataPtr)DeviceDataPtr)->CurrentAttributeSet = AttributeSet; /* Set current attribute set */
  SPI_PDD_EnableHaltMode(SPI1_BASE_PTR,PDD_ENABLE); /* Enter to STOPPED mode */
  while (SPI_PDD_GetTxRxActiveFlag(SPI1_BASE_PTR)) {} /* Wait until the current transmission finished */
  switch (Cpu_GetClockConfiguration()) {
    case CPU_CLOCK_CONFIG_0:
      SPI_PDD_WriteMasterClockTransferAttributeReg(SPI1_BASE_PTR,0U,ConfigurationSet0[AttributeSet]); /* Set required configuration */
      break;
    default:
      break;
  }
  ((SPI_SD_TDeviceDataPtr)DeviceDataPtr)->TxCommand = TxCommandList[AttributeSet]; /* Prepare command for transmision */
  SPI_PDD_EnableHaltMode(SPI1_BASE_PTR,PDD_DISABLE); /* Leave the STOPPED mode */
  return ERR_OK;                       /* OK */
}
コード例 #2
0
ファイル: SPI_SD.c プロジェクト: SeismicPi/SeismicPi
/*
** ===================================================================
**     Method      :  SPI_SD_SetClockConfiguration (component SPIMaster_LDD)
**
**     Description :
**         This method changes the clock configuration. During a clock 
**         configuration change the component changes it`s setting 
**         immediately upon a request.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void SPI_SD_SetClockConfiguration(LDD_TDeviceData *DeviceDataPtr, LDD_TClockConfiguration ClockConfiguration)
{
  SPI_SD_TDeviceData *DeviceDataPrv = (SPI_SD_TDeviceData *)DeviceDataPtr;

  switch (ClockConfiguration) {
    case CPU_CLOCK_CONFIG_0:
      DeviceDataPrv->EnMode = TRUE;    /* Set the flag "device enabled" in the actual speed CPU mode */
      SPI_PDD_WriteMasterClockTransferAttributeReg(SPI1_BASE_PTR,0U,ConfigurationSet0[((SPI_SD_TDeviceDataPtr)DeviceDataPtr)->CurrentAttributeSet]); /* Set required configuration */
      break;
    default:
      DeviceDataPrv->EnMode = FALSE;   /* Set the flag "device disabled" in the actual speed CPU mode */
      break;
  }
  HWEnDi(DeviceDataPtr);               /* Enable/disable device according to status flags */
}
コード例 #3
0
ファイル: SM1.c プロジェクト: andrewseaman35/ECE-15.5
/* ===================================================================*/
LDD_TError SM1_SelectConfiguration(LDD_TDeviceData *DeviceDataPtr, uint8_t ChipSelect, uint8_t AttributeSet)
{
  (void)ChipSelect;                    /* Parameter is not used, suppress unused argument warning */
  if (AttributeSet >= SM1_CONFIGURATION_COUNT) { /* Is Attribute set index out of range? */
    return ERR_PARAM_ATTRIBUTE_SET;    /* Yes, return ERR_PARAM */
  }
  if ((((SM1_TDeviceDataPtr)DeviceDataPtr)->InpDataNumReq != 0x00U) || (((SM1_TDeviceDataPtr)DeviceDataPtr)->OutDataNumReq != 0x00U)) { /* Is the previous receive operation pending? */
    return ERR_BUSY;                   /* If yes then error */
  }
  SPI_PDD_EnableHaltMode(SPI1_BASE_PTR,PDD_ENABLE); /* Enter to STOPPED mode */
  while (SPI_PDD_GetTxRxActiveFlag(SPI1_BASE_PTR)) {} /* Wait until the current transmission finished */
  SPI_PDD_WriteMasterClockTransferAttributeReg(SPI1_BASE_PTR,0U,ConfigurationSet[AttributeSet]); /* Set required configuration */
  ((SM1_TDeviceDataPtr)DeviceDataPtr)->TxCommand = TxCommandList[AttributeSet]; /* Prepare command for transmision */
  SPI_PDD_EnableHaltMode(SPI1_BASE_PTR,PDD_DISABLE); /* Leave the STOPPED mode */
  return ERR_OK;                       /* OK */
}