1 |
786 |
skrzyp |
#ifndef CYGONCE_HAL_CORTEXM_LPC17XX_VAR_LPC17XX_MISC_H
|
2 |
|
|
#define CYGONCE_HAL_CORTEXM_LPC17XX_VAR_LPC17XX_MISC_H
|
3 |
|
|
//=============================================================================
|
4 |
|
|
//
|
5 |
|
|
// lpc17xx_misc.h
|
6 |
|
|
//
|
7 |
|
|
// HAL misc variant support code for NCP LPC17xx header file
|
8 |
|
|
//
|
9 |
|
|
//=============================================================================
|
10 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
11 |
|
|
// -------------------------------------------
|
12 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
13 |
|
|
// Copyright (C) 2010 Free Software Foundation, Inc.
|
14 |
|
|
//
|
15 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
16 |
|
|
// the terms of the GNU General Public License as published by the Free
|
17 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
18 |
|
|
// version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
21 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
22 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
23 |
|
|
// for more details.
|
24 |
|
|
//
|
25 |
|
|
// You should have received a copy of the GNU General Public License
|
26 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use
|
30 |
|
|
// macros or inline functions from this file, or you compile this file
|
31 |
|
|
// and link it with other works to produce a work based on this file,
|
32 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
33 |
|
|
// the GNU General Public License. However the source code for this file
|
34 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
35 |
|
|
// General Public License v2.
|
36 |
|
|
//
|
37 |
|
|
// This exception does not invalidate any other reasons why a work based
|
38 |
|
|
// on this file might be covered by the GNU General Public License.
|
39 |
|
|
// -------------------------------------------
|
40 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
41 |
|
|
//=============================================================================
|
42 |
|
|
//#####DESCRIPTIONBEGIN####
|
43 |
|
|
//
|
44 |
|
|
// Author(s): andyj
|
45 |
|
|
// Contributors: jani, ilijak
|
46 |
|
|
// Date: 2010-12-29
|
47 |
|
|
// Purpose: LPC17XX specific miscellaneous support header file
|
48 |
|
|
// Description:
|
49 |
|
|
// Usage: #include <cyg/hal/lpc17xx_misc.h>
|
50 |
|
|
//
|
51 |
|
|
//####DESCRIPTIONEND####
|
52 |
|
|
//
|
53 |
|
|
//=============================================================================
|
54 |
|
|
|
55 |
|
|
//-----------------------------------------------------------------------------
|
56 |
|
|
// Function to obtain the current processor clock settings
|
57 |
|
|
// Use PCLK identifiers below
|
58 |
|
|
//
|
59 |
|
|
externC cyg_uint32 hal_lpc_get_pclk(cyg_uint32 pclk_id);
|
60 |
|
|
#define CYG_HAL_CORTEXM_LPC17XX_PCLK(_pclkid_) hal_lpc_get_pclk(_pclkid_)
|
61 |
|
|
|
62 |
|
|
//-----------------------------------------------------------------------------
|
63 |
|
|
// Identifiers for peripheral clock. Use these identifiers with the function
|
64 |
|
|
// hal_get_pclk()
|
65 |
|
|
//
|
66 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_WDT 0
|
67 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_TIMER0 1
|
68 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_TIMER1 2
|
69 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_UART0 3
|
70 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_UART1 4
|
71 |
|
|
#if 0 // Not implemented on LPC17xx
|
72 |
|
|
# define CYNUM_HAL_LPC17XX_PCLK_PWM0 5
|
73 |
|
|
#endif
|
74 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_PWM1 6
|
75 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_I2C0 7
|
76 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_SPI 8
|
77 |
|
|
#if 0 // Not implemented on LPC17xx
|
78 |
|
|
# define CYNUM_HAL_LPC17XX_PCLK_RTC 9
|
79 |
|
|
#endif
|
80 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_SSP1 10
|
81 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_DAC 11
|
82 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_ADC 12
|
83 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_CAN1 13
|
84 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_CAN2 14
|
85 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_ACF 15
|
86 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_QEI 16
|
87 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_GPIO 17
|
88 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_PCB 18
|
89 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_I2C1 19
|
90 |
|
|
#if 0 // Not implemented on LPC17xx
|
91 |
|
|
# define CYNUM_HAL_LPC17XX_PCLK_SSP0 21
|
92 |
|
|
#endif
|
93 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_TIMER2 22
|
94 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_TIMER3 23
|
95 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_UART2 24
|
96 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_UART3 25
|
97 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_I2C2 26
|
98 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_I2S 27
|
99 |
|
|
#if 0 // Not implemented on LPC17xx
|
100 |
|
|
# define CYNUM_HAL_LPC17XX_PCLK_MCI 28
|
101 |
|
|
#endif
|
102 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_RIT 29
|
103 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_SYSCON 30
|
104 |
|
|
#define CYNUM_HAL_LPC17XX_PCLK_MC 31
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
//-----------------------------------------------------------------------------
|
108 |
|
|
// Function to enable/disable power for certain peripheral
|
109 |
|
|
// Use PCONP identifiers from below
|
110 |
|
|
//
|
111 |
|
|
externC void hal_lpc_set_power(cyg_uint8 pconp_id, int on);
|
112 |
|
|
#define CYG_HAL_CORTEXM_LPC17XX_SET_POWER(_pconp_id_, _on_) \
|
113 |
|
|
hal_lpc_set_power((_pconp_id_), (_on_))
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
//-----------------------------------------------------------------------------
|
117 |
|
|
// Identifiers for power control, hal_get_pclk()
|
118 |
|
|
//
|
119 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_TIMER0 1
|
120 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_TIMER1 2
|
121 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_UART0 3
|
122 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_UART1 4
|
123 |
|
|
#if 0 // Not implemented on LPC17xx
|
124 |
|
|
# define CYNUM_HAL_LPC17XX_PCONP_PWM0 5
|
125 |
|
|
#endif
|
126 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_PWM1 6
|
127 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_I2C0 7
|
128 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_SPI 8
|
129 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_RTC 9
|
130 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_SSP1 10
|
131 |
|
|
#if 0 // Not implemented on LPC17xx
|
132 |
|
|
# define CYNUM_HAL_LPC17XX_PCONP_EMC 11
|
133 |
|
|
#endif
|
134 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_ADC 12
|
135 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_CAN1 13
|
136 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_CAN2 14
|
137 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_GPIO 15
|
138 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_RIT 16
|
139 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_MCPWM 17
|
140 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_QEI 18
|
141 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_I2C1 19
|
142 |
|
|
#if 0 // Not implemented on LPC17xx
|
143 |
|
|
# define CYNUM_HAL_LPC17XX_PCONP_LCD 20
|
144 |
|
|
#endif
|
145 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_SSP0 21
|
146 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_TIMER2 22
|
147 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_TIMER3 23
|
148 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_UART2 24
|
149 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_UART3 25
|
150 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_I2C2 26
|
151 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_I2S 27
|
152 |
|
|
#if 0 // Not implemented on LPC17xx
|
153 |
|
|
# define CYNUM_HAL_LPC17XX_PCONP_SDC 28
|
154 |
|
|
#endif
|
155 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_GPDMA 29
|
156 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_ENET 30
|
157 |
|
|
#define CYNUM_HAL_LPC17XX_PCONP_USB 31
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
//-----------------------------------------------------------------------------
|
161 |
|
|
// Configure pin function
|
162 |
|
|
//
|
163 |
|
|
externC void hal_lpc_set_pin_function(cyg_uint8 port, cyg_uint8 pin,
|
164 |
|
|
cyg_uint8 function);
|
165 |
|
|
#define CYG_HAL_CORTEXM_LPC17XX_PIN_CFG(_port_, _pin_, _func_) \
|
166 |
|
|
hal_lpc_set_pin_function((_port_), (_pin_), (_func_))
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
//-----------------------------------------------------------------------------
|
170 |
|
|
// Macros to derive the baudrate divider values for the internal UARTs
|
171 |
|
|
// The LPC17xx family supports different baudrate clocks for each single
|
172 |
|
|
// UART. So we need a way to calculate the baudrate for each single UART
|
173 |
|
|
// Now we rely on the fact that we use the same baudrate clock for all
|
174 |
|
|
// UARTs and we query only UART0
|
175 |
|
|
//-----------------------------------------------------------------------------
|
176 |
|
|
|
177 |
|
|
#define CYG_HAL_CORTEXM_LPC17XX_BAUD_GENERATOR(_pclkid_, baud) \
|
178 |
|
|
(CYG_HAL_CORTEXM_LPC17XX_PCLK(_pclkid_)/((baud)*16))
|
179 |
|
|
|
180 |
|
|
//-----------------------------------------------------------------------------
|
181 |
|
|
// LPC17XX platform reset (watchdog resets the board)
|
182 |
|
|
//-----------------------------------------------------------------------------
|
183 |
|
|
#if 0
|
184 |
|
|
externC void hal_lpc_watchdog_reset(void);
|
185 |
|
|
|
186 |
|
|
#define HAL_PLATFORM_RESET() hal_lpc_watchdog_reset()
|
187 |
|
|
#define HAL_PLATFORM_RESET_ENTRY 0
|
188 |
|
|
#endif
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
//-----------------------------------------------------------------------------
|
192 |
|
|
// Compatibility layer for LPC2xxx device drivers
|
193 |
|
|
//-----------------------------------------------------------------------------
|
194 |
|
|
#define CYNUM_HAL_LPC24XX_PCLK_UART0 CYNUM_HAL_LPC17XX_PCLK_UART0
|
195 |
|
|
#define CYNUM_HAL_LPC24XX_PCLK_UART1 CYNUM_HAL_LPC17XX_PCLK_UART1
|
196 |
|
|
#define CYNUM_HAL_LPC24XX_PCLK_UART2 CYNUM_HAL_LPC17XX_PCLK_UART2
|
197 |
|
|
#define CYNUM_HAL_LPC24XX_PCLK_UART3 CYNUM_HAL_LPC17XX_PCLK_UART3
|
198 |
|
|
|
199 |
|
|
#define CYG_HAL_ARM_LPC24XX_BAUD_GENERATOR(_pclkid_, baud) \
|
200 |
|
|
CYG_HAL_CORTEXM_LPC17XX_BAUD_GENERATOR(_pclkid_, baud)
|
201 |
|
|
|
202 |
|
|
//-----------------------------------------------------------------------------
|
203 |
|
|
#endif // CYGONCE_HAL_CORTEXM_LPC17XX_VAR_LPC17XX_MISC_H
|
204 |
|
|
// End of lpc17xx_misc.h
|