[sky9x] Massstorage (not finished at all!)

[stock] 180bytes flash saved
This commit is contained in:
bsongis
2012-09-11 19:58:49 +00:00
parent 91fbcb94d7
commit fcf6f436b0
702 changed files with 166014 additions and 441 deletions
@@ -0,0 +1,44 @@
#include <efs.h>
void hang(void);
void main(void)
{
EmbeddedFileSystem efs;
EmbeddedFile file_r, file_w;
unsigned short i,e;
char buf[512];
debug_init();
DBG((TXT("Hello :-)")));
if(efs_init(&efs,0)!=0){
hang();
}
if(file_fopen(&file_r,&efs.myFs,"orig.txt",'r')!=0){
hang();
}
if(file_fopen(&file_w,&efs.myFs,"copy.txt",'w')!=0){
hang();
}
while(e=file_read(&file_r,512,buf)){
file_write(&file_w,e,buf);
}
file_fclose(&file_r);
file_fclose(&file_w);
fs_umount(&efs.myFs);
hang();
}
void hang(void)
{
while((1))
_NOP();
}
@@ -0,0 +1,110 @@
#include <efs.h>
void hang(void);
unsigned char c2str(unsigned char value,char *buf);
void main(void)
{
EmbeddedFileSystem efs;
EmbeddedFile file_w;
unsigned short i;
unsigned char e;
unsigned char t;
signed char err;
unsigned char offset1;
unsigned char offset2;
char path[100];
debug_init();
DBG((TXT("Welcome (2).\n-------------\n\n")));
if(efs_init(&efs,0)!=0){
DBG((TXT("Could not init filesystem.\n")));
hang();
}
for(i=1;i<=4;i++){
offset1=c2str(1,path);
path[offset1++]='/';
for(e=1;e<=12;e++){
offset2=offset1;
offset2+=c2str(e,path+offset1);
DBG((TXT("Dir name: %s.\n"),path));
}
}
/*for(i=1;i<10;i++){
path[0]='D';
path[1]='I';
path[2]='R';
path[3]=0x30+((i%10000)/1000);
path[4]=0x30+((i%1000)/100);
path[5]=0x30+((i%100)/10);
path[6]=0x30+((i%10)/1);
path[7]='\0';
err=mkdir(&efs.myFs,path);
if(err!=0){
DBG((TXT("ERROR: Could not create directory %s (%d) - returned ERR %d.\n"),path,i,err));
hang();
}
DBG((TXT("DIR %s created.\n"),path));
for(e=1;e<6;e++){
path[7]='/';
path[8]=0x40+e;
path[9]='\0';
err=mkdir(&efs.myFs,path);
if(err!=0){
DBG((TXT("ERROR: Could not create directory %s (%d) - returned ERR %d.\n"),path,i,err));
hang();
}
DBG((TXT("DIR %s created.\n"),path));
for(t=0;t<26;t++){
path[9]='/';
path[10]='t';
path[11]='e';
path[12]='s';
path[13]='t';
path[14]='-';
path[15]=0x41+t;
path[16]='.';
path[17]='t';
path[18]='x';
path[19]='t';
path[20]='\0';
if(file_fopen(&file_w,&efs.myFs,path,'w')!=0){
DBG((TXT("Could not open file %s for writing.\n"),path));
hang();
}
file_write(&file_w,15,"Dit is een test");
file_fclose(&file_w);
}
}
}*/
file_fclose(&file_w);
fs_umount(&efs.myFs);
DBG((TXT("Done :-)\n\n")));
hang();
}
unsigned char c2str(unsigned char value,char *buf)
{
unsigned char i=0;
if(value>=100)
buf[i++]=0x30+(value/100);
if(value>=10)
buf[i++]=0x30+((value%100)/10);
buf[i++]=0x30+(value%10);
buf[i]='\0';
return(i);
}
void hang(void)
{
while((1))
_NOP();
}
@@ -0,0 +1,28 @@
#include <stdio.h>
#include <efs.h>
int main(void)
{
EmbeddedFileSystem efs;
EmbeddedFile file;
unsigned short i,e;
char buf[512];
if(efs_init(&efs,"/dev/sde")!=0){
printf("Could not open filesystem.\n");
return(-1);
}
if(file_fopen(&file,&efs.myFs,"group",'r')!=0){
printf("Could not open file.\n");
return(-2);
}
while(e=file_read(&file,512,buf)){
for(i=0;i<e;i++){
printf("%c",buf[i]);
}
}
return(0);
}
@@ -0,0 +1,143 @@
/***********************************************************************/
/* ROM.ld: Linker Script File */
/***********************************************************************/
ENTRY(_boot)
STACK_SIZE = 0x400;
/* Memory Definitions */
MEMORY
{
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 512k
RAM (rw) : ORIGIN = 0x40000000, LENGTH = 32k
}
/* Section Definitions */
SECTIONS
{
/* first section is .text which is used for code */
.text :
{
/* *crt0.o (.text) */ /* Startup code */
KEEP(*(.init)) /* Startup code from .init-section */
*(.text .text.*) /* remaining code */
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.gcc_except_table)
*(.rodata) /* read-only data (constants) */
*(.rodata*)
*(.gnu.linkonce.r.*)
} > ROM
/***** old:
.text :
{
*crt0.o (.text)
*(.text)
*(.rodata)
*(.rodata*)
*(.glue_7)
*(.glue_7t)
} > ROM
*****/
. = ALIGN(4);
/* .ctors .dtors are used for c++ constructors/destructors */
/* added by Martin Thomas 4/2005 based on Anglia Design example */
.ctors :
{
PROVIDE(__ctors_start__ = .);
KEEP(*(SORT(.ctors.*)))
KEEP(*(.ctors))
PROVIDE(__ctors_end__ = .);
} >ROM
.dtors :
{
PROVIDE(__dtors_start__ = .);
KEEP(*(SORT(.dtors.*)))
KEEP(*(.dtors))
PROVIDE(__dtors_end__ = .);
} >ROM
. = ALIGN(4);
/* mthomas - end */
_etext = . ;
PROVIDE (etext = .);
/* .data section which is used for initialized data */
.data : AT (_etext)
{
_data = .;
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
SORT(CONSTRUCTORS) /* mt 4/2005 */
. = ALIGN(4);
*(.fastrun) /* !!!! "RAM-Function" example */
} > RAM
. = ALIGN(4);
_edata = . ;
PROVIDE (edata = .);
/* .bss section which is used for uninitialized data */
.bss (NOLOAD) :
{
__bss_start = . ;
__bss_start__ = . ;
*(.bss)
*(.gnu.linkonce.b*)
*(COMMON)
. = ALIGN(4);
} > RAM
. = ALIGN(4);
__bss_end__ = . ;
PROVIDE (__bss_end = .);
.stack ALIGN(256) :
{
. += STACK_SIZE;
PROVIDE (_stack = .);
} > RAM
_end = . ;
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
}
@@ -0,0 +1,273 @@
/***********************************************************************/
/* This file is part of the uVision/ARM development tools */
/* Copyright KEIL ELEKTRONIK GmbH 2002-2005 */
/***********************************************************************/
/* */
/* LPC213X.H: Header file for Philips LPC2131/32/34/36/38 */
/* */
/***********************************************************************/
#ifndef __LPC213x_H
#define __LPC213x_H
/* Vectored Interrupt Controller (VIC) */
#define VICIRQStatus (*((volatile unsigned long *) 0xFFFFF000))
#define VICFIQStatus (*((volatile unsigned long *) 0xFFFFF004))
#define VICRawIntr (*((volatile unsigned long *) 0xFFFFF008))
#define VICIntSelect (*((volatile unsigned long *) 0xFFFFF00C))
#define VICIntEnable (*((volatile unsigned long *) 0xFFFFF010))
#define VICIntEnClr (*((volatile unsigned long *) 0xFFFFF014))
#define VICSoftInt (*((volatile unsigned long *) 0xFFFFF018))
#define VICSoftIntClr (*((volatile unsigned long *) 0xFFFFF01C))
#define VICProtection (*((volatile unsigned long *) 0xFFFFF020))
#define VICVectAddr (*((volatile unsigned long *) 0xFFFFF030))
#define VICDefVectAddr (*((volatile unsigned long *) 0xFFFFF034))
#define VICVectAddr0 (*((volatile unsigned long *) 0xFFFFF100))
#define VICVectAddr1 (*((volatile unsigned long *) 0xFFFFF104))
#define VICVectAddr2 (*((volatile unsigned long *) 0xFFFFF108))
#define VICVectAddr3 (*((volatile unsigned long *) 0xFFFFF10C))
#define VICVectAddr4 (*((volatile unsigned long *) 0xFFFFF110))
#define VICVectAddr5 (*((volatile unsigned long *) 0xFFFFF114))
#define VICVectAddr6 (*((volatile unsigned long *) 0xFFFFF118))
#define VICVectAddr7 (*((volatile unsigned long *) 0xFFFFF11C))
#define VICVectAddr8 (*((volatile unsigned long *) 0xFFFFF120))
#define VICVectAddr9 (*((volatile unsigned long *) 0xFFFFF124))
#define VICVectAddr10 (*((volatile unsigned long *) 0xFFFFF128))
#define VICVectAddr11 (*((volatile unsigned long *) 0xFFFFF12C))
#define VICVectAddr12 (*((volatile unsigned long *) 0xFFFFF130))
#define VICVectAddr13 (*((volatile unsigned long *) 0xFFFFF134))
#define VICVectAddr14 (*((volatile unsigned long *) 0xFFFFF138))
#define VICVectAddr15 (*((volatile unsigned long *) 0xFFFFF13C))
#define VICVectCntl0 (*((volatile unsigned long *) 0xFFFFF200))
#define VICVectCntl1 (*((volatile unsigned long *) 0xFFFFF204))
#define VICVectCntl2 (*((volatile unsigned long *) 0xFFFFF208))
#define VICVectCntl3 (*((volatile unsigned long *) 0xFFFFF20C))
#define VICVectCntl4 (*((volatile unsigned long *) 0xFFFFF210))
#define VICVectCntl5 (*((volatile unsigned long *) 0xFFFFF214))
#define VICVectCntl6 (*((volatile unsigned long *) 0xFFFFF218))
#define VICVectCntl7 (*((volatile unsigned long *) 0xFFFFF21C))
#define VICVectCntl8 (*((volatile unsigned long *) 0xFFFFF220))
#define VICVectCntl9 (*((volatile unsigned long *) 0xFFFFF224))
#define VICVectCntl10 (*((volatile unsigned long *) 0xFFFFF228))
#define VICVectCntl11 (*((volatile unsigned long *) 0xFFFFF22C))
#define VICVectCntl12 (*((volatile unsigned long *) 0xFFFFF230))
#define VICVectCntl13 (*((volatile unsigned long *) 0xFFFFF234))
#define VICVectCntl14 (*((volatile unsigned long *) 0xFFFFF238))
#define VICVectCntl15 (*((volatile unsigned long *) 0xFFFFF23C))
/* Pin Connect Block */
#define PINSEL0 (*((volatile unsigned long *) 0xE002C000))
#define PINSEL1 (*((volatile unsigned long *) 0xE002C004))
#define PINSEL2 (*((volatile unsigned long *) 0xE002C014))
/* General Purpose Input/Output (GPIO) */
#define IOPIN0 (*((volatile unsigned long *) 0xE0028000))
#define IOSET0 (*((volatile unsigned long *) 0xE0028004))
#define IODIR0 (*((volatile unsigned long *) 0xE0028008))
#define IOCLR0 (*((volatile unsigned long *) 0xE002800C))
#define IOPIN1 (*((volatile unsigned long *) 0xE0028010))
#define IOSET1 (*((volatile unsigned long *) 0xE0028014))
#define IODIR1 (*((volatile unsigned long *) 0xE0028018))
#define IOCLR1 (*((volatile unsigned long *) 0xE002801C))
/* Memory Accelerator Module (MAM) */
#define MAMCR (*((volatile unsigned char *) 0xE01FC000))
#define MAMTIM (*((volatile unsigned char *) 0xE01FC004))
#define MEMMAP (*((volatile unsigned char *) 0xE01FC040))
/* Phase Locked Loop (PLL) */
#define PLLCON (*((volatile unsigned char *) 0xE01FC080))
#define PLLCFG (*((volatile unsigned char *) 0xE01FC084))
#define PLLSTAT (*((volatile unsigned short*) 0xE01FC088))
#define PLLFEED (*((volatile unsigned char *) 0xE01FC08C))
/* VPB Divider */
#define VPBDIV (*((volatile unsigned char *) 0xE01FC100))
/* Power Control */
#define PCON (*((volatile unsigned char *) 0xE01FC0C0))
#define PCONP (*((volatile unsigned long *) 0xE01FC0C4))
/* External Interrupts */
#define EXTINT (*((volatile unsigned char *) 0xE01FC140))
#define INTWAKE (*((volatile unsigned char *) 0xE01FC144))
#define EXTMODE (*((volatile unsigned char *) 0xE01FC148))
#define EXTPOLAR (*((volatile unsigned char *) 0xE01FC14C))
/* Reset */
#define RSID (*((volatile unsigned char *) 0xE01FC180))
/* Code Security / Debugging */
#define CSPR (*((volatile unsigned char *) 0xE01FC184))
/* Timer 0 */
#define T0IR (*((volatile unsigned long *) 0xE0004000))
#define T0TCR (*((volatile unsigned long *) 0xE0004004))
#define T0TC (*((volatile unsigned long *) 0xE0004008))
#define T0PR (*((volatile unsigned long *) 0xE000400C))
#define T0PC (*((volatile unsigned long *) 0xE0004010))
#define T0MCR (*((volatile unsigned long *) 0xE0004014))
#define T0MR0 (*((volatile unsigned long *) 0xE0004018))
#define T0MR1 (*((volatile unsigned long *) 0xE000401C))
#define T0MR2 (*((volatile unsigned long *) 0xE0004020))
#define T0MR3 (*((volatile unsigned long *) 0xE0004024))
#define T0CCR (*((volatile unsigned long *) 0xE0004028))
#define T0CR0 (*((volatile unsigned long *) 0xE000402C))
#define T0CR1 (*((volatile unsigned long *) 0xE0004030))
#define T0CR2 (*((volatile unsigned long *) 0xE0004034))
#define T0CR3 (*((volatile unsigned long *) 0xE0004038))
#define T0EMR (*((volatile unsigned long *) 0xE000403C))
#define T0CTCR (*((volatile unsigned long *) 0xE0004070))
/* Timer 1 */
#define T1IR (*((volatile unsigned long *) 0xE0008000))
#define T1TCR (*((volatile unsigned long *) 0xE0008004))
#define T1TC (*((volatile unsigned long *) 0xE0008008))
#define T1PR (*((volatile unsigned long *) 0xE000800C))
#define T1PC (*((volatile unsigned long *) 0xE0008010))
#define T1MCR (*((volatile unsigned long *) 0xE0008014))
#define T1MR0 (*((volatile unsigned long *) 0xE0008018))
#define T1MR1 (*((volatile unsigned long *) 0xE000801C))
#define T1MR2 (*((volatile unsigned long *) 0xE0008020))
#define T1MR3 (*((volatile unsigned long *) 0xE0008024))
#define T1CCR (*((volatile unsigned long *) 0xE0008028))
#define T1CR0 (*((volatile unsigned long *) 0xE000802C))
#define T1CR1 (*((volatile unsigned long *) 0xE0008030))
#define T1CR2 (*((volatile unsigned long *) 0xE0008034))
#define T1CR3 (*((volatile unsigned long *) 0xE0008038))
#define T1EMR (*((volatile unsigned long *) 0xE000803C))
#define T1CTCR (*((volatile unsigned long *) 0xE0008070))
/* Pulse Width Modulator (PWM) */
#define PWMIR (*((volatile unsigned long *) 0xE0014000))
#define PWMTCR (*((volatile unsigned long *) 0xE0014004))
#define PWMTC (*((volatile unsigned long *) 0xE0014008))
#define PWMPR (*((volatile unsigned long *) 0xE001400C))
#define PWMPC (*((volatile unsigned long *) 0xE0014010))
#define PWMMCR (*((volatile unsigned long *) 0xE0014014))
#define PWMMR0 (*((volatile unsigned long *) 0xE0014018))
#define PWMMR1 (*((volatile unsigned long *) 0xE001401C))
#define PWMMR2 (*((volatile unsigned long *) 0xE0014020))
#define PWMMR3 (*((volatile unsigned long *) 0xE0014024))
#define PWMMR4 (*((volatile unsigned long *) 0xE0014040))
#define PWMMR5 (*((volatile unsigned long *) 0xE0014044))
#define PWMMR6 (*((volatile unsigned long *) 0xE0014048))
#define PWMEMR (*((volatile unsigned long *) 0xE001403C))
#define PWMPCR (*((volatile unsigned long *) 0xE001404C))
#define PWMLER (*((volatile unsigned long *) 0xE0014050))
/* Universal Asynchronous Receiver Transmitter 0 (UART0) */
#define U0RBR (*((volatile unsigned char *) 0xE000C000))
#define U0THR (*((volatile unsigned char *) 0xE000C000))
#define U0IER (*((volatile unsigned char *) 0xE000C004))
#define U0IIR (*((volatile unsigned char *) 0xE000C008))
#define U0FCR (*((volatile unsigned char *) 0xE000C008))
#define U0LCR (*((volatile unsigned char *) 0xE000C00C))
#define U0LSR (*((volatile unsigned char *) 0xE000C014))
#define U0SCR (*((volatile unsigned char *) 0xE000C01C))
#define U0DLL (*((volatile unsigned char *) 0xE000C000))
#define U0DLM (*((volatile unsigned char *) 0xE000C004))
#define U0TER (*((volatile unsigned char *) 0xE000C030))
/* Universal Asynchronous Receiver Transmitter 1 (UART1) */
#define U1RBR (*((volatile unsigned char *) 0xE0010000))
#define U1THR (*((volatile unsigned char *) 0xE0010000))
#define U1IER (*((volatile unsigned char *) 0xE0010004))
#define U1IIR (*((volatile unsigned char *) 0xE0010008))
#define U1FCR (*((volatile unsigned char *) 0xE0010008))
#define U1LCR (*((volatile unsigned char *) 0xE001000C))
#define U1MCR (*((volatile unsigned char *) 0xE0010010))
#define U1LSR (*((volatile unsigned char *) 0xE0010014))
#define U1MSR (*((volatile unsigned char *) 0xE0010018))
#define U1SCR (*((volatile unsigned char *) 0xE001001C))
#define U1DLL (*((volatile unsigned char *) 0xE0010000))
#define U1DLM (*((volatile unsigned char *) 0xE0010004))
#define U1TER (*((volatile unsigned char *) 0xE0010030))
/* I2C Interface 0 */
#define I20CONSET (*((volatile unsigned char *) 0xE001C000))
#define I20STAT (*((volatile unsigned char *) 0xE001C004))
#define I20DAT (*((volatile unsigned char *) 0xE001C008))
#define I20ADR (*((volatile unsigned char *) 0xE001C00C))
#define I20SCLH (*((volatile unsigned short*) 0xE001C010))
#define I20SCLL (*((volatile unsigned short*) 0xE001C014))
#define I20CONCLR (*((volatile unsigned char *) 0xE001C018))
/* I2C Interface 1 */
#define I21CONSET (*((volatile unsigned char *) 0xE005C000))
#define I21STAT (*((volatile unsigned char *) 0xE005C004))
#define I21DAT (*((volatile unsigned char *) 0xE005C008))
#define I21ADR (*((volatile unsigned char *) 0xE005C00C))
#define I21SCLH (*((volatile unsigned short*) 0xE005C010))
#define I21SCLL (*((volatile unsigned short*) 0xE005C014))
#define I21CONCLR (*((volatile unsigned char *) 0xE005C018))
/* SPI0 (Serial Peripheral Interface 0) */
#define S0SPCR (*((volatile unsigned char *) 0xE0020000))
#define S0SPSR (*((volatile unsigned char *) 0xE0020004))
#define S0SPDR (*((volatile unsigned char *) 0xE0020008))
#define S0SPCCR (*((volatile unsigned char *) 0xE002000C))
#define S0SPTCR (*((volatile unsigned char *) 0xE0020010))
#define S0SPTSR (*((volatile unsigned char *) 0xE0020014))
#define S0SPTOR (*((volatile unsigned char *) 0xE0020018))
#define S0SPINT (*((volatile unsigned char *) 0xE002001C))
/* SSP Controller */
#define SSPCR0 (*((volatile unsigned short* ) 0xE0068000))
#define SSPCR1 (*((volatile unsigned char * ) 0xE0068004))
#define SSPDR (*((volatile unsigned short* ) 0xE0068008))
#define SSPSR (*((volatile unsigned char * ) 0xE006800C))
#define SSPCPSR (*((volatile unsigned char * ) 0xE0068010))
#define SSPIMSC (*((volatile unsigned char * ) 0xE0068014))
#define SSPRIS (*((volatile unsigned char * ) 0xE0068018))
#define SSPMIS (*((volatile unsigned char * ) 0xE006801C))
#define SSPICR (*((volatile unsigned char * ) 0xE0068020))
#define SSPDMACR (*((volatile unsigned char * ) 0xE0068024))
/* Real Time Clock */
#define ILR (*((volatile unsigned char *) 0xE0024000))
#define CTC (*((volatile unsigned short*) 0xE0024004))
#define CCR (*((volatile unsigned char *) 0xE0024008))
#define CIIR (*((volatile unsigned char *) 0xE002400C))
#define AMR (*((volatile unsigned char *) 0xE0024010))
#define CTIME0 (*((volatile unsigned long *) 0xE0024014))
#define CTIME1 (*((volatile unsigned long *) 0xE0024018))
#define CTIME2 (*((volatile unsigned long *) 0xE002401C))
#define SEC (*((volatile unsigned char *) 0xE0024020))
#define MIN (*((volatile unsigned char *) 0xE0024024))
#define HOUR (*((volatile unsigned char *) 0xE0024028))
#define DOM (*((volatile unsigned char *) 0xE002402C))
#define DOW (*((volatile unsigned char *) 0xE0024030))
#define DOY (*((volatile unsigned short*) 0xE0024034))
#define MONTH (*((volatile unsigned char *) 0xE0024038))
#define YEAR (*((volatile unsigned short*) 0xE002403C))
#define ALSEC (*((volatile unsigned char *) 0xE0024060))
#define ALMIN (*((volatile unsigned char *) 0xE0024064))
#define ALHOUR (*((volatile unsigned char *) 0xE0024068))
#define ALDOM (*((volatile unsigned char *) 0xE002406C))
#define ALDOW (*((volatile unsigned char *) 0xE0024070))
#define ALDOY (*((volatile unsigned short*) 0xE0024074))
#define ALMON (*((volatile unsigned char *) 0xE0024078))
#define ALYEAR (*((volatile unsigned short*) 0xE002407C))
#define PREINT (*((volatile unsigned short*) 0xE0024080))
#define PREFRAC (*((volatile unsigned short*) 0xE0024084))
/* A/D Converter 0 (AD0) */
#define AD0CR (*((volatile unsigned long *) 0xE0034000))
#define AD0DR (*((volatile unsigned long *) 0xE0034004))
/* A/D Converter 1 (AD1) */
#define AD1CR (*((volatile unsigned long *) 0xE0060000))
#define AD1DR (*((volatile unsigned long *) 0xE0060004))
/* D/A Converter */
#define DACR (*((volatile unsigned long *) 0xE006C000))
/* Watchdog */
#define WDMOD (*((volatile unsigned char *) 0xE0000000))
#define WDTC (*((volatile unsigned long *) 0xE0000004))
#define WDFEED (*((volatile unsigned char *) 0xE0000008))
#define WDTV (*((volatile unsigned long *) 0xE000000C))
#endif // __LPC213x_H
@@ -0,0 +1,436 @@
# Hey Emacs, this is a -*- makefile -*-
#
# WinARM template makefile
# by Martin Thomas, Kaiserslautern, Germany
# <eversmith@heizung-thomas.de>
#
# based on the WinAVR makefile written by Eric B. Weddington, Jörg Wunsch, et al.
# Released to the Public Domain
# Please read the make user manual!
#
#
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make program = Download the hex file to the device, using lpc21isp
#
# (TODO: make filename.s = Just compile filename.c into the assembler code only)
#
# To rebuild project do "make clean" then "make all".
#
# Changelog:
# - 17. Feb. 2005 - added thumb-interwork support (mth)
# - 28. Apr. 2005 - added C++ support (mth)
# - 29. Arp. 2005 - changed handling for lst-Filename (mth)
#
FLASH_TOOL = ULINK
# MCU name and submodel
MCU = arm7tdmi-s
SUBMDL = LPC2138
THUMB = -mthumb
THUMB_IW = -mthumb-interwork
## Create ROM-Image (final)
RUN_MODE=ROM_RUN
## Create RAM-Image (debugging)
#RUN_MODE=RAM_RUN
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
# Target file name (without extension).
TARGET = main
# List C source files here. (C dependencies are automatically generated.)
# use file-extension c for "c-only"-files
SRC = $(TARGET).c
SRC += uart.c
SRC += ../../src/efs.c ../../src/plibc.c ../../src/disc.c ../../src/partition.c
SRC += ../../src/time.c ../../src/fs.c ../../src/fat.c ../../src/file.c ../../src/dir.c ../../src/ls.c
SRC += ../../src/mkfs.c ../../src/debug.c ../../src/ioman.c ../../src/ui.c ../../src/extract.c
SRC += ../../src/interfaces/lpc2000_spi.c ../../src/interfaces/sd.c
SRC += ../../src/interfaces/lpc2000_dbg_printf.c
# List C source files here which must be compiled in ARM-Mode.
# use file-extension c for "c-only"-files
SRCARM =
# List C++ source files here.
# use file-extension cpp for C++-files
CPPSRC =
# List C++ source files here which must be compiled in ARM-Mode.
# use file-extension cpp for C++-files
#CPPSRCARM = $(TARGET).cpp
CPPSRCARM =
# List Assembler source files here.
# Make them always end in a capital .S. Files ending in a lowercase .s
# will not be considered source files but generated files (assembler
# output from the compiler), and will be deleted upon "make clean"!
# Even though the DOS/Win* filesystem matches both .s and .S the same,
# it will preserve the spelling of the filenames, and gcc itself does
# care about how the name is spelled on its command-line.
ASRC =
# List Assembler source files here which must be assembled in ARM-Mode..
ASRCARM = crt0.S
# Optimization level, can be [0, 1, 2, 3, s].
# 0 = turn off optimization. s = optimize for size.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = s
#OPT = 0
# Debugging format.
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
#DEBUG = stabs
DEBUG = dwarf-2
# List any extra directories to look for include files here.
# Each directory must be seperated by a space.
EXTRAINCDIRS = ../../inc ../../conf
# Compiler flag to set the C Standard level.
# c89 - "ANSI" C
# gnu89 - c89 plus GCC extensions
# c99 - ISO C99 standard (not yet fully implemented)
# gnu99 - c99 plus GCC extensions
CSTANDARD = -std=gnu99
# Place -D or -U options for C here
CDEFS = -D$(RUN_MODE)
# Place -I options here
CINCS =
# Place -D or -U options for ASM here
ADEFS = -D$(RUN_MODE)
# Compiler flags.
# -g*: generate debugging information
# -O*: optimization level
# -f...: tuning, see GCC manual and avr-libc documentation
# -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler.
# -adhlns...: create assembler listing
#
# Flags for C and C++ (arm-none-eabi-gcc/arm-none-eabi-g++)
CFLAGS = -g$(DEBUG)
CFLAGS += $(CDEFS) $(CINCS)
CFLAGS += -O$(OPT)
CFLAGS += -Wall -Wcast-align -Wcast-qual -Wimplicit
CFLAGS += -Wpointer-arith -Wswitch
CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow -Wunused
CFLAGS += -Wa,-adhlns=$(subst $(suffix $<),.lst,$<)
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
# flags only for C
CONLYFLAGS = -Wstrict-prototypes -Wmissing-declarations
CONLYFLAGS += -Wmissing-prototypes -Wnested-externs
CONLYFLAGS += $(CSTANDARD)
# flags only for C++ (arm-none-eabi-g++)
# CPPFLAGS = -fno-rtti -fno-exceptions
CPPFLAGS =
# Assembler flags.
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create listing
# -gstabs: have the assembler create line number information; note that
# for use in COFF files, additional information about filenames
# and function names needs to be present in the assembler source
# files -- see avr-libc docs [FIXME: not yet described there]
##ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:.S=.lst),-g$(DEBUG)
#Additional libraries.
#Support for newlibc-lpc (file: libnewlibc-lpc.a)
NEWLIBLPC = -lnewlib-lpc
MATH_LIB = -lm
CPLUSPLUS_LIB = -lstdc++
# Linker flags.
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS = -nostartfiles -Wl,-Map=$(TARGET).map,--cref
LDFLAGS += -lc
LDFLAGS += $(NEWLIBLPC) $(MATH_LIB)
LDFLAGS += -lc -lgcc
LDFLAGS += $(CPLUSPLUS_LIB)
# Set Linker-Script Depending On Selected Memory
ifeq ($(RUN_MODE),RAM_RUN)
LDFLAGS +=-T$(SUBMDL)-RAM.ld
else
LDFLAGS +=-T$(SUBMDL)-ROM.ld
endif
# ---------------------------------------------------------------------------
# Flash-Programming support using lpc21isp by Martin Maurer
# Settings and variables:
#LPC21ISP = lpc21isp
LPC21ISP = lpc21isp
LPC21ISP_PORT = com1
LPC21ISP_BAUD = 38400
LPC21ISP_XTAL = 12000
LPC21ISP_FLASHFILE = $(TARGET).hex
# verbose output:
#LPC21ISP_DEBUG = -debug
# enter bootloader via RS232 DTR/RTS (only if hardware supports this
# feature - see Philips AppNote):
LPC21ISP_CONTROL = -control
# ---------------------------------------------------------------------------
# Define directories, if needed.
## DIRARM = c:/WinARM/
## DIRARMBIN = $(DIRAVR)/bin/
## DIRAVRUTILS = $(DIRAVR)/utils/bin/
# Define programs and commands.
SHELL = sh
CC = arm-none-eabi-gcc
CPP = arm-none-eabi-g++
OBJCOPY = arm-none-eabi-objcopy
OBJDUMP = arm-none-eabi-objdump
SIZE = arm-none-eabi-size
NM = arm-none-eabi-nm
REMOVE = rm -f
COPY = cp
# Define Messages
# English
MSG_ERRORS_NONE = Errors: none
MSG_BEGIN = -------- begin --------
MSG_END = -------- end --------
MSG_SIZE_BEFORE = Size before:
MSG_SIZE_AFTER = Size after:
MSG_FLASH = Creating load file for Flash:
MSG_EXTENDED_LISTING = Creating Extended Listing:
MSG_SYMBOL_TABLE = Creating Symbol Table:
MSG_LINKING = Linking:
MSG_COMPILING = Compiling C:
MSG_COMPILING_ARM = "Compiling C (ARM-only):"
MSG_COMPILINGCPP = Compiling C++:
MSG_COMPILINGCPP_ARM = "Compiling C++ (ARM-only):"
MSG_ASSEMBLING = Assembling:
MSG_ASSEMBLING_ARM = "Assembling (ARM-only):"
MSG_CLEANING = Cleaning project:
MSG_LPC21_RESETREMINDER = You may have to bring the target in bootloader-mode now.
# Define all object files.
COBJ = $(SRC:.c=.o)
AOBJ = $(ASRC:.S=.o)
COBJARM = $(SRCARM:.c=.o)
AOBJARM = $(ASRCARM:.S=.o)
CPPOBJ = $(CPPSRC:.cpp=.o)
CPPOBJARM = $(CPPSRCARM:.cpp=.o)
# Define all listing files.
LST = $(ASRC:.S=.lst) $(ASRCARM:.S=.lst) $(SRC:.c=.lst) $(SRCARM:.c=.lst)
LST += $(CPPSRC:.cpp=.lst) $(CPPSRCARM:.cpp=.lst)
# Compiler flags to generate dependency files.
### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. $(CFLAGS) $(GENDEPFLAGS)
ALL_ASFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. -x assembler-with-cpp $(ASFLAGS)
# Default target.
all: begin gccversion sizebefore build sizeafter finished end
build: elf hex lss sym
elf: $(TARGET).elf
hex: $(TARGET).hex
lss: $(TARGET).lss
sym: $(TARGET).sym
# Eye candy.
begin:
@echo
@echo $(MSG_BEGIN)
finished:
@echo $(MSG_ERRORS_NONE)
end:
@echo $(MSG_END)
@echo
# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
ELFSIZE = $(SIZE) -A $(TARGET).elf
sizebefore:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
sizeafter:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
# Display compiler version information.
gccversion :
@$(CC) --version
ifeq ($(FLASH_TOOL),ULINK)
# Program the device with Keil's ULINK (needs configured uVision-Workspace).
program: $(TARGET).hex
@echo
@echo "Programming with ULINK"
C:\Keil\uv3\Uv3.exe -f ulinkflash.Uv2 -oulinkflash.txt
else
# Program the device.
program: $(TARGET).hex
@echo
@echo $(MSG_LPC21_RESETREMINDER)
$(LPC21ISP) $(LPC21ISP_CONTROL) $(LPC21ISP_DEBUG) $(LPC21ISP_FLASHFILE) $(LPC21ISP_PORT) $(LPC21ISP_BAUD) $(LPC21ISP_XTAL)
endif
# Create final output files (.hex, .eep) from ELF output file.
# TODO: handling the .eeprom-section should be redundant
%.hex: %.elf
@echo
@echo $(MSG_FLASH) $@
$(OBJCOPY) -O $(FORMAT) $< $@
# Create extended listing file from ELF output file.
# testing: option -C
%.lss: %.elf
@echo
@echo $(MSG_EXTENDED_LISTING) $@
$(OBJDUMP) -h -S -C $< > $@
# Create a symbol table from ELF output file.
%.sym: %.elf
@echo
@echo $(MSG_SYMBOL_TABLE) $@
$(NM) -n $< > $@
# Link: create ELF output file from object files.
.SECONDARY : $(TARGET).elf
.PRECIOUS : $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM)
%.elf: $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM)
@echo
@echo $(MSG_LINKING) $@
$(CC) $(THUMB) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM) --output $@ $(LDFLAGS)
# $(CPP) $(THUMB) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM) --output $@ $(LDFLAGS)
# Compile: create object files from C source files. ARM/Thumb
$(COBJ) : %.o : %.c
@echo
@echo $(MSG_COMPILING) $<
$(CC) -c $(THUMB) $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@
# Compile: create object files from C source files. ARM-only
$(COBJARM) : %.o : %.c
@echo
@echo $(MSG_COMPILING_ARM) $<
$(CC) -c $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@
# Compile: create object files from C++ source files. ARM/Thumb
$(CPPOBJ) : %.o : %.cpp
@echo
@echo $(MSG_COMPILINGCPP) $<
$(CPP) -c $(THUMB) $(ALL_CFLAGS) $(CPPFLAGS) $< -o $@
# Compile: create object files from C++ source files. ARM-only
$(CPPOBJARM) : %.o : %.cpp
@echo
@echo $(MSG_COMPILINGCPP_ARM) $<
$(CPP) -c $(ALL_CFLAGS) $(CPPFLAGS) $< -o $@
# Compile: create assembler files from C source files. ARM/Thumb
## does not work - TODO - hints welcome
##$(COBJ) : %.s : %.c
## $(CC) $(THUMB) -S $(ALL_CFLAGS) $< -o $@
# Assemble: create object files from assembler source files. ARM/Thumb
$(AOBJ) : %.o : %.S
@echo
@echo $(MSG_ASSEMBLING) $<
$(CC) -c $(THUMB) $(ALL_ASFLAGS) $< -o $@
# Assemble: create object files from assembler source files. ARM-only
$(AOBJARM) : %.o : %.S
@echo
@echo $(MSG_ASSEMBLING_ARM) $<
$(CC) -c $(ALL_ASFLAGS) $< -o $@
# Target: clean project.
clean: begin clean_list finished end
clean_list :
@echo
@echo $(MSG_CLEANING)
$(REMOVE) $(TARGET).hex
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).elf
$(REMOVE) $(TARGET).map
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).a90
$(REMOVE) $(TARGET).sym
$(REMOVE) $(TARGET).lnk
$(REMOVE) $(TARGET).lss
$(REMOVE) $(COBJ)
$(REMOVE) $(CPPOBJ)
$(REMOVE) $(AOBJ)
$(REMOVE) $(COBJARM)
$(REMOVE) $(CPPOBJARM)
$(REMOVE) $(AOBJARM)
$(REMOVE) $(LST)
$(REMOVE) $(SRC:.c=.s)
$(REMOVE) $(SRC:.c=.d)
$(REMOVE) $(SRCARM:.c=.s)
$(REMOVE) $(SRCARM:.c=.d)
$(REMOVE) $(CPPSRC:.cpp=.s)
$(REMOVE) $(CPPSRC:.cpp=.d)
$(REMOVE) $(CPPSRCARM:.cpp=.s)
$(REMOVE) $(CPPSRCARM:.cpp=.d)
$(REMOVE) .dep/*
# Include the dependency files.
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
# Listing of phony targets.
.PHONY : all begin finish end sizebefore sizeafter gccversion \
build elf hex lss sym clean clean_list program
@@ -0,0 +1,220 @@
/*
crt0.S for LPC2xxx
- based on examples from R O Software
- based on examples from newlib-lpc
- based on an example from Anglia Designs
collected and modified by Martin Thomas
*/
.global _etext // -> .data initial values in ROM
.global _data // -> .data area in RAM
.global _edata // end of .data area
.global __bss_start // -> .bss area in RAM
.global __bss_end__ // end of .bss area
.global _stack // top of stack
// Stack Sizes
.set UND_STACK_SIZE, 0x00000004
.set ABT_STACK_SIZE, 0x00000004
.set FIQ_STACK_SIZE, 0x00000004
.set IRQ_STACK_SIZE, 0X00000080
.set SVC_STACK_SIZE, 0x00000004
// Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs
.set MODE_USR, 0x10 // User Mode
.set MODE_FIQ, 0x11 // FIQ Mode
.set MODE_IRQ, 0x12 // IRQ Mode
.set MODE_SVC, 0x13 // Supervisor Mode
.set MODE_ABT, 0x17 // Abort Mode
.set MODE_UND, 0x1B // Undefined Mode
.set MODE_SYS, 0x1F // System Mode
.equ I_BIT, 0x80 // when I bit is set, IRQ is disabled
.equ F_BIT, 0x40 // when F bit is set, FIQ is disabled
.text
.arm
.section .init, "ax"
.code 32
.align 2
.global _boot
.func _boot
_boot:
// Runtime Interrupt Vectors
// -------------------------
Vectors:
b _start // reset - _start
ldr pc,_undf // undefined - _undf
ldr pc,_swi // SWI - _swi
ldr pc,_pabt // program abort - _pabt
ldr pc,_dabt // data abort - _dabt
nop // reserved
ldr pc,[pc,#-0xFF0] // IRQ - read the VIC
ldr pc,_fiq // FIQ - _fiq
#if 0
// Use this group for production
_undf: .word _reset // undefined - _reset
_swi: .word _reset // SWI - _reset
_pabt: .word _reset // program abort - _reset
_dabt: .word _reset // data abort - _reset
_irq: .word _reset // IRQ - _reset
_fiq: .word _reset // FIQ - _reset
#else
// Use this group for development
_undf: .word __undf // undefined
_swi: .word __swi // SWI
_pabt: .word __pabt // program abort
_dabt: .word __dabt // data abort
_irq: .word __irq // IRQ
_fiq: .word __fiq // FIQ
__undf: b . // undefined
__swi: b . // SWI
__pabt: b . // program abort
__dabt: b . // data abort
__irq: b . // IRQ
__fiq: b . // FIQ
#endif
.size _boot, . - _boot
.endfunc
// Setup the operating mode & stack.
// ---------------------------------
.global _start, start, _mainCRTStartup
.func _start
_start:
start:
_mainCRTStartup:
// Initialize Interrupt System
// - Set stack location for each mode
// - Leave in System Mode with Interrupts Disabled
// -----------------------------------------------
ldr r0,=_stack
msr CPSR_c,#MODE_UND|I_BIT|F_BIT // Undefined Instruction Mode
mov sp,r0
sub r0,r0,#UND_STACK_SIZE
msr CPSR_c,#MODE_ABT|I_BIT|F_BIT // Abort Mode
mov sp,r0
sub r0,r0,#ABT_STACK_SIZE
msr CPSR_c,#MODE_FIQ|I_BIT|F_BIT // FIQ Mode
mov sp,r0
sub r0,r0,#FIQ_STACK_SIZE
msr CPSR_c,#MODE_IRQ|I_BIT|F_BIT // IRQ Mode
mov sp,r0
sub r0,r0,#IRQ_STACK_SIZE
msr CPSR_c,#MODE_SVC|I_BIT|F_BIT // Supervisor Mode
mov sp,r0
sub r0,r0,#SVC_STACK_SIZE
msr CPSR_c,#MODE_SYS|I_BIT|F_BIT // System Mode
mov sp,r0
// Copy initialized data to its execution address in RAM
// -----------------------------------------------------
#ifdef ROM_RUN
ldr r1,=_etext // -> ROM data start
ldr r2,=_data // -> data start
ldr r3,=_edata // -> end of data
1: cmp r2,r3 // check if data to move
ldrlo r0,[r1],#4 // copy it
strlo r0,[r2],#4
blo 1b // loop until done
#endif
// Clear .bss
// ----------
mov r0,#0 // get a zero
ldr r1,=__bss_start // -> bss start
ldr r2,=__bss_end__ // -> bss end
2: cmp r1,r2 // check if data to clear
strlo r0,[r1],#4 // clear 4 bytes
blo 2b // loop until done
/*
Call C++ constructors (for objects in "global scope")
ctor loop added by Martin Thomas 4/2005
based on a Anglia Design example-application for ST ARM
*/
LDR r0, =__ctors_start__
LDR r1, =__ctors_end__
ctor_loop:
CMP r0, r1
BEQ ctor_end
LDR r2, [r0], #4
STMFD sp!, {r0-r1}
MOV lr, pc
MOV pc, r2
LDMFD sp!, {r0-r1}
B ctor_loop
ctor_end:
// Call main program: main(0)
// --------------------------
mov r0,#0 // no arguments (argc = 0)
mov r1,r0
mov r2,r0
mov fp,r0 // null frame pointer
mov r7,r0 // null frame pointer for thumb
ldr r10,=main
mov lr,pc
/* Enter the C code, use BX instruction so as to never return */
/* use BLX (?) main if you want to use c++ destructors below */
bx r10 // enter main()
/* "global object"-dtors are never called and it should not be
needed since there is no OS to exit to. */
/* Call destructors */
# LDR r0, =__dtors_start__
# LDR r1, =__dtors_end__
dtor_loop:
# CMP r0, r1
# BEQ dtor_end
# LDR r2, [r0], #4
# STMFD sp!, {r0-r1}
# MOV lr, pc
# MOV pc, r2
# LDMFD sp!, {r0-r1}
# B dtor_loop
dtor_end:
.size _start, . - _start
.endfunc
.global _reset, reset, exit, abort
.func _reset
_reset:
reset:
exit:
abort:
#if 0
// Disable interrupts, then force a hardware reset by driving P23 low
// -------------------------------------------------------------------
mrs r0,cpsr // get PSR
orr r0,r0,#I_BIT|F_BIT // disable IRQ and FIQ
msr cpsr,r0 // set up status register
ldr r1,=(PS_BASE) // PS Base Address
ldr r0,=(PS_PIO) // PIO Module
str r0,[r1,#PS_PCER_OFF] // enable its clock
ldr r1,=(PIO_BASE) // PIO Base Address
ldr r0,=(1<<23) // P23
str r0,[r1,#PIO_PER_OFF] // make sure pin is contolled by PIO
str r0,[r1,#PIO_CODR_OFF] // set the pin low
str r0,[r1,#PIO_OER_OFF] // make it an output
#endif
b . // loop until reset
.size _reset, . - _reset
.endfunc
.end
@@ -0,0 +1,153 @@
> "make" all
-------- begin --------
arm-elf-gcc (GCC) 4.0.1 (WinARM)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Assembling (ARM-only): crt0.S
arm-elf-gcc -c -mcpu=arm7tdmi-s -mthumb-interwork -I. -x assembler-with-cpp -DROM_RUN -Wa,-adhlns=crt0.lst,-gdwarf-2 crt0.S -o crt0.o
Compiling C: main.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=main.lst -I../../inc -I../../conf -MD -MP -MF .dep/main.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 main.c -o main.o
Compiling C: uart.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=uart.lst -I../../inc -I../../conf -MD -MP -MF .dep/uart.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 uart.c -o uart.o
Compiling C: ../../src/efs.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/efs.lst -I../../inc -I../../conf -MD -MP -MF .dep/efs.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/efs.c -o ../../src/efs.o
Compiling C: ../../src/plibc.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/plibc.lst -I../../inc -I../../conf -MD -MP -MF .dep/plibc.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/plibc.c -o ../../src/plibc.o
Compiling C: ../../src/disc.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/disc.lst -I../../inc -I../../conf -MD -MP -MF .dep/disc.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/disc.c -o ../../src/disc.o
Compiling C: ../../src/partition.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/partition.lst -I../../inc -I../../conf -MD -MP -MF .dep/partition.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/partition.c -o ../../src/partition.o
Compiling C: ../../src/time.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/time.lst -I../../inc -I../../conf -MD -MP -MF .dep/time.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/time.c -o ../../src/time.o
../../src/time.c:27: warning: no previous prototype for 'fs_makeDate'
../../src/time.c:48: warning: no previous prototype for 'fs_makeTime'
Compiling C: ../../src/fs.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/fs.lst -I../../inc -I../../conf -MD -MP -MF .dep/fs.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/fs.c -o ../../src/fs.o
Compiling C: ../../src/fat.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/fat.lst -I../../inc -I../../conf -MD -MP -MF .dep/fat.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/fat.c -o ../../src/fat.o
../../src/fat.c: In function 'fat_getNextClusterAddress':
../../src/fat.c:112: warning: cast increases required alignment of target type
../../src/fat.c:116: warning: cast increases required alignment of target type
../../src/fat.c: In function 'fat_setNextClusterAddress':
../../src/fat.c:175: warning: cast increases required alignment of target type
../../src/fat.c:180: warning: cast increases required alignment of target type
../../src/fat.c: In function 'fat_getNextClusterAddressWBuf':
../../src/fat.c:279: warning: cast increases required alignment of target type
../../src/fat.c:283: warning: cast increases required alignment of target type
../../src/fat.c: In function 'fat_setNextClusterAddressWBuf':
../../src/fat.c:332: warning: cast increases required alignment of target type
../../src/fat.c:336: warning: cast increases required alignment of target type
Compiling C: ../../src/file.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/file.lst -I../../inc -I../../conf -MD -MP -MF .dep/file.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/file.c -o ../../src/file.o
Compiling C: ../../src/dir.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/dir.lst -I../../inc -I../../conf -MD -MP -MF .dep/dir.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/dir.c -o ../../src/dir.o
../../src/dir.c: In function 'dir_getFileStructure':
../../src/dir.c:38: warning: cast increases required alignment of target type
../../src/dir.c: In function 'dir_setFirstCluster':
../../src/dir.c:95: warning: cast increases required alignment of target type
../../src/dir.c:96: warning: cast increases required alignment of target type
../../src/dir.c: In function 'dir_setFileSize':
../../src/dir.c:112: warning: cast increases required alignment of target type
../../src/dir.c: In function 'dir_findFileinBuf':
../../src/dir.c:150: warning: cast increases required alignment of target type
../../src/dir.c: In function 'dir_findFreeEntryinBuf':
../../src/dir.c:186: warning: cast increases required alignment of target type
Compiling C: ../../src/ls.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/ls.lst -I../../inc -I../../conf -MD -MP -MF .dep/ls.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/ls.c -o ../../src/ls.o
Compiling C: ../../src/mkfs.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/mkfs.lst -I../../inc -I../../conf -MD -MP -MF .dep/mkfs.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/mkfs.c -o ../../src/mkfs.o
../../src/mkfs.c: In function 'mkfs_makevfat':
../../src/mkfs.c:85: warning: cast increases required alignment of target type
../../src/mkfs.c:91: warning: cast increases required alignment of target type
../../src/mkfs.c:97: warning: cast increases required alignment of target type
../../src/mkfs.c:100: warning: cast increases required alignment of target type
../../src/mkfs.c:106: warning: cast increases required alignment of target type
../../src/mkfs.c:109: warning: cast increases required alignment of target type
../../src/mkfs.c:112: warning: cast increases required alignment of target type
../../src/mkfs.c:115: warning: cast increases required alignment of target type
../../src/mkfs.c:118: warning: cast increases required alignment of target type
../../src/mkfs.c:135: warning: cast increases required alignment of target type
../../src/mkfs.c:136: warning: cast increases required alignment of target type
../../src/mkfs.c:137: warning: cast increases required alignment of target type
Compiling C: ../../src/debug.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/debug.lst -I../../inc -I../../conf -MD -MP -MF .dep/debug.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/debug.c -o ../../src/debug.o
Compiling C: ../../src/ioman.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/ioman.lst -I../../inc -I../../conf -MD -MP -MF .dep/ioman.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/ioman.c -o ../../src/ioman.o
Compiling C: ../../src/ui.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/ui.lst -I../../inc -I../../conf -MD -MP -MF .dep/ui.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/ui.c -o ../../src/ui.o
../../src/ui.c: In function 'listFiles':
../../src/ui.c:74: warning: cast increases required alignment of target type
../../src/ui.c:89: warning: cast increases required alignment of target type
Compiling C: ../../src/extract.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/extract.lst -I../../inc -I../../conf -MD -MP -MF .dep/extract.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/extract.c -o ../../src/extract.o
Compiling C: ../../src/interfaces/lpc2000_spi.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/interfaces/lpc2000_spi.lst -I../../inc -I../../conf -MD -MP -MF .dep/lpc2000_spi.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/interfaces/lpc2000_spi.c -o ../../src/interfaces/lpc2000_spi.o
Compiling C: ../../src/interfaces/sd.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/interfaces/sd.lst -I../../inc -I../../conf -MD -MP -MF .dep/sd.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/interfaces/sd.c -o ../../src/interfaces/sd.o
Compiling C: ../../src/interfaces/lpc2000_dbg_printf.c
arm-elf-gcc -c -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=../../src/interfaces/lpc2000_dbg_printf.lst -I../../inc -I../../conf -MD -MP -MF .dep/lpc2000_dbg_printf.o.d -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -std=gnu99 ../../src/interfaces/lpc2000_dbg_printf.c -o ../../src/interfaces/lpc2000_dbg_printf.o
Linking: main.elf
arm-elf-gcc -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2 -DROM_RUN -Os -Wall -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=crt0.lst -I../../inc -I../../conf -MD -MP -MF .dep/main.elf.d crt0.o main.o uart.o ../../src/efs.o ../../src/plibc.o ../../src/disc.o ../../src/partition.o ../../src/time.o ../../src/fs.o ../../src/fat.o ../../src/file.o ../../src/dir.o ../../src/ls.o ../../src/mkfs.o ../../src/debug.o ../../src/ioman.o ../../src/ui.o ../../src/extract.o ../../src/interfaces/lpc2000_spi.o ../../src/interfaces/sd.o ../../src/interfaces/lpc2000_dbg_printf.o --output main.elf -nostartfiles -Wl,-Map=main.map,--cref -lc -lnewlib-lpc -lm -lc -lgcc -lstdc++ -TLPC2138-ROM.ld
Creating load file for Flash: main.hex
arm-elf-objcopy -O ihex main.elf main.hex
Creating Extended Listing: main.lss
arm-elf-objdump -h -S -C main.elf > main.lss
Creating Symbol Table: main.sym
arm-elf-nm -n main.elf > main.sym
Size after:
main.elf :
section size addr
.text 17198 0
.ctors 0 17198
.dtors 0 17198
.data 12 1073741824
.bss 4168 1073741836
.stack 1024 1073746176
.comment 594 0
.debug_aranges 800 0
.debug_pubnames 3606 0
.debug_info 29533 0
.debug_abbrev 6363 0
.debug_line 5750 0
.debug_frame 4396 0
.debug_str 4948 0
.debug_loc 16626 0
.debug_ranges 72 0
Total 95090
Errors: none
-------- end --------
> Process Exit Code: 0
@@ -0,0 +1,65 @@
MMC/SD Card Filesystem Test (P:LPC2138 L:EFSL)
efsl LPC2000-port and this Demo-Application
done by Martin Thomas, Kaiserslautern, Germany
CARD init...spiInit for SPI(0)
Card is initialising.
Card is initialising.
Card is initialising.
Card is initialising.
Card is initialising.
Card is initialising.
Card is initialising.
Card is initialising.
Card is initialising.
Card is initialising.
Card is initialising.
Card is initialising.
Card is initialising.
Card is initialising.
Card is initialising.
CSD: 00 26 00 32 1F 59 83 C4 FE FA CF 92 40 40 C1 40
Drive Size is 252968960 Bytes (494080 Sectors)
Init done...
ok
Directory of 'root':
SD ( 0 bytes )
MARTIN TXT ( 2475 bytes )
LOGDAT TXT ( 200 bytes )
LOGDAT2 TXT ( 825 bytes )
LOGDAT3 TXT ( 650 bytes )
LOGDAT4 TXT ( 1525 bytes )
LOG1 TXT ( 112 bytes )
LOGDAT5 TXT ( 325 bytes )
19992211TXT ( 75 bytes )
19700318TXT ( 56 bytes )
19700319TXT ( 112 bytes )
19851018TXT ( 170 bytes )
19851019TXT ( 2040 bytes )
19881018TXT ( 340 bytes )
19881019TXT ( 1020 bytes )
LOGDAT9 TXT ( 425 bytes )
LOGDATA TXT ( 225 bytes )
File logdatA.txt open. Content:
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
File logdatA.txt open for append. Appending...ok
File logdatA.txt open. Content:
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
@@ -0,0 +1,67 @@
MMC/SD Card Filesystem Test (P:LPC2138 L:EFSL)
efsl LPC2000-port and this Demo-Application
done by Martin Thomas, Kaiserslautern, Germany
CARD init...spiInit for SSP/SPI1
Card is initialising.
Card is initialising.
Card is initialising.
CSD: 00 26 00 32 1F 59 83 C4 FE FA CF 92 40 40 C1 40
Drive Size is 252968960 Bytes (494080 Sectors)
Init done...
ok
Directory of 'root':
SD ( 0 bytes )
MARTIN TXT ( 2475 bytes )
LOGDAT TXT ( 200 bytes )
LOGDAT2 TXT ( 825 bytes )
LOGDAT3 TXT ( 650 bytes )
LOGDAT4 TXT ( 1525 bytes )
LOG1 TXT ( 112 bytes )
LOGDAT5 TXT ( 325 bytes )
19992211TXT ( 75 bytes )
19700318TXT ( 56 bytes )
19700319TXT ( 112 bytes )
19851018TXT ( 170 bytes )
19851019TXT ( 2040 bytes )
19881018TXT ( 340 bytes )
19881019TXT ( 1020 bytes )
LOGDAT9 TXT ( 475 bytes )
LOGDATA TXT ( 400 bytes )
File logdatA.txt open. Content:
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
File logdatA.txt open for append. Appending...ok
File logdatA.txt open. Content:
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
Martin hat's angehaengt
@@ -0,0 +1,150 @@
/* Copyright (c) 2002, Marek Michalkiewicz
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
/* $Id: inttypes.h,v 1.1 2005/11/16 17:33:36 lennartyseboodt Exp $ */
/*
inttypes.h
Contributors:
Created by Marek Michalkiewicz <marekm@linux.org.pl>
*/
#ifndef __INTTYPES_H_
#define __INTTYPES_H_
/** \defgroup avr_inttypes Integer Types
\code #include <inttypes.h> \endcode
Use [u]intN_t if you need exactly N bits.
Since these typedefs are mandated by the C99 standard, they are preferred
over rolling your own typedefs.
\note If avr-gcc's \c -mint8 option is used, no 32-bit types will be
available.
\todo There is a pending patch that may go into gcc to change the
behaviour of the -mint8 option. The current (2003-09-17) situation for
-mint8 is sizeof(int) == 1, sizeof(long) == 2 and sizeof(long long) == 8.
Note the absence of a 4-byte, 32-bit type. The patch proposes to change
sozeof(long long) to be 4 bytes (32 bits). When and if the patch is
included in gcc, we will need to change avr-libc accordingly. */
#if __INT_MAX__ == 127
# define __USING_MINT8 1
#endif
/** \name 8-bit types. */
/*@{*/
/** \ingroup avr_inttypes
8-bit signed type. */
typedef signed char int8_t;
/** \ingroup avr_inttypes
8-bit unsigned type. */
typedef unsigned char uint8_t;
#if __USING_MINT8
typedef long int16_t;
typedef unsigned long uint16_t;
#else /* no -mint8 */
/*@}*/
/** \name 16-bit types. */
/*@{*/
/** \ingroup avr_inttypes
16-bit signed type. */
typedef int int16_t;
/** \ingroup avr_inttypes
16-bit unsigned type. */
typedef unsigned int uint16_t;
/*@}*/
/** \name 32-bit types. */
/*@{*/
/** \ingroup avr_inttypes
32-bit signed type. */
typedef long int32_t;
/** \ingroup avr_inttypes
32-bit unsigned type. */
typedef unsigned long uint32_t;
#endif
/*@}*/
/** \name 64-bit types. */
/*@{*/
/** \ingroup avr_inttypes
64-bit signed type. */
typedef long long int64_t;
/** \ingroup avr_inttypes
64-bit unsigned type. */
typedef unsigned long long uint64_t;
/*@}*/
/** \name Pointer types.
These allow you to declare variables of the same size as a pointer. */
/*@{*/
/** \ingroup avr_inttypes
Signed pointer compatible type. */
typedef int16_t intptr_t;
/** \ingroup avr_inttypes
Unsigned pointer compatible type. */
typedef uint16_t uintptr_t;
/*@}*/
#endif
@@ -0,0 +1 @@
<Project name="lpc2138_efsl_demo1"><File path="crt0.S"></File><File path="inttypes.h"></File><File path="lpc_config.h"></File><File path="LPC2138-ROM.ld"></File><File path="LPC213x.h"></File><File path="lpcUART.h"></File><File path="main.c"></File><File path="Makefile"></File><File path="uart.c"></File><File path="uart.h"></File><File path="C:\WinARM\examples\lpc2138_efsl_0_2_4\inc\debug.h"></File><File path="C:\WinARM\examples\lpc2138_efsl_0_2_4\inc\interfaces\lpc2000_spi.h"></File><File path="C:\WinARM\examples\lpc2138_efsl_0_2_4\inc\interfaces\LPC2000_regs.h"></File><File path="C:\WinARM\examples\lpc2138_efsl_0_2_4\inc\interfaces\lpc2000_dbg_printf.h"></File><File path="C:\WinARM\examples\lpc2138_efsl_0_2_4\inc\interfaces\sd.h"></File><File path="C:\WinARM\examples\lpc2138_efsl_0_2_4\conf\config.h"></File><File path="C:\WinARM\examples\lpc2138_efsl_0_2_4\src\interfaces\sd.c"></File><File path="C:\WinARM\examples\lpc2138_efsl_0_2_4\src\interfaces\lpc2000_spi.c"></File><File path="C:\WinARM\examples\lpc2138_efsl_0_2_4\src\interfaces\lpc2000_dbg_printf.c"></File><File path="C:\WinARM\examples\lpc2138_efsl_0_2_4\docs\readme_LPC2000.txt"></File></Project>
@@ -0,0 +1,86 @@
/******************************************************************************
*
* $RCSfile: lpcUART.h,v $
* $Revision: 1.1 $
*
* Header file for Philips LPC ARM Processors.
* Copyright 2004 R O SoftWare
*
* No guarantees, warrantees, or promises, implied or otherwise.
* May be used for hobby or commercial purposes provided copyright
* notice remains intact.
*
* reduced to learn what is needed for "minimal" uart0-operation
*****************************************************************************/
#ifndef INC_LPC_UART_H
#define INC_LPC_UART_H
///////////////////////////////////////////////////////////////////////////////
// UART defines
// Interrupt Enable Register bit definitions
#define UIER_ERBFI (1 << 0) // Enable Receive Data Available Interrupt
#define UIER_ETBEI (1 << 1) // Enable Transmit Holding Register Empty Interrupt
#define UIER_ELSI (1 << 2) // Enable Receive Line Status Interrupt
#define UIER_EDSSI (1 << 3) // Enable MODEM Status Interrupt
// Interrupt ID Register bit definitions
#define UIIR_NO_INT (1 << 0) // NO INTERRUPTS PENDING
#define UIIR_MS_INT (0 << 1) // MODEM Status
#define UIIR_THRE_INT (1 << 1) // Transmit Holding Register Empty
#define UIIR_RDA_INT (2 << 1) // Receive Data Available
#define UIIR_RLS_INT (3 << 1) // Receive Line Status
#define UIIR_CTI_INT (6 << 1) // Character Timeout Indicator
#define UIIR_ID_MASK 0x0E
// FIFO Control Register bit definitions
#define UFCR_FIFO_ENABLE (1 << 0) // FIFO Enable
#define UFCR_RX_FIFO_RESET (1 << 1) // Reset Receive FIFO
#define UFCR_TX_FIFO_RESET (1 << 2) // Reset Transmit FIFO
#define UFCR_FIFO_TRIG1 (0 << 6) // Trigger @ 1 character in FIFO
#define UFCR_FIFO_TRIG4 (1 << 6) // Trigger @ 4 characters in FIFO
#define UFCR_FIFO_TRIG8 (2 << 6) // Trigger @ 8 characters in FIFO
#define UFCR_FIFO_TRIG14 (3 << 6) // Trigger @ 14 characters in FIFO
// Line Control Register bit definitions
#define ULCR_CHAR_5 (0 << 0) // 5-bit character length
#define ULCR_CHAR_6 (1 << 0) // 6-bit character length
#define ULCR_CHAR_7 (2 << 0) // 7-bit character length
#define ULCR_CHAR_8 (3 << 0) // 8-bit character length
#define ULCR_STOP_1 (0 << 2) // 1 stop bit
#define ULCR_STOP_2 (1 << 2) // 2 stop bits
#define ULCR_PAR_NO (0 << 3) // No Parity
#define ULCR_PAR_ODD (1 << 3) // Odd Parity
#define ULCR_PAR_EVEN (3 << 3) // Even Parity
#define ULCR_PAR_MARK (5 << 3) // MARK "1" Parity
#define ULCR_PAR_SPACE (7 << 3) // SPACE "0" Paruty
#define ULCR_BREAK_ENABLE (1 << 6) // Output BREAK line condition
#define ULCR_DLAB_ENABLE (1 << 7) // Enable Divisor Latch Access
// Modem Control Register bit definitions
#define UMCR_DTR (1 << 0) // Data Terminal Ready
#define UMCR_RTS (1 << 1) // Request To Send
#define UMCR_LB (1 << 4) // Loopback
// Line Status Register bit definitions
#define ULSR_RDR (1 << 0) // Receive Data Ready
#define ULSR_OE (1 << 1) // Overrun Error
#define ULSR_PE (1 << 2) // Parity Error
#define ULSR_FE (1 << 3) // Framing Error
#define ULSR_BI (1 << 4) // Break Interrupt
#define ULSR_THRE (1 << 5) // Transmit Holding Register Empty
#define ULSR_TEMT (1 << 6) // Transmitter Empty
#define ULSR_RXFE (1 << 7) // Error in Receive FIFO
#define ULSR_ERR_MASK 0x1E
// Modem Status Register bit definitions
#define UMSR_DCTS (1 << 0) // Delta Clear To Send
#define UMSR_DDSR (1 << 1) // Delta Data Set Ready
#define UMSR_TERI (1 << 2) // Trailing Edge Ring Indicator
#define UMSR_DDCD (1 << 3) // Delta Data Carrier Detect
#define UMSR_CTS (1 << 4) // Clear To Send
#define UMSR_DSR (1 << 5) // Data Set Ready
#define UMSR_RI (1 << 6) // Ring Indicator
#define UMSR_DCD (1 << 7) // Data Carrier Detect
#endif
@@ -0,0 +1,52 @@
/* System Config */
/*
PLL
- Main clock F_OSC=12,0MHz @ Keil MCB2130) [limits: 10 MHz to 25 MHz]
- System should run at max. Frequency (60MHz) [limit: max 60 MHz]
- Choose multiplier M=5
so cclk = M * F_OSC= 5 * 12000000 = 60000000 Hz
- MSEL-Bit in PLLCFG (bits 0-4) MSEL = M-1
- F_CCO must be inbetween the limits 156 MHz to 320 MHz
datasheet: F_CCO = F_OSC * M * 2 * P
- choose devider P=2 => F_CCO = 12000000Hz * 5 * 2 * 2
= 240 MHz
- PSEL0 (Bit5 in PLLCFG) = 1, PSEL1 (Bit6) = 0 (0b01)
*/
#define FOSC 12000000
#define PLL_M 5
#define MSEL (PLL_M-1)
#define PSEL0 5
#define PSEL1 6
#define PLLE 0
#define PLLC 1
#define PLOCK 10
#define PLL_FEED1 0xAA
#define PLL_FEED2 0x55
/*
MAM(Memory Accelerator Module)
- choosen: MAM fully enabled = MAM-Mode 2
- System-Clock cclk=60MHz -> 3 CCLKs are proposed as fetch timing
*/
#define MAM_MODE 2
#define MAM_FETCH 3
/*
VPB (V... Pheriphal Bus)
- choosen: VPB should run at full speed -> devider VPBDIV=1
=> pclk = cclk = 60MHz
*/
#define VPBDIV_VAL 1
/*
SCB
*/
#define MEMMAP_BOOT_LOADER_MODE 0 // Interrupt vectors are re-mapped to Boot Block.
#define MEMMAP_USER_FLASH_MODE (1<<0) // Interrupt vectors are not re-mapped and reside in Flash.
#define MEMMAP_USER_RAM_MODE (1<<1) // Interrupt vectors are re-mapped to Static RAM.
@@ -0,0 +1,189 @@
/******************************************************************************
efsl Demo-Application for Philips LPC2138 ARM7TDMI-S
Copyright (c) 2005
Martin Thomas, Kaiserslautern, Germany <mthomas@rhrk.uni-kl.de>
*****************************************************************************/
#include <string.h>
#include "LPC213x.h"
#include "lpc_config.h"
#include "uart.h"
#include "efs.h"
#include "ls.h"
#include "mkfs.h"
#include "interfaces/lpc2000_dbg_printf.h"
#define rprintf lpc2000_debug_printf
#define BAUD 115200
#define BIT(x) ((unsigned long)1<<x)
// 1st LED on Keil MCB2130
#define LED1PIN 16
#define LED1BIT BIT(LED1PIN)
#define LEDDIR IODIR1
#define LEDSET IOSET1
#define LEDCLR IOCLR1
static char LogFileName[] = "logdatA.txt";
static void systemInit(void)
{
// --- enable and connect the PLL (Phase Locked Loop) ---
// a. set multiplier and divider
PLLCFG = MSEL | (1<<PSEL1) | (0<<PSEL0);
// b. enable PLL
PLLCON = (1<<PLLE);
// c. feed sequence
PLLFEED = PLL_FEED1;
PLLFEED = PLL_FEED2;
// d. wait for PLL lock (PLOCK bit is set if locked)
while (!(PLLSTAT & (1<<PLOCK)));
// e. connect (and enable) PLL
PLLCON = (1<<PLLE) | (1<<PLLC);
// f. feed sequence
PLLFEED = PLL_FEED1;
PLLFEED = PLL_FEED2;
// --- setup and enable the MAM (Memory Accelerator Module) ---
// a. start change by turning of the MAM (redundant)
MAMCR = 0;
// b. set MAM-Fetch cycle to 3 cclk as recommended for >40MHz
MAMTIM = MAM_FETCH;
// c. enable MAM
MAMCR = MAM_MODE;
// --- set VPB speed ---
VPBDIV = VPBDIV_VAL;
// --- map INT-vector ---
#if defined(RAM_RUN)
MEMMAP = MEMMAP_USER_RAM_MODE;
#elif defined(ROM_RUN)
MEMMAP = MEMMAP_USER_FLASH_MODE;
#else
#error RUN_MODE not defined!
#endif
}
static void gpioInit(void)
{
LEDSET = BIT(LED1PIN); // set Bit = LED off (active low)
LEDDIR |= BIT(LED1PIN); // define LED-Pin as output
}
static void ledToggle(void)
{
static unsigned char state=0;
state = !state;
if (state) LEDCLR = BIT(LED1PIN); // set Bit = LED on
else LEDSET = BIT(LED1PIN); // set Bit = LED off (active low)
}
#if 0
static void hang(void)
{
while(1);
}
#endif
EmbeddedFileSystem efs;
EmbeddedFile filer, filew;
DirList list;
unsigned short e;
unsigned char buf[513];
int main(void)
{
int ch;
int8_t res;
systemInit();
gpioInit();
uart1Init(UART_BAUD(BAUD), UART_8N1, UART_FIFO_8); // setup the UART
uart1Puts("\r\nMMC/SD Card Filesystem Test (P:LPC2138 L:EFSL)\r\n");
uart1Puts("efsl LPC2000-port and this Demo-Application\r\n");
uart1Puts("done by Martin Thomas, Kaiserslautern, Germany\r\n");
/* init efsl debug-output */
lpc2000_debug_devopen(uart1Putch);
ledToggle();
rprintf("CARD init...");
if ( ( res = efs_init( &efs, 0 ) ) != 0 ) {
rprintf("failed with %i\n",res);
}
else {
rprintf("ok\n");
rprintf("Directory of 'root':\n");
ls_openDir( &list, &(efs.myFs) , "/");
while ( ls_getNext( &list ) == 0 ) {
list.currentEntry.FileName[LIST_MAXLENFILENAME-1] = '\0';
rprintf( "%s ( %li bytes )\n" ,
list.currentEntry.FileName,
list.currentEntry.FileSize ) ;
}
if ( file_fopen( &filer, &efs.myFs , LogFileName , 'r' ) == 0 ) {
rprintf("File %s open. Content:\n", LogFileName);
while ( ( e = file_read( &filer, 512, buf ) ) != 0 ) {
buf[e]='\0';
uart1Puts((char*)buf);
}
rprintf("\n");
file_fclose( &filer );
}
if ( file_fopen( &filew, &efs.myFs , LogFileName , 'a' ) == 0 ) {
rprintf("File %s open for append. Appending...", LogFileName);
strcpy((char*)buf, "Martin hat's angehaengt\r\n");
if ( file_write( &filew, strlen((char*)buf), buf ) == strlen((char*)buf) ) {
rprintf("ok\n");
}
else {
rprintf("fail\n");
}
file_fclose( &filew );
}
if ( file_fopen( &filer, &efs.myFs , LogFileName , 'r' ) == 0 ) {
rprintf("File %s open. Content:\n", LogFileName);
while ( ( e = file_read( &filer, 512, buf ) ) != 0 ) {
buf[e]='\0';
uart1Puts((char*)buf);
}
rprintf("\n");
file_fclose( &filer );
}
fs_umount( &efs.myFs ) ;
}
while(1) {
if ((ch = uart1Getch()) >= 0) {
uart1Puts("You pressed : ");
uart1Putch(ch);
uart1Puts("\r\n");
if ( ch == 'M' ) {
rprintf("Creating FS\n");
mkfs_makevfat(&efs.myPart);
}
ledToggle();
}
}
return 0; /* never reached */
}
@@ -0,0 +1,186 @@
/******************************************************************************
*
* $RCSfile: uart.c,v $
* $Revision: 1.1 $
*
* This module provides interface routines to the LPC ARM UARTs.
* Copyright 2004, R O SoftWare
* No guarantees, warrantees, or promises, implied or otherwise.
* May be used for hobby or commercial purposes provided copyright
* notice remains intact.
*
* reduced to see what has to be done for minimum UART-support by mthomas
*****************************************************************************/
// #warning "this is a reduced version of the R O Software code"
#include "LPC213x.h"
#include "uart.h"
/* on LPC210x: UART0 TX-Pin=P0.2, RX-Pin=P0.1
PINSEL0 has to be set to "UART-Function" = Function "01"
for Pin 0.0 and 0.1 */
#define PINSEL_BITPIN0 0
#define PINSEL_BITPIN1 2
#define PINSEL_BITPIN8 16
#define PINSEL_BITPIN9 18
#define PINSEL_FIRST_ALT_FUNC 1
#define PINSEL_SECOND_ALT_FUNC 2
#define PINSEL_THIRD_ALT_FUNC 3
// Values of Bits 0-3 in PINSEL to activate UART0
#define UART0_PINSEL ((PINSEL_FIRST_ALT_FUNC<<PINSEL_BITPIN0)|(PINSEL_FIRST_ALT_FUNC<<PINSEL_BITPIN1))
// Mask of Bits 0-4
#define UART0_PINMASK (0x0000000F) /* PINSEL0 Mask for UART0 */
// Values of Bits 16-19 in PINSEL to activate UART1
#define UART1_PINSEL ((PINSEL_FIRST_ALT_FUNC<<PINSEL_BITPIN8)|(PINSEL_FIRST_ALT_FUNC<<PINSEL_BITPIN9))
// Mask of Bits 16-19
#define UART1_PINMASK (0x000F0000) /* PINSEL0 Mask for UART1 */
// U0_LCR devisor latch bit
#define UART0_LCR_DLAB 7
// U1_LCR devisor latch bit
#define UART1_LCR_DLAB 7
/* baudrate divisor - use UART_BAUD macro
* mode - see typical modes (uart.h)
* fmode - see typical fmodes (uart.h)
* NOTE: uart0Init(UART_BAUD(9600), UART_8N1, UART_FIFO_8);
*/
void uart0Init(uint16_t baud, uint8_t mode, uint8_t fmode)
{
// setup Pin Function Select Register (Pin Connect Block)
// make sure old values of Bits 0-4 are masked out and
// set them according to UART0-Pin-Selection
PINSEL0 = (PINSEL0 & ~UART0_PINMASK) | UART0_PINSEL;
U0IER = 0x00; // disable all interrupts
U0IIR = 0x00; // clear interrupt ID register
U0LSR = 0x00; // clear line status register
// set the baudrate - DLAB must be set to access DLL/DLM
U0LCR = (1<<UART0_LCR_DLAB); // set divisor latches (DLAB)
U0DLL = (uint8_t)baud; // set for baud low byte
U0DLM = (uint8_t)(baud >> 8); // set for baud high byte
// set the number of characters and other
// user specified operating parameters
// Databits, Parity, Stopbits - Settings in Line Control Register
U0LCR = (mode & ~(1<<UART0_LCR_DLAB)); // clear DLAB "on-the-fly"
// setup FIFO Control Register (fifo-enabled + xx trig)
U0FCR = fmode;
}
int uart0Putch(int ch)
{
while (!(U0LSR & ULSR_THRE)) // wait for TX buffer to empty
continue; // also either WDOG() or swap()
U0THR = (uint8_t)ch; // put char to Transmit Holding Register
return (uint8_t)ch; // return char ("stdio-compatible"?)
}
const char *uart0Puts(const char *string)
{
char ch;
while ((ch = *string)) {
if (uart0Putch(ch)<0) break;
string++;
}
return string;
}
int uart0TxEmpty(void)
{
return (U0LSR & (ULSR_THRE | ULSR_TEMT)) == (ULSR_THRE | ULSR_TEMT);
}
void uart0TxFlush(void)
{
U0FCR |= UFCR_TX_FIFO_RESET; // clear the TX fifo
}
/* Returns: character on success, -1 if no character is available */
int uart0Getch(void)
{
if (U0LSR & ULSR_RDR) // check if character is available
return U0RBR; // return character
return -1;
}
/* baudrate divisor - use UART_BAUD macro
* mode - see typical modes (uart.h)
* fmode - see typical fmodes (uart.h)
* NOTE: uart0Init(UART_BAUD(9600), UART_8N1, UART_FIFO_8);
*/
void uart1Init(uint16_t baud, uint8_t mode, uint8_t fmode)
{
// setup Pin Function Select Register (Pin Connect Block)
// make sure old values of Bits 0-4 are masked out and
// set them according to UART0-Pin-Selection
PINSEL0 = (PINSEL0 & ~UART1_PINMASK) | UART1_PINSEL;
U1IER = 0x00; // disable all interrupts
U1IIR = 0x00; // clear interrupt ID register
U1LSR = 0x00; // clear line status register
// set the baudrate - DLAB must be set to access DLL/DLM
U1LCR = (1<<UART1_LCR_DLAB); // set divisor latches (DLAB)
U1DLL = (uint8_t)baud; // set for baud low byte
U1DLM = (uint8_t)(baud >> 8); // set for baud high byte
// set the number of characters and other
// user specified operating parameters
// Databits, Parity, Stopbits - Settings in Line Control Register
U1LCR = (mode & ~(1<<UART1_LCR_DLAB)); // clear DLAB "on-the-fly"
// setup FIFO Control Register (fifo-enabled + xx trig)
U1FCR = fmode;
}
int uart1Putch(int ch)
{
while (!(U1LSR & ULSR_THRE)) // wait for TX buffer to empty
continue; // also either WDOG() or swap()
U1THR = (uint8_t)ch; // put char to Transmit Holding Register
return (uint8_t)ch; // return char ("stdio-compatible"?)
}
const char *uart1Puts(const char *string)
{
char ch;
while ((ch = *string)) {
if (uart1Putch(ch)<0) break;
string++;
}
return string;
}
int uart1TxEmpty(void)
{
return (U1LSR & (ULSR_THRE | ULSR_TEMT)) == (ULSR_THRE | ULSR_TEMT);
}
void uart1TxFlush(void)
{
U1FCR |= UFCR_TX_FIFO_RESET; // clear the TX fifo
}
/* Returns: character on success, -1 if no character is available */
int uart1Getch(void)
{
if (U1LSR & ULSR_RDR) // check if character is available
return U1RBR; // return character
return -1;
}
@@ -0,0 +1,77 @@
/******************************************************************************
* based on software from:
* Copyright 2004, R O SoftWare
* No guarantees, warrantees, or promises, implied or otherwise.
* May be used for hobby or commercial purposes provided copyright
* notice remains intact.
*
* reduced to learn what has to be done to enable and use UART0
*****************************************************************************/
#ifndef INC_UART_H
#define INC_UART_H
#include "inttypes.h"
#include "LPC213x.h"
#include "lpcUART.h"
#include "lpc_config.h"
///////////////////////////////////////////////////////////////////////////////
// use the following macros to determine the 'baud' parameter values
// for uart0Init() and uart1Init()
// CAUTION - 'baud' SHOULD ALWAYS BE A CONSTANT or
// a lot of code will be generated.
// Baud-Rate is calculated based on pclk (VPB-clock)
// the devisor must be 16 times the desired baudrate
#define UART_BAUD(baud) (uint16_t)(((FOSC*PLL_M/VPBDIV_VAL) / ((baud) * 16.0)) + 0.5)
///////////////////////////////////////////////////////////////////////////////
// Definitions for typical UART 'baud' settings
#define B1200 UART_BAUD(1200)
#define B9600 UART_BAUD(9600)
#define B19200 UART_BAUD(19200)
#define B38400 UART_BAUD(38400)
#define B57600 UART_BAUD(57600)
#define B115200 UART_BAUD(115200)
///////////////////////////////////////////////////////////////////////////////
// Definitions for typical UART 'mode' settings
#define UART_8N1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_NO + ULCR_STOP_1)
#define UART_7N1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_NO + ULCR_STOP_1)
#define UART_8N2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_NO + ULCR_STOP_2)
#define UART_7N2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_NO + ULCR_STOP_2)
#define UART_8E1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_1)
#define UART_7E1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_1)
#define UART_8E2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_2)
#define UART_7E2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_2)
#define UART_8O1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_ODD + ULCR_STOP_1)
#define UART_7O1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_ODD + ULCR_STOP_1)
#define UART_8O2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_ODD + ULCR_STOP_2)
#define UART_7O2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_ODD + ULCR_STOP_2)
///////////////////////////////////////////////////////////////////////////////
// Definitions for typical UART 'fmode' settings
#define UART_FIFO_OFF (0x00)
#define UART_FIFO_1 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG1)
#define UART_FIFO_4 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG4)
#define UART_FIFO_8 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG8)
#define UART_FIFO_14 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG14)
void uart0Init(uint16_t baud, uint8_t mode, uint8_t fmode);
int uart0Putch(int ch);
uint16_t uart0Space(void);
const char *uart0Puts(const char *string);
int uart0TxEmpty(void);
void uart0TxFlush(void);
int uart0Getch(void);
void uart1Init(uint16_t baud, uint8_t mode, uint8_t fmode);
int uart1Putch(int ch);
uint16_t uart1Space(void);
const char *uart1Puts(const char *string);
int uart1TxEmpty(void);
void uart1TxFlush(void);
int uart1Getch(void);
#endif
@@ -0,0 +1,143 @@
/***********************************************************************/
/* ROM.ld: Linker Script File */
/***********************************************************************/
ENTRY(_boot)
STACK_SIZE = 0x400;
/* Memory Definitions */
MEMORY
{
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 512k
RAM (rw) : ORIGIN = 0x40000000, LENGTH = 32k
}
/* Section Definitions */
SECTIONS
{
/* first section is .text which is used for code */
.text :
{
/* *crt0.o (.text) */ /* Startup code */
KEEP(*(.init)) /* Startup code from .init-section */
*(.text .text.*) /* remaining code */
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.gcc_except_table)
*(.rodata) /* read-only data (constants) */
*(.rodata*)
*(.gnu.linkonce.r.*)
} > ROM
/***** old:
.text :
{
*crt0.o (.text)
*(.text)
*(.rodata)
*(.rodata*)
*(.glue_7)
*(.glue_7t)
} > ROM
*****/
. = ALIGN(4);
/* .ctors .dtors are used for c++ constructors/destructors */
/* added by Martin Thomas 4/2005 based on Anglia Design example */
.ctors :
{
PROVIDE(__ctors_start__ = .);
KEEP(*(SORT(.ctors.*)))
KEEP(*(.ctors))
PROVIDE(__ctors_end__ = .);
} >ROM
.dtors :
{
PROVIDE(__dtors_start__ = .);
KEEP(*(SORT(.dtors.*)))
KEEP(*(.dtors))
PROVIDE(__dtors_end__ = .);
} >ROM
. = ALIGN(4);
/* mthomas - end */
_etext = . ;
PROVIDE (etext = .);
/* .data section which is used for initialized data */
.data : AT (_etext)
{
_data = .;
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
SORT(CONSTRUCTORS) /* mt 4/2005 */
. = ALIGN(4);
*(.fastrun) /* !!!! "RAM-Function" example */
} > RAM
. = ALIGN(4);
_edata = . ;
PROVIDE (edata = .);
/* .bss section which is used for uninitialized data */
.bss (NOLOAD) :
{
__bss_start = . ;
__bss_start__ = . ;
*(.bss)
*(.gnu.linkonce.b*)
*(COMMON)
. = ALIGN(4);
} > RAM
. = ALIGN(4);
__bss_end__ = . ;
PROVIDE (__bss_end = .);
.stack ALIGN(256) :
{
. += STACK_SIZE;
PROVIDE (_stack = .);
} > RAM
_end = . ;
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
}
@@ -0,0 +1,273 @@
/***********************************************************************/
/* This file is part of the uVision/ARM development tools */
/* Copyright KEIL ELEKTRONIK GmbH 2002-2005 */
/***********************************************************************/
/* */
/* LPC213X.H: Header file for Philips LPC2131/32/34/36/38 */
/* */
/***********************************************************************/
#ifndef __LPC213x_H
#define __LPC213x_H
/* Vectored Interrupt Controller (VIC) */
#define VICIRQStatus (*((volatile unsigned long *) 0xFFFFF000))
#define VICFIQStatus (*((volatile unsigned long *) 0xFFFFF004))
#define VICRawIntr (*((volatile unsigned long *) 0xFFFFF008))
#define VICIntSelect (*((volatile unsigned long *) 0xFFFFF00C))
#define VICIntEnable (*((volatile unsigned long *) 0xFFFFF010))
#define VICIntEnClr (*((volatile unsigned long *) 0xFFFFF014))
#define VICSoftInt (*((volatile unsigned long *) 0xFFFFF018))
#define VICSoftIntClr (*((volatile unsigned long *) 0xFFFFF01C))
#define VICProtection (*((volatile unsigned long *) 0xFFFFF020))
#define VICVectAddr (*((volatile unsigned long *) 0xFFFFF030))
#define VICDefVectAddr (*((volatile unsigned long *) 0xFFFFF034))
#define VICVectAddr0 (*((volatile unsigned long *) 0xFFFFF100))
#define VICVectAddr1 (*((volatile unsigned long *) 0xFFFFF104))
#define VICVectAddr2 (*((volatile unsigned long *) 0xFFFFF108))
#define VICVectAddr3 (*((volatile unsigned long *) 0xFFFFF10C))
#define VICVectAddr4 (*((volatile unsigned long *) 0xFFFFF110))
#define VICVectAddr5 (*((volatile unsigned long *) 0xFFFFF114))
#define VICVectAddr6 (*((volatile unsigned long *) 0xFFFFF118))
#define VICVectAddr7 (*((volatile unsigned long *) 0xFFFFF11C))
#define VICVectAddr8 (*((volatile unsigned long *) 0xFFFFF120))
#define VICVectAddr9 (*((volatile unsigned long *) 0xFFFFF124))
#define VICVectAddr10 (*((volatile unsigned long *) 0xFFFFF128))
#define VICVectAddr11 (*((volatile unsigned long *) 0xFFFFF12C))
#define VICVectAddr12 (*((volatile unsigned long *) 0xFFFFF130))
#define VICVectAddr13 (*((volatile unsigned long *) 0xFFFFF134))
#define VICVectAddr14 (*((volatile unsigned long *) 0xFFFFF138))
#define VICVectAddr15 (*((volatile unsigned long *) 0xFFFFF13C))
#define VICVectCntl0 (*((volatile unsigned long *) 0xFFFFF200))
#define VICVectCntl1 (*((volatile unsigned long *) 0xFFFFF204))
#define VICVectCntl2 (*((volatile unsigned long *) 0xFFFFF208))
#define VICVectCntl3 (*((volatile unsigned long *) 0xFFFFF20C))
#define VICVectCntl4 (*((volatile unsigned long *) 0xFFFFF210))
#define VICVectCntl5 (*((volatile unsigned long *) 0xFFFFF214))
#define VICVectCntl6 (*((volatile unsigned long *) 0xFFFFF218))
#define VICVectCntl7 (*((volatile unsigned long *) 0xFFFFF21C))
#define VICVectCntl8 (*((volatile unsigned long *) 0xFFFFF220))
#define VICVectCntl9 (*((volatile unsigned long *) 0xFFFFF224))
#define VICVectCntl10 (*((volatile unsigned long *) 0xFFFFF228))
#define VICVectCntl11 (*((volatile unsigned long *) 0xFFFFF22C))
#define VICVectCntl12 (*((volatile unsigned long *) 0xFFFFF230))
#define VICVectCntl13 (*((volatile unsigned long *) 0xFFFFF234))
#define VICVectCntl14 (*((volatile unsigned long *) 0xFFFFF238))
#define VICVectCntl15 (*((volatile unsigned long *) 0xFFFFF23C))
/* Pin Connect Block */
#define PINSEL0 (*((volatile unsigned long *) 0xE002C000))
#define PINSEL1 (*((volatile unsigned long *) 0xE002C004))
#define PINSEL2 (*((volatile unsigned long *) 0xE002C014))
/* General Purpose Input/Output (GPIO) */
#define IOPIN0 (*((volatile unsigned long *) 0xE0028000))
#define IOSET0 (*((volatile unsigned long *) 0xE0028004))
#define IODIR0 (*((volatile unsigned long *) 0xE0028008))
#define IOCLR0 (*((volatile unsigned long *) 0xE002800C))
#define IOPIN1 (*((volatile unsigned long *) 0xE0028010))
#define IOSET1 (*((volatile unsigned long *) 0xE0028014))
#define IODIR1 (*((volatile unsigned long *) 0xE0028018))
#define IOCLR1 (*((volatile unsigned long *) 0xE002801C))
/* Memory Accelerator Module (MAM) */
#define MAMCR (*((volatile unsigned char *) 0xE01FC000))
#define MAMTIM (*((volatile unsigned char *) 0xE01FC004))
#define MEMMAP (*((volatile unsigned char *) 0xE01FC040))
/* Phase Locked Loop (PLL) */
#define PLLCON (*((volatile unsigned char *) 0xE01FC080))
#define PLLCFG (*((volatile unsigned char *) 0xE01FC084))
#define PLLSTAT (*((volatile unsigned short*) 0xE01FC088))
#define PLLFEED (*((volatile unsigned char *) 0xE01FC08C))
/* VPB Divider */
#define VPBDIV (*((volatile unsigned char *) 0xE01FC100))
/* Power Control */
#define PCON (*((volatile unsigned char *) 0xE01FC0C0))
#define PCONP (*((volatile unsigned long *) 0xE01FC0C4))
/* External Interrupts */
#define EXTINT (*((volatile unsigned char *) 0xE01FC140))
#define INTWAKE (*((volatile unsigned char *) 0xE01FC144))
#define EXTMODE (*((volatile unsigned char *) 0xE01FC148))
#define EXTPOLAR (*((volatile unsigned char *) 0xE01FC14C))
/* Reset */
#define RSID (*((volatile unsigned char *) 0xE01FC180))
/* Code Security / Debugging */
#define CSPR (*((volatile unsigned char *) 0xE01FC184))
/* Timer 0 */
#define T0IR (*((volatile unsigned long *) 0xE0004000))
#define T0TCR (*((volatile unsigned long *) 0xE0004004))
#define T0TC (*((volatile unsigned long *) 0xE0004008))
#define T0PR (*((volatile unsigned long *) 0xE000400C))
#define T0PC (*((volatile unsigned long *) 0xE0004010))
#define T0MCR (*((volatile unsigned long *) 0xE0004014))
#define T0MR0 (*((volatile unsigned long *) 0xE0004018))
#define T0MR1 (*((volatile unsigned long *) 0xE000401C))
#define T0MR2 (*((volatile unsigned long *) 0xE0004020))
#define T0MR3 (*((volatile unsigned long *) 0xE0004024))
#define T0CCR (*((volatile unsigned long *) 0xE0004028))
#define T0CR0 (*((volatile unsigned long *) 0xE000402C))
#define T0CR1 (*((volatile unsigned long *) 0xE0004030))
#define T0CR2 (*((volatile unsigned long *) 0xE0004034))
#define T0CR3 (*((volatile unsigned long *) 0xE0004038))
#define T0EMR (*((volatile unsigned long *) 0xE000403C))
#define T0CTCR (*((volatile unsigned long *) 0xE0004070))
/* Timer 1 */
#define T1IR (*((volatile unsigned long *) 0xE0008000))
#define T1TCR (*((volatile unsigned long *) 0xE0008004))
#define T1TC (*((volatile unsigned long *) 0xE0008008))
#define T1PR (*((volatile unsigned long *) 0xE000800C))
#define T1PC (*((volatile unsigned long *) 0xE0008010))
#define T1MCR (*((volatile unsigned long *) 0xE0008014))
#define T1MR0 (*((volatile unsigned long *) 0xE0008018))
#define T1MR1 (*((volatile unsigned long *) 0xE000801C))
#define T1MR2 (*((volatile unsigned long *) 0xE0008020))
#define T1MR3 (*((volatile unsigned long *) 0xE0008024))
#define T1CCR (*((volatile unsigned long *) 0xE0008028))
#define T1CR0 (*((volatile unsigned long *) 0xE000802C))
#define T1CR1 (*((volatile unsigned long *) 0xE0008030))
#define T1CR2 (*((volatile unsigned long *) 0xE0008034))
#define T1CR3 (*((volatile unsigned long *) 0xE0008038))
#define T1EMR (*((volatile unsigned long *) 0xE000803C))
#define T1CTCR (*((volatile unsigned long *) 0xE0008070))
/* Pulse Width Modulator (PWM) */
#define PWMIR (*((volatile unsigned long *) 0xE0014000))
#define PWMTCR (*((volatile unsigned long *) 0xE0014004))
#define PWMTC (*((volatile unsigned long *) 0xE0014008))
#define PWMPR (*((volatile unsigned long *) 0xE001400C))
#define PWMPC (*((volatile unsigned long *) 0xE0014010))
#define PWMMCR (*((volatile unsigned long *) 0xE0014014))
#define PWMMR0 (*((volatile unsigned long *) 0xE0014018))
#define PWMMR1 (*((volatile unsigned long *) 0xE001401C))
#define PWMMR2 (*((volatile unsigned long *) 0xE0014020))
#define PWMMR3 (*((volatile unsigned long *) 0xE0014024))
#define PWMMR4 (*((volatile unsigned long *) 0xE0014040))
#define PWMMR5 (*((volatile unsigned long *) 0xE0014044))
#define PWMMR6 (*((volatile unsigned long *) 0xE0014048))
#define PWMEMR (*((volatile unsigned long *) 0xE001403C))
#define PWMPCR (*((volatile unsigned long *) 0xE001404C))
#define PWMLER (*((volatile unsigned long *) 0xE0014050))
/* Universal Asynchronous Receiver Transmitter 0 (UART0) */
#define U0RBR (*((volatile unsigned char *) 0xE000C000))
#define U0THR (*((volatile unsigned char *) 0xE000C000))
#define U0IER (*((volatile unsigned char *) 0xE000C004))
#define U0IIR (*((volatile unsigned char *) 0xE000C008))
#define U0FCR (*((volatile unsigned char *) 0xE000C008))
#define U0LCR (*((volatile unsigned char *) 0xE000C00C))
#define U0LSR (*((volatile unsigned char *) 0xE000C014))
#define U0SCR (*((volatile unsigned char *) 0xE000C01C))
#define U0DLL (*((volatile unsigned char *) 0xE000C000))
#define U0DLM (*((volatile unsigned char *) 0xE000C004))
#define U0TER (*((volatile unsigned char *) 0xE000C030))
/* Universal Asynchronous Receiver Transmitter 1 (UART1) */
#define U1RBR (*((volatile unsigned char *) 0xE0010000))
#define U1THR (*((volatile unsigned char *) 0xE0010000))
#define U1IER (*((volatile unsigned char *) 0xE0010004))
#define U1IIR (*((volatile unsigned char *) 0xE0010008))
#define U1FCR (*((volatile unsigned char *) 0xE0010008))
#define U1LCR (*((volatile unsigned char *) 0xE001000C))
#define U1MCR (*((volatile unsigned char *) 0xE0010010))
#define U1LSR (*((volatile unsigned char *) 0xE0010014))
#define U1MSR (*((volatile unsigned char *) 0xE0010018))
#define U1SCR (*((volatile unsigned char *) 0xE001001C))
#define U1DLL (*((volatile unsigned char *) 0xE0010000))
#define U1DLM (*((volatile unsigned char *) 0xE0010004))
#define U1TER (*((volatile unsigned char *) 0xE0010030))
/* I2C Interface 0 */
#define I20CONSET (*((volatile unsigned char *) 0xE001C000))
#define I20STAT (*((volatile unsigned char *) 0xE001C004))
#define I20DAT (*((volatile unsigned char *) 0xE001C008))
#define I20ADR (*((volatile unsigned char *) 0xE001C00C))
#define I20SCLH (*((volatile unsigned short*) 0xE001C010))
#define I20SCLL (*((volatile unsigned short*) 0xE001C014))
#define I20CONCLR (*((volatile unsigned char *) 0xE001C018))
/* I2C Interface 1 */
#define I21CONSET (*((volatile unsigned char *) 0xE005C000))
#define I21STAT (*((volatile unsigned char *) 0xE005C004))
#define I21DAT (*((volatile unsigned char *) 0xE005C008))
#define I21ADR (*((volatile unsigned char *) 0xE005C00C))
#define I21SCLH (*((volatile unsigned short*) 0xE005C010))
#define I21SCLL (*((volatile unsigned short*) 0xE005C014))
#define I21CONCLR (*((volatile unsigned char *) 0xE005C018))
/* SPI0 (Serial Peripheral Interface 0) */
#define S0SPCR (*((volatile unsigned char *) 0xE0020000))
#define S0SPSR (*((volatile unsigned char *) 0xE0020004))
#define S0SPDR (*((volatile unsigned char *) 0xE0020008))
#define S0SPCCR (*((volatile unsigned char *) 0xE002000C))
#define S0SPTCR (*((volatile unsigned char *) 0xE0020010))
#define S0SPTSR (*((volatile unsigned char *) 0xE0020014))
#define S0SPTOR (*((volatile unsigned char *) 0xE0020018))
#define S0SPINT (*((volatile unsigned char *) 0xE002001C))
/* SSP Controller */
#define SSPCR0 (*((volatile unsigned short* ) 0xE0068000))
#define SSPCR1 (*((volatile unsigned char * ) 0xE0068004))
#define SSPDR (*((volatile unsigned short* ) 0xE0068008))
#define SSPSR (*((volatile unsigned char * ) 0xE006800C))
#define SSPCPSR (*((volatile unsigned char * ) 0xE0068010))
#define SSPIMSC (*((volatile unsigned char * ) 0xE0068014))
#define SSPRIS (*((volatile unsigned char * ) 0xE0068018))
#define SSPMIS (*((volatile unsigned char * ) 0xE006801C))
#define SSPICR (*((volatile unsigned char * ) 0xE0068020))
#define SSPDMACR (*((volatile unsigned char * ) 0xE0068024))
/* Real Time Clock */
#define ILR (*((volatile unsigned char *) 0xE0024000))
#define CTC (*((volatile unsigned short*) 0xE0024004))
#define CCR (*((volatile unsigned char *) 0xE0024008))
#define CIIR (*((volatile unsigned char *) 0xE002400C))
#define AMR (*((volatile unsigned char *) 0xE0024010))
#define CTIME0 (*((volatile unsigned long *) 0xE0024014))
#define CTIME1 (*((volatile unsigned long *) 0xE0024018))
#define CTIME2 (*((volatile unsigned long *) 0xE002401C))
#define SEC (*((volatile unsigned char *) 0xE0024020))
#define MIN (*((volatile unsigned char *) 0xE0024024))
#define HOUR (*((volatile unsigned char *) 0xE0024028))
#define DOM (*((volatile unsigned char *) 0xE002402C))
#define DOW (*((volatile unsigned char *) 0xE0024030))
#define DOY (*((volatile unsigned short*) 0xE0024034))
#define MONTH (*((volatile unsigned char *) 0xE0024038))
#define YEAR (*((volatile unsigned short*) 0xE002403C))
#define ALSEC (*((volatile unsigned char *) 0xE0024060))
#define ALMIN (*((volatile unsigned char *) 0xE0024064))
#define ALHOUR (*((volatile unsigned char *) 0xE0024068))
#define ALDOM (*((volatile unsigned char *) 0xE002406C))
#define ALDOW (*((volatile unsigned char *) 0xE0024070))
#define ALDOY (*((volatile unsigned short*) 0xE0024074))
#define ALMON (*((volatile unsigned char *) 0xE0024078))
#define ALYEAR (*((volatile unsigned short*) 0xE002407C))
#define PREINT (*((volatile unsigned short*) 0xE0024080))
#define PREFRAC (*((volatile unsigned short*) 0xE0024084))
/* A/D Converter 0 (AD0) */
#define AD0CR (*((volatile unsigned long *) 0xE0034000))
#define AD0DR (*((volatile unsigned long *) 0xE0034004))
/* A/D Converter 1 (AD1) */
#define AD1CR (*((volatile unsigned long *) 0xE0060000))
#define AD1DR (*((volatile unsigned long *) 0xE0060004))
/* D/A Converter */
#define DACR (*((volatile unsigned long *) 0xE006C000))
/* Watchdog */
#define WDMOD (*((volatile unsigned char *) 0xE0000000))
#define WDTC (*((volatile unsigned long *) 0xE0000004))
#define WDFEED (*((volatile unsigned char *) 0xE0000008))
#define WDTV (*((volatile unsigned long *) 0xE000000C))
#endif // __LPC213x_H
@@ -0,0 +1,445 @@
# Hey Emacs, this is a -*- makefile -*-
#
# WinARM template makefile
# by Martin Thomas, Kaiserslautern, Germany
# <eversmith@heizung-thomas.de>
#
# based on the WinAVR makefile written by Eric B. Weddington, Jörg Wunsch, et al.
# Released to the Public Domain
# Please read the make user manual!
#
#
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make program = Download the hex file to the device, using lpc21isp
#
# (TODO: make filename.s = Just compile filename.c into the assembler code only)
#
# To rebuild project do "make clean" then "make all".
#
# Changelog:
# - 17. Feb. 2005 - added thumb-interwork support (mth)
# - 28. Apr. 2005 - added C++ support (mth)
# - 29. Arp. 2005 - changed handling for lst-Filename (mth)
# - 15. Nov. 2005 - added library-search-path (EXTRA_LIBDIRS)
#
FLASH_TOOL = ULINK
# MCU name and submodel
MCU = arm7tdmi-s
SUBMDL = LPC2138
THUMB = -mthumb
THUMB_IW = -mthumb-interwork
## Create ROM-Image (final)
RUN_MODE=ROM_RUN
## Create RAM-Image (debugging)
#RUN_MODE=RAM_RUN
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
# Target file name (without extension).
TARGET = main
# List C source files here. (C dependencies are automatically generated.)
# use file-extension c for "c-only"-files
SRC = $(TARGET).c
SRC += uart.c
#SRC += ../../src/efs.c ../../src/plibc.c ../../src/disc.c ../../src/partition.c
#SRC += ../../src/time.c ../../src/fs.c ../../src/fat.c ../../src/file.c ../../src/dir.c ../../src/ls.c
#SRC += ../../src/mkfs.c ../../src/debug.c ../../src/ioman.c ../../src/ui.c ../../src/extract.c
#SRC += ../../src/interfaces/lpc2000_spi.c ../../src/interfaces/sd.c
#SRC += ../../src/interfaces/lpc2000_dbg_printf.c
# List C source files here which must be compiled in ARM-Mode.
# use file-extension c for "c-only"-files
SRCARM =
# List C++ source files here.
# use file-extension cpp for C++-files
CPPSRC =
# List C++ source files here which must be compiled in ARM-Mode.
# use file-extension cpp for C++-files
#CPPSRCARM = $(TARGET).cpp
CPPSRCARM =
# List Assembler source files here.
# Make them always end in a capital .S. Files ending in a lowercase .s
# will not be considered source files but generated files (assembler
# output from the compiler), and will be deleted upon "make clean"!
# Even though the DOS/Win* filesystem matches both .s and .S the same,
# it will preserve the spelling of the filenames, and gcc itself does
# care about how the name is spelled on its command-line.
ASRC =
# List Assembler source files here which must be assembled in ARM-Mode..
ASRCARM = crt0.S
# Optimization level, can be [0, 1, 2, 3, s].
# 0 = turn off optimization. s = optimize for size.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = s
#OPT = 0
# Debugging format.
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
#DEBUG = stabs
DEBUG = dwarf-2
# List any extra directories to look for include files here.
# Each directory must be seperated by a space.
EXTRAINCDIRS = ../../inc ../../conf
# List any extra directories to look for library files here.
# Each directory must be seperated by a space.
EXTRA_LIBDIRS = -L../../
# extra libraries ( to add libxyz.a and libabc.a: -lxyz -labc )
EXTRA_LIBS = -lefsl
# Compiler flag to set the C Standard level.
# c89 - "ANSI" C
# gnu89 - c89 plus GCC extensions
# c99 - ISO C99 standard (not yet fully implemented)
# gnu99 - c99 plus GCC extensions
CSTANDARD = -std=gnu99
# Place -D or -U options for C here
CDEFS = -D$(RUN_MODE)
# Place -I options here
CINCS =
# Place -D or -U options for ASM here
ADEFS = -D$(RUN_MODE)
# Compiler flags.
# -g*: generate debugging information
# -O*: optimization level
# -f...: tuning, see GCC manual and avr-libc documentation
# -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler.
# -adhlns...: create assembler listing
#
# Flags for C and C++ (arm-none-eabi-gcc/arm-none-eabi-g++)
CFLAGS = -g$(DEBUG)
CFLAGS += $(CDEFS) $(CINCS)
CFLAGS += -O$(OPT)
CFLAGS += -Wall -Wcast-align -Wcast-qual -Wimplicit
CFLAGS += -Wpointer-arith -Wswitch
CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow -Wunused
CFLAGS += -Wa,-adhlns=$(subst $(suffix $<),.lst,$<)
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
# flags only for C
CONLYFLAGS = -Wstrict-prototypes -Wmissing-declarations
CONLYFLAGS += -Wmissing-prototypes -Wnested-externs
CONLYFLAGS += $(CSTANDARD)
# flags only for C++ (arm-none-eabi-g++)
# CPPFLAGS = -fno-rtti -fno-exceptions
CPPFLAGS =
# Assembler flags.
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create listing
# -gstabs: have the assembler create line number information; note that
# for use in COFF files, additional information about filenames
# and function names needs to be present in the assembler source
# files -- see avr-libc docs [FIXME: not yet described there]
##ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:.S=.lst),-g$(DEBUG)
#Additional libraries.
#Support for newlibc-lpc (file: libnewlibc-lpc.a)
#NEWLIBLPC = -lnewlib-lpc
MATH_LIB = -lm
#CPLUSPLUS_LIB = -lstdc++
# Linker flags.
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS = -nostartfiles -Wl,-Map=$(TARGET).map,--cref
LDFLAGS += -lc
LDFLAGS += $(NEWLIBLPC) $(MATH_LIB)
LDFLAGS += -lc -lgcc
LDFLAGS += $(CPLUSPLUS_LIB)
LDFLAGS += $(EXTRA_LIBS)
LDFLAGS += $(EXTRA_LIBDIRS)
# Set Linker-Script Depending On Selected Memory
ifeq ($(RUN_MODE),RAM_RUN)
LDFLAGS +=-T$(SUBMDL)-RAM.ld
else
LDFLAGS +=-T$(SUBMDL)-ROM.ld
endif
# ---------------------------------------------------------------------------
# Flash-Programming support using lpc21isp by Martin Maurer
# Settings and variables:
#LPC21ISP = lpc21isp
LPC21ISP = lpc21isp
LPC21ISP_PORT = com1
LPC21ISP_BAUD = 38400
LPC21ISP_XTAL = 12000
LPC21ISP_FLASHFILE = $(TARGET).hex
# verbose output:
#LPC21ISP_DEBUG = -debug
# enter bootloader via RS232 DTR/RTS (only if hardware supports this
# feature - see Philips AppNote):
LPC21ISP_CONTROL = -control
# ---------------------------------------------------------------------------
# Define directories, if needed.
## DIRARM = c:/WinARM/
## DIRARMBIN = $(DIRAVR)/bin/
## DIRAVRUTILS = $(DIRAVR)/utils/bin/
# Define programs and commands.
SHELL = sh
CC = arm-none-eabi-gcc
CPP = arm-none-eabi-g++
OBJCOPY = arm-none-eabi-objcopy
OBJDUMP = arm-none-eabi-objdump
SIZE = arm-none-eabi-size
NM = arm-none-eabi-nm
REMOVE = rm -f
COPY = cp
# Define Messages
# English
MSG_ERRORS_NONE = Errors: none
MSG_BEGIN = -------- begin --------
MSG_END = -------- end --------
MSG_SIZE_BEFORE = Size before:
MSG_SIZE_AFTER = Size after:
MSG_FLASH = Creating load file for Flash:
MSG_EXTENDED_LISTING = Creating Extended Listing:
MSG_SYMBOL_TABLE = Creating Symbol Table:
MSG_LINKING = Linking:
MSG_COMPILING = Compiling C:
MSG_COMPILING_ARM = "Compiling C (ARM-only):"
MSG_COMPILINGCPP = Compiling C++:
MSG_COMPILINGCPP_ARM = "Compiling C++ (ARM-only):"
MSG_ASSEMBLING = Assembling:
MSG_ASSEMBLING_ARM = "Assembling (ARM-only):"
MSG_CLEANING = Cleaning project:
MSG_LPC21_RESETREMINDER = You may have to bring the target in bootloader-mode now.
# Define all object files.
COBJ = $(SRC:.c=.o)
AOBJ = $(ASRC:.S=.o)
COBJARM = $(SRCARM:.c=.o)
AOBJARM = $(ASRCARM:.S=.o)
CPPOBJ = $(CPPSRC:.cpp=.o)
CPPOBJARM = $(CPPSRCARM:.cpp=.o)
# Define all listing files.
LST = $(ASRC:.S=.lst) $(ASRCARM:.S=.lst) $(SRC:.c=.lst) $(SRCARM:.c=.lst)
LST += $(CPPSRC:.cpp=.lst) $(CPPSRCARM:.cpp=.lst)
# Compiler flags to generate dependency files.
### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. $(CFLAGS) $(GENDEPFLAGS)
ALL_ASFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. -x assembler-with-cpp $(ASFLAGS)
# Default target.
all: begin gccversion sizebefore build sizeafter finished end
build: elf hex lss sym
elf: $(TARGET).elf
hex: $(TARGET).hex
lss: $(TARGET).lss
sym: $(TARGET).sym
# Eye candy.
begin:
@echo
@echo $(MSG_BEGIN)
finished:
@echo $(MSG_ERRORS_NONE)
end:
@echo $(MSG_END)
@echo
# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
ELFSIZE = $(SIZE) -A $(TARGET).elf
sizebefore:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
sizeafter:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
# Display compiler version information.
gccversion :
@$(CC) --version
ifeq ($(FLASH_TOOL),ULINK)
# Program the device with Keil's ULINK (needs configured uVision-Workspace).
program: $(TARGET).hex
@echo
@echo "Programming with ULINK"
C:\Keil\uv3\Uv3.exe -f ulinkflash.Uv2 -oulinkflash.txt
else
# Program the device.
program: $(TARGET).hex
@echo
@echo $(MSG_LPC21_RESETREMINDER)
$(LPC21ISP) $(LPC21ISP_CONTROL) $(LPC21ISP_DEBUG) $(LPC21ISP_FLASHFILE) $(LPC21ISP_PORT) $(LPC21ISP_BAUD) $(LPC21ISP_XTAL)
endif
# Create final output files (.hex, .eep) from ELF output file.
# TODO: handling the .eeprom-section should be redundant
%.hex: %.elf
@echo
@echo $(MSG_FLASH) $@
$(OBJCOPY) -O $(FORMAT) $< $@
# Create extended listing file from ELF output file.
# testing: option -C
%.lss: %.elf
@echo
@echo $(MSG_EXTENDED_LISTING) $@
$(OBJDUMP) -h -S -C $< > $@
# Create a symbol table from ELF output file.
%.sym: %.elf
@echo
@echo $(MSG_SYMBOL_TABLE) $@
$(NM) -n $< > $@
# Link: create ELF output file from object files.
.SECONDARY : $(TARGET).elf
.PRECIOUS : $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM)
%.elf: $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM)
@echo
@echo $(MSG_LINKING) $@
$(CC) $(THUMB) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM) --output $@ $(LDFLAGS)
# $(CPP) $(THUMB) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM) --output $@ $(LDFLAGS)
# Compile: create object files from C source files. ARM/Thumb
$(COBJ) : %.o : %.c
@echo
@echo $(MSG_COMPILING) $<
$(CC) -c $(THUMB) $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@
# Compile: create object files from C source files. ARM-only
$(COBJARM) : %.o : %.c
@echo
@echo $(MSG_COMPILING_ARM) $<
$(CC) -c $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@
# Compile: create object files from C++ source files. ARM/Thumb
$(CPPOBJ) : %.o : %.cpp
@echo
@echo $(MSG_COMPILINGCPP) $<
$(CPP) -c $(THUMB) $(ALL_CFLAGS) $(CPPFLAGS) $< -o $@
# Compile: create object files from C++ source files. ARM-only
$(CPPOBJARM) : %.o : %.cpp
@echo
@echo $(MSG_COMPILINGCPP_ARM) $<
$(CPP) -c $(ALL_CFLAGS) $(CPPFLAGS) $< -o $@
# Compile: create assembler files from C source files. ARM/Thumb
## does not work - TODO - hints welcome
##$(COBJ) : %.s : %.c
## $(CC) $(THUMB) -S $(ALL_CFLAGS) $< -o $@
# Assemble: create object files from assembler source files. ARM/Thumb
$(AOBJ) : %.o : %.S
@echo
@echo $(MSG_ASSEMBLING) $<
$(CC) -c $(THUMB) $(ALL_ASFLAGS) $< -o $@
# Assemble: create object files from assembler source files. ARM-only
$(AOBJARM) : %.o : %.S
@echo
@echo $(MSG_ASSEMBLING_ARM) $<
$(CC) -c $(ALL_ASFLAGS) $< -o $@
# Target: clean project.
clean: begin clean_list finished end
clean_list :
@echo
@echo $(MSG_CLEANING)
$(REMOVE) $(TARGET).hex
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).elf
$(REMOVE) $(TARGET).map
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).a90
$(REMOVE) $(TARGET).sym
$(REMOVE) $(TARGET).lnk
$(REMOVE) $(TARGET).lss
$(REMOVE) $(COBJ)
$(REMOVE) $(CPPOBJ)
$(REMOVE) $(AOBJ)
$(REMOVE) $(COBJARM)
$(REMOVE) $(CPPOBJARM)
$(REMOVE) $(AOBJARM)
$(REMOVE) $(LST)
$(REMOVE) $(SRC:.c=.s)
$(REMOVE) $(SRC:.c=.d)
$(REMOVE) $(SRCARM:.c=.s)
$(REMOVE) $(SRCARM:.c=.d)
$(REMOVE) $(CPPSRC:.cpp=.s)
$(REMOVE) $(CPPSRC:.cpp=.d)
$(REMOVE) $(CPPSRCARM:.cpp=.s)
$(REMOVE) $(CPPSRCARM:.cpp=.d)
$(REMOVE) .dep/*
# Include the dependency files.
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
# Listing of phony targets.
.PHONY : all begin finish end sizebefore sizeafter gccversion \
build elf hex lss sym clean clean_list program
@@ -0,0 +1,220 @@
/*
crt0.S for LPC2xxx
- based on examples from R O Software
- based on examples from newlib-lpc
- based on an example from Anglia Designs
collected and modified by Martin Thomas
*/
.global _etext // -> .data initial values in ROM
.global _data // -> .data area in RAM
.global _edata // end of .data area
.global __bss_start // -> .bss area in RAM
.global __bss_end__ // end of .bss area
.global _stack // top of stack
// Stack Sizes
.set UND_STACK_SIZE, 0x00000004
.set ABT_STACK_SIZE, 0x00000004
.set FIQ_STACK_SIZE, 0x00000004
.set IRQ_STACK_SIZE, 0X00000080
.set SVC_STACK_SIZE, 0x00000004
// Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs
.set MODE_USR, 0x10 // User Mode
.set MODE_FIQ, 0x11 // FIQ Mode
.set MODE_IRQ, 0x12 // IRQ Mode
.set MODE_SVC, 0x13 // Supervisor Mode
.set MODE_ABT, 0x17 // Abort Mode
.set MODE_UND, 0x1B // Undefined Mode
.set MODE_SYS, 0x1F // System Mode
.equ I_BIT, 0x80 // when I bit is set, IRQ is disabled
.equ F_BIT, 0x40 // when F bit is set, FIQ is disabled
.text
.arm
.section .init, "ax"
.code 32
.align 2
.global _boot
.func _boot
_boot:
// Runtime Interrupt Vectors
// -------------------------
Vectors:
b _start // reset - _start
ldr pc,_undf // undefined - _undf
ldr pc,_swi // SWI - _swi
ldr pc,_pabt // program abort - _pabt
ldr pc,_dabt // data abort - _dabt
nop // reserved
ldr pc,[pc,#-0xFF0] // IRQ - read the VIC
ldr pc,_fiq // FIQ - _fiq
#if 0
// Use this group for production
_undf: .word _reset // undefined - _reset
_swi: .word _reset // SWI - _reset
_pabt: .word _reset // program abort - _reset
_dabt: .word _reset // data abort - _reset
_irq: .word _reset // IRQ - _reset
_fiq: .word _reset // FIQ - _reset
#else
// Use this group for development
_undf: .word __undf // undefined
_swi: .word __swi // SWI
_pabt: .word __pabt // program abort
_dabt: .word __dabt // data abort
_irq: .word __irq // IRQ
_fiq: .word __fiq // FIQ
__undf: b . // undefined
__swi: b . // SWI
__pabt: b . // program abort
__dabt: b . // data abort
__irq: b . // IRQ
__fiq: b . // FIQ
#endif
.size _boot, . - _boot
.endfunc
// Setup the operating mode & stack.
// ---------------------------------
.global _start, start, _mainCRTStartup
.func _start
_start:
start:
_mainCRTStartup:
// Initialize Interrupt System
// - Set stack location for each mode
// - Leave in System Mode with Interrupts Disabled
// -----------------------------------------------
ldr r0,=_stack
msr CPSR_c,#MODE_UND|I_BIT|F_BIT // Undefined Instruction Mode
mov sp,r0
sub r0,r0,#UND_STACK_SIZE
msr CPSR_c,#MODE_ABT|I_BIT|F_BIT // Abort Mode
mov sp,r0
sub r0,r0,#ABT_STACK_SIZE
msr CPSR_c,#MODE_FIQ|I_BIT|F_BIT // FIQ Mode
mov sp,r0
sub r0,r0,#FIQ_STACK_SIZE
msr CPSR_c,#MODE_IRQ|I_BIT|F_BIT // IRQ Mode
mov sp,r0
sub r0,r0,#IRQ_STACK_SIZE
msr CPSR_c,#MODE_SVC|I_BIT|F_BIT // Supervisor Mode
mov sp,r0
sub r0,r0,#SVC_STACK_SIZE
msr CPSR_c,#MODE_SYS|I_BIT|F_BIT // System Mode
mov sp,r0
// Copy initialized data to its execution address in RAM
// -----------------------------------------------------
#ifdef ROM_RUN
ldr r1,=_etext // -> ROM data start
ldr r2,=_data // -> data start
ldr r3,=_edata // -> end of data
1: cmp r2,r3 // check if data to move
ldrlo r0,[r1],#4 // copy it
strlo r0,[r2],#4
blo 1b // loop until done
#endif
// Clear .bss
// ----------
mov r0,#0 // get a zero
ldr r1,=__bss_start // -> bss start
ldr r2,=__bss_end__ // -> bss end
2: cmp r1,r2 // check if data to clear
strlo r0,[r1],#4 // clear 4 bytes
blo 2b // loop until done
/*
Call C++ constructors (for objects in "global scope")
ctor loop added by Martin Thomas 4/2005
based on a Anglia Design example-application for ST ARM
*/
LDR r0, =__ctors_start__
LDR r1, =__ctors_end__
ctor_loop:
CMP r0, r1
BEQ ctor_end
LDR r2, [r0], #4
STMFD sp!, {r0-r1}
MOV lr, pc
MOV pc, r2
LDMFD sp!, {r0-r1}
B ctor_loop
ctor_end:
// Call main program: main(0)
// --------------------------
mov r0,#0 // no arguments (argc = 0)
mov r1,r0
mov r2,r0
mov fp,r0 // null frame pointer
mov r7,r0 // null frame pointer for thumb
ldr r10,=main
mov lr,pc
/* Enter the C code, use BX instruction so as to never return */
/* use BLX (?) main if you want to use c++ destructors below */
bx r10 // enter main()
/* "global object"-dtors are never called and it should not be
needed since there is no OS to exit to. */
/* Call destructors */
# LDR r0, =__dtors_start__
# LDR r1, =__dtors_end__
dtor_loop:
# CMP r0, r1
# BEQ dtor_end
# LDR r2, [r0], #4
# STMFD sp!, {r0-r1}
# MOV lr, pc
# MOV pc, r2
# LDMFD sp!, {r0-r1}
# B dtor_loop
dtor_end:
.size _start, . - _start
.endfunc
.global _reset, reset, exit, abort
.func _reset
_reset:
reset:
exit:
abort:
#if 0
// Disable interrupts, then force a hardware reset by driving P23 low
// -------------------------------------------------------------------
mrs r0,cpsr // get PSR
orr r0,r0,#I_BIT|F_BIT // disable IRQ and FIQ
msr cpsr,r0 // set up status register
ldr r1,=(PS_BASE) // PS Base Address
ldr r0,=(PS_PIO) // PIO Module
str r0,[r1,#PS_PCER_OFF] // enable its clock
ldr r1,=(PIO_BASE) // PIO Base Address
ldr r0,=(1<<23) // P23
str r0,[r1,#PIO_PER_OFF] // make sure pin is contolled by PIO
str r0,[r1,#PIO_CODR_OFF] // set the pin low
str r0,[r1,#PIO_OER_OFF] // make it an output
#endif
b . // loop until reset
.size _reset, . - _reset
.endfunc
.end
@@ -0,0 +1,150 @@
/* Copyright (c) 2002, Marek Michalkiewicz
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
/* $Id: inttypes.h,v 1.1 2005/11/16 17:33:36 lennartyseboodt Exp $ */
/*
inttypes.h
Contributors:
Created by Marek Michalkiewicz <marekm@linux.org.pl>
*/
#ifndef __INTTYPES_H_
#define __INTTYPES_H_
/** \defgroup avr_inttypes Integer Types
\code #include <inttypes.h> \endcode
Use [u]intN_t if you need exactly N bits.
Since these typedefs are mandated by the C99 standard, they are preferred
over rolling your own typedefs.
\note If avr-gcc's \c -mint8 option is used, no 32-bit types will be
available.
\todo There is a pending patch that may go into gcc to change the
behaviour of the -mint8 option. The current (2003-09-17) situation for
-mint8 is sizeof(int) == 1, sizeof(long) == 2 and sizeof(long long) == 8.
Note the absence of a 4-byte, 32-bit type. The patch proposes to change
sozeof(long long) to be 4 bytes (32 bits). When and if the patch is
included in gcc, we will need to change avr-libc accordingly. */
#if __INT_MAX__ == 127
# define __USING_MINT8 1
#endif
/** \name 8-bit types. */
/*@{*/
/** \ingroup avr_inttypes
8-bit signed type. */
typedef signed char int8_t;
/** \ingroup avr_inttypes
8-bit unsigned type. */
typedef unsigned char uint8_t;
#if __USING_MINT8
typedef long int16_t;
typedef unsigned long uint16_t;
#else /* no -mint8 */
/*@}*/
/** \name 16-bit types. */
/*@{*/
/** \ingroup avr_inttypes
16-bit signed type. */
typedef int int16_t;
/** \ingroup avr_inttypes
16-bit unsigned type. */
typedef unsigned int uint16_t;
/*@}*/
/** \name 32-bit types. */
/*@{*/
/** \ingroup avr_inttypes
32-bit signed type. */
typedef long int32_t;
/** \ingroup avr_inttypes
32-bit unsigned type. */
typedef unsigned long uint32_t;
#endif
/*@}*/
/** \name 64-bit types. */
/*@{*/
/** \ingroup avr_inttypes
64-bit signed type. */
typedef long long int64_t;
/** \ingroup avr_inttypes
64-bit unsigned type. */
typedef unsigned long long uint64_t;
/*@}*/
/** \name Pointer types.
These allow you to declare variables of the same size as a pointer. */
/*@{*/
/** \ingroup avr_inttypes
Signed pointer compatible type. */
typedef int16_t intptr_t;
/** \ingroup avr_inttypes
Unsigned pointer compatible type. */
typedef uint16_t uintptr_t;
/*@}*/
#endif
@@ -0,0 +1 @@
<Project name="lpc2138_efsl_demo2"><File path="crt0.S"></File><File path="inttypes.h"></File><File path="lpc_config.h"></File><File path="LPC2138-ROM.ld"></File><File path="LPC213x.h"></File><File path="lpcUART.h"></File><File path="main.c"></File><File path="Makefile"></File><File path="uart.c"></File><File path="uart.h"></File></Project>
@@ -0,0 +1,86 @@
/******************************************************************************
*
* $RCSfile: lpcUART.h,v $
* $Revision: 1.1 $
*
* Header file for Philips LPC ARM Processors.
* Copyright 2004 R O SoftWare
*
* No guarantees, warrantees, or promises, implied or otherwise.
* May be used for hobby or commercial purposes provided copyright
* notice remains intact.
*
* reduced to learn what is needed for "minimal" uart0-operation
*****************************************************************************/
#ifndef INC_LPC_UART_H
#define INC_LPC_UART_H
///////////////////////////////////////////////////////////////////////////////
// UART defines
// Interrupt Enable Register bit definitions
#define UIER_ERBFI (1 << 0) // Enable Receive Data Available Interrupt
#define UIER_ETBEI (1 << 1) // Enable Transmit Holding Register Empty Interrupt
#define UIER_ELSI (1 << 2) // Enable Receive Line Status Interrupt
#define UIER_EDSSI (1 << 3) // Enable MODEM Status Interrupt
// Interrupt ID Register bit definitions
#define UIIR_NO_INT (1 << 0) // NO INTERRUPTS PENDING
#define UIIR_MS_INT (0 << 1) // MODEM Status
#define UIIR_THRE_INT (1 << 1) // Transmit Holding Register Empty
#define UIIR_RDA_INT (2 << 1) // Receive Data Available
#define UIIR_RLS_INT (3 << 1) // Receive Line Status
#define UIIR_CTI_INT (6 << 1) // Character Timeout Indicator
#define UIIR_ID_MASK 0x0E
// FIFO Control Register bit definitions
#define UFCR_FIFO_ENABLE (1 << 0) // FIFO Enable
#define UFCR_RX_FIFO_RESET (1 << 1) // Reset Receive FIFO
#define UFCR_TX_FIFO_RESET (1 << 2) // Reset Transmit FIFO
#define UFCR_FIFO_TRIG1 (0 << 6) // Trigger @ 1 character in FIFO
#define UFCR_FIFO_TRIG4 (1 << 6) // Trigger @ 4 characters in FIFO
#define UFCR_FIFO_TRIG8 (2 << 6) // Trigger @ 8 characters in FIFO
#define UFCR_FIFO_TRIG14 (3 << 6) // Trigger @ 14 characters in FIFO
// Line Control Register bit definitions
#define ULCR_CHAR_5 (0 << 0) // 5-bit character length
#define ULCR_CHAR_6 (1 << 0) // 6-bit character length
#define ULCR_CHAR_7 (2 << 0) // 7-bit character length
#define ULCR_CHAR_8 (3 << 0) // 8-bit character length
#define ULCR_STOP_1 (0 << 2) // 1 stop bit
#define ULCR_STOP_2 (1 << 2) // 2 stop bits
#define ULCR_PAR_NO (0 << 3) // No Parity
#define ULCR_PAR_ODD (1 << 3) // Odd Parity
#define ULCR_PAR_EVEN (3 << 3) // Even Parity
#define ULCR_PAR_MARK (5 << 3) // MARK "1" Parity
#define ULCR_PAR_SPACE (7 << 3) // SPACE "0" Paruty
#define ULCR_BREAK_ENABLE (1 << 6) // Output BREAK line condition
#define ULCR_DLAB_ENABLE (1 << 7) // Enable Divisor Latch Access
// Modem Control Register bit definitions
#define UMCR_DTR (1 << 0) // Data Terminal Ready
#define UMCR_RTS (1 << 1) // Request To Send
#define UMCR_LB (1 << 4) // Loopback
// Line Status Register bit definitions
#define ULSR_RDR (1 << 0) // Receive Data Ready
#define ULSR_OE (1 << 1) // Overrun Error
#define ULSR_PE (1 << 2) // Parity Error
#define ULSR_FE (1 << 3) // Framing Error
#define ULSR_BI (1 << 4) // Break Interrupt
#define ULSR_THRE (1 << 5) // Transmit Holding Register Empty
#define ULSR_TEMT (1 << 6) // Transmitter Empty
#define ULSR_RXFE (1 << 7) // Error in Receive FIFO
#define ULSR_ERR_MASK 0x1E
// Modem Status Register bit definitions
#define UMSR_DCTS (1 << 0) // Delta Clear To Send
#define UMSR_DDSR (1 << 1) // Delta Data Set Ready
#define UMSR_TERI (1 << 2) // Trailing Edge Ring Indicator
#define UMSR_DDCD (1 << 3) // Delta Data Carrier Detect
#define UMSR_CTS (1 << 4) // Clear To Send
#define UMSR_DSR (1 << 5) // Data Set Ready
#define UMSR_RI (1 << 6) // Ring Indicator
#define UMSR_DCD (1 << 7) // Data Carrier Detect
#endif
@@ -0,0 +1,52 @@
/* System Config */
/*
PLL
- Main clock F_OSC=12,0MHz @ Keil MCB2130) [limits: 10 MHz to 25 MHz]
- System should run at max. Frequency (60MHz) [limit: max 60 MHz]
- Choose multiplier M=5
so cclk = M * F_OSC= 5 * 12000000 = 60000000 Hz
- MSEL-Bit in PLLCFG (bits 0-4) MSEL = M-1
- F_CCO must be inbetween the limits 156 MHz to 320 MHz
datasheet: F_CCO = F_OSC * M * 2 * P
- choose devider P=2 => F_CCO = 12000000Hz * 5 * 2 * 2
= 240 MHz
- PSEL0 (Bit5 in PLLCFG) = 1, PSEL1 (Bit6) = 0 (0b01)
*/
#define FOSC 12000000
#define PLL_M 5
#define MSEL (PLL_M-1)
#define PSEL0 5
#define PSEL1 6
#define PLLE 0
#define PLLC 1
#define PLOCK 10
#define PLL_FEED1 0xAA
#define PLL_FEED2 0x55
/*
MAM(Memory Accelerator Module)
- choosen: MAM fully enabled = MAM-Mode 2
- System-Clock cclk=60MHz -> 3 CCLKs are proposed as fetch timing
*/
#define MAM_MODE 2
#define MAM_FETCH 3
/*
VPB (V... Pheriphal Bus)
- choosen: VPB should run at full speed -> devider VPBDIV=1
=> pclk = cclk = 60MHz
*/
#define VPBDIV_VAL 1
/*
SCB
*/
#define MEMMAP_BOOT_LOADER_MODE 0 // Interrupt vectors are re-mapped to Boot Block.
#define MEMMAP_USER_FLASH_MODE (1<<0) // Interrupt vectors are not re-mapped and reside in Flash.
#define MEMMAP_USER_RAM_MODE (1<<1) // Interrupt vectors are re-mapped to Static RAM.
@@ -0,0 +1,189 @@
/******************************************************************************
efsl Demo-Application for Philips LPC2138 ARM7TDMI-S
Copyright (c) 2005
Martin Thomas, Kaiserslautern, Germany <mthomas@rhrk.uni-kl.de>
*****************************************************************************/
#include <string.h>
#include "LPC213x.h"
#include "lpc_config.h"
#include "uart.h"
#include "efs.h"
#include "ls.h"
#include "mkfs.h"
#include "interfaces/lpc2000_dbg_printf.h"
#define rprintf lpc2000_debug_printf
#define BAUD 115200
#define BIT(x) ((unsigned long)1<<x)
// 1st LED on Keil MCB2130
#define LED1PIN 16
#define LED1BIT BIT(LED1PIN)
#define LEDDIR IODIR1
#define LEDSET IOSET1
#define LEDCLR IOCLR1
static char LogFileName[] = "logdat9.txt";
static void systemInit(void)
{
// --- enable and connect the PLL (Phase Locked Loop) ---
// a. set multiplier and divider
PLLCFG = MSEL | (1<<PSEL1) | (0<<PSEL0);
// b. enable PLL
PLLCON = (1<<PLLE);
// c. feed sequence
PLLFEED = PLL_FEED1;
PLLFEED = PLL_FEED2;
// d. wait for PLL lock (PLOCK bit is set if locked)
while (!(PLLSTAT & (1<<PLOCK)));
// e. connect (and enable) PLL
PLLCON = (1<<PLLE) | (1<<PLLC);
// f. feed sequence
PLLFEED = PLL_FEED1;
PLLFEED = PLL_FEED2;
// --- setup and enable the MAM (Memory Accelerator Module) ---
// a. start change by turning of the MAM (redundant)
MAMCR = 0;
// b. set MAM-Fetch cycle to 3 cclk as recommended for >40MHz
MAMTIM = MAM_FETCH;
// c. enable MAM
MAMCR = MAM_MODE;
// --- set VPB speed ---
VPBDIV = VPBDIV_VAL;
// --- map INT-vector ---
#if defined(RAM_RUN)
MEMMAP = MEMMAP_USER_RAM_MODE;
#elif defined(ROM_RUN)
MEMMAP = MEMMAP_USER_FLASH_MODE;
#else
#error RUN_MODE not defined!
#endif
}
static void gpioInit(void)
{
LEDSET = BIT(LED1PIN); // set Bit = LED off (active low)
LEDDIR |= BIT(LED1PIN); // define LED-Pin as output
}
static void ledToggle(void)
{
static unsigned char state=0;
state = !state;
if (state) LEDCLR = BIT(LED1PIN); // set Bit = LED on
else LEDSET = BIT(LED1PIN); // set Bit = LED off (active low)
}
#if 0
static void hang(void)
{
while(1);
}
#endif
EmbeddedFileSystem efs;
EmbeddedFile filer, filew;
DirList list;
unsigned short e;
unsigned char buf[513];
int main(void)
{
int ch;
int8_t res;
systemInit();
gpioInit();
uart1Init(UART_BAUD(BAUD), UART_8N1, UART_FIFO_8); // setup the UART
uart1Puts("\r\nMMC/SD Card Filesystem Test (P:LPC2138 L:EFSL)\r\n");
uart1Puts("efsl LPC2000-port and this Demo-Application\r\n");
uart1Puts("done by Martin Thomas, Kaiserslautern, Germany\r\n");
/* init efsl debug-output */
lpc2000_debug_devopen(uart1Putch);
ledToggle();
rprintf("CARD init...");
if ( ( res = efs_init( &efs, 0 ) ) != 0 ) {
rprintf("failed with %i\n",res);
}
else {
rprintf("ok\n");
rprintf("Directory of 'root':\n");
ls_openDir( &list, &(efs.myFs) , "/");
while ( ls_getNext( &list ) == 0 ) {
list.currentEntry.FileName[LIST_MAXLENFILENAME-1] = '\0';
rprintf( "%s ( %li bytes )\n" ,
list.currentEntry.FileName,
list.currentEntry.FileSize ) ;
}
if ( file_fopen( &filer, &efs.myFs , LogFileName , 'r' ) == 0 ) {
rprintf("File %s open. Content:\n", LogFileName);
while ( ( e = file_read( &filer, 512, buf ) ) != 0 ) {
buf[e]='\0';
uart1Puts((char*)buf);
}
rprintf("\n");
file_fclose( &filer );
}
if ( file_fopen( &filew, &efs.myFs , LogFileName , 'a' ) == 0 ) {
rprintf("File %s open for append. Appending...", LogFileName);
strcpy((char*)buf, "Martin hat's angehaengt\r\n");
if ( file_write( &filew, strlen((char*)buf), buf ) == strlen((char*)buf) ) {
rprintf("ok\n");
}
else {
rprintf("fail\n");
}
file_fclose( &filew );
}
if ( file_fopen( &filer, &efs.myFs , LogFileName , 'r' ) == 0 ) {
rprintf("File %s open. Content:\n", LogFileName);
while ( ( e = file_read( &filer, 512, buf ) ) != 0 ) {
buf[e]='\0';
uart1Puts((char*)buf);
}
rprintf("\n");
file_fclose( &filer );
}
fs_umount( &efs.myFs ) ;
}
while(1) {
if ((ch = uart1Getch()) >= 0) {
uart1Puts("You pressed : ");
uart1Putch(ch);
uart1Puts("\r\n");
if ( ch == 'M' ) {
rprintf("Creating FS\n");
mkfs_makevfat(&efs.myPart);
}
ledToggle();
}
}
return 0; /* never reached */
}
@@ -0,0 +1,186 @@
/******************************************************************************
*
* $RCSfile: uart.c,v $
* $Revision: 1.1 $
*
* This module provides interface routines to the LPC ARM UARTs.
* Copyright 2004, R O SoftWare
* No guarantees, warrantees, or promises, implied or otherwise.
* May be used for hobby or commercial purposes provided copyright
* notice remains intact.
*
* reduced to see what has to be done for minimum UART-support by mthomas
*****************************************************************************/
// #warning "this is a reduced version of the R O Software code"
#include "LPC213x.h"
#include "uart.h"
/* on LPC210x: UART0 TX-Pin=P0.2, RX-Pin=P0.1
PINSEL0 has to be set to "UART-Function" = Function "01"
for Pin 0.0 and 0.1 */
#define PINSEL_BITPIN0 0
#define PINSEL_BITPIN1 2
#define PINSEL_BITPIN8 16
#define PINSEL_BITPIN9 18
#define PINSEL_FIRST_ALT_FUNC 1
#define PINSEL_SECOND_ALT_FUNC 2
#define PINSEL_THIRD_ALT_FUNC 3
// Values of Bits 0-3 in PINSEL to activate UART0
#define UART0_PINSEL ((PINSEL_FIRST_ALT_FUNC<<PINSEL_BITPIN0)|(PINSEL_FIRST_ALT_FUNC<<PINSEL_BITPIN1))
// Mask of Bits 0-4
#define UART0_PINMASK (0x0000000F) /* PINSEL0 Mask for UART0 */
// Values of Bits 16-19 in PINSEL to activate UART1
#define UART1_PINSEL ((PINSEL_FIRST_ALT_FUNC<<PINSEL_BITPIN8)|(PINSEL_FIRST_ALT_FUNC<<PINSEL_BITPIN9))
// Mask of Bits 16-19
#define UART1_PINMASK (0x000F0000) /* PINSEL0 Mask for UART1 */
// U0_LCR devisor latch bit
#define UART0_LCR_DLAB 7
// U1_LCR devisor latch bit
#define UART1_LCR_DLAB 7
/* baudrate divisor - use UART_BAUD macro
* mode - see typical modes (uart.h)
* fmode - see typical fmodes (uart.h)
* NOTE: uart0Init(UART_BAUD(9600), UART_8N1, UART_FIFO_8);
*/
void uart0Init(uint16_t baud, uint8_t mode, uint8_t fmode)
{
// setup Pin Function Select Register (Pin Connect Block)
// make sure old values of Bits 0-4 are masked out and
// set them according to UART0-Pin-Selection
PINSEL0 = (PINSEL0 & ~UART0_PINMASK) | UART0_PINSEL;
U0IER = 0x00; // disable all interrupts
U0IIR = 0x00; // clear interrupt ID register
U0LSR = 0x00; // clear line status register
// set the baudrate - DLAB must be set to access DLL/DLM
U0LCR = (1<<UART0_LCR_DLAB); // set divisor latches (DLAB)
U0DLL = (uint8_t)baud; // set for baud low byte
U0DLM = (uint8_t)(baud >> 8); // set for baud high byte
// set the number of characters and other
// user specified operating parameters
// Databits, Parity, Stopbits - Settings in Line Control Register
U0LCR = (mode & ~(1<<UART0_LCR_DLAB)); // clear DLAB "on-the-fly"
// setup FIFO Control Register (fifo-enabled + xx trig)
U0FCR = fmode;
}
int uart0Putch(int ch)
{
while (!(U0LSR & ULSR_THRE)) // wait for TX buffer to empty
continue; // also either WDOG() or swap()
U0THR = (uint8_t)ch; // put char to Transmit Holding Register
return (uint8_t)ch; // return char ("stdio-compatible"?)
}
const char *uart0Puts(const char *string)
{
char ch;
while ((ch = *string)) {
if (uart0Putch(ch)<0) break;
string++;
}
return string;
}
int uart0TxEmpty(void)
{
return (U0LSR & (ULSR_THRE | ULSR_TEMT)) == (ULSR_THRE | ULSR_TEMT);
}
void uart0TxFlush(void)
{
U0FCR |= UFCR_TX_FIFO_RESET; // clear the TX fifo
}
/* Returns: character on success, -1 if no character is available */
int uart0Getch(void)
{
if (U0LSR & ULSR_RDR) // check if character is available
return U0RBR; // return character
return -1;
}
/* baudrate divisor - use UART_BAUD macro
* mode - see typical modes (uart.h)
* fmode - see typical fmodes (uart.h)
* NOTE: uart0Init(UART_BAUD(9600), UART_8N1, UART_FIFO_8);
*/
void uart1Init(uint16_t baud, uint8_t mode, uint8_t fmode)
{
// setup Pin Function Select Register (Pin Connect Block)
// make sure old values of Bits 0-4 are masked out and
// set them according to UART0-Pin-Selection
PINSEL0 = (PINSEL0 & ~UART1_PINMASK) | UART1_PINSEL;
U1IER = 0x00; // disable all interrupts
U1IIR = 0x00; // clear interrupt ID register
U1LSR = 0x00; // clear line status register
// set the baudrate - DLAB must be set to access DLL/DLM
U1LCR = (1<<UART1_LCR_DLAB); // set divisor latches (DLAB)
U1DLL = (uint8_t)baud; // set for baud low byte
U1DLM = (uint8_t)(baud >> 8); // set for baud high byte
// set the number of characters and other
// user specified operating parameters
// Databits, Parity, Stopbits - Settings in Line Control Register
U1LCR = (mode & ~(1<<UART1_LCR_DLAB)); // clear DLAB "on-the-fly"
// setup FIFO Control Register (fifo-enabled + xx trig)
U1FCR = fmode;
}
int uart1Putch(int ch)
{
while (!(U1LSR & ULSR_THRE)) // wait for TX buffer to empty
continue; // also either WDOG() or swap()
U1THR = (uint8_t)ch; // put char to Transmit Holding Register
return (uint8_t)ch; // return char ("stdio-compatible"?)
}
const char *uart1Puts(const char *string)
{
char ch;
while ((ch = *string)) {
if (uart1Putch(ch)<0) break;
string++;
}
return string;
}
int uart1TxEmpty(void)
{
return (U1LSR & (ULSR_THRE | ULSR_TEMT)) == (ULSR_THRE | ULSR_TEMT);
}
void uart1TxFlush(void)
{
U1FCR |= UFCR_TX_FIFO_RESET; // clear the TX fifo
}
/* Returns: character on success, -1 if no character is available */
int uart1Getch(void)
{
if (U1LSR & ULSR_RDR) // check if character is available
return U1RBR; // return character
return -1;
}
@@ -0,0 +1,77 @@
/******************************************************************************
* based on software from:
* Copyright 2004, R O SoftWare
* No guarantees, warrantees, or promises, implied or otherwise.
* May be used for hobby or commercial purposes provided copyright
* notice remains intact.
*
* reduced to learn what has to be done to enable and use UART0
*****************************************************************************/
#ifndef INC_UART_H
#define INC_UART_H
#include "inttypes.h"
#include "LPC213x.h"
#include "lpcUART.h"
#include "lpc_config.h"
///////////////////////////////////////////////////////////////////////////////
// use the following macros to determine the 'baud' parameter values
// for uart0Init() and uart1Init()
// CAUTION - 'baud' SHOULD ALWAYS BE A CONSTANT or
// a lot of code will be generated.
// Baud-Rate is calculated based on pclk (VPB-clock)
// the devisor must be 16 times the desired baudrate
#define UART_BAUD(baud) (uint16_t)(((FOSC*PLL_M/VPBDIV_VAL) / ((baud) * 16.0)) + 0.5)
///////////////////////////////////////////////////////////////////////////////
// Definitions for typical UART 'baud' settings
#define B1200 UART_BAUD(1200)
#define B9600 UART_BAUD(9600)
#define B19200 UART_BAUD(19200)
#define B38400 UART_BAUD(38400)
#define B57600 UART_BAUD(57600)
#define B115200 UART_BAUD(115200)
///////////////////////////////////////////////////////////////////////////////
// Definitions for typical UART 'mode' settings
#define UART_8N1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_NO + ULCR_STOP_1)
#define UART_7N1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_NO + ULCR_STOP_1)
#define UART_8N2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_NO + ULCR_STOP_2)
#define UART_7N2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_NO + ULCR_STOP_2)
#define UART_8E1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_1)
#define UART_7E1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_1)
#define UART_8E2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_2)
#define UART_7E2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_2)
#define UART_8O1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_ODD + ULCR_STOP_1)
#define UART_7O1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_ODD + ULCR_STOP_1)
#define UART_8O2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_ODD + ULCR_STOP_2)
#define UART_7O2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_ODD + ULCR_STOP_2)
///////////////////////////////////////////////////////////////////////////////
// Definitions for typical UART 'fmode' settings
#define UART_FIFO_OFF (0x00)
#define UART_FIFO_1 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG1)
#define UART_FIFO_4 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG4)
#define UART_FIFO_8 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG8)
#define UART_FIFO_14 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG14)
void uart0Init(uint16_t baud, uint8_t mode, uint8_t fmode);
int uart0Putch(int ch);
uint16_t uart0Space(void);
const char *uart0Puts(const char *string);
int uart0TxEmpty(void);
void uart0TxFlush(void);
int uart0Getch(void);
void uart1Init(uint16_t baud, uint8_t mode, uint8_t fmode);
int uart1Putch(int ch);
uint16_t uart1Space(void);
const char *uart1Puts(const char *string);
int uart1TxEmpty(void);
void uart1TxFlush(void);
int uart1Getch(void);
#endif