mbed library sources. Supersedes mbed-src. removed serial

Fork of mbed-dev by mbed official

Committer:
mrcrsch
Date:
Mon Feb 13 14:26:36 2017 +0000
Revision:
158:aa577577efe0
Parent:
157:ff67d9f36b67
removed stdio and serial to reduce size

Who changed what in which revision?

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