Пример #1
0
/** Main program entry point. This routine configures the hardware required by the application, then
 *  starts the scheduler to run the application tasks.
 */
int main(void)
{
	/* Disable watchdog if enabled by bootloader/fuses */
	MCUSR &= ~(1 << WDRF);
	wdt_disable();

	/* Disable Clock Division */
	SetSystemClockPrescaler(0);

	/* Hardware Initialization */
	LEDs_Init();
	Dataflash_Init(SPI_SPEED_FCPU_DIV_2);

	/* Clear Dataflash sector protections, if enabled */
	DataflashManager_ResetDataflashProtections();
	
	/* Indicate USB not ready */
	UpdateStatus(Status_USBNotReady);
	
	/* Initialize Scheduler so that it can be used */
	Scheduler_Init();

	/* Initialize USB Subsystem */
	USB_Init();

	/* Scheduling - routine never returns, so put this last in the main function */
	Scheduler_Start();
}
Пример #2
0
/** Main program entry point. This routine configures the hardware required by the application, then
 *  starts the scheduler to run the application tasks.
 */
int main(void)
{
	/* Disable watchdog if enabled by bootloader/fuses */
	MCUSR &= ~(1 << WDRF);
	wdt_disable();

	/* Disable clock division */
	clock_prescale_set(clock_div_1);
	
	/* Hardware Initialization */
	SerialStream_Init(9600, false);
	LEDs_Init();
	
	/* Indicate USB not ready */
	UpdateStatus(Status_USBNotReady);
	
	/* Initialize Scheduler so that it can be used */
	Scheduler_Init();

	/* Initialize USB Subsystem */
	USB_Init();

	/* Start-up message */
	puts_P(PSTR(ESC_RESET ESC_BG_WHITE ESC_INVERSE_ON ESC_ERASE_DISPLAY
	       "Mouse Host Demo running.\r\n" ESC_INVERSE_OFF));
		   
	/* Scheduling - routine never returns, so put this last in the main function */
	Scheduler_Start();
}
Пример #3
0
/** Main program entry point. This routine configures the hardware required by the application, then
 *  starts the scheduler to run the application tasks.
 */
int main(void)
{
	/* Disable watchdog if enabled by bootloader/fuses */
	MCUSR &= ~(1 << WDRF);
	wdt_disable();

	/* Disable clock division */
	clock_prescale_set(clock_div_1);

	/* Hardware Initialization */
	Joystick_Init();
	LEDs_Init();
	Buttons_Init();
	
	/* Millisecond timer initialization, with output compare interrupt enabled for the idle timing */
	OCR0A  = 0x7D;
	TCCR0A = (1 << WGM01);
	TCCR0B = ((1 << CS01) | (1 << CS00));
	TIMSK0 = (1 << OCIE0A);

	/* Indicate USB not ready */
	UpdateStatus(Status_USBNotReady);
	
	/* Initialize Scheduler so that it can be used */
	Scheduler_Init();

	/* Initialize USB Subsystem */
	USB_Init();

	/* Scheduling - routine never returns, so put this last in the main function */
	Scheduler_Start();
}
Пример #4
0
/** Main program entry point. This routine configures the hardware required by the application, then
 *  starts the scheduler to run the application tasks.
 */
int main(void)
{
	/* Disable watchdog if enabled by bootloader/fuses */
	MCUSR &= ~(1 << WDRF);
	wdt_disable();

	/* Disable clock division */
	clock_prescale_set(clock_div_1);

	/* Hardware Initialization */
	Joystick_Init();
	LEDs_Init();
	Buttons_Init();
	
	/* Indicate USB not ready */
	UpdateStatus(Status_USBNotReady);
	
	/* Initialize Scheduler so that it can be used */
	Scheduler_Init();

	/* Initialize USB Subsystem */
	USB_Init();

	/* Scheduling - routine never returns, so put this last in the main function */
	Scheduler_Start();
}
Пример #5
0
int main(void)
{
	uint8_t IOReg = 0;

	/* initialize the board for general non-usb development */
	init_gmd();


	// SPI Mode0 slave with CKDIV = /4 and enable SPI transfer complete interrupt
	// set PB3(MISO) as output, PB0(^SS), PB1(SCK), PB2(MOSI)  as input, and rest as input
	DDRB = (0 << PB0) | (0 << PB1) | (0 << PB2) | (1 << PB3) | (1 << PB4) | (1 << PB5) | (1 << PB6) | (1 << PB7);
	SPCR = ((1 << SPE) | (1 << SPIE) | (0 << MSTR) | (0 << CPOL) | (0 << CPHA));
	SPSR = 0;
	IOReg = SPSR; //need to read to initiliaze
	IOReg = SPDR; //need to read to initiliaze
	SPDR = 0x00; // send 0 over SPI so that the SPI interrupt starts being used
	sei(); // enable interrupts


	/* set PortD as output and start Timer1 */
	DDRD = 0xFF;
	PORTD = 0x00;
	TCCR1A = 0; //start the timer
	//TCCR1B = (1 << CS10); // no Timer1 prescaling, use CLK
	TCCR1B = (1 << CS12); // prescale Timer1 by CLK/256


	/* initialize the scheduler */
	Scheduler_Init();
	Scheduler_Start(); // MCU runs indefinitely, work is done in TASK(MainTask) and interrupts
}
Пример #6
0
/**
 * The main function.
 *
 * \return This function does never return.
 *****************************************************************************/
int main(void)
{
    hw_init();
    i2c_init();
    spi_init();
    cbf_init(&rx_buf);
    cbf_init(&tx_buf);

    // Indicate USB not ready
    UpdateStatus(Status_USBNotReady);

    // Initialize Scheduler so that it can be used
    Scheduler_Init();

    // Initialize USB Subsystem
    USB_Init();

    // Scheduling - routine never returns, so put this last in the main function
    Scheduler_Start();
}
Пример #7
0
/** Main program entry point. This routine configures the hardware required by the application, then
 *  starts the scheduler to run the USB management task.
 */
int main(void)
{
  /* After reset start bootloader? */
  if ((AVR_IS_WDT_RESET()) && (boot_key == DFU_BOOT_KEY_VAL))
    {
      boot_key = 0;
      Bootloader();
    }

  /* Disable watchdog if enabled by bootloader/fuses */
  MCUSR &= ~(1 << WDRF);
  wdt_disable();

  /* Disable clock division */
  clock_prescale_set(clock_div_1);

  /* Hardware Initialization */
  LEDs_Init();

  /* Indicate USB not ready */
  UpdateStatus(Status_USBNotReady);

  /* Initialize Scheduler so that it can be used */
  Scheduler_Init();

  /* Initialize USB Subsystem */
  USB_Init();

  /* Initialize I/O lines */
  //IO_Init();

  /* Initialize Timers */
  Timer_Init();

  /* Initialize Motors */
  Motor_Init();

  /* Scheduling - routine never returns, so put this last in the main function */
  Scheduler_Start();
}
Пример #8
0
int main(void)
{
    /* Disable watchdog if enabled by bootloader/fuses */
    MCUSR &= ~(1 << WDRF);
    wdt_disable();

    /* Disable clock division */
    clock_prescale_set(clock_div_1);

    /* Hardware Initialization */

    DDRB = 0xFF;
    DDRD = 0xFF;
    DDRC = 0xF0;

    /* Initialize Scheduler so that it can be used */
    Scheduler_Init();

    /* Initialize USB Subsystem */
    USB_Init();

    /* Scheduling - routine never returns, so put this last in the main function */
    Scheduler_Start();
}
Пример #9
0
int32_t main(void)
{
	uint32_t u32Index;
	uint8_t mac_def[6];
	uip_ipaddr_t ipaddr;
	struct timer periodic_timer, arp_timer;
	volatile int32_t ax88796c_isr;
	
	Board_Init();
	Uart4_Init();
	_delay_init();
	// Setup scheduler and tasks
	Scheduler_Init();
	Scheduler_AddTask(Task_SetLEDs, 0, 100);
	Scheduler_AddTask(Task_ProcessSwitches, 0, 50);
	Scheduler_AddTask(Task_Adconverter, 500, 100);
	Scheduler_AddTask(Task_SerialTerminalOutput, 0, 1000);

	Scheduler_Start();

	// Configure uIP
	timer_set(&periodic_timer, CLOCK_SECOND / 2);
	timer_set(&arp_timer, CLOCK_SECOND * 10);
	
	mac_def[0] = UIP_ETHADDR0;
	mac_def[1] = UIP_ETHADDR1;
	mac_def[2] = UIP_ETHADDR2;
	mac_def[3] = UIP_ETHADDR3;
	mac_def[4] = UIP_ETHADDR4;
	mac_def[5] = UIP_ETHADDR5;
	
	ax88796c_init(mac_def);
	uip_init();

	init_uip_clock_time();
	
	uip_ipaddr(ipaddr, UIP_IPADDR0,UIP_IPADDR1,UIP_IPADDR2,UIP_IPADDR3);
	uip_sethostaddr(ipaddr);
	
	uip_ipaddr(ipaddr, UIP_DRIPADDR0,UIP_DRIPADDR1,UIP_DRIPADDR2,UIP_DRIPADDR3);
	uip_setdraddr(ipaddr);
	
	uip_ipaddr(ipaddr, UIP_NETMASK0,UIP_NETMASK1,UIP_NETMASK2,UIP_NETMASK3);
	uip_setnetmask(ipaddr);
	
	httpd_init();
	
	/* hello_world_init(); */
    /* telnetd_init(); */
	
	/*{
		dhcpc_init(&mac_def, 6);
	}*/
  
	/*
	uip_ipaddr(ipaddr, 127,0,0,1);
	smtp_configure("localhost", ipaddr);
	SMTP_SEND("*****@*****.**", "", "*****@*****.**", 
		"Testing SMTP from uIP", 
		"Test message sent by uIP\r\n");
	*/

	/*
    webclient_init();
    resolv_init();
    uip_ipaddr(ipaddr, 168,95,1,1);
    resolv_conf(ipaddr);
    resolv_query("www.sics.se");
	*/
	
	while(1){
		Scheduler_DispatchTasks();
		
		ax88796c_isr = ax88796c_check_int();
		if(ax88796c_isr & ISR_LINK){
			if(!ax88796c_check_media()){
				printf ("Link down.\n");
			}else{
				uint16_t bmcr;
				bmcr = ax88796c_mdio_read(PHY_ID, MII_BMCR);
				printf("Link up, %sMbps, %s-duplex\n",(bmcr & BMCR_SPEED100) ? "100" : "10", \
				(bmcr & BMCR_FULLDPLX) ? "full" : "half");
				
			}
		}
		if(ax88796c_isr & ISR_RXPCT){
			uip_len = ax88796c_packet_receive(uip_buf);
		}else{
			uip_len = 0;
		}
		ax88796c_clear_int(ax88796c_isr);
		
		if(uip_len > 0) {
			if(UipBuf->type == htons(UIP_ETHTYPE_IP)) {
				uip_arp_ipin();
				uip_input();
				/* If the above function invocation resulted in data that
				should be sent out on the network, the global variable
				uip_len is set to a value > 0. */
				if(uip_len > 0) {
					uip_arp_out();
					ax88796c_packet_send(uip_buf,uip_len);
				}
			} else if(UipBuf->type == htons(UIP_ETHTYPE_ARP)) {
				uip_arp_arpin();
				/* If the above function invocation resulted in data that
				should be sent out on the network, the global variable
				uip_len is set to a value > 0. */
				if(uip_len > 0) {
					ax88796c_packet_send(uip_buf,uip_len);
				}
			}

		} else if(timer_expired(&periodic_timer)) {
			timer_reset(&periodic_timer);
			for(u32Index = 0; u32Index < UIP_CONNS; u32Index++) {
				uip_periodic(u32Index);
				/* If the above function invocation resulted in data that
				should be sent out on the network, the global variable
				uip_len is set to a value > 0. */
				if(uip_len > 0) {
					uip_arp_out();
					ax88796c_packet_send(uip_buf,uip_len);
				}
			}

#if UIP_UDP
			for(u32Index = 0; u32Index < UIP_UDP_CONNS; u32Index++) {
				uip_udp_periodic(u32Index);
				/* If the above function invocation resulted in data that
				should be sent out on the network, the global variable
				uip_len is set to a value > 0. */
				if(uip_len > 0) {
					uip_arp_out();
					ax88796c_packet_send(uip_buf,uip_len);
				}
			}
#endif /* UIP_UDP */

			/* Call the ARP timer function every 10 seconds. */
			if(timer_expired(&arp_timer)) {
				timer_reset(&arp_timer);
				uip_arp_timer();
			}
		}
	}
}