Parent Directory | Revision Log
Initial import of PIC module
1 | /* H7 -projekt opgave */ |
2 | |
3 | #include <pic18.h> |
4 | #include "delay.h" |
5 | #include "i2c.h" |
6 | #include "lcd.h" |
7 | |
8 | |
9 | #define TC74 0x9A /* I2C TC74 IC */ |
10 | |
11 | void i2c_init(void) |
12 | { |
13 | #ifdef I2C_MODULE |
14 | SSPMode(MASTER_MODE); |
15 | SSPEN = 1; |
16 | CKP = 1; |
17 | #else |
18 | SCL_DIR = I2C_OUTPUT; |
19 | SDA_DIR = I2C_OUTPUT; |
20 | SDA = 0; |
21 | SCL = 0; |
22 | #endif |
23 | } |
24 | |
25 | char ReadTemp(void) |
26 | { |
27 | char temp; |
28 | i2c_WriteTo(TC74); |
29 | i2c_PutByte(0x00); //tell TC74 we want to read |
30 | i2c_ReadFrom(TC74); |
31 | temp = i2c_GetByte(I2C_LAST); |
32 | i2c_Stop(); //assert a stop condition on SDA & SCL |
33 | return temp; |
34 | } |
35 | |
36 | void main(void) |
37 | { |
38 | lcd_init(0); //init in 4-bit mode |
39 | i2c_init(); |
40 | |
41 | while (1) |
42 | { |
43 | } |
44 | } |
ViewVC Help | |
Powered by ViewVC 1.1.20 |