本文整理汇总了C++中HAL_UART_Transmit函数的典型用法代码示例。如果您正苦于以下问题:C++ HAL_UART_Transmit函数的具体用法?C++ HAL_UART_Transmit怎么用?C++ HAL_UART_Transmit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HAL_UART_Transmit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UART_Transmit
int UART_Transmit(uint8_t* data, uint16_t size){
HAL_StatusTypeDef status = HAL_UART_Transmit(&UartHandle, data, size, 0xffff);
if (status != HAL_OK) {
//while (1);
return 0;
}
return 1;
}
示例2: EXTI2_IRQHandler
/**
* @brief This function handles EXTI line2 interrupt.
*/
void EXTI2_IRQHandler(void)
{
/* USER CODE BEGIN EXTI2_IRQn 0 */
HAL_UART_Transmit(&huart2,"IRQexti2\n",9,100);
/* USER CODE END EXTI2_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2);
/* USER CODE BEGIN EXTI2_IRQn 1 */
/* USER CODE END EXTI2_IRQn 1 */
}
示例3: NMI_Handler
/**
* @brief This function handles Non maskable interrupt.
*/
void NMI_Handler(void)
{
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
HAL_UART_Transmit(&huart2,"IRQnmi\n",7,100);
/* USER CODE END NonMaskableInt_IRQn 0 */
HAL_RCC_NMI_IRQHandler();
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
/* USER CODE END NonMaskableInt_IRQn 1 */
}
示例4: Serial_PutByte
/**
* @brief Transmit a byte to the HyperTerminal
* @param param The byte to be sent
* @retval HAL_StatusTypeDef HAL_OK if OK
*/
HAL_StatusTypeDef Serial_PutByte( uint8_t param )
{
/* May be timeouted... */
if ( UartHandle.State == HAL_UART_STATE_TIMEOUT )
{
UartHandle.State = HAL_UART_STATE_READY;
}
return HAL_UART_Transmit(&UartHandle, ¶m, 1, TX_TIMEOUT);
}
示例5: hal_uart_send
int32_t hal_uart_send(uart_dev_t *uart, const void *data, uint32_t size, uint32_t timeout)
{
uint32_t i;
for(i = 0; i < size; i++)
{
HAL_UART_Transmit(&huart4, (uint8_t *)(&data[i]), 1, 0xFFFF);
}
return 0;
}
示例6: armPortWrite
int armPortWrite(void* port, const void* buf, size_t nbyte)
{
UART_HandleTypeDef* huart = (UART_HandleTypeDef*)port;
if(HAL_UART_Transmit(huart, (uint8_t*)buf, nbyte, 100) == HAL_OK)
return nbyte;
return -1;
}
示例7: HELPER_UART_Transmit
/**
* @brief Funzione di trasmissione BLOCCANTE per UART.
* @param numUart: numero della periferica UART da cui trasmettere.
* numUart deve essere precedentemente abilitata per la trasmissione previa inizializzazione
* e 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.
*
* @param pData: puntatore all'area di memoria da cui leggere il valore da trasferire.
*
* @param Size: dimensione del trasferimento.
* @retval Stato, che può assumere uno dei seguenti valori:
* @arg HELPER_UART_OK: trasmissione avvenuta con successo;
* @arg HELPER_UART_ERROR: Errore qualsiasi avvenuto durante la trasmissione.
*/
HELPER_UART_Status_TypeDef HELPER_UART_Transmit(HELPER_UART_TypeDef numUart,uint8_t *pData,uint16_t Size){
UART_HandleTypeDef *UartHandle_x=HELPER_UART_GetHandle(numUart);
while(HAL_UART_Transmit(UartHandle_x, pData, Size, 10000)!=HAL_OK){
if (HAL_UART_GetError(UartHandle_x) != HAL_UART_ERROR_NONE)
return HELPER_UART_ERROR;
}
return HELPER_UART_OK;
}
示例8: xHardwareUartTx
BaseType_t xHardwareUartTx(char* data, uint8_t data_length)
{
if(HAL_UART_Transmit(&UartHandle, (uint8_t*)data, data_length, USARTx_TIMEOUT) != HAL_OK)
{
vErrorWarning("UART: transmit failed");
return pdFAIL;
}
return pdPASS;
}
示例9: SendChar
/* SendChar */
void SendChar (char letter){
aTxBuffer[0]=letter;
if( HAL_UART_Transmit(&huart2,(uint8_t*)aTxBuffer, 1, 500)!= HAL_OK){
while(1){
}
}
}
示例10: MainTask
void MainTask()
{
for(;;)
{
// Wait for adc result and write it to the UART connected to the PC.
osEvent result = osMessageGet(mainTaskMessageQId, osWaitForever);
HAL_UART_Transmit(&huart2, (uint8_t*)&result.value.v, 4, 100);
}
}
示例11: Serial_PutString
/**
* @brief Print a string on the HyperTerminal
* @param p_string: The string to be printed
* @retval None
*/
void Serial_PutString(uint8_t *p_string)
{
uint16_t length = 0;
while (p_string[length] != '\0')
{
length++;
}
HAL_UART_Transmit(&UartHandle, p_string, length, TX_TIMEOUT);
}
示例12: Uart_Tx_String
int Uart_Tx_String(char *string, uint16_t len)
{
HAL_StatusTypeDef status = HAL_UART_Transmit(&UartHandle, (uint8_t *)string, len, 0xFFFF);
if (status != HAL_OK) {
//while (1);
return HAL_MSP_FAIL;
}
return HAL_MSP_SUCCESS;
}
示例13: SendInt
void SendInt(int num)
{
uint8_t array[5];
array[0]=num>>24;
array[1]=num>>16;
array[2]=num>>8;
array[3]=num;
array[4]='\n';
HAL_UART_Transmit(&UartResultHandle,array,5,5);
}
示例14: main
int main(void) {
char msg[20];
HAL_Init();
Nucleo_BSP_Init();
/* Before we can access to every register of the PWR peripheral we must enable it */
__HAL_RCC_PWR_CLK_ENABLE();
while (1) {
if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB)) {
/* If standby flag set in PWR->CSR, then the reset is generated from
* the exit of the standby mode */
sprintf(msg, "RESET after STANDBY mode\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
/* We have to explicitly clear the flag */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU|PWR_FLAG_SB);
}
sprintf(msg, "MCU in run mode\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
while(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) == GPIO_PIN_SET) {
HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
HAL_Delay(100);
}
HAL_Delay(200);
sprintf(msg, "Entering in SLEEP mode\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
SleepMode();
sprintf(msg, "Exiting from SLEEP mode\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
while(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) == GPIO_PIN_SET);
HAL_Delay(200);
sprintf(msg, "Entering in STOP mode\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
StopMode();
sprintf(msg, "Exiting from STOP mode\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
while(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) == GPIO_PIN_SET);
HAL_Delay(200);
sprintf(msg, "Entering in STANDBY mode\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
StandbyMode();
while(1); //Never arrives here, since MCU is reset when exiting from STANDBY
}
}
示例15: UART_SendMsg
/**
* @brief Send a message via UART
* @param Msg the pointer to the message to be sent
* @retval None
*/
void UART_SendMsg(TMsg *Msg)
{
uint16_t CountOut;
CHK_ComputeAndAdd(Msg);
CountOut = ByteStuffCopy((uint8_t*) UART_TxBuffer, Msg);
HAL_UART_Transmit(&UartHandle, (uint8_t*)UART_TxBuffer, CountOut, 5000);
}