-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaxim-max127-test1.c
48 lines (41 loc) · 1.2 KB
/
maxim-max127-test1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma config(Sensor, S1, MAX127, sensorI2CCustomStd)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*
* $Id: maxim-max127-test1.c 133 2013-03-10 15:15:38Z xander $
*/
/**
* maxim-max127.h provides an API for the MAXIM MAX127 ADC. This program
* demonstrates how to use that API.
*
* License: You may use this code as you wish, provided you give credit where it's due.
*
* THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER.
* Xander Soldaat (xander_at_botbench.com)
* 08 March 2009
* version 0.1
*/
#include "drivers/maxim-max127.h"
task main() {
int _chVal = 0;
nxtDisplayTextLine(3, "MAX127");
nxtDisplayTextLine(4, "Test prog");
wait1Msec(1000);
eraseDisplay();
while(true) {
eraseDisplay();
for (int i = 0; i < 8; i++) {
_chVal = MAX127readChan(MAX127, MAX127_I2C_ADDR, i);
// if the return value is < 0 then an error occurred
if (_chVal < 0) {
nxtDisplayTextLine(4, "ERROR!!");
wait1Msec(2000);
StopAllTasks();
}
nxtDisplayTextLine(i, "CH[%d]: %d", i, _chVal);
}
wait1Msec(100);
}
}
/*
* $Id: maxim-max127-test1.c 133 2013-03-10 15:15:38Z xander $
*/