source: rtems/c/src/lib/libbsp/arm/lpc32xx/include/bsp.h @ 76134c5

4.115
Last change on this file since 76134c5 was 76134c5, checked in by Sebastian Huber <sebastian.huber@…>, on 05/19/11 at 12:11:36

2011-05-19 Sebastian Huber <sebastian.huber@…>

  • Makefile.am, preinstall.am: Install new header files.
  • include/bsp.h, include/emc.h, include/lpc32xx.h, misc/emc.c: Update for API changes.
  • Property mode set to 100644
File size: 4.4 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup lpc32xx
5 *
6 * @brief Global BSP definitions.
7 */
8
9/*
10 * Copyright (c) 2009, 2010
11 * embedded brains GmbH
12 * Obere Lagerstr. 30
13 * D-82178 Puchheim
14 * Germany
15 * <rtems@embedded-brains.de>
16 *
17 * The license and distribution terms for this file may be
18 * found in the file LICENSE in this distribution or at
19 * http://www.rtems.com/license/LICENSE.
20 */
21
22#ifndef LIBBSP_ARM_LPC32XX_BSP_H
23#define LIBBSP_ARM_LPC32XX_BSP_H
24
25#include <bspopts.h>
26
27#include <rtems.h>
28#include <rtems/console.h>
29#include <rtems/clockdrv.h>
30
31#include <bsp/lpc32xx.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif /* __cplusplus */
36
37#define BSP_FEATURE_IRQ_EXTENSION
38
39#ifndef ASM
40
41struct rtems_bsdnet_ifconfig;
42
43/**
44 * @defgroup lpc32xx LPC32XX Support
45 *
46 * @ingroup bsp_kit
47 *
48 * @brief LPC32XX support package.
49 *
50 * @{
51 */
52
53/**
54 * @brief Network driver attach and detach function.
55 */
56int lpc_eth_attach_detach(
57  struct rtems_bsdnet_ifconfig *config,
58  int attaching
59);
60
61/**
62 * @brief Standard network driver attach and detach function.
63 */
64#define RTEMS_BSP_NETWORK_DRIVER_ATTACH lpc_eth_attach_detach
65
66/**
67 * @brief Standard network driver name.
68 */
69#define RTEMS_BSP_NETWORK_DRIVER_NAME "eth0"
70
71/**
72 * @brief Optimized idle task.
73 *
74 * This idle task sets the power mode to idle.  This causes the processor clock
75 * to be stopped, while on-chip peripherals remain active.  Any enabled
76 * interrupt from a peripheral or an external interrupt source will cause the
77 * processor to resume execution.
78 *
79 * To enable the idle task use the following in the system configuration:
80 *
81 * @code
82 * #include <bsp.h>
83 *
84 * #define CONFIGURE_INIT
85 *
86 * #define CONFIGURE_IDLE_TASK_BODY lpc32xx_idle
87 *
88 * #include <confdefs.h>
89 * @endcode
90 */
91void *lpc32xx_idle(uintptr_t ignored);
92
93#define LPC32XX_STANDARD_TIMER (&lpc32xx.timer_1)
94
95static inline unsigned lpc32xx_timer(void)
96{
97  volatile lpc_timer *timer = LPC32XX_STANDARD_TIMER;
98
99  return timer->tc;
100}
101
102static inline void lpc32xx_micro_seconds_delay(unsigned us)
103{
104  unsigned start = lpc32xx_timer();
105  unsigned delay = us * (LPC32XX_PERIPH_CLK / 1000000);
106  unsigned elapsed = 0;
107
108  do {
109    elapsed = lpc32xx_timer() - start;
110  } while (elapsed < delay);
111}
112
113void bsp_restart(void *addr);
114
115#define BSP_CONSOLE_UART_BASE LPC32XX_BASE_UART_5
116
117/**
118 * @brief Begin of magic zero area.
119 *
120 * A read from this area returns zero.  Writes have no effect.
121 */
122extern uint32_t lpc32xx_magic_zero_begin [];
123
124/**
125 * @brief End of magic zero area.
126 *
127 * A read from this area returns zero.  Writes have no effect.
128 */
129extern uint32_t lpc32xx_magic_zero_end [];
130
131/**
132 * @brief Size of magic zero area.
133 *
134 * A read from this area returns zero.  Writes have no effect.
135 */
136extern uint32_t lpc32xx_magic_zero_size [];
137
138#ifdef LPC32XX_SCRATCH_AREA_SIZE
139  /**
140   * @rief Scratch area.
141   *
142   * The usage is application specific.
143   */
144  extern uint8_t lpc32xx_scratch_area [LPC32XX_SCRATCH_AREA_SIZE];
145#endif
146
147#define LPC32XX_DO_STOP_GPDMA \
148  do { \
149    if ((LPC32XX_DMACLK_CTRL & 0x1) != 0) { \
150      if ((lpc32xx.dma.cfg & DMA_CFG_E) != 0) { \
151        int i = 0; \
152        for (i = 0; i < 8; ++i) { \
153          lpc32xx.dma.channels [i].cfg = 0; \
154        } \
155        lpc32xx.dma.cfg &= ~DMA_CFG_E; \
156      } \
157      LPC32XX_DMACLK_CTRL = 0; \
158    } \
159  } while (0)
160
161#define LPC32XX_DO_STOP_ETHERNET \
162  do { \
163    if ((LPC32XX_MAC_CLK_CTRL & 0x7) == 0x7) { \
164      lpc32xx.eth.command = 0x38; \
165      lpc32xx.eth.mac1 = 0xcf00; \
166      lpc32xx.eth.mac1 = 0; \
167      LPC32XX_MAC_CLK_CTRL = 0; \
168    } \
169  } while (0)
170
171#define LPC32XX_DO_STOP_USB \
172  do { \
173    if ((LPC32XX_USB_CTRL & 0x010e8000) != 0) { \
174      LPC32XX_OTG_CLK_CTRL = 0; \
175      LPC32XX_USB_CTRL = 0x80000; \
176    } \
177  } while (0)
178
179#define LPC32XX_DO_RESTART(addr) \
180  do { \
181    ARM_SWITCH_REGISTERS; \
182    rtems_interrupt_level level; \
183    uint32_t ctrl = 0; \
184  \
185    rtems_interrupt_disable(level); \
186  \
187    arm_cp15_data_cache_test_and_clean(); \
188    arm_cp15_instruction_cache_invalidate(); \
189  \
190    ctrl = arm_cp15_get_control(); \
191    ctrl &= ~(ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M); \
192    arm_cp15_set_control(ctrl); \
193  \
194    __asm__ volatile ( \
195      ARM_SWITCH_TO_ARM \
196      "mov pc, %[addr]\n" \
197      ARM_SWITCH_BACK \
198      : ARM_SWITCH_OUTPUT \
199      : [addr] "r" (addr) \
200    ); \
201  } while (0)
202
203/** @} */
204
205/**
206 * @defgroup lpc LPC Support
207 *
208 * @ingroup lpc32xx
209 *
210 * @brief LPC support package.
211 */
212
213#endif /* ASM */
214
215#ifdef __cplusplus
216}
217#endif /* __cplusplus */
218
219#endif /* LIBBSP_ARM_LPC32XX_BSP_H */
Note: See TracBrowser for help on using the repository browser.