Exemplo n.º 1
0
/*How SPI slave should work:
   When the CS line goes low... interrupt  to enable SPI_slave
   
   when overflow happens, an overflow interrupt shall go off and send the data it recieved via uart
   
   When the CS line goes high... interrupt to disable the SPI_slave
*/
void SPI_initializeSlave(void) {
   DDRB  |=  (1 << DO);
   DDRB  &= ~((1 << SCK) | (1 << DI) );
   USICR = (1 << USIWM0) | (1 << USICS1); //spi mode | clock source is positive edge using USCK pin
   //configure the pin change interrupt on INT0 -> PD2
   MCUCR &= ~(1 << ISC01);
   MCUCR |= (1 << ISC00);
   GIMSK |= (1 << INT0);
   UART_initialize();
}
Exemplo n.º 2
0
//--------------------------------------------------------------------------//
// Function:	main														//
//--------------------------------------------------------------------------//
void main(void)
{
	int c;
	
  //inicjalizacje
	Init_Interrupts();
	LED_Init();
  UART_initialize(115200);
	
  //jakiœ tam komunikat powitalny
	UART_putc('H');
	UART_putc('e');
	UART_putc('l');
	UART_putc('l');
	UART_putc('o');
	
	for (;;)
	{
    //odbieramy znak i odbijamy go na terminal
		c = UART_getc();
		UART_putc(c);
		
    //w zale¿noœci od tego co przysz³o, prze³¹czamy stan jednej z diod
    switch (c)
		{
			case '1':
				*pPORTFIO_TOGGLE = 0x0040;
				break;
			case '2':
				*pPORTFIO_TOGGLE = 0x0080;
				break;
			case '3':
				*pPORTFIO_TOGGLE = 0x0100;
				break;
			case '4':
				*pPORTFIO_TOGGLE = 0x0200;
				break;
			case '5':
				*pPORTFIO_TOGGLE = 0x0400;
				break;
			case '6':
				*pPORTFIO_TOGGLE = 0x0800;
				break;
		}
	}
}
Exemplo n.º 3
0
/*! \fn int main(void)
    \brief Start of main program
		\details Initializes the peripherals and starts the OS
*/
int main(void)
{
	osKernelInitialize ();                    // initialize CMSIS-RTOS
	
	// initialize peripherals
	UART_initialize();
  printf("\n\rRavenOS demo\n\r");
  LED_initialize(); 
	
	printf("Initializing threads\n\r");
  if (Init_thread0() != 0)
	{
		stop_cpu;
	}
  if (Init_thread1() != 0)
	{
		stop_cpu;
	}
  if (Init_thread2() != 0)
	{
		stop_cpu;
	}	
//  // thread3 is a low priority thread can be used as a more user obvious alternative to print tracing from UART, 
//  // which currently resides in the Idle thread (operated by the RTOS)
//  if (Init_thread3() != 0)
//	{
//		stop_cpu;
//	}
	
	printf("Initializing semaphores\n\r");
  if (Init_Semaphore0() != 0)
	{
		stop_cpu;
	}	
  if (Init_Semaphore1() != 0)
	{
		stop_cpu;
	}		
	printf("Start kernel\n\r");
	osKernelStart ();                         // start thread execution 
	
  // Should not be here
  stop_cpu;
}