source: svn/trunk/zas_dstar/devices/Tuner/S5H1409/IicComm.c @ 2

Last change on this file since 2 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
File size: 3.1 KB
Line 
1/****************************************************************************
2*
3*                       Copyright (c) 2001 Trident Microsystems, Inc.
4*                                                       All rights reserved
5*
6* The content of this file or document is CONFIDENTIAL and PROPRIETARY
7* to Trident Microsystems, Inc.  It is subject to the terms of a License
8* Agreement between Licensee and Trident Microsystems, Inc.
9* restricting among other things, the use, reproduction, distribution
10* and transfer.  Each of the embodiments, including this information and
11* any derivative work shall retain this copyright notice
12*
13* FileName: IicComm.c
14*
15* modification history
16* Created by Alex
17* Date: 2006-4-28
18*******************************************************************************/
19#include "dsthalcommon.h"
20
21int S5H1409_IicTransmit(unsigned char chipAddr, unsigned char *pBuffer, int len )
22{
23        int n;
24       
25        n = DHL_SYS_I2cWrite( chipAddr, 0, 0, pBuffer, len ); 
26        if (n != len)
27                return -1;
28       
29        return 0;
30}
31
32int S5H1409_IicTransmitEx(unsigned char chipAddr, unsigned char *pBuffer, int len )
33{
34        int n;
35#if 1
36        n = DHL_SYS_I2cWrite( chipAddr, 1, pBuffer[0], &pBuffer[1], len-1 ); 
37        if (n != len)
38                return -1;
39#else
40
41        n = DHL_SYS_I2cWrite( chipAddr, 0, 0, pBuffer, len ); 
42        if (n != len)
43                return -1;
44#endif
45        return 0;
46}
47
48/**************************************************************************
49 * Name:
50 *              IicWriteOneRegister
51 * Description:
52 *              write data to one register
53 * Parameter:
54 *              chipaddr: I2c address
55 *                 regaddr:  subaddress
56 *                 data: 2 bytes
57 * return:
58 *              the value of the regaddr
59 *           0 for success,  non-zero for failure
60 * Author:
61 *              Alex
62 ***************************************************************************/
63UINT16 S5H_IicWriteOneRegister(UINT8 chipaddr, UINT8 regaddr, UINT16 data)
64{
65        int n;
66        UINT16 result = 0;
67        UINT8 dataBuf[2] = {0x00, 0x00};
68
69        dataBuf[0] = (data>>8)&0xff;
70        dataBuf[1] = (data)&0xff;       
71               
72        n = DHL_SYS_I2cWrite( chipaddr, 1, regaddr, dataBuf, 2 );
73        if ( n != 2 && n != 3 ) {
74                printf("|%s| ERROR, Return=%d\n", __FUNCTION__, n);
75                result = 1;
76        }
77       
78        return result;
79}
80
81 /**************************************************************************
82 * Name:
83 *              IicReadOneRegister
84 * Description:
85 *              Read one register with 2 bytes
86 * Parameter:
87 *              chipaddr: I2c address
88 *                 regaddr:  subaddress
89 * return:
90 *              the value of the regaddr
91 *           0 for success,  non-zero for failure
92 * Author:
93 *              Alex
94 ***************************************************************************/
95UINT16 S5H_IicReadOneRegister(UINT8 chipaddr, UINT8 regaddr)
96{
97        UINT8 dataBuf[2] = {0x00, 0x00};
98        UINT16 ret_val;
99        int n;
100       
101        n = DHL_SYS_I2cRead( chipaddr, 1, regaddr, dataBuf, 2 );
102        if ( n != 2 ) {
103                printf("|%s| ERROR, Return=%d\n", __FUNCTION__, n);
104        }
105       
106        ret_val = ((dataBuf[0]<<8) | dataBuf[1]);
107       
108        return ret_val;
109}
110
111UINT8 S5H_IicReadTunerByte(UINT8 TunerAddr)
112{
113        UINT8 dataBuf[2] = {0x00, 0x00};
114        UINT8 ret_val;
115        int n;
116       
117        n = DHL_SYS_I2cRead( TunerAddr, 0, 0, dataBuf, 1 );
118        if ( n != 0 ) {
119                printf("|%s| ERROR, Return=%d\n", __FUNCTION__, n);
120        }
121       
122        ret_val = dataBuf[0];
123       
124        return ret_val;
125}
Note: See TracBrowser for help on using the repository browser.