Jacky Tseng
/
imu_driver
handle master side communication of openIMU300ZI module
test/test.cpp@25:3dfd686ae315, 2019-12-20 (annotated)
- Committer:
- Arithemetica
- Date:
- Fri Dec 20 05:12:49 2019 +0000
- Revision:
- 25:3dfd686ae315
- Parent:
- 24:275e886bd61c
change wait time to 10us according to test result
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Arithemetica | 21:9430046ebd9d | 1 | #include "imu_driver.hpp" |
Arithemetica | 21:9430046ebd9d | 2 | |
Arithemetica | 22:713817fa6687 | 3 | #if defined(COMPILE_TEST) |
Arithemetica | 22:713817fa6687 | 4 | |
Arithemetica | 23:3626c7d73505 | 5 | SPI spi2(PB_15, PB_14, PB_13); //1Mbps default, MOSI MISO SCLK, for IMU |
Arithemetica | 21:9430046ebd9d | 6 | Serial pc(USBTX, USBRX, 115200); // print debug message |
Arithemetica | 21:9430046ebd9d | 7 | |
Arithemetica | 21:9430046ebd9d | 8 | inline void test_exti_rcv_normal_msg() |
Arithemetica | 21:9430046ebd9d | 9 | { |
Arithemetica | 21:9430046ebd9d | 10 | ImuDriver<spi2, PC_4, PB_2, PB_1> imu(ImuExtiRcvNormalMsg); //SPI instance, reset, data ready, slave select |
Arithemetica | 21:9430046ebd9d | 11 | |
Arithemetica | 21:9430046ebd9d | 12 | while(true) { |
Arithemetica | 21:9430046ebd9d | 13 | wait_ms(1); |
Arithemetica | 21:9430046ebd9d | 14 | pc.printf("gyro: % .3f, % .3f, % .3f, accel: % .3f, % .3f, % .3f\n\r", |
Arithemetica | 21:9430046ebd9d | 15 | imu.imuProcessedData.rate[0], imu.imuProcessedData.rate[1], imu.imuProcessedData.rate[2], |
Arithemetica | 21:9430046ebd9d | 16 | imu.imuProcessedData.accel[0], imu.imuProcessedData.accel[1], imu.imuProcessedData.accel[2]); |
Arithemetica | 21:9430046ebd9d | 17 | } |
Arithemetica | 21:9430046ebd9d | 18 | } |
Arithemetica | 21:9430046ebd9d | 19 | |
Arithemetica | 21:9430046ebd9d | 20 | inline void test_exti_rcv_ahrs_msg() |
Arithemetica | 21:9430046ebd9d | 21 | { |
Arithemetica | 21:9430046ebd9d | 22 | ImuDriver<spi2, PC_4, PB_2, PB_1> imu(ImuExtiRcvAhrsMsg); //SPI instance, reset, data ready, slave select |
Arithemetica | 21:9430046ebd9d | 23 | |
Arithemetica | 21:9430046ebd9d | 24 | while(true) { |
Arithemetica | 21:9430046ebd9d | 25 | wait_ms(1); |
Arithemetica | 21:9430046ebd9d | 26 | pc.printf("PRY: % .3f, % .3f, % .3f\n\r", imu.ahrsProcessedData.attitude[0], imu.ahrsProcessedData.attitude[1], imu.ahrsProcessedData.attitude[2]); |
Arithemetica | 21:9430046ebd9d | 27 | } |
Arithemetica | 21:9430046ebd9d | 28 | } |
Arithemetica | 21:9430046ebd9d | 29 | |
Arithemetica | 21:9430046ebd9d | 30 | inline void test_exti_rcv_both_msg() |
Arithemetica | 21:9430046ebd9d | 31 | { |
Arithemetica | 24:275e886bd61c | 32 | ImuDriver<spi2, PC_4, PB_2, PB_1> imu(ImuExtiRcvBothMsg); //SPI instance, reset, data ready, slave select |
Arithemetica | 21:9430046ebd9d | 33 | |
Arithemetica | 21:9430046ebd9d | 34 | while(true) { |
Arithemetica | 21:9430046ebd9d | 35 | wait_ms(1); |
Arithemetica | 21:9430046ebd9d | 36 | pc.printf("PRY: % .3f, % .3f, % .3f\n\r", imu.ahrsProcessedData.attitude[0], imu.ahrsProcessedData.attitude[1], imu.ahrsProcessedData.attitude[2]); |
Arithemetica | 21:9430046ebd9d | 37 | pc.printf("gyro: % .3f, % .3f, % .3f, accel: % .3f, % .3f, % .3f\n\r", |
Arithemetica | 21:9430046ebd9d | 38 | imu.imuProcessedData.rate[0], imu.imuProcessedData.rate[1], imu.imuProcessedData.rate[2], |
Arithemetica | 21:9430046ebd9d | 39 | imu.imuProcessedData.accel[0], imu.imuProcessedData.accel[1], imu.imuProcessedData.accel[2]); |
Arithemetica | 21:9430046ebd9d | 40 | } |
Arithemetica | 22:713817fa6687 | 41 | } |
Arithemetica | 22:713817fa6687 | 42 | |
Arithemetica | 22:713817fa6687 | 43 | #endif // COMPILE_TEST |