onewire.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. ChibiOS/RT - Copyright (C) 2014 Uladzimir Pylinsky aka barthess
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. #ifndef _ONEWIRE_H_
  14. #define _ONEWIRE_H_
  15. #include "hal.h"
  16. typedef enum {
  17. onewire_OK = 0,
  18. onewire_No_Dev,
  19. onewire_Dev_Lost,
  20. onewire_CRC_Err,
  21. onewire_MemCmp_Err
  22. } onewire_error_t;
  23. typedef enum {
  24. ow1 = 0,
  25. ow2 = 1
  26. } onewire_dev_t;
  27. typedef struct onewire {
  28. int32_t temperature; /* temperature values in millicelsius */
  29. size_t dev_on_bus;
  30. onewire_error_t err_code;
  31. const onewireConfig * ow_cfg;
  32. } onewired_t;
  33. /*
  34. * PROTOTYPES
  35. */
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. void onewireMeasure(onewired_t * ow);
  40. onewire_error_t onewireGetErrorCode(onewired_t * ow);
  41. uint8_t onewireGetDevicesNum(onewired_t * ow);
  42. int32_t onewireGetTemperature(onewired_t * ow);
  43. #ifdef __cplusplus
  44. }
  45. #endif
  46. #endif /* _ONEWIRE_H_ */