URL
https://opencores.org/ocsvn/openmsp430/openmsp430/trunk
Subversion Repositories openmsp430
Compare Revisions
- This comparison shows the changes necessary to convert path
/openmsp430/trunk/core/sim/rtl_sim/src-c/dhrystone_v2.1
- from Rev 202 to Rev 211
- ↔ Reverse comparison
Rev 202 → Rev 211
/copydata.c
File deleted
/omsp_func.h
40,7 → 40,8
//---------------------------------------------------------- |
// SPECIAL FUNCTION REGISTERS |
//---------------------------------------------------------- |
#define IE1 (*(volatile unsigned char *) 0x0000) |
#define IE1_set_wdtie() __asm__ __volatile__ ("bis.b #0x01, &0x0000") |
//#define IE1 (*(volatile unsigned char *) 0x0000) |
#define IFG1 (*(volatile unsigned char *) 0x0002) |
|
#define CPU_ID_LO (*(volatile unsigned char *) 0x0004) |
121,4 → 122,6
// FUNCTIONS |
//============================================================================= |
|
//int putchar (int txdata); |
// Replace printf statements with custom one |
#include "mylib/cprintf.h" |
#define printf cprintf |
/linker.msp430-elf.x
237,7 → 237,7
/* DWARF 2 */ |
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } |
.debug_abbrev 0 : { *(.debug_abbrev) } |
.debug_line 0 : { *(.debug_line) } |
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) } |
.debug_frame 0 : { *(.debug_frame) } |
.debug_str 0 : { *(.debug_str) } |
.debug_loc 0 : { *(.debug_loc) } |
/omsp_func.c
39,7 → 39,8
// putChar function // |
// (Send a byte to the Port-1) // |
//--------------------------------------------------// |
int putchar (int txdata) { |
//int putchar (int txdata) { |
int tty_putc (int txdata) { |
|
// Write the output character to the Port-1 |
P1OUT = txdata; |
/mylib/copydata.c
0,0 → 1,15
#include <stdint.h> |
#include <string.h> |
|
extern char __datastart; |
extern char __romdatastart; |
extern char __romdatacopysize; |
static void* const datastart=&__datastart; |
static void* const romdatastart=&__romdatastart; |
static uint16_t const romdatacopysize=(uint16_t)&__romdatacopysize; |
|
__attribute__((constructor)) void __data_move() { |
if (datastart!=romdatastart) { |
memmove(datastart,romdatastart,romdatacopysize); |
} |
} |
/mylib/cprintf.c
0,0 → 1,158
#include <stdarg.h> |
|
#include "cprintf.h" |
|
typedef unsigned char byte; |
|
static char hex[] = "0123456789abcdef"; |
|
void |
cput_nibble (int n) |
{ |
tty_putc (hex[n&0x0f]); |
} |
|
void |
cput_hex_byte (int n) |
{ |
cput_nibble (n >> 4); |
cput_nibble (n); |
} |
|
void |
cput_binary_byte (int n) |
{ |
int i; |
for (i=7; i>=0; i--) |
tty_putc((n & (1<<i)) ? '1' : '0'); |
} |
|
void |
cput_hex_word (int n) |
{ |
cput_hex_byte (n >> 8); |
cput_hex_byte (n); |
} |
|
void |
cput_hex_long (long int n) |
{ |
cput_hex_byte (n >> 24); |
cput_hex_byte (n >> 16); |
cput_hex_byte (n >> 8); |
cput_hex_byte (n); |
} |
|
void |
cput_hex_block (char *block, int n) |
{ |
int i = 0; |
while (n) |
{ |
cput_hex_byte (*block++); |
if (--n == 0) |
break; |
i++; |
if ((i & 7) == 0) |
tty_putc (' '); |
else |
tty_putc (':'); |
} |
} |
|
void |
cput_nibble_block (char *block, int n) |
{ |
int i = 0; |
while (n) |
{ |
cput_nibble (*block); |
if (--n == 0) |
break; |
i++; |
if ((i & 7) == 0) |
tty_putc (' '); |
} |
} |
|
void |
cput_number (int n) |
{ |
char buf[20]; |
int i = 0; |
if (n < 0) |
{ |
tty_putc ('-'); |
n = -n; |
} |
while (n > 9) |
{ |
buf[i++] = (n%10) + '0'; |
n /= 10; |
} |
buf[i++] = (n%10) + '0'; |
while (i > 0) |
tty_putc (buf[--i]); |
} |
|
void |
cprintf (const char *fmt, ...) |
{ |
va_list v; |
int i; |
char *s; |
|
va_start (v, fmt); |
|
while (*fmt) |
{ |
if (*fmt != '%') |
tty_putc (*fmt); |
else |
switch (*++fmt) |
{ |
case '%': |
tty_putc ('%'); |
break; |
case 'c': |
i = va_arg (v, int); |
tty_putc(i); |
break; |
case 'd': |
i = va_arg (v, int); |
cput_number(i); |
break; |
case 'b': |
i = va_arg (v, int); |
cput_hex_byte (i); |
break; |
case 'B': |
i = va_arg (v, int); |
cput_binary_byte (i); |
break; |
case 'w': |
i = va_arg (v, int); |
cput_hex_word (i); |
break; |
case 'l': |
i = va_arg (v, int); |
cput_hex_long (i); |
break; |
case 'x': |
s = va_arg (v, char *); |
i = va_arg (v, int); |
cput_hex_block (s, i); |
break; |
case 'n': |
s = va_arg (v, char *); |
i = va_arg (v, int); |
cput_nibble_block (s, i); |
break; |
case 's': |
s = va_arg (v, char *); |
tty_putc (s); |
break; |
} |
fmt ++; |
} |
} |
/mylib/cprintf.h
0,0 → 1,158
void cprintf(const char *, ...); |
/makefile
1,11 → 1,12
# makfile configuration |
NAME = dhrystone_v2.1 |
OBJECTS = dhry_1.o dhry_2.o omsp_func.o copydata.o |
OBJECTS = dhry_1.o dhry_2.o omsp_func.o mylib/copydata.o mylib/cprintf.o |
|
# Compiler performance option (-Os / -O2 / -O3) |
PORT_CFLAGS = -O2 |
|
# Choose GCC toolchain prefix ('msp430' for MSPGCC / 'msp430-elf' for GCC RedHat/TI) |
MSPGCC_PFX = msp430-elf |
ifndef MSPGCC_PFX |
MSPGCC_PFX = msp430 |
endif |
24,11 → 25,12
CC = ${MSPGCC_PFX}-gcc |
OBJCOPY = ${MSPGCC_PFX}-objcopy |
OBJDUMP = ${MSPGCC_PFX}-objdump |
OBJSIZE = ${MSPGCC_PFX}-size |
|
.PHONY: all FORCE clean download dist |
|
#all should be the first target. it's built when make is runwithout args |
all: ${NAME}.elf ${NAME}.a43 ${NAME}.lst |
all: ${NAME}.elf ${NAME}.a43 ${NAME}.lst ${NAME}.size |
|
#configure the next line if you want to use the serial download |
download: download-uart |
43,11 → 45,14
${NAME}.lst: ${NAME}.elf |
${OBJDUMP} -dSt $^ >$@ |
|
${NAME}.size: ${NAME}.elf |
${OBJSIZE} $^ >$@ |
|
download-uart: all |
openmsp430-loader.tcl -device /dev/ttyUSB0 -baudrate 115200 ${NAME}.elf |
|
clean: |
rm -f ${NAME} ${NAME}.a43 ${NAME}.lst ${NAME}.elf *.o |
rm -f ${NAME} ${NAME}.a43 ${NAME}.lst ${NAME}.elf ${NAME}.size *.o mylib/*.o |
|
#backup archive |
dist: |
60,4 → 65,5
dhry_1.o: dhry_1.c |
dhry_2.o: dhry_2.c |
omsp_func.o: omsp_func.c |
copydata.o: copydata.c |
mylib/copydata.o: mylib/copydata.c |
mylib/cprintf.o: mylib/cprintf.c |