![]() |
|
|||
File indexing completed on 2025-05-11 08:23:56
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup RTEMSBSPsPowerPCMPC55XX 0007 * 0008 * @brief Enhanced Modular Input Output Subsystem (eMIOS). 0009 */ 0010 0011 /* 0012 * Copyright (C) 2009, 2011 embedded brains GmbH & Co. KG 0013 * 0014 * Redistribution and use in source and binary forms, with or without 0015 * modification, are permitted provided that the following conditions 0016 * are met: 0017 * 1. Redistributions of source code must retain the above copyright 0018 * notice, this list of conditions and the following disclaimer. 0019 * 2. Redistributions in binary form must reproduce the above copyright 0020 * notice, this list of conditions and the following disclaimer in the 0021 * documentation and/or other materials provided with the distribution. 0022 * 0023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0024 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0025 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0026 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0027 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0028 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0029 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0030 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0031 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0032 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0033 * POSSIBILITY OF SUCH DAMAGE. 0034 */ 0035 0036 #include <mpc55xx/emios.h> 0037 0038 #ifdef MPC55XX_HAS_EMIOS 0039 0040 /** 0041 * @brief Initialize the eMIOS module. 0042 * 0043 * The module is enabled. It is configured to use the internal clock. The 0044 * global prescaler value is set to @a prescaler. If the value is greater than 0045 * the maximum the maxium value will be used instead. A prescaler value of 0046 * zero disables the clock. 0047 * 0048 * @note No protection against concurrent execution. 0049 */ 0050 void mpc55xx_emios_initialize( unsigned prescaler) 0051 { 0052 union EMIOS_MCR_tag mcr = MPC55XX_ZERO_FLAGS; 0053 0054 /* Enable module */ 0055 mcr.B.MDIS = 0; 0056 0057 /* Disable debug mode */ 0058 mcr.B.FRZ = 1; 0059 0060 /* Enable global time base */ 0061 mcr.B.GTBE = 1; 0062 0063 /* Disable global prescaler (= disable clock) */ 0064 mcr.B.GPREN = 0; 0065 0066 /* Set MCR */ 0067 EMIOS.MCR.R = mcr.R; 0068 0069 /* Set OUDR */ 0070 EMIOS.OUDR.R = 0; 0071 0072 /* Set global prescaler value */ 0073 mpc55xx_emios_set_global_prescaler( prescaler); 0074 } 0075 0076 /** 0077 * @brief Returns the global prescaler value of the eMIOS module. 0078 */ 0079 unsigned mpc55xx_emios_global_prescaler( void) 0080 { 0081 union EMIOS_MCR_tag mcr = EMIOS.MCR; 0082 0083 if (mcr.B.GPREN != 0) { 0084 return mcr.B.GPRE + 1; 0085 } else { 0086 return 0; 0087 } 0088 } 0089 0090 /** 0091 * @brief Sets the global prescaler value of the eMIOS module. 0092 * 0093 * The global prescaler value is set to @a prescaler. If the value is greater 0094 * than the maximum the maxium value will be used instead. A prescaler value 0095 * of zero disables the clock. 0096 * 0097 * @note No protection against concurrent execution. 0098 */ 0099 void mpc55xx_emios_set_global_prescaler( unsigned prescaler) 0100 { 0101 union EMIOS_MCR_tag mcr = EMIOS.MCR; 0102 0103 /* Enable or disable the global prescaler */ 0104 mcr.B.GPREN = prescaler > 0 ? 1 : 0; 0105 0106 /* Set global prescaler value */ 0107 if (prescaler > 256) { 0108 prescaler = 256; 0109 } else if (prescaler < 1) { 0110 prescaler = 1; 0111 } 0112 mcr.B.GPRE = prescaler - 1; 0113 0114 /* Set MCR */ 0115 EMIOS.MCR.R = mcr.R; 0116 } 0117 0118 #endif /* MPC55XX_HAS_EMIOS */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |