Merge remote-tracking branch 'upstream/master'

Conflicts:
	Makefile.dep
dev/timer
Ludwig Ortmann 11 years ago
commit f669f9a05b

@ -1,4 +1,4 @@
DIRS = cpu core drivers sys
DIRS = $(RIOTCPU) core drivers sys
all:
mkdir -p $(BINDIR)
@ -6,8 +6,8 @@ all:
clean:
@for i in $(DIRS) ; do $(MAKE) -C $$i clean ; done ;
@if [ -d $(BINDIR) ] ; \
then rmdir --ignore-fail-on-non-empty $(BINDIR) ; \
-@if [ -d $(BINDIR) ] ; \
then rmdir $(BINDIR) ; \
fi
doc:

@ -4,43 +4,8 @@ SRC = $(wildcard *.c)
OBJ = $(SRC:%.c=$(BINDIR)%.o)
DEP = $(SRC:%.c=$(BINDIR)%.d)
ifeq ($(CPU),lpc2387)
INCLUDES += -I$(MAKEBASE)/cpu/arm_common/include/
INCLUDES += -I$(MAKEBASE)/cpu/lpc2387/include
endif
ifeq ($(CPU),lpc214x)
INCLUDES += -I$(MAKEBASE)/cpu/arm_common/include/
INCLUDES += -I$(MAKEBASE)/cpu/lpc214x/include
endif
ifeq ($(CPU),msp430x16x)
INCLUDES += -I$(MAKEBASE)/cpu/msp430-common/include/
INCLUDES += -I$(MAKEBASE)/cpu/msp430x16x/include/
endif
ifeq ($(CPU),cc430)
INCLUDES += -I$(MAKEBASE)/cpu/msp430-common/include/
INCLUDES += -I$(MAKEBASE)/cpu/cc430/include/
endif
ifeq ($(CPU),native)
INCLUDES += -I$(MAKEBASE)/cpu/native/include/
endif
ifeq ($(BOARD),msba2)
INCLUDES += -I$(RIOTBOARD)/msba2/include/
INCLUDES += -I$(RIOTBOARD)/msba2-common/include/
INCLUDES += -I$(RIOTBOARD)/msba2-common/drivers/include/
endif
ifeq ($(BOARD),msb-430)
INCLUDES += -I$(RIOTBOARD)/msb-430/include/
INCLUDES += -I$(RIOTBOARD)/msb-430-common/include/
INCLUDES += -I$(RIOTBOARD)/msb-430-common/drivers/include/
endif
ifeq ($(BOARD),msb-430h)
INCLUDES += -I$(RIOTBOARD)/msb-430h/include/
INCLUDES += -I$(RIOTBOARD)/msb-430-common/include/
INCLUDES += -I$(RIOTBOARD)/msb-430-common/drivers/include/
endif
ifeq ($(BOARD),native)
INCLUDES += -I$(RIOTBOARD)/native/include/
endif
include $(RIOTCPU)/Makefile.base
include $(RIOTBOARD)/Makefile.base
$(BINDIR)$(MODULE).a: $(OBJ) $(ASMOBJ)
$(AR) -rc $(BINDIR)$(MODULE).a $(OBJ) $(ASMOBJ)
@ -55,7 +20,7 @@ $(BINDIR)%.o: %.c
@printf "$(BINDIR)"|cat - $(BINDIR)$*.d > /tmp/riot_out && mv /tmp/riot_out $(BINDIR)$*.d
$(BINDIR)%.o: %.s
$(AS) $(ASFLAGS) $*.s -o $(BINDIR)$*.o
@$(AS) $(ASFLAGS) $*.s -o $(BINDIR)$*.o
# remove compilation products
clean::

@ -14,30 +14,13 @@ ifneq (,$(findstring uart0,$(USEMODULE)))
endif
ifneq (,$(findstring cc110x_ng,$(USEMODULE)))
ifeq (,$(findstring transceiver,$(USEMODULE)))
USEMODULE += transceiver
endif
ifneq (,$(findstring msba2,$(BOARD)))
USEMODULE += cc110x_spi
ifeq (,$(findstring gpioint,$(USEMODULE)))
USEMODULE += gpioint
ifeq (,$(findstring transceiver,$(USEMODULE)))
USEMODULE += transceiver
endif
ifeq (,$(findstring hwtimer,$(USEMODULE)))
USEMODULE += hwtimer
endif
endif
ifneq (,$(findstring msb-430h,$(BOARD)))
USEMODULE += cc110x_spi
ifeq (,$(findstring hwtimer,$(USEMODULE)))
USEMODULE += hwtimer
ifneq (,$(findstring native,$(BOARD)))
USEMODULE += cc110x_spi
endif
endif
ifneq (,$(findstring native,$(BOARD)))
USEMODULE += cc110x_spi
ifeq (,$(findstring hwtimer,$(USEMODULE)))
USEMODULE += hwtimer
endif
endif
endif

@ -1,3 +1,11 @@
ifeq ($(strip $(RIOTCPU)),)
export RIOTCPU =$(RIOTBASE)/cpu
endif
ifeq ($(strip $(MCU)),)
MCU = $(CPU)
endif
# if you want to publish the board into the sources as an uppercase #define
BB = $(shell echo $(BOARD)|tr 'a-z' 'A-Z')
CFLAGS += -DBOARD=$(BB)
@ -15,12 +23,12 @@ PROJBINDIR =$(CURDIR)/bin
## make script for your project. Build RIOT-base here!
all: $(PROJBINDIR)/$(PROJECT).a
@echo "Building project $(PROJECT) for $(BOARD) w/ MCU $(CPU)."
@echo "Building project $(PROJECT) for $(BOARD) w/ MCU $(MCU)."
$(MAKE) -C $(RIOTBOARD)
$(MAKE) -C $(RIOTBASE)
$(LINK) $(UNDEF) -o $(PROJBINDIR)/$(PROJECT).elf -Wl,--start-group $(BASELIBS) -lm -Wl,--end-group -Wl,-Map=$(PROJBINDIR)/$(PROJECT).map $(LINKFLAGS)
$(SIZE) $(PROJBINDIR)/$(PROJECT).elf
$(OBJCOPY) -O ihex $(PROJBINDIR)/$(PROJECT).elf $(PROJBINDIR)/$(PROJECT).hex
@$(LINK) $(UNDEF) -o $(PROJBINDIR)/$(PROJECT).elf -Wl,--start-group $(BASELIBS) -lm -Wl,--end-group -Wl,-Map=$(PROJBINDIR)/$(PROJECT).map $(LINKFLAGS)
@$(SIZE) $(PROJBINDIR)/$(PROJECT).elf
@$(OBJCOPY) -O ihex $(PROJBINDIR)/$(PROJECT).elf $(PROJBINDIR)/$(PROJECT).hex
## your make rules
## Only basic example - modify it for larger projects!!

@ -1,6 +1,5 @@
export MAKEBASE =$(RIOTBASE)
export BINDIR =$(RIOTBASE)/bin/
#UNDEF = $(BINDIR)startup.o $(BINDIR)builddate.o
UNDEF = $(BINDIR)startup.o
### Minimal setup
@ -16,12 +15,13 @@ endif
ifeq ($(CPU),native)
export INCLUDES += -I$(RIOTBASE)/cpu/native/include
endif
ifeq ($(CPU),cc430)
USEMODULE += cpu core lib sys
else
ifeq ($(CPU),stm32f407vgt6)
USEMODULE += stm32f4xxstdperi
UNDEF += $(BINDIR)syscalls.o
endif
#USEMODULE += cpu_drivers cpu core lib sys
USEMODULE += cpu core sys
endif
ED = $(USEMODULE:%=-DMODULE_%)
EXTDEFINES = $(shell echo $(ED)|tr 'a-z' 'A-Z')
BL=$(USEMODULE:%= $(BINDIR)%.a)

@ -1,37 +0,0 @@
License
=======
* All sources and binaries that have been developed at Freie Universität Berlin are
licensed under the GNU General Public License version 3 as published by the
Free Software Foundation.
* Some external sources, especially files developed by SICS are published under
a separate license.
All code files contain licensing information.
ZZZZZZ
ZZZZZZZZZZZZ
ZZZZZZZZZZZZZZZZ
ZZZZZZZ ZZZZZZ
ZZZZZZ ZZZZZ
ZZZZZ ZZZZ
ZZZZ ZZZZZ
ZZZZ ZZZZ
ZZZZ ZZZZZ
ZZZZ ZZZZZZ
ZZZZ ZZZZZZZZ 777 7777 7777777777
ZZ ZZZZ ZZZZZZZZ 777 77777777 77777777777
ZZZZZZZ ZZZZ ZZZZZZZ 777 7777 7777 777
ZZZZZZZZZ ZZZZ Z 777 777 777 777
ZZZZZZ ZZZZ 777 777 777 777
ZZZZZ ZZZZ 777 777 777 777
ZZZZZ ZZZZZ ZZZZ 777 777 777 777
ZZZZ ZZZZZ ZZZZZ 777 777 777 777
ZZZZ ZZZZZ ZZZZZ 777 777 777 777
ZZZZ ZZZZ ZZZZZ 777 777 777 777
ZZZZZ ZZZZZ ZZZZZ 777 777 777 777
ZZZZZZ ZZZZZZ ZZZZZ 777 7777777777 777
ZZZZZZZZZZZZZZZ ZZZZ 777 77777777 777
ZZZZZZZZZZZ Z
ZZZZZ

@ -1,6 +1,30 @@
RIOT OS
=======
RIOT - The revolutionary IoT OS!
ZZZZZZ
ZZZZZZZZZZZZ
ZZZZZZZZZZZZZZZZ
ZZZZZZZ ZZZZZZ
ZZZZZZ ZZZZZ
ZZZZZ ZZZZ
ZZZZ ZZZZZ
ZZZZ ZZZZ
ZZZZ ZZZZZ
ZZZZ ZZZZZZ
ZZZZ ZZZZZZZZ 777 7777 7777777777
ZZ ZZZZ ZZZZZZZZ 777 77777777 77777777777
ZZZZZZZ ZZZZ ZZZZZZZ 777 7777 7777 777
ZZZZZZZZZ ZZZZ Z 777 777 777 777
ZZZZZZ ZZZZ 777 777 777 777
ZZZZZ ZZZZ 777 777 777 777
ZZZZZ ZZZZZ ZZZZ 777 777 777 777
ZZZZ ZZZZZ ZZZZZ 777 777 777 777
ZZZZ ZZZZZ ZZZZZ 777 777 777 777
ZZZZ ZZZZ ZZZZZ 777 777 777 777
ZZZZZ ZZZZZ ZZZZZ 777 777 777 777
ZZZZZZ ZZZZZZ ZZZZZ 777 7777777777 777
ZZZZZZZZZZZZZZZ ZZZZ 777 77777777 777
ZZZZZZZZZZZ Z
ZZZZZ
The friendly Operating System for IoT!
RIOT OS is an operating system for Internet of Things (IoT) devices. It is based on a microkernel and designed for
* energy efficiency
@ -19,3 +43,17 @@ Its features comprise
* TCP and UDP
* 6LoWPAN
* RPL
License
=======
* All sources and binaries that have been developed at Freie Universität Berlin are
licensed under the GNU General Public License version 3 as published by the
Free Software Foundation.
* Some external sources, especially files developed by SICS are published under
a separate license.
All code files contain licensing information.
For more information, see the RIOT website:
http://www.riot-os.org

@ -1,5 +1,5 @@
MODULE =core
INCLUDES = -Iinclude/ -I../sys/include -I../sys/lib -I../sys/drivers/include -I../cpu/$(CPU)/include/ -I../.. -I../drivers/include/
INCLUDES = -Iinclude/ -I../sys/include -I../sys/lib -I../sys/drivers/include -I$(RIOTCPU)/$(CPU)/include/ -I../.. -I../drivers/include/
include $(RIOTBASE)/Makefile.base

@ -2,25 +2,51 @@
* @ingroup kernel
* @{
* @file
* @author Freie Universität Berlin, Computer Systems & Telematics
* @author Kaspar Schleiser <kaspar@schleiser.de>
*/
/*
* kernel_intern.h
*
* Created on: 10.02.09
* Author: kaspar
* @author INRIA
* @author Oliver Hahm <oliver.hahm@inria.fr>
*/
#ifndef KERNEL_INTERN_H_
#define KERNEL_INTERN_H_
/**
* @brief Initializes scheduler and creates main and idle task
*/
void kernel_init(void);
void board_init_drivers(void);
/**
* @brief Optionally: initializes platform specifics (devices, pin configuration etc.)
*/
void board_init(void);
/**
* @brief Gets called upon thread creation to set CPU registers
*
* @param[in] task_func First function to call within the thread
* @param[in] stack_start Start address of the stack
* @param[in] stack_size Stack size
*
* @return stack pointer
*/
char *thread_stack_init(void *task_func, void *stack_start, int stack_size);
/**
* @brief Removes thread from scheduler and set status to STATUS_STOPPED
*/
void sched_task_exit(void);
/**
* @brief Prints human readable, ps-like thread information for debugging purposes
*/
void thread_print_stack (void);
/**
* @brief Calculates stack usage if thread was created using CREATE_STACKTEST
*
* @param[in] stack The thread's stack
*
* @return The current usage (overwritten addresses) of the thread's stack
*/
int thread_measure_stack_usage(char* stack);
/** @} */

@ -26,6 +26,7 @@ void sched_run(void);
void sched_set_status(tcb_t *process, unsigned int status);
void sched_switch(uint16_t current_prio, uint16_t other_prio, int in_isr);
void cpu_switch_context_exit(void);
extern volatile unsigned int sched_context_switch_request;

@ -38,7 +38,6 @@ volatile tcb_t *active_thread;
volatile int lpm_prevent_sleep = 0;
extern void main(void);
extern void cpu_switch_context_exit(void);
static void idle_thread(void) {
while(1) {

@ -171,8 +171,6 @@ void sched_switch(uint16_t current_prio, uint16_t other_prio, int in_isr) {
}
}
extern void cpu_switch_context_exit(void);
void sched_task_exit(void) {
DEBUG("sched_task_exit(): ending task %s...\n", active_thread->name);

@ -7,7 +7,7 @@ ifeq ($(CPU),lpc214x)
endif
ifeq ($(CPU),cc430)
DIRS = msp430 cc430
DIRS = msp430-common cc430
endif
ifeq ($(CPU),msp430x16x)

@ -0,0 +1,20 @@
ifeq ($(CPU),lpc2387)
INCLUDES += -I$(MAKEBASE)/cpu/arm_common/include/
INCLUDES += -I$(MAKEBASE)/cpu/lpc2387/include
endif
ifeq ($(CPU),lpc214x)
INCLUDES += -I$(MAKEBASE)/cpu/arm_common/include/
INCLUDES += -I$(MAKEBASE)/cpu/lpc214x/include
endif
ifeq ($(CPU),msp430x16x)
INCLUDES += -I$(MAKEBASE)/cpu/msp430-common/include/
INCLUDES += -I$(MAKEBASE)/cpu/msp430x16x/include/
endif
ifeq ($(CPU),cc430)
INCLUDES += -I$(MAKEBASE)/cpu/msp430-common/include/
INCLUDES += -I$(MAKEBASE)/cpu/cc430/include/
endif
ifeq ($(CPU),native)
INCLUDES += -I$(MAKEBASE)/cpu/native/include/
endif

@ -25,59 +25,68 @@
#include "sched.h"
#include "kernel_intern.h"
void thread_yield() {
#define STACK_MARKER (0x77777777)
#define REGISTER_CNT (12)
void thread_yield(void)
{
asm("svc 0\n");
}
//----------------------------------------------------------------------------
// Processor specific routine - here for ARM7
// sizeof(void*) = sizeof(int)
//----------------------------------------------------------------------------
char * thread_stack_init(void * task_func, void * stack_start, int stack_size)
/*----------------------------------------------------------------------------
* Processor specific routine - here for ARM7
* sizeof(void*) = sizeof(int)
*--------------------------------------------------------------------------*/
char *thread_stack_init(void *task_func, void *stack_start, int stack_size)
{
unsigned int * stk;
stk = (unsigned int *) stack_start + stack_size;
unsigned int *stk;
stk = (unsigned int *) (stack_start + stack_size);
stk--;
*stk = 0x77777777;
stk--;
*stk = STACK_MARKER;
*stk = (unsigned int)sched_task_exit; // LR
/* set the return address (LR) */
stk--;
*stk = (unsigned int) sched_task_exit;
stk--;
*stk = (unsigned int) stack_start - 4; // SP
/* set the stack pointer (SP) */
stk--;
*stk = (unsigned int) (stack_start + stack_size) - 4;
for (int i = 12; i>= 0 ; i--) { // build base stack
stk--;
*stk = i;
}
/* build base stack */
for (int i = REGISTER_CNT; i>= 0 ; i--) {
stk--;
*stk = i;
}
stk--;
*stk = ((unsigned int) task_func); // Entry Point
stk--;
*stk = (unsigned int) NEW_TASK_CPSR; // spsr
/* set the entry point */
stk--;
*stk = ((unsigned int) task_func);
/* set the saved program status register */
stk--;
*stk = (unsigned int) NEW_TASK_CPSR;
return (char*)stk;
return (char*) stk;
}
void thread_print_stack () {
register void * stack = 0;
void thread_print_stack(void)
{
register void *stack = 0;
asm( "mov %0, sp" : "=r" (stack));
register unsigned int * s = (unsigned int*) stack;
printf("task: %X SP: %X\n", (unsigned int)active_thread, (unsigned int)stack);
register unsigned int *s = (unsigned int*) stack;
printf("task: %X SP: %X\n", (unsigned int) active_thread, (unsigned int) stack);
register int i = 0;
s += 5;
while (*s != 0x77777777) {
printf("STACK (%u) addr=%X = %X \n",i,(unsigned int) s, (unsigned int)*s);
while (*s != STACK_MARKER) {
printf("STACK (%u) addr=%X = %X \n", i, (unsigned int) s, (unsigned int) *s);
s++;
i++;
}
printf("STACK (%u)= %X \n",i,*s);
}
__attribute__((naked,noreturn)) void
arm_reset(void)
__attribute__((naked,noreturn)) void arm_reset(void)
{
dINT();
WDTC = 0x00FFF;

@ -17,23 +17,15 @@ 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/ .
--------------------------------------------------------------------------------
For further information and questions please use the web site
http://scatterweb.mi.fu-berlin.de
and the mailinglist (subscription via web site)
scatterweb@lists.spline.inf.fu-berlin.de
*******************************************************************************/
/**
* @file
* @ingroup lpc2387
* @brief LPC2387 NewLib system calls implementation
* @ingroup lpc2387
* @brief LPC2387 NewLib system calls implementation
*
* @author Freie Universität Berlin, Computer Systems & Telematics
* @author Michael Baar <michael.baar@fu-berlin.de>
* @version $Revision$
* @author Michael Baar <michael.baar@fu-berlin.de>
*
* @note $Id$
*/
#include <errno.h>
@ -56,9 +48,9 @@ and the mailinglist (subscription via web site)
#include "hal-syscalls.h"
#endif
#define DEBUG_SYSCALLS 0
#define DEBUG_SYSCALLS 0
#if DEBUG_SYSCALLS
#define PRINTF(...) printf(__VA_ARGS__)
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
@ -71,14 +63,14 @@ and the mailinglist (subscription via web site)
* @name Heaps (defined in linker script)
* @{
*/
#define NUM_HEAPS 3//2
#define NUM_HEAPS 3//2
extern uintptr_t __heap1_start; ///< start of heap memory space
extern uintptr_t __heap1_max; ///< maximum for end of heap memory space
extern uintptr_t __heap2_start; ///< start of heap memory space
extern uintptr_t __heap2_max; ///< maximum for end of heap memory space
extern uintptr_t __heap3_start; ///< start of heap memory space
extern uintptr_t __heap3_max; ///< maximum for end of heap memory space
extern uintptr_t __heap1_start; ///< start of heap memory space
extern uintptr_t __heap1_max; ///< maximum for end of heap memory space
extern uintptr_t __heap2_start; ///< start of heap memory space
extern uintptr_t __heap2_max; ///< maximum for end of heap memory space
extern uintptr_t __heap3_start; ///< start of heap memory space
extern uintptr_t __heap3_max; ///< maximum for end of heap memory space
/// current position in heap
@ -92,25 +84,27 @@ static const caddr_t heap_start[NUM_HEAPS] = {(caddr_t)&__heap1_start,(caddr_t)&
/** @} */
/*-----------------------------------------------------------------------------------*/
void heap_stats(void) {
for(int i = 0; i < NUM_HEAPS; i++)
printf("# heap %i: %p -- %p -> %p (%li of %li free)\n", i, heap_start[i], heap[i], heap_max[i],
(uint32_t)heap_max[i] - (uint32_t)heap[i], (uint32_t)heap_max[i] - (uint32_t)heap_start[i]);
void heap_stats(void)
{
for(int i = 0; i < NUM_HEAPS; i++)
printf("# heap %i: %p -- %p -> %p (%li of %li free)\n", i, heap_start[i], heap[i], heap_max[i],
(uint32_t)heap_max[i] - (uint32_t)heap[i], (uint32_t)heap_max[i] - (uint32_t)heap_start[i]);
}
/*-----------------------------------------------------------------------------------*/
void __assert_func(const char *file, int line, const char *func, const char *failedexpr)
{
#if SYSLOG_CONF_ASSERT
trace_number(TRACELOG_EV_ASSERTION, line);
syslog(SL_EMERGENCY, "assert", "%s() in %s:%u\n", func, file, line);
trace_number(TRACELOG_EV_ASSERTION, line);
syslog(SL_EMERGENCY, "assert", "%s() in %s:%u\n", func, file, line);
#endif
printf("#! assertion %s failed\n\t%s() in %s:%u\n", failedexpr, func, file, line );
_exit(3);
printf("#! assertion %s failed\n\t%s() in %s:%u\n", failedexpr, func, file, line );
_exit(3);
}
/*-----------------------------------------------------------------------------------*/
void __assert(const char *file, int line, const char *failedexpr)
{
__assert_func(file, line, "?", failedexpr);
__assert_func(file, line, "?", failedexpr);
}
/*-----------------------------------------------------------------------------------*/
caddr_t _sbrk_r(struct _reent *r, size_t incr)
@ -125,198 +119,198 @@ caddr_t _sbrk_r(struct _reent *r, size_t incr)
uint32_t cpsr = disableIRQ();
/* check all heaps for a chunk of the requested size */
for(volatile uint8_t iUsedHeap = 0; iUsedHeap < NUM_HEAPS; iUsedHeap++ ) {
caddr_t new_heap = heap[iUsedHeap] + incr;
#ifdef MODULE_TRACELOG
trace_pointer(TRACELOG_EV_MEMORY, heap[iUsedHeap]);
#endif
if( new_heap <= heap_max[iUsedHeap] ) {
caddr_t prev_heap = heap[iUsedHeap];
#ifdef MODULE_TRACELOG
trace_pointer(TRACELOG_EV_MEMORY, new_heap);
#endif
heap[iUsedHeap] = new_heap;
r->_errno = 0;
restoreIRQ(cpsr);
return prev_heap;
}
}
restoreIRQ(cpsr);
#ifdef MODULE_TRACELOG
trace_string(TRACELOG_EV_MEMORY, "heap!"); // heap full
#endif
r->_errno = ENOMEM;
for (volatile uint8_t iUsedHeap = 0; iUsedHeap < NUM_HEAPS; iUsedHeap++ ) {
caddr_t new_heap = heap[iUsedHeap] + incr;
#ifdef MODULE_TRACELOG
trace_pointer(TRACELOG_EV_MEMORY, heap[iUsedHeap]);
#endif
if( new_heap <= heap_max[iUsedHeap] ) {
caddr_t prev_heap = heap[iUsedHeap];
#ifdef MODULE_TRACELOG
trace_pointer(TRACELOG_EV_MEMORY, new_heap);
#endif
heap[iUsedHeap] = new_heap;
r->_errno = 0;
restoreIRQ(cpsr);
return prev_heap;
}
}
restoreIRQ(cpsr);
#ifdef MODULE_TRACELOG
trace_string(TRACELOG_EV_MEMORY, "heap!"); // heap full
#endif
r->_errno = ENOMEM;
return NULL;
}
/*---------------------------------------------------------------------------*/
int _isatty_r(struct _reent *r, int fd)
{
r->_errno = 0;
if( fd == STDOUT_FILENO || fd == STDERR_FILENO )
return 1;
else
return 0;
r->_errno = 0;
if( fd == STDOUT_FILENO || fd == STDERR_FILENO )
return 1;
else
return 0;
}
/*---------------------------------------------------------------------------*/
_off_t _lseek_r(struct _reent *r, int fd, _off_t pos, int whence)
{
_off_t result = -1;
PRINTF("lseek [%i] pos %li whence %i\n", fd, pos, whence);
_off_t result = -1;
PRINTF("lseek [%i] pos %li whence %i\n", fd, pos, whence);
r->_errno = ENODEV;
r->_errno = ENODEV;
#ifdef MODULE_FAT
result = ff_lseek_r(r, fd, pos, whence);
#endif
PRINTF("lseek returned %li (0 is success)\n", result);
return result;
PRINTF("lseek returned %li (0 is success)\n", result);
return result;
}
/*---------------------------------------------------------------------------*/
int _open_r(struct _reent *r, const char *name, int mode)
{
int ret = -1;
PRINTF("open '%s' mode %#x\n", name, mode);
int ret = -1;
PRINTF("open '%s' mode %#x\n", name, mode);
r->_errno = ENODEV; // no such device
r->_errno = ENODEV; // no such device
#ifdef MODULE_FAT
ret = ff_open_r(r,name,mode);
ret = ff_open_r(r,name,mode);
#endif
PRINTF("open [%i] errno %i\n", ret, r->_errno);
return ret;
PRINTF("open [%i] errno %i\n", ret, r->_errno);
return ret;
}
/*---------------------------------------------------------------------------*/
int _stat_r(struct _reent *r, char *name, struct stat *st)
{
int ret = -1;
PRINTF("_stat_r '%s' \n", name);
r->_errno = ENODEV; // no such device
int ret = -1;
PRINTF("_stat_r '%s' \n", name);
r->_errno = ENODEV; // no such device
#ifdef MODULE_FAT
ret = ff_stat_r(r,name,st);
ret = ff_stat_r(r,name,st);
#endif
PRINTF("_stat_r [%i] errno %i\n", ret, r->_errno);
return ret;
PRINTF("_stat_r [%i] errno %i\n", ret, r->_errno);
return ret;
}
/*---------------------------------------------------------------------------*/
int _fstat_r(struct _reent *r, int fd, struct stat * st)
{
int ret = -1;
int ret = -1;
r->_errno = 0;
memset(st, 0, sizeof(*st));
if( fd == STDOUT_FILENO || fd == STDERR_FILENO ) {
st->st_mode = S_IFCHR;
ret = 0;
} else {
r->_errno = 0;
memset(st, 0, sizeof(*st));
if( fd == STDOUT_FILENO || fd == STDERR_FILENO ) {
st->st_mode = S_IFCHR;
ret = 0;
} else {
#ifdef MODULE_FAT
PRINTF("_fstat_r '%i' \n", fd);
PRINTF("_fstat_r '%i' \n", fd);
ret = ff_fstat_r(r,fd,st);
PRINTF("_fstat_r [%i] errno %i\n", ret, r->_errno);
ret = ff_fstat_r(r,fd,st);
PRINTF("_fstat_r [%i] errno %i\n", ret, r->_errno);
#else
r->_errno = ENODEV;
r->_errno = ENODEV;
#endif
}
return ret;
}
return ret;
}
/*---------------------------------------------------------------------------*/
int _write_r(struct _reent *r, int fd, const void *data, unsigned int count)
{
int result = EOF;
r->_errno = EBADF;
switch(fd) {
case STDOUT_FILENO:
case STDERR_FILENO:
#if FEUERWARE_CONF_ENABLE_HAL
if( stdio != NULL )
result = chardevice_write(stdio, (char*)data, count);
else if( hal_state == HAL_NOT_INITIALIZED )
result = fw_puts((char*)data, count);
#else
result = fw_puts((char*)data, count);
#endif
break;
default:
#ifdef MODULE_FAT
result = ff_write_r(r, fd, data, count);
#endif
PRINTF("write [%i] data @%p count %i\n", fd, data, count);
PRINTF("write [%i] returned %i errno %i\n", fd, result, r->_errno);
break;
}
return result;
int result = EOF;
r->_errno = EBADF;
switch(fd) {
case STDOUT_FILENO:
case STDERR_FILENO:
#if FEUERWARE_CONF_ENABLE_HAL
if( stdio != NULL )
result = chardevice_write(stdio, (char*)data, count);
else if( hal_state == HAL_NOT_INITIALIZED )
result = fw_puts((char*)data, count);
#else
result = fw_puts((char*)data, count);
#endif
break;
default:
#ifdef MODULE_FAT
result = ff_write_r(r, fd, data, count);
#endif
PRINTF("write [%i] data @%p count %i\n", fd, data, count);
PRINTF("write [%i] returned %i errno %i\n", fd, result, r->_errno);
break;
}
return result;
}
/*---------------------------------------------------------------------------*/
int _read_r(struct _reent *r, int fd, void *buffer, unsigned int count)
{
int result = -1;
r->_errno = EBADF;
int result = -1;
r->_errno = EBADF;
#ifdef MODULE_FAT
result = ff_read_r(r, fd, buffer, count);
result = ff_read_r(r, fd, buffer, count);
#endif
PRINTF("read [%i] buffer @%p count %i\n", fd, buffer, count);
PRINTF("read [%i] returned %i\n", fd, result);
PRINTF("read [%i] returned %i\n", fd, result);
return result;
}
/*---------------------------------------------------------------------------*/
int _close_r(struct _reent *r, int fd)
{
int result = -1;
r->_errno = EBADF;
#ifdef MODULE_FAT
ret = ff_close_r(r, fd);
#endif
int result = -1;
r->_errno = EBADF;
#ifdef MODULE_FAT
ret = ff_close_r(r, fd);
#endif
PRINTF("close [%i]\n", fd);
PRINTF("close returned %i errno %i\n", result, errno);
PRINTF("close returned %i errno %i\n", result, errno);
return result;
}
/*---------------------------------------------------------------------------*/
int _unlink_r(struct _reent *r, char* path)
{
int result = -1;
r->_errno = ENODEV;
int result = -1;
r->_errno = ENODEV;
#ifdef MODULE_FAT
result = ff_unlink_r(r, path);
result = ff_unlink_r(r, path);
#endif
PRINTF("unlink '%s'\n", path);
PRINTF("unlink returned %i errno %i\n", result, errno);
PRINTF("unlink returned %i errno %i\n", result, errno);
return result;
}
/*---------------------------------------------------------------------------*/
void _exit(int n)
{
#ifdef MODULE_TRACELOG
trace_number(TRACELOG_EV_EXIT, n);
trace_number(TRACELOG_EV_EXIT, n);
#endif
printf("#! exit %i: resetting\n", n);
printf("#! exit %i: resetting\n", n);
stdio_flush();
arm_reset();
while(1);
stdio_flush();
arm_reset();
while(1);
}
/*---------------------------------------------------------------------------*/
int _getpid(void)
{
return active_thread->pid;
return active_thread->pid;
}
/*---------------------------------------------------------------------------*/
int _kill_r(struct _reent *r, int pid, int sig)
{
/* not implemented */
r->_errno = ESRCH; // no such process
return -1;
/* not implemented */
r->_errno = ESRCH; // no such process
return -1;
}
/*---------------------------------------------------------------------------*/
void _init(void){}

@ -1,6 +1,7 @@
MODULE =cpu
INCLUDES = -Iinclude -Idrivers/include -I../arm_common/include -I../../sys/lib -I../../sys/drivers/include -I../../core/include -I../../sys/include -I../../hal/include -I../../..
INCLUDES += -Iinclude -Idrivers/include -I../arm_common/include -I../../sys/lib -I../../sys/drivers/include -I../../core/include -I../../sys/include -I../../hal/include -I../../..
INCLUDES += -I$(RIOTBASE)/drivers/cc110x_ng/include
DIRS =
all: $(BINDIR)$(MODULE).a

@ -36,7 +36,7 @@
* ************************************************************************************************/
#include <signal.h>
#include <legacymsp430.h>
#include <cpu.h>
#include <cc430-adc.h>
#include <hwtimer.h>

@ -25,13 +25,13 @@ and the mailinglist (subscription via web site)
*******************************************************************************/
#include <stdlib.h>
#include <signal.h>
#include <legacymsp430.h>
#include <gpioint.h>
#include <bitarithm.h>
#include <cpu.h>
#include <irq.h>
#include <hwtimer.h>
#include <cc430x613x.h>
#include <cc430f6137.h>
/** min and max portnumber to generate interrupts */
#define PORTINT_MIN (1)
@ -222,9 +222,10 @@ interrupt (PORT2_VECTOR) __attribute__ ((naked)) port2_isr(void) {
cb[1][ifg_num]();
}
}
else {
cb[1][ifg_num]();
}
//else {
// cb[1][ifg_num]();
//}
P2IFG = 0x00;
P2IE = int_enable;

@ -29,10 +29,10 @@ and the mailinglist (subscription via web site)
*/
#include <string.h>
#include <signal.h>
#include <legacymsp430.h>
#include <irq.h>
#include <cpu.h>
#include <cc430x613x.h>
#include <cc430f6137.h>
#include <cc430-rtc.h>
//static volatile time_t epoch;

@ -1,4 +1,4 @@
#include <signal.h>
#include <legacymsp430.h>
#include <board.h>
#include <hwtimer.h>
#include <hwtimer_arch.h>
@ -12,7 +12,7 @@ static uint32_t ticks = 0;
extern void (*int_handler)(int);
extern void TA0_unset(short timer);
void timerA_init()
void timerA_init(void)
{
ticks = 0; // Set tick counter value to 0
TA0CTL = TASSEL_1 + TACLR; // Clear the timer counter, set ACLK

@ -1,6 +1,6 @@
MODULE =cpu
INCLUDES = -Iinclude -I$(RIOTBASE)/core/include/ -I$(RIOTBOARD)/$(BOARD)/include
INCLUDES += -Iinclude -I$(RIOTBASE)/core/include/ -I$(RIOTBOARD)/$(BOARD)/include
DIRS =
all: $(BINDIR)$(MODULE).a

@ -23,8 +23,11 @@ For further information and questions please use the web site
and the mailinglist (subscription via web site)
scatterweb@lists.spline.inf.fu-berlin.de
*******************************************************************************/
#include <msp430x16x.h>
#ifdef CC430
#include <cc430f6137.h>
#else
#include <msp430x16x.h>
#endif
#include "cpu.h"
#include "kernel.h"
#include "kernel_intern.h"
@ -100,7 +103,7 @@ void cpu_switch_context_exit(void){
char *thread_stack_init(void *task_func, void *stack_start, int stack_size)
{
unsigned short * stk;
stk = (unsigned short *) stack_start + stack_size;
stk = (unsigned short *) (stack_start + stack_size);
*stk = (unsigned short) sched_task_exit;
--stk;

@ -1,6 +1,6 @@
#include <stddef.h>
#include <stdint.h>
#include <msp430x16x.h>
#include <msp430x16x.h>
#include <irq.h>
uint8_t ie1, ie2;

@ -39,7 +39,7 @@ and the mailinglist (subscription via web site)
#include <sched.h>
#include <stdio.h>
#include <signal.h>
#include <legacymsp430.h>
#include <cpu-conf.h>
#define WORDSIZE 16

@ -27,7 +27,11 @@ and the mailinglist (subscription via web site)
#ifndef __HWTIMER_CPU_H
#define __HWTIMER_CPU_H
#include <msp430x16x.h>
#ifdef CC430
#include <cc430f6137.h>
#else
#include <msp430x16x.h>
#endif
#include <stdint.h>
#ifdef __MSP430_HAS_TA2__

@ -1,5 +1,9 @@
#include <irq.h>
#include <msp430x16x.h>
#ifdef CC430
#include <cc430f6137.h>
#else
#include <msp430x16x.h>
#endif
#include <cpu.h>
unsigned int disableIRQ() {

@ -34,7 +34,11 @@
*/
#include "cpu.h"
#include <msp430x16x.h>
#ifdef CC430
#include <cc430f6137.h>
#else
#include <msp430x16x.h>
#endif
#include "msp430.h"

@ -1,4 +1,3 @@
#include <signal.h>
#include <msp430x16x.h>
#include <hwtimer.h>
#include <hwtimer_arch.h>

5
dist/Makefile vendored

@ -5,7 +5,7 @@
#### /this makefile
#### ../../RIOT
#### ../../boards for board definitions (if you have one or more)
####/..
####
# name of your project
export PROJECT =foobar
@ -15,6 +15,7 @@ export BOARD = msb-430
# this has to be the absolute path of the RIOT-base dir
export RIOTBASE =$(CURDIR)/../../RIOT
export RIOTCPU =$(CURDIR)/../../RIOT/cpu
export RIOTBOARD =$(CURDIR)/../../boards
## Modules to include.
@ -28,6 +29,6 @@ export RIOTBOARD =$(CURDIR)/../../boards
#USEMODULE += cc110x
#USEMODULE += fat
export INCLUDES = -I$(RIOTBOARD)/$(BOARD)/include -I$(RIOTBASE)/core/include -I$(RIOTBASE)/cpu/$(CPU)/include -I$(RIOTBASE)/sys/lib -I$(RIOTBASE)/sys/include/ -I$(RIOTBASE)/drivers/include/
export INCLUDES = -I$(RIOTBOARD)/$(BOARD)/include -I$(RIOTBASE)/core/include -I$(RIOTCPU)/$(CPU)/include -I$(RIOTBASE)/sys/lib -I$(RIOTBASE)/sys/include/ -I$(RIOTBASE)/drivers/include/
include $(RIOTBASE)/Makefile.include

@ -211,13 +211,13 @@ static bool spi_receive_packet_variable(uint8_t *rxBuffer, uint8_t length)
rflags.RSSI = status[I_RSSI];
// MSB of LQI is the CRC_OK bit
rflags.CRC = (status[I_LQI] & CRC_OK) >> 7;
if (!rflags.CRC) cc1100_statistic.packets_in_crc_fail++;
rflags.CRC_STATE = (status[I_LQI] & CRC_OK) >> 7;
if (!rflags.CRC_STATE) cc1100_statistic.packets_in_crc_fail++;
// Bit 0-6 of LQI indicates the link quality (LQI)
rflags.LQI = status[I_LQI] & LQI_EST;
return rflags.CRC;
return rflags.CRC_STATE;
}
else
{
@ -761,7 +761,7 @@ void cc1100_init(void)
rflags.RSSI = 0x00;
rflags.LL_ACK = false;
rflags.CAA = false;
rflags.CRC = false;
rflags.CRC_STATE = false;
rflags.SEQ = false;
rflags.MAN_WOR = false;
rflags.KT_RES_ERR = false;

@ -125,13 +125,13 @@ typedef struct cc1100_flags
uint32_t TOF; ///< Time of flight of the last packet and last ACK
uint32_t TCP; ///< Time to compute packet
unsigned RPS : 16; ///< Raw packets sent to transmit last packet
unsigned RTC : 8; ///< Retransmission count of last send packet
unsigned RETC : 8; ///< Retransmission count of last send packet
unsigned RSSI : 8; ///< The RSSI value of last received packet
unsigned RSSI_SEND : 8; ///< The RSSI value of the last send unicast packet of this node
unsigned LQI : 8; ///< The LQI value of the last received packet
unsigned LL_ACK : 1; ///< Is set if Link-Level ACK is received, otherwise 0 (reset on new burst)
unsigned CAA : 1; ///< The status of the air (1 = air free, 0 = air not free)
unsigned CRC : 1; ///< The CRC status of last received packet (1 = OK, 0 = not OK)
unsigned CRC_STATE : 1; ///< The CRC status of last received packet (1 = OK, 0 = not OK)
unsigned SEQ : 1; ///< Sequence number (toggles between 0 and 1)
unsigned MAN_WOR : 1; ///< Manual WOR set (for randomized WOR times => no synch)
unsigned KT_RES_ERR : 1; ///< A hwtimer resource error has occurred (no free timers available)

@ -500,7 +500,7 @@ static bool send_burst(cc1100_packet_layer0_t *packet, uint8_t retries, uint8_t
}
// Store number of transmission retries
rflags.RTC = rtc;
rflags.RETC = rtc;
rflags.RPS = rtc * cc1100_burst_count + i;
if (i > cc1100_burst_count) rflags.RPS--;
rflags.TX = false;

@ -135,15 +135,15 @@ static uint8_t receive_packet_variable(uint8_t *rxBuffer, uint8_t length) {
rflags._RSSI = status[I_RSSI];
// MSB of LQI is the CRC_OK bit
rflags.CRC = (status[I_LQI] & CRC_OK) >> 7;
if (!rflags.CRC) {
rflags.CRC_STATE = (status[I_LQI] & CRC_OK) >> 7;
if (!rflags.CRC_STATE) {
cc110x_statistic.packets_in_crc_fail++;
}
// Bit 0-6 of LQI indicates the link quality (LQI)
rflags._LQI = status[I_LQI] & LQI_EST;
return rflags.CRC;
return rflags.CRC_STATE;
}
/* too many bytes in FIFO */
else {

@ -61,7 +61,7 @@ void cc110x_init(int tpid) {
rflags._RSSI = 0x00;
rflags.LL_ACK = 0;
rflags.CAA = 0;
rflags.CRC = 0;
rflags.CRC_STATE = 0;
rflags.SEQ = 0;
rflags.MAN_WOR = 0;
rflags.KT_RES_ERR = 0;

@ -62,13 +62,13 @@ typedef struct
timex_t TOA; ///< Time of packet arriveal
uint32_t TCP; ///< Time to compute packet
unsigned RPS : 16; ///< Raw packets sent to transmit last packet
unsigned RTC : 8; ///< Retransmission count of last send packet
unsigned RETC : 8; ///< Retransmission count of last send packet
unsigned _RSSI : 8; ///< The RSSI value of last received packet
unsigned RSSI_SEND : 8; ///< The RSSI value of the last send unicast packet of this node
unsigned _LQI : 8; ///< The LQI value of the last received packet
unsigned LL_ACK : 1; ///< Is set if Link-Level ACK is received, otherwise 0 (reset on new burst)
unsigned CAA : 1; ///< The status of the air (1 = air free, 0 = air not free)
unsigned CRC : 1; ///< The CRC status of last received packet (1 = OK, 0 = not OK)
unsigned CRC_STATE : 1; ///< The CRC status of last received packet (1 = OK, 0 = not OK)
unsigned SEQ : 1; ///< Sequence number (toggles between 0 and 1)
unsigned MAN_WOR : 1; ///< Manual WOR set (for randomized WOR times => no synch)
unsigned KT_RES_ERR : 1; ///< A hwtimer resource error has occurred (no free timers available)

@ -1,5 +1,4 @@
INCLUDES = -Iinclude -I$(RIOTBASE)/drivers/ -I$(RIOTBASE)/drivers/include -Ilib -I../.. -I../cpu/$(CPU)/include -I../cpu/ -Ilib/cmdengine -Inet -I../hal/include -I../core/include -Iconfig
INCLUDES = -Iinclude -I$(RIOTBASE)/drivers/ -I$(RIOTBASE)/drivers/include -Ilib -I$(RIOTCPU)/$(CPU)/include -Inet -I../core/include
MODULE =sys
ifneq (,$(findstring auto_init,$(USEMODULE)))

@ -1,4 +1,4 @@
INCLUDES = -I../include -I../drivers/include -I../lib -I../../cpu/$(CPU)/include -I../../cpu/ -I../lib/cmdengine -I../net -I../../hal/include -I../../core/include -I../config
INCLUDES = -I../include -I../drivers/include -I../lib -I$(RIOTCPU)/$(CPU)/include -I../net -I../../core/include
MODULE =lib
include $(RIOTBASE)/Makefile.base

@ -1,7 +1,6 @@
INCLUDES = -I../include -I../drivers/include -I../lib -I../../cpu/$(CPU)/include -I../../cpu/ -I../lib/cmdengine -I../net -I../../hal/include -I../../core/include -I../config
INCLUDES = -I../include -I../drivers/include -I../lib -I$(RIOTCPU)/$(CPU)/include -I../net -I../../core/include
MODULE =logd
include $(MAKEBASE)/Makefile.base

@ -144,17 +144,25 @@ static int readline(shell_t *shell, char* buf, size_t size) {
return 1;
}
static inline void print_prompt(shell_t *shell)
{
shell->put_char('>');
shell->put_char(' ');
return;
}
void shell_run(shell_t *shell) {
char line_buf[255];
print_prompt(shell);
while(1) {
int res = readline(shell, line_buf, sizeof(line_buf));
shell->put_char('>');
if (! res ) {
char* line_copy = strdup(line_buf);
handle_input_line(shell, line_copy);
free(line_copy);
}
print_prompt(