aboutsummaryrefslogtreecommitdiff
path: root/src/sample/io_sample/IR/SendCode/encode/ir_encode.h
blob: 8da1f1e415c0092e623876ca199454ba849cc981 (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
/**
*********************************************************************************************************
*               Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
*********************************************************************************************************
* @file      ir_encode.h
* @brief    This file provides driver of IR protocol encoding.
* @details
* @author    elliot chen
* @date      2017-09-19
* @version   v1.0
* *********************************************************************************************************
*/

#ifndef __IR_ENCODE_H
#define __IR_ENCODE_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "ir_protocol_config.h"

/* Defines ------------------------------------------------------------------*/

/**
  * @brief  Configure maximum length of header of IR protocol
  */

#define IR_MAX_HEADDER_LEN              6

/**
  * @brief  Configure maximum data length of logical 0 and logical 1
  */

#define IR_MAX_LOG_WAVFORM_SIZE         2

/**
  * @brief  IR coding order type definition.
  */

typedef enum
{
    IR_CODING_LSB_FIRST,
    IR_CODING_MSB_FIRST
} IR_CODING_ORDER;

/**
  * @brief  IR coding order type definition.
  */

typedef enum
{
    CARRIER_UNIT,
    TIME_UNIT
} IR_DATA_TYPE;

/**
  * @brief  IR protocol structure definition
  */
typedef struct
{
    uint16_t        carrierFreq;
    IR_CODING_ORDER coding_order;
    IR_DATA_TYPE    unit;
    uint8_t         headerLen;
    IR_DataType     headerBuf[IR_MAX_HEADDER_LEN];
    IR_DataType     log0Buf[IR_MAX_LOG_WAVFORM_SIZE];
    IR_DataType     log1Buf[IR_MAX_LOG_WAVFORM_SIZE];
    IR_DataType     stopBuf;
} IR_ProtocolTypeDef;

/**
  * @brief  IR protocol structure definition  which store IR repeat code.
  */

typedef struct
{
    IR_DATA_TYPE    unit;
    uint8_t     RepeatCodeLen;
    IR_DataType RepeatCodeBuf[IR_REPEAT_CODE_MAX_LEN];
} IR_RepeatCodeTypeDef;

/* Exported functions --------------------------------------------------------*/
IR_Return_Type IR_Encode(IR_DataTypeDef *IR_DataStruct, IR_ProtocolTypeDef *IR_Protocol,
                         bool in_order);
IR_Return_Type IR_RepeatCodeEncode(IR_DataTypeDef *IR_DataStruct,
                                   IR_RepeatCodeTypeDef *IR_Protocol);
IR_DataType ConvertToCarrierCycle(uint32_t time, uint32_t freq, IR_DATA_TYPE data_type);

#ifdef __cplusplus
}
#endif

#endif /*__IR_ENCODE_H*/

/******************* (C) COPYRIGHT 2017 Realtek Semiconductor Corporation *****END OF FILE****/