本文整理汇总了C++中HAL_UART_DeInit函数的典型用法代码示例。如果您正苦于以下问题:C++ HAL_UART_DeInit函数的具体用法?C++ HAL_UART_DeInit怎么用?C++ HAL_UART_DeInit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HAL_UART_DeInit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: USBD_CDC_DeInit
static uint8_t USBD_CDC_DeInit (USBD_HandleTypeDef *pdev, uint8_t cfgidx)
{
USBD_CDC_HandleTypeDef *hcdc = context;
unsigned index;
for (index = 0; index < NUM_OF_CDC_UARTS; index++,hcdc++)
{
/* Close EP IN */
USBD_LL_CloseEP(pdev, parameters[index].data_in_ep);
/* Close EP OUT */
USBD_LL_CloseEP(pdev, parameters[index].data_out_ep);
/* Close Command IN EP */
USBD_LL_CloseEP(pdev, parameters[index].command_ep);
/* DeInitialize the UART peripheral */
if (hcdc->UartHandle.Instance)
if(HAL_UART_DeInit(&hcdc->UartHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
}
return USBD_OK;
}
开发者ID:majbthrd,项目名称:stm32cdcuart,代码行数:27,代码来源:usbd_cdc.c
示例2: _uart_close
/*#####################################################*/
bool _uart_close(Uart_t *UartSettings)
{
HAL_UART_DeInit((UART_HandleTypeDef*)UartSettings->udata);
if(UartSettings->udata)
free(UartSettings->udata);
return true;
}
开发者ID:MorgothCreator,项目名称:mSdk,代码行数:8,代码来源:uart_interface.c
示例3: uart_deinit
void uart_deinit(pyb_uart_obj_t *uart_obj) {
uart_obj->is_enabled = false;
UART_HandleTypeDef *uart = &uart_obj->uart;
HAL_UART_DeInit(uart);
if (uart->Instance == USART1) {
__USART1_FORCE_RESET();
__USART1_RELEASE_RESET();
__USART1_CLK_DISABLE();
} else if (uart->Instance == USART2) {
__USART2_FORCE_RESET();
__USART2_RELEASE_RESET();
__USART2_CLK_DISABLE();
} else if (uart->Instance == USART3) {
__USART3_FORCE_RESET();
__USART3_RELEASE_RESET();
__USART3_CLK_DISABLE();
} else if (uart->Instance == UART4) {
__UART4_FORCE_RESET();
__UART4_RELEASE_RESET();
__UART4_CLK_DISABLE();
} else if (uart->Instance == USART6) {
__USART6_FORCE_RESET();
__USART6_RELEASE_RESET();
__USART6_CLK_DISABLE();
}
}
开发者ID:JMassapina,项目名称:micropython,代码行数:26,代码来源:uart.c
示例4: SleepMode
void SleepMode(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* Disable all GPIOs to reduce power */
MX_GPIO_Deinit();
/* Configure User push-button as external interrupt generator */
__HAL_RCC_GPIOC_CLK_ENABLE();
GPIO_InitStruct.Pin = B1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
HAL_UART_DeInit(&huart2);
/* Suspend Tick increment to prevent wakeup by Systick interrupt.
Otherwise the Systick interrupt will wake up the device within 1ms (HAL time base) */
HAL_SuspendTick();
__HAL_RCC_PWR_CLK_ENABLE();
/* Request to enter SLEEP mode */
HAL_PWR_EnterSLEEPMode(0, PWR_SLEEPENTRY_WFI);
/* Resume Tick interrupt if disabled prior to sleep mode entry*/
HAL_ResumeTick();
/* Reinitialize GPIOs */
MX_GPIO_Init();
/* Reinitialize UART2 */
MX_USART2_UART_Init();
}
开发者ID:Shreeyak,项目名称:mastering-stm32,代码行数:33,代码来源:main-ex1.c
示例5: CDC_Itf_DeInit
/**
* @brief CDC_Itf_DeInit
* DeInitializes the CDC media low layer
* @param None
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
*/
static int8_t CDC_Itf_DeInit(void)
{
/* DeInitialize the UART peripheral */
if(HAL_UART_DeInit(&UartHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
return (USBD_OK);
}
开发者ID:Lembed,项目名称:STM32CubeF1-mirrors,代码行数:16,代码来源:usbd_cdc_interface.c
示例6: Debug_UARTConfig
void Debug_UARTConfig() {
UARTHandle.Instance = USART2;
UARTHandle.Init.BaudRate = UART_BAUDRATE;
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;
UARTHandle.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
HAL_UART_DeInit(&UARTHandle);
HAL_UART_Init(&UARTHandle);
}
开发者ID:RyanSamlalsingh,项目名称:UART-Debug-Library,代码行数:13,代码来源:uart_debug.c
示例7: prvDisableRs232Interface
/**
* @brief Disables the RS232 interface
* @param None
* @retval None
*/
static void prvDisableRs232Interface()
{
HAL_NVIC_DisableIRQ(UART4_IRQn);
HAL_UART_DeInit(&UART_Handle);
__UART4_CLK_DISABLE();
xSemaphoreGive(xSemaphore);
prvRxBuffer1CurrentIndex = 0;
prvRxBuffer1Count = 0;
prvRxBuffer1State = BUFFERState_Writing;
prvRxBuffer2CurrentIndex = 0;
prvRxBuffer2Count = 0;
prvRxBuffer2State = BUFFERState_Writing;
}
开发者ID:efimefimefim,项目名称:HexConnect,代码行数:19,代码来源:rs232_task.c
示例8: HAL_UART_DeInit
void HardwareSerial::begin(uint32_t baud) {
HAL_StatusTypeDef status;
if ( huart6.Init.BaudRate != baud ) {
HAL_UART_DeInit(&huart6);
huart6.Init.BaudRate = baud;
HAL_UART_Init(&huart6);
}
this->tx_in_progress = false;
this->rx_buffer_bytes_available = 0;
this->rx_buffer_index = 0;
receive_request_pending = false;
status = HAL_UART_Receive_IT(&huart6, &this->rx_buffer[this->rx_buffer_index], 1);
}
开发者ID:FRC1640,项目名称:2015-Code,代码行数:15,代码来源:HardwareSerial.cpp
示例9: prvDisableUart1Interface
/**
* @brief Disables the UART1 interface
* @param None
* @retval None
*/
static void prvDisableUart1Interface()
{
HAL_NVIC_DisableIRQ(USART1_IRQn);
HAL_UART_DeInit(&UART_Handle);
__USART1_CLK_DISABLE();
xSemaphoreGive(xSemaphore);
prvRxBuffer1CurrentIndex = 0;
prvRxBuffer1Count = 0;
prvRxBuffer1State = BUFFERState_Writing;
prvRxBuffer2CurrentIndex = 0;
prvRxBuffer2Count = 0;
prvRxBuffer2State = BUFFERState_Writing;
prvChannelIsEnabled = false;
}
开发者ID:efimefimefim,项目名称:HexConnect,代码行数:21,代码来源:uart1_task.c
示例10: PX4FlowPortInit
void PX4FlowPortInit(void)
{
//*******************************************************
//配置USART发送与接受
__USART1_CLK_ENABLE();
PX4_UartHandle.Instance = USART1;
PX4_UartHandle.Init.BaudRate = 115200;
PX4_UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
PX4_UartHandle.Init.StopBits = UART_STOPBITS_1;
PX4_UartHandle.Init.Parity = UART_PARITY_NONE;
PX4_UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
PX4_UartHandle.Init.Mode = UART_MODE_TX_RX;
PX4_UartHandle.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_RXOVERRUNDISABLE_INIT;
PX4_UartHandle.AdvancedInit.OverrunDisable=UART_ADVFEATURE_OVERRUN_DISABLE;//关闭OverRun
HAL_UART_DeInit(&PX4_UartHandle);//卸载USART1
HAL_UART_Init(&PX4_UartHandle);//装载USART1
/* NVIC for USART, to catch the RX complete */
/*##-4- Put UART peripheral in reception process ###########################*/
/* Enable the UART Data Register not empty Interrupt */
__HAL_UART_ENABLE_IT(&PX4_UartHandle, UART_IT_RXNE);
}
开发者ID:authuir,项目名称:Aircraft,代码行数:23,代码来源:px4.c
示例11: uart_init_peripheral
static int uart_init_peripheral(void)
{
__HAL_RCC_USART2_CLK_ENABLE();
__HAL_RCC_DMA1_CLK_ENABLE();
UARThandle.Instance = UART_INSTANCE;
UARThandle.Init.BaudRate = UART_BAUDRATE;
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.OverSampling = UART_OVERSAMPLING_8;
UARThandle.Init.Mode = UART_MODE_TX_RX;
DMAhandle_TX.Instance = DMA1_Stream6;
DMAhandle_TX.Init.Channel = DMA_CHANNEL_4;
DMAhandle_TX.Init.Direction = DMA_MEMORY_TO_PERIPH;
DMAhandle_TX.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
DMAhandle_TX.Init.MemBurst = DMA_MBURST_SINGLE;
DMAhandle_TX.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
DMAhandle_TX.Init.MemInc = DMA_MINC_ENABLE;
DMAhandle_TX.Init.Mode = DMA_NORMAL;
DMAhandle_TX.Init.PeriphBurst = DMA_PBURST_SINGLE;
DMAhandle_TX.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
DMAhandle_TX.Init.PeriphInc = DMA_PINC_DISABLE;
DMAhandle_TX.Init.Priority = DMA_PRIORITY_LOW;
DMAhandle_RX = DMAhandle_TX;
DMAhandle_RX.Instance = DMA1_Stream5;
DMAhandle_RX.Init.Channel = DMA_CHANNEL_4;
DMAhandle_RX.Init.Direction = DMA_PERIPH_TO_MEMORY;
DMAhandle_RX.Init.Mode = DMA_CIRCULAR;
UARThandle.hdmatx = &DMAhandle_TX;
UARThandle.hdmarx = &DMAhandle_RX;
HAL_UART_DeInit(&UARThandle);
HAL_UART_Init(&UARThandle);
UART_INSTANCE->BRR = (2u << 4u) | (5u); /* Baudrate = 2000000 with SYSCLK=168MHz,
* HAL is not very good at figuring this number out... */
HAL_DMA_DeInit(&DMAhandle_TX);
HAL_DMA_Init(&DMAhandle_TX);
HAL_DMA_DeInit(&DMAhandle_RX);
HAL_DMA_Init(&DMAhandle_RX);
NVIC_SetPriority(DMA1_Stream6_IRQn, UART_DMA_TX_IRQ_PRIO);
HAL_NVIC_EnableIRQ(DMA1_Stream6_IRQn);
NVIC_SetPriority(DMA1_Stream5_IRQn, UART_DMA_RX_IRQ_PRIO);
HAL_NVIC_EnableIRQ(DMA1_Stream5_IRQn);
/* Use uart data register as peripheral destination for TX */
DMAhandle_TX.Instance->PAR = (uint32_t) &(UARThandle.Instance->DR);
/* Set source and destination address and buffer length */
DMAhandle_RX.Instance->NDTR = RX_BUF_LEN;
DMAhandle_RX.Instance->PAR = (uint32_t) &(UARThandle.Instance->DR);
DMAhandle_RX.Instance->M0AR = (uint32_t) dma_buffer_rx;
/* Enable UART as DMA enabled receiver */
UARThandle.Instance->CR3 |= USART_CR3_DMAR;
/* Enable transfer complete interrupt */
__HAL_DMA_ENABLE_IT(&DMAhandle_RX, DMA_IT_TC);
__HAL_DMA_ENABLE(&DMAhandle_RX);
return 0;
}
开发者ID:osannolik,项目名称:calmeas,代码行数:69,代码来源:uart.c
示例12: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
#ifndef BOARD_IN_STOP_MODE
GPIO_InitTypeDef GPIO_InitStruct;
#endif
/* STM32F0xx HAL library initialization:
- Configure the Flash prefetch
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Low Level Initialization
*/
HAL_Init();
/* Configure the system clock to 48 MHz */
SystemClock_Config();
/* Configure LED3 */
BSP_LED_Init(LED3);
#ifdef BOARD_IN_STOP_MODE
/* HSI must be UART clock source to be able to wake up the MCU */
__HAL_RCC_USART1_CONFIG(RCC_USART1CLKSOURCE_HSI);
#endif
/*##-1- Configure the UART peripheral ######################################*/
/* Put the USART peripheral in the Asynchronous mode (UART Mode) */
/* UART configured as follows:
- Word Length = 8 Bits
- Stop Bit = One Stop bit
- Parity = None
- BaudRate = 9600 baud
- Hardware flow control disabled (RTS and CTS signals) */
UartHandle.Instance = USARTx;
HAL_UART_DeInit(&UartHandle);
UartHandle.Init.BaudRate = 9600;
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;
UartHandle.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if(HAL_UART_Init(&UartHandle) != HAL_OK)
{
Error_Handler();
}
#ifdef BOARD_IN_STOP_MODE
BSP_LED_On(LED3);
/* wait for two seconds before test start */
HAL_Delay(2000);
/* make sure that no UART transfer is on-going */
while(__HAL_UART_GET_FLAG(&UartHandle, USART_ISR_BUSY) == SET);
/* make sure that UART is ready to receive
* (test carried out again later in HAL_UARTEx_StopModeWakeUpSourceConfig) */
while(__HAL_UART_GET_FLAG(&UartHandle, USART_ISR_REACK) == RESET);
/* set the wake-up event:
* specify wake-up on RXNE flag */
WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_READDATA_NONEMPTY;
if (HAL_UARTEx_StopModeWakeUpSourceConfig(&UartHandle, WakeUpSelection)!= HAL_OK)
{
Error_Handler();
}
/* Enable the UART Wake UP from stop mode Interrupt */
__HAL_UART_ENABLE_IT(&UartHandle, UART_IT_WUF);
/* about to enter stop mode: switch off LED */
BSP_LED_Off(LED3);
/* enable MCU wake-up by UART */
HAL_UARTEx_EnableStopMode(&UartHandle);
/* enter stop mode */
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
/* ... STOP mode ... */
SystemClock_Config_fromSTOP();
/* at that point, MCU has been awoken: the LED has been turned back on */
/* Wake Up based on RXNE flag successful */
HAL_UARTEx_DisableStopMode(&UartHandle);
/* wait for some delay */
HAL_Delay(100);
//.........这里部分代码省略.........
开发者ID:NjordCZ,项目名称:stm32cubef0,代码行数:101,代码来源:main.c
示例13: stm32_configure
static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
{
struct stm32_uart *uart;
RT_ASSERT(serial != RT_NULL);
RT_ASSERT(cfg != RT_NULL);
uart = (struct stm32_uart *)serial->parent.user_data;
uart->UartHandle.Init.BaudRate = cfg->baud_rate;
uart->UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
uart->UartHandle.Init.Mode = UART_MODE_TX_RX;
uart->UartHandle.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
switch (cfg->data_bits)
{
case DATA_BITS_7:
uart->UartHandle.Init.WordLength = UART_WORDLENGTH_7B;
break;
case DATA_BITS_8:
uart->UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
break;
case DATA_BITS_9:
uart->UartHandle.Init.WordLength = UART_WORDLENGTH_9B;
break;
default:
uart->UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
break;
}
switch (cfg->stop_bits)
{
case STOP_BITS_1:
uart->UartHandle.Init.StopBits = UART_STOPBITS_1;
break;
case STOP_BITS_2:
uart->UartHandle.Init.StopBits = UART_STOPBITS_2;
break;
default:
uart->UartHandle.Init.StopBits = UART_STOPBITS_1;
break;
}
switch (cfg->parity)
{
case PARITY_NONE:
uart->UartHandle.Init.Parity = UART_PARITY_NONE;
break;
case PARITY_ODD:
uart->UartHandle.Init.Parity = UART_PARITY_ODD;
break;
case PARITY_EVEN:
uart->UartHandle.Init.Parity = UART_PARITY_EVEN;
break;
default:
uart->UartHandle.Init.Parity = UART_PARITY_NONE;
break;
}
if (HAL_UART_DeInit(&uart->UartHandle) != HAL_OK)
{
return RT_ERROR;
}
if (HAL_UART_Init(&uart->UartHandle) != HAL_OK)
{
return RT_ERROR;
}
return RT_EOK;
}
开发者ID:heyuanjie87,项目名称:rt-thread,代码行数:67,代码来源:drv_usart.c
示例14: HELPER_UART_DeInit
/**
* @brief Uart De-Initialization Function.
* @param numUart: numero della periferica UART da de-inizializzare.
* numUart può assumere uno dei seguenti valori:
* @arg HELPER_UART1: periferica UART 1;
* @arg HELPER_UART2: periferica UART 2.
* @arg HELPER_UART3: periferica UART 3;
* @arg HELPER_UART4: periferica UART 4.
* @arg HELPER_UART5: periferica UART 5;
* @arg HELPER_UART6: periferica UART 6.
*
* @retval None
*/
HAL_StatusTypeDef HELPER_UART_DeInit(HELPER_UART_TypeDef numUart){
return HAL_UART_DeInit(HELPER_UART_GetHandle(numUart));
}
开发者ID:ntonjeta,项目名称:Nodo-Sensore,代码行数:16,代码来源:stm32f4xx_uart_helper.c
示例15: uartReconfigure
void uartReconfigure(uartPort_t *uartPort)
{
/*RCC_PeriphCLKInitTypeDef RCC_PeriphClkInit;
RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_USART2|RCC_PERIPHCLK_USART3|
RCC_PERIPHCLK_UART4|RCC_PERIPHCLK_UART5|RCC_PERIPHCLK_USART6|RCC_PERIPHCLK_UART7|RCC_PERIPHCLK_UART8;
RCC_PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_SYSCLK;
RCC_PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_SYSCLK;
RCC_PeriphClkInit.Usart3ClockSelection = RCC_USART3CLKSOURCE_SYSCLK;
RCC_PeriphClkInit.Uart4ClockSelection = RCC_UART4CLKSOURCE_SYSCLK;
RCC_PeriphClkInit.Uart5ClockSelection = RCC_UART5CLKSOURCE_SYSCLK;
RCC_PeriphClkInit.Usart6ClockSelection = RCC_USART6CLKSOURCE_SYSCLK;
RCC_PeriphClkInit.Uart7ClockSelection = RCC_UART7CLKSOURCE_SYSCLK;
RCC_PeriphClkInit.Uart8ClockSelection = RCC_UART8CLKSOURCE_SYSCLK;
HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit);*/
HAL_UART_DeInit(&uartPort->Handle);
uartPort->Handle.Init.BaudRate = uartPort->port.baudRate;
// according to the stm32 documentation wordlen has to be 9 for parity bits
// this does not seem to matter for rx but will give bad data on tx!
uartPort->Handle.Init.WordLength = (uartPort->port.options & SERIAL_PARITY_EVEN) ? UART_WORDLENGTH_9B : UART_WORDLENGTH_8B;
uartPort->Handle.Init.StopBits = (uartPort->port.options & SERIAL_STOPBITS_2) ? USART_STOPBITS_2 : USART_STOPBITS_1;
uartPort->Handle.Init.Parity = (uartPort->port.options & SERIAL_PARITY_EVEN) ? USART_PARITY_EVEN : USART_PARITY_NONE;
uartPort->Handle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
uartPort->Handle.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
uartPort->Handle.Init.Mode = 0;
if (uartPort->port.mode & MODE_RX)
uartPort->Handle.Init.Mode |= UART_MODE_RX;
if (uartPort->port.mode & MODE_TX)
uartPort->Handle.Init.Mode |= UART_MODE_TX;
usartConfigurePinInversion(uartPort);
#ifdef TARGET_USART_CONFIG
usartTargetConfigure(uartPort);
#endif
if (uartPort->port.options & SERIAL_BIDIR)
{
HAL_HalfDuplex_Init(&uartPort->Handle);
}
else
{
HAL_UART_Init(&uartPort->Handle);
}
// Receive DMA or IRQ
if (uartPort->port.mode & MODE_RX)
{
if (uartPort->rxDMAStream)
{
uartPort->rxDMAHandle.Instance = uartPort->rxDMAStream;
uartPort->rxDMAHandle.Init.Channel = uartPort->rxDMAChannel;
uartPort->rxDMAHandle.Init.Direction = DMA_PERIPH_TO_MEMORY;
uartPort->rxDMAHandle.Init.PeriphInc = DMA_PINC_DISABLE;
uartPort->rxDMAHandle.Init.MemInc = DMA_MINC_ENABLE;
uartPort->rxDMAHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
uartPort->rxDMAHandle.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
uartPort->rxDMAHandle.Init.Mode = DMA_CIRCULAR;
uartPort->rxDMAHandle.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
uartPort->rxDMAHandle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_1QUARTERFULL;
uartPort->rxDMAHandle.Init.PeriphBurst = DMA_PBURST_SINGLE;
uartPort->rxDMAHandle.Init.MemBurst = DMA_MBURST_SINGLE;
uartPort->rxDMAHandle.Init.Priority = DMA_PRIORITY_MEDIUM;
HAL_DMA_DeInit(&uartPort->rxDMAHandle);
HAL_DMA_Init(&uartPort->rxDMAHandle);
/* Associate the initialized DMA handle to the UART handle */
__HAL_LINKDMA(&uartPort->Handle, hdmarx, uartPort->rxDMAHandle);
HAL_UART_Receive_DMA(&uartPort->Handle, (uint8_t*)uartPort->port.rxBuffer, uartPort->port.rxBufferSize);
uartPort->rxDMAPos = __HAL_DMA_GET_COUNTER(&uartPort->rxDMAHandle);
}
else
{
/* Enable the UART Parity Error Interrupt */
SET_BIT(uartPort->USARTx->CR1, USART_CR1_PEIE);
/* Enable the UART Error Interrupt: (Frame error, noise error, overrun error) */
SET_BIT(uartPort->USARTx->CR3, USART_CR3_EIE);
/* Enable the UART Data Register not empty Interrupt */
SET_BIT(uartPort->USARTx->CR1, USART_CR1_RXNEIE);
}
}
// Transmit DMA or IRQ
if (uartPort->port.mode & MODE_TX) {
if (uartPort->txDMAStream) {
uartPort->txDMAHandle.Instance = uartPort->txDMAStream;
uartPort->txDMAHandle.Init.Channel = uartPort->txDMAChannel;
uartPort->txDMAHandle.Init.Direction = DMA_MEMORY_TO_PERIPH;
uartPort->txDMAHandle.Init.PeriphInc = DMA_PINC_DISABLE;
uartPort->txDMAHandle.Init.MemInc = DMA_MINC_ENABLE;
uartPort->txDMAHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
//.........这里部分代码省略.........
开发者ID:rotcehdnih,项目名称:betaflight,代码行数:101,代码来源:serial_uart_hal.c
示例16: armPortClose
int armPortClose(void* port)
{
UART_HandleTypeDef* huart = (UART_HandleTypeDef*)port;
HAL_UART_DeInit(&huart);
return 0;
}
开发者ID:RomualdoGobbo,项目名称:armapi,代码行数:6,代码来源:armport_stm32.c
示例17: source
/* STM32F3xx HAL library initialization:
- Configure the Flash prefetch
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Set NVIC Group Priority to 4
- Low Level Initialization
*/
void com_DMA()
{
HAL_Init();
/* Configure the system clock to 168 Mhz */
SystemClock_Config();
/*##-1- Configure the UART peripheral ######################################*/
/* Put the USART peripheral in the Asynchronous mode (UART Mode) */
/* UART configured as follows:
- Word Length = 8 Bits
- Stop Bit = One Stop bit
- Parity = None
- BaudRate = 9600 baud
- Hardware flow control disabled (RTS and CTS signals) */
UartHandle.USART_BaudRate = 38400;
UartHandle.USART_WordLength = USART_WordLength_8b;
UartHandle.USART_StopBits = USART_StopBits_1;
UartHandle.USART_Parity = USART_Parity_No;
UartHandle.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
UartHandle.USART_Mode = USART_Mode_Rx|USART_Mode_Tx;
if(HAL_UART_DeInit(&UartHandle) != HAL_OK)
{
Error_Handler();
}
if(HAL_UART_Init(&UartHandle) != HAL_OK)
{
Error_Handler();
}
#ifdef TRANSMITTER_BOARD
/* Configure User push-button */
BSP_PB_Init(BUTTON_USER, BUTTON_MODE_GPIO);
/* Wait for User push-button press before starting the Communication */
while (BSP_PB_GetState(BUTTON_USER) == RESET)
{
}
/* The board sends the message and expects to receive it back */
/*##-2- Start the transmission process #####################################*/
/* While the UART in reception process, user can transmit data through
"aTxBuffer" buffer */
if(HAL_UART_Transmit_DMA(&UartHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE)!= HAL_OK)
{
Error_Handler();
}
/*##-3- Wait for the end of the transfer ###################################*/
while (UartReady != SET)
{
}
/* Reset transmission flag */
UartReady = RESET;
/*##-4- Put UART peripheral in reception process ###########################*/
if(HAL_UART_DeInit(&UartHandle) != HAL_OK)
{
Error_Handler();
}
if(HAL_UART_Init(&UartHandle) != HAL_OK)
{
Error_Handler();
}
if(HAL_UART_Receive_DMA(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)
{
Error_Handler();
}
#else
/* The board receives the message and sends it back */
/*##-2- Put UART peripheral in reception process ###########################*/
if(HAL_UART_Receive_DMA(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)
{
Error_Handler();
}
/*##-3- Wait for the end of the transfer ###################################*/
while (UartReady != SET)
{
}
/* Reset transmission flag */
//.........这里部分代码省略.........
开发者ID:tsymiar,项目名称:4AxisFlying,代码行数:101,代码来源:signal_transmit.c
示例18: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/* STM32F0xx HAL library initialization:
- Configure the Flash prefetch
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Low Level Initialization
*/
HAL_Init();
/* Configure the system clock to 48 MHz */
SystemClock_Config();
/* Configure LED3 and LED4 */
BSP_LED_Init(LED3);
BSP_LED_Init(LED4);
/*##-1- Configure the UART peripheral ######################################*/
/* Put the USART peripheral in the Asynchronous mode (UART Mode) */
/* UART configured as follows:
- Word Length = 8 Bits
- Stop Bit = One Stop bit
- Parity = None
- BaudRate = 9600 baud
- Hardware flow control disabled (RTS and CTS signals) */
UartHandle.Instance = USARTx;
UartHandle.Init.BaudRate = 9600;
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;
UartHandle.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if(HAL_UART_DeInit(&UartHandle) != HAL_OK)
{
Error_Handler();
}
if(HAL_UART_Init(&UartHandle) != HAL_OK)
{
Error_Handler();
}
/*##-1- Configure the I2C peripheral ######################################*/
I2cHandle.Instance = I2Cx;
I2cHandle.Init.Timing = I2C_TIMING;
I2cHandle.Init.OwnAddress1 = I2C_ADDRESS;
I2cHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
I2cHandle.Init.OwnAddress2 = 0xFF;
I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
I2cHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if(HAL_I2C_Init(&I2cHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/* Enable the Analog I2C Filter */
HAL_I2CEx_ConfigAnalogFilter(&I2cHandle,I2C_ANALOGFILTER_ENABLE);
/* Configure User push-button Button*/
BSP_PB_Init(BUTTON_USER, BUTTON_MODE_GPIO);
do{
/* Wait for User push-button Button press before starting the Communication */
while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_RESET)
{
}
/* Wait for User push-button Button release before starting the Communication */
while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_SET)
{
}
void ndef_test(void);
float get_adc(void);
ndef_test();
//get_adc();
}while(1);
}
开发者ID:everrin,项目名称:stm32f0_M24LR04E,代码行数:93,代码来源:main.c
示例19: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/* STM32F4xx HAL library initialization:
- Configure the Flash prefetch, instruction and Data caches
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Set NVIC Group Priority to 4
- Low Level Initialization: global MSP (MCU Support Package) initialization
*/
HAL_Init();
/* Configure the system clock to 100 MHz */
SystemClock_Config();
/* Configure LED2 */
BSP_LED_Init(LED2);
/*##-1- Configure the UART peripheral ######################################*/
/* Put the USART peripheral in the Asynchronous mode (UART Mode) */
/* UART configured as follows:
- Word Length = 8 Bits
- Stop Bit = One Stop bit
- Parity = None
- BaudRate = 9600 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;
UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
if(HAL_UART_DeInit(&UartHandle) != HAL_OK)
{
Error_Handler();
}
if(HAL_UART_Init(&UartHandle) != HAL_OK)
{
Error_Handler();
}
#ifdef TRANSMITTER_BOARD
/* Configure User push-button in Interrupt mode */
BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);
/* Wait for User push-button press before starting the Communication.
In the meantime, LED2 is blinking */
while(UserButtonStatus == 0)
{
/* Toggle LED2*/
BSP_LED_Toggle(LED2);
HAL_Delay(100);
}
BSP_LED_Off(LED2);
/* The board sends the message and expects to receive it back */
/*##-2- Start the transmission process #####################################*/
/* While the UART in reception process, user can transmit data through
"aTxBuffer" buffer */
if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE, 5000)!= HAL_OK)
{
Error_Handler();
}
/* Turn LED2 on: Transfer in transmission process is correct */
BSP_LED_On(LED2);
/*##-3- Put UART peripheral in reception process ###########################*/
if(HAL_UART_Receive(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE, 5000) != HAL_OK)
{
Error_Handler();
}
/* Turn LED2 on: Transfer in reception process is correct */
BSP_LED_On(LED2);
#else
/* The board receives the message and sends it back */
/*##-2- Put UART peripheral in reception process ###########################*/
if(HAL_UART_Receive(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE, 0x1FFFFFF) != HAL_OK)
{
Error_Handler();
}
//.........这里部分代码省略.........
开发者ID:Joe-Merten,项目名称:Stm32-Tools-Evaluation,代码行数:101,代码来源:main.c
示例20: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/* STM32F3xx HAL library initialization:
- Configure the Flash prefetch
- Configure the Systick to generate an interrupt each 1 msec
- Set NVIC Group Priority to 4
- Low Level Initialization
*/
HAL_Init();
/* Configure the system clock to 64 MHz */
SystemClock_Config();
/* Configure LED1, LED2 and LED3 */
BSP_LED_Init(LED1);
BSP_LED_Init(LED2);
BSP_LED_Init(LED3);
/*##-1- Configure the UART peripheral ######################################*/
/* Put the USART peripheral in the Asynchronous mode (UART Mode) */
/* UART configured as follows:
- Word Length = 8 Bits
- Stop Bit = One Stop bit
- Parity = None
- BaudRate = 9600 baud
- Hardware flow control disabled (RTS and CTS signals) */
UartHandle.Instance = USARTx;
UartHandle.Init.BaudRate = 9600;
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;
UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
UartHandle.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if(HAL_UART_DeInit(&UartHandle) != HAL_OK)
{
Error_Handler();
}
if(HAL_UART_Init(&UartHandle) != HAL_OK)
{
Error_Handler();
}
#ifdef TRANSMITTER_BOARD
/* Configure User push-button in Interrupt mode */
BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);
/* Wait for User push-button press before starting the Communication.
In the meantime, LED3 is blinking */
while(UserButtonStatus == 0)
{
/* Toggle LED3*/
BSP_LED_Toggle(LED3);
HAL_Delay(100);
}
BSP_LED_Off(LED3);
/* The board sends the message and expects to receive it back */
/*##-2- Start the transmission process #####################################*/
/* While the UART in reception process, user can transmit data through
"aTxBuffer" buffer */
if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE, 5000)!= HAL_OK)
{
Error_Handler();
}
/* Turn LED1 on: Transfer in transmission process is correct */
BSP_LED_On(LED1);
/*##-3- Put UART peripheral in reception process ###########################*/
if(HAL_UART_Receive(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE, 5000) != HAL_OK)
{
Error_Handler();
}
#else
/* The board receives the message and sends it back */
/*##-2- Put UART peripheral in reception process ###########################*/
if(HAL_UART_Receive(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE, 0x1FFFFFF) != HAL_OK)
{
Error_Handler();
}
/* Turn LED1 on: Transfer in reception process is correct */
BSP_LED_On(LED1);
/*##-3- Start the transmission process #####################################*/
//.........这里部分代码省略.........
开发者ID:PaxInstruments,项目名称:STM32CubeF3,代码行数:101,代码来源:main.c
注:本文中的HAL_UART_DeInit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论