/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); palSetPadMode(GPIOB, GPIOB_PIN0, PAL_MODE_ALTERNATE(2) | PAL_STM32_PUDR_FLOATING); palSetPadMode(GPIOB, GPIOB_PIN1, PAL_MODE_ALTERNATE(2) | PAL_STM32_PUDR_FLOATING); palSetPadMode(GPIOB, GPIOB_PIN4, PAL_MODE_ALTERNATE(2) | PAL_STM32_PUDR_FLOATING); palSetPadMode(GPIOB, GPIOB_PIN5, PAL_MODE_ALTERNATE(2) | PAL_STM32_PUDR_FLOATING); eicuStart(&EICUD3, &eicucfg); eicuEnable(&EICUD3); osalThreadSleepMicroseconds(10); // need to stabilize input puns chThdCreateStatic(PulseThreadWA_LED3, sizeof(PulseThreadWA_LED3), NORMALPRIO+1, PulseThread, &pulse_led3); chThdCreateStatic(PulseThreadWA_LED4, sizeof(PulseThreadWA_LED4), NORMALPRIO+1, PulseThread, &pulse_led4); chThdCreateStatic(PulseThreadWA_LED5, sizeof(PulseThreadWA_LED5), NORMALPRIO+1, PulseThread, &pulse_led5); chThdCreateStatic(PulseThreadWA_LED6, sizeof(PulseThreadWA_LED6), NORMALPRIO+1, PulseThread, &pulse_led6); while (true) { osalThreadSleepMilliseconds(500); } return 0; }
int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured * device drivers and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread * and the RTOS is active. */ halInit(); chSysInit(); /* * * Initializes a serial-over-USB CDC driver. * */ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); /* * * Activates the USB driver and then the USB bus pull-up on D+. * */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(500); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); /* * * Start I2C and set up sensors * */ i2cStart(&I2CD2, &i2cfg2); /* Initialize Accelerometer and Gyroscope */ if (MPU6050Init(&mpu6050cfg) != MSG_OK) panic("MPU6050 init failed"); /* Initialization failed */ /* Initialize Magnetometer */ if (HMC5983Init(&hmc5983cfg) != MSG_OK) panic("HMC5983 init failed"); /* Initialization failed */ /* Initialize Barometer */ /* TODO: Add barometer code */ /* Initialize sensor readout */ if (SensorReadInit(&mpu6050cfg, &hmc5983cfg, &mpu6050cal, &hmc5983cal) != MSG_OK) panic("Sensor Read init failed"); /* Initialization failed */ /* * * Start the external interrupts * */ extStart(&EXTD1, &extcfg); /* * * Initialize the RC Outputs * */ if (RCOutputInit(&rcoutputcfg) != MSG_OK) panic("RC output init failed"); /* Initialization failed */ /* * * Start RC Inputs * */ eicuInit(); eicuStart(&EICUD9, &rcinputcfg); eicuEnable(&EICUD9); /* * * Start test thread * */ chThdCreateStatic( waThreadTestEvents, sizeof(waThreadTestEvents), HIGHPRIO, ThreadTestEvents, NULL); while(1) { chThdSleepMilliseconds(100); if (isUSBActive() == true) chprintf((BaseSequentialStream *)&SDU1, "Input width: %u\r\n", ic_test); } }