Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -523,14 +523,30 @@ NUT_ARG_WITH([linux_i2c], [build and install i2c drivers], [auto])
if test "${nut_with_linux_i2c}" != no; then
case ${target_os} in
linux* )
AC_CHECK_HEADER(
[linux/i2c-dev.h],
[AC_DEFINE([HAVE_LINUX_I2C_DEV_H], [1],
[Define to 1 if you have <linux/i2c-dev.h>.])]
)
AC_CHECK_HEADER(
[i2c/smbus.h],
[AC_DEFINE([HAVE_LINUX_SMBUS_H], [1],
[Define to 1 if you have <i2c/smbus.h>.])]
)
AC_CHECK_DECLS(
[i2c_smbus_read_word_data, i2c_smbus_write_word_data, i2c_smbus_read_block_data],
[i2c_smbus_access, i2c_smbus_read_byte_data, i2c_smbus_write_byte_data, i2c_smbus_read_word_data, i2c_smbus_write_word_data, i2c_smbus_read_block_data],
[nut_with_linux_i2c="yes"],
[nut_with_linux_i2c="no"],
[#include <stdio.h>
#ifdef HAVE_LINUX_I2C_DEV_H
#include <linux/i2c-dev.h>
#endif
#ifdef HAVE_LINUX_SMBUS_H
#include <i2c/smbus.h>
#endif
]
)
AC_SEARCH_LIBS([i2c_smbus_read_byte], [i2c])
;;
* )
nut_with_linux_i2c="no"
Expand Down
7 changes: 5 additions & 2 deletions drivers/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ SERIAL_USB_DRIVERLIST = \
NEONXML_DRIVERLIST = netxml-ups
MACOSX_DRIVERLIST = macosx-ups
MODBUS_DRIVERLIST = phoenixcontact_modbus
LINUX_I2C_DRIVERLIST = asem
LINUX_I2C_DRIVERLIST = asem pijuice

# distribute all drivers, even ones that are not built by default
EXTRA_PROGRAMS = $(SERIAL_DRIVERLIST) $(SNMP_DRIVERLIST) $(USB_DRIVERLIST) $(SERIAL_USB_DRIVERLIST) $(NEONXML_DRIVERLIST) $(MACOSX_DRIVERLIST)
Expand Down Expand Up @@ -128,6 +128,7 @@ mge_utalk_SOURCES = mge-utalk.c
microdowell_SOURCES = microdowell.c
oneac_SOURCES = oneac.c
optiups_SOURCES = optiups.c
pijuice_SOURCES = pijuice.c
powercom_SOURCES = powercom.c
powercom_LDADD = $(LDADD) -lm
powerpanel_SOURCES = powerpanel.c powerp-bin.c powerp-txt.c
Expand Down Expand Up @@ -241,9 +242,11 @@ macosx_ups_SOURCES = macosx-ups.c
phoenixcontact_modbus_SOURCES = phoenixcontact_modbus.c
phoenixcontact_modbus_LDADD = $(LDADD_DRIVERS) $(LIBMODBUS_LIBS)

# Asem
# Linux I2C drivers
asem_LDADD = $(LDADD_DRIVERS)
asem_SOURCES = asem.c
pijuice_LDADD = $(LDADD_DRIVERS)
pijuice_SOURCES = pijuice.c

# nutdrv_qx USB/Serial
nutdrv_qx_SOURCES = nutdrv_qx.c
Expand Down
7 changes: 4 additions & 3 deletions drivers/asem.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
so you need to boot with acpi_enforce_resources=lax option.
*/

/* Depends on i2c-dev.h, Linux only */
#include "main.h"

#include <stdio.h>
#include <errno.h>
#include <unistd.h>
/* Depends on i2c-dev.h, Linux only */
#include <linux/i2c-dev.h>

#include "main.h"
#include <sys/ioctl.h>

#ifndef __STR__
# define __STR__(x) #x
Expand Down
Loading