aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-03-05 10:59:11 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-03-05 10:59:11 +0000
commit5e64a9fec2e17d008b9488faa027d2beaa130a88 (patch)
tree3ab9255111b62d78d755bc51d9e650e63b07be25
parent0778745ee12a4f14c001bd205e05728cc01e9633 (diff)
downloadChibiOS-5e64a9fec2e17d008b9488faa027d2beaa130a88.tar.gz
ChibiOS-5e64a9fec2e17d008b9488faa027d2beaa130a88.tar.bz2
ChibiOS-5e64a9fec2e17d008b9488faa027d2beaa130a88.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@215 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--demos/ARM7-AT91SAM7X-GCC/main.c4
-rw-r--r--demos/ARM7-LPC214x-GCC-minimal/main.c4
-rw-r--r--demos/ARM7-LPC214x-GCC/buzzer.c4
-rw-r--r--demos/ARM7-LPC214x-GCC/buzzer.h4
-rw-r--r--demos/ARM7-LPC214x-GCC/main.c14
-rw-r--r--demos/ARM7-LPC214x-GCC/mmcsd.c16
-rw-r--r--demos/ARM7-LPC214x-GCC/mmcsd.h14
-rw-r--r--demos/AVR-ATmega128-GCC/main.c2
-rw-r--r--demos/Win32-MinGW/chcore.c2
-rw-r--r--demos/Win32-MinGW/chcore.h2
-rw-r--r--demos/Win32-MinGW/chtypes.h25
-rw-r--r--demos/Win32-MinGW/demo.c30
-rw-r--r--ports/ARM7-AT91SAM7X/sam7x_serial.c4
-rw-r--r--ports/ARM7-LPC214x/lpc214x_serial.c8
-rw-r--r--ports/ARM7-LPC214x/lpc214x_ssp.c2
-rw-r--r--ports/ARM7-LPC214x/lpc214x_ssp.h2
-rw-r--r--ports/ARM7/chtypes.h25
-rw-r--r--ports/AVR/avr_serial.c6
-rw-r--r--ports/AVR/chtypes.h25
-rw-r--r--ports/Win32/simcom.c18
-rw-r--r--readme.txt14
-rw-r--r--src/chdelta.c4
-rw-r--r--src/chevents.c32
-rw-r--r--src/chinit.c2
-rw-r--r--src/chmsg.c16
-rw-r--r--src/chmtx.c10
-rw-r--r--src/chqueues.c38
-rw-r--r--src/chschd.c12
-rw-r--r--src/chsem.c20
-rw-r--r--src/chserial.c28
-rw-r--r--src/chsleep.c2
-rw-r--r--src/chthreads.c16
-rw-r--r--src/include/ch.h3
-rw-r--r--src/include/debug.h8
-rw-r--r--src/include/delta.h12
-rw-r--r--src/include/events.h18
-rw-r--r--src/include/messages.h14
-rw-r--r--src/include/mutexes.h4
-rw-r--r--src/include/queues.h36
-rw-r--r--src/include/scheduler.h16
-rw-r--r--src/include/semaphores.h16
-rw-r--r--src/include/serial.h26
-rw-r--r--src/include/sleep.h4
-rw-r--r--src/include/threads.h34
-rw-r--r--src/lib/evtimer.h2
-rw-r--r--src/templates/chtypes.h25
-rw-r--r--test/test.c52
47 files changed, 343 insertions, 332 deletions
diff --git a/demos/ARM7-AT91SAM7X-GCC/main.c b/demos/ARM7-AT91SAM7X-GCC/main.c
index f2a3f3737..a255c9939 100644
--- a/demos/ARM7-AT91SAM7X-GCC/main.c
+++ b/demos/ARM7-AT91SAM7X-GCC/main.c
@@ -23,7 +23,7 @@
#include "sam7x_serial.h"
static WorkingArea(waThread1, 64);
-static t_msg Thread1(void *arg) {
+static msg_t Thread1(void *arg) {
while (TRUE) {
AT91C_BASE_PIOB->PIO_SODR = PIOB_LCD_BL; // LCD on.
@@ -38,7 +38,7 @@ static t_msg Thread1(void *arg) {
* Entry point, the interrupts are disabled on entry.
*/
int main(int argc, char **argv) {
- t_msg TestThread(void *p);
+ msg_t TestThread(void *p);
/*
* The main() function becomes a thread here then the interrupts are
diff --git a/demos/ARM7-LPC214x-GCC-minimal/main.c b/demos/ARM7-LPC214x-GCC-minimal/main.c
index 18017f0b5..87d59dce0 100644
--- a/demos/ARM7-LPC214x-GCC-minimal/main.c
+++ b/demos/ARM7-LPC214x-GCC-minimal/main.c
@@ -25,7 +25,7 @@
* Red LEDs blinker thread, times are in milliseconds.
*/
static WorkingArea(waThread1, 64);
-static t_msg Thread1(void *arg) {
+static msg_t Thread1(void *arg) {
while (TRUE) {
IO0CLR = 0x00000800;
@@ -44,7 +44,7 @@ static t_msg Thread1(void *arg) {
* Yellow LED blinker thread, times are in milliseconds.
*/
static WorkingArea(waThread2, 64);
-static t_msg Thread2(void *arg) {
+static msg_t Thread2(void *arg) {
while (TRUE) {
IO0CLR = 0x80000000;
diff --git a/demos/ARM7-LPC214x-GCC/buzzer.c b/demos/ARM7-LPC214x-GCC/buzzer.c
index 9ee122fe1..249b1542b 100644
--- a/demos/ARM7-LPC214x-GCC/buzzer.c
+++ b/demos/ARM7-LPC214x-GCC/buzzer.c
@@ -64,7 +64,7 @@ static void stop(void *p) {
chEvtSendI(&BuzzerSilentEventSource);
}
-void PlaySound(int freq, t_time duration) {
+void PlaySound(int freq, systime_t duration) {
static VirtualTimer bvt;
TC *tc = T1Base;
@@ -82,7 +82,7 @@ void PlaySound(int freq, t_time duration) {
chSysUnlock();
}
-void PlaySoundWait(int freq, t_time duration) {
+void PlaySoundWait(int freq, systime_t duration) {
TC *tc = T1Base;
StopCounter(tc);
diff --git a/demos/ARM7-LPC214x-GCC/buzzer.h b/demos/ARM7-LPC214x-GCC/buzzer.h
index 464e081d8..734cb1a44 100644
--- a/demos/ARM7-LPC214x-GCC/buzzer.h
+++ b/demos/ARM7-LPC214x-GCC/buzzer.h
@@ -24,8 +24,8 @@
extern "C" {
#endif
void InitBuzzer(void);
- void PlaySound(int freq, t_time duration);
- void PlaySoundWait(int freq, t_time duration);
+ void PlaySound(int freq, systime_t duration);
+ void PlaySoundWait(int freq, systime_t duration);
#ifdef __cplusplus
}
#endif
diff --git a/demos/ARM7-LPC214x-GCC/main.c b/demos/ARM7-LPC214x-GCC/main.c
index fe0b9342c..ad2ab2700 100644
--- a/demos/ARM7-LPC214x-GCC/main.c
+++ b/demos/ARM7-LPC214x-GCC/main.c
@@ -29,7 +29,7 @@
* Red LEDs blinker thread, times are in milliseconds.
*/
static WorkingArea(waThread1, 64);
-static t_msg Thread1(void *arg) {
+static msg_t Thread1(void *arg) {
while (TRUE) {
IO0CLR = 0x00000800;
@@ -48,7 +48,7 @@ static t_msg Thread1(void *arg) {
* Yellow LED blinker thread, times are in milliseconds.
*/
static WorkingArea(waThread2, 64);
-static t_msg Thread2(void *arg) {
+static msg_t Thread2(void *arg) {
while (TRUE) {
IO0CLR = 0x80000000;
@@ -62,8 +62,8 @@ static t_msg Thread2(void *arg) {
/*
* Executed as event handler at 500mS intervals.
*/
-static void TimerHandler(t_eventid id) {
- t_msg TestThread(void *p);
+static void TimerHandler(eventid_t id) {
+ msg_t TestThread(void *p);
if (!(IO0PIN & 0x00018000)) { // Both buttons
TestThread(&COM1);
@@ -83,7 +83,7 @@ static void TimerHandler(t_eventid id) {
* Plays sounds when a MMC/SD card is inserted, then initializes the MMC
* driver and reads a sector.
*/
-static void InsertHandler(t_eventid id) {
+static void InsertHandler(eventid_t id) {
static uint8_t rwbuf[512];
MMCCSD data;
@@ -102,7 +102,7 @@ static void InsertHandler(t_eventid id) {
/*
* Plays sounds when a MMC/SD card is removed.
*/
-static void RemoveHandler(t_eventid id) {
+static void RemoveHandler(eventid_t id) {
PlaySoundWait(2000, 100);
PlaySoundWait(1000, 100);
@@ -112,7 +112,7 @@ static void RemoveHandler(t_eventid id) {
* Entry point, the interrupts are disabled on entry.
*/
int main(int argc, char **argv) {
- static const t_evhandler evhndl[] = {
+ static const evhandler_t evhndl[] = {
TimerHandler,
InsertHandler,
RemoveHandler
diff --git a/demos/ARM7-LPC214x-GCC/mmcsd.c b/demos/ARM7-LPC214x-GCC/mmcsd.c
index febfca237..c06123f88 100644
--- a/demos/ARM7-LPC214x-GCC/mmcsd.c
+++ b/demos/ARM7-LPC214x-GCC/mmcsd.c
@@ -91,7 +91,7 @@ void mmcStopPolling(void) {
/*
* Returns TRUE if the card is safely inserted in the reader.
*/
-t_bool mmcCardInserted (void) {
+bool_t mmcCardInserted (void) {
return cnt == 0;
}
@@ -145,7 +145,7 @@ static uint8_t recvr1(void) {
return 0xFF; /* Timeout.*/
}
-static t_bool getdata(uint8_t *buf, uint32_t n) {
+static bool_t getdata(uint8_t *buf, uint32_t n) {
int i;
for (i = 0; i < MMC_WAIT_DATA; i++) {
@@ -162,7 +162,7 @@ static t_bool getdata(uint8_t *buf, uint32_t n) {
/*
* Initializes a card after the power up by selecting the SPI mode.
*/
-t_bool mmcInit(void) {
+bool_t mmcInit(void) {
/*
* Starting initialization with slow clock mode.
@@ -222,7 +222,7 @@ uint8_t mmcSendCommand(uint8_t cmd, uint32_t arg) {
* @param data the pointer to a \p MMCCSD structure
* @return \p TRUE if an error happened
*/
-t_bool mmcGetSize(MMCCSD *data) {
+bool_t mmcGetSize(MMCCSD *data) {
uint8_t buf[16];
sspAcquireBus();
@@ -250,7 +250,7 @@ t_bool mmcGetSize(MMCCSD *data) {
* @param buf the pointer to the read buffer
* @return \p TRUE if an error happened
*/
-t_bool mmcRead(uint8_t *buf, uint32_t blknum) {
+bool_t mmcRead(uint8_t *buf, uint32_t blknum) {
sspAcquireBus();
sendhdr(CMDREAD, blknum << 8);
@@ -273,7 +273,7 @@ t_bool mmcRead(uint8_t *buf, uint32_t blknum) {
* @param buf the pointer to the read buffer
* @return \p TRUE if an error happened
*/
-t_bool mmcReadMultiple(uint8_t *buf, uint32_t blknum, uint32_t n) {
+bool_t mmcReadMultiple(uint8_t *buf, uint32_t blknum, uint32_t n) {
static const uint8_t stopcmd[] = {0x40 | CMDSTOP, 0, 0, 0, 0, 1, 0xFF};
sspAcquireBus();
@@ -309,7 +309,7 @@ t_bool mmcReadMultiple(uint8_t *buf, uint32_t blknum, uint32_t n) {
* the card, this allows to not make useless busy waiting. The invoking
* thread can do other things while the data is being written.
*/
-t_bool mmcWrite(uint8_t *buf, uint32_t blknum) {
+bool_t mmcWrite(uint8_t *buf, uint32_t blknum) {
static const uint8_t start[] = {0xFF, 0xFE};
uint8_t b[4];
@@ -340,7 +340,7 @@ t_bool mmcWrite(uint8_t *buf, uint32_t blknum) {
* the card, this allows to not make useless busy waiting. The invoking
* thread can do other things while the data is being written.
*/
-t_bool mmcWriteMultiple(uint8_t *buf, uint32_t blknum, uint32_t n) {
+bool_t mmcWriteMultiple(uint8_t *buf, uint32_t blknum, uint32_t n) {
static const uint8_t start[] = {0xFF, 0xFC},
stop[] = {0xFD, 0xFF};
uint8_t b[4];
diff --git a/demos/ARM7-LPC214x-GCC/mmcsd.h b/demos/ARM7-LPC214x-GCC/mmcsd.h
index 60396dafb..d7ab4b348 100644
--- a/demos/ARM7-LPC214x-GCC/mmcsd.h
+++ b/demos/ARM7-LPC214x-GCC/mmcsd.h
@@ -48,16 +48,16 @@ extern EventSource MMCInsertEventSource, MMCRemoveEventSource;
#endif
void InitMMC(void);
- t_bool mmcInit(void);
+ bool_t mmcInit(void);
void mmcStartPolling(void);
void mmcStopPolling(void);
- t_bool mmcCardInserted (void);
+ bool_t mmcCardInserted (void);
uint8_t mmcSendCommand(uint8_t cmd, uint32_t arg);
- t_bool mmcGetSize(MMCCSD *data);
- t_bool mmcRead(uint8_t *buf, uint32_t blknum);
- t_bool mmcReadMultiple(uint8_t *buf, uint32_t blknum, uint32_t n);
- t_bool mmcWrite(uint8_t *buf, uint32_t blknum);
- t_bool mmcWriteMultiple(uint8_t *buf, uint32_t blknum, uint32_t n);
+ bool_t mmcGetSize(MMCCSD *data);
+ bool_t mmcRead(uint8_t *buf, uint32_t blknum);
+ bool_t mmcReadMultiple(uint8_t *buf, uint32_t blknum, uint32_t n);
+ bool_t mmcWrite(uint8_t *buf, uint32_t blknum);
+ bool_t mmcWriteMultiple(uint8_t *buf, uint32_t blknum, uint32_t n);
void mmcSynch(void);
#ifdef __cplusplus
}
diff --git a/demos/AVR-ATmega128-GCC/main.c b/demos/AVR-ATmega128-GCC/main.c
index b5103521e..48b263f3c 100644
--- a/demos/AVR-ATmega128-GCC/main.c
+++ b/demos/AVR-ATmega128-GCC/main.c
@@ -26,7 +26,7 @@
void hwinit(void);
static WorkingArea(waThread1, 32);
-static t_msg Thread1(void *arg) {
+static msg_t Thread1(void *arg) {
while (TRUE) {
PORTA ^= PORTA_RELAY;
diff --git a/demos/Win32-MinGW/chcore.c b/demos/Win32-MinGW/chcore.c
index 866ac791e..047fe66da 100644
--- a/demos/Win32-MinGW/chcore.c
+++ b/demos/Win32-MinGW/chcore.c
@@ -91,7 +91,7 @@ void ChkIntSources(void) {
}
}
-t_msg _IdleThread(void *p) {
+msg_t _IdleThread(void *p) {
while (TRUE) {
diff --git a/demos/Win32-MinGW/chcore.h b/demos/Win32-MinGW/chcore.h
index fed88c171..bc0ed3e42 100644
--- a/demos/Win32-MinGW/chcore.h
+++ b/demos/Win32-MinGW/chcore.h
@@ -73,7 +73,7 @@ typedef struct {
#define WorkingArea(s, n) uint32_t s[UserStackSize(n) >> 2];
#define IDLE_THREAD_STACK_SIZE 16384
-t_msg _IdleThread(void *p);
+msg_t _IdleThread(void *p);
__attribute__((fastcall)) void chSysHalt(void);
__attribute__((fastcall)) void chSysSwitchI(Thread *otp, Thread *ntp);
diff --git a/demos/Win32-MinGW/chtypes.h b/demos/Win32-MinGW/chtypes.h
index c8a1dc69c..2fd609b1f 100644
--- a/demos/Win32-MinGW/chtypes.h
+++ b/demos/Win32-MinGW/chtypes.h
@@ -20,21 +20,24 @@
#ifndef _CHTYPES_H_
#define _CHTYPES_H_
+#define __need_NULL
+#define __need_size_t
+#include <stddef.h>
+
#if !defined(_STDINT_H) && !defined(__STDINT_H_)
#include <stdint.h>
#endif
-typedef int8_t t_bool;
-typedef uint8_t t_tmode;
-typedef uint8_t t_tstate;
-typedef uint16_t t_tid;
-typedef uint32_t t_prio;
-typedef int32_t t_msg;
-typedef int32_t t_eventid;
-typedef uint32_t t_eventmask;
-typedef uint32_t t_time;
-typedef int32_t t_cnt;
-typedef uint32_t t_size;
+typedef int8_t bool_t;
+typedef uint8_t tmode_t;
+typedef uint8_t tstate_t;
+typedef uint16_t tid_t;
+typedef uint32_t tprio_t;
+typedef int32_t msg_t;
+typedef int32_t eventid_t;
+typedef uint32_t eventmask_t;
+typedef uint32_t systime_t;
+typedef int32_t cnt_t;
#define INLINE inline
diff --git a/demos/Win32-MinGW/demo.c b/demos/Win32-MinGW/demo.c
index 0b646a50b..f3d276599 100644
--- a/demos/Win32-MinGW/demo.c
+++ b/demos/Win32-MinGW/demo.c
@@ -29,21 +29,21 @@ static uint32_t cdguard;
static WorkingArea(cdarea, 2048);
static Thread *cdtp;
-static t_msg WatchdogThread(void *arg);
-static t_msg ConsoleThread(void *arg);
+static msg_t WatchdogThread(void *arg);
+static msg_t ConsoleThread(void *arg);
-t_msg TestThread(void *p);
+msg_t TestThread(void *p);
void InitCore(void);
extern FullDuplexDriver COM1, COM2;
-#define cprint(msg) chMsgSend(cdtp, (t_msg)msg)
+#define cprint(msg) chMsgSend(cdtp, (msg_t)msg)
/*
* Watchdog thread, it checks magic values located under the various stack
* areas. The system is halted if something is wrong.
*/
-static t_msg WatchdogThread(void *arg) {
+static msg_t WatchdogThread(void *arg) {
wdguard = 0xA51F2E3D;
cdguard = 0xA51F2E3D;
while (TRUE) {
@@ -63,7 +63,7 @@ static t_msg WatchdogThread(void *arg) {
* to the C printf() thread safe and the print operation atomic among threads.
* In this example the message is the zero termitated string itself.
*/
-static t_msg ConsoleThread(void *arg) {
+static msg_t ConsoleThread(void *arg) {
while (!chThdShouldTerminate()) {
printf((char *)chMsgWait());
@@ -78,7 +78,7 @@ static void PrintLineFDD(FullDuplexDriver *sd, char *msg) {
chFDDPut(sd, *msg++);
}
-static t_bool GetLineFDD(FullDuplexDriver *sd, char *line, int size) {
+static bool_t GetLineFDD(FullDuplexDriver *sd, char *line, int size) {
char *p = line;
while (TRUE) {
@@ -116,7 +116,7 @@ static t_bool GetLineFDD(FullDuplexDriver *sd, char *line, int size) {
* Example thread, not much to see here. It simulates the CTRL-C but there
* are no real signals involved.
*/
-static t_msg HelloWorldThread(void *arg) {
+static msg_t HelloWorldThread(void *arg) {
int i;
short c;
FullDuplexDriver *sd = (FullDuplexDriver *)arg;
@@ -140,7 +140,7 @@ static t_msg HelloWorldThread(void *arg) {
return 0;
}
-static t_bool checkend(FullDuplexDriver *sd) {
+static bool_t checkend(FullDuplexDriver *sd) {
char * lp = strtok(NULL, " \009"); /* It is not thread safe but this is a demo.*/
if (lp) {
@@ -155,7 +155,7 @@ static t_bool checkend(FullDuplexDriver *sd) {
* Simple command shell thread, the argument is the serial line for the
* standard input and output. It recognizes few simple commands.
*/
-static t_msg ShellThread(void *arg) {
+static msg_t ShellThread(void *arg) {
FullDuplexDriver *sd = (FullDuplexDriver *)arg;
char *lp, line[64];
Thread *tp;
@@ -225,8 +225,8 @@ static WorkingArea(s1area, 4096);
static Thread *s1;
EventListener s1tel;
-static void COM1Handler(t_eventid id) {
- t_dflags flags;
+static void COM1Handler(eventid_t id) {
+ dflags_t flags;
if (s1 && chThdTerminated(s1)) {
s1 = NULL;
@@ -248,8 +248,8 @@ static WorkingArea(s2area, 4096);
static Thread *s2;
EventListener s2tel;
-static void COM2Handler(t_eventid id) {
- t_dflags flags;
+static void COM2Handler(eventid_t id) {
+ dflags_t flags;
if (s2 && chThdTerminated(s2)) {
s2 = NULL;
@@ -267,7 +267,7 @@ static void COM2Handler(t_eventid id) {
chIQReset(&COM2.sd_iqueue);
}
-static t_evhandler fhandlers[2] = {
+static evhandler_t fhandlers[2] = {
COM1Handler,
COM2Handler
};
diff --git a/ports/ARM7-AT91SAM7X/sam7x_serial.c b/ports/ARM7-AT91SAM7X/sam7x_serial.c
index b3719fbc2..2fad3c380 100644
--- a/ports/ARM7-AT91SAM7X/sam7x_serial.c
+++ b/ports/ARM7-AT91SAM7X/sam7x_serial.c
@@ -32,7 +32,7 @@ static uint8_t ib2[SERIAL_BUFFERS_SIZE];
static uint8_t ob2[SERIAL_BUFFERS_SIZE];
static void SetError(AT91_REG csr, FullDuplexDriver *com) {
- uint16_t sts = 0;
+ dflags_t sts = 0;
if (csr & AT91C_US_OVRE)
sts |= SD_OVERRUN_ERROR;
@@ -53,7 +53,7 @@ static void ServeInterrupt(AT91PS_USART u, FullDuplexDriver *com) {
if (u->US_CSR & AT91C_US_RXRDY)
chFDDIncomingDataI(com, u->US_RHR);
if (u->US_CSR & AT91C_US_TXRDY) {
- t_msg b = chFDDRequestDataI(com);
+ msg_t b = chFDDRequestDataI(com);
if (b < Q_OK)
u->US_IDR = AT91C_US_TXRDY;
else
diff --git a/ports/ARM7-LPC214x/lpc214x_serial.c b/ports/ARM7-LPC214x/lpc214x_serial.c
index 8f4e1d417..76f706ccb 100644
--- a/ports/ARM7-LPC214x/lpc214x_serial.c
+++ b/ports/ARM7-LPC214x/lpc214x_serial.c
@@ -33,7 +33,7 @@ static uint8_t ib2[SERIAL_BUFFERS_SIZE];
static uint8_t ob2[SERIAL_BUFFERS_SIZE];
static void SetError(IOREG32 err, FullDuplexDriver *com) {
- uint16_t sts = 0;
+ dflags_t sts = 0;
if (err & LSR_OVERRUN)
sts |= SD_OVERRUN_ERROR;
@@ -72,7 +72,7 @@ static void ServeInterrupt(UART *u, FullDuplexDriver *com) {
#ifdef FIFO_PRELOAD
int i = FIFO_PRELOAD;
do {
- t_msg b = chOQGetI(&com->sd_oqueue);
+ msg_t b = chOQGetI(&com->sd_oqueue);
if (b < Q_OK) {
u->UART_IER &= ~IER_THRE;
chEvtSendI(&com->sd_oevent);
@@ -81,7 +81,7 @@ static void ServeInterrupt(UART *u, FullDuplexDriver *com) {
u->UART_THR = b;
} while (--i);
#else
- t_msg b = chFDDRequestDataI(com);
+ msg_t b = chFDDRequestDataI(com);
if (b < Q_OK)
u->UART_IER &= ~IER_THRE;
else
@@ -123,7 +123,7 @@ static void preload(UART *u, FullDuplexDriver *com) {
if (u->UART_LSR & LSR_THRE) {
int i = FIFO_PRELOAD;
do {
- t_msg b = chOQGetI(&com->sd_oqueue);
+ msg_t b = chOQGetI(&com->sd_oqueue);
if (b < Q_OK) {
chEvtSendI(&com->sd_oevent);
return;
diff --git a/ports/ARM7-LPC214x/lpc214x_ssp.c b/ports/ARM7-LPC214x/lpc214x_ssp.c
index 80a936f4a..708c2dbeb 100644
--- a/ports/ARM7-LPC214x/lpc214x_ssp.c
+++ b/ports/ARM7-LPC214x/lpc214x_ssp.c
@@ -55,7 +55,7 @@ void sspReleaseBus(void) {
* rest of the system. This kind of peripheral would really need a
* dedicated DMA channel.
*/
-void sspRW(uint8_t *in, uint8_t *out, t_size n) {
+void sspRW(uint8_t *in, uint8_t *out, size_t n) {
int icnt, ocnt;
SSP *ssp = SSPBase;
diff --git a/ports/ARM7-LPC214x/lpc214x_ssp.h b/ports/ARM7-LPC214x/lpc214x_ssp.h
index 70a4be527..55929c2d8 100644
--- a/ports/ARM7-LPC214x/lpc214x_ssp.h
+++ b/ports/ARM7-LPC214x/lpc214x_ssp.h
@@ -34,7 +34,7 @@
void sspAcquireBus(void);
void sspReleaseBus(void);
- void sspRW(uint8_t *in, uint8_t *out, t_size n);
+ void sspRW(uint8_t *in, uint8_t *out, size_t n);
#ifdef __cplusplus
}
#endif
diff --git a/ports/ARM7/chtypes.h b/ports/ARM7/chtypes.h
index c8a1dc69c..2fd609b1f 100644
--- a/ports/ARM7/chtypes.h
+++ b/ports/ARM7/chtypes.h
@@ -20,21 +20,24 @@
#ifndef _CHTYPES_H_
#define _CHTYPES_H_
+#define __need_NULL
+#define __need_size_t
+#include <stddef.h>
+
#if !defined(_STDINT_H) && !defined(__STDINT_H_)
#include <stdint.h>
#endif
-typedef int8_t t_bool;
-typedef uint8_t t_tmode;
-typedef uint8_t t_tstate;
-typedef uint16_t t_tid;
-typedef uint32_t t_prio;
-typedef int32_t t_msg;
-typedef int32_t t_eventid;
-typedef uint32_t t_eventmask;
-typedef uint32_t t_time;
-typedef int32_t t_cnt;
-typedef uint32_t t_size;
+typedef int8_t bool_t;
+typedef uint8_t tmode_t;
+typedef uint8_t tstate_t;
+typedef uint16_t tid_t;
+typedef uint32_t tprio_t;
+typedef int32_t msg_t;
+typedef int32_t eventid_t;
+typedef uint32_t eventmask_t;
+typedef uint32_t systime_t;
+typedef int32_t cnt_t;
#define INLINE inline
diff --git a/ports/AVR/avr_serial.c b/ports/AVR/avr_serial.c
index 535c6d88f..d9db9efcc 100644
--- a/ports/AVR/avr_serial.c
+++ b/ports/AVR/avr_serial.c
@@ -25,7 +25,7 @@
#include "avr_serial.h"
static void SetError(uint8_t sra, FullDuplexDriver *com) {
- uint16_t sts = 0;
+ dflags_t sts = 0;
if (sra & (1 << DOR))
sts |= SD_OVERRUN_ERROR;
@@ -54,7 +54,7 @@ ISR(USART0_RX_vect) {
}
ISR(USART0_UDRE_vect) {
- t_msg b;
+ msg_t b;
chSysIRQEnterI();
@@ -109,7 +109,7 @@ ISR(USART1_RX_vect) {
}
ISR(USART1_UDRE_vect) {
- t_msg b;
+ msg_t b;
chSysIRQEnterI();
diff --git a/ports/AVR/chtypes.h b/ports/AVR/chtypes.h
index 67f188b82..dfcc90a04 100644
--- a/ports/AVR/chtypes.h
+++ b/ports/AVR/chtypes.h
@@ -20,21 +20,24 @@
#ifndef _CHTYPES_H_
#define _CHTYPES_H_
+#define __need_NULL
+#define __need_size_t
+#include <stddef.h>
+
#if !defined(_STDINT_H) && !defined(__STDINT_H_)
#include <stdint.h>
#endif
-typedef int8_t t_bool;
-typedef uint8_t t_tmode;
-typedef uint8_t t_tstate;
-typedef uint8_t t_tid;
-typedef uint8_t t_prio;
-typedef int16_t t_msg;
-typedef uint8_t t_eventid;
-typedef uint8_t t_eventmask;
-typedef uint16_t t_time;
-typedef int8_t t_cnt;
-typedef uint16_t t_size;
+typedef int8_t bool_t;
+typedef uint8_t tmode_t;
+typedef uint8_t tstate_t;
+typedef uint8_t tid_t;
+typedef uint8_t tprio_t;
+typedef int16_t msg_t;
+typedef uint8_t eventid_t;
+typedef uint8_t eventmask_t;
+typedef uint16_t systime_t;
+typedef int8_t cnt_t;
#define INLINE inline
diff --git a/ports/Win32/simcom.c b/ports/Win32/simcom.c
index 656fc2d45..1b676b1f7 100644
--- a/ports/Win32/simcom.c
+++ b/ports/Win32/simcom.c
@@ -108,7 +108,7 @@ void InitSimCom2(void) {
init("COM2", &COM2, &sc2, COM2PORT);
}
-static t_bool connint(char *name, FullDuplexDriver *sd, struct simcom *sc) {
+static bool_t connint(char *name, FullDuplexDriver *sd, struct simcom *sc) {
if (sc->com_data == INVALID_SOCKET) {
struct sockaddr addr;
@@ -134,17 +134,17 @@ abort:
exit(1);
}
-t_bool Com1ConnInterruptSimCom(void) {
+bool_t Com1ConnInterruptSimCom(void) {
return connint("COM1", &COM1, &sc1);
}
-t_bool Com2ConnInterruptSimCom(void) {
+bool_t Com2ConnInterruptSimCom(void) {
return connint("COM2", &COM2, &sc2);
}
-static t_bool inint(char *name, FullDuplexDriver *sd, struct simcom *sc) {
+static bool_t inint(char *name, FullDuplexDriver *sd, struct simcom *sc) {
if (sc->com_data != INVALID_SOCKET) {
int i;
@@ -174,17 +174,17 @@ static t_bool inint(char *name, FullDuplexDriver *sd, struct simcom *sc) {
return FALSE;
}
-t_bool Com1InInterruptSimCom(void) {
+bool_t Com1InInterruptSimCom(void) {
return inint("COM1", &COM1, &sc1);
}
-t_bool Com2InInterruptSimCom(void) {
+bool_t Com2InInterruptSimCom(void) {
return inint("COM2", &COM2, &sc2);
}
-static t_bool outint(char *name, FullDuplexDriver *sd, struct simcom *sc) {
+static bool_t outint(char *name, FullDuplexDriver *sd, struct simcom *sc) {
if (sc->com_data != INVALID_SOCKET) {
int n;
@@ -216,12 +216,12 @@ static t_bool outint(char *name, FullDuplexDriver *sd, struct simcom *sc) {
return FALSE;
}
-t_bool Com1OutInterruptSimCom(void) {
+bool_t Com1OutInterruptSimCom(void) {
return outint("COM1", &COM1, &sc1);
}
-t_bool Com2OutInterruptSimCom(void) {
+bool_t Com2OutInterruptSimCom(void) {
return outint("COM2", &COM2, &sc2);
}
diff --git a/readme.txt b/readme.txt
index f215b04ad..11dbbac36 100644
--- a/readme.txt
+++ b/readme.txt
@@ -63,12 +63,18 @@ AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not complete yet, scheduled
*** Releases ***
*****************************************************************************
-*** 0.5.6 ***
-- Implemented a serial driver in the AVR port.
+*** 0.6.0 ***
- Code refactory, all the old sized-integer definitions like LONG32, UWORD16
etc are now replaced by the proper definitions provided by the compiler
- into stdint.h. This has an impact on some API prototypes but we can't
- help it.
+ into stdint.h.
+- Code refactory, the previous system types style using a t_ in front of the
+ name has been replaced with the standard trailing _t. The system now uses
+ the size_t type defined into stddef.h. Some type names were modified in
+ order to not match commonly used type names.
+- The above changes have an impact on some API prototypes but we can't help
+ it, the change was required because the type names were the main concern of
+ some users.
+- Implemented a serial driver in the AVR port.
- MSVC demo dropped, it is still possible to use the MinGW demo as simulator
in Win32.
- Fixed a minor error in sam7x_serial.h and lpc214x_serial.h.
diff --git a/src/chdelta.c b/src/chdelta.c
index 16dfac5bc..ef4493b79 100644
--- a/src/chdelta.c
+++ b/src/chdelta.c
@@ -33,7 +33,7 @@ DeltaList dlist;
void chVTInit(void) {
dlist.dl_next = dlist.dl_prev = (VirtualTimer *)&dlist;
- dlist.dl_dtime = (t_time)-1;
+ dlist.dl_dtime = (systime_t)-1;
}
/**
@@ -50,7 +50,7 @@ void chVTInit(void) {
* @note Must be called with the interrupts disabled.
* @note The associated function is invoked by an interrupt handler.
*/
-void chVTSetI(VirtualTimer *vtp, t_time time, t_vtfunc vtfunc, void *par) {
+void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par) {
vtp->vt_par = par;
vtp->vt_func = vtfunc;
diff --git a/src/chevents.c b/src/chevents.c
index 9fd2e4543..75ac8b322 100644
--- a/src/chevents.c
+++ b/src/chevents.c
@@ -31,11 +31,11 @@
* @param eid numeric identifier assigned to the Event Listener. The identifier
* is used as index for the event callback function.
* The value must range between zero and the size, in bit, of the
- * \p t_eventid type minus one.
+ * \p eventid_t type minus one.
* @note Multiple Event Listeners can use the same event identifier, the
* listener will share the callback function.
*/
-void chEvtRegister(EventSource *esp, EventListener *elp, t_eventid eid) {
+void chEvtRegister(EventSource *esp, EventListener *elp, eventid_t eid) {
chSysLock();
@@ -77,7 +77,7 @@ void chEvtUnregister(EventSource *esp, EventListener *elp) {
* Clears the pending events specified in the mask.
* @param mask the events to be cleared
*/
-void chEvtClear(t_eventmask mask) {
+void chEvtClear(eventmask_t mask) {
chSysLock();
@@ -125,7 +125,7 @@ void chEvtSendI(EventSource *esp) {
* event handler is specified then the handler is executed before returning.
* @param ewmask mask of the events that should be served by the function,
* \p ALL_EVENTS enables all the sources
- * @param handlers an array of \p t_evhandler. The array must be
+ * @param handlers an array of \p evhandler_t. The array must be
* have indexes from zero up the higher registered event
* identifier. The array can be \p NULL or contain \p NULL
* elements (no callbacks specified).
@@ -136,8 +136,8 @@ void chEvtSendI(EventSource *esp) {
* This means that Event Listeners with a lower event identifier have
* an higher priority.
*/
-t_eventid chEvtWait(t_eventmask ewmask,
- const t_evhandler handlers[]) {
+eventid_t chEvtWait(eventmask_t ewmask,
+ const evhandler_t handlers[]) {
return chEvtWaitTimeout(ewmask, handlers, TIME_INFINITE);
}
@@ -148,7 +148,7 @@ t_eventid chEvtWait(t_eventmask ewmask,
* executed before returning.
* @param ewmask mask of the events that should be served by the function,
* \p ALL_EVENTS enables all the sources
- * @param handlers an array of \p t_evhandler. The array must be
+ * @param handlers an array of \p evhandler_t. The array must be
* have indexes from zero up the higher registered event
* identifier. The array can be NULL or contain NULL elements
* (no callback specified).
@@ -162,11 +162,11 @@ t_eventid chEvtWait(t_eventmask ewmask,
* @note The function is available only if the \p CH_USE_EVENTS_TIMEOUT
* option is enabled in \p chconf.h.
*/
-t_eventid chEvtWaitTimeout(t_eventmask ewmask,
- const t_evhandler handlers[],
- t_time time) {
- t_eventid i;
- t_eventmask m;
+eventid_t chEvtWaitTimeout(eventmask_t ewmask,
+ const evhandler_t handlers[],
+ systime_t time) {
+ eventid_t i;
+ eventmask_t m;
chSysLock();
@@ -189,10 +189,10 @@ t_eventid chEvtWaitTimeout(t_eventmask ewmask,
}
#else /* !CH_USE_EVENTS_TIMEOUT */
-t_eventid chEvtWait(t_eventmask ewmask,
- const t_evhandler handlers[]) {
- t_eventid i;
- t_eventmask m;
+eventid_t chEvtWait(eventmask_t ewmask,
+ const evhandler_t handlers[]) {
+ eventid_t i;
+ eventmask_t m;
chSysLock();
diff --git a/src/chinit.c b/src/chinit.c
index 06ee2fc9b..213f8b4e8 100644
--- a/src/chinit.c
+++ b/src/chinit.c
@@ -55,7 +55,7 @@ void chSysInit(void) {
* serve interrupts in its context while keeping the lowest energy saving
* mode compatible with the system status.
*/
- chThdCreate(IDLEPRIO, 0, waIdleThread, sizeof(waIdleThread), (t_tfunc)_IdleThread, NULL);
+ chThdCreate(IDLEPRIO, 0, waIdleThread, sizeof(waIdleThread), (tfunc_t)_IdleThread, NULL);
}
/**
diff --git a/src/chmsg.c b/src/chmsg.c
index 91a6cc9fd..ae90c8264 100644
--- a/src/chmsg.c
+++ b/src/chmsg.c
@@ -32,7 +32,7 @@
* @param msg the message, it can be a pointer to a complex structure
* @return the return message from \p chMsgRelease()
*/
-t_msg chMsgSend(Thread *tp, t_msg msg) {
+msg_t chMsgSend(Thread *tp, msg_t msg) {
chSysLock();
@@ -70,7 +70,7 @@ t_msg chMsgSend(Thread *tp, t_msg msg) {
* a \p chMsgWait(). The use case is that the server thread is waiting
* for both messages AND events while waiting into \p chEvtWait().
*/
-t_msg chMsgSendWithEvent(Thread *tp, t_msg msg, EventSource *esp) {
+msg_t chMsgSendWithEvent(Thread *tp, msg_t msg, EventSource *esp) {
chSysLock();
@@ -103,8 +103,8 @@ t_msg chMsgSendWithEvent(Thread *tp, t_msg msg, EventSource *esp) {
* you invoke \p chMsgRelease() because the sending thread is
* suspended until then.
*/
-t_msg chMsgWait(void) {
- t_msg msg;
+msg_t chMsgWait(void) {
+ msg_t msg;
chSysLock();
@@ -127,12 +127,12 @@ t_msg chMsgWait(void) {
* suspended until then. Always remember that the message data is not
* copied between the sender and the receiver, just a pointer is passed.
*/
-t_msg chMsgGet(void) {
- t_msg msg;
+msg_t chMsgGet(void) {
+ msg_t msg;
chSysLock();
- msg = chMsgIsPendingI(currp) ? chMsgGetI(currp) : NULL;
+ msg = chMsgIsPendingI(currp) ? chMsgGetI(currp) : (msg_t)NULL;
chSysUnlock();
return msg;
@@ -149,7 +149,7 @@ t_msg chMsgGet(void) {
* The condition is not checked in order to make this code as fast as
* possible.
*/
-void chMsgRelease(t_msg msg) {
+void chMsgRelease(msg_t msg) {
chSysLock();
diff --git a/src/chmtx.c b/src/chmtx.c
index b76902477..6d9e4e18f 100644
--- a/src/chmtx.c
+++ b/src/chmtx.c
@@ -106,8 +106,8 @@ void chMtxLockS(Mutex *mp) {
* @param mp pointer to the \p Mutex structure
* @return \p TRUE if the mutex was successfully acquired else \p FALSE
*/
-t_bool chMtxTryLock(Mutex *mp) {
- t_bool b;
+bool_t chMtxTryLock(Mutex *mp) {
+ bool_t b;
chSysLock();
@@ -126,7 +126,7 @@ t_bool chMtxTryLock(Mutex *mp) {
* @note This function must be called within a \p chSysLock() / \p chSysUnlock()
* block.
*/
-t_bool chMtxTryLockS(Mutex *mp) {
+bool_t chMtxTryLockS(Mutex *mp) {
if (mp->m_owner != NULL)
return FALSE;
@@ -161,7 +161,7 @@ void chMtxUnlock(void) {
/*
* Recalculates the optimal thread priority by scanning the owned mutexes list.
*/
- t_prio newprio = currp->p_realprio;
+ tprio_t newprio = currp->p_realprio;
mp = currp->p_mtxlist;
while (mp != NULL) {
if (chMtxQueueNotEmptyS(mp) && (mp->m_queue.p_next->p_prio > newprio))
@@ -201,7 +201,7 @@ void chMtxUnlockS(void) {
/*
* Recalculates the optimal thread priority by scanning the owned mutexes list.
*/
- t_prio newprio = currp->p_realprio;
+ tprio_t newprio = currp->p_realprio;
mp = currp->p_mtxlist;
while (mp != NULL) {
if (chMtxQueueNotEmptyS(mp) && (mp->m_queue.p_next->p_prio > newprio))
diff --git a/src/chqueues.c b/src/chqueues.c
index eafa50d42..ec456c5f1 100644
--- a/src/chqueues.c
+++ b/src/chqueues.c
@@ -35,7 +35,7 @@
* @param inotify pointer to a callback function that is invoked when
* some data is read from the Queue. The value can be \p NULL.
*/
-void chIQInit(Queue *qp, uint8_t *buffer, t_size size, t_qnotify inotify) {
+void chIQInit(Queue *qp, uint8_t *buffer, size_t size, qnotify_t inotify) {
qp->q_buffer = qp->q_rdptr = qp->q_wrptr = buffer;
qp->q_top = buffer + size;
@@ -68,7 +68,7 @@ void chIQReset(Queue *qp) {
* @note This function must be called with interrupts disabled or from an
* interrupt handler.
*/
-t_msg chIQPutI(Queue *qp, uint8_t b) {
+msg_t chIQPutI(Queue *qp, uint8_t b) {
if (chIQIsFull(qp))
return Q_FULL;
@@ -86,7 +86,7 @@ t_msg chIQPutI(Queue *qp, uint8_t b) {
* @param qp pointer to a \p Queue structure
* @return a byte from the queue or \p Q_RESET if the queue was reset
*/
-t_msg chIQGet(Queue *qp) {
+msg_t chIQGet(Queue *qp) {
uint8_t b;
chSysLock();
@@ -119,9 +119,9 @@ t_msg chIQGet(Queue *qp) {
* @note The function is available only if the \p CH_USE_QUEUES_TIMEOUT
* option is enabled in \p chconf.h.
*/
-t_msg chIQGetTimeout(Queue *qp, t_time time) {
+msg_t chIQGetTimeout(Queue *qp, systime_t time) {
uint8_t b;
- t_msg msg;
+ msg_t msg;
chSysLock();
@@ -153,9 +153,9 @@ t_msg chIQGetTimeout(Queue *qp, t_time time) {
* @note The function is not atomic, if you need atomicity it is suggested
* to use a semaphore for mutual exclusion.
*/
-t_size chIQRead(Queue *qp, uint8_t *buffer, t_size n) {
+size_t chIQRead(Queue *qp, uint8_t *buffer, size_t n) {
- t_size r = 0;
+ size_t r = 0;
while (n--) {
chSysLock();
@@ -193,7 +193,7 @@ t_size chIQRead(Queue *qp, uint8_t *buffer, t_size n) {
* @param onotify pointer to a callback function that is invoked when
* some data is written in the Queue. The value can be \p NULL.
*/
-void chOQInit(Queue *qp, uint8_t *buffer, t_size size, t_qnotify onotify) {
+void chOQInit(Queue *qp, uint8_t *buffer, size_t size, qnotify_t onotify) {
qp->q_buffer = qp->q_rdptr = qp->q_wrptr = buffer;
qp->q_top = buffer + size;
@@ -211,7 +211,7 @@ void chOQReset(Queue *qp) {
chSysLock();
qp->q_rdptr = qp->q_wrptr = qp->q_buffer;
- chSemResetI(&qp->q_sem, (t_cnt)(qp->q_top - qp->q_buffer));
+ chSemResetI(&qp->q_sem, (cnt_t)(qp->q_top - qp->q_buffer));
chSysUnlock();
}
@@ -245,7 +245,7 @@ void chOQPut(Queue *qp, uint8_t b) {
* @note This function must be called with interrupts disabled or from an
* interrupt handler.
*/
-t_msg chOQGetI(Queue *qp) {
+msg_t chOQGetI(Queue *qp) {
uint8_t b;
if (chOQIsEmpty(qp))
@@ -268,9 +268,9 @@ t_msg chOQGetI(Queue *qp) {
* @note The function is not atomic, if you need atomicity it is suggested
* to use a semaphore for mutual exclusion.
*/
-t_size chOQWrite(Queue *qp, uint8_t *buffer, t_size n) {
+size_t chOQWrite(Queue *qp, uint8_t *buffer, size_t n) {
- t_size w = 0;
+ size_t w = 0;
while (n--) {
chSysLock();
@@ -311,8 +311,8 @@ t_size chOQWrite(Queue *qp, uint8_t *buffer, t_size n) {
* @param onotify pointer to a callback function that is invoked when
* some data is written to the queue. The value can be \p NULL.
*/
-void chHDQInit(HalfDuplexQueue *qp, uint8_t *buffer, t_size size,
- t_qnotify inotify, t_qnotify onotify) {
+void chHDQInit(HalfDuplexQueue *qp, uint8_t *buffer, size_t size,
+ qnotify_t inotify, qnotify_t onotify) {
qp->hdq_buffer = qp->hdq_rdptr = qp->hdq_wrptr = buffer;
qp->hdq_top = buffer + size;
@@ -328,7 +328,7 @@ void chHDQInit(HalfDuplexQueue *qp, uint8_t *buffer, t_size size,
* @param qp pointer to a \p HalfDuplexQueue structure
* @return the byte value or \p Q_RESET if the queue was reset
*/
-t_msg chHDQGetReceive(HalfDuplexQueue *qp) {
+msg_t chHDQGetReceive(HalfDuplexQueue *qp) {
uint8_t b;
chSysLock();
@@ -363,9 +363,9 @@ t_msg chHDQGetReceive(HalfDuplexQueue *qp) {
* @note The function is available only if the \p CH_USE_QUEUES_TIMEOUT
* option is enabled in \p chconf.h.
*/
-t_msg chHDQGetReceiveTimeout(HalfDuplexQueue *qp, t_time time) {
+msg_t chHDQGetReceiveTimeout(HalfDuplexQueue *qp, systime_t time) {
uint8_t b;
- t_msg msg;
+ msg_t msg;
chSysLock();
@@ -431,7 +431,7 @@ void chHDQPutTransmit(HalfDuplexQueue *qp, uint8_t b) {
* @note This function must be called with interrupts disabled or from an
* interrupt handler.
*/
-t_msg chHDQGetTransmitI(HalfDuplexQueue *qp) {
+msg_t chHDQGetTransmitI(HalfDuplexQueue *qp) {
uint8_t b;
if (!chHDQIsTransmitting(qp))
@@ -454,7 +454,7 @@ t_msg chHDQGetTransmitI(HalfDuplexQueue *qp) {
* @note This function must be called with interrupts disabled or from an
* interrupt handler.
*/
-t_msg chHDQPutReceiveI(HalfDuplexQueue *qp, uint8_t b) {
+msg_t chHDQPutReceiveI(HalfDuplexQueue *qp, uint8_t b) {
if (chHDQIsTransmitting(qp))
return Q_FULL;
diff --git a/src/chschd.c b/src/chschd.c
index 4f92f92ce..7a14df518 100644
--- a/src/chschd.c
+++ b/src/chschd.c
@@ -54,9 +54,9 @@ void chSchInit(void) {
*/
#ifdef CH_OPTIMIZE_SPEED
/* NOTE: it is inlined in this module only.*/
-INLINE void chSchReadyI(Thread *tp, t_msg msg) {
+INLINE void chSchReadyI(Thread *tp, msg_t msg) {
#else
-void chSchReadyI(Thread *tp, t_msg msg) {
+void chSchReadyI(Thread *tp, msg_t msg) {
#endif
Thread *cp = rlist.r_queue.p_next;
@@ -78,7 +78,7 @@ void chSchReadyI(Thread *tp, t_msg msg) {
* @note The function must be called in the system mutex zone.
* @note The function is not meant to be used in the user code directly.
*/
-void chSchGoSleepS(t_tstate newstate) {
+void chSchGoSleepS(tstate_t newstate) {
Thread *otp;
(otp = currp)->p_state = newstate;
@@ -108,7 +108,7 @@ static void wakeup(void *p) {
* @note The function must be called in the system mutex zone.
* @note The function is not meant to be used in the user code directly.
*/
-t_msg chSchGoSleepTimeoutS(t_tstate newstate, t_time time) {
+msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time) {
VirtualTimer vt;
chVTSetI(&vt, time, wakeup, currp);
@@ -130,7 +130,7 @@ t_msg chSchGoSleepTimeoutS(t_tstate newstate, t_time time) {
* @note It is equivalent to a \p chSchReadyI() followed by a
* \p chSchRescheduleS() but much more efficient.
*/
-void chSchWakeupS(Thread *ntp, t_msg msg) {
+void chSchWakeupS(Thread *ntp, msg_t msg) {
if (ntp->p_prio <= currp->p_prio)
chSchReadyI(ntp, msg);
@@ -181,7 +181,7 @@ void chSchRescheduleS(void) {
* @return \p TRUE if there is a thread that should go in running state
* immediatly else \p FALSE.
*/
-t_bool chSchRescRequiredI(void) {
+bool_t chSchRescRequiredI(void) {
if (isempty(&rlist.r_queue))
return FALSE;
diff --git a/src/chsem.c b/src/chsem.c
index 47ea2fc50..cbbac8909 100644
--- a/src/chsem.c
+++ b/src/chsem.c
@@ -31,7 +31,7 @@
* @param n initial value of the semaphore counter. Must be non-negative.
* @note Can be called with interrupts disabled or enabled.
*/
-void chSemInit(Semaphore *sp, t_cnt n) {
+void chSemInit(Semaphore *sp, cnt_t n) {
chDbgAssert(n >= 0, "chsem.c, chSemInit()");
fifo_init(&sp->s_queue);
@@ -46,7 +46,7 @@ void chSemInit(Semaphore *sp, t_cnt n) {
* instead than a signal because the \p chSemWait() will return
* \p RDY_RESET instead of \p RDY_OK.
*/
-void chSemReset(Semaphore *sp, t_cnt n) {
+void chSemReset(Semaphore *sp, cnt_t n) {
chSysLock();
@@ -65,8 +65,8 @@ void chSemReset(Semaphore *sp, t_cnt n) {
* \p RDY_RESET instead of \p RDY_OK.
* @note This function does not reschedule.
*/
-void chSemResetI(Semaphore *sp, t_cnt n) {
- t_cnt cnt;
+void chSemResetI(Semaphore *sp, cnt_t n) {
+ cnt_t cnt;
chDbgAssert(n >= 0, "chsem.c, chSemResetI()");
cnt = sp->s_cnt;
@@ -80,8 +80,8 @@ void chSemResetI(Semaphore *sp, t_cnt n) {
* @param sp pointer to a \p Semaphore structure
* @return the function can return \p RDY_OK or \p RDY_RESET.
*/
-t_msg chSemWait(Semaphore *sp) {
- t_msg msg;
+msg_t chSemWait(Semaphore *sp) {
+ msg_t msg;
chSysLock();
@@ -98,7 +98,7 @@ t_msg chSemWait(Semaphore *sp) {
* @note This function must be called with interrupts disabled.
* @note This function cannot be called by an interrupt handler.
*/
-t_msg chSemWaitS(Semaphore *sp) {
+msg_t chSemWaitS(Semaphore *sp) {
if (--sp->s_cnt < 0) {
fifo_insert(currp, &sp->s_queue);
@@ -116,8 +116,8 @@ t_msg chSemWaitS(Semaphore *sp) {
* @param time the number of ticks before the operation fails
* @return the function can return \p RDY_OK, \p RDY_TIMEOUT or \p RDY_RESET.
*/
-t_msg chSemWaitTimeout(Semaphore *sp, t_time time) {
- t_msg msg;
+msg_t chSemWaitTimeout(Semaphore *sp, systime_t time) {
+ msg_t msg;
chSysLock();
@@ -137,7 +137,7 @@ t_msg chSemWaitTimeout(Semaphore *sp, t_time time) {
* @note The function is available only if the \p CH_USE_SEMAPHORES_TIMEOUT
* option is enabled in \p chconf.h.
*/
-t_msg chSemWaitTimeoutS(Semaphore *sp, t_time time) {
+msg_t chSemWaitTimeoutS(Semaphore *sp, systime_t time) {
if (--sp->s_cnt < 0) {
fifo_insert(currp, &sp->s_queue);
diff --git a/src/chserial.c b/src/chserial.c
index 8ed682cdf..b57dc96a4 100644
--- a/src/chserial.c
+++ b/src/chserial.c
@@ -40,8 +40,8 @@
* some data is written in the Queue. The value can be \p NULL.
*/
void chFDDInit(FullDuplexDriver *sd,
- uint8_t *ib, t_size isize, t_qnotify inotify,
- uint8_t *ob, t_size osize, t_qnotify onotify) {
+ uint8_t *ib, size_t isize, qnotify_t inotify,
+ uint8_t *ob, size_t osize, qnotify_t onotify) {
chIQInit(&sd->sd_iqueue, ib, isize, inotify);
chEvtInit(&sd->sd_ievent);
@@ -74,9 +74,9 @@ void chFDDIncomingDataI(FullDuplexDriver *sd, uint8_t b) {
* queue is empty (the lower driver usually disables the interrupt
* source when this happens).
*/
-t_msg chFDDRequestDataI(FullDuplexDriver *sd) {
+msg_t chFDDRequestDataI(FullDuplexDriver *sd) {
- t_msg b = chOQGetI(&sd->sd_oqueue);
+ msg_t b = chOQGetI(&sd->sd_oqueue);
if (b < Q_OK)
chEvtSendI(&sd->sd_oevent);
return b;
@@ -88,7 +88,7 @@ t_msg chFDDRequestDataI(FullDuplexDriver *sd) {
* @param sd pointer to a \p FullDuplexDriver structure
* @param mask condition flags to be added to the mask
*/
-void chFDDAddFlagsI(FullDuplexDriver *sd, t_dflags mask) {
+void chFDDAddFlagsI(FullDuplexDriver *sd, dflags_t mask) {
sd->sd_flags |= mask;
chEvtSendI(&sd->sd_sevent);
@@ -100,8 +100,8 @@ void chFDDAddFlagsI(FullDuplexDriver *sd, t_dflags mask) {
* @return the condition flags modified since last time this function was
* invoked
*/
-t_dflags chFDDGetAndClearFlags(FullDuplexDriver *sd) {
- t_dflags mask;
+dflags_t chFDDGetAndClearFlags(FullDuplexDriver *sd) {
+ dflags_t mask;
mask = sd->sd_flags;
sd->sd_flags = SD_NO_ERROR;
@@ -122,8 +122,8 @@ t_dflags chFDDGetAndClearFlags(FullDuplexDriver *sd) {
* @param onotify pointer to a callback function that is invoked when
* some data is written in the queue. The value can be \p NULL.
*/
-void chHDDInit(HalfDuplexDriver *sd, uint8_t *b, t_size size,
- t_qnotify inotify, t_qnotify onotify) {
+void chHDDInit(HalfDuplexDriver *sd, uint8_t *b, size_t size,
+ qnotify_t inotify, qnotify_t onotify) {
chHDQInit(&sd->sd_queue, b, size, inotify, onotify);
chEvtInit(&sd->sd_ievent);
@@ -155,9 +155,9 @@ void chHDDIncomingDataI(HalfDuplexDriver *sd, uint8_t b) {
* queue is empty (the lower driver usually disables the interrupt
* source when this happens).
*/
-t_msg chHDDRequestDataI(HalfDuplexDriver *sd) {
+msg_t chHDDRequestDataI(HalfDuplexDriver *sd) {
- t_msg b = chHDQGetTransmitI(&sd->sd_queue);
+ msg_t b = chHDQGetTransmitI(&sd->sd_queue);
if (b < Q_OK)
chEvtSendI(&sd->sd_oevent);
return b;
@@ -169,7 +169,7 @@ t_msg chHDDRequestDataI(HalfDuplexDriver *sd) {
* @param sd pointer to a \p HalfDuplexDriver structure
* @param mask condition flags to be added to the mask
*/
-void chHDDAddFlagsI(HalfDuplexDriver *sd, t_dflags mask) {
+void chHDDAddFlagsI(HalfDuplexDriver *sd, dflags_t mask) {
sd->sd_flags |= mask;
chEvtSendI(&sd->sd_sevent);
@@ -181,8 +181,8 @@ void chHDDAddFlagsI(HalfDuplexDriver *sd, t_dflags mask) {
* @return the condition flags modified since last time this function was
* invoked
*/
-t_dflags chHDDGetAndClearFlags(HalfDuplexDriver *sd) {
- t_dflags mask;
+dflags_t chHDDGetAndClearFlags(HalfDuplexDriver *sd) {
+ dflags_t mask;
mask = sd->sd_flags;
sd->sd_flags = SD_NO_ERROR;
diff --git a/src/chsleep.c b/src/chsleep.c
index 9dad520c7..859333b79 100644
--- a/src/chsleep.c
+++ b/src/chsleep.c
@@ -29,7 +29,7 @@
* Suspends the invoking thread for the specified time.
* @param time the system ticks number
*/
-void chThdSleep(t_time time) {
+void chThdSleep(systime_t time) {
chSysLock();
diff --git a/src/chthreads.c b/src/chthreads.c
index 26a0cd1d9..1dcda4597 100644
--- a/src/chthreads.c
+++ b/src/chthreads.c
@@ -27,8 +27,8 @@
/*
* Initializes a thread structure.
*/
-void _InitThread(t_prio prio, t_tmode mode, Thread *tp) {
- static t_tid nextid = 0;
+void _InitThread(tprio_t prio, tmode_t mode, Thread *tp) {
+ static tid_t nextid = 0;
tp->p_tid = nextid++;
tp->p_flags = mode;
@@ -89,8 +89,8 @@ static void memfill(uint8_t *p, uint32_t n, uint8_t v) {
* @note A thread can terminate by calling \p chThdExit() or by simply
* returning from its main function.
*/
-Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace,
- t_size wsize, t_tfunc pf, void *arg) {
+Thread *chThdCreate(tprio_t prio, tmode_t mode, void *workspace,
+ size_t wsize, tfunc_t pf, void *arg) {
Thread *tp = workspace;
chDbgAssert((wsize > UserStackSize(0)) && (prio <= HIGHPRIO) &&
@@ -121,7 +121,7 @@ Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace,
* Changes the thread priority, reschedules if necessary.
* @param newprio the new priority of the invoking thread
*/
-void chThdSetPriority(t_prio newprio) {
+void chThdSetPriority(tprio_t newprio) {
chDbgAssert(newprio <= HIGHPRIO, "chthreads.c, chThdSetPriority()")
chSysLock();
@@ -211,7 +211,7 @@ void chThdTerminate(Thread *tp) {
* @param msg the thread exit code. The code can be retrieved by using
* \p chThdWait().
*/
-void chThdExit(t_msg msg) {
+void chThdExit(msg_t msg) {
chSysLock();
@@ -235,8 +235,8 @@ void chThdExit(t_msg msg) {
* @note The function is available only if the \p CH_USE_WAITEXIT
* option is enabled in \p chconf.h.
*/
-t_msg chThdWait(Thread *tp) {
- t_msg msg;
+msg_t chThdWait(Thread *tp) {
+ msg_t msg;
chSysLock();
diff --git a/src/include/ch.h b/src/include/ch.h
index 52d3dd772..4f729a450 100644
--- a/src/include/ch.h
+++ b/src/include/ch.h
@@ -100,9 +100,6 @@
#ifndef TRUE
#define TRUE 1
#endif
-#ifndef NULL
-#define NULL 0
-#endif
#ifdef __cplusplus
extern "C" {
diff --git a/src/include/debug.h b/src/include/debug.h
index 226d80dd6..f902e1ebb 100644
--- a/src/include/debug.h
+++ b/src/include/debug.h
@@ -38,13 +38,13 @@
typedef struct {
void *cse_wtobjp;
- t_time cse_time;
- UWORD16 cse_state: 4;
- UWORD16 cse_tid: 12;
+ systime_t cse_time;
+ uint16_t cse_state: 4;
+ uint16_t cse_tid: 12;
} CtxSwcEvent;
typedef struct {
- t_size tb_size;
+ size_t tb_size;
CtxSwcEvent *tb_ptr;
CtxSwcEvent tb_buffer[TRACE_BUFFER_SIZE];
} TraceBuffer;
diff --git a/src/include/delta.h b/src/include/delta.h
index 4365eb482..1f7a584f0 100644
--- a/src/include/delta.h
+++ b/src/include/delta.h
@@ -28,7 +28,7 @@
#ifdef CH_USE_VIRTUAL_TIMERS
/** Virtual Timer callback function.*/
-typedef void (*t_vtfunc)(void *);
+typedef void (*vtfunc_t)(void *);
typedef struct VirtualTimer VirtualTimer;
@@ -41,10 +41,10 @@ struct VirtualTimer {
/** Previous timer in the delta list.*/
VirtualTimer *vt_prev;
/** Time delta before timeout.*/
- t_time vt_dtime;
+ systime_t vt_dtime;
/** Timer callback function pointer. The pointer is reset to zero after
the callback is invoked.*/
- t_vtfunc vt_func;
+ vtfunc_t vt_func;
/** Timer callback function parameter.*/
void *vt_par;
};
@@ -63,7 +63,7 @@ typedef struct {
/** Last timer in the list.*/
VirtualTimer *dl_prev;
/** Not used but it must be set to /p MAXDELTA.*/
- t_time dl_dtime;
+ systime_t dl_dtime;
} DeltaList;
extern DeltaList dlist;
@@ -74,7 +74,7 @@ extern DeltaList dlist;
\
--dlist.dl_next->vt_dtime; \
while (!(vtp = dlist.dl_next)->vt_dtime) { \
- t_vtfunc fn = vtp->vt_func; \
+ vtfunc_t fn = vtp->vt_func; \
vtp->vt_func = 0; \
(vtp->vt_next->vt_prev = (VirtualTimer *)&dlist)->vt_next = vtp->vt_next; \
fn(vtp->vt_par); \
@@ -91,7 +91,7 @@ extern DeltaList dlist;
extern "C" {
#endif
void chVTInit(void);
- void chVTSetI(VirtualTimer *vtp, t_time time, t_vtfunc vtfunc, void *par);
+ void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par);
void chVTResetI(VirtualTimer *vtp);
#ifdef __cplusplus
}
diff --git a/src/include/events.h b/src/include/events.h
index 78b695910..8cfb0109f 100644
--- a/src/include/events.h
+++ b/src/include/events.h
@@ -41,7 +41,7 @@ struct EventListener {
/** Thread interested in the Event Source.*/
Thread *el_listener;
/** Event identifier associated by the thread to the Event Source.*/
- t_eventid el_id;
+ eventid_t el_id;
};
/**
@@ -74,22 +74,22 @@ typedef struct EventSource {
/** Event Handler callback function.*/
-typedef void (*t_evhandler)(t_eventid);
+typedef void (*evhandler_t)(eventid_t);
#ifdef __cplusplus
extern "C" {
#endif
- void chEvtRegister(EventSource *esp, EventListener *elp, t_eventid eid);
+ void chEvtRegister(EventSource *esp, EventListener *elp, eventid_t eid);
void chEvtUnregister(EventSource *esp, EventListener *elp);
- void chEvtClear(t_eventmask mask);
+ void chEvtClear(eventmask_t mask);
void chEvtSend(EventSource *esp);
void chEvtSendI(EventSource *esp);
- t_eventid chEvtWait(t_eventmask ewmask,
- const t_evhandler handlers[]);
+ eventid_t chEvtWait(eventmask_t ewmask,
+ const evhandler_t handlers[]);
#ifdef CH_USE_EVENTS_TIMEOUT
- t_eventid chEvtWaitTimeout(t_eventmask ewmask,
- const t_evhandler handlers[],
- t_time time);
+ eventid_t chEvtWaitTimeout(eventmask_t ewmask,
+ const evhandler_t handlers[],
+ systime_t time);
#endif
#ifdef __cplusplus
}
diff --git a/src/include/messages.h b/src/include/messages.h
index a5e88c267..ae6ae9bb3 100644
--- a/src/include/messages.h
+++ b/src/include/messages.h
@@ -42,17 +42,13 @@
#ifdef __cplusplus
extern "C" {
#endif
- t_msg chMsgSend(Thread *tp, t_msg msg);
- t_msg chMsgWait(void);
- t_msg chMsgGet(void);
- void chMsgRelease(t_msg msg);
+ msg_t chMsgSend(Thread *tp, msg_t msg);
+ msg_t chMsgWait(void);
+ msg_t chMsgGet(void);
+ void chMsgRelease(msg_t msg);
#ifdef CH_USE_MESSAGES_EVENT
- t_msg chMsgSendWithEvent(Thread *tp, t_msg msg, EventSource *esp);
-#endif
-
-#ifdef CH_USE_MESSAGES_TIMEOUT
- t_msg chMsgSendTimeout(Thread *tp, t_msg msg, t_time time);
+ msg_t chMsgSendWithEvent(Thread *tp, msg_t msg, EventSource *esp);
#endif
#ifdef __cplusplus
}
diff --git a/src/include/mutexes.h b/src/include/mutexes.h
index 022e62dea..9e9c704cc 100644
--- a/src/include/mutexes.h
+++ b/src/include/mutexes.h
@@ -44,8 +44,8 @@ extern "C" {
void chMtxInit(Mutex *mp);
void chMtxLock(Mutex *mp);
void chMtxLockS(Mutex *mp);
- t_bool chMtxTryLock(Mutex *mp);
- t_bool chMtxTryLockS(Mutex *mp);
+ bool_t chMtxTryLock(Mutex *mp);
+ bool_t chMtxTryLockS(Mutex *mp);
void chMtxUnlock(void);
void chMtxUnlockS(void);
void chMtxUnlockAll(void);
diff --git a/src/include/queues.h b/src/include/queues.h
index a28539fd5..5c480e8cf 100644
--- a/src/include/queues.h
+++ b/src/include/queues.h
@@ -26,7 +26,7 @@
#define _QUEUES_H_
/** Queue notification callback type.*/
-typedef void (*t_qnotify)(void);
+typedef void (*qnotify_t)(void);
/** Returned by the queue functions if the operation is successful.*/
#define Q_OK RDY_OK
@@ -56,7 +56,7 @@ typedef struct {
/** Counter semaphore.*/
Semaphore q_sem;
/** Data notification callback.*/
- t_qnotify q_notify;
+ qnotify_t q_notify;
} Queue;
/** Returns the queue's buffer size.*/
@@ -91,24 +91,24 @@ extern "C" {
* Input Queues functions. An Input Queue is usually written into by an
* interrupt handler and read from a thread.
*/
- void chIQInit(Queue *qp, uint8_t *buffer, t_size size, t_qnotify inotify);
+ void chIQInit(Queue *qp, uint8_t *buffer, size_t size, qnotify_t inotify);
void chIQReset(Queue *qp);
- t_msg chIQPutI(Queue *qp, uint8_t b);
- t_msg chIQGet(Queue *qp);
- t_size chIQRead(Queue *qp, uint8_t *buffer, t_size n);
+ msg_t chIQPutI(Queue *qp, uint8_t b);
+ msg_t chIQGet(Queue *qp);
+ size_t chIQRead(Queue *qp, uint8_t *buffer, size_t n);
#ifdef CH_USE_QUEUES_TIMEOUT
- t_msg chIQGetTimeout(Queue *qp, t_time time);
+ msg_t chIQGetTimeout(Queue *qp, systime_t time);
#endif
/*
* Output Queues functions. An Output Queue is usually written into by a
* thread and read from an interrupt handler.
*/
- void chOQInit(Queue *queue, uint8_t *buffer, t_size size, t_qnotify onotify);
+ void chOQInit(Queue *queue, uint8_t *buffer, size_t size, qnotify_t onotify);
void chOQReset(Queue *queue);
void chOQPut(Queue *queue, uint8_t b);
- t_msg chOQGetI(Queue *queue);
- t_size chOQWrite(Queue *queue, uint8_t *buffer, t_size n);
+ msg_t chOQGetI(Queue *queue);
+ size_t chOQWrite(Queue *queue, uint8_t *buffer, size_t n);
#ifdef __cplusplus
}
#endif
@@ -132,9 +132,9 @@ typedef struct {
/** Output counter semaphore.*/
Semaphore hdq_osem;
/** Input data notification callback.*/
- t_qnotify hdq_inotify;
+ qnotify_t hdq_inotify;
/** Output data notification callback.*/
- t_qnotify hdq_onotify;
+ qnotify_t hdq_onotify;
} HalfDuplexQueue;
/** Returns the queue's buffer size.*/
@@ -164,14 +164,14 @@ typedef struct {
#ifdef __cplusplus
extern "C" {
#endif
- void chHDQInit(HalfDuplexQueue *qp, uint8_t *buffer, t_size size,
- t_qnotify inotify, t_qnotify onotify);
- t_msg chHDQGetReceive(HalfDuplexQueue *qp);
+ void chHDQInit(HalfDuplexQueue *qp, uint8_t *buffer, size_t size,
+ qnotify_t inotify, qnotify_t onotify);
+ msg_t chHDQGetReceive(HalfDuplexQueue *qp);
void chHDQPutTransmit(HalfDuplexQueue *qp, uint8_t b);
- t_msg chHDQGetTransmitI(HalfDuplexQueue *qp);
- t_msg chHDQPutReceiveI(HalfDuplexQueue *qp, uint8_t b);
+ msg_t chHDQGetTransmitI(HalfDuplexQueue *qp);
+ msg_t chHDQPutReceiveI(HalfDuplexQueue *qp, uint8_t b);
#ifdef CH_USE_QUEUES_TIMEOUT
- t_msg chHDQGetReceiveTimeout(HalfDuplexQueue *qp, t_time time);
+ msg_t chHDQGetReceiveTimeout(HalfDuplexQueue *qp, systime_t time);
#endif
#ifdef __cplusplus
}
diff --git a/src/include/scheduler.h b/src/include/scheduler.h
index f238002a1..0cd4bff7a 100644
--- a/src/include/scheduler.h
+++ b/src/include/scheduler.h
@@ -39,13 +39,13 @@
*/
typedef struct {
ThreadsQueue r_queue;
- t_prio r_prio;
- t_cnt r_preempt;
+ tprio_t r_prio;
+ cnt_t r_preempt;
#ifndef CH_CURRP_REGISTER_CACHE
Thread *r_current;
#endif
#ifdef CH_USE_SYSTEMTIME
- volatile t_time r_stime;
+ volatile systime_t r_stime;
#endif
} ReadyList;
@@ -58,13 +58,13 @@ extern ReadyList rlist;
extern "C" {
#endif
void chSchInit(void);
- void chSchReadyI(Thread *tp, t_msg msg);
- void chSchGoSleepS(t_tstate newstate);
- t_msg chSchGoSleepTimeoutS(t_tstate newstate, t_time time);
- void chSchWakeupS(Thread *tp, t_msg msg);
+ void chSchReadyI(Thread *tp, msg_t msg);
+ void chSchGoSleepS(tstate_t newstate);
+ msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time);
+ void chSchWakeupS(Thread *tp, msg_t msg);
void chSchDoRescheduleI(void);
void chSchRescheduleS(void);
- t_bool chSchRescRequiredI(void);
+ bool_t chSchRescRequiredI(void);
#ifdef __cplusplus
}
#endif
diff --git a/src/include/semaphores.h b/src/include/semaphores.h
index 0457da81d..c894629a4 100644
--- a/src/include/semaphores.h
+++ b/src/include/semaphores.h
@@ -34,20 +34,20 @@ typedef struct {
/** Queue of the threads sleeping on this Semaphore.*/
ThreadsQueue s_queue;
/** The Semaphore counter.*/
- t_cnt s_cnt;
+ cnt_t s_cnt;
} Semaphore;
#ifdef __cplusplus
extern "C" {
#endif
- void chSemInit(Semaphore *sp, t_cnt n);
- void chSemReset(Semaphore *sp, t_cnt n);
- void chSemResetI(Semaphore *sp, t_cnt n);
- t_msg chSemWait(Semaphore *sp);
- t_msg chSemWaitS(Semaphore *sp);
+ void chSemInit(Semaphore *sp, cnt_t n);
+ void chSemReset(Semaphore *sp, cnt_t n);
+ void chSemResetI(Semaphore *sp, cnt_t n);
+ msg_t chSemWait(Semaphore *sp);
+ msg_t chSemWaitS(Semaphore *sp);
#ifdef CH_USE_SEMAPHORES_TIMEOUT
- t_msg chSemWaitTimeout(Semaphore *sp, t_time time);
- t_msg chSemWaitTimeoutS(Semaphore *sp, t_time time);
+ msg_t chSemWaitTimeout(Semaphore *sp, systime_t time);
+ msg_t chSemWaitTimeoutS(Semaphore *sp, systime_t time);
#endif
void chSemSignal(Semaphore *sp);
void chSemSignalI(Semaphore *sp);
diff --git a/src/include/serial.h b/src/include/serial.h
index 4edef1e19..4b7b02b7c 100644
--- a/src/include/serial.h
+++ b/src/include/serial.h
@@ -41,7 +41,7 @@
#define SD_BREAK_DETECTED 32
/** Serial Driver condition flags type.*/
-typedef uint16_t t_dflags;
+typedef uint16_t dflags_t;
#ifdef CH_USE_SERIAL_FULLDUPLEX
@@ -66,7 +66,7 @@ typedef struct {
/** I/O driver status flags. This field should not be read directly but
* the \p chFDDGetAndClearFlags() funtion should be used instead.*/
- t_dflags sd_flags;
+ dflags_t sd_flags;
/** Status Change \p EventSource. This event is generated when a
* condition flag was changed.*/
EventSource sd_sevent;
@@ -76,12 +76,12 @@ typedef struct {
extern "C" {
#endif
void chFDDInit(FullDuplexDriver *sd,
- uint8_t *ib, t_size isize, t_qnotify inotify,
- uint8_t *ob, t_size osize, t_qnotify onotify);
+ uint8_t *ib, size_t isize, qnotify_t inotify,
+ uint8_t *ob, size_t osize, qnotify_t onotify);
void chFDDIncomingDataI(FullDuplexDriver *sd, uint8_t b);
- t_msg chFDDRequestDataI(FullDuplexDriver *sd);
- void chFDDAddFlagsI(FullDuplexDriver *sd, t_dflags mask);
- t_dflags chFDDGetAndClearFlags(FullDuplexDriver *sd);
+ msg_t chFDDRequestDataI(FullDuplexDriver *sd);
+ void chFDDAddFlagsI(FullDuplexDriver *sd, dflags_t mask);
+ dflags_t chFDDGetAndClearFlags(FullDuplexDriver *sd);
#ifdef __cplusplus
}
#endif
@@ -128,7 +128,7 @@ typedef struct {
/** I/O driver status flags. This field should not be read directly but
* the \p chHDDGetAndClearFlags() funtion should be used
* instead.*/
- t_dflags sd_flags;
+ dflags_t sd_flags;
/** Status Change Event Source. This event is generated when a condition
* flag was changed.*/
EventSource sd_sevent;
@@ -137,12 +137,12 @@ typedef struct {
#ifdef __cplusplus
extern "C" {
#endif
- void chHDDInit(HalfDuplexDriver *sd, uint8_t *b, t_size size,
- t_qnotify inotify, t_qnotify onotify);
+ void chHDDInit(HalfDuplexDriver *sd, uint8_t *b, size_t size,
+ qnotify_t inotify, qnotify_t onotify);
void chHDDIncomingDataI(HalfDuplexDriver *sd, uint8_t b);
- t_msg chHDDRequestDataI(HalfDuplexDriver *sd);
- void chHDDAddFlagsI(HalfDuplexDriver *sd, t_dflags mask);
- t_dflags chHDDGetAndClearFlags(HalfDuplexDriver *sd);
+ msg_t chHDDRequestDataI(HalfDuplexDriver *sd);
+ void chHDDAddFlagsI(HalfDuplexDriver *sd, dflags_t mask);
+ dflags_t chHDDGetAndClearFlags(HalfDuplexDriver *sd);
#ifdef __cplusplus
}
#endif
diff --git a/src/include/sleep.h b/src/include/sleep.h
index 022b7be23..808fbc560 100644
--- a/src/include/sleep.h
+++ b/src/include/sleep.h
@@ -29,7 +29,7 @@
extern "C" {
#endif
#ifdef CH_USE_SLEEP
- void chThdSleep(t_time time);
+ void chThdSleep(systime_t time);
#endif /* CH_USE_SLEEP */
#ifdef __cplusplus
}
@@ -55,7 +55,7 @@ extern "C" {
#define chThdSleepUntil(t) { \
chSysLock(); \
chSchGoSleepTimeoutS(PRSLEEP, \
- (t_time)((t) - chSysGetTime())) \
+ (systime_t)((t) - chSysGetTime())) \
chSysUnlock(); \
}
#endif /* CH_USE_SYSTEMTIME */
diff --git a/src/include/threads.h b/src/include/threads.h
index a0c2189da..11674b322 100644
--- a/src/include/threads.h
+++ b/src/include/threads.h
@@ -39,14 +39,14 @@ struct Thread {
Thread *p_prev;
/* End of the fields shared with the ThreadsQueue structure. */
/** The thread priority.*/
- t_prio p_prio;
+ tprio_t p_prio;
/* End of the fields shared with the ReadyList structure. */
/** Thread identifier. */
- t_tid p_tid;
+ tid_t p_tid;
/** Current thread state.*/
- t_tstate p_state;
+ tstate_t p_state;
/** Mode flags.*/
- t_tmode p_flags;
+ tmode_t p_flags;
/** Machine dependent processor context.*/
Context p_ctx;
/*
@@ -56,9 +56,9 @@ struct Thread {
*/
union {
/** Thread wakeup code (only valid when exiting the \p PRREADY state).*/
- t_msg p_rdymsg;
+ msg_t p_rdymsg;
/** The thread exit code (only while in \p PREXIT state).*/
- t_msg p_exitcode;
+ msg_t p_exitcode;
#ifdef CH_USE_SEMAPHORES
/** Semaphore where the thread is waiting on (only in \p PRWTSEM state).*/
Semaphore *p_wtsemp;
@@ -73,7 +73,7 @@ struct Thread {
#endif
#ifdef CH_USE_EVENTS
/** Enabled events mask (only while in \p PRWTEVENT state).*/
- t_eventmask p_ewmask;
+ eventmask_t p_ewmask;
#endif
#ifdef CH_USE_TRACE
/** Kernel object where the thread is waiting on. It is only valid when
@@ -94,16 +94,16 @@ struct Thread {
#endif
#ifdef CH_USE_MESSAGES
ThreadsQueue p_msgqueue;
- t_msg p_msg;
+ msg_t p_msg;
#endif
#ifdef CH_USE_EVENTS
/** Pending events mask.*/
- t_eventmask p_epending;
+ eventmask_t p_epending;
#endif
#ifdef CH_USE_MUTEXES
/** Owner mutexes list, \p NULL terminated.*/
Mutex *p_mtxlist;
- t_prio p_realprio;
+ tprio_t p_realprio;
#endif
};
@@ -159,10 +159,10 @@ struct Thread {
#define ABSPRIO 255
/* Not an API, don't use into the application code.*/
-void _InitThread(t_prio prio, t_tmode mode, Thread *tp);
+void _InitThread(tprio_t prio, tmode_t mode, Thread *tp);
/** Thread function.*/
-typedef t_msg (*t_tfunc)(void *);
+typedef msg_t (*tfunc_t)(void *);
/*
* Threads APIs.
@@ -170,10 +170,10 @@ typedef t_msg (*t_tfunc)(void *);
#ifdef __cplusplus
extern "C" {
#endif
- Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace,
- t_size wsize, t_tfunc pf, void *arg);
- void chThdSetPriority(t_prio newprio);
- void chThdExit(t_msg msg);
+ Thread *chThdCreate(tprio_t prio, tmode_t mode, void *workspace,
+ size_t wsize, tfunc_t pf, void *arg);
+ void chThdSetPriority(tprio_t newprio);
+ void chThdExit(msg_t msg);
#ifdef CH_USE_RESUME
void chThdResume(Thread *tp);
#endif
@@ -184,7 +184,7 @@ extern "C" {
void chThdTerminate(Thread *tp);
#endif
#ifdef CH_USE_WAITEXIT
- t_msg chThdWait(Thread *tp);
+ msg_t chThdWait(Thread *tp);
#endif
#ifdef __cplusplus
}
diff --git a/src/lib/evtimer.h b/src/lib/evtimer.h
index 5999563d1..7b2e01c6d 100644
--- a/src/lib/evtimer.h
+++ b/src/lib/evtimer.h
@@ -31,7 +31,7 @@
typedef struct {
VirtualTimer et_vt;
EventSource et_es;
- t_time et_interval;
+ systime_t et_interval;
} EvTimer;
#ifdef __cplusplus
diff --git a/src/templates/chtypes.h b/src/templates/chtypes.h
index 08753dc3d..1c4004c6d 100644
--- a/src/templates/chtypes.h
+++ b/src/templates/chtypes.h
@@ -25,21 +25,24 @@
#ifndef _CHTYPES_H_
#define _CHTYPES_H_
+#define __need_NULL
+#define __need_size_t
+#include <stddef.h>
+
#if !defined(_STDINT_H) && !defined(__STDINT_H_)
#include <stdint.h>
#endif
-typedef int8_t bool_t;
-typedef uint8_t t_tmode; /* Thread mode flags, BYTE8 is ok. */
-typedef uint8_t t_tstate; /* Thread state, BYTE8 is ok. */
-typedef uint16_t t_tid; /* Thread id. */
-typedef uint32_t t_prio; /* Priority, use the fastest unsigned type. */
-typedef int32_t t_msg; /* Message, use signed pointer equivalent.*/
-typedef int32_t t_eventid; /* Event Id, use fastest signed.*/
-typedef uint32_t t_eventmask;/* Event Mask, recommended fastest unsigned.*/
-typedef uint32_t t_time; /* Time, recommended fastest unsigned.*/
-typedef int32_t t_cnt; /* Counter, recommended fastest signed.*/
-typedef uint32_t t_size; /* Size, use unsigned pointer equivalent.*/
+typedef int8_t bool_t; /* Signed byte boolean. */
+typedef uint8_t tmode_t; /* Thread mode flags, BYTE8 is ok. */
+typedef uint8_t tstate_t; /* Thread state, BYTE8 is ok. */
+typedef uint16_t tid_t; /* Thread id. */
+typedef uint32_t tprio_t; /* Priority, use the fastest unsigned type. */
+typedef int32_t msg_t; /* Message, use signed pointer equivalent.*/
+typedef int32_t eventid_t; /* Event Id, use fastest signed.*/
+typedef uint32_t eventmask_t;/* Event Mask, recommended fastest unsigned.*/
+typedef uint32_t systime_t; /* System Time, recommended fastest unsigned.*/
+typedef int32_t cnt_t; /* Counter, recommended fastest signed.*/
#define INLINE inline
diff --git a/test/test.c b/test/test.c
index 097406620..4a714931d 100644
--- a/test/test.c
+++ b/test/test.c
@@ -79,9 +79,9 @@ static void println(char *msgp) {
}
__attribute__((noinline))
-void CPU(t_time ms) {
+void CPU(systime_t ms) {
- t_time time = chSysGetTime() + ms;
+ systime_t time = chSysGetTime() + ms;
while (chSysGetTime() != time) {
#if defined(WIN32)
ChkIntSources();
@@ -90,9 +90,9 @@ void CPU(t_time ms) {
}
__attribute__((noinline))
-t_time wait_tick(void) {
+systime_t wait_tick(void) {
- t_time time = chSysGetTime() + 1;
+ systime_t time = chSysGetTime() + 1;
while (chSysGetTime() < time) {
#if defined(WIN32)
ChkIntSources();
@@ -101,20 +101,20 @@ t_time wait_tick(void) {
return time;
}
-t_msg Thread1(void *p) {
+msg_t Thread1(void *p) {
chFDDPut(comp, *(uint8_t *)p);
return 0;
}
-t_msg Thread2(void *p) {
+msg_t Thread2(void *p) {
chSemWait(&sem1);
chFDDPut(comp, *(uint8_t *)p);
return 0;
}
-t_msg Thread3(void *p) {
+msg_t Thread3(void *p) {
chMtxLock(&m1);
chFDDPut(comp, *(uint8_t *)p);
@@ -122,8 +122,8 @@ t_msg Thread3(void *p) {
return 0;
}
-t_msg Thread4(void *p) {
- t_msg msg;
+msg_t Thread4(void *p) {
+ msg_t msg;
int i;
for (i = 0; i < 5; i++) {
@@ -134,14 +134,14 @@ t_msg Thread4(void *p) {
return 0;
}
-t_msg Thread6(void *p) {
+msg_t Thread6(void *p) {
while (!chThdShouldTerminate())
chMsgRelease(chMsgWait() + 1);
return 0;
}
-t_msg Thread7(void *p) {
+msg_t Thread7(void *p) {
return (unsigned int)p + 1;
}
@@ -215,7 +215,7 @@ void testmtx1(void) {
println("");
}
-t_msg Thread8(void *p) {
+msg_t Thread8(void *p) {
chThdSleep(5);
chMtxLock(&m1);
@@ -224,7 +224,7 @@ t_msg Thread8(void *p) {
return 0;
}
-t_msg Thread9(void *p) {
+msg_t Thread9(void *p) {
chMtxLock(&m1);
chThdSleep(20);
@@ -233,7 +233,7 @@ t_msg Thread9(void *p) {
return 0;
}
-t_msg Thread10(void *p) {
+msg_t Thread10(void *p) {
chThdSleep(10);
CPU(50);
@@ -241,7 +241,7 @@ t_msg Thread10(void *p) {
return 0;
}
-t_msg Thread11(void *p) {
+msg_t Thread11(void *p) {
chThdSleep(5);
chSemWait(&sem1);
@@ -250,7 +250,7 @@ t_msg Thread11(void *p) {
return 0;
}
-t_msg Thread12(void *p) {
+msg_t Thread12(void *p) {
chSemWait(&sem1);
chThdSleep(20);
@@ -291,7 +291,7 @@ void testmtx3(void) {
println("");
}
-t_msg Thread13(void *p) {
+msg_t Thread13(void *p) {
chMtxLock(&m1);
CPU(50);
@@ -300,7 +300,7 @@ t_msg Thread13(void *p) {
return 0;
}
-t_msg Thread14(void *p) {
+msg_t Thread14(void *p) {
chThdSleep(10);
chMtxLock(&m2);
@@ -314,7 +314,7 @@ t_msg Thread14(void *p) {
return 0;
}
-t_msg Thread15(void *p) {
+msg_t Thread15(void *p) {
chThdSleep(20);
chMtxLock(&m2);
@@ -324,7 +324,7 @@ t_msg Thread15(void *p) {
return 0;
}
-t_msg Thread16(void *p) {
+msg_t Thread16(void *p) {
chThdSleep(40);
CPU(200);
@@ -332,7 +332,7 @@ t_msg Thread16(void *p) {
return 0;
}
-t_msg Thread17(void *p) {
+msg_t Thread17(void *p) {
chThdSleep(50);
chMtxLock(&m2);
@@ -365,7 +365,7 @@ void testmtx4(void) {
}
void testmsg1(void) {
- t_msg msg;
+ msg_t msg;
println("*** Messages, dispatch test, you should read AABBCCDDEE:");
t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread4, chThdSelf());
@@ -382,7 +382,7 @@ __attribute__((noinline))
unsigned int msg_loop_test(Thread *tp) {
unsigned int i;
- t_time time = wait_tick() + 1000;
+ systime_t time = wait_tick() + 1000;
i = 0;
while (chSysGetTime() < time) {
i = chMsgSend(tp, i);
@@ -461,7 +461,7 @@ chMsgSend(t1, 0);
__attribute__((noinline))
void bench4(void) {
unsigned int i;
- t_time time;
+ systime_t time;
println("*** Kernel Benchmark, threads creation/termination:");
time = wait_tick() + 1000;
@@ -483,7 +483,7 @@ void bench5(void) {
static uint8_t ib[16];
static Queue iq;
unsigned int i;
- t_time time;
+ systime_t time;
println("*** Kernel Benchmark, I/O Queues throughput:");
chIQInit(&iq, ib, sizeof(ib), NULL);
@@ -511,7 +511,7 @@ void bench5(void) {
/**
* Tester thread, this thread must be created with priority \p NORMALPRIO.
*/
-t_msg TestThread(void *p) {
+msg_t TestThread(void *p) {
comp = p;
println("*****************************");