?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 6

Line No. Rev Author Line
1 6 kaklik //*****************************************************************************
2 // File Name : ads7828test.c
3 //
4 // Title : example usage of ADS7828 library functions
5 // Revision : 1.0
6 // Notes :
7 // Target MCU : Atmel AVR series
8 // Editor Tabs : 4
9 //
10 // Revision History:
11 // When Who Description of change
12 // ----------- ----------- -----------------------
13 // 20-Feb-2004 pstang Created the program
14 //*****************************************************************************
15  
16 //----- Include Files ---------------------------------------------------------
17 #include <avr/io.h> // include I/O definitions (port names, pin names, etc)
18 #include <avr/interrupt.h> // include interrupt support
19  
20 #include "global.h" // include our global settings
21 #include "uart.h" // include uart function library
22 #include "rprintf.h" // include printf function library
23 #include "timer.h" // include timer function library (timing, PWM, etc)
24 #include "vt100.h" // include VT100 terminal support
25 #include "i2c.h" // include i2c support
26 #include "ads7828.h" // include ADS7828 support
27  
28 void ads7828test(void);
29  
30 //----- Begin Code ------------------------------------------------------------
31 int main(void)
32 {
33 // initialize our libraries
34 // initialize the UART (serial port)
35 uartInit();
36 uartSetBaudRate(115200);
37 // make all rprintf statements use uart for output
38 rprintfInit(uartSendByte);
39 // initialize the timer system
40 timerInit();
41 // clear terminal screen
42 vt100ClearScreen();
43 vt100SetCursorPos(1,1);
44 // print a little intro message so we know things are working
45 rprintf("\r\nWelcome to ADS7828 test!\r\n");
46  
47 // run tests
48 ads7828test();
49  
50 return 0;
51 }
52  
53  
54 void ads7828test(void)
55 {
56 u08 i;
57 u16 conv=0;
58  
59 // initialize i2c function library
60 i2cInit();
61 i2cSetBitrate(30);
62  
63 // initialize
64 if(ads7828Init(ADS7828_I2C_ADDR))
65 {
66 rprintf("ADS7828 detected and initialized!\r\n");
67 }
68 else
69 {
70 rprintf("Cannot detect ADS7828!\r\n");
71 return;
72 }
73  
74 // use the externally applied voltage on REF pin
75 ads7828SetReference(0);
76 // or use the internal 2.5V voltage reference
77 //ads7828SetReference(1);
78  
79 while(1)
80 {
81 // position cursor
82 vt100SetCursorPos(4,1);
83  
84 for(i=0; i<8; i++)
85 {
86 // convert
87 conv = ads7828Convert(ADS7828_I2C_ADDR, i);
88 // print results
89 rprintf("CH#%d: Conversion result is: %d \r\n", i, conv-2048);
90 }
91 // pause between readings
92 timerPause(100);
93 }
94 }
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3