1 /***************************************************************************//**
2 * \file cy_syspm.h
3 * \version 5.60
4 *
5 * Provides the function definitions for the power management API.
6 *
7 ********************************************************************************
8 * \copyright
9 * Copyright 2016-2020 Cypress Semiconductor Corporation
10 * SPDX-License-Identifier: Apache-2.0
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 *     http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 *******************************************************************************/
25 
26 /**
27 * \addtogroup group_syspm
28 * \{
29 *
30 * Use the System Power Management (SysPm) driver to change power modes and
31 * reduce system power consumption in power sensitive designs.
32 *
33 * The functions and other declarations used in this driver are in cy_syspm.h.
34 * You can include cy_pdl.h to get access to all functions
35 * and declarations in the PDL.
36 *
37 * For multi-CPU devices, this library allows you to individually enter low power
38 * modes for each CPU.
39 *
40 * This document contains the following topics:
41 *
42 * * \ref group_syspm_power_modes
43 * * \ref group_syspm_system_power_modes
44 *   - \ref group_syspm_switching_into_ulp
45 *     - \ref group_syspm_ulp_limitations
46 *   - \ref group_syspm_switching_into_lp
47 *     - \ref group_syspm_lp_limitations
48 *   - \ref group_syspm_switching_into_sleep
49 *   - \ref group_syspm_switching_into_deepsleep
50 *   - \ref group_syspm_wakingup_from_sleep_deepsleep
51 *   - \ref group_syspm_switching_into_hibernate
52 *   - \ref group_syspm_wakingup_from_hibernate
53 * * \ref group_syspm_system_reg_curr_mode
54 *   - \ref group_syspm_system_set_min_reg_curr_mode
55 *   - \ref group_syspm_system_set_normal_reg_curr_mode
56 * * \ref group_syspm_migration_guide_for_syspm_4_0
57 * * \ref group_syspm_managing_pmic
58 * * \ref group_syspm_managing_backup_domain
59 * * \ref group_syspm_cb
60 *   - \ref group_syspm_cb_example
61 *   - \ref group_syspm_cb_config_consideration
62 *     - \ref group_syspm_cb_parameters
63 *     - \ref group_syspm_cb_structures
64 *     - \ref group_syspm_cb_function_implementation
65 *     - \ref group_syspm_cb_flow
66 *     - \ref group_syspm_cb_registering
67 *     - \ref group_syspm_cb_unregistering
68 * * \ref group_syspm_definitions
69 *
70 * \section group_syspm_section_configuration Configuration Considerations
71 * \subsection group_syspm_power_modes Power Modes
72 * PSoC 6 MCUs support four system and three CPU power modes. These power modes
73 * are intended to minimize average power consumption in an application.
74 * System power modes:
75 * * <b>Low Power</b> - All peripheral and CPU power modes
76 *   are available to be used at maximum device frequency and current
77 *   consumption.
78 * * <b>Ultra Low Power</b> - All peripheral and
79 *   CPU power modes are available, but the frequency and current consumption
80 *   are limited to a device specific number.
81 * * <b>Deep Sleep</b> - Device and I/O states is retained. Low-frequency
82 *   peripherals are available. Both CPUs are in CPU Deep Sleep power mode.
83 * * <b>Hibernate</b> - The device and I/O states are frozen and the device
84 *   resets on wakeup.
85 *
86 * The CPU <b>Active</b>, <b>Sleep</b> and <b>Deep Sleep</b> power modes are
87 * Arm-defined power modes supported by the Arm CPU instruction
88 * set architecture (ISA).
89 *
90 * \subsection group_syspm_system_power_modes System Power Modes
91 * * <b>LP</b> - In this mode, code is executed and all logic and
92 *   memories are powered. Firmware may disable/reduce clocks for specific
93 *   peripherals and power down specific analog power domains.
94 *
95 * * <b>ULP</b> - This power mode is like LP mode, but
96 *   with clock restrictions and limited/slower peripherals to achieve lower
97 *   current consumption. Refer to \ref group_syspm_switching_into_ulp in
98 *   Configuration considerations.
99 *
100 * * <b>Deep Sleep</b> - Is a lower power mode where high-frequency clocks are
101 *   disabled. Refer to \ref group_syspm_switching_into_deepsleep in
102 *   Configuration considerations. Deep-sleep-capable peripherals are available.
103 *   A normal wakeup from Deep Sleep returns to either system LP or ULP mode,
104 *   depending on the previous state and programmed behavior for the configured
105 *   wakeup interrupt. Likewise, a debug wakes up from system Deep Sleep and
106 *   woken CPU returns to CPU Sleep. Refer
107 *   to \ref group_syspm_wakingup_from_sleep_deepsleep in Configuration
108 *   considerations.
109 *
110 * * <b>Hibernate</b> - Is the lowest power mode that is entered from
111 *   firmware. Refer to \ref group_syspm_switching_into_hibernate in
112 *   Configuration considerations. On wakeup the CPU(s) and all peripherals
113 *   go through a full reset. The I/O's state is frozen so that the
114 *   output driver state is held in system Hibernate. Note that in this mode,
115 *   the CPU(s) and all peripherals lose their states, so the system and firmware
116 *   reboot on a wakeup event. Backup memory (if present) can be used to store
117 *   limited system state for use on the next reboot. Refer to
118 *   \ref group_syspm_wakingup_from_hibernate in Configuration considerations.
119 *
120 * \subsubsection group_syspm_switching_into_lp Switching the System into Low Power
121 * To set system LP mode you need to set LP voltage for the active core
122 * regulator:
123 * * If active core regulator is the LDO, call:
124 *   \code{.c}
125 *   Cy_SysPm_LdoSetVoltage(CY_SYSPM_LDO_VOLTAGE_LP);
126 *   \endcode
127 * * If active core regulator is the Buck, call:
128 *   \code{.c}
129 *   Cy_SysPm_BuckSetVoltage1(CY_SYSPM_BUCK_OUT1_VOLTAGE_LP)
130 *   \endcode
131 *
132 * After switching into system LP mode, the operating frequency and current
133 * consumption may now be increased up to \ref group_syspm_lp_limitations.
134 * The wait states for flash may be changed to increase device performance by
135 * calling SysLib function Cy_SysLib_SetWaitStates(true, hfClkFreqMz), where
136 * hfClkFreqMz is the frequency of HfClk0 in MHz.
137 *
138 * \subsubsection group_syspm_lp_limitations LP Limitations
139 * When the system is in LP mode, the core regulator voltage is set to
140 * <b>1.1 V (nominal)</b> and the following limitations must be met:
141 *
142 *   - The maximum operating frequency for all Clk_HF paths must not exceed
143 *     <b>150 MHz*</b>, and peripheral and slow clock must
144 *     not exceed <b>100 MHz *</b>
145 *
146 *   - The total current consumption must be less than or equal to
147 *     <b>250 mA *</b>
148 *
149 * \warning * - Numbers shown are approximate and real limit values may be
150 * different because they are device specific. You should refer to the device
151 * datasheet for exact values of maximum frequency and current in system LP mode.
152 *
153 * \subsubsection group_syspm_switching_into_ulp Switching the System into Ultra Low Power
154 * Before switching into system ULP mode, ensure that the device meets
155 * \ref group_syspm_ulp_limitations. Decrease the clock frequencies,
156 * and slow or disable peripherals. Also ensure that appropriate wait state
157 * values are set for the flash. Flash wait states can be set by calling
158 * SysLib function Cy_SysLib_SetWaitStates(true, hfClkFreqMz), where hfClkFreqMz
159 * is the frequency of HfClk0 in MHz.
160 *
161 * After the \ref group_syspm_ulp_limitations are met and appropriate wait
162 * states are set, you must set ULP voltage for the active core regulator:
163 * * If active core regulator is the LDO Core Voltage Regulator, call
164 * Cy_SysPm_LdoSetVoltage(CY_SYSPM_LDO_VOLTAGE_ULP)
165 * * If active core regulator is the Buck Core Voltage Regulator, then call
166 * Cy_SysPm_BuckSetVoltage1(CY_SYSPM_BUCK_OUT1_VOLTAGE_ULP)
167 *
168 * \subsubsection group_syspm_ulp_limitations ULP Limitations
169 * When the system is in ULP mode the core regulator voltage is set to <b>0.9 V
170 * (nominal)</b> and the following limitations must be meet:
171 *
172 *   - The maximum operating frequency for all Clk_HF paths must not exceed
173 *     <b>50 MHz *</b>, whereas the peripheral and slow clock must not exceed
174 *     <b>25 MHz *</b>.
175 *
176 *   - The total current consumption must be less than or equal
177 *     to <b>20 mA*</b>
178 *
179 *   - the flash write operations are prohibited. The flash works in the
180 *     Read-only operation. If Write operations are required, you must switch to
181 *     the system LP mode.
182 *
183 * \warning * - Numbers shown are approximate and real limit values may be
184 * different because they are device specific. You should refer to the device
185 * datasheet for exact values of maximum frequency and current in system
186 * ULP mode.
187 *
188 * \subsubsection group_syspm_switching_into_sleep Switching CPU into Sleep
189 * For multi-CPU devices, the Cy_SysPm_CpuEnterSleep() switches only the CPU
190 * that calls the function into the CPU Sleep power mode.
191 *
192 * All pending interrupts must be cleared before the CPU is put into a
193 * Sleep mode, even if they are masked.
194 *
195 * The CPU event register can be set in the past, for example, as a result of
196 * internal system calls. So an old event can cause the CPU to not enter
197 * Sleep mode upon WFE(). Therefore usually the WFE() is used in an idle loop or
198 * polling loop as it might or might not cause entering of CPU Sleep mode. If
199 * the idle loop or polling loop is not used, then it is recommended to use
200 * WFI() instruction.
201 *
202 * \subsubsection group_syspm_switching_into_deepsleep Switching the System or CPU into Deep Sleep
203 * For multi-CPU devices, the Cy_SysPm_CpuEnterDeepSleep() function switches
204 * only the CPU that calls the function into the CPU Deep Sleep power mode.
205 * To set the whole system into Deep Sleep power mode, ensure that all CPUs call
206 * the Cy_SysPm_CpuEnterDeepSleep() function.
207 *
208 * There are situations when the system does not switch into the Deep Sleep
209 * power mode immediately after the last CPU calls Cy_SysPm_CpuEnterDeepSleep().
210 * The system will switch into Deep Sleep mode automatically a short time later,
211 * after the low power circuits are ready to switch into Deep Sleep. Refer to
212 * the Cy_SysPm_CpuEnterDeepSleep() description for more detail.
213 *
214 * All pending interrupts must be cleared before the system is put into a
215 * Deep Sleep mode, even if they are masked.
216 *
217 * The CPU event register can be set in the past, for example, as a result of
218 * internal system calls. So an old event can cause the CPU to not enter Deep
219 * Sleep mode upon WFE(). Therefore usually the WFE() is used in an idle loop or
220 * polling loop as it might or might not cause entering of CPU Deep Sleep mode.
221 * If the idle loop or polling loop is not used, then it is recommended to use
222 * WFI() instruction.
223 *
224 * For single-CPU devices, SysPm functions that return the status of the
225 * unsupported CPU always return CY_SYSPM_STATUS_<CPU>_DEEPSLEEP.
226 *
227 * \subsubsection group_syspm_wakingup_from_sleep_deepsleep Waking Up from Sleep or Deep Sleep
228 * For Arm-based devices, an interrupt is required for the CPU to wake up.
229 * For multi-CPU devices, one CPU can wake up the other CPU by sending the
230 * event instruction. Use the Cy_SysPm_CpuSendWakeupEvent() function.
231 *
232 * \subsubsection group_syspm_switching_into_hibernate Switching System to Hibernate
233 * If you call Cy_SysPm_SystemEnterHibernate() from either CPU, the system will
234 * be switched into the Hibernate power mode directly, because there is no
235 * handshake between CPUs.
236 *
237 * \subsubsection group_syspm_wakingup_from_hibernate Waking Up from Hibernate
238 *
239 * The system can wake up from Hibernate mode by configuring the following wakeup
240 * sources:
241 * - Wakeup pin
242 * - LP Comparator
243 * - RTC alarm
244 * - WDT interrupt
245 *
246 * Wakeup is supported from device specific pin(s) with programmable polarity.
247 * Additionally, unregulated peripherals can wake the system under some
248 * conditions. For example, a low power comparator can wake the system by
249 * comparing two external voltages, but does not support comparison to an
250 * internally-generated voltage. The backup power domain remains functional, and
251 * if present it can schedule an alarm to wake the system from Hibernate using
252 * the RTC. Alternatively, the Watchdog Timer (WDT) can be configured to wake-up
253 * the system by WDT interrupt. Refer to \ref Cy_SysPm_SetHibernateWakeupSource()
254 * for more detail.
255 *
256 * \subsection group_syspm_system_reg_curr_mode System Regulator Current Mode
257 * In addition to system ULP and LP modes, the five different resource
258 * power settings can be configured to reduce current consumption:
259 * -# <b>Linear regulator low power mode</b>. Can be used only if core current
260 *    is below the LDO regulator LP threshold.
261 * -# <b>POR/BOD circuit low power mode</b>. Requires compatible power supply
262 *    stability due to stability increase response time.
263 * -# <b>Bandgap reference circuits low power mode</b> (turns on Deep Sleep
264 *    Bandgap). Requires design to accept reduced Vref accuracy. Active ref can
265 *    be turned off after this feature is enabled.
266 * -# <b>Reference buffer circuit low power mode</b>. Requires design to accept
267 *    reduced Vref accuracy.
268 * -# <b>Current reference circuit low power mode</b>. Require design to accept
269 *    reduced Iref accuracy.
270 *
271 * These five sub features can modify both system LP or ULP modes as they are
272 * independent from LP/ULP settings.
273 * When all five sub features are set to their low power modes, the system
274 * operates in regulator minimum current mode. In regulator minimum current mode,
275 * the system current consumption is limited to a device-specific value. Refer to
276 * the device datasheet for the exact current consumption value in regulator
277 * minimum current mode.
278 *
279 * When all five sub features are set to their normal mode, the system operates
280 * in regulator normal current mode. When regulator normal current mode is set,
281 * the system may operate at device maximum current.
282 *
283 * \subsection group_syspm_system_set_min_reg_curr_mode Setting Minimum System Regulator Current Mode
284 *
285 * Before setting the regulator minimum current mode ensure that current limits
286 * are be met. After current limits are met, call the
287 * Cy_SysPm_SystemSetMinRegulatorCurrent() function.
288 *
289 * \subsection group_syspm_system_set_normal_reg_curr_mode Setting Normal System Regulator Current Mode
290 *
291 * To set regulator normal current mode, call the
292 * Cy_SysPm_SystemSetNormalRegulatorCurrent() function. After the function call,
293 * the current limits can be increased to a maximum current, depending on what
294 * system power mode is set: LP or ULP.
295 *
296 * \subsection group_syspm_managing_pmic Managing PMIC
297 *
298 * The SysPm driver also provides an API to configure the internal power
299 * management integrated circuit (PMIC) controller for an external PMIC that
300 * supplies Vddd. Use the API to enable the internal PMIC controller output that
301 * is routed to pmic_wakeup_out pin, and configure the polarity of the PMIC
302 * controller input (pmic_wakeup_in) that is used to wake up the PMIC.
303 *
304 * The PMIC controller is automatically enabled when:
305 * * The PMIC is locked by a call to Cy_SysPm_PmicLock()
306 * * The configured polarity of the PMIC input and the polarity driven to
307 *   pmic_wakeup_in pin matches.
308 *
309 * Because a call to Cy_SysPm_PmicLock() automatically enables the PMIC
310 * controller, the PMIC can remain disabled only when it is unlocked. See Cy_SysPm_PmicUnlock()
311 * for more detail.
312 *
313 * Use Cy_SysPm_PmicIsLocked() to read the current PMIC lock status.
314 *
315 * To enable the PMIC, use these functions in this order:
316 * \code{.c}
317 * Cy_SysPm_PmicUnlock();
318 * Cy_SysPm_PmicEnable();
319 * Cy_SysPm_PmicLock();
320 * \endcode
321 *
322 * To disable the PMIC controller, unlock the PMIC. Then call
323 * Cy_SysPm_PmicDisable() with the inverted value of the current active state of
324 * the pmic_wakeup_in pin.
325 * For example, assume the current state of the pmic_wakeup_in pin is active low.
326 * To disable the PMIC controller, call these functions in this order:
327 * \code{.c}
328 * Cy_SysPm_PmicUnlock();
329 * Cy_SysPm_PmicDisable(CY_SYSPM_PMIC_POLARITY_HIGH);
330 * \endcode
331 * Note that you do not call Cy_SysPm_PmicLock(), because that automatically
332 * enables the PMIC.
333 *
334 * While disabled, the PMIC controller is automatically enabled when the
335 * pmic_wakeup_in pin state is changed into a high state.
336 *
337 * To disable the PMIC controller output, call these functions in this order:
338 * Cy_SysPm_PmicUnlock();
339 * Cy_SysPm_PmicDisableOutput();
340 *
341 * Do not call Cy_SysPm_PmicLock() (which automatically enables the PMIC
342 * controller output).
343 *
344 * When disabled, the PMIC controller output is enabled when the PMIC is locked,
345 * or by calling Cy_SysPm_PmicEnableOutput().
346 *
347 * \subsection group_syspm_managing_backup_domain Managing the Backup Domain
348 * The SysPm driver provide functions to:
349 *
350 * * Configure Supercapacitor charging
351 * * Select power supply source (Vbackup or Vddd) for Vddbackup
352 * * Measure Vddbackup using the ADC
353 *
354 * Refer to the \ref group_syspm_functions_backup functions for more detail.
355 *
356 * \subsection group_syspm_cb SysPm Callbacks
357 * The SysPm driver handles low power callbacks declared in the application.
358 *
359 * If there are no callbacks registered, the device executes the power mode
360 * transition. However, frequently your application firmware must make
361 * modifications for low power mode. For example, you may need to disable a
362 * peripheral, or ensure that a message is not being transmitted or received.
363 *
364 * To enable this, the SysPm driver implements a callback mechanism. When a lower
365 * power mode transition is about to take place (either entering or exiting
366 * \ref group_syspm_system_power_modes), the registered callbacks for that
367 * transition are called.
368 *
369 * The SysPm driver organizes all the callbacks into a linked list. While
370 * entering a low power mode, SysPm goes through that linked list from first to
371 * last, executing the callbacks one after another. While exiting low power mode,
372 * SysPm goes through that linked list again, but in the opposite direction from
373 * last to first. This ordering supports prioritization of callbacks relative to
374 * the transition event.
375 *
376 * For example, the picture below shows three callback structures organized into
377 * a linked list: myDeepSleep1, myDeepSleep2, myDeepSleep3 (represented with the
378 * \ref cy_stc_syspm_callback_t configuration structure). Each structure
379 * contains, among other fields, the address of the callback function. The code
380 * snippets below set this up so that myDeepSleep1 is called first when entering
381 * the low power mode. This also means that myDeepSleep1 will be the last one to
382 * execute when exiting the low power mode.
383 *
384 * The callback structures after registration:
385 * \image html syspm_register_eq.png
386 *
387 * Your application must register each callback, so that SysPm can execute it.
388 * Upon registration, the linked list is built by the SysPm driver. Notice
389 * the &myDeepSleep1 address in the myDeepSleep1
390 * \ref cy_stc_syspm_callback_t structure. This is filled in by the SysPm driver,
391 * when you register myDeepSleep1. The cy_stc_syspm_callback_t.order element
392 * defines the order of their execution by the SysPm driver.
393 * Call \ref Cy_SysPm_RegisterCallback() to register each callback function.
394 *
395 * A callback function is typically associated with a particular driver that
396 * handles the peripheral. So the callback mechanism enables a peripheral to
397 * prepare for a low power mode (for instance, shutting down the analog part);
398 * or to perform tasks while exiting a low power mode (like enabling the analog
399 * part again).
400 *
401 * With the callback mechanism you can prevent switching into a low power mode if
402 * a peripheral is not ready. For example, driver X is in the process of
403 * receiving a message. In the callback function implementation simply return
404 * CY_SYSPM_FAIL in a response to CY_SYSPM_CHECK_READY.
405 *
406 * If success is returned while executing a callback, the SysPm driver calls the
407 * next callback and so on to the end of the list. If at some point a callback
408 * returns CY_SYSPM_FAIL in response to the CY_SYSPM_CHECK_READY step, all the
409 * callbacks that have already executed are executed in reverse order, with the
410 * CY_SYSPM_CHECK_FAIL mode parameter. This allows each callback to know that
411 * entering the low power mode has failed. The callback can then undo whatever it
412 * did to prepare for low power mode, if required. For example, if the driver X
413 * callback shut down the analog part, it can re-enable the analog part.
414 *
415 * Let's switch to an example explaining the implementation, setup, and
416 * registration of three callbacks (myDeepSleep1, myDeepSleep2, myDeepSleep2) in
417 * the application. The \ref group_syspm_cb_config_consideration are provided
418 * after the \ref group_syspm_cb_example.
419 *
420 * \subsection group_syspm_cb_example SysPm Callbacks Example
421 *
422 * The following code snippets demonstrate how use the SysPm callbacks mechanism.
423 * We will build the prototype for an application that registers
424 * three callback functions:
425 *    -# myDeepSleep1 - Handles CPU Deep Sleep.
426 *    -# myDeepSleep2 - Handles CPU Deep Sleep and is associated with peripheral
427 *       HW1_address (see <a href="..\..\pdl_user_guide.pdf">PDL Design</a>
428 *       section to learn about the base hardware address).
429 *    -# myDeepSleep3 - Handles entering and exiting system Deep Sleep and is
430 *       associated with peripheral HW2_address.
431 *
432 * We set things up so that the myDeepSleep1 and myDeepSleep2 callbacks do
433 * nothing while entering the low power mode (skip on
434 * CY_SYSPM_SKIP_BEFORE_TRANSITION -
435 * see \ref group_syspm_cb_function_implementation in
436 * \ref group_syspm_cb_config_consideration).
437 * Skipping the actions while entering low power might be useful if you need
438 * to save time while switching low power modes. This is because the callback
439 * function with a skipped mode is not even called avoiding the call and return
440 * overhead.
441 *
442 * Let's first declare the callback functions. Each gets the pointer to the
443 * \ref cy_stc_syspm_callback_params_t structure as the argument.
444 *
445 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_Callback_Func_Declaration
446 *
447 * Now we setup the \ref cy_stc_syspm_callback_params_t structures that we will
448 * pass to the callback functions. Note that for the myDeepSleep2 and
449 * myDeepSleep3 callbacks we also pass pointers to the peripherals related to
450 * that callback (see <a href="..\..\pdl_user_guide.pdf">PDL Design</a> section
451 * to learn about base hardware addresses).
452 * The configuration considerations related to this structure are described
453 * in \ref group_syspm_cb_parameters in \ref group_syspm_cb_config_consideration.
454 *
455 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_Callback_Params_Declaration
456 *
457 * Now we setup the actual callback configuration structures. Each of these
458 * contains, among the other fields, the address of the
459 * \ref cy_stc_syspm_callback_params_t we just set up. We will use the callback
460 * configuration structures later in the code to register the callbacks in the
461 * SysPm driver. Again, we set things up so that the myDeepSleep1 and
462 * myDeepSleep2 callbacks do nothing while entering the low power mode
463 * (skip on CY_SYSPM_SKIP_BEFORE_TRANSITION) - see
464 * \ref group_syspm_cb_function_implementation in
465 * \ref group_syspm_cb_config_consideration.
466 *
467 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_Callback_Structure_Declaration
468 *
469 * Note that in each case the last two fields are NULL. These are fields used by
470 * the SysPm driver to set up the linked list of callback functions.
471 *
472 * The callback structures are now defined and allocated in the user's
473 * memory space:
474 * \image html syspm_before_registration.png
475 *
476 * Now we implement the callback functions. See
477 * \ref group_syspm_cb_function_implementation in
478 * \ref group_syspm_cb_config_consideration for the instructions on how the
479 * callback functions should be implemented.
480 *
481 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_Callback_Func_Implementation
482 *
483 * Finally, we register the callbacks so that the SysPm driver knows about them.
484 * The order in which the callbacks will be called depends upon the order in
485 * which the callbacks are registered. If there are no callbacks registered,
486 * the device just executes the power mode transition.
487 *
488 * Callbacks that reconfigure global resources, such as clock frequencies, should
489 * be registered last. They then modify global resources as the final step before
490 * entering the low power mode, and restore those resources first, as the system
491 * returns from low power mode.
492 *
493 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_RegisterCallback
494 *
495 * We are done configuring three callbacks. Now the SysPm driver will execute the
496 * callbacks appropriately whenever there is a call to a power mode transition
497 * function: \ref Cy_SysPm_CpuEnterSleep(), \ref Cy_SysPm_CpuEnterDeepSleep(),
498 * \ref Cy_SysPm_SystemEnterUlp(), \ref Cy_SysPm_SystemEnterLp(), and
499 * \ref Cy_SysPm_SystemEnterHibernate().
500 * \note On a wakeup from hibernate the device goes through a reset, so the
501 * callbacks with CY_SYSPM_AFTER_TRANSITION are not executed. Refer to
502 * \ref Cy_SysPm_SystemEnterHibernate() for more detail.
503 *
504 * Refer to \ref group_syspm_cb_unregistering in
505 * \ref group_syspm_cb_config_consideration to learn what to do if you need to
506 * remove the callback from the linked list. You might want to unregister the
507 * callback for debug purposes.
508 *
509 * Refer to \ref group_syspm_cb_flow in \ref group_syspm_cb_config_consideration
510 * to learn about how the SysPm processes the callbacks.
511 *
512 * \subsection group_syspm_cb_config_consideration Callback Configuration Considerations
513 *
514 * \subsubsection group_syspm_cb_parameters Callback Function Parameters
515 *
516 * The <b>callbackParams</b> parameter of the callback function is a
517 * \ref cy_stc_syspm_callback_params_t structure. The second parameter
518 * (<b>mode</b>) is for internal use. In the example code we used a
519 * dummy value CY_SYSPM_CHECK_READY to eliminate compilation errors associated
520 * with the enumeration. The driver sets the <b>mode</b> field to the correct
521 * value when calling the callback functions (the mode is referred to as step in
522 * the \ref group_syspm_cb_function_implementation). The callback function reads
523 * the value and executes code based on the mode set by the SysPm driver.
524 * The <b>base</b> and <b>context</b> fields are optional and can be NULL.
525 * Some drivers require a base hardware address and context to store information
526 * about the mode transition. If your callback routine requires access to the
527 * driver registers or context, provide those values
528 * (see <a href="..\..\pdl_user_guide.pdf">PDL Design</a> section
529 * to learn about Base Hardware Address). Be aware of MISRA warnings if these
530 * parameters are NULL.
531 *
532 * \subsubsection group_syspm_cb_structures Callback Function Structure
533 * For each callback, provide a \ref cy_stc_syspm_callback_t structure. Some
534 * fields in this structure are maintained by the driver. Use NULL for
535 * cy_stc_syspm_callback_t.prevItm and cy_stc_syspm_callback_t.nextItm.
536 * Driver uses these fields to build a linked list of callback functions.
537 * The value of cy_stc_syspm_callback_t.order element is used to define the order
538 * how the callbacks are put into linked list, and sequentially, how the
539 * callbacks are executed. See \ref group_syspm_cb_registering section.
540 *
541 * \warning The Cy_SysPm_RegisterCallback() function stores a pointer to the
542 * cy_stc_syspm_callback_t structure. Do not modify elements of the
543 * cy_stc_syspm_callback_t structure after the callback is registered.
544 * You are responsible for ensuring that the structure remains in scope.
545 * Typically the structure is declared as a global or static variable, or as a
546 * local variable in the main() function.
547 *
548 * \subsubsection group_syspm_cb_function_implementation Callback Function Implementation
549 *
550 * Every callback function should handle four possible steps (referred to as
551 * "mode") defined in \ref cy_en_syspm_callback_mode_t :
552 *    * CY_SYSPM_CHECK_READY - Check if ready to enter a power mode.
553 *    * CY_SYSPM_BEFORE_TRANSITION - The actions to be done before entering
554 *      the low power mode.
555 *    * CY_SYSPM_AFTER_TRANSITION - The actions to be done after exiting the
556 *      low power mode.
557 *    * CY_SYSPM_CHECK_FAIL - Roll back any actions performed in the callback
558 *      executed previously with CY_SYSPM_CHECK_READY.
559 *
560 * A callback function can skip steps (see \ref group_syspm_skip_callback_modes).
561 * In our example myDeepSleep1 and myDeepSleep2 callbacks do nothing while
562 * entering the low power mode (skip on CY_SYSPM_BEFORE_TRANSITION). If there is
563 * anything preventing low power mode entry - return CY_SYSPM_FAIL in response to
564 * CY_SYSPM_CHECK_READY in your callback implementation. Note that the callback
565 * should return CY_SYSPM_FAIL only in response to CY_SYSPM_CHECK_READY. The
566 * callback function should always return CY_SYSPM_PASS for other modes:
567 * CY_SYSPM_CHECK_FAIL, CY_SYSPM_BEFORE_TRANSITION, and CY_SYSPM_AFTER_TRANSITION
568 * (see \ref group_syspm_cb_flow).
569 *
570 * \subsubsection group_syspm_cb_flow Callbacks Execution Flow
571 *
572 * This section explains what happens during a power transition, when callbacks
573 * are implemented and set up correctly. The following discussion assumes:
574 * * All required callback functions are defined and implemented
575 * * All cy_stc_syspm_callback_t structures are filled with required values
576 * * All callbacks are successfully registered
577 *
578 * User calls one of the power mode transition functions: \ref Cy_SysPm_CpuEnterSleep(),
579 * \ref Cy_SysPm_CpuEnterDeepSleep(), \ref Cy_SysPm_SystemEnterUlp(),
580 * \ref Cy_SysPm_SystemEnterLp(), or \ref Cy_SysPm_SystemEnterHibernate().
581 * It calls each callback with the mode set to CY_SYSPM_CHECK_READY. This
582 * triggers execution of the code for that mode inside of each user callback.
583 *
584 * The intent of CY_SYSPM_CHECK_READY is to only signal if the resources is ready
585 * to transition. Ideally, no transition changes should be made at this time.
586 * In some cases a small change may be required. For example a communication
587 * resource callback may set a flag telling firmware not to start any new
588 * transition.
589 
590 * If that process is successful for all callbacks, then
591 * \ref Cy_SysPm_ExecuteCallback() calls each callback with the mode set to
592 * CY_SYSPM_BEFORE_TRANSITION. This triggers execution of the code for that mode
593 * inside each user callback. We then enter the low power mode after all callback
594 * are executed.
595 *
596 * When exiting the low power mode, the SysPm driver executes
597 * \ref Cy_SysPm_ExecuteCallback() again. This time it calls each callback in
598 * reverse order, with the mode set to CY_SYSPM_AFTER_TRANSITION. This triggers
599 * execution of the code for that mode inside each user callback. The final
600 * execution of callbacks depends on the low power mode in which callbacks were
601 * called:
602 * * For CPU Sleep or Deep Sleep power modes, the CY_SYSPM_AFTER_TRANSITION mode
603 *   is called after the CPU wakes from Sleep or Deep Sleep.
604 * * For system Hibernate, the CY_SYSPM_AFTER_TRANSITION mode is not executed
605 *   because the device reboots after the wakeup from the Hibernate.
606 * * For system LP and ULP modes, after the CY_SYSPM_AFTER_TRANSITION mode was
607 *   called the system remains in the new power mode: LP or ULP.
608 *
609 * A callback can return CY_SYSPM_FAIL only while executing the
610 * CY_SYSPM_CHECK_READY mode. If that happens, then the remaining callbacks are
611 * not executed. Any callbacks that have already executed are called again, in
612 * reverse order, with CY_SYSPM_CHECK_FAIL. This allows the system to return to
613 * the previous state. If a callback returns a fail then any of the functions
614 * (\ref Cy_SysPm_CpuEnterSleep(), \ref Cy_SysPm_CpuEnterDeepSleep(),
615 * \ref Cy_SysPm_SystemEnterUlp(), \ref Cy_SysPm_SystemEnterLp(), or
616 * \ref Cy_SysPm_SystemEnterHibernate()) that attempt to switch the device into
617 * a low power mode will also return CY_SYSPM_FAIL.
618 *
619 * Callbacks that reconfigure global resources, such as clock frequencies,
620 * should be registered last. They then modify global resources as the final
621 * step before entering the low power mode, and restore those resources first,
622 * as the system returns from low power mode.
623 *
624 * \subsubsection group_syspm_cb_registering Callback Registering
625 * While registration the callback is put into the linked list. The
626 * place where the callback structure is put into the linked list is based on
627 * cy_stc_syspm_callback_t.order. The callback with the lowest
628 * cy_stc_syspm_callback_t.order value will be placed at the beginning of linked
629 * list. The callback with the highest cy_stc_syspm_callback_t.order value will
630 * be placed at the end of the linked list.
631 * If there is already a callback structure in the linked list with the same
632 * cy_stc_syspm_callback_t.order value as you attend to register, then your
633 * callback will be placed right after such a callback.
634 *
635 * Such a registration order defines how the callbacks are executed:
636 * * Callbacks with the lower cy_stc_syspm_callback_t.order are executed first
637 * when entering into low power and last when exiting from low power.
638 * * Callbacks with the higher cy_stc_syspm_callback_t.order are executed last
639 * when entering into low power and first when exiting from low power.
640 *
641 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_RegisterCallback
642 *
643 * Callbacks with equal cy_stc_syspm_callback_t.order values are
644 * registered in the same order as they are registered:
645 * \image html syspm_register_eq.png
646 
647 * Callbacks with a different cy_stc_syspm_callback_t.order value will be
648 * stored based on the cy_stc_syspm_callback_t.order value, with no matter when
649 * they when registered:
650 *
651 * \image html syspm_register_dif.png
652 *
653 * This can be useful to ensure that system resources (clock dividers, etc) are
654 * changed right before entering low power mode and immediately after exiting
655 * from low power.
656 *
657 * \subsubsection group_syspm_cb_unregistering Callback Unregistering
658 *
659 * Unregistering the callback might be useful when you need to dynamically manage
660 * the callbacks.
661 *
662 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_UnregisterCallback
663 * The callback structures after myDeepSleep2 callback is unregistered:
664 * \image html syspm_unregistration.png
665 *
666 * \section group_syspm_definitions Definitions
667 *
668 * <table class="doxtable">
669 *   <tr>
670 *     <th>Term</th>
671 *     <th>Definition</th>
672 *   </tr>
673 *
674 *   <tr>
675 *     <td>LDO</td>
676 *     <td>Low dropout linear regulator. The functions that manage this
677 *         block are grouped as \ref group_syspm_functions_ldo under
678 *         \ref group_syspm_functions_core_regulators</td>
679 *   </tr>
680 *
681 *   <tr>
682 *     <td>SIMO Buck</td>
683 *     <td>Single inductor multiple Output Buck regulator, referred as
684 *         "Buck regulator" throughout the documentation. The functions that
685 *         manage this block are grouped as \ref group_syspm_functions_buck under
686 *         \ref group_syspm_functions_core_regulators</td>
687 *   </tr>
688 *
689 *   <tr>
690 *     <td>SISO Buck</td>
691 *     <td>Single inductor single output Buck regulator, referred as
692 *         "Buck regulator" throughout the documentation. The functions that
693 *         manage this block are grouped as \ref group_syspm_functions_buck under
694 *         \ref group_syspm_functions_core_regulators</td>
695 *   </tr>
696 
697 *   <tr>
698 *     <td>PMIC</td>
699 *     <td>Power management integrated circuit. The functions that manage this
700 *         block are grouped as \ref group_syspm_functions_pmic</td>
701 *   </tr>
702 *
703 *   <tr>
704 *     <td>LP</td>
705 *     <td>System low power mode. See the \ref group_syspm_switching_into_lp
706 *         section for details.</td>
707 *   </tr>
708 *
709 *   <tr>
710 *     <td>ULP</td>
711 *     <td>System ultra low power mode. See the
712 *         \ref group_syspm_switching_into_ulp section for details.</td>
713 *   </tr>
714 * </table>
715 *
716 * \section group_syspm_section_more_information More Information
717 * For more information on the SysPm driver,
718 * refer to the technical reference manual (TRM).
719 *
720 * \section group_syspm_changelog Changelog
721 * <table class="doxtable">
722 *   <tr><th>Version</th><th>Changes</th><th>Reason for Change</th></tr>
723 *   <tr>
724 *     <td rowspan="2">5.60</td>
725 *     <td>
726 *         For PSoC64 device, allow CM0+ to call CY_PRA_FUNCTION_CALL_X_X API in functions
727 *         accessing FUNCTION_POLICY registers. So that System Configuration structure is
728 *         updated with new parameters.
729 *     </td>
730 *     <td>For PSoC64 device, System configuration can be done from CM0+ application.</td>
731 *   </tr>
732 *   <tr>
733 *     <td>Fixed MISRA 2012 violations.</td>
734 *     <td>MISRA 2012 compliance.</td>
735 *   </tr>
736 *   <tr>
737 *     <td>5.50</td>
738 *     <td>
739 *           Added following functions for SRAM power mode configuration:
740 *           \ref Cy_SysPm_SetSRAMMacroPwrMode(), \ref Cy_SysPm_SetSRAMPwrMode(),
741 *           \ref Cy_SysPm_GetSRAMMacroPwrMode(). For PSoC 64 devices these
742 *           functions can return PRA driver status value.
743 *     </td>
744 *     <td>Added support for SRAM power mode configuration.</td>
745 *   </tr>
746 *   <tr>
747 *     <td>5.40</td>
748 *     <td>Support for CM33.</td>
749 *     <td>New devices support.</td>
750 *   </tr>
751 *   <tr>
752 *     <td rowspan="3">5.30</td>
753 *     <td>
754 *           Updated \ref Cy_SysPm_LdoSetVoltage() and Cy_SysPm_SystemSetMinRegulatorCurrent()
755 *           to extend the wakeup delay from Deep Sleep for 1.1 V LDO for the case when system
756 *           regulator is configured to the minimum current mode. Please refer to
757 *           \ref group_syspm_system_reg_curr_mode for the more details on system regulator modes.
758 *     </td>
759 *     <td>Ensure valid VCCD upon wakeup for the system regulator's minimum current mode.</td>
760 *   </tr>
761 *   <tr>
762 *     <td>Fixed MISRA 2012 violations.</td>
763 *     <td>MISRA 2012 compliance.</td>
764 *   </tr>
765 *   <tr>
766 *     <td>Updated the \ref Cy_SysPm_CpuEnterDeepSleep() function to ensure the Low-power mode
767 *         entry abort when a system call intiated by Cortex-M4 or Cortex-M0+ is pending.</td>
768 *     <td>Fixed the issue when the non-blocking flash write intitated by the Cortex-M4 application
769 *         fails to complete because the Cortex-M0+ CPU is in Deep Sleep mode.</td>
770 *   </tr>
771 *   <tr>
772 *     <td>5.20</td>
773 *     <td>
774 *           Updated \ref Cy_SysPm_CpuEnterDeepSleep() function for
775 *           the CYB06xx7 devices.
776 *     </td>
777 *     <td>Added CYB06xx7 device support.</td>
778 *   </tr>
779 *   <tr>
780 *     <td rowspan="3">5.10</td>
781 *     <td>
782 *           Updated the following functions for the PSoC 64 devices:
783 *           \ref Cy_SysPm_CpuEnterDeepSleep(), \ref Cy_SysPm_SystemEnterLp(),
784 *           \ref Cy_SysPm_SystemEnterUlp, \ref Cy_SysPm_SystemEnterHibernate,
785 *           \ref Cy_SysPm_SetHibernateWakeupSource,
786 *           \ref Cy_SysPm_ClearHibernateWakeupSource,
787 *           \ref Cy_SysPm_SystemSetMinRegulatorCurrent,
788 *           \ref Cy_SysPm_SystemSetNormalRegulatorCurrent,
789 *           \ref Cy_SysPm_LdoSetVoltage, \ref Cy_SysPm_LdoSetMode,
790 *           \ref Cy_SysPm_BuckEnable, \ref Cy_SysPm_BuckSetVoltage1,
791 *           Following functions are updated as unavailble for PSoC 64 devices:
792 *           \ref Cy_SysPm_WriteVoltageBitForFlash, \ref Cy_SysPm_SaveRegisters,
793 *           \ref Cy_SysPm_RestoreRegisters,
794 *           \ref Cy_SysPm_BuckSetVoltage2, \ref Cy_SysPm_BuckEnableVoltage2,
795 *           \ref Cy_SysPm_BuckDisableVoltage2,
796 *           \ref Cy_SysPm_BuckSetVoltage2HwControl, SetReadMarginTrimUlp,
797 *           SetReadMarginTrimLp, SetWriteAssistTrimUlp, IsVoltageChangePossible.
798 *     </td>
799 *     <td>
800 *           Added PSoC 64 device support.
801 *     </td>
802 *   </tr>
803 *   <tr>
804 *     <td>
805 *           For PSoC 64 devices the following functions can return PRA driver
806 *           status value:
807 *           \ref Cy_SysPm_CpuEnterDeepSleep(),
808 *           \ref Cy_SysPm_SystemEnterHibernate(),
809 *           \ref Cy_SysPm_SystemEnterLp(),
810 *           \ref Cy_SysPm_SystemEnterUlp(),
811 *           \ref Cy_SysPm_SystemSetMinRegulatorCurrent(),
812 *           \ref Cy_SysPm_SystemSetNormalRegulatorCurrent(),
813 *           \ref Cy_SysPm_LdoSetVoltage(), \ref Cy_SysPm_LdoSetMode(),
814 *           \ref Cy_SysPm_BuckEnable(), \ref Cy_SysPm_BuckSetVoltage1(),
815 *     </td>
816 *     <td>
817 *           For PSoC 64 devices the SysPm driver uses the PRA driver to change
818 *           the protected registers. A SysPm driver function that calls a PRA
819 *           driver function will return the PRA error status code if the called
820 *           PRA function returns an error. In these cases, refer to PRA return
821 *           statuses \ref cy_en_pra_status_t.
822 *     </td>
823 *   </tr>
824 *   <tr>
825 *     <td>Minor documentation updates.</td>
826 *     <td>Documentation enhancement.</td>
827 *   </tr>
828 *   <tr>
829 *     <td>5.0</td>
830 *     <td>
831 *           Updated the internal IsVoltageChangePossible() function
832 *           (\ref Cy_SysPm_LdoSetVoltage(), \ref Cy_SysPm_BuckEnable(),
833 *           \ref Cy_SysPm_BuckSetVoltage1(), \ref Cy_SysPm_SystemEnterUlp()
834 *           and \ref Cy_SysPm_SystemEnterLp() functions are affected).
835 *           For all the devices except CY8C6xx6 and CY8C6xx7 added the check if
836 *           modifying the RAM trim register is allowed.
837 *     </td>
838 *     <td>
839 *           Protecting the system from a possible CPU hard-fault cause. If you
840 *           are using PC > 0 in your project and you want to switch the power
841 *           modes (LP<->ULP), you need to unprotect the CPUSS_TRIM_RAM_CTL and
842 *           CPUSS_TRIM_ROM_CTL registers and can use a programmable PPU for that.
843 *     </td>
844 *   </tr>
845 *   <tr>
846 *     <td rowspan="2">4.50</td>
847 *     <td>Updated the \ref Cy_SysPm_CpuEnterDeepSleep() function.</td>
848 *     <td>
849 *           Updated the mechanism for saving/restoring not retained UDB and clock
850 *           registers in the Cy_SysPm_CpuEnterDeepSleep() function.
851 *     </td>
852 *   </tr>
853 *   <tr>
854 *     <td>
855 *           Updated the \ref Cy_SysPm_CpuEnterDeepSleep() function to use values
856 *           stored into the variable instead of reading them directly from
857 *           SFLASH memory.
858 *     </td>
859 *     <td>
860 *           SFLASH memory can be unavailable to read the correct value after
861 *           a Deep sleep state on the CY8C6xx6 and CY8C6xx7 devices.
862 *     </td>
863 *   </tr>
864 *   <tr>
865 *     <td>4.40</td>
866 *     <td>
867 *           Fixed \ref Cy_SysPm_LdoSetVoltage(), \ref Cy_SysPm_BuckEnable(), and
868 *           \ref Cy_SysPm_BuckSetVoltage1() functions. Corrected the sequence for
869 *           setting the RAM trim value. This behavior is applicable for all
870 *           devices, except CY8C6xx6 and CY8C6xx7.
871 *     </td>
872 *     <td>
873 *           For all devices, except CY8C6xx6 and CY8C6xx7, the trim
874 *           sequence was setting incorrect trim values for RAM.
875 *           This could cause a CPU hard fault.
876 *     </td>
877 *   </tr>
878 *   <tr>
879 *     <td>4.30</td>
880 *     <td>
881 *           Corrected the \ref Cy_SysPm_CpuEnterDeepSleep() function.
882 *           Removed early access to flash values after system Deep Sleep, when
883 *           flash is not ready to be used. Now the \ref Cy_SysPm_CpuEnterDeepSleep()
884 *           function does not access flash until the flash is ready.
885 *           This behavior is applicable only on multi-CPU devices CY8C6xx6 and
886 *           CY8C6xx7.
887 *     </td>
888 *     <td>
889 *           For CY8C6xx6 and CY8C6xx7 early access to flash values after
890 *           system Deep Sleep could potentially cause hard fault.
891 *           Now after system Deep Sleep only ram values are used before
892 *           flash is ready.
893 *     </td>
894 *   </tr>
895 *   <tr>
896 *     <td rowspan="3">4.20</td>
897 *     <td>Updated the \ref Cy_SysPm_RegisterCallback() function.
898 *         Added a new element to callback structure -
899 *         cy_stc_syspm_callback_t.order</td>
900 *     <td>Enhanced the mechanism of callbacks registration and execution. Now
901 *         callbacks can be ordered during registration. This means the
902 *         execution flow now is based on cy_stc_syspm_callback_t.order.
903 *         For more details, see the \ref group_syspm_cb_registering section. </td>
904 *   </tr>
905 *   <tr>
906 *     <td>Updated \ref group_syspm_cb section.
907 *         Added \ref group_syspm_cb_registering section</td>
908 *     <td>Added explanations how to use updated callbacks registration
909 *         mechanism. </td>
910 *   </tr>
911 *   <tr>
912 *     <td>Added new function  \ref Cy_SysPm_GetFailedCallback()</td>
913 *     <td>Added new functionality to support callback debugging</td>
914 *   </tr>
915 *   <tr>
916 *     <td>4.10.1</td>
917 *     <td>
918 *           Updated the Cy_SysPm_BackupEnableVoltageMeasurement() description
919 *     </td>
920 *     <td>
921 *           Changed the scale number from 40% to 10% to correctly reflect a real value.
922 *     </td>
923 *   </tr>
924 *   <tr>
925 *     <td rowspan="3">4.10</td>
926 *     <td>Updated the \ref Cy_SysPm_CpuEnterDeepSleep() function.</td>
927 *     <td>
928 *         Corrected the mechanism for saving/restoring not retained UDB
929 *         registers in the Cy_SysPm_CpuEnterDeepSleep() function.
930 *
931 *         Now, the \ref Cy_SysPm_CpuEnterDeepSleep() function does not put CM0+ CPU
932 *         into Deep Sleep and returns \ref CY_SYSPM_SYSCALL_PENDING status, if a
933 *         syscall operation is pending. This behavior is applicable on multi-CPU
934 *         devices except CY8C6xx6 and CY8C6xx7.
935 *     </td>
936 *   </tr>
937 *   <tr>
938 *     <td>Updated the \ref Cy_SysPm_CpuEnterSleep() function.</td>
939 *     <td>Removed the redundant second call of the WFE() instruction on CM4 CPU.
940 *         This change is applicable for all devices except CY8C6xx6,
941 *         CY8C6xx7.
942 *    </td>
943 *   </tr>
944 *   <tr>
945 *     <td>Added a new \ref CY_SYSPM_SYSCALL_PENDING return status. </td>
946 *     <td>Expanded driver return statuses for indicating new possible events in
947 *         the driver.
948 *     </td>
949 *   </tr>
950 *   </tr>
951 *   <tr>
952 *     <td rowspan="6">4.0</td>
953 *     <td>
954 *          Flattened the organization of the driver source code into the single
955 *          source directory and the single include directory.
956 *     </td>
957 *     <td>Driver library directory-structure simplification.</td>
958 *   </tr>
959 *   <tr>
960 *     <td>
961 *          Changed power modes names. See \ref group_syspm_system_power_modes.
962 *
963 *          Renamed the following functions:
964 *           - Cy_SysPm_Sleep to Cy_SysPm_CpuEnterSleep
965 *           - Cy_SysPm_DeepSleep to Cy_SysPm_CpuEnterDeepSleep
966 *           - Cy_SysPm_Hibernate to Cy_SysPm_SystemEnterHibernate
967 *           - Cy_SysPm_SleepOnExit to Cy_SysPm_CpuSleepOnExit
968 *           - Cy_SysPm_EnterLowPowerMode to Cy_SysPm_SystemSetMinRegulatorCurrent
969 *           - Cy_SysPm_ExitLowPowerMode to Cy_SysPm_SystemSetNormalRegulatorCurrent
970 *           - Cy_SysPm_IsLowPower to Cy_SysPm_IsSystemUlp
971 *
972 *          For all renamed functions, added BWC macros to simplify migration.
973 *     </td>
974 *     <td>Device power modes simplification</td>
975 *   </tr>
976 *   <tr>
977 *     <td>
978 *         Added the following functions:
979 *          - Cy_SysPm_LdoSetMode
980 *          - Cy_SysPm_LdoGetMode
981 *          - Cy_SysPm_WriteVoltageBitForFlash
982 *          - Cy_SysPm_SaveRegisters
983 *          - Cy_SysPm_RestoreRegisters
984 *          - Cy_SysPm_CpuSendWakeupEvent
985 *          - Cy_SysPm_SystemIsMinRegulatorCurrentSet
986 *          - Cy_SysPm_SystemEnterLp
987 *          - Cy_SysPm_SystemEnterUlp
988 *          - Cy_SysPm_IsSystemLp
989 *     </td>
990 *     <td>Added new functionality to configure device power modes</td>
991 *   </tr>
992 *   <tr>
993 *     <td>
994 *          Callback mechanism changes:
995 *          - Removed the limitation for numbers of registered callbacks. Previously it
996 *            was possible to register up to 32 callbacks. Now the maximum registered
997 *            callbacks is not limited by the SysPm driver.
998 *          - Internal enhancement in callback execution flow.
999 *          - <b>Changes with BWC issues</b>:
1000 *            -# Removed the <b>mode</b> element from cy_stc_syspm_callback_params_t
1001 *               structure. Now this element is a separate parameter in the
1002 *               callback function.
1003 *            -# Changed the interface of the callback function,
1004 *               added the cy_en_syspm_callback_mode_t mode parameter:
1005 *               - was cy_en_syspm_status_t FuncName (cy_stc_syspm_callback_params_t *callbackParams);
1006 *               - now cy_en_syspm_status_t FuncName (cy_stc_syspm_callback_params_t *callbackParams,
1007 *                 cy_en_syspm_callback_mode_t mode);
1008 *     </td>
1009 *     <td>Callback mechanism enhancements</td>
1010 *   </tr>
1011 *   <tr>
1012 *     <td>Added register access layer. Use register access macros instead
1013 *         of direct register access using dereferenced pointers.</td>
1014 *     <td>Makes register access device-independent, so that the PDL does
1015 *         not need to be recompiled for each supported part number.</td>
1016 *   </tr>
1017 *   <tr>
1018 *     <td>Added \ref group_syspm_migration_guide_for_syspm_4_0.</td>
1019 *     <td>Provided a guidance for migrating to the latest SysPm driver version</td>
1020 *   </tr>
1021 *   <tr>
1022 *     <td rowspan="2">3.0</td>
1023 *     <td>Removed three functions:
1024 *          - Cy_SysPm_Cm4IsLowPower
1025 *          - Cy_SysPm_Cm0IsLowPower
1026 *          - Cy_SysPm_IoFreeze
1027 *
1028 *         Removed the following macros:
1029 *          - CY_SYSPM_STATUS_CM0_LOWPOWER
1030 *          - CY_SYSPM_STATUS_CM4_LOWPOWER
1031 *     </td>
1032 *     <td>
1033 *         Removed the two functions Cy_SysPm_Cm4IsLowPower,
1034 *         Cy_SysPm_Cm0IsLowPower because low power mode is related to the
1035 *         device and not to the CPU.
1036 *         The function Cy_SysPm_IsSystemUlp must be used instead of these two
1037 *         functions.
1038 *
1039 *         Removed Cy_SysPm_IoFreeze because the are no known use cases with IOs
1040 *         freeze in power modes, except Hibernate. In Hibernate power mode, the
1041 *         IOs are frozen automatically.
1042 *     </td>
1043 *   </tr>
1044 *   <tr>
1045 *     <td>
1046 *         Corrected the syspm callback mechanism behavior. Now callbacks with
1047 *         CY_SYSPM_AFTER_TRANSITION mode are executed from the last registered
1048 *         to the first registered. Previously callbacks with
1049 *         CY_SYSPM_AFTER_TRANSITION mode were executed from last executed to
1050 *         the first registered.
1051 *     </td>
1052 *     <td>Corrected the syspm callbacks execution sequence</td>
1053 *   </tr>
1054 *   <tr>
1055 *     <td>2.21</td>
1056 *     <td>Removed saving/restoring the SysClk measurement counters while
1057 *         in Deep Sleep routine
1058 *     </td>
1059 *     <td>Removed possible corruption of SysClk measurement counters if the
1060 *         core wakes up from the Deep Sleep.
1061 *     </td>
1062 *   </tr>
1063 *   <tr>
1064 *     <td>2.20</td>
1065 *     <td> \n
1066 *          * Added support for changing core voltage when the protection context
1067 *            is other that zero. Such support is available only for devices
1068 *            that support modifying registers via syscall.
1069 *
1070 *          * For preproduction PSoC 6 devices the changing core voltage
1071 *            is prohibited when the protection context is other than zero.
1072 *
1073 *          * Updated the following functions. They now have a
1074 *            \ref cy_en_syspm_status_t return value and use a syscall:
1075 *            - Cy_SysPm_LdoSetVoltage
1076 *            - Cy_SysPm_BuckSetVoltage1
1077 *            - Cy_SysPm_BuckEnable
1078 *
1079 *            No backward compatibility issues.
1080 *
1081 *          * Added new CY_SYSPM_CANCELED element in
1082 *            the \ref cy_en_syspm_status_t.
1083 *
1084 *          * Documentation updates.
1085 *
1086 *          * Added warning that
1087 *            Cy_SysPm_PmicDisable(CY_SYSPM_PMIC_POLARITY_LOW) is not
1088 *            supported by hardware.
1089 *     </td>
1090 *     <td>Added support for changing the core voltage in protection context
1091 *         higher than zero (PC > 0).
1092 *
1093 *         Documentation update and clarification
1094 *     </td>
1095 *   </tr>
1096 *   <tr>
1097 *     <td>2.10</td>
1098 *     <td> \n
1099 *          * Changed names for all Backup, Buck-related functions, defines,
1100 *            and enums
1101 *          * Changed next power mode function names:
1102 *            Cy_SysPm_EnterLowPowerMode
1103 *            Cy_SysPm_ExitLpMode
1104 *            Cy_SysPm_SetHibWakeupSource
1105 *            Cy_SysPm_ClearHibWakeupSource
1106 *            Cy_SysPm_GetIoFreezeStatus
1107 *          * Changed following enumeration names:
1108 *            cy_en_syspm_hib_wakeup_source_t
1109 *            cy_en_syspm_simo_buck_voltage1_t
1110 *            cy_en_syspm_simo_buck_voltage2_t
1111 *          * Updated Power Modes documentation section
1112 *          * Added Low Power Callback Managements section
1113 *          * Documentation edits
1114 *     </td>
1115 *     <td> \n
1116 *          * Improvements made based on usability feedback
1117 *          * Documentation update and clarification
1118 *     </td>
1119 *   </tr>
1120 *   <tr>
1121 *     <td>2.0</td>
1122 *     <td>Enhancement and defect fixes:
1123 *         * Added input parameter(s) validation to all public functions
1124 *         * Removed "_SysPm_" prefixes from the internal functions names
1125 *         * Changed the type of elements with limited set of values, from
1126 *           uint32_t to enumeration
1127 *         * Enhanced syspm callback mechanism
1128 *         * Added functions to control:
1129 *           * Power supply for the Vddbackup
1130 *           * Supercapacitor charge
1131 *           * Vddbackup measurement by ADC
1132 *     </td>
1133 *     <td></td>
1134 *   </tr>
1135 *   <tr>
1136 *     <td>1.0</td>
1137 *     <td>Initial version</td>
1138 *     <td></td>
1139 *   </tr>
1140 * </table>
1141 *
1142 * \subsection group_syspm_migration_guide_for_syspm_4_0 Migration Guide: Moving to SysPm v4.0
1143 *
1144 * This section provides a guideline to migrate from v2.21 to v4.0 of the SysPm
1145 * driver.
1146 *
1147 * \subsubsection group_syspm_migration_into_4_0_intro Introduction
1148 *
1149 * If your application currently uses SysPm v2.21 APIs, you must
1150 * migrate to SysPm v4.0 so that your application continues to operate.
1151 *
1152 * Take a few minutes to review the following information:
1153 * - The APIs related to PSoC 6 \ref group_syspm_power_modes are changed. Old
1154 *   power modes APIs function names are now deprecated and should not be used
1155 *   in new applications.
1156 * - The \ref group_syspm_cb mechanism is changed. The mode element is removed
1157 *   from cy_stc_syspm_callback_params_t structure. Now this element is a
1158 *   separate parameter in the callback function.
1159 *
1160 * \subsubsection group_syspm_migration_into_4_0_names Migrating to new power modes APIs.
1161 * The table below shows the new APIs names that should be used in the
1162 * application instead of old names:
1163 *
1164 * <table class="doxtable">
1165 *   <tr><th>SysPm v2.21 API name</th><th>SysPm v4.0 API name</th><th>Comment</th></tr>
1166 *   <tr>
1167 *     <td>Cy_SysPm_Sleep</td>
1168 *     <td>\ref Cy_SysPm_CpuEnterSleep</td>
1169 *     <td>Renamed, no functional changes</td>
1170 *   </tr>
1171 *   <tr>
1172 *     <td>Cy_SysPm_DeepSleep</td>
1173 *     <td>\ref Cy_SysPm_CpuEnterDeepSleep</td>
1174 *     <td>Renamed, no functional changes</td>
1175 *   </tr>
1176 *   <tr>
1177 *     <td>Cy_SysPm_Hibernate</td>
1178 *     <td>\ref Cy_SysPm_SystemEnterHibernate</td>
1179 *     <td>Renamed, no functional changes</td>
1180 *   </tr>
1181 *   <tr>
1182 *     <td>Cy_SysPm_SleepOnExit</td>
1183 *     <td>\ref Cy_SysPm_CpuSleepOnExit</td>
1184 *     <td>Renamed, no functional changes</td>
1185 *   </tr>
1186 *   <tr>
1187 *     <td>Cy_SysPm_IsLowPower</td>
1188 *     <td>\ref Cy_SysPm_IsSystemUlp</td>
1189 *     <td>Now this function checks whether the device is in ULP mode</td>
1190 *   </tr>
1191 *   <tr>
1192 *     <td>Cy_SysPm_EnterLowPowerMode</td>
1193 *     <td>\ref Cy_SysPm_SystemSetMinRegulatorCurrent</td>
1194 *     <td>The low power active mode does not exist anymore.
1195 *         The \ref group_syspm_system_reg_curr_mode is implemented instead </td>
1196 *     </tr>
1197 *   <tr>
1198 *     <td>Cy_SysPm_ExitLowPowerMode</td>
1199 *     <td>\ref Cy_SysPm_SystemSetNormalRegulatorCurrent</td>
1200 *     <td>The low power active mode does not exist anymore.
1201 *         The \ref group_syspm_system_reg_curr_mode is implemented instead</td>
1202 *   </tr>
1203 *   <tr>
1204 *     <td>Cy_SysPm_Cm4IsLowPower</td>
1205 *     <td>Removed</td>
1206 *     <td>This function is removed because low power mode is related to the system
1207 *         and not to the CPU</td>
1208 *   </tr>
1209 *   <tr>
1210 *     <td>Cy_SysPm_Cm0IsLowPower</td>
1211 *     <td>Removed</td>
1212 *     <td>This function is removed because low power mode is related to the system
1213 *         and not to the CPU</td>
1214 *   </tr>
1215 *   <tr>
1216 *     <td>Cy_SysPm_IoFreeze</td>
1217 *     <td>Removed</td>
1218 *     <td>This function is removed because there are no known use cases to
1219 *         freeze in power modes other than Hibernate</td>
1220 *   </tr>
1221 * </table>
1222 *
1223 * In addition to renamed power modes APIs, the following defines and enum
1224 * elements names are changed:
1225 * <table class="doxtable">
1226 *   <tr><th>SysPm v2.21 defines</th><th>SysPm v4.0 defines</th><th>Comment</th></tr>
1227 *   <tr>
1228 *     <td>CY_SYSPM_ENTER_LP_MODE</td>
1229 *     <td>CY_SYSPM_ULP</td>
1230 *     <td>The \ref cy_en_syspm_callback_type_t element is renamed to align
1231 *         callback types names to new power modes names</td>
1232 *   </tr>
1233 *   <tr>
1234 *     <td>CY_SYSPM_EXIT_LP_MODE</td>
1235 *     <td>CY_SYSPM_LP</td>
1236 *     <td>The \ref cy_en_syspm_callback_type_t element is renamed to align
1237 *         callback types names to new power modes names</td>
1238 *   <tr>
1239 *     <td>CY_SYSPM_STATUS_SYSTEM_LOWPOWER</td>
1240 *     <td>CY_SYSPM_STATUS_SYSTEM_ULP</td>
1241 *     <td>Status define, renamed to align new power modes names
1242 *         and abbreviations</td>
1243 *   </tr>
1244 * </table>
1245 *
1246 * \subsubsection group_syspm_migration_into_4_0_callbacks Migrating to SysPm v4.0 callbacks
1247 *
1248 * Review this section if your application is using the syspm callback mechanism.
1249 *
1250 * To migrate to SysPm v4.0 callbacks you need to perform the following steps:
1251 * -# Remove mode element from all \ref cy_stc_syspm_callback_params_t
1252 *    structures defined in your application. In SysPm v2.21 this structure is:
1253 *    \code{.c}
1254 *    cy_stc_syspm_callback_params_t deepSleepParam1 =
1255 *    {
1256 *        CY_SYSPM_CHECK_READY,
1257 *        &HW1_address,
1258 *        &context
1259 *    };
1260 *    \endcode
1261 *
1262 *    In SysPm v4.0 this structure should be:
1263 *    \code{.c}
1264 *    cy_stc_syspm_callback_params_t deepSleepParam1 =
1265 *    {
1266 *        &HW1_address,
1267 *        &context
1268 *    };
1269 *    \endcode
1270 * -# Update all defined syspm callback function prototypes to have two
1271 *    parameters instead of one. The SysPm v2.21 callback function prototype is:
1272 *    \code{.c}
1273 *    cy_en_syspm_status_t Func1 (cy_stc_syspm_callback_params_t *callbackParams);
1274 *    \endcode
1275 *    The SysPm v4.0 callback function prototype should be:
1276 *    \code{.c}
1277 *    cy_en_syspm_status_t Func1 (cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode);
1278 *    \endcode
1279 * -# Change the syspm callback function implementation to not use a mode
1280 *    value as an element of the callbackParams structure, but, as separate
1281 *    function parameter:
1282 *    SysPm v2.21 callback function implementation:
1283 *    \code{.c}
1284 *    cy_en_syspm_status_t Func1(cy_stc_syspm_callback_params_t *callbackParams)
1285 *    {
1286 *        cy_en_syspm_status_t retVal = CY_SYSPM_FAIL;
1287 *
1288 *        switch(callbackParams->mode)
1289 *        {
1290 *            case CY_SYSPM_CHECK_READY:
1291 *            ...
1292 *        }
1293 *
1294 *        return (retVal);
1295 *    }
1296 *    \endcode
1297 *    SysPm v4.0 callback function implementation:
1298 *    \code{.c}
1299 *    cy_en_syspm_status_t Func1(cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode)
1300 *    {
1301 *        cy_en_syspm_status_t retVal = CY_SYSPM_FAIL;
1302 *
1303 *        switch(mode)
1304 *        {
1305 *            case CY_SYSPM_CHECK_READY:
1306 *            ...
1307 *        }
1308 *
1309 *        return (retVal);
1310 *    }
1311 *    \endcode
1312 * After the changes above are done, you have successfully migrated to SysPm v4.0.
1313 *
1314 * Do not forget to review newly added functionality for SysPm v4.0 in the
1315 * \ref group_syspm_changelog.
1316 
1317 * \defgroup group_syspm_macros Macros
1318 * \defgroup group_syspm_functions Functions
1319 * \{
1320     \defgroup group_syspm_functions_general        General
1321 *   \defgroup group_syspm_functions_power          Power Modes
1322 *   \defgroup group_syspm_functions_power_status   Power Status
1323 *   \defgroup group_syspm_functions_iofreeze       I/Os Freeze
1324 *   \defgroup group_syspm_functions_core_regulators    Core Voltage Regulation
1325 *   \{
1326 *     \defgroup group_syspm_functions_ldo      LDO
1327 *     \defgroup group_syspm_functions_buck     Buck
1328 *   \}
1329 *   \defgroup group_syspm_functions_pmic       PMIC
1330 *   \defgroup group_syspm_functions_backup     Backup Domain
1331 *   \defgroup group_syspm_functions_callback   Low Power Callbacks
1332 * \}
1333 * \defgroup group_syspm_data_structures Data Structures
1334 * \defgroup group_syspm_data_enumerates Enumerated Types
1335 */
1336 
1337 #if !defined (CY_SYSPM_H)
1338 #define CY_SYSPM_H
1339 
1340 #include "cy_device.h"
1341 
1342 #if defined (CY_IP_MXS28SRSS) || defined (CY_IP_MXS40SRSS) || defined (CY_IP_MXS40SSRSS)
1343 
1344 #include <stdbool.h>
1345 #include <stddef.h>
1346 
1347 #include "cy_device.h"
1348 #include "cy_device_headers.h"
1349 #include "cy_syslib.h"
1350 
1351 #if ((CY_CPU_CORTEX_M4) && (defined (CY_DEVICE_SECURE)))
1352     #include "cy_pra.h"
1353 #endif /* #if ((CY_CPU_CORTEX_M4) && (defined (CY_DEVICE_SECURE))) */
1354 
1355 #ifdef __cplusplus
1356 extern "C" {
1357 #endif
1358 
1359 /*******************************************************************************
1360 *       Register Constants
1361 *******************************************************************************/
1362 
1363 /**
1364 * \addtogroup group_syspm_macros
1365 * \{
1366 */
1367 
1368 /** Driver major version */
1369 #define CY_SYSPM_DRV_VERSION_MAJOR       5
1370 
1371 /** Driver minor version */
1372 #define CY_SYSPM_DRV_VERSION_MINOR       50
1373 
1374 /** SysPm driver identifier */
1375 #define CY_SYSPM_ID                      (CY_PDL_DRV_ID(0x10U))
1376 
1377 
1378 /*******************************************************************************
1379 *       Internal Defines
1380 *******************************************************************************/
1381 
1382 /** \cond INTERNAL */
1383 
1384 /* Macro to validate parameters in Cy_SysPm_SetHibernateWakeupSource() and for Cy_SysPm_ClearHibernateWakeupSource() function */
1385 #define CY_SYSPM_IS_WAKE_UP_SOURCE_VALID(wakeupSource)   (0UL == ((wakeupSource) & \
1386                                                          ((uint32_t) ~(CY_SYSPM_HIB_WAKEUP_SOURSE_MASK))))
1387 
1388 /* Macro to validate parameters in Cy_SysPm_PmicDisable() function */
1389 #define CY_SYSPM_IS_POLARITY_VALID(polarity)            (((polarity) == CY_SYSPM_PMIC_POLARITY_LOW) || \
1390                                                          ((polarity) == CY_SYSPM_PMIC_POLARITY_HIGH))
1391 
1392 /* Macro to validate parameters in Cy_SysPm_BuckSetVoltage1() function */
1393 #define CY_SYSPM_IS_BUCK_VOLTAGE1_VALID(voltage)        (((voltage) == CY_SYSPM_BUCK_OUT1_VOLTAGE_0_9V) || \
1394                                                          ((voltage) == CY_SYSPM_BUCK_OUT1_VOLTAGE_1_1V))
1395 
1396 /* Macro to validate parameters in Cy_SysPm_BuckSetVoltage2() function */
1397 #define CY_SYSPM_IS_BUCK_VOLTAGE2_VALID(voltage)        (((voltage) == CY_SYSPM_BUCK_OUT2_VOLTAGE_1_15V) || \
1398                                                          ((voltage) == CY_SYSPM_BUCK_OUT2_VOLTAGE_1_2V)  || \
1399                                                          ((voltage) == CY_SYSPM_BUCK_OUT2_VOLTAGE_1_25V) || \
1400                                                          ((voltage) == CY_SYSPM_BUCK_OUT2_VOLTAGE_1_3V)  || \
1401                                                          ((voltage) == CY_SYSPM_BUCK_OUT2_VOLTAGE_1_35V) || \
1402                                                          ((voltage) == CY_SYSPM_BUCK_OUT2_VOLTAGE_1_4V)  || \
1403                                                          ((voltage) == CY_SYSPM_BUCK_OUT2_VOLTAGE_1_45V) || \
1404                                                          ((voltage) == CY_SYSPM_BUCK_OUT2_VOLTAGE_1_5V))
1405 
1406 /* Macro to validate parameters in Cy_SysPm_BuckIsOutputEnabled() function */
1407 #define CY_SYSPM_IS_BUCK_OUTPUT_VALID(output)           (((output) == CY_SYSPM_BUCK_VBUCK_1) || \
1408                                                          ((output) == CY_SYSPM_BUCK_VRF))
1409 
1410 /* Macro to validate parameters in Cy_SysPm_LdoSetVoltage() function */
1411 #define CY_SYSPM_IS_LDO_VOLTAGE_VALID(voltage)          (((voltage) == CY_SYSPM_LDO_VOLTAGE_0_9V) || \
1412                                                          ((voltage) == CY_SYSPM_LDO_VOLTAGE_1_1V))
1413 
1414 /* Macro to validate parameters in Cy_SysPm_ExecuteCallback() function */
1415 #define CY_SYSPM_IS_CALLBACK_TYPE_VALID(type)           (((type) == CY_SYSPM_SLEEP) || \
1416                                                          ((type) == CY_SYSPM_DEEPSLEEP) || \
1417                                                          ((type) == CY_SYSPM_HIBERNATE) || \
1418                                                          ((type) == CY_SYSPM_ULP) || \
1419                                                          ((type) == CY_SYSPM_LP))
1420 
1421 /* Macro to validate parameters in Cy_SysPm_ExecuteCallback() function */
1422 #define CY_SYSPM_IS_CALLBACK_MODE_VALID(mode)           (((mode) == CY_SYSPM_CHECK_READY) || \
1423                                                          ((mode) == CY_SYSPM_CHECK_FAIL) || \
1424                                                          ((mode) == CY_SYSPM_BEFORE_TRANSITION) || \
1425                                                          ((mode) == CY_SYSPM_AFTER_TRANSITION))
1426 
1427 /* Macro to validate parameters in Cy_SysPm_CpuEnterSleep() and for Cy_SysPm_CpuEnterDeepSleep() function */
1428 #define CY_SYSPM_IS_WAIT_FOR_VALID(waitFor)             (((waitFor) == CY_SYSPM_WAIT_FOR_INTERRUPT) || \
1429                                                          ((waitFor) == CY_SYSPM_WAIT_FOR_EVENT))
1430 
1431 /* Macro to validate parameters in Cy_SysPm_BackupSetSupply() function */
1432 #define CY_SYSPM_IS_VDDBACKUP_VALID(vddBackControl)      (((vddBackControl) == CY_SYSPM_VDDBACKUP_DEFAULT) || \
1433                                                           ((vddBackControl) == CY_SYSPM_VDDBACKUP_VBACKUP))
1434 
1435 /* Macro to validate parameters in Cy_SysPm_BackupSuperCapCharge() function */
1436 #define CY_SYSPM_IS_SC_CHARGE_KEY_VALID(key)            (((key) == CY_SYSPM_SC_CHARGE_ENABLE) || \
1437                                                          ((key) == CY_SYSPM_SC_CHARGE_DISABLE))
1438 
1439 /* Macro to validate parameters in Cy_SysPm_LdoSetMode() function */
1440 #define CY_SYSPM_IS_LDO_MODE_VALID(key)            (((mode) == CY_SYSPM_LDO_MODE_DISABLED) || \
1441                                                     ((mode) == CY_SYSPM_LDO_MODE_NORMAL) || \
1442                                                     ((mode) == CY_SYSPM_LDO_MODE_MIN))
1443 
1444 /* Macro to validate parameters in Cy_SysPm_WriteVoltageBitForFlash() function */
1445 #define CY_SYSPM_IS_BIT_FOR_FLASH_VALID(value)     (((value) == CY_SYSPM_FLASH_VOLTAGE_BIT_ULP) || \
1446                                                     ((value) == CY_SYSPM_FLASH_VOLTAGE_BIT_LP))
1447 
1448 /** The internal define of the SRAM PWR MACRO register key for write operation */
1449 #define CY_SYSPM_PWR_MACRO_CTL_WRITE_KEY            (0x05FAU)
1450 
1451 /** The internal define of the unlock value for the PMIC functions */
1452 #define CY_SYSPM_PMIC_UNLOCK_KEY                    (0x3AU)
1453 
1454 /** The internal define of the first wakeup pin bit used in the
1455 * Cy_SysPm_SetHibernateWakeupSource() function
1456 */
1457 #define CY_SYSPM_HIB_WAKEUP_PIN0_POS                (1UL)
1458 
1459 /** The internal define of the second wakeup pin bit
1460 * used in the Cy_SysPm_SetHibernateWakeupSource() function
1461 */
1462 #define CY_SYSPM_HIB_WAKEUP_PIN1_POS                (2UL)
1463 
1464 /**
1465 * The internal define of the first LPComparator bit
1466 * used in the Cy_SysPm_SetHibernateWakeupSource() function
1467 */
1468 #define CY_SYSPM_HIB_WAKEUP_LPCOMP0_POS             (4UL)
1469 
1470 /**
1471 * The internal define for the second LPComparator bit
1472 * used in the Cy_SysPm_SetHibernateWakeupSource() function
1473 */
1474 #define CY_SYSPM_HIB_WAKEUP_LPCOMP1_POS             (8UL)
1475 
1476 /**
1477 * The internal define of the first LPComparator value
1478 * used in the Cy_SysPm_SetHibernateWakeupSource() function
1479 */
1480 #define CY_SYSPM_HIB_WAKEUP_LPCOMP0_MASK    (_VAL2FLD(SRSS_PWR_HIBERNATE_MASK_HIBPIN, CY_SYSPM_HIB_WAKEUP_LPCOMP0_POS))
1481 
1482 /**
1483 * The internal define of the second LPComparator value
1484 * used in the Cy_SysPm_SetHibernateWakeupSource() function
1485 */
1486 #define CY_SYSPM_HIB_WAKEUP_LPCOMP1_MASK    (_VAL2FLD(SRSS_PWR_HIBERNATE_MASK_HIBPIN, CY_SYSPM_HIB_WAKEUP_LPCOMP1_POS))
1487 
1488 /**
1489 * The internal define of the first wake-up pin value
1490 * used in the Cy_SysPm_SetHibernateWakeupSource() function
1491 */
1492 #define CY_SYSPM_HIB_WAKEUP_PIN0_MASK    (_VAL2FLD(SRSS_PWR_HIBERNATE_MASK_HIBPIN, CY_SYSPM_HIB_WAKEUP_PIN0_POS))
1493 
1494 /**
1495 * The internal define of the second wake-up pin value used
1496 * in the Cy_SysPm_SetHibernateWakeupSource() function
1497 */
1498 #define CY_SYSPM_HIB_WAKEUP_PIN1_MASK    (_VAL2FLD(SRSS_PWR_HIBERNATE_MASK_HIBPIN, CY_SYSPM_HIB_WAKEUP_PIN1_POS))
1499 
1500 /** The internal define for the first LPComparator polarity configuration */
1501 #define CY_SYSPM_HIB_WAKEUP_LPCOMP0_POLARITY_HIGH_MASK    \
1502                                   (_VAL2FLD(SRSS_PWR_HIBERNATE_POLARITY_HIBPIN, CY_SYSPM_HIB_WAKEUP_LPCOMP0_POS))
1503 
1504 /** The internal define for the second LPComparator polarity configuration */
1505 #define CY_SYSPM_HIB_WAKEUP_LPCOMP1_POLARITY_HIGH_MASK    \
1506                                   (_VAL2FLD(SRSS_PWR_HIBERNATE_POLARITY_HIBPIN, CY_SYSPM_HIB_WAKEUP_LPCOMP1_POS))
1507 
1508 /** The internal define for the first wake-up pin polarity configuration */
1509 #define CY_SYSPM_HIB_WAKEUP_PIN0_POLARITY_HIGH_MASK    \
1510                                   (_VAL2FLD(SRSS_PWR_HIBERNATE_POLARITY_HIBPIN, CY_SYSPM_HIB_WAKEUP_PIN0_POS))
1511 
1512 /** The internal define for the second wake-up pin polarity configuration */
1513 #define CY_SYSPM_HIB_WAKEUP_PIN1_POLARITY_HIGH_MASK    \
1514                                   (_VAL2FLD(SRSS_PWR_HIBERNATE_POLARITY_HIBPIN, CY_SYSPM_HIB_WAKEUP_PIN1_POS))
1515 
1516 /* Internal macro of all possible wakeup sources from hibernate power mode */
1517 #define CY_SYSPM_HIB_WAKEUP_SOURSE_MASK    (CY_SYSPM_HIBERNATE_LPCOMP0_HIGH | CY_SYSPM_HIBERNATE_LPCOMP1_HIGH |\
1518                                             CY_SYSPM_HIBERNATE_RTC_ALARM    | CY_SYSPM_HIBERNATE_WDT |\
1519                                             CY_SYSPM_HIBERNATE_PIN0_HIGH    | CY_SYSPM_HIBERNATE_PIN1_HIGH)
1520 
1521 /* The mask for low power modes the power circuits (POR/BOD, Bandgap
1522 *  reference, Reference buffer, Current reference) when active core regulator is
1523 *  LDO
1524 */
1525 #define CY_SYSPM_PWR_CIRCUITS_LPMODE_ACTIVE_LDO_MASK    (SRSS_PWR_CTL_LINREG_LPMODE_Msk | CY_SYSPM_PWR_CIRCUITS_LPMODE_ACTIVE_BUCK_MASK)
1526 
1527 /* The mask for low power modes the power circuits (POR/BOD, Bandgap
1528 *  reference, Reference buffer, Current reference) when active core regulator is
1529 *  Buck
1530 */
1531 #define CY_SYSPM_PWR_CIRCUITS_LPMODE_ACTIVE_BUCK_MASK    (SRSS_PWR_CTL_PORBOD_LPMODE_Msk |\
1532                                                           SRSS_PWR_CTL_ACT_REF_DIS_Msk |\
1533                                                           SRSS_PWR_CTL_VREFBUF_LPMODE_Msk |\
1534                                                           SRSS_PWR_CTL_IREF_LPMODE_Msk)
1535 
1536 /** \endcond */
1537 
1538 /**
1539 * \defgroup group_syspm_return_status The Power Mode Status Defines
1540 * \{
1541 * Defines for the CPU and system power modes status.
1542 */
1543 
1544 /** The CM4 is in CPU Active mode */
1545 #define CY_SYSPM_STATUS_CM4_ACTIVE       (0x01U)
1546 
1547 /** The CM4 is in CPU Sleep mode */
1548 #define CY_SYSPM_STATUS_CM4_SLEEP        (0x02U)
1549 
1550 /** The CM4 is in CPU Deep Sleep mode */
1551 #define CY_SYSPM_STATUS_CM4_DEEPSLEEP    (0x04U)
1552 
1553 /** The CM0p is CPU Active mode */
1554 #define CY_SYSPM_STATUS_CM0_ACTIVE       ((uint32_t) 0x01U << 8U)
1555 
1556 /** The CM0p is in CPU Sleep mode */
1557 #define CY_SYSPM_STATUS_CM0_SLEEP        ((uint32_t) 0x02U << 8U)
1558 
1559 /** The CM0p is in CPU Deep Sleep mode */
1560 #define CY_SYSPM_STATUS_CM0_DEEPSLEEP    ((uint32_t) 0x04U << 8U)
1561 
1562 /** The system is Low Power mode */
1563 #define CY_SYSPM_STATUS_SYSTEM_LP        (0x80U)
1564 
1565 /** The system is in Ultra Low Power mode */
1566 #define CY_SYSPM_STATUS_SYSTEM_ULP       ((uint32_t) 0x08U << 8U)
1567 
1568 /** \} group_syspm_return_status */
1569 
1570 /** \} group_syspm_macros */
1571 
1572 /*******************************************************************************
1573 *       Configuration Structures
1574 *******************************************************************************/
1575 
1576 /**
1577 * \addtogroup group_syspm_data_enumerates
1578 * \{
1579 */
1580 
1581 /** The SysPm function return value status definitions. */
1582 typedef enum
1583 {
1584     CY_SYSPM_SUCCESS         = 0x0U,                                         /**< Successful. */
1585     CY_SYSPM_BAD_PARAM       = CY_SYSPM_ID | CY_PDL_STATUS_ERROR | 0x01U,    /**< One or more invalid parameters. */
1586     CY_SYSPM_TIMEOUT         = CY_SYSPM_ID | CY_PDL_STATUS_ERROR | 0x02U,    /**< A time-out occurred. */
1587     CY_SYSPM_INVALID_STATE   = CY_SYSPM_ID | CY_PDL_STATUS_ERROR | 0x03U,    /**< The operation is not setup or is in an
1588                                                                                   improper state. */
1589     CY_SYSPM_CANCELED        = CY_SYSPM_ID | CY_PDL_STATUS_ERROR | 0x04U,    /**< Operation canceled. */
1590     CY_SYSPM_SYSCALL_PENDING = CY_SYSPM_ID | CY_PDL_STATUS_ERROR | 0x05U,    /**< Canceled due syscall operation pending. */
1591     CY_SYSPM_FAIL            = CY_SYSPM_ID | CY_PDL_STATUS_ERROR | 0xFFU     /**< Unknown failure. */
1592 } cy_en_syspm_status_t;
1593 
1594 /**
1595 * This enumeration is used to initialize the functions wait action. The wait actions can be -
1596 * an interrupt or an event. Refer to the CMSIS for WFE and WFI instruction explanations.
1597 */
1598 typedef enum
1599 {
1600     CY_SYSPM_WAIT_FOR_INTERRUPT,    /**< Wait for an interrupt. */
1601     CY_SYSPM_WAIT_FOR_EVENT         /**< Wait for an event. */
1602 } cy_en_syspm_waitfor_t;
1603 
1604 /** This enumeration is used to configure wakeup sources for the System Hibernate
1605 *   power mode.
1606 */
1607 typedef enum
1608 {
1609     /** Wake on a low logic level for the LPComp0. */
1610     CY_SYSPM_HIBERNATE_LPCOMP0_LOW  = CY_SYSPM_HIB_WAKEUP_LPCOMP0_MASK,
1611 
1612     /** Wake on a high logic level for the LPComp0. */
1613     CY_SYSPM_HIBERNATE_LPCOMP0_HIGH = CY_SYSPM_HIB_WAKEUP_LPCOMP0_MASK | CY_SYSPM_HIB_WAKEUP_LPCOMP0_POLARITY_HIGH_MASK,
1614 
1615     /** Wake on a low logic level for the LPComp1. */
1616     CY_SYSPM_HIBERNATE_LPCOMP1_LOW  = CY_SYSPM_HIB_WAKEUP_LPCOMP1_MASK,
1617 
1618     /** Wake on a high logic level for the LPComp1. */
1619     CY_SYSPM_HIBERNATE_LPCOMP1_HIGH = CY_SYSPM_HIB_WAKEUP_LPCOMP1_MASK | CY_SYSPM_HIB_WAKEUP_LPCOMP1_POLARITY_HIGH_MASK,
1620 
1621     /** Configure the RTC alarm as wakeup source. */
1622     CY_SYSPM_HIBERNATE_RTC_ALARM = SRSS_PWR_HIBERNATE_MASK_HIBALARM_Msk,
1623 
1624     /** Configure the WDT interrupt as wakeup source. */
1625     CY_SYSPM_HIBERNATE_WDT = SRSS_PWR_HIBERNATE_MASK_HIBWDT_Msk,
1626 
1627     /** Configure a low logic level for the first wakeup-pin. See device datasheet for specific pin. */
1628     CY_SYSPM_HIBERNATE_PIN0_LOW  = CY_SYSPM_HIB_WAKEUP_PIN0_MASK,
1629 
1630     /** Configure a high logic level for the first wakeup-pin. See device datasheet for specific pin.*/
1631     CY_SYSPM_HIBERNATE_PIN0_HIGH = CY_SYSPM_HIB_WAKEUP_PIN0_MASK | CY_SYSPM_HIB_WAKEUP_PIN0_POLARITY_HIGH_MASK,
1632 
1633     /** Configure a low logic level for the second wakeup-pin. See device datasheet for specific pin.*/
1634     CY_SYSPM_HIBERNATE_PIN1_LOW  = CY_SYSPM_HIB_WAKEUP_PIN1_MASK,
1635 
1636     /** Configure a high logic level for the second wakeup-pin. See device datasheet for specific pin.*/
1637     CY_SYSPM_HIBERNATE_PIN1_HIGH = CY_SYSPM_HIB_WAKEUP_PIN1_MASK | CY_SYSPM_HIB_WAKEUP_PIN1_POLARITY_HIGH_MASK
1638 } cy_en_syspm_hibernate_wakeup_source_t;
1639 
1640 /** This enumeration is used to select LDO regulator output voltage. */
1641 typedef enum
1642 {
1643     CY_SYSPM_LDO_VOLTAGE_ULP  = 0U,    /**< System ULP nominal LDO voltage.
1644                                             See device datasheet for specific voltage. */
1645     CY_SYSPM_LDO_VOLTAGE_LP   = 1U,    /**< System LP nominal LDO voltage.
1646                                             See device datasheet for specific voltage. */
1647     CY_SYSPM_LDO_VOLTAGE_0_9V = 0U,    /**< 0.9 V nominal LDO voltage */
1648     CY_SYSPM_LDO_VOLTAGE_1_1V = 1U     /**< 1.1 V nominal LDO voltage */
1649 } cy_en_syspm_ldo_voltage_t;
1650 
1651 /** This enumeration is used to select the LDO regulator operating mode. */
1652 typedef enum
1653 {
1654     CY_SYSPM_LDO_MODE_DISABLED = 0U,    /**< Disables the LDO. */
1655     CY_SYSPM_LDO_MODE_NORMAL   = 1U,    /**< Sets normal current mode. See device datasheet for
1656                                              specific maximum current limit. */
1657     CY_SYSPM_LDO_MODE_MIN      = 2U     /**< Sets minimum current mode. See device datasheet for
1658                                              specific  current limit.  */
1659 } cy_en_syspm_ldo_mode_t;
1660 
1661 /**
1662 *  This enumeration is used to select the output voltage for the Buck regulator output 1.
1663 */
1664 typedef enum
1665 {
1666     CY_SYSPM_BUCK_OUT1_VOLTAGE_ULP  = 0x02U,    /**< System ULP nominal Buck voltage.
1667                                                      See device datasheet for specific voltage. */
1668     CY_SYSPM_BUCK_OUT1_VOLTAGE_LP   = 0x05U,    /**< LP nominal Buck voltage.
1669                                                      See device datasheet for specific voltage. */
1670     CY_SYSPM_BUCK_OUT1_VOLTAGE_0_9V = 0x02U,    /**< 0.9 V nominal Buck voltage */
1671     CY_SYSPM_BUCK_OUT1_VOLTAGE_1_1V = 0x05U     /**< 1.1 V nominal Buck voltage */
1672 } cy_en_syspm_buck_voltage1_t;
1673 
1674 /** This enumeration is used to select the Buck regulator outputs. */
1675 typedef enum
1676 {
1677     CY_SYSPM_BUCK_VBUCK_1 = 0x0U,    /**< Buck output 1 Voltage (Vbuck1). Typically used to
1678                                           supply the PSoC digital core logic. */
1679     CY_SYSPM_BUCK_VRF                /**< Buck out 2 Voltage (Vbuckrf). Typically used to
1680                                           supply the BLE radio logic. */
1681 } cy_en_syspm_buck_out_t;
1682 
1683 /**
1684 * This enumeration is used to select the output voltage for the Buck regulator
1685 * output 2, which can source the BLE radio.
1686 */
1687 typedef enum
1688 {
1689     CY_SYSPM_BUCK_OUT2_VOLTAGE_1_15V = 0U,    /**< 1.15 V nominal voltage. */
1690     CY_SYSPM_BUCK_OUT2_VOLTAGE_1_2V  = 1U,    /**< 1.20 V nominal voltage. */
1691     CY_SYSPM_BUCK_OUT2_VOLTAGE_1_25V = 2U,    /**< 1.25 V nominal voltage. */
1692     CY_SYSPM_BUCK_OUT2_VOLTAGE_1_3V  = 3U,    /**< 1.3 V nominal voltage.  */
1693     CY_SYSPM_BUCK_OUT2_VOLTAGE_1_35V = 4U,    /**< 1.35 V nominal voltage. */
1694     CY_SYSPM_BUCK_OUT2_VOLTAGE_1_4V  = 5U,    /**< 1.4 V nominal voltage. */
1695     CY_SYSPM_BUCK_OUT2_VOLTAGE_1_45V = 6U,    /**< 1.45 V nominal voltage. */
1696     CY_SYSPM_BUCK_OUT2_VOLTAGE_1_5V  = 7U     /**< 1.5 V nominal voltage. */
1697 } cy_en_syspm_buck_voltage2_t;
1698 
1699 /**
1700 * This enumeration is used to set the polarity for the PMIC input. The PMIC output is
1701 * automatically enabled when the configured polarity of the PMIC input and the logic level
1702 * driven to the pmic_wakeup_in pin match.
1703 *
1704 * \warning
1705 * Do not use CY_SYSPM_PMIC_POLARITY_LOW as it is not supported by hardware.
1706 */
1707 typedef enum
1708 {
1709     CY_SYSPM_PMIC_POLARITY_LOW   = 0U,    /**< Set active low logic level for the PMIC input. */
1710     CY_SYSPM_PMIC_POLARITY_HIGH  = 1U     /**< Set active high logic level for the PMIC input. */
1711 } cy_en_syspm_pmic_wakeup_polarity_t;
1712 
1713 /** This enumeration selects Vbackup or Vddd to supply Vddbackup. */
1714 typedef enum
1715 {
1716     CY_SYSPM_VDDBACKUP_DEFAULT         = 0U,    /**< Logic automatically selects Vddd if present or
1717                                                      Vbackup if Vddd is not present to supply Vddbackup */
1718     CY_SYSPM_VDDBACKUP_VBACKUP         = 2U     /**< Sets only Vbackup to supply Vddbackup */
1719 } cy_en_syspm_vddbackup_control_t;
1720 
1721 /** This enumeration enables supercapacitor charging. */
1722 typedef enum
1723 {
1724     CY_SYSPM_SC_CHARGE_ENABLE     = 0x3CU,    /**< Enables supercapacitor charging */
1725     CY_SYSPM_SC_CHARGE_DISABLE    = 0x00U     /**< Disables supercapacitor charging */
1726 } cy_en_syspm_sc_charge_key_t;
1727 
1728 /** This enumeration configures the flash voltage bit for different system power modes. */
1729 typedef enum
1730 {
1731     CY_SYSPM_FLASH_VOLTAGE_BIT_LP  = 0U,    /**< Set the flash voltage bit for system LP mode */
1732     CY_SYSPM_FLASH_VOLTAGE_BIT_ULP = 1U,    /**< Set the flash voltage bit for system ULP mode */
1733 } cy_en_syspm_flash_voltage_bit_t;
1734 
1735 /**
1736 * This enumeration is used to select the low power mode for which the
1737 * appropriate registered callback handler will be executed. For example,
1738 * the registered callback of the type CY_SYSPM_SLEEP will be executed while
1739 * switching into the Sleep power mode.
1740 */
1741 typedef enum
1742 {
1743     CY_SYSPM_SLEEP      = 0U,    /**< The Sleep enum callback type */
1744     CY_SYSPM_DEEPSLEEP  = 1U,    /**< The Deep Sleep enum callback type */
1745     CY_SYSPM_HIBERNATE  = 2U,    /**< The Hibernate enum callback type */
1746     CY_SYSPM_LP         = 3U,    /**< The Low Power enum callback type */
1747     CY_SYSPM_ULP        = 4U     /**< The Ultra Low Power enum callback type */
1748 } cy_en_syspm_callback_type_t;
1749 
1750 /** This enumeration specifies the associated callback mode. This enum defines the callback mode. */
1751 typedef enum
1752 {
1753     CY_SYSPM_CHECK_READY        = 0x01U,    /**< Callbacks with this mode are executed before entering into the
1754                                                  low power mode. The purpose of his callback function is to check
1755                                                  if the device is ready to enter the low power mode. */
1756     CY_SYSPM_CHECK_FAIL         = 0x02U,    /**< Callbacks with this mode are executed after the CY_SYSPM_CHECK_READY
1757                                                  callbacks execution returns CY_SYSPM_FAIL.
1758                                                  The callback with the CY_SYSPM_CHECK_FAIL mode should roll back the
1759                                                  actions performed in the previously executed callback with
1760                                                  CY_SYSPM_CHECK_READY */
1761     CY_SYSPM_BEFORE_TRANSITION  = 0x04U,    /**< Callbacks with this mode are executed after the CY_SYSPM_CHECK_READY
1762                                                  callbacks execution returns CY_SYSPM_SUCCESS.
1763                                                  Performs the actions to be done before entering into the
1764                                                  low power mode. */
1765     CY_SYSPM_AFTER_TRANSITION   = 0x08U     /**< Performs the actions to be done after exiting the low power mode
1766                                                  if entered. */
1767 } cy_en_syspm_callback_mode_t;
1768 
1769 #if defined (CY_IP_MXS40SRSS) || defined (CY_DOXYGEN)
1770 /**
1771 * \note
1772 * This macro is available for CAT1A devices.
1773 **/
1774 /**
1775 * This enumeration is used to select a particular SRAM.
1776 */
1777 typedef enum
1778 {
1779     CY_SYSPM_SRAM0_MEMORY      = 0U,    /**< SRAM0 Memory Area */
1780     CY_SYSPM_SRAM1_MEMORY      = 1U,    /**< SRAM1 Memory Area */
1781     CY_SYSPM_SRAM2_MEMORY      = 2U,    /**< SRAM2 Memory Area */
1782 } cy_en_syspm_sram_index_t;
1783 
1784 /**
1785 * This enumeration is used to select a particular SRAM Power Mode.
1786 */
1787 typedef enum
1788 {
1789     CY_SYSPM_SRAM_PWR_MODE_OFF      = 0U,   /**< SRAM Power Mode OFF */
1790     CY_SYSPM_SRAM_PWR_MODE_INVALID  = 1U,   /**< Invalid SRAM Power Mode */
1791     CY_SYSPM_SRAM_PWR_MODE_RET      = 2U,   /**< SRAM Power Mode RET */
1792     CY_SYSPM_SRAM_PWR_MODE_ON       = 3U    /**< SRAM Power Mode ON */
1793 } cy_en_syspm_sram_pwr_mode_t;
1794 #endif
1795 /** \} group_syspm_data_enumerates */
1796 
1797 /**
1798 * \addtogroup group_syspm_macros
1799 * \{
1800 */
1801 /**
1802 * \defgroup group_syspm_skip_callback_modes Defines to skip the callbacks modes
1803 * \{
1804 * Defines for the SysPm callbacks modes that can be skipped during execution.
1805 * For more information about callbacks modes, refer
1806 * to \ref cy_en_syspm_callback_mode_t.
1807 */
1808 #define CY_SYSPM_SKIP_CHECK_READY                   (0x01U)   /**< Define to skip check ready mode in the syspm callback */
1809 #define CY_SYSPM_SKIP_CHECK_FAIL                    (0x02U)   /**< Define to skip check fail mode in the syspm callback */
1810 #define CY_SYSPM_SKIP_BEFORE_TRANSITION             (0x04U)   /**< Define to skip before transition mode in the syspm callback */
1811 #define CY_SYSPM_SKIP_AFTER_TRANSITION              (0x08U)   /**< Define to skip after transition mode in the syspm callback */
1812 /** \} group_syspm_skip_callback_modes */
1813 /** \} group_syspm_macros */
1814 
1815 /**
1816 * \addtogroup group_syspm_data_structures
1817 * \{
1818 */
1819 
1820 /** The structure contains syspm callback parameters */
1821 typedef struct
1822 {
1823     void *base;         /**< Base address of a HW instance, matches name of the driver in
1824                              the API for the base address. Can be undefined if not required. Base address is not
1825                              required for the SysPm driver as the device has only one set of power modes */
1826     void *context;      /**< Context for the handler function. This item can be
1827                              skipped if not required. Can be undefined if not required. */
1828 
1829 } cy_stc_syspm_callback_params_t;
1830 
1831 /** The type for syspm callbacks */
1832 typedef cy_en_syspm_status_t (*Cy_SysPmCallback) (cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode);
1833 
1834 /** Structure with syspm callback configuration elements */
1835 typedef struct cy_stc_syspm_callback
1836 {
1837     Cy_SysPmCallback callback;                         /**< The callback handler function. */
1838     cy_en_syspm_callback_type_t type;                  /**< The callback type, see \ref cy_en_syspm_callback_type_t. */
1839     uint32_t skipMode;                                 /**< The mask of modes to be skipped during callback
1840                                                             execution, see \ref group_syspm_skip_callback_modes. The
1841                                                             corresponding callback mode won't execute if the
1842                                                             appropriate define is set. These values can be ORed.
1843                                                             If all modes are required to be executed this element
1844                                                             should be equal to zero. Skipping unneeded callback modes speeds up
1845                                                             power mode transitions by skipping unneeded operations. */
1846 
1847     cy_stc_syspm_callback_params_t *callbackParams;    /**< The address of a cy_stc_syspm_callback_params_t,
1848                                                             the callback is executed with these parameters. */
1849 
1850     struct cy_stc_syspm_callback *prevItm;             /**< The previous list item. This element should not be
1851                                                             defined, or defined as NULL. It is for internal
1852                                                             usage to link this structure to the next registered
1853                                                             structure. It will be updated during callback
1854                                                             registration. Do not modify this element at run-time. */
1855 
1856     struct cy_stc_syspm_callback *nextItm;             /**< The next list item. This element should not be
1857                                                             defined, or defined as NULL. It is for internal usage to
1858                                                             link this structure to the previous registered structure.
1859                                                             It will be updated during callback registration. Do not
1860                                                             modify this element at run-time. */
1861     uint8_t order;                                     /**< Holds the callback execution order value. Range: 0-255.
1862                                                             While entering low power mode, callbacks with lower order values
1863                                                             are executed first. While exiting low power mode,
1864                                                             the callbacks are executed in the opposite order.
1865                                                             Callbacks with the same order value are executed in the
1866                                                             order they are registered in the application. */
1867 } cy_stc_syspm_callback_t;
1868 
1869 /** This internal structure stores non-retained registers in the system Deep Sleep
1870 *   power mode. On wakeup from system Deep Sleep, these registers are restored.
1871 */
1872 typedef struct
1873 {
1874     uint32_t CY_SYSPM_UDB_UDBIF_BANK_CTL_REG;    /**< UDB interface control register */
1875 
1876     uint32_t CY_SYSPM_UDB_BCTL_MDCLK_EN_REG;    /**< UDB bank MDCLK_EN register */
1877     uint32_t CY_SYSPM_UDB_BCTL_MBCLK_EN_REG;    /**< UDB bank MBCLK_EN register */
1878     uint32_t CY_SYSPM_UDB_BCTL_BOTSEL_L_REG;    /**< UDB bank BOTSEL_L register */
1879     uint32_t CY_SYSPM_UDB_BCTL_BOTSEL_U_REG;    /**< UDB bank BOTSEL_U register */
1880     uint32_t CY_SYSPM_UDB_BCTL_QCLK_EN0_REG;    /**< UDB bank QCLK_EN0 register */
1881     uint32_t CY_SYSPM_UDB_BCTL_QCLK_EN1_REG;    /**< UDB bank QCLK_EN1 register */
1882     uint32_t CY_SYSPM_UDB_BCTL_QCLK_EN2_REG;    /**< UDB bank QCLK_EN2 register */
1883 
1884 #if defined (CY_IP_MXS40SRSS)
1885     /**
1886     * \note
1887     * This parameter is available for CAT1A devices.
1888     **/
1889     uint32_t CY_SYSPM_CM0_CLOCK_CTL_REG;        /**< CPUSS CM0+ clock control register */
1890     /**
1891     * \note
1892     * This parameter is available for CAT1A devices.
1893     **/
1894     uint32_t CY_SYSPM_CM4_CLOCK_CTL_REG;        /**< CPUSS CM4 clock control register */
1895 #endif /* CY_IP_MXS40SRSS */
1896 
1897 } cy_stc_syspm_backup_regs_t;
1898 
1899 #if (defined(CY_DEVICE_SECURE))
1900 /** PRA structure for Cy_SysPm_BuckSetVoltage2 function parameters */
1901 typedef struct
1902 {
1903     cy_en_syspm_buck_voltage2_t praVoltage;     /**< The voltage of the Buck regulator output 2 */
1904     bool praWaitToSettle;                       /**< Enable/disable the delay after setting a higher voltage */
1905 } cy_stc_pra_voltage2_t;
1906 
1907 typedef struct
1908 {
1909     cy_en_syspm_sram_index_t sramNum;           /**< SRAM index */
1910     uint32_t sramMacroNum;                      /**< SRAM macro number */
1911     cy_en_syspm_sram_pwr_mode_t sramPwrMode;    /**< Power mode */
1912 } cy_stc_pra_sram_power_mode_config_t;
1913 
1914 #endif /* (defined(CY_DEVICE_SECURE)) */
1915 /** \} group_syspm_data_structures */
1916 
1917 /**
1918 * \addtogroup group_syspm_functions
1919 * \{
1920 */
1921 
1922 /**
1923 * \addtogroup group_syspm_functions_general
1924 * \{
1925 */
1926 #if defined (CY_IP_MXS40SRSS) || defined (CY_DOXYGEN)
1927 
1928 /*******************************************************************************
1929 * Function Name: Cy_SysPm_SetSRAMMacroPwrMode
1930 ****************************************************************************//**
1931 *
1932 * Function to set Power Mode for each of the Macro in a particular SRAM.
1933 *
1934 * \param sramNum
1935 * SRAM's index number has to be passed
1936 * ex: CY_SYSPM_SRAM0_MEMORY or CY_SYSPM_SRAM1_MEMORY or CY_SYSPM_SRAM2_MEMORY
1937 * See \ref cy_en_syspm_sram_index_t.
1938 *
1939 * \param sramMacroNum
1940 * Macro number of a particular SRAM.
1941 *
1942 * \note
1943 * If SRAM1 and SRAM2 consists of single power partition, power mode will be
1944 * applied to whole SRAM region, so 0 must be passed for sramMacroNum parameter.
1945 *
1946 * \param sramPwrMode
1947 * Power Mode that needs to be set.
1948 *
1949 * \return
1950 * - CY_SYSPM_SUCCESS - SRAM MACRO power mode is set.
1951 * - CY_SYSPM_BAD_PARAM - Input parameters are out of range.
1952 * See \ref cy_en_syspm_status_t.
1953 *
1954 * For the PSoC 64 devices there are possible situations when function returns
1955 * the PRA error status code. This is because for PSoC 64 devices the function
1956 * uses the PRA driver to change the protected registers. Refer to
1957 * \ref cy_en_pra_status_t for more details.
1958 *
1959 * \note
1960 * This API is available for CAT1A devices.
1961 *
1962 *******************************************************************************/
1963 cy_en_syspm_status_t Cy_SysPm_SetSRAMMacroPwrMode(cy_en_syspm_sram_index_t sramNum, uint32_t sramMacroNum, cy_en_syspm_sram_pwr_mode_t sramPwrMode);
1964 
1965 /*******************************************************************************
1966 * Function Name: Cy_SysPm_GetSRAMMacroPwrMode
1967 ****************************************************************************//**
1968 *
1969 * Function to get Power Mode for each of the Macro in a particular SRAM.
1970 *
1971 * \param sramNum
1972 * SRAM's index number has to be passed
1973 * ex: CY_SYSPM_SRAM0_MEMORY or CY_SYSPM_SRAM1_MEMORY or CY_SYSPM_SRAM2_MEMORY
1974 * See \ref cy_en_syspm_sram_index_t.
1975 *
1976 * \param sramMacroNum
1977 * Macro number of a particular SRAM.
1978 *
1979 * \note
1980 * If SRAM1 and SRAM2 consists of single power partition, power mode will be
1981 * applied to whole SRAM region, so 0 must be passed for sramMacroNum parameter,
1982 * and the power mode obtained will be for whole SRAM.
1983 *
1984 * \return
1985 * Returns SRAM power mode. See \ref cy_en_syspm_sram_pwr_mode_t.
1986 *
1987 * \note
1988 * This API is available for CAT1A devices.
1989 *
1990 *******************************************************************************/
1991 cy_en_syspm_sram_pwr_mode_t Cy_SysPm_GetSRAMMacroPwrMode(cy_en_syspm_sram_index_t sramNum, uint32_t sramMacroNum);
1992 
1993 
1994 /*******************************************************************************
1995 * Function Name: Cy_SysPm_SetSRAMPwrMode
1996 ****************************************************************************//**
1997 *
1998 * Function to set Power Mode for all the Macros for a particular SRAM.
1999 *
2000 * \param sramNum
2001 * SRAM's index number has to be passed
2002 * ex: CY_SYSPM_SRAM0_MEMORY or CY_SYSPM_SRAM1_MEMORY or CY_SYSPM_SRAM2_MEMORY
2003 * See \ref cy_en_syspm_sram_index_t.
2004 *
2005 * \param sramPwrMode
2006 * Power Mode that needs to be set.
2007 *
2008 * \return
2009 * - CY_SYSPM_SUCCESS - SRAM power mode is set.
2010 * - CY_SYSPM_BAD_PARAM - Input parameters are out of range.
2011 * See \ref cy_en_syspm_status_t.
2012 *
2013 * For the PSoC 64 devices there are possible situations when function returns
2014 * the PRA error status code. This is because for PSoC 64 devices the function
2015 * uses the PRA driver to change the protected registers. Refer to
2016 * \ref cy_en_pra_status_t for more details.
2017 *
2018 * \note
2019 * This API is available for CAT1A devices.
2020 *
2021 *******************************************************************************/
2022 cy_en_syspm_status_t Cy_SysPm_SetSRAMPwrMode(cy_en_syspm_sram_index_t sramNum, cy_en_syspm_sram_pwr_mode_t sramPwrMode);
2023 #endif
2024 
2025 /*******************************************************************************
2026 * Function Name: Cy_SysPm_WriteVoltageBitForFlash
2027 ****************************************************************************//**
2028 *
2029 * Function that changes the voltage setting for flash.
2030 *
2031 * \note
2032 * Call this function before system enters ULP mode. Call this function after
2033 * the system enters LP mode.
2034 *
2035 * \param value
2036 * Value to be set in the flash voltage control register.
2037 * See \ref cy_en_syspm_flash_voltage_bit_t.
2038 *
2039 * \return
2040 * - CY_SYSPM_SUCCESS - The voltage is set.
2041 * - CY_SYSPM_CANCELED - Operation was canceled. Call the function again until
2042 *   the function returns CY_SYSPM_SUCCESS. See \ref cy_en_syspm_status_t.
2043 *
2044 * \funcusage
2045 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_WriteVoltageBitForFlash
2046 *
2047 *******************************************************************************/
2048 cy_en_syspm_status_t Cy_SysPm_WriteVoltageBitForFlash(cy_en_syspm_flash_voltage_bit_t value);
2049 
2050 #if !((CY_CPU_CORTEX_M4) && (defined (CY_DEVICE_SECURE)))
2051 
2052 /*******************************************************************************
2053 * Function Name: Cy_SysPm_SaveRegisters
2054 ****************************************************************************//**
2055 *
2056 * \note Behavior of this API is IP dependent. \n
2057 * On CAT1A devices: \n
2058 * Saves non-retained UDB registers and the slow and fast clock dividers before
2059 * system entering system Deep Sleep.
2060 * Must be called if programmable logic or function are implemented in the UDB
2061 * array.
2062 * Cypress ID #280370, #1451.
2063 * On CAT1B devices: \n
2064 * Saves non-retained UDB registers before system entering system Deep Sleep.
2065 * Must be called if programmable logic or function are implemented in the UDB
2066 * array.
2067 * Cypress ID #280370.
2068 * \warning
2069 * Only one CPU on dual CPU devices should call this function. If both CPUs call
2070 * this function the UDB state restored may be inconsistent with the expected
2071 * state when restored.
2072 *
2073 * \param regs
2074 * The structure where the registers are saved.
2075 *
2076 * \funcusage
2077 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_SaveRestoreRegisters
2078 *
2079 *******************************************************************************/
2080 void Cy_SysPm_SaveRegisters(cy_stc_syspm_backup_regs_t *regs);
2081 
2082 
2083 /*******************************************************************************
2084 * Function Name: Cy_SysPm_RestoreRegisters
2085 ****************************************************************************//**
2086 *
2087 * \note Behavior of this API is IP dependent. \n
2088 * On CAT1A devices: \
2089 * Restores non-retained UDB registers and the slow and fast clock dividers
2090 * before system entering system Deep Sleep.
2091 * Must be called if programmable logic or function are implemented in the UDB
2092 * array.
2093 * Cypress ID #280370, #1451.
2094 * On CAT1B devices: \
2095 * Restores non-retained UDB registers before system entering system Deep Sleep.
2096 * Must be called if programmable logic or function are implemented in the UDB
2097 * array.
2098 * Cypress ID #280370.
2099 * \warning
2100 * Only one CPU on dual CPU devices should call this function. If both CPUs call
2101 * this function the UDB state restored may be inconsistent with the expected
2102 * state when restored.
2103 *
2104 * \param regs
2105 * The structure with data stored (using Cy_SysPm_SaveRegisters()) into the
2106 * required registers after Deep Sleep.
2107 *
2108 * \note
2109 * CAT1B devices, registers are non-retained type.
2110 *
2111 * \funcusage
2112 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_SaveRestoreRegisters
2113 *
2114 *******************************************************************************/
2115 void Cy_SysPm_RestoreRegisters(cy_stc_syspm_backup_regs_t const *regs);
2116 
2117 #endif /* !((CY_CPU_CORTEX_M4) && (defined (CY_DEVICE_SECURE))) */
2118 /** \} group_syspm_functions_general */
2119 
2120 
2121 /**
2122 * \addtogroup group_syspm_functions_power_status
2123 * \{
2124 */
2125 
2126 
2127 /*******************************************************************************
2128 * Function Name: Cy_SysPm_ReadStatus
2129 ****************************************************************************//**
2130 *
2131 * Reads the power modes status of the system and CPU(s).
2132 *
2133 * \return
2134 * The current power mode. See \ref group_syspm_return_status.
2135 *
2136 * \funcusage
2137 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_ReadStatus
2138 *
2139 *******************************************************************************/
2140 uint32_t Cy_SysPm_ReadStatus(void);
2141 /** \} group_syspm_functions_power_status */
2142 
2143 /**
2144 * \addtogroup group_syspm_functions_power
2145 * \{
2146 */
2147 
2148 
2149 /*******************************************************************************
2150 * Function Name: Cy_SysPm_CpuEnterSleep
2151 ****************************************************************************//**
2152 *
2153 * Sets executing CPU to Sleep mode.
2154 *
2155 * Puts the CPU executing this function into CPU Sleep power mode. If callback
2156 * functions were registered they are also executed.
2157 *
2158 * For more detail about switching into CPU Sleep power mode and debug,
2159 * refer to the device technical reference manual (TRM).
2160 *
2161 * If at least one callback function with the CY_SYSPM_SLEEP type was registered,
2162 * the following algorithm is executed:
2163 * Prior to entering CPU Sleep mode, all callback functions of the CY_SYSPM_SLEEP
2164 * type with the CY_SYSPM_CHECK_READY parameter are called. This allows the
2165 * driver to signal whether it is ready to enter the low power mode. If any of
2166 * the callbacks of the CY_SYSPM_SLEEP type with the CY_SYSPM_CHECK_READY
2167 * parameter returns CY_SYSPM_FAIL, the remaining callbacks of the
2168 * CY_SYSPM_SLEEP type with the CY_SYSPM_CHECK_READY parameter are skipped.
2169 * After the first CY_SYSPM_FAIL, all the CY_SYSPM_SLEEP callbacks that were
2170 * previously executed before getting the CY_SYSPM_CHECK_FAIL are executed with
2171 * the CY_SYSPM_CHECK_FAIL parameter. The CPU Sleep mode is not entered and the
2172 * Cy_SysPm_CpuEnterSleep() function returns CY_SYSPM_FAIL.
2173 *
2174 * If all of the callbacks of the CY_SYSPM_SLEEP type with the
2175 * CY_SYSPM_CHECK_READY parameter return CY_SYSPM_SUCCESS, then all
2176 * callbacks of the CY_SYSPM_SLEEP type with the CY_SYSPM_CHECK_FAIL parameters
2177 * calls are skipped. All callbacks of the CY_SYSPM_SLEEP type and then
2178 * CY_SYSPM_BEFORE_TRANSITION parameter calls are executed, allowing the
2179 * peripherals to prepare for CPU Sleep. The CPU then enters Sleep mode.
2180 * This is a CPU-centric power mode. This means that the CPU has entered Sleep
2181 * mode and its main clock is removed. Any enabled interrupt can cause a CPU
2182 * wakeup from Sleep mode.
2183 *
2184 * For multi-core devices, CPU wakeup can also be performed using the Send Event
2185 * (SEV) assembly instruction executed from the other active CPU. Such wakeup is
2186 * expected only if the CPU Sleep power mode is done with WFE assembly
2187 * instruction.
2188 *
2189 * After a wakeup from CPU Sleep, all of the registered callbacks of the
2190 * CY_SYSPM_SLEEP type and with the CY_SYSPM_AFTER_TRANSITION parameter are
2191 * executed to return the peripherals to CPU active operation.
2192 * The Cy_SysPm_CpuEnterSleep() function returns CY_SYSPM_SUCCESS.
2193 * No callbacks of the CY_SYSPM_SLEEP type with the CY_SYSPM_BEFORE_TRANSITION
2194 * parameter or callbacks of the CY_SYSPM_SLEEP type and
2195 * CY_SYSPM_AFTER_TRANSITION parameter callbacks are executed if CPU Sleep mode
2196 * is not entered.
2197 *
2198 * \note The last callback that returns CY_SYSPM_FAIL is not executed with the
2199 * CY_SYSPM_CHECK_FAIL parameter because of the FAIL. The callback generating
2200 * CY_SYSPM_FAIL is expected to not make any changes that require being undone.
2201 *
2202 * To support control of callback execution order th following method is
2203 * implemented. Callback function with the CY_SYSPM_CHECK_READY and
2204 * CY_SYSPM_BEFORE_TRANSITION parameter are executed in the same order they are
2205 * registered. Callback function with the CY_SYSPM_CHECK_FAIL and
2206 * CY_SYSPM_AFTER_TRANSITION parameter are executed in the reverse order they
2207 * are registered.
2208 
2209 * The return value from executed callback functions with the
2210 * CY_SYSPM_CHECK_FAIL, CY_SYSPM_BEFORE_TRANSITION, and CY_SYSPM_AFTER_TRANSITION
2211 * modes are ignored.
2212 *
2213 * \ref cy_en_syspm_callback_mode_t, except the CY_SYSPM_CHECK_READY, are ignored
2214 *
2215 * \note The Arm BSD assembly instruction is not required in this function
2216 * because the function implementation ensures the SLEEPDEEP bit of SCS register
2217 * is settled prior executing WFI/WFE instruction.
2218 *
2219 * \param waitFor
2220 * Selects wait for action. See \ref cy_en_syspm_waitfor_t.
2221 *
2222 * \return
2223 * Entered status, see \ref cy_en_syspm_status_t.
2224 *
2225 * \sideeffect
2226 * For CY8C6xx6, CY8C6xx7 devices this function clears the Event Register of the
2227 * CM4 CPU after wakeup from WFE.
2228 *
2229 * \funcusage
2230 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_CpuEnterSleep
2231 *
2232 *******************************************************************************/
2233 cy_en_syspm_status_t Cy_SysPm_CpuEnterSleep(cy_en_syspm_waitfor_t waitFor);
2234 
2235 
2236 /*******************************************************************************
2237 * Function Name: Cy_SysPm_CpuEnterDeepSleep
2238 ****************************************************************************//**
2239 *
2240 * Sets executing CPU to the Deep Sleep mode.
2241 *
2242 * Puts the CPU executing the function into CPU Deep Sleep. For a single CPU
2243 * devices the device will immediately transition to system Deep Sleep. For a
2244 * dual CPU devices the device will transition to system Deep Sleep only after
2245 * both CPUs are in CPU Deep Sleep power mode.
2246 *
2247 * Prior to entering the CPU Deep Sleep mode, all callbacks of the
2248 * CY_SYSPM_DEEPSLEEP type with the CY_SYSPM_CHECK_READY parameter registered
2249 * callbacks are called, allowing the driver to signal whether it is ready to
2250 * enter the power mode. If any CY_SYSPM_DEEPSLEEP type with the
2251 * CY_SYSPM_CHECK_READY parameter call returns CY_SYSPM_FAIL, the remaining
2252 * callback CY_SYSPM_DEEPSLEEP type with the CY_SYSPM_CHECK_READY parameter are
2253 * skipped. After the first CY_SYSPM_FAIL, all the CY_SYSPM_DEEPSLEEP callbacks
2254 * that were previously executed before getting the CY_SYSPM_CHECK_FAIL are
2255 * executed with the CY_SYSPM_CHECK_FAIL parameter. The CPU Deep Sleep mode is
2256 * not entered and the Cy_SysPm_CpuEnterDeepSleep() function returns
2257 * CY_SYSPM_FAIL.
2258 *
2259 * If all callbacks of the CY_SYSPM_DEEPSLEEP type with the CY_SYSPM_CHECK_READY
2260 * parameter return CY_SYSPM_SUCCESS, then all callbacks of the
2261 * CY_SYSPM_DEEPSLEEP type with the CY_SYSPM_CHECK_FAIL parameter calls are
2262 * skipped. All callbacks of the CY_SYSPM_DEEPSLEEP type with the
2263 * CY_SYSPM_BEFORE_TRANSITION parameter calls are then executed, allowing the
2264 * peripherals to prepare for CPU Deep Sleep. The Deep Sleep mode is then
2265 * entered. Any enabled interrupt can cause a wakeup from the Deep Sleep mode.
2266 *
2267 * \note The last callback that returns CY_SYSPM_FAIL is not executed with the
2268 * CY_SYSPM_CHECK_FAIL parameter because of the FAIL. The callback generating
2269 * CY_SYSPM_FAIL is expected to not make any changes that require being undone.
2270 *
2271 * For multi-CPU devices (except CY8C6xx6 and CY8C6xx7) there is a possible
2272 * situation when a syscall operation (for example during flash read or write)
2273 * is executing. If the CM0+ CPU tries to enter Deep Sleep, it will fail. All
2274 * the CY_SYSPM_DEEPSLEEP callbacks that were previously executed, are executed
2275 * with the CY_SYSPM_CHECK_FAIL parameter. Deep Sleep mode is not entered and
2276 * the Cy_SysPm_CpuEnterDeepSleep() function returns CY_SYSPM_SYSCALL_PENDING.
2277 *
2278 * The return value from executed callback functions with the
2279 * CY_SYSPM_CHECK_FAIL, CY_SYSPM_BEFORE_TRANSITION, and CY_SYSPM_AFTER_TRANSITION
2280 * modes are ignored.
2281 *
2282 * If the firmware attempts to enter this mode before the system is ready (that
2283 * is, when PWR_CONTROL.LPM_READY = 0), then the CPU(s) will go into the CPU
2284 * Sleep mode instead and automatically enter system Deep Sleep mode when the
2285 * system is ready. On dual CPU devices, if one CPU enters CPU Deep Sleep and the
2286 * other CPU remains active or is in CPU Sleep the first CPU will remain in CPU
2287 * Deep Sleep. A CPU Deep Sleep is functionally identical to CPU Sleep.
2288 *
2289 * The device enters system Deep Sleep mode when all the CPU(s) are in CPU
2290 * Deep Sleep, there are no busy peripherals, the debugger is not active, and the
2291 * Deep Sleep power and reference are ready (PWR_CONTROL.LPM_READY=1).
2292 *
2293 * The peripherals that do not need a clock or that receive a clock from their
2294 * external interface (e.g. I2C/SPI) may continue operating in system Deep Sleep.
2295 * All circuits using current from Vccdpslp supply are limited by its maximum
2296 * current specification of the Deep Sleep regulator.
2297 *
2298 * Wakeup occurs when an interrupt asserts from a Deep Sleep active peripheral.
2299 * For more detail, see the corresponding peripheral's datasheet.
2300 *
2301 * For multi-core devices, CPU wakeup can also be performed using the Send Event
2302 * (SEV) assembly instruction executed from the other active CPU. Such wakeup is
2303 * expected only if the CPU Sleep power mode is done with WFE assembly
2304 * instruction.
2305 *
2306 * \note
2307 * For multi-CPU devices, the second CPU, if it did not participate in
2308 * system wakeup, remains in CPU Deep Sleep mode. Any Deep Sleep capable
2309 * interrupt routed to this CPU can also wake it.
2310 *
2311 * For more detail about switching into the system Deep Sleep power mode and
2312 * debug, refer to the device TRM.
2313 *
2314 * A normal wakeup from the Deep Sleep power mode returns to either ULP or LP
2315 * mode, depending on the previous state and programmed behavior for the
2316 * particular wakeup interrupt. As soon as the system resumes LP or ULP mode the
2317 * CPU(s) return to CPU Active or CPU Deep Sleep mode, depending on their
2318 * configured wakeup settings.
2319 *
2320 * After wakeup from CPU Deep Sleep, all of the registered callbacks with
2321 * CY_SYSPM_DEEPSLEEP type with CY_SYSPM_AFTER_TRANSITION are executed to return
2322 * peripherals to active operation. The Cy_SysPm_CpuEnterDeepSleep() function
2323 * returns CY_SYSPM_SUCCESS. No callbacks are executed with CY_SYSPM_DEEPSLEEP
2324 * type with CY_SYSPM_BEFORE_TRANSITION or CY_SYSPM_AFTER_TRANSITION parameter,
2325 * if Deep Sleep mode was not entered.
2326 *
2327 * To support control of callback execution order th following method is
2328 * implemented. Callback function with the CY_SYSPM_CHECK_READY and
2329 * CY_SYSPM_BEFORE_TRANSITION parameter are executed in the same order they are
2330 * registered. Callback function with the CY_SYSPM_CHECK_FAIL and
2331 * CY_SYSPM_AFTER_TRANSITION parameter are executed in the reverse order they
2332 * are registered.
2333 *
2334 * \param waitFor
2335 * Selects wait for action. See \ref cy_en_syspm_waitfor_t.
2336 *
2337 * \sideeffect
2338 * For CY8C6xx6, CY8C6xx7 devices this function clears the Event Register of the
2339 * CM4 CPU after wakeup from WFE.
2340 *
2341 * \sideeffect
2342 * This function changes the slow and fast clock dividers right before
2343 * entering into system Deep Sleep and restores these dividers after wakeup.
2344 *
2345 * \return
2346 * Entered status, see \ref cy_en_syspm_status_t.
2347 * For the PSoC 64 devices there are possible situations when function returns
2348 * the PRA error status code. This is because for PSoC 64 devices the function
2349 * uses the PRA driver to change the protected registers. Refer to
2350 * \ref cy_en_pra_status_t for more details.
2351 *
2352 * \note
2353 * The FLL/PLL are not restored right before the CPU(s) start executing the
2354 * instructions after system Deep Sleep. This can affect the peripheral that is
2355 * driven by PLL/FLL. Ensure that the PLL/FLL are properly restored (locked)
2356 * after wakeup from System Deep Sleep. Refer to the
2357 * \ref group_sysclk driver documentation for information about how to
2358 * read the PLL/FLL lock statuses.
2359 *
2360 * \note The Arm BSD assembly instruction is not required in this function
2361 * because the function implementation ensures the SLEEPDEEP bit of SCS register
2362 * is settled prior executing the WFI/WFE instruction.
2363 *
2364 * \funcusage
2365 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_CpuEnterDeepSleep
2366 *
2367 *******************************************************************************/
2368 cy_en_syspm_status_t Cy_SysPm_CpuEnterDeepSleep(cy_en_syspm_waitfor_t waitFor);
2369 
2370 
2371 /*******************************************************************************
2372 * Function Name: Cy_SysPm_SystemEnterLp
2373 ****************************************************************************//**
2374 *
2375 * Sets device into system Low Power mode.
2376 *
2377 * Returns the system to the default LP mode by raising the core voltage.
2378 * In the LP mode, the clock frequencies can be increased to t
2379 he LP mode
2380 * limitations. Refer to the device datasheet for frequency limitations in the
2381 * LP mode. Approximate LP limit values - \ref group_syspm_lp_limitations.
2382 *
2383 * Prior to entering the system LP mode, all the registered CY_SYSPM_LP callbacks
2384 * with CY_SYSPM_CHECK_READY parameter are called. This allows the driver to
2385 * signal that it is not ready to enter the system LP mode. If any CY_SYSPM_LP
2386 * callbacks with the CY_SYSPM_CHECK_READY parameter call return CY_SYSPM_FAIL,
2387 * the remaining CY_SYSPM_LP callbacks with the
2388 * CY_SYSPM_CHECK_READY parameter calls are skipped.
2389 *
2390 * After a CY_SYSPM_FAIL, all of the CY_SYSPM_LP callbacks with
2391 * CY_SYSPM_CHECK_FAIL parameter are executed that correspond to the
2392 * CY_SYSPM_LP callbacks with CY_SYSPM_CHECK_READY parameter that occurred up to
2393 * the point of failure. System LP mode is not entered and the
2394 * Cy_SysPm_SystemEnterLp() function returns CY_SYSPM_FAIL.
2395 *
2396 * If all CY_SYSPM_LP callbacks with the CY_SYSPM_CHECK_READY
2397 * parameter return CY_SYSPM_SUCCESS, then all CY_SYSPM_LP callbacks with
2398 * CY_SYSPM_CHECK_FAIL are skipped and all CY_SYSPM_LP callbacks with the
2399 * CY_SYSPM_BEFORE_TRANSITION parameter are executed. This allows the
2400 * peripherals to prepare for LP mode. The system LP mode is then entered.
2401 *
2402 * After entering the system LP mode, all of the registered
2403 * CY_SYSPM_LP callbacks with the CY_SYSPM_AFTER_TRANSITION parameter
2404 * are executed to complete preparing the peripherals for low power operation.
2405 * The Cy_SysPm_SystemEnterLp() function returns CY_SYSPM_SUCCESS.
2406 * No CY_SYSPM_LP callbacks with the CY_SYSPM_BEFORE_TRANSITION or
2407 * CY_SYSPM_AFTER_TRANSITION parameter are executed if the system LP mode is not
2408 * entered.
2409 *
2410 * \note The last callback that returns CY_SYSPM_FAIL is not executed with the
2411 * CY_SYSPM_CHECK_FAIL parameter because of the FAIL. The callback generating
2412 * CY_SYSPM_FAIL is expected to not make any changes that require being undone.
2413 *
2414 * The return value from executed callback functions with the
2415 * CY_SYSPM_CHECK_FAIL, CY_SYSPM_BEFORE_TRANSITION, and CY_SYSPM_AFTER_TRANSITION
2416 * modes are ignored.
2417 *
2418 * To support control of callback execution order th following method is
2419 * implemented. Callback function with the CY_SYSPM_CHECK_READY and
2420 * CY_SYSPM_BEFORE_TRANSITION parameter are executed in the same order they are
2421 * registered. Callback function with the CY_SYSPM_CHECK_FAIL and
2422 * CY_SYSPM_AFTER_TRANSITION parameter are executed in the reverse order they
2423 * are registered.
2424 *
2425 * \return
2426 * - CY_SYSPM_SUCCESS - Entered the system LP mode or the device is already in LP mode.
2427 * - CY_SYSPM_INVALID_STATE - The system LP mode was not set. The system LP mode
2428 *   was not set because the protection context value is higher than zero
2429 *   (PC > 0) or the device revision does not support modifying registers
2430 *   (to enter LP mode) via syscall.
2431 * - CY_SYSPM_CANCELED - Operation was canceled. Call the function again until
2432 *   the function returns CY_SYSPM_SUCCESS.
2433 * - CY_SYSPM_FAIL - The system LP mode is not entered.
2434 *   For the PSoC 64 devices there are possible situations when function returns
2435 *   the PRA error status code. This is because for PSoC 64 devices the function
2436 *   uses the PRA driver to change the protected registers. Refer to
2437 *   \ref cy_en_pra_status_t for more details.
2438 *
2439 * \funcusage
2440 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_SystemEnterLp
2441 *
2442 *******************************************************************************/
2443 cy_en_syspm_status_t Cy_SysPm_SystemEnterLp(void);
2444 
2445 
2446 /*******************************************************************************
2447 * Function Name: Cy_SysPm_SystemEnterUlp
2448 ****************************************************************************//**
2449 *
2450 * Sets device into system Ultra Low Power mode.
2451 *
2452 * System ULP mode is similar to system LP mode. The difference is that the
2453 * system is put under \ref group_syspm_ulp_limitations.
2454 *
2455 * Before entering system ULP mode, the user must configure the system so
2456 * the maximum clock frequencies are less than the ULP mode specifications
2457 * presented in the device datasheet. Refer to the device datasheet for
2458 * the maximum clock limitations in the ULP mode with reduced core supply
2459 * regulator voltages.
2460 *
2461 * Prior to entering system ULP mode, all the registered CY_SYSPM_ULP callbacks
2462 * with CY_SYSPM_CHECK_READY parameter are called. This allows the driver to
2463 * signal if it is not ready to enter system ULP mode. If any CY_SYSPM_ULP
2464 * callback with the CY_SYSPM_CHECK_READY parameter call returns CY_SYSPM_FAIL,
2465 * the remaining CY_SYSPM_ULP callbacks with the CY_SYSPM_CHECK_READY parameter
2466 * are skipped.
2467 *
2468 * After a CY_SYSPM_FAIL, all of the CY_SYSPM_ULP callbacks with the
2469 * CY_SYSPM_CHECK_FAIL parameter are executed that correspond to the
2470 * CY_SYSPM_ULP callback with CY_SYSPM_CHECK_READY parameter that occurred up to
2471 * the point of failure. System ULP mode is not entered
2472 * and the Cy_SysPm_SystemEnterUlp() function returns CY_SYSPM_FAIL.
2473 *
2474 * If all CY_SYSPM_ULP callbacks with the CY_SYSPM_CHECK_READY
2475 * parameter return CY_SYSPM_SUCCESS, then all CY_SYSPM_ULP
2476 * callbacks with CY_SYSPM_CHECK_FAIL calls are skipped and all CY_SYSPM_ULP
2477 * callbacks with the CY_SYSPM_BEFORE_TRANSITION parameter are executed. This
2478 * allows preparation for ULP. The system ULP mode is then entered.
2479 *
2480 * After entering system ULP, all of the registered CY_SYSPM_ULP callbacks with
2481 * the CY_SYSPM_AFTER_TRANSITION parameter are executed to complete preparing the
2482 * peripherals for ULP operation. The Cy_SysPm_SystemEnterUlp() function
2483 * returns CY_SYSPM_SUCCESS. No CY_SYSPM_ULP callbacks with the
2484 * CY_SYSPM_BEFORE_TRANSITION or CY_SYSPM_AFTER_TRANSITION parameter are
2485 * executed, if ULP mode is not entered.
2486 *
2487 * \note The last callback that returns CY_SYSPM_FAIL is not executed with the
2488 * CY_SYSPM_CHECK_FAIL parameter because of the FAIL. The callback generating
2489 * CY_SYSPM_FAIL is expected to not make any changes that require being undone.
2490 *
2491 * The return value from executed callback functions with the
2492 * CY_SYSPM_CHECK_FAIL, CY_SYSPM_BEFORE_TRANSITION, and CY_SYSPM_AFTER_TRANSITION
2493 * modes are ignored.
2494 *
2495 * To support control of callback execution order th following method is
2496 * implemented. Callback function with the CY_SYSPM_CHECK_READY and
2497 * CY_SYSPM_BEFORE_TRANSITION parameter are executed in the same order they are
2498 * registered. Callback function with the CY_SYSPM_CHECK_FAIL and
2499 * CY_SYSPM_AFTER_TRANSITION parameter are executed in the reverse order they
2500 * are registered.
2501 *
2502 * \return
2503 * - CY_SYSPM_SUCCESS - Entered the system ULP mode or the device is already in ULP mode.
2504 * - CY_SYSPM_INVALID_STATE - System ULP mode was not set. The ULP mode was not
2505 *   set because the protection context value is higher than zero (PC > 0) or the
2506 *   device revision does not support modifying registers (to enter system
2507 *   ULP mode) via syscall.
2508 * - CY_SYSPM_CANCELED - Operation was canceled. Call the function again until
2509 *   the function returns CY_SYSPM_SUCCESS.
2510 * - CY_SYSPM_FAIL - The system ULP mode is not entered.
2511 *   For the PSoC 64 devices there are possible situations when function returns
2512 *   the PRA error status code. This is because for PSoC 64 devices the function
2513 *   uses the PRA driver to change the protected registers. Refer to
2514 *   \ref cy_en_pra_status_t for more details.
2515 *
2516 * \funcusage
2517 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_SystemEnterUlp
2518 *
2519 *******************************************************************************/
2520 cy_en_syspm_status_t Cy_SysPm_SystemEnterUlp(void);
2521 
2522 
2523 /*******************************************************************************
2524 * Function Name: Cy_SysPm_SystemEnterHibernate
2525 ****************************************************************************//**
2526 *
2527 * Sets the device into system Hibernate mode.
2528 *
2529 * Puts the device into the system Hibernate power mode. Prior to entering
2530 * Hibernate mode, all callbacks of the CY_SYSPM_HIBERNATE type are executed.
2531 *
2532 * First, callbacks of the CY_SYSPM_HIBERNATE type are called with the
2533 * CY_SYSPM_CHECK_READY parameter. This allows the callback to signal that the
2534 * driver is not ready to enter the system Hibernate power mode. If any of the
2535 * callback return CY_SYSPM_FAIL, the remaining CY_SYSPM_HIBERNATE callbacks are
2536 * skipped. In this case, all of the callbacks that have already been called are
2537 * called again with the CY_SYSPM_CHECK_FAIL parameter. System Hibernate mode is
2538 * not entered and the Cy_SysPm_SystemEnterHibernate() function returns
2539 * CY_SYSPM_FAIL.
2540 *
2541 * If all CY_SYSPM_HIBERNATE callbacks with the CY_SYSPM_CHECK_READY parameter
2542 * return CY_SYSPM_SUCCESS, then all CY_SYSPM_HIBERNATE callbacks with
2543 * CY_SYSPM_CHECK_FAIL calls are skipped and all CY_SYSPM_HIBERNATE callbacks
2544 * with CY_SYSPM_BEFORE_TRANSITION parameter are executed allowing the
2545 * peripherals to prepare for system Hibernate.
2546 *
2547 * The I/O output state is automatically frozen by hardware system and Hibernate
2548 * mode is then entered. In Hibernate mode, all internal supplies are off and no
2549 * internal state is retained. The only exception is resources powered by the
2550 * Vbackup domain continue to operate, if enabled. For multi-CPU devices, there
2551 * is no handshake with the CPUs and the chip will enter Hibernate power
2552 * mode immediately.
2553 *
2554 * \note The last callback that returns CY_SYSPM_FAIL is not executed with the
2555 * CY_SYSPM_CHECK_FAIL parameter because of the FAIL. The callback generating
2556 * CY_SYSPM_FAIL is expected to not make any changes that require being undone.
2557 *
2558 * The return value from executed callback functions with the
2559 * CY_SYSPM_CHECK_FAIL, CY_SYSPM_BEFORE_TRANSITION, and CY_SYSPM_AFTER_TRANSITION
2560 * modes are ignored.
2561 *
2562 * Wakeup from system Hibernate is triggered by toggling the wakeup pin(s), WDT
2563 * match, or back-up domain RTC alarm expiration, depending on how the they are
2564 * configured. A wakeup causes a normal boot procedure.
2565 * To configure the wakeup pin(s), a digital input pin must be configured, and
2566 * resistively pulled up or down to the inverse state of the wakeup polarity. To
2567 * distinguish a Hibernate mode from a general reset wakeup event, the
2568 * Cy_SysLib_GetResetReason() function can be used. The wakeup pin and low-power
2569 * comparators are active-low by default. The wakeup pin or the LPComparators
2570 * polarity can be changed with the \ref Cy_SysPm_SetHibernateWakeupSource()
2571 * function.
2572 * This function call will not return if system Hibernate mode is entered.
2573 * The CY_SYSPM_HIBERNATE callbacks with the CY_SYSPM_AFTER_TRANSITION parameter
2574 * are never executed.
2575 *
2576 * This function freezes the I/O pins implicitly. Entering system Hibernate mode
2577 * before freezing the I/O pins is not possible. The I/O pins remain frozen after
2578 * waking from Hibernate mode until the firmware unfreezes them with
2579 * a \ref Cy_SysPm_IoUnfreeze() function call.
2580 *
2581 * Boot firmware should reconfigure the I/O pins as required by the application
2582 * prior unfreezing them.
2583 *
2584 * To support control of callback execution order th following method is
2585 * implemented. Callback function with the CY_SYSPM_CHECK_READY and
2586 * CY_SYSPM_BEFORE_TRANSITION parameter are executed in the same order they are
2587 * registered. Callback function with the CY_SYSPM_CHECK_FAIL and
2588 * CY_SYSPM_AFTER_TRANSITION parameter are executed in the reverse order they
2589 * are registered.
2590 *
2591 * \return
2592 * Entered status, see \ref cy_en_syspm_status_t.
2593 * For the PSoC 64 devices there are possible situations when function returns
2594 * the PRA error status code. This is because for PSoC 64 devices the function
2595 * uses the PRA driver to change the protected registers. Refer to
2596 * \ref cy_en_pra_status_t for more details.
2597 *
2598 * \funcusage
2599 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_SystemEnterHibernate
2600 *
2601 *******************************************************************************/
2602 cy_en_syspm_status_t Cy_SysPm_SystemEnterHibernate(void);
2603 
2604 
2605 /*******************************************************************************
2606 * Function Name: Cy_SysPm_SetHibernateWakeupSource
2607 ****************************************************************************//**
2608 *
2609 * This function configures sources to wake up the device from the system
2610 * Hibernate power mode. Sources can be wakeup pins, LPComparators, Watchdog (WDT)
2611 * interrupt, or a Real-Time clock (RTC) alarm (interrupt). Wakeup from system
2612 * Hibernate always results in a device reset and normal boot process.
2613 *
2614 * Wakeup pins:
2615 *
2616 * A wakeup is supported by up to two pins with programmable polarity. These pins
2617 * are typically connected to the GPIO pins or on-chip peripherals under some
2618 * conditions. See device datasheet for specific pin connections.
2619 * Setting the wakeup pin to this level will cause a wakeup from system Hibernate
2620 * mode. The wakeup pins are active-low by default.
2621 *
2622 * LPComparators:
2623 *
2624 * A wakeup is supported by up to two LPComps with programmable polarity.
2625 * Setting the LPComp to this level will cause a wakeup from system Hibernate
2626 * mode. The wakeup LPComps are active-low by default.
2627 *
2628 * \note The low-power comparators should be configured and enabled before
2629 * switching to system Hibernate mode. Refer to the LPComp
2630 * driver description for more detail.
2631 *
2632 * Watchdog Timer:
2633 *
2634 * \note The WDT should be configured and enabled before entering to system
2635 * Hibernate mode.
2636 *
2637 * A wakeup is performed by a WDT interrupt.
2638 *
2639 * Real-time Clock:
2640 *
2641 * A wakeup is performed by the RTC alarm.
2642 * Refer to the Real-Time Clock (RTC) driver description for more detail.
2643 *
2644 * For information about wakeup sources and their assignment in specific
2645 * devices, refer to the appropriate device TRM.
2646 *
2647 * \param wakeupSource
2648 * The source to be configured as a wakeup source from
2649 * the system Hibernate power mode, see \ref cy_en_syspm_hibernate_wakeup_source_t.
2650 * The input parameter values can be ORed. For example, if you want to enable
2651 * LPComp0 (active high) and WDT, call this function:
2652 * Cy_SysPm_SetHibernateWakeupSource(CY_SYSPM_HIBERNATE_LPCOMP0_HIGH | CY_SYSPM_HIBERNATE_WDT).
2653 *
2654 * \warning Do not call this function with different polarity levels for the same
2655 * wakeup source. For example, do not call a function like this:
2656 * Cy_SysPm_SetHibernateWakeupSource(CY_SYSPM_HIBERNATE_LPCOMP0_LOW, CY_SYSPM_HIBERNATE_LPCOMP0_HIGH);
2657 *
2658 * \funcusage
2659 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_SetHibernateWakeupSource
2660 *
2661 *******************************************************************************/
2662 void Cy_SysPm_SetHibernateWakeupSource(uint32_t wakeupSource);
2663 
2664 
2665 /*******************************************************************************
2666 * Function Name: Cy_SysPm_ClearHibernateWakeupSource
2667 ****************************************************************************//**
2668 *
2669 * This function disables a wakeup source that was previously configured to
2670 * wake up the device from the system Hibernate mode.
2671 *
2672 * \param wakeupSource
2673 * For the source to be disabled, see \ref cy_en_syspm_hibernate_wakeup_source_t.
2674 * The input parameters values can be ORed. For example, if you want to disable
2675 * LPComp0 (active high) and WDT call this function:
2676 * Cy_SysPm_ClearHibernateWakeupSource(CY_SYSPM_HIBERNATE_LPCOMP0_HIGH | CY_SYSPM_HIBERNATE_WDT).
2677 *
2678 * \funcusage
2679 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_ClearHibernateWakeupSource
2680 *
2681 *******************************************************************************/
2682 void Cy_SysPm_ClearHibernateWakeupSource(uint32_t wakeupSource);
2683 
2684 
2685 /*******************************************************************************
2686 * Function Name: Cy_SysPm_SystemSetMinRegulatorCurrent
2687 ****************************************************************************//**
2688 *
2689 * Sets the system into minimum core regulator current mode. This mode limits
2690 * maximum current available for the system core logic.
2691 *
2692 * Minimum regulator current mode modifies operation of the system in LP or ULP
2693 * modes to further reduce current consumption. If the system current is below
2694 * datasheet current limits for the active core voltage regulator (LDO or Buck),
2695 * this mode may be entered. The user is responsible for ensuring the
2696 * regulator current limit is met in their application.
2697 *
2698 * When in minimum regulator current mode, the following system resources are
2699 * also set to their LP mode:
2700 * - Linear regulator (If LDO is active regulator)
2701 * - POR/BOD circuit
2702 * - Bandgap reference circuit
2703 * - Reference buffer circuit
2704 * - Current reference circuit
2705 *
2706 * The LDO and Buck current limits must be met prior to entering this
2707 * mode. If these are not met, the device may brown out, resulting in an
2708 * exception or reset. These changes also reduce power supply rejection of
2709 * the affected system resources, which can result in increased noise or response
2710 * time. These effects must be evaluated in each application.
2711 *
2712 * \return
2713 * See \ref cy_en_syspm_status_t.
2714 * - CY_SYSPM_SUCCESS - Minimum regulator current mode was set
2715 * - CY_SYSPM_CANCELED - The power circuits were not ready to enter into
2716 *   minimum current mode. You should call the function again.
2717 *   For the PSoC 64 devices there are possible situations when function returns
2718 *   the PRA error status code. This is because for PSoC 64 devices the function
2719 *   uses the PRA driver to change the protected registers. Refer to
2720 *   \ref cy_en_pra_status_t for more details.
2721 *
2722 * Refer to device datasheet for maximum current value in regulator minimum
2723 * current mode.
2724 *
2725 * \funcusage
2726 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_SystemSetMinRegulatorCurrent
2727 *
2728 *******************************************************************************/
2729 cy_en_syspm_status_t Cy_SysPm_SystemSetMinRegulatorCurrent(void);
2730 
2731 
2732 /*******************************************************************************
2733 * Function Name: Cy_SysPm_SystemSetNormalRegulatorCurrent
2734 ****************************************************************************//**
2735 *
2736 * Sets the system to normal regulator current mode.
2737 *
2738 * Normal regulator current mode modifies operation of the system in LP or ULP
2739 * modes to provide maximum core current consumption. If the LDO core regulator
2740 * is in use, the normal mode output current limits may be used. If the buck
2741 * regulator is in use, its reduced current output limits still apply.
2742 *
2743 * When in normal regulator current mode, the following system resources are set
2744 * to their normal mode:
2745 * - Linear regulator (If LDO is active regulator)
2746 * - POR/BOD circuit
2747 * - Bandgap reference circuit
2748 * - Reference buffer circuit
2749 * - Current reference circuit
2750 *
2751 * \return
2752 * - CY_SYSPM_SUCCESS - Normal regulator current mode was set
2753 * - CY_SYSPM_TIMEOUT - The timeout occurred because device was not
2754 *   ready to enter into the normal regulator current mode
2755 *   For the PSoC 64 devices there are possible situations when function returns
2756 *   the PRA error status code. This is because for PSoC 64 devices the function
2757 *   uses the PRA driver to change the protected registers. Refer to
2758 *   \ref cy_en_pra_status_t for more details.
2759 *
2760 * \funcusage
2761 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_SystemSetNormalRegulatorCurrent
2762 *
2763 *******************************************************************************/
2764 cy_en_syspm_status_t Cy_SysPm_SystemSetNormalRegulatorCurrent(void);
2765 
2766 
2767 /*******************************************************************************
2768 * Function Name: Cy_SysPm_CpuSleepOnExit
2769 ****************************************************************************//**
2770 *
2771 * This function configures the sleep-on-exit feature of the CPU.
2772 *
2773 * This API sets the SLEEPONEXIT bit of the SCR register.
2774 *
2775 * When the sleep-on-exit feature is enabled (the SLEEPONEXIT bit is set),
2776 * the CPU wakes up to service the interrupt and then immediately goes
2777 * back to sleep. Because of this, the unstacking process is not carried out, so
2778 * this feature is useful for interrupt driven application and helps to
2779 * reduce unnecessary stack push and pop operations.
2780 * The CPU does not go to sleep if the interrupt handler returns to
2781 * another interrupt handler (nested interrupt).
2782 * You can use this feature in applications that require the CPU to only run
2783 * when an interrupt occurs.
2784 *
2785 * When the sleep-on-exit feature is disabled (the SLEEPONEXIT bit is cleared),
2786 * the CPU returns back to the main thread after servicing the interrupt
2787 * without going back to sleep.
2788 *
2789 * Refer to the Arm documentation about the sleep-on-exit feature and
2790 * SLEEPONEXIT in the SCR register.
2791 *
2792 * \param enable
2793 * - True if enable sleep-on-exit feature.
2794 * - False if disable sleep-on-exit feature.
2795 *
2796 * \funcusage
2797 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_CpuSleepOnExit
2798 *
2799 *******************************************************************************/
2800 void Cy_SysPm_CpuSleepOnExit(bool enable);
2801 
2802 /** \} group_syspm_functions_power */
2803 
2804 /**
2805 * \addtogroup group_syspm_functions_iofreeze
2806 * \{
2807 */
2808 
2809 
2810 /*******************************************************************************
2811 * Function Name: Cy_SysPm_IoUnfreeze
2812 ****************************************************************************//**
2813 *
2814 * This function unfreezes the I/O cells that are automatically frozen when
2815 * Hibernate is entered with the call to \ref Cy_SysPm_SystemEnterHibernate().
2816 *
2817 * I/O cells remain frozen after a wakeup from Hibernate mode until the
2818 * firmware unfreezes them by calling this function.
2819 *
2820 * If the firmware must retain the data value on the pin, then the
2821 * value must be read and re-written to the pin's port data register before
2822 * calling this function. Furthermore, the drive mode must be re-programmed
2823 * before the pins are unfrozen. If this is not done, the pin will change to
2824 * the default state the moment the freeze is removed.
2825 *
2826 * Note that I/O cell configuration can be changed while frozen. The new
2827 * configuration becomes effective only after the pins are unfrozen.
2828 *
2829 * \funcusage
2830 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_IoUnfreeze
2831 *
2832 *******************************************************************************/
2833 void Cy_SysPm_IoUnfreeze(void);
2834 
2835 /** \} group_syspm_functions_iofreeze */
2836 
2837 /**
2838 * \addtogroup group_syspm_functions_ldo
2839 * \{
2840 */
2841 
2842 
2843 /*******************************************************************************
2844 * Function Name: Cy_SysPm_LdoSetVoltage
2845 ****************************************************************************//**
2846 *
2847 * Set output voltage on the core LDO regulator.
2848 *
2849 * When changing from a higher voltage to a lower voltage as when the device
2850 * enters system ULP mode, ensure that:
2851 * * The device maximum operating frequency for all the Clk_HF paths, peripheral,
2852 *   and slow clock are under the \ref group_syspm_ulp_limitations.
2853 * * The total current consumption is under the \ref group_syspm_ulp_limitations.
2854 * * The appropriate wait states values are set for the flash using
2855 *   The Cy_SysLib_SetWaitStates() function as explained below.
2856 *
2857 * <b>Setting wait states values for flash</b>
2858 *
2859 * The flash access time when the core voltage is 0.9 V (nominal) is
2860 * longer than at 1.1 V (nominal). Therefore, the number of the wait states must
2861 * be adjusted. Use the Cy_SysLib_SetWaitStates() function to set the appropriate
2862 * wait state values for flash.
2863 *
2864 * To change from a higher voltage to a lower voltage 0.9 V (nominal),
2865 * call the Cy_SysLib_SetWaitStates(true, hfClkFreqMz) function before changing
2866 * the voltage, where hfClkFreqMz is the frequency of HfClk0 in MHz.
2867 *
2868 * To change from a lower voltage to a higher voltage 1.1 V (nominal), calling
2869 * the Cy_SysLib_SetWaitStates(false, hfClkFreqMz) function to set the
2870 * wait states is optional, but can be done to improve performance.
2871 * The clock frequency may now be increased up to
2872 * \ref group_syspm_lp_limitations.
2873 *
2874 * \note 1. The output is set to 0.9 V (nominal) - the system is in ULP mode and
2875 * flash works for read-only operation.
2876 * \note 2. The output is set to 1.1 V (nominal) - the system is in LP mode
2877 * and flash works for read and write operations.
2878 * \note 3. The actual device Vccd voltage can be different from the nominal
2879 * voltage because the actual voltage value depends on conditions
2880 * including the load current.
2881 *
2882 * For more detail, refer to the \ref group_syspm_switching_into_ulp and
2883 * \ref group_syspm_switching_into_lp sections.
2884 * Refer to the \ref group_syslib driver for more detail about setting the wait
2885 * states.
2886 *
2887 * \param voltage
2888 * The desired output regulator voltage.
2889 * See \ref cy_en_syspm_ldo_voltage_t voltage
2890 *
2891 * \return
2892 * - CY_SYSPM_SUCCESS - The voltage is set.
2893 * - CY_SYSPM_INVALID_STATE - The voltage was not set. The voltage cannot be set
2894 *   because the protection context value is higher than zero (PC > 0) or the
2895 *   device revision does not support modifying registers via syscall.
2896 * - CY_SYSPM_CANCELED - Operation was canceled. Call the function again until
2897 *   the function returns CY_SYSPM_SUCCESS. See \ref cy_en_syspm_status_t.
2898 *   For the PSoC 64 devices there are possible situations when function returns
2899 *   the PRA error status code. This is because for PSoC 64 devices the function
2900 *   uses the PRA driver to change the protected registers. Refer to
2901 *   \ref cy_en_pra_status_t for more details.
2902 *
2903 * \funcusage
2904 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_VoltageRegulator
2905 *
2906 *******************************************************************************/
2907 cy_en_syspm_status_t Cy_SysPm_LdoSetVoltage(cy_en_syspm_ldo_voltage_t voltage);
2908 
2909 
2910 /*******************************************************************************
2911 * Function Name: Cy_SysPm_LdoSetMode
2912 ****************************************************************************//**
2913 *
2914 * Configures the core LDO regulator operating mode to one of three modes.
2915 * Disabled - turns off the LDO regulator and should be selected only after the
2916 * Buck regulator is operating. Normal mode configures the LDO for operation at
2917 * the maximum output current limit. Minimal current mode optimizes the LDO at a
2918 * reduced output current limit. Specific device current limits can be found in
2919 * the device datasheet.
2920 *
2921 * \param mode
2922 * The desired LDO regulator operating mode.
2923 * See \ref cy_en_syspm_ldo_mode_t mode
2924 *
2925 * \return
2926 * - CY_SYSPM_SUCCESS - Requested regulator current mode was set
2927 * - CY_SYSPM_CANCELED - The power circuits were not ready to enter into
2928 *   minimum current mode. You should try to call the function again
2929 * - CY_SYSPM_TIMEOUT - Timeout occurred because of active reference was not
2930 *   ready to enter into the normal regulator current mode
2931 * - CY_SYSPM_FAIL - incorrect mode value was passed
2932 *   For the PSoC 64 devices there are possible situations when function returns
2933 *   the PRA error status code. This is because for PSoC 64 devices the function
2934 *   uses the PRA driver to change the protected registers. Refer to
2935 *   \ref cy_en_pra_status_t for more details.
2936 *
2937 * \sideeffect
2938 * For PSoC 64 series devices CY_SYSPM_LDO_MODE_DISABLED mode is not supported.
2939 * Use \ref Cy_SysPm_BuckEnable() instead.
2940 *
2941 *******************************************************************************/
2942 cy_en_syspm_status_t Cy_SysPm_LdoSetMode(cy_en_syspm_ldo_mode_t mode);
2943 
2944 
2945 /*******************************************************************************
2946 * Function Name: Cy_SysPm_LdoGetMode
2947 ****************************************************************************//**
2948 *
2949 * Returns the current core LDO regulator operating mode.
2950 *
2951 * \return
2952 * The LDO regulator operating mode.
2953 * See \ref cy_en_syspm_ldo_mode_t mode
2954 *
2955 *******************************************************************************/
2956 cy_en_syspm_ldo_mode_t Cy_SysPm_LdoGetMode(void);
2957 /** \} group_syspm_functions_ldo */
2958 
2959 /**
2960 * \addtogroup group_syspm_functions_buck
2961 * \{
2962 */
2963 
2964 
2965 /*******************************************************************************
2966 * Function Name: Cy_SysPm_BuckEnable
2967 ****************************************************************************//**
2968 *
2969 * Switch the core supply regulator to Buck core regulator instead of the LDO
2970 * regulator.
2971 * The Buck core regulator provides output voltage(s) using one external
2972 * inductor and can supply Vccd with higher efficiency than the LDO under some
2973 * conditions, such as high external supply voltage.
2974 *
2975 * Before changing from LDO to Buck, ensure that the circuit board has
2976 * connected Vccbuck1 to Vccd and also populated the
2977 * necessary external components for the Buck regulator, including an
2978 * inductor and a capacitor for each output.
2979 * Refer to the device TRM for more detail.
2980 *
2981 * When changing from a higher voltage to a lower voltage
2982 * (from system LP = LDO 1.1 V (nominal) to system ULP = Buck 0.9 V (nominal)),
2983 * ensure that:
2984 * * The device maximum operating frequency for all the Clk_HF paths, peripheral,
2985 *   and slow clock are under the \ref group_syspm_ulp_limitations.
2986 * * The total current consumption is under the \ref group_syspm_ulp_limitations.
2987 *
2988 * * The appropriate wait states values are set for the flash using
2989 *   the Cy_SysLib_SetWaitStates() function as explained below.
2990 *
2991 * <b>Setting wait states values for flash</b>
2992 *
2993 * The flash access time when the core output voltage is 0.9 V (nominal) is
2994 * longer than at 1.1 V (nominal). Therefore, the number of the wait states must
2995 * be adjusted. Use the Cy_SysLib_SetWaitStates() function to set the appropriate
2996 * wait state values for flash.
2997 *
2998 * To change from a higher voltage (LDO 1.1 V) to a lower voltage (Buck 0.9 V),
2999 * call the Cy_SysLib_SetWaitStates(true, hfClkFreqMz) function before changing
3000 * the voltage, where hfClkFreqMz is the frequency of HfClk0 in MHz.
3001 *
3002 * To change from a lower voltage (LDO 0.9 V (nominal) to a higher voltage
3003 * (Buck 1.1 V (nominal)), call the Cy_SysLib_SetWaitStates(false,
3004 * hfClkFreqMz) function to set the wait states after the voltage change.
3005 * It is optional, but can be done to improve performance. The clock frequency
3006 * may now be increased up to system LP mode limits for the new voltage.
3007 *
3008 * \note 1. If the final Buck output is set to 0.9 V (nominal) - the system is in
3009 *  ULP mode and flash allows read-only operations.
3010 * \note 2. If the final Buck output is set to 1.1 V (nominal) - the system is in
3011 *  LP mode flash allows the read and write operations.
3012 * \note 3. The actual device Vccd voltage can be different from the nominal
3013 *  voltage because the actual voltage value depends on conditions
3014 *  including the load current.
3015 *
3016 * \warning There is no safe way to go back to the LDO after the
3017 *  Buck regulator supplies a core. The function enabling the Buck regulator
3018 *  switches off the LDO.
3019 *
3020 * \warning Buck converter requires additional external components populated on
3021 * dedicated pins. Refer to device datasheet for details.
3022 *
3023 * For more detail, refer to the \ref group_syspm_switching_into_ulp and
3024 * \ref group_syspm_switching_into_lp sections.
3025 * Refer to the \ref group_syslib driver for more detail about setting wait
3026 * states.
3027 *
3028 * \param voltage
3029 * The desired output 1 regulator voltage (Vccbuck1).
3030 * See \ref cy_en_syspm_buck_voltage1_t.
3031 *
3032 * \return
3033 * - CY_SYSPM_SUCCESS - The voltage is set as requested.
3034 *   (There is no change if the new voltage is the same as the previous voltage.)
3035 * - CY_SYSPM_INVALID_STATE - The voltage was not set. The voltage cannot be set
3036 *   because the protection context value is higher than zero (PC > 0) or the
3037 *   device revision does not support modifying registers via syscall.
3038 * - CY_SYSPM_CANCELED - Operation was canceled. Call the function again until
3039 *   the function returns CY_SYSPM_SUCCESS. See \ref cy_en_syspm_status_t.
3040 *   For the PSoC 64 devices there are possible situations when function returns
3041 *   the PRA error status code. This is because for PSoC 64 devices the function
3042 *   uses the PRA driver to change the protected registers. Refer to
3043 *   \ref cy_en_pra_status_t for more details.
3044 *
3045 * \note
3046 * The function is applicable only for devices with a Buck regulator.
3047 *
3048 * Function uses a critical section to prevent interrupting the regulators
3049 * switch.
3050 *
3051 * \funcusage
3052 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_BuckEnable
3053 *
3054 *******************************************************************************/
3055 cy_en_syspm_status_t Cy_SysPm_BuckEnable(cy_en_syspm_buck_voltage1_t voltage);
3056 
3057 
3058 /*******************************************************************************
3059 * Function Name: Cy_SysPm_BuckSetVoltage1
3060 ****************************************************************************//**
3061 *
3062 * Sets the output 1 voltage for the Buck regulator that can supply the device
3063 * core. This output can supply the device core instead of the LDO regulator.
3064 *
3065 * When changing from a higher voltage 1.1 V (nominal) to a lower voltage 0.9 V
3066 * (nominal), ensure that:
3067 * * The device maximum operating frequency for all the Clk_HF paths, peripheral,
3068 *   and slow clock are under the \ref group_syspm_ulp_limitations.
3069 * * The total current consumption is under the \ref group_syspm_ulp_limitations.
3070 * * The appropriate wait states values are set for the flash using
3071 *   the Cy_SysLib_SetWaitStates() function as explained below.
3072 *
3073 * <b>Setting wait states values for flash</b>
3074 *
3075 * The flash access time when the core output voltage is 0.9 V (nominal) is
3076 * longer than at 1.1 V (nominal). Therefore, the number of the wait states must
3077 * be adjusted. Use the Cy_SysLib_SetWaitStates() function to set the appropriate
3078 * wait state values for flash.
3079 *
3080 * To change from a higher voltage to a lower voltage 0.9 V (nominal),
3081 * call the Cy_SysLib_SetWaitStates(true, hfClkFreqMz) function before changing
3082 * the voltage, where hfClkFreqMz is the frequency of HfClk0 in MHz.
3083 *
3084 * To change from a lower voltage to a higher voltage 1.1 V (nominal), call
3085 * the Cy_SysLib_SetWaitStates(false, hfClkFreqMz) function to set the
3086 * wait states. It is optional, but can be done to improve the performance.
3087 * The clock frequency may now be increased up to
3088 * \ref group_syspm_lp_limitations for a new voltage.
3089 *
3090 * \note 1. The output is set to 0.9 V (nominal) - the system  is in ULP mode
3091 *  flash allows read-only operations.
3092 * \note 2. The output is set to 1.1 V (nominal) - the system is in LP mode and
3093 *  flash allows the read and write operations.
3094 * \note 3. The actual device Vccd voltage can be different from the nominal
3095 *  voltage because the actual voltage value depends on the conditions
3096 *  including the load current.
3097 *
3098 * \warning Buck converter requires additional external components populated on
3099 * dedicated pins. Refer to device datasheet for details.
3100 *
3101 * For more detail, refer to the \ref group_syspm_switching_into_ulp and
3102 * \ref group_syspm_switching_into_lp sections.
3103 * Refer to the \ref group_syslib driver for more detail about setting the
3104 * wait states.
3105 *
3106 * \param voltage
3107 * The desired output 1 regulator voltage (Vccbuck1).
3108 * See \ref cy_en_syspm_buck_voltage1_t
3109 *
3110 * \return
3111 * - CY_SYSPM_SUCCESS - The voltage is set.
3112 * - CY_SYSPM_INVALID_STATE - The voltage was not set. The voltage cannot be set
3113 *   because the protection context value is higher than zero (PC > 0) or the
3114 *   device revision does not support modifying registers via syscall.
3115 * - CY_SYSPM_CANCELED - Operation was canceled. Call the function again until
3116 *   the function returns CY_SYSPM_SUCCESS. See \ref cy_en_syspm_status_t.
3117 *   For the PSoC 64 devices there are possible situations when function returns
3118 *   the PRA error status code. This is because for PSoC 64 devices the function
3119 *   uses the PRA driver to change the protected registers. Refer to
3120 *   \ref cy_en_pra_status_t for more details.
3121 *
3122 * \funcusage
3123 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_VoltageRegulator
3124 *
3125 * \sideeffect
3126 * For PSoC 64 series devices Cy_SysPm_BuckSetVoltage1() has the same functional
3127 * behavior as \ref Cy_SysPm_BuckEnable() function.
3128 *
3129 *******************************************************************************/
3130 cy_en_syspm_status_t Cy_SysPm_BuckSetVoltage1(cy_en_syspm_buck_voltage1_t voltage);
3131 
3132 
3133 /*******************************************************************************
3134 * Function Name: Cy_SysPm_BuckSetVoltage2
3135 ****************************************************************************//**
3136 *
3137 * This function sets output voltage 2 (Vbuckrf) of the SIMO Buck regulator.
3138 *
3139 * \param voltage
3140 * The voltage of the Buck regulator output 2 (Vbuckrf).
3141 * See \ref cy_en_syspm_buck_voltage2_t.
3142 *
3143 * \param waitToSettle
3144 * - True to enable the 200 us delay after setting a higher voltage.
3145 * - False to disable the 200 us delay after setting a higher voltage.
3146 *
3147 * \warning You must enable the delay (waitToSettle = true)
3148 * while changing from a lower voltage to a higher voltage.
3149 *
3150 * \note The 200 us delay is required only when changing from a
3151 * lower voltage to a higher voltage. When changing from a higher voltage to a
3152 * lower one, the delay is not required.
3153 *
3154 * \warning The function works only on devices with the SIMO Buck regulator.
3155 * Refer to the device datasheet for information on whether the device contains
3156 * SIMO Buck.
3157 *
3158 * \warning Buck converter requires additional external components populated on
3159 * dedicated pins. Refer to device datasheet for details.
3160 *
3161 * \funcusage
3162 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_BuckSetVoltage2
3163 *
3164 *******************************************************************************/
3165 void Cy_SysPm_BuckSetVoltage2(cy_en_syspm_buck_voltage2_t voltage, bool waitToSettle);
3166 
3167 
3168 /*******************************************************************************
3169 * Function Name: Cy_SysPm_BuckEnableVoltage2
3170 ****************************************************************************//**
3171 *
3172 * Enable the output 2 voltage (Vbuckrf) of the SIMO Buck regulator.
3173 * The output 2 voltage (Vbuckrf) of the Buck regulator is typically used to
3174 * supply the BLE radio.
3175 * This function does following actions, when the Buck regulator does not
3176 * supply the core:
3177 * * Enables the Buck regulator
3178 * * Enables the output 2, but do not enables the output 1.
3179 *
3180 * \note The function does not affect Buck output 1 that typically supplies core.
3181 *
3182 * \warning The function does not select the Buck output 2 voltage and
3183 * does not set/clear the HW-controlled bit for Buck output 2. Call
3184 * Cy_SysPm_BuckSetVoltage2() or Cy_SysPm_BuckSetVoltage2HwControl() to
3185 * configure the Buck output 2.
3186 *
3187 * \warning The function works only on devices with the SIMO Buck regulator.
3188 * Refer to the device datasheet for information on whether the device contains
3189 * the SIMO Buck.
3190 *
3191 * \warning Buck converter requires additional external components populated on
3192 * dedicated pins. Refer to device datasheet for details.
3193 *
3194 * \funcusage
3195 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_BuckEnableVoltage2
3196 *
3197 *******************************************************************************/
3198 void Cy_SysPm_BuckEnableVoltage2(void);
3199 
3200 
3201 /*******************************************************************************
3202 * Function Name: Cy_SysPm_BuckIsOutputEnabled
3203 ****************************************************************************//**
3204 *
3205 * This function gets the current output status of the Buck outputs.
3206 *
3207 * \param output
3208 * The Buck regulator output. See \ref cy_en_syspm_buck_out_t.
3209 *
3210 * \return
3211 * - True if the requested output is enabled.
3212 * - False if the requested output is disabled.
3213 *
3214 * \funcusage
3215 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_BuckIsOutputEnabled
3216 *
3217 *******************************************************************************/
3218 bool Cy_SysPm_BuckIsOutputEnabled(cy_en_syspm_buck_out_t output);
3219 /** \} group_syspm_functions_buck */
3220 
3221 /**
3222 * \addtogroup group_syspm_functions_callback
3223 * \{
3224 */
3225 
3226 
3227 /*******************************************************************************
3228 * Function Name: Cy_SysPm_RegisterCallback
3229 ****************************************************************************//**
3230 *
3231 * Registers a new syspm callback.
3232 *
3233 * A callback is a function called after an event in the driver or
3234 * middleware module has occurred. The handler callback API will be executed if
3235 * the specific event occurs. SysPm callbacks are called when changing power
3236 * modes. See \ref cy_stc_syspm_callback_t.
3237 *
3238 * \note The registered callbacks are executed in two orders, based on callback
3239 * mode \ref cy_en_syspm_callback_mode_t. For modes CY_SYSPM_CHECK_READY and
3240 * CY_SYSPM_BEFORE_TRANSITION, the order is same order as callbacks were
3241 * registered.
3242 * For modes CY_SYSPM_AFTER_TRANSITION and CY_SYSPM_CHECK_FAIL, the order is
3243 * reverse as the order callbacks were registered.
3244 *
3245 * \param handler
3246 * The address of the syspm callback structure.
3247 * See \ref cy_stc_syspm_callback_t.
3248 *
3249 * \return
3250 * - True if a callback was registered.
3251 * - False if a callback was not registered.
3252 *
3253 * \note Do not modify the registered structure in run-time.
3254 * \warning After being registered, the SysPm callback structures must be
3255 * allocated during power mode transition.
3256 *
3257 * \funcusage
3258 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_Callback_Func_Declaration
3259 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_Callback_Params_Declaration
3260 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_Callback_Structure_Declaration
3261 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_Callback_Func_Implementation
3262 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_RegisterCallback
3263 *
3264 *******************************************************************************/
3265 bool Cy_SysPm_RegisterCallback(cy_stc_syspm_callback_t *handler);
3266 
3267 
3268 /*******************************************************************************
3269 * Function Name: Cy_SysPm_UnregisterCallback
3270 ****************************************************************************//**
3271 *
3272 * This function unregisters a callback.
3273 *
3274 * The registered callback can be unregistered and the function returns true.
3275 * Otherwise, false is returned.
3276 *
3277 * \param handler The item that should be unregistered.
3278 * See \ref cy_stc_syspm_callback_t.
3279 *
3280 * \return
3281 * - True if callback was unregistered.
3282 * - False if it was not unregistered or no callbacks are registered.
3283 *
3284 * \funcusage
3285 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_UnregisterCallback
3286 *
3287 *******************************************************************************/
3288 bool Cy_SysPm_UnregisterCallback(cy_stc_syspm_callback_t const *handler);
3289 
3290 
3291 /*******************************************************************************
3292 * Function Name: Cy_SysPm_ExecuteCallback
3293 ****************************************************************************//**
3294 *
3295 * The function executes all registered callbacks with provided type and mode.
3296 * \note This low-level function is being used by \ref Cy_SysPm_CpuEnterSleep,
3297 * \ref Cy_SysPm_CpuEnterDeepSleep, \ref Cy_SysPm_SystemEnterHibernate,
3298 * \ref Cy_SysPm_SystemEnterUlp and \ref Cy_SysPm_SystemEnterLp API functions.
3299 * However, it might be also useful as an independent API function in some custom
3300 * applications.
3301 *
3302 * \note The registered callbacks will be executed in order based on
3303 * \ref cy_en_syspm_callback_type_t value. There are two possible callback
3304 * execution orders:
3305 * * From first registered to last registered. This order applies to
3306 *   callbacks with mode CY_SYSPM_CHECK_READY and CY_SYSPM_BEFORE_TRANSITION.
3307 * * Backward flow execution:
3308 *   - From last registered to the first registered. This order applies
3309 *     to callbacks with mode CY_SYSPM_AFTER_TRANSITION.
3310 *   - From last called to the first registered callback. This order applies
3311 *     to callbacks with mode CY_SYSPM_CHECK_FAIL. Note that, the last called
3312 *     callback function  that generated the CY_SYSPM_CHECK_FAIL is skipped when
3313 *     mode CY_SYSPM_CHECK_FAIL. This is because the callback that returns
3314 *     CY_SYSPM_FAIL already knows that it failed and will not take any action
3315 *     that requires correction.
3316 *
3317 * If no callbacks are registered, returns CY_SYSPM_SUCCESS.
3318 *
3319 * \param type
3320 * The callback type. See \ref cy_en_syspm_callback_type_t.
3321 *
3322 * \param mode
3323 * The callback mode. See \ref cy_en_syspm_callback_mode_t.
3324 *
3325 * \return
3326 * - CY_SYSPM_SUCCESS if callback successfully completed or nor callbacks
3327 *   registered.
3328 * - CY_SYSPM_FAIL one of the executed callback(s) returned fail.
3329 *
3330 * \funcusage
3331 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_ExecuteCallback
3332 *
3333 *******************************************************************************/
3334 cy_en_syspm_status_t Cy_SysPm_ExecuteCallback(cy_en_syspm_callback_type_t type, cy_en_syspm_callback_mode_t mode);
3335 
3336 
3337 /*******************************************************************************
3338 * Function Name: Cy_SysPm_GetFailedCallback
3339 ****************************************************************************//**
3340 *
3341 * Reads the result of the callback execution after the power mode functions
3342 * execution.
3343 *
3344 * This function reads the value of the pointer that stores the result of callback
3345 * execution. It takes power mode as the parameter and returns the address of the
3346 * callback configuration structure in the case of failure or NULL in the case of
3347 * success. This address of the failed callback allows finding the callback that
3348 * blocks entering power mode.
3349 *
3350 * \param type
3351 * Power mode for which a callback execution result is required.
3352 *
3353 * \return
3354 * - The address of the callback configuration structure if the callback handler
3355 * function failed.
3356 * - NULL if the callback skipped or executed successfully.
3357 *
3358 * \funcusage
3359 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_GetFailedCallback
3360 *
3361 *******************************************************************************/
3362 cy_stc_syspm_callback_t* Cy_SysPm_GetFailedCallback(cy_en_syspm_callback_type_t type);
3363 /** \} group_syspm_functions_callback */
3364 
3365 /**
3366 * \addtogroup group_syspm_functions_power_status
3367 * \{
3368 */
3369 /*******************************************************************************
3370 * Function Name: Cy_SysPm_Cm4IsActive
3371 ****************************************************************************//**
3372 *
3373 * Checks if CM4 is in CPU Active mode.
3374 *
3375 * \return
3376 * - True if CM4 is in CPU Active mode.
3377 * - False if the CM4 is not in CPU Active mode.
3378 *
3379 * \funcusage
3380 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_Cm4IsActive
3381 *
3382 *******************************************************************************/
3383 bool Cy_SysPm_Cm4IsActive(void);
3384 
3385 
3386 /*******************************************************************************
3387 * Function Name: Cy_SysPm_Cm4IsSleep
3388 ****************************************************************************//**
3389 *
3390 * Checks if the CM4 is in CPU Sleep mode.
3391 *
3392 * \return
3393 * - True if the CM4 is in CPU Sleep mode.
3394 * - False if the CM4 is not in CPU Sleep mode.
3395 *
3396 * \funcusage
3397 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_Cm4IsSleep
3398 *
3399 *******************************************************************************/
3400 bool Cy_SysPm_Cm4IsSleep(void);
3401 
3402 
3403 /*******************************************************************************
3404 * Function Name: Cy_SysPm_Cm4IsDeepSleep
3405 ****************************************************************************//**
3406 *
3407 * Checks if the CM4 is in the CPU Deep Sleep mode.
3408 *
3409 * \return
3410 * - True if CM4 is in CPU Deep Sleep mode.
3411 * - False if the CM4 is not CPU in Deep Sleep mode.
3412 *
3413 * \funcusage
3414 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_Cm4IsDeepSleep
3415 *
3416 *******************************************************************************/
3417 bool Cy_SysPm_Cm4IsDeepSleep(void);
3418 
3419 
3420 /*******************************************************************************
3421 * Function Name: Cy_SysPm_Cm0IsActive
3422 ****************************************************************************//**
3423 *
3424 * Checks if the CM0+ is in CPU Active mode.
3425 *
3426 * \return
3427 * - True if the CM0+ is in CPU Sleep mode.
3428 * - False if the CM0+ is not in CPU Sleep mode.
3429 *
3430 * \funcusage
3431 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_Cm0IsActive
3432 *
3433 *******************************************************************************/
3434 bool Cy_SysPm_Cm0IsActive(void);
3435 
3436 
3437 /*******************************************************************************
3438 * Function Name: Cy_SysPm_Cm0IsSleep
3439 ****************************************************************************//**
3440 *
3441 * Checks if the CM0+ is in CPU Sleep mode.
3442 *
3443 * \return
3444 * - True if the CM0+ is in CPU Sleep mode.
3445 * - False if the CM0+ is not in CPU Sleep mode.
3446 *
3447 * \funcusage
3448 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_Cm0IsSleep
3449 *
3450 *******************************************************************************/
3451 bool Cy_SysPm_Cm0IsSleep(void);
3452 
3453 
3454 /*******************************************************************************
3455 * Function Name: Cy_SysPm_Cm0IsDeepSleep
3456 ****************************************************************************//**
3457 *
3458 * Checks if the CM0+ is in CPU Deep Sleep mode.
3459 *
3460 * \return
3461 * - True if the CM0+ is in CPU Deep Sleep mode
3462 * - False if the CM0+ is not in CPU Deep Sleep mode
3463 *
3464 * \funcusage
3465 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_Cm0IsDeepSleep
3466 *
3467 *******************************************************************************/
3468 bool Cy_SysPm_Cm0IsDeepSleep(void);
3469 
3470 
3471 /*******************************************************************************
3472 * Function Name: Cy_SysPm_IsSystemLp
3473 ****************************************************************************//**
3474 *
3475 * Checks if the system is in LP mode.
3476 *
3477 * \return
3478 * - True the system is in LP mode.
3479 * - False the system is not in LP mode.
3480 *
3481 * \funcusage
3482 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_IsSystemLp
3483 *
3484 *******************************************************************************/
3485 bool Cy_SysPm_IsSystemLp(void);
3486 
3487 /*******************************************************************************
3488 * Function Name: Cy_SysPm_IsSystemUlp
3489 ****************************************************************************//**
3490 *
3491 * Checks if the system is in ULP mode.
3492 *
3493 * \return
3494 * - True the system is in ULP mode.
3495 * - False the system is is not ULP mode.
3496 *
3497 * \funcusage
3498 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_IsSystemUlp
3499 *
3500 *******************************************************************************/
3501 bool Cy_SysPm_IsSystemUlp(void);
3502 /** \} group_syspm_functions_power_status */
3503 
3504 
3505 /**
3506 * \addtogroup group_syspm_functions_power
3507 * \{
3508 */
3509 /*******************************************************************************
3510 * Function Name: Cy_SysPm_CpuSendWakeupEvent
3511 ****************************************************************************//**
3512 *
3513 * Sends the SEV (Send Event) ARM instruction to the system.
3514 *
3515 * \funcusage
3516 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_CpuSendWakeupEvent
3517 *
3518 *******************************************************************************/
3519 void Cy_SysPm_CpuSendWakeupEvent(void);
3520 
3521 
3522 /*******************************************************************************
3523 * Function Name: Cy_SysPm_SystemIsMinRegulatorCurrentSet
3524 ****************************************************************************//**
3525 *
3526 * Check whether the system regulator is set to minimal current mode.
3527 *
3528 * \return
3529 * - True - system is in regulator minimum current mode.
3530 * - False - system is in normal regulator current mode.
3531 *
3532 * \funcusage
3533 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_SystemSetNormalRegulatorCurrent
3534 *
3535 * \note CAT1B devices, function always returns 0.
3536 *
3537 *******************************************************************************/
3538 bool Cy_SysPm_SystemIsMinRegulatorCurrentSet(void);
3539 /** \} group_syspm_functions_power */
3540 
3541 
3542 /**
3543 * \addtogroup group_syspm_functions_buck
3544 * \{
3545 */
3546 /*******************************************************************************
3547 * Function Name: Cy_SysPm_BuckIsEnabled
3548 ****************************************************************************//**
3549 *
3550 * Get the current status of the Buck regulator.
3551 *
3552 * \return
3553 * - True if the Buck regulator is enabled.
3554 * - False if it is disabled.
3555 *
3556 * \funcusage
3557 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_VoltageRegulator
3558 *
3559 *******************************************************************************/
3560 bool Cy_SysPm_BuckIsEnabled(void);
3561 
3562 
3563 /*******************************************************************************
3564 * Function Name: Cy_SysPm_BuckGetVoltage1
3565 ****************************************************************************//**
3566 *
3567 * Gets the current nominal output 1 voltage (Vccbuck1) of
3568 * the Buck regulator.
3569 *
3570 * \note The actual device output 1 voltage (Vccbuck1) can be different from
3571 * the nominal voltage because the actual voltage value depends on conditions
3572 * including load current.
3573 *
3574 * \return
3575 * The nominal output voltage 1 (Vccbuck1) of the Buck regulator.
3576 * See \ref cy_en_syspm_buck_voltage1_t.
3577 *
3578 * \funcusage
3579 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_VoltageRegulator
3580 *
3581 * \note CAT1B devices, function always returns 0.
3582 *
3583 *******************************************************************************/
3584 cy_en_syspm_buck_voltage1_t Cy_SysPm_BuckGetVoltage1(void);
3585 
3586 /*******************************************************************************
3587 * Function Name: Cy_SysPm_BuckGetVoltage2
3588 ****************************************************************************//**
3589 *
3590 * Gets the current output 2 nominal voltage (Vbuckrf) of the SIMO
3591 * Buck regulator.
3592 *
3593 * \note The actual device output 2 voltage (Vbuckrf) can be different from the
3594 * nominal voltage because the actual voltage value depends on conditions
3595 * including load current.
3596 *
3597 * \return
3598 * The nominal output voltage of the Buck SIMO regulator output 2
3599 * voltage (Vbuckrf). See \ref cy_en_syspm_buck_voltage2_t.
3600 *
3601 * \note
3602 * Function returns zero for devices without a SIMO Buck regulator.
3603 * Refer to the device datasheet about information on whether device contains
3604 * a SIMO Buck.
3605 *
3606 * \funcusage
3607 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_BuckGetVoltage2
3608 *
3609 *******************************************************************************/
3610 cy_en_syspm_buck_voltage2_t Cy_SysPm_BuckGetVoltage2(void);
3611 
3612 /*******************************************************************************
3613 * Function Name: Cy_SysPm_BuckDisableVoltage2
3614 ****************************************************************************//**
3615 *
3616 * Disables the output 2 voltage (Vbuckrf) of the SIMO Buck regulator. The
3617 * output 2 voltage (Vbuckrf) of the Buck regulator is typically used to supply
3618 * the BLE radio.
3619 *
3620 * \note The function does not have effect, if the Buck regulator is
3621 * switched off.
3622 *
3623 * \note If you are switching the voltage supply source for BLE radio, ensure
3624 * that the new voltage supply for the BLE HW block is settled
3625 * and is stable before calling the Cy_SysPm_BuckDisableVoltage2() function.
3626 *
3627 * This function is applicable for devices with the SIMO Buck regulator.
3628 * Refer to the device datasheet for information about whether the device
3629 * contains a SIMO Buck.
3630 *
3631 * \funcusage
3632 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_BuckDisableVoltage2
3633 *
3634 *******************************************************************************/
3635 void Cy_SysPm_BuckDisableVoltage2(void);
3636 
3637 /*******************************************************************************
3638 * Function Name: Cy_SysPm_BuckSetVoltage2HwControl
3639 ****************************************************************************//**
3640 *
3641 * Sets the hardware control for SIMO Buck output 2 (Vbuckrf).
3642 *
3643 * When hardware control is enabled for the Vbuckrf output, the firmware
3644 * controlled enable register setting is ignored and the hardware signal is used
3645 * instead. If the product has supporting hardware like BLE radio, it can
3646 * directly control the enable signal for Vbuckrf.
3647 *
3648 * \param hwControl
3649 * Enables/disables hardware control for the SIMO Buck output 2.
3650 *
3651 * Function does not have an effect if SIMO Buck regulator is disabled.
3652 *
3653 * The function is applicable for devices with the SIMO Buck regulator.
3654 * Refer to the device datasheet for information about whether the device
3655 * contains a SIMO Buck.
3656 *
3657 * \funcusage
3658 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_BuckSetVoltage2HwControl
3659 *
3660 *******************************************************************************/
3661 void Cy_SysPm_BuckSetVoltage2HwControl(bool hwControl);
3662 
3663 /*******************************************************************************
3664 * Function Name: Cy_SysPm_BuckIsVoltage2HwControlled
3665 ****************************************************************************//**
3666 *
3667 * Returns the hardware control state for Buck output 2 (Vbuckrf).
3668 *
3669 * When hardware control is enabled for the Vbuckrf output, the firmware
3670 * controlled enable register setting is ignored and the hardware signal is used
3671 * instead. If the product has supporting hardware like BLE radio, it can
3672 * directly control the enable signal for Vbuckrf.
3673 *
3674 * \return
3675 * - True if HW control is set.
3676 * - False if FW control is set for the Buck output 2.
3677 *
3678 * The function is applicable for devices with the SIMO Buck regulator.
3679 * Refer to device datasheet about information if device contains
3680 * SIMO Buck.
3681 *
3682 * \funcusage
3683 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_BuckIsVoltage2HwControlled
3684 *
3685 *******************************************************************************/
3686 bool Cy_SysPm_BuckIsVoltage2HwControlled(void);
3687 /** \} group_syspm_functions_buck */
3688 
3689 
3690 /**
3691 * \addtogroup group_syspm_functions_ldo
3692 * \{
3693 */
3694 /*******************************************************************************
3695 * Function Name: Cy_SysPm_LdoGetVoltage
3696 ****************************************************************************//**
3697 *
3698 * Gets the current output voltage value of the core LDO regulator.
3699 *
3700 * \note The actual device Vccd voltage can be different from the
3701 * nominal voltage because the actual voltage value depends on conditions
3702 * including the load current.
3703 *
3704 * \return
3705 * The nominal output voltage of the LDO. See \ref cy_en_syspm_ldo_voltage_t.
3706 *
3707 * \funcusage
3708 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_VoltageRegulator
3709 *
3710 *
3711 * \note CAT1B devices, function always returns 0.
3712 *
3713 *******************************************************************************/
3714 cy_en_syspm_ldo_voltage_t Cy_SysPm_LdoGetVoltage(void);
3715 
3716 
3717 /*******************************************************************************
3718 * Function Name: Cy_SysPm_LdoIsEnabled
3719 ****************************************************************************//**
3720 *
3721 * Reads the current status of the core LDO regulator.
3722 *
3723 * \return
3724 * - True means the LDO is enabled.
3725 * - False means it is disabled.
3726 *
3727 * \funcusage
3728 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_VoltageRegulator
3729 *
3730 * \note For CAT1B devices IP, function always returns 0.
3731 *
3732 *******************************************************************************/
3733 bool Cy_SysPm_LdoIsEnabled(void);
3734 /** \} group_syspm_functions_ldo */
3735 
3736 
3737 /**
3738 * \addtogroup group_syspm_functions_iofreeze
3739 * \{
3740 */
3741 /*******************************************************************************
3742 * Function Name: Cy_SysPm_IoIsFrozen
3743 ****************************************************************************//**
3744 *
3745 * Checks whether IOs are frozen.
3746 *
3747 * \return
3748 * - True if IOs are frozen.
3749 * - False if IOs are unfrozen.
3750 *
3751 * \funcusage
3752 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_IoUnfreeze
3753 *
3754 *******************************************************************************/
3755 bool Cy_SysPm_IoIsFrozen(void);
3756 /** \} group_syspm_functions_iofreeze */
3757 
3758 /**
3759 * \addtogroup group_syspm_functions_pmic
3760 * \{
3761 */
3762 
3763 
3764 /*******************************************************************************
3765 * Function Name: Cy_SysPm_PmicEnable
3766 ****************************************************************************//**
3767 *
3768 * Enable the external PMIC controller that supplies Vddd (if present).
3769 *
3770 * For information about the PMIC controller input and output pins and their
3771 * assignment in specific devices, refer to the appropriate device TRM.
3772 *
3773 * This function is not effective when the PMIC controller is locked. Call
3774 * Cy_SysPm_PmicUnlock() before enabling the PMIC.
3775 *
3776 * \funcusage
3777 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_PmicEnable
3778 *
3779 *******************************************************************************/
3780 void Cy_SysPm_PmicEnable(void);
3781 
3782 
3783 /*******************************************************************************
3784 * Function Name: Cy_SysPm_PmicDisable
3785 ****************************************************************************//**
3786 *
3787 * Disable the external PMIC controller that supplies Vddd (if present).
3788 * This function does not affect the PMIC controller output pin. The PMIC
3789 * controller input pin has programmable polarity to
3790 * enable the external PMIC using different input polarities. The PMIC controller
3791 * is automatically enabled when the input pin polarity and configured polarity
3792 * match. This function is not effective when the active level of PMIC controller
3793 * input pin is equal to the configured PMIC controller polarity.
3794 *
3795 * The function is not effective when the PMIC controller is locked. Call
3796 * Cy_SysPm_PmicUnlock() before enabling the PMIC controller.
3797 *
3798 * \param polarity
3799 * Configures the PMIC controller wakeup input pin to be active low or active
3800 * high. The PMIC will be automatically enabled when the set polarity and the
3801 * active level of PMIC input pin match.
3802 * See \ref cy_en_syspm_pmic_wakeup_polarity_t.
3803 *
3804 * The PMIC controller will be enabled automatically by any of RTC alarm or
3805 * PMIC wakeup events, regardless of the PMIC controller lock state.
3806 *
3807 * \note
3808 * Before disabling the PMIC controller, ensure that PMIC input and PMIC output
3809 * pins are configured correctly to enable expected PMIC operation.
3810 *
3811 * \warning
3812 * The PMIC is enabled automatically when you call Cy_SysPm_PmicLock().
3813 * To keep the external PMIC disabled, the PMIC controller must remain unlocked.
3814 *
3815 * \warning
3816 * Do not call Cy_SysPm_PmicDisable(CY_SYSPM_PMIC_POLARITY_LOW) because this
3817 * is not supported by hardware.
3818 *
3819 * For information about the PMIC controller input and output pins and their
3820 * assignment in the specific devices, refer to the appropriate
3821 * device TRM.
3822 *
3823 * \funcusage
3824 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_PmicDisable
3825 *
3826 *******************************************************************************/
3827 void Cy_SysPm_PmicDisable(cy_en_syspm_pmic_wakeup_polarity_t polarity);
3828 
3829 
3830 /*******************************************************************************
3831 * Function Name: Cy_SysPm_PmicAlwaysEnable
3832 ****************************************************************************//**
3833 *
3834 * Enable the external PMIC controller that supplies Vddd (if present) and force
3835 * active. This is a Write once API. It ensures that the PMIC controller cannot
3836 * be disabled or polarity changed until a next device reset.
3837 *
3838 * For information about the PMIC controller input and output pins and their
3839 * assignment in the specific devices, refer to the appropriate device TRM.
3840 *
3841 * \funcusage
3842 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_PmicAlwaysEnable
3843 *
3844 *******************************************************************************/
3845 void Cy_SysPm_PmicAlwaysEnable(void);
3846 
3847 
3848 /*******************************************************************************
3849 * Function Name: Cy_SysPm_PmicEnableOutput
3850 ****************************************************************************//**
3851 *
3852 * Enables the PMIC controller output pin.
3853 *
3854 * The function is not effective when the PMIC controller is locked. Call
3855 * Cy_SysPm_PmicUnlock() before enabling the PMIC controller.
3856 *
3857 * For information about the PMIC controller output pin and its assignment in
3858 * specific devices, refer to the appropriate device TRM.
3859 *
3860 * \funcusage
3861 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_PmicEnableOutput
3862 *
3863 *******************************************************************************/
3864 void Cy_SysPm_PmicEnableOutput(void);
3865 
3866 
3867 /*******************************************************************************
3868 * Function Name: Cy_SysPm_PmicDisableOutput
3869 ****************************************************************************//**
3870 *
3871 * Disables the PMIC controller output pin.
3872 *
3873 * When the PMIC controller output pin is disabled and is unlocked, the PMIC
3874 * controller output pin can be used for the another purpose.
3875 *
3876 * The function has no effect when the PMIC is locked. Call
3877 * Cy_SysPm_PmicUnlock() before enabling the PMIC.
3878 *
3879 * For information about the PMIC controller output pin and its assignment in
3880 * specific devices, refer to the appropriate device TRM.
3881 *
3882 * \note
3883 * After the PMIC controller output is disabled, the PMIC output pin returns to
3884 * its GPIO configured state.
3885 *
3886 * \warning
3887 * The PMIC controller output is enabled automatically when you call
3888 * Cy_SysPm_PmicLock(). To keep the PMIC controller output disabled, the PMIC
3889 * controller must remain unlocked.
3890 *
3891 * \funcusage
3892 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_PmicDisableOutput
3893 *
3894 *******************************************************************************/
3895 void Cy_SysPm_PmicDisableOutput(void);
3896 
3897 
3898 /*******************************************************************************
3899 * Function Name: Cy_SysPm_PmicLock
3900 ****************************************************************************//**
3901 *
3902 * Locks the PMIC control controller register so that no changes can be made.
3903 * The changes are related to PMIC enabling/disabling and PMIC output pin
3904 * enabling/disabling.
3905 *
3906 * \warning
3907 * The PMIC controller and/or the PMIC output are enabled automatically when
3908 * you call Cy_SysPm_PmicLock(). To keep the PMIC or PMIC controller output
3909 * disabled, the PMIC controller must remain unlocked.
3910 *
3911 * \funcusage
3912 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_PmicLock
3913 *
3914 *******************************************************************************/
3915 void Cy_SysPm_PmicLock(void);
3916 
3917 
3918 /*******************************************************************************
3919 * Function Name: Cy_SysPm_PmicUnlock
3920 ****************************************************************************//**
3921 *
3922 * Unlocks the PMIC control register so that changes can be made. The changes are
3923 * related to the PMIC controller enabling/disabling and PMIC output pin
3924 * enabling/disabling.
3925 *
3926 * \warning
3927 * The PMIC controller and/or the PMIC output are enabled automatically when
3928 * you call Cy_SysPm_PmicLock(). To keep the PMIC controller or PMIC output
3929 * disabled, the PMIC must remain unlocked.
3930 *
3931 * \funcusage
3932 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_PmicEnable
3933 *
3934 *******************************************************************************/
3935 void Cy_SysPm_PmicUnlock(void);
3936 
3937 
3938 /*******************************************************************************
3939 * Function Name: Cy_SysPm_PmicIsEnabled
3940 ****************************************************************************//**
3941 *
3942 * This function returns the status of the PMIC controller.
3943 *
3944 * \return
3945 * - True if the PMIC is enabled.
3946 * - False if the PMIC is disabled.
3947 *
3948 * \funcusage
3949 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_PmicLock
3950 *
3951 *******************************************************************************/
3952 bool Cy_SysPm_PmicIsEnabled(void);
3953 
3954 
3955 /*******************************************************************************
3956 * Function Name: Cy_SysPm_PmicIsOutputEnabled
3957 ****************************************************************************//**
3958 *
3959 * This function returns the status of the PMIC controller output.
3960 *
3961 * \return
3962 * - True if the PMIC output is enabled.
3963 * - False if the PMIC output is disabled.
3964 *
3965 * \funcusage
3966 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_PmicDisable
3967 *
3968 *******************************************************************************/
3969 bool Cy_SysPm_PmicIsOutputEnabled(void);
3970 
3971 
3972 /*******************************************************************************
3973 * Function Name: Cy_SysPm_PmicIsLocked
3974 ****************************************************************************//**
3975 *
3976 * Returns the PMIC controller lock status.
3977 *
3978 * \return
3979 * - True if the PMIC is locked.
3980 * - False if the PMIC is unlocked.
3981 *
3982 * \funcusage
3983 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_PmicLock
3984 *
3985 *******************************************************************************/
3986 bool Cy_SysPm_PmicIsLocked(void);
3987 
3988 /** \} group_syspm_functions_pmic */
3989 
3990 
3991 /**
3992 * \addtogroup group_syspm_functions_backup
3993 * \{
3994 */
3995 /*******************************************************************************
3996 * Function Name: Cy_SysPm_BackupSetSupply
3997 ****************************************************************************//**
3998 *
3999 * Sets the backup supply (Vddback) operation mode.
4000 *
4001 * \param
4002 * vddBackControl
4003 * Selects backup supply (Vddback) operation mode.
4004 * See \ref cy_en_syspm_vddbackup_control_t.
4005 *
4006 * Refer to device TRM for more detail about backup supply modes.
4007 *
4008 * \funcusage
4009 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_BackupSetSupply
4010 *
4011 *******************************************************************************/
4012 void Cy_SysPm_BackupSetSupply(cy_en_syspm_vddbackup_control_t vddBackControl);
4013 
4014 
4015 /*******************************************************************************
4016 * Function Name: Cy_SysPm_BackupGetSupply
4017 ****************************************************************************//**
4018 *
4019 * Returns the current backup supply (Vddback) operation mode.
4020 *
4021 * \return
4022 * The current backup supply (Vddback) operation mode,
4023 * see \ref cy_en_syspm_status_t.
4024 *
4025 * Refer to device TRM for more detail about backup supply modes.
4026 *
4027 * \funcusage
4028 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_BackupGetSupply
4029 *
4030 *******************************************************************************/
4031 cy_en_syspm_vddbackup_control_t Cy_SysPm_BackupGetSupply(void);
4032 
4033 /*******************************************************************************
4034 * Function Name: Cy_SysPm_BackupEnableVoltageMeasurement
4035 ****************************************************************************//**
4036 *
4037 * This function enables Vbackup supply measurement by the ADC. The function
4038 * connects the Vbackup supply to AMuxBusA. The ADC input can then be connected
4039 * to AMuxBusA. Note that the measured signal is scaled by 10% to allow full
4040 * range measurement by the ADC.
4041 *
4042 * Refer to device TRM for more detail about Vbackup supply measurement.
4043 *
4044 * \funcusage
4045 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_BackupEnableVoltageMeasurement
4046 *
4047 *******************************************************************************/
4048 void Cy_SysPm_BackupEnableVoltageMeasurement(void);
4049 
4050 
4051 /*******************************************************************************
4052 * Function Name: Cy_SysPm_BackupDisableVoltageMeasurement
4053 ****************************************************************************//**
4054 *
4055 * The function disables Vbackup supply measurement by the ADC by disconnecting
4056 * the Vbackup supply from AMuxBusA.
4057 *
4058 * Refer to device TRM for more detail about Vbackup supply measurement.
4059 *
4060 * \funcusage
4061 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_BackupDisableVoltageMeasurement
4062 *
4063 *******************************************************************************/
4064 void Cy_SysPm_BackupDisableVoltageMeasurement(void);
4065 
4066 /*******************************************************************************
4067 * Function Name: Cy_SysPm_BackupSuperCapCharge
4068 ****************************************************************************//**
4069 *
4070 * Configures the supercapacitor charger circuit.
4071 *
4072 * \param key
4073 * Passes the key to enable or disable the supercapacitor charger circuit.
4074 * See \ref cy_en_syspm_sc_charge_key_t.
4075 *
4076 * \warning
4077 * This function is used only for charging the supercapacitor.
4078 * Do not use this function to charge a battery. Refer to device TRM for more
4079 * detail.
4080 *
4081 * \funcusage
4082 * \snippet syspm/snippet/main.c snippet_Cy_SysPm_BackupSuperCapCharge
4083 *
4084 *******************************************************************************/
4085 void Cy_SysPm_BackupSuperCapCharge(cy_en_syspm_sc_charge_key_t key);
4086 
4087 /** \} group_syspm_functions_backup */
4088 /** \} group_syspm_functions */
4089 
4090 /** \cond INTERNAL */
4091 
4092 /*******************************************************************************
4093 * Backward compatibility macro. The following code is DEPRECATED and must
4094 * not be used in new projects
4095 *******************************************************************************/
4096 
4097 /* BWC defines for Buck related functions */
4098 typedef cy_en_syspm_buck_voltage1_t          cy_en_syspm_simo_buck_voltage1_t;
4099 typedef cy_en_syspm_buck_voltage2_t          cy_en_syspm_simo_buck_voltage2_t;
4100 
4101 #define Cy_SysPm_SimoBuckGetVoltage2         Cy_SysPm_BuckGetVoltage2
4102 #define Cy_SysPm_DisableVoltage2             Cy_SysPm_BuckDisableVoltage2
4103 #define Cy_SysPm_EnableVoltage2              Cy_SysPm_BuckEnableVoltage2
4104 #define Cy_SysPm_SimoBuckSetHwControl        Cy_SysPm_BuckSetVoltage2HwControl
4105 #define Cy_SysPm_SimoBuckGetHwControl        Cy_SysPm_BuckIsVoltage2HwControlled
4106 #define Cy_SysPm_SimoBuckSetVoltage2         Cy_SysPm_BuckSetVoltage2
4107 
4108 #define CY_SYSPM_SIMO_BUCK_OUT2_VOLTAGE_1_15V   CY_SYSPM_BUCK_OUT2_VOLTAGE_1_15V
4109 #define CY_SYSPM_SIMO_BUCK_OUT2_VOLTAGE_1_2V    CY_SYSPM_BUCK_OUT2_VOLTAGE_1_2V
4110 #define CY_SYSPM_SIMO_BUCK_OUT2_VOLTAGE_1_25V   CY_SYSPM_BUCK_OUT2_VOLTAGE_1_25V
4111 #define CY_SYSPM_SIMO_BUCK_OUT2_VOLTAGE_1_3V    CY_SYSPM_BUCK_OUT2_VOLTAGE_1_3V
4112 #define CY_SYSPM_SIMO_BUCK_OUT2_VOLTAGE_1_35V   CY_SYSPM_BUCK_OUT2_VOLTAGE_1_35V
4113 #define CY_SYSPM_SIMO_BUCK_OUT2_VOLTAGE_1_4V    CY_SYSPM_BUCK_OUT2_VOLTAGE_1_4V
4114 #define CY_SYSPM_SIMO_BUCK_OUT2_VOLTAGE_1_45V   CY_SYSPM_BUCK_OUT2_VOLTAGE_1_45V
4115 #define CY_SYSPM_SIMO_BUCK_OUT2_VOLTAGE_1_5V    CY_SYSPM_BUCK_OUT2_VOLTAGE_1_5V
4116 
4117 #define CY_SYSPM_SIMO_BUCK_OUT1_VOLTAGE_0_9V     CY_SYSPM_BUCK_OUT1_VOLTAGE_0_9V
4118 #define CY_SYSPM_SIMO_BUCK_OUT1_VOLTAGE_1_1V     CY_SYSPM_BUCK_OUT1_VOLTAGE_1_1V
4119 
4120 #define Cy_SysPm_SwitchToSimoBuck()          (Cy_SysPm_BuckEnable(CY_SYSPM_BUCK_OUT1_VOLTAGE_0_9V))
4121 #define Cy_SysPm_SimoBuckGetVoltage1         Cy_SysPm_BuckGetVoltage1
4122 #define Cy_SysPm_SimoBuckIsEnabled           Cy_SysPm_BuckIsEnabled
4123 #define Cy_SysPm_SimoBuckSetVoltage1         Cy_SysPm_BuckSetVoltage1
4124 #define Cy_SysPm_SimoBuckOutputIsEnabled     Cy_SysPm_BuckIsOutputEnabled
4125 
4126 #define CY_SYSPM_LPCOMP0_LOW                 CY_SYSPM_HIBERNATE_LPCOMP0_LOW
4127 #define CY_SYSPM_LPCOMP0_HIGH                CY_SYSPM_HIBERNATE_LPCOMP0_HIGH
4128 #define CY_SYSPM_LPCOMP1_LOW                 CY_SYSPM_HIBERNATE_LPCOMP1_LOW
4129 #define CY_SYSPM_LPCOMP1_HIGH                CY_SYSPM_HIBERNATE_LPCOMP1_HIGH
4130 #define CY_SYSPM_HIBALARM                    CY_SYSPM_HIBERNATE_RTC_ALARM
4131 #define CY_SYSPM_HIBWDT                      CY_SYSPM_HIBERNATE_WDT
4132 #define CY_SYSPM_HIBPIN0_LOW                 CY_SYSPM_HIBERNATE_PIN0_LOW
4133 #define CY_SYSPM_HIBPIN0_HIGH                CY_SYSPM_HIBERNATE_PIN0_HIGH
4134 #define CY_SYSPM_HIBPIN1_LOW                 CY_SYSPM_HIBERNATE_PIN1_LOW
4135 #define CY_SYSPM_HIBPIN1_HIGH                CY_SYSPM_HIBERNATE_PIN1_HIGH
4136 
4137 #define CY_SYSPM_ENTER_LP_MODE               CY_SYSPM_ULP
4138 #define CY_SYSPM_EXIT_LP_MODE                CY_SYSPM_LP
4139 #define CY_SYSPM_STATUS_SYSTEM_LOWPOWER      CY_SYSPM_STATUS_SYSTEM_ULP
4140 
4141 typedef cy_en_syspm_hibernate_wakeup_source_t  cy_en_syspm_hib_wakeup_source_t;
4142 
4143 /* BWC defines related to hibernation functions */
4144 #define Cy_SysPm_SetHibWakeupSource          Cy_SysPm_SetHibernateWakeupSource
4145 #define Cy_SysPm_ClearHibWakeupSource        Cy_SysPm_ClearHibernateWakeupSource
4146 #define Cy_SysPm_GetIoFreezeStatus           Cy_SysPm_IoIsFrozen
4147 
4148 /* BWC defines for Backup related functions */
4149 #define Cy_SysPm_SetBackupSupply             Cy_SysPm_BackupSetSupply
4150 #define Cy_SysPm_GetBackupSupply             Cy_SysPm_BackupGetSupply
4151 #define Cy_SysPm_EnableBackupVMeasure        Cy_SysPm_BackupEnableVoltageMeasurement
4152 #define Cy_SysPm_DisableBackupVMeasure       Cy_SysPm_BackupDisableVoltageMeasurement
4153 
4154 /* BWC defines for PMIC related functions */
4155 #define Cy_SysPm_EnablePmic                  Cy_SysPm_PmicEnable
4156 #define Cy_SysPm_DisablePmic                 Cy_SysPm_PmicDisable
4157 #define Cy_SysPm_AlwaysEnablePmic            Cy_SysPm_PmicAlwaysEnable
4158 #define Cy_SysPm_EnablePmicOutput            Cy_SysPm_PmicEnableOutput
4159 #define Cy_SysPm_DisablePmicOutput           Cy_SysPm_PmicDisableOutput
4160 #define Cy_SysPm_LockPmic                    Cy_SysPm_PmicLock
4161 #define Cy_SysPm_UnlockPmic                  Cy_SysPm_PmicUnlock
4162 #define Cy_SysPm_IsPmicEnabled               Cy_SysPm_PmicIsEnabled
4163 #define Cy_SysPm_IsPmicOutputEnabled         Cy_SysPm_PmicIsOutputEnabled
4164 #define Cy_SysPm_IsPmicLocked                Cy_SysPm_PmicIsLocked
4165 
4166 /* BWC defines for functions related to low power transition */
4167 #define Cy_SysPm_Sleep                       Cy_SysPm_CpuEnterSleep
4168 #define Cy_SysPm_DeepSleep                   Cy_SysPm_CpuEnterDeepSleep
4169 #define Cy_SysPm_Hibernate                   Cy_SysPm_SystemEnterHibernate
4170 
4171 #define Cy_SysPm_SleepOnExit                 Cy_SysPm_CpuSleepOnExit
4172 
4173 /* BWC defines for functions related to low power transition */
4174 #define Cy_SysPm_EnterLpMode                 Cy_SysPm_EnterLowPowerMode
4175 #define Cy_SysPm_ExitLpMode                  Cy_SysPm_ExitLowPowerMode
4176 #define Cy_SysPm_IsLowPower                  Cy_SysPm_IsSystemUlp
4177 
4178 #define Cy_SysPm_EnterLowPowerMode           Cy_SysPm_SystemSetMinRegulatorCurrent
4179 #define Cy_SysPm_ExitLowPowerMode            Cy_SysPm_SystemSetNormalRegulatorCurrent
4180 
4181 #define CY_SYSPM_WAKEUP_PIN0_BIT             CY_SYSPM_HIB_WAKEUP_PIN0_POS
4182 #define CY_SYSPM_WAKEUP_PIN1_BIT             CY_SYSPM_HIB_WAKEUP_PIN1_POS
4183 #define CY_SYSPM_WAKEUP_LPCOMP0_BIT          CY_SYSPM_HIB_WAKEUP_LPCOMP0_POS
4184 #define CY_SYSPM_WAKEUP_LPCOMP1_BIT          CY_SYSPM_HIB_WAKEUP_LPCOMP1_POS
4185 
4186 #define CY_SYSPM_WAKEUP_LPCOMP0                  CY_SYSPM_HIB_WAKEUP_LPCOMP0_MASK
4187 #define CY_SYSPM_WAKEUP_LPCOMP1                  CY_SYSPM_HIB_WAKEUP_LPCOMP0_MASK
4188 #define CY_SYSPM_WAKEUP_PIN0                     CY_SYSPM_HIB_WAKEUP_PIN0_MASK
4189 #define CY_SYSPM_WAKEUP_PIN1                     CY_SYSPM_HIB_WAKEUP_PIN1_MASK
4190 #define CY_SYSPM_WAKEUP_LPCOMP0_POLARITY_HIGH    CY_SYSPM_HIB_WAKEUP_LPCOMP0_POLARITY_HIGH_MASK
4191 #define CY_SYSPM_WAKEUP_LPCOMP1_POLARITY_HIGH    CY_SYSPM_HIB_WAKEUP_LPCOMP1_POLARITY_HIGH_MASK
4192 #define CY_SYSPM_WAKEUP_PIN0_POLARITY_HIGH       CY_SYSPM_HIB_WAKEUP_PIN0_POLARITY_HIGH_MASK
4193 #define CY_SYSPM_WAKEUP_PIN1_POLARITY_HIGH       CY_SYSPM_HIB_WAKEUP_PIN1_POLARITY_HIGH_MASK
4194 
4195 #define CY_SYSPM_PWR_TOKEN_HIBERNATE             HIBERNATE_TOKEN
4196 #define CY_SYSPM_PWR_WAKEUP_HIB_MASK             HIBERNATE_WAKEUP_MASK
4197 #define CY_SYSPM_PWR_RETAIN_HIBERNATE_STATUS     HIBERNATE_RETAIN_STATUS_MASK
4198 #define CY_SYSPM_PWR_SET_HIBERNATE               SET_HIBERNATE_MODE
4199 #define CY_SYSPM_PWR_HIBERNATE_UNLOCK            HIBERNATE_UNLOCK_VAL
4200 
4201 /** \endcond */
4202 
4203 #ifdef __cplusplus
4204 }
4205 #endif
4206 
4207 #endif /* CY_IP_MXS40SRSS */
4208 
4209 #endif /* CY_SYSPM_H */
4210 
4211 /** \} group_syspm */
4212 
4213 
4214 /* [] END OF FILE */
4215