aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/src
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/src')
-rw-r--r--os/hal/src/serial.c66
1 files changed, 32 insertions, 34 deletions
diff --git a/os/hal/src/serial.c b/os/hal/src/serial.c
index 1372d5acc..49355ec33 100644
--- a/os/hal/src/serial.c
+++ b/os/hal/src/serial.c
@@ -48,50 +48,48 @@
static size_t writes(void *ip, const uint8_t *bp, size_t n) {
- return chOQWriteTimeout(&((SerialDriver *)ip)->sd.oqueue, bp,
+ return chOQWriteTimeout(&((SerialDriver *)ip)->oqueue, bp,
n, TIME_INFINITE);
}
static size_t reads(void *ip, uint8_t *bp, size_t n) {
- return chIQReadTimeout(&((SerialDriver *)ip)->sd.iqueue, bp,
+ return chIQReadTimeout(&((SerialDriver *)ip)->iqueue, bp,
n, TIME_INFINITE);
}
static bool_t putwouldblock(void *ip) {
- return chOQIsFull(&((SerialDriver *)ip)->sd.oqueue);
+ return chOQIsFull(&((SerialDriver *)ip)->oqueue);
}
static bool_t getwouldblock(void *ip) {
- return chIQIsEmpty(&((SerialDriver *)ip)->sd.iqueue);
+ return chIQIsEmpty(&((SerialDriver *)ip)->iqueue);
}
static msg_t putt(void *ip, uint8_t b, systime_t timeout) {
- return chOQPutTimeout(&((SerialDriver *)ip)->sd.oqueue, b, timeout);
+ return chOQPutTimeout(&((SerialDriver *)ip)->oqueue, b, timeout);
}
static msg_t gett(void *ip, systime_t timeout) {
- return chIQGetTimeout(&((SerialDriver *)ip)->sd.iqueue, timeout);
+ return chIQGetTimeout(&((SerialDriver *)ip)->iqueue, timeout);
}
static size_t writet(void *ip, const uint8_t *bp, size_t n, systime_t time) {
- return chOQWriteTimeout(&((SerialDriver *)ip)->sd.oqueue, bp, n, time);
+ return chOQWriteTimeout(&((SerialDriver *)ip)->oqueue, bp, n, time);
}
static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
- return chIQReadTimeout(&((SerialDriver *)ip)->sd.iqueue, bp, n, time);
+ return chIQReadTimeout(&((SerialDriver *)ip)->iqueue, bp, n, time);
}
static const struct SerialDriverVMT vmt = {
- {writes, reads},
- {putwouldblock, getwouldblock, putt, gett, writet, readt},
- {}
+ writes, reads, putwouldblock, getwouldblock, putt, gett, writet, readt
};
/*===========================================================================*/
@@ -122,13 +120,13 @@ void sdInit(void) {
void sdObjectInit(SerialDriver *sdp, qnotify_t inotify, qnotify_t onotify) {
sdp->vmt = &vmt;
- chEvtInit(&sdp->bac.ievent);
- chEvtInit(&sdp->bac.oevent);
- chEvtInit(&sdp->sd.sevent);
- sdp->sd.state = SD_STOP;
- sdp->sd.flags = SD_NO_ERROR;
- chIQInit(&sdp->sd.iqueue, sdp->sd.ib, SERIAL_BUFFERS_SIZE, inotify);
- chOQInit(&sdp->sd.oqueue, sdp->sd.ob, SERIAL_BUFFERS_SIZE, onotify);
+ chEvtInit(&sdp->ievent);
+ chEvtInit(&sdp->oevent);
+ chEvtInit(&sdp->sevent);
+ sdp->state = SD_STOP;
+ sdp->flags = SD_NO_ERROR;
+ chIQInit(&sdp->iqueue, sdp->ib, SERIAL_BUFFERS_SIZE, inotify);
+ chOQInit(&sdp->oqueue, sdp->ob, SERIAL_BUFFERS_SIZE, onotify);
}
/**
@@ -144,12 +142,12 @@ void sdStart(SerialDriver *sdp, const SerialConfig *config) {
chDbgCheck(sdp != NULL, "sdStart");
chSysLock();
- chDbgAssert((sdp->sd.state == SD_STOP) || (sdp->sd.state == SD_READY),
+ chDbgAssert((sdp->state == SD_STOP) || (sdp->state == SD_READY),
"sdStart(), #1",
"invalid state");
- sdp->sd.config = config;
+ sdp->config = config;
sd_lld_start(sdp);
- sdp->sd.state = SD_READY;
+ sdp->state = SD_READY;
chSysUnlock();
}
@@ -165,13 +163,13 @@ void sdStop(SerialDriver *sdp) {
chDbgCheck(sdp != NULL, "sdStop");
chSysLock();
- chDbgAssert((sdp->sd.state == SD_STOP) || (sdp->sd.state == SD_READY),
+ chDbgAssert((sdp->state == SD_STOP) || (sdp->state == SD_READY),
"sdStop(), #1",
"invalid state");
sd_lld_stop(sdp);
- sdp->sd.state = SD_STOP;
- chOQResetI(&sdp->sd.oqueue);
- chIQResetI(&sdp->sd.iqueue);
+ sdp->state = SD_STOP;
+ chOQResetI(&sdp->oqueue);
+ chIQResetI(&sdp->iqueue);
chSchRescheduleS();
chSysUnlock();
}
@@ -194,9 +192,9 @@ void sdIncomingDataI(SerialDriver *sdp, uint8_t b) {
chDbgCheck(sdp != NULL, "sdIncomingDataI");
- if (chIQIsEmpty(&sdp->sd.iqueue))
- chEvtBroadcastI(&sdp->bac.ievent);
- if (chIQPutI(&sdp->sd.iqueue, b) < Q_OK)
+ if (chIQIsEmpty(&sdp->iqueue))
+ chEvtBroadcastI(&sdp->ievent);
+ if (chIQPutI(&sdp->iqueue, b) < Q_OK)
sdAddFlagsI(sdp, SD_OVERRUN_ERROR);
}
@@ -217,9 +215,9 @@ msg_t sdRequestDataI(SerialDriver *sdp) {
chDbgCheck(sdp != NULL, "sdRequestDataI");
- msg_t b = chOQGetI(&sdp->sd.oqueue);
+ msg_t b = chOQGetI(&sdp->oqueue);
if (b < Q_OK)
- chEvtBroadcastI(&sdp->bac.oevent);
+ chEvtBroadcastI(&sdp->oevent);
return b;
}
@@ -235,8 +233,8 @@ void sdAddFlagsI(SerialDriver *sdp, sdflags_t mask) {
chDbgCheck(sdp != NULL, "sdAddFlagsI");
- sdp->sd.flags |= mask;
- chEvtBroadcastI(&sdp->sd.sevent);
+ sdp->flags |= mask;
+ chEvtBroadcastI(&sdp->sevent);
}
/**
@@ -252,8 +250,8 @@ sdflags_t sdGetAndClearFlags(SerialDriver *sdp) {
chDbgCheck(sdp != NULL, "sdGetAndClearFlags");
chSysLock();
- mask = sdp->sd.flags;
- sdp->sd.flags = SD_NO_ERROR;
+ mask = sdp->flags;
+ sdp->flags = SD_NO_ERROR;
chSysUnlock();
return mask;
}