updated decode algorithms from CC26XX example

This commit is contained in:
strawmanbobi
2018-10-21 20:16:02 +08:00
parent e8df3fa50c
commit 9907252733
8 changed files with 60 additions and 19 deletions

View File

@@ -357,7 +357,7 @@ typedef struct tag_head
{
UINT16 tag;
UINT16 len;
unsigned short offset;
UINT16 offset;
UINT8 *p_data;
} t_tag_head;

View File

@@ -29,6 +29,10 @@ extern "C"
#define TRUE 1
#define FALSE 0
#define FORMAT_HEX 16
#define FORMAT_DECIMAL 10
typedef unsigned char UINT8;
typedef signed char INT8;
typedef unsigned short UINT16;
@@ -39,12 +43,12 @@ typedef int BOOL;
void noprint(const char *fmt, ...);
#if !defined BOARD_CC26XX
#define ir_malloc(A) malloc(A)
#define ir_free(A) free(A)
#else
#if defined BOARD_CC26XX
#define ir_malloc(A) ICall_malloc(A)
#define ir_free(A) ICall_free(A)
#else
#define ir_malloc(A) malloc(A)
#define ir_free(A) free(A)
#endif
#define ir_memcpy(A, B, C) memcpy(A, B, C)

View File

@@ -73,7 +73,7 @@ typedef struct ir_data
UINT8 index;
} t_ir_data;
#if !defined BOARD_51
#if !defined BOARD_51 && !defined BOARD_STM8
#pragma pack(1)
#endif
typedef struct ir_cycles
@@ -83,7 +83,7 @@ typedef struct ir_cycles
UINT16 space;
} t_ir_cycles;
#if !defined BOARD_51
#if !defined BOARD_51 && !defined BOARD_STM8
#pragma pack()
#endif

View File

@@ -9,15 +9,18 @@ Revision log:
* 2017-01-03: created by strawmanbobi
**************************************************************************************/
#include <stdlib.h>
#include "../include/ir_ac_binary_parse.h"
#include "../include/ir_decode.h"
UINT16 tag_head_offset = 0;
extern struct ir_bin_buffer *p_ir_buffer;
#if defined USE_DYNAMIC_TAG
extern struct tag_head* tags;
#else
extern struct tag_head tags[];
#endif
UINT8 tag_count = 0;
const UINT16 tag_index[TAG_COUNT_FOR_PROTOCOL] =
@@ -30,7 +33,11 @@ const UINT16 tag_index[TAG_COUNT_FOR_PROTOCOL] =
INT8 binary_parse_offset()
{
int i = 0;
#if defined BOARD_ESP8266
UINT8 *phead = (UINT8 *)&p_ir_buffer->data[1];
#else
UINT16 *phead = (UINT16 *)&p_ir_buffer->data[1];
#endif // BOARD_ESP8266
tag_count = p_ir_buffer->data[0];
if (TAG_COUNT_FOR_PROTOCOL != tag_count)
@@ -40,16 +47,29 @@ INT8 binary_parse_offset()
tag_head_offset = (UINT16) ((tag_count << 1) + 1);
#if defined USE_DYNAMIC_TAG
tags = (t_tag_head *) ir_malloc(tag_count * sizeof(t_tag_head));
if (NULL == tags)
{
return IR_DECODE_FAILED;
}
#endif
for (i = 0; i < tag_count; i++)
{
tags[i].tag = tag_index[i];
#if defined BOARD_STM8 && defined COMPILER_IAR
UINT16 offset = *(phead + i);
tags[i].offset = (offset >> 8) | (offset << 8);
#elif defined BOARD_ESP8266
UINT16 tmp_a = *(phead + i * 2);
UINT16 tmp_b = *(phead + i * 2 + 1);
tags[i].offset = tmp_b << 8 | tmp_a;
#else
tags[i].offset = *(phead + i);
#endif
if (tags[i].offset == TAG_INVALID)
{
@@ -96,7 +116,7 @@ INT8 binary_parse_len()
void binary_tags_info()
{
#if defined BOARD_PC
#if defined BOARD_PC && defined DEBUG
UINT16 i = 0;
for (i = 0; i < tag_count; i++)
{

View File

@@ -22,7 +22,12 @@ Revision log:
#include "../include/ir_utils.h"
#if defined USE_DYNAMIC_TAG
extern struct tag_head *tags;
#else
extern struct tag_head tags[];
#endif
extern UINT8 tag_count;
static INT8 ir_context_init();
@@ -88,6 +93,7 @@ INT8 ir_ac_lib_parse()
context->si.mode_count = 2;
}
context->si.dir_index = 0;
break;
}
}
@@ -359,11 +365,13 @@ INT8 ir_ac_lib_parse()
}
}
#if defined USE_DYNAMIC_TAG
if (NULL != tags)
{
ir_free(tags);
tags = NULL;
}
#endif
ir_hex_code = (UINT8 *) ir_malloc(context->default_code.len);
if (NULL == ir_hex_code)

View File

@@ -96,7 +96,6 @@ INT8 parse_common_ac_parameter(t_tag_head *tag, t_tag_comp *comp_data, UINT8 wit
string_to_hex_common(tag->p_data, hex_data, hex_len);
// parse hex data to AC data structure
//*comp_len = hex_len;
if (AC_PARAMETER_TYPE_1 == type)
{

View File

@@ -21,8 +21,12 @@ Revision log:
struct ir_bin_buffer binary_file;
struct ir_bin_buffer *p_ir_buffer = &binary_file;
struct tag_head *tags;
#if defined USE_DYNAMIC_TAG
struct tag_head *tags;
#else
struct tag_head tags[TAG_COUNT_FOR_PROTOCOL];
#endif
UINT8 *ir_hex_code = NULL;
UINT8 ir_hex_len = 0;
@@ -67,7 +71,7 @@ void noprint(const char *fmt, ...)
}
// pubic function definitions
#if (!defined BOARD_51 && !defined BOARD_CC26XX)
INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* file_name)
{
INT8 ret = IR_DECODE_SUCCEEDED;
@@ -111,7 +115,12 @@ INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* fi
}
}
}
#else
INT8 ir_file_open(const UINT8 category, const UINT8 sub_category, const char* file_name)
{
return IR_DECODE_SUCCESS;
}
#endif
INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binary, UINT16 binary_length)
{
@@ -263,7 +272,7 @@ static UINT16 ir_ac_lib_control(t_remote_ac_status ac_status, UINT16 *user_data,
UINT16 time_length = 0;
#if defined BOARD_PC
UINT8 i = 0;
UINT16 i = 0;
#endif
if (0 == context->default_code.len)
@@ -375,12 +384,15 @@ static UINT16 ir_ac_lib_control(t_remote_ac_status ac_status, UINT16 *user_data,
static INT8 ir_ac_lib_close()
{
#if defined USE_DYNAMIC_TAG
// free context
if (NULL != tags)
{
ir_free(tags);
tags = NULL;
}
#endif
free_ac_context();
return IR_DECODE_SUCCEEDED;