mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

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

Committer:
mbed_official
Date:
Thu Apr 03 11:45:06 2014 +0100
Revision:
149:1fb5f62b92bd
Parent:
targets/hal/TARGET_Freescale/TARGET_KSDK_MCUS/TARGET_KSDK_CODE/hal/wdog/fsl_wdog_hal.c@146:f64d43ff0c18
Child:
324:406fd2029f23
Synchronized with git revision 220c0bb39ceee40016e1e86350c058963d01ed42

Full URL: https://github.com/mbedmicro/mbed/commit/220c0bb39ceee40016e1e86350c058963d01ed42/

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 146:f64d43ff0c18 1 /*
mbed_official 146:f64d43ff0c18 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
mbed_official 146:f64d43ff0c18 3 * All rights reserved.
mbed_official 146:f64d43ff0c18 4 *
mbed_official 146:f64d43ff0c18 5 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 146:f64d43ff0c18 6 * are permitted provided that the following conditions are met:
mbed_official 146:f64d43ff0c18 7 *
mbed_official 146:f64d43ff0c18 8 * o Redistributions of source code must retain the above copyright notice, this list
mbed_official 146:f64d43ff0c18 9 * of conditions and the following disclaimer.
mbed_official 146:f64d43ff0c18 10 *
mbed_official 146:f64d43ff0c18 11 * o Redistributions in binary form must reproduce the above copyright notice, this
mbed_official 146:f64d43ff0c18 12 * list of conditions and the following disclaimer in the documentation and/or
mbed_official 146:f64d43ff0c18 13 * other materials provided with the distribution.
mbed_official 146:f64d43ff0c18 14 *
mbed_official 146:f64d43ff0c18 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
mbed_official 146:f64d43ff0c18 16 * contributors may be used to endorse or promote products derived from this
mbed_official 146:f64d43ff0c18 17 * software without specific prior written permission.
mbed_official 146:f64d43ff0c18 18 *
mbed_official 146:f64d43ff0c18 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 146:f64d43ff0c18 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 146:f64d43ff0c18 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 146:f64d43ff0c18 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
mbed_official 146:f64d43ff0c18 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 146:f64d43ff0c18 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 146:f64d43ff0c18 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
mbed_official 146:f64d43ff0c18 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 146:f64d43ff0c18 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 146:f64d43ff0c18 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 146:f64d43ff0c18 29 */
mbed_official 146:f64d43ff0c18 30
mbed_official 146:f64d43ff0c18 31 #include "fsl_wdog_hal.h"
mbed_official 146:f64d43ff0c18 32
mbed_official 146:f64d43ff0c18 33 /*******************************************************************************
mbed_official 146:f64d43ff0c18 34 * Definitions
mbed_official 146:f64d43ff0c18 35 *******************************************************************************/
mbed_official 146:f64d43ff0c18 36
mbed_official 146:f64d43ff0c18 37 /*******************************************************************************
mbed_official 146:f64d43ff0c18 38 * Variables
mbed_official 146:f64d43ff0c18 39 *******************************************************************************/
mbed_official 146:f64d43ff0c18 40
mbed_official 146:f64d43ff0c18 41 /*!
mbed_official 146:f64d43ff0c18 42 * @brief Watchdog internal config buffer to handle control and
mbed_official 146:f64d43ff0c18 43 * configure register's write-once-only character.
mbed_official 146:f64d43ff0c18 44 * Reset value of WDOG_STCTRLH is 0x1D3
mbed_official 146:f64d43ff0c18 45 */
mbed_official 146:f64d43ff0c18 46 static volatile uint32_t s_wdogSTCTRLH = 0x1D3;
mbed_official 146:f64d43ff0c18 47
mbed_official 146:f64d43ff0c18 48 /*******************************************************************************
mbed_official 146:f64d43ff0c18 49 * Code
mbed_official 146:f64d43ff0c18 50 *******************************************************************************/
mbed_official 146:f64d43ff0c18 51
mbed_official 146:f64d43ff0c18 52 /*FUNCTION****************************************************************
mbed_official 146:f64d43ff0c18 53 *
mbed_official 146:f64d43ff0c18 54 * Function Name : wdog_hal_enable
mbed_official 146:f64d43ff0c18 55 * Description : Enable watchdog module. Should be called after all
mbed_official 146:f64d43ff0c18 56 * necessary configure have been set.
mbed_official 146:f64d43ff0c18 57 * This function is used to enable the WDOG and must be called after all
mbed_official 146:f64d43ff0c18 58 * necessary configure have been set.
mbed_official 146:f64d43ff0c18 59 *
mbed_official 146:f64d43ff0c18 60 *END*********************************************************************/
mbed_official 146:f64d43ff0c18 61 void wdog_hal_enable(void)
mbed_official 146:f64d43ff0c18 62 {
mbed_official 146:f64d43ff0c18 63 s_wdogSTCTRLH |= BM_WDOG_STCTRLH_WDOGEN;
mbed_official 146:f64d43ff0c18 64 HW_WDOG_STCTRLH_WR(s_wdogSTCTRLH);
mbed_official 146:f64d43ff0c18 65 }
mbed_official 146:f64d43ff0c18 66
mbed_official 146:f64d43ff0c18 67 /*FUNCTION****************************************************************
mbed_official 146:f64d43ff0c18 68 *
mbed_official 146:f64d43ff0c18 69 * Function Name : wdog_hal_disable
mbed_official 146:f64d43ff0c18 70 * Description : Disable watchdog module.
mbed_official 146:f64d43ff0c18 71 * This function is used to disable the WDOG.
mbed_official 146:f64d43ff0c18 72 *
mbed_official 146:f64d43ff0c18 73 *END*********************************************************************/
mbed_official 146:f64d43ff0c18 74 void wdog_hal_disable(void)
mbed_official 146:f64d43ff0c18 75 {
mbed_official 146:f64d43ff0c18 76 s_wdogSTCTRLH &= ~BM_WDOG_STCTRLH_WDOGEN;
mbed_official 146:f64d43ff0c18 77 HW_WDOG_STCTRLH_WR(s_wdogSTCTRLH);
mbed_official 146:f64d43ff0c18 78 }
mbed_official 146:f64d43ff0c18 79
mbed_official 146:f64d43ff0c18 80 /*FUNCTION****************************************************************
mbed_official 146:f64d43ff0c18 81 *
mbed_official 146:f64d43ff0c18 82 * Function Name : wdog_hal_configure_interrupt
mbed_official 146:f64d43ff0c18 83 * Description : Enable and disable watchdog interrupt.
mbed_official 146:f64d43ff0c18 84 * This function is used to configure the WDOG interrupt.
mbed_official 146:f64d43ff0c18 85 * Configure is saved in internal configure buffer and write back to
mbed_official 146:f64d43ff0c18 86 * register in wdog_hal_enable function, so this function must be
mbed_official 146:f64d43ff0c18 87 * called before wdog_hal_enable is called.
mbed_official 146:f64d43ff0c18 88 *
mbed_official 146:f64d43ff0c18 89 *END*********************************************************************/
mbed_official 146:f64d43ff0c18 90 void wdog_hal_configure_interrupt(bool isEnabled)
mbed_official 146:f64d43ff0c18 91 {
mbed_official 146:f64d43ff0c18 92 if (isEnabled)
mbed_official 146:f64d43ff0c18 93 {
mbed_official 146:f64d43ff0c18 94 s_wdogSTCTRLH |= BM_WDOG_STCTRLH_IRQRSTEN;
mbed_official 146:f64d43ff0c18 95 }
mbed_official 146:f64d43ff0c18 96 else
mbed_official 146:f64d43ff0c18 97 {
mbed_official 146:f64d43ff0c18 98 s_wdogSTCTRLH &= ~BM_WDOG_STCTRLH_IRQRSTEN;
mbed_official 146:f64d43ff0c18 99 }
mbed_official 146:f64d43ff0c18 100 }
mbed_official 146:f64d43ff0c18 101
mbed_official 146:f64d43ff0c18 102 /*FUNCTION****************************************************************
mbed_official 146:f64d43ff0c18 103 *
mbed_official 146:f64d43ff0c18 104 * Function Name : wdog_hal_set_clock_source
mbed_official 146:f64d43ff0c18 105 * Description : set watchdog clock Source
mbed_official 146:f64d43ff0c18 106 * This function is used to set the WDOG clock source, there are two clock sources can be used,
mbed_official 146:f64d43ff0c18 107 * one is LPO clock and the other is bus clock.
mbed_official 146:f64d43ff0c18 108 * Configure is saved in internal configure buffer and write back to
mbed_official 146:f64d43ff0c18 109 * register in wdog_hal_enable function, so this function must be
mbed_official 146:f64d43ff0c18 110 * called before wdog_hal_enable is called.
mbed_official 146:f64d43ff0c18 111 *
mbed_official 146:f64d43ff0c18 112 *END*********************************************************************/
mbed_official 146:f64d43ff0c18 113 void wdog_hal_set_clock_source(wdog_clock_source_t clockSource)
mbed_official 146:f64d43ff0c18 114 {
mbed_official 146:f64d43ff0c18 115 if (kWdogDedicatedClock == clockSource)
mbed_official 146:f64d43ff0c18 116 {
mbed_official 146:f64d43ff0c18 117 s_wdogSTCTRLH &= ~BM_WDOG_STCTRLH_CLKSRC;
mbed_official 146:f64d43ff0c18 118 }
mbed_official 146:f64d43ff0c18 119 else
mbed_official 146:f64d43ff0c18 120 {
mbed_official 146:f64d43ff0c18 121 s_wdogSTCTRLH |= BM_WDOG_STCTRLH_CLKSRC;
mbed_official 146:f64d43ff0c18 122 }
mbed_official 146:f64d43ff0c18 123 }
mbed_official 146:f64d43ff0c18 124
mbed_official 146:f64d43ff0c18 125 /*FUNCTION****************************************************************
mbed_official 146:f64d43ff0c18 126 *
mbed_official 146:f64d43ff0c18 127 * Function Name : wdog_hal_configure_window_mode
mbed_official 146:f64d43ff0c18 128 * Description : Enable and disable watchdog window mode
mbed_official 146:f64d43ff0c18 129 * This function is used to configure the WDOG window mode.
mbed_official 146:f64d43ff0c18 130 * Configure is saved in internal configure buffer and write back to
mbed_official 146:f64d43ff0c18 131 * register in wdog_hal_enable function, so this function must be
mbed_official 146:f64d43ff0c18 132 * called before wdog_hal_enable is called.
mbed_official 146:f64d43ff0c18 133 *
mbed_official 146:f64d43ff0c18 134 *END*********************************************************************/
mbed_official 146:f64d43ff0c18 135 void wdog_hal_configure_window_mode(bool isEnabled)
mbed_official 146:f64d43ff0c18 136 {
mbed_official 146:f64d43ff0c18 137 if (isEnabled)
mbed_official 146:f64d43ff0c18 138 {
mbed_official 146:f64d43ff0c18 139 s_wdogSTCTRLH |= BM_WDOG_STCTRLH_WINEN;
mbed_official 146:f64d43ff0c18 140 }
mbed_official 146:f64d43ff0c18 141 else
mbed_official 146:f64d43ff0c18 142 {
mbed_official 146:f64d43ff0c18 143 s_wdogSTCTRLH &= ~BM_WDOG_STCTRLH_WINEN;
mbed_official 146:f64d43ff0c18 144 }
mbed_official 146:f64d43ff0c18 145 }
mbed_official 146:f64d43ff0c18 146
mbed_official 146:f64d43ff0c18 147 /*FUNCTION****************************************************************
mbed_official 146:f64d43ff0c18 148 *
mbed_official 146:f64d43ff0c18 149 * Function Name : wdog_hal_configure_register_update
mbed_official 146:f64d43ff0c18 150 * Description : Enable and disable watchdog write-once-only register update
mbed_official 146:f64d43ff0c18 151 * This function is used to configure the WDOG register update feature, if disable means that
mbed_official 146:f64d43ff0c18 152 * Configure is saved in internal configure buffer and write back to
mbed_official 146:f64d43ff0c18 153 * register in wdog_hal_enable function, so this function must be
mbed_official 146:f64d43ff0c18 154 * called before wdog_hal_enable is called.
mbed_official 146:f64d43ff0c18 155 *
mbed_official 146:f64d43ff0c18 156 *END*********************************************************************/
mbed_official 146:f64d43ff0c18 157 void wdog_hal_configure_register_update(bool isEnabled)
mbed_official 146:f64d43ff0c18 158 {
mbed_official 146:f64d43ff0c18 159 if (isEnabled)
mbed_official 146:f64d43ff0c18 160 {
mbed_official 146:f64d43ff0c18 161 s_wdogSTCTRLH |= BM_WDOG_STCTRLH_ALLOWUPDATE;
mbed_official 146:f64d43ff0c18 162 }
mbed_official 146:f64d43ff0c18 163 else
mbed_official 146:f64d43ff0c18 164 {
mbed_official 146:f64d43ff0c18 165 s_wdogSTCTRLH &= ~BM_WDOG_STCTRLH_ALLOWUPDATE;
mbed_official 146:f64d43ff0c18 166 }
mbed_official 146:f64d43ff0c18 167 }
mbed_official 146:f64d43ff0c18 168
mbed_official 146:f64d43ff0c18 169 /*FUNCTION****************************************************************
mbed_official 146:f64d43ff0c18 170 *
mbed_official 146:f64d43ff0c18 171 * Function Name : wdog_hal_configure_enabled_in_cpu_debug_mode
mbed_official 146:f64d43ff0c18 172 * Description : Set whether watchdog is working while cpu is in debug mode
mbed_official 146:f64d43ff0c18 173 * This function is used to configure whether the WDOG is enabled in CPU debug mode.
mbed_official 146:f64d43ff0c18 174 * Configure is saved in internal configure buffer and write back to
mbed_official 146:f64d43ff0c18 175 * register in wdog_hal_enable function, so this function must be
mbed_official 146:f64d43ff0c18 176 * called before wdog_hal_enable is called.
mbed_official 146:f64d43ff0c18 177 *
mbed_official 146:f64d43ff0c18 178 *END*********************************************************************/
mbed_official 146:f64d43ff0c18 179 void wdog_hal_configure_enabled_in_cpu_debug_mode(bool isEnabled)
mbed_official 146:f64d43ff0c18 180 {
mbed_official 146:f64d43ff0c18 181 if (isEnabled)
mbed_official 146:f64d43ff0c18 182 {
mbed_official 146:f64d43ff0c18 183 s_wdogSTCTRLH |= BM_WDOG_STCTRLH_DBGEN;
mbed_official 146:f64d43ff0c18 184 }
mbed_official 146:f64d43ff0c18 185 else
mbed_official 146:f64d43ff0c18 186 {
mbed_official 146:f64d43ff0c18 187 s_wdogSTCTRLH &= ~BM_WDOG_STCTRLH_DBGEN;
mbed_official 146:f64d43ff0c18 188 }
mbed_official 146:f64d43ff0c18 189 }
mbed_official 146:f64d43ff0c18 190
mbed_official 146:f64d43ff0c18 191 /*FUNCTION****************************************************************
mbed_official 146:f64d43ff0c18 192 *
mbed_official 146:f64d43ff0c18 193 * Function Name : wdog_hal_configure_enabled_in_cpu_stop_mode
mbed_official 146:f64d43ff0c18 194 * Description : Set whether watchdog is working while cpu is in stop mode
mbed_official 146:f64d43ff0c18 195 * This function is used to configure whether the WDOG is enabled in CPU stop mode.
mbed_official 146:f64d43ff0c18 196 * Configure is saved in internal configure buffer and write back to
mbed_official 146:f64d43ff0c18 197 * register in wdog_hal_enable function, so this function must be
mbed_official 146:f64d43ff0c18 198 * called before wdog_hal_enable is called.
mbed_official 146:f64d43ff0c18 199 *
mbed_official 146:f64d43ff0c18 200 *END*********************************************************************/
mbed_official 146:f64d43ff0c18 201 void wdog_hal_configure_enabled_in_cpu_stop_mode(bool isEnabled)
mbed_official 146:f64d43ff0c18 202 {
mbed_official 146:f64d43ff0c18 203 if (isEnabled)
mbed_official 146:f64d43ff0c18 204 {
mbed_official 146:f64d43ff0c18 205 s_wdogSTCTRLH |= BM_WDOG_STCTRLH_STOPEN;
mbed_official 146:f64d43ff0c18 206 }
mbed_official 146:f64d43ff0c18 207 else
mbed_official 146:f64d43ff0c18 208 {
mbed_official 146:f64d43ff0c18 209 s_wdogSTCTRLH &= ~BM_WDOG_STCTRLH_STOPEN;
mbed_official 146:f64d43ff0c18 210 }
mbed_official 146:f64d43ff0c18 211 }
mbed_official 146:f64d43ff0c18 212
mbed_official 146:f64d43ff0c18 213 /*FUNCTION****************************************************************
mbed_official 146:f64d43ff0c18 214 *
mbed_official 146:f64d43ff0c18 215 * Function Name : wdog_hal_configure_enabled_in_cpu_wait_mode
mbed_official 146:f64d43ff0c18 216 * Description : Set whether watchdog is working while cpu is in wait mode
mbed_official 146:f64d43ff0c18 217 * This function is used to configure whether the WDOG is enabled in CPU wait mode.
mbed_official 146:f64d43ff0c18 218 * Configure is saved in internal configure buffer and write back to
mbed_official 146:f64d43ff0c18 219 * register in wdog_hal_enable function, so this function must be
mbed_official 146:f64d43ff0c18 220 * called before wdog_hal_enable is called.
mbed_official 146:f64d43ff0c18 221 *
mbed_official 146:f64d43ff0c18 222 *END*********************************************************************/
mbed_official 146:f64d43ff0c18 223 void wdog_hal_configure_enabled_in_cpu_wait_mode(bool isEnabled)
mbed_official 146:f64d43ff0c18 224 {
mbed_official 146:f64d43ff0c18 225 if (isEnabled)
mbed_official 146:f64d43ff0c18 226 {
mbed_official 146:f64d43ff0c18 227 s_wdogSTCTRLH |= BM_WDOG_STCTRLH_WAITEN;
mbed_official 146:f64d43ff0c18 228 }
mbed_official 146:f64d43ff0c18 229 else
mbed_official 146:f64d43ff0c18 230 {
mbed_official 146:f64d43ff0c18 231 s_wdogSTCTRLH &= ~BM_WDOG_STCTRLH_WAITEN;
mbed_official 146:f64d43ff0c18 232 }
mbed_official 146:f64d43ff0c18 233 }
mbed_official 146:f64d43ff0c18 234
mbed_official 146:f64d43ff0c18 235 /*******************************************************************************
mbed_official 146:f64d43ff0c18 236 * EOF
mbed_official 146:f64d43ff0c18 237 *******************************************************************************/
mbed_official 146:f64d43ff0c18 238