mbed library sources. Supersedes mbed-src. Edited target satm32f446 for user USART3 pins

Dependents:   IGLOO_board

Fork of mbed-dev by mbed official

Committer:
ua1arn
Date:
Mon Jul 30 12:31:10 2018 +0000
Revision:
188:3f10722804f9
Parent:
186:707f6e361f3e
before add multi-configuration USB descriptors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Anna Bridge 186:707f6e361f3e 1 /*******************************************************************************
Anna Bridge 186:707f6e361f3e 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
Anna Bridge 186:707f6e361f3e 3 *
Anna Bridge 186:707f6e361f3e 4 * Permission is hereby granted, free of charge, to any person obtaining a
Anna Bridge 186:707f6e361f3e 5 * copy of this software and associated documentation files (the "Software"),
Anna Bridge 186:707f6e361f3e 6 * to deal in the Software without restriction, including without limitation
Anna Bridge 186:707f6e361f3e 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
Anna Bridge 186:707f6e361f3e 8 * and/or sell copies of the Software, and to permit persons to whom the
Anna Bridge 186:707f6e361f3e 9 * Software is furnished to do so, subject to the following conditions:
Anna Bridge 186:707f6e361f3e 10 *
Anna Bridge 186:707f6e361f3e 11 * The above copyright notice and this permission notice shall be included
Anna Bridge 186:707f6e361f3e 12 * in all copies or substantial portions of the Software.
Anna Bridge 186:707f6e361f3e 13 *
Anna Bridge 186:707f6e361f3e 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
Anna Bridge 186:707f6e361f3e 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Anna Bridge 186:707f6e361f3e 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Anna Bridge 186:707f6e361f3e 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
Anna Bridge 186:707f6e361f3e 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
Anna Bridge 186:707f6e361f3e 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Anna Bridge 186:707f6e361f3e 20 * OTHER DEALINGS IN THE SOFTWARE.
Anna Bridge 186:707f6e361f3e 21 *
Anna Bridge 186:707f6e361f3e 22 * Except as contained in this notice, the name of Maxim Integrated
Anna Bridge 186:707f6e361f3e 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
Anna Bridge 186:707f6e361f3e 24 * Products, Inc. Branding Policy.
Anna Bridge 186:707f6e361f3e 25 *
Anna Bridge 186:707f6e361f3e 26 * The mere transfer of this software does not imply any licenses
Anna Bridge 186:707f6e361f3e 27 * of trade secrets, proprietary technology, copyrights, patents,
Anna Bridge 186:707f6e361f3e 28 * trademarks, maskwork rights, or any other form of intellectual
Anna Bridge 186:707f6e361f3e 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
Anna Bridge 186:707f6e361f3e 30 * ownership rights.
Anna Bridge 186:707f6e361f3e 31 *
Anna Bridge 186:707f6e361f3e 32 * $Date: 2016-03-21 09:04:59 -0500 (Mon, 21 Mar 2016) $
Anna Bridge 186:707f6e361f3e 33 * $Revision: 22006 $
Anna Bridge 186:707f6e361f3e 34 *
Anna Bridge 186:707f6e361f3e 35 ******************************************************************************/
Anna Bridge 186:707f6e361f3e 36
Anna Bridge 186:707f6e361f3e 37 /**
Anna Bridge 186:707f6e361f3e 38 * @file lp.h
Anna Bridge 186:707f6e361f3e 39 * @brief This is the high level API for the Lower Power
Anna Bridge 186:707f6e361f3e 40 */
Anna Bridge 186:707f6e361f3e 41
Anna Bridge 186:707f6e361f3e 42 #ifndef _LP_H_
Anna Bridge 186:707f6e361f3e 43 #define _LP_H_
Anna Bridge 186:707f6e361f3e 44
Anna Bridge 186:707f6e361f3e 45 #include "gpio.h"
Anna Bridge 186:707f6e361f3e 46 #include "pwrman_regs.h"
Anna Bridge 186:707f6e361f3e 47 #include "pwrseq_regs.h"
Anna Bridge 186:707f6e361f3e 48
Anna Bridge 186:707f6e361f3e 49 #ifdef __cplusplus
Anna Bridge 186:707f6e361f3e 50 extern "C" {
Anna Bridge 186:707f6e361f3e 51 #endif
Anna Bridge 186:707f6e361f3e 52
Anna Bridge 186:707f6e361f3e 53 /***** Definitions *****/
Anna Bridge 186:707f6e361f3e 54 /**
Anna Bridge 186:707f6e361f3e 55 * @brief Enumerations for pull-up and pull-downs
Anna Bridge 186:707f6e361f3e 56 *
Anna Bridge 186:707f6e361f3e 57 */
Anna Bridge 186:707f6e361f3e 58 typedef enum {
Anna Bridge 186:707f6e361f3e 59 LP_WEAK_PULL_DOWN = -1,
Anna Bridge 186:707f6e361f3e 60 LP_NO_PULL = 0,
Anna Bridge 186:707f6e361f3e 61 LP_WEAK_PULL_UP = 1
Anna Bridge 186:707f6e361f3e 62 }
Anna Bridge 186:707f6e361f3e 63 lp_pu_pd_select_t;
Anna Bridge 186:707f6e361f3e 64
Anna Bridge 186:707f6e361f3e 65 /***** Function Prototypes *****/
Anna Bridge 186:707f6e361f3e 66
Anna Bridge 186:707f6e361f3e 67 /**
Anna Bridge 186:707f6e361f3e 68 * @brief Gets the first boot flag
Anna Bridge 186:707f6e361f3e 69 *
Anna Bridge 186:707f6e361f3e 70 * @returns 0 if FIRST_BOOT was not set, or 1 if FIRST_BOOT was set
Anna Bridge 186:707f6e361f3e 71 */
Anna Bridge 186:707f6e361f3e 72 __STATIC_INLINE unsigned int LP_IsFirstBoot()
Anna Bridge 186:707f6e361f3e 73 {
Anna Bridge 186:707f6e361f3e 74 return ((MXC_PWRSEQ->reg0 & MXC_F_PWRSEQ_REG0_PWR_FIRST_BOOT) >> MXC_F_PWRSEQ_REG0_PWR_FIRST_BOOT_POS);
Anna Bridge 186:707f6e361f3e 75 }
Anna Bridge 186:707f6e361f3e 76
Anna Bridge 186:707f6e361f3e 77 /**
Anna Bridge 186:707f6e361f3e 78 * @brief Clears the first boot flag
Anna Bridge 186:707f6e361f3e 79 *
Anna Bridge 186:707f6e361f3e 80 */
Anna Bridge 186:707f6e361f3e 81 __STATIC_INLINE void LP_ClearFirstBoot()
Anna Bridge 186:707f6e361f3e 82 {
Anna Bridge 186:707f6e361f3e 83 MXC_PWRSEQ->reg0 &= ~MXC_F_PWRSEQ_REG0_PWR_FIRST_BOOT;
Anna Bridge 186:707f6e361f3e 84 }
Anna Bridge 186:707f6e361f3e 85
Anna Bridge 186:707f6e361f3e 86 /**
Anna Bridge 186:707f6e361f3e 87 * @brief Determines of program woke up from LP0
Anna Bridge 186:707f6e361f3e 88 *
Anna Bridge 186:707f6e361f3e 89 * @returns 0 if not woken up from LP0, or 1 if woken from LP0
Anna Bridge 186:707f6e361f3e 90 */
Anna Bridge 186:707f6e361f3e 91 __STATIC_INLINE unsigned int LP_IsLP0WakeUp()
Anna Bridge 186:707f6e361f3e 92 {
Anna Bridge 186:707f6e361f3e 93 //POR should be set and first boot clear
Anna Bridge 186:707f6e361f3e 94 if((MXC_PWRMAN->pwr_rst_ctrl & MXC_F_PWRMAN_PWR_RST_CTRL_POR) &&
Anna Bridge 186:707f6e361f3e 95 ((MXC_PWRSEQ->reg0 & MXC_F_PWRSEQ_REG0_PWR_FIRST_BOOT) == 0))
Anna Bridge 186:707f6e361f3e 96 return 1;
Anna Bridge 186:707f6e361f3e 97 else
Anna Bridge 186:707f6e361f3e 98 return 0;
Anna Bridge 186:707f6e361f3e 99
Anna Bridge 186:707f6e361f3e 100 }
Anna Bridge 186:707f6e361f3e 101
Anna Bridge 186:707f6e361f3e 102 __STATIC_INLINE unsigned int LP_GetWakeUpFlags(void)
Anna Bridge 186:707f6e361f3e 103 {
Anna Bridge 186:707f6e361f3e 104 return MXC_PWRSEQ->flags;
Anna Bridge 186:707f6e361f3e 105 }
Anna Bridge 186:707f6e361f3e 106 /**
Anna Bridge 186:707f6e361f3e 107 * @brief Clear ALL wake-up configuration on all pins. Disables wake-up entirely.
Anna Bridge 186:707f6e361f3e 108 */
Anna Bridge 186:707f6e361f3e 109 void LP_ClearWakeUpConfig(void);
Anna Bridge 186:707f6e361f3e 110
Anna Bridge 186:707f6e361f3e 111 /**
Anna Bridge 186:707f6e361f3e 112 * @brief Read wake-up flags, clear flags, and return to caller.
Anna Bridge 186:707f6e361f3e 113 * @returns Wake-up flags from Power Sequencer
Anna Bridge 186:707f6e361f3e 114 */
Anna Bridge 186:707f6e361f3e 115 unsigned int LP_ClearWakeUpFlags(void);
Anna Bridge 186:707f6e361f3e 116
Anna Bridge 186:707f6e361f3e 117 /**
Anna Bridge 186:707f6e361f3e 118 * @brief This function configures one GPIO pin to wake the processor from LP0 or LP1.
Anna Bridge 186:707f6e361f3e 119 * It is not used for LP2 wake-up, as normal GPIO interrupt processing is active in that mode.
Anna Bridge 186:707f6e361f3e 120 * @param gpio GPIO pointer describing the port and pin for selected wake-up source
Anna Bridge 186:707f6e361f3e 121 * @param act_high If non-zero, the signal is configured for active high wake-up. Otherwise, active low.
Anna Bridge 186:707f6e361f3e 122 * @param wk_pu_pd Selection for the 1 Meg ohm pull-up or pull-down on this pin, see #lp_pu_pd_select_t
Anna Bridge 186:707f6e361f3e 123 * @returns #E_NO_ERROR on success, error if unsuccessful.
Anna Bridge 186:707f6e361f3e 124 */
Anna Bridge 186:707f6e361f3e 125 int LP_ConfigGPIOWakeUpDetect(const gpio_cfg_t *gpio, unsigned int act_high, lp_pu_pd_select_t wk_pu_pd);
Anna Bridge 186:707f6e361f3e 126
Anna Bridge 186:707f6e361f3e 127 /**
Anna Bridge 186:707f6e361f3e 128 * @brief Clear the wake-up configuration on one specific GPIO pin
Anna Bridge 186:707f6e361f3e 129 * @param gpio GPIO pointer describing the port and pin for selected wake-up source
Anna Bridge 186:707f6e361f3e 130 * @returns #E_NO_ERROR on success, error if unsuccessful.
Anna Bridge 186:707f6e361f3e 131 */
Anna Bridge 186:707f6e361f3e 132 int LP_ClearGPIOWakeUpDetect(const gpio_cfg_t *gpio);
Anna Bridge 186:707f6e361f3e 133
Anna Bridge 186:707f6e361f3e 134 /**
Anna Bridge 186:707f6e361f3e 135 * @brief Check if a specific gpio triggered the wake up
Anna Bridge 186:707f6e361f3e 136 * @param gpio GPIO pointer describing the port and pin(s)
Anna Bridge 186:707f6e361f3e 137 * @returns 0 = gpio passed in did not trigger a wake up
Anna Bridge 186:707f6e361f3e 138 * nonzero = at least one of the gpio passed in triggered a wake up
Anna Bridge 186:707f6e361f3e 139 * the bit set represents which pin is the wake up source
Anna Bridge 186:707f6e361f3e 140 */
Anna Bridge 186:707f6e361f3e 141 int LP_IsGPIOWakeUpSource(const gpio_cfg_t *gpio);
Anna Bridge 186:707f6e361f3e 142
Anna Bridge 186:707f6e361f3e 143 /**
Anna Bridge 186:707f6e361f3e 144 * @brief Wake on USB plug or unplug
Anna Bridge 186:707f6e361f3e 145 * @param plug_en set to 1 to enable wake-up when USB VBUS is detected
Anna Bridge 186:707f6e361f3e 146 * @param unplug_en set to 1 to enable wake-up when USB VBUS disappears
Anna Bridge 186:707f6e361f3e 147 * @returns #E_NO_ERROR on success, error if unsuccessful.
Anna Bridge 186:707f6e361f3e 148 */
Anna Bridge 186:707f6e361f3e 149 int LP_ConfigUSBWakeUp(unsigned int plug_en, unsigned int unplug_en);
Anna Bridge 186:707f6e361f3e 150
Anna Bridge 186:707f6e361f3e 151 /**
Anna Bridge 186:707f6e361f3e 152 * @brief Wake on any enabled event signal from RTC
Anna Bridge 186:707f6e361f3e 153 * @param comp0_en set to 1 to enable wake-up when RTC Comparison 0 is set
Anna Bridge 186:707f6e361f3e 154 * @param comp1_en set to 1 to enable wake-up when RTC Comparison 1 is set
Anna Bridge 186:707f6e361f3e 155 * @param prescale_cmp_en set to 1 to enable wake-up when RTC Prescaler Compare is set
Anna Bridge 186:707f6e361f3e 156 * @param rollover_en set to 1 to enable wake-up when RTC Roll-over is set
Anna Bridge 186:707f6e361f3e 157 * @returns #E_NO_ERROR on success, error if unsuccessful.
Anna Bridge 186:707f6e361f3e 158 */
Anna Bridge 186:707f6e361f3e 159 int LP_ConfigRTCWakeUp(unsigned int comp0_en, unsigned int comp1_en, unsigned int prescale_cmp_en, unsigned int rollover_en);
Anna Bridge 186:707f6e361f3e 160
Anna Bridge 186:707f6e361f3e 161 /**
Anna Bridge 186:707f6e361f3e 162 * @brief Enter LP2 power-saving mode
Anna Bridge 186:707f6e361f3e 163 * @returns #E_NO_ERROR on success, error if unsuccessful.
Anna Bridge 186:707f6e361f3e 164 */
Anna Bridge 186:707f6e361f3e 165 int LP_EnterLP2(void);
Anna Bridge 186:707f6e361f3e 166
Anna Bridge 186:707f6e361f3e 167 /**
Anna Bridge 186:707f6e361f3e 168 * @brief Enter LP1 mode, which saves CPU state and SRAM. Execution resumes after this call.
Anna Bridge 186:707f6e361f3e 169 * @note Interrupts should be globally disabled before calling this function.
Anna Bridge 186:707f6e361f3e 170 * @returns #E_NO_ERROR on success, error if unsuccessful.
Anna Bridge 186:707f6e361f3e 171 */
Anna Bridge 186:707f6e361f3e 172 int LP_EnterLP1(void);
Anna Bridge 186:707f6e361f3e 173
Anna Bridge 186:707f6e361f3e 174 /**
Anna Bridge 186:707f6e361f3e 175 * @brief Enter the lowest-possible power mode, known as LP0. SRAM contents are lost.
Anna Bridge 186:707f6e361f3e 176 * Waking up from LP0 is like a system reset. This function does not return.
Anna Bridge 186:707f6e361f3e 177 * @note Interrupts are globally disabled upon entering this function.
Anna Bridge 186:707f6e361f3e 178 */
Anna Bridge 186:707f6e361f3e 179 void LP_EnterLP0(void);
Anna Bridge 186:707f6e361f3e 180
Anna Bridge 186:707f6e361f3e 181 #ifdef __cplusplus
Anna Bridge 186:707f6e361f3e 182 }
Anna Bridge 186:707f6e361f3e 183 #endif
Anna Bridge 186:707f6e361f3e 184
Anna Bridge 186:707f6e361f3e 185 #endif /* _LP_H_ */