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 }
/** * @brief sdlogger_spi_direct_init * Initialize the logger and SD Card. */ void sdlogger_spi_direct_init(void) { /* Initialize the SD Card */ sdcard_spi_init(&sdcard1, &(SDLOGGER_SPI_LINK_DEVICE), SDLOGGER_SPI_LINK_SLAVE_NUMBER); /* Set values in the struct to their defaults */ sdlogger_spi.status = SDLogger_Initializing; sdlogger_spi.next_available_address = 0; sdlogger_spi.last_completed = 0; sdlogger_spi.sdcard_buf_idx = 1; /* Fill internal buffer with zeros */ for (uint8_t i = 0; i < sizeof(sdlogger_spi.buffer); i++) { sdlogger_spi.buffer[i] = 0; } sdlogger_spi.idx = 0; sdlogger_spi.log_len = 0; sdlogger_spi.command = 0; sdlogger_spi.download_id = 0; sdlogger_spi.download_address = 0; sdlogger_spi.download_length = 0; /* Set function pointers in link_device to the logger functions */ sdlogger_spi.device.check_free_space = (check_free_space_t)sdlogger_spi_direct_check_free_space; sdlogger_spi.device.put_byte = (put_byte_t)sdlogger_spi_direct_put_byte; sdlogger_spi.device.send_message = (send_message_t)sdlogger_spi_direct_send_message; sdlogger_spi.device.char_available = (char_available_t)sdlogger_spi_direct_char_available; sdlogger_spi.device.get_byte = (get_byte_t)sdlogger_spi_direct_get_byte; sdlogger_spi.device.periph = &sdlogger_spi; /* Init pprzlog_tp */ pprzlog_transport_init(); }