0b6de2d69d19f59162e21387e23b8ab972775c4a
[fw/sdcc] / device / examples / ds390 / i2c390 / i2c390.c
1 /* This example compiles right out of the box for TINI after you did a 
2    make install of sdcc (latest revision :).
3
4    It prints the value of the DS1621 temperature sensor (at address 2) 
5    and the 4 values of the PCF8591 ad-convertor (at address 0).
6    It (ab)uses the CAN CTX and CTR pins of the DS80C390.
7    Make sure you have pull-up resistors connected or it WON'T work.
8
9    Just do a "make" which compiles and compresses it a little.
10    Than use JavaKit to load i2c390.hex (it goes into bank 1, see Makefile)
11    Type 'E' in JavaKit and enjoy :) */
12
13 /* if you are using the (default) interrupt scheme for serial i/o,
14    you need to include this in the main program, so the vector will
15    be initialized */
16 #include <serial390.h>
17
18 #include <stdio.h>
19
20 #include "ds1621.h"
21 #include "pcf8591.h"
22
23
24 void main (void) {
25
26   while(1) {
27     printf ("%s %03bu %03bu %03bu %03bu\n\r", 
28             ReadDS1621(2),
29             ReadPCF8591(0,0), 
30             ReadPCF8591(0,1), 
31             ReadPCF8591(0,2), 
32             ReadPCF8591(0,3));
33   }
34 }