MTB CAT1 Peripheral driver library

General Description

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, locks, and configures the CSD HW block. More...
 
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. More...
 
cy_en_csd_status_t Cy_CSD_Capture (CSD_Type *base, cy_en_csd_key_t key, cy_stc_csd_context_t *context)
 Acquires and locks the CSD HW block without changing its configuration. More...
 
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. More...
 
uint32_t Cy_CSD_GetVrefTrim (uint32_t referenceVoltage)
 Adjusts the provided reference voltage based on factory trimmed SFLASH Vref trim registers. More...
 
__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. More...
 
__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). More...
 
__STATIC_INLINE uint32_t Cy_CSD_ReadReg (const CSD_Type *base, uint32_t offset)
 Reads value from the specified the CSD HW block register. More...
 
__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. More...
 
__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. More...
 
__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. More...
 
__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. More...
 

Function Documentation

◆ Cy_CSD_Init()

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, locks, and configures the CSD HW block.

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

If the acquisition is successful, 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.

To capture the CSD block without its reconfiguration, use the Cy_CSD_Capture() function.

Parameters
baseThe pointer to a CSD HW block base address.
configThe pointer to a configuration structure that contains the initial configuration.
keyThe ID of middleware or a user-level function to work with the specified CSD HW block.
contextThe pointer to the context structure allocated by the user or middleware.
Returns
Returns the operation result status (CSD status code). See cy_en_csd_status_t.

◆ Cy_CSD_DeInit()

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.

Parameters
basePointer to a CSD HW block base address.
keyThe ID of middleware or a user-level function to work with the specified CSD HW block.
contextThe pointer to the context structure allocated by the user or middleware.
Returns
Returns the operation result status (CSD status code). See cy_en_csd_status_t.

◆ Cy_CSD_Capture()

cy_en_csd_status_t Cy_CSD_Capture ( CSD_Type *  base,
cy_en_csd_key_t  key,
cy_stc_csd_context_t context 
)

Acquires and locks the CSD HW block without changing its configuration.

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

Note
This is a low-level function. Use the Cy_CSD_Init() function instead. The Cy_CSD_Capture() function is used by upper-level middleware to improve efficiency. It also can be used to implement specific use cases. If this function is used, configure the CSD block using the Cy_CSD_Configure() function.
Parameters
baseThe pointer to a CSD HW block base address.
keyThe ID of middleware or a user-level function to work with the specified CSD HW block.
contextThe pointer to the context structure allocated by the user or middleware.
Returns
Returns the operation result status (CSD status code). See cy_en_csd_status_t.

◆ Cy_CSD_Configure()

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.

Parameters
baseThe pointer to a CSD HW block base address.
configThe pointer to a configuration structure that contains initial configuration.
keyThe ID of middleware or a user-level function to work with the specified CSD HW block.
contextThe pointer to the context structure allocated by the user or middleware.
Returns
Returns the operation result status (CSD status code). See cy_en_csd_status_t.

◆ Cy_CSD_GetVrefTrim()

uint32_t Cy_CSD_GetVrefTrim ( uint32_t  referenceVoltage)

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

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

Parameters
referenceVoltageThe reference voltage to trim.
Returns
Returns a trimmed reference voltage.

◆ Cy_CSD_GetLockStatus()

__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.

Parameters
basePointer to a CSD HW block base address.
contextThe pointer to the context structure allocated by a user or middleware.
Returns
Returns a key code. See cy_en_csd_key_t.
Function Usage
key = Cy_CSD_GetLockStatus(CSD0, &csdContext);
if (CY_CSD_NONE_KEY == key)
{
/* The CSD block is not captured */
}

◆ Cy_CSD_GetConversionStatus()

__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).

Parameters
basePointer to a CSD HW block base address.
contextThe pointer to the context structure allocated by a user or middleware.
Returns
Returns status code. See cy_en_csd_status_t.
Function Usage
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 */
}

◆ Cy_CSD_ReadReg()

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

Reads value from the specified the CSD HW block register.

Parameters
basePointer to a CSD HW block base address.
offsetRegister offset relative to base address.
Returns
Returns a value of the CSD HW block register, specified by the offset parameter.

◆ Cy_CSD_WriteReg()

__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
basePointer to a CSD HW block base address.
offsetRegister offset relative to base address.
valueValue to be written to the register.

◆ Cy_CSD_SetBits()

__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
basePointer to a CSD HW block base address.
offsetRegister offset relative to base address.
maskMask value for register bits to be set.

◆ Cy_CSD_ClrBits()

__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
basePointer to a CSD HW block base address.
offsetRegister offset relative to base address.
maskMask value for register bits to be cleared.

◆ Cy_CSD_WriteBits()

__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
basePointer to a CSD HW block base address.
offsetRegister offset relative to base address.
maskSpecifies bits to be modified.
valueSpecifies a value to be written to the register.