PSoC 6 Peripheral Driver Library

General Description

API Reference

 Status codes
 Function status type codes.
 
 Assert Classes and Levels
 Defines for the Assert Classes and Levels.
 
 Reset cause
 Define RESET_CAUSE mask values.
 
 Unique ID
 Unique ID fields positions.
 

Macros

#define CY_CPU_CORTEX_M0P   (__CORTEX_M == 0)
 CM0+ core CPU Code.
 
#define CY_CPU_CORTEX_M4   (__CORTEX_M == 4)
 CM4 core CPU Code.
 
#define CY_ARM_FAULT_DEBUG_DISABLED   (0U)
 The macro to disable the Fault Handler.
 
#define CY_ARM_FAULT_DEBUG_ENABLED   (1U)
 The macro to enable the Fault Handler.
 
#define CY_ARM_FAULT_DEBUG   (CY_ARM_FAULT_DEBUG_ENABLED)
 The macro defines if the Fault Handler is enabled. More...
 
#define CY_SYSLIB_DRV_VERSION_MAJOR   2
 The driver major version.
 
#define CY_SYSLIB_DRV_VERSION_MINOR   40
 The driver minor version.
 
#define CY_LO8(x)   ((uint8_t) ((x) & 0xFFU))
 Get the lower 8 bits of a 16-bit value. More...
 
#define CY_HI8(x)   ((uint8_t) ((uint16_t)(x) >> 8U))
 Get the upper 8 bits of a 16-bit value. More...
 
#define CY_LO16(x)   ((uint16_t) ((x) & 0xFFFFU))
 Get the lower 16 bits of a 32-bit value. More...
 
#define CY_HI16(x)   ((uint16_t) ((uint32_t)(x) >> 16U))
 Get the upper 16 bits of a 32-bit value. More...
 
#define CY_SWAP_ENDIAN16(x)   ((uint16_t)(((x) << 8U) | (((x) >> 8U) & 0x00FFU)))
 Swap the byte ordering of a 16-bit value.
 
#define CY_SWAP_ENDIAN32(x)
 Swap the byte ordering of a 32-bit value. More...
 
#define CY_SWAP_ENDIAN64(x)
 Swap the byte ordering of a 64-bit value. More...
 
#define CY_MAX_FILE_NAME_SIZE   (24U)
 The max size of the file name which stores the ASSERT location.
 
#define CY_R0_Pos   (0U)
 The position of the R0 content in a fault structure.
 
#define CY_R1_Pos   (1U)
 The position of the R1 content in a fault structure.
 
#define CY_R2_Pos   (2U)
 The position of the R2 content in a fault structure.
 
#define CY_R3_Pos   (3U)
 The position of the R3 content in a fault structure.
 
#define CY_R12_Pos   (4U)
 The position of the R12 content in a fault structure.
 
#define CY_LR_Pos   (5U)
 The position of the LR content in a fault structure.
 
#define CY_PC_Pos   (6U)
 The position of the PC content in a fault structure.
 
#define CY_PSR_Pos   (7U)
 The position of the PSR content in a fault structure.
 
#define CY_GET_REG8(addr)   (*((const volatile uint8_t *)(addr)))
 Reads the 8-bit value from the specified address. More...
 
#define CY_SET_REG8(addr, value)   (*((volatile uint8_t *)(addr)) = (uint8_t)(value))
 Writes an 8-bit value to the specified address. More...
 
#define CY_GET_REG16(addr)   (*((const volatile uint16_t *)(addr)))
 Reads the 16-bit value from the specified address. More...
 
#define CY_SET_REG16(addr, value)   (*((volatile uint16_t *)(addr)) = (uint16_t)(value))
 Writes the 16-bit value to the specified address. More...
 
#define CY_GET_REG24(addr)
 Reads the 24-bit value from the specified address. More...
 
#define CY_SET_REG24(addr, value)
 Writes the 24-bit value to the specified address. More...
 
#define CY_GET_REG32(addr)   (*((const volatile uint32_t *)(addr)))
 Reads the 32-bit value from the specified register. More...
 
#define CY_SET_REG32(addr, value)   (*((volatile uint32_t *)(addr)) = (uint32_t)(value))
 Writes the 32-bit value to the specified register. More...
 
#define CY_ASSERT(x)
 The macro that evaluates the expression and, if it is false (evaluates to 0), the processor is halted. More...
 
#define _CLR_SET_FLD32U(reg, field, value)   (((reg) & ((uint32_t)(~(field ## _Msk)))) | (_VAL2FLD(field, value)))
 The macro for setting a register with a name field and value for providing get-clear-modify-write operations. More...
 
#define CY_REG32_CLR_SET(reg, field, value)   ((reg) = _CLR_SET_FLD32U((reg), field, (value)))
 Uses _CLR_SET_FLD32U macro for providing get-clear-modify-write operations with a name field and value and writes a resulting value to the 32-bit register.
 
#define _CLR_SET_FLD16U(reg, field, value)
 The macro for setting a 16-bit register with a name field and value for providing get-clear-modify-write operations. More...
 
#define CY_REG16_CLR_SET(reg, field, value)   ((reg) = _CLR_SET_FLD16U((reg), field, (value)))
 Uses _CLR_SET_FLD16U macro for providing get-clear-modify-write operations with a name field and value and writes a resulting value to the 16-bit register.
 
#define _CLR_SET_FLD8U(reg, field, value)
 The macro for setting a 8-bit register with a name field and value for providing get-clear-modify-write operations. More...
 
#define CY_REG8_CLR_SET(reg, field, value)   ((reg) = _CLR_SET_FLD8U((reg), field, (value)))
 Uses _CLR_SET_FLD8U macro for providing get-clear-modify-write operations with a name field and value and writes a resulting value to the 8-bit register.
 
#define _BOOL2FLD(field, value)   (((value) != false) ? (field ## _Msk) : 0UL)
 Returns a field mask if the value is not false. More...
 
#define _FLD2BOOL(field, value)   (((value) & (field ## _Msk)) != 0UL)
 Returns true, if the value includes the field mask. More...
 
#define CY_SYSLIB_DIV_ROUND(a, b)   (((a) + ((b) / 2U)) / (b))
 Calculates a / b with rounding to the nearest integer, a and b must have the same sign.
 
#define CY_SYSLIB_DIV_ROUNDUP(a, b)   ((((a) - 1U) / (b)) + 1U)
 Calculates a / b with rounding up if remainder != 0, both a and b must be positive.
 
#define CY_DELAY_MS_OVERFLOW   (0x8000U)
 Defines a 32-kHz clock delay.
 
#define CY_IPC_DATA_FOR_CM4_SOFT_RESET   (0x1B000002UL)
 Bit[31:24] Opcode = 0x1B (SoftReset) Bit[7:1] Type = 1 (Only CM4 reset)
 

Typedefs

typedef void(* cy_israddress) (void)
 Type of ISR callbacks.
 
typedef char char_t
 Specific-length typedef for the basic numerical types of char.
 
typedef float float32_t
 Specific-length typedef for the basic numerical types of float.
 
typedef double float64_t
 Specific-length typedef for the basic numerical types of double.
 

Variables

char_t cy_assertFileName [CY_MAX_FILE_NAME_SIZE]
 The assert buffer.
 
uint32_t cy_assertLine
 The assert line value.
 
cy_stc_fault_frame_t cy_faultFrame
 Fault frame structure.
 

Macro Definition Documentation

◆ CY_ARM_FAULT_DEBUG

#define CY_ARM_FAULT_DEBUG   (CY_ARM_FAULT_DEBUG_ENABLED)

The macro defines if the Fault Handler is enabled.

Enabled by default.

◆ CY_LO8

#define CY_LO8 (   x)    ((uint8_t) ((x) & 0xFFU))

Get the lower 8 bits of a 16-bit value.

◆ CY_HI8

#define CY_HI8 (   x)    ((uint8_t) ((uint16_t)(x) >> 8U))

Get the upper 8 bits of a 16-bit value.

◆ CY_LO16

#define CY_LO16 (   x)    ((uint16_t) ((x) & 0xFFFFU))

Get the lower 16 bits of a 32-bit value.

◆ CY_HI16

#define CY_HI16 (   x)    ((uint16_t) ((uint32_t)(x) >> 16U))

Get the upper 16 bits of a 32-bit value.

◆ CY_SWAP_ENDIAN32

#define CY_SWAP_ENDIAN32 (   x)
Value:
((uint32_t)((((x) >> 24U) & 0x000000FFU) | (((x) & 0x00FF0000U) >> 8U) | \
(((x) & 0x0000FF00U) << 8U) | ((x) << 24U)))

Swap the byte ordering of a 32-bit value.

◆ CY_SWAP_ENDIAN64

#define CY_SWAP_ENDIAN64 (   x)
Value:
((uint64_t) (((uint64_t) CY_SWAP_ENDIAN32((uint32_t)(x)) << 32U) | \
CY_SWAP_ENDIAN32((uint32_t)((x) >> 32U))))
#define CY_SWAP_ENDIAN32(x)
Swap the byte ordering of a 32-bit value.
Definition: cy_syslib.h:487

Swap the byte ordering of a 64-bit value.

◆ CY_GET_REG8

#define CY_GET_REG8 (   addr)    (*((const volatile uint8_t *)(addr)))

Reads the 8-bit value from the specified address.

This function can't be used to access the Core register, otherwise a fault occurs.

Parameters
addrThe register address.
Returns
The read value.

◆ CY_SET_REG8

#define CY_SET_REG8 (   addr,
  value 
)    (*((volatile uint8_t *)(addr)) = (uint8_t)(value))

Writes an 8-bit value to the specified address.

This function can't be used to access the Core register, otherwise a fault occurs.

Parameters
addrThe register address.
valueThe value to write.

◆ CY_GET_REG16

#define CY_GET_REG16 (   addr)    (*((const volatile uint16_t *)(addr)))

Reads the 16-bit value from the specified address.

Parameters
addrThe register address.
Returns
The read value.

◆ CY_SET_REG16

#define CY_SET_REG16 (   addr,
  value 
)    (*((volatile uint16_t *)(addr)) = (uint16_t)(value))

Writes the 16-bit value to the specified address.

Parameters
addrThe register address.
valueThe value to write.

◆ CY_GET_REG24

#define CY_GET_REG24 (   addr)
Value:
(((uint32_t) (*((const volatile uint8_t *)(addr)))) | \
(((uint32_t) (*((const volatile uint8_t *)(addr) + 1))) << 8U) | \
(((uint32_t) (*((const volatile uint8_t *)(addr) + 2))) << 16U))

Reads the 24-bit value from the specified address.

Parameters
addrThe register address.
Returns
The read value.

◆ CY_SET_REG24

#define CY_SET_REG24 (   addr,
  value 
)
Value:
do \
{ \
(*((volatile uint8_t *) (addr))) = (uint8_t)(value); \
(*((volatile uint8_t *) (addr) + 1)) = (uint8_t)((value) >> 8U); \
(*((volatile uint8_t *) (addr) + 2)) = (uint8_t)((value) >> 16U); \
} \
while(0)

Writes the 24-bit value to the specified address.

Parameters
addrThe register address.
valueThe value to write.

◆ CY_GET_REG32

#define CY_GET_REG32 (   addr)    (*((const volatile uint32_t *)(addr)))

Reads the 32-bit value from the specified register.

The address is the little endian order (LSB in lowest address).

Parameters
addrThe register address.
Returns
The read value.

◆ CY_SET_REG32

#define CY_SET_REG32 (   addr,
  value 
)    (*((volatile uint32_t *)(addr)) = (uint32_t)(value))

Writes the 32-bit value to the specified register.

The address is the little endian order (LSB in lowest address).

Parameters
addrThe register address.
valueThe value to write.

◆ CY_ASSERT

#define CY_ASSERT (   x)
Value:
do \
{ \
if(!(x)) \
{ \
Cy_SysLib_AssertFailed((char_t *) __FILE__, (uint32_t) __LINE__); \
} \
} while(0)
char char_t
Specific-length typedef for the basic numerical types of char.
Definition: cy_syslib.h:556

The macro that evaluates the expression and, if it is false (evaluates to 0), the processor is halted.

Cy_SysLib_AssertFailed() is called when the logical expression is false to store the ASSERT location and halt the processor.

Parameters
xThe logical expression. Asserts if false.
Note
This macro is evaluated unless NDEBUG is not defined. If NDEBUG is defined, just empty do while cycle is generated for this macro for the sake of consistency and to avoid MISRA violation. NDEBUG is defined by default for a Release build setting and not defined for a Debug build setting.

◆ _CLR_SET_FLD32U

#define _CLR_SET_FLD32U (   reg,
  field,
  value 
)    (((reg) & ((uint32_t)(~(field ## _Msk)))) | (_VAL2FLD(field, value)))

The macro for setting a register with a name field and value for providing get-clear-modify-write operations.

Returns a resulting value to be assigned to the register.

◆ _CLR_SET_FLD16U

#define _CLR_SET_FLD16U (   reg,
  field,
  value 
)
Value:
((uint16_t)(((reg) & ((uint16_t)(~(field ## _Msk)))) | \
((uint16_t)_VAL2FLD(field, value))))

The macro for setting a 16-bit register with a name field and value for providing get-clear-modify-write operations.

Returns a resulting value to be assigned to the 16-bit register.

◆ _CLR_SET_FLD8U

#define _CLR_SET_FLD8U (   reg,
  field,
  value 
)
Value:
((uint8_t)(((reg) & ((uint8_t)(~(field ## _Msk)))) | \
((uint8_t)_VAL2FLD(field, value))))

The macro for setting a 8-bit register with a name field and value for providing get-clear-modify-write operations.

Returns a resulting value to be assigned to the 8-bit register.

◆ _BOOL2FLD

#define _BOOL2FLD (   field,
  value 
)    (((value) != false) ? (field ## _Msk) : 0UL)

Returns a field mask if the value is not false.

Returns 0, if the value is false.

◆ _FLD2BOOL

#define _FLD2BOOL (   field,
  value 
)    (((value) & (field ## _Msk)) != 0UL)

Returns true, if the value includes the field mask.

Returns false, if the value doesn't include the field mask.