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

master
gdisirio 2012-05-08 17:09:20 +00:00
parent ba6519a2ea
commit d0a2e55ed0
31 changed files with 190 additions and 505 deletions

View File

@ -74,7 +74,7 @@ static bool_t mmc_is_protected(void) {
/* Generic large buffer.*/ /* Generic large buffer.*/
uint8_t fbuff[1024]; uint8_t fbuff[1024];
static FRESULT scan_files(BaseChannel *chp, char *path) { static FRESULT scan_files(BaseSequentialStream *chp, char *path) {
FRESULT res; FRESULT res;
FILINFO fno; FILINFO fno;
DIR dir; DIR dir;
@ -114,7 +114,7 @@ static FRESULT scan_files(BaseChannel *chp, char *path) {
#define SHELL_WA_SIZE THD_WA_SIZE(1024) #define SHELL_WA_SIZE THD_WA_SIZE(1024)
#define TEST_WA_SIZE THD_WA_SIZE(256) #define TEST_WA_SIZE THD_WA_SIZE(256)
static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) { static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
size_t n, size; size_t n, size;
(void)argv; (void)argv;
@ -128,7 +128,7 @@ static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) {
chprintf(chp, "heap free total : %u bytes\r\n", size); chprintf(chp, "heap free total : %u bytes\r\n", size);
} }
static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) { static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
static const char *states[] = {THD_STATE_NAMES}; static const char *states[] = {THD_STATE_NAMES};
Thread *tp; Thread *tp;
@ -148,7 +148,7 @@ static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) {
} while (tp != NULL); } while (tp != NULL);
} }
static void cmd_test(BaseChannel *chp, int argc, char *argv[]) { static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
Thread *tp; Thread *tp;
(void)argv; (void)argv;
@ -165,7 +165,7 @@ static void cmd_test(BaseChannel *chp, int argc, char *argv[]) {
chThdWait(tp); chThdWait(tp);
} }
static void cmd_tree(BaseChannel *chp, int argc, char *argv[]) { static void cmd_tree(BaseSequentialStream *chp, int argc, char *argv[]) {
FRESULT err; FRESULT err;
uint32_t clusters; uint32_t clusters;
FATFS *fsp; FATFS *fsp;
@ -201,7 +201,7 @@ static const ShellCommand commands[] = {
}; };
static const ShellConfig shell_cfg1 = { static const ShellConfig shell_cfg1 = {
(BaseChannel *)&SD1, (BaseSequentialStream *)&SD1,
commands commands
}; };

View File

@ -74,7 +74,7 @@ static bool_t mmc_is_protected(void) {
/* Generic large buffer.*/ /* Generic large buffer.*/
uint8_t fbuff[1024]; uint8_t fbuff[1024];
static FRESULT scan_files(BaseChannel *chp, char *path) { static FRESULT scan_files(BaseSequentialStream *chp, char *path) {
FRESULT res; FRESULT res;
FILINFO fno; FILINFO fno;
DIR dir; DIR dir;
@ -114,7 +114,7 @@ static FRESULT scan_files(BaseChannel *chp, char *path) {
#define SHELL_WA_SIZE THD_WA_SIZE(1024) #define SHELL_WA_SIZE THD_WA_SIZE(1024)
#define TEST_WA_SIZE THD_WA_SIZE(256) #define TEST_WA_SIZE THD_WA_SIZE(256)
static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) { static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
size_t n, size; size_t n, size;
(void)argv; (void)argv;
@ -128,7 +128,7 @@ static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) {
chprintf(chp, "heap free total : %u bytes\r\n", size); chprintf(chp, "heap free total : %u bytes\r\n", size);
} }
static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) { static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
static const char *states[] = {THD_STATE_NAMES}; static const char *states[] = {THD_STATE_NAMES};
Thread *tp; Thread *tp;
@ -148,7 +148,7 @@ static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) {
} while (tp != NULL); } while (tp != NULL);
} }
static void cmd_test(BaseChannel *chp, int argc, char *argv[]) { static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
Thread *tp; Thread *tp;
(void)argv; (void)argv;
@ -165,7 +165,7 @@ static void cmd_test(BaseChannel *chp, int argc, char *argv[]) {
chThdWait(tp); chThdWait(tp);
} }
static void cmd_tree(BaseChannel *chp, int argc, char *argv[]) { static void cmd_tree(BaseSequentialStream *chp, int argc, char *argv[]) {
FRESULT err; FRESULT err;
uint32_t clusters; uint32_t clusters;
FATFS *fsp; FATFS *fsp;
@ -201,7 +201,7 @@ static const ShellCommand commands[] = {
}; };
static const ShellConfig shell_cfg1 = { static const ShellConfig shell_cfg1 = {
(BaseChannel *)&SD1, (BaseSequentialStream *)&SD1,
commands commands
}; };

View File

@ -62,7 +62,7 @@ static bool_t mmc_is_protected(void) {return !palReadPad(IOPORT3, GPIOC_MMCWP);}
/* Generic large buffer.*/ /* Generic large buffer.*/
uint8_t fbuff[1024]; uint8_t fbuff[1024];
static FRESULT scan_files(BaseChannel *chp, char *path) { static FRESULT scan_files(BaseSequentialStream *chp, char *path) {
FRESULT res; FRESULT res;
FILINFO fno; FILINFO fno;
DIR dir; DIR dir;
@ -102,7 +102,7 @@ static FRESULT scan_files(BaseChannel *chp, char *path) {
#define SHELL_WA_SIZE THD_WA_SIZE(2048) #define SHELL_WA_SIZE THD_WA_SIZE(2048)
#define TEST_WA_SIZE THD_WA_SIZE(256) #define TEST_WA_SIZE THD_WA_SIZE(256)
static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) { static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
size_t n, size; size_t n, size;
(void)argv; (void)argv;
@ -116,7 +116,7 @@ static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) {
chprintf(chp, "heap free total : %u bytes\r\n", size); chprintf(chp, "heap free total : %u bytes\r\n", size);
} }
static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) { static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
static const char *states[] = {THD_STATE_NAMES}; static const char *states[] = {THD_STATE_NAMES};
Thread *tp; Thread *tp;
@ -136,7 +136,7 @@ static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) {
} while (tp != NULL); } while (tp != NULL);
} }
static void cmd_test(BaseChannel *chp, int argc, char *argv[]) { static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
Thread *tp; Thread *tp;
(void)argv; (void)argv;
@ -153,7 +153,7 @@ static void cmd_test(BaseChannel *chp, int argc, char *argv[]) {
chThdWait(tp); chThdWait(tp);
} }
static void cmd_tree(BaseChannel *chp, int argc, char *argv[]) { static void cmd_tree(BaseSequentialStream *chp, int argc, char *argv[]) {
FRESULT err; FRESULT err;
uint32_t clusters; uint32_t clusters;
FATFS *fsp; FATFS *fsp;
@ -189,7 +189,7 @@ static const ShellCommand commands[] = {
}; };
static const ShellConfig shell_cfg1 = { static const ShellConfig shell_cfg1 = {
(BaseChannel *)&SD2, (BaseSequentialStream *)&SD2,
commands commands
}; };

View File

@ -141,7 +141,7 @@ static bool_t fs_ready = FALSE;
/* Generic large buffer.*/ /* Generic large buffer.*/
uint8_t fbuff[1024]; uint8_t fbuff[1024];
static FRESULT scan_files(BaseChannel *chp, char *path) { static FRESULT scan_files(BaseSequentialStream *chp, char *path) {
FRESULT res; FRESULT res;
FILINFO fno; FILINFO fno;
DIR dir; DIR dir;
@ -181,7 +181,7 @@ static FRESULT scan_files(BaseChannel *chp, char *path) {
#define SHELL_WA_SIZE THD_WA_SIZE(2048) #define SHELL_WA_SIZE THD_WA_SIZE(2048)
#define TEST_WA_SIZE THD_WA_SIZE(256) #define TEST_WA_SIZE THD_WA_SIZE(256)
static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) { static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
size_t n, size; size_t n, size;
(void)argv; (void)argv;
@ -195,7 +195,7 @@ static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) {
chprintf(chp, "heap free total : %u bytes\r\n", size); chprintf(chp, "heap free total : %u bytes\r\n", size);
} }
static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) { static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
static const char *states[] = {THD_STATE_NAMES}; static const char *states[] = {THD_STATE_NAMES};
Thread *tp; Thread *tp;
@ -215,7 +215,7 @@ static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) {
} while (tp != NULL); } while (tp != NULL);
} }
static void cmd_test(BaseChannel *chp, int argc, char *argv[]) { static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
Thread *tp; Thread *tp;
(void)argv; (void)argv;
@ -232,7 +232,7 @@ static void cmd_test(BaseChannel *chp, int argc, char *argv[]) {
chThdWait(tp); chThdWait(tp);
} }
static void cmd_tree(BaseChannel *chp, int argc, char *argv[]) { static void cmd_tree(BaseSequentialStream *chp, int argc, char *argv[]) {
FRESULT err; FRESULT err;
uint32_t clusters; uint32_t clusters;
FATFS *fsp; FATFS *fsp;
@ -268,7 +268,7 @@ static const ShellCommand commands[] = {
}; };
static const ShellConfig shell_cfg1 = { static const ShellConfig shell_cfg1 = {
(BaseChannel *)&SD1, (BaseSequentialStream *)&SD1,
commands commands
}; };

View File

@ -274,7 +274,7 @@ int main(void) {
x = (int8_t)lis302dlReadRegister(&SPID1, LIS302DL_OUTX); x = (int8_t)lis302dlReadRegister(&SPID1, LIS302DL_OUTX);
y = (int8_t)lis302dlReadRegister(&SPID1, LIS302DL_OUTY); y = (int8_t)lis302dlReadRegister(&SPID1, LIS302DL_OUTY);
z = (int8_t)lis302dlReadRegister(&SPID1, LIS302DL_OUTZ); z = (int8_t)lis302dlReadRegister(&SPID1, LIS302DL_OUTZ);
chprintf((BaseChannel *)&SD2, "%d, %d, %d\r\n", x, y, z); chprintf((BaseSequentialStream *)&SD2, "%d, %d, %d\r\n", x, y, z);
chThdSleepMilliseconds(500); chThdSleepMilliseconds(500);
} }
} }

View File

@ -29,7 +29,7 @@
#define SHELL_WA_SIZE THD_WA_SIZE(1024) #define SHELL_WA_SIZE THD_WA_SIZE(1024)
#define TEST_WA_SIZE THD_WA_SIZE(256) #define TEST_WA_SIZE THD_WA_SIZE(256)
static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) { static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
size_t n, size; size_t n, size;
(void)argv; (void)argv;
@ -43,7 +43,7 @@ static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) {
chprintf(chp, "heap free total : %u bytes\r\n", size); chprintf(chp, "heap free total : %u bytes\r\n", size);
} }
static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) { static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
static const char *states[] = {THD_STATE_NAMES}; static const char *states[] = {THD_STATE_NAMES};
Thread *tp; Thread *tp;
@ -63,7 +63,7 @@ static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) {
} while (tp != NULL); } while (tp != NULL);
} }
static void cmd_test(BaseChannel *chp, int argc, char *argv[]) { static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
Thread *tp; Thread *tp;
(void)argv; (void)argv;
@ -88,7 +88,7 @@ static const ShellCommand commands[] = {
}; };
static const ShellConfig shell_cfg1 = { static const ShellConfig shell_cfg1 = {
(BaseChannel *)&SD1, (BaseSequentialStream *)&SD1,
commands commands
}; };

View File

@ -71,7 +71,7 @@
* *
* @brief @p BaseChannel virtual methods table. * @brief @p BaseChannel virtual methods table.
*/ */
struct tmp_BaseChannelVMT { struct BaseChannelVMT {
_base_channel_methods _base_channel_methods
}; };
@ -86,7 +86,7 @@ typedef struct {
/** @brief Virtual Methods Table.*/ /** @brief Virtual Methods Table.*/
const struct BaseChannelVMT *vmt; const struct BaseChannelVMT *vmt;
_base_channel_data _base_channel_data
} tmp_BaseChannel; } BaseChannel;
/** /**
* @name Macro Functions (BaseChannel) * @name Macro Functions (BaseChannel)
@ -98,6 +98,7 @@ typedef struct {
* block. * block.
* *
* @param[in] ip pointer to a @p BaseChannel or derived class * @param[in] ip pointer to a @p BaseChannel or derived class
*
* @return The output queue status. * @return The output queue status.
* @retval FALSE if the output queue has space and would not block a * @retval FALSE if the output queue has space and would not block a
* write operation. * write operation.
@ -114,6 +115,7 @@ typedef struct {
* block. * block.
* *
* @param[in] ip pointer to a @p BaseChannel or derived class * @param[in] ip pointer to a @p BaseChannel or derived class
*
* @return The input queue status. * @return The input queue status.
* @retval FALSE if the input queue contains data and would not block a * @retval FALSE if the input queue contains data and would not block a
* read operation. * read operation.
@ -131,6 +133,7 @@ typedef struct {
* *
* @param[in] ip pointer to a @p BaseChannel or derived class * @param[in] ip pointer to a @p BaseChannel or derived class
* @param[in] b the byte value to be written to the channel * @param[in] b the byte value to be written to the channel
*
* @return The operation status. * @return The operation status.
* @retval Q_OK if the operation succeeded. * @retval Q_OK if the operation succeeded.
* @retval Q_RESET if the channel associated queue (if any) was reset. * @retval Q_RESET if the channel associated queue (if any) was reset.
@ -166,6 +169,7 @@ typedef struct {
* is not available then the calling thread is suspended. * is not available then the calling thread is suspended.
* *
* @param[in] ip pointer to a @p BaseChannel or derived class * @param[in] ip pointer to a @p BaseChannel or derived class
*
* @return A byte value from the queue. * @return A byte value from the queue.
* @retval Q_RESET if the channel associated queue (if any) has been * @retval Q_RESET if the channel associated queue (if any) has been
* reset. * reset.
@ -194,6 +198,21 @@ typedef struct {
*/ */
#define chnGetTimeout(ip, time) ((ip)->vmt->get(ip, time)) #define chnGetTimeout(ip, time) ((ip)->vmt->get(ip, time))
/**
* @brief Channel blocking write.
* @details The function writes data from a buffer to a channel. If the channel
* is not ready to accept data then the calling thread is suspended.
*
* @param[in] ip pointer to a @p BaseChannel or derived class
* @param[out] bp pointer to the data buffer
* @param[in] n the maximum amount of data to be transferred
*
* @return The number of bytes transferred.
*
* @api
*/
#define chnWrite(ip, bp, n) chSequentialStreamWrite(ip, bp, n)
/** /**
* @brief Channel blocking write with timeout. * @brief Channel blocking write with timeout.
* @details The function writes data from a buffer to a channel. If the channel * @details The function writes data from a buffer to a channel. If the channel
@ -213,6 +232,21 @@ typedef struct {
*/ */
#define chnWriteTimeout(ip, bp, n, time) ((ip)->vmt->writet(ip, bp, n, time)) #define chnWriteTimeout(ip, bp, n, time) ((ip)->vmt->writet(ip, bp, n, time))
/**
* @brief Channel blocking read.
* @details The function reads data from a channel into a buffer. If the data
* is not available then the calling thread is suspended.
*
* @param[in] ip pointer to a @p BaseChannel or derived class
* @param[in] bp pointer to the data buffer
* @param[in] n the maximum amount of data to be transferred
*
* @return The number of bytes transferred.
*
* @api
*/
#define chnRead(ip, bp, n) chSequentialStreamRead(ip, bp, n)
/** /**
* @brief Channel blocking read with timeout. * @brief Channel blocking read with timeout.
* @details The function reads data from a channel into a buffer. If the data * @details The function reads data from a channel into a buffer. If the data
@ -260,7 +294,7 @@ typedef uint_fast16_t chnflags_t;
/** /**
* @brief @p BaseAsynchronousChannel specific methods. * @brief @p BaseAsynchronousChannel specific methods.
*/ */
#define tmp__base_asynchronous_channel_methods \ #define _base_asynchronous_channel_methods \
_base_channel_methods \ _base_channel_methods \
/* Channel read method with timeout specification.*/ \ /* Channel read method with timeout specification.*/ \
chnflags_t (*getflags)(void *instance); chnflags_t (*getflags)(void *instance);
@ -268,7 +302,7 @@ typedef uint_fast16_t chnflags_t;
/** /**
* @brief @p BaseAsynchronousChannel specific data. * @brief @p BaseAsynchronousChannel specific data.
*/ */
#define tmp__base_asynchronous_channel_data \ #define _base_asynchronous_channel_data \
_base_channel_data \ _base_channel_data \
/* I/O condition event source.*/ \ /* I/O condition event source.*/ \
EventSource event; \ EventSource event; \
@ -280,7 +314,7 @@ typedef uint_fast16_t chnflags_t;
* *
* @brief @p BaseAsynchronousChannel virtual methods table. * @brief @p BaseAsynchronousChannel virtual methods table.
*/ */
struct tmp_BaseAsynchronousChannelVMT { struct BaseAsynchronousChannelVMT {
_base_asynchronous_channel_methods _base_asynchronous_channel_methods
}; };
@ -295,7 +329,7 @@ typedef struct {
/** @brief Virtual Methods Table.*/ /** @brief Virtual Methods Table.*/
const struct BaseAsynchronousChannelVMT *vmt; const struct BaseAsynchronousChannelVMT *vmt;
_base_asynchronous_channel_data _base_asynchronous_channel_data
} tmp_BaseAsynchronousChannel; } BaseAsynchronousChannel;
/** /**
* @name Macro Functions (BaseAsynchronousChannel) * @name Macro Functions (BaseAsynchronousChannel)

View File

@ -139,7 +139,7 @@ static void usart_deinit(AT91PS_USART u) {
* @param[in] sdp communication channel associated to the USART * @param[in] sdp communication channel associated to the USART
*/ */
static void set_error(SerialDriver *sdp, AT91_REG csr) { static void set_error(SerialDriver *sdp, AT91_REG csr) {
ioflags_t sts = 0; chnflags_t sts = 0;
if (csr & AT91C_US_OVRE) if (csr & AT91C_US_OVRE)
sts |= SD_OVERRUN_ERROR; sts |= SD_OVERRUN_ERROR;
@ -150,7 +150,7 @@ static void set_error(SerialDriver *sdp, AT91_REG csr) {
if (csr & AT91C_US_RXBRK) if (csr & AT91C_US_RXBRK)
sts |= SD_BREAK_DETECTED; sts |= SD_BREAK_DETECTED;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, sts); chnAddFlagsI(sdp, sts);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
} }
@ -181,7 +181,7 @@ void sd_lld_serve_interrupt(SerialDriver *sdp) {
chSysLockFromIsr(); chSysLockFromIsr();
b = chOQGetI(&sdp->oqueue); b = chOQGetI(&sdp->oqueue);
if (b < Q_OK) { if (b < Q_OK) {
chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY); chnAddFlagsI(sdp, CHN_OUTPUT_EMPTY);
u->US_IDR = AT91C_US_TXRDY; u->US_IDR = AT91C_US_TXRDY;
} }
else else

View File

@ -70,7 +70,7 @@ static const SerialConfig default_config = {
/*===========================================================================*/ /*===========================================================================*/
static void set_error(uint8_t sra, SerialDriver *sdp) { static void set_error(uint8_t sra, SerialDriver *sdp) {
ioflags_t sts = 0; chnflags_t sts = 0;
if (sra & (1 << DOR)) if (sra & (1 << DOR))
sts |= SD_OVERRUN_ERROR; sts |= SD_OVERRUN_ERROR;
@ -79,7 +79,7 @@ static void set_error(uint8_t sra, SerialDriver *sdp) {
if (sra & (1 << FE)) if (sra & (1 << FE))
sts |= SD_FRAMING_ERROR; sts |= SD_FRAMING_ERROR;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, sts); chnAddFlagsI(sdp, sts);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
} }

View File

@ -101,7 +101,7 @@ static void uart_deinit(LPC_UART_TypeDef *u) {
* @param[in] err UART LSR register value * @param[in] err UART LSR register value
*/ */
static void set_error(SerialDriver *sdp, IOREG32 err) { static void set_error(SerialDriver *sdp, IOREG32 err) {
ioflags_t sts = 0; chnflags_t sts = 0;
if (err & LSR_OVERRUN) if (err & LSR_OVERRUN)
sts |= SD_OVERRUN_ERROR; sts |= SD_OVERRUN_ERROR;
@ -112,7 +112,7 @@ static void set_error(SerialDriver *sdp, IOREG32 err) {
if (err & LSR_BREAK) if (err & LSR_BREAK)
sts |= SD_BREAK_DETECTED; sts |= SD_BREAK_DETECTED;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, sts); chnAddFlagsI(sdp, sts);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
} }
@ -139,12 +139,12 @@ static void serve_interrupt(SerialDriver *sdp) {
case IIR_SRC_RX: case IIR_SRC_RX:
chSysLockFromIsr(); chSysLockFromIsr();
if (chIQIsEmptyI(&sdp->iqueue)) if (chIQIsEmptyI(&sdp->iqueue))
chIOAddFlagsI(sdp, IO_INPUT_AVAILABLE); chnAddFlagsI(sdp, CHN_INPUT_AVAILABLE);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
while (u->LSR & LSR_RBR_FULL) { while (u->LSR & LSR_RBR_FULL) {
chSysLockFromIsr(); chSysLockFromIsr();
if (chIQPutI(&sdp->iqueue, u->RBR) < Q_OK) if (chIQPutI(&sdp->iqueue, u->RBR) < Q_OK)
chIOAddFlagsI(sdp, SD_OVERRUN_ERROR); chnAddFlagsI(sdp, SD_OVERRUN_ERROR);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
} }
break; break;
@ -160,7 +160,7 @@ static void serve_interrupt(SerialDriver *sdp) {
if (b < Q_OK) { if (b < Q_OK) {
u->IER &= ~IER_THRE; u->IER &= ~IER_THRE;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY); chnAddFlagsI(sdp, CHN_OUTPUT_EMPTY);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
break; break;
} }
@ -186,7 +186,7 @@ static void preload(SerialDriver *sdp) {
do { do {
msg_t b = chOQGetI(&sdp->oqueue); msg_t b = chOQGetI(&sdp->oqueue);
if (b < Q_OK) { if (b < Q_OK) {
chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY); chnAddFlagsI(sdp, CHN_OUTPUT_EMPTY);
return; return;
} }
u->THR = b; u->THR = b;

View File

@ -101,7 +101,7 @@ static void uart_deinit(LPC_UART_TypeDef *u) {
* @param[in] err UART LSR register value * @param[in] err UART LSR register value
*/ */
static void set_error(SerialDriver *sdp, IOREG32 err) { static void set_error(SerialDriver *sdp, IOREG32 err) {
ioflags_t sts = 0; chnflags_t sts = 0;
if (err & LSR_OVERRUN) if (err & LSR_OVERRUN)
sts |= SD_OVERRUN_ERROR; sts |= SD_OVERRUN_ERROR;
@ -112,7 +112,7 @@ static void set_error(SerialDriver *sdp, IOREG32 err) {
if (err & LSR_BREAK) if (err & LSR_BREAK)
sts |= SD_BREAK_DETECTED; sts |= SD_BREAK_DETECTED;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, sts); chnAddFlagsI(sdp, sts);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
} }
@ -139,12 +139,12 @@ static void serve_interrupt(SerialDriver *sdp) {
case IIR_SRC_RX: case IIR_SRC_RX:
chSysLockFromIsr(); chSysLockFromIsr();
if (chIQIsEmptyI(&sdp->iqueue)) if (chIQIsEmptyI(&sdp->iqueue))
chIOAddFlagsI(sdp, IO_INPUT_AVAILABLE); chnAddFlagsI(sdp, CHN_INPUT_AVAILABLE);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
while (u->LSR & LSR_RBR_FULL) { while (u->LSR & LSR_RBR_FULL) {
chSysLockFromIsr(); chSysLockFromIsr();
if (chIQPutI(&sdp->iqueue, u->RBR) < Q_OK) if (chIQPutI(&sdp->iqueue, u->RBR) < Q_OK)
chIOAddFlagsI(sdp, SD_OVERRUN_ERROR); chnAddFlagsI(sdp, SD_OVERRUN_ERROR);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
} }
break; break;
@ -160,7 +160,7 @@ static void serve_interrupt(SerialDriver *sdp) {
if (b < Q_OK) { if (b < Q_OK) {
u->IER &= ~IER_THRE; u->IER &= ~IER_THRE;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY); chnAddFlagsI(sdp, CHN_OUTPUT_EMPTY);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
break; break;
} }
@ -186,7 +186,7 @@ static void preload(SerialDriver *sdp) {
do { do {
msg_t b = chOQGetI(&sdp->oqueue); msg_t b = chOQGetI(&sdp->oqueue);
if (b < Q_OK) { if (b < Q_OK) {
chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY); chnAddFlagsI(sdp, CHN_OUTPUT_EMPTY);
return; return;
} }
u->THR = b; u->THR = b;

View File

@ -106,7 +106,7 @@ static void uart_deinit(UART *u) {
* @param[in] err UART LSR register value * @param[in] err UART LSR register value
*/ */
static void set_error(SerialDriver *sdp, IOREG32 err) { static void set_error(SerialDriver *sdp, IOREG32 err) {
ioflags_t sts = 0; chnflags_t sts = 0;
if (err & LSR_OVERRUN) if (err & LSR_OVERRUN)
sts |= SD_OVERRUN_ERROR; sts |= SD_OVERRUN_ERROR;
@ -117,7 +117,7 @@ static void set_error(SerialDriver *sdp, IOREG32 err) {
if (err & LSR_BREAK) if (err & LSR_BREAK)
sts |= SD_BREAK_DETECTED; sts |= SD_BREAK_DETECTED;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, sts); chnAddFlagsI(sdp, sts);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
} }
@ -145,12 +145,12 @@ static void serve_interrupt(SerialDriver *sdp) {
case IIR_SRC_RX: case IIR_SRC_RX:
chSysLockFromIsr(); chSysLockFromIsr();
if (chIQIsEmptyI(&sdp->iqueue)) if (chIQIsEmptyI(&sdp->iqueue))
chIOAddFlagsI(sdp, IO_INPUT_AVAILABLE); chnAddFlagsI(sdp, CHN_INPUT_AVAILABLE);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
while (u->UART_LSR & LSR_RBR_FULL) { while (u->UART_LSR & LSR_RBR_FULL) {
chSysLockFromIsr(); chSysLockFromIsr();
if (chIQPutI(&sdp->iqueue, u->UART_RBR) < Q_OK) if (chIQPutI(&sdp->iqueue, u->UART_RBR) < Q_OK)
chIOAddFlagsI(sdp, SD_OVERRUN_ERROR); chnAddFlagsI(sdp, SD_OVERRUN_ERROR);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
} }
break; break;
@ -166,7 +166,7 @@ static void serve_interrupt(SerialDriver *sdp) {
if (b < Q_OK) { if (b < Q_OK) {
u->UART_IER &= ~IER_THRE; u->UART_IER &= ~IER_THRE;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY); chnAddFlagsI(sdp, CHN_OUTPUT_EMPTY);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
break; break;
} }
@ -192,7 +192,7 @@ static void preload(SerialDriver *sdp) {
do { do {
msg_t b = chOQGetI(&sdp->oqueue); msg_t b = chOQGetI(&sdp->oqueue);
if (b < Q_OK) { if (b < Q_OK) {
chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY); chnAddFlagsI(sdp, CHN_OUTPUT_EMPTY);
return; return;
} }
u->UART_THR = b; u->UART_THR = b;

View File

@ -60,7 +60,7 @@ static const SerialConfig default_config = {
/*===========================================================================*/ /*===========================================================================*/
static void set_error(SerialDriver *sdp, uint8_t urctl) { static void set_error(SerialDriver *sdp, uint8_t urctl) {
ioflags_t sts = 0; chnflags_t sts = 0;
if (urctl & OE) if (urctl & OE)
sts |= SD_OVERRUN_ERROR; sts |= SD_OVERRUN_ERROR;
@ -71,7 +71,7 @@ static void set_error(SerialDriver *sdp, uint8_t urctl) {
if (urctl & BRK) if (urctl & BRK)
sts |= SD_BREAK_DETECTED; sts |= SD_BREAK_DETECTED;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, sts); chnAddFlagsI(sdp, sts);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
} }

View File

@ -121,7 +121,7 @@ static bool_t connint(SerialDriver *sdp) {
goto abort; goto abort;
} }
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, IO_CONNECTED); chnAddFlagsI(sdp, CHN_CONNECTED);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
return TRUE; return TRUE;
} }
@ -149,7 +149,7 @@ static bool_t inint(SerialDriver *sdp) {
close(sdp->com_data); close(sdp->com_data);
sdp->com_data = INVALID_SOCKET; sdp->com_data = INVALID_SOCKET;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, IO_DISCONNECTED); chnAddFlagsI(sdp, CHN_DISCONNECTED);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
return FALSE; return FALSE;
case INVALID_SOCKET: case INVALID_SOCKET:
@ -190,7 +190,7 @@ static bool_t outint(SerialDriver *sdp) {
close(sdp->com_data); close(sdp->com_data);
sdp->com_data = INVALID_SOCKET; sdp->com_data = INVALID_SOCKET;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, IO_DISCONNECTED); chnAddFlagsI(sdp, CHN_DISCONNECTED);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
return FALSE; return FALSE;
case INVALID_SOCKET: case INVALID_SOCKET:

View File

@ -117,7 +117,7 @@ static void esci_deinit(volatile struct ESCI_tag *escip) {
* @param[in] sr eSCI SR register value * @param[in] sr eSCI SR register value
*/ */
static void set_error(SerialDriver *sdp, uint32_t sr) { static void set_error(SerialDriver *sdp, uint32_t sr) {
ioflags_t sts = 0; chnflags_t sts = 0;
if (sr & 0x08000000) if (sr & 0x08000000)
sts |= SD_OVERRUN_ERROR; sts |= SD_OVERRUN_ERROR;
@ -130,7 +130,7 @@ static void set_error(SerialDriver *sdp, uint32_t sr) {
/* if (sr & 0x00000000) /* if (sr & 0x00000000)
sts |= SD_BREAK_DETECTED;*/ sts |= SD_BREAK_DETECTED;*/
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, sts); chnAddFlagsI(sdp, sts);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
} }
@ -156,7 +156,7 @@ static void serve_interrupt(SerialDriver *sdp) {
chSysLockFromIsr(); chSysLockFromIsr();
b = chOQGetI(&sdp->oqueue); b = chOQGetI(&sdp->oqueue);
if (b < Q_OK) { if (b < Q_OK) {
chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY); chnAddFlagsI(sdp, CHN_OUTPUT_EMPTY);
escip->CR1.B.TIE = 0; escip->CR1.B.TIE = 0;
} }
else { else {

View File

@ -140,7 +140,7 @@ static void usart_deinit(USART_TypeDef *u) {
* @param[in] sr USART SR register value * @param[in] sr USART SR register value
*/ */
static void set_error(SerialDriver *sdp, uint16_t sr) { static void set_error(SerialDriver *sdp, uint16_t sr) {
ioflags_t sts = 0; chnflags_t sts = 0;
if (sr & USART_SR_ORE) if (sr & USART_SR_ORE)
sts |= SD_OVERRUN_ERROR; sts |= SD_OVERRUN_ERROR;
@ -151,7 +151,7 @@ static void set_error(SerialDriver *sdp, uint16_t sr) {
if (sr & USART_SR_NE) if (sr & USART_SR_NE)
sts |= SD_NOISE_ERROR; sts |= SD_NOISE_ERROR;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, sts); chnAddFlagsI(sdp, sts);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
} }
@ -172,7 +172,7 @@ static void serve_interrupt(SerialDriver *sdp) {
/* Special case, LIN break detection.*/ /* Special case, LIN break detection.*/
if (sr & USART_SR_LBD) { if (sr & USART_SR_LBD) {
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, SD_BREAK_DETECTED); chnAddFlagsI(sdp, SD_BREAK_DETECTED);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
u->SR &= ~USART_SR_LBD; u->SR &= ~USART_SR_LBD;
} }
@ -188,7 +188,7 @@ static void serve_interrupt(SerialDriver *sdp) {
chSysLockFromIsr(); chSysLockFromIsr();
b = chOQGetI(&sdp->oqueue); b = chOQGetI(&sdp->oqueue);
if (b < Q_OK) { if (b < Q_OK) {
chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY); chnAddFlagsI(sdp, CHN_OUTPUT_EMPTY);
u->CR1 = (cr1 & ~USART_CR1_TXEIE) | USART_CR1_TCIE; u->CR1 = (cr1 & ~USART_CR1_TXEIE) | USART_CR1_TCIE;
} }
else else
@ -198,7 +198,7 @@ static void serve_interrupt(SerialDriver *sdp) {
/* Physical transmission end.*/ /* Physical transmission end.*/
if (sr & USART_SR_TC) { if (sr & USART_SR_TC) {
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, IO_TRANSMISSION_END); chnAddFlagsI(sdp, CHN_TRANSMISSION_END);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
u->CR1 = cr1 & ~USART_CR1_TCIE; u->CR1 = cr1 & ~USART_CR1_TCIE;
u->SR &= ~USART_SR_TC; u->SR &= ~USART_SR_TC;

View File

@ -115,7 +115,7 @@ static void notify3(GenericQueue *qp) {
* @notapi * @notapi
*/ */
void sd_lld_set_error(SerialDriver *sdp, uint8_t sr) { void sd_lld_set_error(SerialDriver *sdp, uint8_t sr) {
ioflags_t sts = 0; chnflags_t sts = 0;
if (sr & USART_SR_OR) if (sr & USART_SR_OR)
sts |= SD_OVERRUN_ERROR; sts |= SD_OVERRUN_ERROR;
@ -126,7 +126,7 @@ void sd_lld_set_error(SerialDriver *sdp, uint8_t sr) {
if (sr & USART_SR_PE) if (sr & USART_SR_PE)
sts |= SD_PARITY_ERROR; sts |= SD_PARITY_ERROR;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, sts); chnAddFlagsI(sdp, sts);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
} }

View File

@ -73,7 +73,7 @@ static ROMCONST SerialConfig default_config = {
/*===========================================================================*/ /*===========================================================================*/
static void set_error(SerialDriver *sdp, uint8_t sr) { static void set_error(SerialDriver *sdp, uint8_t sr) {
ioflags_t sts = 0; chnflags_t sts = 0;
/* Note, SR register bit definitions are equal for all UARTs so using /* Note, SR register bit definitions are equal for all UARTs so using
the UART1 definitions is fine.*/ the UART1 definitions is fine.*/
@ -86,7 +86,7 @@ static void set_error(SerialDriver *sdp, uint8_t sr) {
if (sr & UART1_SR_PE) if (sr & UART1_SR_PE)
sts |= SD_PARITY_ERROR; sts |= SD_PARITY_ERROR;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, sts); chnAddFlagsI(sdp, sts);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
} }

View File

@ -114,7 +114,7 @@ static bool_t connint(SerialDriver *sdp) {
goto abort; goto abort;
} }
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, IO_CONNECTED); chnAddFlagsI(sdp, CHN_CONNECTED);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
return TRUE; return TRUE;
} }
@ -143,7 +143,7 @@ static bool_t inint(SerialDriver *sdp) {
closesocket(sdp->com_data); closesocket(sdp->com_data);
sdp->com_data = INVALID_SOCKET; sdp->com_data = INVALID_SOCKET;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, IO_DISCONNECTED); chnAddFlagsI(sdp, CHN_DISCONNECTED);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
return FALSE; return FALSE;
case SOCKET_ERROR: case SOCKET_ERROR:
@ -184,7 +184,7 @@ static bool_t outint(SerialDriver *sdp) {
closesocket(sdp->com_data); closesocket(sdp->com_data);
sdp->com_data = INVALID_SOCKET; sdp->com_data = INVALID_SOCKET;
chSysLockFromIsr(); chSysLockFromIsr();
chIOAddFlagsI(sdp, IO_DISCONNECTED); chnAddFlagsI(sdp, CHN_DISCONNECTED);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
return FALSE; return FALSE;
case SOCKET_ERROR: case SOCKET_ERROR:

View File

@ -94,8 +94,8 @@ static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
return chIQReadTimeout(&((SerialDriver *)ip)->iqueue, bp, n, time); return chIQReadTimeout(&((SerialDriver *)ip)->iqueue, bp, n, time);
} }
static ioflags_t getflags(void *ip) { static chnflags_t getflags(void *ip) {
_ch_get_and_clear_flags_impl(ip); _chn_get_and_clear_flags_impl(ip);
} }
static const struct SerialDriverVMT vmt = { static const struct SerialDriverVMT vmt = {
@ -139,7 +139,7 @@ void sdObjectInit(SerialDriver *sdp, qnotify_t inotify, qnotify_t onotify) {
sdp->vmt = &vmt; sdp->vmt = &vmt;
chEvtInit(&sdp->event); chEvtInit(&sdp->event);
sdp->flags = IO_NO_ERROR; sdp->flags = CHN_NO_ERROR;
sdp->state = SD_STOP; sdp->state = SD_STOP;
chIQInit(&sdp->iqueue, sdp->ib, SERIAL_BUFFERS_SIZE, inotify); chIQInit(&sdp->iqueue, sdp->ib, SERIAL_BUFFERS_SIZE, inotify);
chOQInit(&sdp->oqueue, sdp->ob, SERIAL_BUFFERS_SIZE, onotify); chOQInit(&sdp->oqueue, sdp->ob, SERIAL_BUFFERS_SIZE, onotify);
@ -215,9 +215,9 @@ void sdIncomingDataI(SerialDriver *sdp, uint8_t b) {
chDbgCheck(sdp != NULL, "sdIncomingDataI"); chDbgCheck(sdp != NULL, "sdIncomingDataI");
if (chIQIsEmptyI(&sdp->iqueue)) if (chIQIsEmptyI(&sdp->iqueue))
chIOAddFlagsI(sdp, IO_INPUT_AVAILABLE); chnAddFlagsI(sdp, CHN_INPUT_AVAILABLE);
if (chIQPutI(&sdp->iqueue, b) < Q_OK) if (chIQPutI(&sdp->iqueue, b) < Q_OK)
chIOAddFlagsI(sdp, SD_OVERRUN_ERROR); chnAddFlagsI(sdp, SD_OVERRUN_ERROR);
} }
/** /**
@ -243,7 +243,7 @@ msg_t sdRequestDataI(SerialDriver *sdp) {
b = chOQGetI(&sdp->oqueue); b = chOQGetI(&sdp->oqueue);
if (b < Q_OK) if (b < Q_OK)
chIOAddFlagsI(sdp, IO_OUTPUT_EMPTY); chnAddFlagsI(sdp, CHN_OUTPUT_EMPTY);
return b; return b;
} }

View File

@ -103,7 +103,7 @@ static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
return chIQReadTimeout(&((SerialUSBDriver *)ip)->iqueue, bp, n, time); return chIQReadTimeout(&((SerialUSBDriver *)ip)->iqueue, bp, n, time);
} }
static ioflags_t getflags(void *ip) { static chnflags_t getflags(void *ip) {
_ch_get_and_clear_flags_impl(ip); _ch_get_and_clear_flags_impl(ip);
} }
@ -133,7 +133,7 @@ static void inotify(GenericQueue *qp) {
chSysLock(); chSysLock();
usbStartReceiveI(sdup->config->usbp, USB_CDC_DATA_AVAILABLE_EP); usbStartReceiveI(sdup->config->usbp, USB_CDC_DATA_AVAILABLE_EP);
chIOAddFlagsI(sdup, IO_INPUT_AVAILABLE); chnAddFlagsI(sdup, CHN_INPUT_AVAILABLE);
sdup->iqueue.q_rdptr = sdup->iqueue.q_buffer; sdup->iqueue.q_rdptr = sdup->iqueue.q_buffer;
sdup->iqueue.q_counter = n; sdup->iqueue.q_counter = n;
while (notempty(&sdup->iqueue.q_waiting)) while (notempty(&sdup->iqueue.q_waiting))
@ -160,7 +160,7 @@ static void onotify(GenericQueue *qp) {
chSysLock(); chSysLock();
usbStartTransmitI(sdup->config->usbp, USB_CDC_DATA_REQUEST_EP); usbStartTransmitI(sdup->config->usbp, USB_CDC_DATA_REQUEST_EP);
chIOAddFlagsI(sdup, IO_OUTPUT_EMPTY); chnAddFlagsI(sdup, CHN_OUTPUT_EMPTY);
sdup->oqueue.q_wrptr = sdup->oqueue.q_buffer; sdup->oqueue.q_wrptr = sdup->oqueue.q_buffer;
sdup->oqueue.q_counter = chQSizeI(&sdup->oqueue); sdup->oqueue.q_counter = chQSizeI(&sdup->oqueue);
while (notempty(&sdup->oqueue.q_waiting)) while (notempty(&sdup->oqueue.q_waiting))
@ -195,7 +195,7 @@ void sduObjectInit(SerialUSBDriver *sdup) {
sdup->vmt = &vmt; sdup->vmt = &vmt;
chEvtInit(&sdup->event); chEvtInit(&sdup->event);
sdup->flags = IO_NO_ERROR; sdup->flags = CHN_NO_ERROR;
sdup->state = SDU_STOP; sdup->state = SDU_STOP;
chIQInit(&sdup->iqueue, sdup->ib, SERIAL_USB_BUFFERS_SIZE, inotify); chIQInit(&sdup->iqueue, sdup->ib, SERIAL_USB_BUFFERS_SIZE, inotify);
chOQInit(&sdup->oqueue, sdup->ob, SERIAL_USB_BUFFERS_SIZE, onotify); chOQInit(&sdup->oqueue, sdup->ob, SERIAL_USB_BUFFERS_SIZE, onotify);
@ -312,7 +312,7 @@ void sduDataTransmitted(USBDriver *usbp, usbep_t ep) {
chSysLockFromIsr(); chSysLockFromIsr();
usbStartTransmitI(usbp, ep); usbStartTransmitI(usbp, ep);
chIOAddFlagsI(sdup, IO_OUTPUT_EMPTY); chnAddFlagsI(sdup, CHN_OUTPUT_EMPTY);
sdup->oqueue.q_wrptr = sdup->oqueue.q_buffer; sdup->oqueue.q_wrptr = sdup->oqueue.q_buffer;
sdup->oqueue.q_counter = chQSizeI(&sdup->oqueue); sdup->oqueue.q_counter = chQSizeI(&sdup->oqueue);
while (notempty(&sdup->oqueue.q_waiting)) while (notempty(&sdup->oqueue.q_waiting))
@ -348,7 +348,7 @@ void sduDataReceived(USBDriver *usbp, usbep_t ep) {
chSysLockFromIsr(); chSysLockFromIsr();
usbStartReceiveI(usbp, ep); usbStartReceiveI(usbp, ep);
chIOAddFlagsI(sdup, IO_INPUT_AVAILABLE); chnAddFlagsI(sdup, CHN_INPUT_AVAILABLE);
sdup->iqueue.q_rdptr = sdup->iqueue.q_buffer; sdup->iqueue.q_rdptr = sdup->iqueue.q_buffer;
sdup->iqueue.q_counter = n; sdup->iqueue.q_counter = n;
while (notempty(&sdup->iqueue.q_waiting)) while (notempty(&sdup->iqueue.q_waiting))

View File

@ -123,7 +123,6 @@
#include "chinline.h" #include "chinline.h"
#include "chqueues.h" #include "chqueues.h"
#include "chstreams.h" #include "chstreams.h"
#include "chioch.h"
#include "chfiles.h" #include "chfiles.h"
#include "chdebug.h" #include "chdebug.h"

View File

@ -1,370 +0,0 @@
/*
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
2011,2012 Giovanni Di Sirio.
This file is part of ChibiOS/RT.
ChibiOS/RT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
ChibiOS/RT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file chioch.h
* @brief I/O channels.
* @details This header defines abstract interfaces useful to access generic
* I/O resources in a standardized way.
*
* @addtogroup io_channels
* @details This module defines an abstract interface for I/O channels by
* extending the @p BaseSequentialStream interface. Note that no code
* is present, I/O channels are just abstract interface like
* structures, you should look at the systems as to a set of abstract
* C++ classes (even if written in C). Specific device drivers can
* use/extend the interface and implement them.<br>
* This system has the advantage to make the access to channels
* independent from the implementation logic.
* @{
*/
#ifndef _CHIOCH_H_
#define _CHIOCH_H_
/**
* @brief @p BaseChannel specific methods.
*/
#define _base_channel_methods \
_base_sequential_stream_methods \
/* Channel output check.*/ \
bool_t (*putwouldblock)(void *instance); \
/* Channel input check.*/ \
bool_t (*getwouldblock)(void *instance); \
/* Channel put method with timeout specification.*/ \
msg_t (*put)(void *instance, uint8_t b, systime_t time); \
/* Channel get method with timeout specification.*/ \
msg_t (*get)(void *instance, systime_t time); \
/* Channel write method with timeout specification.*/ \
size_t (*writet)(void *instance, const uint8_t *bp, \
size_t n, systime_t time); \
/* Channel read method with timeout specification.*/ \
size_t (*readt)(void *instance, uint8_t *bp, size_t n, systime_t time);
/**
* @brief @p BaseChannel specific data.
* @note It is empty because @p BaseChannel is only an interface without
* implementation.
*/
#define _base_channel_data \
_base_sequential_stream_data
/**
* @extends BaseSequentialStreamVMT
*
* @brief @p BaseChannel virtual methods table.
*/
struct BaseChannelVMT {
_base_channel_methods
};
/**
* @extends BaseSequentialStream
*
* @brief Base channel class.
* @details This class represents a generic, byte-wide, I/O channel. This class
* introduces generic I/O primitives with timeout specification.
*/
typedef struct {
/** @brief Virtual Methods Table.*/
const struct BaseChannelVMT *vmt;
_base_channel_data
} BaseChannel;
/**
* @name Macro Functions (BaseChannel)
* @{
*/
/**
* @brief Channel output check.
* @details This function verifies if a subsequent put/write operation would
* block.
*
* @param[in] ip pointer to a @p BaseChannel or derived class
* @return The output queue status.
* @retval FALSE if the output queue has space and would not block a
* write operation.
* @retval TRUE if the output queue is full and would block a write
* operation.
*
* @api
*/
#define chIOPutWouldBlock(ip) ((ip)->vmt->putwouldblock(ip))
/**
* @brief Channel input check.
* @details This function verifies if a subsequent get/read operation would
* block.
*
* @param[in] ip pointer to a @p BaseChannel or derived class
* @return The input queue status.
* @retval FALSE if the input queue contains data and would not block a
* read operation.
* @retval TRUE if the input queue is empty and would block a read
* operation.
*
* @api
*/
#define chIOGetWouldBlock(ip) ((ip)->vmt->getwouldblock(ip))
/**
* @brief Channel blocking byte write.
* @details This function writes a byte value to a channel. If the channel
* is not ready to accept data then the calling thread is suspended.
*
* @param[in] ip pointer to a @p BaseChannel or derived class
* @param[in] b the byte value to be written to the channel
* @return The operation status.
* @retval Q_OK if the operation succeeded.
* @retval Q_RESET if the channel associated queue (if any) was reset.
*
* @api
*/
#define chIOPut(ip, b) ((ip)->vmt->put(ip, b, TIME_INFINITE))
/**
* @brief Channel blocking byte write with timeout.
* @details This function writes a byte value to a channel. If the channel
* is not ready to accept data then the calling thread is suspended.
*
* @param[in] ip pointer to a @p BaseChannel or derived class
* @param[in] b the byte value to be written to the channel
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
* - @a TIME_IMMEDIATE immediate timeout.
* - @a TIME_INFINITE no timeout.
* .
* @return The operation status.
* @retval Q_OK if the operation succeeded.
* @retval Q_TIMEOUT if the specified time expired.
* @retval Q_RESET if the channel associated queue (if any) was reset.
*
* @api
*/
#define chIOPutTimeout(ip, b, time) ((ip)->vmt->put(ip, b, time))
/**
* @brief Channel blocking byte read.
* @details This function reads a byte value from a channel. If the data
* is not available then the calling thread is suspended.
*
* @param[in] ip pointer to a @p BaseChannel or derived class
* @return A byte value from the queue.
* @retval Q_RESET if the channel associated queue (if any) has been
* reset.
*
* @api
*/
#define chIOGet(ip) ((ip)->vmt->get(ip, TIME_INFINITE))
/**
* @brief Channel blocking byte read with timeout.
* @details This function reads a byte value from a channel. If the data
* is not available then the calling thread is suspended.
*
* @param[in] ip pointer to a @p BaseChannel or derived class
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
* - @a TIME_IMMEDIATE immediate timeout.
* - @a TIME_INFINITE no timeout.
* .
* @return A byte value from the queue.
* @retval Q_TIMEOUT if the specified time expired.
* @retval Q_RESET if the channel associated queue (if any) has been
* reset.
*
* @api
*/
#define chIOGetTimeout(ip, time) ((ip)->vmt->get(ip, time))
/**
* @brief Channel blocking write with timeout.
* @details The function writes data from a buffer to a channel. If the channel
* is not ready to accept data then the calling thread is suspended.
*
* @param[in] ip pointer to a @p BaseChannel or derived class
* @param[out] bp pointer to the data buffer
* @param[in] n the maximum amount of data to be transferred
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
* - @a TIME_IMMEDIATE immediate timeout.
* - @a TIME_INFINITE no timeout.
* .
* @return The number of bytes transferred.
*
* @api
*/
#define chIOWriteTimeout(ip, bp, n, time) \
((ip)->vmt->writet(ip, bp, n, time))
/**
* @brief Channel blocking read with timeout.
* @details The function reads data from a channel into a buffer. If the data
* is not available then the calling thread is suspended.
*
* @param[in] ip pointer to a @p BaseChannel or derived class
* @param[in] bp pointer to the data buffer
* @param[in] n the maximum amount of data to be transferred
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
* - @a TIME_IMMEDIATE immediate timeout.
* - @a TIME_INFINITE no timeout.
* .
* @return The number of bytes transferred.
*
* @api
*/
#define chIOReadTimeout(ip, bp, n, time) \
((ip)->vmt->readt(ip, bp, n, time))
/** @} */
#if CH_USE_EVENTS || defined(__DOXYGEN__)
/**
* @name I/O status flags
* @{
*/
/** @brief No pending conditions.*/
#define IO_NO_ERROR 0
/** @brief Connection happened.*/
#define IO_CONNECTED 1
/** @brief Disconnection happened.*/
#define IO_DISCONNECTED 2
/** @brief Data available in the input queue.*/
#define IO_INPUT_AVAILABLE 4
/** @brief Output queue empty.*/
#define IO_OUTPUT_EMPTY 8
/** @brief Transmission end.*/
#define IO_TRANSMISSION_END 16
/** @} */
/**
* @brief Type of an I/O condition flags mask.
*/
typedef uint_fast16_t ioflags_t;
/**
* @brief @p BaseAsynchronousChannel specific methods.
*/
#define _base_asynchronous_channel_methods \
_base_channel_methods \
/* Channel read method with timeout specification.*/ \
ioflags_t (*getflags)(void *instance);
/**
* @brief @p BaseAsynchronousChannel specific data.
*/
#define _base_asynchronous_channel_data \
_base_channel_data \
/* I/O condition event source.*/ \
EventSource event; \
/* I/O condition flags.*/ \
ioflags_t flags;
/**
* @extends BaseChannelVMT
*
* @brief @p BaseAsynchronousChannel virtual methods table.
*/
struct BaseAsynchronousChannelVMT {
_base_asynchronous_channel_methods
};
/**
* @extends BaseChannel
*
* @brief Base asynchronous channel class.
* @details This class extends @p BaseChannel by adding event sources fields
* for asynchronous I/O for use in an event-driven environment.
*/
typedef struct {
/** @brief Virtual Methods Table.*/
const struct BaseAsynchronousChannelVMT *vmt;
_base_asynchronous_channel_data
} BaseAsynchronousChannel;
/**
* @name Macro Functions (BaseAsynchronousChannel)
* @{
*/
/**
* @brief Returns the I/O condition event source.
* @details The event source is broadcasted when an I/O condition happens.
*
* @param[in] ip pointer to a @p BaseAsynchronousChannel or derived
* class
* @return A pointer to an @p EventSource object.
*
* @api
*/
#define chIOGetEventSource(ip) (&((ip)->event))
/**
* @brief Adds status flags to the channel's mask.
* @details This function is usually called from the I/O ISRs in order to
* notify I/O conditions such as data events, errors, signal
* changes etc.
*
* @param[in] ip pointer to a @p BaseAsynchronousChannel or derived
* class
* @param[in] mask condition flags to be added to the mask
*
* @iclass
*/
#define chIOAddFlagsI(ip, mask) { \
(ip)->flags |= (mask); \
chEvtBroadcastI(&(ip)->event); \
}
/**
* @brief Returns and clears the status flags associated to the channel.
*
* @param[in] ip pointer to a @p BaseAsynchronousChannel or derived
* class
* @return The condition flags modified since last time this
* function was invoked.
*
* @api
*/
#define chIOGetAndClearFlags(ip) ((ip)->vmt->getflags(ip))
/** @} */
/**
* @brief Default implementation of the @p getflags virtual method.
*
* @param[in] ip pointer to a @p BaseAsynchronousChannel or derived
* class
* @return The condition flags modified since last time this
* function was invoked.
*
* @notapi
*/
#define _ch_get_and_clear_flags_impl(ip) \
ioflags_t mask; \
chSysLock(); \
mask = ((BaseAsynchronousChannel *)(ip))->flags; \
((BaseAsynchronousChannel *)(ip))->flags = IO_NO_ERROR; \
chSysUnlock(); \
return mask
#endif /* CH_USE_EVENTS */
#endif /* _CHIOCH_H_ */
/** @} */

View File

@ -29,6 +29,11 @@
#define MAX_FILLER 11 #define MAX_FILLER 11
#define FLOAT_PRECISION 100000 #define FLOAT_PRECISION 100000
static void _putc(BaseSequentialStream *chp, char c) {
chSequentialStreamWrite(chp, (const uint8_t *)&c, 1);
}
static char *long_to_string_with_divisor(char *p, static char *long_to_string_with_divisor(char *p,
long num, long num,
unsigned radix, unsigned radix,
@ -83,7 +88,7 @@ static char *ftoa(char *p, double num) {
/** /**
* @brief System formatted output function. * @brief System formatted output function.
* @details This function implements a minimal @p printf() like functionality * @details This function implements a minimal @p printf() like functionality
* with output on a @p BaseChannel. * with output on a @p BaseSequentialStream.
* The general parameters format is: %[-][width|*][.precision|*][l|L]p. * The general parameters format is: %[-][width|*][.precision|*][l|L]p.
* The following parameter types (p) are supported: * The following parameter types (p) are supported:
* - <b>x</b> hexadecimal integer. * - <b>x</b> hexadecimal integer.
@ -98,10 +103,10 @@ static char *ftoa(char *p, double num) {
* - <b>s</b> string. * - <b>s</b> string.
* . * .
* *
* @param[in] chp pointer to a @p BaseChannel implementing object * @param[in] chp pointer to a @p BaseSequentialStream implementing object
* @param[in] fmt formatting string * @param[in] fmt formatting string
*/ */
void chprintf(BaseChannel *chp, const char *fmt, ...) { void chprintf(BaseSequentialStream *chp, const char *fmt, ...) {
va_list ap; va_list ap;
char tmpbuf[MAX_FILLER + 1]; char tmpbuf[MAX_FILLER + 1];
char *p, *s, c, filler; char *p, *s, c, filler;
@ -120,7 +125,7 @@ void chprintf(BaseChannel *chp, const char *fmt, ...) {
return; return;
} }
if (c != '%') { if (c != '%') {
chIOPut(chp, (uint8_t)c); _putc(chp, (uint8_t)c);
continue; continue;
} }
p = tmpbuf; p = tmpbuf;
@ -235,18 +240,18 @@ unsigned_common:
width = -width; width = -width;
if (width < 0) { if (width < 0) {
if (*s == '-' && filler == '0') { if (*s == '-' && filler == '0') {
chIOPut(chp, (uint8_t)*s++); _putc(chp, (uint8_t)*s++);
i--; i--;
} }
do do
chIOPut(chp, (uint8_t)filler); _putc(chp, (uint8_t)filler);
while (++width != 0); while (++width != 0);
} }
while (--i >= 0) while (--i >= 0)
chIOPut(chp, (uint8_t)*s++); _putc(chp, (uint8_t)*s++);
while (width) { while (width) {
chIOPut(chp, (uint8_t)filler); _putc(chp, (uint8_t)filler);
width--; width--;
} }
} }

View File

@ -39,7 +39,7 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void chprintf(BaseChannel *chp, const char *fmt, ...); void chprintf(BaseSequentialStream *chp, const char *fmt, ...);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -38,6 +38,11 @@
*/ */
EventSource shell_terminated; EventSource shell_terminated;
static void _putc(BaseSequentialStream *chp, char c) {
chSequentialStreamWrite(chp, (const uint8_t *)&c, 1);
}
static char *_strtok(char *str, const char *delim, char **saveptr) { static char *_strtok(char *str, const char *delim, char **saveptr) {
char *token; char *token;
if (str) if (str)
@ -55,12 +60,12 @@ static char *_strtok(char *str, const char *delim, char **saveptr) {
return *token ? token : NULL; return *token ? token : NULL;
} }
static void usage(BaseChannel *chp, char *p) { static void usage(BaseSequentialStream *chp, char *p) {
chprintf(chp, "Usage: %s\r\n", p); chprintf(chp, "Usage: %s\r\n", p);
} }
static void list_commands(BaseChannel *chp, const ShellCommand *scp) { static void list_commands(BaseSequentialStream *chp, const ShellCommand *scp) {
while (scp->sc_name != NULL) { while (scp->sc_name != NULL) {
chprintf(chp, "%s ", scp->sc_name); chprintf(chp, "%s ", scp->sc_name);
@ -68,7 +73,7 @@ static void list_commands(BaseChannel *chp, const ShellCommand *scp) {
} }
} }
static void cmd_info(BaseChannel *chp, int argc, char *argv[]) { static void cmd_info(BaseSequentialStream *chp, int argc, char *argv[]) {
(void)argv; (void)argv;
if (argc > 0) { if (argc > 0) {
@ -100,7 +105,7 @@ static void cmd_info(BaseChannel *chp, int argc, char *argv[]) {
#endif #endif
} }
static void cmd_systime(BaseChannel *chp, int argc, char *argv[]) { static void cmd_systime(BaseSequentialStream *chp, int argc, char *argv[]) {
(void)argv; (void)argv;
if (argc > 0) { if (argc > 0) {
@ -119,7 +124,7 @@ static ShellCommand local_commands[] = {
{NULL, NULL} {NULL, NULL}
}; };
static bool_t cmdexec(const ShellCommand *scp, BaseChannel *chp, static bool_t cmdexec(const ShellCommand *scp, BaseSequentialStream *chp,
char *name, int argc, char *argv[]) { char *name, int argc, char *argv[]) {
while (scp->sc_name != NULL) { while (scp->sc_name != NULL) {
@ -135,7 +140,7 @@ static bool_t cmdexec(const ShellCommand *scp, BaseChannel *chp,
/** /**
* @brief Shell thread function. * @brief Shell thread function.
* *
* @param[in] p pointer to a @p BaseChannel object * @param[in] p pointer to a @p BaseSequentialStream object
* @return Termination reason. * @return Termination reason.
* @retval RDY_OK terminated by command. * @retval RDY_OK terminated by command.
* @retval RDY_RESET terminated by reset condition on the I/O channel. * @retval RDY_RESET terminated by reset condition on the I/O channel.
@ -143,7 +148,7 @@ static bool_t cmdexec(const ShellCommand *scp, BaseChannel *chp,
static msg_t shell_thread(void *p) { static msg_t shell_thread(void *p) {
int n; int n;
msg_t msg = RDY_OK; msg_t msg = RDY_OK;
BaseChannel *chp = ((ShellConfig *)p)->sc_channel; BaseSequentialStream *chp = ((ShellConfig *)p)->sc_channel;
const ShellCommand *scp = ((ShellConfig *)p)->sc_commands; const ShellCommand *scp = ((ShellConfig *)p)->sc_commands;
char *lp, *cmd, *tokp, line[SHELL_MAX_LINE_LENGTH]; char *lp, *cmd, *tokp, line[SHELL_MAX_LINE_LENGTH];
char *args[SHELL_MAX_ARGUMENTS + 1]; char *args[SHELL_MAX_ARGUMENTS + 1];
@ -245,19 +250,20 @@ Thread *shellCreateStatic(const ShellConfig *scp, void *wsp,
/** /**
* @brief Reads a whole line from the input channel. * @brief Reads a whole line from the input channel.
* *
* @param[in] chp pointer to a @p BaseChannel object * @param[in] chp pointer to a @p BaseSequentialStream object
* @param[in] line pointer to the line buffer * @param[in] line pointer to the line buffer
* @param[in] size buffer maximum length * @param[in] size buffer maximum length
* @return The operation status. * @return The operation status.
* @retval TRUE the channel was reset or CTRL-D pressed. * @retval TRUE the channel was reset or CTRL-D pressed.
* @retval FALSE operation successful. * @retval FALSE operation successful.
*/ */
bool_t shellGetLine(BaseChannel *chp, char *line, unsigned size) { bool_t shellGetLine(BaseSequentialStream *chp, char *line, unsigned size) {
char *p = line; char *p = line;
while (TRUE) { while (TRUE) {
short c = (short)chIOGet(chp); char c;
if (c < 0)
if (chSequentialStreamRead(chp, (uint8_t *)&c, 1) == 0)
return TRUE; return TRUE;
if (c == 4) { if (c == 4) {
chprintf(chp, "^D"); chprintf(chp, "^D");
@ -265,9 +271,9 @@ bool_t shellGetLine(BaseChannel *chp, char *line, unsigned size) {
} }
if (c == 8) { if (c == 8) {
if (p != line) { if (p != line) {
chIOPut(chp, (uint8_t)c); _putc(chp, c);
chIOPut(chp, 0x20); _putc(chp, 0x20);
chIOPut(chp, (uint8_t)c); _putc(chp, c);
p--; p--;
} }
continue; continue;
@ -280,7 +286,7 @@ bool_t shellGetLine(BaseChannel *chp, char *line, unsigned size) {
if (c < 0x20) if (c < 0x20)
continue; continue;
if (p < line + size - 1) { if (p < line + size - 1) {
chIOPut(chp, (uint8_t)c); _putc(chp, c);
*p++ = (char)c; *p++ = (char)c;
} }
} }

View File

@ -46,7 +46,7 @@
/** /**
* @brief Command handler function type. * @brief Command handler function type.
*/ */
typedef void (*shellcmd_t)(BaseChannel *chp, int argc, char *argv[]); typedef void (*shellcmd_t)(BaseSequentialStream *chp, int argc, char *argv[]);
/** /**
* @brief Custom command entry type. * @brief Custom command entry type.
@ -60,7 +60,7 @@ typedef struct {
* @brief Shell descriptor type. * @brief Shell descriptor type.
*/ */
typedef struct { typedef struct {
BaseChannel *sc_channel; /**< @brief I/O channel associated BaseSequentialStream *sc_channel; /**< @brief I/O channel associated
to the shell. */ to the shell. */
const ShellCommand *sc_commands; /**< @brief Shell extra commands const ShellCommand *sc_commands; /**< @brief Shell extra commands
table. */ table. */
@ -77,7 +77,7 @@ extern "C" {
Thread *shellCreate(const ShellConfig *scp, size_t size, tprio_t prio); Thread *shellCreate(const ShellConfig *scp, size_t size, tprio_t prio);
Thread *shellCreateStatic(const ShellConfig *scp, void *wsp, Thread *shellCreateStatic(const ShellConfig *scp, void *wsp,
size_t size, tprio_t prio); size_t size, tprio_t prio);
bool_t shellGetLine(BaseChannel *chp, char *line, unsigned size); bool_t shellGetLine(BaseSequentialStream *chp, char *line, unsigned size);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -171,6 +171,12 @@
lwIP demos (backported to 2.4.1). lwIP demos (backported to 2.4.1).
- NEW: lwIP related code is not centralized into a single place, no need to - NEW: lwIP related code is not centralized into a single place, no need to
duplicate the code in each application or demo (backported to 2.4.1). duplicate the code in each application or demo (backported to 2.4.1).
- CHANGE: Removed the chioch.h header from the kernel, now channels interface
is exported by the HAL.
- CHANGE: chprintf() now takes a BaseSequentialStream as parameter instead
of a BaseChannel making it more generic.
- CHANGE: Now the shell requires a BaseSequentialStream instead of a
BaseChannel for communications making it more generic.
- CHANGE: Kernel memory pools now do not check the alignment of the inserted - CHANGE: Kernel memory pools now do not check the alignment of the inserted
objects, it is responsibility of the application to insert properly objects, it is responsibility of the application to insert properly
aligned objects. aligned objects.

View File

@ -85,7 +85,12 @@ void * ROMCONST wa[5] = {test.wa.T0, test.wa.T1, test.wa.T2,
/* /*
* Console output. * Console output.
*/ */
static BaseChannel *chp; static BaseSequentialStream *chp;
static void _putc(BaseSequentialStream *chp, char c) {
chSequentialStreamWrite(chp, (const uint8_t *)&c, 1);
}
/** /**
* @brief Prints a decimal unsigned number. * @brief Prints a decimal unsigned number.
@ -96,13 +101,13 @@ void test_printn(uint32_t n) {
char buf[16], *p; char buf[16], *p;
if (!n) if (!n)
chIOPut(chp, '0'); _putc(chp, '0');
else { else {
p = buf; p = buf;
while (n) while (n)
*p++ = (n % 10) + '0', n /= 10; *p++ = (n % 10) + '0', n /= 10;
while (p > buf) while (p > buf)
chIOPut(chp, *--p); _putc(chp, *--p);
} }
} }
@ -114,7 +119,7 @@ void test_printn(uint32_t n) {
void test_print(const char *msgp) { void test_print(const char *msgp) {
while (*msgp) while (*msgp)
chIOPut(chp, *msgp++); _putc(chp, *msgp++);
} }
/** /**
@ -125,8 +130,7 @@ void test_print(const char *msgp) {
void test_println(const char *msgp) { void test_println(const char *msgp) {
test_print(msgp); test_print(msgp);
chIOPut(chp, '\r'); chSequentialStreamWrite(chp, (const uint8_t *)"\r\n", 1);
chIOPut(chp, '\n');
} }
/* /*
@ -141,7 +145,7 @@ static void print_tokens(void) {
char *cp = tokens_buffer; char *cp = tokens_buffer;
while (cp < tokp) while (cp < tokp)
chIOPut(chp, *cp++); _putc(chp, *cp++);
} }
/** /**
@ -306,9 +310,8 @@ static void print_line(void) {
unsigned i; unsigned i;
for (i = 0; i < 76; i++) for (i = 0; i < 76; i++)
chIOPut(chp, '-'); _putc(chp, '-');
chIOPut(chp, '\r'); chSequentialStreamWrite(chp, (const uint8_t *)"\r\n", 1);
chIOPut(chp, '\n');
} }
/** /**

View File

@ -113,7 +113,7 @@ bool_t sdc_lld_is_write_protected(SDCDriver *sdcp) {
/** /**
* *
*/ */
void cmd_sdiotest(BaseChannel *chp, int argc, char *argv[]){ void cmd_sdiotest(BaseSequentialStream *chp, int argc, char *argv[]){
(void)argc; (void)argc;
(void)argv; (void)argv;
uint32_t i = 0; uint32_t i = 0;
@ -356,7 +356,7 @@ static const ShellCommand commands[] = {
{NULL, NULL} {NULL, NULL}
}; };
static const ShellConfig shell_cfg1 = { static const ShellConfig shell_cfg1 = {
(BaseChannel *)&SD2, (BaseSequentialStream *)&SD2,
commands commands
}; };

View File

@ -20,6 +20,12 @@ Within 2.5.x:
* FatFs 0.9x integration. * FatFs 0.9x integration.
- USB driver model revision. - USB driver model revision.
X STM32 OTG USB cell support for CL, F2, F4 devices. X STM32 OTG USB cell support for CL, F2, F4 devices.
X Streaming DAC/I2S driver model and STM32 implementation.
- Unified LPC1xxx HAL.
- LPC11xx and LPC13xx HALs merged in the unified one.
- LPC17xx support.
- NUC120 support.
- STM32F0 support.
- Add USARTs support to the STM32 SPI driver. - Add USARTs support to the STM32 SPI driver.
- Add option to use another counter instead of the systick counter into the - Add option to use another counter instead of the systick counter into the
trace buffer. trace buffer.
@ -31,12 +37,8 @@ X STM32 OTG USB cell support for CL, F2, F4 devices.
to be updated. to be updated.
- Runtime errors manager in HAL. - Runtime errors manager in HAL.
- Critical errors manager in HAL (to replace or complement assertions). - Critical errors manager in HAL (to replace or complement assertions).
- Streaming DAC/I2S driver model and STM32 implementation. - Add ADC3 support to the STM32F1xx ADC driver.
- Add ADC3 support to the STM32 ADC driver.
- Update C++ wrapper. - Update C++ wrapper.
- STM32F0 support.
- LPC17xx support.
- NUC120 support.
? Add the RTC service inside the kernel and port, remove from HAL. ? Add the RTC service inside the kernel and port, remove from HAL.
Within 2.x.x Within 2.x.x