mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 04:07:33 +08:00
added SSP support files, fixed some typos
This commit is contained in:
@@ -1,3 +1,17 @@
|
||||
2008-09-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||
|
||||
* ssp/ssp.c, misc/dma.c, include/dma.h, include/ssp.h: New files.
|
||||
|
||||
* Makefile.am, preinstall.am, README: Update.
|
||||
|
||||
* include/irq.h: Fixed typos.
|
||||
|
||||
* include/lpc24xx.h: New defines and types. Converted to UNIX line
|
||||
endings.
|
||||
|
||||
* misc/system-clocks.c, startup/bspstart.c: Update for utility.h
|
||||
changes.
|
||||
|
||||
2008-09-30 Ralf Corsépius <ralf.corsepius@rtems.org>
|
||||
|
||||
* clock/clock-config.c: include "../../../shared/clockdrv_shell.h".
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# @file
|
||||
#
|
||||
# @brief Makefile of LibBSP for the LPC247X boards.
|
||||
# @brief Makefile of LibBSP for the LPC24XX boards.
|
||||
#
|
||||
|
||||
# $Id$
|
||||
@@ -22,8 +22,8 @@ dist_project_lib_DATA = bsp_specs
|
||||
include_HEADERS = include/bsp.h
|
||||
|
||||
nodist_include_HEADERS = include/bspopts.h
|
||||
|
||||
nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h
|
||||
DISTCLEANFILES = include/bspopts.h
|
||||
|
||||
include_bsp_HEADERS = ../../shared/include/utility.h \
|
||||
../../shared/include/irq-generic.h \
|
||||
@@ -33,25 +33,32 @@ include_bsp_HEADERS = ../../shared/include/utility.h \
|
||||
include/irq-config.h \
|
||||
include/irq.h \
|
||||
include/lpc24xx.h \
|
||||
include/system-clocks.h
|
||||
include/system-clocks.h \
|
||||
include/ssp.h \
|
||||
include/dma.h
|
||||
|
||||
###############################################################################
|
||||
# Data #
|
||||
###############################################################################
|
||||
|
||||
noinst_LIBRARIES = libbspstart.a
|
||||
|
||||
libbspstart_a_SOURCES = ../shared/start/start.S
|
||||
|
||||
project_lib_DATA = start.$(OBJEXT)
|
||||
|
||||
dist_project_lib_DATA += ../shared/startup/linkcmds.base startup/linkcmds
|
||||
dist_project_lib_DATA += ../shared/startup/linkcmds.base \
|
||||
startup/linkcmds
|
||||
|
||||
###############################################################################
|
||||
# LibBSP #
|
||||
###############################################################################
|
||||
|
||||
noinst_LIBRARIES += libbsp.a
|
||||
|
||||
libbsp_a_SOURCES =
|
||||
|
||||
# shared
|
||||
# Shared
|
||||
libbsp_a_SOURCES += ../../shared/bootcard.c \
|
||||
../../shared/bspclean.c \
|
||||
../../shared/bspreset.c \
|
||||
@@ -64,35 +71,39 @@ libbsp_a_SOURCES += ../../shared/bootcard.c \
|
||||
../../shared/sbrk.c \
|
||||
../shared/abort/simple_abort.c
|
||||
|
||||
# startup
|
||||
# Startup
|
||||
libbsp_a_SOURCES += startup/bspstart.c
|
||||
|
||||
# irq
|
||||
# IRQ
|
||||
libbsp_a_SOURCES += ../../shared/src/irq-generic.c \
|
||||
../../shared/src/irq-legacy.c \
|
||||
../shared/irq/irq_asm.S \
|
||||
irq/irq.c
|
||||
|
||||
# console
|
||||
# Console
|
||||
libbsp_a_SOURCES += ../../shared/console.c \
|
||||
console/console-config.c
|
||||
|
||||
# clock
|
||||
libbsp_a_SOURCES += clock/clock-config.c ../../../shared/clockdrv_shell.h
|
||||
# Clock
|
||||
libbsp_a_SOURCES += clock/clock-config.c \
|
||||
../../../shared/clockdrv_shell.h
|
||||
|
||||
# rtc
|
||||
# RTC
|
||||
libbsp_a_SOURCES += ../../shared/tod.c \
|
||||
rtc/rtc-config.c
|
||||
|
||||
# misc
|
||||
libbsp_a_SOURCES += misc/system-clocks.c
|
||||
# Misc
|
||||
libbsp_a_SOURCES += misc/system-clocks.c \
|
||||
misc/dma.c
|
||||
|
||||
# SSP
|
||||
libbsp_a_SOURCES += ssp/ssp.c
|
||||
|
||||
###############################################################################
|
||||
# Special Rules #
|
||||
###############################################################################
|
||||
|
||||
start.$(OBJEXT): ../shared/start/start.S
|
||||
$(CPPASCOMPILE) -o $@ -c $<
|
||||
DISTCLEANFILES = include/bspopts.h
|
||||
|
||||
include $(srcdir)/preinstall.am
|
||||
include $(top_srcdir)/../../../../automake/local.am
|
||||
|
||||
@@ -10,3 +10,4 @@ Drivers:
|
||||
o Console
|
||||
o Clock
|
||||
o RTC
|
||||
o SSP (SPI mode): This driver is in active development. Use with care.
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup lpc24xx
|
||||
*
|
||||
* @brief DMA support.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008
|
||||
* Embedded Brains GmbH
|
||||
* Obere Lagerstr. 30
|
||||
* D-82178 Puchheim
|
||||
* Germany
|
||||
* rtems@embedded-brains.de
|
||||
*
|
||||
* The license and distribution terms for this file may be found in the file
|
||||
* LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifndef LIBBSP_ARM_LPC24XX_DMA_H
|
||||
#define LIBBSP_ARM_LPC24XX_DMA_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void lpc24xx_dma_initialize( void);
|
||||
|
||||
bool lpc24xx_dma_channel_obtain( unsigned channel);
|
||||
|
||||
void lpc24xx_dma_channel_release( unsigned channel);
|
||||
|
||||
void lpc24xx_dma_channel_disable( unsigned channel, bool force);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* LIBBSP_ARM_LPC24XX_DMA_H */
|
||||
@@ -35,16 +35,16 @@
|
||||
|
||||
#define LPC24XX_IRQ_WDT 0
|
||||
#define LPC24XX_IRQ_SOFTWARE 1
|
||||
#define LPC24XX_IRQ_ARM CORE_0 2
|
||||
#define LPC24XX_IRQ_ARM CORE_1 3
|
||||
#define LPC24XX_IRQ_ARM_CORE_0 2
|
||||
#define LPC24XX_IRQ_ARM_CORE_1 3
|
||||
#define LPC24XX_IRQ_TIMER_0 4
|
||||
#define LPC24XX_IRQ_TIMER_1 5
|
||||
#define LPC24XX_IRQ_UART_0 6
|
||||
#define LPC24XX_IRQ_UART_1 7
|
||||
#define LPC24XX_IRQ_PWM 8
|
||||
#define LPC24XX_IRQ_I2C_0 9
|
||||
#define LPC24XX_IRQ_SPI_SSP0 10
|
||||
#define LPC24XX_IRQ_SSP1 11
|
||||
#define LPC24XX_IRQ_SPI_SSP_0 10
|
||||
#define LPC24XX_IRQ_SSP_1 11
|
||||
#define LPC24XX_IRQ_PLL 12
|
||||
#define LPC24XX_IRQ_RTC 13
|
||||
#define LPC24XX_IRQ_EINT_0 14
|
||||
@@ -61,8 +61,8 @@
|
||||
#define LPC24XX_IRQ_DMA 25
|
||||
#define LPC24XX_IRQ_TIMER_2 26
|
||||
#define LPC24XX_IRQ_TIMER_3 27
|
||||
#define LPC24XX_IRQ_UART2 28
|
||||
#define LPC24XX_IRQ_UART3 29
|
||||
#define LPC24XX_IRQ_UART_2 28
|
||||
#define LPC24XX_IRQ_UART_3 29
|
||||
#define LPC24XX_IRQ_I2C_2 30
|
||||
#define LPC24XX_IRQ_I2S 31
|
||||
|
||||
@@ -76,8 +76,6 @@
|
||||
*/
|
||||
#define BSP_INTERRUPT_VECTOR_MAX LPC24XX_IRQ_I2S
|
||||
|
||||
#define BSP_FEATURE_IRQ_EXTENSION
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* ASM */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup lpc24xx
|
||||
*
|
||||
* @brief LibI2C bus driver for the Synchronous Serial Port (SSP).
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008
|
||||
* Embedded Brains GmbH
|
||||
* Obere Lagerstr. 30
|
||||
* D-82178 Puchheim
|
||||
* Germany
|
||||
* rtems@embedded-brains.de
|
||||
*
|
||||
* The license and distribution terms for this file may be found in the file
|
||||
* LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifndef LIBBSP_ARM_LPC24XX_SSP_H
|
||||
#define LIBBSP_ARM_LPC24XX_SSP_H
|
||||
|
||||
#include <rtems/libi2c.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern rtems_libi2c_bus_t * const lpc24xx_ssp_0;
|
||||
|
||||
extern rtems_libi2c_bus_t * const lpc24xx_ssp_1;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* LIBBSP_ARM_LPC24XX_SSP_H */
|
||||
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup lpc24xx
|
||||
*
|
||||
* @brief DMA support.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008
|
||||
* Embedded Brains GmbH
|
||||
* Obere Lagerstr. 30
|
||||
* D-82178 Puchheim
|
||||
* Germany
|
||||
* rtems@embedded-brains.de
|
||||
*
|
||||
* The license and distribution terms for this file may be found in the file
|
||||
* LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
|
||||
*/
|
||||
|
||||
#include <rtems/endian.h>
|
||||
|
||||
#include <bsp/lpc24xx.h>
|
||||
#include <bsp/dma.h>
|
||||
|
||||
/**
|
||||
* @brief Table that indicates if a channel is currently occupied.
|
||||
*/
|
||||
static bool lpc24xx_dma_channel_occupation [GPDMA_CH_NUMBER];
|
||||
|
||||
/**
|
||||
* @brief Initializes the general purpose DMA.
|
||||
*/
|
||||
void lpc24xx_dma_initialize( void)
|
||||
{
|
||||
rtems_interrupt_level level;
|
||||
|
||||
/* Enable power */
|
||||
rtems_interrupt_disable( level);
|
||||
PCONP = SET_FLAG( PCONP, PCONP_PCGPDMA);
|
||||
rtems_interrupt_enable( level);
|
||||
|
||||
/* Disable module */
|
||||
GPDMA_CONFIG = 0;
|
||||
|
||||
/* Enable module */
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
GPDMA_CONFIG = GPDMA_CONFIG_EN;
|
||||
#else
|
||||
GPDMA_CONFIG = GPDMA_CONFIG_EN | GPDMA_CONFIG_MODE;
|
||||
#endif
|
||||
|
||||
/* Reset registers */
|
||||
GPDMA_SOFT_SREQ = 0;
|
||||
GPDMA_SOFT_BREQ = 0;
|
||||
GPDMA_SOFT_LSREQ = 0;
|
||||
GPDMA_SOFT_LBREQ = 0;
|
||||
GPDMA_SYNC = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns true if the channel @a channel was obtained.
|
||||
*
|
||||
* If the channel number @a channel is out of range the last valid channel will
|
||||
* be used.
|
||||
*/
|
||||
bool lpc24xx_dma_channel_obtain( unsigned channel)
|
||||
{
|
||||
rtems_interrupt_level level;
|
||||
bool occupation = true;
|
||||
|
||||
if (channel > GPDMA_CH_NUMBER) {
|
||||
channel = GPDMA_CH_NUMBER - 1;
|
||||
}
|
||||
|
||||
rtems_interrupt_disable( level);
|
||||
occupation = lpc24xx_dma_channel_occupation [channel];
|
||||
lpc24xx_dma_channel_occupation [channel] = true;
|
||||
rtems_interrupt_enable( level);
|
||||
|
||||
return !occupation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Releases the channel @a channel. You must have obtained this channel
|
||||
* with lpc24xx_dma_channel_obtain() previously.
|
||||
*
|
||||
* If the channel number @a channel is out of range the last valid channel will
|
||||
* be used.
|
||||
*/
|
||||
void lpc24xx_dma_channel_release( unsigned channel)
|
||||
{
|
||||
if (channel > GPDMA_CH_NUMBER) {
|
||||
channel = GPDMA_CH_NUMBER - 1;
|
||||
}
|
||||
|
||||
lpc24xx_dma_channel_occupation [channel] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disables the channel @a channel.
|
||||
*
|
||||
* If @a force is false the channel will be halted and disabled when the
|
||||
* channel is inactive. If the channel number @a channel is out of range the
|
||||
* last valid channel will be used.
|
||||
*/
|
||||
void lpc24xx_dma_channel_disable( unsigned channel, bool force)
|
||||
{
|
||||
volatile lpc24xx_dma_channel *ch = GPDMA_CH_BASE_ADDR( channel);
|
||||
uint32_t cfg = ch->cfg;
|
||||
|
||||
if (!force) {
|
||||
/* Halt */
|
||||
ch->cfg = SET_FLAG( cfg, GPDMA_CH_CFG_HALT);
|
||||
|
||||
/* Wait for inactive */
|
||||
do {
|
||||
cfg = ch->cfg;
|
||||
} while (IS_FLAG_SET( cfg, GPDMA_CH_CFG_ACTIVE));
|
||||
}
|
||||
|
||||
/* Disable */
|
||||
ch->cfg = CLEAR_FLAG( cfg, GPDMA_CH_CFG_EN);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ unsigned lpc24xx_cclk( void)
|
||||
}
|
||||
|
||||
/* Get PLL output frequency */
|
||||
if (REG_FLAG_IS_SET( PLLSTAT, PLLSTAT_PLLC)) {
|
||||
if (IS_FLAG_SET( PLLSTAT, PLLSTAT_PLLC)) {
|
||||
uint32_t pllcfg = PLLCFG;
|
||||
unsigned n = GET_PLLCFG_NSEL( pllcfg) + 1;
|
||||
unsigned m = GET_PLLCFG_MSEL( pllcfg) + 1;
|
||||
@@ -110,10 +110,10 @@ static void lpc24xx_pll_config( uint32_t val)
|
||||
*/
|
||||
void lpc24xx_set_pll( unsigned clksrc, unsigned nsel, unsigned msel, unsigned cclksel)
|
||||
{
|
||||
bool pll_enabled = REG_FLAG_IS_SET( PLLSTAT, PLLSTAT_PLLE);
|
||||
bool pll_enabled = IS_FLAG_SET( PLLSTAT, PLLSTAT_PLLE);
|
||||
|
||||
/* Disconnect PLL if necessary */
|
||||
if (REG_FLAG_IS_SET( PLLSTAT, PLLSTAT_PLLC)) {
|
||||
if (IS_FLAG_SET( PLLSTAT, PLLSTAT_PLLC)) {
|
||||
if (pll_enabled) {
|
||||
lpc24xx_pll_config( PLLCON_PLLE);
|
||||
} else {
|
||||
@@ -139,7 +139,7 @@ void lpc24xx_set_pll( unsigned clksrc, unsigned nsel, unsigned msel, unsigned cc
|
||||
lpc24xx_pll_config( PLLCON_PLLE);
|
||||
|
||||
/* Wait for lock */
|
||||
while (REG_FLAG_IS_CLEARED( PLLSTAT, PLLSTAT_PLOCK)) {
|
||||
while (IS_FLAG_CLEARED( PLLSTAT, PLLSTAT_PLOCK)) {
|
||||
/* Wait */
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,14 @@ $(PROJECT_INCLUDE)/bsp/system-clocks.h: include/system-clocks.h $(PROJECT_INCLUD
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/system-clocks.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/system-clocks.h
|
||||
|
||||
$(PROJECT_INCLUDE)/bsp/ssp.h: include/ssp.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/ssp.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/ssp.h
|
||||
|
||||
$(PROJECT_INCLUDE)/bsp/dma.h: include/dma.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/dma.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/dma.h
|
||||
|
||||
$(PROJECT_LIB)/start.$(OBJEXT): start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)
|
||||
TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <bsp.h>
|
||||
#include <bsp/bootcard.h>
|
||||
#include <bsp/dma.h>
|
||||
#include <bsp/irq.h>
|
||||
#include <bsp/linker-symbols.h>
|
||||
#include <bsp/lpc24xx.h>
|
||||
@@ -61,23 +62,26 @@ void bsp_start( void)
|
||||
/* Spin forever */
|
||||
}
|
||||
}
|
||||
|
||||
/* DMA */
|
||||
lpc24xx_dma_initialize();
|
||||
}
|
||||
|
||||
#define ULSR_THRE 0x00000020U
|
||||
|
||||
static void my_BSP_output_char( char c)
|
||||
static void lpc24xx_BSP_output_char( char c)
|
||||
{
|
||||
while (REG_FLAG_IS_CLEARED( U0LSR, ULSR_THRE)) {
|
||||
while (IS_FLAG_CLEARED( U0LSR, ULSR_THRE)) {
|
||||
/* Wait */
|
||||
}
|
||||
U0THR = c;
|
||||
|
||||
if (c == '\n') {
|
||||
while (REG_FLAG_IS_CLEARED( U0LSR, ULSR_THRE)) {
|
||||
while (IS_FLAG_CLEARED( U0LSR, ULSR_THRE)) {
|
||||
/* Wait */
|
||||
}
|
||||
U0THR = '\r';
|
||||
}
|
||||
}
|
||||
|
||||
BSP_output_char_function_type BSP_output_char = my_BSP_output_char;
|
||||
BSP_output_char_function_type BSP_output_char = lpc24xx_BSP_output_char;
|
||||
|
||||
Reference in New Issue
Block a user