source: rtems/c/src/lib/libbsp/arm/lpc24xx/startup/bspstart.c @ c468f18b

4.104.115
Last change on this file since c468f18b was c468f18b, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 12/15/09 at 15:20:47

add support for LPC32xx

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup lpc24xx
5 *
6 * @brief Startup code.
7 */
8
9/*
10 * Copyright (c) 2008, 2009
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#include <bsp.h>
23#include <bsp/bootcard.h>
24#include <bsp/dma.h>
25#include <bsp/io.h>
26#include <bsp/irq-generic.h>
27#include <bsp/irq.h>
28#include <bsp/linker-symbols.h>
29#include <bsp/lpc24xx.h>
30#include <bsp/stackalloc.h>
31#include <bsp/system-clocks.h>
32
33void bsp_start(void)
34{
35  /* Initialize Timer 1 */
36  lpc24xx_module_enable(LPC24XX_MODULE_TIMER_1, LPC24XX_MODULE_CCLK);
37
38  /* Initialize standard timer */
39  lpc24xx_timer_initialize();
40
41  /* Initialize console */
42  #ifdef LPC24XX_CONFIG_CONSOLE
43    lpc24xx_module_enable(LPC24XX_MODULE_UART_0, LPC24XX_MODULE_CCLK);
44    lpc24xx_io_config(LPC24XX_MODULE_UART_0, LPC24XX_CONFIG_CONSOLE);
45    U0LCR = 0;
46    U0IER = 0;
47    U0LCR = 0x80;
48    U0DLL = lpc24xx_cclk() / 16 / LPC24XX_UART_BAUD;
49    U0DLM = 0;
50    U0LCR = 0x03;
51    U0FCR = 0x07;
52  #endif
53
54  /* Interrupts */
55  if (bsp_interrupt_initialize() != RTEMS_SUCCESSFUL) {
56    _CPU_Fatal_halt(0xe);
57  }
58
59  /* DMA */
60  lpc24xx_dma_initialize();
61
62  /* Task stacks */
63  #ifdef LPC24XX_SPECIAL_TASK_STACKS_SUPPORT
64    bsp_stack_initialize(
65      bsp_section_stack_begin,
66      (uintptr_t) bsp_section_stack_size
67    );
68  #endif
69
70  /* UART configurations */
71  #ifdef LPC24XX_CONFIG_UART_1
72    lpc24xx_module_enable(LPC24XX_MODULE_UART_1, LPC24XX_MODULE_CCLK);
73    lpc24xx_io_config(LPC24XX_MODULE_UART_1, LPC24XX_CONFIG_UART_1);
74  #endif
75  #ifdef LPC24XX_CONFIG_UART_2
76    lpc24xx_module_enable(LPC24XX_MODULE_UART_2, LPC24XX_MODULE_CCLK);
77    lpc24xx_io_config(LPC24XX_MODULE_UART_2, LPC24XX_CONFIG_UART_2);
78  #endif
79  #ifdef LPC24XX_CONFIG_UART_3
80    lpc24xx_module_enable(LPC24XX_MODULE_UART_3, LPC24XX_MODULE_CCLK);
81    lpc24xx_io_config(LPC24XX_MODULE_UART_3, LPC24XX_CONFIG_UART_3);
82  #endif
83}
84
85#define ULSR_THRE 0x00000020U
86
87static void lpc24xx_BSP_output_char(char c)
88{
89  while (IS_FLAG_CLEARED(U0LSR, ULSR_THRE)) {
90    /* Wait */
91  }
92  U0THR = c;
93
94  if (c == '\n') {
95    while (IS_FLAG_CLEARED(U0LSR, ULSR_THRE)) {
96      /* Wait */
97    }
98    U0THR = '\r';
99  }
100}
101
102BSP_output_char_function_type BSP_output_char = lpc24xx_BSP_output_char;
Note: See TracBrowser for help on using the repository browser.