NXP's driver library for LPC17xx, ported to mbed's online compiler. Not tested! I had to fix a lot of warings and found a couple of pretty obvious bugs, so the chances are there are more. Original: http://ics.nxp.com/support/documents/microcontrollers/zip/lpc17xx.cmsis.driver.library.zip

Dependencies:   mbed

Committer:
igorsk
Date:
Wed Feb 17 16:22:39 2010 +0000
Revision:
0:1063a091a062

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
igorsk 0:1063a091a062 1 /**
igorsk 0:1063a091a062 2 * @file : lpc17xx_rit.c
igorsk 0:1063a091a062 3 * @brief : Contains all functions support for RIT firmware library on LPC17xx
igorsk 0:1063a091a062 4 * @version : 1.0
igorsk 0:1063a091a062 5 * @date : 7. May. 2009
igorsk 0:1063a091a062 6 * @author : NguyenCao
igorsk 0:1063a091a062 7 **************************************************************************
igorsk 0:1063a091a062 8 * Software that is described herein is for illustrative purposes only
igorsk 0:1063a091a062 9 * which provides customers with programming information regarding the
igorsk 0:1063a091a062 10 * products. This software is supplied "AS IS" without any warranties.
igorsk 0:1063a091a062 11 * NXP Semiconductors assumes no responsibility or liability for the
igorsk 0:1063a091a062 12 * use of the software, conveys no license or title under any patent,
igorsk 0:1063a091a062 13 * copyright, or mask work right to the product. NXP Semiconductors
igorsk 0:1063a091a062 14 * reserves the right to make changes in the software without
igorsk 0:1063a091a062 15 * notification. NXP Semiconductors also make no representation or
igorsk 0:1063a091a062 16 * warranty that such application will be suitable for the specified
igorsk 0:1063a091a062 17 * use without further testing or modification.
igorsk 0:1063a091a062 18 **********************************************************************/
igorsk 0:1063a091a062 19
igorsk 0:1063a091a062 20 /* Peripheral group ----------------------------------------------------------- */
igorsk 0:1063a091a062 21 /** @addtogroup RIT
igorsk 0:1063a091a062 22 * @{
igorsk 0:1063a091a062 23 */
igorsk 0:1063a091a062 24
igorsk 0:1063a091a062 25 /* Includes ------------------------------------------------------------------- */
igorsk 0:1063a091a062 26 #include "lpc17xx_rit.h"
igorsk 0:1063a091a062 27 #include "lpc17xx_clkpwr.h"
igorsk 0:1063a091a062 28
igorsk 0:1063a091a062 29 /* If this source file built with example, the LPC17xx FW library configuration
igorsk 0:1063a091a062 30 * file in each example directory ("lpc17xx_libcfg.h") must be included,
igorsk 0:1063a091a062 31 * otherwise the default FW library configuration file must be included instead
igorsk 0:1063a091a062 32 */
igorsk 0:1063a091a062 33 #ifdef __BUILD_WITH_EXAMPLE__
igorsk 0:1063a091a062 34 #include "lpc17xx_libcfg.h"
igorsk 0:1063a091a062 35 #else
igorsk 0:1063a091a062 36 #include "lpc17xx_libcfg_default.h"
igorsk 0:1063a091a062 37 #endif /* __BUILD_WITH_EXAMPLE__ */
igorsk 0:1063a091a062 38
igorsk 0:1063a091a062 39 #ifdef _RIT
igorsk 0:1063a091a062 40
igorsk 0:1063a091a062 41 /* Public Functions ----------------------------------------------------------- */
igorsk 0:1063a091a062 42 /** @addtogroup RIT_Public_Functions
igorsk 0:1063a091a062 43 * @{
igorsk 0:1063a091a062 44 */
igorsk 0:1063a091a062 45
igorsk 0:1063a091a062 46 /******************************************************************************//*
igorsk 0:1063a091a062 47 * @brief Initial for RIT
igorsk 0:1063a091a062 48 * - Turn on power and clock
igorsk 0:1063a091a062 49 * - Setup default register values
igorsk 0:1063a091a062 50 * @param[in] RITx is RIT peripheral selected, should be: RIT
igorsk 0:1063a091a062 51 * @return None
igorsk 0:1063a091a062 52 *******************************************************************************/
igorsk 0:1063a091a062 53 void RIT_Init(LPC_RIT_TypeDef *RITx)
igorsk 0:1063a091a062 54 {
igorsk 0:1063a091a062 55 CHECK_PARAM(PARAM_RITx(RITx));
igorsk 0:1063a091a062 56 CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCRIT, ENABLE);
igorsk 0:1063a091a062 57 //Set up default register values
igorsk 0:1063a091a062 58 RITx->RICOMPVAL = 0xFFFFFFFF;
igorsk 0:1063a091a062 59 RITx->RIMASK = 0x00000000;
igorsk 0:1063a091a062 60 RITx->RICTRL = 0x0C;
igorsk 0:1063a091a062 61 RITx->RICOUNTER = 0x00000000;
igorsk 0:1063a091a062 62 // Turn on power and clock
igorsk 0:1063a091a062 63
igorsk 0:1063a091a062 64 }
igorsk 0:1063a091a062 65 /******************************************************************************//*
igorsk 0:1063a091a062 66 * @brief DeInitial for RIT
igorsk 0:1063a091a062 67 * - Turn off power and clock
igorsk 0:1063a091a062 68 * - ReSetup default register values
igorsk 0:1063a091a062 69 * @param[in] RITx is RIT peripheral selected, should be: RIT
igorsk 0:1063a091a062 70 * @return None
igorsk 0:1063a091a062 71 *******************************************************************************/
igorsk 0:1063a091a062 72 void RIT_DeInit(LPC_RIT_TypeDef *RITx)
igorsk 0:1063a091a062 73 {
igorsk 0:1063a091a062 74 CHECK_PARAM(PARAM_RITx(RITx));
igorsk 0:1063a091a062 75
igorsk 0:1063a091a062 76 // Turn off power and clock
igorsk 0:1063a091a062 77 CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCRIT, DISABLE);
igorsk 0:1063a091a062 78 //ReSetup default register values
igorsk 0:1063a091a062 79 RITx->RICOMPVAL = 0xFFFFFFFF;
igorsk 0:1063a091a062 80 RITx->RIMASK = 0x00000000;
igorsk 0:1063a091a062 81 RITx->RICTRL = 0x0C;
igorsk 0:1063a091a062 82 RITx->RICOUNTER = 0x00000000;
igorsk 0:1063a091a062 83 }
igorsk 0:1063a091a062 84 /******************************************************************************//*
igorsk 0:1063a091a062 85 * @brief Set compare value, mask value and time counter value
igorsk 0:1063a091a062 86 * @param[in] RITx is RIT peripheral selected, should be: RIT
igorsk 0:1063a091a062 87 * @param[in] value: pointer to RIT_CMP_VAL Structure
igorsk 0:1063a091a062 88 * @return None
igorsk 0:1063a091a062 89 *******************************************************************************/
igorsk 0:1063a091a062 90 void RIT_TimerConfig(LPC_RIT_TypeDef *RITx, RIT_CMP_VAL *value)
igorsk 0:1063a091a062 91 {
igorsk 0:1063a091a062 92 CHECK_PARAM(PARAM_RITx(RITx));
igorsk 0:1063a091a062 93
igorsk 0:1063a091a062 94 RITx->RICOMPVAL = value->CMPVAL;
igorsk 0:1063a091a062 95 RITx->RIMASK = value->MASKVAL;
igorsk 0:1063a091a062 96 RITx->RICOUNTER = value->COUNTVAL;
igorsk 0:1063a091a062 97 }
igorsk 0:1063a091a062 98 /******************************************************************************//*
igorsk 0:1063a091a062 99 * @brief Enable/Disable Timer
igorsk 0:1063a091a062 100 * @param[in] RITx is RIT peripheral selected, should be: RIT
igorsk 0:1063a091a062 101 * @param[in] NewState New State of this function
igorsk 0:1063a091a062 102 * -ENABLE: Enable Timer
igorsk 0:1063a091a062 103 * -DISABLE: Disable Timer
igorsk 0:1063a091a062 104 * @return None
igorsk 0:1063a091a062 105 *******************************************************************************/
igorsk 0:1063a091a062 106 void RIT_Cmd(LPC_RIT_TypeDef *RITx, FunctionalState NewState)
igorsk 0:1063a091a062 107 {
igorsk 0:1063a091a062 108 CHECK_PARAM(PARAM_RITx(RITx));
igorsk 0:1063a091a062 109 CHECK_PARAM(PARAM_FUNCTIONALSTATE(NewState));
igorsk 0:1063a091a062 110
igorsk 0:1063a091a062 111 //Enable or Disable Timer
igorsk 0:1063a091a062 112 if(NewState==ENABLE)
igorsk 0:1063a091a062 113 {
igorsk 0:1063a091a062 114 RITx->RICTRL |= RIT_CTRL_TEN;
igorsk 0:1063a091a062 115 }
igorsk 0:1063a091a062 116 else
igorsk 0:1063a091a062 117 {
igorsk 0:1063a091a062 118 RITx->RICTRL &= ~RIT_CTRL_TEN;
igorsk 0:1063a091a062 119 }
igorsk 0:1063a091a062 120 }
igorsk 0:1063a091a062 121 /******************************************************************************//*
igorsk 0:1063a091a062 122 * @brief Timer Enable/Disable Clear
igorsk 0:1063a091a062 123 * @param[in] RITx is RIT peripheral selected, should be: RIT
igorsk 0:1063a091a062 124 * @param[in] NewState New State of this function
igorsk 0:1063a091a062 125 * -ENABLE: The timer will be cleared to 0 whenever
igorsk 0:1063a091a062 126 * the counter value equals the masked compare value specified
igorsk 0:1063a091a062 127 * by the contents of RICOMPVAL and RIMASK register
igorsk 0:1063a091a062 128 * -DISABLE: The timer will not be clear to 0
igorsk 0:1063a091a062 129 * @return None
igorsk 0:1063a091a062 130 *******************************************************************************/
igorsk 0:1063a091a062 131 void RIT_TimerClearCmd(LPC_RIT_TypeDef *RITx, FunctionalState NewState)
igorsk 0:1063a091a062 132 {
igorsk 0:1063a091a062 133 CHECK_PARAM(PARAM_RITx(RITx));
igorsk 0:1063a091a062 134 CHECK_PARAM(PARAM_FUNCTIONALSTATE(NewState));
igorsk 0:1063a091a062 135
igorsk 0:1063a091a062 136 //Timer Enable/Disable Clear
igorsk 0:1063a091a062 137 if(NewState==ENABLE)
igorsk 0:1063a091a062 138 {
igorsk 0:1063a091a062 139 RITx->RICTRL |= RIT_CTRL_ENCLR;
igorsk 0:1063a091a062 140 }
igorsk 0:1063a091a062 141 else
igorsk 0:1063a091a062 142 {
igorsk 0:1063a091a062 143 RITx->RICTRL &= ~RIT_CTRL_ENCLR;
igorsk 0:1063a091a062 144 }
igorsk 0:1063a091a062 145 }
igorsk 0:1063a091a062 146 /******************************************************************************//*
igorsk 0:1063a091a062 147 * @brief Timer Enable/Disable on break
igorsk 0:1063a091a062 148 * @param[in] RITx is RIT peripheral selected, should be: RIT
igorsk 0:1063a091a062 149 * @param[in] NewState New State of this function
igorsk 0:1063a091a062 150 * -ENABLE: The timer is halted whenever a hardware break condition occurs
igorsk 0:1063a091a062 151 * -DISABLE: Hardware break has no effect on the timer operation
igorsk 0:1063a091a062 152 * @return None
igorsk 0:1063a091a062 153 *******************************************************************************/
igorsk 0:1063a091a062 154 void RIT_TimerEnableOnBreakCmd(LPC_RIT_TypeDef *RITx, FunctionalState NewState)
igorsk 0:1063a091a062 155 {
igorsk 0:1063a091a062 156 CHECK_PARAM(PARAM_RITx(RITx));
igorsk 0:1063a091a062 157 CHECK_PARAM(PARAM_FUNCTIONALSTATE(NewState));
igorsk 0:1063a091a062 158
igorsk 0:1063a091a062 159 //Timer Enable/Disable on break
igorsk 0:1063a091a062 160 if(NewState==ENABLE)
igorsk 0:1063a091a062 161 {
igorsk 0:1063a091a062 162 RITx->RICTRL |= RIT_CTRL_ENBR;
igorsk 0:1063a091a062 163 }
igorsk 0:1063a091a062 164 else
igorsk 0:1063a091a062 165 {
igorsk 0:1063a091a062 166 RITx->RICTRL &= ~RIT_CTRL_ENBR;
igorsk 0:1063a091a062 167 }
igorsk 0:1063a091a062 168 }
igorsk 0:1063a091a062 169 /******************************************************************************//*
igorsk 0:1063a091a062 170 * @brief Check whether interrupt flag is set or not
igorsk 0:1063a091a062 171 * @param[in] RITx is RIT peripheral selected, should be: RIT
igorsk 0:1063a091a062 172 * @return Current interrupt status, could be: SET/RESET
igorsk 0:1063a091a062 173 *******************************************************************************/
igorsk 0:1063a091a062 174 IntStatus RIT_GetIntStatus(LPC_RIT_TypeDef *RITx)
igorsk 0:1063a091a062 175 {
igorsk 0:1063a091a062 176 IntStatus result;
igorsk 0:1063a091a062 177 CHECK_PARAM(PARAM_RITx(RITx));
igorsk 0:1063a091a062 178 if((RITx->RICTRL&RIT_CTRL_INTEN)==1) result= SET;
igorsk 0:1063a091a062 179 else return RESET;
igorsk 0:1063a091a062 180 //clear interrupt flag
igorsk 0:1063a091a062 181 RITx->RICTRL |= RIT_CTRL_INTEN;
igorsk 0:1063a091a062 182 return result;
igorsk 0:1063a091a062 183 }
igorsk 0:1063a091a062 184
igorsk 0:1063a091a062 185 /**
igorsk 0:1063a091a062 186 * @}
igorsk 0:1063a091a062 187 */
igorsk 0:1063a091a062 188
igorsk 0:1063a091a062 189 #endif /* _RIT */
igorsk 0:1063a091a062 190
igorsk 0:1063a091a062 191 /**
igorsk 0:1063a091a062 192 * @}
igorsk 0:1063a091a062 193 */
igorsk 0:1063a091a062 194
igorsk 0:1063a091a062 195 /* --------------------------------- End Of File ------------------------------ */