int main(void) { cpu_init(); uart_init(); systick_init(); AdsPinConfig(); spi_init(); init_ethernet(); httpd_init(); last_arp_time = last_tcp_time = 0; while(1) { //MAP_SysCtlSleep(); task_lwip(); task_enc(); task_ads(); } return 0; }
/** * Hardware setup * Initializes pins, clocks, etc */ void HAL_setup(void){/*{{{*/ //Configure clock to run at 120MHz //configCPU_CLOCK_HZ = 120MHz //Needs to be set for FreeRTOS g_syshz = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000L); MAP_SysCtlMOSCConfigSet(SYSCTL_MOSC_HIGHFREQ); //Enable all GPIOs MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ); init_ethernet(); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); //Configure reset pin for XBD MAP_GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, RESET_PIN); //Reset XBD xbd_reset(true); //Configure UART MAP_GPIOPinConfigure(GPIO_PA0_U0RX); MAP_GPIOPinConfigure(GPIO_PA1_U0TX); MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); MAP_UARTConfigSetExpClk(UART0_BASE, g_syshz, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // //Configure measurement stuff measure_setup(); //Configure xbd i2c comm i2c_comm_setup(); //Setup watchdog watchdog_setup(); //Unreset XBD xbd_reset(false); }/*}}}*/
void Network::Init() { CleanRing(); Reset(); // if(LinkIsUp()) // reprap.GetPlatform()->SetHeater(0,1.0); // else // reprap.GetPlatform()->SetHeater(0,0.0); if(!NETWORK) // NETWORK needs to be true to turn on the ethernet. It is defined in Configuration.h return; init_ethernet(reprap.GetPlatform()->IPAddress(), reprap.GetPlatform()->NetMask(), reprap.GetPlatform()->GateWay()); active = true; }
void Network::Init() { if (!isEnabled) { platform->Message(HOST_MESSAGE, "Attempting to start the network when it is disabled.\n"); return; } init_ethernet(platform->MACAddress(), hostname); longWait = platform->Time(); state = NetworkInitializing; }
/** * \brief Main program function. Configure the hardware, initialize lwIP * TCP/IP stack, and start HTTP service. */ int main(void) { /* Initialize the SAM system. */ system_init(); delay_init(); /* Setup USART module to output results */ setup_usart_channel(); /* Print example information. */ puts(STRING_HEADER); /* Bring up the ethernet interface & initialize timer0, channel0. */ init_ethernet(); /* Bring up the web server. */ httpd_init(); /* Program main loop. */ while (1) { /* Check for input packet and process it. */ ethernet_task(); } }
/** * \brief Main program function. Configure the hardware, initialize lwIP * TCP/IP stack, and start HTTP service. */ int main(void) { /* Initialize the SAM system. */ sysclk_init(); board_init(); /* Configure debug UART */ configure_console(); /* Print example information. */ puts(STRING_HEADER); /* Bring up the ethernet interface & initialize timer0, channel0. */ init_ethernet(); /* Bring up the web server. */ httpd_init(); /* Program main loop. */ while (1) { /* Check for input packet and process it. */ ethernet_task(); } }
/** * \brief GFX task core function. * * \param pvParameters Junk parameter. */ static void gfx_task(void *pvParameters) { uint32_t blink = 0; /* Get rid of this compiler warning. */ pvParameters = pvParameters; /* Enable display, backlight and print ATMEL logo. */ ili93xx_set_cursor_position(0,0); ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(0, 0, ILI93XX_LCD_WIDTH, ILI93XX_LCD_HEIGHT); gfx_draw_bmpfile(logo_atmel_bmp); ili93xx_display_on(); for (uint32_t i = AAT31XX_MIN_BACKLIGHT_LEVEL; i <= AAT31XX_MAX_BACKLIGHT_LEVEL; ++i) { aat31xx_set_backlight(i); vTaskDelay(40); } vTaskDelay(presentation_delay); /* Draw IP config menu. */ ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(0, 0, ILI93XX_LCD_WIDTH, ILI93XX_LCD_HEIGHT); #if (IP_SELECTION == IP_FIXED) /* Static IP button selected. */ /* Button 1. */ ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_rectangle(20,70,220,130); ili93xx_set_foreground_color(0xE4E4E4u); ili93xx_draw_rectangle(22,72,222,132); ili93xx_set_foreground_color(COLOR_LIGHTGREY); ili93xx_draw_filled_rectangle(21,71,221,131); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(92, 91, (uint8_t *)"Static"); /* Button 2. */ ili93xx_set_foreground_color(0xE4E4E4u); ili93xx_draw_rectangle(20,170,220,230); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_rectangle(22,172,222,232); ili93xx_set_foreground_color(COLOR_LIGHTGREY); ili93xx_draw_filled_rectangle(21,171,221,231); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(102, 191, (uint8_t *)"DHCP"); #else /* DHCP IP button selected. */ /* Button 1. */ ili93xx_set_foreground_color(0xE4E4E4u); ili93xx_draw_rectangle(20,70,220,130); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_rectangle(22,72,222,132); ili93xx_set_foreground_color(COLOR_LIGHTGREY); ili93xx_draw_filled_rectangle(21,71,221,131); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(92, 91, (uint8_t *)"Static"); /* Button 2. */ ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_rectangle(20,170,220,230); ili93xx_set_foreground_color(0xE4E4E4u); ili93xx_draw_rectangle(22,172,222,232); ili93xx_set_foreground_color(COLOR_LIGHTGREY); ili93xx_draw_filled_rectangle(21,171,221,231); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_string(102, 191, (uint8_t *)"DHCP"); #endif ili93xx_draw_string(22, 30, (uint8_t *)"IP Configuration"); ili93xx_draw_string(20, 260, (uint8_t *)"Assigned IP:"); ili93xx_draw_rectangle(20,280,220,310); /* Bring up the ethernet interface & initializes timer0, channel0 */ ili93xx_draw_string(30, 290, (uint8_t *)"Please wait..."); init_ethernet(); app_hold = 0; /* Show configured IP and unlock all other waiting tasks. */ ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(20,280,220,310); ili93xx_draw_filled_rectangle(0,0,240,60); ili93xx_set_foreground_color(COLOR_BLACK); ili93xx_draw_rectangle(20,280,220,310); ili93xx_draw_string(30, 290, (uint8_t const*)g_c_ipconfig); /* GFX task Loop. */ while (1) { /* Make HTTP text to blink to show GFX task activity. */ if (blink == 0) { ili93xx_draw_string(5, 30, (uint8_t *)"HTTP server running!"); blink = 1; } else { ili93xx_set_foreground_color(COLOR_WHITE); ili93xx_draw_filled_rectangle(0,0,240,60); ili93xx_set_foreground_color(COLOR_BLACK); blink = 0; } /* Sleep to reach the expected blink rate. */ /* Leave some CPU time for other tasks. */ vTaskDelay(gfx_refresh_rate); } }
void Network::Init() { RepRapNetworkSetMACAddress(reprap.GetPlatform()->MACAddress()); init_ethernet(); }
int main ( void ) { int_init(); // This is specific for OpenRISC, you may need to call some other routine here // in order to initialise interrupt support and so on. // We use a serial port console to display informational messages. init_uart( UART1_BASE_ADDR ); uart_print( UART1_BASE_ADDR, "This is the Ethernet example program." EOL ); init_ethernet(); int_add( ETH_IRQ, ð_interrupt, NULL ); // Use an Ethernet sniffer like Wireshark in order to see the test frame sent. uart_print( UART1_BASE_ADDR, "Sending the first test frame (which has invalid protocol contents)..." EOL ); int pos = 0; write_broadcast_mac_addr( ð_tx_packet[ pos ] ); pos += MAC_ADDR_LEN; write_own_mac_addr( ð_tx_packet[ pos ] ); pos += MAC_ADDR_LEN; eth_tx_packet[ pos + 0 ] = 0x10; eth_tx_packet[ pos + 1 ] = 0x20; eth_tx_packet[ pos + 2 ] = 0x30; eth_tx_packet[ pos + 3 ] = 0x40; eth_tx_packet[ pos + 4 ] = 0x50; eth_tx_packet[ pos + 5 ] = 0x60; pos += 6; int fill_to_end = 0; if ( fill_to_end ) { while ( pos < MAX_FRAME_LEN ) { eth_tx_packet[ pos ] = (unsigned char) pos; ++pos; } } start_ethernet_send( pos ); wait_until_frame_was_sent(); uart_print( UART1_BASE_ADDR, "Sending the second test frame (which has invalid protocol contents)..." EOL ); pos = 0; write_broadcast_mac_addr( ð_tx_packet[ pos ] ); pos += MAC_ADDR_LEN; write_own_mac_addr( ð_tx_packet[ pos ] ); pos += MAC_ADDR_LEN; eth_tx_packet[ pos + 0 ] = 0x11; eth_tx_packet[ pos + 1 ] = 0x22; eth_tx_packet[ pos + 2 ] = 0x33; eth_tx_packet[ pos + 3 ] = 0x44; eth_tx_packet[ pos + 4 ] = 0x55; eth_tx_packet[ pos + 5 ] = 0x66; pos += 6; start_ethernet_send( pos ); wait_until_frame_was_sent(); const int dump_all_register_values = 0; if ( dump_all_register_values ) { register_read_test(); } // Main infinite loop. // // Wait for incoming frames, dump their contents and reply to a single type of ARP request. // See the README file for an example on how to generate the right type of APR request with arping. for ( ; ; ) { uart_print( UART1_BASE_ADDR, "Waiting for a frame to be received..." EOL ); REG32( get_bd_ptr_addr( s_current_rx_bd_index ) ) = (unsigned long) eth_rx_packet; uint32_t receive_flags = ETH_RXBD_EMPTY | ETH_RXBD_IRQ; if ( s_current_rx_bd_index == BUFFER_DESCRIPTOR_COUNT - 1 ) receive_flags += ETH_RXBD_WRAP; REG32( get_bd_status_addr( s_current_rx_bd_index ) ) = receive_flags; uint32_t status; for ( ; ; ) { status = REG32( get_bd_status_addr( s_current_rx_bd_index ) ); if ( 0 == ( status & ETH_RXBD_EMPTY ) ) { uart_print( UART1_BASE_ADDR, "Frame received." EOL ); break; } } if ( status & ( ETH_RXBD_OR | ETH_RXBD_IS | ETH_RXBD_DN | ETH_RXBD_TL | ETH_RXBD_SF | ETH_RXBD_CRC | ETH_RXBD_LC ) ) { uart_print( UART1_BASE_ADDR, "Error receiving frame, rx status is: " ); uart_print_hex( UART1_BASE_ADDR, status, 8 ); uart_print( UART1_BASE_ADDR, EOL ); } else { const int eth_rx_len = ( status >> 16 ); const int should_dump_frame_contents = 0; if ( should_dump_frame_contents ) { uart_print( UART1_BASE_ADDR, "Received length: " ); uart_print_int( UART1_BASE_ADDR, eth_rx_len ); uart_print( UART1_BASE_ADDR, EOL ); uart_print( UART1_BASE_ADDR, "Frame data: " ); int i; for ( i = 0; i < eth_rx_len; i++ ) { uart_print_hex( UART1_BASE_ADDR, eth_rx_packet[i], 2 ); uart_print( UART1_BASE_ADDR," " ); } uart_print( UART1_BASE_ADDR, EOL "End of received data." EOL ); } if ( ! process_received_frame( eth_rx_len ) ) { uart_print( UART1_BASE_ADDR, "The received frame has been ignored." EOL ); } } ++s_current_rx_bd_index; if ( s_current_rx_bd_index == BUFFER_DESCRIPTOR_COUNT ) s_current_rx_bd_index = TX_BD_COUNT; } }