source: rtems/cpukit/include/dev/i2c/sensor-lm75a.h @ 255fe43

Last change on this file since 255fe43 was 255fe43, checked in by Joel Sherrill <joel@…>, on 03/01/22 at 20:40:44

cpukit/: Scripted embedded brains header file clean up

Updates #4625.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief Temperature Sensor LM75A Driver API
5 *
6 * @ingroup I2CSensorLM75A
7 */
8
9/*
10 * Copyright (c) 2017 embedded brains GmbH.  All rights reserved.
11 *
12 * The license and distribution terms for this file may be
13 * found in the file LICENSE in this distribution or at
14 * http://www.rtems.org/license/LICENSE.
15 */
16
17#ifndef _DEV_I2C_SENSOR_LM75A_H
18#define _DEV_I2C_SENSOR_LM75A_H
19
20#include <dev/i2c/i2c.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif /* __cplusplus */
25
26/**
27 * @defgroup I2CSensorLM75A Temperature Sensor LM75A Driver
28 *
29 * @ingroup I2CDevice
30 *
31 * @brief Driver for NXP or Texas Instruments LM75A temperature sensor.
32 *
33 * @{
34 */
35
36int i2c_dev_register_sensor_lm75a(
37  const char *bus_path,
38  const char *dev_path,
39  uint16_t address
40);
41
42typedef enum {
43  SENSOR_LM75A_GET_CONF = I2C_DEV_IO_CONTROL,
44  SENSOR_LM75A_SET_CONF,
45  SENSOR_LM75A_CLEAR_AND_SET_CONF,
46  SENSOR_LM75A_GET_TEMP,
47  SENSOR_LM75A_GET_TOS,
48  SENSOR_LM75A_SET_TOS,
49  SENSOR_LM75A_GET_THYST,
50  SENSOR_LM75A_SET_THYST
51} sensor_lm75a_command;
52
53static inline int sensor_lm75a_get_conf(int fd, uint8_t *val)
54{
55  return ioctl(fd, SENSOR_LM75A_GET_CONF, val);
56}
57
58static inline int sensor_lm75a_set_conf(int fd, uint8_t val)
59{
60  return ioctl(fd, SENSOR_LM75A_SET_CONF, (void *)(uintptr_t) val);
61}
62
63static inline int sensor_lm75a_clear_and_set_conf(
64  int fd,
65  uint8_t clear,
66  uint8_t set
67)
68{
69  uint16_t clear_and_set = (uint16_t) (((uint16_t) set << 8) | clear);
70
71  return ioctl(
72    fd,
73    SENSOR_LM75A_CLEAR_AND_SET_CONF,
74    (void *)(uintptr_t) clear_and_set
75  );
76}
77
78static inline int sensor_lm75a_get_temp(int fd, int16_t *val)
79{
80  return ioctl(fd, SENSOR_LM75A_GET_TEMP, val);
81}
82
83static inline int sensor_lm75a_get_temp_celsius(int fd, double *celsius)
84{
85  int rv;
86  int16_t val;
87
88  rv = ioctl(fd, SENSOR_LM75A_GET_TEMP, &val);
89  *celsius = (((int) val) >> 5) * 0.125;
90  return rv;
91}
92
93static inline int sensor_lm75a_get_tos(int fd, uint16_t *val)
94{
95  return ioctl(fd, SENSOR_LM75A_GET_TOS, val);
96}
97
98static inline int sensor_lm75a_set_tos(int fd, uint16_t val)
99{
100  return ioctl(fd, SENSOR_LM75A_SET_TOS, (void *)(uintptr_t) val);
101}
102
103static inline int sensor_lm75a_get_thyst(int fd, uint16_t *val)
104{
105  return ioctl(fd, SENSOR_LM75A_GET_THYST, val);
106}
107
108static inline int sensor_lm75a_set_thyst(int fd, uint16_t val)
109{
110  return ioctl(fd, SENSOR_LM75A_SET_THYST, (void *)(uintptr_t) val);
111}
112
113/** @} */
114
115#ifdef __cplusplus
116}
117#endif /* __cplusplus */
118
119#endif /* _DEV_I2C_SENSOR_LM75A_H */
Note: See TracBrowser for help on using the repository browser.