Basic utility types, macros and functions.
Macros | |
#define | CY_UNUSED_PARAMETER(x) ( (void)(x) ) |
Simple macro to suppress the unused parameter warning by casting to void. | |
#define | CY_HALT() |
Halt the processor in the debug state. More... | |
#define | CY_ASSERT_HANDLER() CY_HALT() |
Default assert handler. More... | |
#define | CY_ASSERT(x) |
Utility macro when neither NDEBUG or CY_NO_ASSERT is not declared to check a condition and, if false, trigger a breakpoint. More... | |
#define | CY_ASSERT_AND_RETURN(condition, value) |
Assert an argument is true, else call assert handler and return a value. More... | |
#define | CY_ASSERT_AND_RETURN_VOID(condition) |
Assert an argument is true, else call assert handler and return. More... | |
#define | CY_LO8(x) ((uint8_t) ((x) & 0xFFU)) |
Get the lower 8 bits of a 16-bit value. | |
#define | CY_HI8(x) ((uint8_t) ((uint16_t)(x) >> 8U)) |
Get the upper 8 bits of a 16-bit value. | |
#define | CY_LO16(x) ((uint16_t) ((x) & 0xFFFFU)) |
Get the lower 16 bits of a 32-bit value. | |
#define | CY_HI16(x) ((uint16_t) ((uint32_t)(x) >> 16U)) |
Get the upper 16 bits of a 32-bit value. | |
#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_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 | _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) ((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. 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) ((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. 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_HALT | ( | ) |
Halt the processor in the debug state.
#define CY_ASSERT_HANDLER | ( | ) | CY_HALT() |
Default assert handler.
To override, define CY_CUSTOM_ASSERT_HANDLER and define own CY_ASSERT_HANDLER API
#define CY_ASSERT | ( | x | ) |
Utility macro when neither NDEBUG or CY_NO_ASSERT is not declared to check a condition and, if false, trigger a breakpoint.
Assert an argument is true, else call assert handler
#define CY_ASSERT_AND_RETURN | ( | condition, | |
value | |||
) |
Assert an argument is true, else call assert handler and return a value.
#define CY_ASSERT_AND_RETURN_VOID | ( | condition | ) |
Assert an argument is true, else call assert handler and return.
#define CY_SWAP_ENDIAN32 | ( | x | ) |
Swap the byte ordering of a 32-bit value.
#define CY_SWAP_ENDIAN64 | ( | x | ) |
Swap the byte ordering of a 64-bit value.
#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.
addr | The register address. |
#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.
addr | The register address. |
value | The value to write. |
#define CY_GET_REG16 | ( | addr | ) | (*((const volatile uint16_t *)(addr))) |
Reads the 16-bit value from the specified address.
addr | The register address. |
#define CY_SET_REG16 | ( | addr, | |
value | |||
) | (*((volatile uint16_t *)(addr)) = (uint16_t)(value)) |
Writes the 16-bit value to the specified address.
addr | The register address. |
value | The value to write. |
#define CY_GET_REG24 | ( | addr | ) |
Reads the 24-bit value from the specified address.
addr | The register address. |
#define CY_SET_REG24 | ( | addr, | |
value | |||
) |
Writes the 24-bit value to the specified address.
addr | The register address. |
value | The value to write. |
#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).
addr | The register address. |
#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).
addr | The register address. |
value | The value to write. |
#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.
#define _CLR_SET_FLD16U | ( | reg, | |
field, | |||
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.
#define _CLR_SET_FLD8U | ( | reg, | |
field, | |||
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.
#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.
#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.