summaryrefslogtreecommitdiffstats
path: root/firmware/include/si570.h
blob: 9bcc36868068cfa3a85a4e10a160cde741dee427 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef __SI570_H__
#define __SI570_H__

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

#include <stdint.h>

#define SI570_ADDR  0x55
#define SI570_XTAL  114285000L

struct range {
	uint32_t min;
	uint32_t max;
};

struct si570_info {
	struct range freq_range[3];
	uint32_t   init_freq;
};

//device-context
struct si570_ctx {
	int init;
	int lock;
	void *i2c;
	uint8_t	slave_addr;

	uint32_t xtal;
	const struct si570_info *info;
};

//API
int si570_init(struct si570_ctx *ctx, void *i2c_dev, uint8_t i2c_addr);
int si570_read_calibration(struct si570_ctx *ctx);
int si570_reset(struct si570_ctx *ctx);
//mode of operation
int si570_get_lock(struct si570_ctx *ctx);
//frequency
int si570_set_freq(struct si570_ctx *ctx, uint32_t freq, int trim);
//dump all registers
void si570_regdump(struct si570_ctx *ctx);

#endif //__SI570_H__