A demo application for HXC900 LoRaWAN module using Nucleo-L053R8.

Dependencies:   mbed

Committer:
fahadmirza
Date:
Thu Jan 24 23:45:12 2019 +0000
Revision:
39:cb0e5a76ab15
Parent:
5:53302861bfea
Doxygen style header

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fahadmirza 0:a0c5877bd360 1 /**
fahadmirza 0:a0c5877bd360 2 ******************************************************************************
fahadmirza 0:a0c5877bd360 3 * @file low_power_manager.h
fahadmirza 0:a0c5877bd360 4 * @author MCD Application Team
fahadmirza 0:a0c5877bd360 5 * @version V1.1.4
fahadmirza 0:a0c5877bd360 6 * @date 08-January-2018
fahadmirza 0:a0c5877bd360 7 * @brief Header for stm32xx_lpm.c module
fahadmirza 0:a0c5877bd360 8 ******************************************************************************
fahadmirza 0:a0c5877bd360 9 * @attention
fahadmirza 0:a0c5877bd360 10 *
fahadmirza 0:a0c5877bd360 11 * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics International N.V.
fahadmirza 0:a0c5877bd360 12 * All rights reserved.</center></h2>
fahadmirza 0:a0c5877bd360 13 *
fahadmirza 0:a0c5877bd360 14 * Redistribution and use in source and binary forms, with or without
fahadmirza 0:a0c5877bd360 15 * modification, are permitted, provided that the following conditions are met:
fahadmirza 0:a0c5877bd360 16 *
fahadmirza 0:a0c5877bd360 17 * 1. Redistribution of source code must retain the above copyright notice,
fahadmirza 0:a0c5877bd360 18 * this list of conditions and the following disclaimer.
fahadmirza 0:a0c5877bd360 19 * 2. Redistributions in binary form must reproduce the above copyright notice,
fahadmirza 0:a0c5877bd360 20 * this list of conditions and the following disclaimer in the documentation
fahadmirza 0:a0c5877bd360 21 * and/or other materials provided with the distribution.
fahadmirza 0:a0c5877bd360 22 * 3. Neither the name of STMicroelectronics nor the names of other
fahadmirza 0:a0c5877bd360 23 * contributors to this software may be used to endorse or promote products
fahadmirza 0:a0c5877bd360 24 * derived from this software without specific written permission.
fahadmirza 0:a0c5877bd360 25 * 4. This software, including modifications and/or derivative works of this
fahadmirza 0:a0c5877bd360 26 * software, must execute solely and exclusively on microcontroller or
fahadmirza 0:a0c5877bd360 27 * microprocessor devices manufactured by or for STMicroelectronics.
fahadmirza 0:a0c5877bd360 28 * 5. Redistribution and use of this software other than as permitted under
fahadmirza 0:a0c5877bd360 29 * this license is void and will automatically terminate your rights under
fahadmirza 0:a0c5877bd360 30 * this license.
fahadmirza 0:a0c5877bd360 31 *
fahadmirza 0:a0c5877bd360 32 * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
fahadmirza 0:a0c5877bd360 33 * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
fahadmirza 0:a0c5877bd360 34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
fahadmirza 0:a0c5877bd360 35 * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
fahadmirza 0:a0c5877bd360 36 * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
fahadmirza 0:a0c5877bd360 37 * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
fahadmirza 0:a0c5877bd360 38 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
fahadmirza 0:a0c5877bd360 39 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
fahadmirza 0:a0c5877bd360 40 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
fahadmirza 0:a0c5877bd360 41 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
fahadmirza 0:a0c5877bd360 42 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
fahadmirza 0:a0c5877bd360 43 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
fahadmirza 0:a0c5877bd360 44 *
fahadmirza 0:a0c5877bd360 45 ******************************************************************************
fahadmirza 0:a0c5877bd360 46 */
fahadmirza 0:a0c5877bd360 47
fahadmirza 0:a0c5877bd360 48 /* Define to prevent recursive inclusion -------------------------------------*/
fahadmirza 0:a0c5877bd360 49 #ifndef __STM32_LPM__H
fahadmirza 0:a0c5877bd360 50 #define __STM32_LPM__H
fahadmirza 0:a0c5877bd360 51
fahadmirza 0:a0c5877bd360 52 #ifdef __cplusplus
fahadmirza 0:a0c5877bd360 53 extern "C" {
fahadmirza 0:a0c5877bd360 54 #endif
fahadmirza 0:a0c5877bd360 55
fahadmirza 0:a0c5877bd360 56 /* Includes ------------------------------------------------------------------*/
fahadmirza 0:a0c5877bd360 57 /*low power manager configuration*/
fahadmirza 0:a0c5877bd360 58 typedef enum
fahadmirza 0:a0c5877bd360 59 {
fahadmirza 0:a0c5877bd360 60 LPM_APPLI_Id = (1 << 0),
fahadmirza 0:a0c5877bd360 61 LPM_LIB_Id = (1 << 1),
fahadmirza 0:a0c5877bd360 62 LPM_RTC_Id = (1 << 2),
fahadmirza 0:a0c5877bd360 63 LPM_GPS_Id = (1 << 3),
fahadmirza 0:a0c5877bd360 64 LPM_UART_RX_Id = (1 << 4),
fahadmirza 0:a0c5877bd360 65 LPM_UART_TX_Id = (1 << 5),
fahadmirza 0:a0c5877bd360 66 } LPM_Id_t;
fahadmirza 0:a0c5877bd360 67
fahadmirza 0:a0c5877bd360 68 /**
fahadmirza 0:a0c5877bd360 69 * Low Power Mode selected
fahadmirza 0:a0c5877bd360 70 */
fahadmirza 0:a0c5877bd360 71 typedef enum
fahadmirza 0:a0c5877bd360 72 {
fahadmirza 0:a0c5877bd360 73 LPM_Enable=0,
fahadmirza 0:a0c5877bd360 74 LPM_Disable,
fahadmirza 0:a0c5877bd360 75 } LPM_SetMode_t;
fahadmirza 0:a0c5877bd360 76
fahadmirza 0:a0c5877bd360 77 typedef enum
fahadmirza 0:a0c5877bd360 78 {
fahadmirza 0:a0c5877bd360 79 LPM_SleepMode,
fahadmirza 0:a0c5877bd360 80 LPM_StopMode,
fahadmirza 0:a0c5877bd360 81 LPM_OffMode,
fahadmirza 0:a0c5877bd360 82 } LPM_GetMode_t;
fahadmirza 0:a0c5877bd360 83
fahadmirza 0:a0c5877bd360 84 /* Exported constants --------------------------------------------------------*/
fahadmirza 0:a0c5877bd360 85 /* External variables --------------------------------------------------------*/
fahadmirza 0:a0c5877bd360 86 /* Exported macros -----------------------------------------------------------*/
fahadmirza 0:a0c5877bd360 87 /* Exported functions ------------------------------------------------------- */
fahadmirza 0:a0c5877bd360 88 /**
fahadmirza 0:a0c5877bd360 89 * @brief This API returns the Low Power Mode selected that will be applied when the system will enter low power mode
fahadmirza 0:a0c5877bd360 90 * if there is no update between the time the mode is read with this API and the time the system enters
fahadmirza 0:a0c5877bd360 91 * low power mode.
fahadmirza 0:a0c5877bd360 92 * @param None
fahadmirza 0:a0c5877bd360 93 * @retval LPM_ModeSelected_t
fahadmirza 0:a0c5877bd360 94 */
fahadmirza 0:a0c5877bd360 95 LPM_GetMode_t LPM_GetMode(void);
fahadmirza 0:a0c5877bd360 96 /**
fahadmirza 0:a0c5877bd360 97 * @brief This API notifies the low power manager if the specified user allows the Off mode or not.
fahadmirza 0:a0c5877bd360 98 * When the application does not require the system clock, it enters Stop Mode if at least one user disallow
fahadmirza 0:a0c5877bd360 99 * Off Mode. Otherwise, it enters Off Mode.
fahadmirza 0:a0c5877bd360 100 * The default mode selection for all users is Off mode enabled
fahadmirza 0:a0c5877bd360 101 * @param id: process Id
fahadmirza 0:a0c5877bd360 102 * @param mode: mode selected
fahadmirza 0:a0c5877bd360 103 * @retval None
fahadmirza 0:a0c5877bd360 104 */
fahadmirza 0:a0c5877bd360 105 void LPM_SetStopMode(LPM_Id_t id, LPM_SetMode_t mode);
fahadmirza 0:a0c5877bd360 106
fahadmirza 0:a0c5877bd360 107 void LPM_SetOffMode(LPM_Id_t id, LPM_SetMode_t mode);
fahadmirza 0:a0c5877bd360 108 /**
fahadmirza 0:a0c5877bd360 109 * @brief This API shall be used by the application when there is no more code to execute so that the system may
fahadmirza 0:a0c5877bd360 110 * enter low-power mode. The mode selected depends on the information received from LPM_OffModeSelection() and
fahadmirza 0:a0c5877bd360 111 * LPM_SysclockRequest()
fahadmirza 0:a0c5877bd360 112 * This function shall be called in critical section
fahadmirza 0:a0c5877bd360 113 * @param None
fahadmirza 0:a0c5877bd360 114 * @retval None
fahadmirza 0:a0c5877bd360 115 */
fahadmirza 0:a0c5877bd360 116 void LPM_EnterLowPower(void);
fahadmirza 0:a0c5877bd360 117
fahadmirza 0:a0c5877bd360 118 /**
fahadmirza 0:a0c5877bd360 119 * @brief This API is called by the low power manager in a critical section (PRIMASK bit set) to allow the
fahadmirza 0:a0c5877bd360 120 * application to implement dedicated code before entering Sleep Mode
fahadmirza 0:a0c5877bd360 121 * @param None
fahadmirza 0:a0c5877bd360 122 * @retval None
fahadmirza 0:a0c5877bd360 123 */
fahadmirza 0:a0c5877bd360 124 void LPM_EnterSleepMode(void);
fahadmirza 0:a0c5877bd360 125
fahadmirza 0:a0c5877bd360 126 /**
fahadmirza 0:a0c5877bd360 127 * @brief This API is called by the low power manager in a critical section (PRIMASK bit set) to allow the
fahadmirza 0:a0c5877bd360 128 * application to implement dedicated code before getting out from Sleep Mode
fahadmirza 0:a0c5877bd360 129 * @param None
fahadmirza 0:a0c5877bd360 130 * @retval None
fahadmirza 0:a0c5877bd360 131 */
fahadmirza 0:a0c5877bd360 132 void LPM_ExitSleepMode(void);
fahadmirza 0:a0c5877bd360 133
fahadmirza 0:a0c5877bd360 134 /**
fahadmirza 0:a0c5877bd360 135 * @brief This API is called by the low power manager in a critical section (PRIMASK bit set) to allow the
fahadmirza 0:a0c5877bd360 136 * application to implement dedicated code before entering Stop Mode
fahadmirza 0:a0c5877bd360 137 * @param None
fahadmirza 0:a0c5877bd360 138 * @retval None
fahadmirza 0:a0c5877bd360 139 */
fahadmirza 0:a0c5877bd360 140 void LPM_EnterStopMode(void);
fahadmirza 0:a0c5877bd360 141
fahadmirza 0:a0c5877bd360 142 /**
fahadmirza 0:a0c5877bd360 143 * @brief This API is called by the low power manager in a critical section (PRIMASK bit set) to allow the
fahadmirza 0:a0c5877bd360 144 * application to implement dedicated code before getting out from Stop Mode. This is where the application
fahadmirza 0:a0c5877bd360 145 * should reconfigure the clock tree when needed
fahadmirza 0:a0c5877bd360 146 * @param None
fahadmirza 0:a0c5877bd360 147 * @retval None
fahadmirza 0:a0c5877bd360 148 */
fahadmirza 0:a0c5877bd360 149 void LPM_ExitStopMode(void);
fahadmirza 0:a0c5877bd360 150
fahadmirza 0:a0c5877bd360 151 /**
fahadmirza 0:a0c5877bd360 152 * @brief This API is called by the low power manager in a critical section (PRIMASK bit set) to allow the
fahadmirza 0:a0c5877bd360 153 * application to implement dedicated code before entering Off mode. This is where the application could save
fahadmirza 0:a0c5877bd360 154 * data in the retention memory as the RAM memory content will be lost
fahadmirza 0:a0c5877bd360 155 * @param None
fahadmirza 0:a0c5877bd360 156 * @retval None
fahadmirza 0:a0c5877bd360 157 */
fahadmirza 0:a0c5877bd360 158 void LPM_EnterOffMode(void);
fahadmirza 0:a0c5877bd360 159
fahadmirza 0:a0c5877bd360 160
fahadmirza 0:a0c5877bd360 161 /**
fahadmirza 0:a0c5877bd360 162 * @brief This API is called by the low power manager in a critical section (PRIMASK bit set) to allow the
fahadmirza 0:a0c5877bd360 163 * application to implement dedicated code before getting out from Off mode. This can only happen when the
fahadmirza 0:a0c5877bd360 164 * Off mode is finally not entered. In that case, the application may reverse some configurations done before
fahadmirza 0:a0c5877bd360 165 * entering Off mode. When Off mode is successful, the system is reset when getting out from this low-power mode
fahadmirza 0:a0c5877bd360 166 * @param None
fahadmirza 0:a0c5877bd360 167 * @retval None
fahadmirza 0:a0c5877bd360 168 */
fahadmirza 0:a0c5877bd360 169 void LPM_ExitOffMode(void);
fahadmirza 0:a0c5877bd360 170
fahadmirza 0:a0c5877bd360 171 #ifdef __cplusplus
fahadmirza 0:a0c5877bd360 172 }
fahadmirza 0:a0c5877bd360 173 #endif
fahadmirza 0:a0c5877bd360 174
fahadmirza 0:a0c5877bd360 175 #endif /*__STM32_LPM__H */
fahadmirza 0:a0c5877bd360 176
fahadmirza 0:a0c5877bd360 177 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
fahadmirza 0:a0c5877bd360 178