OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [lib/] [source/] [neorv32_uart.c] - Diff between revs 55 and 61

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 55 Rev 61
Line 44... Line 44...
 **************************************************************************/
 **************************************************************************/
 
 
#include "neorv32.h"
#include "neorv32.h"
#include "neorv32_uart.h"
#include "neorv32_uart.h"
#include <string.h>
#include <string.h>
 
#include <stdarg.h>
 
 
/// \cond
/// \cond
// Private functions
// Private functions
static void __neorv32_uart_itoa(uint32_t x, char *res) __attribute__((unused)); // GCC: do not ouput a warning when this variable is unused
static void __neorv32_uart_itoa(uint32_t x, char *res) __attribute__((unused)); // GCC: do not ouput a warning when this variable is unused
static void __neorv32_uart_tohex(uint32_t x, char *res) __attribute__((unused)); // GCC: do not ouput a warning when this variable is unused
static void __neorv32_uart_tohex(uint32_t x, char *res) __attribute__((unused)); // GCC: do not ouput a warning when this variable is unused
Line 92... Line 93...
 **************************************************************************/
 **************************************************************************/
void neorv32_uart_disable(void) { neorv32_uart0_disable(); }
void neorv32_uart_disable(void) { neorv32_uart0_disable(); }
 
 
 
 
/**********************************************************************//**
/**********************************************************************//**
 
 * Enable UART0.
 
 * @warning This functions maps to UART0 (primary UART).
 
 **************************************************************************/
 
void neorv32_uart_enable(void) { neorv32_uart0_enable(); }
 
 
 
 
 
/**********************************************************************//**
 * Send single char via UART0.
 * Send single char via UART0.
 *
 *
 * @warning This functions maps to UART0 (primary UART).
 * @warning This functions maps to UART0 (primary UART).
 * @note This function is blocking.
 * @note This function is blocking.
 *
 *
Line 308... Line 316...
  UART0_CT &= ~((uint32_t)(1 << UART_CT_EN));
  UART0_CT &= ~((uint32_t)(1 << UART_CT_EN));
}
}
 
 
 
 
/**********************************************************************//**
/**********************************************************************//**
 
 * Enable UART0.
 
 **************************************************************************/
 
void neorv32_uart0_enable(void) {
 
 
 
  UART0_CT = ((uint32_t)(1 << UART_CT_EN));
 
}
 
 
 
 
 
/**********************************************************************//**
 * Send single char via UART0.
 * Send single char via UART0.
 *
 *
 * @note This function is blocking.
 * @note This function is blocking.
 *
 *
 * @param[in] c Char to be send.
 * @param[in] c Char to be send.
 **************************************************************************/
 **************************************************************************/
void neorv32_uart0_putc(char c) {
void neorv32_uart0_putc(char c) {
 
 
#if defined UART0_SIM_MODE || defined UART_SIM_MODE
 
  UART0_DATA = ((uint32_t)c) << UART_DATA_LSB;
 
#else
 
  // wait for previous transfer to finish
  // wait for previous transfer to finish
  while ((UART0_CT & (1<<UART_CT_TX_BUSY)) != 0);
  while ((UART0_CT & (1<<UART_CT_TX_BUSY)) != 0);
  UART0_DATA = ((uint32_t)c) << UART_DATA_LSB;
  UART0_DATA = ((uint32_t)c) << UART_DATA_LSB;
#endif
 
}
}
 
 
 
 
/**********************************************************************//**
/**********************************************************************//**
 * Check if UART0 TX is busy.
 * Check if UART0 TX is busy.
Line 663... Line 676...
  UART1_CT &= ~((uint32_t)(1 << UART_CT_EN));
  UART1_CT &= ~((uint32_t)(1 << UART_CT_EN));
}
}
 
 
 
 
/**********************************************************************//**
/**********************************************************************//**
 
 * Enable UART1.
 
 **************************************************************************/
 
void neorv32_uart1_enable(void) {
 
 
 
  UART1_CT |= ((uint32_t)(1 << UART_CT_EN));
 
}
 
 
 
 
 
/**********************************************************************//**
 * Send single char via UART1.
 * Send single char via UART1.
 *
 *
 * @note This function is blocking.
 * @note This function is blocking.
 *
 *
 * @param[in] c Char to be send.
 * @param[in] c Char to be send.
 **************************************************************************/
 **************************************************************************/
void neorv32_uart1_putc(char c) {
void neorv32_uart1_putc(char c) {
 
 
#ifdef UART1_SIM_MODE
 
  UART1_DATA = ((uint32_t)c) << UART_DATA_LSB;
 
#else
 
  // wait for previous transfer to finish
  // wait for previous transfer to finish
  while ((UART1_CT & (1<<UART_CT_TX_BUSY)) != 0);
  while ((UART1_CT & (1<<UART_CT_TX_BUSY)) != 0);
  UART1_DATA = ((uint32_t)c) << UART_DATA_LSB;
  UART1_DATA = ((uint32_t)c) << UART_DATA_LSB;
#endif
 
}
}
 
 
 
 
/**********************************************************************//**
/**********************************************************************//**
 * Check if UART1 TX is busy.
 * Check if UART1 TX is busy.

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.