git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@215 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2008-03-05 10:59:11 +00:00
parent 0778745ee1
commit 5e64a9fec2
47 changed files with 343 additions and 332 deletions

View File

@ -23,7 +23,7 @@
#include "sam7x_serial.h" #include "sam7x_serial.h"
static WorkingArea(waThread1, 64); static WorkingArea(waThread1, 64);
static t_msg Thread1(void *arg) { static msg_t Thread1(void *arg) {
while (TRUE) { while (TRUE) {
AT91C_BASE_PIOB->PIO_SODR = PIOB_LCD_BL; // LCD on. 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. * Entry point, the interrupts are disabled on entry.
*/ */
int main(int argc, char **argv) { 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 * The main() function becomes a thread here then the interrupts are

View File

@ -25,7 +25,7 @@
* Red LEDs blinker thread, times are in milliseconds. * Red LEDs blinker thread, times are in milliseconds.
*/ */
static WorkingArea(waThread1, 64); static WorkingArea(waThread1, 64);
static t_msg Thread1(void *arg) { static msg_t Thread1(void *arg) {
while (TRUE) { while (TRUE) {
IO0CLR = 0x00000800; IO0CLR = 0x00000800;
@ -44,7 +44,7 @@ static t_msg Thread1(void *arg) {
* Yellow LED blinker thread, times are in milliseconds. * Yellow LED blinker thread, times are in milliseconds.
*/ */
static WorkingArea(waThread2, 64); static WorkingArea(waThread2, 64);
static t_msg Thread2(void *arg) { static msg_t Thread2(void *arg) {
while (TRUE) { while (TRUE) {
IO0CLR = 0x80000000; IO0CLR = 0x80000000;

View File

@ -64,7 +64,7 @@ static void stop(void *p) {
chEvtSendI(&BuzzerSilentEventSource); chEvtSendI(&BuzzerSilentEventSource);
} }
void PlaySound(int freq, t_time duration) { void PlaySound(int freq, systime_t duration) {
static VirtualTimer bvt; static VirtualTimer bvt;
TC *tc = T1Base; TC *tc = T1Base;
@ -82,7 +82,7 @@ void PlaySound(int freq, t_time duration) {
chSysUnlock(); chSysUnlock();
} }
void PlaySoundWait(int freq, t_time duration) { void PlaySoundWait(int freq, systime_t duration) {
TC *tc = T1Base; TC *tc = T1Base;
StopCounter(tc); StopCounter(tc);

View File

@ -24,8 +24,8 @@
extern "C" { extern "C" {
#endif #endif
void InitBuzzer(void); void InitBuzzer(void);
void PlaySound(int freq, t_time duration); void PlaySound(int freq, systime_t duration);
void PlaySoundWait(int freq, t_time duration); void PlaySoundWait(int freq, systime_t duration);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -29,7 +29,7 @@
* Red LEDs blinker thread, times are in milliseconds. * Red LEDs blinker thread, times are in milliseconds.
*/ */
static WorkingArea(waThread1, 64); static WorkingArea(waThread1, 64);
static t_msg Thread1(void *arg) { static msg_t Thread1(void *arg) {
while (TRUE) { while (TRUE) {
IO0CLR = 0x00000800; IO0CLR = 0x00000800;
@ -48,7 +48,7 @@ static t_msg Thread1(void *arg) {
* Yellow LED blinker thread, times are in milliseconds. * Yellow LED blinker thread, times are in milliseconds.
*/ */
static WorkingArea(waThread2, 64); static WorkingArea(waThread2, 64);
static t_msg Thread2(void *arg) { static msg_t Thread2(void *arg) {
while (TRUE) { while (TRUE) {
IO0CLR = 0x80000000; IO0CLR = 0x80000000;
@ -62,8 +62,8 @@ static t_msg Thread2(void *arg) {
/* /*
* Executed as event handler at 500mS intervals. * Executed as event handler at 500mS intervals.
*/ */
static void TimerHandler(t_eventid id) { static void TimerHandler(eventid_t id) {
t_msg TestThread(void *p); msg_t TestThread(void *p);
if (!(IO0PIN & 0x00018000)) { // Both buttons if (!(IO0PIN & 0x00018000)) { // Both buttons
TestThread(&COM1); 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 * Plays sounds when a MMC/SD card is inserted, then initializes the MMC
* driver and reads a sector. * driver and reads a sector.
*/ */
static void InsertHandler(t_eventid id) { static void InsertHandler(eventid_t id) {
static uint8_t rwbuf[512]; static uint8_t rwbuf[512];
MMCCSD data; MMCCSD data;
@ -102,7 +102,7 @@ static void InsertHandler(t_eventid id) {
/* /*
* Plays sounds when a MMC/SD card is removed. * 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(2000, 100);
PlaySoundWait(1000, 100); PlaySoundWait(1000, 100);
@ -112,7 +112,7 @@ static void RemoveHandler(t_eventid id) {
* Entry point, the interrupts are disabled on entry. * Entry point, the interrupts are disabled on entry.
*/ */
int main(int argc, char **argv) { int main(int argc, char **argv) {
static const t_evhandler evhndl[] = { static const evhandler_t evhndl[] = {
TimerHandler, TimerHandler,
InsertHandler, InsertHandler,
RemoveHandler RemoveHandler

View File

@ -91,7 +91,7 @@ void mmcStopPolling(void) {
/* /*
* Returns TRUE if the card is safely inserted in the reader. * Returns TRUE if the card is safely inserted in the reader.
*/ */
t_bool mmcCardInserted (void) { bool_t mmcCardInserted (void) {
return cnt == 0; return cnt == 0;
} }
@ -145,7 +145,7 @@ static uint8_t recvr1(void) {
return 0xFF; /* Timeout.*/ 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; int i;
for (i = 0; i < MMC_WAIT_DATA; 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. * 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. * 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 * @param data the pointer to a \p MMCCSD structure
* @return \p TRUE if an error happened * @return \p TRUE if an error happened
*/ */
t_bool mmcGetSize(MMCCSD *data) { bool_t mmcGetSize(MMCCSD *data) {
uint8_t buf[16]; uint8_t buf[16];
sspAcquireBus(); sspAcquireBus();
@ -250,7 +250,7 @@ t_bool mmcGetSize(MMCCSD *data) {
* @param buf the pointer to the read buffer * @param buf the pointer to the read buffer
* @return \p TRUE if an error happened * @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(); sspAcquireBus();
sendhdr(CMDREAD, blknum << 8); 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 * @param buf the pointer to the read buffer
* @return \p TRUE if an error happened * @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}; static const uint8_t stopcmd[] = {0x40 | CMDSTOP, 0, 0, 0, 0, 1, 0xFF};
sspAcquireBus(); 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 * the card, this allows to not make useless busy waiting. The invoking
* thread can do other things while the data is being written. * 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}; static const uint8_t start[] = {0xFF, 0xFE};
uint8_t b[4]; 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 * the card, this allows to not make useless busy waiting. The invoking
* thread can do other things while the data is being written. * 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}, static const uint8_t start[] = {0xFF, 0xFC},
stop[] = {0xFD, 0xFF}; stop[] = {0xFD, 0xFF};
uint8_t b[4]; uint8_t b[4];

View File

@ -48,16 +48,16 @@ extern EventSource MMCInsertEventSource, MMCRemoveEventSource;
#endif #endif
void InitMMC(void); void InitMMC(void);
t_bool mmcInit(void); bool_t mmcInit(void);
void mmcStartPolling(void); void mmcStartPolling(void);
void mmcStopPolling(void); void mmcStopPolling(void);
t_bool mmcCardInserted (void); bool_t mmcCardInserted (void);
uint8_t mmcSendCommand(uint8_t cmd, uint32_t arg); uint8_t mmcSendCommand(uint8_t cmd, uint32_t arg);
t_bool mmcGetSize(MMCCSD *data); bool_t mmcGetSize(MMCCSD *data);
t_bool mmcRead(uint8_t *buf, uint32_t blknum); bool_t mmcRead(uint8_t *buf, uint32_t blknum);
t_bool mmcReadMultiple(uint8_t *buf, uint32_t blknum, uint32_t n); bool_t mmcReadMultiple(uint8_t *buf, uint32_t blknum, uint32_t n);
t_bool mmcWrite(uint8_t *buf, uint32_t blknum); bool_t mmcWrite(uint8_t *buf, uint32_t blknum);
t_bool mmcWriteMultiple(uint8_t *buf, uint32_t blknum, uint32_t n); bool_t mmcWriteMultiple(uint8_t *buf, uint32_t blknum, uint32_t n);
void mmcSynch(void); void mmcSynch(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -26,7 +26,7 @@
void hwinit(void); void hwinit(void);
static WorkingArea(waThread1, 32); static WorkingArea(waThread1, 32);
static t_msg Thread1(void *arg) { static msg_t Thread1(void *arg) {
while (TRUE) { while (TRUE) {
PORTA ^= PORTA_RELAY; PORTA ^= PORTA_RELAY;

View File

@ -91,7 +91,7 @@ void ChkIntSources(void) {
} }
} }
t_msg _IdleThread(void *p) { msg_t _IdleThread(void *p) {
while (TRUE) { while (TRUE) {

View File

@ -73,7 +73,7 @@ typedef struct {
#define WorkingArea(s, n) uint32_t s[UserStackSize(n) >> 2]; #define WorkingArea(s, n) uint32_t s[UserStackSize(n) >> 2];
#define IDLE_THREAD_STACK_SIZE 16384 #define IDLE_THREAD_STACK_SIZE 16384
t_msg _IdleThread(void *p); msg_t _IdleThread(void *p);
__attribute__((fastcall)) void chSysHalt(void); __attribute__((fastcall)) void chSysHalt(void);
__attribute__((fastcall)) void chSysSwitchI(Thread *otp, Thread *ntp); __attribute__((fastcall)) void chSysSwitchI(Thread *otp, Thread *ntp);

View File

@ -20,21 +20,24 @@
#ifndef _CHTYPES_H_ #ifndef _CHTYPES_H_
#define _CHTYPES_H_ #define _CHTYPES_H_
#define __need_NULL
#define __need_size_t
#include <stddef.h>
#if !defined(_STDINT_H) && !defined(__STDINT_H_) #if !defined(_STDINT_H) && !defined(__STDINT_H_)
#include <stdint.h> #include <stdint.h>
#endif #endif
typedef int8_t t_bool; typedef int8_t bool_t;
typedef uint8_t t_tmode; typedef uint8_t tmode_t;
typedef uint8_t t_tstate; typedef uint8_t tstate_t;
typedef uint16_t t_tid; typedef uint16_t tid_t;
typedef uint32_t t_prio; typedef uint32_t tprio_t;
typedef int32_t t_msg; typedef int32_t msg_t;
typedef int32_t t_eventid; typedef int32_t eventid_t;
typedef uint32_t t_eventmask; typedef uint32_t eventmask_t;
typedef uint32_t t_time; typedef uint32_t systime_t;
typedef int32_t t_cnt; typedef int32_t cnt_t;
typedef uint32_t t_size;
#define INLINE inline #define INLINE inline

View File

@ -29,21 +29,21 @@ static uint32_t cdguard;
static WorkingArea(cdarea, 2048); static WorkingArea(cdarea, 2048);
static Thread *cdtp; static Thread *cdtp;
static t_msg WatchdogThread(void *arg); static msg_t WatchdogThread(void *arg);
static t_msg ConsoleThread(void *arg); static msg_t ConsoleThread(void *arg);
t_msg TestThread(void *p); msg_t TestThread(void *p);
void InitCore(void); void InitCore(void);
extern FullDuplexDriver COM1, COM2; 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 * Watchdog thread, it checks magic values located under the various stack
* areas. The system is halted if something is wrong. * areas. The system is halted if something is wrong.
*/ */
static t_msg WatchdogThread(void *arg) { static msg_t WatchdogThread(void *arg) {
wdguard = 0xA51F2E3D; wdguard = 0xA51F2E3D;
cdguard = 0xA51F2E3D; cdguard = 0xA51F2E3D;
while (TRUE) { 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. * to the C printf() thread safe and the print operation atomic among threads.
* In this example the message is the zero termitated string itself. * 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()) { while (!chThdShouldTerminate()) {
printf((char *)chMsgWait()); printf((char *)chMsgWait());
@ -78,7 +78,7 @@ static void PrintLineFDD(FullDuplexDriver *sd, char *msg) {
chFDDPut(sd, *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; char *p = line;
while (TRUE) { 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 * Example thread, not much to see here. It simulates the CTRL-C but there
* are no real signals involved. * are no real signals involved.
*/ */
static t_msg HelloWorldThread(void *arg) { static msg_t HelloWorldThread(void *arg) {
int i; int i;
short c; short c;
FullDuplexDriver *sd = (FullDuplexDriver *)arg; FullDuplexDriver *sd = (FullDuplexDriver *)arg;
@ -140,7 +140,7 @@ static t_msg HelloWorldThread(void *arg) {
return 0; 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.*/ char * lp = strtok(NULL, " \009"); /* It is not thread safe but this is a demo.*/
if (lp) { if (lp) {
@ -155,7 +155,7 @@ static t_bool checkend(FullDuplexDriver *sd) {
* Simple command shell thread, the argument is the serial line for the * Simple command shell thread, the argument is the serial line for the
* standard input and output. It recognizes few simple commands. * 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; FullDuplexDriver *sd = (FullDuplexDriver *)arg;
char *lp, line[64]; char *lp, line[64];
Thread *tp; Thread *tp;
@ -225,8 +225,8 @@ static WorkingArea(s1area, 4096);
static Thread *s1; static Thread *s1;
EventListener s1tel; EventListener s1tel;
static void COM1Handler(t_eventid id) { static void COM1Handler(eventid_t id) {
t_dflags flags; dflags_t flags;
if (s1 && chThdTerminated(s1)) { if (s1 && chThdTerminated(s1)) {
s1 = NULL; s1 = NULL;
@ -248,8 +248,8 @@ static WorkingArea(s2area, 4096);
static Thread *s2; static Thread *s2;
EventListener s2tel; EventListener s2tel;
static void COM2Handler(t_eventid id) { static void COM2Handler(eventid_t id) {
t_dflags flags; dflags_t flags;
if (s2 && chThdTerminated(s2)) { if (s2 && chThdTerminated(s2)) {
s2 = NULL; s2 = NULL;
@ -267,7 +267,7 @@ static void COM2Handler(t_eventid id) {
chIQReset(&COM2.sd_iqueue); chIQReset(&COM2.sd_iqueue);
} }
static t_evhandler fhandlers[2] = { static evhandler_t fhandlers[2] = {
COM1Handler, COM1Handler,
COM2Handler COM2Handler
}; };

View File

@ -32,7 +32,7 @@ static uint8_t ib2[SERIAL_BUFFERS_SIZE];
static uint8_t ob2[SERIAL_BUFFERS_SIZE]; static uint8_t ob2[SERIAL_BUFFERS_SIZE];
static void SetError(AT91_REG csr, FullDuplexDriver *com) { static void SetError(AT91_REG csr, FullDuplexDriver *com) {
uint16_t sts = 0; dflags_t sts = 0;
if (csr & AT91C_US_OVRE) if (csr & AT91C_US_OVRE)
sts |= SD_OVERRUN_ERROR; sts |= SD_OVERRUN_ERROR;
@ -53,7 +53,7 @@ static void ServeInterrupt(AT91PS_USART u, FullDuplexDriver *com) {
if (u->US_CSR & AT91C_US_RXRDY) if (u->US_CSR & AT91C_US_RXRDY)
chFDDIncomingDataI(com, u->US_RHR); chFDDIncomingDataI(com, u->US_RHR);
if (u->US_CSR & AT91C_US_TXRDY) { if (u->US_CSR & AT91C_US_TXRDY) {
t_msg b = chFDDRequestDataI(com); msg_t b = chFDDRequestDataI(com);
if (b < Q_OK) if (b < Q_OK)
u->US_IDR = AT91C_US_TXRDY; u->US_IDR = AT91C_US_TXRDY;
else else

View File

@ -33,7 +33,7 @@ static uint8_t ib2[SERIAL_BUFFERS_SIZE];
static uint8_t ob2[SERIAL_BUFFERS_SIZE]; static uint8_t ob2[SERIAL_BUFFERS_SIZE];
static void SetError(IOREG32 err, FullDuplexDriver *com) { static void SetError(IOREG32 err, FullDuplexDriver *com) {
uint16_t sts = 0; dflags_t sts = 0;
if (err & LSR_OVERRUN) if (err & LSR_OVERRUN)
sts |= SD_OVERRUN_ERROR; sts |= SD_OVERRUN_ERROR;
@ -72,7 +72,7 @@ static void ServeInterrupt(UART *u, FullDuplexDriver *com) {
#ifdef FIFO_PRELOAD #ifdef FIFO_PRELOAD
int i = FIFO_PRELOAD; int i = FIFO_PRELOAD;
do { do {
t_msg b = chOQGetI(&com->sd_oqueue); msg_t b = chOQGetI(&com->sd_oqueue);
if (b < Q_OK) { if (b < Q_OK) {
u->UART_IER &= ~IER_THRE; u->UART_IER &= ~IER_THRE;
chEvtSendI(&com->sd_oevent); chEvtSendI(&com->sd_oevent);
@ -81,7 +81,7 @@ static void ServeInterrupt(UART *u, FullDuplexDriver *com) {
u->UART_THR = b; u->UART_THR = b;
} while (--i); } while (--i);
#else #else
t_msg b = chFDDRequestDataI(com); msg_t b = chFDDRequestDataI(com);
if (b < Q_OK) if (b < Q_OK)
u->UART_IER &= ~IER_THRE; u->UART_IER &= ~IER_THRE;
else else
@ -123,7 +123,7 @@ static void preload(UART *u, FullDuplexDriver *com) {
if (u->UART_LSR & LSR_THRE) { if (u->UART_LSR & LSR_THRE) {
int i = FIFO_PRELOAD; int i = FIFO_PRELOAD;
do { do {
t_msg b = chOQGetI(&com->sd_oqueue); msg_t b = chOQGetI(&com->sd_oqueue);
if (b < Q_OK) { if (b < Q_OK) {
chEvtSendI(&com->sd_oevent); chEvtSendI(&com->sd_oevent);
return; return;

View File

@ -55,7 +55,7 @@ void sspReleaseBus(void) {
* rest of the system. This kind of peripheral would really need a * rest of the system. This kind of peripheral would really need a
* dedicated DMA channel. * 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; int icnt, ocnt;
SSP *ssp = SSPBase; SSP *ssp = SSPBase;

View File

@ -34,7 +34,7 @@
void sspAcquireBus(void); void sspAcquireBus(void);
void sspReleaseBus(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 #ifdef __cplusplus
} }
#endif #endif

View File

@ -20,21 +20,24 @@
#ifndef _CHTYPES_H_ #ifndef _CHTYPES_H_
#define _CHTYPES_H_ #define _CHTYPES_H_
#define __need_NULL
#define __need_size_t
#include <stddef.h>
#if !defined(_STDINT_H) && !defined(__STDINT_H_) #if !defined(_STDINT_H) && !defined(__STDINT_H_)
#include <stdint.h> #include <stdint.h>
#endif #endif
typedef int8_t t_bool; typedef int8_t bool_t;
typedef uint8_t t_tmode; typedef uint8_t tmode_t;
typedef uint8_t t_tstate; typedef uint8_t tstate_t;
typedef uint16_t t_tid; typedef uint16_t tid_t;
typedef uint32_t t_prio; typedef uint32_t tprio_t;
typedef int32_t t_msg; typedef int32_t msg_t;
typedef int32_t t_eventid; typedef int32_t eventid_t;
typedef uint32_t t_eventmask; typedef uint32_t eventmask_t;
typedef uint32_t t_time; typedef uint32_t systime_t;
typedef int32_t t_cnt; typedef int32_t cnt_t;
typedef uint32_t t_size;
#define INLINE inline #define INLINE inline

View File

@ -25,7 +25,7 @@
#include "avr_serial.h" #include "avr_serial.h"
static void SetError(uint8_t sra, FullDuplexDriver *com) { static void SetError(uint8_t sra, FullDuplexDriver *com) {
uint16_t sts = 0; dflags_t sts = 0;
if (sra & (1 << DOR)) if (sra & (1 << DOR))
sts |= SD_OVERRUN_ERROR; sts |= SD_OVERRUN_ERROR;
@ -54,7 +54,7 @@ ISR(USART0_RX_vect) {
} }
ISR(USART0_UDRE_vect) { ISR(USART0_UDRE_vect) {
t_msg b; msg_t b;
chSysIRQEnterI(); chSysIRQEnterI();
@ -109,7 +109,7 @@ ISR(USART1_RX_vect) {
} }
ISR(USART1_UDRE_vect) { ISR(USART1_UDRE_vect) {
t_msg b; msg_t b;
chSysIRQEnterI(); chSysIRQEnterI();

View File

@ -20,21 +20,24 @@
#ifndef _CHTYPES_H_ #ifndef _CHTYPES_H_
#define _CHTYPES_H_ #define _CHTYPES_H_
#define __need_NULL
#define __need_size_t
#include <stddef.h>
#if !defined(_STDINT_H) && !defined(__STDINT_H_) #if !defined(_STDINT_H) && !defined(__STDINT_H_)
#include <stdint.h> #include <stdint.h>
#endif #endif
typedef int8_t t_bool; typedef int8_t bool_t;
typedef uint8_t t_tmode; typedef uint8_t tmode_t;
typedef uint8_t t_tstate; typedef uint8_t tstate_t;
typedef uint8_t t_tid; typedef uint8_t tid_t;
typedef uint8_t t_prio; typedef uint8_t tprio_t;
typedef int16_t t_msg; typedef int16_t msg_t;
typedef uint8_t t_eventid; typedef uint8_t eventid_t;
typedef uint8_t t_eventmask; typedef uint8_t eventmask_t;
typedef uint16_t t_time; typedef uint16_t systime_t;
typedef int8_t t_cnt; typedef int8_t cnt_t;
typedef uint16_t t_size;
#define INLINE inline #define INLINE inline

View File

@ -108,7 +108,7 @@ void InitSimCom2(void) {
init("COM2", &COM2, &sc2, COM2PORT); 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) { if (sc->com_data == INVALID_SOCKET) {
struct sockaddr addr; struct sockaddr addr;
@ -134,17 +134,17 @@ abort:
exit(1); exit(1);
} }
t_bool Com1ConnInterruptSimCom(void) { bool_t Com1ConnInterruptSimCom(void) {
return connint("COM1", &COM1, &sc1); return connint("COM1", &COM1, &sc1);
} }
t_bool Com2ConnInterruptSimCom(void) { bool_t Com2ConnInterruptSimCom(void) {
return connint("COM2", &COM2, &sc2); 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) { if (sc->com_data != INVALID_SOCKET) {
int i; int i;
@ -174,17 +174,17 @@ static t_bool inint(char *name, FullDuplexDriver *sd, struct simcom *sc) {
return FALSE; return FALSE;
} }
t_bool Com1InInterruptSimCom(void) { bool_t Com1InInterruptSimCom(void) {
return inint("COM1", &COM1, &sc1); return inint("COM1", &COM1, &sc1);
} }
t_bool Com2InInterruptSimCom(void) { bool_t Com2InInterruptSimCom(void) {
return inint("COM2", &COM2, &sc2); 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) { if (sc->com_data != INVALID_SOCKET) {
int n; int n;
@ -216,12 +216,12 @@ static t_bool outint(char *name, FullDuplexDriver *sd, struct simcom *sc) {
return FALSE; return FALSE;
} }
t_bool Com1OutInterruptSimCom(void) { bool_t Com1OutInterruptSimCom(void) {
return outint("COM1", &COM1, &sc1); return outint("COM1", &COM1, &sc1);
} }
t_bool Com2OutInterruptSimCom(void) { bool_t Com2OutInterruptSimCom(void) {
return outint("COM2", &COM2, &sc2); return outint("COM2", &COM2, &sc2);
} }

View File

@ -63,12 +63,18 @@ AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not complete yet, scheduled
*** Releases *** *** Releases ***
***************************************************************************** *****************************************************************************
*** 0.5.6 *** *** 0.6.0 ***
- Implemented a serial driver in the AVR port.
- Code refactory, all the old sized-integer definitions like LONG32, UWORD16 - Code refactory, all the old sized-integer definitions like LONG32, UWORD16
etc are now replaced by the proper definitions provided by the compiler 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 into stdint.h.
help it. - 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 - MSVC demo dropped, it is still possible to use the MinGW demo as simulator
in Win32. in Win32.
- Fixed a minor error in sam7x_serial.h and lpc214x_serial.h. - Fixed a minor error in sam7x_serial.h and lpc214x_serial.h.

View File

@ -33,7 +33,7 @@ DeltaList dlist;
void chVTInit(void) { void chVTInit(void) {
dlist.dl_next = dlist.dl_prev = (VirtualTimer *)&dlist; 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 Must be called with the interrupts disabled.
* @note The associated function is invoked by an interrupt handler. * @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_par = par;
vtp->vt_func = vtfunc; vtp->vt_func = vtfunc;

View File

@ -31,11 +31,11 @@
* @param eid numeric identifier assigned to the Event Listener. The identifier * @param eid numeric identifier assigned to the Event Listener. The identifier
* is used as index for the event callback function. * is used as index for the event callback function.
* The value must range between zero and the size, in bit, of the * 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 * @note Multiple Event Listeners can use the same event identifier, the
* listener will share the callback function. * 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(); chSysLock();
@ -77,7 +77,7 @@ void chEvtUnregister(EventSource *esp, EventListener *elp) {
* Clears the pending events specified in the mask. * Clears the pending events specified in the mask.
* @param mask the events to be cleared * @param mask the events to be cleared
*/ */
void chEvtClear(t_eventmask mask) { void chEvtClear(eventmask_t mask) {
chSysLock(); chSysLock();
@ -125,7 +125,7 @@ void chEvtSendI(EventSource *esp) {
* event handler is specified then the handler is executed before returning. * event handler is specified then the handler is executed before returning.
* @param ewmask mask of the events that should be served by the function, * @param ewmask mask of the events that should be served by the function,
* \p ALL_EVENTS enables all the sources * \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 * have indexes from zero up the higher registered event
* identifier. The array can be \p NULL or contain \p NULL * identifier. The array can be \p NULL or contain \p NULL
* elements (no callbacks specified). * elements (no callbacks specified).
@ -136,8 +136,8 @@ void chEvtSendI(EventSource *esp) {
* This means that Event Listeners with a lower event identifier have * This means that Event Listeners with a lower event identifier have
* an higher priority. * an higher priority.
*/ */
t_eventid chEvtWait(t_eventmask ewmask, eventid_t chEvtWait(eventmask_t ewmask,
const t_evhandler handlers[]) { const evhandler_t handlers[]) {
return chEvtWaitTimeout(ewmask, handlers, TIME_INFINITE); return chEvtWaitTimeout(ewmask, handlers, TIME_INFINITE);
} }
@ -148,7 +148,7 @@ t_eventid chEvtWait(t_eventmask ewmask,
* executed before returning. * executed before returning.
* @param ewmask mask of the events that should be served by the function, * @param ewmask mask of the events that should be served by the function,
* \p ALL_EVENTS enables all the sources * \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 * have indexes from zero up the higher registered event
* identifier. The array can be NULL or contain NULL elements * identifier. The array can be NULL or contain NULL elements
* (no callback specified). * (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 * @note The function is available only if the \p CH_USE_EVENTS_TIMEOUT
* option is enabled in \p chconf.h. * option is enabled in \p chconf.h.
*/ */
t_eventid chEvtWaitTimeout(t_eventmask ewmask, eventid_t chEvtWaitTimeout(eventmask_t ewmask,
const t_evhandler handlers[], const evhandler_t handlers[],
t_time time) { systime_t time) {
t_eventid i; eventid_t i;
t_eventmask m; eventmask_t m;
chSysLock(); chSysLock();
@ -189,10 +189,10 @@ t_eventid chEvtWaitTimeout(t_eventmask ewmask,
} }
#else /* !CH_USE_EVENTS_TIMEOUT */ #else /* !CH_USE_EVENTS_TIMEOUT */
t_eventid chEvtWait(t_eventmask ewmask, eventid_t chEvtWait(eventmask_t ewmask,
const t_evhandler handlers[]) { const evhandler_t handlers[]) {
t_eventid i; eventid_t i;
t_eventmask m; eventmask_t m;
chSysLock(); chSysLock();

View File

@ -55,7 +55,7 @@ void chSysInit(void) {
* serve interrupts in its context while keeping the lowest energy saving * serve interrupts in its context while keeping the lowest energy saving
* mode compatible with the system status. * 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);
} }
/** /**

View File

@ -32,7 +32,7 @@
* @param msg the message, it can be a pointer to a complex structure * @param msg the message, it can be a pointer to a complex structure
* @return the return message from \p chMsgRelease() * @return the return message from \p chMsgRelease()
*/ */
t_msg chMsgSend(Thread *tp, t_msg msg) { msg_t chMsgSend(Thread *tp, msg_t msg) {
chSysLock(); 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 * a \p chMsgWait(). The use case is that the server thread is waiting
* for both messages AND events while waiting into \p chEvtWait(). * 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(); chSysLock();
@ -103,8 +103,8 @@ t_msg chMsgSendWithEvent(Thread *tp, t_msg msg, EventSource *esp) {
* you invoke \p chMsgRelease() because the sending thread is * you invoke \p chMsgRelease() because the sending thread is
* suspended until then. * suspended until then.
*/ */
t_msg chMsgWait(void) { msg_t chMsgWait(void) {
t_msg msg; msg_t msg;
chSysLock(); chSysLock();
@ -127,12 +127,12 @@ t_msg chMsgWait(void) {
* suspended until then. Always remember that the message data is not * suspended until then. Always remember that the message data is not
* copied between the sender and the receiver, just a pointer is passed. * copied between the sender and the receiver, just a pointer is passed.
*/ */
t_msg chMsgGet(void) { msg_t chMsgGet(void) {
t_msg msg; msg_t msg;
chSysLock(); chSysLock();
msg = chMsgIsPendingI(currp) ? chMsgGetI(currp) : NULL; msg = chMsgIsPendingI(currp) ? chMsgGetI(currp) : (msg_t)NULL;
chSysUnlock(); chSysUnlock();
return msg; return msg;
@ -149,7 +149,7 @@ t_msg chMsgGet(void) {
* The condition is not checked in order to make this code as fast as * The condition is not checked in order to make this code as fast as
* possible. * possible.
*/ */
void chMsgRelease(t_msg msg) { void chMsgRelease(msg_t msg) {
chSysLock(); chSysLock();

View File

@ -106,8 +106,8 @@ void chMtxLockS(Mutex *mp) {
* @param mp pointer to the \p Mutex structure * @param mp pointer to the \p Mutex structure
* @return \p TRUE if the mutex was successfully acquired else \p FALSE * @return \p TRUE if the mutex was successfully acquired else \p FALSE
*/ */
t_bool chMtxTryLock(Mutex *mp) { bool_t chMtxTryLock(Mutex *mp) {
t_bool b; bool_t b;
chSysLock(); chSysLock();
@ -126,7 +126,7 @@ t_bool chMtxTryLock(Mutex *mp) {
* @note This function must be called within a \p chSysLock() / \p chSysUnlock() * @note This function must be called within a \p chSysLock() / \p chSysUnlock()
* block. * block.
*/ */
t_bool chMtxTryLockS(Mutex *mp) { bool_t chMtxTryLockS(Mutex *mp) {
if (mp->m_owner != NULL) if (mp->m_owner != NULL)
return FALSE; return FALSE;
@ -161,7 +161,7 @@ void chMtxUnlock(void) {
/* /*
* Recalculates the optimal thread priority by scanning the owned mutexes list. * 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; mp = currp->p_mtxlist;
while (mp != NULL) { while (mp != NULL) {
if (chMtxQueueNotEmptyS(mp) && (mp->m_queue.p_next->p_prio > newprio)) 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. * 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; mp = currp->p_mtxlist;
while (mp != NULL) { while (mp != NULL) {
if (chMtxQueueNotEmptyS(mp) && (mp->m_queue.p_next->p_prio > newprio)) if (chMtxQueueNotEmptyS(mp) && (mp->m_queue.p_next->p_prio > newprio))

View File

@ -35,7 +35,7 @@
* @param inotify pointer to a callback function that is invoked when * @param inotify pointer to a callback function that is invoked when
* some data is read from the Queue. The value can be \p NULL. * 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_buffer = qp->q_rdptr = qp->q_wrptr = buffer;
qp->q_top = buffer + size; 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 * @note This function must be called with interrupts disabled or from an
* interrupt handler. * interrupt handler.
*/ */
t_msg chIQPutI(Queue *qp, uint8_t b) { msg_t chIQPutI(Queue *qp, uint8_t b) {
if (chIQIsFull(qp)) if (chIQIsFull(qp))
return Q_FULL; return Q_FULL;
@ -86,7 +86,7 @@ t_msg chIQPutI(Queue *qp, uint8_t b) {
* @param qp pointer to a \p Queue structure * @param qp pointer to a \p Queue structure
* @return a byte from the queue or \p Q_RESET if the queue was reset * @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; uint8_t b;
chSysLock(); chSysLock();
@ -119,9 +119,9 @@ t_msg chIQGet(Queue *qp) {
* @note The function is available only if the \p CH_USE_QUEUES_TIMEOUT * @note The function is available only if the \p CH_USE_QUEUES_TIMEOUT
* option is enabled in \p chconf.h. * 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; uint8_t b;
t_msg msg; msg_t msg;
chSysLock(); 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 * @note The function is not atomic, if you need atomicity it is suggested
* to use a semaphore for mutual exclusion. * 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--) { while (n--) {
chSysLock(); 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 * @param onotify pointer to a callback function that is invoked when
* some data is written in the Queue. The value can be \p NULL. * 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_buffer = qp->q_rdptr = qp->q_wrptr = buffer;
qp->q_top = buffer + size; qp->q_top = buffer + size;
@ -211,7 +211,7 @@ void chOQReset(Queue *qp) {
chSysLock(); chSysLock();
qp->q_rdptr = qp->q_wrptr = qp->q_buffer; 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(); chSysUnlock();
} }
@ -245,7 +245,7 @@ void chOQPut(Queue *qp, uint8_t b) {
* @note This function must be called with interrupts disabled or from an * @note This function must be called with interrupts disabled or from an
* interrupt handler. * interrupt handler.
*/ */
t_msg chOQGetI(Queue *qp) { msg_t chOQGetI(Queue *qp) {
uint8_t b; uint8_t b;
if (chOQIsEmpty(qp)) 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 * @note The function is not atomic, if you need atomicity it is suggested
* to use a semaphore for mutual exclusion. * 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--) { while (n--) {
chSysLock(); 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 * @param onotify pointer to a callback function that is invoked when
* some data is written to the queue. The value can be \p NULL. * some data is written to the queue. The value can be \p NULL.
*/ */
void chHDQInit(HalfDuplexQueue *qp, uint8_t *buffer, t_size size, void chHDQInit(HalfDuplexQueue *qp, uint8_t *buffer, size_t size,
t_qnotify inotify, t_qnotify onotify) { qnotify_t inotify, qnotify_t onotify) {
qp->hdq_buffer = qp->hdq_rdptr = qp->hdq_wrptr = buffer; qp->hdq_buffer = qp->hdq_rdptr = qp->hdq_wrptr = buffer;
qp->hdq_top = buffer + size; 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 * @param qp pointer to a \p HalfDuplexQueue structure
* @return the byte value or \p Q_RESET if the queue was reset * @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; uint8_t b;
chSysLock(); chSysLock();
@ -363,9 +363,9 @@ t_msg chHDQGetReceive(HalfDuplexQueue *qp) {
* @note The function is available only if the \p CH_USE_QUEUES_TIMEOUT * @note The function is available only if the \p CH_USE_QUEUES_TIMEOUT
* option is enabled in \p chconf.h. * 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; uint8_t b;
t_msg msg; msg_t msg;
chSysLock(); chSysLock();
@ -431,7 +431,7 @@ void chHDQPutTransmit(HalfDuplexQueue *qp, uint8_t b) {
* @note This function must be called with interrupts disabled or from an * @note This function must be called with interrupts disabled or from an
* interrupt handler. * interrupt handler.
*/ */
t_msg chHDQGetTransmitI(HalfDuplexQueue *qp) { msg_t chHDQGetTransmitI(HalfDuplexQueue *qp) {
uint8_t b; uint8_t b;
if (!chHDQIsTransmitting(qp)) if (!chHDQIsTransmitting(qp))
@ -454,7 +454,7 @@ t_msg chHDQGetTransmitI(HalfDuplexQueue *qp) {
* @note This function must be called with interrupts disabled or from an * @note This function must be called with interrupts disabled or from an
* interrupt handler. * interrupt handler.
*/ */
t_msg chHDQPutReceiveI(HalfDuplexQueue *qp, uint8_t b) { msg_t chHDQPutReceiveI(HalfDuplexQueue *qp, uint8_t b) {
if (chHDQIsTransmitting(qp)) if (chHDQIsTransmitting(qp))
return Q_FULL; return Q_FULL;

View File

@ -54,9 +54,9 @@ void chSchInit(void) {
*/ */
#ifdef CH_OPTIMIZE_SPEED #ifdef CH_OPTIMIZE_SPEED
/* NOTE: it is inlined in this module only.*/ /* 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 #else
void chSchReadyI(Thread *tp, t_msg msg) { void chSchReadyI(Thread *tp, msg_t msg) {
#endif #endif
Thread *cp = rlist.r_queue.p_next; 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 must be called in the system mutex zone.
* @note The function is not meant to be used in the user code directly. * @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; Thread *otp;
(otp = currp)->p_state = newstate; (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 must be called in the system mutex zone.
* @note The function is not meant to be used in the user code directly. * @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; VirtualTimer vt;
chVTSetI(&vt, time, wakeup, currp); 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 * @note It is equivalent to a \p chSchReadyI() followed by a
* \p chSchRescheduleS() but much more efficient. * \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) if (ntp->p_prio <= currp->p_prio)
chSchReadyI(ntp, msg); chSchReadyI(ntp, msg);
@ -181,7 +181,7 @@ void chSchRescheduleS(void) {
* @return \p TRUE if there is a thread that should go in running state * @return \p TRUE if there is a thread that should go in running state
* immediatly else \p FALSE. * immediatly else \p FALSE.
*/ */
t_bool chSchRescRequiredI(void) { bool_t chSchRescRequiredI(void) {
if (isempty(&rlist.r_queue)) if (isempty(&rlist.r_queue))
return FALSE; return FALSE;

View File

@ -31,7 +31,7 @@
* @param n initial value of the semaphore counter. Must be non-negative. * @param n initial value of the semaphore counter. Must be non-negative.
* @note Can be called with interrupts disabled or enabled. * @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()"); chDbgAssert(n >= 0, "chsem.c, chSemInit()");
fifo_init(&sp->s_queue); 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 * instead than a signal because the \p chSemWait() will return
* \p RDY_RESET instead of \p RDY_OK. * \p RDY_RESET instead of \p RDY_OK.
*/ */
void chSemReset(Semaphore *sp, t_cnt n) { void chSemReset(Semaphore *sp, cnt_t n) {
chSysLock(); chSysLock();
@ -65,8 +65,8 @@ void chSemReset(Semaphore *sp, t_cnt n) {
* \p RDY_RESET instead of \p RDY_OK. * \p RDY_RESET instead of \p RDY_OK.
* @note This function does not reschedule. * @note This function does not reschedule.
*/ */
void chSemResetI(Semaphore *sp, t_cnt n) { void chSemResetI(Semaphore *sp, cnt_t n) {
t_cnt cnt; cnt_t cnt;
chDbgAssert(n >= 0, "chsem.c, chSemResetI()"); chDbgAssert(n >= 0, "chsem.c, chSemResetI()");
cnt = sp->s_cnt; cnt = sp->s_cnt;
@ -80,8 +80,8 @@ void chSemResetI(Semaphore *sp, t_cnt n) {
* @param sp pointer to a \p Semaphore structure * @param sp pointer to a \p Semaphore structure
* @return the function can return \p RDY_OK or \p RDY_RESET. * @return the function can return \p RDY_OK or \p RDY_RESET.
*/ */
t_msg chSemWait(Semaphore *sp) { msg_t chSemWait(Semaphore *sp) {
t_msg msg; msg_t msg;
chSysLock(); chSysLock();
@ -98,7 +98,7 @@ t_msg chSemWait(Semaphore *sp) {
* @note This function must be called with interrupts disabled. * @note This function must be called with interrupts disabled.
* @note This function cannot be called by an interrupt handler. * @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) { if (--sp->s_cnt < 0) {
fifo_insert(currp, &sp->s_queue); 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 * @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. * @return the function can return \p RDY_OK, \p RDY_TIMEOUT or \p RDY_RESET.
*/ */
t_msg chSemWaitTimeout(Semaphore *sp, t_time time) { msg_t chSemWaitTimeout(Semaphore *sp, systime_t time) {
t_msg msg; msg_t msg;
chSysLock(); 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 * @note The function is available only if the \p CH_USE_SEMAPHORES_TIMEOUT
* option is enabled in \p chconf.h. * 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) { if (--sp->s_cnt < 0) {
fifo_insert(currp, &sp->s_queue); fifo_insert(currp, &sp->s_queue);

View File

@ -40,8 +40,8 @@
* some data is written in the Queue. The value can be \p NULL. * some data is written in the Queue. The value can be \p NULL.
*/ */
void chFDDInit(FullDuplexDriver *sd, void chFDDInit(FullDuplexDriver *sd,
uint8_t *ib, t_size isize, t_qnotify inotify, uint8_t *ib, size_t isize, qnotify_t inotify,
uint8_t *ob, t_size osize, t_qnotify onotify) { uint8_t *ob, size_t osize, qnotify_t onotify) {
chIQInit(&sd->sd_iqueue, ib, isize, inotify); chIQInit(&sd->sd_iqueue, ib, isize, inotify);
chEvtInit(&sd->sd_ievent); 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 * queue is empty (the lower driver usually disables the interrupt
* source when this happens). * 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) if (b < Q_OK)
chEvtSendI(&sd->sd_oevent); chEvtSendI(&sd->sd_oevent);
return b; return b;
@ -88,7 +88,7 @@ t_msg chFDDRequestDataI(FullDuplexDriver *sd) {
* @param sd pointer to a \p FullDuplexDriver structure * @param sd pointer to a \p FullDuplexDriver structure
* @param mask condition flags to be added to the mask * @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; sd->sd_flags |= mask;
chEvtSendI(&sd->sd_sevent); 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 * @return the condition flags modified since last time this function was
* invoked * invoked
*/ */
t_dflags chFDDGetAndClearFlags(FullDuplexDriver *sd) { dflags_t chFDDGetAndClearFlags(FullDuplexDriver *sd) {
t_dflags mask; dflags_t mask;
mask = sd->sd_flags; mask = sd->sd_flags;
sd->sd_flags = SD_NO_ERROR; 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 * @param onotify pointer to a callback function that is invoked when
* some data is written in the queue. The value can be \p NULL. * some data is written in the queue. The value can be \p NULL.
*/ */
void chHDDInit(HalfDuplexDriver *sd, uint8_t *b, t_size size, void chHDDInit(HalfDuplexDriver *sd, uint8_t *b, size_t size,
t_qnotify inotify, t_qnotify onotify) { qnotify_t inotify, qnotify_t onotify) {
chHDQInit(&sd->sd_queue, b, size, inotify, onotify); chHDQInit(&sd->sd_queue, b, size, inotify, onotify);
chEvtInit(&sd->sd_ievent); 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 * queue is empty (the lower driver usually disables the interrupt
* source when this happens). * 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) if (b < Q_OK)
chEvtSendI(&sd->sd_oevent); chEvtSendI(&sd->sd_oevent);
return b; return b;
@ -169,7 +169,7 @@ t_msg chHDDRequestDataI(HalfDuplexDriver *sd) {
* @param sd pointer to a \p HalfDuplexDriver structure * @param sd pointer to a \p HalfDuplexDriver structure
* @param mask condition flags to be added to the mask * @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; sd->sd_flags |= mask;
chEvtSendI(&sd->sd_sevent); 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 * @return the condition flags modified since last time this function was
* invoked * invoked
*/ */
t_dflags chHDDGetAndClearFlags(HalfDuplexDriver *sd) { dflags_t chHDDGetAndClearFlags(HalfDuplexDriver *sd) {
t_dflags mask; dflags_t mask;
mask = sd->sd_flags; mask = sd->sd_flags;
sd->sd_flags = SD_NO_ERROR; sd->sd_flags = SD_NO_ERROR;

View File

@ -29,7 +29,7 @@
* Suspends the invoking thread for the specified time. * Suspends the invoking thread for the specified time.
* @param time the system ticks number * @param time the system ticks number
*/ */
void chThdSleep(t_time time) { void chThdSleep(systime_t time) {
chSysLock(); chSysLock();

View File

@ -27,8 +27,8 @@
/* /*
* Initializes a thread structure. * Initializes a thread structure.
*/ */
void _InitThread(t_prio prio, t_tmode mode, Thread *tp) { void _InitThread(tprio_t prio, tmode_t mode, Thread *tp) {
static t_tid nextid = 0; static tid_t nextid = 0;
tp->p_tid = nextid++; tp->p_tid = nextid++;
tp->p_flags = mode; 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 * @note A thread can terminate by calling \p chThdExit() or by simply
* returning from its main function. * returning from its main function.
*/ */
Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace, Thread *chThdCreate(tprio_t prio, tmode_t mode, void *workspace,
t_size wsize, t_tfunc pf, void *arg) { size_t wsize, tfunc_t pf, void *arg) {
Thread *tp = workspace; Thread *tp = workspace;
chDbgAssert((wsize > UserStackSize(0)) && (prio <= HIGHPRIO) && 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. * Changes the thread priority, reschedules if necessary.
* @param newprio the new priority of the invoking thread * @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()") chDbgAssert(newprio <= HIGHPRIO, "chthreads.c, chThdSetPriority()")
chSysLock(); chSysLock();
@ -211,7 +211,7 @@ void chThdTerminate(Thread *tp) {
* @param msg the thread exit code. The code can be retrieved by using * @param msg the thread exit code. The code can be retrieved by using
* \p chThdWait(). * \p chThdWait().
*/ */
void chThdExit(t_msg msg) { void chThdExit(msg_t msg) {
chSysLock(); chSysLock();
@ -235,8 +235,8 @@ void chThdExit(t_msg msg) {
* @note The function is available only if the \p CH_USE_WAITEXIT * @note The function is available only if the \p CH_USE_WAITEXIT
* option is enabled in \p chconf.h. * option is enabled in \p chconf.h.
*/ */
t_msg chThdWait(Thread *tp) { msg_t chThdWait(Thread *tp) {
t_msg msg; msg_t msg;
chSysLock(); chSysLock();

View File

@ -100,9 +100,6 @@
#ifndef TRUE #ifndef TRUE
#define TRUE 1 #define TRUE 1
#endif #endif
#ifndef NULL
#define NULL 0
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -38,13 +38,13 @@
typedef struct { typedef struct {
void *cse_wtobjp; void *cse_wtobjp;
t_time cse_time; systime_t cse_time;
UWORD16 cse_state: 4; uint16_t cse_state: 4;
UWORD16 cse_tid: 12; uint16_t cse_tid: 12;
} CtxSwcEvent; } CtxSwcEvent;
typedef struct { typedef struct {
t_size tb_size; size_t tb_size;
CtxSwcEvent *tb_ptr; CtxSwcEvent *tb_ptr;
CtxSwcEvent tb_buffer[TRACE_BUFFER_SIZE]; CtxSwcEvent tb_buffer[TRACE_BUFFER_SIZE];
} TraceBuffer; } TraceBuffer;

View File

@ -28,7 +28,7 @@
#ifdef CH_USE_VIRTUAL_TIMERS #ifdef CH_USE_VIRTUAL_TIMERS
/** Virtual Timer callback function.*/ /** Virtual Timer callback function.*/
typedef void (*t_vtfunc)(void *); typedef void (*vtfunc_t)(void *);
typedef struct VirtualTimer VirtualTimer; typedef struct VirtualTimer VirtualTimer;
@ -41,10 +41,10 @@ struct VirtualTimer {
/** Previous timer in the delta list.*/ /** Previous timer in the delta list.*/
VirtualTimer *vt_prev; VirtualTimer *vt_prev;
/** Time delta before timeout.*/ /** Time delta before timeout.*/
t_time vt_dtime; systime_t vt_dtime;
/** Timer callback function pointer. The pointer is reset to zero after /** Timer callback function pointer. The pointer is reset to zero after
the callback is invoked.*/ the callback is invoked.*/
t_vtfunc vt_func; vtfunc_t vt_func;
/** Timer callback function parameter.*/ /** Timer callback function parameter.*/
void *vt_par; void *vt_par;
}; };
@ -63,7 +63,7 @@ typedef struct {
/** Last timer in the list.*/ /** Last timer in the list.*/
VirtualTimer *dl_prev; VirtualTimer *dl_prev;
/** Not used but it must be set to /p MAXDELTA.*/ /** Not used but it must be set to /p MAXDELTA.*/
t_time dl_dtime; systime_t dl_dtime;
} DeltaList; } DeltaList;
extern DeltaList dlist; extern DeltaList dlist;
@ -74,7 +74,7 @@ extern DeltaList dlist;
\ \
--dlist.dl_next->vt_dtime; \ --dlist.dl_next->vt_dtime; \
while (!(vtp = 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_func = 0; \
(vtp->vt_next->vt_prev = (VirtualTimer *)&dlist)->vt_next = vtp->vt_next; \ (vtp->vt_next->vt_prev = (VirtualTimer *)&dlist)->vt_next = vtp->vt_next; \
fn(vtp->vt_par); \ fn(vtp->vt_par); \
@ -91,7 +91,7 @@ extern DeltaList dlist;
extern "C" { extern "C" {
#endif #endif
void chVTInit(void); 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); void chVTResetI(VirtualTimer *vtp);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -41,7 +41,7 @@ struct EventListener {
/** Thread interested in the Event Source.*/ /** Thread interested in the Event Source.*/
Thread *el_listener; Thread *el_listener;
/** Event identifier associated by the thread to the Event Source.*/ /** 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.*/ /** Event Handler callback function.*/
typedef void (*t_evhandler)(t_eventid); typedef void (*evhandler_t)(eventid_t);
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #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 chEvtUnregister(EventSource *esp, EventListener *elp);
void chEvtClear(t_eventmask mask); void chEvtClear(eventmask_t mask);
void chEvtSend(EventSource *esp); void chEvtSend(EventSource *esp);
void chEvtSendI(EventSource *esp); void chEvtSendI(EventSource *esp);
t_eventid chEvtWait(t_eventmask ewmask, eventid_t chEvtWait(eventmask_t ewmask,
const t_evhandler handlers[]); const evhandler_t handlers[]);
#ifdef CH_USE_EVENTS_TIMEOUT #ifdef CH_USE_EVENTS_TIMEOUT
t_eventid chEvtWaitTimeout(t_eventmask ewmask, eventid_t chEvtWaitTimeout(eventmask_t ewmask,
const t_evhandler handlers[], const evhandler_t handlers[],
t_time time); systime_t time);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -42,17 +42,13 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
t_msg chMsgSend(Thread *tp, t_msg msg); msg_t chMsgSend(Thread *tp, msg_t msg);
t_msg chMsgWait(void); msg_t chMsgWait(void);
t_msg chMsgGet(void); msg_t chMsgGet(void);
void chMsgRelease(t_msg msg); void chMsgRelease(msg_t msg);
#ifdef CH_USE_MESSAGES_EVENT #ifdef CH_USE_MESSAGES_EVENT
t_msg chMsgSendWithEvent(Thread *tp, t_msg msg, EventSource *esp); msg_t chMsgSendWithEvent(Thread *tp, msg_t msg, EventSource *esp);
#endif
#ifdef CH_USE_MESSAGES_TIMEOUT
t_msg chMsgSendTimeout(Thread *tp, t_msg msg, t_time time);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -44,8 +44,8 @@ extern "C" {
void chMtxInit(Mutex *mp); void chMtxInit(Mutex *mp);
void chMtxLock(Mutex *mp); void chMtxLock(Mutex *mp);
void chMtxLockS(Mutex *mp); void chMtxLockS(Mutex *mp);
t_bool chMtxTryLock(Mutex *mp); bool_t chMtxTryLock(Mutex *mp);
t_bool chMtxTryLockS(Mutex *mp); bool_t chMtxTryLockS(Mutex *mp);
void chMtxUnlock(void); void chMtxUnlock(void);
void chMtxUnlockS(void); void chMtxUnlockS(void);
void chMtxUnlockAll(void); void chMtxUnlockAll(void);

View File

@ -26,7 +26,7 @@
#define _QUEUES_H_ #define _QUEUES_H_
/** Queue notification callback type.*/ /** Queue notification callback type.*/
typedef void (*t_qnotify)(void); typedef void (*qnotify_t)(void);
/** Returned by the queue functions if the operation is successful.*/ /** Returned by the queue functions if the operation is successful.*/
#define Q_OK RDY_OK #define Q_OK RDY_OK
@ -56,7 +56,7 @@ typedef struct {
/** Counter semaphore.*/ /** Counter semaphore.*/
Semaphore q_sem; Semaphore q_sem;
/** Data notification callback.*/ /** Data notification callback.*/
t_qnotify q_notify; qnotify_t q_notify;
} Queue; } Queue;
/** Returns the queue's buffer size.*/ /** Returns the queue's buffer size.*/
@ -91,24 +91,24 @@ extern "C" {
* Input Queues functions. An Input Queue is usually written into by an * Input Queues functions. An Input Queue is usually written into by an
* interrupt handler and read from a thread. * 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); void chIQReset(Queue *qp);
t_msg chIQPutI(Queue *qp, uint8_t b); msg_t chIQPutI(Queue *qp, uint8_t b);
t_msg chIQGet(Queue *qp); msg_t chIQGet(Queue *qp);
t_size chIQRead(Queue *qp, uint8_t *buffer, t_size n); size_t chIQRead(Queue *qp, uint8_t *buffer, size_t n);
#ifdef CH_USE_QUEUES_TIMEOUT #ifdef CH_USE_QUEUES_TIMEOUT
t_msg chIQGetTimeout(Queue *qp, t_time time); msg_t chIQGetTimeout(Queue *qp, systime_t 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, 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 chOQReset(Queue *queue);
void chOQPut(Queue *queue, uint8_t b); void chOQPut(Queue *queue, uint8_t b);
t_msg chOQGetI(Queue *queue); msg_t chOQGetI(Queue *queue);
t_size chOQWrite(Queue *queue, uint8_t *buffer, t_size n); size_t chOQWrite(Queue *queue, uint8_t *buffer, size_t n);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
@ -132,9 +132,9 @@ typedef struct {
/** Output counter semaphore.*/ /** Output counter semaphore.*/
Semaphore hdq_osem; Semaphore hdq_osem;
/** Input data notification callback.*/ /** Input data notification callback.*/
t_qnotify hdq_inotify; qnotify_t hdq_inotify;
/** Output data notification callback.*/ /** Output data notification callback.*/
t_qnotify hdq_onotify; qnotify_t hdq_onotify;
} HalfDuplexQueue; } HalfDuplexQueue;
/** Returns the queue's buffer size.*/ /** Returns the queue's buffer size.*/
@ -164,14 +164,14 @@ typedef struct {
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void chHDQInit(HalfDuplexQueue *qp, uint8_t *buffer, t_size size, void chHDQInit(HalfDuplexQueue *qp, uint8_t *buffer, size_t size,
t_qnotify inotify, t_qnotify onotify); qnotify_t inotify, qnotify_t onotify);
t_msg chHDQGetReceive(HalfDuplexQueue *qp); msg_t chHDQGetReceive(HalfDuplexQueue *qp);
void chHDQPutTransmit(HalfDuplexQueue *qp, uint8_t b); void chHDQPutTransmit(HalfDuplexQueue *qp, uint8_t b);
t_msg chHDQGetTransmitI(HalfDuplexQueue *qp); msg_t chHDQGetTransmitI(HalfDuplexQueue *qp);
t_msg chHDQPutReceiveI(HalfDuplexQueue *qp, uint8_t b); msg_t chHDQPutReceiveI(HalfDuplexQueue *qp, uint8_t b);
#ifdef CH_USE_QUEUES_TIMEOUT #ifdef CH_USE_QUEUES_TIMEOUT
t_msg chHDQGetReceiveTimeout(HalfDuplexQueue *qp, t_time time); msg_t chHDQGetReceiveTimeout(HalfDuplexQueue *qp, systime_t time);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -39,13 +39,13 @@
*/ */
typedef struct { typedef struct {
ThreadsQueue r_queue; ThreadsQueue r_queue;
t_prio r_prio; tprio_t r_prio;
t_cnt r_preempt; cnt_t r_preempt;
#ifndef CH_CURRP_REGISTER_CACHE #ifndef CH_CURRP_REGISTER_CACHE
Thread *r_current; Thread *r_current;
#endif #endif
#ifdef CH_USE_SYSTEMTIME #ifdef CH_USE_SYSTEMTIME
volatile t_time r_stime; volatile systime_t r_stime;
#endif #endif
} ReadyList; } ReadyList;
@ -58,13 +58,13 @@ extern ReadyList rlist;
extern "C" { extern "C" {
#endif #endif
void chSchInit(void); void chSchInit(void);
void chSchReadyI(Thread *tp, t_msg msg); void chSchReadyI(Thread *tp, msg_t msg);
void chSchGoSleepS(t_tstate newstate); void chSchGoSleepS(tstate_t newstate);
t_msg chSchGoSleepTimeoutS(t_tstate newstate, t_time time); msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time);
void chSchWakeupS(Thread *tp, t_msg msg); void chSchWakeupS(Thread *tp, msg_t msg);
void chSchDoRescheduleI(void); void chSchDoRescheduleI(void);
void chSchRescheduleS(void); void chSchRescheduleS(void);
t_bool chSchRescRequiredI(void); bool_t chSchRescRequiredI(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -34,20 +34,20 @@ typedef struct {
/** Queue of the threads sleeping on this Semaphore.*/ /** Queue of the threads sleeping on this Semaphore.*/
ThreadsQueue s_queue; ThreadsQueue s_queue;
/** The Semaphore counter.*/ /** The Semaphore counter.*/
t_cnt s_cnt; cnt_t s_cnt;
} Semaphore; } Semaphore;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void chSemInit(Semaphore *sp, t_cnt n); void chSemInit(Semaphore *sp, cnt_t n);
void chSemReset(Semaphore *sp, t_cnt n); void chSemReset(Semaphore *sp, cnt_t n);
void chSemResetI(Semaphore *sp, t_cnt n); void chSemResetI(Semaphore *sp, cnt_t n);
t_msg chSemWait(Semaphore *sp); msg_t chSemWait(Semaphore *sp);
t_msg chSemWaitS(Semaphore *sp); msg_t chSemWaitS(Semaphore *sp);
#ifdef CH_USE_SEMAPHORES_TIMEOUT #ifdef CH_USE_SEMAPHORES_TIMEOUT
t_msg chSemWaitTimeout(Semaphore *sp, t_time time); msg_t chSemWaitTimeout(Semaphore *sp, systime_t time);
t_msg chSemWaitTimeoutS(Semaphore *sp, t_time time); msg_t chSemWaitTimeoutS(Semaphore *sp, systime_t time);
#endif #endif
void chSemSignal(Semaphore *sp); void chSemSignal(Semaphore *sp);
void chSemSignalI(Semaphore *sp); void chSemSignalI(Semaphore *sp);

View File

@ -41,7 +41,7 @@
#define SD_BREAK_DETECTED 32 #define SD_BREAK_DETECTED 32
/** Serial Driver condition flags type.*/ /** Serial Driver condition flags type.*/
typedef uint16_t t_dflags; typedef uint16_t dflags_t;
#ifdef CH_USE_SERIAL_FULLDUPLEX #ifdef CH_USE_SERIAL_FULLDUPLEX
@ -66,7 +66,7 @@ typedef struct {
/** I/O driver status flags. This field should not be read directly but /** I/O driver status flags. This field should not be read directly but
* the \p chFDDGetAndClearFlags() funtion should be used instead.*/ * 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 /** Status Change \p EventSource. This event is generated when a
* condition flag was changed.*/ * condition flag was changed.*/
EventSource sd_sevent; EventSource sd_sevent;
@ -76,12 +76,12 @@ typedef struct {
extern "C" { extern "C" {
#endif #endif
void chFDDInit(FullDuplexDriver *sd, void chFDDInit(FullDuplexDriver *sd,
uint8_t *ib, t_size isize, t_qnotify inotify, uint8_t *ib, size_t isize, qnotify_t inotify,
uint8_t *ob, t_size osize, t_qnotify onotify); uint8_t *ob, size_t osize, qnotify_t onotify);
void chFDDIncomingDataI(FullDuplexDriver *sd, uint8_t b); void chFDDIncomingDataI(FullDuplexDriver *sd, uint8_t b);
t_msg chFDDRequestDataI(FullDuplexDriver *sd); msg_t chFDDRequestDataI(FullDuplexDriver *sd);
void chFDDAddFlagsI(FullDuplexDriver *sd, t_dflags mask); void chFDDAddFlagsI(FullDuplexDriver *sd, dflags_t mask);
t_dflags chFDDGetAndClearFlags(FullDuplexDriver *sd); dflags_t chFDDGetAndClearFlags(FullDuplexDriver *sd);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
@ -128,7 +128,7 @@ typedef struct {
/** I/O driver status flags. This field should not be read directly but /** I/O driver status flags. This field should not be read directly but
* the \p chHDDGetAndClearFlags() funtion should be used * the \p chHDDGetAndClearFlags() funtion should be used
* instead.*/ * instead.*/
t_dflags sd_flags; dflags_t sd_flags;
/** Status Change Event Source. This event is generated when a condition /** Status Change Event Source. This event is generated when a condition
* flag was changed.*/ * flag was changed.*/
EventSource sd_sevent; EventSource sd_sevent;
@ -137,12 +137,12 @@ typedef struct {
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void chHDDInit(HalfDuplexDriver *sd, uint8_t *b, t_size size, void chHDDInit(HalfDuplexDriver *sd, uint8_t *b, size_t size,
t_qnotify inotify, t_qnotify onotify); qnotify_t inotify, qnotify_t onotify);
void chHDDIncomingDataI(HalfDuplexDriver *sd, uint8_t b); void chHDDIncomingDataI(HalfDuplexDriver *sd, uint8_t b);
t_msg chHDDRequestDataI(HalfDuplexDriver *sd); msg_t chHDDRequestDataI(HalfDuplexDriver *sd);
void chHDDAddFlagsI(HalfDuplexDriver *sd, t_dflags mask); void chHDDAddFlagsI(HalfDuplexDriver *sd, dflags_t mask);
t_dflags chHDDGetAndClearFlags(HalfDuplexDriver *sd); dflags_t chHDDGetAndClearFlags(HalfDuplexDriver *sd);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -29,7 +29,7 @@
extern "C" { extern "C" {
#endif #endif
#ifdef CH_USE_SLEEP #ifdef CH_USE_SLEEP
void chThdSleep(t_time time); void chThdSleep(systime_t time);
#endif /* CH_USE_SLEEP */ #endif /* CH_USE_SLEEP */
#ifdef __cplusplus #ifdef __cplusplus
} }
@ -55,7 +55,7 @@ extern "C" {
#define chThdSleepUntil(t) { \ #define chThdSleepUntil(t) { \
chSysLock(); \ chSysLock(); \
chSchGoSleepTimeoutS(PRSLEEP, \ chSchGoSleepTimeoutS(PRSLEEP, \
(t_time)((t) - chSysGetTime())) \ (systime_t)((t) - chSysGetTime())) \
chSysUnlock(); \ chSysUnlock(); \
} }
#endif /* CH_USE_SYSTEMTIME */ #endif /* CH_USE_SYSTEMTIME */

View File

@ -39,14 +39,14 @@ struct Thread {
Thread *p_prev; Thread *p_prev;
/* End of the fields shared with the ThreadsQueue structure. */ /* End of the fields shared with the ThreadsQueue structure. */
/** The thread priority.*/ /** The thread priority.*/
t_prio p_prio; tprio_t p_prio;
/* End of the fields shared with the ReadyList structure. */ /* End of the fields shared with the ReadyList structure. */
/** Thread identifier. */ /** Thread identifier. */
t_tid p_tid; tid_t p_tid;
/** Current thread state.*/ /** Current thread state.*/
t_tstate p_state; tstate_t p_state;
/** Mode flags.*/ /** Mode flags.*/
t_tmode p_flags; tmode_t p_flags;
/** Machine dependent processor context.*/ /** Machine dependent processor context.*/
Context p_ctx; Context p_ctx;
/* /*
@ -56,9 +56,9 @@ struct Thread {
*/ */
union { union {
/** Thread wakeup code (only valid when exiting the \p PRREADY state).*/ /** 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).*/ /** The thread exit code (only while in \p PREXIT state).*/
t_msg p_exitcode; msg_t p_exitcode;
#ifdef CH_USE_SEMAPHORES #ifdef CH_USE_SEMAPHORES
/** Semaphore where the thread is waiting on (only in \p PRWTSEM state).*/ /** Semaphore where the thread is waiting on (only in \p PRWTSEM state).*/
Semaphore *p_wtsemp; Semaphore *p_wtsemp;
@ -73,7 +73,7 @@ struct Thread {
#endif #endif
#ifdef CH_USE_EVENTS #ifdef CH_USE_EVENTS
/** Enabled events mask (only while in \p PRWTEVENT state).*/ /** Enabled events mask (only while in \p PRWTEVENT state).*/
t_eventmask p_ewmask; eventmask_t p_ewmask;
#endif #endif
#ifdef CH_USE_TRACE #ifdef CH_USE_TRACE
/** Kernel object where the thread is waiting on. It is only valid when /** Kernel object where the thread is waiting on. It is only valid when
@ -94,16 +94,16 @@ struct Thread {
#endif #endif
#ifdef CH_USE_MESSAGES #ifdef CH_USE_MESSAGES
ThreadsQueue p_msgqueue; ThreadsQueue p_msgqueue;
t_msg p_msg; msg_t p_msg;
#endif #endif
#ifdef CH_USE_EVENTS #ifdef CH_USE_EVENTS
/** Pending events mask.*/ /** Pending events mask.*/
t_eventmask p_epending; eventmask_t p_epending;
#endif #endif
#ifdef CH_USE_MUTEXES #ifdef CH_USE_MUTEXES
/** Owner mutexes list, \p NULL terminated.*/ /** Owner mutexes list, \p NULL terminated.*/
Mutex *p_mtxlist; Mutex *p_mtxlist;
t_prio p_realprio; tprio_t p_realprio;
#endif #endif
}; };
@ -159,10 +159,10 @@ struct Thread {
#define ABSPRIO 255 #define ABSPRIO 255
/* Not an API, don't use into the application code.*/ /* 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.*/ /** Thread function.*/
typedef t_msg (*t_tfunc)(void *); typedef msg_t (*tfunc_t)(void *);
/* /*
* Threads APIs. * Threads APIs.
@ -170,10 +170,10 @@ typedef t_msg (*t_tfunc)(void *);
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace, Thread *chThdCreate(tprio_t prio, tmode_t mode, void *workspace,
t_size wsize, t_tfunc pf, void *arg); size_t wsize, tfunc_t pf, void *arg);
void chThdSetPriority(t_prio newprio); void chThdSetPriority(tprio_t newprio);
void chThdExit(t_msg msg); void chThdExit(msg_t msg);
#ifdef CH_USE_RESUME #ifdef CH_USE_RESUME
void chThdResume(Thread *tp); void chThdResume(Thread *tp);
#endif #endif
@ -184,7 +184,7 @@ extern "C" {
void chThdTerminate(Thread *tp); void chThdTerminate(Thread *tp);
#endif #endif
#ifdef CH_USE_WAITEXIT #ifdef CH_USE_WAITEXIT
t_msg chThdWait(Thread *tp); msg_t chThdWait(Thread *tp);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -31,7 +31,7 @@
typedef struct { typedef struct {
VirtualTimer et_vt; VirtualTimer et_vt;
EventSource et_es; EventSource et_es;
t_time et_interval; systime_t et_interval;
} EvTimer; } EvTimer;
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -25,21 +25,24 @@
#ifndef _CHTYPES_H_ #ifndef _CHTYPES_H_
#define _CHTYPES_H_ #define _CHTYPES_H_
#define __need_NULL
#define __need_size_t
#include <stddef.h>
#if !defined(_STDINT_H) && !defined(__STDINT_H_) #if !defined(_STDINT_H) && !defined(__STDINT_H_)
#include <stdint.h> #include <stdint.h>
#endif #endif
typedef int8_t bool_t; typedef int8_t bool_t; /* Signed byte boolean. */
typedef uint8_t t_tmode; /* Thread mode flags, BYTE8 is ok. */ typedef uint8_t tmode_t; /* Thread mode flags, BYTE8 is ok. */
typedef uint8_t t_tstate; /* Thread state, BYTE8 is ok. */ typedef uint8_t tstate_t; /* Thread state, BYTE8 is ok. */
typedef uint16_t t_tid; /* Thread id. */ typedef uint16_t tid_t; /* Thread id. */
typedef uint32_t t_prio; /* Priority, use the fastest unsigned type. */ typedef uint32_t tprio_t; /* Priority, use the fastest unsigned type. */
typedef int32_t t_msg; /* Message, use signed pointer equivalent.*/ typedef int32_t msg_t; /* Message, use signed pointer equivalent.*/
typedef int32_t t_eventid; /* Event Id, use fastest signed.*/ typedef int32_t eventid_t; /* Event Id, use fastest signed.*/
typedef uint32_t t_eventmask;/* Event Mask, recommended fastest unsigned.*/ typedef uint32_t eventmask_t;/* Event Mask, recommended fastest unsigned.*/
typedef uint32_t t_time; /* Time, recommended fastest unsigned.*/ typedef uint32_t systime_t; /* System Time, recommended fastest unsigned.*/
typedef int32_t t_cnt; /* Counter, recommended fastest signed.*/ typedef int32_t cnt_t; /* Counter, recommended fastest signed.*/
typedef uint32_t t_size; /* Size, use unsigned pointer equivalent.*/
#define INLINE inline #define INLINE inline

View File

@ -79,9 +79,9 @@ static void println(char *msgp) {
} }
__attribute__((noinline)) __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) { while (chSysGetTime() != time) {
#if defined(WIN32) #if defined(WIN32)
ChkIntSources(); ChkIntSources();
@ -90,9 +90,9 @@ void CPU(t_time ms) {
} }
__attribute__((noinline)) __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) { while (chSysGetTime() < time) {
#if defined(WIN32) #if defined(WIN32)
ChkIntSources(); ChkIntSources();
@ -101,20 +101,20 @@ t_time wait_tick(void) {
return time; return time;
} }
t_msg Thread1(void *p) { msg_t Thread1(void *p) {
chFDDPut(comp, *(uint8_t *)p); chFDDPut(comp, *(uint8_t *)p);
return 0; return 0;
} }
t_msg Thread2(void *p) { msg_t Thread2(void *p) {
chSemWait(&sem1); chSemWait(&sem1);
chFDDPut(comp, *(uint8_t *)p); chFDDPut(comp, *(uint8_t *)p);
return 0; return 0;
} }
t_msg Thread3(void *p) { msg_t Thread3(void *p) {
chMtxLock(&m1); chMtxLock(&m1);
chFDDPut(comp, *(uint8_t *)p); chFDDPut(comp, *(uint8_t *)p);
@ -122,8 +122,8 @@ t_msg Thread3(void *p) {
return 0; return 0;
} }
t_msg Thread4(void *p) { msg_t Thread4(void *p) {
t_msg msg; msg_t msg;
int i; int i;
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
@ -134,14 +134,14 @@ t_msg Thread4(void *p) {
return 0; return 0;
} }
t_msg Thread6(void *p) { msg_t Thread6(void *p) {
while (!chThdShouldTerminate()) while (!chThdShouldTerminate())
chMsgRelease(chMsgWait() + 1); chMsgRelease(chMsgWait() + 1);
return 0; return 0;
} }
t_msg Thread7(void *p) { msg_t Thread7(void *p) {
return (unsigned int)p + 1; return (unsigned int)p + 1;
} }
@ -215,7 +215,7 @@ void testmtx1(void) {
println(""); println("");
} }
t_msg Thread8(void *p) { msg_t Thread8(void *p) {
chThdSleep(5); chThdSleep(5);
chMtxLock(&m1); chMtxLock(&m1);
@ -224,7 +224,7 @@ t_msg Thread8(void *p) {
return 0; return 0;
} }
t_msg Thread9(void *p) { msg_t Thread9(void *p) {
chMtxLock(&m1); chMtxLock(&m1);
chThdSleep(20); chThdSleep(20);
@ -233,7 +233,7 @@ t_msg Thread9(void *p) {
return 0; return 0;
} }
t_msg Thread10(void *p) { msg_t Thread10(void *p) {
chThdSleep(10); chThdSleep(10);
CPU(50); CPU(50);
@ -241,7 +241,7 @@ t_msg Thread10(void *p) {
return 0; return 0;
} }
t_msg Thread11(void *p) { msg_t Thread11(void *p) {
chThdSleep(5); chThdSleep(5);
chSemWait(&sem1); chSemWait(&sem1);
@ -250,7 +250,7 @@ t_msg Thread11(void *p) {
return 0; return 0;
} }
t_msg Thread12(void *p) { msg_t Thread12(void *p) {
chSemWait(&sem1); chSemWait(&sem1);
chThdSleep(20); chThdSleep(20);
@ -291,7 +291,7 @@ void testmtx3(void) {
println(""); println("");
} }
t_msg Thread13(void *p) { msg_t Thread13(void *p) {
chMtxLock(&m1); chMtxLock(&m1);
CPU(50); CPU(50);
@ -300,7 +300,7 @@ t_msg Thread13(void *p) {
return 0; return 0;
} }
t_msg Thread14(void *p) { msg_t Thread14(void *p) {
chThdSleep(10); chThdSleep(10);
chMtxLock(&m2); chMtxLock(&m2);
@ -314,7 +314,7 @@ t_msg Thread14(void *p) {
return 0; return 0;
} }
t_msg Thread15(void *p) { msg_t Thread15(void *p) {
chThdSleep(20); chThdSleep(20);
chMtxLock(&m2); chMtxLock(&m2);
@ -324,7 +324,7 @@ t_msg Thread15(void *p) {
return 0; return 0;
} }
t_msg Thread16(void *p) { msg_t Thread16(void *p) {
chThdSleep(40); chThdSleep(40);
CPU(200); CPU(200);
@ -332,7 +332,7 @@ t_msg Thread16(void *p) {
return 0; return 0;
} }
t_msg Thread17(void *p) { msg_t Thread17(void *p) {
chThdSleep(50); chThdSleep(50);
chMtxLock(&m2); chMtxLock(&m2);
@ -365,7 +365,7 @@ void testmtx4(void) {
} }
void testmsg1(void) { void testmsg1(void) {
t_msg msg; msg_t msg;
println("*** Messages, dispatch test, you should read AABBCCDDEE:"); println("*** Messages, dispatch test, you should read AABBCCDDEE:");
t1 = chThdCreate(chThdGetPriority()-1, 0, wsT1, sizeof(wsT1), Thread4, chThdSelf()); 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 msg_loop_test(Thread *tp) {
unsigned int i; unsigned int i;
t_time time = wait_tick() + 1000; systime_t time = wait_tick() + 1000;
i = 0; i = 0;
while (chSysGetTime() < time) { while (chSysGetTime() < time) {
i = chMsgSend(tp, i); i = chMsgSend(tp, i);
@ -461,7 +461,7 @@ chMsgSend(t1, 0);
__attribute__((noinline)) __attribute__((noinline))
void bench4(void) { void bench4(void) {
unsigned int i; unsigned int i;
t_time time; systime_t time;
println("*** Kernel Benchmark, threads creation/termination:"); println("*** Kernel Benchmark, threads creation/termination:");
time = wait_tick() + 1000; time = wait_tick() + 1000;
@ -483,7 +483,7 @@ void bench5(void) {
static uint8_t ib[16]; static uint8_t ib[16];
static Queue iq; static Queue iq;
unsigned int i; unsigned int i;
t_time time; systime_t time;
println("*** Kernel Benchmark, I/O Queues throughput:"); println("*** Kernel Benchmark, I/O Queues throughput:");
chIQInit(&iq, ib, sizeof(ib), NULL); chIQInit(&iq, ib, sizeof(ib), NULL);
@ -511,7 +511,7 @@ void bench5(void) {
/** /**
* Tester thread, this thread must be created with priority \p NORMALPRIO. * Tester thread, this thread must be created with priority \p NORMALPRIO.
*/ */
t_msg TestThread(void *p) { msg_t TestThread(void *p) {
comp = p; comp = p;
println("*****************************"); println("*****************************");