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

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [example/] [blink_led/] [main.c] - Diff between revs 22 and 23

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

Rev 22 Rev 23
Line 46... Line 46...
 * @name User configuration
 * @name User configuration
 **************************************************************************/
 **************************************************************************/
/**@{*/
/**@{*/
/** UART BAUD rate */
/** UART BAUD rate */
#define BAUD_RATE 19200
#define BAUD_RATE 19200
 
/** Use the custom ASM version for blinking the LEDs if != 0 */
 
#define USE_ASM_VERSION 0
/**@}*/
/**@}*/
 
 
 
 
/**********************************************************************//**
/**********************************************************************//**
 
 * ASM function to blink LEDs (if enabled)
 
 **************************************************************************/
 
extern void blink_led_asm(uint32_t gpio_out_addr);
 
 
 
 
 
/**********************************************************************//**
 * Main function; shows an incrementing 8-bit counter on GPIO.output(7:0).
 * Main function; shows an incrementing 8-bit counter on GPIO.output(7:0).
 *
 *
 * @note This program requires the GPIO controller to be synthesized (the UART is optional).
 * @note This program requires the GPIO controller to be synthesized (the UART is optional).
 *
 *
 * @return Irrelevant.
 * @return Irrelevant.
Line 74... Line 82...
  neorv32_rte_setup();
  neorv32_rte_setup();
 
 
  // say hello
  // say hello
  neorv32_uart_print("Blinking LED demo program\n");
  neorv32_uart_print("Blinking LED demo program\n");
 
 
 
 
 
// use C version of LED blinking
 
#if (USE_ASM_VERSION == 0)
 
 
  neorv32_gpio_port_set(0); // clear gpio output put
  neorv32_gpio_port_set(0); // clear gpio output put
 
 
  int cnt = 0;
  int cnt = 0;
 
 
  while (1) {
  while (1) {
    neorv32_gpio_port_set(cnt++ & 0xFF); // increment counter and mask for lowest 8 bit
    neorv32_gpio_port_set(cnt++ & 0xFF); // increment counter and mask for lowest 8 bit
    neorv32_cpu_delay_ms(200); // wait 200ms using busy wait
    neorv32_cpu_delay_ms(200); // wait 200ms using busy wait
  }
  }
 
 
 
// use ASM version of LED blinking (file: blink_led_in_asm.S)
 
#else
 
 
 
  blink_led_asm((uint32_t)(&GPIO_OUTPUT));
 
 
 
#endif
  return 0;
  return 0;
}
}
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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