本文整理汇总了C++中xSerialPutChar函数的典型用法代码示例。如果您正苦于以下问题:C++ xSerialPutChar函数的具体用法?C++ xSerialPutChar怎么用?C++ xSerialPutChar使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xSerialPutChar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vSerialPutString
void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )
{
signed char *pxNext;
/* A couple of parameters that this port does not use. */
( void ) usStringLength;
( void ) pxPort;
/* NOTE: This implementation does not handle the queue being full as no block time is used! */
/* The port handle is not required as this driver only supports UART0. */
( void ) pxPort;
/* Send each character in the string, one at a time. */
pxNext = ( signed char * ) pcString;
while( *pxNext )
{
xSerialPutChar( pxPort, *pxNext, serNO_BLOCK );
pxNext++;
}
}
示例2: portTASK_FUNCTION
static portTASK_FUNCTION( vComTxTask, pvParameters )
{
signed char cByteToSend;
portTickType xTimeToWait;
/* Just to stop compiler warnings. */
( void ) pvParameters;
for( ;; )
{
/* Simply transmit a sequence of characters from comFIRST_BYTE to
comLAST_BYTE. */
for( cByteToSend = comFIRST_BYTE; cByteToSend <= comLAST_BYTE; cByteToSend++ )
{
if( xSerialPutChar( xPort, cByteToSend, comNO_BLOCK ) == pdPASS )
{
vParTestToggleLED( uxBaseLED + comTX_LED_OFFSET );
}
}
/* Turn the LED off while we are not doing anything. */
vParTestSetLED( uxBaseLED + comTX_LED_OFFSET, pdFALSE );
/* We have posted all the characters in the string - wait before
re-sending. Wait a pseudo-random time as this will provide a better
test. */
xTimeToWait = xTaskGetTickCount() + comOFFSET_TIME;
/* Make sure we don't wait too long... */
xTimeToWait %= comTX_MAX_BLOCK_TIME;
/* ...but we do want to wait. */
if( xTimeToWait < comTX_MIN_BLOCK_TIME )
{
xTimeToWait = comTX_MIN_BLOCK_TIME;
}
vTaskDelay( xTimeToWait );
}
} /*lint !e715 !e818 pvParameters is required for a task function even if it is not referenced. */
示例3: prvUSARTEchoTask
/* Described at the top of this file. */
static void prvUSARTEchoTask( void *pvParameters )
{
signed char cChar;
/* String declared static to ensure it does not end up on the stack, no matter
what the optimisation level. */
static const char *pcLongishString =
"ABBA was a Swedish pop music group formed in Stockholm in 1972, consisting of Anni-Frid Frida Lyngstad, "
"Björn Ulvaeus, Benny Andersson and Agnetha Fältskog. Throughout the band's existence, Fältskog and Ulvaeus "
"were a married couple, as were Lyngstad and Andersson - although both couples later divorced. They became one "
"of the most commercially successful acts in the history of popular music, and they topped the charts worldwide "
"from 1972 to 1983. ABBA gained international popularity employing catchy song hooks, simple lyrics, sound "
"effects (reverb, phasing) and a Wall of Sound achieved by overdubbing the female singers' voices in multiple "
"harmonies. As their popularity grew, they were sought after to tour Europe, Australia, and North America, drawing "
"crowds of ardent fans, notably in Australia. Touring became a contentious issue, being particularly cumbersome for "
"Fältskog, but they continued to release studio albums to widespread commercial success. At the height of their "
"popularity, however, both relationships began suffering strain that led ultimately to the collapse of first the "
"Ulvaeus-Fältskog marriage (in 1979) and then of the Andersson-Lyngstad marriage in 1981. In the late 1970s and early "
"1980s these relationship changes began manifesting in the group's music, as they produced more thoughtful, "
"introspective lyrics with different compositions.";
/* Just to avoid compiler warnings. */
( void ) pvParameters;
/* Initialise COM0, which is USART1 according to the STM32 libraries. */
lCOMPortInit( mainCOM0, mainBAUD_RATE );
/* Try sending out a string all in one go, as a very basic test of the
lSerialPutString() function. */
lSerialPutString( mainCOM0, pcLongishString, strlen( pcLongishString ) );
for( ;; )
{
/* Block to wait for a character to be received on COM0. */
xSerialGetChar( mainCOM0, &cChar, portMAX_DELAY );
/* Write the received character back to COM0. */
xSerialPutChar( mainCOM0, cChar, 0 );
}
}
示例4: testUSART
void testUSART(void)
{
u8 temp,recvNum;
while(1){
recvNum=uxQueueMessagesWaiting(xRxedChars);
printf("Hello world!,rec=%d\r\n",recvNum);
Delay_Ms(500);
if(recvNum>0)
{
while(recvNum--){
xSerialGetChar((signed char*)&temp,0);
xSerialPutChar(temp , 5/portTICK_RATE_MS);
}
//xSerialPutChar('\r' , 5/portTICK_RATE_MS);
//xSerialPutChar('\n' , 5/portTICK_RATE_MS);
}
Delay_Ms(300);
}
}
示例5: taskUART
/*********************************************************************
* Function: void taskSerial(void* pvParameter)
*
* PreCondition: None
*
* Input: None
*
* Output: Does not return
*
* Side Effects: None
*
* Overview:
*
* Note:
********************************************************************/
void taskUART(void* pvParameter)
{
static GRAPHICS_MSG msg;
unsigned char val;
// vTaskSetApplicationTaskTag( NULL, ( void * ) 's' );
xSerialPortInitMinimal( 115200, 10 );
while (1) {
vTaskDelay( 50 / portTICK_RATE_MS ); // Wait 50ms
if( xSerialGetChar(NULL, &val, 0xffff ) )
xSerialPutChar( NULL, val, 0xffff );
// LATFbits.LATF3 ^= 0x04;
// LATDbits.LATD0 ^= 0x01;
// xSerialPutChar( NULL, 'A', 0xffff );
// xSerialPutChar( NULL, 'B', 0xffff );
}
}
示例6: main
/* Creates the tasks, then starts the scheduler. */
void main( void )
{
/* Initialise the required hardware. */
vParTestInitialise();
/* Send a character so we have some visible feedback of a reset. */
xSerialPortInitMinimal( mainBAUD_RATE, mainCOMMS_QUEUE_LENGTH );
xSerialPutChar( NULL, 'X', mainNO_BLOCK );
/* Start a few of the standard demo tasks found in the demo\common directory. */
vStartMathTasks( tskIDLE_PRIORITY );
vStartLEDFlashTasks( mainLED_FLASH_PRIORITY );
/* Start the check task defined in this file. */
xTaskCreate( vErrorChecks, ( const char * const ) "Check", portMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
/* Start the scheduler. Will never return here. */
vTaskStartScheduler();
while(1) /* This point should never be reached. */
{
}
}
示例7: ReceiveCmd
static int ReceiveCmd(char* buf)
{
unsigned short idx = -1;
/* accumulate characters until the enter is hit */
do {
/* increment index pointer for each character increment */
idx++;
if (xSerialGetChar(xComPort, (signed char *) &buf[idx], portMAX_DELAY) == pdFALSE) {
continue;
}
/* echo the character back to the terminal */
xSerialPutChar(xComPort, buf[idx], 0);
/* handle the hit of an backspace by shifting the idx back */
if(buf[idx] == '\b'){
idx -= 2;
}
/* add some verbosity for the demo */
if (verbose >= 2) {
printf("buf[%d] = 0x%02x\n", idx, buf[idx]);
}
} while ((buf[idx] != '\n') && (buf[idx] != '\r'));
/* return the command string without the new line, so we have only the command */
buf[idx] = '\0';
if (verbose >= 1){
mdump(buf, 512);
}
/* return the length of the string */
return idx + 1;
}
示例8: prvUARTCommandConsoleTask
static void prvUARTCommandConsoleTask( void *pvParameters )
{
signed char cRxedChar;
uint8_t ucInputIndex = 0;
char *pcOutputString;
static char cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ];
BaseType_t xReturned;
xComPortHandle xPort;
( void ) pvParameters;
/* Obtain the address of the output buffer. Note there is no mutual
exclusion on this buffer as it is assumed only one command console interface
will be used at any one time. */
pcOutputString = FreeRTOS_CLIGetOutputBuffer();
/* Initialise the UART. */
xPort = xSerialPortInitMinimal( configCLI_BAUD_RATE, cmdQUEUE_LENGTH );
/* Send the welcome message. */
vSerialPutString( xPort, ( signed char * ) pcWelcomeMessage, ( unsigned short ) strlen( pcWelcomeMessage ) );
for( ;; )
{
/* Wait for the next character. The while loop is used in case
INCLUDE_vTaskSuspend is not set to 1 - in which case portMAX_DELAY will
be a genuine block time rather than an infinite block time. */
while( xSerialGetChar( xPort, &cRxedChar, portMAX_DELAY ) != pdPASS );
/* Ensure exclusive access to the UART Tx. */
if( xSemaphoreTake( xTxMutex, cmdMAX_MUTEX_WAIT ) == pdPASS )
{
/* Echo the character back. */
xSerialPutChar( xPort, cRxedChar, portMAX_DELAY );
/* Was it the end of the line? */
if( cRxedChar == '\n' || cRxedChar == '\r' )
{
/* Just to space the output from the input. */
vSerialPutString( xPort, ( signed char * ) pcNewLine, ( unsigned short ) strlen( pcNewLine ) );
/* See if the command is empty, indicating that the last command
is to be executed again. */
if( ucInputIndex == 0 )
{
/* Copy the last command back into the input string. */
strcpy( cInputString, cLastInputString );
}
/* Pass the received command to the command interpreter. The
command interpreter is called repeatedly until it returns
pdFALSE (indicating there is no more output) as it might
generate more than one string. */
do
{
/* Get the next output string from the command interpreter. */
xReturned = FreeRTOS_CLIProcessCommand( cInputString, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );
/* Write the generated string to the UART. */
vSerialPutString( xPort, ( signed char * ) pcOutputString, ( unsigned short ) strlen( pcOutputString ) );
} while( xReturned != pdFALSE );
/* All the strings generated by the input command have been
sent. Clear the input string ready to receive the next command.
Remember the command that was just processed first in case it is
to be processed again. */
strcpy( cLastInputString, cInputString );
ucInputIndex = 0;
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
vSerialPutString( xPort, ( signed char * ) pcEndOfOutputMessage, ( unsigned short ) strlen( pcEndOfOutputMessage ) );
}
else
{
if( cRxedChar == '\r' )
{
/* Ignore the character. */
}
else if( ( cRxedChar == '\b' ) || ( cRxedChar == cmdASCII_DEL ) )
{
/* Backspace was pressed. Erase the last character in the
string - if any. */
if( ucInputIndex > 0 )
{
ucInputIndex--;
cInputString[ ucInputIndex ] = '\0';
}
}
else
{
/* A character was entered. Add it to the string entered so
far. When a \n is entered the complete string will be
passed to the command interpreter. */
if( ( cRxedChar >= ' ' ) && ( cRxedChar <= '~' ) )
{
if( ucInputIndex < cmdMAX_INPUT_SIZE )
{
cInputString[ ucInputIndex ] = cRxedChar;
ucInputIndex++;
//.........这里部分代码省略.........
示例9: prvUARTCommandConsoleTask
static void prvUARTCommandConsoleTask( void *pvParameters )
{
char cRxedChar, cInputIndex = 0, *pcOutputString;
static char cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ];
portBASE_TYPE xReturned;
( void ) pvParameters;
/* Obtain the address of the output buffer. Note there is no mutual
exclusion on this buffer as it is assumed only one command console
interface will be used at any one time. */
pcOutputString = FreeRTOS_CLIGetOutputBuffer();
/* Send the welcome message. */
vSerialPutString( NULL, ( const signed char * ) pcWelcomeMessage, strlen( ( char * ) pcWelcomeMessage ) );
for( ;; )
{
/* Only interested in reading one character at a time. */
while( xSerialGetChar( NULL, ( signed char * ) &cRxedChar, portMAX_DELAY ) == pdFALSE );
/* Echo the character back. */
xSerialPutChar( NULL, cRxedChar, portMAX_DELAY );
/* Was it the end of the line? */
if( cRxedChar == '\n' || cRxedChar == '\r' )
{
/* Just to space the output from the input. */
vSerialPutString( NULL, ( const signed char * ) pcNewLine, strlen( ( char * ) pcNewLine ) );
/* See if the command is empty, indicating that the last command is
to be executed again. */
if( cInputIndex == 0 )
{
/* Copy the last command back into the input string. */
strcpy( ( char * ) cInputString, ( char * ) cLastInputString );
}
/* Pass the received command to the command interpreter. The
command interpreter is called repeatedly until it returns pdFALSE
(indicating there is no more output) as it might generate more than
one string. */
do
{
/* Get the next output string from the command interpreter. */
xReturned = FreeRTOS_CLIProcessCommand( cInputString, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );
/* Write the generated string to the UART. */
vSerialPutString( NULL, ( const signed char * ) pcOutputString, strlen( ( char * ) pcOutputString ) );
} while( xReturned != pdFALSE );
/* All the strings generated by the input command have been sent.
Clear the input string ready to receive the next command. Remember
the command that was just processed first in case it is to be
processed again. */
strcpy( ( char * ) cLastInputString, ( char * ) cInputString );
cInputIndex = 0;
memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );
vSerialPutString( NULL, ( const signed char * ) pcEndOfOutputMessage, strlen( ( char * ) pcEndOfOutputMessage ) );
}
else
{
if( cRxedChar == '\r' )
{
/* Ignore the character. */
}
else if( cRxedChar == '\b' )
{
/* Backspace was pressed. Erase the last character in the
string - if any. */
if( cInputIndex > 0 )
{
cInputIndex--;
cInputString[ cInputIndex ] = '\0';
}
}
else
{
/* A character was entered. Add it to the string
entered so far. When a \n is entered the complete
string will be passed to the command interpreter. */
if( ( cRxedChar >= ' ' ) && ( cRxedChar <= '~' ) )
{
if( cInputIndex < cmdMAX_INPUT_SIZE )
{
cInputString[ cInputIndex ] = cRxedChar;
cInputIndex++;
}
}
}
}
}
}
示例10: fputc
int fputc(int ch, FILE *f)
{
xSerialPutChar( (u8)ch, 0/portTICK_RATE_MS);
return ch;
}
示例11: portTASK_FUNCTION
//.........这里部分代码省略.........
#endif
#ifdef BOARD_KOMON_KONTER_3_0
if (loopambil%20==0) { // 5x20 = 100
hitung_rpm();
data_frek_rpm();
}
#endif
#ifdef PAKAI_I2C
#if 0
if (st_tsc) {
if (loopambil%500==0) { // 2*250: 500ms = 0.5 detik
printf("__detik: %3d\r\n", c++);
//baca_register_tsc();
#if 1
if (int_berganti() == 0)
{
printf("disentuh\r\n");
}
else
printf("HIGH\r\n");
//vSerialPutString(0, "HIGH\r\n");
#endif
}
}
#endif
#if 0
if (st_tsc) {
if (xSerialGetChar(1, &c, 0xFFFF ) == pdTRUE)
{
vSerialPutString(0, "Tombol ditekan = ");
xSerialPutChar( 0, (char ) c);
vSerialPutString(0, " \r\n");
if ( (char) c == 's')
{
printf(" Set\r\n");
/*
if (i2c_set_register(0x68, 1, 8))
{
out(" NO ACK !!\r\n");
}
else
out(" OK\r\n");
*/
if (setup_fma())
{
printf(" NO ack !\r\n");
}
else
printf(" OK ack !\r\n");
}
else
{
printf("====\r\n");
for (i=0; i<16; i++)
{
if (i == 8) printf("****\r\n");
if (i2c_read_register(0x68, (0x50 + i), &a))
{
示例12: BluetoothModemTask
//.........这里部分代码省略.........
const char *atSetDeviceName = "AT*agln=\"PIP-Watch\",0\r\n";
lSerialPutString( comBTM, atSetDeviceName, strlen(atSetDeviceName) );
if (btmExpectOK()) {
// failed
assert_failed(__FILE__, __LINE__);
}
const char *atSetPin = "AT*agfp=\"1234\",0\r";
lSerialPutString( comBTM, atSetPin, strlen(atSetPin) );
if (btmExpectOK()) {
// failed
assert_failed(__FILE__, __LINE__);
}
const char *atToDataMode = "AT*addm\r";
lSerialPutString( comBTM, atToDataMode, strlen(atToDataMode) );
if (btmExpectOK()) {
// failed
assert_failed(__FILE__, __LINE__);
}
/* Try sending out a string all in one go, as a very basic test of the
lSerialPutString() function. */
// lSerialPutString( comBTM, pcLongishString, strlen( pcLongishString ) );
int k = 0;
char *buf = NULL;
for( ;; )
{
/* Block to wait for a character to be received on COM0. */
xSerialGetChar( comBTM, &cChar, portMAX_DELAY );
/* Write the received character back to COM0. */
xSerialPutChar( comBTM, cChar, 0 );
if (!buf) {
buf = pvPortMalloc(sizeof(char) * 32);
#if 0
/* start ADC conversion by software */
// ADC_ClearFlag(ADC1, ADC_FLAG_EOC);
ADC_ClearFlag(ADC1, ADC_FLAG_STRT);
ADC_Cmd(ADC1, ENABLE);
#if 0
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
/* wait till the conversion starts */
while (ADC_GetSoftwareStartConvStatus(ADC1) != RESET) { }
#endif
/* wait till the conversion ends */
while (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) != SET) { }
#endif
k = 0;
// k = itostr(buf, 32, RTC_GetCounter());
// k = itostr(buf, 32, ADC_GetConversionValue(ADC1));
// k = itostr(buf, 32, vbat_measured);
// k = itostr(buf, 32, vbat_percent);
// ADC_ClearFlag(ADC1, ADC_FLAG_EOC);
}
buf[k++] = cChar;
if (cChar == '\r' || k >= 30) {
buf[k] = '\0';
for (int i = 0; i < k-4; ++i) {
if (buf[i] == '*') {
/* set time: *<hours><minutes> */
int hours = (buf[i+1]-'0')*10 + (buf[i+2]-'0');
int minutes = (buf[i+3]-'0')*10 + (buf[i+4]-'0');
hours %= 24;
minutes %= 60;
current_rtime.sec = 0;
current_rtime.hour = hours;
current_rtime.min = minutes;
break;
}
}
if (xQueueSend(toDisplayStrQueue, &buf, 0) == pdTRUE) {
// ok; will alloc new buffer
buf = NULL;
} else {
// fail; ignore, keep buffer
}
// motor demo
GPIO_SetBits(GPIOB, 1 << 13);
vTaskDelay( ( TickType_t ) 300 / portTICK_PERIOD_MS );
GPIO_ResetBits(GPIOB, 1 << 13);
k = 0;
xSerialPutChar( comBTM, '\n', 0 );
}
}
}
示例13: TaskMonitor
static void TaskMonitor(void *pvParameters) // Monitor for Serial Interface
{
(void) pvParameters;
uint8_t *ptr;
int32_t p1;
// create the buffer on the heap (so they can be moved later).
if(LineBuffer == NULL) // if there is no Line buffer allocated (pointer is NULL), then allocate buffer.
if( !(LineBuffer = (uint8_t *) pvPortMalloc( sizeof(uint8_t) * LINE_SIZE )))
xSerialPrint_P(PSTR("pvPortMalloc for *LineBuffer fail..!\r\n"));
while(1)
{
xSerialPutChar(&xSerialPort, '>');
ptr = LineBuffer;
get_line(ptr, (uint8_t)(sizeof(uint8_t)* LINE_SIZE)); //sizeof (Line);
switch (*ptr++) {
case 'h' : // help
xSerialPrint_P( PSTR("rt - reset maximum & minimum temperatures\r\n") );
xSerialPrint_P( PSTR("t - show the time\r\n") );
xSerialPrint_P( PSTR("t - set the time\r\nt [<year yy> <month mm> <date dd> <day: Sun=0> <hour hh> <minute mm> <second ss>]\r\n") );
break;
#ifdef portRTC_DEFINED
case 't' : /* t [<year yy> <month mm> <date dd> <day: Sun=0> <hour hh> <minute mm> <second ss>] */
if (xatoi(&ptr, &p1)) {
SetTimeDate.tm_year = (uint8_t)p1 + 100; // convert to (Gregorian - 1900)
xatoi(&ptr, &p1); SetTimeDate.tm_mon = (uint8_t)p1;
xatoi(&ptr, &p1); SetTimeDate.tm_mday = (uint8_t)p1;
xatoi(&ptr, &p1); SetTimeDate.tm_wday = (uint8_t)p1;
xatoi(&ptr, &p1); SetTimeDate.tm_hour = (uint8_t)p1;
xatoi(&ptr, &p1); SetTimeDate.tm_min = (uint8_t)p1;
if (!xatoi(&ptr, &p1))
break;
SetTimeDate.tm_sec = (uint8_t)p1;
xSerialPrintf_P(PSTR("Set: %u/%u/%u %2u:%02u:%02u\r\n"), SetTimeDate.tm_year, SetTimeDate.tm_mon, SetTimeDate.tm_mday, SetTimeDate.tm_hour, SetTimeDate.tm_min, SetTimeDate.tm_sec);
if (setDateTimeDS1307( &SetTimeDate ) == pdTRUE)
xSerialPrint_P( PSTR("Setting successful\r\n") );
} else {
if (getDateTimeDS1307( &xCurrentTempTime.DateTime) == pdTRUE)
xSerialPrintf_P(PSTR("Current: %u/%u/%u %2u:%02u:%02u\r\n"), xCurrentTempTime.DateTime.tm_year + 1900, xCurrentTempTime.DateTime.tm_mon, xCurrentTempTime.DateTime.tm_mday, xCurrentTempTime.DateTime.tm_hour, xCurrentTempTime.DateTime.tm_min, xCurrentTempTime.DateTime.tm_sec);
}
break;
#endif
case 'r' : // reset
switch (*ptr++) {
case 't' : // temperature
xMaximumTempTime = xCurrentTempTime;
xMinimumTempTime = xCurrentTempTime;
// Now we commit the time and temperature to the EEPROM, forever...
eeprom_update_block(&xMaximumTempTime, &xMaximumEverTempTime, sizeof(xRTCTempArray));
eeprom_update_block(&xMinimumTempTime, &xMinimumEverTempTime, sizeof(xRTCTempArray));
break;
default :
break;
}
break;
default :
break;
}
// xSerialPrintf_P(PSTR("\r\nSerial Monitor: Stack HighWater @ %u"), uxTaskGetStackHighWaterMark(NULL));
// xSerialPrintf_P(PSTR("\r\nFree Heap Size: %u\r\n"), xPortGetMinimumEverFreeHeapSize() ); // needs heap_1, heap_2 or heap_4 for this function to succeed.
}
}
示例14: vPutCharToUSARTy
/* Send character to second USART with default TIMEOUT */
void vPutCharToUSARTy( unsigned char data )
{
xSerialPutChar(serCOM2, data, serNO_BLOCK);
}
示例15: fputc
int fputc(int ch, FILE *f)
{
xSerialPutChar(0, ch, 0);
return ch;
}