summaryrefslogtreecommitdiff
path: root/i2c.c
diff options
context:
space:
mode:
authorMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-14 10:32:21 -0400
committerMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-14 10:32:21 -0400
commitcc81ed5ed18464d6e632c79a1ccc9a2a8eea45b4 (patch)
treef6c1168e533fe28859269c111864ce82f88a8300 /i2c.c
parent1d122d034def5e9f7e0a76159866de0f36ab56f7 (diff)
astyle formatting run
Diffstat (limited to 'i2c.c')
-rw-r--r--i2c.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/i2c.c b/i2c.c
index 9dc4fe9..84a9338 100644
--- a/i2c.c
+++ b/i2c.c
@@ -10,45 +10,51 @@
#define I2C_BUS "/dev/i2c-3"
-void I2C_Write(gulong address, guchar value) {
+void I2C_Write(gulong address, guchar value)
+{
struct i2c_smbus_ioctl_data argswrite;
- argswrite.read_write = I2C_SMBUS_WRITE;
- argswrite.size = I2C_SMBUS_BYTE;
- argswrite.data = NULL;
+ argswrite.read_write = I2C_SMBUS_WRITE;
+ argswrite.size = I2C_SMBUS_BYTE;
+ argswrite.data = NULL;
argswrite.command = value;
int device = open(I2C_BUS, O_RDWR);
// FIXME?
- if (device == -1) return;
+ if (device == -1) {
+ return;
+ }
ioctl(device, I2C_SLAVE, address);
- ioctl(device, I2C_SMBUS, &argswrite);
+ ioctl(device, I2C_SMBUS, &argswrite);
close(device);
}
-guchar I2C_Read(gulong address) {
+guchar I2C_Read(gulong address)
+{
union i2c_smbus_data data;
- struct i2c_smbus_ioctl_data argsread;
-
- argsread.read_write = I2C_SMBUS_READ;
- argsread.size = I2C_SMBUS_BYTE;
- argsread.data = &data;
- argsread.command = 0;
+ struct i2c_smbus_ioctl_data argsread;
- int device = open(I2C_BUS, O_RDWR);
+ argsread.read_write = I2C_SMBUS_READ;
+ argsread.size = I2C_SMBUS_BYTE;
+ argsread.data = &data;
+ argsread.command = 0;
- if (device == -1) return 0;
+ int device = open(I2C_BUS, O_RDWR);
+
+ if (device == -1) {
+ return 0;
+ }
- ioctl(device, I2C_SLAVE, address);
- ioctl(device, I2C_SMBUS, &argsread);
+ ioctl(device, I2C_SLAVE, address);
+ ioctl(device, I2C_SMBUS, &argsread);
- close(device);
+ close(device);
return data.byte;
}