Project

General

Profile

Download (1.66 KB) Statistics
| Branch: | Tag: | Revision:
1
#ifndef __SI570_H__
2
#define __SI570_H__
3

    
4
/* (C) 2005-2011 by maintech GmbH
5
 * (C) 2011-2012 by Harald Welte <laforge@gnumonks.org>
6
 *
7
 * All Rights Reserved
8
 *
9
 * This program is free software; you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation; either version 3 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22

    
23
#include <stdint.h>
24

    
25
#define SI570_ADDR  0x55
26
#define SI570_XTAL  114285000L
27

    
28
struct range {
29
	uint32_t min;
30
	uint32_t max;
31
};
32

    
33
struct si570_info {
34
	struct range freq_range[3];
35
	uint32_t   init_freq;
36
};
37

    
38
//device-context
39
struct si570_ctx {
40
	int init;
41
	int lock;
42
	void *i2c;
43
	uint8_t	slave_addr;
44

    
45
	uint32_t xtal;
46
	const struct si570_info *info;
47
};
48

    
49
//API
50
int si570_init(struct si570_ctx *ctx, void *i2c_dev, uint8_t i2c_addr);
51
int si570_reinit(struct si570_ctx *ctx);
52
int si570_read_calibration(struct si570_ctx *ctx);
53
int si570_reset(struct si570_ctx *ctx);
54
//mode of operation
55
int si570_get_lock(struct si570_ctx *ctx);
56
//frequency
57
int si570_set_freq(struct si570_ctx *ctx, uint32_t freq, int trim);
58
//dump all registers
59
void si570_regdump(struct si570_ctx *ctx);
60
//write register(s)
61
int si570_reg_write(struct si570_ctx *ctx, uint8_t reg, int len, const uint8_t* data);
62

    
63
#endif //__SI570_H__
(10-10/12)
Add picture from clipboard (Maximum size: 48.8 MB)