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

Subversion Repositories neorv32

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

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

Rev 12 Rev 22
Line 205... Line 205...
 *
 *
 * @note This function is blocking.
 * @note This function is blocking.
 *
 *
 * @param[in] s Pointer to string.
 * @param[in] s Pointer to string.
 **************************************************************************/
 **************************************************************************/
void neorv32_uart_print(char *s) {
void neorv32_uart_print(const char *s) {
 
 
  char c = 0;
  char c = 0;
  while ((c = *s++)) {
  while ((c = *s++)) {
    if (c == '\n') {
    if (c == '\n') {
      neorv32_uart_putc('\r');
      neorv32_uart_putc('\r');
Line 225... Line 225...
 * @param[in] x Unsigned input number.
 * @param[in] x Unsigned input number.
 * @param[in,out] res Pointer for storing the reuslting number string (11 chars).
 * @param[in,out] res Pointer for storing the reuslting number string (11 chars).
 **************************************************************************/
 **************************************************************************/
static void __neorv32_uart_itoa(uint32_t x, char *res) {
static void __neorv32_uart_itoa(uint32_t x, char *res) {
 
 
  static const char numbers[10] = "0123456789";
  static const char numbers[] = "0123456789";
  char buffer1[11];
  char buffer1[11];
  uint16_t i, j;
  uint16_t i, j;
 
 
  buffer1[10] = '\0';
  buffer1[10] = '\0';
  res[10] = '\0';
  res[10] = '\0';
Line 265... Line 265...
 * @param[in] x Unsigned input number.
 * @param[in] x Unsigned input number.
 * @param[in,out] res Pointer for storing the reuslting number string (9 chars).
 * @param[in,out] res Pointer for storing the reuslting number string (9 chars).
 **************************************************************************/
 **************************************************************************/
static void __neorv32_uart_tohex(uint32_t x, char *res) {
static void __neorv32_uart_tohex(uint32_t x, char *res) {
 
 
  static const char symbols[16] = "0123456789abcdef";
  static const char symbols[] = "0123456789abcdef";
 
 
  int i;
  int i;
  for (i=0; i<8; i++) { // nibble by bibble
  for (i=0; i<8; i++) { // nibble by bibble
    uint32_t num_tmp = x >> (4*i);
    uint32_t num_tmp = x >> (4*i);
    res[7-i] = (char)symbols[num_tmp & 0x0f];
    res[7-i] = (char)symbols[num_tmp & 0x0f];
Line 292... Line 292...
 * <TR><TD>%i</TD><TD>32-bit signed number, printed as decimal</TD></TR>
 * <TR><TD>%i</TD><TD>32-bit signed number, printed as decimal</TD></TR>
 * <TR><TD>%u</TD><TD>32-bit unsigned number, printed as decimal</TD></TR>
 * <TR><TD>%u</TD><TD>32-bit unsigned number, printed as decimal</TD></TR>
 * <TR><TD>%x</TD><TD>32-bit number, printed as 8-char hexadecimal</TD></TR>
 * <TR><TD>%x</TD><TD>32-bit number, printed as 8-char hexadecimal</TD></TR>
 * </TABLE>
 * </TABLE>
 **************************************************************************/
 **************************************************************************/
void neorv32_uart_printf(char *format, ...) {
void neorv32_uart_printf(const char *format, ...) {
 
 
  char c, string_buf[11];
  char c, string_buf[11];
  int32_t n;
  int32_t n;
 
 
  va_list a;
  va_list a;

powered by: WebSVN 2.1.0

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