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

4.104.115
Last change on this file since ba938b8 was ba938b8, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on Sep 18, 2009 at 8:05:40 AM

Changes throughout.

  • Property mode set to 100644
File size: 2.3 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  bsp_stack_initialize(
64    bsp_section_stack_begin,
65    (uintptr_t) bsp_section_stack_size
66  );
67
68  /* UART configurations */
69  #ifdef LPC24XX_CONFIG_UART_1
70    lpc24xx_module_enable(LPC24XX_MODULE_UART, 1, LPC24XX_MODULE_CCLK);
71    lpc24xx_io_config(LPC24XX_MODULE_UART, 1, LPC24XX_CONFIG_UART_1);
72  #endif
73  #ifdef LPC24XX_CONFIG_UART_2
74    lpc24xx_module_enable(LPC24XX_MODULE_UART, 2, LPC24XX_MODULE_CCLK);
75    lpc24xx_io_config(LPC24XX_MODULE_UART, 2, LPC24XX_CONFIG_UART_2);
76  #endif
77  #ifdef LPC24XX_CONFIG_UART_3
78    lpc24xx_module_enable(LPC24XX_MODULE_UART, 3, LPC24XX_MODULE_CCLK);
79    lpc24xx_io_config(LPC24XX_MODULE_UART, 3, LPC24XX_CONFIG_UART_3);
80  #endif
81}
82
83#define ULSR_THRE 0x00000020U
84
85static void lpc24xx_BSP_output_char(char c)
86{
87  while (IS_FLAG_CLEARED(U0LSR, ULSR_THRE)) {
88    /* Wait */
89  }
90  U0THR = c;
91
92  if (c == '\n') {
93    while (IS_FLAG_CLEARED(U0LSR, ULSR_THRE)) {
94      /* Wait */
95    }
96    U0THR = '\r';
97  }
98}
99
100BSP_output_char_function_type BSP_output_char = lpc24xx_BSP_output_char;
Note: See TracBrowser for help on using the repository browser.