Skip to content

Commit 3766dba

Browse files
Merge pull request #3 from TimerOverflow/20190723
20190723
2 parents 5c5ac6d + 784993d commit 3766dba

File tree

3 files changed

+53
-17
lines changed

3 files changed

+53
-17
lines changed

DataSampling.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <stdlib.h>
88
#include "DataSampling.h"
99
/*********************************************************************************/
10-
#if(DATA_SAMPLING_REVISION_DATE != 20180403)
10+
#if(DATA_SAMPLING_REVISION_DATE != 20190723)
1111
#error wrong include file. (DataSampling.h)
1212
#endif
1313
/*********************************************************************************/
@@ -26,9 +26,9 @@
2626
3) 설명
2727
- 인수로 전달받은 데이터로 버퍼를 채움.
2828
*/
29-
static void FillBuffer(tag_DataSampling *Smp, int Data)
29+
static void FillBuffer(tag_DataSampling *Smp, tS16 Data)
3030
{
31-
int i;
31+
tS16 i;
3232

3333
Smp->Sum = Smp->Index = 0;
3434
for(i = 0; i < Smp->Level; i++)
@@ -51,14 +51,14 @@ static void FillBuffer(tag_DataSampling *Smp, int Data)
5151
- 'tag_DataSampling' 인스턴스의 필수 초기화 실행.
5252
- DataSampling 모듈을 사용하기 위해 선행적 실행 필요.
5353
*/
54-
char DataSamplingInitGeneral(tag_DataSampling *Smp, int BufSize)
54+
tU8 DataSamplingInitGeneral(tag_DataSampling *Smp, tS16 BufSize)
5555
{
5656
if(Smp->Bit.InitGeneral == true)
5757
{
5858
return true;
5959
}
6060

61-
Smp->Buf = (int *) malloc(sizeof(int) * BufSize);
61+
Smp->Buf = (tS16 *) malloc(sizeof(tS16) * BufSize);
6262

6363
if(Smp->Buf != null)
6464
{
@@ -81,7 +81,7 @@ char DataSamplingInitGeneral(tag_DataSampling *Smp, int BufSize)
8181
3) 설명
8282
- 샘플링 수준(Level) 변경.
8383
*/
84-
void DataSamplingChangeLevel(tag_DataSampling *Smp, int Level)
84+
void DataSamplingChangeLevel(tag_DataSampling *Smp, tS16 Level)
8585
{
8686
if((Smp->Bit.InitGeneral == false) || (Smp->Bit.InitFillBuffer == false))
8787
{
@@ -106,9 +106,9 @@ void DataSamplingChangeLevel(tag_DataSampling *Smp, int Level)
106106
3) 설명
107107
- ring buffer 형식으로 데이터를 입력 받아 평균을 내어 샘플링.
108108
*/
109-
int DataSamplingGetData(tag_DataSampling *Smp, int Data)
109+
tS16 DataSamplingGetData(tag_DataSampling *Smp, tS16 Data)
110110
{
111-
int Result;
111+
tS16 Result;
112112

113113
if(Smp->Bit.InitGeneral == false)
114114
{

DataSampling.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77
#ifndef __DATA_SAMPLING_H__
88
#define __DATA_SAMPLING_H__
99
/*********************************************************************************/
10-
#define DATA_SAMPLING_REVISION_DATE 20180403
10+
#include "SysTypedef.h"
11+
/*********************************************************************************/
12+
#define DATA_SAMPLING_REVISION_DATE 20190723
1113
/*********************************************************************************/
1214
/** REVISION HISTORY **/
1315
/*
16+
2019. 07. 23. - SysTypedef.h 적용.
17+
Jeong Hyun Gu
18+
1419
2018. 04. 03. - DataSamplingResetData() 함수 추가.
1520
Jeong Hyun Gu
1621
@@ -35,21 +40,21 @@ typedef struct
3540
{
3641
struct
3742
{
38-
char InitGeneral : 1; //필수초기화
39-
char InitFillBuffer : 1; //버퍼초기화
43+
tU8 InitGeneral : 1; //필수초기화
44+
tU8 InitFillBuffer : 1; //버퍼초기화
4045
}Bit;
4146

42-
int *Buf;
43-
int Index, BufSize, Level;
44-
long Sum;
47+
tS16 *Buf;
48+
tS16 Index, BufSize, Level;
49+
tS32 Sum;
4550
}tag_DataSampling;
4651

4752
/*********************************************************************************/
4853
/**Function**/
4954

50-
char DataSamplingInitGeneral(tag_DataSampling *Smp, int BufSize);
51-
void DataSamplingChangeLevel(tag_DataSampling *Smp, int Level);
52-
int DataSamplingGetData(tag_DataSampling *Smp, int Data);
55+
tU8 DataSamplingInitGeneral(tag_DataSampling *Smp, tS16 BufSize);
56+
void DataSamplingChangeLevel(tag_DataSampling *Smp, tS16 Level);
57+
tS16 DataSamplingGetData(tag_DataSampling *Smp, tS16 Data);
5358
void DataSamplingResetData(tag_DataSampling *Smp);
5459

5560
/*********************************************************************************/

SysTypedef.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*********************************************************************************/
2+
/*
3+
* Author : Jeong Hyun Gu
4+
* File name : SysTypedef.h
5+
*/
6+
/*********************************************************************************/
7+
#ifndef __SYS_TYPEDEF_H__
8+
#define __SYS_TYPEDEF_H__
9+
/*********************************************************************************/
10+
/**Define**/
11+
12+
typedef unsigned char tU8;
13+
typedef signed char tS8;
14+
15+
typedef unsigned int tU16;
16+
typedef signed int tS16;
17+
18+
typedef unsigned long tU32;
19+
typedef signed long tS32;
20+
21+
/*********************************************************************************/
22+
/**Enum**/
23+
24+
/*********************************************************************************/
25+
/**Struct**/
26+
27+
/*********************************************************************************/
28+
/**Function**/
29+
30+
/*********************************************************************************/
31+
#endif //__SYS_TYPEDEF_H__

0 commit comments

Comments
 (0)