git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8636 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
a71da8de12
commit
d9973ea126
|
@ -295,6 +295,7 @@ msg_t ibqGetTimeout(input_buffers_queue_t *ibqp, systime_t timeout) {
|
||||||
* - @a TIME_INFINITE no timeout.
|
* - @a TIME_INFINITE no timeout.
|
||||||
* .
|
* .
|
||||||
* @return The number of bytes effectively transferred.
|
* @return The number of bytes effectively transferred.
|
||||||
|
* @retval 0 if a timeout occurred.
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
@ -316,20 +317,30 @@ size_t ibqReadTimeout(input_buffers_queue_t *ibqp, uint8_t *bp,
|
||||||
|
|
||||||
/* This condition indicates that a new buffer must be acquired.*/
|
/* This condition indicates that a new buffer must be acquired.*/
|
||||||
if (ibqp->ptr == NULL) {
|
if (ibqp->ptr == NULL) {
|
||||||
systime_t next_timeout = deadline - osalOsGetSystemTimeX();
|
msg_t msg;
|
||||||
|
|
||||||
/* Handling the case where the system time went past the deadline,
|
if (timeout == TIME_IMMEDIATE) {
|
||||||
in this case next becomes a very high number because the system
|
msg = MSG_TIMEOUT;
|
||||||
time is an unsigned type.*/
|
|
||||||
if (next_timeout > timeout) {
|
|
||||||
ibqp->accessed = false;
|
|
||||||
return MSG_TIMEOUT;
|
|
||||||
}
|
}
|
||||||
|
else if (timeout == TIME_INFINITE) {
|
||||||
|
msg = ibqGetFullBufferTimeout(ibqp, timeout);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
systime_t next_timeout = deadline - osalOsGetSystemTimeX();
|
||||||
|
|
||||||
msg_t msg = ibqGetFullBufferTimeout(ibqp, next_timeout);
|
/* Handling the case where the system time went past the deadline,
|
||||||
|
in this case next becomes a very high number because the system
|
||||||
|
time is an unsigned type.*/
|
||||||
|
if (next_timeout > timeout) {
|
||||||
|
msg = MSG_TIMEOUT;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
msg = ibqGetFullBufferTimeout(ibqp, next_timeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (msg != MSG_OK) {
|
if (msg != MSG_OK) {
|
||||||
ibqp->accessed = false;
|
ibqp->accessed = false;
|
||||||
return msg;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -611,6 +622,7 @@ msg_t obqPutTimeout(output_buffers_queue_t *obqp, uint8_t b,
|
||||||
* - @a TIME_INFINITE no timeout.
|
* - @a TIME_INFINITE no timeout.
|
||||||
* .
|
* .
|
||||||
* @return The number of bytes effectively transferred.
|
* @return The number of bytes effectively transferred.
|
||||||
|
* @retval 0 if a timeout occurred.
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
@ -632,20 +644,30 @@ size_t obqWriteTimeout(output_buffers_queue_t *obqp, const uint8_t *bp,
|
||||||
|
|
||||||
/* This condition indicates that a new buffer must be acquired.*/
|
/* This condition indicates that a new buffer must be acquired.*/
|
||||||
if (obqp->ptr == NULL) {
|
if (obqp->ptr == NULL) {
|
||||||
systime_t next_timeout = deadline - osalOsGetSystemTimeX();
|
msg_t msg;
|
||||||
|
|
||||||
/* Handling the case where the system time went past the deadline,
|
if (timeout == TIME_IMMEDIATE) {
|
||||||
in this case next becomes a very high number because the system
|
msg = MSG_TIMEOUT;
|
||||||
time is an unsigned type.*/
|
|
||||||
if (next_timeout > timeout) {
|
|
||||||
obqp->accessed = false;
|
|
||||||
return MSG_TIMEOUT;
|
|
||||||
}
|
}
|
||||||
|
else if (timeout == TIME_INFINITE) {
|
||||||
|
msg = obqGetEmptyBufferTimeout(obqp, timeout);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
systime_t next_timeout = deadline - osalOsGetSystemTimeX();
|
||||||
|
|
||||||
msg_t msg = obqGetEmptyBufferTimeout(obqp, next_timeout);
|
/* Handling the case where the system time went past the deadline,
|
||||||
|
in this case next becomes a very high number because the system
|
||||||
|
time is an unsigned type.*/
|
||||||
|
if (next_timeout > timeout) {
|
||||||
|
msg = MSG_TIMEOUT;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
msg = obqGetEmptyBufferTimeout(obqp, next_timeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (msg != MSG_OK) {
|
if (msg != MSG_OK) {
|
||||||
obqp->accessed = false;
|
obqp->accessed = false;
|
||||||
return msg;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,13 +33,13 @@
|
||||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
|
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="DIEPTSIZ-ie[1]-ie-otg-usbp-config-null-_idle_thread-(format)" val="4"/><content id="bcounter-null-obqTryFlushI-(format)" val="4"/><content id="n-sduSOFHookI-(format)" val="4"/></contentList>"/>
|
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="vt_lasttime-vtlist-null-_idle_thread-(format)" val="4"/><content id="vt_lasttime-vtlist-null-port_wait_for_interrupt-(format)" val="4"/><content id="DIEPTSIZ-ie[1]-ie-otg-usbp-config-null-_idle_thread-(format)" val="4"/><content id="bcounter-null-obqTryFlushI-(format)" val="4"/><content id="n-sduSOFHookI-(format)" val="4"/></contentList>"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
|
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
|
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
|
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="STM32F4xx-USB_CDC"/>
|
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="STM32F4xx-USB_CDC"/>
|
||||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
|
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="0.588576619"/>
|
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="0.1487191575"/>
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
<listEntry value="/STM32F4xx-USB_CDC"/>
|
<listEntry value="/STM32F4xx-USB_CDC"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
|
|
|
@ -84,6 +84,7 @@ static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
|
||||||
chThdWait(tp);
|
chThdWait(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Can be measured using dd if=/dev/xxxx of=/dev/null bs=512 count=10000.*/
|
||||||
static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) {
|
static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) {
|
||||||
static uint8_t buf[] =
|
static uint8_t buf[] =
|
||||||
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
|
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
|
||||||
|
@ -112,12 +113,12 @@ static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) {
|
||||||
while (chnGetTimeout((BaseChannel *)chp, TIME_IMMEDIATE) == Q_TIMEOUT) {
|
while (chnGetTimeout((BaseChannel *)chp, TIME_IMMEDIATE) == Q_TIMEOUT) {
|
||||||
#if 1
|
#if 1
|
||||||
/* Writing in stream mode.*/
|
/* Writing in stream mode.*/
|
||||||
chSequentialStreamWrite(&SDU1, buf, sizeof buf - 1);
|
streamWrite(&SDU1, buf, sizeof buf - 1);
|
||||||
#else
|
#else
|
||||||
/* Writing in buffer mode.*/
|
/* Writing in buffer mode.*/
|
||||||
(void) obqGetEmptyBufferTimeout(&SDU1.obqueue, TIME_INFINITE);
|
(void) obqGetEmptyBufferTimeout(&SDU1.obqueue, TIME_INFINITE);
|
||||||
memcpy(SDU1.obqueue.ptr, buf, 256);
|
memcpy(SDU1.obqueue.ptr, buf, SERIAL_USB_BUFFERS_SIZE);
|
||||||
obqPostFullBuffer(&SDU1.obqueue, 256);
|
obqPostFullBuffer(&SDU1.obqueue, SERIAL_USB_BUFFERS_SIZE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
chprintf(chp, "\r\n\nstopped\r\n");
|
chprintf(chp, "\r\n\nstopped\r\n");
|
||||||
|
@ -141,7 +142,7 @@ static const ShellConfig shell_cfg1 = {
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Red LED blinker thread, times are in milliseconds.
|
* LED blinker thread, times are in milliseconds.
|
||||||
*/
|
*/
|
||||||
static THD_WORKING_AREA(waThread1, 128);
|
static THD_WORKING_AREA(waThread1, 128);
|
||||||
static THD_FUNCTION(Thread1, arg) {
|
static THD_FUNCTION(Thread1, arg) {
|
||||||
|
|
Loading…
Reference in New Issue