[sky9x] Revert to last version where massstorage was ok for all SDs!

[stock] Flash saving
[stock] Voice mod port from er9x
This commit is contained in:
bsongis
2012-09-19 22:15:20 +00:00
parent 9a7976cf6e
commit 3a9c375908
286 changed files with 79393 additions and 7903 deletions
+13 -16
View File
@@ -428,12 +428,11 @@ endif
RUN_FROM_FLASH = 1
ifeq ($(PCB), X9D)
# V4 ARM, so ...
# X9D, so ...
OPT = 2
CPPDEFS += -DPCBX9D -DPCBARM -DAUDIO -DHAPTIC -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1
EXTRAINCDIRS += ersky9x ersky9x/libraries ersky9x/libraries/board ersky9x/libraries/drivers CoOS/kernel CoOS/portable
EXTRAINCDIRS += ersky9x ersky9x/libraries ersky9x/libraries/drivers CoOS/kernel CoOS/portable
BOARDSRC = board_ersky9x.cpp
SRC += ersky9x/libraries/usb/device/massstorage/SBCMethods.c ersky9x/libraries/memories/mci_cmd_pdc.c
SRC += ersky9x/core_cm3.c ersky9x/board_lowlevel.c ersky9x/crt.c ersky9x/vectors_sam3s.c
SRC += CoOS/kernel/core.c CoOS/kernel/hook.c CoOS/kernel/task.c CoOS/kernel/event.c CoOS/kernel/time.c CoOS/kernel/timer.c CoOS/kernel/flag.c CoOS/kernel/mutex.c CoOS/kernel/serviceReq.c CoOS/portable/GCC/port.c CoOS/portable/arch.c
SRC += ersky9x/libraries/usb/device/core/USBD_UDP.c ersky9x/libraries/drivers/pmc/pmc.c ersky9x/libraries/drivers/pio/pio.c ersky9x/libraries/drivers/pio/pio_it.c ersky9x/libraries/usb/common/core/USBEndpointDescriptor.c ersky9x/libraries/usb/common/core/USBGenericRequest.c ersky9x/libraries/usb/device/massstorage/MSDDriver.c ersky9x/libraries/usb/device/core/USBDDriver.c ersky9x/libraries/usb/common/core/USBFeatureRequest.c ersky9x/libraries/usb/device/massstorage/MSDDStateMachine.c
@@ -441,10 +440,11 @@ ifeq ($(PCB), X9D)
SRC += ersky9x/libraries/usb/device/core/USBDCallbacks_Resumed.c ersky9x/libraries/usb/device/core/USBDCallbacks_Reset.c ersky9x/libraries/usb/device/core/USBDCallbacks_Suspended.c ersky9x/libraries/usb/device/core/USBDCallbacks_Initialized.c ersky9x/libraries/usb/device/core/USBDDriverCb_IfSettingChanged.c # TODO remove them
SRC += ersky9x/libraries/usb/device/massstorage/MSDLun.c ersky9x/libraries/usb/device/massstorage/MSDDriverDescriptors.c
SRC += ersky9x/syscalls.c
SRC += ersky9x/libraries/usb/device/massstorage/SBCMethods.c ersky9x/libraries/memories/MEDSdcard.c
EEPROMSRC = eeprom_arm.cpp
PULSESSRC = pulses_arm.cpp
CPPSRC += ersky9x/audio.cpp haptic.cpp
CPPSRC += ersky9x/sound_driver.cpp ersky9x/haptic_driver.cpp ersky9x/sdcard.cpp
CPPSRC += ersky9x/sound_driver.cpp ersky9x/haptic_driver.cpp ersky9x/sdcard_driver.cpp
ifeq ($(SDCARD), YES)
SRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c ersky9x/diskio.c
@@ -463,19 +463,11 @@ ifeq ($(PCB), X9D)
endif
ifeq ($(PCB), ARM)
# Sky9x, so ...
# ARM, so ...
OPT = 2
CPPDEFS += -DPCBARM -DAUDIO -DHAPTIC -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1
EXTRAINCDIRS += ersky9x ersky9x/libraries ersky9x/libraries/board ersky9x/libraries/drivers CoOS/kernel CoOS/portable
BOARDSRC = board_ersky9x.cpp
ifeq ($(SDCARD), YES)
SRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c ersky9x/diskio.c
CPPDEFS += -DVOICE
endif
SRC += ersky9x/libraries/usb/device/massstorage/SBCMethods.c ersky9x/libraries/memories/Media.c ersky9x/libraries/memories/MEDSdmmc.c ersky9x/libraries/memories/mci_cmd_pdc.c
SRC += ersky9x/libraries/memories/sdmmc.c ersky9x/libraries/drivers/hsmci/hsmci_pdc.c
EXTRAINCDIRS += ersky9x ersky9x/libraries ersky9x/libraries/drivers CoOS/kernel CoOS/portable
BOARDSRC = board_ersky9x.cpp
SRC += ersky9x/core_cm3.c ersky9x/board_lowlevel.c ersky9x/crt.c ersky9x/vectors_sam3s.c
SRC += CoOS/kernel/core.c CoOS/kernel/hook.c CoOS/kernel/task.c CoOS/kernel/event.c CoOS/kernel/time.c CoOS/kernel/timer.c CoOS/kernel/flag.c CoOS/kernel/mutex.c CoOS/kernel/serviceReq.c CoOS/portable/GCC/port.c CoOS/portable/arch.c
SRC += ersky9x/libraries/usb/device/core/USBD_UDP.c ersky9x/libraries/drivers/pmc/pmc.c ersky9x/libraries/drivers/pio/pio.c ersky9x/libraries/drivers/pio/pio_it.c ersky9x/libraries/usb/common/core/USBEndpointDescriptor.c ersky9x/libraries/usb/common/core/USBGenericRequest.c ersky9x/libraries/usb/device/massstorage/MSDDriver.c ersky9x/libraries/usb/device/core/USBDDriver.c ersky9x/libraries/usb/common/core/USBFeatureRequest.c ersky9x/libraries/usb/device/massstorage/MSDDStateMachine.c
@@ -483,11 +475,16 @@ ifeq ($(PCB), ARM)
SRC += ersky9x/libraries/usb/device/core/USBDCallbacks_Resumed.c ersky9x/libraries/usb/device/core/USBDCallbacks_Reset.c ersky9x/libraries/usb/device/core/USBDCallbacks_Suspended.c ersky9x/libraries/usb/device/core/USBDCallbacks_Initialized.c ersky9x/libraries/usb/device/core/USBDDriverCb_IfSettingChanged.c # TODO remove them
SRC += ersky9x/libraries/usb/device/massstorage/MSDLun.c ersky9x/libraries/usb/device/massstorage/MSDDriverDescriptors.c
SRC += ersky9x/syscalls.c
SRC += ersky9x/libraries/usb/device/massstorage/SBCMethods.c ersky9x/libraries/memories/MEDSdcard.c
EEPROMSRC = eeprom_arm.cpp
PULSESSRC = pulses_arm.cpp
CPPSRC += ersky9x/audio.cpp haptic.cpp
CPPSRC += ersky9x/sound_driver.cpp ersky9x/haptic_driver.cpp ersky9x/sdcard.cpp
CPPSRC += ersky9x/sound_driver.cpp ersky9x/haptic_driver.cpp ersky9x/sdcard_driver.cpp
ifeq ($(SDCARD), YES)
SRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c ersky9x/diskio.c
CPPDEFS += -DVOICE
endif
ifeq ($(BLUETOOTH), YES)
MODS:=${MODS}S
+3 -26
View File
@@ -32,6 +32,7 @@
*/
#include "open9x.h"
#include "ersky9x/board.h"
uint32_t Master_frequency ;
volatile uint32_t Tenms ;
@@ -799,6 +800,8 @@ void board_init()
init_rotary_encoder();
init_SDcard();
}
#endif
@@ -1228,29 +1231,3 @@ uint16_t getCurrent()
return (current_scale * Current) / 8192;
}
#endif
// CooCox global variables
OS_TID mixerTaskId;
OS_STK mixerStack[MIXER_STACK_SIZE];
OS_TID menusTaskId;
OS_STK menusStack[MENUS_STACK_SIZE];
OS_TID audioTaskId;
OS_STK audioStack[AUDIO_STACK_SIZE];
#if defined(BLUETOOTH)
OS_TID btTaskId;
OS_STK btStack[BT_STACK_SIZE];
#endif
#if defined(DEBUG)
OS_TID debugTaskId;
OS_STK debugStack[DEBUG_STACK_SIZE];
#endif
OS_TCID audioTimer;
OS_FlagID audioFlag;
OS_MutexID audioMutex;
OS_MutexID mixerMutex;
+7 -92
View File
@@ -35,35 +35,7 @@
#define board_ersky9x_h
#include <stdio.h>
#if !defined(SIMU)
#ifdef __cplusplus
extern "C" {
#endif
#include <CoOS.h>
#ifdef __cplusplus
}
#endif
#else
#define OS_MutexID int
#define OS_FlagID int
#define OS_TID int
#define OS_TCID int
#define OS_STK char
#define CoSetFlag(...)
#define CoClearFlag(...)
#define CoSetTmrCnt(...)
#define CoEnterISR(...)
#define CoExitISR(...)
#define CoStartTmr(...)
#define CoWaitForSingleFlag(...) 0
#define CoEnterMutexSection(...)
#define CoLeaveMutexSection(...)
#define CoTickDelay(...)
#define CoCreateFlag(...) 0
#endif
#include "ersky9x/libraries/board/board.h"
#include "ersky9x/board.h"
#include "ersky9x/sound_driver.h"
#include "ersky9x/haptic_driver.h"
#include "ersky9x/debug.h"
@@ -72,6 +44,12 @@ extern "C" {
#include "ersky9x/bluetooth.h"
#endif
extern "C" {
extern void init_SDcard();
extern void sdInit();
extern void sdPoll10mS();
}
#define PIN_ENABLE 0x001
#define PIN_PERIPHERAL 0x000
#define PIN_INPUT 0x002
@@ -111,69 +89,6 @@ extern uint32_t read_keys();
#define usbPlugged() (PIOC->PIO_PDSR & PIO_PC25)
// CooCox global variables
#define MIXER_PRIO 5
#define MENUS_PRIO 10
#define AUDIO_PRIO 7
#define BT_PRIO 15
#define DEBUG_PRIO 10
#define MIXER_STACK_SIZE 500
#define MENUS_STACK_SIZE 2000
#define AUDIO_STACK_SIZE 500
#define BT_STACK_SIZE 500
#define DEBUG_STACK_SIZE 500
extern OS_MutexID mixerMutex;
extern OS_TID mixerTaskId;
extern OS_TID menusTaskId;
extern OS_TID audioTaskId;
#if defined(BLUETOOTH)
extern OS_TID btTaskId;
#endif
#if defined(DEBUG)
extern OS_TID debugTaskId;
#endif
extern OS_TCID audioTimer;
extern OS_FlagID audioFlag;
extern OS_MutexID audioMutex;
extern OS_MutexID mixerMutex;
extern uint32_t Master_frequency ;
struct t_serial_tx
{
uint8_t *buffer ;
uint16_t size ;
volatile uint16_t ready ;
};
#define SD_STATE_ERROR -1
#define SD_STATE_STARTUP 0
#define SD_STATE_CONNECTED 1
#define SD_STATE_MOUNTED 3
extern volatile int8_t sdState;
#define CardIsConnected() ( (PIOB->PIO_PDSR & PIO_PB7) == 0 )
#define CardIsMounted() (CardIsConnected() && sdState==SD_STATE_MOUNTED)
#include "ersky9x/debug.h"
#ifdef SIMU
#define CONVERT_PTR(x) ((uint32_t)(uint64_t)(x))
#else
#include "core_cm3.h"
#include "memories/sdmmc.h"
#define CONVERT_PTR(x) ((uint32_t)(x))
#endif
#if defined(REVB)
extern uint16_t Current_analogue;
extern uint16_t Current_max;
+2 -2
View File
@@ -935,7 +935,7 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc)
DIR archiveFolder;
UINT written;
if (!CardIsMounted()) {
if (!sd_card_mounted()) {
return STR_NO_SDCARD;
}
@@ -1010,7 +1010,7 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
FIL restoreFile;
UINT read;
if (!CardIsMounted()) {
if (!sd_card_mounted()) {
return STR_NO_SDCARD;
}
File diff suppressed because it is too large Load Diff
+11 -16
View File
@@ -67,13 +67,17 @@ const char * audioFilenames[] = {
uint32_t sdAvailableAudioFiles = 0;
// TODO enable the assert when it's C++
extern "C" {
void retrieveAvailableAudioFiles()
{
FILINFO info;
char filename[32] = SYSTEM_SOUNDS_PATH "/";
#if !defined WIN32 && defined __GNUC__
assert(sizeof(audioFilenames)==AU_FRSKY_FIRST*sizeof(char *));
assert(sizeof(sdAvailableAudioFiles)*8 > AU_FRSKY_FIRST);
#endif
uint32_t availableAudioFiles = 0;
@@ -86,6 +90,7 @@ void retrieveAvailableAudioFiles()
sdAvailableAudioFiles = availableAudioFiles;
}
}
inline bool isAudioFileAvailable(uint8_t i, char * filename)
{
@@ -156,21 +161,10 @@ uint32_t pcmFreq = 8000;
#ifndef SIMU
void audioTask(void* pdata)
{
#if defined(SDCARD)
if (CardIsConnected() && sdState==SD_STATE_CONNECTED) {
// We lower the priority to allow the splash to be displayed...
CoSetPriority(audioTaskId, MENUS_PRIO+1);
if (f_mount(0, &g_FATFS_Obj) == FR_OK) {
retrieveAvailableAudioFiles();
sdState = SD_STATE_MOUNTED;
}
else {
sdState = SD_STATE_ERROR;
}
CoSetPriority(audioTaskId, AUDIO_PRIO);
AUDIO_TADA();
}
#endif
#if defined(SDCARD)
sdInit();
AUDIO_TADA();
#endif
while (1) {
@@ -434,6 +428,7 @@ void AudioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tFlag
{
CoEnterMutexSection(audioMutex);
if (tFlags & PLAY_SOUND_VARIO) {
background.freq = tFreq * 2;
background.duration = tLen;
@@ -477,7 +472,7 @@ void AudioQueue::playFile(const char *filename, uint8_t flags, uint8_t id)
#if defined(SIMU)
printf("playFile(\"%s\")\n", filename); fflush(stdout);
#else
if (!CardIsMounted())
if (Card_initialized && !sd_card_mounted())
return;
CoEnterMutexSection(audioMutex);
+656
View File
@@ -0,0 +1,656 @@
/*
* Authors (alphabetical order)
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Jean-Pierre Parisy
* - Karl Szmutny <shadow@privy.de>
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - Thomas Husterer
*
* open9x is based on code named
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
* and the original (and ongoing) project by
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef board_h
#define board_h
#include <stdint.h>
#include "chip.h"
#ifdef REVA
#include "AT91SAM3S2.h"
#else
#include "AT91SAM3S4.h"
#endif
#ifdef SIMU
#define CONVERT_PTR(x) ((uint32_t)(uint64_t)(x))
#else
#include "core_cm3.h"
#define CONVERT_PTR(x) ((uint32_t)(x))
#endif
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \par
/// This page lists several definition related to the board description.
///
/// Definitions
/// - BOARD_NAME
/// Name of the board.
#define BOARD_NAME "AT91SAM3S-EK"
/// Board definition.
#define at91sam3sek
/// Family definition (already defined).
#define at91sam3s
/// Core definition
#define cortexm3
// TODO remove these definitions
//#define BOARD_REV_A
#define BOARD_REV_B
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \par sam3s_ek_opfreq "SAM3S-EK - Operating frequencies"
/// This page lists several definition related to the board operating frequency
/// (when using the initialization done by board_lowlevel.c).
///
/// !Definitions
/// - BOARD_MAINOSC
/// - BOARD_MCK
/// Frequency of the board main oscillator.
#define BOARD_MAINOSC 12000000
/// Master clock frequency (when using board_lowlevel.c).
#define BOARD_MCK 64000000
//------------------------------------------------------------------------------
// ADC
//------------------------------------------------------------------------------
/// Startup time max, return from Idle mode (in µs)
#define ADC_STARTUP_TIME_MAX 15
/// Track and hold Acquisition Time min (in ns)
#define ADC_TRACK_HOLD_TIME_MIN 1200
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// USB attributes configuration descriptor (bus or self powered, remote wakeup)
//#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_SELFPOWERED_RWAKEUP
#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_SELFPOWERED_NORWAKEUP
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \par sam3s_ek_piodef "SAM3S-EK - PIO definitions"
/// This pages lists all the pio definitions contained in board.h. The constants
/// are named using the following convention: PIN_* for a constant which defines
/// a single Pin instance (but may include several PIOs sharing the same
/// controller), and PINS_* for a list of Pin instances.
///
/// !ADC
/// - PIN_ADC0_AD0
/// - PIN_ADC0_AD1
/// - PIN_ADC0_AD2
/// - PIN_ADC0_AD3
/// - PIN_ADC0_AD4
/// - PIN_ADC0_AD5
/// - PIN_ADC0_AD6
/// - PIN_ADC0_AD7
/// - PINS_ADC0
///
/// !UART
/// - PINS_UART
///
/// !EBI
/// - PIN_EBI_DATA_BUS
/// - PIN_EBI_NCS0
/// - PIN_EBI_NRD
/// - PIN_EBI_NWE
/// - PIN_EBI_ADDR_BUS
/// - PIN_EBI_PSRAM_NBS
/// - PIN_EBI_A1
/// - PIN_EBI_LCD_RS
///
/// !LEDs
/// - PIN_LED_0
/// - PIN_LED_1
/// - PIN_LED_2
/// - PINS_LEDS
///
/// !MCI
/// - PINS_MCI
///
/// !Push buttons
/// - PIN_PUSHBUTTON_1
/// - PIN_PUSHBUTTON_2
/// - PINS_PUSHBUTTONS
/// - PUSHBUTTON_BP1
/// - PUSHBUTTON_BP2
///
/// !PWMC
/// - PIN_PWMC_PWMH0
/// - PIN_PWMC_PWML0
/// - PIN_PWMC_PWMH1
/// - PIN_PWMC_PWML1
/// - PIN_PWMC_PWMH2
/// - PIN_PWMC_PWML2
/// - PIN_PWMC_PWMH3
/// - PIN_PWMC_PWML3
/// - PIN_PWM_LED0
/// - PIN_PWM_LED1
/// - PIN_PWM_LED2
/// - CHANNEL_PWM_LED0
/// - CHANNEL_PWM_LED1
/// - CHANNEL_PWM_LED2
///
/// !SPI
/// - PIN_SPI_MISO
/// - PIN_SPI_MOSI
/// - PIN_SPI_SPCK
/// - PINS_SPI
/// - PIN_SPI_NPCS0_PA11
///
/// ! SSC
/// - PIN_SSC_TD
/// - PIN_SSC_TK
/// - PIN_SSC_TF
/// - PINS_SSC_CODEC
///
/// ! PCK0
/// - PIN_PCK0
///
/// !TWI
/// - PIN_TWI_TWD0
/// - PIN_TWI_TWCK0
/// - PINS_TWI
///
/// !USART0
/// - PIN_USART0_RXD
/// - PIN_USART0_TXD
/// - PIN_USART0_CTS
/// - PIN_USART0_RTS
/// - PIN_USART0_SCK
///
/// !USB
/// - PIN_USB_PULLUP
///
/// ADC_AD0 pin definition.
#define PIN_ADC0_AD0 {1 << 21, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT}
/// ADC_AD1 pin definition.
#define PIN_ADC0_AD1 {1 << 30, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT}
/// ADC_AD2 pin definition.
#define PIN_ADC0_AD2 {1 << 3, PIOB, ID_PIOB, PIO_INPUT, PIO_DEFAULT}
/// ADC_AD3 pin definition.
#define PIN_ADC0_AD3 {1 << 4, PIOB, ID_PIOB, PIO_INPUT, PIO_DEFAULT}
/// ADC_AD4 pin definition.
#define PIN_ADC0_AD4 {1 << 15, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT}
/// ADC_AD5 pin definition.
#define PIN_ADC0_AD5 {1 << 16, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT}
/// ADC_AD6 pin definition.
#define PIN_ADC0_AD6 {1 << 17, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT}
/// ADC_AD7 pin definition.
#define PIN_ADC0_AD7 {1 << 18, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT}
/// Pins ADC
#define PINS_ADC PIN_ADC0_AD0, PIN_ADC0_AD1, PIN_ADC0_AD2, PIN_ADC0_AD3, PIN_ADC0_AD4, PIN_ADC0_AD5, PIN_ADC0_AD6, PIN_ADC0_AD7
/** UART pins (UTXD0 and URXD0) definitions, PA9,10. */
#define PINS_UART {0x00000600, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
/// EBI
#define PIN_EBI_DATA_BUS {0xFF, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
#define PIN_EBI_NRD {1 << 11, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
#define PIN_EBI_NWE {1 << 8, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
#define PIN_EBI_NCS0 {1 << 20, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_PULLUP}
#define PIN_EBI_PSRAM_ADDR_BUS {0x3f00fff, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
#define PIN_EBI_PSRAM_NBS {1 << 7, PIOB, ID_PIOB, PIO_PERIPH_B, PIO_PULLUP}, \
{1 << 15, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
#define PIN_EBI_A1 {1 << 19, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
#define PIN_EBI_NCS1 {1 << 15, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} /* LCD CS pin */
#define PIN_EBI_LCD_RS {1 << 19, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP} /* LCD RS pin */
#ifdef BOARD_REV_A
/** LED #0 pin definition. */
#define PIN_LED_0 {1 << 20, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT}
/** LED #1 pin definition. */
#define PIN_LED_1 {1 << 21, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT}
/** LED #2 pin definition. */
#define PIN_LED_2 {1 << 22, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT}
#endif
#ifdef BOARD_REV_B
/** LED #0 pin definition. */
#define PIN_LED_0 {1 << 19, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
/** LED #1 pin definition. */
#define PIN_LED_1 {1 << 20, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
/** LED #2 pin definition. */
#define PIN_LED_2 {1 << 20, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT}
#endif
/** List of all LEDs definitions. */
#define PINS_LEDS PIN_LED_0, PIN_LED_1, PIN_LED_2
/** MCI pins definition. */
#define PINS_MCI {0x3fUL << 26, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_PULLUP}
/** MCI pin Card Detect. */
#define PIN_MCI_CD {PIO_PB7, PIOB, ID_PIOB, PIO_INPUT, PIO_PULLUP}
/** Push button #0 definition. Attributes = pull-up + debounce + interrupt on rising edge. */
#define PIN_PUSHBUTTON_1 {1 << 3, PIOB, ID_PIOB, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE}
/** Push button #1 definition. Attributes = pull-up + debounce + interrupt on falling edge. */
#define PIN_PUSHBUTTON_2 {1 << 12, PIOC, ID_PIOC, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE}
/** List of all push button definitions. */
#define PINS_PUSHBUTTONS PIN_PUSHBUTTON_1, PIN_PUSHBUTTON_2
/** Push button #1 index. */
#define PUSHBUTTON_BP1 0
/** Push button #2 index. */
#define PUSHBUTTON_BP2 1
/// Simulated joystick LEFT index.
#define JOYSTICK_LEFT 0
/// Simulated joystick RIGHT index.
#define JOYSTICK_RIGHT 1
/** PWMC PWM0 pin definition. */
#define PIN_PWMC_PWMH0 {1 << 18, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT}
#define PIN_PWMC_PWML0 {1 << 19, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT}
/** PWMC PWM1 pin definition. */
#define PIN_PWMC_PWMH1 {1 << 19, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT}
#define PIN_PWMC_PWML1 {1 << 20, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT}
/** PWMC PWM2 pin definition. */
#define PIN_PWMC_PWMH2 {1 << 20, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT}
#define PIN_PWMC_PWML2 {1 << 16, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_DEFAULT}
/** PWMC PWM3 pin definition. */
#define PIN_PWMC_PWMH3 {1 << 21, PIOC, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT}
#define PIN_PWMC_PWML3 {1 << 15, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_DEFAULT}
/** PWM pin definition for LED0 */
#define PIN_PWM_LED0 PIN_PWMC_PWMH0, PIN_PWMC_PWML0
/** PWM pin definition for LED1 */
#define PIN_PWM_LED1 PIN_PWMC_PWMH2, PIN_PWMC_PWML2
/** PWM pin definition for LED2 */
#define PIN_PWM_LED2 PIN_PWMC_PWMH3, PIN_PWMC_PWML3
/** PWM channel for LED0 */
#define CHANNEL_PWM_LED0 0
/** PWM channel for LED1 */
#define CHANNEL_PWM_LED1 2
/** PWM channel for LED2 */
#define CHANNEL_PWM_LED2 3
/** SPI MISO pin definition. */
#define PIN_SPI_MISO {1 << 12, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
/** SPI MOSI pin definition. */
#define PIN_SPI_MOSI {1 << 13, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
/** SPI SPCK pin definition. */
#define PIN_SPI_SPCK {1 << 14, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
/** SPI chip select pin definition. */
#define PIN_SPI_NPCS0_PA11 {1 << 11, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
/** List of SPI pin definitions (MISO, MOSI & SPCK). */
#define PINS_SPI PIN_SPI_MISO, PIN_SPI_MOSI, PIN_SPI_SPCK
/// SSC pins definition.
#define PIN_SSC_TD {0x1 << 26, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
#define PIN_SSC_TK {0x1 << 28, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
#define PIN_SSC_TF {0x1 << 30, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
#define PINS_SSC_CODEC PIN_SSC_TD, PIN_SSC_TK, PIN_SSC_TF
/// PCK0
#define PIN_PCK0 {0x1 << 21, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT}
/// TWI pins definition.
#define TWI_V3XX
#define PIN_TWI_TWD0 {0x1 << 9, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
#define PIN_TWI_TWCK0 {0x1 << 10, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
#define PINS_TWI0 PIN_TWI_TWD0, PIN_TWI_TWCK0
#define PIN_TWI_TWD1 {0x1 << 24, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
#define PIN_TWI_TWCK1 {0x1 << 25, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
#define PINS_TWI1 PIN_TWI_TWD1, PIN_TWI_TWCK1
/// USART0
#define PIN_USART0_RXD {0x1 << 19, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
#define PIN_USART0_TXD {0x1 << 18, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
#define PIN_USART0_CTS {0x1 << 8, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT}
#define PIN_USART0_RTS {0x1 << 7, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT}
#define PIN_USART0_SCK {0x1 << 17, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
/// USART1
#define PIN_USART1_RXD {0x1 << 21, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
#define PIN_USART1_TXD {0x1 << 22, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
#define PIN_USART1_CTS {0x1 << 25, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
#define PIN_USART1_RTS {0x1 << 24, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
#define PIN_USART1_EN {0x1 << 23, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
/// USB VBus monitoring pin definition.
#ifdef BOARD_REV_A
#define PIN_USB_VBUS {1 << 23, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT}
#endif
#ifdef BOARD_REV_B
#define PIN_USB_VBUS {1 << 21, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT}
#endif
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \par sam3s_ek_extcomp "SAM3S-EK - External components"
/// This page lists the definitions related to external on-board components
/// located in the board.h file for the AT91SAM3S-EK.
///
/// !AT45 Dataflash Card
/// - BOARD_AT45_A_SPI_BASE
/// - BOARD_AT45_A_SPI_ID
/// - BOARD_AT45_A_SPI_PINS
/// - BOARD_AT45_A_SPI
/// - BOARD_AT45_A_NPCS
/// - BOARD_AT45_A_NPCS_PIN
///
/// !AT45 Dataflash (serial onboard DataFlash)
/// - BOARD_AT45_B_SPI_BASE
/// - BOARD_AT45_B_SPI_ID
/// - BOARD_AT45_B_SPI_PINS
/// - BOARD_AT45_B_SPI
/// - BOARD_AT45_B_NPCS
/// - BOARD_AT45_B_NPCS_PIN
///
/// !AT26 Serial Flash
/// - BOARD_AT26_A_SPI_BASE
/// - BOARD_AT26_A_SPI_ID
/// - BOARD_AT26_A_SPI_PINS
/// - BOARD_AT26_A_SPI
/// - BOARD_AT26_A_NPCS
/// - BOARD_AT26_A_NPCS_PIN
///
/// !SD Card
/// - MCI2_INTERFACE
/// - BOARD_SD_MCI_BASE
/// - BOARD_SD_MCI_ID
/// - BOARD_SD_PINS
/// - BOARD_SD_SLOT
///
/// !PSRAM
/// - BOARD_PSRAM_PINS
///
/// !LCD
/// - BOARD_LCD_ILI9325
/// - BOARD_LCD_PINS
/// - BOARD_BACKLIGHT_PIN
/// - BOARD_LCD_BASE
/// - BOARD_LCD_RS
/// - BOARD_LCD_WIDTH
/// - BOARD_LCD_HEIGHT
///
/// !TouchScreen
/// - BOARD_TSC_ADS7843
/// - PIN_TCS_IRQ
/// - PIN_TCS_BUSY
/// - BOARD_TSC_SPI_BASE
/// - BOARD_TSC_SPI_ID
/// - BOARD_TSC_SPI_PINS
/// - BOARD_TSC_NPCS
/// - BOARD_TSC_NPCS_PIN
///
/// Base address of SPI peripheral connected to the dataflash.
//#define BOARD_AT45_A_SPI_BASE SPI0
///// Identifier of SPI peripheral connected to the dataflash.
//#define BOARD_AT45_A_SPI_ID ID_SPI0
///// Pins of the SPI peripheral connected to the dataflash.
//#define BOARD_AT45_A_SPI_PINS PINS_SPI0
///// Dataflahs SPI number.
//#define BOARD_AT45_A_SPI 0
///// Chip select connected to the dataflash.
//#define BOARD_AT45_A_NPCS 3
///// Chip select pin connected to the dataflash.
//#define BOARD_AT45_A_NPCS_PIN PIN_SPI0_NPCS3
/// Base address of SPI peripheral connected to the dataflash.
//#define BOARD_AT45_B_SPI_BASE SPI1
///// Identifier of SPI peripheral connected to the dataflash.
//#define BOARD_AT45_B_SPI_ID ID_SPI1
///// Pins of the SPI peripheral connected to the dataflash.
//#define BOARD_AT45_B_SPI_PINS PINS_SPI1
///// Dataflahs SPI number.
//#define BOARD_AT45_B_SPI 1
///// Chip select connected to the dataflash.
//#define BOARD_AT45_B_NPCS 3
///// Chip select pin connected to the dataflash.
//#define BOARD_AT45_B_NPCS_PIN PIN_SPI1_NPCS3
/// Base address of SPI peripheral connected to the serialflash.
//#define BOARD_AT26_A_SPI_BASE SPI0
///// Identifier of SPI peripheral connected to the serialflash.
//#define BOARD_AT26_A_SPI_ID ID_SPI0
///// Pins of the SPI peripheral connected to the serialflash.
//#define BOARD_AT26_A_SPI_PINS PINS_SPI0
///// Serialflash SPI number.
//#define BOARD_AT26_A_SPI 0
///// Chip select connected to the serialflash.
//#define BOARD_AT26_A_NPCS 3
///// Chip select pin connected to the serialflash.
//#define BOARD_AT26_A_NPCS_PIN PIN_SPI0_NPCS3
/// ISO7816
/// - PIN_SMARTCARD_CONNECT
/// - PIN_ISO7816_RSTMC
/// - PINS_ISO7816
/// Smartcard detection pin
//#define PIN_SMARTCARD_CONNECT {1 << 5, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT}
/// PIN used for reset the smartcard
//#define PIN_ISO7816_RSTMC {1 << 7, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
/// Pins used for connect the smartcard
//#define PINS_ISO7816 PIN_USART0_TXD, PIN_USART0_SCK, PIN_ISO7816_RSTMC
/// Dma channel number
#define BOARD_MCI_DMA_CHANNEL 0
/// MCI0 DMA hardware handshaking ID
#define DMA_HW_SRC_REQ_ID_MCI0 AT91C_HDMA_SRC_PER_0
#define DMA_HW_DEST_REQ_ID_MCI0 AT91C_HDMA_DST_PER_0
/// MCI1 DMA hardware handshaking ID
#define DMA_HW_SRC_REQ_ID_MCI1 AT91C_HDMA_SRC_PER_13
#define DMA_HW_DEST_REQ_ID_MCI1 AT91C_HDMA_DST_PER_13
/// SD DMA hardware handshaking ID
#define BOARD_SD_DMA_HW_SRC_REQ_ID DMA_HW_SRC_REQ_ID_MCI0
#define BOARD_SD_DMA_HW_DEST_REQ_ID DMA_HW_DEST_REQ_ID_MCI0
/// HS MCI interface
#define MCI2_INTERFACE
/// Base address of the MCI peripheral connected to the SD card.
#define BOARD_SD_MCI_BASE MCI0//MCI
///// Peripheral identifier of the MCI connected to the SD card.
#define BOARD_SD_MCI_ID AT91C_ID_MCI0 ID_MCI0 //ID_MCI
///// MCI pins that shall be configured to access the SD card.
#define BOARD_SD_PINS PINS_MCI
///// MCI slot to which the SD card is connected to.
#define BOARD_SD_SLOT MCI_SD_SLOTA
///// MCI Card Detect pin.
#define BOARD_SD_PIN_CD PIN_MCI_CD
#define CardIsConnected() ( (PIOB->PIO_PDSR & PIO_PB7) == 0 )
// States for initialising card
#define SD_ST_ERR -1
#define SD_ST_STARTUP 0
#define SD_ST_EMPTY 1
#define SD_ST_INIT1 2
#define SD_ST_INIT2 3
#define SD_ST_IDLE 4
#define SD_ST_READY 5
#define SD_ST_IDENT 6
#define SD_ST_STBY 7
#define SD_ST_TRAN 8
#define SD_ST_DATA 9
#define SD_ST_MOUNTED 10
extern int32_t Card_state;
extern volatile uint32_t Card_initialized;
/*
#define BOARD_PSRAM_PINS PIN_EBI_DATA_BUS, PIN_EBI_NCS0, PIN_EBI_NRD, PIN_EBI_NWE, \
PIN_EBI_PSRAM_ADDR_BUS, PIN_EBI_PSRAM_NBS, PIN_EBI_A1
*/
/** Indicates board has an ILI9325 external component to manage LCD. */
#define BOARD_LCD_ILI9325
/** LCD pins definition. */
#define BOARD_LCD_PINS PIN_EBI_DATA_BUS, PIN_EBI_NRD, PIN_EBI_NWE, \
PIN_EBI_NCS1, PIN_EBI_LCD_RS
/** Backlight pin definition. */
#define BOARD_BACKLIGHT_PIN {1 << 13, PIOC, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT}
/** Define ILI9325 base address. */
#define BOARD_LCD_BASE 0x61000000
/** Define ILI9325 register select signal. */
#define BOARD_LCD_RS (1 << 1)
/** Display width in pixels. */
#define BOARD_LCD_WIDTH 240
/** Display height in pixels. */
#define BOARD_LCD_HEIGHT 320
/** Indicates board has an ADS7843 external component to manage Touch Screen */
#define BOARD_TSC_ADS7843
#ifdef BOARD_REV_A
/** Touchscreen controller IRQ pin definition. */
#define PIN_TCS_IRQ {PIO_PA4, PIOA, ID_PIOA, PIO_INPUT, PIO_DEBOUNCE | PIO_IT_AIME | PIO_IT_EDGE}
#define PIN_TCS_IRQ_WUP_ID (1 << 3)
/** Touchscreen controller Busy pin definition. */
#define PIN_TCS_BUSY {PIO_PA5, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP}
#endif
#ifdef BOARD_REV_B
/** Touchscreen controller IRQ pin definition. */
#define PIN_TCS_IRQ {PIO_PA16, PIOA, ID_PIOA, PIO_INPUT, PIO_DEBOUNCE | PIO_IT_AIME | PIO_IT_EDGE}
#define PIN_TCS_IRQ_WUP_ID (1 << 15)
/** Touchscreen controller Busy pin definition. */
#define PIN_TCS_BUSY {PIO_PA17, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP}
#endif
/** Base address of SPI peripheral connected to the touchscreen controller. */
#define BOARD_TSC_SPI_BASE SPI
/** Identifier of SPI peripheral connected to the touchscreen controller. */
#define BOARD_TSC_SPI_ID ID_SPI
/** Pins of the SPI peripheral connected to the touchscreen controller. */
#define BOARD_TSC_SPI_PINS PINS_SPI
/** Chip select connected to the touchscreen controller. */
#define BOARD_TSC_NPCS 0
/** Chip select pin connected to the touchscreen controller. */
#define BOARD_TSC_NPCS_PIN PIN_SPI_NPCS0_PA11
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \par sam3s_ek_mem "SAM3S-EK - Memories"
/// This page lists definitions related to internal & external on-board memories.
///
/// !Embedded Flash
/// - BOARD_FLASH_EFC
/// Internal SRAM address
#define AT91C_ISRAM AT91C_IRAM
#define AT91C_ISRAM_SIZE 0x00008000
#define AT91C_IFLASH_SIZE (0x40000)
#define AT91C_IFLASH_PAGE_SIZE (256) // Internal FLASH 0 Page Size: 256 bytes
#define AT91C_IFLASH_NB_OF_PAGES (1024) // Internal FLASH 0 Number of Pages: 512
#define AT91C_IFLASH_LOCK_REGION_SIZE (16384) // Internal FLASH 0 Lock Region Size: 16 Kbytes
#define AT91C_IFLASH_NB_OF_LOCK_BITS (16) // Internal FLASH 0 Number of Lock Bits: 16
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \section sam3s_ek_extcomp "SAM3S-EK - External components"
/// This page lists the definitions related to external on-board components
/// located in the board.h file for the SAM3S-EK.
///
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \par sam3s_ek_chipdef "SAM3S-EK - Individual chip definition"
/// This page lists the definitions related to different chip's definition
/// located in the board.h file for the SAM3S-EK.
/// DBGU
#define BOARD_DBGU_ID ID_DBGU
/// Rtc
#define BOARD_RTC_ID ID_RTC
/// Twi eeprom
#define BOARD_ID_TWI_EEPROM ID_TWI1
#define BOARD_BASE_TWI_EEPROM TWI1
#define BOARD_PINS_TWI_EEPROM PINS_TWI1
/// USART
#define BOARD_PIN_USART_RXD PIN_USART1_RXD
#define BOARD_PIN_USART_TXD PIN_USART1_TXD
#define BOARD_PIN_USART_CTS PIN_USART1_CTS
#define BOARD_PIN_USART_RTS PIN_USART1_RTS
#define BOARD_PIN_USART_EN PIN_USART1_EN
#define BOARD_USART_BASE USART1
#define BOARD_ID_USART ID_USART1
//------------------------------------------------------------------------------
#define PIN_EBI_NANDOE {1 << 9, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
#define PIN_EBI_NANDWE {1 << 10, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
#define PIN_EBI_NANDCLE {1 << 17, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
#define PIN_EBI_NANDALE {1 << 16, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
#define PIN_EBI_NANDIO {0x000000FF, PIOC, ID_PIOC, PIO_PERIPH_A, PIO_PULLUP}
/// Nandflash chip enable pin definition.
#define BOARD_NF_CE_PIN {1 << 14, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT}
/// Nandflash ready/busy pin definition.
#define BOARD_NF_RB_PIN {1 << 18, PIOC, ID_PIOC, PIO_INPUT, PIO_PULLUP}
/// Nandflash controller peripheral pins definition.
#define PINS_NANDFLASH PIN_EBI_NANDIO, BOARD_NF_CE_PIN, BOARD_NF_RB_PIN, PIN_EBI_NANDOE, \
PIN_EBI_NANDWE, PIN_EBI_NANDCLE, PIN_EBI_NANDALE
/// Address for transferring command bytes to the nandflash.
#define BOARD_NF_COMMAND_ADDR 0x60400000
/// Address for transferring address bytes to the nandflash.
#define BOARD_NF_ADDRESS_ADDR 0x60200000
/// Address for transferring data bytes to the nandflash.
#define BOARD_NF_DATA_ADDR 0x60000000
extern uint32_t Master_frequency ;
struct t_serial_tx
{
uint8_t *buffer ;
uint16_t size ;
volatile uint16_t ready ;
};
#endif
-2
View File
@@ -39,8 +39,6 @@
* Headers
*----------------------------------------------------------------------------*/
// TODO duplicated file!
#include "board.h"
/*----------------------------------------------------------------------------
+130
View File
@@ -0,0 +1,130 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, Atmel Corporation
*
* 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 disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \unit
/// !Purpose
///
/// Definition of AT91SAM3S4 characteristics and features
///
/// !Usage
/// -# For ARM core feature, see "AT91SAM3S4 - ARM core features".
/// -# For IP features, see "AT91SAM3S4 - IP features".
/// -# For misc, see "AT91SAM3S4 - Misc".
//------------------------------------------------------------------------------
#ifndef CHIP_H
#define CHIP_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "AT91SAM3S4 - ARM core features"
/// This page lists several characteristics related to the ARM core
///
//ARM core features
/// ARM core definition.
#define cortexm3
/// family definition.
#define at91sam3s
//------------------------------------------------------------------------------
/// \page "AT91SAM3S4 - IP features"
/// This page lists several characteristics related to the embedded IP
///
//IP FEATURES
// EFC GPNVM number
#define CHIP_EFC_NUM_GPNVMS 3
/// Indicates chip has an Enhanced EFC.
#define CHIP_FLASH_EEFC
// DMA channels number
#define CHIP_DMA_CHANNEL_NUM 4
// Indicate chip's MCI interface.
#define MCI2_INTERFACE
// Indicate chip SSC has DMA interface.
#define CHIP_SSC_DMA
// Indicate chip SPI has DMA interface.
#define CHIP_SPI_DMA
/// Indicates chip has an UDP Full Speed.
#define CHIP_USB_UDP
/// Indicates chip has an internal pull-up.
#define CHIP_USB_PULLUP_INTERNAL
/// Number of USB endpoints
#define CHIP_USB_NUMENDPOINTS 8
/// Endpoints max paxcket size
#define CHIP_USB_ENDPOINTS_MAXPACKETSIZE(i) \
((i == 0) ? 64 : \
((i == 1) ? 64 : \
((i == 2) ? 64 : \
((i == 3) ? 64 : \
((i == 4) ? 512 : \
((i == 5) ? 512 : \
((i == 6) ? 64 : \
((i == 7) ? 64 : 0 ))))))))
/// Endpoints Number of Bank
#define CHIP_USB_ENDPOINTS_BANKS(i) \
((i == 0) ? 1 : \
((i == 1) ? 2 : \
((i == 2) ? 2 : \
((i == 3) ? 1 : \
((i == 4) ? 2 : \
((i == 5) ? 2 : \
((i == 6) ? 2 : \
((i == 7) ? 2 : 0 ))))))))
//------------------------------------------------------------------------------
/// \page "AT91SAM3S4 - Misc "
/// This page lists misc features
///
//Misc
#endif //#ifndef CHIP_H
-2
View File
@@ -21,8 +21,6 @@
*
******************************************************************************/
// TODO duplicated file
#include <stdint.h>
/* define compiler specific symbols */
-2
View File
@@ -21,8 +21,6 @@
*
******************************************************************************/
// TODO duplicated file
#ifndef __CM3_CORE_H__
#define __CM3_CORE_H__
+1333 -276
View File
File diff suppressed because it is too large Load Diff
@@ -207,8 +207,8 @@ typedef struct {
typedef struct {
WoReg ADC_CR; /**< \brief (Adc Offset: 0x00) Control Register */
RwReg ADC_MR; /**< \brief (Adc Offset: 0x04) Mode Register */
RwReg ADC_SEQR1; /**< \brief (Adc Offset: 0x08) Channel Sequence 1Register */
RwReg ADC_SEQR2; /**< \brief (Adc Offset: 0x0C) Channel Sequence 2 Register */
RwReg ADC_SEQ1R; /**< \brief (Adc Offset: 0x08) Channel Sequence 1Register */
RwReg ADC_SEQ2R; /**< \brief (Adc Offset: 0x0C) Channel Sequence 2 Register */
WoReg ADC_CHER; /**< \brief (Adc Offset: 0x10) Channel Enable Register */
WoReg ADC_CHDR; /**< \brief (Adc Offset: 0x14) Channel Disable Register */
RoReg ADC_CHSR; /**< \brief (Adc Offset: 0x18) Channel Status Register */
@@ -918,121 +918,40 @@ typedef struct {
#define HSMCI_CR_PWSDIS (0x1 << 3) /**< \brief (HSMCI_CR) Power Save Mode Disable */
#define HSMCI_CR_SWRST (0x1 << 7) /**< \brief (HSMCI_CR) Software Reset */
/* -------- HSMCI_MR : (HSMCI Offset: 0x04) Mode Register -------- */
#define HSMCI_MR_CLKDIV_Pos 0
#define HSMCI_MR_CLKDIV_Msk (0xffu << HSMCI_MR_CLKDIV_Pos) /**< \brief (HSMCI_MR) Clock Divider */
#define HSMCI_MR_CLKDIV(value) ((HSMCI_MR_CLKDIV_Msk & ((value) << HSMCI_MR_CLKDIV_Pos)))
#define HSMCI_MR_PWSDIV_Pos 8
#define HSMCI_MR_PWSDIV_Msk (0x7u << HSMCI_MR_PWSDIV_Pos) /**< \brief (HSMCI_MR) Power Saving Divider */
#define HSMCI_MR_PWSDIV(value) ((HSMCI_MR_PWSDIV_Msk & ((value) << HSMCI_MR_PWSDIV_Pos)))
#define HSMCI_MR_RDPROOF (0x1u << 11) /**< \brief (HSMCI_MR) */
#define HSMCI_MR_WRPROOF (0x1u << 12) /**< \brief (HSMCI_MR) */
#define HSMCI_MR_FBYTE (0x1u << 13) /**< \brief (HSMCI_MR) Force Byte Transfer */
#define HSMCI_MR_PADV (0x1u << 14) /**< \brief (HSMCI_MR) Padding Value */
#define HSMCI_MR_PDCMODE (0x1u << 15) /**< \brief (HSMCI_MR) PDC-oriented Mode */
#define HSMCI_MR_BLKLEN_Pos 16
#define HSMCI_MR_BLKLEN_Msk (0xffffu << HSMCI_MR_BLKLEN_Pos) /**< \brief (HSMCI_MR) Data Block Length */
#define HSMCI_MR_BLKLEN(value) ((HSMCI_MR_BLKLEN_Msk & ((value) << HSMCI_MR_BLKLEN_Pos)))
#define HSMCI_MR_CLKDIV (0xff << 0) /**< \brief (HSMCI_MR) Clock Divider */
#define HSMCI_MR_PWSDIV (0x7 << 8) /**< \brief (HSMCI_MR) Power Saving Divider */
#define HSMCI_MR_RDPROOF (0x1 << 11) /**< \brief (HSMCI_MR) */
#define HSMCI_MR_WRPROOF (0x1 << 12) /**< \brief (HSMCI_MR) */
#define HSMCI_MR_FBYTE (0x1 << 13) /**< \brief (HSMCI_MR) Force Byte Transfer */
#define HSMCI_MR_PADV (0x1 << 14) /**< \brief (HSMCI_MR) Padding Value */
#define HSMCI_MR_PDCMODE (0x1 << 15) /**< \brief (HSMCI_MR) PDC-oriented Mode */
#define HSMCI_MR_BLKLEN (0xffff << 16) /**< \brief (HSMCI_MR) Data Block Length */
/* -------- HSMCI_DTOR : (HSMCI Offset: 0x08) Data Timeout Register -------- */
#define HSMCI_DTOR_DTOCYC_Pos 0
#define HSMCI_DTOR_DTOCYC_Msk (0xfu << HSMCI_DTOR_DTOCYC_Pos) /**< \brief (HSMCI_DTOR) Data Timeout Cycle Number */
#define HSMCI_DTOR_DTOCYC(value) ((HSMCI_DTOR_DTOCYC_Msk & ((value) << HSMCI_DTOR_DTOCYC_Pos)))
#define HSMCI_DTOR_DTOMUL_Pos 4
#define HSMCI_DTOR_DTOMUL_Msk (0x7u << HSMCI_DTOR_DTOMUL_Pos) /**< \brief (HSMCI_DTOR) Data Timeout Multiplier */
#define HSMCI_DTOR_DTOMUL_1 (0x0u << 4) /**< \brief (HSMCI_DTOR) DTOCYC */
#define HSMCI_DTOR_DTOMUL_16 (0x1u << 4) /**< \brief (HSMCI_DTOR) DTOCYC x 16 */
#define HSMCI_DTOR_DTOMUL_128 (0x2u << 4) /**< \brief (HSMCI_DTOR) DTOCYC x 128 */
#define HSMCI_DTOR_DTOMUL_256 (0x3u << 4) /**< \brief (HSMCI_DTOR) DTOCYC x 256 */
#define HSMCI_DTOR_DTOMUL_1024 (0x4u << 4) /**< \brief (HSMCI_DTOR) DTOCYC x 1024 */
#define HSMCI_DTOR_DTOMUL_4096 (0x5u << 4) /**< \brief (HSMCI_DTOR) DTOCYC x 4096 */
#define HSMCI_DTOR_DTOMUL_65536 (0x6u << 4) /**< \brief (HSMCI_DTOR) DTOCYC x 65536 */
#define HSMCI_DTOR_DTOMUL_1048576 (0x7u << 4) /**< \brief (HSMCI_DTOR) DTOCYC x 1048576 */
#define HSMCI_DTOR_DTOCYC (0xf << 0) /**< \brief (HSMCI_DTOR) Data Timeout Cycle Number */
#define HSMCI_DTOR_DTOMUL (0x7 << 4) /**< \brief (HSMCI_DTOR) Data Timeout Multiplier */
/* -------- HSMCI_SDCR : (HSMCI Offset: 0x0C) SD/SDIO Card Register -------- */
#define HSMCI_SDCR_SDCSEL_Pos 0
#define HSMCI_SDCR_SDCSEL_Msk (0x3u << HSMCI_SDCR_SDCSEL_Pos) /**< \brief (HSMCI_SDCR) SDCard/SDIO Slot */
#define HSMCI_SDCR_SDCSEL_SLOTA (0x0u << 0) /**< \brief (HSMCI_SDCR) Slot A is selected. */
#define HSMCI_SDCR_SDCSEL_SLOTB (0x1u << 0) /**< \brief (HSMCI_SDCR) - */
#define HSMCI_SDCR_SDCSEL_SLOTC (0x2u << 0) /**< \brief (HSMCI_SDCR) - */
#define HSMCI_SDCR_SDCSEL_SLOTD (0x3u << 0) /**< \brief (HSMCI_SDCR) - */
#define HSMCI_SDCR_SDCBUS_Pos 6
#define HSMCI_SDCR_SDCBUS_Msk (0x3u << HSMCI_SDCR_SDCBUS_Pos) /**< \brief (HSMCI_SDCR) SDCard/SDIO Bus Width */
#define HSMCI_SDCR_SDCBUS_1 (0x0u << 6) /**< \brief (HSMCI_SDCR) 1 bit */
#define HSMCI_SDCR_SDCBUS_4 (0x2u << 6) /**< \brief (HSMCI_SDCR) 4 bit */
#define HSMCI_SDCR_SDCBUS_8 (0x3u << 6) /**< \brief (HSMCI_SDCR) 8 bit */
#define HSMCI_SDCR_SDCSEL (0x3 << 0) /**< \brief (HSMCI_SDCR) SDCard/SDIO Slot */
#define HSMCI_SDCR_SDCBUS (0x3 << 6) /**< \brief (HSMCI_SDCR) SDCard/SDIO Bus Width */
/* -------- HSMCI_ARGR : (HSMCI Offset: 0x10) Argument Register -------- */
#define HSMCI_ARGR_ARG (0xffffffff << 0) /**< \brief (HSMCI_ARGR) Command Argument */
/* -------- HSMCI_CMDR : (HSMCI Offset: 0x14) Command Register -------- */
#define HSMCI_CMDR_CMDNB_Pos 0
#define HSMCI_CMDR_CMDNB_Msk (0x3fu << HSMCI_CMDR_CMDNB_Pos) /**< \brief (HSMCI_CMDR) Command Number */
#define HSMCI_CMDR_CMDNB(value) ((HSMCI_CMDR_CMDNB_Msk & ((value) << HSMCI_CMDR_CMDNB_Pos)))
#define HSMCI_CMDR_RSPTYP_Pos 6
#define HSMCI_CMDR_RSPTYP_Msk (0x3u << HSMCI_CMDR_RSPTYP_Pos) /**< \brief (HSMCI_CMDR) Response Type */
#define HSMCI_CMDR_RSPTYP_NORESP (0x0u << 6) /**< \brief (HSMCI_CMDR) No response. */
#define HSMCI_CMDR_RSPTYP_48_BIT (0x1u << 6) /**< \brief (HSMCI_CMDR) 48-bit response. */
#define HSMCI_CMDR_RSPTYP_136_BIT (0x2u << 6) /**< \brief (HSMCI_CMDR) 136-bit response. */
#define HSMCI_CMDR_RSPTYP_R1B (0x3u << 6) /**< \brief (HSMCI_CMDR) R1b response type */
#define HSMCI_CMDR_SPCMD_Pos 8
#define HSMCI_CMDR_SPCMD_Msk (0x7u << HSMCI_CMDR_SPCMD_Pos) /**< \brief (HSMCI_CMDR) Special Command */
#define HSMCI_CMDR_SPCMD_STD (0x0u << 8) /**< \brief (HSMCI_CMDR) Not a special CMD. */
#define HSMCI_CMDR_SPCMD_INIT (0x1u << 8) /**< \brief (HSMCI_CMDR) Initialization CMD:74 clock cycles for initialization sequence. */
#define HSMCI_CMDR_SPCMD_SYNC (0x2u << 8) /**< \brief (HSMCI_CMDR) Synchronized CMD:Wait for the end of the current data block transfer before sending the pending command. */
#define HSMCI_CMDR_SPCMD_CE_ATA (0x3u << 8) /**< \brief (HSMCI_CMDR) CE-ATA Completion Signal disable Command.The host cancels the ability for the device to return a command completion signal on the command line. */
#define HSMCI_CMDR_SPCMD_IT_CMD (0x4u << 8) /**< \brief (HSMCI_CMDR) Interrupt command:Corresponds to the Interrupt Mode (CMD40). */
#define HSMCI_CMDR_SPCMD_IT_RESP (0x5u << 8) /**< \brief (HSMCI_CMDR) Interrupt response:Corresponds to the Interrupt Mode (CMD40). */
#define HSMCI_CMDR_SPCMD_BOR (0x6u << 8) /**< \brief (HSMCI_CMDR) Boot Operation Request.Start a boot operation mode, the host processor can read boot data from the MMC device directly. */
#define HSMCI_CMDR_SPCMD_EBO (0x7u << 8) /**< \brief (HSMCI_CMDR) End Boot Operation.This command allows the host processor to terminate the boot operation mode. */
#define HSMCI_CMDR_OPDCMD (0x1u << 11) /**< \brief (HSMCI_CMDR) Open Drain Command */
#define HSMCI_CMDR_OPDCMD_PUSHPULL (0x0u << 11) /**< \brief (HSMCI_CMDR) Push pull command. */
#define HSMCI_CMDR_OPDCMD_OPENDRAIN (0x1u << 11) /**< \brief (HSMCI_CMDR) Open drain command. */
#define HSMCI_CMDR_MAXLAT (0x1u << 12) /**< \brief (HSMCI_CMDR) Max Latency for Command to Response */
#define HSMCI_CMDR_MAXLAT_5 (0x0u << 12) /**< \brief (HSMCI_CMDR) 5-cycle max latency. */
#define HSMCI_CMDR_MAXLAT_64 (0x1u << 12) /**< \brief (HSMCI_CMDR) 64-cycle max latency. */
#define HSMCI_CMDR_TRCMD_Pos 16
#define HSMCI_CMDR_TRCMD_Msk (0x3u << HSMCI_CMDR_TRCMD_Pos) /**< \brief (HSMCI_CMDR) Transfer Command */
#define HSMCI_CMDR_TRCMD_NO_DATA (0x0u << 16) /**< \brief (HSMCI_CMDR) No data transfer */
#define HSMCI_CMDR_TRCMD_START_DATA (0x1u << 16) /**< \brief (HSMCI_CMDR) Start data transfer */
#define HSMCI_CMDR_TRCMD_STOP_DATA (0x2u << 16) /**< \brief (HSMCI_CMDR) Stop data transfer */
#define HSMCI_CMDR_TRDIR (0x1u << 18) /**< \brief (HSMCI_CMDR) Transfer Direction */
#define HSMCI_CMDR_TRDIR_WRITE (0x0u << 18) /**< \brief (HSMCI_CMDR) Write. */
#define HSMCI_CMDR_TRDIR_READ (0x1u << 18) /**< \brief (HSMCI_CMDR) Read. */
#define HSMCI_CMDR_TRTYP_Pos 19
#define HSMCI_CMDR_TRTYP_Msk (0x7u << HSMCI_CMDR_TRTYP_Pos) /**< \brief (HSMCI_CMDR) Transfer Type */
#define HSMCI_CMDR_TRTYP_SINGLE (0x0u << 19) /**< \brief (HSMCI_CMDR) MMC/SDCard Single Block */
#define HSMCI_CMDR_TRTYP_MULTIPLE (0x1u << 19) /**< \brief (HSMCI_CMDR) MMC/SDCard Multiple Block */
#define HSMCI_CMDR_TRTYP_STREAM (0x2u << 19) /**< \brief (HSMCI_CMDR) MMC Stream */
#define HSMCI_CMDR_TRTYP_BYTE (0x4u << 19) /**< \brief (HSMCI_CMDR) SDIO Byte */
#define HSMCI_CMDR_TRTYP_BLOCK (0x5u << 19) /**< \brief (HSMCI_CMDR) SDIO Block */
#define HSMCI_CMDR_IOSPCMD_Pos 24
#define HSMCI_CMDR_IOSPCMD_Msk (0x3u << HSMCI_CMDR_IOSPCMD_Pos) /**< \brief (HSMCI_CMDR) SDIO Special Command */
#define HSMCI_CMDR_IOSPCMD_STD (0x0u << 24) /**< \brief (HSMCI_CMDR) Not an SDIO Special Command */
#define HSMCI_CMDR_IOSPCMD_SUSPEND (0x1u << 24) /**< \brief (HSMCI_CMDR) SDIO Suspend Command */
#define HSMCI_CMDR_IOSPCMD_RESUME (0x2u << 24) /**< \brief (HSMCI_CMDR) SDIO Resume Command */
#define HSMCI_CMDR_ATACS (0x1u << 26) /**< \brief (HSMCI_CMDR) ATA with Command Completion Signal */
#define HSMCI_CMDR_ATACS_NORMAL (0x0u << 26) /**< \brief (HSMCI_CMDR) Normal operation mode. */
#define HSMCI_CMDR_ATACS_COMPLETION (0x1u << 26) /**< \brief (HSMCI_CMDR) This bit indicates that a completion signal is expected within a programmed amount of time (HSMCI_CSTOR). */
#define HSMCI_CMDR_BOOT_ACK (0x1u << 27) /**< \brief (HSMCI_CMDR) Boot Operation Acknowledge. */
#define HSMCI_CMDR_CMDNB (0x3f << 0) /**< \brief (HSMCI_CMDR) Command Number */
#define HSMCI_CMDR_RSPTYP (0x3 << 6) /**< \brief (HSMCI_CMDR) Response Type */
#define HSMCI_CMDR_SPCMD (0x7 << 8) /**< \brief (HSMCI_CMDR) Special Command */
#define HSMCI_CMDR_OPDCMD (0x1 << 11) /**< \brief (HSMCI_CMDR) Open Drain Command */
#define HSMCI_CMDR_MAXLAT (0x1 << 12) /**< \brief (HSMCI_CMDR) Max Latency for Command to Response */
#define HSMCI_CMDR_TRCMD (0x3 << 16) /**< \brief (HSMCI_CMDR) Transfer Command */
#define HSMCI_CMDR_TRDIR (0x1 << 18) /**< \brief (HSMCI_CMDR) Transfer Direction */
#define HSMCI_CMDR_TRTYP (0x7 << 19) /**< \brief (HSMCI_CMDR) Transfer Type */
#define HSMCI_CMDR_IOSPCMD (0x3 << 24) /**< \brief (HSMCI_CMDR) SDIO Special Command */
#define HSMCI_CMDR_ATACS (0x1 << 26) /**< \brief (HSMCI_CMDR) ATA with Command Completion Signal */
#define HSMCI_CMDR_BOOT_ACK (0x1 << 27) /**< \brief (HSMCI_CMDR) Boot Operation Acknowledge. */
/* -------- HSMCI_BLKR : (HSMCI Offset: 0x18) Block Register -------- */
#define HSMCI_BLKR_BCNT_Pos 0
#define HSMCI_BLKR_BCNT_Msk (0xffffu << HSMCI_BLKR_BCNT_Pos) /**< \brief (HSMCI_BLKR) MMC/SDIO Block Count - SDIO Byte Count */
#define HSMCI_BLKR_BCNT_MULTIPLE (0x0u << 0) /**< \brief (HSMCI_BLKR) MMC/SDCARD Multiple BlockFrom 1 to 65635: Value 0 corresponds to an infinite block transfer. */
#define HSMCI_BLKR_BCNT_BYTE (0x4u << 0) /**< \brief (HSMCI_BLKR) SDIO ByteFrom 1 to 512 bytes: Value 0 corresponds to a 512-byte transfer.Values from 0x200 to 0xFFFF are forbidden. */
#define HSMCI_BLKR_BCNT_BLOCK (0x5u << 0) /**< \brief (HSMCI_BLKR) SDIO BlockFrom 1 to 511 blocks: Value 0 corresponds to an infinite block transfer.Values from 0x200 to 0xFFFF are forbidden. */
#define HSMCI_BLKR_BLKLEN_Pos 16
#define HSMCI_BLKR_BLKLEN_Msk (0xffffu << HSMCI_BLKR_BLKLEN_Pos) /**< \brief (HSMCI_BLKR) Data Block Length */
#define HSMCI_BLKR_BLKLEN(value) ((HSMCI_BLKR_BLKLEN_Msk & ((value) << HSMCI_BLKR_BLKLEN_Pos)))
#define HSMCI_BLKR_BCNT (0xffff << 0) /**< \brief (HSMCI_BLKR) MMC/SDIO Block Count - SDIO Byte Count */
#define HSMCI_BLKR_BLKLEN (0xffff << 16) /**< \brief (HSMCI_BLKR) Data Block Length */
/* -------- HSMCI_CSTOR : (HSMCI Offset: 0x1C) Completion Signal Timeout Register -------- */
#define HSMCI_CSTOR_CSTOCYC_Pos 0
#define HSMCI_CSTOR_CSTOCYC_Msk (0xfu << HSMCI_CSTOR_CSTOCYC_Pos) /**< \brief (HSMCI_CSTOR) Completion Signal Timeout Cycle Number */
#define HSMCI_CSTOR_CSTOCYC(value) ((HSMCI_CSTOR_CSTOCYC_Msk & ((value) << HSMCI_CSTOR_CSTOCYC_Pos)))
#define HSMCI_CSTOR_CSTOMUL_Pos 4
#define HSMCI_CSTOR_CSTOMUL_Msk (0x7u << HSMCI_CSTOR_CSTOMUL_Pos) /**< \brief (HSMCI_CSTOR) Completion Signal Timeout Multiplier */
#define HSMCI_CSTOR_CSTOMUL_1 (0x0u << 4) /**< \brief (HSMCI_CSTOR) CSTOCYC x 1 */
#define HSMCI_CSTOR_CSTOMUL_16 (0x1u << 4) /**< \brief (HSMCI_CSTOR) CSTOCYC x 16 */
#define HSMCI_CSTOR_CSTOMUL_128 (0x2u << 4) /**< \brief (HSMCI_CSTOR) CSTOCYC x 128 */
#define HSMCI_CSTOR_CSTOMUL_256 (0x3u << 4) /**< \brief (HSMCI_CSTOR) CSTOCYC x 256 */
#define HSMCI_CSTOR_CSTOMUL_1024 (0x4u << 4) /**< \brief (HSMCI_CSTOR) CSTOCYC x 1024 */
#define HSMCI_CSTOR_CSTOMUL_4096 (0x5u << 4) /**< \brief (HSMCI_CSTOR) CSTOCYC x 4096 */
#define HSMCI_CSTOR_CSTOMUL_65536 (0x6u << 4) /**< \brief (HSMCI_CSTOR) CSTOCYC x 65536 */
#define HSMCI_CSTOR_CSTOMUL_1048576 (0x7u << 4) /**< \brief (HSMCI_CSTOR) CSTOCYC x 1048576 */
#define HSMCI_CSTOR_CSTOCYC (0xf << 0) /**< \brief (HSMCI_CSTOR) Completion Signal Timeout Cycle Number */
#define HSMCI_CSTOR_CSTOMUL (0x7 << 4) /**< \brief (HSMCI_CSTOR) Completion Signal Timeout Multiplier */
/* -------- HSMCI_RSPR[4] : (HSMCI Offset: 0x20) Response Register -------- */
#define HSMCI_RSPR_RSP (0xffffffff << 0) /**< \brief (HSMCI_RSPR[4]) Response */
/* -------- HSMCI_RDR : (HSMCI Offset: 0x30) Receive Data Register -------- */
@@ -1403,7 +1322,6 @@ typedef struct {
RoReg PIO_PCIMR; /**< \brief (Pio Offset: 0x15C) Parallel Capture Interrupt Mask Register */
RoReg PIO_PCISR; /**< \brief (Pio Offset: 0x160) Parallel Capture Interrupt Status Register */
RoReg PIO_PCRHR; /**< \brief (Pio Offset: 0x164) Parallel Capture Reception Holding Register */
RwReg Reserved14[38];
} Pio;
#endif /* __ASSEMBLY__ */
/* -------- PIO_PER : (PIO Offset: 0x0000) PIO Enable Register -------- */
@@ -3082,15 +3000,9 @@ typedef struct {
#define CKGR_PLLAR_MULA (0x7ff << 16) /**< \brief (CKGR_PLLAR) PLLA Multiplier */
#define CKGR_PLLAR_STUCKTO1 (0x1 << 29) /**< \brief (CKGR_PLLAR) */
/* -------- CKGR_PLLBR : (PMC Offset: 0x002C) PLLB Register -------- */
#define CKGR_PLLBR_DIVB_Pos 0
#define CKGR_PLLBR_DIVB_Msk (0xffu << CKGR_PLLBR_DIVB_Pos) /**< \brief (CKGR_PLLBR) Divider */
#define CKGR_PLLBR_DIVB(value) ((CKGR_PLLBR_DIVB_Msk & ((value) << CKGR_PLLBR_DIVB_Pos)))
#define CKGR_PLLBR_PLLBCOUNT_Pos 8
#define CKGR_PLLBR_PLLBCOUNT_Msk (0x3fu << CKGR_PLLBR_PLLBCOUNT_Pos) /**< \brief (CKGR_PLLBR) PLLB Counter */
#define CKGR_PLLBR_PLLBCOUNT(value) ((CKGR_PLLBR_PLLBCOUNT_Msk & ((value) << CKGR_PLLBR_PLLBCOUNT_Pos)))
#define CKGR_PLLBR_MULB_Pos 16
#define CKGR_PLLBR_MULB_Msk (0x7ffu << CKGR_PLLBR_MULB_Pos) /**< \brief (CKGR_PLLBR) PLLB Multiplier */
#define CKGR_PLLBR_MULB(value) ((CKGR_PLLBR_MULB_Msk & ((value) << CKGR_PLLBR_MULB_Pos)))
#define CKGR_PLLBR_DIVB (0xff << 0) /**< \brief (CKGR_PLLBR) Divider */
#define CKGR_PLLBR_PLLBCOUNT (0x3f << 8) /**< \brief (CKGR_PLLBR) PLLB Counter */
#define CKGR_PLLBR_MULB (0x7ff << 16) /**< \brief (CKGR_PLLBR) PLLB Multiplier */
/* -------- PMC_MCKR : (PMC Offset: 0x0030) Master Clock Register -------- */
#define PMC_MCKR_CSS (0x3 << 0) /**< \brief (PMC_MCKR) Master Clock Source Selection */
#define PMC_MCKR_CSS_SLOW_CLK (0x0 << 0) /**< \brief (PMC_MCKR) Slow Clock is selected */
@@ -3108,10 +3020,8 @@ typedef struct {
#define PMC_MCKR_PLLADIV2 (0x1 << 12) /**< \brief (PMC_MCKR) PLLA Divisor by 2 */
#define PMC_MCKR_PLLBDIV2 (0x1 << 13) /**< \brief (PMC_MCKR) PLLB Divisor by 2 */
/* -------- PMC_USB : (PMC Offset: 0x0038) USB Clock Register -------- */
#define PMC_USB_USBS (0x1u << 0) /**< \brief (PMC_USB) USB Input Clock Selection */
#define PMC_USB_USBDIV_Pos 8
#define PMC_USB_USBDIV_Msk (0xfu << PMC_USB_USBDIV_Pos) /**< \brief (PMC_USB) Divider for USB Clock. */
#define PMC_USB_USBDIV(value) ((PMC_USB_USBDIV_Msk & ((value) << PMC_USB_USBDIV_Pos)))
#define PMC_USB_USBS (0x1 << 0) /**< \brief (PMC_USB) USB Input Clock Selection */
#define PMC_USB_USBDIV (0xf << 8) /**< \brief (PMC_USB) Divider for USB Clock. */
/* -------- PMC_PCK[3] : (PMC Offset: 0x0040) Programmable Clock 0 Register -------- */
#define PMC_PCK_CSS (0x7 << 0) /**< \brief (PMC_PCK[3]) Master Clock Source Selection */
#define PMC_PCK_PRES (0x7 << 4) /**< \brief (PMC_PCK[3]) Programmable Clock Prescaler */
@@ -3329,8 +3239,8 @@ typedef struct {
RwReg PWM_CMR; /**< \brief (PwmCh_num Offset: 0x0) PWM Channel Mode Register */
RwReg PWM_CDTY; /**< \brief (PwmCh_num Offset: 0x4) PWM Channel Duty Cycle Register */
RwReg PWM_CDTYUPD; /**< \brief (PwmCh_num Offset: 0x8) PWM Channel Duty Cycle Update Register */
RwReg PWM_CPDR; /**< \brief (PwmCh_num Offset: 0xC) PWM Channel Period Register */
RwReg PWM_CPDRUPD; /**< \brief (PwmCh_num Offset: 0x10) PWM Channel Period Update Register */
RwReg PWM_CPRD; /**< \brief (PwmCh_num Offset: 0xC) PWM Channel Period Register */
RwReg PWM_CPRDUPD; /**< \brief (PwmCh_num Offset: 0x10) PWM Channel Period Update Register */
RwReg PWM_CCNT; /**< \brief (PwmCh_num Offset: 0x14) PWM Channel Counter Register */
RwReg PWM_DT; /**< \brief (PwmCh_num Offset: 0x18) PWM Channel Dead Time Register */
RwReg PWM_DTUPD; /**< \brief (PwmCh_num Offset: 0x1C) PWM Channel Dead Time Update Register */
@@ -4323,7 +4233,7 @@ typedef struct {
RwReg SPI_TNCR; /**< \brief (Spi Offset: 0x11C) Transmit Next Counter Register */
WoReg SPI_PTCR; /**< \brief (Spi Offset: 0x120) Transfer Control Register */
RoReg SPI_PTSR; /**< \brief (Spi Offset: 0x124) Transfer Status Register */
} Spi, AT91S_SPI, *AT91PS_SPI;
} Spi;
#endif /* __ASSEMBLY__ */
/* -------- SPI_CR : (SPI Offset: 0x00) Control Register -------- */
#define SPI_CR_SPIEN (0x1 << 0) /**< \brief (SPI_CR) SPI Enable */
@@ -4935,11 +4845,6 @@ typedef struct {
} Tc;
#endif /* __ASSEMBLY__ */
/* -------- TC_CCR0 : (TC Offset: 0x0) Channel Control Register (channel = 0) -------- */
#define TC_CCR_CLKEN TC_CCR0_CLKEN /**< \brief (TC_CCR) Counter Clock Enable Command */
#define TC_CCR_CLKDIS TC_CCR0_CLKDIS /**< \brief (TC_CCR) Counter Clock Disable Command */
#define TC_CCR_SWTRG TC_CCR0_SWTRG /**< \brief (TC_CCR) Software Trigger Command */
#define TC_CCR0_CLKEN (0x1 << 0) /**< \brief (TC_CCR0) Counter Clock Enable Command */
#define TC_CCR0_CLKDIS (0x1 << 1) /**< \brief (TC_CCR0) Counter Clock Disable Command */
#define TC_CCR0_SWTRG (0x1 << 2) /**< \brief (TC_CCR0) Software Trigger Command */
@@ -4967,8 +4872,6 @@ typedef struct {
#define TC_CMR0_ETRGEDG_FALLING (0x2 << 8) /**< \brief (TC_CMR0) falling edge */
#define TC_CMR0_ETRGEDG_BOTH (0x3 << 8) /**< \brief (TC_CMR0) each edge */
#define TC_CMR0_ABETRG (0x1 << 10) /**< \brief (TC_CMR0) TIOA or TIOB External Trigger Selection */
#define TC_CMR_CPCTRG TC_CMR0_CPCTRG
#define TC_CMR0_CPCTRG (0x1 << 14) /**< \brief (TC_CMR0) RC Compare Trigger Enable */
#define TC_CMR0_WAVE (0x1 << 15) /**< \brief (TC_CMR0) */
#define TC_CMR0_LDRA (0x3 << 16) /**< \brief (TC_CMR0) RA Loading Selection */
@@ -5016,8 +4919,6 @@ typedef struct {
#define TC_IER0_LOVRS (0x1 << 1) /**< \brief (TC_IER0) Load Overrun */
#define TC_IER0_CPAS (0x1 << 2) /**< \brief (TC_IER0) RA Compare */
#define TC_IER0_CPBS (0x1 << 3) /**< \brief (TC_IER0) RB Compare */
#define TC_IER_CPCS TC_IER0_CPCS
#define TC_IER0_CPCS (0x1 << 4) /**< \brief (TC_IER0) RC Compare */
#define TC_IER0_LDRAS (0x1 << 5) /**< \brief (TC_IER0) RA Loading */
#define TC_IER0_LDRBS (0x1 << 6) /**< \brief (TC_IER0) RB Loading */
@@ -5565,10 +5466,8 @@ typedef struct {
#define UDP_GLB_STAT_RSMINPR (0x1 << 3) /**< \brief (UDP_GLB_STAT) */
#define UDP_GLB_STAT_RMWUPE (0x1 << 4) /**< \brief (UDP_GLB_STAT) Remote Wake Up Enable */
/* -------- UDP_FADDR : (UDP Offset: 0x008) Function Address Register -------- */
#define UDP_FADDR_FADD_Pos 0
#define UDP_FADDR_FADD_Msk (0x7fu << UDP_FADDR_FADD_Pos) /**< \brief (UDP_FADDR) Function Address Value */
#define UDP_FADDR_FADD(value) ((UDP_FADDR_FADD_Msk & ((value) << UDP_FADDR_FADD_Pos)))
#define UDP_FADDR_FEN (0x1u << 8) /**< \brief (UDP_FADDR) Function Enable */
#define UDP_FADDR_FADD (0x7f << 0) /**< \brief (UDP_FADDR) Function Address Value */
#define UDP_FADDR_FEN (0x1 << 8) /**< \brief (UDP_FADDR) Function Enable */
/* -------- UDP_IER : (UDP Offset: 0x010) Interrupt Enable Register -------- */
#define UDP_IER_EP0INT (0x1 << 0) /**< \brief (UDP_IER) Enable Endpoint 0 Interrupt */
#define UDP_IER_EP1INT (0x1 << 1) /**< \brief (UDP_IER) Enable Endpoint 1 Interrupt */
@@ -5652,20 +5551,17 @@ typedef struct {
#define UDP_CSR_FORCESTALL (0x1 << 5) /**< \brief (UDP_CSR[8]) Force Stall (used by Control, Bulk and Isochronous Endpoints) */
#define UDP_CSR_RX_DATA_BK1 (0x1 << 6) /**< \brief (UDP_CSR[8]) Receive Data Bank 1 (only used by endpoints with ping-pong attributes) */
#define UDP_CSR_DIR (0x1 << 7) /**< \brief (UDP_CSR[8]) Transfer Direction (only available for control endpoints) */
#define UDP_CSR_EPTYPE_Pos 8
#define UDP_CSR_EPTYPE_Msk (0x7u << UDP_CSR_EPTYPE_Pos) /**< \brief (UDP_CSR[8]) Endpoint Type */
#define UDP_CSR_EPTYPE_CTRL (0x0u << 8) /**< \brief (UDP_CSR[8]) Control */
#define UDP_CSR_EPTYPE_ISO_OUT (0x1u << 8) /**< \brief (UDP_CSR[8]) Isochronous OUT */
#define UDP_CSR_EPTYPE_BULK_OUT (0x2u << 8) /**< \brief (UDP_CSR[8]) Bulk OUT */
#define UDP_CSR_EPTYPE_INT_OUT (0x3u << 8) /**< \brief (UDP_CSR[8]) Interrupt OUT */
#define UDP_CSR_EPTYPE_ISO_IN (0x5u << 8) /**< \brief (UDP_CSR[8]) Isochronous IN */
#define UDP_CSR_EPTYPE_BULK_IN (0x6u << 8) /**< \brief (UDP_CSR[8]) Bulk IN */
#define UDP_CSR_EPTYPE_INT_IN (0x7u << 8) /**< \brief (UDP_CSR[8]) Interrupt IN */
#define UDP_CSR_EPTYPE (0x7 << 8) /**< \brief (UDP_CSR[8]) Endpoint Type */
#define UDP_CSR_EPTYPE_CTRL (0x0 << 8) /**< \brief (UDP_CSR[8]) Control */
#define UDP_CSR_EPTYPE_ISO_OUT (0x1 << 8) /**< \brief (UDP_CSR[8]) Isochronous OUT */
#define UDP_CSR_EPTYPE_BULK_OUT (0x2 << 8) /**< \brief (UDP_CSR[8]) Bulk OUT */
#define UDP_CSR_EPTYPE_INT_OUT (0x3 << 8) /**< \brief (UDP_CSR[8]) Interrupt OUT */
#define UDP_CSR_EPTYPE_ISO_IN (0x5 << 8) /**< \brief (UDP_CSR[8]) Isochronous IN */
#define UDP_CSR_EPTYPE_BULK_IN (0x6 << 8) /**< \brief (UDP_CSR[8]) Bulk IN */
#define UDP_CSR_EPTYPE_INT_IN (0x7 << 8) /**< \brief (UDP_CSR[8]) Interrupt IN */
#define UDP_CSR_DTGLE (0x1 << 11) /**< \brief (UDP_CSR[8]) Data Toggle */
#define UDP_CSR_EPEDS (0x1 << 15) /**< \brief (UDP_CSR[8]) Endpoint Enable Disable */
#define UDP_CSR_RXBYTECNT_Pos 16
#define UDP_CSR_RXBYTECNT_Msk (0x7ffu << UDP_CSR_RXBYTECNT_Pos) /**< \brief (UDP_CSR[8]) Number of Bytes Available in the FIFO */
#define UDP_CSR_RXBYTECNT(value) ((UDP_CSR_RXBYTECNT_Msk & ((value) << UDP_CSR_RXBYTECNT_Pos)))
#define UDP_CSR_RXBYTECNT (0x7ff << 16) /**< \brief (UDP_CSR[8]) Number of Bytes Available in the FIFO */
/* -------- UDP_FDR[8] : (UDP Offset: 0x4C) Endpoint FIFO Data Register (ept_num = 0) -------- */
#define UDP_FDR_FIFO_DATA (0xff << 0) /**< \brief (UDP_FDR[8]) FIFO Data Value */
/* -------- UDP_TXVC : (UDP Offset: 0x074) Transceiver Control Register -------- */
@@ -6848,11 +6744,6 @@ typedef struct {
#define WDT CAST(Wdt , 0x400E1450U) /**< \brief (WDT ) Base Address */
#define RTC CAST(Rtc , 0x400E1460U) /**< \brief (RTC ) Base Address */
#define GPBR CAST(Gpbr , 0x400E1490U) /**< \brief (GPBR ) Base Address */
// indices for three pio structures
#define iPIOA 0
#define iPIOB 1
#define iPIOC 2
/*@}*/
/* ***************************************************************************** */
+24 -10
View File
@@ -76,12 +76,11 @@
#include <stdint.h>
#include <stdbool.h>
#ifdef REVA
// TODO
#include "AT91SAM3S2.h"
#if defined(at91sam3s4)
#include "at91sam3s4/chip.h"
#include "at91sam3s4/AT91SAM3S4.h"
#else
#include "at91sam3s4/chip.h"
#include "at91sam3s4/AT91SAM3S4.h"
#error Board does not support the specified chip.
#endif
//------------------------------------------------------------------------------
@@ -122,6 +121,7 @@
#define BOARD_MAINOSC 12000000
/// Master clock frequency (when using board_lowlevel.c).
//#define BOARD_MCK 48000000
#define BOARD_MCK 64000000
//------------------------------------------------------------------------------
@@ -293,10 +293,17 @@
/** List of all LEDs definitions. */
#define PINS_LEDS PIN_LED_0, PIN_LED_1, PIN_LED_2
/** MCI pins definition. */
#define PINS_MCI {0x3fUL << 26, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_PULLUP}
/** MCI pin Card Detect. */
#define PIN_MCI_CD {PIO_PB7, PIOB, ID_PIOB, PIO_INPUT, PIO_PULLUP}
#if 0
// TODO check BSS
/// MCI pins definition.
#define PINS_MCI {0x1f8, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_PULLUP}, \
{1 << 3, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
/// MCI pin Card Detect
#define PIN_MCI_CD \
{AT91C_PIO_PA25, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP}
#endif
/** Push button #0 definition. Attributes = pull-up + debounce + interrupt on rising edge. */
#define PIN_PUSHBUTTON_1 {1 << 3, PIOB, ID_PIOB, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE}
/** Push button #1 definition. Attributes = pull-up + debounce + interrupt on falling edge. */
@@ -382,6 +389,8 @@
#define PIN_USART1_RTS {0x1 << 24, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
#define PIN_USART1_EN {0x1 << 23, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
/// USB VBus monitoring pin definition.
#ifdef BOARD_REV_A
#define PIN_USB_VBUS {1 << 23, PIOC, ID_PIOC, PIO_INPUT, PIO_DEFAULT}
@@ -518,8 +527,13 @@
#define MCI2_INTERFACE
/// Base address of the MCI peripheral connected to the SD card.
#define BOARD_SD_MCI_BASE MCI0//MCI
#if 0
// TODO check BSS
///// Peripheral identifier of the MCI connected to the SD card.
#define BOARD_SD_MCI_ID AT91C_ID_MCI0 ID_MCI0 //ID_MCI
#define BOARD_SD_MCI_ID ID_MCI0 //ID_MCI
#endif
///// MCI pins that shall be configured to access the SD card.
#define BOARD_SD_PINS PINS_MCI
///// MCI slot to which the SD card is connected to.
-203
View File
@@ -1,203 +0,0 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, Atmel Corporation
*
* 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 disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
* ----------------------------------------------------------------------------
*/
/** \addtogroup hsmci_module Working with HSMCI
* The HSMCI driver provides the interface to configure and use the HSMCI
* peripheral.
*
* The user needs to set the number of wait states depending on the frequency used.\n
* Configure number of cycles for flash read/write operations in the FWS field of HSMCI_FMR.
*
* It offers a function to send flash command to HSMCI and waits for the
* flash to be ready.
*
* To send flash command, the user could do in either of following way:
* <ul>
* <li>Write a correct key, command and argument in HSMCI_FCR. </li>
* <li>Or, Use IAP (In Application Programming) function which is executed from
* ROM directly, this allows flash programming to be done by code running in flash.</li>
* <li>Once the command is achieved, it can be detected even by polling EEFC_FSR or interrupt.
* </ul>
*
* The command argument could be a page number,GPNVM number or nothing, it depends on
* the command itself. Some useful functions in this driver could help user tranlate physical
* flash address into a page number and vice verse.
*
* For more accurate information, please look at the EEFC section of the
* Datasheet.
*
* Related files :\n
* \ref hsmci_pdc.c\n
* \ref hsmci.h.\n
*/
/*@{*/
/*@}*/
/**
* \file
*/
/**
*
* \section Purpose
*
* Implement MultiMediaCard(MCI) Interface Driver
*
* \section Usage
*
* -# MCI_Init(): Initializes a MCI driver instance and the underlying
* peripheral.
* -# MCI_Handler() : Interrupt handler which is called by ISR handler.
* -# MCI_SetSpeed() : Configure the MCI CLKDIV in the _MR register
* (\ref Hsmci::HSMCI_MR).
* -# MCI_SetBusWidth() : Configure the MCI SDCBUS in the _SDCR register
* (\ref Hsmci::HSMCI_SDCR).
* -# MCI_EnableHsMode() : Configure the MCI HSMODE in the _CFG register
* (\ref Hsmci::HSMCI_CFG).
*/
#ifndef HSMCID_H
#define HSMCID_H
/** \addtogroup sdmmc_hal
*@{
*/
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include <stdint.h>
#include <stdio.h>
#include "board.h"
/*----------------------------------------------------------------------------
* Constants
*----------------------------------------------------------------------------*/
/* Transfer type */
/** MultiMedia Transfer type: no data */
#define MCI_NO_TRANSFER 0
/** MultiMedia Transfer type: Device to Host (read) */
#define MCI_START_READ 1
/** MultiMedia Transfer type: Host to Device (write) & check BUSY */
#define MCI_START_WRITE 2
/** Device to Host (read) without command */
#define MCI_READ 3
/** Host to Device (write) without command & check BUSY */
#define MCI_WRITE 4
/** MultiMedia Transfer type: STOP transfer */
#define MCI_STOP_TRANSFER 5
/** MCI Initialize clock 400K Hz */
#define MCI_INITIAL_SPEED 400000
/*----------------------------------------------------------------------------
* Types
*----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* \brief MCI Transfer Request prepared by the application upper layer.
*
* This structure is sent to the Sdmmc_SendCommand function to start the transfer.
* At the end of the transfer, the callback is invoked.
*/
typedef struct _MciCmd {
/** Command code. */
uint32_t cmd;
/** Command argument. */
uint32_t arg;
/** Data buffer, with MCI_DMA_ENABLE defined 1, the buffer can be
* 1, 2 or 4 bytes aligned. It has to be 4 byte aligned if no DMA.
*/
uint8_t *pData;
/** Size of data block in bytes. */
uint16_t blockSize;
/** Number of blocks to be transfered */
uint16_t nbBlock;
/** Response buffer. */
uint32_t *pResp;
/** Optional user-provided callback function. */
void (*callback)( uint8_t status, void *pArg ) ;
/** Optional argument to the callback function. */
void *pArg;
/** SD card command option. */
uint8_t resType:7, /** Response */
busyCheck:1; /** Check busy as end of command */
/** Indicate transfer type */
uint8_t tranType;
/** Indicate end of transfer status */
uint8_t status;
/** Command state. */
volatile uint8_t state;
} MciCmd;
/**
* \brief MCI Driver
*/
typedef struct
{
/** Pointer to a MCI peripheral. */
Hsmci *pMciHw;
/** Pointer to currently executing command. */
MciCmd *pCommand;
/** MCI peripheral identifier. */
uint8_t mciId;
/** Mutex. */
volatile uint8_t semaphore;
} Mcid;
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
extern void MCI_Disable(Hsmci *pMciHw);
extern void MCI_Enable(Hsmci *pMciHw);
extern uint8_t MCI_EnableHsMode(Mcid * pMci, uint8_t hsEnable);
extern void MCI_Init( Mcid *pMci, Hsmci *pMciHw, uint8_t mciId, uint32_t dwMCk ) ;
extern uint32_t MCI_SetBusWidth(Mcid *pMci, uint32_t busWidth);
extern uint32_t MCI_SetSpeed(Mcid *pMci, uint32_t mciSpeed, uint32_t mck);
/* pdc if used */
extern void MCI_Reset(Mcid *pMci, uint8_t keepSettings);
#ifdef __cplusplus
}
#endif
/**@}*/
#endif //#ifndef HSMCID_H
@@ -1,308 +0,0 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* 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 disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
* ----------------------------------------------------------------------------
*/
/**
* \file
*
* Implementation of High Speed MultiMedia Card Interface (HSMCI) controller,
* using PDC to transfer data.
*
*/
/*---------------------------------------------------------------------------
* Headers
*---------------------------------------------------------------------------*/
#include "board.h"
#include "hsmci.h"
#include "pmc/pmc.h"
// #include <assert.h>
#define assert(...)
/*---------------------------------------------------------------------------
* Local macros
*---------------------------------------------------------------------------*/
/** Reset MCI */
#define MCI_RESET(pMciHw) (pMciHw->HSMCI_CR = HSMCI_CR_SWRST)
/*---------------------------------------------------------------------------
* Exported functions
*---------------------------------------------------------------------------*/
/**
* Enable MCI
* \param pMciHw Pointer to a MCI peripheral.
*/
void MCI_Enable(Hsmci *pMciHw)
{
pMciHw->HSMCI_CR = HSMCI_CR_MCIEN;
}
/**
* Disable MCI
* \param pMciHw Pointer to a MCI peripheral.
*/
void MCI_Disable(Hsmci *pMciHw)
{
pMciHw->HSMCI_CR = HSMCI_CR_MCIDIS;
}
/**
* Initializes a MCI driver instance and the underlying peripheral.
* \param pMci Pointer to a MCI driver instance.
* \param pMciHw Pointer to a MCI peripheral.
* \param mciId MCI peripheral identifier.
*/
void MCI_Init( Mcid *pMci, Hsmci *pMciHw, uint8_t mciId, uint32_t dwMCk )
{
unsigned short clkDiv;
/* Initialize the MCI driver structure */
pMci->pMciHw = pMciHw;
pMci->mciId = mciId;
pMci->semaphore = 1;
pMci->pCommand = NULL;
/* Enable the MCI peripheral */
PMC_EnablePeripheral( mciId ) ;
/* Reset the MCI */
pMciHw->HSMCI_CR = HSMCI_CR_SWRST;
/* Disable the MCI */
pMciHw->HSMCI_CR = HSMCI_CR_MCIDIS | HSMCI_CR_PWSDIS;
/* Disable all the interrupts */
pMciHw->HSMCI_IDR = 0xFFFFFFFF;
/* Set the Data Timeout Register */
pMciHw->HSMCI_DTOR = HSMCI_DTOR_DTOCYC_Msk | HSMCI_DTOR_DTOMUL_Msk ;
/* CSTOR ? */
pMciHw->HSMCI_CSTOR = HSMCI_CSTOR_CSTOCYC_Msk | HSMCI_CSTOR_CSTOMUL_Msk ;
/* Set the Mode Register: 400KHz for MCK = 48MHz (CLKDIV = 58) */
clkDiv = (dwMCk / (MCI_INITIAL_SPEED * 2)) - 1;
pMciHw->HSMCI_MR = (clkDiv | (HSMCI_MR_PWSDIV( 0x07 )) ) ;
/* Set the SDCard Register 1-bit, slot A */
pMciHw->HSMCI_SDCR = HSMCI_SDCR_SDCSEL_SLOTA | HSMCI_SDCR_SDCBUS_1 ;
/* Enable the MCI and the Power Saving */
pMciHw->HSMCI_CR = HSMCI_CR_MCIEN;
/* Configure MCI */
pMciHw->HSMCI_CFG = HSMCI_CFG_FIFOMODE
| ((1 << 4) & HSMCI_CFG_FERRCTRL);
/* Disable the MCI peripheral clock. */
PMC_DisablePeripheral(mciId);
}
/**
* Reset MCI HW interface and disable it.
* \param keepSettings Keep old register settings, including
* _MR, _SDCR, _DTOR, _CSTOR, _DMA and _CFG.
*/
void MCI_Reset(Mcid *pMci, uint8_t keepSettings)
{
Hsmci *pMciHw = pMci->pMciHw;
uint8_t mciDis;
assert(pMci);
assert(pMci->pMciHw);
PMC_EnablePeripheral(pMci->mciId);
mciDis = PMC_IsPeriphEnabled(pMci->mciId);
if (keepSettings)
{
uint32_t mr, sdcr, dtor, cstor;
uint32_t cfg;
mr = pMciHw->HSMCI_MR;
sdcr = pMciHw->HSMCI_SDCR;
dtor = pMciHw->HSMCI_DTOR;
cstor = pMciHw->HSMCI_CSTOR;
cfg = pMciHw->HSMCI_CFG;
MCI_RESET(pMciHw);
MCI_Disable(pMciHw);
pMciHw->HSMCI_MR = mr;
pMciHw->HSMCI_SDCR = sdcr;
pMciHw->HSMCI_DTOR = dtor;
pMciHw->HSMCI_CSTOR = cstor;
pMciHw->HSMCI_CFG = cfg;
}
else
{
MCI_RESET(pMciHw);
MCI_Disable(pMciHw);
}
if ( mciDis )
{
PMC_DisablePeripheral( pMci->mciId ) ;
}
}
/**
* Configure the MCI CLKDIV in the MCI_MR register. The max. for MCI clock is
* MCK/2 and corresponds to CLKDIV = 0
* \param pMci Pointer to the low level MCI driver.
* \param mciSpeed MCI clock speed in Hz, 0 will not change current speed.
* \param mck MCK to generate MCI Clock, in Hz
* \return The actual speed used, 0 for fail.
*/
uint32_t MCI_SetSpeed( Mcid* pMci, uint32_t mciSpeed, uint32_t mck )
{
Hsmci *pMciHw = pMci->pMciHw;
uint32_t mciMr;
uint32_t clkdiv;
uint8_t mciDis;
assert(pMci);
assert(pMciHw);
PMC_EnablePeripheral(pMci->mciId);
mciDis = PMC_IsPeriphEnabled(pMci->mciId);
mciMr = pMciHw->HSMCI_MR & (~(uint32_t)HSMCI_MR_CLKDIV_Msk);
/* Multimedia Card Interface clock (MCCK or MCI_CK) is Master Clock (MCK)
* divided by (2*(CLKDIV+1))
* mciSpeed = MCK / (2*(CLKDIV+1)) */
if (mciSpeed > 0)
{
clkdiv = (mck / 2 / mciSpeed);
/* Speed should not bigger than expired one */
if (mciSpeed < mck/2/clkdiv)
{
clkdiv ++;
}
if ( clkdiv > 0 )
{
clkdiv -= 1;
}
assert( (clkdiv & 0xFFFFFF00) == 0 ) ; /* "mciSpeed too small" */
}
else
{
clkdiv = 0 ;
}
/* Actual MCI speed */
mciSpeed = mck / 2 / (clkdiv + 1);
/* Modify MR */
pMciHw->HSMCI_MR = mciMr | clkdiv;
if ( mciDis )
{
PMC_DisablePeripheral( pMci->mciId ) ;
}
return (mciSpeed);
}
/**
* Configure the MCI_CFG to enable the HS mode
* \param pMci Pointer to the low level MCI driver.
* \param hsEnable 1 to enable, 0 to disable HS mode.
*/
uint8_t MCI_EnableHsMode(Mcid* pMci, uint8_t hsEnable)
{
Hsmci *pMciHw = pMci->pMciHw;
uint32_t cfgr;
uint8_t mciDis;
uint8_t rc = 0;
assert(pMci);
assert(pMci->pMciHw);
PMC_EnablePeripheral(pMci->mciId);
mciDis = PMC_IsPeriphEnabled(pMci->mciId);
cfgr = pMciHw->HSMCI_CFG;
if (hsEnable == 1)
{
cfgr |= HSMCI_CFG_HSMODE;
}
else
{
if (hsEnable == 0)
{
cfgr &= ~(uint32_t)HSMCI_CFG_HSMODE;
}
else
{
rc = ((cfgr & HSMCI_CFG_HSMODE) != 0);
}
}
pMciHw->HSMCI_CFG = cfgr;
if (mciDis)
{
PMC_DisablePeripheral(pMci->mciId);
}
return rc;
}
/**
* Configure the MCI SDCBUS in the MCI_SDCR register. Only two modes available
*
* \param pMci Pointer to the low level MCI driver.
* \param busWidth MCI bus width mode. 00: 1-bit, 10: 4-bit, 11: 8-bit.
*/
uint32_t MCI_SetBusWidth(Mcid*pMci, uint32_t busWidth)
{
Hsmci *pMciHw = pMci->pMciHw;
uint32_t mciSdcr;
uint8_t mciDis;
assert(pMci);
assert(pMci->pMciHw);
if( (busWidth != HSMCI_SDCR_SDCBUS_1) && (busWidth != HSMCI_SDCR_SDCBUS_4) && (busWidth != HSMCI_SDCR_SDCBUS_8) )
{
return (uint32_t)-1;
}
busWidth &= HSMCI_SDCR_SDCBUS_Msk ;
PMC_EnablePeripheral(pMci->mciId);
mciDis = PMC_IsPeriphEnabled(pMci->mciId);
mciSdcr = (pMciHw->HSMCI_SDCR & ~(uint32_t)(HSMCI_SDCR_SDCBUS_Msk));
pMciHw->HSMCI_SDCR = mciSdcr | busWidth;
if (mciDis)
{
PMC_DisablePeripheral(pMci->mciId);
}
return 0;
}
@@ -0,0 +1,16 @@
COPT=-g3 -Wall -Os -mmcu=atmega128
INCLUDEDIRS=-Iinc -Iconf
CFLAGS=$(COPT) $(INCLUDEDIRS)
CC=avr-gcc
AR=avr-ar
OBJCOPY=avr-objcopy
OBJ=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/mkfs.o src/debug.o src/ioman.o src/ui.o src/extract.o src/interfaces/atmega128.o src/interfaces/sd.o
all: lib
lib: $(OBJ)
$(AR) rcs libefsl.a $(OBJ)
clean :
rm -f $(OBJ) libefsl.a
@@ -0,0 +1,51 @@
COPT=-g3 -ansi -Wall -pedantic -O0
#COPT=-O3 -march=pentium3 -g3
INCLUDEDIRS=-Iinc -Iconf
CFLAGS=$(COPT) $(INCLUDEDIRS)
CC=gcc
AR=ar
OBJ=src/efs.o
OBJ+=src/plibc.o
OBJ+=src/disc.o
OBJ+=src/partition.o
OBJ+=src/fs.o
OBJ+=src/fat.o
OBJ+=src/time.o
OBJ+=src/file.o
OBJ+=src/dir.o
OBJ+=src/mkfs.o
OBJ+=src/debug.o
OBJ+=src/ioman.o
OBJ+=src/ui.o
OBJ+=src/ls.o
OBJ+=src/extract.o
OBJ+=src/interfaces/helper.o
OBJ+=src/interfaces/linuxfile.o
all: lib
lib: $(OBJ)
$(AR) rcs libefsl.a $(OBJ)
len: src/len.o lib
$(CC) $(CFLAGS) -o test src/len.o -L. -lefsl
regtest: clean src/regressiontest.o $(OBJ)
$(CC) $(CFLAGS) -o regtest src/regressiontest.o $(OBJ)
mv regtest testfiles
clean:
rm -f $(OBJ) src/len.o src/flex.o src/regressiontest.o test libefsl.a
@cd linuxutils ; make clean
clearscreen:
clear
utils: lib
@cd linuxutils ; make all
purge: clean clearscreen len
image: clearscreen
dd if=/dev/zero of=./image32 bs=1M count=50
/sbin/mkfs.vfat -F32 -v ./image32
@@ -0,0 +1,25 @@
# efsl library makefile for LPC2000
# by Martin Thomas
# (based on the efsl avr- and the WinARM-template makefiles)
MCU = arm7tdmi-s
THUMB = -mthumb -mthumb-interwork
COPT= -mcpu=$(MCU) $(THUMB) -g3 -Wall -Os
INCLUDEDIRS=-Iinc -Iconf
CFLAGS=$(COPT) $(INCLUDEDIRS)
CC=arm-elf-gcc
AR=arm-elf-ar
OBJCOPY=arm-elf-objcopy
OBJ=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/mkfs.o src/debug.o src/ioman.o src/ui.o src/extract.o src/interfaces/sd.o
OBJ+=src/ls.o
OBJ+=src/interfaces/lpc2000_spi.o src/interfaces/lpc2000_dbg_printf.o
all: lib
lib: $(OBJ)
$(AR) rcs libefsl.a $(OBJ)
clean :
rm -f $(OBJ) libefsl.a
@@ -0,0 +1,157 @@
#ifndef __EFSL_CONFIG_H__
#define __EFSL_CONFIG_H__
/* Hardware target
---------------
* Here you will define for what hardware-endpoint EFSL should be compiled.
* Look in interfaces.h to see what systems are supported, and add your own
* there if you need to write your own driver. Then, define the name you
* selected for your hardware there here. Make sure that you only select one
* device!
*/
/*#define HW_ENDPOINT_LINUX*/
#define HW_ENDPOINT_ATMEGA128_SD
/*#define HW_ENDPOINT_DSP_TI6713_SD*/
/* Memory configuration
--------------------
* Here you must configure wheter your processor can access memory byte
* oriented. All x86 processors can do it, AVR's can do it to. Some DSP
* or other microcontrollers can't. If you have an 8 bit system you're safe.
* If you are really unsure, leave the setting commented out, it will be slower
* but it will work for sure.
*/
#define BYTE_ALIGNMENT
/* Cache configuration
-------------------
* Here you must configure how much memory of cache you can/want to use.
* The number you put at IOMAN_NUMBUFFER is multiplied by 512. So 1 means
* 512 bytes cache, 4 means 2048 bytes cache. More is better.
* The number after IOMAN_NUMITERATIONS should be untouched.
* The last field (IOMAN_DO_MEMALLOC) is to tell ioman to allocate it's
* own memory in it's structure, or not. If you choose to do it yourself
* you will have to pass a pointer to the memory as the last argument of
* ioman_init.
*/
#define IOMAN_NUMBUFFER 1
#define IOMAN_NUMITERATIONS 3
#define IOMAN_DO_MEMALLOC
/* Cluster pre-allocation
----------------------
* When writing files, the function that performs the actual write has to
* calculate how many clusters it will need for that request. It then allocates
* that number of new clusters to the file. Since this involves some
* calculations and writing of the FAT, you might find it beneficial to limit
* the number of allocations, and allow fwrite to pre-allocate a number of
* clusters extra. This setting determines how many clusters will be extra
* allocated whenever this is required.
* Take in carefull consideration how large your clustersize is, putting 10 here
* with a clustersize of 32kb means you might waste 320 kb.
* The first option is for preallocating files, the other is used when enlarging
* a directory to accomodate more files
*/
#define CLUSTER_PREALLOC_FILE 0
#define CLUSTER_PREALLOC_DIRECTORY 0
/* Endianess configuration
-----------------------
* Here you can configure wheter your architecture is little or big endian. This
* is important since all FAT structures are stored in intel little endian
* order. So if you have a big endian system the library has to convert all
* figures to big endian in order to work.
*/
#define LITTLE_ENDIAN
/* Date and Time support
---------------------
* Here you can enable or disable date and time support. If you enable
* it you will have to create 6 functions, that are described in the
* EFSL manual. If the functions are not present when linking your
* program with the library you will get unresolved dependencies.
*/
/* #define DATE_TIME_SUPPORT */
/* Error reporting support
-----------------------
* When you receive an error in userland, it usually only gives limited
* information (most likely, fail or success). If error detection and
* reporting is important for you, you can enable more detailed error
* reporting here. This is optional, the costs are 1 byte per object,
* and a small increase in code size.
* You can enable error recording for all object, or you can select the
* object manually.
* For full error reporting use FULL_ERROR_SUPPORT
* For only the base-core of the library use BASE_ERROR_SUPPORT
* For IO/Man use ERRSUP_IOMAN
* For Disc use ERRSUP_IOMAN
* For Part use ERRSUP_PARTITION
* For Fs use ERRSUP_FILESYSTEM
* For File use ERRSUP_FILE
*/
#define FULL_ERROR_SUPPORT
/*#define BASE_ERROR_SUPPORT*/
/* List options
------------
* In this section you can configure what kind of data you will get from
* directory listing requests. Please refer to the documentation for
* more information
*/
#define LIST_MAXLENFILENAME 12
/* Debugging configuration
-----------------------
* Here you can configure the debugging behaviour. Debugging is different
* on every platform (see debug.h for more information).
* If your hardware has no means of output (printf) dont define any anything,
* and nothing will happen. For real world use debugging should be turned off.
*/
#define DEBUG
/* Debugging configuration - AVR Specific: PORT
--------------------------------------------
* Here you can select which UART you want to use for debugging.
* If you did not define DEBUG, this setting has no effect.
* Note that it is not a good idea to use a port that you use in userspace.
*/
#define DEBUG_PORT 0 /* Select UART0 */
/*#define DEBUG_PORT 1*/ /* Select UART1 */
/* Debugging configuration - AVR Specific: UBRR
--------------------------------------------
* Here you can set UBRR, this value will select the serial clock speed.
* This value depends on your baudrate and clockrate. U2X is by standard 0,
* if you would want this 1 for some reason, this can be done in debug.c.
*/
#define DEBUG_UBRR 51 /* 9600bps on 8Mhz */
/*#define DEBUG_UBRR 95*/ /* 9600bps on 14.7456Mhz */
/*#define DEBUG_UBRR 103*/ /* 9600bps on 16Mhz */
#endif
@@ -0,0 +1,129 @@
#ifndef __EFSL_CONFIG_H__
#define __EFSL_CONFIG_H__
/* Hardware target
---------------
* Here you will define for what hardware-endpoint EFSL should be compiled.
* Look in interfaces.h to see what systems are supported, and add your own
* there if you need to write your own driver. Then, define the name you
* selected for your hardware there here. Make sure that you only select one
* device!
*/
#define HW_ENDPOINT_LINUX
/*#define HW_ENDPOINT_ATMEGA128_SD*/
/*#define HW_ENDPOINT_DSP_TI6713_SD*/
/* Memory configuration
--------------------
* Here you must configure wheter your processor can access memory byte
* oriented. All x86 processors can do it, AVR's can do it to. Some DSP
* or other microcontrollers can't. If you have an 8 bit system you're safe.
* If you are really unsure, leave the setting commented out, it will be slower
* but it will work for sure.
*/
/*#define BYTE_ALIGNMENT*/
/* Cache configuration
-------------------
* Here you must configure how much memory of cache you can/want to use.
* The number you put at IOMAN_NUMBUFFER is multiplied by 512. So 1 means
* 512 bytes cache, 4 means 2048 bytes cache. More is better.
* The number after IOMAN_NUMITERATIONS should be untouched.
* The last field (IOMAN_DO_MEMALLOC) is to tell ioman to allocate it's
* own memory in it's structure, or not. If you choose to do it yourself
* you will have to pass a pointer to the memory as the last argument of
* ioman_init.
*/
#define IOMAN_NUMBUFFER 100
#define IOMAN_NUMITERATIONS 3
#define IOMAN_DO_MEMALLOC
/* Cluster pre-allocation
----------------------
* When writing files, the function that performs the actual write has to
* calculate how many clusters it will need for that request. It then allocates
* that number of new clusters to the file. Since this involves some
* calculations and writing of the FAT, you might find it beneficial to limit
* the number of allocations, and allow fwrite to pre-allocate a number of
* clusters extra. This setting determines how many clusters will be extra
* allocated whenever this is required.
* Take in carefull consideration how large your clustersize is, putting 10 here
* with a clustersize of 32kb means you might waste 320 kb.
* The first option is for preallocating files, the other is used when enlarging
* a directory to accomodate more files
*/
#define CLUSTER_PREALLOC_FILE 50
#define CLUSTER_PREALLOC_DIRECTORY 5
/* Endianess configuration
-----------------------
* Here you can configure wheter your architecture is little or big endian. This
* is important since all FAT structures are stored in intel little endian
* order. So if you have a big endian system the library has to convert all
* figures to big endian in order to work.
*/
#define LITTLE_ENDIAN
/* Date and Time support
---------------------
* Here you can enable or disable date and time support. If you enable
* it you will have to create 6 functions, that are described in the
* EFSL manual. If the functions are not present when linking your
* program with the library you will get unresolved dependencies.
*/
/* #define DATE_TIME_SUPPORT */
/* Error reporting support
-----------------------
* When you receive an error in userland, it usually only gives limited
* information (most likely, fail or success). If error detection and
* reporting is important for you, you can enable more detailed error
* reporting here. This is optional, the costs are 1 byte per object,
* and a small increase in code size.
* You can enable error recording for all object, or you can select the
* object manually.
* For full error reporting use FULL_ERROR_SUPPORT
* For only the base-core of the library use BASE_ERROR_SUPPORT
* For IO/Man use ERRSUP_IOMAN
* For Disc use ERRSUP_IOMAN
* For Part use ERRSUP_PARTITION
* For Fs use ERRSUP_FILESYSTEM
* For File use ERRSUP_FILE
*/
#define FULL_ERROR_SUPPORT
/*#define BASE_ERROR_SUPPORT*/
/* Debugging configuration
-----------------------
* Here you can configure the debugging behaviour. Debugging is different
* on every platform (see debug.h for more information).
* If your hardware has no means of output (printf) dont define any anything,
* and nothing will happen. For real world use debugging should be turned off.
*/
#define DEBUG
/*#define DO_FUNC_DEBUG*/
/* List options
------------
* In this section you can configure what kind of data you will get from
* directory listing requests. Please refer to the documentation for
* more information
*/
#define LIST_MAXLENFILENAME 12
#endif
@@ -0,0 +1,146 @@
#ifndef __EFSL_CONFIG_H__
#define __EFSL_CONFIG_H__
/* This is for the LPC2000 SD-Card SPI interface (M. Thomas) */
/* Hardware target
---------------
* Here you will define for what hardware-endpoint EFSL should be compiled.
* Look in interfaces.h to see what systems are supported, and add your own
* there if you need to write your own driver. Then, define the name you
* selected for your hardware there here. Make sure that you only select one
* device!
*/
/*#define HW_ENDPOINT_LINUX*/
/*#define HW_ENDPOINT_ATMEGA128_SD*/
#define HW_ENDPOINT_LPC2000_SD
/* defines the interface for LPC213x (0=SPI0 1=SPI1) */
// #define HW_ENDPOINT_LPC2000_SPINUM (0)
#define HW_ENDPOINT_LPC2000_SPINUM (1)
/*#define HW_ENDPOINT_DSP_TI6713_SD*/
/* Memory configuration
--------------------
* Here you must configure wheter your processor can access memory byte
* oriented. All x86 processors can do it, AVR's can do it to. Some DSP
* or other microcontrollers can't. If you have an 8 bit system you're safe.
* If you are really unsure, leave the setting commented out, it will be slower
* but it will work for sure.
*/
/* disabled for ARM (mt): #define BYTE_ALIGNMENT */
/* Cache configuration
-------------------
* Here you must configure how much memory of cache you can/want to use.
* The number you put at IOMAN_NUMBUFFER is multiplied by 512. So 1 means
* 512 bytes cache, 4 means 2048 bytes cache. More is better.
* The number after IOMAN_NUMITERATIONS should be untouched.
* The last field (IOMAN_DO_MEMALLOC) is to tell ioman to allocate it's
* own memory in it's structure, or not. If you choose to do it yourself
* you will have to pass a pointer to the memory as the last argument of
* ioman_init.
*/
/*#define IOMAN_NUMBUFFER 1*/
#define IOMAN_NUMBUFFER 6 /* 32kB RAM on the LPC2138 - let's use 3 kB */
#define IOMAN_NUMITERATIONS 3
#define IOMAN_DO_MEMALLOC
/* Cluster pre-allocation
----------------------
* When writing files, the function that performs the actual write has to
* calculate how many clusters it will need for that request. It then allocates
* that number of new clusters to the file. Since this involves some calculations
* and writing of the FAT, you might find it beneficial to limit the number of
* allocations, and allow fwrite to pre-allocate a number of clusters extra.
* This setting determines how many clusters will be extra allocated whenever
* this is required.
* Take in carefull consideration how large your clustersize is, putting 10 here
* with a clustersize of 32kb means you might waste 320 kb.
* The first option is for preallocating files, the other is used when enlarging
* a directory to accomodate more files
*/
/*#define CLUSTER_PREALLOC_FILE 0*/
#define CLUSTER_PREALLOC_FILE 2
#define CLUSTER_PREALLOC_DIRECTORY 0
/* Endianess configuration
-----------------------
* Here you can configure wheter your architecture is little or big endian. This
* is important since all FAT structures are stored in intel little endian order.
* So if you have a big endian system the library has to convert all figures to
* big endian in order to work.
*/
#define LITTLE_ENDIAN
/* Date and Time support
---------------------
* Here you can enable or disable date and time support. If you enable
* it you will have to create 6 functions, that are described in the
* EFSL manual. If the functions are not present when linking your
* program with the library you will get unresolved dependencies.
*/
/*#define DATE_TIME_SUPPORT*/
/* Error reporting support
-----------------------
* When you receive an error in userland, it usually only gives limited
* information (most likely, fail or success). If error detection and
* reporting is important for you, you can enable more detailed error
* reporting here. This is optional, the costs are 1 byte per object,
* and a small increase in code size.
* You can enable error recording for all object, or you can select the
* object manually.
* For full error reporting use FULL_ERROR_SUPPORT
* For only the base-core of the library use BASE_ERROR_SUPPORT
* For IO/Man use ERRSUP_IOMAN
* For Disc use ERRSUP_IOMAN
* For Part use ERRSUP_PARTITION
* For Fs use ERRSUP_FILESYSTEM
* For File use ERRSUP_FILE
*/
#define FULL_ERROR_SUPPORT
/*#define BASE_ERROR_SUPPORT*/
/* List options
------------
* In this section youcan configure what kind of data you will get from
* directory listing requests. Please refer to the documentation for
* more information
*/
#define LIST_MAXLENFILENAME 12
/* Debugging configuration
-----------------------
* Here you can configure the debugging behaviour. Debugging is different
* on every platform (see debug.h for more information).
* If your hardware has no means of output (printf) dont define any anything,
* and nothing will happen. For real world use debugging should be turned off.
*/
#define DEBUG
#endif
@@ -0,0 +1,133 @@
#ifndef __EFSL_CONFIG_H__
#define __EFSL_CONFIG_H__
/* Hardware target
---------------
* Here you will define for what hardware-endpoint EFSL should be compiled.
* Look in interfaces.h to see what systems are supported, and add your own
* there if you need to write your own driver. Then, define the name you
* selected for your hardware there here. Make sure that you only select one
* device!
*/
/*#define HW_ENDPOINT_LINUX*/
/*#define HW_ENDPOINT_ATMEGA128_SD*/
/*#define HW_ENDPOINT_DSP_TI6713_SD*/
#define HW_ENDPOINT_NIOS_2_SD
/* Memory configuration
--------------------
* Here you must configure wheter your processor can access memory byte
* oriented. All x86 processors can do it, AVR's can do it to. Some DSP
* or other microcontrollers can't. If you have an 8 bit system you're safe.
* If you are really unsure, leave the setting commented out, it will be slower
* but it will work for sure.
*/
/*#define BYTE_ALIGNMENT*/
/* Cache configuration
-------------------
* Here you must configure how much memory of cache you can/want to use.
* The number you put at IOMAN_NUMBUFFER is multiplied by 512. So 1 means
* 512 bytes cache, 4 means 2048 bytes cache. More is better.
* The number after IOMAN_NUMITERATIONS should be untouched.
* The last field (IOMAN_DO_MEMALLOC) is to tell ioman to allocate it's
* own memory in it's structure, or not. If you choose to do it yourself
* you will have to pass a pointer to the memory as the last argument of
* ioman_init.
*/
#define IOMAN_NUMBUFFER 1
#define IOMAN_NUMITERATIONS 3
#define IOMAN_DO_MEMALLOC
/* Cluster pre-allocation
----------------------
* When writing files, the function that performs the actual write has to
* calculate how many clusters it will need for that request. It then allocates
* that number of new clusters to the file. Since this involves some
* calculations and writing of the FAT, you might find it beneficial to limit
* the number of allocations, and allow fwrite to pre-allocate a number of
* clusters extra. This setting determines how many clusters will be extra
* allocated whenever this is required.
* Take in carefull consideration how large your clustersize is, putting 10 here
* with a clustersize of 32kb means you might waste 320 kb.
* The first option is for preallocating files, the other is used when enlarging
* a directory to accomodate more files
*/
#define CLUSTER_PREALLOC_FILE 0
#define CLUSTER_PREALLOC_DIRECTORY 0
/* Endianess configuration
-----------------------
* Here you can configure wheter your architecture is little or big endian. This
* is important since all FAT structures are stored in intel little endian
* order. So if you have a big endian system the library has to convert all
* figures to big endian in order to work.
*/
#define LITTLE_ENDIAN
/* Date and Time support
---------------------
* Here you can enable or disable date and time support. If you enable
* it you will have to create 6 functions, that are described in the
* EFSL manual. If the functions are not present when linking your
* program with the library you will get unresolved dependencies.
*/
/* #define DATE_TIME_SUPPORT */
/* Error reporting support
-----------------------
* When you receive an error in userland, it usually only gives limited
* information (most likely, fail or success). If error detection and
* reporting is important for you, you can enable more detailed error
* reporting here. This is optional, the costs are 1 byte per object,
* and a small increase in code size.
* You can enable error recording for all object, or you can select the
* object manually.
* For full error reporting use FULL_ERROR_SUPPORT
* For only the base-core of the library use BASE_ERROR_SUPPORT
* For IO/Man use ERRSUP_IOMAN
* For Disc use ERRSUP_IOMAN
* For Part use ERRSUP_PARTITION
* For Fs use ERRSUP_FILESYSTEM
* For File use ERRSUP_FILE
*/
#define FULL_ERROR_SUPPORT
/*#define BASE_ERROR_SUPPORT*/
/* List options
------------
* In this section you can configure what kind of data you will get from
* directory listing requests. Please refer to the documentation for
* more information
*/
#define LIST_MAXLENFILENAME 12
/* Debugging configuration
-----------------------
* Here you can configure the debugging behaviour. Debugging is different
* on every platform (see debug.h for more information).
* If your hardware has no means of output (printf) dont define any anything,
* and nothing will happen. For real world use debugging should be turned off.
*/
#define DEBUG
#endif
@@ -0,0 +1,147 @@
#ifndef __EFSL_CONFIG_H__
#define __EFSL_CONFIG_H__
/* This is for the LPC2000 SD-Card SPI interface (M. Thomas) */
/* Hardware target
---------------
* Here you will define for what hardware-endpoint EFSL should be compiled.
* Look in interfaces.h to see what systems are supported, and add your own
* there if you need to write your own driver. Then, define the name you
* selected for your hardware there here. Make sure that you only select one
* device!
*/
/*#define HW_ENDPOINT_LINUX*/
/*#define HW_ENDPOINT_ATMEGA128_SD*/
//#define HW_ENDPOINT_LPC2000_SD
/* defines the interface for LPC213x (0=SPI0 1=SPI1) */
// #define HW_ENDPOINT_LPC2000_SPINUM (0)
// #define HW_ENDPOINT_LPC2000_SPINUM (1)
/*#define HW_ENDPOINT_DSP_TI6713_SD*/
#define HW_ENDPOINT_AT91SAM
/* Memory configuration
--------------------
* Here you must configure wheter your processor can access memory byte
* oriented. All x86 processors can do it, AVR's can do it to. Some DSP
* or other microcontrollers can't. If you have an 8 bit system you're safe.
* If you are really unsure, leave the setting commented out, it will be slower
* but it will work for sure.
*/
/* disabled for ARM (mt): #define BYTE_ALIGNMENT */
/* Cache configuration
-------------------
* Here you must configure how much memory of cache you can/want to use.
* The number you put at IOMAN_NUMBUFFER is multiplied by 512. So 1 means
* 512 bytes cache, 4 means 2048 bytes cache. More is better.
* The number after IOMAN_NUMITERATIONS should be untouched.
* The last field (IOMAN_DO_MEMALLOC) is to tell ioman to allocate it's
* own memory in it's structure, or not. If you choose to do it yourself
* you will have to pass a pointer to the memory as the last argument of
* ioman_init.
*/
/*#define IOMAN_NUMBUFFER 1*/
#define IOMAN_NUMBUFFER 3
#define IOMAN_NUMITERATIONS 3
#define IOMAN_DO_MEMALLOC
/* Cluster pre-allocation
----------------------
* When writing files, the function that performs the actual write has to
* calculate how many clusters it will need for that request. It then allocates
* that number of new clusters to the file. Since this involves some calculations
* and writing of the FAT, you might find it beneficial to limit the number of
* allocations, and allow fwrite to pre-allocate a number of clusters extra.
* This setting determines how many clusters will be extra allocated whenever
* this is required.
* Take in carefull consideration how large your clustersize is, putting 10 here
* with a clustersize of 32kb means you might waste 320 kb.
* The first option is for preallocating files, the other is used when enlarging
* a directory to accomodate more files
*/
/*#define CLUSTER_PREALLOC_FILE 0*/
#define CLUSTER_PREALLOC_FILE 2
#define CLUSTER_PREALLOC_DIRECTORY 0
/* Endianess configuration
-----------------------
* Here you can configure wheter your architecture is little or big endian. This
* is important since all FAT structures are stored in intel little endian order.
* So if you have a big endian system the library has to convert all figures to
* big endian in order to work.
*/
#define LITTLE_ENDIAN
/* Date and Time support
---------------------
* Here you can enable or disable date and time support. If you enable
* it you will have to create 6 functions, that are described in the
* EFSL manual. If the functions are not present when linking your
* program with the library you will get unresolved dependencies.
*/
/*#define DATE_TIME_SUPPORT*/
/* Error reporting support
-----------------------
* When you receive an error in userland, it usually only gives limited
* information (most likely, fail or success). If error detection and
* reporting is important for you, you can enable more detailed error
* reporting here. This is optional, the costs are 1 byte per object,
* and a small increase in code size.
* You can enable error recording for all object, or you can select the
* object manually.
* For full error reporting use FULL_ERROR_SUPPORT
* For only the base-core of the library use BASE_ERROR_SUPPORT
* For IO/Man use ERRSUP_IOMAN
* For Disc use ERRSUP_IOMAN
* For Part use ERRSUP_PARTITION
* For Fs use ERRSUP_FILESYSTEM
* For File use ERRSUP_FILE
*/
#define FULL_ERROR_SUPPORT
/*#define BASE_ERROR_SUPPORT*/
/* List options
------------
* In this section youcan configure what kind of data you will get from
* directory listing requests. Please refer to the documentation for
* more information
*/
#define LIST_MAXLENFILENAME 12
/* Debugging configuration
-----------------------
* Here you can configure the debugging behaviour. Debugging is different
* on every platform (see debug.h for more information).
* If your hardware has no means of output (printf) dont define any anything,
* and nothing will happen. For real world use debugging should be turned off.
*/
#ifndef NDEBUG
// #define DEBUG 0
#endif
#endif
@@ -0,0 +1,13 @@
all: manual.tex
latex manual.tex
latex manual.tex # Needs to be done a second time to make sure that the contents table is correct
dvips -o manual.ps manual.dvi
dvipdfm manual.dvi
clean:
rm -f manual.aux
rm -f manual.dvi
rm -f manual.log
rm -f manual.pdf
rm -f manual.ps
rm -f manual.toc
Binary file not shown.
@@ -0,0 +1,132 @@
\documentclass[a4paper,fleqn]{article}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{color}
\usepackage{array}
\usepackage{verbatim}
\usepackage{longtable}
\newcommand{\filename}[1]{
\textsf{#1}
}
\newcommand{\code}[1]{
\texttt{#1}
}
\newcommand{\external}[1]{
\textbf{#1}
}
\newcommand{\thead}[1]{
\textbf{#1}
}
%\usepackage[latin1]{inputenc}
%\usepackage[T1]{fontenc}
\lstset{language=C}
\begin{document}
\title{\Huge{EFSL}\\\Large{Embedded Filesystem Library}}
\author{Lennart Ysboodt - Michael De Nil}
\date{$\copyright$ 2005}
\maketitle
\newpage
\tableofcontents
\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}
\newpage
\section{Preface}
\input{pages/preface}
\newpage
\section{Getting started}
\subsection{On Linux (file)}
\input{pages/linux}
\newpage
\subsection{On AVR (SD-Card)}
\input{pages/avr}
\newpage
\subsection{On DSP (SD-Card)}
\input{pages/tms6713}
\newpage
\subsection{On ARM7 (SD-Card)}
\input{pages/arm7}
\newpage
\section{Configuring EFSL}
\input{pages/config}
\newpage
\section{EFSL Functions}
\subsection{Date and time support}
\input{pages/dateandtime}
\newpage
\subsection{efs\_init}
\input{pages/efs_init}
\newpage
\subsection{file\_fopen}
\input{pages/file_fopen}
\newpage
\subsection{file\_fclose}
\input{pages/file_fclose}
\newpage
\subsection{file\_read}
\input{pages/file_read}
\newpage
\subsection{file\_write}
\input{pages/file_write}
\newpage
\subsection{mkdir}
\input{pages/mkdir}
\newpage
\subsection{ls\_openDir}
\input{pages/lsopendir}
\newpage
\subsection{ls\_getNext}
\input{pages/lsgetnext}
\newpage
\subsection{rmfile}
\input{pages/rmfile}
\newpage
\subsection{Getting the free space}
\input{pages/freespace}
\newpage
\newpage
\section{EFSL utilities}
\input{pages/utils}
\newpage
\newpage
\section{Developer notes}
\subsection{Integer types}
\input{pages/types}
\subsection{Debugging}
\input{pages/debug}
\subsection{Adding support for a new endpoint}
\input{pages/driver}
\subsection{I/O Manager}
\input{pages/ioman}
\subsection{C library for EFSL}
\input{pages/plibc}
\newpage
\section{Legal notes}
\input{pages/license}
%\newpage
%\section{Internals}
%\subsection{Overview}
%\subsection{Flowcharts}
%\subsection{Portability}
%
%\section{Examples}
%\subsection{Example 1}
%\subsection{Example 2}
%
\end{document}
@@ -0,0 +1,120 @@
This section describes how the ARM7 port of EFSL works. This documentation was written
by Martin Thomas, as is the port to the ARM7 and the examples included with EFSL.
The examples are pretty large, so we will not print them here, they have their own
subdirectory in the examples sections and should be quite understandable.
Please note that the LPC2000 interface is Copyright (c) by Martin Thomas, Kaiserslautern, Germany.
\subsubsection{License}
The LPC2000-interface inherits the
LGPL-license from the main efsl-source.
\subsubsection{General information about the ARM7 port}
\begin{itemize}
\item A GNU arm-elf toolchain/cross-compiler
must be available to build the examples
and the library.
\item The interface supports SD-Cards
connected to the LPC2000 SPI ("SPI0")
and SSP ("SPI1") interface. The SPI-
interface is hardcoded by the value
defined in config.h and can not be
changed during runtime.
\item Only some parts of the LPC2000-family
have the fast SSP-Interface (i.e. LPC213x,
LPC214x) others only provide the slower
SPI interface.
\item \code{\#define BYTE\_ALIGNMENT} is disabled
for the LPC-interace in config.h
It didn't work with alignment enabled.
\item Buffers can be configured as
described in the efsl-manual.
\item To build the library libefsl.a for
LPCs use the makefile Makefile-LPC2000
in the efsl-root-directory.
\item The hardware connection is similar
to the connection described
in the efsl-manual for Atmel AVRs.
(I have mounted the pullups in my
test-system but initial test have
been done successfully without the
pull-up resistors)
\item So far the interface has only been
tested with a LPC2138-controller
and the SPI(0) and SSP-Interface.
Other LPC2000-ARM7 controllers
should be supported too. Verify
that the register-adresses in
inc/interfaces/LPC2000\_regs.h
match the used controller and the
maximum speed defined in lpc2000\_spi.c
is available for the part.
Verify the pin-connections in lpc2000\_spi.c.
\end{itemize}
\subsubsection{Example code}
There are two LPC demo-applications
provided in the examples-directory:
\begin{enumerate}
\item Example lpc2138\_ssp\_standalone:
This application gets build with
the efsl source-code. The library
libefsl.a is not needed.
The application demonstrates:
- Init of the efsl LPC2000 debug-system
- Init of the efsl-library
- List contents of the SD-Card's
root directory
- Open a file and type the content
- Append a line of text to a file
- "cat/type" the file's content again
The application prints status- and
debug-messages to the LPC UART1
(115200,8,N,1,no FC)
\item Example lpc2138\_ssp\_withlib:
Same functions as the standalone
applications but the libefsl.a must
be available for linking.
\end{enumerate}
\subsubsection{Test Hard- and Software}
\begin{itemize}
\item Keil (keil.com) MCB2130 board
\item SD/MMC-connector from Buerklin.de
\item SanDisk "standard" SD-Card 256MB
(not the "highspeed"-version)
\item WinARM (arm-elf GNU toolchain)
\item Bray++ Terminal
\end{itemize}
\subsubsection{Credits}
\begin{itemize}
\item The LPC2000 debug-printf routine
is based on code from Holger Klabunde
and has been modified to support
a "fdevopen"-function. The original
code has no copyright-notice and
is derived from an free code by
Volker Oth.
\item Register-defintions based on
a header-file from Keil GmbH (supplied
with the DKARM trial-version)
\end{itemize}
@@ -0,0 +1,190 @@
This section describes how to implement Efsl on a AVR $\mu C$ connected to
an SD-Card (SPI). For getting efsl to compile, the avr-gcc compiler and
avr-libc library are required. On Windows you should install WinAVR
(http://winavr.sourceforge.net/), on Linux you can install the packages
separately (see http://www.nongnu.org/avr-libc/user-manual/install\_tools.html
for a nice howto).
\subsubsection{Hardware}
First, you need set up a prototype in which you connect the CD, CMD, DAT0
\& CLK lines from the SD-Card to /CS, MOSI, MISO \& SCK from the Atmega.
\newline
\includegraphics[scale=0.65]{pics/sdcard.eps}
\newline
%\parbox[c]{.4\textwidth}{\begin{center}\includegraphics[width=.4\textwidth]{pics/sdconnection}\end{center}}
\parbox[c]{.5\textwidth}{
Connect the following lines on the SD-card:
\begin{itemize}
\item{Pin 9 (DAT2) - NC\\(or pull-up to 3.3V)}
\item{Pin 1 (CD) - Any pin on the Atmega128}
\item{Pin 2 (CMD) - MOSI\\(pin 12 on the Atmega128)}
\item{Pin 3 (Vss) - GND}
\item{Pin 4 (Vdd) - +3.3V}
\item{Pin 5 (CLK) - SCK\\(pin 11 on the Atmega128)}
\item{Pin 6 (Vss) - GND}
\item{Pin 7 (DAT0) - MISO\\(pin 12 on the Atmega128)}
\item{Pin 8 (DAT1) - NC\\(or pull-up to 3.3V)}
\end{itemize}
}
\parbox[c]{.5\textwidth}{\begin{center}
\includegraphics[width=.5\textwidth]{pics/sdconnection}
\newline\newline
Remark: this schematic includes pull-up's to 3.3V, which
can be left off.
\end{center}}
\newline
Remark 1: Make sure that your $\mu C$ is running on 3,3V, so you don't
damage your SD-Card.\newline
\newline
Remark 2: CD is currently static set to PB0, but will become variable
in future releases.
\subsubsection{Download \& Compile}
Let's get started:
\begin{enumerate}
\item{Get the latest release of efsl on http://www.sf.net/projects/efsl/}
\item{Unpack the library (on Windows, you can use WinACE or WinRAR)}
\item{Copy \filename{Makefile-AVR} to \filename{Makefile}}
\item{Copy \filename{conf/config-sample-avr.h} to \filename{conf/config.h}}
\item{Compile the library (\code{make lib})}
\end{enumerate}
Now you should have \filename{libefsl.a} in the efsl directory.
\subsubsection{Example}
Since Efsl itself is only a library, it's not supposed to do anything out of
the box, than just compile. To get started, we'll show here a small example
program that opens an existing file and writes the content to a new file.
\newline\newline
First, create a new directory in which you put the compiled efsl-library
(\filename{libefsl.a}) and create a new file called \filename{avrtest.c} containing:
\lstset{numbers=left, stepnumber=1, numberstyle=\small, numbersep=5pt, tabsize=4}
\begin{lstlisting}
#include <efs.h>
void hang(void);
void main(void)
{
EmbeddedFileSystem efs;
EmbeddedFile file_r, file_w;
unsigned short i,e;
char buf[512];
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();
}
\end{lstlisting}
$ $\newline
Some extra information on the code above:
\begin{itemize}
\item{Line 1: The header file for efsl is included here. When using the
basic efsl functions, \filename{efs.h} is the only header file on the
efsl library that needs to be included.}
\item{Line 7: The object efs is created, this object will contain
information about the hardware layer, the partition table and
the disc.}
\item{Line 8: The objects \code{file\_r} and \code{file\_w} are created, these objects
will contain information about the files that we will open on the
efs-object.}
\item{Line 9: A buffer of 512 bytes is allocated. This buffer will be
used for reading and writing blocks of data.}
\item{Line 12: Call of \code{efs\_init()}, which will initialize the efs-object.
To this function we pass:
\begin{enumerate}
\item{A pointer to the efs-object.}
\item{A pointer to the file that contains the partition table /
file system (in this example, we select a device as file).}
\end{enumerate}
If this function returns 0, it means that a valid fat partition is
found on the SD-card connected.
If no valid fat-filesystem is found, or the file does not exist, the
function returns a negative value. In this example we then go to an
infinite loop to prevent the program to continue.}
\item{Line 16 \& 20: Call of \code{file\_fopen()}, which will initialize the
file-objects. To this function we pass:
\begin{enumerate}
\item{A pointer to the file-object.}
\item{A pointer to the filesystem-object.}
\item{A pointer to the filename.}
\item{A char containing the the mode (read, write, append).}
\end{enumerate}
If this function returns 0, it means the file has successfully been
opened for reading / writing / appending.
If the file could not be opened (because for example a file already
exists), a negative value is returned.}
\item{Line 24: Call of \code{file\_read()}, which will read a given value of
bytes (in this example 512) from a file and put it's content into
the buffer passed (in this example called buf). This function returns
the amount of bytes read, so the while-loop will be executed as long
as there are bytes left in the file.}
\item{Line 25: Call of \code{file\_write()}, which will write a given value
of bytes (in this example, the amount of bytes that was read
by \code{file\_read()}) from the buffer passed to a file. This function returns
the amount of bytes written.}
\item{Line 28 \& 29: Call of \code{file\_fclose()}, which will close the
file-objects.}
\item{Line 31: Call of \code{fs\_umount()}, which will write all buffers to
the the SD-card.}
\end{itemize}
\subsubsection{Testing}
So now let's test the program:
\begin{enumerate}
\item
{
Make sure that your directory contains both the example from above
called \filename{avrtest.c} and the library \filename{libefsl.a}.
}
\item
{ Compile the program:
\begin{itemize}
\item{On Linux (with avr-gcc): avr-gcc -I/home/user/efsl/inc/
-I/home/user/efsl/conf -ffreestanding -mmcu=atmega128 -Os -o
avrtest.o avrtest.c -L./ -lefsl}
\item{On Windows (with WinAVR): avr-gcc
-Ic:$\backslash$efsl$\backslash$inc
-Ic:$\backslash$efsl$\backslash$conf
-ffreestanding -mmcu=atmega128 -Os -o
avrtest.o avrtest.c -L.$\backslash$ -lefsl}
\end{itemize}
}
\item{Generate a hexfile
(avr-objcopy -j .text -j .data -O ihex avrtest.o avrtest.hex)}
\item{Connect an SD-card to your Atmega128 with a file called
\filename{orig.txt} on it.}
\item
{
Flash the hex file into your $\mu C$.
\begin{itemize}
\item{On Linux: avrdude -P /dev/ttyUSB0 -c stk500 -p m128 -Uflash:w:avrtest.hex}
\item{On Windows: use Atmel AVR-Studio}
\end{itemize}
}
\item{Reset your $\mu C$ and wait some time (depending on how big
the file \filename{orig.txt} is).}
\item{Disconnect the SD-card, so you can put it in your card reader
and find out if the file \filename{orig.txt} is copied to
\filename{copy.txt}.}
\end{enumerate}
@@ -0,0 +1,194 @@
In this section we're going to talk about the configuration file (\filename{config.h}),
that defines the behavior of the library. In the configuration files there are many
settings, most of which default to safe or 'standard' compliant settings.
For every platform we try to deliver a sample configuration, with setting tweaked for
that architecture. This documentation only refers to the general elements which are
tied to the library rather that the target hardware.
\subsection{Hardware target}
Here you will define what kind of hardware you will be using. Please refer to
section \ref{hwdriver} to learn how to write a hardware endpoint.
Here you must \code{\#define} the name of your hardware endpoint.
The following list contains the endpoints that the library ships with.\\
\begin{tabular}{|l|p{8cm}|}
\hline
\code{HW\_ENDPOINT\_LINUX}& This endpoint uses a regular file as
a "disc" containing a filesystem. This is a great endpoint for
testing and debugging. All development is done using this emulation.\\
\code{HW\_ENDPOINT\_ATMEGA128\_SD}& This endpoint is for the Atmel ATMega 128
with an SD card attached to the SPI pins of the device. Several settings
that are specific for this endpoint can be found in the AVR sample
configuration. A Makefile is also provided for compiling the EFSL library
using avr-gcc.\\
\code{HW\_ENDPOINT\_DSP\_TI6713\_SD}& This endpoint is for a TI DSP, it should
work with any McBSP port, due to the infinite amount of options, you should
refer to the source code of this endpoint for fine tuning, or selecting what
port to use (defaults to McBSP0).\\
\hline
\end{tabular}
\subsection{Memory configuration}
This section only has one option, called \code{BYTE\_ALIGNMENT}. If you define
this keyword the library will assume that your CPU is capable of accessing the
memory in any way it sees fit. This is the case on AVR, because they are 8 bit
processors, and it is also the case on Intel x86 hardware. Both architectures can
read and write words, or double words on any location in memory, be it word aligned
or not.
However, some CPU's, are not capable of doing this, and require that all double words
are aligned on a double word boundary, and all word are aligned on a word boundary.
This causes problems with some of the casts that are performed in EFSL. If you have such
a CPU, then you must comment this option out. The effect is that special functions
will be used to copy or cast memory. These functions work around the problem by
using memCpy, or manually copying elements of the structs that are normally cast when
\code{BYTE\_ALIGNMENT} is defined.
If you have an 8 bit architecture, or are running on PC, there is no need to turn this
off. If you do, the library will work fine, and maybe even without slowdown.
On architectures that do have the alignment problem, you should turn this flag off.
Failure to do so will result in undefined behavior.
\subsection{Cache configuration}
This section is dedicated to configuring the cache memory for the library. Caching
is performed by the IOMan object, see section \ref{ioman}.
\subsubsection*{IOMAN\_NUMBUFFER}
This number determines how much memory will be used for caching. Since this
is sector based one \code{IOMAN\_NUMBUFFER} equals to 512 byes of memory, plus
a small overhead in settings (approximately 8 bytes). This number is also affected
by \code{IOMAN\_NUMITERATIONS}.
You should carefully consider how much memory you will dedicate to caching. A too
low number will cause excessive data transfer to and from the disc, where a too high
number will simply be a waste of memory.
A good rule of thumb is to use 1 buffer per filesystem you create, and 2 buffers
per file you want to use simultaneously. So for a simple application with
one filesystem, and one file operation, 2 or 3 buffers will be fine. If you have memory
to spare, you can use 6 buffers. Using more buffers will have a minimal effect on
performance.
If you want to seek and rewrite portions of a file, add an extra buffer for that file.
Using the list function or creating directories will be disc intensive, try to smoothen
it by using an extra 3 buffer for either operation.
It is perfectly possible to have multiple files op for reading and writing, on different
filesystems, with listing etc and only using 1 buffer. It will be a tough blow on
performance though.
\subsubsection*{IOMAN\_NUMITERATION}
This number controls how many stack places each cache place gets. Refer to the IOMan
section for an explanation. In short, if you only have 1 buffer, leave it at 3. If you
use more than 4 buffers try decreasing the number to 2 or 1 for a small memory gain.
If you get errors, it means you have set it too low (see error support). It is best
to leave this at the default setting (do not increase it), unless you know what you
are doing.
\subsubsection*{IOMAN\_DOMEMALLOC}
This configures how IOMan will get it's memory. If you leave it enable, the memory
will be allocated by IOMan itself. That means that when you declare the IOMan object
it will have a member the size of $512 \cdot \mathrm{IOMAN\_NUMBUFFER}$.
That also means that that huge lump of memory will reside on the stack. On a true embedded platform with no malloc, this is your best option.
The last argument of \code{ioman\_init} will be ignored.
If you comment this out,IOMan will take a \code{euint8*} pointer as it's third
argument to \code{ioman\_init}. It will use the memory pointed to as cache.
You will have to make sure it's reserved and of the correct size.
This allows you to put the memory on the heap, or perform special tricks like
deallocating it without having to umount your filesystem and open files.
On systems with malloc, this is the recommended setting.
If you use the efs wrapper object, please look at the \code{efs\_init} documentation
on how to pass the ioman pointer.
\subsection{Pre-allocation}
Our VFAT module supports the concept of pre-allocation. When writing files, for
example log files, it is usually done with tiny bits a time. That is not the
most efficient way, but it is usually the only solution that works on embedded
systems. Every time you cross a cluster boundary with your write, the library
has to search a new cluster (reading the FAT), allocate it (write to the FAT).
Clearly, this is a waste. The solution we came up with was preallocating. This means
that when you write to a file, and fwrite sees that it needs to allocate more clusters,
it will allocate too many of them. Since this is done in one operation, it requires
usually only one read and one write to the FAT. This can save up to 50\% disc I/O
in some applications.
The drawback is that the allocation happens in larger chunks, if you do this with
many files, you might end up with larger than normal amounts of slackspace.
We have also implemented this feature for directories. This is very useful if you
have to create a lot of small files, since the directories grow by larger portions
then.
\subsubsection*{CLUSTER\_PREALLOC\_FILE}
This number determines the default value of extra clusters that will be allocated
with every sizeincrease. For example, if fwrite calculates that it needs 7 clusters,
and \code{CLUSTER\_PREALLOC\_FILE} is 30 then efsl will allocate 37 clusters.
This means (assuming every write needs 7 clusters) that the next 4 writes won't
require any write operation to the FAT (and due to the cluster cache the FAT will probably have to be read only once).
The value you put here will be the default value, it can be changed per file
object. (not yet implemented).
\subsubsection*{CLUSTER\_PREALLOC\_DIRECTORY}
The same explanation as above counts, only this value is used for directories.
Generally you should not put this above 10 (unless your speed tests prove otherwise
off course).
\subsection{Endianness}
The Microsoft FAT filesystem was originally created to be run on Intel compatible hardware.
Therefore the Microsoft programmers decided to record all data on the disc in little endian
format. Our library supports running on big endian devices. Here you can select whether your
target CPU is little or big endian.
Running on big endian will cause some performance lose because (rather simple) calculations have
to be made to all numbers that have to interpreted by the library. This does not apply to
data within the files off course.
If the flag \code{\#LITTLE\_ENDIAN} is set, efsl will assume that your hardware is little endian.
If you have a big endian system, you should comment this out. The function \code{fs\_checkEndian}
will tell you if you have selected the right endianness, this is a check you might want to use.
\subsection{Date and time}
This flag determines if you want to have date and time support. With date and time support we
mean that when you create or update a file the directory entry will receive the correct date and
time stamp.
Please refer to section \ref{dateandtime} to learn more about how this works.
If you disable date and time support by commenting the \code{\#DATE\_TIME\_SUPPORT} then
all dates and times that need to be created or updated will be set to zero, which in FAT land corresponds to the first of January of the year 1970.
\subsection{Errors}
When the library encounters an error, there be an error cascade moving from the error-causing object
to the topmost object where the request started. Seen from userland this gives you extremely little
information, usually nothing more than fail or success.
Every object in the library has an optional error field, that contains a unique number that
corresponds to a specific error. If you examine every error field you can see exactly where the
error was started and what the effect was on the higher level objects.
In a more practical sense you can display an error number or explanation to your users, giving
yourself or them a better chance to correct or avoid the problem.
Please see the section on error on what every value means.
\subsection{Debug}
In the config, debugging can be turned on or off by defining DEBUG. This can be
very useful when hacking on the efsl library, or when something goes wrong.
In applications this option should be turned off.
The debugging behaviour will depend on the platform you are using:
\begin{itemize}
\item{On Linux debug lines will printed to the console}
\item{On AVR debug will be sent over a selected UART\\
Make sure you set the following two values in your config.h:
\begin{itemize}
\item{DEBUG\_PORT: here you need to set which UART the library
may use}
\item{DEBUG\_UBRR: here you need to select the UBRR-value
(see the avr-datasheets for these values)}
\end{itemize}
}
\item{On DSP debug will call the printf function
(can only be used with a dsk-board)}
\end{itemize}
@@ -0,0 +1,34 @@
\label{dateandtime}
The EFSL library supports setting and updating all date and time fields
supported by the filesystem. In order to do this the library must
know the current time and date at all times. Since it has to run everywhere,
there is no standard mechanism to get the date/time, and some systems do
not have a clock.
With default configuration there is no date or time support, you have to
turn it on manually in the configuration file \filename{config.h}.
You will have to uncomment the field named \code{\#define DATE\_TIME\_SUPPORT},
in order to activate date/time support.
Furthermore you will have to provide the library with date and time information.
A set of defines was used for this, when date/time support is not enabled,
the defines automatically return \code{0x0000} for all time and date fields,
so there is no performance suffer when you do not need date/time support.
If you do need it you will have to provide 6 functions to the library
that will tell it the time. Since these functions may get called often,
it is highly recommended that you cache the time result somewhere so
you can serve the library directly from ram. If you do not do this and
your RTC request take a lot of time, you may suffer large losses in read
or write operations depending on your hardware.
The six functions are:
\begin{itemize}
\item\code{euint16 efsl\_getYear(void)}
\item\code{euint8 efsl\_getMonth(void)}
\item\code{euint8 efsl\_getDay(void)}
\item\code{euint8 efsl\_getHour(void)}
\item\code{euint8 efsl\_getMinute(void)}
\item\code{euint8 efsl\_getSecond(void)}
\end{itemize}
Internally the library will recalculate these numbers to match the
filesystem that is currently in use.
@@ -0,0 +1,40 @@
Since debugging on every device is completely different, a DBG macro is
implemented. On Linux for example, this macro will print the string given
to the screen (using printf). On AVR, it will send debug strings through the
UART. For compatibility with other devices, it is necessary that you always use
the DBG-macro instead of a device-specific debugging commands.\newline
\newline
Because AVR-GCC puts strings in sram memory by default, every string should be
surrounded by the TXT-macro. On AVR, this macro will put the string in program
memory (flash), on any other device, this macro will be ignored.\newline
\newline
Example of a debug string:\\
\code{DBG((TXT("This is test nr \%d of \%d.$\backslash$n"),id,total));}
\subsubsection{Debugging on Linux}
On linux, debugging strings are sent to stdout using printf.\newline
\newline
To enable debugging, set DEBUG in \filename{config.h}.
\subsubsection{Debugging on AVR}
On AVR, debugging strings are sent through the UART and can be read using
a terminal like minicom (linux) or hyperterminal (windows). Standard, the
first UART is used, but this can be changed in \filename{debug.c} to the
second UART.\newline
\newline
To enable debugging:
\begin{itemize}
\item{Set DEBUG in \filename{config.h}}
\item{Set DEBUG\_PORT to the number of the UART efsl may use for debugging
in \filename{config.h}}
\item{Set DEBUG\_UBRR according to your baudrate \& clock speed in
\filename{config.h} (see the avr datasheet for this value)}
\item{Initialize debugging in your program by calling \code{debug\_init()}}
\end{itemize}
Remark: when you use the serial port in your main program, make sure you
use a different UART than the one efsl is using when sending debug string.
\subsubsection{Debugging on DSP}
On DSP, debugging strings are sent to Code Composer using the printf function.
\newline\newline
To enable debugging, set DEBUG in \filename{config.h}.\newline
\newline
Remark: this will only work when using a DSK-kit.
@@ -0,0 +1,165 @@
\label{hwdriver}
This section will describe step by step how to write an hardware endpoint.
You will be required to write your own endpoint in case non of the existing endpoints
matches your hardware.
First let's have a look at how EFSL is structured internally.\\\\
\includegraphics[scale=0.4]{schematics/objectmodel.eps}\\
As you can see we have created a linear object model that is quite simple.
The file en filesystem object deal with handling the filesystem specific stuff.
Below that we find the Partition object that is responsible for translating partition
relative addressing into disc-based LBA addressing.
The Disc object hold the partition table, and has a direct link to a cache manager, IOMan.
In IOMan, all requests for disc sectors come together. IOMan will perform checks to see
if sectors have to be read from disc (or from memory), or written back to disc.
In the latter case (reading or writing to disc), a request is made to the hardware layer.
The hardware interface has 3 responsibilities :
\begin{itemize}
\item Initialize the hardware
\item Read sectors from disc
\item Write sectors to disc
\end{itemize}
All requests are \textsl{sector}based, a sector is a 512 byte piece from the disc, that is aligned to
a 512 byte boundary.\\\\
\includegraphics[scale=0.4]{schematics/sector.eps}
In this example we will create a new endpoint that will add support for data over pigeon carrier
for the EFSL. Initializing the hardware will require feeding the pigeon and telling it where the
data is. Reading/Writing will entail giving the bird the sector and letting it fly.
Perform the following steps:
\begin{enumerate}
\item Choose a name for your endpoint\\
You will need this name to create the required defines in the source code.
For our example I've chosen the name \code{PIGEON\_CARRIER}.
For consistency the final name is then \code{HW\_ENDPOINT\_PIGEON\_CARRIER}.
\item Verify the sizes of integers\\
Open \filename{inc/types.h} and create a new entry for pigeon carriers. Perhaps
one of the existing sets is identical to yours and you can copy-paste it.
\item Add your endpoint to \filename{interface.h}\\
Locate the file \filename{interface.h} located in the directory \filename{inc/}
Add a pigeon entry (located above the \code{\#else ... NO INTERFACE DEFINED})
\begin{lstlisting}
#if defined(HW_ENDPOINT_0)
#include "interfaces/0.h"
#elif defined(HW_ENDPOINT_1)
#include "interfaces/1.h"
#elif defined(HW_ENDPOINT_PIGEON_CARRIER)
#include "interfaces/pigeon.h"
#else
#error "NO INTERFACE DEFINED - see interface.h"
#endif
\end{lstlisting}
\item Select your endpoint in \filename{conf/config.h}
\item Create your sourcefiles\\
Create a header file in \filename{inc/} and a sourcefile in \filename {src/interfaces}.
In this example I'm using \filename{pigeon.h} and \filename{pigeon.c}.
\item Add your object file to the Makefile
Take the Makefile that works best on your platform (they should all work with
GNU/Make), or create a new one, using the existing one's as a template.
Make sure to include your new pigeon object to the library.
If you have an 'ar' like utility you can create a static library, else you may
have to create a new project containing all required source files.
\end{enumerate}
The basic framework is now complete, now all that's left to do is to write the code
that will perform the actual flying work.
\subsubsection{hwInterface}
This structure represents the underlying hardware. There are some field that are required
to be present (because EFSL uses them), but you may put in as much or a little as
your driver requires to access the hardware.
As always in embedded design it is recommended to keep this structure as small
as possible.
Example:
\begin{lstlisting}
struct hwInterface{
/* Field created for THIS hardware */
Pigeon pigeon;
/* Obligatory fields */
euint32 sectorCount;
};
typedef struct hwInterface hwInterface;
\end{lstlisting}
\subsubsection{if\_initInterface}
This function will be called one time, when the hardware object is initialized by
\code{efs\_init()}. This code should bring the hardware in a ready to use state.
The function's prototype is\\
\code{esint16 if\_initInterface(hwInterface *hw, euint8* opts);}
Optionally but recommended you should fill in the hw->sectorCount field with the number
of sectors. This field is used to validate sectorrequests.
An example of a initInterface function :
\begin{lstlisting}
esint16 if_initInterface(hwInterface *hw, euint8* opts)
{
/* Parse options */
parse_options(opts); /* Your application may not need options */
/* Check hardware state */
if(!alive(hw->pigeon)){
//printf("Pigeon died! :-(\n");
return(DEAD_PIGEON); /* #define DEAD_PIGEON -1 */
}
/* Initialize hardware */
feed(hw->pigeon);
pet (hw->pigeon);
/* Get sectors count */
hw->numSectors = ask_pigeon_num_sectors(hw->pigeon);
return(0);
}
\end{lstlisting}
\subsubsection{if\_readBuf}
This function is responsible to read a sector from the disc and store it in a user supplied buffer. You will receive the hardware object, an address and a pointer to memory for storing
the buffer.
Please be very careful to respect the boundaries of the buffers, since it will usually be IOMan
calling this function, and if you have a buffer overflow you might corrupt the cache of the
the next buffer, which in turn may produce extremely rare and impossible to retrace behavior.
The function prototype is:\\
\code{esint16 if\_readBuf(hwInterface *hw,euint32 address, euint8* buf);}
The address is an LBA address, relative to the beginning of the disc. Should you be
accessing an old hard disc, or a device which uses some other form of addressing you will have to
recalculate the address to your own addressing scheme. Please note that there is no support
for sectors that are not 512 bytes large.
\begin{lstlisting}
esint8 if_readBuf(hwInterface* hw,euint32 address,euint8* buf)
{
Message new_message;
new_message.address = address;
new_message.command = READ;
pigeon_send(hw->pigeon,new_message); /* Launches the pigeon */
while(!pigeon_returned(hw->pigeon)); /* Wait until the bird is back */
memcpy(new_message.data,buf,512); /* Copy buffer */
return(0);
}
\end{lstlisting}
\subsubsection{if\_writeBuf}
The function \code{if\_writeBuf} works exactly the same as it's reading variant.
@@ -0,0 +1,45 @@
\subsubsection*{Purpose}
Initializes the hardware and the software layer.
\subsubsection*{Prototype}
\code{esint8 efs\_init(EmbeddedFileSystem *efs, eint8* opts);}
\subsubsection*{Arguments}
Objects passed to \code{efs\_init}:
\begin{itemize}
\item{\code{efs}: empty EmbeddedFileSystem object}
\item
{
\code{opts}: character string containing options, depending on what
interface you are using:
\begin{itemize}
\item{Linux: opts points to the path to the device}
\item{AVR: opts points to the card enable pin (TODO)}
\item{DSP: opts points to the card enable memory address (TODO)}
\end{itemize}
}
\end{itemize}
\subsubsection*{Return value}
Returns 0 if no errors are detected.\\
\newline
Returns non-zero if a low-level error is detected:
\begin{itemize}
\item{Returns -1 if the interface could not be initialized.}
\item{Returns -2 if the filesystem could not be initialized.}
\end{itemize}
\subsubsection*{Example}
\lstset{numbers=left, stepnumber=1, numberstyle=\small, numbersep=5pt, tabsize=4}
\begin{lstlisting}
#include "efs.h"
void main(void)
{
EmbeddedFileSystem efsl;
esint8 ret;
DBG((TXT("Will init efsl now.\n")));
ret=efs_init(&efsl,"/dev/sda");
if(ret==0)
DBG((TXT("Filesystem correctly initialized.\n")));
else
DBG((TXT("Could not initialize filesystem (err \%d).\n"),ret));
}
\end{lstlisting}
@@ -0,0 +1,43 @@
\subsubsection*{Purpose}
Updates file records and closes file object.
\subsubsection*{Prototype}
\code{esint8 file\_fclose(File *file);}
\subsubsection*{Arguments}
Objects passed to \code{file\_fopen}:
\begin{itemize}
\item{\code{file}: pointer to a File object}
\end{itemize}
\subsubsection*{Return value}
Returns 0 if no errors are detected.\\
\newline
Returns non-zero if an error is detected.
\subsubsection*{Example}
\lstset{numbers=left, stepnumber=1, numberstyle=\small, numbersep=5pt, tabsize=4}
\begin{lstlisting}
#include "efs.h"
void main(void)
{
EmbeddedFileSystem efsl;
File file;
/* Initialize efsl */
DBG((TXT("Will init efsl now.\n")));
if(efs_init(&efsl,"/dev/sda")!=0){
DBG((TXT("Could not initialize filesystem (err \%d).\n"),ret));
exit(-1);
}
DBG((TXT("Filesystem correctly initialized.\n")));
/* Open file for reading */
if(file_fopen(&file, &efsl.myFs, "read.txt", 'r')!=0){
DBG((TXT("Could not open file for reading.\n")));
exit(-1);
}
DBG((TXT("File opened for reading.\n")));
/* Close file & filesystem */
fclose(&file);
fs_umount(&efs.myFs);
}
\end{lstlisting}
@@ -0,0 +1,70 @@
\subsubsection*{Purpose}
Searches for file and initializes the file object.
\subsubsection*{Prototype}
\code{esint8 file\_fopen(File *file, FileSystem *fs, eint8 *filename, eint8 mode);}
\subsubsection*{Arguments}
Objects passed to \code{file\_fopen}:
\begin{itemize}
\item{\code{file}: pointer to a File object}
\item{\code{fs}: pointer to the FileSystem object}
\item{\code{filename}: pointer to the path + filename}
\item
{
\code{mode}: mode of opening, this can be:
\begin{itemize}
\item{'r': open file for reading}
\item{'w': open file for writing}
\item{'a': open file for appending}
\end{itemize}
}
\end{itemize}
\subsubsection*{Return value}
Returns 0 if no errors are detected.\\
\newline
Returns non-zero if an error is detected:
\begin{itemize}
\item{Returns -1 if the file you are trying to open for reading could not
be found.}
\item{Returns -2 if the file you are trying to open for writing already
exists.}
\item{Returns -3 if no free spot could be found for writing or appending.}
\item{Returns -4 if mode is not correct (if it is not 'r', 'w' or 'a').}
\end{itemize}
\subsubsection*{Example}
\lstset{numbers=left, stepnumber=1, numberstyle=\small, numbersep=5pt, tabsize=4}
\begin{lstlisting}
#include "efs.h"
void main(void)
{
EmbeddedFileSystem efsl;
File file_read, file_write;
/* Initialize efsl */
DBG((TXT("Will init efsl now.\n")));
if(efs_init(&efsl,"/dev/sda")!=0){
DBG((TXT("Could not initialize filesystem (err \%d).\n"),ret));
exit(-1);
}
DBG((TXT("Filesystem correctly initialized.\n")));
/* Open file for reading */
if(file_fopen(&file_read, &efsl.myFs, "read.txt", 'r')!=0){
DBG((TXT("Could not open file for reading.\n")));
exit(-1);
}
DBG((TXT("File opened for reading.\n")));
/* Open file for writing */
if(file_fopen(&file_write, &efsl.myFs, "write.txt", 'w')!=0){
DBG((TXT("Could not open file for writing.\n")));
exit(-2);
}
DBG((TXT("File opened for writing.\n")));
/* Close files & filesystem */
fclose(&file_read);
fclose(&file_write);
fs_umount(&efs.myFs);
}
\end{lstlisting}
@@ -0,0 +1,51 @@
\subsubsection*{Purpose}
Reads a file and puts it's content in a buffer.
\subsubsection*{Prototype}
\code{euint32 file\_read (File *file, euint32 size, euint8 *buf);}
\subsubsection*{Arguments}
Objects passed to \code{file\_read}:
\begin{itemize}
\item{\code{file}: pointer to a File object}
\item{\code{size}: amount of bytes you want to read / put in buf}
\item{\code{buf}: pointer to the buffer you want to store the data}
\end{itemize}
\subsubsection*{Return value}
Returns the amount of bytes read.
\subsubsection*{Example}
\lstset{numbers=left, stepnumber=1, numberstyle=\small, numbersep=5pt, tabsize=4}
\begin{lstlisting}
#include "efs.h"
void main(void)
{
EmbeddedFileSystem efsl;
euint8 buffer[512];
euint16 e, f;
File file;
/* Initialize efsl */
DBG((TXT("Will init efsl now.\n")));
if(efs_init(&efsl,"/dev/sda")!=0){
DBG((TXT("Could not initialize filesystem (err \%d).\n"),ret));
exit(-1);
}
DBG((TXT("Filesystem correctly initialized.\n")));
/* Open file for reading */
if(file_fopen(&file, &efsl.myFs, "read.txt", 'r')!=0){
DBG((TXT("Could not open file for reading.\n")));
exit(-1);
}
DBG((TXT("File opened for reading.\n")));
/* Read file and print content */
while((e=file_read(&file,512,buffer))){
for(f=0;f<e;f++)
DBG((TXT("\%c"),buffer[f]));
}
/* Close file & filesystem */
fclose(&file);
fs_umount(&efs.myFs);
}
\end{lstlisting}
@@ -0,0 +1,52 @@
\subsubsection*{Purpose}
Reads a file and puts it's content in a buffer.
\subsubsection*{Prototype}
\code{euint32 file\_write(File *file, euint32 size, euint8 *buf)}
\subsubsection*{Arguments}
Objects passed to \code{file\_read}:
\begin{itemize}
\item{\code{file}: pointer to a File object}
\item{\code{size}: amount of bytes you want to write}
\item{\code{buf}: pointer to the buffer you want to write the data from}
\end{itemize}
\subsubsection*{Return value}
Returns the amount of bytes written.
\subsubsection*{Example}
\lstset{numbers=left, stepnumber=1, numberstyle=\small, numbersep=5pt, tabsize=4}
\begin{lstlisting}
#include <string.h>
#include "efs.h"
void main(void)
{
EmbeddedFileSystem efsl;
euint8 *buffer = "This is a test.\n";
euint16 e=0;
File file;
/* Initialize efsl */
DBG((TXT("Will init efsl now.\n")));
if(efs_init(&efsl,"/dev/sda")!=0){
DBG((TXT("Could not initialize filesystem (err \%d).\n"),ret));
exit(-1);
}
DBG((TXT("Filesystem correctly initialized.\n")));
/* Open file for writing */
if(file_fopen(&file, &efsl.myFs, "write.txt", 'w')!=0){
DBG((TXT("Could not open file for writing.\n")));
exit(-1);
}
DBG((TXT("File opened for reading.\n")));
/* Write buffer to file */
if( file_write(&file,strlen(buffer),buffer) == strlen(buffer) )
DBG((TXT("File written.\n")));
else
DBG((TXT("Could not write file.\n")));
/* Close file & filesystem */
fclose(&file);
fs_umount(&efs.myFs);
}
\end{lstlisting}
@@ -0,0 +1,35 @@
\hyphenation{count-Free-Clusters File-System}
To get the free space left on EFSL 0.2 is a bit tricky. This
feature was implemented after it had gone into stable, so it
couln't interfere with other library functions.
If the filesystem type is FAT12 of FAT16, you must call\\
\code{euint32 fat\_countFreeClusters (FileSystem *fs)} to know
the amount of free clusters. Please note that this is an expensive
function call in terms of speed. It will also work on FAT32 volumes,
but there is a better alternative for that.
Usually FAT32 volumes are substantially larger than FAT12 of FAT16 volumes.
Microsoft, in it's infinite wisdom, decided to use the second sector of
the partition to dump various statistics about the filesystem. Problem
is they are inaccurate, so if you want to be really sure, always use the
beforementioned countFreeClusters function.
To save time, you can also use \code{esint8 fs\_getFsInfo(FileSystem *fs,euint8 force\_update)}.
If force\_update is set to 0, this function will simply gather the data
that is stored on the disc regarding free space. If you call it with
force\_update set to 1, it will gather this data, but correct the result
with a call to countFreeClusters.
After that you will find the result in fs->FreeClusterCount.
To save time, call getFsInfo after you mounted the filesystem,
and just before you umount the filesystem give a call to setFsInfo.
This will make the updated clustercount get written to disc, so you
don't have to go through the lenghty verification everytime.
The functions that have the largest impact on free space (allocClusterChain
and unlinkClusterChain) keep track of the changes they make and they update
the fs->FreeClusterCount field accordingly.
This is an ugly ``add-on'', and will be replaced by a decent implementation
in the 0.3/0.4 series.
@@ -0,0 +1,236 @@
\label{ioman}
The IOManager that is the second lowest layer of the embedded filesystems library is
responsible for coordinating disk input and output, as well as managing a caching
system. This documentation describes the second implementation of IOMan, which includes
features such as :
\begin{itemize}
\item Delayed write
\item Buffer reference statistics
\item Buffer exportable to users
\item Support for cached direct I/O as well as indirect I/O
\item Can allocate memory itself (on the stack), or you can do it yourself (heap)
\end{itemize}
\subsubsection{General operation}
Because of the limited memory nature of most embedded devices for which this library is
intended several design decisions were made to minimize memory usage. Some of these required
that some concessions be made. One of them is that there is no memory protection, since
most devices don't have the memory to support this, or lack the ability to protect memory.
When IOMan receives a request for a sector, it will make sure it has the sector in it's
own memory cache and then give the caller a \code{euint8*} pointer to that cache. The
user is then free to do operations on that memory, and when it is done it should tell
IOMan so. Several things can go wrong with this: you can request a sector for reading,
and then write in the cache, thereby corrupting it. Or you can request a sector, but never
release it (sort of a memory leak), which may result in very bad performance, and a deadlocked
I/O manager.
But, taking into account that very little memory is required for operation, if you follow the I/O man rules, you will get a pretty clever caching object that will make writing new filesystems
a simple job.
\subsubsection{Cache decisions}
Whenever ioman receives a request to fetch a sector, be it read or write, it will have to make sure
it has, or can get the sector you want. It follows a certain path to do this.\label{cachemethod}
\begin{enumerate}
\item First of all it will scan it's cache range to see if it already has the sector.
If it is found, and it was a write request, the cache is marked writable. Usage and
reference get incremented and a pointer is then returned to the requester. If the
buffer cannot be found, ioman proceeds to step 2.
\item When an item is not in cache, it has to be fetched from the disc, the best place to
store it is in memory that does not contain anything useful yet. Ioman will search for
a place that is currently not occupied by anything. If it is found, the sector will be
placed on that spot and a pointer returned. Else, ioman proceeds to step 3.
\item Since there is no other choice than to overwrite an already existing cache, ioman will
try to find one that is the least interesting. First it will search for caches that
are marked not writable, and have no users. Ioman will then select the one that has the
least references. If there are none, it will search for caches that don't have users and
are writable. Once again the one with the least references is returned. Since it is
writable ioman will flush it to disc first. After that the requested sector is put there
and a pointer returned. If it cannot find any caches that have no users it will go to
step 4.
\item Since every cache spot is in use ioman will have to select one for overallocation.
Since this selection is dependant on many factors and is rather complex, a points
system is used. The algorithm considers every cache place and allocated a certain number
of points to it, lower means that it is a better candidate for overallocation. Fifty
percent of the points goes to the cache being marked writable, since having to write
a sector is expensive. Another 35 percent goes to how many overallocations have
already been done on that spot. It doesn't make sense to always overalloc the same buffer,
it is better to spread this. The remaining 15 percent is determined by the number of
references to the sector.
After a function has selected the best candidate, ioman will overwrite that spot with
the new sector. It will also push the status and sectornumber onto that cache's
retrieval stack, so that when the sector is released, the older sector can be retrieved.
If this fails go to step 5.
\item When ioman gets here it will return a (nil) pointer and flag an error.
\end{enumerate}
\subsubsection{Functions}
\begin{longtable}{|p{0.35\textwidth}|p{0.65\textwidth}|}
\hline
\multicolumn{2}{|c|}{
\textbf{I/O Manager Functions}
} \\
\multicolumn{2}{|c|}{} \\
\hline
\hline
\endfirsthead
\hline
\multicolumn{2}{|c|}{\textbf{I/O Manager Functions (continued)}} \\
\hline
\endhead
\hline
\endfoot
\hline
\endlastfoot
\code{ioman\_init} & \code{esint8 (IOManager *ioman, hwInterface *iface, euint8* bufferarea)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This function is called to initialize the internal state of the I/O manager. It should be the
first function you call on an ioman object. Failure to do so will result in undefined behavior.
The function clears all internal variables to a default safe state, and sets up it's memory region.
There are two possibilities, if you supply a 0 pointer then a function will be called that contains
a static variable with a size of 512 * \code{IOMAN\_NUMBUFFERS}, else, it will be assumed that
you allocated that memory yourself and the pointer you provided will be used.
}\\
\hline
\code{\external{ioman\_reset}} & \code{void (IOManager *ioman)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This function is called from the initialization function, it does the actual reset of all variables.
}\\
\hline
\code{ioman\_pop} & \code{esint8 (IOManager *ioman,euint16 bufplace)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This function fetches settings (sector number, usage and status register) from stack \code{bufplace}
and puts it back on the main registers. It will return 0 on succesful pop, and -1 on error, or when
there are no elements to pop.
}\\
\hline
\code{ioman\_push} & \code{esint8 (IOManager *ioman,euint16 bufplace)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This function pushes the settings of cache \code{bufplace} onto that cache's stack. It does not
destroy the data in the main registers. It will return 0 for a successful push, and -1 on error, or
when there is no more space to push a new element.
}\\
\hline
\code{ioman\_readSector} & \code{esint8 (IOManager *ioman,euint32 address,euint8* buf)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This function does the actual reading from the hardware, it is the one and only function that
calls \code{if\_readBuf()}, here a retry on failure policy could be implemented. This function
will correctly stream errors upwards. All calls made to this function in the iomanager are checked
for their return value, so errors propagate correctly upwards.
The address it receives is relative to the beginning of the disc, no assumptions about \code{buf}
may be made, it can be withing ioman's cache memory range, but it could also be a buffer from userspace.
The function will return 0 on success and -1 on failure.
}\\
\hline
\code{ioman\_writeSector} & \code{esint8 (IOManager *ioman, euint32 address, euint8* buf)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This function does the actual writing to the hardware, it is the one and only function that
calls \code{if\_writeBuf()}, here a retry on failure policy could be implemented. This function
will correctly stream errors upwards. All calls made to this function in the iomanager are checked
for their return value, so errors propagate correctly upwards.
The address it receives is relative to the beginning of the disc, no assumptions about \code{buf}
may be made, it can be withing ioman's cache memory range, but it could also be a buffer from userspace.
The function will return 0 on success and -1 on failure.
}\\
\hline
\code{\external{ioman\_getSector}} & \code{euint8* (IOManager *ioman,euint32 address, euint8 mode)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This function is the one that is called most from the higher library routines. It is the function
that will present you with a pointer to memory containing sector number \code{address}. There are
several modes that you can select or combine.\newline
\begin{tabular}{|l|p{.6\textwidth}|}
\hline
\code{IOM\_MODE\_READONLY} & This attribute says to ioman that it needs a buffer only for reading.
This does not mean that you are allowed to write to it, doing so results in undefined behavior.
You cannot combine this option with the \code{IOM\_MODE\_READWRITE} option.\\
\code{IOM\_MODE\_READWRITE} & This attribute says to ioman that it would like not only to read from
but also to write to that buffer. When you release the sector your changes will be written to disc.
This may not happen immediately though, if you want to force it take a look at the
\code{ioman\_flushRange()} function. This option cannot be combined with the
\code{IOM\_MODE\_READONLY} option.\\
\code{IOM\_MODE\_EXP\_REQ} & This option tell the iomanager that the request is exceptional, for
example that the request is unlikely to happen again. The library adds this flags to the options
when requesting the bootrecord, to prevent it from getting a high rating, which should prevent it
from being removed from the cache.\\
\hline
\end{tabular}\newline
These options can be combined by ORing them together.
}\\
\hline
\code{ioman\_releaseSector} & \code{esint8 (IOManager *ioman,euint8* buf)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This function tells ioman that you are done with one of the cache elements and that it can do
it's bidding with it. Forgetting to call this function may result in deadlocked iomanagers.
}\\
\hline
\code{ioman\_directSectorRead} & \code{esint8 (IOManager *ioman,euint32 address, euint8* buf)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This is a variant of the normal getsector. Sometimes you need a sector from the disc, but all
you want to do with it is export it directly to userbuffers. It would be foolish to force a
caching of that sector if there is external space available for it.
This function will fetch sector \code{address} from disc and place it in the memory pointed to
by \code{buf}. Should there be a free spot available the sector will be cached there, so that
it may be used in the future. If the sector was available from cache in the first place, it
will simply be \code{memCpy()}'d from the cache to the userspace buffer.
}\\
\hline
\code{ioman\_directSectorWrite} & \code{esint8 (IOManager *ioman,euint32 address, euint8* buf)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This function is based on the same philosophy as \code{ioman\_directSectorRead()}, however,
contrary to what the name may lead to believe it also passes through a caching layer. If
there is an unused spot (or the sector is in cache), the userbuffer will be copied to that
spot and will remain there until the space is needed or a flush is forced.
}\\
\hline
\code{ioman\_flushRange} & \code{esint8 (IOManager *ioman,euint32 address\_low, euint32 address\_high)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This function is used to ask ioman to flush all sectors to disc that are in a specific
range. For example you might want to flush a specific range of your filesystem without
needlessly disturb other parts. The range is \code{address\_low <= n => address\_high}.
Off course only sectors that are marked as writable are flushed to disc.
}\\
\hline
\code{ioman\_flushAll} & \code{esint8 (IOManager *ioman)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This function will cause ioman to flush out all cache units that are marked writable. If
they do not have any users, they will lose their writable mark.
}\\
\hline
\end{longtable}
@@ -0,0 +1,489 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -0,0 +1,12 @@
This library is subject to the Lesser General Public License version 2.1.
We have chosen this license in stead of the BSD license because we feel strongly
that more effort was needed in the field of quality software in the embedded field.
Please note that if you make changes to the library itself, those modifications must be
made public, but that writing support for new hardware and linking it into the library,
does not fall under this category. However, we would off course appreciate it tremendously
if you would send us in code to support new hardware.
\subsection{GNU Lesser General Public License}
\verbatiminput{pages/lgpl.txt}
@@ -0,0 +1,138 @@
Debugging efsl on embedded devices is a rather hard job, because
you can't just printf debug strings or watch memory maps easily.
Because of that, core development has been performed under the
Linux operating system. Under Linux, efsl can be compiled as
library and used as a userspace filesystem handler. On Unix-
style operating system (like Linux), all devices (usb stick, disc, \ldots)
can be seen as a file, and as such been opened by efsl.\newline
\newline
In the following section, we will explain how to get started using
efsl as userspace filesystem handler. However, please note that the main
focus for efsl is to support embedded systems, which usually don't even
have 1\% of the memory you have on a PC. Accessing files on a FAT-filesystem
with efsl will be much slower than when accessing these files with the Linux
FAT kernel modules.
\subsubsection{Download \& Compile}
Let's get started:
\begin{enumerate}
\item{Get the latest release of efsl on http://www.sf.net/projects/efsl/
and put it in your homedir}
\item{Unpack the library (tar xvfj efsl-version.tar.bz2)}
\item{Get inside the directory (cd $\sim$/efsl)}
\item{Create a symlink from \filename{Makefile-LINUX} to \filename{Makefile}
(ln -s Makefile-LINUX Makefile)}
\item{Copy \filename{conf/config-sample-linux.h} to \filename{conf/config.h}
(cp conf/config-sample-linux.h conf/config.h)}
\item{Compile the library (make lib)}
\item{Find the compiled filesystem library (libefsl.a) in the current
directory}
\end{enumerate}
If you got any errors with the steps above, please check that that you have
the following packages installed: tar, gcc, libgcc, binutils \& make.
\subsubsection{Example}
Since efsl itself is only a library, it's not supposed to do anything
out of the box, than just compile. To get started, we'll show here a small
example program that opens a file on a disc/usb-stick/floppy that contains
a FAT-filesystem and prints it's content to stdout.\newline
\newline
First, create a new directory in which you put the compiled efsl-library
(\filename{libefsl.a}) and create a new file called \filename{linuxtest.c} containing:
\lstset{numbers=left, stepnumber=1, numberstyle=\small, numbersep=5pt, tabsize=4}
\begin{lstlisting}
#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/sda")!=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);
}
\end{lstlisting}
$ $\newline
Some extra information on the code above:
\begin{itemize}
\item{Line 1-2: The header files for stdio (used for printf) and efsl
are included. When using the basic efsl functions, \filename{efs.h} is
the only header file of the efsl library that needs to be included.}
\item{Line 6: The object efs is created, this object will contain
information about the hardware layer, the partition table and
the disc.}
\item{Line 7: The object file is created, this object will contain
information about the file that we will open on the efs-object.}
\item{Line 9: A buffer of 512 bytes is allocated. This buffer will
be filled by fread with data.}
\item{Line 11-14: Call of \code{efs\_init}, which will initialize the efs-object.
To this function we pass:
\begin{enumerate}
\item{A pointer to the efs-object.}
\item{A pointer to the file that contains the partition table /
file system (in this example, we select a device as file).}
\end{enumerate}
If this function returns 0, it means that a valid fat partition is
found on the device given.
If no valid fat-filesystem is found, or the file does not exist, the
function returns a negative value. In this example we then print an
error message and quit.}
\item{Line 16-19: Call of \code{file\_fopen()}, which will initialize the
file-object. To this function we pass:
\begin{enumerate}
\item{A pointer to the file-object.}
\item{A pointer to the filesystem-object.}
\item{A pointer to the filename.}
\item{A char containing the the mode (read, write, append).}
\end{enumerate}
If this function returns 0, it means the file has successfully been
opened for reading / writing / appending.
If the file could not be opened, a negative value is returned.
}
\item{Line 21-24: Call of \code{file\_read()}, which will read a given value of
bytes (in this example 512) from a file and put it's content into
the buffer passed (in this example called buf). This function returns
the amount of bytes read, so the while-loop will be executed as long
as there are bytes left in the file. The code inside the while-loop
will print all characters in the buffer.}
\end{itemize}
\subsubsection{Testing}
So now let's test the program:
\begin{enumerate}
\item{Compile the program
(gcc -I/home/user/efsl/inc/ -I/home/user/efsl/conf -o linuxtest
linuxtest.c -L./ -lefsl).}
\item{Insert a usb-disc, floppy, mp3-stick, \ldots with a valid
fat-filesystem on it.}
\item{Mount the device, copy the file /etc/group on it's root dir \& umount
it.}
\item{Check that you have permission to access the device
(chown username /dev/sda*)}
\item{Run the program (./linuxtest)}
\end{enumerate}
@@ -0,0 +1,52 @@
\subsubsection*{Purpose}
This function fetches the next valid file in the current directory and copies
all relevant information to \code{dirlist->currentEntry}.
\subsubsection*{Prototype}
\code{esint8 ls\_getNext(DirList *dlist);}
\subsubsection*{Arguments}
Objects passed to \code{ls\_getNext}:
\begin{itemize}
\item{\code{dlist}: pointer to a DirList object}
\end{itemize}
\subsubsection*{Return value}
This function will return 0 when it has found a next file in the directory, and
was successful in copying it to \code{dirlist->currentEntry}. It will return -1
when there are no more files in the directory.
\subsubsection*{Example}
To browse through a directory you should first open it with \code{ls\_openDir} and
then you can call \code{ls\_getNext} in a loop to iterate through the files. Please
note that they are unsorted.
\lstset{numbers=left, stepnumber=1, numberstyle=\small, numbersep=5pt, tabsize=4}
\begin{lstlisting}
#include "efs.h"
#include "ls.h"
void main(void)
{
EmbeddedFileSystem efsl;
DirList list;
/* Initialize efsl */
if(efs_init(&efsl,"/dev/sda")!=0){
DBG((TXT("Could not initialize filesystem (err \%d).\n"),ret));
exit(-1);
}
/* Open the directory */
ls_openDir(list,&(efsl.myFs),"/usr/bin/");
/* Print a list of all files and their filesize */
while(ls_getNext(list)==0){
DBG((TXT("%s (%li bytes)\n"),
list->currentEntry.FileName,
list->currentEntry.FileSize));
}
/* Correctly close the filesystem */
fs_umount(&efs.myFs);
}
\end{lstlisting}
Please note that it is not required to close this object, if you wish to switch
to another directory you can just call \code{ls\_openDir} on the object again.
@@ -0,0 +1,42 @@
\subsubsection*{Purpose}
This function opens a directory for viewing, allowing you to iterate through
it's contents.
\subsubsection*{Prototype}
\code{esint8 ls\_openDir(DirList *dlist,FileSystem *fs,eint8* dirname);}
\subsubsection*{Arguments}
Objects passed to \code{ls\_openDir}:
\begin{itemize}
\item{\code{dlist}: pointer to a DirList object}
\item{\code{fs}: pointer to the FileSystem object}
\item{\code{dirname}: C string containing the directorypath}
\end{itemize}
\subsubsection*{Return value}
This function will return 0 when it has opened the directory, and -1 on error.\\
\subsubsection*{Example}
\lstset{numbers=left, stepnumber=1, numberstyle=\small, numbersep=5pt, tabsize=4}
\begin{lstlisting}
#include "efs.h"
#include "ls.h"
void main(void)
{
EmbeddedFileSystem efsl;
DirList list;
/* Initialize efsl */
if(efs_init(&efsl,"/dev/sda")!=0){
DBG((TXT("Could not initialize filesystem (err \%d).\n"),ret));
exit(-1);
}
/* Open the directory */
ls_openDir(list,&(efsl.myFs),"/usr/bin/");
/* Correctly close the filesystem */
fs_umount(&efs.myFs);
}
\end{lstlisting}
Please note that it is not required to close this object, if you wish to switch
to another directory you can just call \code{ls\_openDir} on the object again.
@@ -0,0 +1,47 @@
\subsubsection*{Purpose}
Creates a new directory.
\subsubsection*{Prototype}
\code{esint8 mkdir(FileSystem *fs,eint8* dirname);}
\subsubsection*{Arguments}
Objects passed to \code{mkdir}:
\begin{itemize}
\item{\code{fs}: pointer to the FileSystem object}
\item{\code{dir}: pointer to the path + name of the new directory}
\end{itemize}
\subsubsection*{Return value}
Returns 0 if no errors are detected.\\
\newline
Returns non-zero if an error is detected:
\begin{itemize}
\item{Returns -1 if the directory already exists.}
\item{Returns -2 if the path is incorrect (parent directory does not exists).}
\item{Returns -3 if no free space is available to create the directory.}
\end{itemize}
\subsubsection*{Example}
\lstset{numbers=left, stepnumber=1, numberstyle=\small, numbersep=5pt, tabsize=4}
\begin{lstlisting}
#include "efs.h"
void main(void)
{
EmbeddedFileSystem efsl;
/* Initialize efsl */
DBG((TXT("Will init efsl now.\n")));
if(efs_init(&efsl,"/dev/sda")!=0){
DBG((TXT("Could not initialize filesystem (err \%d).\n"),ret));
exit(-1);
}
DBG((TXT("Filesystem correctly initialized.\n")));
/* Create new directories */
if(mkdir(&efsl.myFs,"dir1")==0){
mkdir(&efsl.myFs,"dir1/subdir1");
mkdir(&efsl.myFs,"dir1/subdir2");
mkdir(&efsl.myFs,"dir1/subdir3");
}
/* Close filesystem */
fs_umount(&efsl.myFs);
}
\end{lstlisting}
@@ -0,0 +1,62 @@
This section of the manual describes the minimalistic C library functions that were
created for EFSL. Since EFSL was designed for ultimate portability, no assumptions about the
workings or even the presence of a C library could be made. Fortunately only very few functions
had to be created that mimicked the operations of well known C library functions.
\\
\begin{longtable}{|p{0.35\textwidth}|p{0.65\textwidth}|}
\hline
\multicolumn{2}{|c|}{
\textbf{PLibC Functions}
} \\
\multicolumn{2}{|c|}{} \\
\hline
\hline
\endfirsthead
\hline
\multicolumn{2}{|c|}{\textbf{PLibC Functions (continued)}} \\
\hline
\endhead
\hline
\endfoot
\hline
\endlastfoot
\code{strMatch} & \code{euint16 strMatch(eint8* bufa, eint8*bufb,euint32 n)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This function compares the strings \code{bufa} and \code{bufb} for \code{n} bytes.
It will return the number of bytes in that section that does not match. So if you
want to compare two strings the return value should be 0, for the strings to match over
the entire \code{n} area.
}\\
\hline
\code{memCpy} & \code{void memCpy(void* psrc, void* pdest, euint32 size)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This function will copy the contents at location \code{psrc} to location \code{pdest} over
a range of \code{size} bytes.
}\\
\hline
\code{memClr} & \code{void memClr(void *pdest,euint32 size)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This function will set the memory at \code{pdest} to value \code{0x00} for a range of
\code{size} bytes.
}\\
\hline
\code{memSet} & \code{void memSet(void *pdest,euint32 size,euint8 data)} \\
\hline
\multicolumn{2}{|p{\textwidth}|}{
This function will set the memory at \code{pdest} to value \code{data} for a range of
\code{size} bytes.
}\\
\hline
\end{longtable}
@@ -0,0 +1,31 @@
\subsection{Project aims}
The EFSL project aims to create a library for filesystems, to be used on
various embedded systems. Currently we support the Microsoft FAT filesystem
family. It is our intention to create pure ANSI C code that compiles on
anything that bears the name 'C compiler'. We don't make assumptions about
endianness or how the memory alignment is arranged on your architecture.
\newline\newline
Adding code for your specific hardware is straightforward, just add code that
fetches or writes a 512 byte sector, and the library will do the rest.
Existing code can be used, writing your own code is only required when you
have hardware for which no target exists.
\subsection{Project status}
Efsl currently supports FAT12, FAT16 and FAT32. Read and write has been tested
and is stable. Efsl runs on PC (GNU/Linux, development environment),
TMS C6000 DSP's from Texas instruments, and ATMega's from Atmel.
You can use this code with as little as 1 kilobyte RAM, however if you have
more at your disposal, an infinite amount can be used as cache memory.
The more memory you commit, the better the performance will be.
\subsection{License}
This project is released under the Lesser General Public license, which
means that you may use the library and it's sourcecode for any purpose you want,
that you may link with it and use it commercially, but that ANY change to the
code must be released under the same license. We would appreciate if you would send
us a patch when you add support for new hardware, but this is not obligatory, since it
falls under linking as far as the LGPL is concerned.
\subsection{Contact}
You can reach us by email:\\
\begin{tabular}{ll}
Michael De Nil & michael@flex-it.be\\
Lennart Yseboodt & len@belf.be\\
\end{tabular}
@@ -0,0 +1,42 @@
\subsubsection*{Purpose}
Deletes a file.
\subsubsection*{Prototype}
\code{esint16 rmfile(FileSystem *fs,euint8* filename);}
\subsubsection*{Arguments}
Objects passed to \code{rmfile}:
\begin{itemize}
\item{\code{fs}: pointer to the FileSystem object}
\item{\code{filename}: pointer to the path + name of the file to be removed}
\end{itemize}
\subsubsection*{Return value}
Returns 0 if no errors are detected.\\
\newline
Returns non-zero if an error is detected, most likely that the file does not exist.
\subsubsection*{Note}
If you have opened a file with \code{fopen()}, and you wish to delete it, first
close all instances of that file. If you do not, you may corrupt the filesystem.
\subsubsection*{Example}
\lstset{numbers=left, stepnumber=1, numberstyle=\small, numbersep=5pt, tabsize=4}
\begin{lstlisting}
#include "efs.h"
void main(void)
{
EmbeddedFileSystem efsl;
/* Initialize efsl */
DBG((TXT("Will init efsl now.\n")));
if(efs_init(&efsl,"/dev/sda")!=0){
DBG((TXT("Could not initialize filesystem (err \%d).\n"),ret));
exit(-1);
}
DBG((TXT("Filesystem correctly initialized.\n")));
/* Delete some files */
rmfile(&efsl.myFs,"file0.txt");
rmfile(&efsl.myFs,"dir0/file0.txt");
/* Close filesystem */
fs_umount(&efsl.myFs);
}
\end{lstlisting}
@@ -0,0 +1,98 @@
This section will tell you everything you need to know to start using the
embedded filesystems library on a TMS Digital Signal Processor from Texas Instruments.
The only thing that is required is that you have a McBSP port available, and that your DSP
support CLOCKSTOP mode, which is required to connect a SPI compatible device.
There are special DSP's from TI which have a special MMC/SD card controller, if you want to
use this special interface you will have to create a hardware endpoint for it. This section only
describes connecting an SD card to a normal McBSP port, since every TI DSP has at least one of them.
\subsubsection{Hardware}
Connecting the SD card to the McBSP is straightforward, you will have to make 4 data related
connections, Vcc and ground, resulting in a 6 wire interface.\\
\begin{tabular}{|l|l|l|l|l|}
\hline
\multicolumn{3}{|c|}{SD Card Interface}&\multicolumn{2}{|c|}{McBSP Interface}\\
\hline
1 & CS & Chip select & FSX & Frame Sync Transmit \\
2 & MOSI & Master out Slave In & DX & Data transmit \\
3 & GND & Supply Ground &&\\
4 & Vcc & Supply voltage (3.3 Volt) &&\\
5 & Clk & Clock & CLKX & Clock Transmit\\
6 & GND & Supply ground &&\\
7 & MISO & Master in Slave out & DR & Data receive \\
8 & NC & Not connected &&\\
9 & NC & Not connected &&\\
\hline
\end{tabular}\\
You can optionally pull the DataIn and DataOut lines up to Vcc with a $10k\Omega$ resistor, but
we found that this was not required for operation.\\
\includegraphics[scale=0.4]{schematics/sdcard.eps}\\
The frame sync from the McBSP port is used to select the card whenever a databyte has to be transferred, it is connected to the chip select of the SD card. The DX and DR pins are connected to the SDcard's DataIn and DataOut lines respectively. Finally the McBSP will have to generate a clock for
the SDcard so that it can perform operations, this is accomplished by connecting the clock transmit
line of the McBSP port to the CLK pin of the SDCard.
\subsubsection{McBSP configuration}
\begin{longtable}{|p{0.13\textwidth}|p{0.1\textwidth}|p{0.06\textwidth}|p{0.75\textwidth}|}
\hline
\multicolumn{4}{|c|}{
\textbf{McBSP Register Explanations}
} \\
\hline
\hline
\endfirsthead
\hline
\multicolumn{4}{|c|}{\textbf{mcbsp registers (continued)}} \\
\hline
\endhead
\hline
\endfoot
\hline
\endlastfoot
\multicolumn{3}{|c|}{SPCR}&
\multicolumn{1}{c|}{Serial Port Control Register}\\
\hline
Name & Bit & Value &\multicolumn{1}{c|}{Value \code{(0x00001800 | 0x00410001)}}\\
\hline
RRST&\code{0}&\code{1b} & The serial port receiver is enabled \\
XRST&\code{16}&\code{1b} & The serial port transmitter is enabled \\
CLKSTP&\code{12:11}&\code{11b} & Clock starts on falling edge without delay(see CLKXM) \\
GRST&\code{22}&\code{1b} & Sample rate generator is pulled out of reset \\
\hline
\multicolumn{3}{|c|}{PCR}&
\multicolumn{1}{c|}{Pin Control Register}\\
\hline
Name &Bit & Value &\multicolumn{1}{c|}{Value \code{0x00000A0C}}\\
\hline
CLKXP&\code{1} &\code{0b} & Transmit data on the rising edge ofthe clock\\
FSXP&\code{3} &\code{1b} & Frame Sync (Chip select on SD card) is active low\\
CLKXM&\code{9} &\code{1b} & McBSP is a master in SPI mode and generates the clock based on
the sample rate generator\\
FSXM&\code{10} &\code{1b} & Frame sync is determined by tge sample rate generator\\
\hline
\multicolumn{3}{|c|}{RCR/XCR}&
\multicolumn{1}{c|}{Receive/Transmit Control Register}\\
\hline
Name &Bit & Value &\multicolumn{1}{c|}{Value \code{0x00010000}}\\
\hline
RWDLEN&\code{7:5} &\code{000b} & Receive element is 8 bits (1byte) large\\
XDATDLY&\code{17:16} &\code{01b} & 1 bit data delay (after frame sync)\\
\hline
\multicolumn{3}{|c|}{SRGR}&
\multicolumn{1}{c|}{Sample Rate Genrator}\\
\hline
Name &Bit & Value &\multicolumn{1}{c|}{Value \code{0x20000002}}\\
\hline
CLKSM&\code{29} &\code{1b} & The sample rate generator clock is derived from the internal clock\\
FSGM&\code{28} &\code{0b} & The transmit frame sync signal is generated on every DXR to XSR copy\\
CLKGDV&\code{7:0}&\code{0x02h} & The clock divider\\
\hline
\end{longtable}
@@ -0,0 +1,26 @@
Standard C data types have the annoying tendency to have different sizes on difference compilers
and platforms. Therefore we have created 9 new types that are used everywhere throughout the library.
When you implement your platform you should check if any of the existing one matches your hardware,
or create a new one.\\
\\
Here's an overview:\\\\
\begin{tabular}{|p{4cm}|l|l|}
\hline
\textbf{Type} & \textbf{Size} & \textbf{Signedness}\\
\hline
\hline
\texttt{eint8} & 1 byte & default to platform \\
\texttt{esint8} & 1 byte & signed \\
\texttt{euint8} & 1 byte & unsigned \\
\hline
\texttt{eint16} & 2 bytes & default to platform \\
\texttt{esint16} & 2 bytes & signed \\
\texttt{euint16} & 2 bytes & unsigned \\
\hline
\texttt{eint32} & 4 bytes & default to platform \\
\texttt{esint32} & 4 bytes & signed \\
\texttt{euint32} & 4 bytes & unsigned \\
\hline
\end{tabular}
$ $\\\\\\
You will find the relevant code in the file \filename{types.h} in the directory \filename{inc/}.
@@ -0,0 +1,84 @@
\subsection{Notations}
The utilities can be compiled and run on any POSIX compliant system.
Although not tested on Windows, they should work there as well. In order
to be able to make the utilities, you should have run make in the main directory,
so that an libefsl.a has been made. These utilities link against that library.
You can run the binaries without arguments to get a short help, which is repeated
here in the 'usage` section of the utilities.
All utilities take an image, or a device as their first argument. If the image/device
is a partition, and hence does not contain a partition table, it will be recognised and treated
as such.
If a partition table is found, the first partition with a FAT signature will be used.
Arguments between $<>$ brackets are mandatory, arguments between $[]$ brackets are optional.
\subsection{cpo}
\subsubsection*{Usage}
cpo $<$fs$>$ $<$file\_read$>$ $<$local\_write$>$ [bufsize]
\subsubsection*{Operation}
Cpo copies a file residing in a fat filesystem to your local file system. It copies
outwards. The first argument \code{fs} is the image or device on which the source
filesystem resides. The second argument (\code{file\_read} is the path and filename
of the sourcefile in \code{fs}. The third argument (\code{local\_write}) is the
local file to which you want to write the contents.
The fourth, optional, arguments (\code{bufsize}) says cpo what size of copy buffers
to use. This operates the same as dd. This is used in testing the library, the
default value is 4096 bytes.
\subsection{cpi}
\subsubsection*{Usage}
cpi $<$fs$>$ $<$local\_read$>$ $<$file\_write$>$ [bufsize]
\subsubsection*{Operation}
Cpi copies a file from your local filesystem to a fat filesystem. It copies inwards.
The first argument \code{fs} is the image or device on which the source
filesystem resides. The second argument (\code{local\_read} is the path and filename
of the sourcefile on your local filesystem. The third argument (\code{file\_write}) is the
path and filename to which you want to write the contents.
Cpi will bail out when the destination target already exists.
The fourth, optional, arguments (\code{bufsize}) says cpi what size of copy buffers
to use. This operates the same as dd. This is used in testing the library, the
default value is 4096 bytes.
\subsection{cpa}
\subsubsection*{Usage}
cpa $<$fs$>$ $<$local\_read$>$ $<$file\_append$>$ [bufsize]
\subsubsection*{Operation}
Cpa copies a file from your local filesystem to a fat filesystem. It copies inwards.
The first argument \code{fs} is the image or device on which the source
filesystem resides. The second argument (\code{local\_read} is the path and filename
of the sourcefile on your local filesystem. The third argument (\code{file\_append}) is the
path and filename to which you want to write the contents.
Cpa will append to the destination target, or create it if it doesn't exist yet.
The fourth, optional, arguments (\code{bufsize}) says cpi what size of copy buffers
to use. This operates the same as dd. This is used in testing the library, the
default value is 4096 bytes.
\subsection{list}
\subsubsection*{Usage}
list $<$fs$>$ $<$directory$>$
\subsubsection*{Operation}
List will give a listing of existing files on a given filesystem \code{fs}, that
reside in the directory \code{directory}. To get the contents of the root directory,
give a forward slash (/) as the directory argument.
\subsection{mkdir}
\subsubsection*{Usage}
mkdir $<$fs$>$ $<$dirname$>$
\subsubsection*{Operation}
Mkdir will create a new directory in the filesystem \code{fs}. You must provide the full path
of the new directory as an argument.
\subsection{rmfile}
\subsubsection*{Usage}
rmfile $<$fs$>$ $<$filename$>$
\subsubsection*{Operation}
Rmfile will delete a file from a filesystem \code{fs}.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -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
+142
View File
@@ -0,0 +1,142 @@
/*****************************************************************************\
* efs - General purpose Embedded Filesystem library *
* --------------------------------------------------------- *
* *
* Filename : debug.h *
* Description : Headerfile for debug.c *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; version 2 *
* of the License. *
*
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* As a special exception, if other files instantiate templates or *
* use macros or inline functions from this file, or you compile this *
* file and link it with other works to produce a work based on this file, *
* this file does not by itself cause the resulting work to be covered *
* by the GNU General Public License. However the source code for this *
* file must still be made available in accordance with section (3) of *
* the GNU General Public License. *
* *
* This exception does not invalidate any other reasons why a work based *
* on this file might be covered by the GNU General Public License. *
* *
* (c)2006 Lennart Yseboodt *
* (c)2006 Michael De Nil *
\*****************************************************************************/
/* Contributions
* LPC2000 ARM7 Interface (c)2005 Martin Thomas *
*/
#ifndef __DEBUG_H__
#define __DEBUG_H__
/*****************************************************************************/
#include "types.h"
#include "config.h"
/*****************************************************************************/
#ifndef DEBUG
#define TXT(x) ;
#define DBG(x) ;
#define FUNC_IN(x) ;
#define FUNC_OUT(x) ;
#endif
#ifdef DEBUG
#if defined(HW_ENDPOINT_LINUX) || defined(HW_ENDPOINT_LINUX64)
#define HW_ENDPOINT_LINUX_ALL
#endif
#ifdef HW_ENDPOINT_ATMEGA128_SD
#include <avr/io.h>
#include <compat/ina90.h>
#include <avr/pgmspace.h>
#include <stdio.h>
#define TXT(x) PSTR(x)
#define DBG(x) debug x
#define FUNC_IN(x) ;
#define FUNC_OUT(x) ;
#endif
#ifdef HW_ENDPOINT_LINUX_ALL
#include <stdio.h>
#include <stdarg.h>
#define TXT(x) x
#define DBG(x) debug x
#define FUNC_IN(x) debug_funcin(x)
#define FUNC_OUT(x) debug_funcout(x)
#endif
#ifdef HW_ENDPOINT_DSP_TI6713_SD
#include <stdio.h>
#include <stdarg.h>
#define TXT(x) x
#define DBG(x) printf x
#define FUNC_IN(x) ;
#define FUNC_OUT(x) ;
#endif
#ifdef HW_ENDPOINT_NIOS_2_SD
#include <stdio.h>
#include <stdarg.h>
#define TXT(x) x
#define DBG(x) printf x
#define FUNC_IN(x) ;
#define FUNC_OUT(x) ;
#endif
#ifdef HW_ENDPOINT_LPC2000_SD
#include "interfaces/lpc2000_dbg_printf.h"
#define TXT(x) x
#define DBG(x) debug x
#define FUNC_IN(x) ;
#define FUNC_OUT(x) ;
#define debug lpc2000_debug_printf
#endif
#ifdef HW_ENDPOINT_AT91SAM
#include <stdio.h>
#include <stdarg.h>
#define TXT(x) x
#ifndef NDEBUG
#define DBG(x) printf x
#else
#define DBG(x)
#endif
#define FUNC_IN(x) ;
#define FUNC_OUT(x) ;
#else
void debug(const eint8 *format, ...); /* This is messy FIXME */
#endif
void debug_init();
void debug_end();
#ifdef HW_ENDPOINT_LINUX_ALL
FILE* debugfile;
volatile euint8 tw;
void debug_funcin(const eint8 *format, ...);
void debug_funcout(const eint8 *format, ...);
euint8 debug_getByte();
euint8 debug_getString(euint8 *data,euint16 length);
#endif
#ifdef HW_ENDPOINT_ATMEGA128_SD
void debug_initUART(euint16 baudrate );
void debug_sendByte(euint8 data );
#endif
#endif
#endif
+84
View File
@@ -0,0 +1,84 @@
/*****************************************************************************\
* efs - General purpose Embedded Filesystem library *
* --------------------- ----------------------------------- *
* *
* Filename : dir.h *
* Description : Headerfile for dir.c The files are an extend of the fs.c fs.h *
* pair. *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; version 2 *
* of the License. *
*
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* As a special exception, if other files instantiate templates or *
* use macros or inline functions from this file, or you compile this *
* file and link it with other works to produce a work based on this file, *
* this file does not by itself cause the resulting work to be covered *
* by the GNU General Public License. However the source code for this *
* file must still be made available in accordance with section (3) of *
* the GNU General Public License. *
* *
* This exception does not invalidate any other reasons why a work based *
* on this file might be covered by the GNU General Public License. *
* *
* (c)2006 Lennart Yseboodt *
* (c)2006 Michael De Nil *
\*****************************************************************************/
#ifndef __DDIR_H__
#define __DDIR_H__
/*****************************************************************************/
#include "config.h"
#include "error.h"
#include "fat.h"
#include "plibc.h"
#include "types.h"
#include "ioman.h"
#include "time.h"
#include "fs.h"
/*****************************************************************************/
#define ATTR_READ_ONLY 0x01
#define ATTR_HIDDEN 0x02
#define ATTR_SYSTEM 0x04
#define ATTR_VOLUME_ID 0x08
#define ATTR_DIRECTORY 0x10
#define ATTR_ARCHIVE 0x20
#define OFFSET_DE_FILENAME 0
#define OFFSET_DE_ATTRIBUTE 11
#define OFFSET_DE_NTRESERVED 12
#define OFFSET_DE_CRTIMETNT 13
#define OFFSET_DE_CREATETIME 14
#define OFFSET_DE_CREATEDATE 16
#define OFFSET_DE_LASTACCESSDATE 18
#define OFFSET_DE_FIRSTCLUSTERHIGH 20
#define OFFSET_DE_WRITETIME 22
#define OFFSET_DE_WRITEDATE 24
#define OFFSET_DE_FIRSTCLUSTERLOW 26
#define OFFSET_DE_FILESIZE 28
#define DIRFIND_FILE 0
#define DIRFIND_FREE 1
void dir_getFileStructure(FileSystem *fs,FileRecord *filerec,FileLocation *loc);
void dir_createDirectoryEntry(FileSystem *fs,FileRecord *filerec,FileLocation *loc);
void dir_createDefaultEntry(FileSystem *fs,FileRecord *filerec,eint8* fatfilename);
void dir_setFirstCluster(FileSystem *fs,FileLocation *loc,euint32 cluster_addr);
void dir_setFileSize(FileSystem *fs,FileLocation *loc,euint32 numbytes);
euint32 dir_findinRoot(FileSystem *fs,eint8 * fatname, FileLocation *loc);
euint32 dir_findinDir(FileSystem *fs, eint8 * fatname, euint32 startCluster, FileLocation *loc, euint8 mode);
euint32 dir_findinBuf(euint8 *buf,eint8 *fatname, FileLocation *loc, euint8 mode);
euint32 dir_findinCluster(FileSystem *fs,euint32 cluster,eint8 *fatname, FileLocation *loc, euint8 mode);
euint32 dir_findinRootArea(FileSystem *fs,eint8* fatname, FileLocation *loc, euint8 mode);
esint8 dir_getFatFileName(eint8* filename, eint8* fatfilename);
esint8 dir_updateDirectoryEntry(FileSystem *fs,FileRecord *entry,FileLocation *loc);
esint8 dir_addCluster(FileSystem *fs,euint32 firstCluster);
#endif
+88
View File
@@ -0,0 +1,88 @@
/*****************************************************************************\
* efs - General purpose Embedded Filesystem library *
* --------------------- ----------------------------------- *
* *
* Filename : disc.h *
* Description : This is the header file for disc.c *
* *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; version 2 *
* of the License. *
*
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* As a special exception, if other files instantiate templates or *
* use macros or inline functions from this file, or you compile this *
* file and link it with other works to produce a work based on this file, *
* this file does not by itself cause the resulting work to be covered *
* by the GNU General Public License. However the source code for this *
* file must still be made available in accordance with section (3) of *
* the GNU General Public License. *
* *
* This exception does not invalidate any other reasons why a work based *
* on this file might be covered by the GNU General Public License. *
* *
* (c)2006 Lennart Yseboodt *
* (c)2006 Michael De Nil *
\*****************************************************************************/
#ifndef __DISC_H_
#define __DISC_H_
/*****************************************************************************/
#include "config.h"
#include "error.h"
#include "interface.h"
#include "ioman.h"
#include "types.h"
#include "debug.h"
/*****************************************************************************/
#define LBA_ADDR_MBR 0
#define PARTITION_TABLE_OFFSET 0x1BE
/**********************************************************\
PartitionField
------------
* uchar type Type of partition
* ulong LBA_begin LBA address of first sector.
* ulong numSectors Number of 512byte sectors
This structure is a literal representation of a 16 byte
partitionfield. Direct I/O is possible.
\**********************************************************/
struct PartitionField{
euint8 bootFlag;
euint8 CHS_begin[3];
euint8 type;
euint8 CHS_end[3];
euint32 LBA_begin;
euint32 numSectors;
};
typedef struct PartitionField PartitionField;
#define SIZE_PARTITION_FIELD 16
/***************************************************************************************\
Disc
--
* CompactFlash* sourcedisc Pointer to the hardwareobject that this disc is on.
* PartitionField* partitions Array of PartitionFields, containing the partition info
\***************************************************************************************/
struct Disc{
IOManager *ioman;
DISC_ERR_EUINT8
PartitionField partitions[4];
};
typedef struct Disc Disc;
void disc_initDisc(Disc *disc,IOManager *ioman);
void disc_loadMBR(Disc *disc);
#include "extract.h"
#endif
+63
View File
@@ -0,0 +1,63 @@
/*****************************************************************************\
* efs - General purpose Embedded Filesystem library *
* --------------------- ----------------------------------- *
* *
* Filename : efs.h *
* Description : Headerfile for efs.c *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; version 2 *
* of the License. *
*
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* As a special exception, if other files instantiate templates or *
* use macros or inline functions from this file, or you compile this *
* file and link it with other works to produce a work based on this file, *
* this file does not by itself cause the resulting work to be covered *
* by the GNU General Public License. However the source code for this *
* file must still be made available in accordance with section (3) of *
* the GNU General Public License. *
* *
* This exception does not invalidate any other reasons why a work based *
* on this file might be covered by the GNU General Public License. *
* *
* (c)2006 Lennart Yseboodt *
* (c)2006 Michael De Nil *
\*****************************************************************************/
#ifndef __EFS_H__
#define __EFS_H__
/*****************************************************************************/
#include "types.h"
#include "config.h"
#include "interface.h"
#include "disc.h"
#include "partition.h"
#include "fs.h"
#include "file.h"
#include "time.h"
#include "ui.h"
/*****************************************************************************/
typedef File EmbeddedFile;
struct EmbeddedFileSystem{
hwInterface myCard;
IOManager myIOman;
Disc myDisc;
Partition myPart;
FileSystem myFs;
};
typedef struct EmbeddedFileSystem EmbeddedFileSystem;
esint8 efs_init(EmbeddedFileSystem * efs,eint8 * opts);
#endif
+123
View File
@@ -0,0 +1,123 @@
/*****************************************************************************\
* efs - General purpose Embedded Filesystem library *
* --------------------- ----------------------------------- *
* *
* Filename : error.h *
* Description : Header file containing error-defines. *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; version 2 *
* of the License. *
*
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* As a special exception, if other files instantiate templates or *
* use macros or inline functions from this file, or you compile this *
* file and link it with other works to produce a work based on this file, *
* this file does not by itself cause the resulting work to be covered *
* by the GNU General Public License. However the source code for this *
* file must still be made available in accordance with section (3) of *
* the GNU General Public License. *
* *
* This exception does not invalidate any other reasons why a work based *
* on this file might be covered by the GNU General Public License. *
* *
* (c)2006 Lennart Yseboodt *
* (c)2006 Michael De Nil *
\*****************************************************************************/
#ifndef __ERROR_H_
#define __ERROR_H_
/*****************************************************************************/
#include "config.h"
#include "interface.h"
/*****************************************************************************/
#if defined (FULL_ERROR_SUPPORT)
#define ERRSUP_IOMAN
#define ERRSUP_DISC
#define ERRSUP_PARTITION
#define ERRSUP_FAT_FILESYSTEM
#define ERRSUP_FAT_FILESYSTEM
#elif defined (BASE_ERROR_SUPPORT)
#define ERRSUP_IOMAN
#define ERRSUP_DISC
#define ERRSUP_PARTITION
#endif
#if defined (HWINT_HAS_ERROR_SUPPORT) && defined (INTERFACE_ERROR_SUPPORT)
#define ERRSUP_HWINTERFACE
#endif
#ifdef ERRSUP_IOMAN
#define IOMAN_ERR_EUINT8 euint8 error;
#define ioman_setError(ioman,errval) ioman->error = errval
#define ioman_getError(ioman) ioman->error
#else
#define IOMAN_ERR_EUINT8
#define ioman_setError(ioman,errval)
#define ioman_getError(ioman) 0
#endif
#ifdef ERRSUP_DISC
#define DISC_ERR_EUINT8 euint8 error;
#define disc_setError(disc,errval) disc->error = errval
#define disc_getError(disc) disc->error
#else
#define DISC_ERR_EUINT8
#define disc_setError(disc,errval)
#define disc_getError(disc) 0
#endif
#ifdef ERRSUP_PART
#define PART_ERR_EUINT8 euint8 error;
#define part_setError(part,errval) part->error = errval
#define part_getError(part) part->error
#else
#define PART_ERR_EUINT8
#define part_setError(part,errval)
#define part_getError(part) 0
#endif
#ifdef ERRSUP_FAT_FILESYSTEM
#define FILESYSTEM_ERR_EUINT8 euint8 error;
#define fs_setError(fs,errval) fs->error = errval
#define fs_getError(fs) fs->error
#else
#define FILESYSTEM_ERR_EUINT8
#define fs_setError(fs,errval)
#define fs_getError(fs) 0
#endif
#ifdef ERRSUP_FILE
#define FILE_ERR_EUINT8 euint8 error;
#define file_setError(file,errval) file->error = errval
#define file_getError(file) file->error
#else
#define FILE_ERR_EUINT8
#define file_setError(file,errval)
#define file_getError(file) 0
#endif
#define IOMAN_NOERROR 0
#define IOMAN_ERR_SETATTROUTOFBOUNDS 1
#define IOMAN_ERR_GETATTROUTOFBOUNDS 2
#define IOMAN_ERR_READFAIL 3
#define IOMAN_ERR_WRITEFAIL 4
#define IOMAN_ERR_OPOUTOFBOUNDS 5
#define IOMAN_ERR_PUSHBEYONDSTACK 6
#define IOMAN_ERR_POPEMPTYSTACK 7
#define IOMAN_ERR_CACHEPTROUTOFRANGE 8
#define IOMAN_ERR_WRITEREADONLYSECTOR 9
#define IOMAN_ERR_NOMEMORY 10
#define DISC_NOERROR 0
#define PART_NOERROR 0
#endif
@@ -0,0 +1,74 @@
/*****************************************************************************\
* efs - General purpose Embedded Filesystem library *
* --------------------- ----------------------------------- *
* *
* Filename : extract.h *
* Description : Headerfile for extract.c *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; version 2 *
* of the License. *
*
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* As a special exception, if other files instantiate templates or *
* use macros or inline functions from this file, or you compile this *
* file and link it with other works to produce a work based on this file, *
* this file does not by itself cause the resulting work to be covered *
* by the GNU General Public License. However the source code for this *
* file must still be made available in accordance with section (3) of *
* the GNU General Public License. *
* *
* This exception does not invalidate any other reasons why a work based *
* on this file might be covered by the GNU General Public License. *
* *
* (c)2006 Lennart Yseboodt *
* (c)2006 Michael De Nil *
\*****************************************************************************/
#ifndef __EXTRACT_H_
#define __EXTRACT_H_
/*****************************************************************************/
#include "config.h"
#include "disc.h"
#include "types.h"
/*****************************************************************************/
#ifdef BIG_ENDIAN
#define ltb_end16(x) ((((uint16)(x) & 0xff00) >> 8) | \
(((uint16)(x) & 0x00ff) << 8))
#define ltb_end32(x) ((((uint32)(x) & 0xff000000) >> 24) | \
(((uint32)(x) & 0x00ff0000) >> 8) | \
(((uint32)(x) & 0x0000ff00) << 8) | \
(((uint32)(x) & 0x000000ff) << 24))
#else
#define ltb_end16(x) (x)
#define ltb_end32(x) (x)
#endif
#define btl_end16 ltb_end16
#define btl_end32 ltb_end32
/*****************************************************************************/
euint16 ex_getb16(euint8* buf,euint32 offset);
void ex_setb16(euint8* buf,euint32 offset,euint16 data);
euint32 ex_getb32(euint8* buf,euint32 offset);
void ex_setb32(euint8* buf,euint32 offset,euint32 data);
void ex_getPartitionField(euint8* buf,PartitionField* pf, euint32 offset);
void ex_setPartitionField(euint8* buf,PartitionField* pf, euint32 offset);
#endif
+62
View File
@@ -0,0 +1,62 @@
/*****************************************************************************\
* efs - General purpose Embedded Filesystem library *
* --------------------- ----------------------------------- *
* *
* Filename : fat.h *
* Description : Headerfile for fat.c The files are an extend of the fs.c fs.h *
* pair. *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; version 2 *
* of the License. *
*
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* As a special exception, if other files instantiate templates or *
* use macros or inline functions from this file, or you compile this *
* file and link it with other works to produce a work based on this file, *
* this file does not by itself cause the resulting work to be covered *
* by the GNU General Public License. However the source code for this *
* file must still be made available in accordance with section (3) of *
* the GNU General Public License. *
* *
* This exception does not invalidate any other reasons why a work based *
* on this file might be covered by the GNU General Public License. *
* *
* (c)2006 Lennart Yseboodt *
* (c)2006 Michael De Nil *
\*****************************************************************************/
#ifndef __FAT_H_
#define __FAT_H_
/*****************************************************************************/
#include "config.h"
#include "error.h"
#include "file.h"
#include "debug.h"
#include "types.h"
/*****************************************************************************/
euint32 fat_getSectorAddressFatEntry(FileSystem *fs,euint32 cluster_addr);
euint32 fat_getNextClusterAddress(FileSystem *fs, euint32 cluster_addr, euint16 *linear);
void fat_setNextClusterAddress(FileSystem *fs,euint32 cluster_addr,euint32 next_cluster_addr);
eint16 fat_isEocMarker(FileSystem *fs,euint32 fat_entry);
euint32 fat_giveEocMarker(FileSystem *fs);
euint32 fat_findClusterAddress(FileSystem *fs,euint32 cluster,euint32 offset, euint8 *linear);
euint32 fat_getNextClusterAddressWBuf(FileSystem *fs,euint32 cluster_addr, euint8 * buf);
void fat_setNextClusterAddressWBuf(FileSystem *fs,euint32 cluster_addr,euint32 next_cluster_addr,euint8 * buf);
esint16 fat_getNextClusterChain(FileSystem *fs, ClusterChain *Cache);
void fat_bogus(void);
esint16 fat_LogicToDiscCluster(FileSystem *fs, ClusterChain *Cache,euint32 logiccluster);
eint16 fat_allocClusterChain(FileSystem *fs,ClusterChain *Cache,euint32 num_clusters);
eint16 fat_unlinkClusterChain(FileSystem *fs,ClusterChain *Cache);
euint32 fat_countClustersInChain(FileSystem *fs,euint32 firstcluster);
euint32 fat_DiscToLogicCluster(FileSystem *fs,euint32 firstcluster,euint32 disccluster);
euint32 fat_countFreeClusters(FileSystem *fs);
#endif
+95
View File
@@ -0,0 +1,95 @@
/*****************************************************************************\
* efs - General purpose Embedded Filesystem library *
* --------------------- ----------------------------------- *
* *
* Filename : file.h *
* Description : Headerfile for file.c *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; version 2 *
* of the License. *
*
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* As a special exception, if other files instantiate templates or *
* use macros or inline functions from this file, or you compile this *
* file and link it with other works to produce a work based on this file, *
* this file does not by itself cause the resulting work to be covered *
* by the GNU General Public License. However the source code for this *
* file must still be made available in accordance with section (3) of *
* the GNU General Public License. *
* *
* This exception does not invalidate any other reasons why a work based *
* on this file might be covered by the GNU General Public License. *
* *
* (c)2006 Lennart Yseboodt *
* (c)2006 Michael De Nil *
\*****************************************************************************/
#ifndef __FILE_H_
#define __FILE_H_
/*****************************************************************************/
#include "config.h"
#include "error.h"
#include "time.h"
#include "fs.h"
#include "dir.h"
#include "plibc.h"
#include "debug.h"
#include "types.h"
#include "fat.h"
/*****************************************************************************/
#define MODE_READ 0x72
#define MODE_WRITE 0x77
#define MODE_APPEND 0x61
#define FILE_STATUS_OPEN 0
#define FILE_STATUS_WRITE 1
/*****************************************************************************\
* File
* ------
* FileRecord DirEntry Copy of the FileRecord for this file
* FileLocation Location Location of the direntry
* FileSystem *fs Pointer to the filesystem this file is on
* FileCache Cache Pointer to the cache object of the file
* euint8 FileStatus Contains bitfield regarding filestatus
* euint32 FilePtr Offsetpointer for fread/fwrite functions
* euint32 FileSize Working copy of the filesize, always use this,
it is more up to date than DirEntry->FileSize,
which is only updated when flushing to disc.
\*****************************************************************************/
struct File{
FileRecord DirEntry;
FileLocation Location; /* Location in directory!! */
FileSystem *fs;
ClusterChain Cache;
euint8 FileStatus;
euint32 FilePtr;
euint32 FileSize;
};
typedef struct File File;
esint8 file_fopen(File *file, FileSystem *fs,eint8 *filename, eint8 mode);
esint8 file_fclose(File *file);
esint16 file_setpos(File *file,euint32 pos);
euint32 file_fread(File *file,euint32 offset, euint32 size,euint8 *buf);
euint32 file_read (File *file,euint32 size,euint8 *buf);
euint32 file_fwrite(File* file,euint32 offset,euint32 size,euint8* buf);
euint32 file_write (File* file,euint32 size,euint8* buf);
eint8* file_normalToFatName(eint8* filename,eint8* fatfilename);
euint8 file_validateChar(euint8 c);
void file_initFile(File *file, FileSystem *fs, FileLocation *loc);
eint16 file_allocClusterChain(File *file,euint32 num_clusters);
void file_setAttr(File* file,euint8 attribute,euint8 val);
euint8 file_getAttr(File* file,euint8 attribute);
euint32 file_requiredCluster(File *file,euint32 offset, euint32 size);
#endif
+196
View File
@@ -0,0 +1,196 @@
/*****************************************************************************\
* efs - General purpose Embedded Filesystem library *
* --------------------- ----------------------------------- *
* *
* Filename : fs.h *
* Description : Headerfile for fs.c *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; version 2 *
* of the License. *
*
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* As a special exception, if other files instantiate templates or *
* use macros or inline functions from this file, or you compile this *
* file and link it with other works to produce a work based on this file, *
* this file does not by itself cause the resulting work to be covered *
* by the GNU General Public License. However the source code for this *
* file must still be made available in accordance with section (3) of *
* the GNU General Public License. *
* *
* This exception does not invalidate any other reasons why a work based *
* on this file might be covered by the GNU General Public License. *
* *
* (c)2006 Lennart Yseboodt *
* (c)2006 Michael De Nil *
\*****************************************************************************/
#ifndef __FS_H_
#define __FS_H_
/*****************************************************************************/
#include "config.h"
#include "error.h"
#include "partition.h"
#include "types.h"
#include "debug.h"
#include "time.h"
/*****************************************************************************/
#define FAT12 1
#define FAT16 2
#define FAT32 3
#define FS_INFO_SECTOR 1
#define FSINFO_MAGIC_BEGIN 0x41615252
#define FSINFO_MAGIC_END 0xAA550000
/*****************************************************************************************\
VolumeId
------
* ushort BytesPerSector Must be 512 or shit happens.
* uchar SectorsPerCluster Must be multiple of 2 (1,2,4,8,16 or 32)
* ushort ReservedSectorCount Number of sectors after which the first FAT begins.
* uchar NumberOfFats Should be 2
* ushort RootEntryCount Number of filerecords the Rootdir can contain. NOT for FAT32
* ushort SectorCount16 Number of Sectors for 12/16 bit FAT
* ushort FatSectorCount16 Number of Sectors for 1 FAT on FAT12/16 bit FAT's
* ulong SectorCount32 Number of Sectors for 32 bit FAT
* ulong FatSectorCount32 Number of Sectors for 1 FAT on FAT32
* ulong RootCluster Clusternumber of the first cluster of the RootDir on FAT 32
This is NOT a complete volumeId copy, no direct I/O is possible.
\*****************************************************************************************/
struct VolumeId{
euint16 BytesPerSector;
euint8 SectorsPerCluster;
euint16 ReservedSectorCount;
euint8 NumberOfFats;
euint16 RootEntryCount;
euint16 SectorCount16;
euint16 FatSectorCount16;
euint32 SectorCount32;
euint32 FatSectorCount32;
euint32 RootCluster;
};
typedef struct VolumeId VolumeId;
/**************************************************************************************************\
FileSystem
--------
* Partition* part Pointer to partition on which this FS resides.
* VolumeId volumeId Contains important FS info.
* ulong DataClusterCount Number of dataclusters. This number determines the FATType.
* ulong FatSectorCount Number of sectors for 1 FAT, regardless of FATType
* ulong SectorCount Number of sectors, regardless of FATType
* ulong FirstSectorRootDir First sector of the RootDir.
* uchar type Determines FATType (FAT12 FAT16 or FAT32 are defined)
\**************************************************************************************************/
struct FileSystem{
Partition *part;
VolumeId volumeId;
euint32 DataClusterCount;
euint32 FatSectorCount;
euint32 SectorCount;
euint32 FirstSectorRootDir;
euint32 FirstClusterCurrentDir;
euint32 FreeClusterCount;
euint32 NextFreeCluster;
euint8 type;
};
typedef struct FileSystem FileSystem;
/**************************************************************************************************\ FileLocation
----------
* euint32 Sector Sector where the directoryentry of the file/directory can be found.
* euint8 Offset Offset (in 32byte segments) where in the sector the entry is.
\**************************************************************************************************/
struct FileLocation{
euint32 Sector;
euint8 Offset;
euint8 attrib;
};
typedef struct FileLocation FileLocation;
/*****************************************************************************\
* FileCache
* -----------
* This struct acts as cache for the current file. It contains the current
* FATPointer (next location in the FAT table), LogicCluster
* (the last part of the file that was read) and DataCluster
* (the last cluster that was read).
* euint8 Linear For how many more clusters the file is nonfragmented
* euint32 LogicCluster This field determines the n'th cluster of the file as current
* euint32 DiscCluster If this field is 0, it means the cache is invalid. Otherwise
it is the clusternumber corresponding with
logic(FirstCluster+LogicCluster).
* euint32 FirstCluster First cluster of the chain. Zero or one are invalid.
* euint32 LastCluster Last cluster of the chain (is not always filled in)
\*****************************************************************************/
struct ClusterChain{
euint8 Linear;
esint32 LogicCluster;
euint32 DiscCluster;
euint32 FirstCluster;
euint32 LastCluster;
euint32 ClusterCount;
};
typedef struct ClusterChain ClusterChain;
/*****************************************************************************\
* FileRecord *
* ------------ *
* This struct represents a 32 byte file entry as it occurs in the data area *
* of the filesystem. Direct I/O is possible. *
\*****************************************************************************/
struct FileRecord{
euint8 FileName[11];
euint8 Attribute;
euint8 NTReserved;
euint8 MilliSecTimeStamp;
euint16 CreatedTime;
euint16 CreatedDate;
euint16 AccessDate;
euint16 FirstClusterHigh;
euint16 WriteTime;
euint16 WriteDate;
euint16 FirstClusterLow;
euint32 FileSize;
};
typedef struct FileRecord FileRecord;
eint16 fs_initFs(FileSystem *fs,Partition *part);
eint16 fs_isValidFat(Partition *part);
void fs_loadVolumeId(FileSystem *fs, Partition *part);
esint16 fs_verifySanity(FileSystem *fs);
void fs_countDataSectors(FileSystem *fs);
void fs_determineFatType(FileSystem *fs);
void fs_findFirstSectorRootDir(FileSystem *fs);
void fs_initCurrentDir(FileSystem *fs);
euint32 fs_getSectorAddressRootDir(FileSystem *fs,euint32 secref);
euint32 fs_clusterToSector(FileSystem *fs,euint32 cluster);
euint32 fs_sectorToCluster(FileSystem *fs,euint32 sector);
euint32 fs_getNextFreeCluster(FileSystem *fs,euint32 startingcluster);
euint32 fs_giveFreeClusterHint(FileSystem *fs);
esint16 fs_findFreeFile(FileSystem *fs,eint8* filename,FileLocation *loc,euint8 mode);
esint8 fs_findFile(FileSystem *fs,eint8* filename,FileLocation *loc,euint32 *lastDir);
esint8 fs_findFile_broken(FileSystem *fs,eint8* filename,FileLocation *loc);
euint32 fs_getLastCluster(FileSystem *fs,ClusterChain *Cache);
euint32 fs_getFirstClusterRootDir(FileSystem *fs);
euint16 fs_makeDate(void);
euint16 fs_makeTime(void);
void fs_setFirstClusterInDirEntry(FileRecord *rec,euint32 cluster_addr);
void fs_initClusterChain(FileSystem *fs,ClusterChain *cache,euint32 cluster_addr);
esint8 fs_flushFs(FileSystem *fs);
esint8 fs_umount(FileSystem *fs);
esint8 fs_clearCluster(FileSystem *fs,euint32 cluster);
esint8 fs_getFsInfo(FileSystem *fs,euint8 force_update);
esint8 fs_setFsInfo(FileSystem *fs);
#endif
@@ -0,0 +1,56 @@
/*****************************************************************************\
* efs - General purpose Embedded Filesystem library *
* -------------------------------------------------------- *
* *
* Filename : interface.h *
* Description : This headerfile includes the right interface headerfile *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; version 2 *
* of the License. *
*
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* As a special exception, if other files instantiate templates or *
* use macros or inline functions from this file, or you compile this *
* file and link it with other works to produce a work based on this file, *
* this file does not by itself cause the resulting work to be covered *
* by the GNU General Public License. However the source code for this *
* file must still be made available in accordance with section (3) of *
* the GNU General Public License. *
* *
* This exception does not invalidate any other reasons why a work based *
* on this file might be covered by the GNU General Public License. *
* *
* (c)2006 Lennart Yseboodt *
* (c)2006 Michael De Nil *
\*****************************************************************************/
#ifndef __TYPES_H__
#define __TYPES_H__
/*****************************************************************************/
#include "types.h"
#include "config.h"
/*****************************************************************************/
#if defined(HW_ENDPOINT_LINUX) || defined(HW_ENDPOINT_LINUX64)
#include "interfaces/linuxfile.h"
#elif defined(HW_ENDPOINT_ATMEGA128_SD)
#include "interfaces/atmega128.h"
#elif defined(HW_ENDPOINT_DSP_TI6713_SD)
#include "interfaces/dsp67xx.h"
#elif defined(HW_ENDPOINT_LPC2000_SD)
#include "interfaces/lpc2000_spi.h"
#elif defined(HW_ENDPOINT_AT91SAM)
#include "interfaces/at91sam7s_spi.h"
#else
#error "NO INTERFACE DEFINED - see interface.h"
#endif
#endif
@@ -0,0 +1,72 @@
/* based on LPC213x.h from Keil GmbH (keil.com/arm.com) */
#ifndef LPC2000_regs_h
#define LPC2000_regs_h
/* 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))
/* 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 */
/* maybe useful for the efsl time-handling : */
#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))
#endif

Some files were not shown because too many files have changed in this diff Show More