mirror of
https://github.com/oliverschmidt/contiki.git
synced 2025-02-01 18:33:12 +00:00
update build system for board specific code that's 'local' to the
program you are building. update tests to consolidate common code.
This commit is contained in:
parent
a791be393b
commit
87cd9c7a36
@ -11,9 +11,10 @@ include $(MC1322X)/board/Makefile.board
|
||||
|
||||
include $(MC1322X)/libmc1322x/Makefile.lib
|
||||
|
||||
# default start and isr
|
||||
CFLAGS += -I$(MC1322X)/src
|
||||
|
||||
CFLAGS += -I$(MC1322X)/src -I.
|
||||
|
||||
# default start and isr
|
||||
ifndef START
|
||||
START = $(MC1322X)/src/start.o
|
||||
endif
|
||||
@ -21,6 +22,7 @@ ifndef ISR
|
||||
ISR = $(MC1322X)/src/isr.o
|
||||
endif
|
||||
SRCOBJS += $(MC1322X)/src/default_lowlevel.o
|
||||
BOARDOBJS := $(addprefix $(OBJDIR)/,$(COBJS))
|
||||
|
||||
ARCH = arm
|
||||
CPU = arm7tdmi-s
|
||||
@ -28,16 +30,20 @@ export ARCH CPU VENDOR
|
||||
|
||||
.SECONDARY:
|
||||
|
||||
#.depend: Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
|
||||
# $(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
|
||||
#sinclude .depend
|
||||
|
||||
$(START): $(START:.o=.s)
|
||||
$(CC) $(AFLAGS) -c -o $@ $<
|
||||
|
||||
$(ISR): $(ISR:.o=.c)
|
||||
$(CC) $(CFLAGS) $(ARM_FLAGS) $< -c -o $@
|
||||
|
||||
%_$(BOARD).elf: %.elf
|
||||
%_$(BOARD).elf: %.elf $(BOARDOBJS)
|
||||
mv $< $@
|
||||
|
||||
%.elf: $(START) $(ISR) $(SRCOBJS) $(OBJDIR)/%.o $(LINKERSCRIPT) $(LIBMC1322X)/libmc1322x.a
|
||||
%.elf: $(START) $(ISR) $(SRCOBJS) $(OBJDIR)/%.o $(BOARDOBJS) $(LINKERSCRIPT) $(LIBMC1322X)/libmc1322x.a
|
||||
$(CC) $(LDFLAGS) $(AOBJS) \
|
||||
$(filter %.o %.a,$+) -o $@
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
BOARDS := redbee-dev redbee-r1
|
||||
|
||||
OBJDIR := obj_$(BOARD)_board
|
||||
CFLAGS += -I$(OBJDIR) -I$(MC1322X)/board
|
||||
CFLAGS += -I$(OBJDIR) -I$(MC1322X)/board -DBOARD=$(BOARD)
|
||||
|
||||
$(OBJDIR):
|
||||
ifndef BOARD
|
||||
|
@ -4,5 +4,9 @@
|
||||
#include "types.h"
|
||||
#include "isr.h"
|
||||
#include "gpio.h"
|
||||
#include "crm.h"
|
||||
#include "nvm.h"
|
||||
#include "uart1.h"
|
||||
#include "utils.h"
|
||||
|
||||
#endif
|
||||
|
@ -1,8 +1,6 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define CAT2(x, y, z) x##y##z
|
||||
|
||||
#define bit(bit) (1 << bit)
|
||||
|
@ -1,5 +1,11 @@
|
||||
MC1322X := ..
|
||||
|
||||
# all off the common objects for each target
|
||||
# a COBJ is made for EACH board and goes the obj_$(BOARD)_board directory
|
||||
# board specific code is OK in these files
|
||||
COBJS := tests.o put.o
|
||||
|
||||
# all of the target programs to build
|
||||
TARGETS := blink-red blink-green blink-blue blink-white blink-allio uart1-loopback nvm-read nvm-write
|
||||
|
||||
include $(MC1322X)/Makefile.include
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <mc1322x.h>
|
||||
#include <board.h>
|
||||
#include <uart1.h>
|
||||
#include <nvm.h>
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
/* INC = 767; MOD = 9999 works: 115200 @ 24 MHz 16 bit sample */
|
||||
#define INC 767
|
||||
@ -10,39 +10,15 @@
|
||||
#define READ_ADDR 0x1F000
|
||||
#define NBYTES 1024
|
||||
|
||||
void putc(char c);
|
||||
void puts(char *s);
|
||||
void put_hex(uint8_t x);
|
||||
void put_hex16(uint16_t x);
|
||||
void put_hex32(uint32_t x);
|
||||
|
||||
const uint8_t hex[16]={'0','1','2','3','4','5','6','7',
|
||||
'8','9','a','b','c','d','e','f'};
|
||||
|
||||
|
||||
|
||||
void main(void) {
|
||||
nvmType_t type=0;
|
||||
nvmErr_t err;
|
||||
uint32_t buf[NBYTES/4];
|
||||
uint32_t i;
|
||||
|
||||
/* Restore UART regs. to default */
|
||||
/* in case there is still bootloader state leftover */
|
||||
uart_init(INC, MOD);
|
||||
|
||||
*UART1_CON = 0x0000c800; /* mask interrupts, 16 bit sample --- helps explain the baud rate */
|
||||
|
||||
/* INC = 767; MOD = 9999 works: 115200 @ 24 MHz 16 bit sample */
|
||||
#define INC 767
|
||||
#define MOD 9999
|
||||
*UART1_BR = INC<<16 | MOD;
|
||||
|
||||
/* see Section 11.5.1.2 Alternate Modes */
|
||||
/* you must enable the peripheral first BEFORE setting the function in GPIO_FUNC_SEL */
|
||||
/* From the datasheet: "The peripheral function will control operation of the pad IF */
|
||||
/* THE PERIPHERAL IS ENABLED. */
|
||||
*UART1_CON = 0x00000003; /* enable receive and transmit */
|
||||
*GPIO_FUNC_SEL0 = ( (0x01 << (14*2)) | (0x01 << (15*2)) ); /* set GPIO15-14 to UART (UART1 TX and RX)*/
|
||||
print_welcome("nvm-read");
|
||||
|
||||
vreg_init();
|
||||
|
||||
@ -73,33 +49,3 @@ void main(void) {
|
||||
while(1) {continue;};
|
||||
}
|
||||
|
||||
void putc(char c) {
|
||||
while(*UT1CON == 31); /* wait for there to be room in the buffer */
|
||||
*UART1_DATA = c;
|
||||
}
|
||||
|
||||
void puts(char *s) {
|
||||
while(s && *s!=0) {
|
||||
putc(*s++);
|
||||
}
|
||||
}
|
||||
|
||||
void put_hex(uint8_t x)
|
||||
{
|
||||
putc(hex[x >> 4]);
|
||||
putc(hex[x & 15]);
|
||||
}
|
||||
|
||||
void put_hex16(uint16_t x)
|
||||
{
|
||||
put_hex((x >> 8) & 0xFF);
|
||||
put_hex((x) & 0xFF);
|
||||
}
|
||||
|
||||
void put_hex32(uint32_t x)
|
||||
{
|
||||
put_hex((x >> 24) & 0xFF);
|
||||
put_hex((x >> 16) & 0xFF);
|
||||
put_hex((x >> 8) & 0xFF);
|
||||
put_hex((x) & 0xFF);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <mc1322x.h>
|
||||
#include <board.h>
|
||||
#include <uart1.h>
|
||||
#include <nvm.h>
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
/* INC = 767; MOD = 9999 works: 115200 @ 24 MHz 16 bit sample */
|
||||
#define INC 767
|
||||
@ -12,34 +12,15 @@
|
||||
#define WRITEVAL0 0xdeadbeef
|
||||
#define WRITEVAL1 0xdeadbeef
|
||||
|
||||
void putc(char c);
|
||||
void puts(char *s);
|
||||
void put_hex(uint8_t x);
|
||||
void put_hex16(uint16_t x);
|
||||
void put_hex32(uint32_t x);
|
||||
|
||||
const uint8_t hex[16]={'0','1','2','3','4','5','6','7',
|
||||
'8','9','a','b','c','d','e','f'};
|
||||
|
||||
void main(void) {
|
||||
nvmType_t type=0;
|
||||
nvmErr_t err;
|
||||
uint32_t buf[NBYTES/4];
|
||||
uint32_t i;
|
||||
|
||||
*UART1_CON = 0x0000c800; /* mask interrupts, 16 bit sample --- helps explain the baud rate */
|
||||
uart_init(INC, MOD);
|
||||
|
||||
/* INC = 767; MOD = 9999 works: 115200 @ 24 MHz 16 bit sample */
|
||||
#define INC 767
|
||||
#define MOD 9999
|
||||
*UART1_BR = INC<<16 | MOD;
|
||||
|
||||
/* see Section 11.5.1.2 Alternate Modes */
|
||||
/* you must enable the peripheral first BEFORE setting the function in GPIO_FUNC_SEL */
|
||||
/* From the datasheet: "The peripheral function will control operation of the pad IF */
|
||||
/* THE PERIPHERAL IS ENABLED. */
|
||||
*UART1_CON = 0x00000003; /* enable receive and transmit */
|
||||
*GPIO_FUNC_SEL0 = ( (0x01 << (14*2)) | (0x01 << (15*2)) ); /* set GPIO15-14 to UART (UART1 TX and RX)*/
|
||||
print_welcome("nvm-write");
|
||||
|
||||
vreg_init();
|
||||
|
||||
@ -89,33 +70,3 @@ void main(void) {
|
||||
while(1) {continue;};
|
||||
}
|
||||
|
||||
void putc(char c) {
|
||||
while(*UT1CON == 31); /* wait for there to be room in the buffer */
|
||||
*UART1_DATA = c;
|
||||
}
|
||||
|
||||
void puts(char *s) {
|
||||
while(s && *s!=0) {
|
||||
putc(*s++);
|
||||
}
|
||||
}
|
||||
|
||||
void put_hex(uint8_t x)
|
||||
{
|
||||
putc(hex[x >> 4]);
|
||||
putc(hex[x & 15]);
|
||||
}
|
||||
|
||||
void put_hex16(uint16_t x)
|
||||
{
|
||||
put_hex((x >> 8) & 0xFF);
|
||||
put_hex((x) & 0xFF);
|
||||
}
|
||||
|
||||
void put_hex32(uint32_t x)
|
||||
{
|
||||
put_hex((x >> 24) & 0xFF);
|
||||
put_hex((x >> 16) & 0xFF);
|
||||
put_hex((x >> 8) & 0xFF);
|
||||
put_hex((x) & 0xFF);
|
||||
}
|
||||
|
36
tests/put.c
Normal file
36
tests/put.c
Normal file
@ -0,0 +1,36 @@
|
||||
#include <mc1322x.h>
|
||||
#include <board.h>
|
||||
|
||||
const uint8_t hex[16]={'0','1','2','3','4','5','6','7',
|
||||
'8','9','a','b','c','d','e','f'};
|
||||
|
||||
void putc(char c) {
|
||||
while(*UT1CON == 31); /* wait for there to be room in the buffer */
|
||||
*UART1_DATA = c;
|
||||
}
|
||||
|
||||
void puts(char *s) {
|
||||
while(s && *s!=0) {
|
||||
putc(*s++);
|
||||
}
|
||||
}
|
||||
|
||||
void put_hex(uint8_t x)
|
||||
{
|
||||
putc(hex[x >> 4]);
|
||||
putc(hex[x & 15]);
|
||||
}
|
||||
|
||||
void put_hex16(uint16_t x)
|
||||
{
|
||||
put_hex((x >> 8) & 0xFF);
|
||||
put_hex((x) & 0xFF);
|
||||
}
|
||||
|
||||
void put_hex32(uint32_t x)
|
||||
{
|
||||
put_hex((x >> 24) & 0xFF);
|
||||
put_hex((x >> 16) & 0xFF);
|
||||
put_hex((x >> 8) & 0xFF);
|
||||
put_hex((x) & 0xFF);
|
||||
}
|
10
tests/put.h
Normal file
10
tests/put.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef PUT_H
|
||||
#define PUT_H
|
||||
|
||||
void putc(char c);
|
||||
void puts(char *s);
|
||||
void put_hex(uint8_t x);
|
||||
void put_hex16(uint16_t x);
|
||||
void put_hex32(uint32_t x);
|
||||
|
||||
#endif
|
@ -1,19 +1,12 @@
|
||||
#define GPIO_FUNC_SEL0 0x80000018 /* GPIO 15 - 0; 2 bit blocks */
|
||||
#include <mc1322x.h>
|
||||
#include <board.h>
|
||||
|
||||
#define BASE_UART1 0x80005000
|
||||
#define UART1_CON 0x80005000
|
||||
#define UART1_STAT 0x80005004
|
||||
#define UART1_DATA 0x80005008
|
||||
#define UR1CON 0x8000500c
|
||||
#define UT1CON 0x80005010
|
||||
#define UART1_CTS 0x80005014
|
||||
#define UART1_BR 0x80005018
|
||||
#include "tests.h"
|
||||
#include "put.h"
|
||||
|
||||
#include "embedded_types.h"
|
||||
|
||||
#define reg(x) (*(volatile uint32_t *)(x))
|
||||
|
||||
#define DELAY 400000
|
||||
/* INC = 767; MOD = 9999 works: 115200 @ 24 MHz 16 bit sample */
|
||||
#define INC 767
|
||||
#define MOD 9999
|
||||
|
||||
void putc(uint8_t c);
|
||||
void puts(uint8_t *s);
|
||||
@ -28,30 +21,11 @@ const uint8_t hex[16]={'0','1','2','3','4','5','6','7',
|
||||
#define DUMP_LEN 0x00014000
|
||||
//#define DUMP_LEN 16
|
||||
|
||||
#include "isr.h"
|
||||
|
||||
__attribute__ ((section ("startup")))
|
||||
void main(void) {
|
||||
volatile uint32_t i;
|
||||
// volatile uint8_t *data;
|
||||
volatile uint8_t *data;
|
||||
|
||||
/* Restore UART regs. to default */
|
||||
/* in case there is still bootloader state leftover */
|
||||
|
||||
reg(UART1_CON) = 0x0000c800; /* mask interrupts, 16 bit sample --- helps explain the baud rate */
|
||||
|
||||
/* INC = 767; MOD = 9999 works: 115200 @ 24 MHz 16 bit sample */
|
||||
#define INC 767
|
||||
#define MOD 9999
|
||||
reg(UART1_BR) = INC<<16 | MOD;
|
||||
|
||||
/* see Section 11.5.1.2 Alternate Modes */
|
||||
/* you must enable the peripheral first BEFORE setting the function in GPIO_FUNC_SEL */
|
||||
/* From the datasheet: "The peripheral function will control operation of the pad IF */
|
||||
/* THE PERIPHERAL IS ENABLED. */
|
||||
reg(UART1_CON) = 0x00000003; /* enable receive and transmit */
|
||||
reg(GPIO_FUNC_SEL0) = ( (0x01 << (14*2)) | (0x01 << (15*2)) ); /* set GPIO15-14 to UART (UART1 TX and RX)*/
|
||||
uart_init(inc, mod);
|
||||
|
||||
for(data=DUMP_BASE; data<(DUMP_BASE+DUMP_LEN); data++) {
|
||||
putc(*data);
|
||||
|
32
tests/tests.c
Normal file
32
tests/tests.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include <mc1322x.h>
|
||||
#include "put.h"
|
||||
|
||||
void uart_init(uint16_t inc, uint16_t mod) {
|
||||
/* Restore UART regs. to default */
|
||||
/* in case there is still bootloader state leftover */
|
||||
|
||||
*UART1_CON = 0x0000c800; /* mask interrupts, 16 bit sample --- helps explain the baud rate */
|
||||
|
||||
/* INC = 767; MOD = 9999 works: 115200 @ 24 MHz 16 bit sample */
|
||||
*UART1_BR = (inc << 16) | mod;
|
||||
|
||||
/* see Section 11.5.1.2 Alternate Modes */
|
||||
/* you must enable the peripheral first BEFORE setting the function in GPIO_FUNC_SEL */
|
||||
/* From the datasheet: "The peripheral function will control operation of the pad IF */
|
||||
/* THE PERIPHERAL IS ENABLED. */
|
||||
*UART1_CON = 0x00000003; /* enable receive and transmit */
|
||||
*GPIO_FUNC_SEL0 = ( (0x01 << (14*2)) | (0x01 << (15*2)) ); /* set GPIO15-14 to UART (UART1 TX and RX)*/
|
||||
|
||||
}
|
||||
|
||||
void print_welcome(char* testname) {
|
||||
puts("mc1322x-test: ");
|
||||
puts(testname);
|
||||
puts("\n\r");
|
||||
puts("board: ");
|
||||
#if (BOARD == redbee-dev)
|
||||
puts("redbee-dev");
|
||||
#elif (BOARD == redbee-r1)
|
||||
puts("redbee-dev");
|
||||
#endif
|
||||
}
|
9
tests/tests.h
Normal file
9
tests/tests.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef TESTS_H
|
||||
#define TESTS_H
|
||||
|
||||
#include "put.h"
|
||||
|
||||
void uart_init(uint16_t inc, uint16_t mod);
|
||||
void print_welcome(char* testname);
|
||||
|
||||
#endif
|
@ -1,25 +1,13 @@
|
||||
#include <mc1322x.h>
|
||||
#include <board.h>
|
||||
#include <uart1.h>
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
/* INC = 767; MOD = 9999 works: 115200 @ 24 MHz 16 bit sample */
|
||||
#define INC 767
|
||||
#define MOD 9999
|
||||
|
||||
void main(void) {
|
||||
|
||||
/* mask interrupts, 16 bit sample --- helps explain the baud rate */
|
||||
*UART1_CON = 0x0000c800;
|
||||
|
||||
|
||||
*UART1_BR = INC<<16 | MOD;
|
||||
|
||||
/* see Section 11.5.1.2 Alternate Modes */
|
||||
/* you must enable the peripheral first BEFORE setting the function in GPIO_FUNC_SEL */
|
||||
/* From the datasheet: "The peripheral function will control operation of the pad IF */
|
||||
/* THE PERIPHERAL IS ENABLED. */
|
||||
*UART1_CON = 0x00000003; /* enable receive and transmit */
|
||||
*GPIO_FUNC_SEL0 = ( (0x01 << (14*2)) | (0x01 << (15*2)) ); /* set GPIO15-14 to UART (UART1 TX and RX)*/
|
||||
|
||||
uint8_t c;
|
||||
while(1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user