static int pci_edu_init(PCIDevice *pdev) { EduState *edu = DO_UPCAST(EduState, pdev, pdev); uint8_t *pci_conf = pdev->config; timer_init_ms(&edu->dma_timer, QEMU_CLOCK_VIRTUAL, edu_dma_timer, edu); qemu_mutex_init(&edu->thr_mutex); qemu_cond_init(&edu->thr_cond); qemu_thread_create(&edu->thread, "edu", edu_fact_thread, edu, QEMU_THREAD_JOINABLE); pci_config_set_interrupt_pin(pci_conf, 1); memory_region_init_io(&edu->mmio, OBJECT(edu), &edu_mmio_ops, edu, "edu-mmio", 1 << 20); pci_register_bar(pdev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &edu->mmio); return 0; }
int main() { char buffer[20]; int i; float tmp, roll_angle; float acc_gyro = 0, dt; struct Gyro1DKalman filter_roll; struct Gyro1DKalman filter_pitch; init_microcontroller(); adc_init(); adc_start(); timer_init_ms(); uart1_open(); uart1_puts("Device initialized\n\r"); uart1_puts("Entering main loop\n\r"); init_Gyro1DKalman(&filter_roll, 0.0001, 0.0003, 0.69); while(1) { dt = timer_dt(); // time passed in s since last call // execute kalman filter tmp = PredictAccG_roll(accelero_z(), accelero_y(), accelero_x()); ars_predict(&filter_roll, gyro_roll_rad(), dt); // Kalman predict roll_angle = ars_update(&filter_roll, tmp); // Kalman update + result (angle) //PrintAll(accelero_x(), accelero_y(), accelero_z(), gyro_roll_rad(), gyro_pitch_rad(), r); PrintForVbApp(roll_angle / 3.14*180.0, tmp); //PrintForStabilizer(r); } uart1_close(); return 0; }