/************************************************************************************//** ** \brief This is the entry point for the bootloader application and is called ** by the reset interrupt vector after the C-startup routines executed. ** \return none. ** ****************************************************************************************/ void main(void) { /* initialize the microcontroller */ Init(); /* initialize the network application */ NetInit(); /* initialize the bootloader interface */ BootComInit(); /* start the infinite program loop */ while (1) { /* toggle LED with a fixed frequency */ LedToggle(); /* run the network task */ NetTask(); /* check for bootloader activation request */ BootComCheckActivationRequest(); } } /*** end of main ***/
int main(void) { uint8_t i; P5DIR|=BIT1; //P5OUT&=~BIT1; P5OUT|=BIT1; _DINT(); //Disable Interrupts -- For initlization purposes WDTCTL = WDTPW + WDTHOLD; //Stop WDT /* Set System Clock Frequency to (121+1) * 32786 * 2 = 7.995392Mhz This freq. allows for 2400 - 230400 bit rate UART operation with less than 0.86% error */ FLL_CTL0 = (DCOPLUS | XCAP18PF); //Enable Frequency Multiplier (DCO+) and XIN/XOUT caps to 18pF SCFI0 = (FLLD_2 | FN_8); //Set Multiplier to 2, and DCO range to 8MHz nominal SCFQCTL = 121; //7.995392Mhz Operation with No Modulation //setup serial port #if DEBUG_SERIAL debug_serial_init(); printf("asd %i",23244); #endif for(i=0;i<6;i++) uNet_eth_address.addr[i]=_eth_addr[i]; // init NIC device driver #if DEBUG_SERIAL printf("MAC address:%x:%x:%x:%x:%x:%x\r\n",\ (int)_eth_addr[0],(int)_eth_addr[1],(int)_eth_addr[2],\ (int)_eth_addr[3],(int)_eth_addr[4],(int)_eth_addr[5]); printf("Initializing NIC...\r\n"); #endif nic_init(_eth_addr); uip_ipaddr_t ipaddr; uip_setethaddr(uNet_eth_address); #if DEBUG_SERIAL printf("Initializing uIP...\r\n"); #endif //init uIP uip_init(); #if DEBUG_SERIAL printf("Initializing ARP...\r\n"); #endif //init ARP cache uip_arp_init(); #if DEBUG_SERIAL printf("Initializing timer...\r\n"); #endif // init periodic timer clock_init(); //#if DEBUG_SERIAL printf("Initializing webclient...\r\n"); //#endif webclient_init(); _EINT(); // reenable interrupts if(!_enable_dhcp) { #if DEBUG_SERIAL printf("Initializing tcp/ip settings\r\n"); #endif //#if DEBUG_SERIAL printf("IP %i.%i.%i.%i\r\n", (int)_ip_addr[0],(int)_ip_addr[1],(int)_ip_addr[2],(int)_ip_addr[3]); printf("NetMask %i.%i.%i.%i\r\n", (int)_net_mask[0],(int)_net_mask[1],(int)_net_mask[2],(int)_net_mask[3]); printf("Gateway %i.%i.%i.%i\r\n", (int)_gateway[0],(int)_gateway[1],(int)_gateway[2],(int)_gateway[3]); //#endif uip_ipaddr(ipaddr, _ip_addr[0], _ip_addr[1], _ip_addr[2], _ip_addr[3]); uip_sethostaddr(ipaddr); uip_ipaddr(ipaddr, _net_mask[0], _net_mask[1], _net_mask[2], _net_mask[3]); uip_setnetmask(ipaddr); uip_ipaddr(ipaddr, _gateway[0], _gateway[1], _gateway[2], _gateway[3]); uip_setdraddr(ipaddr); } else { #if DEBUG_SERIAL printf("Going to query DHCP server...\r\n"); #endif uip_ipaddr(ipaddr, 0, 0, 0, 0); uip_sethostaddr(ipaddr); uip_setnetmask(ipaddr); uip_setdraddr(ipaddr); } timer_set(&periodic_timer, CLOCK_SECOND * 2 ); timer_set(&arp_timer, CLOCK_SECOND * 10); /* if(_enable_dhcp) { dhcpc_init(&uNet_eth_address.addr[0], 6); dhcpc_request(); } */ /* Initialize Scheduler so that it can be used */ //Scheduler_Init(); /* Initialize USB Subsystem */ //USB_Init(); //Scheduler_SetTaskMode(NetTask, TASK_RUN); /* Scheduling - routine never returns, so put this last in the main function */ //Scheduler_Start(); //#if DEBUG_SERIAL printf("Starting main loop...\r\n"); //#endif while(1) { NetTask(); webclient_get("www", SERVER_PORT,"/"); } }