I2CDevice.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (C) 2015-2016 Intel Corporation. All rights reserved.
  3. *
  4. * This file is free software: you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This file is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. * See the GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #pragma once
  18. #include <inttypes.h>
  19. #include <AP_HAL/HAL.h>
  20. #include <AP_HAL/I2CDevice.h>
  21. #include <AP_HAL/utility/OwnPtr.h>
  22. namespace Empty {
  23. class I2CDevice : public AP_HAL::I2CDevice {
  24. public:
  25. I2CDevice()
  26. {
  27. }
  28. virtual ~I2CDevice() { }
  29. /* AP_HAL::I2CDevice implementation */
  30. /* See AP_HAL::I2CDevice::set_address() */
  31. void set_address(uint8_t address) override { }
  32. /* See AP_HAL::I2CDevice::set_retries() */
  33. void set_retries(uint8_t retries) override { }
  34. /* AP_HAL::Device implementation */
  35. /* See AP_HAL::Device::transfer() */
  36. bool transfer(const uint8_t *send, uint32_t send_len,
  37. uint8_t *recv, uint32_t recv_len) override
  38. {
  39. return true;
  40. }
  41. bool read_registers_multiple(uint8_t first_reg, uint8_t *recv,
  42. uint32_t recv_len, uint8_t times) override
  43. {
  44. return true;
  45. }
  46. /* See AP_HAL::Device::set_speed() */
  47. bool set_speed(enum AP_HAL::Device::Speed speed) override { return true; }
  48. /* See AP_HAL::Device::get_semaphore() */
  49. AP_HAL::Semaphore *get_semaphore() override { return nullptr; }
  50. /* See AP_HAL::Device::register_periodic_callback() */
  51. AP_HAL::Device::PeriodicHandle register_periodic_callback(
  52. uint32_t period_usec, AP_HAL::Device::PeriodicCb) override
  53. {
  54. return nullptr;
  55. }
  56. /* See Device::adjust_periodic_callback() */
  57. virtual bool adjust_periodic_callback(
  58. AP_HAL::Device::PeriodicHandle h, uint32_t period_usec) override
  59. {
  60. return true;
  61. }
  62. };
  63. class I2CDeviceManager : public AP_HAL::I2CDeviceManager {
  64. public:
  65. I2CDeviceManager() { }
  66. /* AP_HAL::I2CDeviceManager implementation */
  67. AP_HAL::OwnPtr<AP_HAL::I2CDevice> get_device(uint8_t bus, uint8_t address,
  68. uint32_t bus_clock=400000,
  69. bool use_smbus = false,
  70. uint32_t timeout_ms=4) override
  71. {
  72. return nullptr;
  73. }
  74. };
  75. }