git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@39 35acf78f-673a-0410-8e92-d51de3d6d3f4
parent
ff4dd3f8f0
commit
d6d799ed48
|
@ -62,7 +62,7 @@ UDEFS =
|
||||||
UADEFS =
|
UADEFS =
|
||||||
|
|
||||||
# List ARM-mode C source files here
|
# List ARM-mode C source files here
|
||||||
ASRC = chcore.c main.c buzzer.c \
|
ASRC = chcore.c main.c buzzer.c ../../src/lib/evtimer.c \
|
||||||
../../test/test.c ../../ports/ARM7-LPC214x/GCC/lpc214x_serial.c \
|
../../test/test.c ../../ports/ARM7-LPC214x/GCC/lpc214x_serial.c \
|
||||||
../../src/chinit.c ../../src/chlists.c ../../src/chdelta.c ../../src/chschd.c \
|
../../src/chinit.c ../../src/chlists.c ../../src/chdelta.c ../../src/chschd.c \
|
||||||
../../src/chthreads.c ../../src/chsem.c ../../src/chevents.c ../../src/chmsg.c \
|
../../src/chthreads.c ../../src/chsem.c ../../src/chevents.c ../../src/chmsg.c \
|
||||||
|
@ -92,8 +92,6 @@ AOPT =
|
||||||
TOPT = -mthumb -D THUMB
|
TOPT = -mthumb -D THUMB
|
||||||
|
|
||||||
# Common options here
|
# Common options here
|
||||||
# NOTE: -mthumb-interwork increases the code size, remove it if you dont have
|
|
||||||
# Thumb code anywhere in the project.
|
|
||||||
# NOTE: -ffixed-f7 is only needed if you enabled CH_CURRP_REGISTER_CACHE in chconf.h.
|
# NOTE: -ffixed-f7 is only needed if you enabled CH_CURRP_REGISTER_CACHE in chconf.h.
|
||||||
OPT = -O2 -ggdb -fomit-frame-pointer -fno-strict-aliasing
|
OPT = -O2 -ggdb -fomit-frame-pointer -fno-strict-aliasing
|
||||||
#OPT += -ffixed-f7
|
#OPT += -ffixed-f7
|
||||||
|
@ -117,7 +115,7 @@ LIBS = $(DLIBS) $(ULIBS)
|
||||||
MCFLAGS = -mcpu=$(MCU)
|
MCFLAGS = -mcpu=$(MCU)
|
||||||
|
|
||||||
ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
|
ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
|
||||||
CPFLAGS = $(MCFLAGS) $(OPT) $(WARN) -fverbose-asm -Wa,-ahlms=$(<:.c=.lst) $(DEFS)
|
CPFLAGS = $(MCFLAGS) $(OPT) $(WARN) -Wa,-ahlms=$(<:.c=.lst) $(DEFS)
|
||||||
LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
|
LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
|
||||||
ODFLAGS = -x --syms
|
ODFLAGS = -x --syms
|
||||||
|
|
||||||
|
@ -137,15 +135,19 @@ CPFLAGS += -MD -MP -MF .dep/$(@F).d
|
||||||
all: $(OBJS) $(PROJECT).elf $(PROJECT).hex $(PROJECT).bin $(PROJECT).dmp
|
all: $(OBJS) $(PROJECT).elf $(PROJECT).hex $(PROJECT).bin $(PROJECT).dmp
|
||||||
|
|
||||||
$(AOBJS) : %.o : %.c
|
$(AOBJS) : %.o : %.c
|
||||||
|
@echo
|
||||||
$(CC) -c $(CPFLAGS) $(AOPT) -I . $(INCDIR) $< -o $@
|
$(CC) -c $(CPFLAGS) $(AOPT) -I . $(INCDIR) $< -o $@
|
||||||
|
|
||||||
$(TOBJS) : %.o : %.c
|
$(TOBJS) : %.o : %.c
|
||||||
|
@echo
|
||||||
$(CC) -c $(CPFLAGS) $(TOPT) -I . $(INCDIR) $< -o $@
|
$(CC) -c $(CPFLAGS) $(TOPT) -I . $(INCDIR) $< -o $@
|
||||||
|
|
||||||
$(ASMOBJS) : %.o : %.s
|
$(ASMOBJS) : %.o : %.s
|
||||||
|
@echo
|
||||||
$(AS) -c $(ASFLAGS) $< -o $@
|
$(AS) -c $(ASFLAGS) $< -o $@
|
||||||
|
|
||||||
%elf: $(OBJS)
|
%elf: $(OBJS)
|
||||||
|
@echo
|
||||||
$(CC) $(ASMOBJS) $(AOBJS) $(TOBJS) $(LDFLAGS) $(LIBS) -o $@
|
$(CC) $(ASMOBJS) $(AOBJS) $(TOBJS) $(LDFLAGS) $(LIBS) -o $@
|
||||||
|
|
||||||
%hex: %elf
|
%hex: %elf
|
||||||
|
|
|
@ -98,7 +98,7 @@ extern void chSysUnlock(void);
|
||||||
sizeof(struct stackregs) + (n) + (INT_REQUIRED_STACK))
|
sizeof(struct stackregs) + (n) + (INT_REQUIRED_STACK))
|
||||||
|
|
||||||
void chSysHalt(void) __attribute__((noreturn));
|
void chSysHalt(void) __attribute__((noreturn));
|
||||||
void chSysPause(void);
|
void chSysPause(void) __attribute__((noreturn));
|
||||||
void chSysSwitchI(Context *oldp, Context *newp);
|
void chSysSwitchI(Context *oldp, Context *newp);
|
||||||
void threadstart(void);
|
void threadstart(void);
|
||||||
void DefFiqHandler(void);
|
void DefFiqHandler(void);
|
||||||
|
|
|
@ -57,18 +57,18 @@ static BYTE8 waThread3[UserStackSize(64)];
|
||||||
|
|
||||||
static t_msg Thread3(void *arg) {
|
static t_msg Thread3(void *arg) {
|
||||||
t_msg TestThread(void *p);
|
t_msg TestThread(void *p);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
if (!(IO0PIN & 0x00018000)) {
|
if (!(IO0PIN & 0x00018000)) {
|
||||||
TestThread(&COM1);
|
TestThread(&COM1);
|
||||||
PlaySound(500, 100);
|
PlaySound(500, 100);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!(IO0PIN & 0x00008000)) // Button 1
|
if (!(IO0PIN & 0x00008000)) // Button 1
|
||||||
PlaySound(1000, 100);
|
PlaySound(1000, 100);
|
||||||
if (!(IO0PIN & 0x00010000)) // Button 2
|
if (!(IO0PIN & 0x00010000)) // Button 2
|
||||||
chFDDWrite(&COM1, (BYTE8 *)"Hello World!\r\n", 14);
|
chFDDWrite(&COM1, (BYTE8 *)"Hello World!\r\n", 14);
|
||||||
}
|
}
|
||||||
chThdSleep(500);
|
chThdSleep(500);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -97,8 +97,8 @@ typedef struct {
|
||||||
#define chSysLock() asm("cli")
|
#define chSysLock() asm("cli")
|
||||||
#define chSysUnlock() asm("sei")
|
#define chSysUnlock() asm("sei")
|
||||||
|
|
||||||
void chSysHalt(void);
|
void chSysHalt(void) __attribute__((noreturn)) ;
|
||||||
void chSysPause(void);
|
void chSysPause(void) __attribute__((noreturn)) ;
|
||||||
void chSysSwitchI(Context *oldp, Context *newp);
|
void chSysSwitchI(Context *oldp, Context *newp);
|
||||||
|
|
||||||
#endif /* _CHCORE_H_ */
|
#endif /* _CHCORE_H_ */
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
./license.txt - GPL3 license file.
|
./license.txt - GPL3 license file.
|
||||||
./src/ - ChibiOS/RT portable kernel source files.
|
./src/ - ChibiOS/RT portable kernel source files.
|
||||||
./src/include/ - ChibiOS/RT include files.
|
./src/include/ - ChibiOS/RT include files.
|
||||||
|
./src/lib/ - ChibiOS/RT library code that can be included into
|
||||||
|
user applications but is not part of the core system.
|
||||||
|
The code in this directory is meant to be portable,
|
||||||
|
generic and architecture indipendent.
|
||||||
./src/templates/ - ChibiOS/RT non portable source templates, new ports
|
./src/templates/ - ChibiOS/RT non portable source templates, new ports
|
||||||
are started by copying the templates into a new
|
are started by copying the templates into a new
|
||||||
directory under ./demos/.
|
directory under ./demos/.
|
||||||
|
@ -35,7 +39,9 @@ AVR-AT90CANx-GCC - Port on AVER AT90CAN128, not complete yet.
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
|
|
||||||
*** 0.3.2 ***
|
*** 0.3.2 ***
|
||||||
- Removed an obsolete definition in ./src/templates/chtypes.h
|
- Added a generic events generator timer to the library code.
|
||||||
|
- Added the "#ifdef __cplusplus" stuff to the header files.
|
||||||
|
- Removed an obsolete definition in ./src/templates/chtypes.h.
|
||||||
|
|
||||||
*** 0.3.1 ***
|
*** 0.3.1 ***
|
||||||
- Test program added to the demos. Telnet the MinGW and MSVS demos and type
|
- Test program added to the demos. Telnet the MinGW and MSVS demos and type
|
||||||
|
|
|
@ -92,7 +92,13 @@
|
||||||
#define NULL 0
|
#define NULL 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void chSysInit(void);
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
void chSysInit(void);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _CH_H_ */
|
#endif /* _CH_H_ */
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,6 @@ typedef struct {
|
||||||
t_time dl_dtime;
|
t_time dl_dtime;
|
||||||
} DeltaList;
|
} DeltaList;
|
||||||
|
|
||||||
|
|
||||||
extern DeltaList dlist;
|
extern DeltaList dlist;
|
||||||
|
|
||||||
#define chVTDoTickI() \
|
#define chVTDoTickI() \
|
||||||
|
@ -85,9 +84,15 @@ extern DeltaList dlist;
|
||||||
/*
|
/*
|
||||||
* Virtual Timers APIs.
|
* Virtual Timers APIs.
|
||||||
*/
|
*/
|
||||||
void chVTInit(void);
|
#ifdef __cplusplus
|
||||||
void chVTSetI(VirtualTimer *vtp, t_time time, t_vtfunc vtfunc, void *par);
|
extern "C" {
|
||||||
void chVTResetI(VirtualTimer *vtp);
|
#endif
|
||||||
|
void chVTInit(void);
|
||||||
|
void chVTSetI(VirtualTimer *vtp, t_time time, t_vtfunc vtfunc, void *par);
|
||||||
|
void chVTResetI(VirtualTimer *vtp);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* CH_USE_VIRTUAL_TIMER */
|
#endif /* CH_USE_VIRTUAL_TIMER */
|
||||||
|
|
||||||
|
|
|
@ -76,18 +76,24 @@ typedef struct EventSource {
|
||||||
/** Event Handler callback function.*/
|
/** Event Handler callback function.*/
|
||||||
typedef void (*t_evhandler)(t_eventid);
|
typedef void (*t_evhandler)(t_eventid);
|
||||||
|
|
||||||
void chEvtRegister(EventSource *esp, EventListener *elp, t_eventid eid);
|
#ifdef __cplusplus
|
||||||
void chEvtUnregister(EventSource *esp, EventListener *elp);
|
extern "C" {
|
||||||
void chEvtClear(t_eventmask mask);
|
#endif
|
||||||
void chEvtSend(EventSource *esp);
|
void chEvtRegister(EventSource *esp, EventListener *elp, t_eventid eid);
|
||||||
void chEvtSendI(EventSource *esp);
|
void chEvtUnregister(EventSource *esp, EventListener *elp);
|
||||||
t_eventid chEvtWait(t_eventmask ewmask,
|
void chEvtClear(t_eventmask mask);
|
||||||
t_evhandler handlers[]);
|
void chEvtSend(EventSource *esp);
|
||||||
|
void chEvtSendI(EventSource *esp);
|
||||||
|
t_eventid chEvtWait(t_eventmask ewmask,
|
||||||
|
t_evhandler handlers[]);
|
||||||
#ifdef CH_USE_EVENTS_TIMEOUT
|
#ifdef CH_USE_EVENTS_TIMEOUT
|
||||||
t_eventid chEvtWaitTimeout(t_eventmask ewmask,
|
t_eventid chEvtWaitTimeout(t_eventmask ewmask,
|
||||||
t_evhandler handlers[],
|
t_evhandler handlers[],
|
||||||
t_time time);
|
t_time time);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* CH_USE_EVENTS */
|
#endif /* CH_USE_EVENTS */
|
||||||
|
|
||||||
|
|
|
@ -55,12 +55,20 @@ typedef struct {
|
||||||
#define list_init(tlp) ((tlp)->p_next = (Thread *)(tlp))
|
#define list_init(tlp) ((tlp)->p_next = (Thread *)(tlp))
|
||||||
|
|
||||||
#ifndef CH_OPTIMIZE_SPEED
|
#ifndef CH_OPTIMIZE_SPEED
|
||||||
void fifo_insert(Thread *tp, ThreadsQueue *tqp);
|
|
||||||
Thread *fifo_remove(ThreadsQueue *tqp);
|
#ifdef __cplusplus
|
||||||
Thread *dequeue(Thread *tp);
|
extern "C" {
|
||||||
void list_insert(Thread *tp, ThreadsList *tlp);
|
|
||||||
Thread *list_remove(ThreadsList *tlp);
|
|
||||||
#endif
|
#endif
|
||||||
|
void fifo_insert(Thread *tp, ThreadsQueue *tqp);
|
||||||
|
Thread *fifo_remove(ThreadsQueue *tqp);
|
||||||
|
Thread *dequeue(Thread *tp);
|
||||||
|
void list_insert(Thread *tp, ThreadsList *tlp);
|
||||||
|
Thread *list_remove(ThreadsList *tlp);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CH_OPTIMIZE_SPEED */
|
||||||
|
|
||||||
#endif /* _LISTS_H_ */
|
#endif /* _LISTS_H_ */
|
||||||
|
|
||||||
|
|
|
@ -31,25 +31,31 @@
|
||||||
* Evaluates to TRUE if the thread has pending messages.
|
* Evaluates to TRUE if the thread has pending messages.
|
||||||
*/
|
*/
|
||||||
#define chMsgIsPendingI(tp) \
|
#define chMsgIsPendingI(tp) \
|
||||||
((tp)->p_msgqueue.p_next != (Thread *)&(tp)->p_msgqueue)
|
((tp)->p_msgqueue.p_next != (Thread *)&(tp)->p_msgqueue)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the first message in the queue.
|
* Returns the first message in the queue.
|
||||||
*/
|
*/
|
||||||
#define chMsgGetI(tp) \
|
#define chMsgGetI(tp) \
|
||||||
((tp)->p_msgqueue.p_next->p_msg)
|
((tp)->p_msgqueue.p_next->p_msg)
|
||||||
|
|
||||||
t_msg chMsgSend(Thread *tp, t_msg msg);
|
#ifdef __cplusplus
|
||||||
t_msg chMsgWait(void);
|
extern "C" {
|
||||||
t_msg chMsgGet(void);
|
#endif
|
||||||
void chMsgRelease(t_msg msg);
|
t_msg chMsgSend(Thread *tp, t_msg msg);
|
||||||
|
t_msg chMsgWait(void);
|
||||||
|
t_msg chMsgGet(void);
|
||||||
|
void chMsgRelease(t_msg msg);
|
||||||
|
|
||||||
#ifdef CH_USE_MESSAGES_EVENT
|
#ifdef CH_USE_MESSAGES_EVENT
|
||||||
t_msg chMsgSendWithEvent(Thread *tp, t_msg msg, EventSource *esp);
|
t_msg chMsgSendWithEvent(Thread *tp, t_msg msg, EventSource *esp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CH_USE_MESSAGES_TIMEOUT
|
#ifdef CH_USE_MESSAGES_TIMEOUT
|
||||||
t_msg chMsgSendTimeout(Thread *tp, t_msg msg, t_time time);
|
t_msg chMsgSendTimeout(Thread *tp, t_msg msg, t_time time);
|
||||||
|
#endif
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* CH_USE_MESSAGES */
|
#endif /* CH_USE_MESSAGES */
|
||||||
|
|
|
@ -84,28 +84,34 @@ typedef struct {
|
||||||
#define chOQIsFull(q) \
|
#define chOQIsFull(q) \
|
||||||
(chQSpace(q) <= 0)
|
(chQSpace(q) <= 0)
|
||||||
|
|
||||||
/*
|
#ifdef __cplusplus
|
||||||
* Input Queues functions. An Input Queue is usually written into by an
|
extern "C" {
|
||||||
* interrupt handler and read from a thread.
|
#endif
|
||||||
*/
|
/*
|
||||||
void chIQInit(Queue *qp, BYTE8 *buffer, t_size size, t_qnotify inotify);
|
* Input Queues functions. An Input Queue is usually written into by an
|
||||||
void chIQReset(Queue *qp);
|
* interrupt handler and read from a thread.
|
||||||
t_msg chIQPutI(Queue *qp, BYTE8 b);
|
*/
|
||||||
t_msg chIQGet(Queue *qp);
|
void chIQInit(Queue *qp, BYTE8 *buffer, t_size size, t_qnotify inotify);
|
||||||
t_size chIQRead(Queue *qp, BYTE8 *buffer, t_size n);
|
void chIQReset(Queue *qp);
|
||||||
|
t_msg chIQPutI(Queue *qp, BYTE8 b);
|
||||||
|
t_msg chIQGet(Queue *qp);
|
||||||
|
t_size chIQRead(Queue *qp, BYTE8 *buffer, t_size n);
|
||||||
#ifdef CH_USE_QUEUES_TIMEOUT
|
#ifdef CH_USE_QUEUES_TIMEOUT
|
||||||
t_msg chIQGetTimeout(Queue *qp, t_time time);
|
t_msg chIQGetTimeout(Queue *qp, t_time time);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Output Queues functions. An Output Queue is usually written into by a
|
* Output Queues functions. An Output Queue is usually written into by a
|
||||||
* thread and read from an interrupt handler.
|
* thread and read from an interrupt handler.
|
||||||
*/
|
*/
|
||||||
void chOQInit(Queue *queue, BYTE8 *buffer, t_size size, t_qnotify onotify);
|
void chOQInit(Queue *queue, BYTE8 *buffer, t_size size, t_qnotify onotify);
|
||||||
void chOQReset(Queue *queue);
|
void chOQReset(Queue *queue);
|
||||||
void chOQPut(Queue *queue, BYTE8 b);
|
void chOQPut(Queue *queue, BYTE8 b);
|
||||||
t_msg chOQGetI(Queue *queue);
|
t_msg chOQGetI(Queue *queue);
|
||||||
t_size chOQWrite(Queue *queue, BYTE8 *buffer, t_size n);
|
t_size chOQWrite(Queue *queue, BYTE8 *buffer, t_size n);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif /* CH_USE_QUEUES */
|
#endif /* CH_USE_QUEUES */
|
||||||
|
|
||||||
#ifdef CH_USE_QUEUES_HALFDUPLEX
|
#ifdef CH_USE_QUEUES_HALFDUPLEX
|
||||||
|
@ -155,14 +161,20 @@ typedef struct {
|
||||||
#define chHDQIsFullReceive(q) \
|
#define chHDQIsFullReceive(q) \
|
||||||
(chHDQFilledSpace(q) >= chHDQSize(q))
|
(chHDQFilledSpace(q) >= chHDQSize(q))
|
||||||
|
|
||||||
void chHDQInit(HalfDuplexQueue *qp, BYTE8 *buffer, t_size size,
|
#ifdef __cplusplus
|
||||||
t_qnotify inotify, t_qnotify onotify);
|
extern "C" {
|
||||||
t_msg chHDQGetReceive(HalfDuplexQueue *qp);
|
#endif
|
||||||
void chHDQPutTransmit(HalfDuplexQueue *qp, BYTE8 b);
|
void chHDQInit(HalfDuplexQueue *qp, BYTE8 *buffer, t_size size,
|
||||||
t_msg chHDQGetTransmitI(HalfDuplexQueue *qp);
|
t_qnotify inotify, t_qnotify onotify);
|
||||||
t_msg chHDQPutReceiveI(HalfDuplexQueue *qp, BYTE8 b);
|
t_msg chHDQGetReceive(HalfDuplexQueue *qp);
|
||||||
|
void chHDQPutTransmit(HalfDuplexQueue *qp, BYTE8 b);
|
||||||
|
t_msg chHDQGetTransmitI(HalfDuplexQueue *qp);
|
||||||
|
t_msg chHDQPutReceiveI(HalfDuplexQueue *qp, BYTE8 b);
|
||||||
#ifdef CH_USE_QUEUES_TIMEOUT
|
#ifdef CH_USE_QUEUES_TIMEOUT
|
||||||
t_msg chHDQGetReceiveTimeout(HalfDuplexQueue *qp, t_time time);
|
t_msg chHDQGetReceiveTimeout(HalfDuplexQueue *qp, t_time time);
|
||||||
|
#endif
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* CH_USE_QUEUES_HALFDUPLEX */
|
#endif /* CH_USE_QUEUES_HALFDUPLEX */
|
||||||
|
|
|
@ -45,14 +45,20 @@ typedef struct {
|
||||||
/*
|
/*
|
||||||
* Scheduler APIs.
|
* Scheduler APIs.
|
||||||
*/
|
*/
|
||||||
void chSchInit(void);
|
#ifdef __cplusplus
|
||||||
Thread *chSchReadyI(Thread *tp);
|
extern "C" {
|
||||||
void chSchGoSleepI(t_tstate newstate);
|
#endif
|
||||||
void chSchWakeupI(Thread *tp, t_msg msg);
|
void chSchInit(void);
|
||||||
void chSchRescheduleI(void);
|
Thread *chSchReadyI(Thread *tp);
|
||||||
void chSchDoRescheduleI(void);
|
void chSchGoSleepI(t_tstate newstate);
|
||||||
BOOL chSchRescRequiredI(void);
|
void chSchWakeupI(Thread *tp, t_msg msg);
|
||||||
void chSchTimerHandlerI(void);
|
void chSchRescheduleI(void);
|
||||||
|
void chSchDoRescheduleI(void);
|
||||||
|
BOOL chSchRescRequiredI(void);
|
||||||
|
void chSchTimerHandlerI(void);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current thread pointer.
|
* Current thread pointer.
|
||||||
|
|
|
@ -37,22 +37,28 @@ typedef struct {
|
||||||
t_cnt s_cnt;
|
t_cnt s_cnt;
|
||||||
} Semaphore;
|
} Semaphore;
|
||||||
|
|
||||||
void chSemInit(Semaphore *sp, t_cnt n);
|
#ifdef __cplusplus
|
||||||
void chSemReset(Semaphore *sp, t_cnt n);
|
extern "C" {
|
||||||
void chSemResetI(Semaphore *sp, t_cnt n);
|
#endif
|
||||||
void chSemWait(Semaphore *sp);
|
void chSemInit(Semaphore *sp, t_cnt n);
|
||||||
void chSemWaitS(Semaphore *sp);
|
void chSemReset(Semaphore *sp, t_cnt n);
|
||||||
t_msg chSemWaitTimeout(Semaphore *sp, t_time time);
|
void chSemResetI(Semaphore *sp, t_cnt n);
|
||||||
t_msg chSemWaitTimeoutS(Semaphore *sp, t_time time);
|
void chSemWait(Semaphore *sp);
|
||||||
void chSemSignal(Semaphore *sp);
|
void chSemWaitS(Semaphore *sp);
|
||||||
void chSemSignalI(Semaphore *sp);
|
t_msg chSemWaitTimeout(Semaphore *sp, t_time time);
|
||||||
void chSemSignalWait(Semaphore *sps, Semaphore *spw);
|
t_msg chSemWaitTimeoutS(Semaphore *sp, t_time time);
|
||||||
|
void chSemSignal(Semaphore *sp);
|
||||||
|
void chSemSignalI(Semaphore *sp);
|
||||||
|
void chSemSignalWait(Semaphore *sps, Semaphore *spw);
|
||||||
|
|
||||||
#ifdef CH_USE_RT_SEMAPHORES
|
#ifdef CH_USE_RT_SEMAPHORES
|
||||||
void chSemRaisePrioWait(Semaphore *sp);
|
void chSemRaisePrioWait(Semaphore *sp);
|
||||||
void chSemLowerPrioSignal(Semaphore *sp);
|
void chSemLowerPrioSignal(Semaphore *sp);
|
||||||
void chSemRaisePrioSignalWait(Semaphore *sps, Semaphore *spw);
|
void chSemRaisePrioSignalWait(Semaphore *sps, Semaphore *spw);
|
||||||
void chSemLowerPrioSignalWait(Semaphore *sps, Semaphore *spw);
|
void chSemLowerPrioSignalWait(Semaphore *sps, Semaphore *spw);
|
||||||
|
#endif
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -72,13 +72,19 @@ typedef struct {
|
||||||
EventSource sd_sevent;
|
EventSource sd_sevent;
|
||||||
} FullDuplexDriver;
|
} FullDuplexDriver;
|
||||||
|
|
||||||
void chFDDInit(FullDuplexDriver *sd,
|
#ifdef __cplusplus
|
||||||
BYTE8 *ib, t_size isize, t_qnotify inotify,
|
extern "C" {
|
||||||
BYTE8 *ob, t_size osize, t_qnotify onotify);
|
#endif
|
||||||
void chFDDIncomingDataI(FullDuplexDriver *sd, BYTE8 b);
|
void chFDDInit(FullDuplexDriver *sd,
|
||||||
t_msg chFDDRequestDataI(FullDuplexDriver *sd);
|
BYTE8 *ib, t_size isize, t_qnotify inotify,
|
||||||
void chFDDAddFlagsI(FullDuplexDriver *sd, t_dflags mask);
|
BYTE8 *ob, t_size osize, t_qnotify onotify);
|
||||||
t_dflags chFDDGetAndClearFlags(FullDuplexDriver *sd);
|
void chFDDIncomingDataI(FullDuplexDriver *sd, BYTE8 b);
|
||||||
|
t_msg chFDDRequestDataI(FullDuplexDriver *sd);
|
||||||
|
void chFDDAddFlagsI(FullDuplexDriver *sd, t_dflags mask);
|
||||||
|
t_dflags chFDDGetAndClearFlags(FullDuplexDriver *sd);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/** @see chIQRead()*/
|
/** @see chIQRead()*/
|
||||||
#define chFDDRead(sd, b, n) \
|
#define chFDDRead(sd, b, n) \
|
||||||
|
@ -128,12 +134,18 @@ typedef struct {
|
||||||
EventSource sd_sevent;
|
EventSource sd_sevent;
|
||||||
} HalfDuplexDriver;
|
} HalfDuplexDriver;
|
||||||
|
|
||||||
void chHDDInit(HalfDuplexDriver *sd, BYTE8 *b, t_size size,
|
#ifdef __cplusplus
|
||||||
t_qnotify inotify, t_qnotify onotify);
|
extern "C" {
|
||||||
void chHDDIncomingDataI(HalfDuplexDriver *sd, BYTE8 b);
|
#endif
|
||||||
t_msg chHDDRequestDataI(HalfDuplexDriver *sd);
|
void chHDDInit(HalfDuplexDriver *sd, BYTE8 *b, t_size size,
|
||||||
void chHDDAddFlagsI(HalfDuplexDriver *sd, t_dflags mask);
|
t_qnotify inotify, t_qnotify onotify);
|
||||||
t_dflags chHDDGetAndClearFlags(HalfDuplexDriver *sd);
|
void chHDDIncomingDataI(HalfDuplexDriver *sd, BYTE8 b);
|
||||||
|
t_msg chHDDRequestDataI(HalfDuplexDriver *sd);
|
||||||
|
void chHDDAddFlagsI(HalfDuplexDriver *sd, t_dflags mask);
|
||||||
|
t_dflags chHDDGetAndClearFlags(HalfDuplexDriver *sd);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/** @see chHDQGetReceive()*/
|
/** @see chHDQGetReceive()*/
|
||||||
#define chHDDGetReceive(sd) \
|
#define chHDDGetReceive(sd) \
|
||||||
|
|
|
@ -25,18 +25,19 @@
|
||||||
#ifndef _SLEEP_H_
|
#ifndef _SLEEP_H_
|
||||||
#define _SLEEP_H_
|
#define _SLEEP_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
#ifdef CH_USE_SLEEP
|
#ifdef CH_USE_SLEEP
|
||||||
|
void chThdSleep(t_time time);
|
||||||
void chThdSleep(t_time time);
|
|
||||||
|
|
||||||
#ifdef CH_USE_SYSTEMTIME
|
#ifdef CH_USE_SYSTEMTIME
|
||||||
|
void chThdSleepUntil(t_time time);
|
||||||
void chThdSleepUntil(t_time time);
|
t_time chSysGetTime(void);
|
||||||
t_time chSysGetTime(void);
|
|
||||||
|
|
||||||
#endif /* CH_USE_SYSTEMTIME */
|
#endif /* CH_USE_SYSTEMTIME */
|
||||||
|
|
||||||
#endif /* CH_USE_SLEEP */
|
#endif /* CH_USE_SLEEP */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _SLEEP_H_ */
|
#endif /* _SLEEP_H_ */
|
||||||
|
|
||||||
|
|
|
@ -186,10 +186,22 @@ static INLINE Thread *list_remove(ThreadsList *tlp) {
|
||||||
/*
|
/*
|
||||||
* Threads APIs.
|
* Threads APIs.
|
||||||
*/
|
*/
|
||||||
Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace,
|
#ifdef __cplusplus
|
||||||
t_size wsize, t_tfunc pf, void *arg);
|
extern "C" {
|
||||||
void chThdResume(Thread *tp);
|
#endif
|
||||||
void chThdExit(t_msg msg);
|
Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace,
|
||||||
|
t_size wsize, t_tfunc pf, void *arg);
|
||||||
|
void chThdResume(Thread *tp);
|
||||||
|
void chThdExit(t_msg msg);
|
||||||
|
#ifdef CH_USE_TERMINATE
|
||||||
|
void chThdTerminate(Thread *tp);
|
||||||
|
#endif
|
||||||
|
#ifdef CH_USE_WAITEXIT
|
||||||
|
t_msg chThdWait(Thread *tp);
|
||||||
|
#endif
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Returns the pointer to the \p Thread currently in execution.*/
|
/** Returns the pointer to the \p Thread currently in execution.*/
|
||||||
#define chThdSelf() currp
|
#define chThdSelf() currp
|
||||||
|
@ -200,20 +212,11 @@ void chThdExit(t_msg msg);
|
||||||
/** Verifies if the specified thread is in the \p PREXIT state.*/
|
/** Verifies if the specified thread is in the \p PREXIT state.*/
|
||||||
#define chThdTerminated(tp) ((tp)->p_state == PREXIT)
|
#define chThdTerminated(tp) ((tp)->p_state == PREXIT)
|
||||||
|
|
||||||
#ifdef CH_USE_TERMINATE
|
|
||||||
/**
|
/**
|
||||||
* Verifies if the current thread has a termination request pending.
|
* Verifies if the current thread has a termination request pending.
|
||||||
*/
|
*/
|
||||||
#define chThdShouldTerminate() (currp->p_flags & P_TERMINATE)
|
#define chThdShouldTerminate() (currp->p_flags & P_TERMINATE)
|
||||||
|
|
||||||
void chThdTerminate(Thread *tp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CH_USE_WAITEXIT
|
|
||||||
t_msg chThdWait(Thread *tp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CH_USE_EXIT_EVENT
|
|
||||||
/**
|
/**
|
||||||
* Returns the exit event source for the specified thread. The source is
|
* Returns the exit event source for the specified thread. The source is
|
||||||
* signaled when the thread terminates.
|
* signaled when the thread terminates.
|
||||||
|
@ -235,7 +238,6 @@ t_msg chThdWait(Thread *tp);
|
||||||
* option is enabled in \p chconf.h.
|
* option is enabled in \p chconf.h.
|
||||||
*/
|
*/
|
||||||
#define chThdGetExitEventSource(tp) (&(tp)->p_exitesource)
|
#define chThdGetExitEventSource(tp) (&(tp)->p_exitesource)
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _THREADS_H_ */
|
#endif /* _THREADS_H_ */
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT 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.
|
||||||
|
|
||||||
|
ChibiOS/RT 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file evtimer.c
|
||||||
|
* @{
|
||||||
|
* Event Timer, this timer generates an event at regular intervals. The
|
||||||
|
* listening threads can use the event to perform time related activities.
|
||||||
|
* Multiple threads can listen to the same timer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ch.h>
|
||||||
|
|
||||||
|
#include "evtimer.h"
|
||||||
|
|
||||||
|
static void tmrcb(void *p) {
|
||||||
|
EvTimer *etp = p;
|
||||||
|
|
||||||
|
chVTSetI(&etp->et_vt, etp->et_interval, tmrcb, etp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the timer, if the timer was already running then the function has
|
||||||
|
* no effect.
|
||||||
|
* @param etp pointer to an initialized \p EvTimer structure.
|
||||||
|
*/
|
||||||
|
void evtStart(EvTimer *etp) {
|
||||||
|
|
||||||
|
chSysLock();
|
||||||
|
|
||||||
|
if (!etp->et_vt.vt_func)
|
||||||
|
chVTSetI(&etp->et_vt, etp->et_interval, tmrcb, etp);
|
||||||
|
|
||||||
|
chSysUnlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops the timer, if the timer was already stopped then the function has
|
||||||
|
* no effect.
|
||||||
|
* @param etp pointer to an initialized \p EvTimer structure.
|
||||||
|
*/
|
||||||
|
void evtStop(EvTimer *etp) {
|
||||||
|
|
||||||
|
chSysLock();
|
||||||
|
|
||||||
|
if (etp->et_vt.vt_func)
|
||||||
|
chVTResetI(&etp->et_vt);
|
||||||
|
|
||||||
|
chSysUnlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT 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.
|
||||||
|
|
||||||
|
ChibiOS/RT 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file evtimer.h
|
||||||
|
* @{
|
||||||
|
* Event Timer definitions.
|
||||||
|
* @see evtimer.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _EVTIMER_H_
|
||||||
|
#define _EVTIMER_H_
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
VirtualTimer et_vt;
|
||||||
|
EventSource et_es;
|
||||||
|
t_time et_interval;
|
||||||
|
} EvTimer;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
void evtStart(EvTimer *etp);
|
||||||
|
void evtStop(EvTimer *etp);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes an \p EvTimer structure.
|
||||||
|
*/
|
||||||
|
#define evtInit(et, i) (chEvtInit(&(etp)->et_es), \
|
||||||
|
(etp)->et_vt.vt_func = NULL, \
|
||||||
|
(etp)->et_interval = (i))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the invoking thread as listener on the timer event.
|
||||||
|
*/
|
||||||
|
#define evtRegister(etp, el, eid) chEvtRegister(&(etp)->et_es, el, eid)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregisters the invoking thread as listener on the timer event.
|
||||||
|
*/
|
||||||
|
#define evtUnregister(etp, el) chEvtUnregister(&(etp)->et_es, el)
|
||||||
|
|
||||||
|
#endif /* _EVTIMER_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -35,7 +35,7 @@ static BYTE8 wsT5[UserStackSize(64)];
|
||||||
static Thread *t1, *t2, *t3, *t4, *t5;
|
static Thread *t1, *t2, *t3, *t4, *t5;
|
||||||
|
|
||||||
static FullDuplexDriver *comp;
|
static FullDuplexDriver *comp;
|
||||||
static Semaphore sem1, sem2;
|
static Semaphore sem1;
|
||||||
|
|
||||||
static void wait(void) {
|
static void wait(void) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue