]> sigrok.org Git - libsigrokdecode.git/blob - irmp/irmp-main-sharedlib.h
irmp: introduce PC side shared library code for IRMP core logic
[libsigrokdecode.git] / irmp / irmp-main-sharedlib.h
1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2  * irmpharedLib.h
3  *
4  * Copyright (c) 2009-2019 Frank Meyer - frank(at)fli4l.de
5  * Copyright (c) 2009-2019 RenĂ© Staffen - r.staffen(at)gmx.de
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *---------------------------------------------------------------------------------------------------------------------------------------------------
12  */
13
14 #ifndef IRMP_SHARED_H
15 #define IRMP_SHARED_H
16
17 #include <stdint.h>
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 #ifndef IRMP_DLLEXPORT
24
25 #if defined WIN32 && defined _MSC_VER
26 # define IRMP_DLLEXPORT __declspec(dllimport)
27 #else
28 # define IRMP_DLLEXPORT
29 #endif
30 #endif // !IRMP_DLLEXPORT
31
32
33 /**
34  * result data
35  */
36 typedef struct
37
38     uint32_t    protocol;     ///< protocol, e.g. NEC_PROTOCOL
39     const char* protocolName; ///< name of the protocol
40     uint32_t    address;      ///< address
41     uint32_t    command;      ///< command
42     uint32_t    flags;        ///< flags currently only repetition (bit 0)
43     uint32_t    startSample;  ///< the sampleindex there the detected command started
44     uint32_t    endSample;    ///< the sampleindex there the detected command ended
45 }  IRMP_DataExt;
46
47
48 /**
49  * Returns the sample rate for that the irmp library was compiled for.
50  * Any data provided has resamble  this sample rate or detection will fail.
51  */
52 IRMP_DLLEXPORT  uint32_t IRMP_GetSampleRate(void);
53
54 /**
55  * Resets the internal state of the detector 
56  * This has to be called before start processing data.
57  */
58 IRMP_DLLEXPORT  void IRMP_Reset(void);
59
60 /**
61  * Feeds a single sample into the detecor.
62  * Returns 1 if a ir command was detected.
63  * Use IRMP_GetData to retrieve the data.
64  * Make sure, that Reset was called before adding first Sample.
65  */
66 IRMP_DLLEXPORT  uint32_t IRMP_AddSample(const uint8_t i_sample);
67
68
69 /**
70  * Proceses the given buffer and stops on the first found command and returns it data.
71  * Further calls resume the processing at the previously stopped position.
72  * Make sure, that Reset was called before first calling Detect.
73  */
74 IRMP_DLLEXPORT  IRMP_DataExt IRMP_Detect(const uint8_t* i_buff, uint32_t i_len);
75
76
77 /**
78  * If a valid IR frame was detected the provided output structure is filled
79  * \returns 1 if data was available, 0 else
80  */
81 IRMP_DLLEXPORT  uint32_t IRMP_GetData(IRMP_DataExt* o_data);
82
83 /** returns the the name of the given protocol number */
84 IRMP_DLLEXPORT  const char* IRMP_GetProtocolName(uint32_t i_protocol);
85
86
87 #ifdef __cplusplus
88 }
89 #endif
90
91 #endif // IRMP_SHARED_H