The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Thu Nov 08 11:45:42 2018 +0000
Revision:
171:3a7713b1edbc
Parent:
TARGET_MIMXRT1050_EVK/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/TARGET_EVK/lpm.h@170:e95d10626187
mbed library. Release version 164

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 170:e95d10626187 1 /*
AnnaBridge 170:e95d10626187 2 * The Clear BSD License
AnnaBridge 170:e95d10626187 3 * Copyright 2017 NXP
AnnaBridge 170:e95d10626187 4 * All rights reserved.
AnnaBridge 170:e95d10626187 5 *
AnnaBridge 170:e95d10626187 6 *
AnnaBridge 170:e95d10626187 7 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 170:e95d10626187 8 * are permitted (subject to the limitations in the disclaimer below) provided
AnnaBridge 170:e95d10626187 9 * that the following conditions are met:
AnnaBridge 170:e95d10626187 10 *
AnnaBridge 170:e95d10626187 11 * o Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 170:e95d10626187 12 * of conditions and the following disclaimer.
AnnaBridge 170:e95d10626187 13 *
AnnaBridge 170:e95d10626187 14 * o Redistributions in binary form must reproduce the above copyright notice, this
AnnaBridge 170:e95d10626187 15 * list of conditions and the following disclaimer in the documentation and/or
AnnaBridge 170:e95d10626187 16 * other materials provided with the distribution.
AnnaBridge 170:e95d10626187 17 *
AnnaBridge 170:e95d10626187 18 * o Neither the name of the copyright holder nor the names of its
AnnaBridge 170:e95d10626187 19 * contributors may be used to endorse or promote products derived from this
AnnaBridge 170:e95d10626187 20 * software without specific prior written permission.
AnnaBridge 170:e95d10626187 21 *
AnnaBridge 170:e95d10626187 22 * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
AnnaBridge 170:e95d10626187 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 170:e95d10626187 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 170:e95d10626187 25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 170:e95d10626187 26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 170:e95d10626187 27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 170:e95d10626187 28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 170:e95d10626187 29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 170:e95d10626187 30 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 170:e95d10626187 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 170:e95d10626187 32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 170:e95d10626187 33 */
AnnaBridge 170:e95d10626187 34
AnnaBridge 170:e95d10626187 35 #ifndef _LPM_H_
AnnaBridge 170:e95d10626187 36 #define _LPM_H_
AnnaBridge 170:e95d10626187 37
AnnaBridge 170:e95d10626187 38 #include "fsl_clock.h"
AnnaBridge 170:e95d10626187 39
AnnaBridge 170:e95d10626187 40 /*******************************************************************************
AnnaBridge 170:e95d10626187 41 * Definitions
AnnaBridge 170:e95d10626187 42 ******************************************************************************/
AnnaBridge 170:e95d10626187 43 extern void vPortGPTIsr(void);
AnnaBridge 170:e95d10626187 44
AnnaBridge 170:e95d10626187 45 #define vPortGptIsr GPT1_IRQHandler
AnnaBridge 170:e95d10626187 46
AnnaBridge 170:e95d10626187 47 #define CLOCK_SET_MUX(mux, value) \
AnnaBridge 170:e95d10626187 48 \
AnnaBridge 170:e95d10626187 49 do \
AnnaBridge 170:e95d10626187 50 { \
AnnaBridge 170:e95d10626187 51 CCM_TUPLE_REG(CCM, mux) = (CCM_TUPLE_REG(CCM, mux) & (~CCM_TUPLE_MASK(mux))) | \
AnnaBridge 170:e95d10626187 52 (((uint32_t)((value) << CCM_TUPLE_SHIFT(mux))) & CCM_TUPLE_MASK(mux)); \
AnnaBridge 170:e95d10626187 53 while (CCM->CDHIPR != 0) \
AnnaBridge 170:e95d10626187 54 { \
AnnaBridge 170:e95d10626187 55 } \
AnnaBridge 170:e95d10626187 56 \
AnnaBridge 170:e95d10626187 57 } \
AnnaBridge 170:e95d10626187 58 while (0)
AnnaBridge 170:e95d10626187 59
AnnaBridge 170:e95d10626187 60 #define CLOCK_SET_DIV(divider, value) \
AnnaBridge 170:e95d10626187 61 \
AnnaBridge 170:e95d10626187 62 do \
AnnaBridge 170:e95d10626187 63 { \
AnnaBridge 170:e95d10626187 64 CCM_TUPLE_REG(CCM, divider) = (CCM_TUPLE_REG(CCM, divider) & (~CCM_TUPLE_MASK(divider))) | \
AnnaBridge 170:e95d10626187 65 (((uint32_t)((value) << CCM_TUPLE_SHIFT(divider))) & CCM_TUPLE_MASK(divider)); \
AnnaBridge 170:e95d10626187 66 while (CCM->CDHIPR != 0) \
AnnaBridge 170:e95d10626187 67 { \
AnnaBridge 170:e95d10626187 68 } \
AnnaBridge 170:e95d10626187 69 \
AnnaBridge 170:e95d10626187 70 } \
AnnaBridge 170:e95d10626187 71 while (0)
AnnaBridge 170:e95d10626187 72
AnnaBridge 170:e95d10626187 73 #define CLOCK_CCM_HANDSHAKE_WAIT() \
AnnaBridge 170:e95d10626187 74 \
AnnaBridge 170:e95d10626187 75 do \
AnnaBridge 170:e95d10626187 76 { \
AnnaBridge 170:e95d10626187 77 while (CCM->CDHIPR != 0) \
AnnaBridge 170:e95d10626187 78 { \
AnnaBridge 170:e95d10626187 79 } \
AnnaBridge 170:e95d10626187 80 \
AnnaBridge 170:e95d10626187 81 } \
AnnaBridge 170:e95d10626187 82 while (0)
AnnaBridge 170:e95d10626187 83
AnnaBridge 170:e95d10626187 84 #define LPM_DELAY(value) \
AnnaBridge 170:e95d10626187 85 \
AnnaBridge 170:e95d10626187 86 do \
AnnaBridge 170:e95d10626187 87 { \
AnnaBridge 170:e95d10626187 88 for (uint32_t i = 0; i < 5 * value; i++) \
AnnaBridge 170:e95d10626187 89 { \
AnnaBridge 170:e95d10626187 90 __NOP(); \
AnnaBridge 170:e95d10626187 91 } \
AnnaBridge 170:e95d10626187 92 \
AnnaBridge 170:e95d10626187 93 } \
AnnaBridge 170:e95d10626187 94 while (0)
AnnaBridge 170:e95d10626187 95
AnnaBridge 170:e95d10626187 96 #define ROM_CODE_ENTRY_ADDR (0x200000U)
AnnaBridge 170:e95d10626187 97
AnnaBridge 170:e95d10626187 98 /*! @name Time sensitive region */
AnnaBridge 170:e95d10626187 99 /* @{ */
AnnaBridge 170:e95d10626187 100 #if defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)
AnnaBridge 170:e95d10626187 101 #if (defined(__ICCARM__))
AnnaBridge 170:e95d10626187 102 #define AT_QUICKACCESS_SECTION_CODE(func) __ramfunc func
AnnaBridge 170:e95d10626187 103 #elif(defined(__ARMCC_VERSION))
AnnaBridge 170:e95d10626187 104 #define AT_QUICKACCESS_SECTION_CODE(func) __attribute__((section("RamFunction"))) func
AnnaBridge 170:e95d10626187 105 #elif defined(__MCUXPRESSO)
AnnaBridge 170:e95d10626187 106 #define AT_QUICKACCESS_SECTION_CODE(func) __attribute__((section(".ramfunc.$SRAM_ITC"))) func
AnnaBridge 170:e95d10626187 107 #elif(defined(__GNUC__))
AnnaBridge 170:e95d10626187 108 #define AT_QUICKACCESS_SECTION_CODE(func) __attribute__((section("RamFunction"))) func
AnnaBridge 170:e95d10626187 109 #else
AnnaBridge 170:e95d10626187 110 #error Toolchain not supported.
AnnaBridge 170:e95d10626187 111 #endif /* defined(__ICCARM__) */
AnnaBridge 170:e95d10626187 112 #else
AnnaBridge 170:e95d10626187 113 #if (defined(__ICCARM__))
AnnaBridge 170:e95d10626187 114 #define AT_QUICKACCESS_SECTION_CODE(func) func
AnnaBridge 170:e95d10626187 115 #elif(defined(__ARMCC_VERSION))
AnnaBridge 170:e95d10626187 116 #define AT_QUICKACCESS_SECTION_CODE(func) func
AnnaBridge 170:e95d10626187 117 #elif(defined(__MCUXPRESSO))
AnnaBridge 170:e95d10626187 118 #define AT_QUICKACCESS_SECTION_CODE(func) func
AnnaBridge 170:e95d10626187 119 #elif(defined(__GNUC__))
AnnaBridge 170:e95d10626187 120 #define AT_QUICKACCESS_SECTION_CODE(func) func
AnnaBridge 170:e95d10626187 121 #else
AnnaBridge 170:e95d10626187 122 #error Toolchain not supported.
AnnaBridge 170:e95d10626187 123 #endif
AnnaBridge 170:e95d10626187 124 #endif /* __FSL_SDK_DRIVER_QUICK_ACCESS_ENABLE */
AnnaBridge 170:e95d10626187 125
AnnaBridge 170:e95d10626187 126 /*******************************************************************************
AnnaBridge 170:e95d10626187 127 * API
AnnaBridge 170:e95d10626187 128 ******************************************************************************/
AnnaBridge 170:e95d10626187 129
AnnaBridge 170:e95d10626187 130 #if defined(__cplusplus)
AnnaBridge 170:e95d10626187 131 extern "C" {
AnnaBridge 170:e95d10626187 132 #endif /* __cplusplus*/
AnnaBridge 170:e95d10626187 133
AnnaBridge 170:e95d10626187 134 AT_QUICKACCESS_SECTION_CODE(void LPM_SwitchFlexspiClock(clock_mode_t powermode));
AnnaBridge 170:e95d10626187 135 AT_QUICKACCESS_SECTION_CODE(void LPM_RestoreFlexspiClock(void));
AnnaBridge 170:e95d10626187 136
AnnaBridge 170:e95d10626187 137 /* Initialize the Low Power Management */
AnnaBridge 170:e95d10626187 138 bool LPM_Init(void);
AnnaBridge 170:e95d10626187 139
AnnaBridge 170:e95d10626187 140 /* Deinitialize the Low Power Management */
AnnaBridge 170:e95d10626187 141 void LPM_Deinit(void);
AnnaBridge 170:e95d10626187 142
AnnaBridge 170:e95d10626187 143 /* Enable wakeup source in low power mode */
AnnaBridge 170:e95d10626187 144 void LPM_EnableWakeupSource(uint32_t irq);
AnnaBridge 170:e95d10626187 145
AnnaBridge 170:e95d10626187 146 /* Disable wakeup source in low power mode */
AnnaBridge 170:e95d10626187 147 void LPM_DisableWakeupSource(uint32_t irq);
AnnaBridge 170:e95d10626187 148
AnnaBridge 170:e95d10626187 149 #if defined(__cplusplus)
AnnaBridge 170:e95d10626187 150 }
AnnaBridge 170:e95d10626187 151 #endif /* __cplusplus*/
AnnaBridge 170:e95d10626187 152
AnnaBridge 170:e95d10626187 153 #endif /* _LPM_H_ */