Functions

group group_csd_functions

Functions

cy_en_csd_status_t Cy_CSD_Init(CSD_Type *base, cy_stc_csd_config_t const *config, cy_en_csd_key_t key, cy_stc_csd_context_t *context)

Acquires and locks the CSD HW block and configures it.

If the CSD HW block is already in use by other middleware or by the application program, then the function returns the CY_CSD_LOCKED status and does not configure the CSD HW block.

In case of successful acquisition, this function writes configuration data into all CSD HW block registers (except read-only registers and SEQ_START register) at once. Because the SEQ_START register is excluded from write, use the Cy_CSD_WriteReg() function to trigger the state machine for scan or conversion.

Return

Returns an operation result status (CSD status code). See cy_en_csd_status_t.

Parameters
  • base: Pointer to a CSD HW block base address.

  • config: The pointer to a configuration structure that contains the initial configuration.

  • key: An ID of middleware or user-level function that is going to work with the specified CSD HW block.

  • context: The pointer to the context structure allocated by a user or middleware.

cy_en_csd_status_t Cy_CSD_DeInit(const CSD_Type *base, cy_en_csd_key_t key, cy_stc_csd_context_t *context)

Releases the CSD HW block previously captured and locked by the caller.

If the CSD HW block is acquired by another caller or the block is in the busy state (performing scan or conversion), the de-initialization request is ignored and the corresponding status is returned.

Return

Returns an operation result status (CSD status code). See cy_en_csd_status_t.

Parameters
  • base: Pointer to a CSD HW block base address.

  • key: An ID of middleware or user-level function that is going to work with a specified CSD HW block.

  • context: The pointer to the context structure allocated by a user or middleware.

cy_en_csd_status_t Cy_CSD_Configure(CSD_Type *base, const cy_stc_csd_config_t *config, cy_en_csd_key_t key, const cy_stc_csd_context_t *context)

Sets configuration of all CSD HW block registers at once.

This function writes configuration data into all CSD block registers (except read-only registers and the SEQ_START register) at once. Because the SEQ_START register is excluded from write, use the Cy_CSD_WriteReg() function to perform triggering state machine for scan or conversion.

Return

Returns an operation result status (CSD status code). See cy_en_csd_status_t.

Parameters
  • base: Pointer to a CSD HW block base address.

  • config: The pointer to a configuration structure that contains initial configuration.

  • key: An ID of middleware or user-level function that is going to work with the specified CSD HW block.

  • context: The pointer to the context structure allocated by a user or middleware.

uint32_t Cy_CSD_GetVrefTrim(uint32_t referenceVoltage)

Adjusts the provided reference voltage based on factory trimmed SFALSH Vref trim registers.

This function is mainly used by CSDADC middleware only to get the most accurate reference voltage possible.

Return

Returns a trimmed reference voltage.

Parameters
  • referenceVoltage: The reference voltage to trim.

__STATIC_INLINE cy_en_csd_key_t Cy_CSD_GetLockStatus (const CSD_Type *base, const cy_stc_csd_context_t *context)

Verifies whether the specified CSD HW block is acquired and locked by a higher-level firmware.


    cy_en_csd_key_t key;

    key = Cy_CSD_GetLockStatus(CSD0, &csdContext);
    if (CY_CSD_NONE_KEY == key)
    {
        /* The CSD block is not captured */
    }
    
Return

Returns a key code. See cy_en_csd_key_t.

Function Usage

Parameters
  • base: Pointer to a CSD HW block base address.

  • context: The pointer to the context structure allocated by a user or middleware.

__STATIC_INLINE cy_en_csd_status_t Cy_CSD_GetConversionStatus (const CSD_Type *base, const cy_stc_csd_context_t *context)

Verifies whether the specified CSD HW block is busy (performing scan or conversion).

    
    cy_en_csd_status_t status;
    
    status = Cy_CSD_GetConversionStatus(CSD0, &csdContext);
    if (CY_CSD_BUSY == status)
    {
        /* The CSD block is performing a conversion */
    }
    else
    {
        /* The CSD block is not busy and a new conversion could be started */
    }
    
Return

Returns status code. See cy_en_csd_status_t.

Function Usage

Parameters
  • base: Pointer to a CSD HW block base address.

  • context: The pointer to the context structure allocated by a user or middleware.

__STATIC_INLINE uint32_t Cy_CSD_ReadReg (const CSD_Type *base, uint32_t offset)

Reads value from the specified the CSD HW block register.

Return

Returns a value of the CSD HW block register, specified by the offset parameter.

Parameters
  • base: Pointer to a CSD HW block base address.

  • offset: Register offset relative to base address.

__STATIC_INLINE void Cy_CSD_WriteReg (CSD_Type *base, uint32_t offset, uint32_t value)

Writes a value to the specified CSD HW block register.

Parameters
  • base: Pointer to a CSD HW block base address.

  • offset: Register offset relative to base address.

  • value: Value to be written to the register.

__STATIC_INLINE void Cy_CSD_SetBits (CSD_Type *base, uint32_t offset, uint32_t mask)

Sets bits, specified by the Mask parameter in the CSD HW block register, specified by the Offset parameter.

Parameters
  • base: Pointer to a CSD HW block base address.

  • offset: Register offset relative to base address.

  • mask: Mask value for register bits to be set.

__STATIC_INLINE void Cy_CSD_ClrBits (CSD_Type *base, uint32_t offset, uint32_t mask)

Clears bits, specified by the Mask parameter in the CSD HW block register, specified by the Offset parameter.

Parameters
  • base: Pointer to a CSD HW block base address.

  • offset: Register offset relative to base address.

  • mask: Mask value for register bits to be cleared.

__STATIC_INLINE void Cy_CSD_WriteBits (CSD_Type *base, uint32_t offset, uint32_t mask, uint32_t value)

Writes field, specified by the Mask parameter with the value, specified by the Value parameter.

Parameters
  • base: Pointer to a CSD HW block base address.

  • offset: Register offset relative to base address.

  • mask: Specifies bits to be modified.

  • value: Specifies a value to be written to the register.