CMSIS2000  0.0.7
 Указатель Структуры данных Файлы Функции Переменные Определения типов Перечисления Элементы перечислений Макросы Группы Страницы
lpc2xxx_pclk.h
См. документацию.
1 /*
2  * CMSIS2000
3  * CMSIS-like sources for LPC2xxx series MCUs
4  *
5  * (C) Copyright 2011-2012, Dmitriy Cherepanov, All Rights Reserved
6  *
7  * Version: 0.0.7
8  * Date of the Last Update: 2013-03-04
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a copy
11  * of this software and associated documentation files (the "Software"), to
12  * deal in the Software without restriction, including without limitation the
13  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14  * sell copies of the Software, and to permit persons to whom the Software is
15  * furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included in
18  * all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26  * IN THE SOFTWARE.
27  *
28  * Do not be lasy! For the latest version see http://irtos.sourceforge.net .
29  *
30  *
31 #*/
32 
33 #ifndef _PORT_LPC2XXX_PCLK_H_
34 #define _PORT_LPC2XXX_PCLK_H_ 1
35 /*-----------Документация Doxygen -- Doxygen documentation -----------------*/
36 /** \file
37  *\if russian_lng
38  * Определения для схемы PCLK (peripheral) NXP LPC2xxx
39  *\else
40  * Definitions for NXP LPC2xxx PLCLK (peripheral) module and POWERMODI:E
41  *\endif
42  * \ingroup LPC2xxx_System_periphiral
43  * @{
44  */
45 #if _HASBSPBRD > 0
46 #include "bsp_board_def.h"/* board /definitions if you do not have this file then create it with '#include "mcu_id.h"' line*/
47 #else
48  #include "mcu_id.h"
49 #endif
50 #include "lpc2xxx_pllclk.h"
51 /*------ LPC peripheral numbers ----------------------------------------------*/
52 #define WDT_lpc_periph 0 /**< number for WDT. */
53 #define TIMER0_lpc_periph 1 /**< number for TIMER0.*/
54 #define TIMER1_lpc_periph 2 /**< number for TIMER1. */
55 #define UART0_lpc_periph 3 /**< number for UART0. */
56 #define UART1_lpc_periph 4 /**< number for UART1. */
57 #define PWM0_lpc_periph 5 /**< number for PWM0. */
58 #define PWM1_lpc_periph 6 /**< number for PWM1 */
59 #define I2C0_lpc_periph 7 /**< number for I2C0. */
60 #define SPI_lpc_periph 8 /**< number for SPI */
61 #define RTC_lpc_periph 9 /**< number for RTC. */
62 #define SSP1_lpc_periph 10 /**< number for SSP1. */
63 #define DAC_lpc_periph 11 /**< number for DAC. */
64 #define ADC_lpc_periph 12 /**< number for ADC. */
65 #define ADC0_lpc_periph ADC_lpc_periph /**< number for ADC.0 */
66 #define CAN1_lpc_periph 13 /**< number for CAN1.*/
67 #define CAN2_lpc_periph 14 /**< number for CAN2. */
68 #define ACF_lpc_periph 15 /**< number for CAN filtering.*/
69 
70 #define BAT_RAM_lpc_periph 16/**< number for the battery supported RAM */
71 #define GPIO_lpc_periph 17 /**< number for GPIOs.*/
72 #define PCB_lpc_periph 18 /**< number for the Pin Connect block. */
73 #define I2C1_lpc_periph 19 /**< number for I2C1. */
74 #define LCD_lpc_periph 20
75 #define ADC1_lpc_periph 20
76 #define SSP0_lpc_periph 21 /**< number for SSP0. */
77 #define TIMER2_lpc_periph 22 /**< number for TIMER2 */
78 #define TIMER3_lpc_periph 23 /**< number for TIMER3. */
79 #define UART2_lpc_periph 24/**< number for UART2 */
80 #define UART3_lpc_periph 25/**< number for UART3. */
81 #define I2C2_lpc_periph 26/**< number for I2C2. */
82 #define I2S_lpc_periph 27/**< number for I2S. */
83 #define MCI_lpc_periph 28/**< number for MCI. */
84 #define GPDMA_lpc_periph 29
85 #define ENET_lpc_periph 30
86 #define SYSCON_lpc_periph 30 /**<number for the System Control */
87 #define USB_lpc_periph 31/**< number for USB */
88 /*---------Peripheral Clocks -> PLCK deviders---------------------------------*/
89 /**\addtogroup LPC2xxx_System_periphiral
90  * \brief NXP PLCK divider
91  * NXP PCLK Peripheral Clock devider -> PLCK divider (VPB bus clock dividers)
92  * Bit1 Bit0 Description
93  * 0 0 cclk/4 (1/4 From CPU CLOCK)
94  * 0 1 cclk/1 (No division)
95  * 1 0 cclk/2 (1/2 From CPU CLOCK)
96  * 1 1 cclk/6 or cclk/8
97  */
98 #define PLCK_divider_4 0
99 #define PLCK_divider_1 1
100 #define PLCK_divider_2 2
101 #define PLCK_divider_8 3 /* sometime it is 6*/
102 #define PLCK_divider_6 3 /* sometime it is 8*/
103 /*
104 00 PCLK_xyz = CCLK/4
105 01 PCLK_xyz = CCLK[1]
106 10 PCLK_xyz = CCLK/2
107 11 Peripheral’s clock is selected to PCLK_xyz = CCLK/8
108 except for CAN1, CAN2, and CAN filtering when ’11’
109 selects PCLK_xyz = CCLK/6.
110 */
111 /** PLCK devider convert division coefficient to value witch goes on multiplexor*/
112 #define LPC2XXX_PLCK_DIVIDER_VALUE(devider_koeff) PLCK_divider_##devider_koeff
113 /*----------------------------------------------------------------------------*/
114 #if ((i_MCU_MODEL > 2300) || ((i_MCU_MODEL > 1700) && (i_MCU_MODEL < 1900)))
115 
116 /** calculate value for two bits to PCLKSEL0 and PCLKSEL1 registers
117  \param koeff -- division coefficient -- passable values are 4, 1, 2, (8 or 6)
118  \param module -- param module from peripheral_offsets.h
119 \code
120 PCLKSEL0 = LPC2XXX_PCLK_V(WDT,4) | LPC2XXX_PCLK_V(TIMER0,1)
121 \endcode
122 */
123 #define LPC2XXX_PCLK_V(module,koeff) (1<<((module##_lpc_periph&0x0F) + 1))*LPC2XXX_PLCK_DIVIDER_VALUE(koeff)
124 /* why plus 1 ???*/
125 
126 
127 #define GET_PCLKSEL(module) ((module##_lpc_periph*0x10)/16)
128 
129 #define SET_PCLKSEL(module,koeff) PCLKSEL##GET_PCLKSEL(module) = \
130  PCLKSEL##GET_PCLKSEL(module) | LPC2XXX_PCLK_V(module,koeff)
131 #else
132  #ifndef PCLK_DIVIDER
133  #define PCLK_DIVIDER 4
134  #endif
135 #endif
136 
137 #define APBDIV_Val LPC2XXX_PLCK_DIVIDER_VALUE(PCLK_DIVIDER)
138 #define F_PCLK_HZ (F_CCLK_HZ/PCLK_DIVIDER)
139 /** @} end of group LPC2xxx_System_periphiral */
140 #endif /* _PORT_LPC2XXX_PCLK_H_ */