Пример #1
0
LDD_TError DAC_SetBuffer (
    /* [IN] Device data structure pointer. */
    LDD_TDeviceDataPtr  DeviceData,
    /* [IN] Pointer to array containing user data. */
    uint_16_ptr         DataArrayPtr,
    /* [IN] Length of user data array which should be written to data buffer. */
    uint_8              DataArrayLength,
    /* [IN] Index of first written data buffer register. */
    uint_8              StartBufferReg
)
{
    DAC_MemMapPtr DAC_BasePtr = ((DAC_TDeviceDataPtr)DeviceData)->DAC_MODULE_BASE_PTR;
    uint_32       i;

    /* Range test -> Are input parameters in possible range? */
    if((StartBufferReg + DataArrayLength) > DAC_BUFFER_MAX_SIZE) 
    {
        return DAC_ERROR_RANGE;                  /* No, return ERR_RANGE. */
    }

    for(i = 0U; i < DataArrayLength; i++)
    {
        DAC_PDD_SetData(DAC_BasePtr,(uint_16)(*(DataArrayPtr + i)),(StartBufferReg + i));
    }

    return DAC_ERROR_OK;
}
Пример #2
0
LDD_TError DAC_SetValue (
    /* [IN] Device data structure pointer. */
    LDD_TDeviceDataPtr  DeviceData,
    /* [IN] User data */
    LDD_DAC_TData       Data
)
{
    DAC_MemMapPtr DAC_BasePtr = ((DAC_TDeviceDataPtr)DeviceData)->DAC_MODULE_BASE_PTR;
    
    DAC_PDD_SetData(DAC_BasePtr,(uint_16)Data, 0);

    return DAC_ERROR_OK;
}
Пример #3
0
/*
** ===================================================================
**     Method      :  DA1_SetValue (component DAC_LDD)
**
**     Description :
**         Sets DAC output voltage according to specified value.
**         Input data format is specified by <Data mode> property
**         settings. If selected formatting is not native for DAC
**         device which is used then any necessary transformations (e.g.
**         shifting) are done.
**     Parameters  :
**         NAME            - DESCRIPTION
**       * DeviceDataPtr   - Pointer to device data
**                           structure.
**         Data            - User data.
**     Returns     :
**         ---             - Error code, possible codes:
**                           - ERR_OK - OK.
**                           - ERR_SPEED - This device does not work in
**                           the active clock configuration.
**                           - ERR_DISABLED - Component or device is
**                           disabled.
** ===================================================================
*/
LDD_TError DA1_SetValue(LDD_TDeviceData *DeviceDataPtr, LDD_DAC_TData Data)
{
  /* 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 (((DA1_TDeviceData*)DeviceDataPtr)->EnMode == 0x00U) { /* Is the device disabled in the actual speed CPU mode? */
    return ERR_SPEED;                  /* No, return ERR_SPEED */
  }
  /* Device state test - this test can be disabled by setting the "Ignore enable test"
     property to the "yes" value in the "Configuration inspector" */
  if (DAC_PDD_GetDeviceEnabled(DAC0_BASE_PTR) == PDD_DISABLE) { /* Is device enabled? */
    return ERR_DISABLED;               /* No, return ERR_DISABLED */
  }
  DAC_PDD_SetData(DAC0_BASE_PTR,(uint16_t)Data,0U);
  return ERR_OK;
}
Пример #4
0
/*
** ===================================================================
**     Method      :  DA1_SetBuffer (component DAC_LDD)
**
**     Description :
**         Writes an array of data words to the data buffer registers.
**         Array is defined by pointer to start address and by it's
**         length. First written data buffer register is defined by
**         index.
**         If the length of array exceeds number of registers between
**         the first written register and the last one at the end of
**         the buffer then an ERR_PARAM_RANGE is returned and no data
**         are written. It is possible to write all register available
**         in hardware - no checking for current upper limit value of
**         buffer is done.
**         DataArrayPtr has fixed data type regardless of current
**         hardware or design time configuration and must be always
**         used. Real type of user data is specified in <Data mode>
**         property.
**         If the DMA service is enabled then this methods can be used
**         to prepare DMA transfer via channel handled by DMA Transfer
**         inherited component. 
**         _/Note: This method is available only if DAC device is
**         supporting data buffer and Data buffer is enabled./_
**     Parameters  :
**         NAME            - DESCRIPTION
**       * DeviceDataPtr   - Device data structure
**                           pointer returned by <Init> method.
**       * DataArrayPtr    - Pointer to array
**                           containing user data.
**         DataArrayLength - Length of user
**                           data array which should be written to data
**                           buffer.
**         FirstRegisterIndex - Index of
**                           first written data buffer register.
**     Returns     :
**         ---             - Error code, possible codes:
**                           - ERR_OK - OK.
**                           - ERR_SPEED - This device does not work in
**                           the active clock configuration.
**                           - ERR_DISABLED - Component or device is
**                           disabled.
**                           - ERR_PARAM_RANGE - Index of last written
**                           buffer register would be out of buffer
**                           range.
** ===================================================================
*/
LDD_TError DA1_SetBuffer(LDD_TDeviceData *DeviceDataPtr, LDD_TData *DataArrayPtr, uint8_t DataArrayLength, uint8_t FirstRegisterIndex)
{
  uint8_t i;

  /* 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 (((DA1_TDeviceData*)DeviceDataPtr)->EnMode == 0x00U) { /* Is the device disabled in the actual speed CPU mode? */
    return ERR_SPEED;                  /* No, return ERR_SPEED */
  }
  /* Device state test - this test can be disabled by setting the "Ignore enable test"
     property to the "yes" value in the "Configuration inspector" */
  if (DAC_PDD_GetDeviceEnabled(DAC0_BASE_PTR) == PDD_DISABLE) { /* Is device enabled? */
    return ERR_DISABLED;               /* No, return ERR_DISABLED */
  }
  /* Range test - this test can be disabled by setting the "Ignore range checking"
     property to the "yes" value in the "Configuration inspector" */
  if((FirstRegisterIndex + DataArrayLength) > DA1_BUFFER_MAX_SIZE) { /* Are input parameters in possible range? */
    return ERR_PARAM_RANGE;            /* No, return ERR_PARAM_RANGE */
  }
  for(i=0U;i<DataArrayLength;i++) {
    DAC_PDD_SetData(DAC0_BASE_PTR,(uint16_t)(((uint16_t*)DataArrayPtr)[i]),(FirstRegisterIndex + i));
  }
  return ERR_OK;
}
/* ===================================================================*/
LDD_TError DacLdd1_SetValue(LDD_TDeviceData *DeviceDataPtr, LDD_DAC_TData Data)
{
  (void)DeviceDataPtr;                 /* Parameter not used, suppress not used argument warning */
  DAC_PDD_SetData(DAC0_BASE_PTR,(uint16_t)Data,0U);
  return ERR_OK;
}