void downlink_init(void) { downlink.nb_ovrn = 0; downlink.nb_bytes = 0; downlink.nb_msgs = 0; #if defined DATALINK #if DATALINK == PPRZ || DATALINK == SUPERBITRF || DATALINK == W5100 pprz_transport_init(&pprz_tp); #endif #if DATALINK == XBEE xbee_init(); #endif #if DATALINK == W5100 w5100_init(); #endif #endif #if USE_PPRZLOG pprzlog_transport_init(); #endif #if SITL ivy_transport_init(); #endif #if PERIODIC_TELEMETRY register_periodic_telemetry(DefaultPeriodic, "DATALINK_REPORT", send_downlink); #endif }
void init_ap( void ) { #ifndef SINGLE_MCU /** init done in main_fbw in single MCU */ mcu_init(); #endif /* SINGLE_MCU */ /************* Sensors initialization ***************/ #if USE_GPS gps_init(); #endif #ifdef USE_GPIO GpioInit(); #endif #if USE_IMU imu_init(); #endif #if USE_AHRS_ALIGNER ahrs_aligner_init(); #endif #if USE_AHRS ahrs_init(); #endif #if USE_BAROMETER baro_init(); #endif ins_init(); stateInit(); /************* Links initialization ***************/ #if defined MCU_SPI_LINK || defined MCU_UART_LINK link_mcu_init(); #endif #if USE_AUDIO_TELEMETRY audio_telemetry_init(); #endif /************ Internal status ***************/ autopilot_init(); h_ctl_init(); v_ctl_init(); nav_init(); modules_init(); settings_init(); /**** start timers for periodic functions *****/ sensors_tid = sys_time_register_timer(1./PERIODIC_FREQUENCY, NULL); navigation_tid = sys_time_register_timer(1./NAVIGATION_FREQUENCY, NULL); attitude_tid = sys_time_register_timer(1./CONTROL_FREQUENCY, NULL); modules_tid = sys_time_register_timer(1./MODULES_FREQUENCY, NULL); telemetry_tid = sys_time_register_timer(1./60, NULL); monitor_tid = sys_time_register_timer(1.0, NULL); /** - start interrupt task */ mcu_int_enable(); #if defined DATALINK #if DATALINK == XBEE xbee_init(); #endif #if DATALINK == W5100 w5100_init(); #endif #endif /* DATALINK */ #if defined AEROCOMM_DATA_PIN IO0DIR |= _BV(AEROCOMM_DATA_PIN); IO0SET = _BV(AEROCOMM_DATA_PIN); #endif /************ Multi-uavs status ***************/ #ifdef TRAFFIC_INFO traffic_info_init(); #endif }
void init_ap( void ) { #ifndef SINGLE_MCU /** init done in main_fbw in single MCU */ mcu_init(); #endif /* SINGLE_MCU */ /****** initialize and reset state interface ********/ stateInit(); /************* Sensors initialization ***************/ #if USE_GPS gps_init(); #endif #if USE_IMU imu_init(); #if USE_IMU_FLOAT imu_float_init(); #endif #endif #if USE_AHRS_ALIGNER ahrs_aligner_init(); #endif #if USE_AHRS ahrs_init(); #endif #if USE_AHRS && USE_IMU register_periodic_telemetry(DefaultPeriodic, "STATE_FILTER_STATUS", send_fliter_status); #endif air_data_init(); #if USE_BARO_BOARD baro_init(); #endif ins_init(); /************* Links initialization ***************/ #if defined MCU_SPI_LINK || defined MCU_UART_LINK link_mcu_init(); #endif #if USE_AUDIO_TELEMETRY audio_telemetry_init(); #endif /************ Internal status ***************/ autopilot_init(); h_ctl_init(); v_ctl_init(); nav_init(); modules_init(); settings_init(); /**** start timers for periodic functions *****/ sensors_tid = sys_time_register_timer(1./PERIODIC_FREQUENCY, NULL); navigation_tid = sys_time_register_timer(1./NAVIGATION_FREQUENCY, NULL); attitude_tid = sys_time_register_timer(1./CONTROL_FREQUENCY, NULL); modules_tid = sys_time_register_timer(1./MODULES_FREQUENCY, NULL); telemetry_tid = sys_time_register_timer(1./TELEMETRY_FREQUENCY, NULL); monitor_tid = sys_time_register_timer(1.0, NULL); /** - start interrupt task */ mcu_int_enable(); #if defined DATALINK #if DATALINK == XBEE xbee_init(); #endif #if DATALINK == W5100 w5100_init(); #endif #endif /* DATALINK */ #if defined AEROCOMM_DATA_PIN IO0DIR |= _BV(AEROCOMM_DATA_PIN); IO0SET = _BV(AEROCOMM_DATA_PIN); #endif /************ Multi-uavs status ***************/ #ifdef TRAFFIC_INFO traffic_info_init(); #endif /* set initial trim values. * these are passed to fbw via inter_mcu. */ ap_state->command_roll_trim = COMMAND_ROLL_TRIM; ap_state->command_pitch_trim = COMMAND_PITCH_TRIM; ap_state->command_yaw_trim = COMMAND_YAW_TRIM; }
int main(void) { ansi_init(); uart_init();// Initialize UART Peripheral IntializeTimer(); // Clear the Screen of the hyper terminal <send clear code> spi_init();// Initialize SPI w5100_init();// Initial the W5100 Ethernet if(S0_initialize_socket(MR_TCP,30000)) { printf("INIT DONE 2\n"); //S0_connect(dest_ip,dest_port); } printf("%x\n",get_socket0_status()); uart_putch('\0',&uart_str); uart_flush(); host= http_extract_host(url); relativeAddress = http_extract_relativeAddress(url,strlen(host)); request= http_create_request(method,relativeAddress,httpV,host); ;//="GET / HTTP/1.1\r\nHost: www.google.com\r\nConnection: keep-alive\r\nUser-Agent: Mozilla/5.0 (windows NT 6.1; wow64) Applewebkit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 safari/537.11\r\nAccept: text/html\r\nAccept-Encoding: gzip, deflate\r\n"; //printf("%s",request); S0_connect(dest_ip,dest_port); if(get_socket0_status() == SOCK_ESTABLISHED) { printf("Connected\n"); uart_putch('\0',&uart_str); } // Loop forever int loop = 1, counter = 0; //sei(); while(loop) { // keep reading the socket zero status // and handle at least socket closed and socket established uint8_t sockstat=get_socket0_status(); switch(sockstat/*Handle all possible socket status here*/) { case SOCK_CLOSED: //printf("ERROR1\n"); //uart_putch('\0',&uart_str); //S0_connect(dest_ip,dest_port); printf("%x\n",get_socket0_status()); uart_putch('\0',&uart_str); loop = 0; break; case SOCK_ESTABLISHED: printf("SOCK_ESTABLISHED\n"); uart_putch('\0',&uart_str); // Get the client request size // And read the client Request in temp buffer // make sure the temp buffer is sending GET request S0_send((uint8_t*)request,strlen(request)); printf("Request Sent\n"); uart_putch('\0',&uart_str); uart_flush(); _delay_ms(2000); if(S0_RX_getReceivedSize() != 0) { counter++; S0_recv(buf,S0_RX_getReceivedSize()); printf("RECV Response\n"); uart_putch('\0',&uart_str); printf("%s",(char*)buf); uart_putch('\0',&uart_str); //loop =0; } // create a buffer that will hold the response and send it // if the GET request has an option to turn on/off a LED Carry that now. // finally disconnect the socket with the client. break; case SOCK_FIN_WAIT: case SOCK_CLOSING: case SOCK_TIME_WAIT: case SOCK_CLOSE_WAIT: case SOCK_LAST_ACK: loop = 0; printf("Recevied %d\n",counter); uart_putch('\0',&uart_str); close(0); // force the socket to be closed break; //default: //printf("nothing\n"); } } return 0; }
void main(void) { char key; videomode(VIDEOMODE_80COL); printf("Init\n"); w5100_init(&parms); printf("(S)end or e(X)it\n"); do { unsigned len; if (kbhit()) { key = cgetc(); } else { key = '\0'; } if (key == 's') { unsigned i; len = 500; printf("Send Len %d To %d.%d.%d.%d", len, parms.serverip[0], parms.serverip[1], parms.serverip[2], parms.serverip[3]); while (!w5100_send_init(len)) { printf("!"); } for (i = 0; i < len; ++i) { w5100_send_byte(i); } w5100_send_done(); printf(".\n"); } len = w5100_recv_init(); if (len) { unsigned i; printf("Recv Len %d From %d.%d.%d.%d", len, parms.serverip[0], parms.serverip[1], parms.serverip[2], parms.serverip[3]); for (i = 0; i < len; ++i) { if ((i % 24) == 0) { printf("\n$%04X:", i); } printf(" %02X", w5100_recv_byte()); } w5100_recv_done(); printf(".\n"); } } while (key != 'x'); printf("Done\n"); }