Exemple #1
0
static int uart_stm32_fifo_fill(struct device *dev, const uint8_t *tx_data,
				  int size)
{
	struct uart_stm32_data *data = DEV_DATA(dev);
	UART_HandleTypeDef *UartHandle = &data->huart;
	uint8_t num_tx = 0;

	while ((size - num_tx > 0) && __HAL_UART_GET_FLAG(UartHandle,
		UART_FLAG_TXE)) {
		/* TXE flag will be cleared with byte write to DR register */

		/* Send a character (8bit , parity none) */
#if defined(CONFIG_SOC_SERIES_STM32F1X) || defined(CONFIG_SOC_SERIES_STM32F4X)
		/* Use direct access for F1, F4 until Low Level API is available
		 * Once it is we can remove the if/else
		 */
		UartHandle->Instance->DR = (tx_data[num_tx++] &
					(uint8_t)0x00FF);
#else
		LL_USART_TransmitData8(UartHandle->Instance, tx_data[num_tx++]);
#endif
	}

	return num_tx;
}
Exemple #2
0
static void uart_stm32_poll_out(struct device *dev,
					unsigned char c)
{
	USART_TypeDef *UartInstance = UART_STRUCT(dev);

	/* Wait for TXE flag to be raised */
	while (!LL_USART_IsActiveFlag_TXE(UartInstance))
		;

	LL_USART_ClearFlag_TC(UartInstance);

	LL_USART_TransmitData8(UartInstance, (u8_t)c);
}
Exemple #3
0
int _write (int fd, const void *buf, size_t count) {
   if ((fd != STDOUT_FILENO) && (fd != STDERR_FILENO)) {
      errno = EBADF;
      return -1;
   }
   // size_t i;
   uint8_t* ch = ((uint8_t*)buf);
   for(size_t i = 0; i < count; i++){
      // while(!LL_USART_IsActiveFlag_TXE(USART6));   
      LL_USART_TransmitData8(USART6, *ch++);
      while(!LL_USART_IsActiveFlag_TXE(USART6));
   }
   return count;
}
Exemple #4
0
static int uart_stm32_fifo_fill(struct device *dev, const u8_t *tx_data,
				  int size)
{
	USART_TypeDef *UartInstance = UART_STRUCT(dev);
	u8_t num_tx = 0U;

	while ((size - num_tx > 0) &&
	       LL_USART_IsActiveFlag_TXE(UartInstance)) {
		/* TXE flag will be cleared with byte write to DR|RDR register */

		/* Send a character (8bit , parity none) */
		LL_USART_TransmitData8(UartInstance, tx_data[num_tx++]);
	}

	return num_tx;
}