1 /***********************************************************************************************//** 2 * \file cy_result.h 3 * 4 * \brief 5 * Basic function result handling. Defines a simple type for conveying 6 * information about whether something succeeded or details about any issues 7 * that were detected. 8 * 9 *************************************************************************************************** 10 * \copyright 11 * Copyright 2018-2022 Cypress Semiconductor Corporation (an Infineon company) or 12 * an affiliate of Cypress Semiconductor Corporation 13 * 14 * SPDX-License-Identifier: Apache-2.0 15 * 16 * Licensed under the Apache License, Version 2.0 (the "License"); 17 * you may not use this file except in compliance with the License. 18 * You may obtain a copy of the License at 19 * 20 * http://www.apache.org/licenses/LICENSE-2.0 21 * 22 * Unless required by applicable law or agreed to in writing, software 23 * distributed under the License is distributed on an "AS IS" BASIS, 24 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 * See the License for the specific language governing permissions and 26 * limitations under the License. 27 **************************************************************************************************/ 28 29 /** 30 * \addtogroup group_result Result Type 31 * \ingroup group_abstraction 32 * \{ 33 * \anchor anchor_general_description 34 * \brief Defines a type and related utilities for function result handling. 35 * 36 * The @ref cy_rslt_t type is a structured bitfield which encodes information about result type, 37 * the originating module, and a code for the specific error (or warning etc). In order to extract 38 * these individual fields from a @ref cy_rslt_t value, the utility macros @ref CY_RSLT_GET_TYPE, 39 * @ref CY_RSLT_GET_MODULE, and @ref CY_RSLT_GET_CODE are provided. Alternatively, a newer 40 * @ref cy_rslt_decode_t, union was created to help make the decoding process easier. The 41 * @ref cy_rslt_decode_t also uses enums for the type and module to make decoding even easier. 42 * Example uses of both approaches are shown below: 43 * 44 * Decoding @ref cy_rslt_t directly: 45 * \code 46 * cy_rslt_t result = cy_hal_do_operation(arg); 47 * 48 * // Will be CY_RSLT_TYPE_INFO, CY_RSLT_TYPE_WARNING, CY_RSLT_TYPE_ERROR, or CY_RSLT_TYPE_FATAL 49 * uint8_t type = CY_RSLT_GET_TYPE(result) 50 * 51 * // See the "Modules" section for possible values 52 * uint16_t module_id = CY_RSLT_GET_MODULE(result); 53 * 54 * // Specific error codes are defined by each module 55 * uint16_t error_code = CY_RSLT_GET_CODE(result); 56 * 57 * printf("type=%d, module=%d, code=%d\n", type, module_id, error_code); 58 * \endcode 59 * 60 * Using @ref cy_rslt_decode_t to decode: 61 * \code 62 * cy_rslt_decode_t result; 63 * result.raw = cy_hal_do_operation(arg); 64 * 65 * printf("type=%d, module=%d, code=%d\n", result.type, result.module, result.code); 66 * \endcode 67 */ 68 69 #pragma once 70 71 #include <stdint.h> 72 73 #if defined(__cplusplus) 74 extern "C" { 75 #endif 76 77 /** \cond INTERNAL */ 78 /** Mask for the bit at position "x" */ 79 #define CY_BIT_MASK(x) ((1UL << (x)) - 1U) 80 81 /** Bit position of the result type */ 82 #define CY_RSLT_TYPE_POSITION (16U) 83 /** Bit width of the result type */ 84 #define CY_RSLT_TYPE_WIDTH (2U) 85 /** Bit position of the module identifier */ 86 #define CY_RSLT_MODULE_POSITION (18U) 87 /** Bit width of the module identifier */ 88 #define CY_RSLT_MODULE_WIDTH (14U) 89 /** Bit position of the submodule identifier */ 90 #define CY_RSLT_SUBMODULE_POSITION (8U) 91 /** Bit width of the submodule identifier */ 92 #define CY_RSLT_SUBMODULE_WIDTH (8U) 93 /** Bit position of the result code */ 94 #define CY_RSLT_CODE_POSITION (0U) 95 /** Bit width of the result code */ 96 #define CY_RSLT_CODE_WIDTH (16U) 97 98 /** Mask for the result type */ 99 #define CY_RSLT_TYPE_MASK CY_BIT_MASK(CY_RSLT_TYPE_WIDTH) 100 /** Mask for the module identifier */ 101 #define CY_RSLT_MODULE_MASK CY_BIT_MASK(CY_RSLT_MODULE_WIDTH) 102 /** Mask for the result code */ 103 #define CY_RSLT_CODE_MASK CY_BIT_MASK(CY_RSLT_CODE_WIDTH) 104 /** Mask for submodule identifier */ 105 #define CY_RSLT_SUBMODULE_MASK CY_BIT_MASK(CY_RSLT_SUBMODULE_WIDTH) 106 107 /** \endcond */ 108 109 /** 110 * \{ 111 * @name Fields 112 * Utility macros for constructing result values and extracting individual fields from existing 113 * results. 114 */ 115 116 /** 117 * @brief Get the value of the result type field 118 * @param x the @ref cy_rslt_t value from which to extract the result type 119 */ 120 #define CY_RSLT_GET_TYPE(x) (((x) >> CY_RSLT_TYPE_POSITION) & CY_RSLT_TYPE_MASK) 121 /** 122 * @brief Get the value of the module identifier field 123 * @param x the @ref cy_rslt_t value from which to extract the module id 124 */ 125 #define CY_RSLT_GET_MODULE(x) (((x) >> CY_RSLT_MODULE_POSITION) & CY_RSLT_MODULE_MASK) 126 /** 127 * @brief Get the value of the result code field 128 * @param x the @ref cy_rslt_t value from which to extract the result code 129 */ 130 #define CY_RSLT_GET_CODE(x) (((x) >> CY_RSLT_CODE_POSITION) & CY_RSLT_CODE_MASK) 131 132 /** \} fields */ 133 134 /** 135 * \{ 136 * @name Result Types 137 * Defines codes to identify the type of result. 138 */ 139 140 /** 141 * Defines codes to identify the type of result 142 */ 143 typedef enum 144 { 145 /** The result code is informational-only */ 146 CY_RSLT_TYPE_INFO = 0U, 147 /** The result code is warning of a problem but will proceed */ 148 CY_RSLT_TYPE_WARNING = 1U, 149 /** The result code is an error */ 150 CY_RSLT_TYPE_ERROR = 2U, 151 /** The result code is a fatal error */ 152 CY_RSLT_TYPE_FATAL = 3U 153 } cy_en_rslt_type_t; 154 155 /** \} severity */ 156 157 158 /** 159 * \{ 160 * @name Modules 161 * @anchor anchor_modules 162 * Defines codes to identify the module from which an error originated. 163 * For some large libraries, a range of module codes is defined here; 164 * see the library documentation for values corresponding to individual modules. 165 * Valid range is 0x0000-0x4000. 166 */ 167 168 /** Base module identifier for peripheral driver library drivers (0x0000 - 0x007F) */ 169 #define CY_RSLT_MODULE_DRIVERS_PDL_BASE (0x0000U) 170 /** \cond INTERNAL */ 171 /** Deprecated. Base module identifier for wireless host driver library modules (0x0080 - 0x00FF) */ 172 #define CY_RSLT_MODULE_DRIVERS_WHD_BASE (0x0080U) 173 /** Deprecated. Use @ref CY_RSLT_MODULE_ABSTRACTION_HAL */ 174 #define CY_RSLT_MODULE_ABSTRACTION_HAL_BASE (0x0100U) 175 /** Deprecated. Base module identifier for Board Libraries (0x01A0 - 0x01BF) */ 176 #define CY_RSLT_MODULE_BOARD_LIB_BASE (0x01A0U) 177 /** Deprecated. Base module identifier for Shield Board Libraries (0x01B8 - 0x01BF) */ 178 #define CY_RSLT_MODULE_BOARD_SHIELD_BASE (0x01B8U) 179 /** Deprecated. Base module identifier for Board Hardware Libraries (0x01C0 - 0x01FF) */ 180 #define CY_RSLT_MODULE_BOARD_HARDWARE_BASE (0x01C0U) 181 /** Deprecated. Base module identifier for Middleware Libraries (0x0200 - 0x02FF) */ 182 #define CY_RSLT_MODULE_MIDDLEWARE_BASE (0x0200U) 183 /** Deprecated. Base identifier for environment abstraction modules (0x0184 - 0x019F) */ 184 #define CY_RSLT_MODULE_ABSTRACTION_ENV (0x0184U) 185 /** \endcond */ 186 187 188 /** 189 * Define codes to identify the module from which an error originated. 190 * @note This is provided as a debugging convenience tool, not as a definitive 191 * list of all module IDs. Due to the distributed nature of ModusToolbox™, each 192 * library has its own release schedule. It is possible that some module IDs 193 * may not appear in the enumeration yet. Missing items are expected to be 194 * added over time. 195 */ 196 typedef enum 197 { 198 /** Module identifier for the SAR driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 199 CY_RSLT_MODULE_DRIVER_SAR = 0x0001, 200 /** Module identifier for the Device Firmware Update (DFU) driver. Asset(s): (dfu) */ 201 CY_RSLT_MODULE_DRIVER_DFU = 0x0006, 202 /** Module identifier for the Capsense driver. Asset(s): (capsense) */ 203 CY_RSLT_MODULE_DRIVER_CAPSENSE = 0x0007, 204 /** Module identifier for the USB Device driver. Asset(s): (usbdev) */ 205 CY_RSLT_MODULE_DRIVER_USB_DEV = 0x0008, 206 /** Module identifier for the Continuous Time Block (CTB) driver. Asset(s): (mtb-pdl-cat1, 207 mtb-pdl-cat2) */ 208 CY_RSLT_MODULE_DRIVER_CTB = 0x000b, 209 /** Module identifier for the Crypto driver. Asset(s): (mtb-pdl-cat1) */ 210 CY_RSLT_MODULE_DRIVER_CRYPTO = 0x000c, 211 /** Module identifier for the SysPm driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 212 CY_RSLT_MODULE_DRIVER_SYSPM = 0x0010, 213 /** Module identifier for the SysLib driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 214 CY_RSLT_MODULE_DRIVER_SYSLIB = 0x0011, 215 /** Module identifier for the SysClk driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 216 CY_RSLT_MODULE_DRIVER_SYSCLK = 0x0012, 217 /** Module identifier for the DMA driver. Asset(s): (mtb-pdl-cat1) */ 218 CY_RSLT_MODULE_DRIVER_DMA = 0x0013, 219 /** Module identifier for the Flash driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 220 CY_RSLT_MODULE_DRIVER_FLASH = 0x0014, 221 /** Module identifier for the SysInt driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 222 CY_RSLT_MODULE_DRIVER_SYSINT = 0x0015, 223 /** Module identifier for the GPIO driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 224 CY_RSLT_MODULE_DRIVER_GPIO = 0x0016, 225 /** Module identifier for the Programmable Analog Sub System (PASS) driver. Asset(s): 226 (mtb-pdl-cat1) */ 227 CY_RSLT_MODULE_DRIVER_SYSANALOG = 0x0017, 228 /** Module identifier for the Continuous Time DAC (CTDAC) driver. Asset(s): (mtb-pdl-cat1) */ 229 CY_RSLT_MODULE_DRIVER_CTDAC = 0x0019, 230 /** Module identifier for the eFuse driver. Asset(s): (mtb-pdl-cat1) */ 231 CY_RSLT_MODULE_DRIVER_EFUSE = 0x001a, 232 /** Module identifier for the Emulated EEPROM driver. Asset(s): (emeeprom) */ 233 CY_RSLT_MODULE_DRIVER_EM_EEPROM = 0x001b, 234 /** Module identifier for the Profile driver. Asset(s): (mtb-pdl-cat1) */ 235 CY_RSLT_MODULE_DRIVER_PROFILE = 0x001e, 236 /** Module identifier for the I2S driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 237 CY_RSLT_MODULE_DRIVER_I2S = 0x0020, 238 /** Module identifier for the IPC driver. Asset(s): (mtb-pdl-cat1) */ 239 CY_RSLT_MODULE_DRIVER_IPC = 0x0022, 240 /** Module identifier for the Low Power Comparator (LPCOMP) driver. Asset(s): (mtb-pdl-cat1, 241 mtb-pdl-cat2) */ 242 CY_RSLT_MODULE_DRIVER_LPCOMP = 0x0023, 243 /** Module identifier for the PDM-PCM driver. Asset(s): (mtb-pdl-cat1) */ 244 CY_RSLT_MODULE_DRIVER_PDM_PCM = 0x0026, 245 /** Module identifier for the RTC driver. Asset(s): (mtb-pdl-cat1) */ 246 CY_RSLT_MODULE_DRIVER_RTC = 0x0028, 247 /** Module identifier for the Serial Communications Block (SCB) driver. 248 Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 249 CY_RSLT_MODULE_DRIVER_SCB = 0x002a, 250 /** Module identifier for the Serial Memory Interface (SMIF) driver. Asset(s): (mtb-pdl-cat1) */ 251 CY_RSLT_MODULE_DRIVER_SMIF = 0x002c, 252 /** Module identifier for the Timer/Counter/PWM (TCPWM) driver. 253 Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 254 CY_RSLT_MODULE_DRIVER_TCPWM = 0x002d, 255 /** Module identifier for the Protection driver. Asset(s): (mtb-pdl-cat1) */ 256 CY_RSLT_MODULE_DRIVER_PROT = 0x0030, 257 /** Module identifier for the TRIGMUX driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 258 CY_RSLT_MODULE_DRIVER_TRIGMUX = 0x0033, 259 /** Module identifier for the WDT driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 260 CY_RSLT_MODULE_DRIVER_WDT = 0x0034, 261 /** Module identifier for the (WDC / MCWDT) driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 262 CY_RSLT_MODULE_DRIVER_MCWDT = 0x0035, 263 /** Module identifier for the LIN driver. Asset(s): (mtb-pdl-cat1) */ 264 CY_RSLT_MODULE_DRIVER_LIN = 0x0037, 265 /** Module identifier for the LVD driver. Asset(s): (mtb-pdl-cat1) */ 266 CY_RSLT_MODULE_DRIVER_LVD = 0x0039, 267 /** Module identifier for the SD_HOST driver. Asset(s): (mtb-pdl-cat1) */ 268 CY_RSLT_MODULE_DRIVER_SD_HOST = 0x003a, 269 /** Module identifier for the USBFS driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 270 CY_RSLT_MODULE_DRIVER_USBFS = 0x003b, 271 /** Module identifier for the DMAC driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 272 CY_RSLT_MODULE_DRIVER_DMAC = 0x003f, 273 /** Module identifier for the SegLCD driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 274 CY_RSLT_MODULE_DRIVER_SEGLCD = 0x0040, 275 /** Module identifier for the CSD driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 276 CY_RSLT_MODULE_DRIVER_CSD = 0x0041, 277 /** Module identifier for the SmartIO driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 278 CY_RSLT_MODULE_DRIVER_SMARTIO = 0x0042, 279 /** Module identifier for the CSDIDAC driver. Asset(s): (csdidac) */ 280 CY_RSLT_MODULE_DRIVER_CSDIDAC = 0x0044, 281 /** Module identifier for the CAN FD driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 282 CY_RSLT_MODULE_DRIVER_CANFD = 0x0045, 283 /** Module identifier for the PRA driver. Asset(s): (mtb-pdl-cat1) */ 284 CY_RSLT_MODULE_DRIVER_PRA = 0x0046, 285 /** Module identifier for the MSC driver. Asset(s): (mtb-pdl-cat2) */ 286 CY_RSLT_MODULE_DRIVER_MSC = 0x0047, 287 /** Module identifier for the ADC Mic driver. Asset(s): (mtb-pdl-cat1) 288 * Module identifier for the USB PD driver. Asset(s): (mtb-pdl-cat2) 289 */ 290 CY_RSLT_MODULE_DRIVER_ADCMIC = 0x0048, 291 /** Module identifier for the MSC LP driver. Asset(s): (mtb-pdl-cat2) */ 292 CY_RSLT_MODULE_DRIVER_MSCLP = 0x0049, 293 /** Module identifier for the Event Gen driver. Asset(s): (mtb-pdl-cat1) */ 294 CY_RSLT_MODULE_DRIVER_EVTGEN = 0x004a, 295 /** Module identifier for the SAR v2 driver. Asset(s): (mtb-pdl-cat1) */ 296 CY_RSLT_MODULE_DRIVER_SAR2 = 0x004b, 297 /** Module identifier for the Key Scan driver. Asset(s): (mtb-pdl-cat1) */ 298 CY_RSLT_MODULE_DRIVER_KEYSCAN = 0x0072, 299 /** Module identifier for the PDM-PCM v2 driver. Asset(s): (mtb-pdl-cat1) */ 300 CY_RSLT_MODULE_DRIVER_PDM_PCM2 = 0x0073, 301 /** Module identifier for the Crypto Lite driver. Asset(s): (mtb-pdl-cat1, mtb-pdl-cat2) */ 302 CY_RSLT_MODULE_DRIVER_CRYPTOLITE = 0x0074, 303 /** Module identifier for the SysFault driver. Asset(s): (mtb-pdl-cat1) */ 304 CY_RSLT_MODULE_DRIVER_SYSFAULT = 0x0076, 305 /** Module identifier for the LVD HT driver. Asset(s): (mtb-pdl-cat1) */ 306 CY_RSLT_MODULE_DRIVER_LVD_HT = 0x0078, 307 /** Module identifier for the WiFi Host Driver. Asset(s): (wifi-host-driver) */ 308 CY_RSLT_MODULE_DRIVER_WHD = 0x0080, 309 310 /** Module identifier for the Hardware Abstraction Layer. 311 Asset(s): (mtb-hal-cat1, mtb-hal-cat2, ...) */ 312 CY_RSLT_MODULE_ABSTRACTION_HAL = 0x0100, 313 /** Module identifier for board support package. Asset(s): (BSPs) */ 314 CY_RSLT_MODULE_ABSTRACTION_BSP = 0x0180, 315 /** Module identifier for file system abstraction */ 316 CY_RSLT_MODULE_ABSTRACTION_FS = 0x0181, 317 /** Module identifier for resource abstraction. Asset(s): (abstraction-resource) */ 318 CY_RSLT_MODULE_ABSTRACTION_RESOURCE = 0x0182, 319 /** Module identifier for RTOS abstraction. Asset(s): (abstraction-rtos) */ 320 CY_RSLT_MODULE_ABSTRACTION_OS = 0x0183, 321 322 /** Module identifier for the Retarget IO Board Library. Asset(s): (retarget-io) */ 323 CY_RSLT_MODULE_BOARD_LIB_RETARGET_IO = 0x1A0, 324 /** Module identifier for the RGB LED Board Library. Asset(s): (rgb-led) */ 325 CY_RSLT_MODULE_BOARD_LIB_RGB_LED = 0x01A1, 326 /** Module identifier for the Serial Flash Board Library. Asset(s): (serial-flash) */ 327 CY_RSLT_MODULE_BOARD_LIB_SERIAL_FLASH = 0x01A2, 328 /** Module identifier for the WiFi Host Driver + Board Support Integration Library. 329 Asset(s): (whd-bsp-integration) */ 330 CY_RSLT_MODULE_BOARD_LIB_WHD_INTEGRATION = 0x01A3, 331 332 /** Module identifier for Shield Board CY8CKIT-028-EPD. Asset(s): (CY8CKIT-028-EPD) */ 333 CY_RSLT_MODULE_BOARD_SHIELD_028_EPD = 0x01B8, 334 /** Module identifier for Shield Board CY8CKIT-028-TFT. Asset(s): (CY8CKIT-028-TFT) */ 335 CY_RSLT_MODULE_BOARD_SHIELD_028_TFT = 0x01B9, 336 /** Module identifier for Shield Board CY8CKIT-032. Asset(s): (CY8CKIT-032) */ 337 CY_RSLT_MODULE_BOARD_SHIELD_032 = 0x01BA, 338 /** Module identifier for Shield Board CY8CKIT-028-SENSE. Asset(s): (CY8CKIT-028-SENSE) */ 339 CY_RSLT_MODULE_BOARD_SHIELD_028_SENSE = 0x01BB, 340 341 /** Module identifier for the BMI160 Motion Sensor Library. Asset(s): (sensor-motion-bmi160) */ 342 CY_RSLT_MODULE_BOARD_HARDWARE_BMI160 = 0x01C0, 343 /** Module identifier for the E2271CS021 E-Ink Controller Library. 344 Asset(s): (display-eink-e2271cs021) */ 345 CY_RSLT_MODULE_BOARD_HARDWARE_E2271CS021 = 0x01C1, 346 /** Module identifier for the NTC GPIO Thermistor Library. Asset(s): (thermistor) */ 347 CY_RSLT_MODULE_BOARD_HARDWARE_THERMISTOR = 0x01C2, 348 /** Module identifier for the SSD1306 OLED Controller Library. 349 Asset(s): (display-oled-ssd1306) */ 350 CY_RSLT_MODULE_BOARD_HARDWARE_SSD1306 = 0x01C3, 351 /** Module identifier for the ST7789V TFT Controller Library. Asset(s): (display-tft-st7789v) */ 352 CY_RSLT_MODULE_BOARD_HARDWARE_ST7789V = 0x01C4, 353 /** Module identifier for the Light Sensor Library. Asset(s): (sensor-light) */ 354 CY_RSLT_MODULE_BOARD_HARDWARE_LIGHT_SENSOR = 0x01C5, 355 /** Module identifier for the AK4954A Audio Codec Library. Asset(s): (audio-codec-ak4954a) */ 356 CY_RSLT_MODULE_BOARD_HARDWARE_AK4954A = 0x01C6, 357 /** Module identifier for the BMI160 Motion Sensor Library. 358 Asset(s): (sensor-orientation-bmx160) */ 359 CY_RSLT_MODULE_BOARD_HARDWARE_BMX160 = 0x01C7, 360 /** Module identifier for the XENSIV™ DPS3XX Pressure Sensor Library. 361 Asset(s): (sensor-xensiv-dps3xx) */ 362 CY_RSLT_MODULE_BOARD_HARDWARE_DPS3XX = 0x01C8, 363 /** Module identifier for the WM8960 Audio Codec Library. Asset(s): (audio-codec-wm8960) */ 364 CY_RSLT_MODULE_BOARD_HARDWARE_WM8960 = 0x01C9, 365 /** Module identifier for the XENSIV™ PAS CO2 Sensor Library. 366 Asset(s): (sensor-xensiv-pasco2) */ 367 CY_RSLT_MODULE_BOARD_HARDWARE_XENSIV_PASCO2 = 0x01CA, 368 /** Module identifier for the XENSIV™ BGT60TRxx Sensor Library. 369 Asset(s): (sensor-xensiv-bgt60trxx) */ 370 CY_RSLT_MODULE_BOARD_HARDWARE_XENSIV_BGT60TRXX = 0x01CC, 371 /** Module identifier for the LM49450 Audio Codec Library. Asset(s): (audio-codec-lm49450) */ 372 CY_RSLT_MODULE_BOARD_HARDWARE_LM49450 = 0x01CE, 373 374 /** Module identifier for the MDNS library. Asset(s): (mdns) */ 375 CY_RSLT_MODULE_MIDDLEWARE_MNDS = 0x200, 376 /** Module identifier for the ASW IoT library. Asset(s): (aws-iot) */ 377 CY_RSLT_MODULE_MIDDLEWARE_AWS = 0x201, 378 /** Module identifier for the JSON parser library. Asset(s): (connectivity-utilities) */ 379 CY_RSLT_MODULE_MIDDLEWARE_JSON = 0x202, 380 /** Module identifier for the Linked List library. Asset(s): (connectivity-utilities) */ 381 CY_RSLT_MODULE_MIDDLEWARE_LINKED_LIST = 0x203, 382 /** Module identifier for the Command Console library. Asset(s): (command-console) */ 383 CY_RSLT_MODULE_MIDDLEWARE_COMMAND_CONSOLE = 0x204, 384 /** Module identifier for the HTTP Server library. Asset(s): (http-server) */ 385 CY_RSLT_MODULE_MIDDLEWARE_HTTP_SERVER = 0x205, 386 /** Module identifier for the Enterprise Security library. Asset(s): (enterprise-security) */ 387 CY_RSLT_MODULE_MIDDLEWARE_ENTERPRISE_SECURITY = 0x206, 388 /** Module identifier for the TCP/IP library. Asset(s): (connectivity-utilities) */ 389 CY_RSLT_MODULE_MIDDLEWARE_TCPIP = 0x207, 390 /** Module identifier for the Generic middleware library. 391 Asset(s): (connectivity-utilities, wifi-mw-core) */ 392 CY_RSLT_MODULE_MIDDLEWARE_MW = 0x208, 393 /** Module identifier for the TLS library. Asset(s): (cy-mbedtls) */ 394 CY_RSLT_MODULE_MIDDLEWARE_TLS = 0x209, 395 /** Module identifier for the Secure Sockets library. Asset(s): (secure-sockets) */ 396 CY_RSLT_MODULE_MIDDLEWARE_SECURE_SOCKETS = 0x20a, 397 /** Module identifier for the WiFi Connection Manager library (WCM). 398 Asset(s): (wifi-connection-manager) */ 399 CY_RSLT_MODULE_MIDDLEWARE_WCM = 0x20b, 400 /** Module identifier for the lwIP WHD port library. Asset(s): (wifi-mw-core) */ 401 CY_RSLT_MODULE_MIDDLEWARE_LWIP_WHD_PORT = 0x20c, 402 /** Module identifier for the OTA Update library. Asset(s): (anycloud-ota) */ 403 CY_RSLT_MODULE_MIDDLEWARE_OTA_UPDATE = 0x20d, 404 /** Module identifier for the HTTP Clinet library. Asset(s): (http-client) */ 405 CY_RSLT_MODULE_MIDDLEWARE_HTTP_CLIENT = 0x20e, 406 /** Module identifier for the Machine Learning(ML) library. Asset(s): (ml-middleware) */ 407 CY_RSLT_MODULE_MIDDLEWARE_ML = 0x20f, 408 409 /** Module identifier for the KV Store Middleware Library. Asset(s): (kv-store) */ 410 CY_RSLT_MODULE_MIDDLEWARE_KVSTORE = 0x250, 411 /** Module identifier for the LIN Middleware Library. Asset(s): (lin) */ 412 CY_RSLT_MODULE_MIDDLEWARE_LIN = 0x0251, 413 /** Module identifier for the UBM Middleware Library. Asset(s): (ubm) */ 414 CY_RSLT_MODULE_MIDDLEWARE_UBM = 0x0252 415 } cy_en_rslt_module_t; 416 417 /** \} modules */ 418 419 /** 420 * @brief Provides the result of an operation as a structured bitfield. 421 * 422 * @note A newer version @ref cy_rslt_decode_t is also available for improved 423 * debugging experience. 424 * 425 * See the \ref anchor_general_description "General Description" 426 * for more details on structure and usage. 427 */ 428 typedef uint32_t cy_rslt_t; 429 430 /** 431 * @brief Provides the result of an operation as a structured bitfield. 432 * 433 * This is an updated version of @ref cy_rslt_t that pulls the individual 434 * fields out into their own members for easier readability. The organization 435 * and meaning of items is exactly the same. The new version can be used as follows: 436 * cy_rslt_decode_t result; 437 * result.raw = my_function_that_returns_cy_rslt_t(); 438 * 439 * See the @ref anchor_general_description "General Description" 440 * for more details on structure and usage. 441 */ 442 typedef union 443 { 444 cy_rslt_t raw; //!< The raw uint32/cy_rslt_t value 445 /** Anonymous struct breaking out each of the fields of the result type */ 446 struct 447 { 448 uint16_t code : CY_RSLT_CODE_WIDTH; //!< The 16bit result code 449 cy_en_rslt_type_t type : CY_RSLT_TYPE_WIDTH; //!< The 2bit result type 450 cy_en_rslt_module_t module : CY_RSLT_MODULE_WIDTH; //!< The 14bit module id 451 }; 452 } cy_rslt_decode_t; 453 454 /** @ref cy_rslt_t return value indicating success */ 455 #define CY_RSLT_SUCCESS ((cy_rslt_t)0x00000000U) 456 457 /** 458 * @brief Create a new @ref cy_rslt_t value that encodes the specified type, module, and result 459 * code. 460 * @param type one of @ref CY_RSLT_TYPE_INFO, @ref CY_RSLT_TYPE_WARNING, 461 * @ref CY_RSLT_TYPE_ERROR, @ref CY_RSLT_TYPE_FATAL 462 * @param module Identifies the module where this result originated; see @ref anchor_modules 463 * "Modules". 464 * @param code a module-defined identifier to identify the specific situation that 465 * this result describes. 466 */ 467 #define CY_RSLT_CREATE(type, module, code) \ 468 ((((uint16_t) (module) & CY_RSLT_MODULE_MASK) << CY_RSLT_MODULE_POSITION) | \ 469 ((((uint16_t) code) & CY_RSLT_CODE_MASK) << CY_RSLT_CODE_POSITION) | \ 470 ((((uint16_t) type) & CY_RSLT_TYPE_MASK) << CY_RSLT_TYPE_POSITION)) 471 472 /** 473 * @brief Create a new @ref cy_rslt_t value that encodes the specified type, module and 474 * result code. This is a variant of @ref CY_RSLT_CREATE for result codes that need to handle 475 * submodules as well. 476 * @param type one of @ref CY_RSLT_TYPE_INFO, @ref CY_RSLT_TYPE_WARNING, 477 * @ref CY_RSLT_TYPE_ERROR, @ref CY_RSLT_TYPE_FATAL 478 * @param module Identifies the module where this result originated; see @ref anchor_modules 479 * "Modules". 480 * @param submodule An asset defined subset of the module. The submodule consumes part 481 * of the "code" section and thus the size of the valid code is then reduced. 482 * @param code a module-defined identifier to identify the specific situation that 483 * this result describes. 484 */ 485 #define CY_RSLT_CREATE_EX(type, module, submodule, code) \ 486 (((((uint16_t) module) & CY_RSLT_MODULE_MASK) << CY_RSLT_MODULE_POSITION) | \ 487 ((((((((uint16_t)submodule) & CY_RSLT_SUBMODULE_MASK) << CY_RSLT_SUBMODULE_POSITION) | \ 488 ((uint16_t) code)) & CY_RSLT_CODE_MASK) << CY_RSLT_CODE_POSITION)) | \ 489 ((((uint16_t) type) & CY_RSLT_TYPE_MASK) << CY_RSLT_TYPE_POSITION)) 490 491 #ifdef __cplusplus 492 } 493 #endif 494 495 /** \} group_result */ 496