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

4.104.115
Last change on this file since ba938b8d was ba938b8d, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 09/18/09 at 08:05:40

Changes throughout.

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[5aeed17]1/**
2 * @file
3 *
4 * @ingroup lpc24xx
5 *
6 * @brief Startup code.
7 */
8
9/*
[ba938b8d]10 * Copyright (c) 2008, 2009
11 * embedded brains GmbH
[5aeed17]12 * Obere Lagerstr. 30
13 * D-82178 Puchheim
14 * Germany
[ba938b8d]15 * <rtems@embedded-brains.de>
[5aeed17]16 *
[ba938b8d]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.
[5aeed17]20 */
21
22#include <bsp.h>
23#include <bsp/bootcard.h>
[29cc1477]24#include <bsp/dma.h>
[7ae2775]25#include <bsp/io.h>
26#include <bsp/irq-generic.h>
[5aeed17]27#include <bsp/irq.h>
28#include <bsp/linker-symbols.h>
29#include <bsp/lpc24xx.h>
[7ae2775]30#include <bsp/stackalloc.h>
[5aeed17]31#include <bsp/system-clocks.h>
32
[ba938b8d]33void bsp_start(void)
[9647f7fe]34{
[ba938b8d]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;
[7ae2775]52  #endif
[5aeed17]53
54  /* Interrupts */
55  if (bsp_interrupt_initialize() != RTEMS_SUCCESSFUL) {
[ba938b8d]56    _CPU_Fatal_halt(0xe);
[5aeed17]57  }
[29cc1477]58
59  /* DMA */
60  lpc24xx_dma_initialize();
[7ae2775]61
62  /* Task stacks */
63  bsp_stack_initialize(
64    bsp_section_stack_begin,
[ba938b8d]65    (uintptr_t) bsp_section_stack_size
[7ae2775]66  );
67
68  /* UART configurations */
69  #ifdef LPC24XX_CONFIG_UART_1
[ba938b8d]70    lpc24xx_module_enable(LPC24XX_MODULE_UART, 1, LPC24XX_MODULE_CCLK);
71    lpc24xx_io_config(LPC24XX_MODULE_UART, 1, LPC24XX_CONFIG_UART_1);
[7ae2775]72  #endif
73  #ifdef LPC24XX_CONFIG_UART_2
[ba938b8d]74    lpc24xx_module_enable(LPC24XX_MODULE_UART, 2, LPC24XX_MODULE_CCLK);
75    lpc24xx_io_config(LPC24XX_MODULE_UART, 2, LPC24XX_CONFIG_UART_2);
[7ae2775]76  #endif
77  #ifdef LPC24XX_CONFIG_UART_3
[ba938b8d]78    lpc24xx_module_enable(LPC24XX_MODULE_UART, 3, LPC24XX_MODULE_CCLK);
79    lpc24xx_io_config(LPC24XX_MODULE_UART, 3, LPC24XX_CONFIG_UART_3);
[7ae2775]80  #endif
[5aeed17]81}
82
83#define ULSR_THRE 0x00000020U
84
[ba938b8d]85static void lpc24xx_BSP_output_char(char c)
[5aeed17]86{
[ba938b8d]87  while (IS_FLAG_CLEARED(U0LSR, ULSR_THRE)) {
[5aeed17]88    /* Wait */
89  }
90  U0THR = c;
91
92  if (c == '\n') {
[ba938b8d]93    while (IS_FLAG_CLEARED(U0LSR, ULSR_THRE)) {
[5aeed17]94      /* Wait */
95    }
96    U0THR = '\r';
97  }
98}
99
[29cc1477]100BSP_output_char_function_type BSP_output_char = lpc24xx_BSP_output_char;
Note: See TracBrowser for help on using the repository browser.