当前位置: 首页>>代码示例>>C++>>正文


C++ HAL_UART_Receive_IT函数代码示例

本文整理汇总了C++中HAL_UART_Receive_IT函数的典型用法代码示例。如果您正苦于以下问题:C++ HAL_UART_Receive_IT函数的具体用法?C++ HAL_UART_Receive_IT怎么用?C++ HAL_UART_Receive_IT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了HAL_UART_Receive_IT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Hal_FlipBUff

static BOOL Hal_FlipBUff(USER_UART_HandleTypeDef *pHandle)
{
			uint8_t tmp;

			tmp = WhichLowBuffer(pHandle); 	
			if(tmp==ERR)
					return FALSE;
			//disable interrupt
			__HAL_UART_DISABLE_IT(&(pHandle->UartHandle), UART_IT_RXNE);  
			//save low buff to upbuff
			pHandle->UpBufferPtr = pBuffTable[tmp];  
			pHandle->UpBufferCount =  pHandle->UartHandle.RxXferSize - pHandle->UartHandle.RxXferCount;		
			//change the uart state
			if(pHandle->UartHandle.State==HAL_UART_STATE_BUSY_TX_RX) 
					pHandle->UartHandle.State = HAL_UART_STATE_BUSY_TX;
			else
					pHandle->UartHandle.State = HAL_UART_STATE_READY;
			
			//flip buffer
			if(tmp==0)
					HAL_UART_Receive_IT(&(pHandle->UartHandle), (uint8_t *)pBuffTable[1], HAL_BUFFER_SIZE);
			else
					HAL_UART_Receive_IT(&(pHandle->UartHandle), (uint8_t *)pBuffTable[0], HAL_BUFFER_SIZE);
			__HAL_UART_ENABLE_IT(&(pHandle->UartHandle), UART_IT_RXNE);
			
			return TRUE;
}
开发者ID:fanqh,项目名称:FlipBuff,代码行数:27,代码来源:flip_buff.c

示例2: HAL_UART_RxCpltCallback

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
	if(Rx_Data[0] != 59) // 받은 문자가 ';'이 아니면
	{
		if(Buffer_idx >= MAX_BUFFER_SIZE) // 수신버퍼의 사이즈가 5가 넘으면
		{
			Buffer_idx = 0;					// 버퍼인덱스도 0부터 시작
			for(int i = 0; i<MAX_BUFFER_SIZE; i++)
				Rx_Buffer[i] = '\0';
		}
		Rx_Buffer[Buffer_idx] = Rx_Data[0];	// 수신데이터를 버퍼에 처넣음		
		Buffer_idx++;
		HAL_UART_Receive_IT(&huart1, (uint8_t *)Rx_Data, 1); // 다시 받을 준비
	}
	else // ';'을 받으면
	{	
		char temp[50];
		sprintf(temp, "Rx_Data : %c\tBuffer : %s\tBuffer_Idx : %d\n", Rx_Data[0], Rx_Buffer, Buffer_idx);
		
		Buffer_idx = 0;		// 버퍼 초기화			
			for(int i = 0; i<MAX_BUFFER_SIZE; i++)
				Rx_Buffer[i] = '\0'; // 버퍼 초기화		
		HAL_UART_Transmit_IT(&huart1, (uint8_t *)temp, 50);
	}
}
开发者ID:Bit-Embedded-3,项目名称:smart_glove,代码行数:25,代码来源:main.c

示例3: HAL_UART_GPS_ErrorCallback

/**
  * @brief  UART error callbacks
  * @param  huart: UART handle
  * @note   This example shows a simple way to report transfer error, and you can
  *         add your own implementation.
  * @retval None
  */
void HAL_UART_GPS_ErrorCallback(UART_HandleTypeDef *huart)
{
    HAL_UART_GPS_MspDeInit(&UartHandle_gps);
    GpsUsartInit();
    HAL_UART_GPS_MspInit(&UartHandle_gps);
    HAL_UART_Receive_IT(&UartHandle_gps, (u8*)&recv_char_gps, 1);
}
开发者ID:HargicStudio,项目名称:AirMonitor,代码行数:14,代码来源:gps_dev.c

示例4: BSP_UART_Init

void BSP_UART_Init(void) {

	GPIO_InitTypeDef GPIO_InitStruct;

	__GPIOD_CLK_ENABLE()
	;

	__HAL_RCC_USART3_CLK_ENABLE()
	;

	GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_8;
	GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
	GPIO_InitStruct.Pull = GPIO_PULLUP;
	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
	GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
	HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

	UART3_Handle.Instance = USART3;
	UART3_Handle.Init.BaudRate = 115200;
	UART3_Handle.Init.WordLength = UART_WORDLENGTH_8B;
	UART3_Handle.Init.StopBits = UART_STOPBITS_1;
	UART3_Handle.Init.Parity = UART_PARITY_NONE;
	UART3_Handle.Init.Mode = UART_MODE_TX_RX;
	UART3_Handle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
	UART3_Handle.Init.OverSampling = UART_OVERSAMPLING_16;
	HAL_UART_Init(&UART3_Handle);

	HAL_NVIC_SetPriority(USART3_IRQn, 0, 1);
	HAL_NVIC_EnableIRQ(USART3_IRQn);

	HAL_UART_Receive_IT(&UART3_Handle, &dato, 1);
}
开发者ID:nahuelrudisi,项目名称:TPBlinky,代码行数:32,代码来源:bsp.c

示例5: HAL_UART_CP15_ErrorCallback

/**
  * @brief  UART error callbacks
  * @param  huart: UART handle
  * @note   This example shows a simple way to report transfer error, and you can
  *         add your own implementation.
  * @retval None
  */
void HAL_UART_CP15_ErrorCallback(UART_HandleTypeDef *huart)
{
    HAL_UART_CP15_MspDeInit(&UartHandle_cp15);
    CP15UsartInit();
    HAL_UART_CP15_MspInit(&UartHandle_cp15);
    HAL_UART_Receive_IT(&UartHandle_cp15, (u8*)&recv_char_cp15, 1);
}
开发者ID:HargicStudio,项目名称:AirMonitor,代码行数:14,代码来源:cp15_dev.c

示例6: main

int main(void)
{
  // Reset of all peripherals, Initializes the Flash interface and the Systick .
  HAL_Init();

  // Configure the system clock .
  SystemClock_Config();

  // Initialize all configured peripherals .
  MX_GPIO_Init();
  MX_UART4_Init();
  
  // Initializes the Global MSP .
  HAL_MspInit();
  HAL_UART_MspInit( &huart4 );
   
  __HAL_UART_ENABLE_IT( &huart4, UART_IT_RXNE);
  HAL_UART_Receive_IT( &huart4 , string , 154 );
  
  while (1)
  {
    HAL_GPIO_WritePin( GPIOD , GPIO_PIN_15 , GPIO_PIN_SET );
    delay(5000000);
    HAL_GPIO_WritePin( GPIOD , GPIO_PIN_15 , GPIO_PIN_RESET );
    delay(5000000);
  }
}
开发者ID:mostafayasin,项目名称:MOTSL,代码行数:27,代码来源:main-RX-int-hal.c

示例7: MX_USART1_UART_Init

/* USART1 init function */
void MX_USART1_UART_Init(void)
{

  huart1.Instance = USART1;
  huart1.Init.BaudRate = 9600;
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
  huart1.Init.StopBits = UART_STOPBITS_1;
  huart1.Init.Parity = UART_PARITY_NONE;
  huart1.Init.Mode = UART_MODE_TX_RX;
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
	
	if(HAL_UART_Init(&huart1) != HAL_OK){  
      printf("Uart Init Error!\r\n"); 
			while(1);
  }  

	NVIC_SetPriority(USART1_IRQn,0);  
	NVIC_EnableIRQ(USART1_IRQn);  
	uart_rev.front = aRxBuffer;  
	uart_rev.rear = aRxBuffer;
	//assign space to receive input
	if(HAL_UART_Receive_IT(&huart1,(uint8_t*)aRxBuffer,1) != HAL_OK){  
			printf("Uart Read Error!\r\n"); 
	}  
}
开发者ID:he7850,项目名称:stm32f103-application,代码行数:27,代码来源:main.c

示例8: uartRxCompleteCallback

// TODO: Packet RX timeout, buffer full check?
void uartRxCompleteCallback(Client* c)
{
	static uint8_t packetCount = 0;
	static uint8_t rxState = RX_PACKET_IDLE;

	c->rxBuffer[packetCount++] = c->rxByte;
	switch (rxState)
	{
	case RX_PACKET_IDLE:
		rxState = RX_PACKET_GOTLENGTH;
		break;
	case RX_PACKET_GOTLENGTH:
		rxState = RX_PACKET_GOTCOMMAND;
		break;
	case RX_PACKET_GOTCOMMAND:
		; // has to be here, otherwise 'deceleration after label' error
		uint8_t packetLength = c->rxBuffer[0];
		if (packetCount == packetLength + 1) // Got rest of packet
		{
			packetCount = 0;
			// Integrity checking
			uint32_t crcRx = c->rxBuffer[packetLength - 3] | (c->rxBuffer[packetLength - 2] << 8)
					| (c->rxBuffer[packetLength - 1] << 16) | (c->rxBuffer[packetLength] << 24);
			uint32_t crcCode = HAL_CRC_Calculate(c->peripheral_CRC, (uint32_t*)(c->rxBuffer), packetLength - 3);
			crcCode ^= 0xffffffff;
			if (crcRx == crcCode) // validate packet
			{
				rxHandlePacket(c, c->rxBuffer);
			}
			rxState = RX_PACKET_IDLE;
		}
		break;
	}
	HAL_UART_Receive_IT(c->peripheral_UART, &c->rxByte, 1);
}
开发者ID:RoanBrand,项目名称:STM32SerialToTCPBridgeClient,代码行数:36,代码来源:SerialToTCPBridgeProtocol.c

示例9: serial_rx_asynch

/** 
 * Begin asynchronous RX transfer (enable interrupt for data collecting)
 * The used buffer is specified in the serial object, rx_buff
 *
 * @param obj        The serial object
 * @param rx         The buffer for sending
 * @param rx_length  The number of words to transmit
 * @param rx_width   The bit width of buffer word
 * @param handler    The serial handler
 * @param event      The logical OR of events to be registered
 * @param handler    The serial handler
 * @param char_match A character in range 0-254 to be matched
 * @param hint       A suggestion for how to use DMA with this transfer
 */
void serial_rx_asynch(serial_t *obj, void *rx, size_t rx_length, uint8_t rx_width, uint32_t handler, uint32_t event, uint8_t char_match, DMAUsage hint)
{
    // TODO: DMA usage is currently ignored
    (void) hint;

    /* Sanity check arguments */
    MBED_ASSERT(obj);
    MBED_ASSERT(rx != (void*)0);
    MBED_ASSERT(rx_width == 8); // support only 8b width
    
    struct serial_s *obj_s = SERIAL_S(obj);
    UART_HandleTypeDef *huart = &uart_handlers[obj_s->index];

    serial_enable_event(obj, SERIAL_EVENT_RX_ALL, 0);
    serial_enable_event(obj, event, 1);
    
    // set CharMatch
    obj->char_match = char_match;
    
    serial_rx_buffer_set(obj, rx, rx_length, rx_width);

    IRQn_Type irq_n = serial_get_irq_n(obj);
    NVIC_ClearPendingIRQ(irq_n);
    NVIC_DisableIRQ(irq_n);
    NVIC_SetPriority(irq_n, 0);
    NVIC_SetVector(irq_n, (uint32_t)handler);
    NVIC_EnableIRQ(irq_n);

    // following HAL function will enable the RXNE interrupt + error interrupts    
    HAL_UART_Receive_IT(huart, (uint8_t*)rx, rx_length);
}
开发者ID:AlessandroA,项目名称:mbed,代码行数:45,代码来源:serial_api.c

示例10: HAL_NVIC_DisableIRQ

uint8_t HardwareSerial::read(void) {

	if ( rx_buffer_bytes_available < 1 ) return -1;

	HAL_NVIC_DisableIRQ(USART6_IRQn);
	int next_index = this->rx_buffer_index - this->rx_buffer_bytes_available;
	if ( next_index < 0 ) {
		next_index += UART_RX_BUFFER_SIZE;
	}
	this->rx_buffer_bytes_available--;

	/* If receive buffer was full, and has been emptied, begin receiving more data now. */
	HAL_StatusTypeDef status;
	if ( Serial6.rx_buffer_bytes_available == (UART_RX_BUFFER_SIZE-1) ) {
		status = HAL_UART_Receive_IT(&huart6, &Serial6.rx_buffer[Serial6.rx_buffer_index], 1);
		if ( HAL_OK == status ) {
			full_buffer = false;
		} else {
			failed_posted_read = false;
		}
	}
    HAL_NVIC_EnableIRQ(USART6_IRQn);

	return this->rx_buffer[next_index];
}
开发者ID:FRC1640,项目名称:2015-Code,代码行数:25,代码来源:HardwareSerial.cpp

示例11: UartDebugConfig0

/** @brief: config uartDebug. here it uses uartPort3
 ****************************************************************/
void UartDebugConfig0(void) {
	UART_HandleTypeDef * huart = calloc(1, sizeof(UART_HandleTypeDef));
	REQUIRE(huart != 0);
	huartDebugPort = huart;//huartDebugPort must be defined as early as possible bf enable interrupt

	rxDebugDataRingBuffer = RingBufferConstructor();
	REQUIRE(rxDebugDataRingBuffer != 0);
	RingBufferConfig(rxDebugDataRingBuffer, RX_BUFFER_SIZE, sizeof(int8_t));
	txDebugDataRingBuffer = RingBufferConstructor();
	REQUIRE(txDebugDataRingBuffer != 0);
	RingBufferConfig(txDebugDataRingBuffer, TX_BUFFER_SIZE, sizeof(int8_t));
	txDebugLengthRingBuffer = RingBufferConstructor();
	REQUIRE(txDebugLengthRingBuffer != 0);
	RingBufferConfig(txDebugLengthRingBuffer, TX_BUFFER_SIZE, sizeof(int8_t));

#if DEBUGUART_ID == 6
	Uart6PortConfig(huart);
#elif DEBUGUART_ID == 1
	Uart1PortConfig(huart);
#elif DEBUGUART_ID == 3
	Uart3PortConfig(huart);
#elif DEBUGUART_ID == 2
	Uart2PortConfig(huart);
#endif
	huart->pRxBuffPtr = (uint8_t *) rxMsgBuffer;
	huart->pTxBuffPtr = (uint8_t *) txMsgBuffer;
	HAL_UART_Receive_IT(huart, (uint8_t *) (huart->pRxBuffPtr), 1);


}
开发者ID:glocklueng,项目名称:myLib,代码行数:32,代码来源:cDebugUart.c

示例12: rs232RxCpltCallback

/**
  * @brief  Rx Transfer completed callback
  * @param  None
  * @retval None
  */
void rs232RxCpltCallback()
{
	if (prvRxBuffer1State != BUFFERState_Reading && prvRxBuffer1Count < RX_BUFFER_SIZE)
	{
		prvRxBuffer1State = BUFFERState_Writing;
		prvRxBuffer1[prvRxBuffer1CurrentIndex++] = prvReceivedByte;
		prvRxBuffer1Count++;
		/* Start the timer which will clear the buffer if it's not already started */
		if (xTimerIsTimerActive(prvBuffer1ClearTimer) == pdFALSE)
			xTimerStartFromISR(prvBuffer1ClearTimer, NULL);
	}
	else if (prvRxBuffer2State != BUFFERState_Reading && prvRxBuffer2Count < RX_BUFFER_SIZE)
	{
		prvRxBuffer2State = BUFFERState_Writing;
		prvRxBuffer2[prvRxBuffer2CurrentIndex++] = prvReceivedByte;
		prvRxBuffer2Count++;
		/* Start the timer which will clear the buffer if it's not already started */
		if (xTimerIsTimerActive(prvBuffer2ClearTimer) == pdFALSE)
			xTimerStartFromISR(prvBuffer2ClearTimer, NULL);
	}
	else
	{
		/* No buffer available, something has gone wrong */
		HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_3);
	}

	/* Continue receiving data */
	HAL_UART_Receive_IT(&UART_Handle, &prvReceivedByte, 1);
	/* Give back the semaphore now that we are done */
	xSemaphoreGiveFromISR(xSemaphore, NULL);
}
开发者ID:efimefimefim,项目名称:HexConnect,代码行数:36,代码来源:rs232_task.c

示例13: CDC_Itf_Init

/**
  * @brief  CDC_Itf_Init
  *         Initializes the CDC media low layer
  * @param  None
  * @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
  */
static int8_t CDC_Itf_Init(void)
{
#if 0
  /*##-1- Configure the UART peripheral ######################################*/
  /* Put the USART peripheral in the Asynchronous mode (UART Mode) */
  /* USART configured as follow:
      - Word Length = 8 Bits
      - Stop Bit    = One Stop bit
      - Parity      = No parity
      - BaudRate    = 115200 baud
      - Hardware flow control disabled (RTS and CTS signals) */
  UartHandle.Instance        = USARTx;
  UartHandle.Init.BaudRate   = 115200;
  UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
  UartHandle.Init.StopBits   = UART_STOPBITS_1;
  UartHandle.Init.Parity     = UART_PARITY_NONE;
  UartHandle.Init.HwFlowCtl  = UART_HWCONTROL_NONE;
  UartHandle.Init.Mode       = UART_MODE_TX_RX;
  
  if(HAL_UART_Init(&UartHandle) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler();
  }
  
  /*##-2- Put UART peripheral in IT reception process ########################*/
  /* Any data received will be stored in "UserTxBuffer" buffer  */
  if(HAL_UART_Receive_IT(&UartHandle, (uint8_t *)UserTxBuffer, 1) != HAL_OK)
  {
    /* Transfer error in reception process */
    Error_Handler();
  }
  
  /*##-3- Configure the TIM Base generation  #################################*/
  now done in HAL_MspInit
  TIM_Config();
#endif
  
    /*##-4- Start the TIM Base generation in interrupt mode ####################*/
    /* Start Channel1 */
    __HAL_TIM_ENABLE_IT(&TIM3_Handle, TIM_IT_UPDATE);
  
    /*##-5- Set Application Buffers ############################################*/
    USBD_CDC_SetTxBuffer(&hUSBDDevice, UserTxBuffer, 0);
    USBD_CDC_SetRxBuffer(&hUSBDDevice, UserRxBuffer);

    UserRxBufCur = 0;
    UserRxBufLen = 0;
  
    /* NOTE: we cannot reset these here, because USBD_CDC_SetInterrupt
     * may be called before this init function to set these values.
     * This can happen if the USB enumeration occurs after the call to
     * USBD_CDC_SetInterrupt.
    user_interrupt_char = VCP_CHAR_NONE;
    user_interrupt_data = NULL;
    */

    return (USBD_OK);
}
开发者ID:patrickhpunkt,项目名称:micropython,代码行数:65,代码来源:usbd_cdc_interface.c

示例14: HAL_UARTDebug_RxCpltCallback

void HAL_UARTDebug_RxCpltCallback(UART_HandleTypeDef *huart) {
	PushRingBuffer(rxDebugDataRingBuffer, (--(huart->pRxBuffPtr)));
	//rearm
	HAL_StatusTypeDef ret = HAL_UART_Receive_IT(huart, (uint8_t*) (huart->pRxBuffPtr), 1);
	if(ret != HAL_OK){
		rearmUartReceiveIT = 1;
	}
}
开发者ID:glocklueng,项目名称:myLib,代码行数:8,代码来源:cDebugUart.c

示例15: Uart3PortConfig

/** @brief: call dma,gpio,uart config
 *  @details: after call Uart3PortConfig, all the hardware configuration should be set up properly
 ****************************************************************/
void Uart3PortConfig(UART_HandleTypeDef * huart) {
    Uart3GPIOInit();
    Uart3NVICInit(huart);
    Uart3DMAInit(huart);
    Uart3UARTInit(huart);
    huart->Instance = USART3;
    HAL_UART_Receive_IT(huart, (uint8_t *)(huart->pRxBuffPtr), 1);
}
开发者ID:glocklueng,项目名称:myLib,代码行数:11,代码来源:cUartPort.c


注:本文中的HAL_UART_Receive_IT函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。