VoxelProgrammerBase.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * TI Voxel Lib component.
  3. *
  4. * Copyright (c) 2014 Texas Instruments Inc.
  5. */
  6. #ifndef VOXEL_TI_VOXEL_PROGRAMMER_BASE_H
  7. #define VOXEL_TI_VOXEL_PROGRAMMER_BASE_H
  8. #include "RegisterProgrammer.h"
  9. #include "Device.h"
  10. #include "TI3DToFExports.h"
  11. namespace Voxel
  12. {
  13. namespace TI
  14. {
  15. class TI3DTOF_EXPORT VoxelProgrammerBase: public RegisterProgrammer
  16. {
  17. public:
  18. typedef Map<uint, uint> SlaveAddressToByteMap;
  19. protected:
  20. DevicePtr _device;
  21. mutable Mutex _mutex;
  22. SlaveAddressToByteMap _slaveAddressToByteMap;
  23. virtual bool _readRegister(uint16_t slaveAddress, uint16_t registerAddress, uint32_t &value, uint8_t length) const = 0;
  24. virtual bool _writeRegister(uint16_t slaveAddress, uint16_t registerAddress, uint32_t value, uint8_t length) = 0;
  25. public:
  26. VoxelProgrammerBase(const SlaveAddressToByteMap &map, DevicePtr device);
  27. virtual bool readRegister(uint32_t address, uint32_t &value) const;
  28. virtual bool writeRegister(uint32_t address, uint32_t value);
  29. // getValue() and setValue() are internally called readRegister() and writeRegister() which are thread-safe. So, no mutex locking in getValue() and setValue()
  30. virtual bool getValue(const Parameter &param, uint32_t &value) const;
  31. virtual bool setValue(const Parameter &param, uint32_t value, bool writeOnly = false);
  32. virtual ~VoxelProgrammerBase() {}
  33. };
  34. }
  35. }
  36. #endif // VOXEL_TI_VOXELXU_PROGRAMMER_H