-
Notifications
You must be signed in to change notification settings - Fork 50
/
si5351.h
48 lines (42 loc) · 1.28 KB
/
si5351.h
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
#ifndef _SI5351_H
#define _SI5351_H
/*
* si5351.h
*
* Created: March 2021
* Author: Arjan
*
* Driver for Si5351A chip.
* VFO 0 is a quadrature clock on outputs 0 and 1,
* VFO 1 is a regular clock on output 2.
*
* VFO 0 allows to set frequency and phase offsets of 0-90-180-270 deg (delay clk1 wrt clk0)
* VFO 1 just allows to set frequency, phase is ignored
*
* Use the 'set' functions to change VFO settings.
* Make regular calls to the 'evaluate' function to commit the changes (if any).
* To get smooth tuning, a suggested interval is 0.1sec, e.g. from a timer loop
*
* See si5351.c for more information
*
*/
// Phase definitions for si_setphase()
#define PH000 0
#define PH090 1
#define PH180 2
#define PH270 3
typedef struct
{
uint32_t freq; // type can hold up to 4GHz
uint8_t phase; // in quarter waves (0, 1, 2, 3)
uint8_t ri; // Ri (1 .. 128), but should be 1 for VFO 0
uint8_t msi; // MSi parameter a (4, 6, 8 .. 126)
double msn; // MSN (24.0 .. 35.9999)
} vfo_t;
int si_getreg(uint8_t *buffer, uint8_t reg, uint8_t len);
int si_getvfo(int i, vfo_t *v);
void si_setphase(int i, uint8_t p);
void si_enable(int i, bool en);
void si_init(void);
int si_evaluate(int i, uint32_t freq);
#endif /* _SI5351_H */