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

This commit is contained in:
gdisirio 2008-03-03 15:52:55 +00:00
parent c9efc76157
commit ec0a917ae1
24 changed files with 207 additions and 220 deletions

View File

@ -51,7 +51,7 @@ int main(int argc, char **argv) {
while (TRUE) {
chThdSleep(500);
if (!(AT91C_BASE_PIOB->PIO_PDSR & PIOB_SW1))
chFDDWrite(&COM1, (BYTE8 *)"Hello World!\r\n", 14);
chFDDWrite(&COM1, (uint8_t *)"Hello World!\r\n", 14);
if (!(AT91C_BASE_PIOB->PIO_PDSR & PIOB_SW2))
TestThread(&COM1);
}

View File

@ -73,7 +73,7 @@ static void TimerHandler(t_eventid id) {
if (!(IO0PIN & 0x00008000)) // Button 1
PlaySound(1000, 100);
if (!(IO0PIN & 0x00010000)) { // Button 2
chFDDWrite(&COM1, (BYTE8 *)"Hello World!\r\n", 14);
chFDDWrite(&COM1, (uint8_t *)"Hello World!\r\n", 14);
PlaySound(2000, 100);
}
}
@ -84,7 +84,7 @@ static void TimerHandler(t_eventid id) {
* driver and reads a sector.
*/
static void InsertHandler(t_eventid id) {
static BYTE8 rwbuf[512];
static uint8_t rwbuf[512];
MMCCSD data;
PlaySoundWait(1000, 100);

View File

@ -91,14 +91,14 @@ void mmcStopPolling(void) {
/*
* Returns TRUE if the card is safely inserted in the reader.
*/
BOOL mmcCardInserted (void) {
t_bool mmcCardInserted (void) {
return cnt == 0;
}
static void wait(void) {
int i;
BYTE8 buf[4];
uint8_t buf[4];
for (i = 0; i < 16; i++) {
sspRW(buf, NULL, 1);
@ -116,8 +116,8 @@ static void wait(void) {
}
}
static void sendhdr(BYTE8 cmd, ULONG32 arg) {
BYTE8 buf[6];
static void sendhdr(uint8_t cmd, uint32_t arg) {
uint8_t buf[6];
/*
* Wait for the bus to become idle if a write operation was in progress.
@ -133,9 +133,9 @@ static void sendhdr(BYTE8 cmd, ULONG32 arg) {
sspRW(NULL, buf, 6);
}
static BYTE8 recvr1(void) {
static uint8_t recvr1(void) {
int i;
BYTE8 r1[1];
uint8_t r1[1];
for (i = 0; i < 9; i++) {
sspRW(r1, NULL, 1);
@ -145,7 +145,7 @@ static BYTE8 recvr1(void) {
return 0xFF; /* Timeout.*/
}
static BOOL getdata(BYTE8 *buf, ULONG32 n) {
static t_bool getdata(uint8_t *buf, uint32_t n) {
int i;
for (i = 0; i < MMC_WAIT_DATA; i++) {
@ -162,7 +162,7 @@ static BOOL getdata(BYTE8 *buf, ULONG32 n) {
/*
* Initializes a card after the power up by selecting the SPI mode.
*/
BOOL mmcInit(void) {
t_bool mmcInit(void) {
/*
* Starting initialization with slow clock mode.
@ -187,7 +187,7 @@ BOOL mmcInit(void) {
*/
i = 0;
while (TRUE) {
BYTE8 b = mmcSendCommand(CMDINIT, 0);
uint8_t b = mmcSendCommand(CMDINIT, 0);
if (b == 0x00)
break;
if (b != 0x01)
@ -207,8 +207,8 @@ BOOL mmcInit(void) {
/*
* Sends a simple command and returns a R1-type response.
*/
BYTE8 mmcSendCommand(BYTE8 cmd, ULONG32 arg) {
BYTE8 r1;
uint8_t mmcSendCommand(uint8_t cmd, uint32_t arg) {
uint8_t r1;
sspAcquireBus();
sendhdr(cmd, arg);
@ -222,8 +222,8 @@ BYTE8 mmcSendCommand(BYTE8 cmd, ULONG32 arg) {
* @param data the pointer to a \p MMCCSD structure
* @return \p TRUE if an error happened
*/
BOOL mmcGetSize(MMCCSD *data) {
BYTE8 buf[16];
t_bool mmcGetSize(MMCCSD *data) {
uint8_t buf[16];
sspAcquireBus();
sendhdr(CMDREADCSD, 0);
@ -250,7 +250,7 @@ BOOL mmcGetSize(MMCCSD *data) {
* @param buf the pointer to the read buffer
* @return \p TRUE if an error happened
*/
BOOL mmcRead(BYTE8 *buf, ULONG32 blknum) {
t_bool mmcRead(uint8_t *buf, uint32_t blknum) {
sspAcquireBus();
sendhdr(CMDREAD, blknum << 8);
@ -273,8 +273,8 @@ BOOL mmcRead(BYTE8 *buf, ULONG32 blknum) {
* @param buf the pointer to the read buffer
* @return \p TRUE if an error happened
*/
BOOL mmcReadMultiple(BYTE8 *buf, ULONG32 blknum, ULONG32 n) {
static const BYTE8 stopcmd[] = {0x40 | CMDSTOP, 0, 0, 0, 0, 1, 0xFF};
t_bool mmcReadMultiple(uint8_t *buf, uint32_t blknum, uint32_t n) {
static const uint8_t stopcmd[] = {0x40 | CMDSTOP, 0, 0, 0, 0, 1, 0xFF};
sspAcquireBus();
sendhdr(CMDREADMULTIPLE, blknum << 8);
@ -290,7 +290,7 @@ BOOL mmcReadMultiple(BYTE8 *buf, ULONG32 blknum, ULONG32 n) {
buf += 512;
n--;
}
sspRW(NULL, (BYTE8 *)stopcmd, sizeof(stopcmd));
sspRW(NULL, (uint8_t *)stopcmd, sizeof(stopcmd));
if (recvr1() != 0x00) {
sspReleaseBus();
return TRUE;
@ -309,9 +309,9 @@ BOOL mmcReadMultiple(BYTE8 *buf, ULONG32 blknum, ULONG32 n) {
* the card, this allows to not make useless busy waiting. The invoking
* thread can do other things while the data is being written.
*/
BOOL mmcWrite(BYTE8 *buf, ULONG32 blknum) {
static const BYTE8 start[] = {0xFF, 0xFE};
BYTE8 b[4];
t_bool mmcWrite(uint8_t *buf, uint32_t blknum) {
static const uint8_t start[] = {0xFF, 0xFE};
uint8_t b[4];
sspAcquireBus();
sendhdr(CMDWRITE, blknum << 8);
@ -319,7 +319,7 @@ BOOL mmcWrite(BYTE8 *buf, ULONG32 blknum) {
sspReleaseBus();
return TRUE;
}
sspRW(NULL, (BYTE8 *)start, 2); /* Data prologue.*/
sspRW(NULL, (uint8_t *)start, 2); /* Data prologue.*/
sspRW(NULL, buf, 512); /* Data.*/
sspRW(NULL, NULL, 2); /* CRC ignored in this version.*/
sspRW(b, NULL, 1);
@ -340,10 +340,10 @@ BOOL mmcWrite(BYTE8 *buf, ULONG32 blknum) {
* the card, this allows to not make useless busy waiting. The invoking
* thread can do other things while the data is being written.
*/
BOOL mmcWriteMultiple(BYTE8 *buf, ULONG32 blknum, ULONG32 n) {
static const BYTE8 start[] = {0xFF, 0xFC},
t_bool mmcWriteMultiple(uint8_t *buf, uint32_t blknum, uint32_t n) {
static const uint8_t start[] = {0xFF, 0xFC},
stop[] = {0xFD, 0xFF};
BYTE8 b[4];
uint8_t b[4];
sspAcquireBus();
sendhdr(CMDWRITEMULTIPLE, blknum << 8);
@ -352,7 +352,7 @@ BOOL mmcWriteMultiple(BYTE8 *buf, ULONG32 blknum, ULONG32 n) {
return TRUE;
}
while (n) {
sspRW(NULL, (BYTE8 *)start, sizeof(start)); /* Data prologue.*/
sspRW(NULL, (uint8_t *)start, sizeof(start)); /* Data prologue.*/
sspRW(NULL, buf, 512); /* Data.*/
sspRW(NULL, NULL, 2); /* CRC ignored in this version.*/
sspRW(b, NULL, 1);
@ -364,7 +364,7 @@ BOOL mmcWriteMultiple(BYTE8 *buf, ULONG32 blknum, ULONG32 n) {
buf += 512;
n--;
}
sspRW(NULL, (BYTE8 *)stop, sizeof(stop)); /* Stops the transfer.*/
sspRW(NULL, (uint8_t *)stop, sizeof(stop)); /* Stops the transfer.*/
sspReleaseBus();
return FALSE;
}
@ -373,7 +373,7 @@ BOOL mmcWriteMultiple(BYTE8 *buf, ULONG32 blknum, ULONG32 n) {
* Makes sure that pending operations are completed before returning.
*/
void mmcSynch(void) {
BYTE8 buf[4];
uint8_t buf[4];
sspAcquireBus();
while (TRUE) {

View File

@ -37,8 +37,8 @@
#define CMDWRITEMULTIPLE 25
typedef struct {
ULONG32 csize;
ULONG32 rdblklen;
uint32_t csize;
uint32_t rdblklen;
} MMCCSD;
extern EventSource MMCInsertEventSource, MMCRemoveEventSource;
@ -48,16 +48,16 @@ extern EventSource MMCInsertEventSource, MMCRemoveEventSource;
#endif
void InitMMC(void);
BOOL mmcInit(void);
t_bool mmcInit(void);
void mmcStartPolling(void);
void mmcStopPolling(void);
BOOL mmcCardInserted (void);
BYTE8 mmcSendCommand(BYTE8 cmd, ULONG32 arg);
BOOL mmcGetSize(MMCCSD *data);
BOOL mmcRead(BYTE8 *buf, ULONG32 blknum);
BOOL mmcReadMultiple(BYTE8 *buf, ULONG32 blknum, ULONG32 n);
BOOL mmcWrite(BYTE8 *buf, ULONG32 blknum);
BOOL mmcWriteMultiple(BYTE8 *buf, ULONG32 blknum, ULONG32 n);
t_bool 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);
void mmcSynch(void);
#ifdef __cplusplus
}

View File

@ -24,15 +24,15 @@
#include "at91lib/aic.h"
FullDuplexDriver COM1;
static BYTE8 ib1[SERIAL_BUFFERS_SIZE];
static BYTE8 ob1[SERIAL_BUFFERS_SIZE];
static uint8_t ib1[SERIAL_BUFFERS_SIZE];
static uint8_t ob1[SERIAL_BUFFERS_SIZE];
FullDuplexDriver COM2;
static BYTE8 ib2[SERIAL_BUFFERS_SIZE];
static BYTE8 ob2[SERIAL_BUFFERS_SIZE];
static uint8_t ib2[SERIAL_BUFFERS_SIZE];
static uint8_t ob2[SERIAL_BUFFERS_SIZE];
static void SetError(AT91_REG csr, FullDuplexDriver *com) {
UWORD16 sts = 0;
uint16_t sts = 0;
if (csr & AT91C_US_OVRE)
sts |= SD_OVERRUN_ERROR;

View File

@ -25,15 +25,15 @@
#include "board.h"
FullDuplexDriver COM1;
BYTE8 ib1[SERIAL_BUFFERS_SIZE];
BYTE8 ob1[SERIAL_BUFFERS_SIZE];
uint8_t ib1[SERIAL_BUFFERS_SIZE];
uint8_t ob1[SERIAL_BUFFERS_SIZE];
FullDuplexDriver COM2;
BYTE8 ib2[SERIAL_BUFFERS_SIZE];
BYTE8 ob2[SERIAL_BUFFERS_SIZE];
uint8_t ib2[SERIAL_BUFFERS_SIZE];
uint8_t ob2[SERIAL_BUFFERS_SIZE];
static void SetError(IOREG32 err, FullDuplexDriver *com) {
UWORD16 sts = 0;
uint16_t sts = 0;
if (err & LSR_OVERRUN)
sts |= SD_OVERRUN_ERROR;

View File

@ -55,7 +55,7 @@ void sspReleaseBus(void) {
* rest of the system. This kind of peripheral would really need a
* dedicated DMA channel.
*/
void sspRW(BYTE8 *in, BYTE8 *out, t_size n) {
void sspRW(uint8_t *in, uint8_t *out, t_size n) {
int icnt, ocnt;
SSP *ssp = SSPBase;

View File

@ -34,7 +34,7 @@
void sspAcquireBus(void);
void sspReleaseBus(void);
void sspRW(BYTE8 *in, BYTE8 *out, t_size n);
void sspRW(uint8_t *in, uint8_t *out, t_size n);
#ifdef __cplusplus
}
#endif

View File

@ -64,7 +64,7 @@ typedef struct {
* Platform dependent part of the \p chThdCreate() API.
*/
#define SETUP_CONTEXT(workspace, wsize, pf, arg) { \
tp->p_ctx.r13 = (struct intctx *)((BYTE8 *)workspace + \
tp->p_ctx.r13 = (struct intctx *)((uint8_t *)workspace + \
wsize - \
sizeof(struct intctx)); \
tp->p_ctx.r13->r4 = pf; \
@ -91,7 +91,7 @@ extern void chSysUnlock(void);
sizeof(struct extctx) + \
(n) + \
INT_REQUIRED_STACK)
#define WorkingArea(s, n) ULONG32 s[UserStackSize(n) >> 2];
#define WorkingArea(s, n) uint32_t s[UserStackSize(n) >> 2];
#ifdef THUMB
#define chSysSwitchI chSysSwitchI_thumb

View File

@ -20,27 +20,21 @@
#ifndef _CHTYPES_H_
#define _CHTYPES_H_
/*
* Generic types often dependant on the compiler.
*/
#define BOOL char
#define BYTE8 unsigned char
#define SBYTE8 char
#define WORD16 short
#define UWORD16 unsigned short
#define LONG32 int
#define ULONG32 unsigned int
#if !defined(_STDINT_H) && !defined(__STDINT_H_)
#include <stdint.h>
#endif
typedef BYTE8 t_tmode;
typedef BYTE8 t_tstate;
typedef UWORD16 t_tid;
typedef ULONG32 t_prio;
typedef LONG32 t_msg;
typedef LONG32 t_eventid;
typedef ULONG32 t_eventmask;
typedef ULONG32 t_time;
typedef LONG32 t_cnt;
typedef ULONG32 t_size;
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;
#define INLINE inline

View File

@ -24,52 +24,52 @@
* Interrupt saved context.
*/
struct extctx {
BYTE8 _next;
BYTE8 r31;
BYTE8 r30;
BYTE8 r27;
BYTE8 r26;
BYTE8 r25;
BYTE8 r24;
BYTE8 r23;
BYTE8 r22;
BYTE8 r21;
BYTE8 r20;
BYTE8 r19;
BYTE8 r18;
BYTE8 sr;
BYTE8 r1;
BYTE8 r0;
UWORD16 pc;
uint8_t _next;
uint8_t r31;
uint8_t r30;
uint8_t r27;
uint8_t r26;
uint8_t r25;
uint8_t r24;
uint8_t r23;
uint8_t r22;
uint8_t r21;
uint8_t r20;
uint8_t r19;
uint8_t r18;
uint8_t sr;
uint8_t r1;
uint8_t r0;
uint16_t pc;
};
/*
* System saved context.
*/
struct intctx {
BYTE8 _next;
BYTE8 r29;
BYTE8 r28;
BYTE8 r17;
BYTE8 r16;
BYTE8 r15;
BYTE8 r14;
BYTE8 r13;
BYTE8 r12;
BYTE8 r11;
BYTE8 r10;
uint8_t _next;
uint8_t r29;
uint8_t r28;
uint8_t r17;
uint8_t r16;
uint8_t r15;
uint8_t r14;
uint8_t r13;
uint8_t r12;
uint8_t r11;
uint8_t r10;
#ifndef CH_CURRP_REGISTER_CACHE
BYTE8 r9;
BYTE8 r8;
uint8_t r9;
uint8_t r8;
#endif
BYTE8 r7;
BYTE8 r6;
BYTE8 r5;
BYTE8 r4;
BYTE8 r3;
BYTE8 r2;
BYTE8 pcl;
BYTE8 pch;
uint8_t r7;
uint8_t r6;
uint8_t r5;
uint8_t r4;
uint8_t r3;
uint8_t r2;
uint8_t pcl;
uint8_t pch;
};
/*
@ -84,7 +84,7 @@ typedef struct {
* Platform dependent part of the \p chThdCreate() API.
*/
#define SETUP_CONTEXT(workspace, wsize, pf, arg) { \
tp->p_ctx.sp = (struct intctx*)((BYTE8 *)workspace + wsize - 1 - \
tp->p_ctx.sp = (struct intctx*)((uint8_t *)workspace + wsize - 1 - \
(sizeof(struct intctx) - 1)); \
tp->p_ctx.sp->r2 = (int)pf; \
tp->p_ctx.sp->r3 = (int)pf >> 8; \
@ -100,7 +100,7 @@ typedef struct {
(sizeof(struct intctx) - 1) + \
(sizeof(struct extctx) - 1) + \
(n) + (INT_REQUIRED_STACK))
#define WorkingArea(s, n) BYTE8 s[UserStackSize(n)];
#define WorkingArea(s, n) uint8_t s[UserStackSize(n)];
#define chSysLock() asm volatile ("cli")

View File

@ -20,28 +20,21 @@
#ifndef _CHTYPES_H_
#define _CHTYPES_H_
/*
* Generic types often dependant on the compiler.
*/
#define BOOL char
#define BYTE8 unsigned char
#define SBYTE8 signed char
#define WORD16 int
#define UWORD16 unsigned int
#define LONG32 long
#define ULONG32 unsigned long
#define PTR_EQ int
#if !defined(_STDINT_H) && !defined(__STDINT_H_)
#include <stdint.h>
#endif
typedef BYTE8 t_tmode;
typedef BYTE8 t_tstate;
typedef BYTE8 t_tid;
typedef BYTE8 t_prio;
typedef WORD16 t_msg;
typedef BYTE8 t_eventid;
typedef BYTE8 t_eventmask;
typedef UWORD16 t_time;
typedef SBYTE8 t_cnt;
typedef UWORD16 t_size;
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;
#define INLINE inline

View File

@ -63,6 +63,12 @@ AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not complete yet, scheduled
*** Releases ***
*****************************************************************************
*** 0.5.6 ***
- 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.
*** 0.5.5 ***
- Added an AVRmega128 port. The previous AT90CANx port is still present but
it will be redone after the AVRmega128 port is complete because it will

View File

@ -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
*/
BOOL chMtxTryLock(Mutex *mp) {
BOOL b;
t_bool chMtxTryLock(Mutex *mp) {
t_bool b;
chSysLock();
@ -126,7 +126,7 @@ BOOL chMtxTryLock(Mutex *mp) {
* @note This function must be called within a \p chSysLock() / \p chSysUnlock()
* block.
*/
BOOL chMtxTryLockS(Mutex *mp) {
t_bool chMtxTryLockS(Mutex *mp) {
if (mp->m_owner != NULL)
return FALSE;

View File

@ -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, BYTE8 *buffer, t_size size, t_qnotify inotify) {
void chIQInit(Queue *qp, uint8_t *buffer, t_size size, t_qnotify 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, BYTE8 b) {
t_msg chIQPutI(Queue *qp, uint8_t b) {
if (chIQIsFull(qp))
return Q_FULL;
@ -87,7 +87,7 @@ t_msg chIQPutI(Queue *qp, BYTE8 b) {
* @return a byte from the queue or \p Q_RESET if the queue was reset
*/
t_msg chIQGet(Queue *qp) {
BYTE8 b;
uint8_t b;
chSysLock();
@ -120,7 +120,7 @@ t_msg chIQGet(Queue *qp) {
* option is enabled in \p chconf.h.
*/
t_msg chIQGetTimeout(Queue *qp, t_time time) {
BYTE8 b;
uint8_t b;
t_msg msg;
chSysLock();
@ -153,7 +153,7 @@ 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, BYTE8 *buffer, t_size n) {
t_size chIQRead(Queue *qp, uint8_t *buffer, t_size n) {
t_size r = 0;
while (n--) {
@ -193,7 +193,7 @@ t_size chIQRead(Queue *qp, BYTE8 *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, BYTE8 *buffer, t_size size, t_qnotify onotify) {
void chOQInit(Queue *qp, uint8_t *buffer, t_size size, t_qnotify onotify) {
qp->q_buffer = qp->q_rdptr = qp->q_wrptr = buffer;
qp->q_top = buffer + size;
@ -222,7 +222,7 @@ void chOQReset(Queue *qp) {
* @param qp pointer to a \p Queue structure
* @param b the byte value to be written
*/
void chOQPut(Queue *qp, BYTE8 b) {
void chOQPut(Queue *qp, uint8_t b) {
chSysLock();
@ -246,7 +246,7 @@ void chOQPut(Queue *qp, BYTE8 b) {
* interrupt handler.
*/
t_msg chOQGetI(Queue *qp) {
BYTE8 b;
uint8_t b;
if (chOQIsEmpty(qp))
return Q_EMPTY;
@ -268,7 +268,7 @@ 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, BYTE8 *buffer, t_size n) {
t_size chOQWrite(Queue *qp, uint8_t *buffer, t_size n) {
t_size w = 0;
while (n--) {
@ -311,7 +311,7 @@ t_size chOQWrite(Queue *qp, BYTE8 *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, BYTE8 *buffer, t_size size,
void chHDQInit(HalfDuplexQueue *qp, uint8_t *buffer, t_size size,
t_qnotify inotify, t_qnotify onotify) {
qp->hdq_buffer = qp->hdq_rdptr = qp->hdq_wrptr = buffer;
@ -329,7 +329,7 @@ void chHDQInit(HalfDuplexQueue *qp, BYTE8 *buffer, t_size size,
* @return the byte value or \p Q_RESET if the queue was reset
*/
t_msg chHDQGetReceive(HalfDuplexQueue *qp) {
BYTE8 b;
uint8_t b;
chSysLock();
@ -364,7 +364,7 @@ t_msg chHDQGetReceive(HalfDuplexQueue *qp) {
* option is enabled in \p chconf.h.
*/
t_msg chHDQGetReceiveTimeout(HalfDuplexQueue *qp, t_time time) {
BYTE8 b;
uint8_t b;
t_msg msg;
chSysLock();
@ -397,7 +397,7 @@ t_msg chHDQGetReceiveTimeout(HalfDuplexQueue *qp, t_time time) {
* @param qp pointer to a \p HalfDuplexQueue structure
* @param b the byte value to be written
*/
void chHDQPutTransmit(HalfDuplexQueue *qp, BYTE8 b) {
void chHDQPutTransmit(HalfDuplexQueue *qp, uint8_t b) {
chSysLock();
@ -432,7 +432,7 @@ void chHDQPutTransmit(HalfDuplexQueue *qp, BYTE8 b) {
* interrupt handler.
*/
t_msg chHDQGetTransmitI(HalfDuplexQueue *qp) {
BYTE8 b;
uint8_t b;
if (!chHDQIsTransmitting(qp))
return Q_EMPTY;
@ -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, BYTE8 b) {
t_msg chHDQPutReceiveI(HalfDuplexQueue *qp, uint8_t b) {
if (chHDQIsTransmitting(qp))
return Q_FULL;

View File

@ -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.
*/
BOOL chSchRescRequiredI(void) {
t_bool chSchRescRequiredI(void) {
if (isempty(&rlist.r_queue))
return FALSE;

View File

@ -40,8 +40,8 @@
* some data is written in the Queue. The value can be \p NULL.
*/
void chFDDInit(FullDuplexDriver *sd,
BYTE8 *ib, t_size isize, t_qnotify inotify,
BYTE8 *ob, t_size osize, t_qnotify onotify) {
uint8_t *ib, t_size isize, t_qnotify inotify,
uint8_t *ob, t_size osize, t_qnotify onotify) {
chIQInit(&sd->sd_iqueue, ib, isize, inotify);
chEvtInit(&sd->sd_ievent);
@ -57,7 +57,7 @@ void chFDDInit(FullDuplexDriver *sd,
* @param sd pointer to a \p FullDuplexDriver structure
* @param b the byte to be written in the driver's Input Queue
*/
void chFDDIncomingDataI(FullDuplexDriver *sd, BYTE8 b) {
void chFDDIncomingDataI(FullDuplexDriver *sd, uint8_t b) {
if (chIQPutI(&sd->sd_iqueue, b) < Q_OK)
chFDDAddFlagsI(sd, SD_OVERRUN_ERROR);
@ -122,7 +122,7 @@ 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, BYTE8 *b, t_size size,
void chHDDInit(HalfDuplexDriver *sd, uint8_t *b, t_size size,
t_qnotify inotify, t_qnotify onotify) {
chHDQInit(&sd->sd_queue, b, size, inotify, onotify);
@ -138,7 +138,7 @@ void chHDDInit(HalfDuplexDriver *sd, BYTE8 *b, t_size size,
* @param sd pointer to a \p FullDuplexDriver structure
* @param b the byte to be written in the driver's Input Queue
*/
void chHDDIncomingDataI(HalfDuplexDriver *sd, BYTE8 b) {
void chHDDIncomingDataI(HalfDuplexDriver *sd, uint8_t b) {
if (chHDQPutReceiveI(&sd->sd_queue, b) < Q_OK)
chHDDAddFlagsI(sd, SD_OVERRUN_ERROR);

View File

@ -53,7 +53,7 @@ void _InitThread(t_prio prio, t_tmode mode, Thread *tp) {
}
#ifdef CH_USE_DEBUG
static void memfill(BYTE8 *p, ULONG32 n, BYTE8 v) {
static void memfill(uint8_t *p, uint32_t n, uint8_t v) {
while (n)
*p++ = v, n--;

View File

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

View File

@ -46,13 +46,13 @@ typedef void (*t_qnotify)(void);
*/
typedef struct {
/** Pointer to the queue buffer.*/
BYTE8 *q_buffer;
uint8_t *q_buffer;
/** Pointer to the first location after the buffer.*/
BYTE8 *q_top;
uint8_t *q_top;
/** Write pointer.*/
BYTE8 *q_wrptr;
uint8_t *q_wrptr;
/** Read pointer.*/
BYTE8 *q_rdptr;
uint8_t *q_rdptr;
/** Counter semaphore.*/
Semaphore q_sem;
/** Data notification callback.*/
@ -91,11 +91,11 @@ 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, BYTE8 *buffer, t_size size, t_qnotify inotify);
void chIQInit(Queue *qp, uint8_t *buffer, t_size size, t_qnotify inotify);
void chIQReset(Queue *qp);
t_msg chIQPutI(Queue *qp, BYTE8 b);
t_msg chIQPutI(Queue *qp, uint8_t b);
t_msg chIQGet(Queue *qp);
t_size chIQRead(Queue *qp, BYTE8 *buffer, t_size n);
t_size chIQRead(Queue *qp, uint8_t *buffer, t_size n);
#ifdef CH_USE_QUEUES_TIMEOUT
t_msg chIQGetTimeout(Queue *qp, t_time time);
#endif
@ -104,11 +104,11 @@ extern "C" {
* Output Queues functions. An Output Queue is usually written into by a
* thread and read from an interrupt handler.
*/
void chOQInit(Queue *queue, BYTE8 *buffer, t_size size, t_qnotify onotify);
void chOQInit(Queue *queue, uint8_t *buffer, t_size size, t_qnotify onotify);
void chOQReset(Queue *queue);
void chOQPut(Queue *queue, BYTE8 b);
void chOQPut(Queue *queue, uint8_t b);
t_msg chOQGetI(Queue *queue);
t_size chOQWrite(Queue *queue, BYTE8 *buffer, t_size n);
t_size chOQWrite(Queue *queue, uint8_t *buffer, t_size n);
#ifdef __cplusplus
}
#endif
@ -120,13 +120,13 @@ extern "C" {
*/
typedef struct {
/** Pointer to the queue buffer.*/
BYTE8 *hdq_buffer;
uint8_t *hdq_buffer;
/** Pointer to the first location after the buffer.*/
BYTE8 *hdq_top;
uint8_t *hdq_top;
/** Write pointer.*/
BYTE8 *hdq_wrptr;
uint8_t *hdq_wrptr;
/** Read pointer.*/
BYTE8 *hdq_rdptr;
uint8_t *hdq_rdptr;
/** Input counter semaphore.*/
Semaphore hdq_isem;
/** Output counter semaphore.*/
@ -164,12 +164,12 @@ typedef struct {
#ifdef __cplusplus
extern "C" {
#endif
void chHDQInit(HalfDuplexQueue *qp, BYTE8 *buffer, t_size size,
void chHDQInit(HalfDuplexQueue *qp, uint8_t *buffer, t_size size,
t_qnotify inotify, t_qnotify onotify);
t_msg chHDQGetReceive(HalfDuplexQueue *qp);
void chHDQPutTransmit(HalfDuplexQueue *qp, BYTE8 b);
void chHDQPutTransmit(HalfDuplexQueue *qp, uint8_t b);
t_msg chHDQGetTransmitI(HalfDuplexQueue *qp);
t_msg chHDQPutReceiveI(HalfDuplexQueue *qp, BYTE8 b);
t_msg chHDQPutReceiveI(HalfDuplexQueue *qp, uint8_t b);
#ifdef CH_USE_QUEUES_TIMEOUT
t_msg chHDQGetReceiveTimeout(HalfDuplexQueue *qp, t_time time);
#endif

View File

@ -64,7 +64,7 @@ extern "C" {
void chSchWakeupS(Thread *tp, t_msg msg);
void chSchDoRescheduleI(void);
void chSchRescheduleS(void);
BOOL chSchRescRequiredI(void);
t_bool chSchRescRequiredI(void);
#ifdef __cplusplus
}
#endif

View File

@ -41,7 +41,7 @@
#define SD_BREAK_DETECTED 32
/** Serial Driver condition flags type.*/
typedef UWORD16 t_dflags;
typedef uint16_t t_dflags;
#ifdef CH_USE_SERIAL_FULLDUPLEX
@ -76,9 +76,9 @@ typedef struct {
extern "C" {
#endif
void chFDDInit(FullDuplexDriver *sd,
BYTE8 *ib, t_size isize, t_qnotify inotify,
BYTE8 *ob, t_size osize, t_qnotify onotify);
void chFDDIncomingDataI(FullDuplexDriver *sd, BYTE8 b);
uint8_t *ib, t_size isize, t_qnotify inotify,
uint8_t *ob, t_size osize, t_qnotify 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);
@ -137,9 +137,9 @@ typedef struct {
#ifdef __cplusplus
extern "C" {
#endif
void chHDDInit(HalfDuplexDriver *sd, BYTE8 *b, t_size size,
void chHDDInit(HalfDuplexDriver *sd, uint8_t *b, t_size size,
t_qnotify inotify, t_qnotify onotify);
void chHDDIncomingDataI(HalfDuplexDriver *sd, BYTE8 b);
void chHDDIncomingDataI(HalfDuplexDriver *sd, uint8_t b);
t_msg chHDDRequestDataI(HalfDuplexDriver *sd);
void chHDDAddFlagsI(HalfDuplexDriver *sd, t_dflags mask);
t_dflags chHDDGetAndClearFlags(HalfDuplexDriver *sd);

View File

@ -25,27 +25,21 @@
#ifndef _CHTYPES_H_
#define _CHTYPES_H_
/*
* Generic types often dependant on the compiler.
*/
#define BOOL char
#define BYTE8 unsigned char
#define SBYTE8 char
#define WORD16 short
#define UWORD16 unsigned short
#define LONG32 int
#define ULONG32 unsigned int
#if !defined(_STDINT_H) && !defined(__STDINT_H_)
#include <stdint.h>
#endif
typedef BYTE8 t_tmode; /* Thread mode flags, BYTE8 is ok. */
typedef BYTE8 t_tstate; /* Thread state, BYTE8 is ok. */
typedef UWORD16 t_tid; /* Thread id. */
typedef ULONG32 t_prio; /* Priority, use the fastest unsigned type. */
typedef LONG32 t_msg; /* Message, use signed pointer equivalent.*/
typedef LONG32 t_eventid; /* Event Id, use fastest signed.*/
typedef ULONG32 t_eventmask;/* Event Mask, recommended fastest unsigned.*/
typedef ULONG32 t_time; /* Time, recommended fastest unsigned.*/
typedef LONG32 t_cnt; /* Counter, recommended fastest signed.*/
typedef ULONG32 t_size; /* Size, use unsigned pointer equivalent.*/
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.*/
#define INLINE inline

View File

@ -103,21 +103,21 @@ t_time wait_tick(void) {
t_msg Thread1(void *p) {
chFDDPut(comp, *(BYTE8 *)p);
chFDDPut(comp, *(uint8_t *)p);
return 0;
}
t_msg Thread2(void *p) {
chSemWait(&sem1);
chFDDPut(comp, *(BYTE8 *)p);
chFDDPut(comp, *(uint8_t *)p);
return 0;
}
t_msg Thread3(void *p) {
chMtxLock(&m1);
chFDDPut(comp, *(BYTE8 *)p);
chFDDPut(comp, *(uint8_t *)p);
chMtxUnlock();
return 0;
}
@ -220,7 +220,7 @@ t_msg Thread8(void *p) {
chThdSleep(5);
chMtxLock(&m1);
chMtxUnlock();
chFDDPut(comp, *(BYTE8 *)p);
chFDDPut(comp, *(uint8_t *)p);
return 0;
}
@ -229,7 +229,7 @@ t_msg Thread9(void *p) {
chMtxLock(&m1);
chThdSleep(20);
chMtxUnlock();
chFDDPut(comp, *(BYTE8 *)p);
chFDDPut(comp, *(uint8_t *)p);
return 0;
}
@ -237,7 +237,7 @@ t_msg Thread10(void *p) {
chThdSleep(10);
CPU(50);
chFDDPut(comp, *(BYTE8 *)p);
chFDDPut(comp, *(uint8_t *)p);
return 0;
}
@ -246,7 +246,7 @@ t_msg Thread11(void *p) {
chThdSleep(5);
chSemWait(&sem1);
chSemSignal(&sem1);
chFDDPut(comp, *(BYTE8 *)p);
chFDDPut(comp, *(uint8_t *)p);
return 0;
}
@ -255,7 +255,7 @@ t_msg Thread12(void *p) {
chSemWait(&sem1);
chThdSleep(20);
chSemSignal(&sem1);
chFDDPut(comp, *(BYTE8 *)p);
chFDDPut(comp, *(uint8_t *)p);
return 0;
}
@ -296,7 +296,7 @@ t_msg Thread13(void *p) {
chMtxLock(&m1);
CPU(50);
chMtxUnlock();
chFDDPut(comp, *(BYTE8 *)p);
chFDDPut(comp, *(uint8_t *)p);
return 0;
}
@ -310,7 +310,7 @@ t_msg Thread14(void *p) {
chMtxUnlock();
CPU(20);
chMtxUnlock();
chFDDPut(comp, *(BYTE8 *)p);
chFDDPut(comp, *(uint8_t *)p);
return 0;
}
@ -320,7 +320,7 @@ t_msg Thread15(void *p) {
chMtxLock(&m2);
CPU(50);
chMtxUnlock();
chFDDPut(comp, *(BYTE8 *)p);
chFDDPut(comp, *(uint8_t *)p);
return 0;
}
@ -328,7 +328,7 @@ t_msg Thread16(void *p) {
chThdSleep(40);
CPU(200);
chFDDPut(comp, *(BYTE8 *)p);
chFDDPut(comp, *(uint8_t *)p);
return 0;
}
@ -338,7 +338,7 @@ t_msg Thread17(void *p) {
chMtxLock(&m2);
CPU(50);
chMtxUnlock();
chFDDPut(comp, *(BYTE8 *)p);
chFDDPut(comp, *(uint8_t *)p);
return 0;
}
@ -480,7 +480,7 @@ void bench4(void) {
__attribute__((noinline))
void bench5(void) {
static BYTE8 ib[16];
static uint8_t ib[16];
static Queue iq;
unsigned int i;
t_time time;