Exemplo n.º 1
0
int
main(int argc, char* argv[])
{
  // Send a greeting to the trace device (skipped on Release).
  trace_puts("Hello ARM World!");

  // At this stage the system clock should have already been configured
  // at high speed.
  trace_printf("System clock: %u Hz\n", SystemCoreClock);

  timer_start();

  blink_led_init();
  
  uint32_t seconds = 0;

  // Infinite loop
  while (1)
    {
      blink_led_on();
      timer_sleep(seconds == 0 ? TIMER_FREQUENCY_HZ : BLINK_ON_TICKS);

      blink_led_off();
      timer_sleep(BLINK_OFF_TICKS);

      ++seconds;

      // Count seconds on the trace device.
      trace_printf("Second %u\n", seconds);
    }
  // Infinite loop, never return.
}
Exemplo n.º 2
0
int main(void)
{
  // By customising __initialize_args() it is possible to pass arguments,
  // for example when running tests with semihosting you can pass various
  // options to the test.
  // trace_dump_args(argc, argv);

  // Send a greeting to the trace device (skipped on Release).
  trace_puts("Hello ARM World!");

  // The standard output and the standard error should be forwarded to
  // the trace device. For this to work, a redirection in _write.c is
  // required.
  puts("Standard output message.");
  fprintf(stderr, "Standard error message.\n");

  // At this stage the system clock should have already been configured
  // at high speed.
  //trace_printf("System clock: %uHz\n", SystemCoreClock);

  //timer_start();
  HAL_Init();
  blink_led_init();
  
  HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0);
  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
  blink_led_off();
  // Infinite loop
  while (1)
    {
      blink_led_on();
      HAL_Delay(1000);
      //timer_sleep(BLINK_ON_TICKS);
      //delay(1000U);
      blink_led_off();
      //timer_sleep(BLINK_OFF_TICKS);
      HAL_Delay(1000);
      // Count seconds on the trace device.
      trace_printf("Second\n");
    }
  // Infinite loop, never return.
}
Exemplo n.º 3
0
int
main(int argc, char* argv[])
{

  int x;
	// Show the program parameters (passed via semihosting).
  // Output is via the semihosting output channel.
  trace_dump_args(argc, argv);

  // Send a greeting to the trace device (skipped on Release).
  trace_puts("Hello ARM World!");

  // Send a message to the standard output.
  puts("Standard output message.");

  // Send a message to the standard error.
  fprintf(stderr, "Standard error message.\n");

  // At this stage the system clock should have already been configured
  // at high speed.
  trace_printf("System clock: %uHz\n", SystemCoreClock);

  timer_start();

  blink_led_init();
  
  uint32_t seconds = 0;

  printf("input x\r\n");
  scanf("%d",&x);
  printf("%d",x);

  test_read_file_from_host("d:/test.txt");
  // Infinite loop
  while (1)
    {
      blink_led_on();
      timer_sleep(BLINK_ON_TICKS);

      blink_led_off();
      timer_sleep(BLINK_OFF_TICKS);

      ++seconds;

      // Count seconds on the trace device.
      trace_printf("Second %u\n", seconds);
    }
  // Infinite loop, never return.
}
Exemplo n.º 4
0
void
blink_led_init()
{
  // Turn on clock for port module
  SIM->SCGC5 |= BLINK_SCGC5_MASKx(BLINK_PORT_NUMBER);

  // Set the pin multiplexer to GPIO mode
  BLINK_PORTx(BLINK_PORT_NUMBER)->PCR[BLINK_PIN_NUMBER] = PORT_PCR_MUX(1);

  // Set the pin as output
  BLINK_GPIOx(BLINK_PORT_NUMBER)->PDDR |= BLINK_PIN_MASK(BLINK_PIN_NUMBER);

  // Start with led turned off
  blink_led_off();
}