Skip to content

Commit

Permalink
[drivers] Move some files to drivers
Browse files Browse the repository at this point in the history
Fix up Makefiles and .c file includes so things build again

Moved: delay lcd tick

Signed-off-by: Christopher Hall <hsw@openmoko.com>


git-svn-id: https://wikipediardware.googlecode.com/svn/trunk@1687 974c56cd-8151-0410-98c4-7bb2f43fa8c1
  • Loading branch information
hsw@openmoko.com committed May 22, 2009
1 parent 7b5d188 commit 1d4b274
Show file tree
Hide file tree
Showing 21 changed files with 84 additions and 51 deletions.
1 change: 0 additions & 1 deletion samo-lib/Mk/definitions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ SAMO_LIB := $(shell readlink -es ../samo-lib || readlink -es ../../samo-lib || r
SAMO_LIB_MK = ${SAMO_LIB}/Mk

SAMO_LIB_INCLUDE = ${SAMO_LIB}/include
SAMO_LIB_SRC = ${SAMO_LIB}/src

MINI_LIBC = ${SAMO_LIB}/mini-libc
MINI_LIBC_INCLUDE = ${MINI_LIBC}/include
Expand Down
7 changes: 7 additions & 0 deletions samo-lib/drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ TARGETS = lib/libdrivers.a
OBJECTS += sd_spi.o
OBJECTS += sd_api.o
OBJECTS += mmc.o
OBJECTS += tick.o
OBJECTS += delay_us.o
OBJECTS += delay_nop.o
OBJECTS += lcd.o

# does not build - not used??
#OBJECTS += fatfs_stdio.o

BUILD_OBJECTS = $(addprefix ${BUILD_PREFIX},${OBJECTS})

Expand Down
8 changes: 8 additions & 0 deletions samo-lib/drivers/include/delay.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#if !defined(_DELAY_H_)
#define _DELAY_H_ 1

// simple busy wait delay loops
void delay(unsigned int nops); // deprecated
void delay_us(unsigned int microsec);

#endif
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions samo-lib/drivers/src/delay_nop.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright (c) 2009 Openmoko
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, either version 3 of the License, or
(at your option) any later version.
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "delay.h"

void delay(unsigned int nops)
{
while (nops--)
asm volatile ("nop");
}
33 changes: 33 additions & 0 deletions samo-lib/drivers/src/delay_us.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright (c) 2009 Openmoko
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, either version 3 of the License, or
(at your option) any later version.
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "delay.h"

void delay_us(unsigned int microsec)
{
while (microsec--) {
// at 48 MHz this should take 1 micro second
asm volatile (
"\tld.w\t%r4, 6\n"
"delay_loop:\n"
"\tnop\n"
"\tnop\n"
"\tsub\t%r4, 1\n"
"\tjrne\tdelay_loop"
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version
// 3 of the License, or (at your option) any later version.
//
//

#include <stdlib.h>
#include <string.h>
Expand Down
4 changes: 2 additions & 2 deletions samo-lib/src/lcd.c → samo-lib/drivers/src/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <types.h>
#include <misc.h>
#include <stdlib.h>
#include "regs.h"
#include "samo.h"
#include "delay.h"
#include "lcd.h"


Expand Down
16 changes: 1 addition & 15 deletions samo-lib/drivers/src/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <samo.h>
#include <diskio.h>
#include <mmc.h>
#include <delay.h>
#include "ff_config.h"

#ifdef _USE_CACHE
Expand Down Expand Up @@ -66,21 +67,6 @@ DSTATUS Stat = STA_NOINIT; /* Disk status */
static
BYTE CardType; /* b0:MMC, b1:SDv1, b2:SDv2, b3:Block addressing */

void delay_us(unsigned int microsec)
{
while (microsec--) {
//asm volatile("nop");
// at 48 MHz this should take 1 micro second
asm volatile (
"\tld.w\t%r4,12\n"
"delay_loop:\n"
"\tnop\n"
"\tsub\t%r4,1\n"
"\tjrne\tdelay_loop"
);
}
}

/*-----------------------------------------------------------------------*/
/* Receive a byte from MMC via SPI (Platform dependent) */
/*-----------------------------------------------------------------------*/
Expand Down
Empty file modified samo-lib/drivers/src/sd_api.c
100755 → 100644
Empty file.
Empty file modified samo-lib/drivers/src/sd_spi.c
100755 → 100644
Empty file.
Empty file modified samo-lib/drivers/src/sd_spi.h
100755 → 100644
Empty file.
File renamed without changes.
2 changes: 1 addition & 1 deletion samo-lib/forth/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CROSS_LDFLAGS = -static --strip-all --no-gc-sections --omagic
CROSS_ASFLAGS = -mc33pe --fatal-warnings


vpath %.c :${SAMO_LIB_SRC}
#vpath %.c src


all: forth.elf
Expand Down
4 changes: 1 addition & 3 deletions samo-lib/mahatma/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ LIBS += $$($(CC) -print-libgcc-file-name)

BUILD_PREFIX := build/

vpath %.c $(WIKI_APP_SRC):$(INDEXING_SRC):$(SAMO_LIB_SRC):$(MINILZO_SRC)
vpath %.c $(WIKI_APP_SRC):$(INDEXING_SRC):$(MINILZO_SRC)


GUILIB_COBJS = guilib.o glyph.o fontfile.o
Expand Down Expand Up @@ -76,12 +76,10 @@ OBJECTS += touchscreen.o
OBJECTS += suspend.o
OBJECTS += msg-output.o
OBJECTS += gui.o
OBJECTS += tick.o
OBJECTS += gpio.o
OBJECTS += serial.o
OBJECTS += traps.o
OBJECTS += input.o
OBJECTS += lcd.o
OBJECTS += misc.o
OBJECTS += profile.o
OBJECTS += $(GUILIB_COBJS) $(WIKIAPP_COBJS) $(MINILZO_COBJS) $(PERF_COBJ)
Expand Down
7 changes: 4 additions & 3 deletions samo-lib/mbr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ LDFLAGS = -static --strip-all -s --no-gc-sections -N -L$(MINI_LIBC)
INCLUDES = -I${FATFS_INCLUDE}
INCLUDES += -I${FATFS_CONFIG_INCLUDE}
INCLUDES += -I${MINI_LIBC_INCLUDE}
INCLUDES += -I${DRIVERS_INCLUDE}
INCLUDES += -I$(SAMO_LIB_INCLUDE)
INCLUDES += -I$(WIKI_APP_INCLUDE)

Expand All @@ -31,7 +32,7 @@ TARGETS = $(FLASH_ROM_MAP_FILE) mbr
APPLICATIONS =
APPLICATION_CLEAN =

VPATH = $(SAMO_LIB_SRC) $(WIKI_APP_SRC)
vpath %.c $(WIKI_APP_SRC)

.PHONY: all
all: $(TARGETS) all-applications
Expand Down Expand Up @@ -80,14 +81,14 @@ endef

# Applications for the boot loader

$(call MAKE_APP,menu,misc.o lcd.o, splash.h)
$(call MAKE_APP,menu,misc.o,splash.h)
$(call MAKE_APP,hello,misc.o)
$(call MAKE_APP,memory-test,misc.o)
$(call MAKE_APP,key-test,misc.o)
$(call MAKE_APP,forth-loader,misc.o elf32.o)
$(call MAKE_APP,kernel-loader,misc.o elf32.o)
$(call MAKE_APP,rs232-loader,misc.o)
$(call MAKE_APP,lcd-test,misc.o lcd.o)
$(call MAKE_APP,lcd-test,misc.o)

# application pre-depends

Expand Down
1 change: 1 addition & 0 deletions samo-lib/mbr/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "regs.h"
#include "types.h"
#include "samo.h"
#include "delay.h"
#include "misc.h"


Expand Down
21 changes: 0 additions & 21 deletions wiki-app/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,3 @@ void print_dec32(uint32_t value)
}
print(&c[i]);
}

void delay(unsigned int nops)
{
while (nops--)
asm volatile ("nop");
}

void delay_us(unsigned int microsec)
{
while (microsec--) {
// at 48 MHz this should take 1 micro second
asm volatile (
"\tld.w\t%r4, 6\n"
"delay_loop:\n"
"\tnop\n"
"\tnop\n"
"\tsub\t%r4, 1\n"
"\tjrne\tdelay_loop"
);
}
}
4 changes: 0 additions & 4 deletions wiki-app/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,5 @@ void hex_dump(const void *buffer, uint32_t size);
void print_byte(uint8_t val);
void print_u32(uint32_t val);

// simple busy wait delay loops
void delay(unsigned int nops); // deprecated
void delay_us(unsigned int microsec);

#endif /* MISC_H */

1 change: 1 addition & 0 deletions wiki-app/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <tick.h>
#include <string.h>
#include <msg.h>
#include <delay.h>
#include <regs.h>
#include <samo.h>

Expand Down

0 comments on commit 1d4b274

Please sign in to comment.