本文整理汇总了C++中xQueueCreate函数的典型用法代码示例。如果您正苦于以下问题:C++ xQueueCreate函数的具体用法?C++ xQueueCreate怎么用?C++ xQueueCreate使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xQueueCreate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xSerialPortInitMinimal
/*
* See the serial2.h header file.
*/
xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
{
xComPortHandle xReturn;
UART_InitTypeDef UART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
EIC_IRQInitTypeDef EIC_IRQInitStructure;
/* Create the queues used to hold Rx and Tx characters. */
xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed char ) );
xCharsForTx = xQueueCreate( uxQueueLength + 1, ( unsigned portBASE_TYPE ) sizeof( signed char ) );
/* If the queues were created correctly then setup the serial port
hardware. */
if( ( xRxedChars != serINVALID_QUEUE ) && ( xCharsForTx != serINVALID_QUEUE ) )
{
portENTER_CRITICAL();
{
/* Enable the UART0 Clock. */
MRCC_PeripheralClockConfig( MRCC_Peripheral_UART0, ENABLE );
/* Configure the UART0_Tx as alternate function */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_Init(GPIO0, &GPIO_InitStructure);
/* Configure the UART0_Rx as input floating */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_Init(GPIO0, &GPIO_InitStructure);
/* Configure UART0. */
UART_InitStructure.UART_WordLength = UART_WordLength_8D;
UART_InitStructure.UART_StopBits = UART_StopBits_1;
UART_InitStructure.UART_Parity = UART_Parity_No;
UART_InitStructure.UART_BaudRate = ulWantedBaud;
UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None;
UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx;
UART_InitStructure.UART_TxFIFOLevel = UART_FIFOLevel_1_2; /* FIFO size 16 bytes, FIFO level 8 bytes */
UART_InitStructure.UART_RxFIFOLevel = UART_FIFOLevel_1_2; /* FIFO size 16 bytes, FIFO level 8 bytes */
UART_Init(UART0, &UART_InitStructure);
/* Enable the UART0 */
UART_Cmd(UART0, ENABLE);
/* Configure the IEC for the UART interrupts. */
EIC_IRQInitStructure.EIC_IRQChannelCmd = ENABLE;
EIC_IRQInitStructure.EIC_IRQChannel = UART0_IRQChannel;
EIC_IRQInitStructure.EIC_IRQChannelPriority = 1;
EIC_IRQInit(&EIC_IRQInitStructure);
xQueueEmpty = pdTRUE;
UART_ITConfig( UART0, UART_IT_Transmit | UART_IT_Receive, ENABLE );
}
portEXIT_CRITICAL();
}
else
{
xReturn = ( xComPortHandle ) 0;
}
/* This demo file only supports a single port but we have to return
something to comply with the standard demo header file. */
return xReturn;
}
示例2: adc_init
void adc_init(adc_t* adc)
{
static int already_initialized = 0;
gpio_clock_init(adc->GPIOx);
GPIO_InitTypeDef GPIO_InitStructure =
{
.GPIO_Pin = adc->GPIO_Pin_x,
.GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_IN_FLOATING,
};
GPIO_Init(adc->GPIOx, &GPIO_InitStructure);
// avoid configuring ADC2 again:
if (already_initialized)
return;
already_initialized = 1;
adc_clock_init(ADC2);
xADCMutex = xSemaphoreCreateMutex();
xADCQueue = xQueueCreate(10, sizeof(unsigned short));
ADC_Cmd(ADC2, ENABLE);
// Wait until it stabilizes
wait_us(1000);
ADC_InitTypeDef ADC_InitStructure;
ADC_StructInit(&ADC_InitStructure);
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_NbrOfChannel = 1;
ADC_Init(ADC2, &ADC_InitStructure);
ADC_StartCalibration(ADC2);
while (ADC_GetCalibrationStatus(ADC2));
ADC_Cmd(ADC2, DISABLE);
ADC_ITConfig(ADC2, ADC_IT_EOC, ENABLE);
// Enable interrupt UART:
NVIC_InitTypeDef NVIC_InitStructure =
{
.NVIC_IRQChannel = ADC1_2_IRQn,
.NVIC_IRQChannelPreemptionPriority = 7,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
};
NVIC_Init(&NVIC_InitStructure);
ADC_Cmd(ADC2, ENABLE);
}
void ADC1_2_IRQHandler(void)
{
signed portBASE_TYPE xHigherPriorityTaskWoken;
unsigned short in_buffer = ADC2->DR & 0xfff;
xQueueSendToBackFromISR(xADCQueue, &in_buffer,
&xHigherPriorityTaskWoken);
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
}
unsigned short adc_read(adc_t* adc)
{
unsigned short in_buffer;
xSemaphoreTake(xADCMutex, portMAX_DELAY);
// we use the same ADC for all peripherals
ADC_RegularChannelConfig(ADC2, adc->ADC_Channel, 1,
ADC_SampleTime_239Cycles5);
ADC_Cmd(ADC2, ENABLE);
xQueueReceive(xADCQueue, &in_buffer, portMAX_DELAY);
xSemaphoreGive(xADCMutex);
return in_buffer;
}
示例3: vStartAltBlockingQueueTasks
void vStartAltBlockingQueueTasks( unsigned portBASE_TYPE uxPriority )
{
xBlockingQueueParameters *pxQueueParameters1, *pxQueueParameters2;
xBlockingQueueParameters *pxQueueParameters3, *pxQueueParameters4;
xBlockingQueueParameters *pxQueueParameters5, *pxQueueParameters6;
const unsigned portBASE_TYPE uxQueueSize1 = 1, uxQueueSize5 = 5;
const portTickType xBlockTime = ( portTickType ) 1000 / portTICK_RATE_MS;
const portTickType xDontBlock = ( portTickType ) 0;
/* Create the first two tasks as described at the top of the file. */
/* First create the structure used to pass parameters to the consumer tasks. */
pxQueueParameters1 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
/* Create the queue used by the first two tasks to pass the incrementing number.
Pass a pointer to the queue in the parameter structure. */
pxQueueParameters1->xQueue = xQueueCreate( uxQueueSize1, ( unsigned portBASE_TYPE ) sizeof( unsigned portSHORT ) );
/* The consumer is created first so gets a block time as described above. */
pxQueueParameters1->xBlockTime = xBlockTime;
/* Pass in the variable that this task is going to increment so we can check it
is still running. */
pxQueueParameters1->psCheckVariable = &( sBlockingConsumerCount[ 0 ] );
/* Create the structure used to pass parameters to the producer task. */
pxQueueParameters2 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
/* Pass the queue to this task also, using the parameter structure. */
pxQueueParameters2->xQueue = pxQueueParameters1->xQueue;
/* The producer is not going to block - as soon as it posts the consumer will
wake and remove the item so the producer should always have room to post. */
pxQueueParameters2->xBlockTime = xDontBlock;
/* Pass in the variable that this task is going to increment so we can check
it is still running. */
pxQueueParameters2->psCheckVariable = &( sBlockingProducerCount[ 0 ] );
/* Note the producer has a lower priority than the consumer when the tasks are
spawned. */
xTaskCreate( vBlockingQueueConsumer, ( signed portCHAR * ) "QConsB1", blckqSTACK_SIZE, ( void * ) pxQueueParameters1, uxPriority, NULL );
xTaskCreate( vBlockingQueueProducer, ( signed portCHAR * ) "QProdB2", blckqSTACK_SIZE, ( void * ) pxQueueParameters2, tskIDLE_PRIORITY, NULL );
/* Create the second two tasks as described at the top of the file. This uses
the same mechanism but reverses the task priorities. */
pxQueueParameters3 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
pxQueueParameters3->xQueue = xQueueCreate( uxQueueSize1, ( unsigned portBASE_TYPE ) sizeof( unsigned portSHORT ) );
pxQueueParameters3->xBlockTime = xDontBlock;
pxQueueParameters3->psCheckVariable = &( sBlockingProducerCount[ 1 ] );
pxQueueParameters4 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
pxQueueParameters4->xQueue = pxQueueParameters3->xQueue;
pxQueueParameters4->xBlockTime = xBlockTime;
pxQueueParameters4->psCheckVariable = &( sBlockingConsumerCount[ 1 ] );
xTaskCreate( vBlockingQueueConsumer, ( signed portCHAR * ) "QProdB3", blckqSTACK_SIZE, ( void * ) pxQueueParameters3, tskIDLE_PRIORITY, NULL );
xTaskCreate( vBlockingQueueProducer, ( signed portCHAR * ) "QConsB4", blckqSTACK_SIZE, ( void * ) pxQueueParameters4, uxPriority, NULL );
/* Create the last two tasks as described above. The mechanism is again just
the same. This time both parameter structures are given a block time. */
pxQueueParameters5 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
pxQueueParameters5->xQueue = xQueueCreate( uxQueueSize5, ( unsigned portBASE_TYPE ) sizeof( unsigned portSHORT ) );
pxQueueParameters5->xBlockTime = xBlockTime;
pxQueueParameters5->psCheckVariable = &( sBlockingProducerCount[ 2 ] );
pxQueueParameters6 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
pxQueueParameters6->xQueue = pxQueueParameters5->xQueue;
pxQueueParameters6->xBlockTime = xBlockTime;
pxQueueParameters6->psCheckVariable = &( sBlockingConsumerCount[ 2 ] );
xTaskCreate( vBlockingQueueProducer, ( signed portCHAR * ) "QProdB5", blckqSTACK_SIZE, ( void * ) pxQueueParameters5, tskIDLE_PRIORITY, NULL );
xTaskCreate( vBlockingQueueConsumer, ( signed portCHAR * ) "QConsB6", blckqSTACK_SIZE, ( void * ) pxQueueParameters6, tskIDLE_PRIORITY, NULL );
}
示例4: SerialOpen
/*---------------------------------------------------------------------------/
/ Communication port init & open & close
/---------------------------------------------------------------------------*/
xCOM SerialOpen(xCOM USARTx, u32 BaudRate, portBASE_TYPE uxQueueLength)
{
GPIO_InitTypeDef GPIO_InitStruct;
USART_InitTypeDef USART_InitStruct;
NVIC_InitTypeDef NVIC_InitStruct;
xCOM xResult = (xCOM)NULL;
u8 portNo = USARTx == USART1 ? 0 : 1;
// Create Queue
if(USARTx == USART1)
{
if(xUSART1_RxQueue == serINVALID_QUEUE)
xUSART1_RxQueue = xQueueCreate(uxQueueLength, (unsigned portBASE_TYPE)sizeof(signed portCHAR));
if(xUSART1_TxQueue == serINVALID_QUEUE)
xUSART1_TxQueue = xQueueCreate(uxQueueLength, (unsigned portBASE_TYPE)sizeof(signed portCHAR));
if(xUSART1_RxQueue == serINVALID_QUEUE || xUSART1_TxQueue == serINVALID_QUEUE) return xResult;
}
else if(USARTx == USART6)
{
if(xUSART6_RxQueue == serINVALID_QUEUE)
xUSART6_RxQueue = xQueueCreate(uxQueueLength, (unsigned portBASE_TYPE)sizeof(signed portCHAR));
if(xUSART6_TxQueue == serINVALID_QUEUE)
xUSART6_TxQueue = xQueueCreate(uxQueueLength, (unsigned portBASE_TYPE)sizeof(signed portCHAR));
if(xUSART6_RxQueue == serINVALID_QUEUE || xUSART6_TxQueue == serINVALID_QUEUE) return xResult;
}
// queue init
xQueueInit(USARTx);
// Enable USARTx clock
if(USARTx == USART1)
{
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1);
}
else if(USARTx == USART6)
{
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_USART6);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_USART6);
}
//Configure USART1 Rx (PA10) as input floating
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStruct.GPIO_Pin = (USARTx == USART1 ? (GPIO_Pin_9 | GPIO_Pin_10) : (GPIO_Pin_6 | GPIO_Pin_7));
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStruct);
// USART staus
USART_InitStruct.USART_BaudRate = BaudRate;
USART_InitStruct.USART_WordLength = USART_WordLength_8b;
USART_InitStruct.USART_StopBits = USART_StopBits_1;
USART_InitStruct.USART_Parity = USART_Parity_No ;
USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStruct.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USARTx, &USART_InitStruct);
// RX Interrupt
USART_ITConfig( USARTx, USART_IT_RXNE, ENABLE );
// Interrupt handler
NVIC_InitStruct.NVIC_IRQChannel = (USARTx == USART1 ? USART1_IRQn : USART6_IRQn);
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init( &NVIC_InitStruct );
// Set communication port
USART_Cmd( USARTx, ENABLE );
// Flag
gIsComState[portNo] = TRUE;
// 초기화 시킨 포트 리턴
return xResult = USARTx;
}
示例5: sys_mbox_new
/**
* Creates a new mailbox.
*
* @param size is the number of entries in the mailbox.
* @return the handle of the created mailbox.
*/
sys_mbox_t
sys_mbox_new(int size)
{
unsigned long datasize;
xQueueHandle mbox;
u32_t i;
/* Fail if the mailbox size is too large. */
if(size > MBOX_MAX) {
#if SYS_STATS
STATS_INC(sys.mbox.err);
#endif /* SYS_STATS */
return 0;
}
/* Find a mailbox that is not in use. */
for(i = 0; i < SYS_MBOX_MAX; i++) {
if(mboxes[i].queue == 0) {
break;
}
}
if(i == SYS_MBOX_MAX) {
#if SYS_STATS
STATS_INC(sys.mbox.err);
#endif /* SYS_STATS */
return 0;
}
/* Compute the size of the queue memory required by this mailbox. */
datasize = (sizeof(void *) * size) + portQUEUE_OVERHEAD_BYTES;
/* Create a queue for this mailbox. */
#if RTOS_SAFERTOS
if(xQueueCreate(mboxes[i].buffer, datasize, size, sizeof(void *),
&mbox) != pdPASS) {
#elif RTOS_FREERTOS
mbox = xQueueCreate(size, sizeof(void *));
if(mbox == NULL) {
#endif /* RTOS_SAFERTOS */
#if SYS_STATS
STATS_INC(sys.mbox.err);
#endif /* SYS_STATS */
return 0;
}
/* Update the mailbox statistics. */
#if SYS_STATS
STATS_INC(sys.mbox.used);
#if LWIP_STATS
if(lwip_stats.sys.mbox.max < lwip_stats.sys.mbox.used) {
lwip_stats.sys.mbox.max = lwip_stats.sys.mbox.used;
}
#endif
#endif /* SYS_STATS */
/* Save the queue handle. */
mboxes[i].queue = mbox;
/* Return this mailbox. */
return &(mboxes[i]);
}
/**
* Sends a message to a mailbox.
*
* @param mbox is the mailbox
* @param msg is the message to send
*/
void
sys_mbox_post(sys_mbox_t mbox, void *msg)
{
/* Send this message to the queue. */
while(xQueueSend(mbox->queue, &msg, portMAX_DELAY) != pdPASS);
}
/**
* Tries to send a message to a mailbox.
*
* @param mbox is the mailbox
* @param msg is the message to send
* @return ERR_OK if the message was sent and ERR_MEM if there was no space for
* the message
*/
err_t
sys_mbox_trypost(sys_mbox_t mbox, void *msg)
{
/* Send this message to the queue. */
if(xQueueSend(mbox->queue, &msg, 0) == pdPASS) {
return ERR_OK;
}
/* Update the mailbox statistics. */
#if SYS_STATS
//.........这里部分代码省略.........
示例6: rtos_init_dispatcher
void rtos_init_dispatcher() {
main_queue_handle = xQueueCreate(32, sizeof(struct rtos_event));
xTaskCreate(disp_task, (const signed char *) "disp_task",
(V7_STACK_SIZE + 1024) / 4, NULL, tskIDLE_PRIORITY + 2,
&disp_task_handle);
}
示例7: lCOMPortInit
/*
* See header file for parameter descriptions.
*/
long lCOMPortInit( unsigned long ulPort, unsigned long ulWantedBaud )
{
long lReturn = pdFAIL;
USART_InitTypeDef USART_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
if( ulPort < serNUM_COM_PORTS ) {
/* The common (not port dependent) part of the initialisation. */
USART_InitStructure.USART_BaudRate = ulWantedBaud;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = configLIBRARY_KERNEL_INTERRUPT_PRIORITY;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
/* Init the buffer structures with the buffer for the COM port being
initialised, and perform any non-common initialisation necessary. This
does not check to see if the COM port has already been initialised. */
if( ulPort == 0 ) {
/* Create the queue of chars that are waiting to be sent to COM0. */
xCharsForTx[ 0 ] = xQueueCreate( serTX_QUEUE_LEN, sizeof( char ) );
/* Create the queue used to hold characters received from COM0. */
xRxedChars[ 0 ] = xQueueCreate( serRX_QUEUE_LEN, sizeof( char ) );
/* Enable COM0 clock - the ST libraries start numbering from UART1. */
RCC_APB2PeriphClockCmd( RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE );
/* Configure USART1 Rx (PA10) as input floating */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init( GPIOA, &GPIO_InitStructure );
/* Configure USART1 Tx (PA9) as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init( GPIOA, &GPIO_InitStructure );
USART_Init( USART1, &USART_InitStructure );
USART_ITConfig( USART1, USART_IT_RXNE, ENABLE );
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQChannel;
NVIC_Init( &NVIC_InitStructure );
USART_DMACmd( USART1, ( USART_DMAReq_Tx | USART_DMAReq_Rx ), ENABLE );
USART_Cmd( USART1, ENABLE );
/* Everything is ok. */
lReturn = pdPASS;
} else if( ulPort == 1 ) {
/* Create the queue of chars that are waiting to be sent to COM1. */
xCharsForTx[ 1 ] = xQueueCreate( serTX_QUEUE_LEN, sizeof( char ) );
/* Create the queue used to hold characters received from COM0. */
xRxedChars[ 1 ] = xQueueCreate( serRX_QUEUE_LEN, sizeof( char ) );
/* Enable COM0 clock - the ST libraries start numbering from 1. */
RCC_APB2PeriphClockCmd( RCC_APB1Periph_USART2 | RCC_APB2Periph_GPIOA, ENABLE );
/* Configure USART2 Rx (PA3) as input floating */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init( GPIOA, &GPIO_InitStructure );
/* Configure USART2 Tx (PA2) as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init( GPIOA, &GPIO_InitStructure );
USART_Init( USART2, &USART_InitStructure );
USART_ITConfig( USART2, USART_IT_RXNE, ENABLE );
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQChannel;
NVIC_Init( &NVIC_InitStructure );
USART_DMACmd( USART2, ( USART_DMAReq_Tx | USART_DMAReq_Rx ), ENABLE );
USART_Cmd( USART2, ENABLE );
/* Everything is ok. */
lReturn = pdPASS;
} else {
/* Nothing to do unless more than two ports are supported. */
}
}
return lReturn;
}
示例8: xSerialPortInitMinimal
/*
* See the serial2.h header file.
*/
xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
{
xComPortHandle xReturn;
USART_InitTypeDef USART_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
/* Create the queues used to hold Rx/Tx characters. */
xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed char ) );
xCharsForTx = xQueueCreate( uxQueueLength + 1, ( unsigned portBASE_TYPE ) sizeof( signed char ) );
/* If the queue/semaphore was created correctly then setup the serial port
hardware. */
if( ( xRxedChars != serINVALID_QUEUE ) && ( xCharsForTx != serINVALID_QUEUE ) )
{
/* Enable USART1 clock */
RCC_APB2PeriphClockCmd( RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE );
/* Configure USART1 Rx (PA10) as input floating */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init( GPIOA, &GPIO_InitStructure );
/* Configure USART1 Tx (PA9) as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init( GPIOA, &GPIO_InitStructure );
USART_InitStructure.USART_BaudRate = ulWantedBaud;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No ;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_InitStructure.USART_Clock = USART_Clock_Disable;
USART_InitStructure.USART_CPOL = USART_CPOL_Low;
USART_InitStructure.USART_CPHA = USART_CPHA_2Edge;
USART_InitStructure.USART_LastBit = USART_LastBit_Disable;
USART_Init( USART1, &USART_InitStructure );
USART_ITConfig( USART1, USART_IT_RXNE, ENABLE );
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = configLIBRARY_KERNEL_INTERRUPT_PRIORITY;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init( &NVIC_InitStructure );
USART_Cmd( USART1, ENABLE );
}
else
{
xReturn = ( xComPortHandle ) 0;
}
/* This demo file only supports a single port but we have to return
something to comply with the standard demo header file. */
return xReturn;
}
示例9: spi_slave_initialize
esp_err_t spi_slave_initialize(spi_host_device_t host, const spi_bus_config_t *bus_config, const spi_slave_interface_config_t *slave_config, int dma_chan)
{
bool native, claimed;
//We only support HSPI/VSPI, period.
SPI_CHECK(VALID_HOST(host), "invalid host", ESP_ERR_INVALID_ARG);
claimed = spicommon_periph_claim(host);
SPI_CHECK(claimed, "host already in use", ESP_ERR_INVALID_STATE);
spihost[host] = malloc(sizeof(spi_slave_t));
if (spihost[host] == NULL) goto nomem;
memset(spihost[host], 0, sizeof(spi_slave_t));
memcpy(&spihost[host]->cfg, slave_config, sizeof(spi_slave_interface_config_t));
spicommon_bus_initialize_io(host, bus_config, dma_chan, SPICOMMON_BUSFLAG_SLAVE, &native);
gpio_set_direction(slave_config->spics_io_num, GPIO_MODE_INPUT);
spicommon_cs_initialize(host, slave_config->spics_io_num, 0, native == false);
spihost[host]->no_gpio_matrix = native;
spihost[host]->dma_chan = dma_chan;
if (dma_chan != 0) {
//See how many dma descriptors we need and allocate them
int dma_desc_ct = (bus_config->max_transfer_sz + SPI_MAX_DMA_LEN - 1) / SPI_MAX_DMA_LEN;
if (dma_desc_ct == 0) dma_desc_ct = 1; //default to 4k when max is not given
spihost[host]->max_transfer_sz = dma_desc_ct * SPI_MAX_DMA_LEN;
spihost[host]->dmadesc_tx = pvPortMallocCaps(sizeof(lldesc_t) * dma_desc_ct, MALLOC_CAP_DMA);
spihost[host]->dmadesc_rx = pvPortMallocCaps(sizeof(lldesc_t) * dma_desc_ct, MALLOC_CAP_DMA);
if (!spihost[host]->dmadesc_tx || !spihost[host]->dmadesc_rx) goto nomem;
} else {
//We're limited to non-DMA transfers: the SPI work registers can hold 64 bytes at most.
spihost[host]->max_transfer_sz = 16 * 4;
}
//Create queues
spihost[host]->trans_queue = xQueueCreate(slave_config->queue_size, sizeof(spi_slave_transaction_t *));
spihost[host]->ret_queue = xQueueCreate(slave_config->queue_size, sizeof(spi_slave_transaction_t *));
if (!spihost[host]->trans_queue || !spihost[host]->ret_queue) goto nomem;
esp_intr_alloc(spicommon_irqsource_for_host(host), ESP_INTR_FLAG_INTRDISABLED, spi_intr, (void *)spihost[host], &spihost[host]->intr);
spihost[host]->hw = spicommon_hw_for_host(host);
//Configure slave
spihost[host]->hw->clock.val = 0;
spihost[host]->hw->user.val = 0;
spihost[host]->hw->ctrl.val = 0;
spihost[host]->hw->slave.wr_rd_buf_en = 1; //no sure if needed
spihost[host]->hw->user.doutdin = 1; //we only support full duplex
spihost[host]->hw->user.sio = 0;
spihost[host]->hw->slave.slave_mode = 1;
spihost[host]->hw->dma_conf.val |= SPI_OUT_RST | SPI_IN_RST | SPI_AHBM_RST | SPI_AHBM_FIFO_RST;
spihost[host]->hw->dma_out_link.start = 0;
spihost[host]->hw->dma_in_link.start = 0;
spihost[host]->hw->dma_conf.val &= ~(SPI_OUT_RST | SPI_IN_RST | SPI_AHBM_RST | SPI_AHBM_FIFO_RST);
spihost[host]->hw->dma_conf.out_data_burst_en = 1;
spihost[host]->hw->slave.sync_reset = 1;
spihost[host]->hw->slave.sync_reset = 0;
bool nodelay = true;
spihost[host]->hw->ctrl.rd_bit_order = (slave_config->flags & SPI_SLAVE_RXBIT_LSBFIRST) ? 1 : 0;
spihost[host]->hw->ctrl.wr_bit_order = (slave_config->flags & SPI_SLAVE_TXBIT_LSBFIRST) ? 1 : 0;
if (slave_config->mode == 0) {
spihost[host]->hw->pin.ck_idle_edge = 0;
spihost[host]->hw->user.ck_i_edge = 1;
spihost[host]->hw->ctrl2.miso_delay_mode = nodelay ? 0 : 2;
} else if (slave_config->mode == 1) {
spihost[host]->hw->pin.ck_idle_edge = 0;
spihost[host]->hw->user.ck_i_edge = 0;
spihost[host]->hw->ctrl2.miso_delay_mode = nodelay ? 0 : 1;
} else if (slave_config->mode == 2) {
spihost[host]->hw->pin.ck_idle_edge = 1;
spihost[host]->hw->user.ck_i_edge = 0;
spihost[host]->hw->ctrl2.miso_delay_mode = nodelay ? 0 : 1;
} else if (slave_config->mode == 3) {
spihost[host]->hw->pin.ck_idle_edge = 1;
spihost[host]->hw->user.ck_i_edge = 1;
spihost[host]->hw->ctrl2.miso_delay_mode = nodelay ? 0 : 2;
}
//Reset DMA
spihost[host]->hw->dma_conf.val |= SPI_OUT_RST | SPI_IN_RST | SPI_AHBM_RST | SPI_AHBM_FIFO_RST;
spihost[host]->hw->dma_out_link.start = 0;
spihost[host]->hw->dma_in_link.start = 0;
spihost[host]->hw->dma_conf.val &= ~(SPI_OUT_RST | SPI_IN_RST | SPI_AHBM_RST | SPI_AHBM_FIFO_RST);
//Disable unneeded ints
spihost[host]->hw->slave.rd_buf_done = 0;
spihost[host]->hw->slave.wr_buf_done = 0;
spihost[host]->hw->slave.rd_sta_done = 0;
spihost[host]->hw->slave.wr_sta_done = 0;
spihost[host]->hw->slave.rd_buf_inten = 0;
spihost[host]->hw->slave.wr_buf_inten = 0;
spihost[host]->hw->slave.rd_sta_inten = 0;
spihost[host]->hw->slave.wr_sta_inten = 0;
//Force a transaction done interrupt. This interrupt won't fire yet because we initialized the SPI interrupt as
//disabled. This way, we can just enable the SPI interrupt and the interrupt handler will kick in, handling
//any transactions that are queued.
spihost[host]->hw->slave.trans_inten = 1;
spihost[host]->hw->slave.trans_done = 1;
//.........这里部分代码省略.........
示例10: main
int main(int argc, char* argv[]) {
int i = 0; // indice usato per i cicli for
int n = 0; // variabile per il numero di sensori
xQueueHandle queue[NUM_PRIORITIES];
Sync_Init sync_sensor;
initNode();
initSensors();
// initNetwork(); funzione fornita dal livello rete
if ( join(getID()) == 0) { // supponendo sia questa la firma
// scrive nel log che si e' verificato un errore di autenticazione
while(1);
}
for (i = 0; i < NUM_PRIORITIES; i++)
queue[i] = xQueueCreate(MAX_QUEUE_LENGTH, sizeof(Message));
if (xTaskCreate(asyncRequestManage,// nome della funzione
"Gestione richieste asincrone",
configMINIMAL_STACK_SIZE,
queue(1), // parametri della funzione: queue(1)
3) != pdTRUE) {
// scrive nel log che si `e verificato un errore di gestione della memoria
while(1);
}
n = getNumSensors();
for (i = 0; i < n; i++) {
if (getPeriod(getSensorID(i)) > 0) {
sync_sensor.ID = getSensorID(i);
sync_sensor.period = getPeriod(getSensorID(i));
if (xTaskCreate(syncSensorManage,// nome della funzione
"Task di gestione di un sensore sincrono ",
configMINIMAL_STACK_SIZE,
(void *)&sync_sensor, // parametri della funzione
2) != pdTRUE) {
// scrive nel log che si `e verificato un errore di gestione della memoria
while(1);
}
}
}
if (xTaskCreate(sendOverNetwork,// nome della funzione
"Task per l'invio dei messaggi",
configMINIMAL_STACK_SIZE,
(void *)queue, // parametri della funzione
1) != pdTRUE) {
// scrive nel log che si `e verificato un errore di gestione della memoria
while(1);
}
vTaskStartScheduler();
while (1);
}
示例11: U5_Open
/********************************************************************
* *
* U5_Open *
* *
*********************************************************************
INPUT : uint32_t speed : baudrate
uint16_t ft : frame type see FRAME_TYPE_enum
uint16_t pt : parity type see PARITY_TYPE_enum
*********************************************************************
* *
* Open the serial port for DTE comunications *
* *
********************************************************************/
void U5_Open(uint32_t speed,uint16_t parity,uint16_t stopbits)
{
USART_InitTypeDef USART_InitStructure;
U5_Close() ;
switch(stopbits)
{
case UARTSB_1:
stopbits = USART_StopBits_1;
break;
case UARTSB_2:
stopbits = USART_StopBits_2;
break;
default:
return;
}
switch(parity)
{
case UARTP_None:
mask_U5 = 0xff;
parity = USART_Parity_No;
break;
case UARTP_Even:
mask_U5 = 0x7f;
parity = USART_Parity_Even;
break;
case UARTP_Odd:
mask_U5 = 0x7f;
parity = USART_Parity_Odd;
break;
default:
return;
}
//set Baud Rate
USART_InitStructure.USART_BaudRate = speed ;
// UART5 parameters overtake configuration ----------------------------
/* UART5 configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Hardware flow control enabled (RTS and CTS signals)
- Receive and transmit enabled
*/
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_Parity = parity ;
USART_InitStructure.USART_StopBits = stopbits;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
// configure the UART5
USART_Init(UART5, &USART_InitStructure);
/* Configure UART5 Rx (PD.2) as input floating */
GpioInit(GPIOD,GPIO_Pin_2,GPIO_Mode_IN_FLOATING,0);
/* Configure UART5 Tx (PC.12) as alternate function push-pull */
GpioInit(GPIOC,GPIO_Pin_12,GPIO_Mode_AF_PP,0);
if (!xRxQueue)
xRxQueue = xQueueCreate( RxQueueSize, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) );
if (!xTxQueue)
xTxQueue = xQueueCreate( TxQueueSize, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) );
if (!prntfBuf)
prntfBuf = pvPortMalloc(PRNTFBUF_SIZE);
if (!xSemaPrintf)
xSemaPrintf = xSemaphoreCreateMutex();
// Enable UART5
USART_Cmd(UART5, ENABLE);
U5_ClearTx();
U5_ClearRx();
NVIC_SetPriority(UART5_IRQn,UART5_IRQ_PRIO);
// Enable IRQ
NVIC_EnableIRQ(UART5_IRQn);
active_U5 = TRUE;
}
示例12: prvCreateAndDeleteStaticallyAllocatedQueues
static void prvCreateAndDeleteStaticallyAllocatedQueues( void )
{
QueueHandle_t xQueue;
/* StaticQueue_t is a publicly accessible structure that has the same size and
alignment requirements as the real queue structure. It is provided as a
mechanism for applications to know the size of the queue (which is dependent on
the architecture and configuration file settings) without breaking the strict
data hiding policy by exposing the real queue internals. This StaticQueue_t
variable is passed into the xQueueCreateStatic() function calls within this
function. */
static StaticQueue_t xStaticQueue;
/* The queue storage area must be large enough to hold the maximum number of
items it is possible for the queue to hold at any one time, which equals the
queue length (in items, not bytes) multiplied by the size of each item. In this
case the queue will hold staticQUEUE_LENGTH_IN_ITEMS 64-bit items. See
http://www.freertos.org/Embedded-RTOS-Queues.html */
static uint8_t ucQueueStorageArea[ staticQUEUE_LENGTH_IN_ITEMS * sizeof( uint64_t ) ];
/* Create the queue. xQueueCreateStatic() has two more parameters than the
usual xQueueCreate() function. The first new parameter is a pointer to the
pre-allocated queue storage area. The second new parameter is a pointer to
the StaticQueue_t structure that will hold the queue state information in
an anonymous way. If the two pointers are passed as NULL then the data
will be allocated dynamically as if xQueueCreate() had been called. */
xQueue = xQueueCreateStatic( staticQUEUE_LENGTH_IN_ITEMS, /* The maximum number of items the queue can hold. */
sizeof( uint64_t ), /* The size of each item. */
ucQueueStorageArea, /* The buffer used to hold items within the queue. */
&xStaticQueue ); /* The static queue structure that will hold the state of the queue. */
/* The queue handle should equal the static queue structure passed into the
xQueueCreateStatic() function. */
configASSERT( xQueue == ( QueueHandle_t ) &xStaticQueue );
/* Ensure the queue passes a few sanity checks as a valid queue. */
prvSanityCheckCreatedQueue( xQueue );
/* Delete the queue again so the buffers can be reused. */
vQueueDelete( xQueue );
/* Now do the same using a dynamically allocated queue to ensure the delete
function is working correctly in both the static and dynamic memory
allocation cases. */
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
{
xQueue = xQueueCreate( staticQUEUE_LENGTH_IN_ITEMS, /* The maximum number of items the queue can hold. */
sizeof( uint64_t ) ); /* The size of each item. */
/* The queue handle should equal the static queue structure passed into the
xQueueCreateStatic() function. */
configASSERT( xQueue != NULL );
/* Ensure the queue passes a few sanity checks as a valid queue. */
prvSanityCheckCreatedQueue( xQueue );
/* Delete the queue again so the buffers can be reused. */
vQueueDelete( xQueue );
}
#endif
}
示例13: csp_queue_create
csp_queue_handle_t csp_queue_create(int length, size_t item_size) {
return xQueueCreate(length, item_size);
}
示例14: vOLEDTask
// *************** vOLEDTask ***************
void vOLEDTask( void *pvParameters )
{
xOLEDMessage xMessage;
unsigned portLONG ulY, ulMaxY;
// unsigned portBASE_TYPE uxUnusedStackOnEntry;
/* Functions to access the OLED. The one used depends on the dev kit
being used. */
void ( *vOLEDInit )( unsigned portLONG ) = NULL;
void ( *vOLEDStringDraw )( const portCHAR *, unsigned portLONG, unsigned portLONG, unsigned portCHAR ) = NULL;
void ( *vOLEDImageDraw )( const unsigned portCHAR *, unsigned portLONG, unsigned portLONG, unsigned portLONG, unsigned portLONG ) = NULL;
void ( *vOLEDClear )( void ) = NULL;
/* Create the queue used by the OLED task. Messages for display on the OLED
are received via this queue. */
xOLEDQueue = xQueueCreate( mainOLED_QUEUE_SIZE, sizeof( xOLEDMessage ) );
/* Get the "high water mark" for this thread's stack. This value indicates
the smallest amount of unused stack reached for this thread. A value of
0 means the thread has either filled or overflowed its stack. Note that
this function call is for demo only and serves no purpose here. */
// uxUnusedStackOnEntry = uxTaskGetStackHighWaterMark( NULL );
/* Map the OLED access functions to the driver functions that are appropriate
for the evaluation kit being used. */
switch( HWREG( SYSCTL_DID1 ) & SYSCTL_DID1_PRTNO_MASK )
{
// case SYSCTL_DID1_PRTNO_6965 :
// case SYSCTL_DID1_PRTNO_2965 : vOLEDInit = OSRAM128x64x4Init;
// vOLEDStringDraw = OSRAM128x64x4StringDraw;
// vOLEDImageDraw = OSRAM128x64x4ImageDraw;
// vOLEDClear = OSRAM128x64x4Clear;
// ulMaxY = mainMAX_ROWS_64;
// break;
//
case SYSCTL_DID1_PRTNO_1968 :
case SYSCTL_DID1_PRTNO_8962 :
default : vOLEDInit = RIT128x96x4Init;
vOLEDStringDraw = RIT128x96x4StringDraw;
vOLEDImageDraw = RIT128x96x4ImageDraw;
vOLEDClear = RIT128x96x4Clear;
ulMaxY = mainMAX_ROWS_96;
break;
// default : vOLEDInit = vFormike128x128x16Init;
// vOLEDStringDraw = vFormike128x128x16StringDraw;
// vOLEDImageDraw = vFormike128x128x16ImageDraw;
// vOLEDClear = vFormike128x128x16Clear;
// ulMaxY = mainMAX_ROWS_128;
// break;
}
ulY = ulMaxY;
/* Initialise the OLED and display a startup message. */
vOLEDInit( ulSSI_FREQUENCY );
vOLEDStringDraw( "POWERED BY FreeRTOS", 0, 0, mainFULL_SCALE );
for( ;; )
{
/* Wait for a message to arrive that requires displaying. */
xQueueReceive( xOLEDQueue, &xMessage, portMAX_DELAY );
/* Write the message on the next available row. */
ulY += mainCHARACTER_HEIGHT;
if( ulY >= ulMaxY )
{
ulY = mainCHARACTER_HEIGHT;
vOLEDClear();
//vOLEDStringDraw( pcWelcomeMessage, 0, 0, mainFULL_SCALE );
}
/* Display the message along with the maximum jitter time from the
high priority time test. */
vOLEDStringDraw( xMessage.pcMessage, 0, ulY, mainFULL_SCALE );
}
}
示例15: Serial_Configuration
//AFIO->MAPR=(AFIO->MAPR|AFIO_MAPR_CAN_REMAP_0|AFIO_MAPR_CAN_REMAP_1)&AFIO_MAPR_CAN_REMAP_0;
void Serial_Configuration(unsigned int brate)
{
#ifdef USE_INT
NVIC_InitTypeDef NVIC_InitStructure;
#endif
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1
| RCC_APB2Periph_GPIOA
| RCC_APB2Periph_GPIOB
| RCC_APB2Periph_AFIO, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);
GPIO_InitStructure.GPIO_Pin = USART_TXD_PIN ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(USART_GPIO, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = USART_RXD_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//更具外部电路是否有上下拉电阻需要改变
GPIO_Init(USART_GPIO, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = USART_RTS_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//RTS应该配置为推挽输出,配置为AF时会因为没有配置流控制而不起作用
GPIO_Init(USART_GPIO, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = brate; //波特率115200
USART_InitStructure.USART_WordLength = USART_WordLength_8b; //字长8位
USART_InitStructure.USART_StopBits = USART_StopBits_1; //1位停止字节
USART_InitStructure.USART_Parity = USART_Parity_No; //无奇偶校验
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;//无流控制
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;//打开Rx接收和Tx发送功能
USART_Init(USART_PORT, &USART_InitStructure);//初始化USART
#ifdef USE_INT
USART_ITConfig(USART_PORT, USART_IT_RXNE, ENABLE); // 使能指定的USART1接收中断
USART_ITConfig(USART_PORT, USART_IT_TXE, DISABLE); // 失能指定的USART1发送中断
USART_ITConfig(USART_PORT, USART_IT_TC, ENABLE); // 失能指定的USART1发送完成中断
USART_ClearITPendingBit(USART1, USART_IT_TC);
USART_ClearITPendingBit(USART1, USART_IT_RXNE);
NVIC_InitStructure.NVIC_IRQChannel = USART_NVIC_IRQ;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = UART_PRI;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
xRxedChars = xQueueCreate( serialRxQueueLength, sizeof(u8 ) );
xCharsForTx = xQueueCreate( serialTxQueueLength , sizeof(u8 ) );
if(xRxedChars != NULL){
printf("xRxedChars created OK ! \r\n");
}
if(xCharsForTx != NULL){
printf("xCharsForTx created OK ! \r\n");
}
xSem_UART_CMD = xSemaphoreCreateCounting(2,0);
if( xSem_UART_CMD != NULL )
{
printf("xSem_UART_CMD created OK ! \r\n");
}
#endif
USART_Cmd(USART_PORT, ENABLE);//启动串口
USART_CON_TORECV;
}