mirror of https://github.com/ARMmbed/mbed-os.git
Update core_lib to 1.2.0.22384
parent
9b946a4f0d
commit
4ca2f281c0
545
targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/core_lib/include/cy_result.h
Normal file → Executable file
545
targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/core_lib/include/cy_result.h
Normal file → Executable file
|
@ -1,54 +1,70 @@
|
|||
/***************************************************************************//**
|
||||
* \file cy_result.h
|
||||
*
|
||||
* \brief
|
||||
* Basic function result handling. Defines a simple type for conveying
|
||||
* information about whether something succeeded or details about any issues
|
||||
* that were detected.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
* Copyright 2018-2020 Cypress Semiconductor Corporation
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
/***********************************************************************************************//**
|
||||
* \file cy_result.h
|
||||
*
|
||||
* \brief
|
||||
* Basic function result handling. Defines a simple type for conveying
|
||||
* information about whether something succeeded or details about any issues
|
||||
* that were detected.
|
||||
*
|
||||
***************************************************************************************************
|
||||
* \copyright
|
||||
* Copyright 2018-2021 Cypress Semiconductor Corporation
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**************************************************************************************************/
|
||||
|
||||
/**
|
||||
* \addtogroup group_result Result Type
|
||||
* \ingroup group_abstraction
|
||||
* \{
|
||||
* \anchor anchor_general_description
|
||||
* \brief Defines a type and related utilities for function result handling.
|
||||
*
|
||||
* The @ref cy_rslt_t type is a structured bitfield which encodes information
|
||||
* about result type, the originating module, and a code for the specific
|
||||
* error (or warning etc). In order to extract these individual fields from
|
||||
* a @ref cy_rslt_t value, the utility macros @ref CY_RSLT_GET_TYPE, @ref CY_RSLT_GET_MODULE,
|
||||
* and @ref CY_RSLT_GET_CODE are provided. For example:
|
||||
* \code
|
||||
* cy_rslt_t result = cy_hal_do_operation(arg);
|
||||
* // Will be CY_RSLT_TYPE_INFO, CY_RSLT_TYPE_WARNING, CY_RSLT_TYPE_ERROR, or CY_RSLT_TYPE_FATAL
|
||||
* uint8_t type = CY_RSLT_GET_TYPE(result)
|
||||
* // See the "Modules" section for possible values
|
||||
* uint16_t module_id = CY_RSLT_GET_MODULE(result);
|
||||
* // Specific error codes are defined by each module
|
||||
* uint16_t error_code = CY_RSLT_GET_CODE(result);
|
||||
* \endcode
|
||||
*/
|
||||
* \addtogroup group_result Result Type
|
||||
* \ingroup group_abstraction
|
||||
* \{
|
||||
* \anchor anchor_general_description
|
||||
* \brief Defines a type and related utilities for function result handling.
|
||||
*
|
||||
* The @ref cy_rslt_t type is a structured bitfield which encodes information about result type,
|
||||
* the originating module, and a code for the specific error (or warning etc). In order to extract
|
||||
* these individual fields from a @ref cy_rslt_t value, the utility macros @ref CY_RSLT_GET_TYPE,
|
||||
* @ref CY_RSLT_GET_MODULE, and @ref CY_RSLT_GET_CODE are provided. Alternatively, a newer
|
||||
* @ref cy_rslt_decode_t, union was created to help make the decoding process easier. The
|
||||
* @ref cy_rslt_decode_t also uses enums for the type and module to make decoding even easier.
|
||||
* Example uses of both approaches are shown below:
|
||||
*
|
||||
* Decoding @ref cy_rslt_t directly:
|
||||
* \code
|
||||
* cy_rslt_t result = cy_hal_do_operation(arg);
|
||||
*
|
||||
* // Will be CY_RSLT_TYPE_INFO, CY_RSLT_TYPE_WARNING, CY_RSLT_TYPE_ERROR, or CY_RSLT_TYPE_FATAL
|
||||
* uint8_t type = CY_RSLT_GET_TYPE(result)
|
||||
*
|
||||
* // See the "Modules" section for possible values
|
||||
* uint16_t module_id = CY_RSLT_GET_MODULE(result);
|
||||
*
|
||||
* // Specific error codes are defined by each module
|
||||
* uint16_t error_code = CY_RSLT_GET_CODE(result);
|
||||
*
|
||||
* printf("type=%d, module=%d, code=%d\n", type, module_id, error_code);
|
||||
* \endcode
|
||||
*
|
||||
* Using @ref cy_rslt_decode_t to decode:
|
||||
* \code
|
||||
* cy_rslt_decode_t result;
|
||||
* result.raw = cy_hal_do_operation(arg);
|
||||
*
|
||||
* printf("type=%d, module=%d, code=%d\n", result.type, result.module, result.code);
|
||||
* \endcode
|
||||
*/
|
||||
|
||||
#if !defined(CY_RESULT_H)
|
||||
#define CY_RESULT_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -56,17 +72,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Provides the result of an operation as a structured bitfield.
|
||||
*
|
||||
* See the \ref anchor_general_description "General Description"
|
||||
* for more details on structure and usage.
|
||||
*/
|
||||
typedef uint32_t cy_rslt_t;
|
||||
|
||||
/** @ref cy_rslt_t return value indicating success */
|
||||
#define CY_RSLT_SUCCESS ((cy_rslt_t)0x00000000U)
|
||||
|
||||
/** \cond INTERNAL */
|
||||
/** Mask for the bit at position "x" */
|
||||
#define CY_BIT_MASK(x) ((1UL << (x)) - 1U)
|
||||
|
@ -94,135 +99,331 @@ typedef uint32_t cy_rslt_t;
|
|||
/** \endcond */
|
||||
|
||||
/**
|
||||
* \{
|
||||
* @name Fields
|
||||
* Utility macros for constructing result values and extracting individual fields from existing results.
|
||||
*/
|
||||
* \{
|
||||
* @name Fields
|
||||
* Utility macros for constructing result values and extracting individual fields from existing
|
||||
* results.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Get the value of the result type field
|
||||
* @param x the @ref cy_rslt_t value from which to extract the result type
|
||||
*/
|
||||
* @brief Get the value of the result type field
|
||||
* @param x the @ref cy_rslt_t value from which to extract the result type
|
||||
*/
|
||||
#define CY_RSLT_GET_TYPE(x) (((x) >> CY_RSLT_TYPE_POSITION) & CY_RSLT_TYPE_MASK)
|
||||
/**
|
||||
* @brief Get the value of the module identifier field
|
||||
* @param x the @ref cy_rslt_t value from which to extract the module id
|
||||
*/
|
||||
* @brief Get the value of the module identifier field
|
||||
* @param x the @ref cy_rslt_t value from which to extract the module id
|
||||
*/
|
||||
#define CY_RSLT_GET_MODULE(x) (((x) >> CY_RSLT_MODULE_POSITION) & CY_RSLT_MODULE_MASK)
|
||||
/**
|
||||
* @brief Get the value of the result code field
|
||||
* @param x the @ref cy_rslt_t value from which to extract the result code
|
||||
*/
|
||||
* @brief Get the value of the result code field
|
||||
* @param x the @ref cy_rslt_t value from which to extract the result code
|
||||
*/
|
||||
#define CY_RSLT_GET_CODE(x) (((x) >> CY_RSLT_CODE_POSITION) & CY_RSLT_CODE_MASK)
|
||||
|
||||
/** \} fields */
|
||||
|
||||
/**
|
||||
* @brief Create a new @ref cy_rslt_t value that encodes the specified type, module, and result code.
|
||||
* @param type one of @ref CY_RSLT_TYPE_INFO, @ref CY_RSLT_TYPE_WARNING,
|
||||
* @ref CY_RSLT_TYPE_ERROR, @ref CY_RSLT_TYPE_FATAL
|
||||
* @param module Identifies the module where this result originated; see @ref anchor_modules "Modules".
|
||||
* @param code a module-defined identifier to identify the specific situation that
|
||||
* this result describes.
|
||||
*/
|
||||
* \{
|
||||
* @name Result Types
|
||||
* Defines codes to identify the type of result.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Defines codes to identify the type of result
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/** The result code is informational-only */
|
||||
CY_RSLT_TYPE_INFO = 0U,
|
||||
/** The result code is warning of a problem but will proceed */
|
||||
CY_RSLT_TYPE_WARNING = 1U,
|
||||
/** The result code is an error */
|
||||
CY_RSLT_TYPE_ERROR = 2U,
|
||||
/** The result code is a fatal error */
|
||||
CY_RSLT_TYPE_FATAL = 3U
|
||||
} cy_en_rslt_type_t;
|
||||
|
||||
/** \} severity */
|
||||
|
||||
|
||||
/**
|
||||
* \{
|
||||
* @name Modules
|
||||
* @anchor anchor_modules
|
||||
* Defines codes to identify the module from which an error originated.
|
||||
* For some large libraries, a range of module codes is defined here;
|
||||
* see the library documentation for values corresponding to individual modules.
|
||||
* Valid range is 0x0000-0x4000.
|
||||
*/
|
||||
|
||||
/** Base module identifier for peripheral driver library drivers (0x0000 - 0x007F) */
|
||||
#define CY_RSLT_MODULE_DRIVERS_PDL_BASE (0x0000U)
|
||||
/** \cond INTERNAL */
|
||||
/** Deprecated. Base module identifier for wireless host driver library modules (0x0080 - 0x00FF) */
|
||||
#define CY_RSLT_MODULE_DRIVERS_WHD_BASE (0x0080U)
|
||||
/** Deprecated. Use @ref CY_RSLT_MODULE_ABSTRACTION_HAL */
|
||||
#define CY_RSLT_MODULE_ABSTRACTION_HAL_BASE (0x0100U)
|
||||
/** Deprecated. Base module identifier for Board Libraries (0x01A0 - 0x01BF) */
|
||||
#define CY_RSLT_MODULE_BOARD_LIB_BASE (0x01A0U)
|
||||
/** Deprecated. Base module identifier for Shield Board Libraries (0x01B8 - 0x01BF) */
|
||||
#define CY_RSLT_MODULE_BOARD_SHIELD_BASE (0x01B8U)
|
||||
/** Deprecated. Base module identifier for Board Hardware Libraries (0x01C0 - 0x01FF) */
|
||||
#define CY_RSLT_MODULE_BOARD_HARDWARE_BASE (0x01C0U)
|
||||
/** Deprecated. Base module identifier for Middleware Libraries (0x0200 - 0x02FF) */
|
||||
#define CY_RSLT_MODULE_MIDDLEWARE_BASE (0x0200U)
|
||||
/** Deprecated. Base identifier for environment abstraction modules (0x0184 - 0x019F) */
|
||||
#define CY_RSLT_MODULE_ABSTRACTION_ENV (0x0184U)
|
||||
/** \endcond */
|
||||
|
||||
|
||||
/**
|
||||
* Define codes to identify the module from which an error originated.
|
||||
* @note This is provided as a debugging convenience tool, not as a definitive
|
||||
* list of all module IDs. Due to the distributed nature of ModusToolbox, each
|
||||
* library has its own release schedule. It is possible that some module IDs
|
||||
* may not appear in the enumeration yet. Missing items are expected to be
|
||||
* added over time.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/** Module identifier for the SAR driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_SAR = 0x0001,
|
||||
/** Module identifier for the Device Firmware Update (DFU) driver. Asset(s): (dfu) */
|
||||
CY_RSLT_MODULE_DRIVER_DFU = 0x0006,
|
||||
/** Module identifier for the Capsense driver. Asset(s): (capsense) */
|
||||
CY_RSLT_MODULE_DRIVER_CAPSENSE = 0x0007,
|
||||
/** Module identifier for the USB Device driver. Asset(s): (usbdev) */
|
||||
CY_RSLT_MODULE_DRIVER_USB_DEV = 0x0008,
|
||||
/** Module identifier for the Continuous Time Block (CTB) driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_CTB = 0x000b,
|
||||
/** Module identifier for the Crypto driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_CRYPTO = 0x000c,
|
||||
/** Module identifier for the SysPm driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_SYSPM = 0x0010,
|
||||
/** Module identifier for the SysLib driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_SYSLIB = 0x0011,
|
||||
/** Module identifier for the SysClk driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_SYSCLK = 0x0012,
|
||||
/** Module identifier for the DMA driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_DMA = 0x0013,
|
||||
/** Module identifier for the Flash driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_FLASH = 0x0014,
|
||||
/** Module identifier for the SysInt driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_SYSINT = 0x0015,
|
||||
/** Module identifier for the GPIO driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_GPIO = 0x0016,
|
||||
/** Module identifier for the Programmable Analog Sub System (PASS) driver. Asset(s):
|
||||
(mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_SYSANALOG = 0x0017,
|
||||
/** Module identifier for the Continuous Time DAC (CTDAC) driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_CTDAC = 0x0019,
|
||||
/** Module identifier for the eFuse driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_EFUSE = 0x001a,
|
||||
/** Module identifier for the Emulated EEPROM driver. Asset(s): (emeeprom) */
|
||||
CY_RSLT_MODULE_DRIVER_EM_EEPROM = 0x001b,
|
||||
/** Module identifier for the Profile driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_PROFILE = 0x001e,
|
||||
/** Module identifier for the I2S driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_I2S = 0x0020,
|
||||
/** Module identifier for the IPC driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_IPC = 0x0022,
|
||||
/** Module identifier for the Low Power Comparator (LPCOMP) driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_LPCOMP = 0x0023,
|
||||
/** Module identifier for the PDM-PCM driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_PDM_PCM = 0x0026,
|
||||
/** Module identifier for the RTC driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_RTC = 0x0028,
|
||||
/** Module identifier for the Serial Communications Block (SCB) driver.
|
||||
Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_SCB = 0x002a,
|
||||
/** Module identifier for the Serial Memory Interface (SMIF) driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_SMIF = 0x002c,
|
||||
/** Module identifier for the Timer/Counter/PWM (TCPWM) driver.
|
||||
Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_TCPWM = 0x002d,
|
||||
/** Module identifier for the Protection driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_PROT = 0x0030,
|
||||
/** Module identifier for the TRIGMUX driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_TRIGMUX = 0x0033,
|
||||
/** Module identifier for the WDT driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_WDT = 0x0034,
|
||||
/** Module identifier for the (WDC / MCWDT) driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_MCWDT = 0x0035,
|
||||
/** Module identifier for the LVD driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_LVD = 0x0039,
|
||||
/** Module identifier for the SD_HOST driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_SD_HOST = 0x003a,
|
||||
/** Module identifier for the USBFS driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_USBFS = 0x003b,
|
||||
/** Module identifier for the DMAC driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_DMAC = 0x003f,
|
||||
/** Module identifier for the SegLCD driver. Asset(s): (mtb-pdl-cat1) */
|
||||
CY_RSLT_MODULE_DRIVER_SEGLCD = 0x0040,
|
||||
/** Module identifier for the CSD driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_CSD = 0x0041,
|
||||
/** Module identifier for the SmartIO driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_SMARTIO = 0x0042,
|
||||
/** Module identifier for the CSDIDAC driver. Asset(s): (csdidac) */
|
||||
CY_RSLT_MODULE_DRIVER_CSDIDAC = 0x0044,
|
||||
/** Module identifier for the CAN FD driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_CANFD = 0x0045,
|
||||
/** Module identifier for the MSC driver. Asset(s): (mtb-pdl-cat2) */
|
||||
CY_RSLT_MODULE_DRIVER_MSC = 0x0047,
|
||||
/** Module identifier for the WiFi Host Driver. Asset(s): (wifi-host-driver) */
|
||||
CY_RSLT_MODULE_DRIVER_WHD = 0x0080,
|
||||
|
||||
/** Module identifier for the Hardware Abstraction Layer.
|
||||
Asset(s): (mtb-hal-cat1, mtb-hal-cat2, ...) */
|
||||
CY_RSLT_MODULE_ABSTRACTION_HAL = 0x0100,
|
||||
/** Module identifier for board support package. Asset(s): (BSPs) */
|
||||
CY_RSLT_MODULE_ABSTRACTION_BSP = 0x0180,
|
||||
/** Module identifier for file system abstraction */
|
||||
CY_RSLT_MODULE_ABSTRACTION_FS = 0x0181,
|
||||
/** Module identifier for resource abstraction. Asset(s): (abstraction-resource) */
|
||||
CY_RSLT_MODULE_ABSTRACTION_RESOURCE = 0x0182,
|
||||
/** Module identifier for RTOS abstraction. Asset(s): (abstraction-rtos) */
|
||||
CY_RSLT_MODULE_ABSTRACTION_OS = 0x0183,
|
||||
|
||||
/** Module identifier for the Retarget IO Board Library. Asset(s): (retarget-io) */
|
||||
CY_RSLT_MODULE_BOARD_LIB_RETARGET_IO = 0x1A0,
|
||||
/** Module identifier for the RGB LED Board Library. Asset(s): (rgb-led) */
|
||||
CY_RSLT_MODULE_BOARD_LIB_RGB_LED = 0x01A1,
|
||||
/** Module identifier for the Serial Flash Board Library. Asset(s): (serial-flash) */
|
||||
CY_RSLT_MODULE_BOARD_LIB_SERIAL_FLASH = 0x01A2,
|
||||
/** Module identifier for the WiFi Host Driver + Board Support Integration Library.
|
||||
Asset(s): (whd-bsp-integration) */
|
||||
CY_RSLT_MODULE_BOARD_LIB_WHD_INTEGRATION = 0x01A3,
|
||||
|
||||
/** Module identifier for Shield Board CY8CKIT-028-EPD. Asset(s): (CY8CKIT-028-EPD) */
|
||||
CY_RSLT_MODULE_BOARD_SHIELD_028_EPD = 0x01B8,
|
||||
/** Module identifier for Shield Board CY8CKIT-028-TFT. Asset(s): (CY8CKIT-028-TFT) */
|
||||
CY_RSLT_MODULE_BOARD_SHIELD_028_TFT = 0x01B9,
|
||||
/** Module identifier for Shield Board CY8CKIT-032. Asset(s): (CY8CKIT-032) */
|
||||
CY_RSLT_MODULE_BOARD_SHIELD_032 = 0x01BA,
|
||||
/** Module identifier for Shield Board CY8CKIT-028-SENSE. Asset(s): (CY8CKIT-028-SENSE) */
|
||||
CY_RSLT_MODULE_BOARD_SHIELD_028_SENSE = 0x01BB,
|
||||
|
||||
/** Module identifier for the BMI160 Motion Sensor Library. Asset(s): (sensor-motion-bmi160) */
|
||||
CY_RSLT_MODULE_BOARD_HARDWARE_BMI160 = 0x01C0,
|
||||
/** Module identifier for the E2271CS021 E-Ink Controller Library.
|
||||
Asset(s): (display-eink-e2271cs021) */
|
||||
CY_RSLT_MODULE_BOARD_HARDWARE_E2271CS021 = 0x01C1,
|
||||
/** Module identifier for the NTC GPIO Thermistor Library. Asset(s): (thermistor) */
|
||||
CY_RSLT_MODULE_BOARD_HARDWARE_THERMISTOR = 0x01C2,
|
||||
/** Module identifier for the SSD1306 OLED Controller Library.
|
||||
Asset(s): (display-oled-ssd1306) */
|
||||
CY_RSLT_MODULE_BOARD_HARDWARE_SSD1306 = 0x01C3,
|
||||
/** Module identifier for the ST7789V TFT Controller Library. Asset(s): (display-tft-st7789v) */
|
||||
CY_RSLT_MODULE_BOARD_HARDWARE_ST7789V = 0x01C4,
|
||||
/** Module identifier for the Light Sensor Library. Asset(s): (sensor-light) */
|
||||
CY_RSLT_MODULE_BOARD_HARDWARE_LIGHT_SENSOR = 0x01C5,
|
||||
/** Module identifier for the AK4954A Audio Codec Library. Asset(s): (audio-codec-ak4954a) */
|
||||
CY_RSLT_MODULE_BOARD_HARDWARE_AK4954A = 0x01C6,
|
||||
/** Module identifier for the BMI160 Motion Sensor Library.
|
||||
Asset(s): (sensor-orientation-bmx160) */
|
||||
CY_RSLT_MODULE_BOARD_HARDWARE_BMX160 = 0x01C7,
|
||||
/** Module identifier for the XENSIV DPS3XX Pressure Sensor Library */
|
||||
CY_RSLT_MODULE_BOARD_HARDWARE_DPS3XX = 0x01C8,
|
||||
/** Module identifier for the WM8960 Audio Codec Library */
|
||||
CY_RSLT_MODULE_BOARD_HARDWARE_WM8960 = 0x01C9,
|
||||
|
||||
/** Module identifier for the MDNS library. Asset(s): (mdns) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_MNDS = 0x200,
|
||||
/** Module identifier for the ASW IoT library. Asset(s): (aws-iot) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_AWS = 0x201,
|
||||
/** Module identifier for the JSON parser library. Asset(s): (connectivity-utilities) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_JSON = 0x202,
|
||||
/** Module identifier for the Linked List library. Asset(s): (connectivity-utilities) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_LINKED_LIST = 0x203,
|
||||
/** Module identifier for the Command Console library. Asset(s): (command-console) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_COMMAND_CONSOLE = 0x204,
|
||||
/** Module identifier for the HTTP Server library. Asset(s): (http-server) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_HTTP_SERVER = 0x205,
|
||||
/** Module identifier for the Enterprise Security library. Asset(s): (enterprise-security) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_ENTERPRISE_SECURITY = 0x206,
|
||||
/** Module identifier for the TCP/IP library. Asset(s): (connectivity-utilities) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_TCPIP = 0x207,
|
||||
/** Module identifier for the Generic middleware library.
|
||||
Asset(s): (connectivity-utilities, wifi-mw-core) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_MW = 0x208,
|
||||
/** Module identifier for the TLS library. Asset(s): (cy-mbedtls) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_TLS = 0x209,
|
||||
/** Module identifier for the Secure Sockets library. Asset(s): (secure-sockets) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_SECURE_SOCKETS = 0x20a,
|
||||
/** Module identifier for the WiFi Connection Manager library (WCM).
|
||||
Asset(s): (wifi-connection-manager) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_WCM = 0x20b,
|
||||
/** Module identifier for the lwIP WHD port library. Asset(s): (wifi-mw-core) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_LWIP_WHD_PORT = 0x20c,
|
||||
/** Module identifier for the OTA Update library. Asset(s): (anycloud-ota) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_OTA_UPDATE = 0x20d,
|
||||
/** Module identifier for the HTTP Clinet library. Asset(s): (http-client) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_HTTP_CLIENT = 0x20e,
|
||||
|
||||
/** Module identifier for the KV Store Middleware Library. Asset(s): (kv-store) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_KVSTORE = 0x250,
|
||||
/** Module identifier for the LIN Middleware Library. Asset(s): (lin) */
|
||||
CY_RSLT_MODULE_MIDDLEWARE_LIN = 0x0251
|
||||
} cy_en_rslt_module_t;
|
||||
|
||||
/** \} modules */
|
||||
|
||||
/**
|
||||
* @brief Provides the result of an operation as a structured bitfield.
|
||||
*
|
||||
* @note A newer version @ref cy_rslt_decode_t is also available for improved
|
||||
* debugging experience.
|
||||
*
|
||||
* See the \ref anchor_general_description "General Description"
|
||||
* for more details on structure and usage.
|
||||
*/
|
||||
typedef uint32_t cy_rslt_t;
|
||||
|
||||
/**
|
||||
* @brief Provides the result of an operation as a structured bitfield.
|
||||
*
|
||||
* This is an updated version of @ref cy_rslt_t that pulls the individual
|
||||
* fields out into their own members for easier readability. The organization
|
||||
* and meaning of items is exactly the same. The new version can be used as follows:
|
||||
* cy_rslt_decode_t result;
|
||||
* result.raw = my_function_that_returns_cy_rslt_t();
|
||||
*
|
||||
* See the @ref anchor_general_description "General Description"
|
||||
* for more details on structure and usage.
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
cy_rslt_t raw; //!< The raw uint32/cy_rslt_t value
|
||||
/** Anonymous struct breaking out each of the fields of the result type */
|
||||
struct
|
||||
{
|
||||
uint16_t code : CY_RSLT_CODE_WIDTH; //!< The 16bit result code
|
||||
cy_en_rslt_type_t type : CY_RSLT_TYPE_WIDTH; //!< The 2bit result type
|
||||
cy_en_rslt_module_t module : CY_RSLT_MODULE_WIDTH; //!< The 14bit module id
|
||||
};
|
||||
} cy_rslt_decode_t;
|
||||
|
||||
/** @ref cy_rslt_t return value indicating success */
|
||||
#define CY_RSLT_SUCCESS ((cy_rslt_t)0x00000000U)
|
||||
|
||||
/**
|
||||
* @brief Create a new @ref cy_rslt_t value that encodes the specified type, module, and result
|
||||
* code.
|
||||
* @param type one of @ref CY_RSLT_TYPE_INFO, @ref CY_RSLT_TYPE_WARNING,
|
||||
* @ref CY_RSLT_TYPE_ERROR, @ref CY_RSLT_TYPE_FATAL
|
||||
* @param module Identifies the module where this result originated; see @ref anchor_modules
|
||||
* "Modules".
|
||||
* @param code a module-defined identifier to identify the specific situation that
|
||||
* this result describes.
|
||||
*/
|
||||
#define CY_RSLT_CREATE(type, module, code) \
|
||||
((((module) & CY_RSLT_MODULE_MASK) << CY_RSLT_MODULE_POSITION) | \
|
||||
(((code) & CY_RSLT_CODE_MASK) << CY_RSLT_CODE_POSITION) | \
|
||||
(((type) & CY_RSLT_TYPE_MASK) << CY_RSLT_TYPE_POSITION))
|
||||
|
||||
/** \} fields */
|
||||
|
||||
/**
|
||||
* \{
|
||||
* @name Result Types
|
||||
* Defines codes to identify the type of result.
|
||||
*/
|
||||
|
||||
/** @brief The result code is informational-only */
|
||||
#define CY_RSLT_TYPE_INFO (0U)
|
||||
/** @brief The result code is warning of a problem but will proceed */
|
||||
#define CY_RSLT_TYPE_WARNING (1U)
|
||||
/** @brief The result code is an error */
|
||||
#define CY_RSLT_TYPE_ERROR (2U)
|
||||
/** @brief The result code is a fatal error */
|
||||
#define CY_RSLT_TYPE_FATAL (3U)
|
||||
|
||||
/** \} severity */
|
||||
|
||||
/**
|
||||
* \{
|
||||
* @name Modules
|
||||
* @anchor anchor_modules
|
||||
* Defines codes to identify the module from which an error originated.
|
||||
* For some large libraries, a range of module codes is defined here;
|
||||
* see the library documentation for values corresponding to individual modules.
|
||||
* Valid range is 0x0000-0x4000.
|
||||
*/
|
||||
/**** DRIVER Module codes: 0x0000 - 0x00FF ****/
|
||||
/** Base module identifier for peripheral driver library drivers (0x0000 - 0x007F) */
|
||||
#define CY_RSLT_MODULE_DRIVERS_PDL_BASE (0x0000U)
|
||||
/** Base module identifier for wireless host driver library modules (0x0080 - 0x00FF) */
|
||||
#define CY_RSLT_MODULE_DRIVERS_WHD_BASE (0x0080U)
|
||||
|
||||
/** Deprecated. Use \ref CY_RSLT_MODULE_ABSTRACTION_HAL */
|
||||
#define CY_RSLT_MODULE_ABSTRACTION_HAL_BASE (0x0100U)
|
||||
/** Module identifier for the Hardware Abstraction Layer */
|
||||
#define CY_RSLT_MODULE_ABSTRACTION_HAL (0x0100U)
|
||||
/** Module identifier for board support package */
|
||||
#define CY_RSLT_MODULE_ABSTRACTION_BSP (0x0180U)
|
||||
/** Module identifier for file system abstraction */
|
||||
#define CY_RSLT_MODULE_ABSTRACTION_FS (0x0181U)
|
||||
/** Module identifier for resource abstraction */
|
||||
#define CY_RSLT_MODULE_ABSTRACTION_RESOURCE (0x0182U)
|
||||
/** Module identifier for rtos abstraction */
|
||||
#define CY_RSLT_MODULE_ABSTRACTION_OS (0x0183U)
|
||||
/** Base identifier for environment abstraction modules (0x0184 - 0x01FF) */
|
||||
#define CY_RSLT_MODULE_ABSTRACTION_ENV (0x0184U)
|
||||
|
||||
/** Base module identifier for Board Libraries (0x01A0 - 0x01BF) */
|
||||
#define CY_RSLT_MODULE_BOARD_LIB_BASE (0x01A0U)
|
||||
/** Module identifier for the Retarget IO Board Library */
|
||||
#define CY_RSLT_MODULE_BOARD_LIB_RETARGET_IO (0x1A0U)
|
||||
/** Module identifier for the RGB LED Board Library */
|
||||
#define CY_RSLT_MODULE_BOARD_LIB_RGB_LED (0x01A1U)
|
||||
/** Module identifier for the Serial Flash Board Library */
|
||||
#define CY_RSLT_MODULE_BOARD_LIB_SERIAL_FLASH (0x01A2U)
|
||||
/** Module identifier for the WiFi Host Driver + Board Support Integration Library */
|
||||
#define CY_RSLT_MODULE_BOARD_LIB_WHD_INTEGRATION (0x01A3U)
|
||||
|
||||
/** Base module identifier for Shield Board Libraries (0x01B8 - 0x01BF) */
|
||||
#define CY_RSLT_MODULE_BOARD_SHIELD_BASE (0x01B8U)
|
||||
/** Module identifier for Shield Board CY8CKIT-028-EPD */
|
||||
#define CY_RSLT_MODULE_BOARD_SHIELD_028_EPD (0x01B8U)
|
||||
/** Module identifier for Shield Board CY8CKIT-028-TFT */
|
||||
#define CY_RSLT_MODULE_BOARD_SHIELD_028_TFT (0x01B9U)
|
||||
/** Module identifier for Shield Board CY8CKIT-032 */
|
||||
#define CY_RSLT_MODULE_BOARD_SHIELD_032 (0x01BAU)
|
||||
|
||||
/** Base module identifier for Board Hardware Libraries (0x01C0 - 0x01FF) */
|
||||
#define CY_RSLT_MODULE_BOARD_HARDWARE_BASE (0x01C0U)
|
||||
/** Module identifier for the BMI160 Motion Sensor Library */
|
||||
#define CY_RSLT_MODULE_BOARD_HARDWARE_BMI160 (0x01C0U)
|
||||
/** Module identifier for the E2271CS021 E-Ink Controller Library */
|
||||
#define CY_RSLT_MODULE_BOARD_HARDWARE_E2271CS021 (0x01C1U)
|
||||
/** Module identifier for the NTC GPIO Thermistor Library */
|
||||
#define CY_RSLT_MODULE_BOARD_HARDWARE_THERMISTOR (0x01C2U)
|
||||
/** Module identifier for the SSD1306 OLED Controller Library */
|
||||
#define CY_RSLT_MODULE_BOARD_HARDWARE_SSD1306 (0x01C3U)
|
||||
/** Module identifier for the ST7789V TFT Controller Library */
|
||||
#define CY_RSLT_MODULE_BOARD_HARDWARE_ST7789V (0x01C4U)
|
||||
/** Module identifier for the Light Sensor Library */
|
||||
#define CY_RSLT_MODULE_BOARD_HARDWARE_LIGHT_SENSOR (0x01C5U)
|
||||
/** Module identifier for the AK4954A Audio Codec Library */
|
||||
#define CY_RSLT_MODULE_BOARD_HARDWARE_AK4954A (0x01C6U)
|
||||
|
||||
/** Base module identifier for Middleware Libraries (0x0200 - 0x02FF) */
|
||||
#define CY_RSLT_MODULE_MIDDLEWARE_BASE (0x0200U)
|
||||
|
||||
/** \} modules */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CY_RESULT_H */
|
||||
|
||||
/** \} group_result */
|
||||
|
|
502
targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/core_lib/include/cy_utils.h
Normal file → Executable file
502
targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/core_lib/include/cy_utils.h
Normal file → Executable file
|
@ -1,36 +1,35 @@
|
|||
/***************************************************************************//**
|
||||
* \file cy_utils.h
|
||||
*
|
||||
* \brief
|
||||
* Basic utility macros and functions.
|
||||
*
|
||||
********************************************************************************
|
||||
* \copyright
|
||||
* Copyright 2018-2020 Cypress Semiconductor Corporation
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
/***********************************************************************************************//**
|
||||
* \file cy_utils.h
|
||||
*
|
||||
* \brief
|
||||
* Basic utility macros and functions.
|
||||
*
|
||||
***************************************************************************************************
|
||||
* \copyright
|
||||
* Copyright 2018-2021 Cypress Semiconductor Corporation
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**************************************************************************************************/
|
||||
|
||||
/**
|
||||
* \addtogroup group_utils Utilities
|
||||
* \ingroup group_abstraction
|
||||
* \{
|
||||
* Basic utility macros and functions.
|
||||
*/
|
||||
* \addtogroup group_utils Utilities
|
||||
* \ingroup group_abstraction
|
||||
* \{
|
||||
* Basic utility macros and functions.
|
||||
*/
|
||||
|
||||
#if !defined(CY_UTILS_H)
|
||||
#define CY_UTILS_H
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
@ -49,11 +48,13 @@ static inline void CY_HALT(void)
|
|||
__asm(" bkpt 1");
|
||||
}
|
||||
|
||||
|
||||
#ifdef CY_ASSERT
|
||||
#undef CY_ASSERT
|
||||
#endif /* ifdef(CY_ASSERT) */
|
||||
#endif // ifdef(CY_ASSERT)
|
||||
|
||||
/** Utility macro when neither NDEBUG or CY_NO_ASSERT is not declared to check a condition and, if false, trigger a breakpoint */
|
||||
/** Utility macro when neither NDEBUG or CY_NO_ASSERT is not declared to check a condition and, if
|
||||
false, trigger a breakpoint */
|
||||
#if defined(NDEBUG) || defined(CY_NO_ASSERT)
|
||||
#define CY_ASSERT(x) do { \
|
||||
} while(false)
|
||||
|
@ -64,7 +65,7 @@ static inline void CY_HALT(void)
|
|||
CY_HALT(); \
|
||||
} \
|
||||
} while(false)
|
||||
#endif /* defined(NDEBUG) */
|
||||
#endif // defined(NDEBUG)
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -85,8 +86,9 @@ static inline void CY_HALT(void)
|
|||
#define CY_SWAP_ENDIAN16(x) ((uint16_t)(((x) << 8U) | (((x) >> 8U) & 0x00FFU)))
|
||||
|
||||
/** Swap the byte ordering of a 32-bit value */
|
||||
#define CY_SWAP_ENDIAN32(x) ((uint32_t)((((x) >> 24U) & 0x000000FFU) | (((x) & 0x00FF0000U) >> 8U) | \
|
||||
(((x) & 0x0000FF00U) << 8U) | ((x) << 24U)))
|
||||
#define CY_SWAP_ENDIAN32(x) \
|
||||
((uint32_t)((((x) >> 24U) & 0x000000FFU) | (((x) & 0x00FF0000U) >> 8U) | \
|
||||
(((x) & 0x0000FF00U) << 8U) | ((x) << 24U)))
|
||||
|
||||
/** Swap the byte ordering of a 64-bit value */
|
||||
#define CY_SWAP_ENDIAN64(x) ((uint64_t) (((uint64_t) CY_SWAP_ENDIAN32((uint32_t)(x)) << 32U) | \
|
||||
|
@ -97,19 +99,19 @@ static inline void CY_HALT(void)
|
|||
* Memory model definitions
|
||||
*******************************************************************************/
|
||||
#if defined(__ARMCC_VERSION)
|
||||
/** To create cross compiler compatible code, use the CY_NOINIT, CY_SECTION, CY_UNUSED, CY_ALIGN
|
||||
* attributes at the first place of declaration/definition.
|
||||
* For example: CY_NOINIT uint32_t noinitVar;
|
||||
*/
|
||||
/** To create cross compiler compatible code, use the CY_NOINIT, CY_SECTION, CY_UNUSED, CY_ALIGN
|
||||
* attributes at the first place of declaration/definition.
|
||||
* For example: CY_NOINIT uint32_t noinitVar;
|
||||
*/
|
||||
#if (__ARMCC_VERSION >= 6010050)
|
||||
#define CY_NOINIT __attribute__ ((section(".noinit")))
|
||||
#else
|
||||
#define CY_NOINIT __attribute__ ((section(".noinit"), zero_init))
|
||||
#endif /* (__ARMCC_VERSION >= 6010050) */
|
||||
#endif // (__ARMCC_VERSION >= 6010050)
|
||||
#define CY_SECTION(name) __attribute__ ((section(name)))
|
||||
#define CY_UNUSED __attribute__ ((unused))
|
||||
#define CY_NOINLINE __attribute__ ((noinline))
|
||||
/* Specifies the minimum alignment (in bytes) for variables of the specified type. */
|
||||
// Specifies the minimum alignment (in bytes) for variables of the specified type.
|
||||
#define CY_ALIGN(align) __ALIGNED(align)
|
||||
#define CY_RAMFUNC_BEGIN __attribute__ ((section(".cy_ramfunc")))
|
||||
#define CY_RAMFUNC_END
|
||||
|
@ -141,251 +143,253 @@ static inline void CY_HALT(void)
|
|||
#define CY_ALIGN(align) CY_PRAGMA(data_alignment = align)
|
||||
#else
|
||||
#define CY_ALIGN(align) __ALIGNED(align)
|
||||
#endif /* (__VER__ < 8010001) */
|
||||
#else
|
||||
#endif // (__VER__ < 8010001)
|
||||
#else // if defined(__ARMCC_VERSION)
|
||||
#error "An unsupported toolchain"
|
||||
#endif /* (__ARMCC_VERSION) */
|
||||
#endif // (__ARMCC_VERSION)
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: CY_GET_REG8(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.
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \return The read value.
|
||||
*
|
||||
*******************************************************************************/
|
||||
/***************************************************************************************************
|
||||
* Macro Name: CY_GET_REG8(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.
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \return The read value.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
#define CY_GET_REG8(addr) (*((const volatile uint8_t *)(addr)))
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: CY_SET_REG8(addr, 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.
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \param value The value to write.
|
||||
*
|
||||
*******************************************************************************/
|
||||
/***************************************************************************************************
|
||||
* Macro Name: CY_SET_REG8(addr, 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.
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \param value The value to write.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
#define CY_SET_REG8(addr, value) (*((volatile uint8_t *)(addr)) = (uint8_t)(value))
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: CY_GET_REG16(addr)
|
||||
****************************************************************************//**
|
||||
*
|
||||
* Reads the 16-bit value from the specified address.
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \return The read value.
|
||||
*
|
||||
*******************************************************************************/
|
||||
/***************************************************************************************************
|
||||
* Macro Name: CY_GET_REG16(addr)
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* Reads the 16-bit value from the specified address.
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \return The read value.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
#define CY_GET_REG16(addr) (*((const volatile uint16_t *)(addr)))
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: CY_SET_REG16(addr, value)
|
||||
****************************************************************************//**
|
||||
*
|
||||
* Writes the 16-bit value to the specified address.
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \param value The value to write.
|
||||
*
|
||||
*******************************************************************************/
|
||||
/***************************************************************************************************
|
||||
* Macro Name: CY_SET_REG16(addr, value)
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* Writes the 16-bit value to the specified address.
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \param value The value to write.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
#define CY_SET_REG16(addr, value) (*((volatile uint16_t *)(addr)) = (uint16_t)(value))
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: CY_GET_REG24(addr)
|
||||
****************************************************************************//**
|
||||
*
|
||||
* Reads the 24-bit value from the specified address.
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \return The read value.
|
||||
*
|
||||
*******************************************************************************/
|
||||
#define CY_GET_REG24(addr) (((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))
|
||||
/***************************************************************************************************
|
||||
* Macro Name: CY_GET_REG24(addr)
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* Reads the 24-bit value from the specified address.
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \return The read value.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
#define CY_GET_REG24(addr) (((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))
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: CY_SET_REG24(addr, value)
|
||||
****************************************************************************//**
|
||||
*
|
||||
* Writes the 24-bit value to the specified address.
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \param value The value to write.
|
||||
*
|
||||
*******************************************************************************/
|
||||
#define CY_SET_REG24(addr, 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)
|
||||
/***************************************************************************************************
|
||||
* Macro Name: CY_SET_REG24(addr, value)
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* Writes the 24-bit value to the specified address.
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \param value The value to write.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
#define CY_SET_REG24(addr, 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)
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: CY_GET_REG32(addr)
|
||||
****************************************************************************//**
|
||||
*
|
||||
* Reads the 32-bit value from the specified register. The address is the little
|
||||
* endian order (LSB in lowest address).
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \return The read value.
|
||||
*
|
||||
*******************************************************************************/
|
||||
/***************************************************************************************************
|
||||
* Macro Name: CY_GET_REG32(addr)
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* Reads the 32-bit value from the specified register. The address is the little
|
||||
* endian order (LSB in lowest address).
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \return The read value.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
#define CY_GET_REG32(addr) (*((const volatile uint32_t *)(addr)))
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: CY_SET_REG32(addr, value)
|
||||
****************************************************************************//**
|
||||
*
|
||||
* Writes the 32-bit value to the specified register. The address is the little
|
||||
* endian order (LSB in lowest address).
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \param value The value to write.
|
||||
*
|
||||
*******************************************************************************/
|
||||
/***************************************************************************************************
|
||||
* Macro Name: CY_SET_REG32(addr, value)
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* Writes the 32-bit value to the specified register. The address is the little
|
||||
* endian order (LSB in lowest address).
|
||||
*
|
||||
* \param addr The register address.
|
||||
*
|
||||
* \param value The value to write.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
#define CY_SET_REG32(addr, value) (*((volatile uint32_t *)(addr)) = (uint32_t)(value))
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: _CLR_SET_FLD32U
|
||||
****************************************************************************//**
|
||||
*
|
||||
* 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_FLD32U(reg, field, value) (((reg) & ((uint32_t)(~(field ## _Msk)))) | (_VAL2FLD(field, value)))
|
||||
/***************************************************************************************************
|
||||
* Macro Name: _CLR_SET_FLD32U
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* 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_FLD32U(reg, field, value) \
|
||||
(((reg) & ((uint32_t)(~(field ## _Msk)))) | (_VAL2FLD(field, value)))
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: CY_REG32_CLR_SET
|
||||
****************************************************************************//**
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*******************************************************************************/
|
||||
/***************************************************************************************************
|
||||
* Macro Name: CY_REG32_CLR_SET
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* 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 CY_REG32_CLR_SET(reg, field, value) ((reg) = _CLR_SET_FLD32U((reg), field, (value)))
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: _CLR_SET_FLD16U
|
||||
****************************************************************************//**
|
||||
*
|
||||
* 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_FLD16U(reg, field, value) ((uint16_t)(((reg) & ((uint16_t)(~(field ## _Msk)))) | \
|
||||
((uint16_t)_VAL2FLD(field, value))))
|
||||
/***************************************************************************************************
|
||||
* Macro Name: _CLR_SET_FLD16U
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* 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_FLD16U(reg, field, value) \
|
||||
((uint16_t)(((reg) & ((uint16_t)(~(field ## _Msk)))) | ((uint16_t)_VAL2FLD(field, value))))
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: CY_REG16_CLR_SET
|
||||
****************************************************************************//**
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*******************************************************************************/
|
||||
/***************************************************************************************************
|
||||
* Macro Name: CY_REG16_CLR_SET
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* 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 CY_REG16_CLR_SET(reg, field, value) ((reg) = _CLR_SET_FLD16U((reg), field, (value)))
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: _CLR_SET_FLD8U
|
||||
****************************************************************************//**
|
||||
*
|
||||
* 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 _CLR_SET_FLD8U(reg, field, value) ((uint8_t)(((reg) & ((uint8_t)(~(field ## _Msk)))) | \
|
||||
((uint8_t)_VAL2FLD(field, value))))
|
||||
/***************************************************************************************************
|
||||
* Macro Name: _CLR_SET_FLD8U
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* 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 _CLR_SET_FLD8U(reg, field, value) \
|
||||
((uint8_t)(((reg) & ((uint8_t)(~(field ## _Msk)))) | ((uint8_t)_VAL2FLD(field, value))))
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: CY_REG8_CLR_SET
|
||||
****************************************************************************//**
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*******************************************************************************/
|
||||
/***************************************************************************************************
|
||||
* Macro Name: CY_REG8_CLR_SET
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* 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 CY_REG8_CLR_SET(reg, field, value) ((reg) = _CLR_SET_FLD8U((reg), field, (value)))
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: _BOOL2FLD
|
||||
****************************************************************************//**
|
||||
*
|
||||
* Returns a field mask if the value is not false.
|
||||
* Returns 0, if the value is false.
|
||||
*
|
||||
*******************************************************************************/
|
||||
/***************************************************************************************************
|
||||
* Macro Name: _BOOL2FLD
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* Returns a field mask if the value is not false.
|
||||
* Returns 0, if the value is false.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
#define _BOOL2FLD(field, value) (((value) != false) ? (field ## _Msk) : 0UL)
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: _FLD2BOOL
|
||||
****************************************************************************//**
|
||||
*
|
||||
* Returns true, if the value includes the field mask.
|
||||
* Returns false, if the value doesn't include the field mask.
|
||||
*
|
||||
*******************************************************************************/
|
||||
/***************************************************************************************************
|
||||
* Macro Name: _FLD2BOOL
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* Returns true, if the value includes the field mask.
|
||||
* Returns false, if the value doesn't include the field mask.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
#define _FLD2BOOL(field, value) (((value) & (field ## _Msk)) != 0UL)
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: CY_SYSLIB_DIV_ROUND
|
||||
****************************************************************************//**
|
||||
*
|
||||
* Calculates a / b with rounding to the nearest integer,
|
||||
* a and b must have the same sign.
|
||||
*
|
||||
*******************************************************************************/
|
||||
/***************************************************************************************************
|
||||
* Macro Name: CY_SYSLIB_DIV_ROUND
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* Calculates a / b with rounding to the nearest integer,
|
||||
* a and b must have the same sign.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
#define CY_SYSLIB_DIV_ROUND(a, b) (((a) + ((b) / 2U)) / (b))
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Macro Name: CY_SYSLIB_DIV_ROUNDUP
|
||||
****************************************************************************//**
|
||||
*
|
||||
* Calculates a / b with rounding up if remainder != 0,
|
||||
* both a and b must be positive.
|
||||
*
|
||||
*******************************************************************************/
|
||||
/***************************************************************************************************
|
||||
* Macro Name: CY_SYSLIB_DIV_ROUNDUP
|
||||
***********************************************************************************************//**
|
||||
*
|
||||
* Calculates a / b with rounding up if remainder != 0,
|
||||
* both a and b must be positive.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
#define CY_SYSLIB_DIV_ROUNDUP(a, b) ((((a) - 1U) / (b)) + 1U)
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -394,33 +398,33 @@ static inline void CY_HALT(void)
|
|||
|
||||
/** \cond INTERNAL */
|
||||
|
||||
#ifdef CY_COVERITY_2012_CHECK /* Check MISRA-C:2012 with Coverity tool */
|
||||
#ifdef CY_COVERITY_2012_CHECK // Check MISRA-C:2012 with Coverity tool
|
||||
#define CY_COVERITY_PRAGMA_STR(a) #a
|
||||
|
||||
#define CY_MISRA_DEVIATE_LINE(MISRA,MESSAGE) \
|
||||
#define CY_MISRA_DEVIATE_LINE(MISRA, MESSAGE) \
|
||||
_Pragma(CY_COVERITY_PRAGMA_STR(coverity compliance deviate MISRA MESSAGE))
|
||||
|
||||
#define CY_MISRA_FP_LINE(MISRA,MESSAGE) \
|
||||
#define CY_MISRA_FP_LINE(MISRA, MESSAGE) \
|
||||
_Pragma(CY_COVERITY_PRAGMA_STR(coverity compliance fp MISRA MESSAGE))
|
||||
|
||||
#define CY_MISRA_DEVIATE_BLOCK_START(MISRA,COUNT,MESSAGE) \
|
||||
#define CY_MISRA_DEVIATE_BLOCK_START(MISRA, COUNT, MESSAGE) \
|
||||
_Pragma(CY_COVERITY_PRAGMA_STR(coverity compliance block (deviate:COUNT MISRA MESSAGE)))
|
||||
|
||||
#define CY_MISRA_FP_BLOCK_START(MISRA,COUNT,MESSAGE) \
|
||||
#define CY_MISRA_FP_BLOCK_START(MISRA, COUNT, MESSAGE) \
|
||||
_Pragma(CY_COVERITY_PRAGMA_STR(coverity compliance block (fp:COUNT MISRA MESSAGE)))
|
||||
|
||||
#define CY_MISRA_BLOCK_END(MISRA) \
|
||||
_Pragma(CY_COVERITY_PRAGMA_STR(coverity compliance end_block MISRA))
|
||||
|
||||
#else /* General usage */
|
||||
#else // General usage
|
||||
|
||||
#define CY_MISRA_DEVIATE_LINE(MISRA,MESSAGE) do{}while(false)
|
||||
#define CY_MISRA_FP_LINE(MISRA,MESSAGE) do{}while(false)
|
||||
#define CY_MISRA_DEVIATE_BLOCK_START(MISRA,COUNT,MESSAGE)
|
||||
#define CY_MISRA_FP_BLOCK_START(MISRA,COUNT,MESSAGE)
|
||||
#define CY_MISRA_DEVIATE_LINE(MISRA, MESSAGE) do{}while(false)
|
||||
#define CY_MISRA_FP_LINE(MISRA, MESSAGE) do{}while(false)
|
||||
#define CY_MISRA_DEVIATE_BLOCK_START(MISRA, COUNT, MESSAGE)
|
||||
#define CY_MISRA_FP_BLOCK_START(MISRA, COUNT, MESSAGE)
|
||||
#define CY_MISRA_BLOCK_END(MISRA)
|
||||
|
||||
#endif /* CY_COVERITY_2012_CHECK */
|
||||
#endif // CY_COVERITY_2012_CHECK
|
||||
|
||||
/** \endcond */
|
||||
|
||||
|
@ -428,6 +432,4 @@ _Pragma(CY_COVERITY_PRAGMA_STR(coverity compliance end_block MISRA))
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif /* CY_UTILS_H */
|
||||
|
||||
/** \} group_utils */
|
||||
|
|
|
@ -1 +1 @@
|
|||
<version>1.1.4.17634</version>
|
||||
<version>1.2.0.22384</version>
|
||||
|
|
Loading…
Reference in New Issue