Skip to content

Commit 6c7cb63

Browse files
Merge pull request #7 from TimerOverflow/fix
convert tab -> space
2 parents 62df8ac + 73076c4 commit 6c7cb63

File tree

4 files changed

+159
-159
lines changed

4 files changed

+159
-159
lines changed

DataSampling.c

Lines changed: 111 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -23,166 +23,166 @@ static tS32 Ret;
2323
/*********************************************************************************/
2424
inline static void InToBuf(tag_DataSampling *Smp, tU8 Idx, tS32 Data)
2525
{
26-
switch(Smp->DataSize)
27-
{
28-
case sizeof(tS8) : pS8 = (tS8 *) Smp->Buf; pS8[Idx] = Data; break;
29-
case sizeof(tS16) : pS16 = (tS16 *) Smp->Buf; pS16[Idx] = Data; break;
30-
case sizeof(tS32) : pS32 = (tS32 *) Smp->Buf; pS32[Idx] = Data; break;
31-
}
26+
switch(Smp->DataSize)
27+
{
28+
case sizeof(tS8) : pS8 = (tS8 *) Smp->Buf; pS8[Idx] = Data; break;
29+
case sizeof(tS16) : pS16 = (tS16 *) Smp->Buf; pS16[Idx] = Data; break;
30+
case sizeof(tS32) : pS32 = (tS32 *) Smp->Buf; pS32[Idx] = Data; break;
31+
}
3232
}
3333
/*********************************************************************************/
3434
inline static tS32 OutFromBuf(tag_DataSampling *Smp, tU8 Idx)
3535
{
36-
switch(Smp->DataSize)
37-
{
38-
case sizeof(tS8) : pS8 = (tS8 *) Smp->Buf; Ret = pS8[Idx]; break;
39-
case sizeof(tS16) : pS16 = (tS16 *) Smp->Buf; Ret = pS16[Idx]; break;
40-
case sizeof(tS32) : pS32 = (tS32 *) Smp->Buf; Ret = pS32[Idx]; break;
41-
}
42-
43-
return Ret;
36+
switch(Smp->DataSize)
37+
{
38+
case sizeof(tS8) : pS8 = (tS8 *) Smp->Buf; Ret = pS8[Idx]; break;
39+
case sizeof(tS16) : pS16 = (tS16 *) Smp->Buf; Ret = pS16[Idx]; break;
40+
case sizeof(tS32) : pS32 = (tS32 *) Smp->Buf; Ret = pS32[Idx]; break;
41+
}
42+
43+
return Ret;
4444
}
4545
/*********************************************************************************/
4646
/*
47-
1) 인수
48-
- Smp : tag_DataSampling 인스턴스의 주소.
49-
- Data : 버퍼를 채울 데이터.
47+
1) 인수
48+
- Smp : tag_DataSampling 인스턴스의 주소.
49+
- Data : 버퍼를 채울 데이터.
5050
51-
2) 반환
52-
- 없음.
51+
2) 반환
52+
- 없음.
5353
54-
3) 설명
55-
- 인수로 전달받은 데이터로 버퍼를 채움.
54+
3) 설명
55+
- 인수로 전달받은 데이터로 버퍼를 채움.
5656
*/
5757
static void FillBuffer(tag_DataSampling *Smp, tS32 Data)
5858
{
59-
tS16 i;
60-
61-
Smp->Sum = Smp->Index = 0;
62-
for(i = 0; i < Smp->Level; i++)
63-
{
64-
InToBuf(Smp, i, Data);
65-
Smp->Sum += Data;
66-
}
59+
tS16 i;
60+
61+
Smp->Sum = Smp->Index = 0;
62+
for(i = 0; i < Smp->Level; i++)
63+
{
64+
InToBuf(Smp, i, Data);
65+
Smp->Sum += Data;
66+
}
6767
}
6868
/*********************************************************************************/
6969
/*
70-
1) 인수
71-
- Smp : tag_DataSampling 인스턴스의 주소.
72-
- BufSize : 동적할당 받을 버퍼의 크기.
70+
1) 인수
71+
- Smp : tag_DataSampling 인스턴스의 주소.
72+
- BufSize : 동적할당 받을 버퍼의 크기.
7373
74-
2) 반환
75-
- 0 : 초기화 실패.
76-
- 1 : 초기화 성공.
74+
2) 반환
75+
- 0 : 초기화 실패.
76+
- 1 : 초기화 성공.
7777
78-
3) 설명
79-
- 'tag_DataSampling' 인스턴스의 필수 초기화 실행.
80-
- DataSampling 모듈을 사용하기 위해 선행적 실행 필요.
78+
3) 설명
79+
- 'tag_DataSampling' 인스턴스의 필수 초기화 실행.
80+
- DataSampling 모듈을 사용하기 위해 선행적 실행 필요.
8181
*/
8282
tU8 DataSamplingInitGeneral(tag_DataSampling *Smp, tS16 BufSize, tS8 DataSize)
8383
{
84-
if(Smp->Bit.InitGeneral == true)
85-
{
86-
return true;
87-
}
88-
89-
if((DataSize != sizeof(tS8)) && (DataSize != sizeof(tS16)) && (DataSize != sizeof(tS32)))
90-
{
91-
return false;
92-
}
93-
94-
Smp->DataSize = DataSize;
95-
96-
Smp->Buf = malloc(Smp->DataSize * BufSize);
97-
98-
if(Smp->Buf != null)
99-
{
100-
Smp->Level = Smp->BufSize = BufSize;
101-
Smp->Sum = Smp->Index = 0;
102-
Smp->Bit.InitGeneral = true;
103-
}
104-
105-
return Smp->Bit.InitGeneral;
84+
if(Smp->Bit.InitGeneral == true)
85+
{
86+
return true;
87+
}
88+
89+
if((DataSize != sizeof(tS8)) && (DataSize != sizeof(tS16)) && (DataSize != sizeof(tS32)))
90+
{
91+
return false;
92+
}
93+
94+
Smp->DataSize = DataSize;
95+
96+
Smp->Buf = malloc(Smp->DataSize * BufSize);
97+
98+
if(Smp->Buf != null)
99+
{
100+
Smp->Level = Smp->BufSize = BufSize;
101+
Smp->Sum = Smp->Index = 0;
102+
Smp->Bit.InitGeneral = true;
103+
}
104+
105+
return Smp->Bit.InitGeneral;
106106
}
107107
/*********************************************************************************/
108108
/*
109-
1) 인수
110-
- Smp : tag_DataSampling 인스턴스의 주소.
111-
- Level : 변경할 샘플링 수준.
109+
1) 인수
110+
- Smp : tag_DataSampling 인스턴스의 주소.
111+
- Level : 변경할 샘플링 수준.
112112
113-
2) 반환
114-
- 없음.
113+
2) 반환
114+
- 없음.
115115
116-
3) 설명
117-
- 샘플링 수준(Level) 변경.
116+
3) 설명
117+
- 샘플링 수준(Level) 변경.
118118
*/
119119
void DataSamplingChangeLevel(tag_DataSampling *Smp, tS16 Level)
120120
{
121-
if((Smp->Bit.InitGeneral == false) || (Smp->Bit.InitFillBuffer == false))
122-
{
123-
return;
124-
}
125-
126-
if((Smp->Level != Level) && (1 <= Level) && (Level <= Smp->Level))
127-
{
128-
Smp->Level = Level;
129-
FillBuffer(Smp, OutFromBuf(Smp, 0));
130-
}
121+
if((Smp->Bit.InitGeneral == false) || (Smp->Bit.InitFillBuffer == false))
122+
{
123+
return;
124+
}
125+
126+
if((Smp->Level != Level) && (1 <= Level) && (Level <= Smp->Level))
127+
{
128+
Smp->Level = Level;
129+
FillBuffer(Smp, OutFromBuf(Smp, 0));
130+
}
131131
}
132132
/*********************************************************************************/
133133
/*
134-
1) 인수
135-
- Smp : tag_DataSampling 인스턴스의 주소.
136-
- Data : 데이터.
134+
1) 인수
135+
- Smp : tag_DataSampling 인스턴스의 주소.
136+
- Data : 데이터.
137137
138-
2) 반환
139-
- Result : 샘플링된 데이터.
138+
2) 반환
139+
- Result : 샘플링된 데이터.
140140
141-
3) 설명
142-
- ring buffer 형식으로 데이터를 입력 받아 평균을 내어 샘플링.
141+
3) 설명
142+
- ring buffer 형식으로 데이터를 입력 받아 평균을 내어 샘플링.
143143
*/
144144
tS32 DataSamplingGetData(tag_DataSampling *Smp, tS32 Data)
145145
{
146-
tS32 Result;
146+
tS32 Result;
147147

148-
if(Smp->Bit.InitGeneral == false)
149-
{
150-
return 0;
151-
}
148+
if(Smp->Bit.InitGeneral == false)
149+
{
150+
return 0;
151+
}
152152

153-
if(Smp->Bit.InitFillBuffer == false)
154-
{
155-
Smp->Bit.InitFillBuffer = true;
156-
FillBuffer(Smp, Data);
157-
}
153+
if(Smp->Bit.InitFillBuffer == false)
154+
{
155+
Smp->Bit.InitFillBuffer = true;
156+
FillBuffer(Smp, Data);
157+
}
158158

159-
Smp->Sum -= OutFromBuf(Smp, Smp->Index);
160-
InToBuf(Smp, Smp->Index, Data);
161-
Smp->Sum += OutFromBuf(Smp, Smp->Index);
162-
Result = Smp->Sum / Smp->Level;
159+
Smp->Sum -= OutFromBuf(Smp, Smp->Index);
160+
InToBuf(Smp, Smp->Index, Data);
161+
Smp->Sum += OutFromBuf(Smp, Smp->Index);
162+
Result = Smp->Sum / Smp->Level;
163163

164-
if(++(Smp->Index) >= Smp->Level) Smp->Index = 0;
164+
if(++(Smp->Index) >= Smp->Level) Smp->Index = 0;
165165

166-
return Result;
166+
return Result;
167167
}
168168
/*********************************************************************************/
169169
/*
170-
1) 인수
171-
- Smp : tag_DataSampling 인스턴스의 주소.
170+
1) 인수
171+
- Smp : tag_DataSampling 인스턴스의 주소.
172172
173-
2) 반환
174-
- 없음.
173+
2) 반환
174+
- 없음.
175175
176-
3) 설명
177-
- 버퍼 초기화 실행.
176+
3) 설명
177+
- 버퍼 초기화 실행.
178178
*/
179179
void DataSamplingResetData(tag_DataSampling *Smp)
180180
{
181-
if((Smp->Bit.InitGeneral == false) || (Smp->Bit.InitFillBuffer == false))
182-
{
183-
return;
184-
}
181+
if((Smp->Bit.InitGeneral == false) || (Smp->Bit.InitFillBuffer == false))
182+
{
183+
return;
184+
}
185185

186-
Smp->Bit.InitFillBuffer = false;
186+
Smp->Bit.InitFillBuffer = false;
187187
}
188188
/*********************************************************************************/

DataSampling.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,35 @@
55
*/
66
/*********************************************************************************/
77
#ifndef __DATA_SAMPLING_H__
8-
#define __DATA_SAMPLING_H__
8+
#define __DATA_SAMPLING_H__
99
/*********************************************************************************/
1010
#include "SysTypedef.h"
1111
/*********************************************************************************/
12-
#define DATA_SAMPLING_REVISION_DATE 20200724
12+
#define DATA_SAMPLING_REVISION_DATE 20200724
1313
/*********************************************************************************/
1414
/** REVISION HISTORY **/
1515
/*
16-
2020. 07. 24. - 이제 샘플링 데이터의 자료형을 tS8, tS16, tS32 중 선택할 수 있음.
17-
Jeong Hyun Gu
16+
2020. 07. 24. - 이제 샘플링 데이터의 자료형을 tS8, tS16, tS32 중 선택할 수 있음.
17+
Jeong Hyun Gu
1818
19-
2020. 04. 16. - DataSamplingResetData()에서 FillBuffer()호출 부분 삭제.
20-
Jeong Hyun Gu
19+
2020. 04. 16. - DataSamplingResetData()에서 FillBuffer()호출 부분 삭제.
20+
Jeong Hyun Gu
2121
22-
2019. 07. 23. - SysTypedef.h 적용.
23-
Jeong Hyun Gu
22+
2019. 07. 23. - SysTypedef.h 적용.
23+
Jeong Hyun Gu
2424
25-
2018. 04. 03. - DataSamplingResetData() 함수 추가.
26-
Jeong Hyun Gu
25+
2018. 04. 03. - DataSamplingResetData() 함수 추가.
26+
Jeong Hyun Gu
2727
28-
2017. 10. 17. - 초기버전.
29-
Jeong Hyun Gu
28+
2017. 10. 17. - 초기버전.
29+
Jeong Hyun Gu
3030
*/
3131
/*********************************************************************************/
3232
/**Define**/
3333

34-
#define false 0
35-
#define true 1
36-
#define null 0
34+
#define false 0
35+
#define true 1
36+
#define null 0
3737

3838
/*********************************************************************************/
3939
/**Enum**/
@@ -44,16 +44,16 @@
4444

4545
typedef struct
4646
{
47-
struct
48-
{
49-
tU8 InitGeneral : 1; //필수초기화
50-
tU8 InitFillBuffer : 1; //버퍼초기화
51-
}Bit;
47+
struct
48+
{
49+
tU8 InitGeneral : 1; //필수초기화
50+
tU8 InitFillBuffer : 1; //버퍼초기화
51+
}Bit;
5252

53-
void *Buf;
54-
tS16 Index, BufSize, Level;
55-
tS32 Sum;
56-
tS8 DataSize;
53+
void *Buf;
54+
tS16 Index, BufSize, Level;
55+
tS32 Sum;
56+
tS8 DataSize;
5757
}tag_DataSampling;
5858

5959
/*********************************************************************************/

SysTypedef.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
/*********************************************************************************/
1010
/**Define**/
1111

12-
typedef unsigned char tU8;
13-
typedef signed char tS8;
12+
typedef unsigned char tU8;
13+
typedef signed char tS8;
1414

15-
typedef unsigned int tU16;
16-
typedef signed int tS16;
15+
typedef unsigned int tU16;
16+
typedef signed int tS16;
1717

18-
typedef unsigned long tU32;
19-
typedef signed long tS32;
18+
typedef unsigned long tU32;
19+
typedef signed long tS32;
2020

2121
/*********************************************************************************/
2222
/**Enum**/

0 commit comments

Comments
 (0)