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

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [example/] [demo_twi/] [main.c] - Diff between revs 60 and 64

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

Rev 60 Rev 64
Line 178... Line 178...
  neorv32_uart_printf("Select new clock prescaler (0..7): ");
  neorv32_uart_printf("Select new clock prescaler (0..7): ");
  neorv32_uart_scan(terminal_buffer, 2, 1); // 1 hex char plus '\0'
  neorv32_uart_scan(terminal_buffer, 2, 1); // 1 hex char plus '\0'
  uint8_t prsc = (uint8_t)hexstr_to_uint(terminal_buffer, strlen(terminal_buffer));
  uint8_t prsc = (uint8_t)hexstr_to_uint(terminal_buffer, strlen(terminal_buffer));
 
 
  if ((prsc >= 0) && (prsc < 8)) { // valid?
  if ((prsc >= 0) && (prsc < 8)) { // valid?
    TWI_CT = 0; // reset
    NEORV32_TWI.CTRL = 0; // reset
    TWI_CT = (1 << TWI_CT_EN) | (prsc << TWI_CT_PRSC0);
    NEORV32_TWI.CTRL = (1 << TWI_CTRL_EN) | (prsc << TWI_CTRL_PRSC0);
    neorv32_uart_printf("\nDone.\n");
    neorv32_uart_printf("\nDone.\n");
  }
  }
  else {
  else {
    neorv32_uart_printf("\nInvalid selection!\n");
    neorv32_uart_printf("\nInvalid selection!\n");
    return;
    return;
Line 200... Line 200...
    case 5: div = 4 * 1024; break;
    case 5: div = 4 * 1024; break;
    case 6: div = 4 * 2048; break;
    case 6: div = 4 * 2048; break;
    case 7: div = 4 * 4096; break;
    case 7: div = 4 * 4096; break;
    default: div = 0; break;
    default: div = 0; break;
  }
  }
  uint32_t clock = SYSINFO_CLK / div;
  uint32_t clock = NEORV32_SYSINFO.CLK / div;
  neorv32_uart_printf("New I2C clock: %u Hz\n", clock);
  neorv32_uart_printf("New I2C clock: %u Hz\n", clock);
}
}
 
 
 
 
/**********************************************************************//**
/**********************************************************************//**

powered by: WebSVN 2.1.0

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