Exemple #1
0
ELK_PRECONSTRUCTOR()
{
  static int setup;
  if (setup) {
    return;
  }

  // Set up the console for interrupt serial I/O.
  sem_init(&sem_output, 0, 1);
  sem_init(&sem_input, 0, 1);
  ibuffer_in = ibuffer_out = ibuffer;
  sem_init(&sem_obuffer, 0, 0);
  obuffer_in = obuffer_out = obuffer;

  // Set up the system calls.
  SYSCALL(ioctl);
  SYSCALL(write);
  SYSCALL(writev);
  SYSCALL(read);
  SYSCALL(readv);

  // Register the interrupt handler.
  console_interrupt_register(rx_interrupt, tx_interrupt);

  // Enable the receive interrupt.
  console_enable_rx_interrupt();
  setup = 1;
}
Exemple #2
0
/**
 *  \brief LIN Application entry point.
 *
 *  \return Unused (ANSI-C compatibility).
 */
int main(void)
{
	/* Output example information */
	console_example_info("LIN Example");

	/* Configure Console interrupts */
	printf("Initializing console interrupts\r\n");
	console_set_rx_handler(_console_handler);
	console_enable_rx_interrupt();

	/* Configure Timer/Counter */
	_configure_tc();

	/* Configure com port */
	_init_com_master();
	_init_com_slave();

	/* main LIN program */
	_display_menu();
	do {
		switch (key) {
		case 'P':
		case 'p':
		case 'S':
		case 's':
		case 'I':
		case 'i':
			tc_stop(TC0, TC_CHANNEL);
			_process_button_evt();
			_display_menu();
			if (key == 'I' || key == 'i')
				tc_stop(TC0, 0);
			else
				tc_start(TC0, TC_CHANNEL);
			key = 0;
			break;
		default:
			break;
		}
	} while (key != 'q' && key != 'Q');

	tc_stop(TC0, TC_CHANNEL);
	timer_wait(500);
	printf("\n\rEnd of demo\n\r");
	while (1);
}