summaryrefslogtreecommitdiff
path: root/libdso138.h
blob: 70202ba846a8880d89bf952915113c38ddd439de (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
//////////////////////////////////////////////////////////////////////////////
//
// 	Filename:	libdso138.h
//	Version:		
//	Data:		
//
//	Author:		Liu, Zemin
//	Company:	JYE Tech Ltd.
//	Web:		www.jyetech.com
//
//-----------------------------------------------------------------------------
//
// 	Target: 		STM32F103C8
// 	Tool chain: 	CodeSourcery G++
//
//-----------------------------------------------------------------------------
//	Required files:
//
//-----------------------------------------------------------------------------
//	Notes:
//
//
//-----------------------------------------------------------------------------
//	Revision History:
//
///////////////////////////////////////////////////////////////////////////////

#ifndef	libdso138_h

#define	libdso138_h

//#include	"Common.h"

// =======================================================

#define	VPosMax	255
#define	VPosMin		-255

#define	VSenMax	VS_10mV
#define	VSenMin		VS_5V

#define	CplMax		CP_GND
#define	CplMin		CP_DC

#define	TBMax		TB_10us
#define	TBMin		TB_500s

#define	TrigModeMax	TM_Single
#define	TrigModeMin		TM_Auto

#define	TrigEdgeMax	TE_Rising
#define	TrigEdgeMin		TE_Falling

#define	TrigLvlMax		300
#define	TrigLvlMin		-300

#define	SampleBufSizeMax	0x400

#define	RecLenMax		SampleBufSizeMax
#define	RecLenMin		512


// =======================================================
//	Scope control type definitions
// =======================================================
//

// -- Time base type
enum	TimeBase {
//	TB_min,
	TB_Custom 	= 0,	
	TB_500s,		
	TB_200s,		
	TB_100s,		
	TB_50s,		
	TB_20s,		
	TB_10s,		
	TB_5s,		
	TB_2s,		
	TB_1s,		
	TB_05s,		
	TB_02s,		
	TB_01s,		
	TB_50ms,	
	TB_20ms,	
	TB_10ms,	
	TB_5ms,		
	TB_2ms,		
	TB_1ms,		
	TB_05ms,	
	TB_02ms,	
	TB_01ms,	
	TB_50us,	
	TB_20us,	
	TB_10us,	
	TB_5us,		
	TB_2us,		
	TB_1us,		
	TB_05us,	
	TB_02us,
	TB_01us,
	TB_50ns,
	TB_20ns,
	TB_10ns,
//	TB_max
	};

// -- Trig Mode type
enum TrigMode	{
	TM_Auto,
	TM_Normal,
	TM_Single,
	TM_Max
	};


// -- Trig Edge type
enum TrigEdge {
	TE_Falling,
	TE_Rising,
	};

// -- V sensitivity type
typedef	enum 	{
	VS_UnCal		= 0,
	VS_50V,
	VS_20V,
	VS_10V,
	VS_5V,
	VS_2V,
	VS_1V,
	VS_05V,
	VS_02V,
	VS_01V,
	VS_50mV,
	VS_20mV,
	VS_10mV,
	VS_5mV,
	VS_Last
	}TY_VSen ;

// -- Coupling type
enum 	Couple{
	CP_DC,
	CP_AC,
	CP_GND
	};

enum FocusType {
	FC_Timebase	= 0,
	FC_TrigMode,
	FC_TrigEdge,
	FC_TrigLvl,
	FC_HPos,
	FC_VPos,
	FC_Max

};


enum DsoStatus {
	DSO_CaptureDone 		= 0x0001,
	DSO_Trigged 			= 0x0002,
	DSO_Hold 				= 0x0004,
	DSO_Rolling 				= 0x0008,
	DSO_NormalDisplay		= 0x0080,
};

enum DispUpdateFlags {
	Disp_Panel 		= 0x0001,
	Disp_Param 		= 0x0002,
	Disp_Trace 		= 0x0004,
};

// =====================================
// Exported variables
//
extern	U16	*SampleBuf;
extern	U16	*CurrentSample;
extern	U8	LibVersion[];
extern	U8	NoScopePanel;



// -- Function Prototypes --
void	DSO_Init(void);
void	StartCapture(void);
void	StopCapture(void);
U16	GetDsoStatus(void);
void	SetHold(void);
void	ClrHold(void);
void	UpdateTimebase(void);

S8	SetVSen(S8 vsen);
S8	SetCpl(S8 cpl);
S16	SetVPos(S16 vpos);
S8	SetTimeBase(S8 timebase);
S16	SetHPos(S16 hpos);
S8	SetTrigMode(S8 trigmode);
S8	SetTrigEdge(S8 trigslope);
S16 SetTrigLvl(S16 triglvl);
U16	SetRecLen(U16 reclen);
S16	SetVPosOfs(S16 ofs);

S8 	GetVSen(void);
S8 	GetCpl(void);
S16 	GetVPos(void);
S8 	GetTimebase(void);
S16 	GetHPos(void);
S8 	GetTrigMode(void);
S8 	GetTrigEdge(void);
S16 	GetTrigLvl(void);
U16 	GetRecLen(void);
S16	GetVPosOfs(void);

void	DsoDisplay(void);
void	UpdateDisp(U16 disp);
void Rolling(void);
U8	SetFocus(U8 focus);
U8	GetFocus(void);

S16	GetAverage(void);

#endif