aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/chmtx.c6
-rw-r--r--src/chqueues.c30
-rw-r--r--src/chschd.c2
-rw-r--r--src/chserial.c10
-rw-r--r--src/chthreads.c2
-rw-r--r--src/include/mutexes.h4
-rw-r--r--src/include/queues.h34
-rw-r--r--src/include/scheduler.h2
-rw-r--r--src/include/serial.h12
-rw-r--r--src/templates/chtypes.h36
10 files changed, 66 insertions, 72 deletions
diff --git a/src/chmtx.c b/src/chmtx.c
index 3a1e2e00f..b76902477 100644
--- a/src/chmtx.c
+++ b/src/chmtx.c
@@ -106,8 +106,8 @@ void chMtxLockS(Mutex *mp) {
* @param mp pointer to the \p Mutex structure
* @return \p TRUE if the mutex was successfully acquired else \p FALSE
*/
-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;
diff --git a/src/chqueues.c b/src/chqueues.c
index ddc2cfdff..eafa50d42 100644
--- a/src/chqueues.c
+++ b/src/chqueues.c
@@ -35,7 +35,7 @@
* @param inotify pointer to a callback function that is invoked when
* some data is read from the Queue. The value can be \p NULL.
*/
-void chIQInit(Queue *qp, 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;
diff --git a/src/chschd.c b/src/chschd.c
index 1242ea275..4f92f92ce 100644
--- a/src/chschd.c
+++ b/src/chschd.c
@@ -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;
diff --git a/src/chserial.c b/src/chserial.c
index 196c9d5c2..8ed682cdf 100644
--- a/src/chserial.c
+++ b/src/chserial.c
@@ -40,8 +40,8 @@
* some data is written in the Queue. The value can be \p NULL.
*/
void chFDDInit(FullDuplexDriver *sd,
- 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);
diff --git a/src/chthreads.c b/src/chthreads.c
index 8a27acdb9..26a0cd1d9 100644
--- a/src/chthreads.c
+++ b/src/chthreads.c
@@ -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--;
diff --git a/src/include/mutexes.h b/src/include/mutexes.h
index 9e9422bd5..022e62dea 100644
--- a/src/include/mutexes.h
+++ b/src/include/mutexes.h
@@ -44,8 +44,8 @@ extern "C" {
void chMtxInit(Mutex *mp);
void chMtxLock(Mutex *mp);
void chMtxLockS(Mutex *mp);
- 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);
diff --git a/src/include/queues.h b/src/include/queues.h
index 31258ce69..a28539fd5 100644
--- a/src/include/queues.h
+++ b/src/include/queues.h
@@ -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
diff --git a/src/include/scheduler.h b/src/include/scheduler.h
index 6f4d54e56..f238002a1 100644
--- a/src/include/scheduler.h
+++ b/src/include/scheduler.h
@@ -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
diff --git a/src/include/serial.h b/src/include/serial.h
index 8e3127bac..4edef1e19 100644
--- a/src/include/serial.h
+++ b/src/include/serial.h
@@ -41,7 +41,7 @@
#define SD_BREAK_DETECTED 32
/** Serial Driver condition flags type.*/
-typedef 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);
diff --git a/src/templates/chtypes.h b/src/templates/chtypes.h
index fdbdae7b9..08753dc3d 100644
--- a/src/templates/chtypes.h
+++ b/src/templates/chtypes.h
@@ -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
-
-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.*/
+#if !defined(_STDINT_H) && !defined(__STDINT_H_)
+#include <stdint.h>
+#endif
+
+typedef int8_t bool_t;
+typedef uint8_t t_tmode; /* Thread mode flags, BYTE8 is ok. */
+typedef uint8_t t_tstate; /* Thread state, BYTE8 is ok. */
+typedef uint16_t t_tid; /* Thread id. */
+typedef uint32_t t_prio; /* Priority, use the fastest unsigned type. */
+typedef int32_t t_msg; /* Message, use signed pointer equivalent.*/
+typedef int32_t t_eventid; /* Event Id, use fastest signed.*/
+typedef uint32_t t_eventmask;/* Event Mask, recommended fastest unsigned.*/
+typedef uint32_t t_time; /* Time, recommended fastest unsigned.*/
+typedef int32_t t_cnt; /* Counter, recommended fastest signed.*/
+typedef uint32_t t_size; /* Size, use unsigned pointer equivalent.*/
#define INLINE inline