added support for STM8
This commit is contained in:
@@ -19,6 +19,9 @@ extern "C"
|
|||||||
|
|
||||||
#include "ir_decode.h"
|
#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_power(t_remote_ac_status ac_status, UINT8 function_code);
|
||||||
|
|
||||||
INT8 apply_mode(t_remote_ac_status ac_status, UINT8 function_code);
|
INT8 apply_mode(t_remote_ac_status ac_status, UINT8 function_code);
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ typedef struct tag_head
|
|||||||
{
|
{
|
||||||
UINT16 tag;
|
UINT16 tag;
|
||||||
UINT16 len;
|
UINT16 len;
|
||||||
unsigned short offset;
|
UINT16 offset;
|
||||||
UINT8 *p_data;
|
UINT8 *p_data;
|
||||||
} t_tag_head;
|
} t_tag_head;
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ extern "C"
|
|||||||
#define TRUE 1
|
#define TRUE 1
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
|
|
||||||
|
#define FORMAT_HEX 16
|
||||||
|
#define FORMAT_DECIMAL 10
|
||||||
|
|
||||||
|
|
||||||
typedef unsigned char UINT8;
|
typedef unsigned char UINT8;
|
||||||
typedef signed char INT8;
|
typedef signed char INT8;
|
||||||
typedef unsigned short UINT16;
|
typedef unsigned short UINT16;
|
||||||
@@ -39,12 +43,12 @@ typedef int BOOL;
|
|||||||
|
|
||||||
void noprint(const char *fmt, ...);
|
void noprint(const char *fmt, ...);
|
||||||
|
|
||||||
#if !defined BOARD_CC26XX
|
#if defined BOARD_CC26XX
|
||||||
#define ir_malloc(A) malloc(A)
|
|
||||||
#define ir_free(A) free(A)
|
|
||||||
#else
|
|
||||||
#define ir_malloc(A) ICall_malloc(A)
|
#define ir_malloc(A) ICall_malloc(A)
|
||||||
#define ir_free(A) ICall_free(A)
|
#define ir_free(A) ICall_free(A)
|
||||||
|
#else
|
||||||
|
#define ir_malloc(A) malloc(A)
|
||||||
|
#define ir_free(A) free(A)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ir_memcpy(A, B, C) memcpy(A, B, C)
|
#define ir_memcpy(A, B, C) memcpy(A, B, C)
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ typedef struct ir_data
|
|||||||
UINT8 index;
|
UINT8 index;
|
||||||
} t_ir_data;
|
} t_ir_data;
|
||||||
|
|
||||||
#if !defined BOARD_51
|
#if !defined BOARD_51 && !defined BOARD_STM8
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
#endif
|
#endif
|
||||||
typedef struct ir_cycles
|
typedef struct ir_cycles
|
||||||
@@ -83,7 +83,7 @@ typedef struct ir_cycles
|
|||||||
UINT16 space;
|
UINT16 space;
|
||||||
} t_ir_cycles;
|
} t_ir_cycles;
|
||||||
|
|
||||||
#if !defined BOARD_51
|
#if !defined BOARD_51 && !defined BOARD_STM8
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -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 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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -49,7 +49,13 @@ INT8 binary_parse_offset()
|
|||||||
for (i = 0; i < tag_count; i++)
|
for (i = 0; i < tag_count; i++)
|
||||||
{
|
{
|
||||||
tags[i].tag = tag_index[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);
|
tags[i].offset = *(phead + i);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (tags[i].offset == TAG_INVALID)
|
if (tags[i].offset == TAG_INVALID)
|
||||||
{
|
{
|
||||||
@@ -96,7 +102,7 @@ INT8 binary_parse_len()
|
|||||||
|
|
||||||
void binary_tags_info()
|
void binary_tags_info()
|
||||||
{
|
{
|
||||||
#if defined BOARD_PC
|
#if defined BOARD_PC && defined DEBUG
|
||||||
UINT16 i = 0;
|
UINT16 i = 0;
|
||||||
for (i = 0; i < tag_count; i++)
|
for (i = 0; i < tag_count; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ INT8 ir_ac_lib_parse()
|
|||||||
context->si.type = SWING_TYPE_NORMAL;
|
context->si.type = SWING_TYPE_NORMAL;
|
||||||
context->si.mode_count = 2;
|
context->si.mode_count = 2;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
context->si.dir_index = 0;
|
context->si.dir_index = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
string_to_hex_common(tag->p_data, hex_data, hex_len);
|
||||||
|
|
||||||
// parse hex data to AC data structure
|
// parse hex data to AC data structure
|
||||||
//*comp_len = hex_len;
|
|
||||||
|
|
||||||
if (AC_PARAMETER_TYPE_1 == type)
|
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)
|
INT8 parse_default_code(struct tag_head *tag, t_ac_hex *default_code)
|
||||||
{
|
{
|
||||||
UINT16 byteLen = 0;
|
|
||||||
|
|
||||||
if (NULL == tag)
|
if (NULL == tag)
|
||||||
{
|
{
|
||||||
return IR_DECODE_FAILED;
|
return IR_DECODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
byteLen = tag->len >> 1;
|
|
||||||
string_to_hex(tag->p_data, default_code);
|
string_to_hex(tag->p_data, default_code);
|
||||||
|
|
||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ Revision log:
|
|||||||
|
|
||||||
#include "../include/ir_defs.h"
|
#include "../include/ir_defs.h"
|
||||||
#include "../include/ir_decode.h"
|
#include "../include/ir_decode.h"
|
||||||
|
#include "../include/ir_tv_control.h"
|
||||||
|
|
||||||
|
|
||||||
struct buffer
|
struct buffer
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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)
|
BOOL is_in(const UINT8 *array, UINT8 value, UINT8 len)
|
||||||
{
|
{
|
||||||
UINT16 i = 0;
|
UINT16 i = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user