AP_Common.cpp 986 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // Unit tests for the AP_Common code
  3. //
  4. #include <AP_Common/AP_Common.h>
  5. #include <AP_HAL/AP_HAL.h>
  6. void setup();
  7. void loop();
  8. void test_high_low_byte(void);
  9. const AP_HAL::HAL& hal = AP_HAL::get_HAL();
  10. void test_high_low_byte(void)
  11. {
  12. // test each value from 0 to 300
  13. for (uint16_t i = 0; i <= 300; i++) {
  14. uint8_t high = HIGHBYTE(i);
  15. uint8_t low = LOWBYTE(i);
  16. hal.console->printf("\ni:%u high:%u low:%u", (unsigned int)i, (unsigned int)high, (unsigned int)low);
  17. }
  18. // test values from 300 to 65400 at increments of 200
  19. for (uint16_t i = 301; i <= 65400; i += 200) {
  20. uint8_t high = HIGHBYTE(i);
  21. uint8_t low = LOWBYTE(i);
  22. hal.console->printf("\ni:%u high:%u low:%u", (unsigned int)i, (unsigned int)high, (unsigned int)low);
  23. }
  24. }
  25. /*
  26. * euler angle tests
  27. */
  28. void setup(void)
  29. {
  30. hal.console->printf("AP_Common tests\n\n");
  31. test_high_low_byte();
  32. }
  33. void loop(void)
  34. {
  35. // do nothing
  36. }
  37. AP_HAL_MAIN();