Pi IoT In C Using Linux Drivers - Hwmon |
Written by Harry Fairhead | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Monday, 21 June 2021 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Page 1 of 3 As well as raw bus drivers there are also many direct device drivers which hide the details of how the devices are interfaced. Many of these conform to either the IIO or Hwmon approach. In this extract from my recent book on Linux drivers the focus is on Hwmon - the oldest of the approaches. Raspberry Pi IoT In C Using Linux DriversBy Harry FairheadBuy from Amazon. Contents
<ASIN:1871962641> <ASIN:B08W9V7TP9> Sensor Drivers – Linux IIO & HwmonAs well as supporting the I2C bus in a general way, there are also a number of I2C device drivers. These allow you to use I2C devices without worrying about the exact nature of the protocol in use. Some of these device drivers conform to either one or other of a broader, protocol-independent way of implementing drivers – hwmon, relating to the hardware monitoring system and iio, for interfacing Linux Industrial I/O devices. These form a framework for creating, publishing and using drivers for devices irrespective of the protocol used to control them. As you can see in the table below the majority are I2C devices. At the time of writing the following devices are supported:
The majority of these devices are available at reasonable cost in either prototype-friendly DIL packages or as breakout boards. Of course, there are many sensors that are not supported by a Linux driver, but making a choice from this list can save you a lot of time and trouble. Some of the above device drivers are part of the Industrial I/O (IIO) subsystem project and some are part of the older hwmon subsystem. The hwmon subsystem is intended to be a way of reading and configuring sensors and devices that are built into the system. For example, you can read the CPU temperature or the supply voltage of the Pi using the built-in sensors that are part of hwmon. However, you can also add drivers to the hwmon subsystem that aren’t built in. This use of hwmon as a “home” for sensors is what led to the decision to create IIO as a better and more appropriate place for sensors. There are some big differences between hwmon and IIO. In particular IIO only deals with input devices and, in principle, it can do so in much more sophisticated ways than hwmon. Hwmon has the advantage of dealing with input and output devices, but it is much simpler. Let’s start with hwmon and see the general principles in action. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Last Updated ( Monday, 21 June 2021 ) |