diff --git a/src/ir_decoder/include/ir_ac_apply.h b/src/ir_decoder/include/ir_ac_apply.h index 0e8b5a4..a9dc4d2 100644 --- a/src/ir_decoder/include/ir_ac_apply.h +++ b/src/ir_decoder/include/ir_ac_apply.h @@ -19,6 +19,9 @@ extern "C" #include "ir_decode.h" +#define MIN_TAG_LENGTH_TYPE_1 4 +#define MIN_TAG_LENGTH_TYPE_2 6 + INT8 apply_power(t_remote_ac_status ac_status, UINT8 function_code); INT8 apply_mode(t_remote_ac_status ac_status, UINT8 function_code); diff --git a/src/ir_decoder/include/ir_ac_control.h b/src/ir_decoder/include/ir_ac_control.h index 6eeee04..1ce4882 100644 --- a/src/ir_decoder/include/ir_ac_control.h +++ b/src/ir_decoder/include/ir_ac_control.h @@ -357,7 +357,7 @@ typedef struct tag_head { UINT16 tag; UINT16 len; - unsigned short offset; + UINT16 offset; UINT8 *p_data; } t_tag_head; diff --git a/src/ir_decoder/include/ir_defs.h b/src/ir_decoder/include/ir_defs.h index 7b60e53..b16e660 100644 --- a/src/ir_decoder/include/ir_defs.h +++ b/src/ir_decoder/include/ir_defs.h @@ -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) diff --git a/src/ir_decoder/include/ir_tv_control.h b/src/ir_decoder/include/ir_tv_control.h index 9e86741..50dfaf4 100644 --- a/src/ir_decoder/include/ir_tv_control.h +++ b/src/ir_decoder/include/ir_tv_control.h @@ -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 diff --git a/src/ir_decoder/include/ir_utils.h b/src/ir_decoder/include/ir_utils.h index 33871a3..667bdf1 100644 --- a/src/ir_decoder/include/ir_utils.h +++ b/src/ir_decoder/include/ir_utils.h @@ -28,6 +28,8 @@ extern void string_to_hex_common(UINT8 *p, UINT8 *hex_data, UINT16 len); extern BOOL is_in(const UINT8 *array, UINT8 value, UINT8 len); +extern void hex_byte_to_double_char(char *dest, UINT8 length, UINT8 src); + #ifdef __cplusplus } #endif diff --git a/src/ir_decoder/src/ir_ac_binary_parse.c b/src/ir_decoder/src/ir_ac_binary_parse.c index 747a8b8..3765810 100644 --- a/src/ir_decoder/src/ir_ac_binary_parse.c +++ b/src/ir_decoder/src/ir_ac_binary_parse.c @@ -49,7 +49,13 @@ INT8 binary_parse_offset() 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); +#else tags[i].offset = *(phead + i); +#endif if (tags[i].offset == TAG_INVALID) { @@ -96,7 +102,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++) { diff --git a/src/ir_decoder/src/ir_ac_control.c b/src/ir_decoder/src/ir_ac_control.c index 2bd8219..aebc888 100644 --- a/src/ir_decoder/src/ir_ac_control.c +++ b/src/ir_decoder/src/ir_ac_control.c @@ -87,6 +87,7 @@ INT8 ir_ac_lib_parse() context->si.type = SWING_TYPE_NORMAL; context->si.mode_count = 2; } + break; context->si.dir_index = 0; } } diff --git a/src/ir_decoder/src/ir_ac_parse_parameter.c b/src/ir_decoder/src/ir_ac_parse_parameter.c index 70137bd..e5c8cea 100644 --- a/src/ir_decoder/src/ir_ac_parse_parameter.c +++ b/src/ir_decoder/src/ir_ac_parse_parameter.c @@ -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) { @@ -138,14 +137,11 @@ INT8 parse_common_ac_parameter(t_tag_head *tag, t_tag_comp *comp_data, UINT8 wit INT8 parse_default_code(struct tag_head *tag, t_ac_hex *default_code) { - UINT16 byteLen = 0; - if (NULL == tag) { return IR_DECODE_FAILED; } - byteLen = tag->len >> 1; string_to_hex(tag->p_data, default_code); return IR_DECODE_SUCCEEDED; diff --git a/src/ir_decoder/src/ir_tv_control.c b/src/ir_decoder/src/ir_tv_control.c index f2dbde2..78cb9b9 100644 --- a/src/ir_decoder/src/ir_tv_control.c +++ b/src/ir_decoder/src/ir_tv_control.c @@ -13,6 +13,8 @@ Revision log: #include "../include/ir_defs.h" #include "../include/ir_decode.h" +#include "../include/ir_tv_control.h" + struct buffer { diff --git a/src/ir_decoder/src/ir_utils.c b/src/ir_decoder/src/ir_utils.c index e1a972a..6867df7 100644 --- a/src/ir_decoder/src/ir_utils.c +++ b/src/ir_decoder/src/ir_utils.c @@ -53,6 +53,37 @@ void string_to_hex(UINT8 *p, t_ac_hex *pac_hex) } } +char hex_half_byte_to_single_char(UINT8 length, UINT8 half_byte) +{ + if (1 != length || half_byte >= 16) + { + return '0'; + } + if (half_byte >= 10 && half_byte < 16) + { + return (char) (half_byte - 10 + 0x41); + } + else + { + return (char) (half_byte + 0x30); + } +} + +void hex_byte_to_double_char(char *dest, UINT8 length, UINT8 src) +{ + UINT8 hi_num = 0; + UINT8 lo_num = 0; + if (NULL == dest || 2 != length) + { + return; + } + hi_num = (UINT8) ((src >> 4) & 0x0F); + lo_num = (UINT8) (src & 0x0F); + + dest[0] = hex_half_byte_to_single_char(1, hi_num); + dest[1] = hex_half_byte_to_single_char(1, lo_num); +} + BOOL is_in(const UINT8 *array, UINT8 value, UINT8 len) { UINT16 i = 0;