diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_apply.h b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_apply.h index 4c3db32..a9dc4d2 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_apply.h +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_apply.h @@ -22,15 +22,15 @@ extern "C" #define MIN_TAG_LENGTH_TYPE_1 4 #define MIN_TAG_LENGTH_TYPE_2 6 -INT8 apply_power(remote_ac_status_t ac_status, UINT8 function_code); +INT8 apply_power(t_remote_ac_status ac_status, UINT8 function_code); -INT8 apply_mode(remote_ac_status_t ac_status, UINT8 function_code); +INT8 apply_mode(t_remote_ac_status ac_status, UINT8 function_code); -INT8 apply_wind_speed(remote_ac_status_t ac_status, UINT8 function_code); +INT8 apply_wind_speed(t_remote_ac_status ac_status, UINT8 function_code); -INT8 apply_swing(remote_ac_status_t ac_status, UINT8 function_code); +INT8 apply_swing(t_remote_ac_status ac_status, UINT8 function_code); -INT8 apply_temperature(remote_ac_status_t ac_status, UINT8 function_code); +INT8 apply_temperature(t_remote_ac_status ac_status, UINT8 function_code); INT8 apply_function(struct ac_protocol *protocol, UINT8 function); diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_control.h b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_control.h index 6d297c0..6eeee04 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_control.h +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_control.h @@ -19,22 +19,22 @@ extern "C" #include "ir_defs.h" -#define TAG_COUNT_FOR_PROTOCOL 29 +#define TAG_COUNT_FOR_PROTOCOL 29 -#define TAG_INVALID 0xffff +#define TAG_INVALID 0xffff -#define MAX_DELAYCODE_NUM 16 -#define MAX_BITNUM 16 +#define MAX_DELAYCODE_NUM 16 +#define MAX_BITNUM 16 -#define AC_PARAMETER_TYPE_1 0 -#define AC_PARAMETER_TYPE_2 1 +#define AC_PARAMETER_TYPE_1 0 +#define AC_PARAMETER_TYPE_2 1 typedef enum { AC_POWER_ON = 0, AC_POWER_OFF, AC_POWER_MAX -} ac_power; +} t_ac_power; typedef enum { @@ -54,7 +54,7 @@ typedef enum AC_TEMP_29, AC_TEMP_30, AC_TEMP_MAX -} ac_temperature; +} t_ac_temperature; typedef enum { @@ -64,7 +64,7 @@ typedef enum AC_MODE_FAN, AC_MODE_DRY, AC_MODE_MAX -} ac_mode; +} t_ac_mode; typedef enum { @@ -76,7 +76,7 @@ typedef enum AC_FUNCTION_WIND_SWING, AC_FUNCTION_WIND_FIX, AC_FUNCTION_MAX, -} ac_function; +} t_ac_function; typedef enum { @@ -85,14 +85,14 @@ typedef enum AC_WS_MEDIUM, AC_WS_HIGH, AC_WS_MAX -} ac_wind_speed; +} t_ac_wind_speed; typedef enum { AC_SWING_ON = 0, AC_SWING_OFF, AC_SWING_MAX -} ac_swing; +} t_ac_swing; typedef enum { @@ -107,7 +107,7 @@ typedef enum TEMP_TYPE_DYNAMIC = 0, TEMP_TYPE_STATIC, TEMP_TYPE_MAX, -} temp_type; +} t_temp_type; // enumeration for application polymorphism typedef enum @@ -120,32 +120,32 @@ typedef enum AC_APPLY_WIND_SWING, AC_APPLY_WIND_FIX, AC_APPLY_MAX -} ac_apply; +} t_ac_apply; typedef struct _ac_hex { UINT8 len; UINT8 *data; -} ac_hex; +} t_ac_hex; typedef struct _ac_level { UINT16 low; UINT16 high; -} ac_level; +} t_ac_level; typedef struct _ac_bootcode { UINT16 len; UINT16 data[16]; -} ac_bootcode; +} t_ac_bootcode; typedef struct _ac_delaycode { INT16 pos; UINT16 time[8]; UINT16 time_cnt; -} ac_delaycode; +} t_ac_delaycode; /* * the array of tag_100X application data @@ -157,78 +157,78 @@ typedef struct _tag_comp_type_1 { UINT8 seg_len; UINT8 *segment; -} tag_comp; +} t_tag_comp; typedef struct _tag_swing_info { swing_type type; UINT8 mode_count; UINT8 dir_index; -} swing_info; +} t_swing_info; typedef struct _tag_power_1 { UINT8 len; - tag_comp comp_data[AC_POWER_MAX]; -} power_1; + t_tag_comp comp_data[AC_POWER_MAX]; +} t_power_1; typedef struct _tag_temp_1 { UINT8 len; UINT8 type; - tag_comp comp_data[AC_TEMP_MAX]; -} temp_1; + t_tag_comp comp_data[AC_TEMP_MAX]; +} t_temp_1; typedef struct tag_mode_1 { UINT8 len; - tag_comp comp_data[AC_MODE_MAX]; -} mode_1; + t_tag_comp comp_data[AC_MODE_MAX]; +} t_mode_1; typedef struct tag_speed_1 { UINT8 len; - tag_comp comp_data[AC_WS_MAX]; -} speed_1; + t_tag_comp comp_data[AC_WS_MAX]; +} t_speed_1; typedef struct tag_swing_1 { UINT8 len; UINT16 count; - tag_comp *comp_data; -} swing_1; + t_tag_comp *comp_data; +} t_swing_1; typedef struct tag_temp_2 { UINT8 len; UINT8 type; - tag_comp comp_data[AC_TEMP_MAX]; -} temp_2; + t_tag_comp comp_data[AC_TEMP_MAX]; +} t_temp_2; typedef struct tag_mode_2 { UINT8 len; - tag_comp comp_data[AC_MODE_MAX]; -} mode_2; + t_tag_comp comp_data[AC_MODE_MAX]; +} t_mode_2; typedef struct tag_speed_2 { UINT8 len; - tag_comp comp_data[AC_WS_MAX]; -} speed_2; + t_tag_comp comp_data[AC_WS_MAX]; +} t_speed_2; typedef struct tag_swing_2 { UINT8 len; UINT16 count; - tag_comp *comp_data; -} swing_2; + t_tag_comp *comp_data; +} t_swing_2; #if defined SUPPORT_HORIZONTAL_SWING typedef struct tag_horiswing_1 { UINT16 len; - tag_comp comp_data[AC_HORI_SWING_MAX]; + t_tag_comp comp_data[AC_HORI_SWING_MAX]; } hori_swing_1; #endif @@ -241,39 +241,39 @@ typedef struct _tag_checksum_data UINT8 checksum_byte_pos; UINT8 checksum_plus; UINT8 *spec_pos; -} tag_checksum_data; +} t_tag_checksum_data; typedef struct tag_checksum { UINT8 len; UINT16 count; - tag_checksum_data *checksum_data; -} tchecksum; + t_tag_checksum_data *checksum_data; +} t_checksum; typedef struct tag_function_1 { UINT8 len; - tag_comp comp_data[AC_FUNCTION_MAX - 1]; -} function_1; + t_tag_comp comp_data[AC_FUNCTION_MAX - 1]; +} t_function_1; typedef struct tag_function_2 { UINT8 len; - tag_comp comp_data[AC_FUNCTION_MAX - 1]; -} function_2; + t_tag_comp comp_data[AC_FUNCTION_MAX - 1]; +} t_function_2; typedef struct tag_solo_code { UINT8 len; UINT8 solo_func_count; UINT8 solo_function_codes[AC_FUNCTION_MAX - 1]; -} solo_code; +} t_solo_code; typedef struct _ac_bitnum { INT16 pos; UINT16 bits; -} ac_bitnum; +} t_ac_bit_num; typedef enum { @@ -283,7 +283,7 @@ typedef enum N_FAN, N_DRY, N_MODE_MAX, -} ac_n_mode; +} t_ac_n_mode; typedef enum { @@ -296,68 +296,69 @@ typedef enum CHECKSUM_TYPE_SPEC_HALF_BYTE_ONE_BYTE, CHECKSUM_TYPE_SPEC_HALF_BYTE_INVERSE_ONE_BYTE, CHECKSUM_TYPE_MAX, -} checksum_type; +} t_checksum_type; typedef struct _ac_n_mode_info { UINT8 enable; - UINT8 allspeed; - UINT8 alltemp; + UINT8 all_speed; + UINT8 all_temp; UINT8 temp[AC_TEMP_MAX]; UINT8 temp_cnt; UINT8 speed[AC_WS_MAX]; UINT8 speed_cnt; -} ac_n_mode_info; +} t_ac_n_mode_info; typedef struct ac_protocol { UINT8 endian; - // ac_hex default_code; - ac_hex default_code; - ac_level zero; - ac_level one; - ac_bootcode bootcode; - ac_delaycode dc[MAX_DELAYCODE_NUM]; - power_1 power1; - temp_1 temp1; - mode_1 mode1; - speed_1 speed1; - swing_1 swing1; - tchecksum checksum; + // t_ac_hex default_code; + t_ac_hex default_code; + t_ac_level zero; + t_ac_level one; + t_ac_bootcode boot_code; + t_ac_delaycode dc[MAX_DELAYCODE_NUM]; + t_power_1 power1; + t_temp_1 temp1; + t_mode_1 mode1; + t_speed_1 speed1; + t_swing_1 swing1; + t_checksum checksum; - function_1 function1; - function_2 function2; + t_function_1 function1; + t_function_2 function2; - temp_2 temp2; - mode_2 mode2; - speed_2 speed2; - swing_2 swing2; + t_temp_2 temp2; + t_mode_2 mode2; + t_speed_2 speed2; + t_swing_2 swing2; - swing_info si; - solo_code sc; + t_swing_info si; + t_solo_code sc; UINT8 swing_status; BOOL change_wind_direction; UINT16 dc_cnt; - ac_bitnum bitnum[MAX_BITNUM]; - UINT16 bitnum_cnt; + t_ac_bit_num bit_num[MAX_BITNUM]; + UINT16 bit_num_cnt; UINT16 repeat_times; - UINT16 frame_length; - ac_n_mode_info n_mode[N_MODE_MAX]; + t_ac_n_mode_info n_mode[N_MODE_MAX]; UINT16 code_cnt; - UINT8 lastbit; + UINT8 last_bit; UINT16 *time; UINT8 solo_function_mark; -} protocol; + + UINT16 frame_length; +} t_ac_protocol; typedef struct tag_head { UINT16 tag; UINT16 len; unsigned short offset; - UINT8 *pdata; + UINT8 *p_data; } t_tag_head; struct ir_bin_buffer @@ -369,19 +370,18 @@ struct ir_bin_buffer typedef struct REMOTE_AC_STATUS { - ac_power acPower; - ac_temperature acTemp; - ac_mode acMode; - ac_swing acWindDir; - ac_wind_speed acWindSpeed; - UINT8 acDisplay; - UINT8 acSleep; - UINT8 acTimer; -} remote_ac_status_t; + t_ac_power ac_power; + t_ac_temperature ac_temp; + t_ac_mode ac_mode; + t_ac_swing ac_wind_dir; + t_ac_wind_speed ac_wind_speed; + UINT8 ac_display; + UINT8 ac_sleep; + UINT8 ac_timer; +} t_remote_ac_status; // function polymorphism -typedef INT8 (*lp_apply_ac_parameter)(remote_ac_status_t ac_status, UINT8 function_code); - +typedef INT8 (*lp_apply_ac_parameter)(t_remote_ac_status ac_status, UINT8 function_code); #define TAG_AC_BOOT_CODE 1 #define TAG_AC_ZERO 2 @@ -389,7 +389,7 @@ typedef INT8 (*lp_apply_ac_parameter)(remote_ac_status_t ac_status, UINT8 functi #define TAG_AC_DELAY_CODE 4 #define TAG_AC_FRAME_LENGTH 5 #define TAG_AC_ENDIAN 6 -#define TAG_AC_LASTBIT 7 +#define TAG_AC_LAST_BIT 7 #define TAG_AC_POWER_1 21 #define TAG_AC_DEFAULT_CODE 22 @@ -413,17 +413,17 @@ typedef INT8 (*lp_apply_ac_parameter)(remote_ac_status_t ac_status, UINT8 functi #define TAG_AC_BAN_FUNCTION_IN_DRY_MODE 45 #define TAG_AC_SWING_INFO 46 #define TAG_AC_REPEAT_TIMES 47 -#define TAG_AC_BITNUM 48 +#define TAG_AC_BIT_NUM 48 // definition about size -#define PROTOCOL_SIZE (sizeof(protocol)) +#define PROTOCOL_SIZE (sizeof(t_ac_protocol)) /* exported variables */ extern UINT8 *ir_hex_code; extern UINT8 ir_hex_len; -extern protocol *context; +extern t_ac_protocol *context; extern INT8 ir_ac_lib_parse(); diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_parse_forbidden_info.h b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_parse_forbidden_info.h index c0cce82..8f0f5b1 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_parse_forbidden_info.h +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_parse_forbidden_info.h @@ -19,7 +19,7 @@ extern "C" #include "ir_decode.h" -extern INT8 parse_nmode(struct tag_head *tag, ac_n_mode index); +extern INT8 parse_nmode(struct tag_head *tag, t_ac_n_mode index); #ifdef __cplusplus } diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_parse_parameter.h b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_parse_parameter.h index 1da7132..6d53e89 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_parse_parameter.h +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_ac_parse_parameter.h @@ -19,37 +19,37 @@ extern "C" #include "ir_decode.h" -extern INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_end, UINT8 type); +extern INT8 parse_common_ac_parameter(t_tag_head *tag, t_tag_comp *comp_data, UINT8 with_end, UINT8 type); -extern INT8 parse_default_code(struct tag_head *tag, ac_hex *default_code); +extern INT8 parse_default_code(struct tag_head *tag, t_ac_hex *default_code); -extern INT8 parse_power_1(struct tag_head *tag, power_1 *power1); +extern INT8 parse_power_1(struct tag_head *tag, t_power_1 *power1); -extern INT8 parse_temp_1(struct tag_head *tag, temp_1 *temp1); +extern INT8 parse_temp_1(struct tag_head *tag, t_temp_1 *temp1); -extern INT8 parse_mode_1(struct tag_head *tag, mode_1 *mode1); +extern INT8 parse_mode_1(struct tag_head *tag, t_mode_1 *mode1); -extern INT8 parse_speed_1(struct tag_head *tag, speed_1 *speed1); +extern INT8 parse_speed_1(struct tag_head *tag, t_speed_1 *speed1); -extern INT8 parse_swing_1(struct tag_head *tag, swing_1 *swing1, UINT16 swing_count); +extern INT8 parse_swing_1(struct tag_head *tag, t_swing_1 *swing1, UINT16 swing_count); -extern INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum); +extern INT8 parse_checksum(struct tag_head *tag, t_checksum *checksum); -extern INT8 parse_function_1_tag29(struct tag_head *tag, function_1 *function1); +extern INT8 parse_function_1_tag29(struct tag_head *tag, t_function_1 *function1); -extern INT8 parse_temp_2(struct tag_head *tag, temp_2 *temp2); +extern INT8 parse_temp_2(struct tag_head *tag, t_temp_2 *temp2); -extern INT8 parse_mode_2(struct tag_head *tag, mode_2 *mode2); +extern INT8 parse_mode_2(struct tag_head *tag, t_mode_2 *mode2); -extern INT8 parse_speed_2(struct tag_head *tag, speed_2 *speed2); +extern INT8 parse_speed_2(struct tag_head *tag, t_speed_2 *speed2); -extern INT8 parse_swing_2(struct tag_head *tag, swing_2 *swing2, UINT16 swing_count); +extern INT8 parse_swing_2(struct tag_head *tag, t_swing_2 *swing2, UINT16 swing_count); -extern INT8 parse_function_2_tag34(struct tag_head *tag, function_2 *function2); +extern INT8 parse_function_2_tag34(struct tag_head *tag, t_function_2 *function2); -extern INT8 parse_swing_info(struct tag_head *tag, swing_info *si); +extern INT8 parse_swing_info(struct tag_head *tag, t_swing_info *si); -extern INT8 parse_solo_code(struct tag_head *tag, solo_code *sc); +extern INT8 parse_solo_code(struct tag_head *tag, t_solo_code *sc); #ifdef __cplusplus } diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_decode.h b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_decode.h index 5ae4b17..b2fff07 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_decode.h +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_decode.h @@ -75,7 +75,7 @@ extern INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8 * * returns: length of decoded data (0 indicates decode failure) */ -extern UINT16 ir_decode(UINT8 key_code, UINT16* user_data, remote_ac_status_t* ac_status, BOOL change_wind_direction); +extern UINT16 ir_decode(UINT8 key_code, UINT16* user_data, t_remote_ac_status* ac_status, BOOL change_wind_direction); /** * function ir_close diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_tv_control.h b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_tv_control.h index a4e1661..9e86741 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_tv_control.h +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_tv_control.h @@ -63,7 +63,7 @@ typedef enum ir_flags IRDA_E, IRDA_F, IRDA_MAX = 20, -} ir_flags_t; +} t_ir_flags; typedef struct ir_data { @@ -71,7 +71,7 @@ typedef struct ir_data UINT8 lsb; UINT8 mode; UINT8 index; -} ir_data_t; +} t_ir_data; #if !defined BOARD_51 #pragma pack(1) @@ -81,7 +81,8 @@ typedef struct ir_cycles UINT8 flag; UINT16 mask; UINT16 space; -} ir_cycles_t; +} t_ir_cycles; + #if !defined BOARD_51 #pragma pack() #endif @@ -113,7 +114,7 @@ typedef enum tv_key_value TV_8, TV_9, TV_KEY_MAX, -} tv_key_value_t; +} t_tv_key_value; typedef enum stb_key_value @@ -143,7 +144,7 @@ typedef enum stb_key_value STB_8, STB_9, STB_KEY_MAX, -} stb_key_value_t; +} t_stb_key_value; typedef enum nw_key_value { @@ -169,7 +170,7 @@ typedef enum nw_key_value NW_8, NW_9, NW_KEY_MAX, -} nw_key_value_t; +} t_nw_key_value; typedef enum cm_key_value { @@ -189,13 +190,13 @@ typedef enum cm_key_value CM_MENU, CM_MODE, CM_KEY_MAX, -} cm_key_value_t; +} t_cm_key_value; typedef struct ir_data_tv { char magic[4]; UINT8 per_keycode_bytes; -} ir_data_tv_t; +} t_ir_data_tv; extern INT8 tv_lib_open(UINT8 *binary, UINT16 binary_length); diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_utils.h b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_utils.h index 2f036ae..667bdf1 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_utils.h +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/include/ir_utils.h @@ -22,13 +22,11 @@ extern "C" #include -extern void string_to_hex(UINT8 *p, ac_hex *pac_hex, UINT16 len); - -extern void string_to_intArray(UINT8 *p, UINT8 *binary_code, UINT16 len); +extern void string_to_hex(UINT8 *p, t_ac_hex *pac_hex); extern void string_to_hex_common(UINT8 *p, UINT8 *hex_data, UINT16 len); -extern BOOL isin(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); diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_apply.c b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_apply.c index 7206bcc..905ddc8 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_apply.c +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_apply.c @@ -17,16 +17,16 @@ static INT8 apply_ac_power(struct ac_protocol *protocol, UINT8 power_status); static INT8 apply_ac_mode(struct ac_protocol *protocol, UINT8 mode_status); -static INT8 apply_ac_temperature(struct ac_protocol *protocol, UINT8 temperature); +static INT8 apply_ac_temperature(struct ac_protocol *protocol, UINT8 temp_diff); static INT8 apply_ac_wind_speed(struct ac_protocol *protocol, UINT8 wind_speed); -static INT8 apply_ac_swing(struct ac_protocol *protocol, UINT8 swing_status); +static INT8 apply_ac_swing(struct ac_protocol *protocol, UINT8 swing_mode); static UINT8 has_function(struct ac_protocol *protocol, UINT8 function); -INT8 apply_ac_parameter_type_1(UINT8 *dc_data, tag_comp *comp_data, UINT8 current_seg, UINT8 is_temp) +INT8 apply_ac_parameter_type_1(UINT8 *dc_data, t_tag_comp *comp_data, UINT8 current_seg, UINT8 is_temp) { if (0 != (comp_data->seg_len & 0x01)) { @@ -45,7 +45,7 @@ INT8 apply_ac_parameter_type_1(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren return IR_DECODE_SUCCEEDED; } -INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 current_seg, UINT8 is_temp) +INT8 apply_ac_parameter_type_2(UINT8 *dc_data, t_tag_comp *comp_data, UINT8 current_seg, UINT8 is_temp) { UINT8 start_bit = 0; UINT8 end_bit = 0; @@ -59,11 +59,10 @@ INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren return IR_DECODE_FAILED; } - // TODO: to be validated start_bit = comp_data->segment[current_seg]; end_bit = comp_data->segment[current_seg + 1]; cover_byte_pos_hi = start_bit >> 3; - cover_byte_pos_lo = (end_bit - 1) >> 3; + cover_byte_pos_lo = (UINT8) (end_bit - 1) >> 3; if (cover_byte_pos_hi == cover_byte_pos_lo) { // cover_byte_pos_hi or cover_bytes_pos_lo is target byte to be applied with AC parameter @@ -72,12 +71,12 @@ INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren UINT8 int_start_bit = start_bit - (cover_byte_pos_hi << 3); UINT8 int_end_bit = end_bit - (cover_byte_pos_lo << 3); UINT8 bit_range = end_bit - start_bit; - UINT8 mask = (0xFF << (8 - int_start_bit)) | (0xFF >> int_end_bit); + UINT8 mask = (UINT8) ((0xFF << (8 - int_start_bit)) | (0xFF >> int_end_bit)); UINT8 origin = dc_data[cover_byte_pos_lo]; if (TRUE == is_temp) { - move_bit = 8 - int_end_bit; + move_bit = (UINT8) (8 - int_end_bit); value = (origin & mask) | (((((origin & ~mask) >> move_bit) + raw_value) << move_bit) & ~mask); } else @@ -88,14 +87,13 @@ INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren } else { - UINT8 value = 0x00; - UINT8 origin_hi = 0x00; - UINT8 origin_lo = 0x00; - UINT8 mask_hi = 0x00; - UINT8 mask_lo = 0x00; - UINT8 raw_value = 0x00; - UINT8 int_start_bit = 0x00; - UINT8 int_end_bit = 0x00; + UINT8 origin_hi = 0; + UINT8 origin_lo = 0; + UINT8 mask_hi = 0; + UINT8 mask_lo = 0; + UINT8 raw_value = 0; + UINT8 int_start_bit = 0; + UINT8 int_end_bit = 0; if (cover_byte_pos_hi > cover_byte_pos_lo) { @@ -111,8 +109,8 @@ INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren int_start_bit = start_bit - (cover_byte_pos_hi << 3); int_end_bit = end_bit - (cover_byte_pos_lo << 3); - mask_hi = 0xFF << (8 - int_start_bit); - mask_lo = 0xFF >> int_end_bit; + mask_hi = (UINT8) 0xFF << (8 - int_start_bit); + mask_lo = (UINT8) 0xFF >> int_end_bit; value = ((origin_hi & ~mask_hi) << int_end_bit) | ((origin_lo & ~mask_lo) >> (8 - int_end_bit)); @@ -121,11 +119,11 @@ INT8 apply_ac_parameter_type_2(UINT8 *dc_data, tag_comp *comp_data, UINT8 curren raw_value += value; } - dc_data[cover_byte_pos_hi] = (origin_hi & mask_hi) | - (((0xFF >> (8 - bit_range)) & raw_value) >> int_end_bit); + dc_data[cover_byte_pos_hi] = (UINT8) ((origin_hi & mask_hi) | + (((0xFF >> (8 - bit_range)) & raw_value) >> int_end_bit)); - dc_data[cover_byte_pos_lo] = (origin_lo & mask_lo) | - (((0xFF >> (8 - bit_range)) & raw_value) << (8 - int_end_bit)); + dc_data[cover_byte_pos_lo] = (UINT8) ((origin_lo & mask_lo) | + (((0xFF >> (8 - bit_range)) & raw_value) << (8 - int_end_bit))); } return IR_DECODE_SUCCEEDED; @@ -346,7 +344,7 @@ static INT8 apply_ac_swing(struct ac_protocol *protocol, UINT8 swing_mode) return IR_DECODE_SUCCEEDED; } -static INT8 apply_checksum_byte(UINT8 *ac_code, tag_checksum_data cs, BOOL inverse) +static INT8 apply_checksum_byte(UINT8 *ac_code, t_tag_checksum_data cs, BOOL inverse) { UINT16 i = 0; UINT8 checksum = 0x00; @@ -374,7 +372,7 @@ static INT8 apply_checksum_byte(UINT8 *ac_code, tag_checksum_data cs, BOOL inver return IR_DECODE_SUCCEEDED; } -static INT8 apply_checksum_halfbyte(UINT8 *ac_code, tag_checksum_data cs, BOOL inverse) +static INT8 apply_checksum_halfbyte(UINT8 *ac_code, t_tag_checksum_data cs, BOOL inverse) { UINT16 i = 0; UINT8 checksum = 0x00; @@ -402,7 +400,7 @@ static INT8 apply_checksum_halfbyte(UINT8 *ac_code, tag_checksum_data cs, BOOL i return IR_DECODE_SUCCEEDED; } -static INT8 apply_checksum_spec_byte(UINT8 *ac_code, tag_checksum_data cs, BOOL inverse) +static INT8 apply_checksum_spec_byte(UINT8 *ac_code, t_tag_checksum_data cs, BOOL inverse) { UINT16 i = 0; UINT8 apply_byte_pos = 0; @@ -442,18 +440,18 @@ static INT8 apply_checksum_spec_byte(UINT8 *ac_code, tag_checksum_data cs, BOOL if (0 == (cs.checksum_byte_pos & 0x01)) { // save low bits and add checksum as high bits - ac_code[apply_byte_pos] = (ac_code[apply_byte_pos] & 0x0F) | (checksum << 4); + ac_code[apply_byte_pos] = (UINT8) ((ac_code[apply_byte_pos] & 0x0F) | (checksum << 4)); } else { // save high bits and add checksum as low bits - ac_code[apply_byte_pos] = (ac_code[apply_byte_pos] & 0xF0) | (checksum & 0x0F); + ac_code[apply_byte_pos] = (UINT8) ((ac_code[apply_byte_pos] & 0xF0) | (checksum & 0x0F)); } return IR_DECODE_SUCCEEDED; } -static INT8 apply_checksum_spec_byte_onebyte(UINT8 *ac_code, tag_checksum_data cs, BOOL inverse) +static INT8 apply_checksum_spec_byte_onebyte(UINT8 *ac_code, t_tag_checksum_data cs, BOOL inverse) { UINT16 i = 0; UINT8 apply_byte_pos = 0; @@ -605,15 +603,15 @@ INT8 apply_checksum(struct ac_protocol *protocol) return IR_DECODE_SUCCEEDED; } -INT8 apply_power(remote_ac_status_t ac_status, UINT8 function_code) +INT8 apply_power(t_remote_ac_status ac_status, UINT8 function_code) { - apply_ac_power(context, ac_status.acPower); + apply_ac_power(context, ac_status.ac_power); return IR_DECODE_SUCCEEDED; } -INT8 apply_mode(remote_ac_status_t ac_status, UINT8 function_code) +INT8 apply_mode(t_remote_ac_status ac_status, UINT8 function_code) { - if (IR_DECODE_FAILED == apply_ac_mode(context, ac_status.acMode)) + if (IR_DECODE_FAILED == apply_ac_mode(context, ac_status.ac_mode)) { // do not implement this mechanism since mode, temperature, wind // speed would have unspecified function @@ -626,16 +624,16 @@ INT8 apply_mode(remote_ac_status_t ac_status, UINT8 function_code) return IR_DECODE_SUCCEEDED; } -INT8 apply_wind_speed(remote_ac_status_t ac_status, UINT8 function_code) +INT8 apply_wind_speed(t_remote_ac_status ac_status, UINT8 function_code) { - if (FALSE == context->n_mode[ac_status.acMode].allspeed) + if (FALSE == context->n_mode[ac_status.ac_mode].all_speed) { // if this level is not in black list - if (!isin(context->n_mode[ac_status.acMode].speed, - ac_status.acWindSpeed, - context->n_mode[ac_status.acMode].speed_cnt)) + if (!is_in(context->n_mode[ac_status.ac_mode].speed, + ac_status.ac_wind_speed, + context->n_mode[ac_status.ac_mode].speed_cnt)) { - if (IR_DECODE_FAILED == apply_ac_wind_speed(context, ac_status.acWindSpeed) && + if (IR_DECODE_FAILED == apply_ac_wind_speed(context, ac_status.ac_wind_speed) && function_code == AC_FUNCTION_WIND_SPEED) { // do not implement this mechanism since mode, temperature, wind @@ -676,7 +674,7 @@ INT8 apply_wind_speed(remote_ac_status_t ac_status, UINT8 function_code) return IR_DECODE_SUCCEEDED; } -INT8 apply_swing(remote_ac_status_t ac_status, UINT8 function_code) +INT8 apply_swing(t_remote_ac_status ac_status, UINT8 function_code) { if (function_code == AC_FUNCTION_WIND_FIX) { @@ -719,15 +717,15 @@ INT8 apply_swing(remote_ac_status_t ac_status, UINT8 function_code) return IR_DECODE_SUCCEEDED; } -INT8 apply_temperature(remote_ac_status_t ac_status, UINT8 function_code) +INT8 apply_temperature(t_remote_ac_status ac_status, UINT8 function_code) { - if (FALSE == context->n_mode[ac_status.acMode].alltemp) + if (FALSE == context->n_mode[ac_status.ac_mode].all_temp) { - if (!isin(context->n_mode[ac_status.acMode].temp, - ac_status.acTemp, - context->n_mode[ac_status.acMode].temp_cnt)) + if (!is_in(context->n_mode[ac_status.ac_mode].temp, + ac_status.ac_temp, + context->n_mode[ac_status.ac_mode].temp_cnt)) { - if (IR_DECODE_FAILED == apply_ac_temperature(context, ac_status.acTemp)) + if (IR_DECODE_FAILED == apply_ac_temperature(context, ac_status.ac_temp)) { if (function_code == AC_FUNCTION_TEMPERATURE_UP /*&& FALSE == has_function(context, AC_FUNCTION_TEMPERATURE_UP)*/) diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_binary_parse.c b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_binary_parse.c index cf07677..747a8b8 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_binary_parse.c +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_binary_parse.c @@ -114,7 +114,7 @@ INT8 binary_parse_data() UINT16 i = 0; for (i = 0; i < tag_count; i++) { - tags[i].pdata = p_ir_buffer->data + tags[i].offset + tag_head_offset; + tags[i].p_data = p_ir_buffer->data + tags[i].offset + tag_head_offset; } return IR_DECODE_SUCCEEDED; diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_build_frame.c b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_build_frame.c index 1cf2b75..f3f767d 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_build_frame.c +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_build_frame.c @@ -12,7 +12,7 @@ Revision log: #include "../include/ir_ac_build_frame.h" #include "../include/ir_decode.h" -extern protocol *context; +extern t_ac_protocol *context; //return bit number per byte,default value is 8 @@ -21,19 +21,19 @@ UINT8 bits_per_byte(UINT8 index) UINT8 i = 0; UINT8 size = 0; - if (context->bitnum_cnt == 0) + if (context->bit_num_cnt == 0) return 8; //defaut value - if (context->bitnum_cnt >= MAX_BITNUM) + if (context->bit_num_cnt >= MAX_BITNUM) size = MAX_BITNUM; else - size = (UINT8) context->bitnum_cnt; + size = (UINT8) context->bit_num_cnt; for (i = 0; i < size; i++) { - if (context->bitnum[i].pos == index) - return (UINT8) context->bitnum[i].bits; - if (context->bitnum[i].pos > index) + if (context->bit_num[i].pos == index) + return (UINT8) context->bit_num[i].bits; + if (context->bit_num[i].pos > index) return 8; } return 8; @@ -67,7 +67,7 @@ UINT16 add_delaycode(UINT8 index) } } - if ((context->lastbit == 0) && (index == (ir_hex_len - 1))) + if ((context->last_bit == 0) && (index == (ir_hex_len - 1))) { context->time[context->code_cnt++] = context->one.low; //high } @@ -97,11 +97,11 @@ UINT16 create_ir_frame() context->code_cnt = 0; // boot code - for (i = 0; i < context->bootcode.len; i++) + for (i = 0; i < context->boot_code.len; i++) { - context->time[context->code_cnt++] = context->bootcode.data[i]; + context->time[context->code_cnt++] = context->boot_code.data[i]; } - //code_cnt += context->bootcode.len; + //code_cnt += context->boot_code.len; for (i = 0; i < ir_hex_len; i++) { diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_control.c b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_control.c index b84d882..2bd8219 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_control.c +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_control.c @@ -30,7 +30,7 @@ static INT8 ir_context_init(); static INT8 ir_context_init() { - ir_memset(context, 0, sizeof(protocol)); + ir_memset(context, 0, sizeof(t_ac_protocol)); return IR_DECODE_SUCCEEDED; } @@ -59,14 +59,14 @@ INT8 ir_ac_lib_parse() binary_tags_info(); context->endian = 0; - context->lastbit = 0; + context->last_bit = 0; context->repeat_times = 1; for (i = 0; i < N_MODE_MAX; i++) { context->n_mode[i].enable = TRUE; - context->n_mode[i].allspeed = FALSE; - context->n_mode[i].alltemp = FALSE; + context->n_mode[i].all_speed = FALSE; + context->n_mode[i].all_temp = FALSE; ir_memset(context->n_mode[i].speed, 0x00, AC_WS_MAX); context->n_mode[i].speed_cnt = 0; ir_memset(context->n_mode[i].temp, 0x00, AC_TEMP_MAX); @@ -105,8 +105,8 @@ INT8 ir_ac_lib_parse() { context->swing1.count = context->si.mode_count; context->swing1.len = (UINT8) tags[i].len >> 1; - swing_space_size = sizeof(tag_comp) * context->si.mode_count; - context->swing1.comp_data = (tag_comp *) ir_malloc(swing_space_size); + swing_space_size = sizeof(t_tag_comp) * context->si.mode_count; + context->swing1.comp_data = (t_tag_comp *) ir_malloc(swing_space_size); if (NULL == context->swing1.comp_data) { return IR_DECODE_FAILED; @@ -125,8 +125,8 @@ INT8 ir_ac_lib_parse() { context->swing2.count = context->si.mode_count; context->swing2.len = (UINT8) tags[i].len >> 1; - swing_space_size = sizeof(tag_comp) * context->si.mode_count; - context->swing2.comp_data = (tag_comp *) ir_malloc(swing_space_size); + swing_space_size = sizeof(t_tag_comp) * context->si.mode_count; + context->swing2.comp_data = (t_tag_comp *) ir_malloc(swing_space_size); if (NULL == context->swing2.comp_data) { return IR_DECODE_FAILED; @@ -286,7 +286,7 @@ INT8 ir_ac_lib_parse() return IR_DECODE_FAILED; } } - else if (tags[i].tag == TAG_AC_BITNUM) + else if (tags[i].tag == TAG_AC_BIT_NUM) { if (IR_DECODE_FAILED == parse_bit_num(&tags[i])) { @@ -350,7 +350,7 @@ INT8 ir_ac_lib_parse() return IR_DECODE_FAILED; } } - if (tags[i].tag == TAG_AC_LASTBIT) + if (tags[i].tag == TAG_AC_LAST_BIT) { if (IR_DECODE_FAILED == parse_lastbit(&tags[i])) { @@ -382,7 +382,7 @@ INT8 ir_ac_lib_parse() // bit order from right to left : power, mode, temp+, temp-, wind_speed, swing, fix for (i = AC_FUNCTION_POWER; i < AC_FUNCTION_MAX; i++) { - if (isin(context->sc.solo_function_codes, i, context->sc.solo_func_count)) + if (is_in(context->sc.solo_function_codes, i, context->sc.solo_func_count)) { context->solo_function_mark |= (1 << (i - 1)); } diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_parse_forbidden_info.c b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_parse_forbidden_info.c index d7c8c3a..0ea1c47 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_parse_forbidden_info.c +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_parse_forbidden_info.c @@ -17,10 +17,10 @@ Revision log: #include "../include/ir_ac_parse_forbidden_info.h" -extern protocol *context; +extern t_ac_protocol *context; -INT8 parse_nmode_data_speed(char *pdata, ac_n_mode seq) +INT8 parse_nmode_data_speed(char *pdata, t_ac_n_mode seq) { char buf[16] = {0}; char *p = pdata; @@ -44,7 +44,7 @@ INT8 parse_nmode_data_speed(char *pdata, ac_n_mode seq) return IR_DECODE_SUCCEEDED; } -INT8 parse_nmode_data_temp(char *pdata, ac_n_mode seq) +INT8 parse_nmode_data_temp(char *pdata, t_ac_n_mode seq) { char buf[16] = {0}; @@ -68,7 +68,7 @@ INT8 parse_nmode_data_temp(char *pdata, ac_n_mode seq) return IR_DECODE_SUCCEEDED; } -INT8 parse_nmode_pos(char *buf, ac_n_mode index) +INT8 parse_nmode_pos(char *buf, t_ac_n_mode index) { UINT16 i = 0; char data[64] = {0}; @@ -77,11 +77,11 @@ INT8 parse_nmode_pos(char *buf, ac_n_mode index) { if (buf[0] == 'S' || buf[0] == 's') { - context->n_mode[index].allspeed = 1; + context->n_mode[index].all_speed = 1; } else if (buf[0] == 'T' || buf[0] == 't') { - context->n_mode[index].alltemp = 1; + context->n_mode[index].all_temp = 1; } return IR_DECODE_SUCCEEDED; } @@ -106,14 +106,14 @@ INT8 parse_nmode_pos(char *buf, ac_n_mode index) return IR_DECODE_SUCCEEDED; } -INT8 parse_nmode(struct tag_head *tag, ac_n_mode index) +INT8 parse_nmode(struct tag_head *tag, t_ac_n_mode index) { UINT16 i = 0; UINT16 preindex = 0; char buf[64] = {0}; - if (tag->pdata[0] == 'N' && tag->pdata[1] == 'A') + if (tag->p_data[0] == 'N' && tag->p_data[1] == 'A') { // ban this function directly context->n_mode[index].enable = 0; @@ -127,16 +127,16 @@ INT8 parse_nmode(struct tag_head *tag, ac_n_mode index) preindex = 0; for (i = 0; i < tag->len; i++) { - if (tag->pdata[i] == '|') + if (tag->p_data[i] == '|') { - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); preindex = (UINT16) (i + 1); parse_nmode_pos(buf, index); ir_memset(buf, 0, 64); } } - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); parse_nmode_pos(buf, index); ir_memset(buf, 0, 64); return IR_DECODE_SUCCEEDED; diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_parse_frame_info.c b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_parse_frame_info.c index 5a20932..b96bca1 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_parse_frame_info.c +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_parse_frame_info.c @@ -28,7 +28,7 @@ INT8 parse_boot_code(struct tag_head *tag) { return IR_DECODE_FAILED; } - p = tag->pdata; + p = tag->p_data; if (NULL == p) { @@ -41,13 +41,13 @@ INT8 parse_boot_code(struct tag_head *tag) { index++; } - ir_memcpy(buf, tag->pdata + pos, index - pos); + ir_memcpy(buf, tag->p_data + pos, index - pos); pos = (UINT16) (index + 1); index = pos; - context->bootcode.data[cnt++] = (UINT16) (atoi((char *) buf)); + context->boot_code.data[cnt++] = (UINT16) (atoi((char *) buf)); ir_memset(buf, 0, 16); } - context->bootcode.len = cnt; + context->boot_code.len = cnt; return IR_DECODE_SUCCEEDED; } @@ -62,7 +62,7 @@ INT8 parse_zero(struct tag_head *tag) { return IR_DECODE_FAILED; } - p = tag->pdata; + p = tag->p_data; if (NULL == p) { @@ -74,8 +74,8 @@ INT8 parse_zero(struct tag_head *tag) index++; } - ir_memcpy(low, tag->pdata, index); - ir_memcpy(high, tag->pdata + index + 1, (size_t) (tag->len - index - 1)); + ir_memcpy(low, tag->p_data, index); + ir_memcpy(high, tag->p_data + index + 1, (size_t) (tag->len - index - 1)); context->zero.low = (UINT16) (atoi((char *) low)); context->zero.high = (UINT16) (atoi((char *) high)); @@ -93,7 +93,7 @@ INT8 parse_one(struct tag_head *tag) { return IR_DECODE_FAILED; } - p = tag->pdata; + p = tag->p_data; if (NULL == p) { @@ -104,8 +104,8 @@ INT8 parse_one(struct tag_head *tag) { index++; } - ir_memcpy(low, tag->pdata, index); - ir_memcpy(high, tag->pdata + index + 1, (size_t) (tag->len - index - 1)); + ir_memcpy(low, tag->p_data, index); + ir_memcpy(high, tag->p_data + index + 1, (size_t) (tag->len - index - 1)); context->one.low = (UINT16) (atoi((char *) low)); context->one.high = (UINT16) (atoi((char *) high)); @@ -183,16 +183,16 @@ INT8 parse_delay_code(struct tag_head *tag) for (i = 0; i < tag->len; i++) { - if (tag->pdata[i] == '|') + if (tag->p_data[i] == '|') { - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); preindex = (UINT16) (i + 1); parse_delay_code_pos(buf); ir_memset(buf, 0, 64); } } - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); parse_delay_code_pos(buf); ir_memset(buf, 0, 64); @@ -217,7 +217,7 @@ INT8 parse_frame_len(struct tag_head *tag, UINT16 len) ir_memset(temp, 0x00, len + 1); - ir_memcpy(temp, tag->pdata, len); + ir_memcpy(temp, tag->p_data, len); temp[len] = '\0'; context->frame_length = (UINT16) (atoi((char *) temp)); @@ -234,7 +234,7 @@ INT8 parse_endian(struct tag_head *tag) { return IR_DECODE_FAILED; } - ir_memcpy(buf, tag->pdata, tag->len); + ir_memcpy(buf, tag->p_data, tag->len); context->endian = (UINT8) (atoi((char *) buf)); return IR_DECODE_SUCCEEDED; } @@ -247,8 +247,8 @@ INT8 parse_lastbit(struct tag_head *tag) { return IR_DECODE_FAILED; } - ir_memcpy(buf, tag->pdata, tag->len); - context->lastbit = (UINT8) (atoi((char *) buf)); + ir_memcpy(buf, tag->p_data, tag->len); + context->last_bit = (UINT8) (atoi((char *) buf)); return IR_DECODE_SUCCEEDED; } @@ -260,7 +260,7 @@ INT8 parse_repeat_times(struct tag_head *tag) return IR_DECODE_FAILED; } - ir_memcpy(asc_code, tag->pdata, tag->len); + ir_memcpy(asc_code, tag->p_data, tag->len); context->repeat_times = (UINT16) (atoi((char *) asc_code)); @@ -287,9 +287,9 @@ INT8 parse_delay_code_tag48_pos(UINT8 *buf) } } - context->bitnum[context->bitnum_cnt].pos = (UINT16) (atoi((char *) start)); - context->bitnum[context->bitnum_cnt].bits = (UINT16) (atoi((char *) data)); - context->bitnum_cnt++; + context->bit_num[context->bit_num_cnt].pos = (UINT16) (atoi((char *) start)); + context->bit_num[context->bit_num_cnt].bits = (UINT16) (atoi((char *) data)); + context->bit_num_cnt++; return IR_DECODE_SUCCEEDED; } @@ -307,23 +307,23 @@ INT8 parse_bit_num(struct tag_head *tag) preindex = 0; for (i = 0; i < tag->len; i++) { - if (tag->pdata[i] == '|') + if (tag->p_data[i] == '|') { - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); preindex = (UINT16) (i + 1); parse_delay_code_tag48_pos(buf); ir_memset(buf, 0, 64); } } - ir_memcpy(buf, tag->pdata + preindex, i - preindex); + ir_memcpy(buf, tag->p_data + preindex, i - preindex); parse_delay_code_tag48_pos(buf); ir_memset(buf, 0, 64); - for (i = 0; i < context->bitnum_cnt; i++) + for (i = 0; i < context->bit_num_cnt; i++) { - if (context->bitnum[i].pos == -1) - context->bitnum[i].pos = (UINT16) (context->default_code.len - 1); //convert -1 to last data pos + if (context->bit_num[i].pos == -1) + context->bit_num[i].pos = (UINT16) (context->default_code.len - 1); //convert -1 to last data pos } return IR_DECODE_SUCCEEDED; } diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_parse_parameter.c b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_parse_parameter.c index 39b03b7..70137bd 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_parse_parameter.c +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_ac_parse_parameter.c @@ -17,7 +17,7 @@ Revision log: #include "../include/ir_ac_parse_parameter.h" -INT8 parse_comp_data_type_1(UINT8 *data, UINT16 *trav_offset, tag_comp *comp) +INT8 parse_comp_data_type_1(UINT8 *data, UINT16 *trav_offset, t_tag_comp *comp) { UINT8 seg_len = data[*trav_offset]; (*trav_offset)++; @@ -43,7 +43,7 @@ INT8 parse_comp_data_type_1(UINT8 *data, UINT16 *trav_offset, tag_comp *comp) return IR_DECODE_SUCCEEDED; } -INT8 parse_comp_data_type_2(UINT8 *data, UINT16 *trav_offset, tag_comp *comp) +INT8 parse_comp_data_type_2(UINT8 *data, UINT16 *trav_offset, t_tag_comp *comp) { UINT8 seg_len = data[*trav_offset]; (*trav_offset)++; @@ -69,7 +69,7 @@ INT8 parse_comp_data_type_2(UINT8 *data, UINT16 *trav_offset, tag_comp *comp) return IR_DECODE_SUCCEEDED; } -INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_end, UINT8 type) +INT8 parse_common_ac_parameter(t_tag_head *tag, t_tag_comp *comp_data, UINT8 with_end, UINT8 type) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -93,7 +93,7 @@ INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_ return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to AC data structure //*comp_len = hex_len; @@ -136,7 +136,7 @@ INT8 parse_common_ac_parameter(t_tag_head *tag, tag_comp *comp_data, UINT8 with_ return IR_DECODE_SUCCEEDED; } -INT8 parse_default_code(struct tag_head *tag, ac_hex *default_code) +INT8 parse_default_code(struct tag_head *tag, t_ac_hex *default_code) { UINT16 byteLen = 0; @@ -146,12 +146,12 @@ INT8 parse_default_code(struct tag_head *tag, ac_hex *default_code) } byteLen = tag->len >> 1; - string_to_hex(tag->pdata, default_code, byteLen); + string_to_hex(tag->p_data, default_code); return IR_DECODE_SUCCEEDED; } -INT8 parse_power_1(struct tag_head *tag, power_1 *power1) +INT8 parse_power_1(struct tag_head *tag, t_power_1 *power1) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -176,7 +176,7 @@ INT8 parse_power_1(struct tag_head *tag, power_1 *power1) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to power1 data structure power1->len = (UINT8) hex_len; @@ -201,7 +201,7 @@ INT8 parse_power_1(struct tag_head *tag, power_1 *power1) return IR_DECODE_SUCCEEDED; } -INT8 parse_temp_1(struct tag_head *tag, temp_1 *temp1) +INT8 parse_temp_1(struct tag_head *tag, t_temp_1 *temp1) { UINT16 hex_len = 0; UINT16 i = 0; @@ -222,7 +222,7 @@ INT8 parse_temp_1(struct tag_head *tag, temp_1 *temp1) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data according to length if (hex_data[0] == hex_len - 1) @@ -276,7 +276,7 @@ INT8 parse_temp_1(struct tag_head *tag, temp_1 *temp1) return IR_DECODE_SUCCEEDED; } -INT8 parse_mode_1(struct tag_head *tag, mode_1 *mode1) +INT8 parse_mode_1(struct tag_head *tag, t_mode_1 *mode1) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -296,7 +296,7 @@ INT8 parse_mode_1(struct tag_head *tag, mode_1 *mode1) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to mode1 data structure mode1->len = (UINT8) hex_len; @@ -320,7 +320,7 @@ INT8 parse_mode_1(struct tag_head *tag, mode_1 *mode1) return IR_DECODE_SUCCEEDED; } -INT8 parse_speed_1(struct tag_head *tag, speed_1 *speed1) +INT8 parse_speed_1(struct tag_head *tag, t_speed_1 *speed1) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -340,7 +340,7 @@ INT8 parse_speed_1(struct tag_head *tag, speed_1 *speed1) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to speed1 data structure speed1->len = (UINT8) hex_len; @@ -364,7 +364,7 @@ INT8 parse_speed_1(struct tag_head *tag, speed_1 *speed1) return IR_DECODE_SUCCEEDED; } -INT8 parse_swing_1(struct tag_head *tag, swing_1 *swing1, UINT16 swing_count) +INT8 parse_swing_1(struct tag_head *tag, t_swing_1 *swing1, UINT16 swing_count) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -384,12 +384,12 @@ INT8 parse_swing_1(struct tag_head *tag, swing_1 *swing1, UINT16 swing_count) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to swing1 data structure swing1->count = swing_count; swing1->len = (UINT8) hex_len; - swing1->comp_data = (tag_comp *) ir_malloc(sizeof(tag_comp) * swing_count); + swing1->comp_data = (t_tag_comp *) ir_malloc(sizeof(t_tag_comp) * swing_count); if (NULL == swing1->comp_data) { ir_free(hex_data); @@ -415,7 +415,7 @@ INT8 parse_swing_1(struct tag_head *tag, swing_1 *swing1, UINT16 swing_count) return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, UINT16 len) +INT8 parse_checksum_byte_typed(UINT8 *csdata, t_tag_checksum_data *checksum, UINT16 len) { checksum->start_byte_pos = csdata[2]; checksum->end_byte_pos = csdata[3]; @@ -434,7 +434,7 @@ INT8 parse_checksum_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, UINT1 return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum_half_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, UINT16 len) +INT8 parse_checksum_half_byte_typed(UINT8 *csdata, t_tag_checksum_data *checksum, UINT16 len) { checksum->start_byte_pos = csdata[2]; checksum->end_byte_pos = csdata[3]; @@ -452,7 +452,7 @@ INT8 parse_checksum_half_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum_spec_half_byte_typed(UINT8 *csdata, tag_checksum_data *checksum, UINT16 len) +INT8 parse_checksum_spec_half_byte_typed(UINT8 *csdata, t_tag_checksum_data *checksum, UINT16 len) { /* * note: @@ -478,14 +478,14 @@ INT8 parse_checksum_spec_half_byte_typed(UINT8 *csdata, tag_checksum_data *check return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum_malloc(struct tag_head *tag, tchecksum *checksum) +INT8 parse_checksum_malloc(struct tag_head *tag, t_checksum *checksum) { UINT8 i = 0; UINT8 cnt = 0; for (i = 0; i < tag->len; i++) { - if (tag->pdata[i] == '|') + if (tag->p_data[i] == '|') { cnt++; } @@ -493,18 +493,18 @@ INT8 parse_checksum_malloc(struct tag_head *tag, tchecksum *checksum) checksum->len = (UINT8) ((tag->len - cnt) >> 1); checksum->count = (UINT16) (cnt + 1); - checksum->checksum_data = (tag_checksum_data *) ir_malloc(sizeof(tag_checksum_data) * checksum->count); + checksum->checksum_data = (t_tag_checksum_data *) ir_malloc(sizeof(t_tag_checksum_data) * checksum->count); if (NULL == checksum->checksum_data) { return IR_DECODE_FAILED; } - ir_memset(checksum->checksum_data, 0x00, sizeof(tag_checksum_data) * checksum->count); + ir_memset(checksum->checksum_data, 0x00, sizeof(t_tag_checksum_data) * checksum->count); return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum_data(UINT8 *buf, tag_checksum_data *checksum, UINT8 length) +INT8 parse_checksum_data(UINT8 *buf, t_tag_checksum_data *checksum, UINT8 length) { UINT8 *hex_data = NULL; UINT16 hex_len = 0; @@ -574,7 +574,7 @@ INT8 parse_checksum_data(UINT8 *buf, tag_checksum_data *checksum, UINT8 length) return IR_DECODE_SUCCEEDED; } -INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum) +INT8 parse_checksum(struct tag_head *tag, t_checksum *checksum) { UINT8 i = 0; UINT8 num = 0; @@ -597,9 +597,9 @@ INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum) for (i = 0; i < tag->len; i++) { - if (tag->pdata[i] == '|') + if (tag->p_data[i] == '|') { - if (IR_DECODE_FAILED == parse_checksum_data(tag->pdata + preindex, + if (IR_DECODE_FAILED == parse_checksum_data(tag->p_data + preindex, checksum->checksum_data + num, (UINT8) (i - preindex) >> 1)) { @@ -610,7 +610,7 @@ INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum) } } - if (IR_DECODE_FAILED == parse_checksum_data(tag->pdata + preindex, + if (IR_DECODE_FAILED == parse_checksum_data(tag->p_data + preindex, checksum->checksum_data + num, (UINT8) (i - preindex) >> 1)) { @@ -620,7 +620,7 @@ INT8 parse_checksum(struct tag_head *tag, tchecksum *checksum) return IR_DECODE_SUCCEEDED; } -INT8 parse_function_1(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) +INT8 parse_function_1(UINT8 *data, UINT16 *trav_offset, t_tag_comp *mode_seg) { UINT8 seg_len = 0; BOOL valid_function_id = TRUE; @@ -687,7 +687,7 @@ INT8 parse_function_1(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) return function_id; } -INT8 parse_function_1_tag29(struct tag_head *tag, function_1 *function1) +INT8 parse_function_1_tag29(struct tag_head *tag, t_function_1 *function1) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -712,7 +712,7 @@ INT8 parse_function_1_tag29(struct tag_head *tag, function_1 *function1) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to mode1 data structure function1->len = (UINT8) hex_len; @@ -743,7 +743,7 @@ INT8 parse_function_1_tag29(struct tag_head *tag, function_1 *function1) return IR_DECODE_SUCCEEDED; } -INT8 parse_temp_2(struct tag_head *tag, temp_2 *temp2) +INT8 parse_temp_2(struct tag_head *tag, t_temp_2 *temp2) { UINT16 hex_len = 0; UINT16 i = 0; @@ -769,7 +769,7 @@ INT8 parse_temp_2(struct tag_head *tag, temp_2 *temp2) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data according to length if (hex_data[0] == hex_len - 1) @@ -823,7 +823,7 @@ INT8 parse_temp_2(struct tag_head *tag, temp_2 *temp2) return IR_DECODE_SUCCEEDED; } -INT8 parse_mode_2(struct tag_head *tag, mode_2 *mode2) +INT8 parse_mode_2(struct tag_head *tag, t_mode_2 *mode2) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -848,7 +848,7 @@ INT8 parse_mode_2(struct tag_head *tag, mode_2 *mode2) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to mode1 data structure mode2->len = (UINT8) hex_len; @@ -872,7 +872,7 @@ INT8 parse_mode_2(struct tag_head *tag, mode_2 *mode2) return IR_DECODE_SUCCEEDED; } -INT8 parse_speed_2(struct tag_head *tag, speed_2 *speed2) +INT8 parse_speed_2(struct tag_head *tag, t_speed_2 *speed2) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -897,7 +897,7 @@ INT8 parse_speed_2(struct tag_head *tag, speed_2 *speed2) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to speed1 data structure speed2->len = (UINT8) hex_len; @@ -921,7 +921,7 @@ INT8 parse_speed_2(struct tag_head *tag, speed_2 *speed2) return IR_DECODE_SUCCEEDED; } -INT8 parse_swing_2(struct tag_head *tag, swing_2 *swing2, UINT16 swing_count) +INT8 parse_swing_2(struct tag_head *tag, t_swing_2 *swing2, UINT16 swing_count) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -946,12 +946,12 @@ INT8 parse_swing_2(struct tag_head *tag, swing_2 *swing2, UINT16 swing_count) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to swing2 data structure swing2->count = swing_count; swing2->len = (UINT8) hex_len; - swing2->comp_data = (tag_comp *) ir_malloc(sizeof(tag_comp) * swing_count); + swing2->comp_data = (t_tag_comp *) ir_malloc(sizeof(t_tag_comp) * swing_count); if (NULL == swing2->comp_data) { ir_free(hex_data); @@ -977,7 +977,7 @@ INT8 parse_swing_2(struct tag_head *tag, swing_2 *swing2, UINT16 swing_count) return IR_DECODE_SUCCEEDED; } -INT8 parse_function_2(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) +INT8 parse_function_2(UINT8 *data, UINT16 *trav_offset, t_tag_comp *mode_seg) { UINT8 seg_len = 0; BOOL valid_function_id = TRUE; @@ -1045,7 +1045,7 @@ INT8 parse_function_2(UINT8 *data, UINT16 *trav_offset, tag_comp *mode_seg) return function_id; } -INT8 parse_function_2_tag34(struct tag_head *tag, function_2 *function2) +INT8 parse_function_2_tag34(struct tag_head *tag, t_function_2 *function2) { UINT16 hex_len = 0; UINT16 trav_offset = 0; @@ -1070,7 +1070,7 @@ INT8 parse_function_2_tag34(struct tag_head *tag, function_2 *function2) return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to mode1 data structure function2->len = (UINT8) hex_len; @@ -1101,7 +1101,7 @@ INT8 parse_function_2_tag34(struct tag_head *tag, function_2 *function2) return IR_DECODE_SUCCEEDED; } -INT8 parse_swing_info(struct tag_head *tag, swing_info *si) +INT8 parse_swing_info(struct tag_head *tag, t_swing_info *si) { if (NULL == tag) { @@ -1117,13 +1117,13 @@ INT8 parse_swing_info(struct tag_head *tag, swing_info *si) */ if (1 == tag->len) { - if ('0' == tag->pdata[0]) + if ('0' == tag->p_data[0]) { // to identify if there is only 1 status in TAG 26 OR 33 si->type = SWING_TYPE_NOT_SPECIFIED; si->mode_count = 0; } - else if ('1' == tag->pdata[0]) + else if ('1' == tag->p_data[0]) { si->type = SWING_TYPE_SWING_ONLY; si->mode_count = 1; @@ -1145,7 +1145,7 @@ INT8 parse_swing_info(struct tag_head *tag, swing_info *si) return IR_DECODE_SUCCEEDED; } -INT8 parse_solo_code(struct tag_head *tag, solo_code *sc) +INT8 parse_solo_code(struct tag_head *tag, t_solo_code *sc) { UINT16 hex_len = 0; UINT8 *hex_data = NULL; @@ -1175,7 +1175,7 @@ INT8 parse_solo_code(struct tag_head *tag, solo_code *sc) { return IR_DECODE_FAILED; } - string_to_hex_common(tag->pdata, hex_data, hex_len); + string_to_hex_common(tag->p_data, hex_data, hex_len); // parse hex data to mode1 data structure sc->len = (UINT8) hex_len; diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_decode.c b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_decode.c index cfc7b5b..f2b8cdd 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_decode.c +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_decode.c @@ -35,7 +35,7 @@ UINT8 *binary_content = NULL; UINT8 ir_binary_type = IR_TYPE_STATUS; UINT8 ir_hexadecimal = SUB_CATEGORY_QUATERNARY; -protocol *context = (protocol *) byteArray; +t_ac_protocol *context = (t_ac_protocol *) byteArray; lp_apply_ac_parameter apply_table[AC_APPLY_MAX] = { @@ -51,7 +51,7 @@ lp_apply_ac_parameter apply_table[AC_APPLY_MAX] = // static functions declarations static INT8 ir_ac_file_open(const char *file_name); static INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length); -static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code, +static UINT16 ir_ac_lib_control(t_remote_ac_status ac_status, UINT16 *user_data, UINT8 function_code, BOOL change_wind_direction); static INT8 ir_ac_lib_close(); static INT8 ir_tv_file_open(const char *file_name); @@ -159,7 +159,7 @@ INT8 ir_binary_open(const UINT8 category, const UINT8 sub_category, UINT8* binar } -UINT16 ir_decode(UINT8 key_code, UINT16* user_data, remote_ac_status_t* ac_status, BOOL change_wind_direction) +UINT16 ir_decode(UINT8 key_code, UINT16* user_data, t_remote_ac_status* ac_status, BOOL change_wind_direction) { if (IR_TYPE_COMMANDS == ir_binary_type) { @@ -257,7 +257,7 @@ static INT8 ir_ac_lib_open(UINT8 *binary, UINT16 binary_length) return IR_DECODE_SUCCEEDED; } -static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, UINT8 function_code, +static UINT16 ir_ac_lib_control(t_remote_ac_status ac_status, UINT16 *user_data, UINT8 function_code, BOOL change_wind_direction) { UINT16 time_length = 0; @@ -281,7 +281,7 @@ static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, ir_memcpy(ir_hex_code, context->default_code.data, context->default_code.len); #if defined USE_APPLY_TABLE - if(ac_status.acPower != AC_POWER_OFF) + if(ac_status.ac_power != AC_POWER_OFF) { for (i = AC_APPLY_POWER; i < AC_APPLY_MAX; i++) { @@ -289,7 +289,7 @@ static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, } } #else - if (ac_status.acPower == AC_POWER_OFF) + if (ac_status.ac_power == AC_POWER_OFF) { // otherwise, power should always be applied apply_power(ac_status, function_code); @@ -297,7 +297,7 @@ static UINT16 ir_ac_lib_control(remote_ac_status_t ac_status, UINT16 *user_data, else { // check the mode as the first priority, despite any other status - if (TRUE == context->n_mode[ac_status.acMode].enable) + if (TRUE == context->n_mode[ac_status.ac_mode].enable) { if (is_solo_function(function_code)) { @@ -400,7 +400,7 @@ INT8 get_temperature_range(UINT8 ac_mode, INT8 *temp_min, INT8 *temp_max) return IR_DECODE_FAILED; } - if (1 == context->n_mode[ac_mode].alltemp) + if (1 == context->n_mode[ac_mode].all_temp) { *temp_min = *temp_max = -1; return IR_DECODE_SUCCEEDED; @@ -410,7 +410,7 @@ INT8 get_temperature_range(UINT8 ac_mode, INT8 *temp_min, INT8 *temp_max) *temp_max = -1; for (i = 0; i < AC_TEMP_MAX; i++) { - if (isin(context->n_mode[ac_mode].temp, i, context->n_mode[ac_mode].temp_cnt) || + if (is_in(context->n_mode[ac_mode].temp, i, context->n_mode[ac_mode].temp_cnt) || (context->temp1.len != 0 && 0 == context->temp1.comp_data[i].seg_len) || (context->temp2.len != 0 && 0 == context->temp2.comp_data[i].seg_len)) { @@ -463,7 +463,7 @@ INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8 *supported_wind_speed) return IR_DECODE_FAILED; } - if (1 == context->n_mode[ac_mode].allspeed) + if (1 == context->n_mode[ac_mode].all_speed) { *supported_wind_speed = 0; return IR_DECODE_SUCCEEDED; @@ -473,7 +473,7 @@ INT8 get_supported_wind_speed(UINT8 ac_mode, UINT8 *supported_wind_speed) for (i = 0; i < AC_WS_MAX; i++) { - if (isin(context->n_mode[ac_mode].speed, i, context->n_mode[ac_mode].speed_cnt) || + if (is_in(context->n_mode[ac_mode].speed, i, context->n_mode[ac_mode].speed_cnt) || (context->speed1.len != 0 && 0 == context->speed1.comp_data[i].seg_len) || (context->speed2.len != 0 && 0 == context->speed2.comp_data[i].seg_len)) { diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_tv_control.c b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_tv_control.c index e4b04ba..78cb9b9 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_tv_control.c +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_tv_control.c @@ -26,12 +26,11 @@ struct buffer static struct buffer *pbuffer = &ir_file; -//static UINT8 *prot_name = NULL; static UINT8 *prot_cycles_num = NULL; -static ir_cycles_t *prot_cycles_data[IRDA_MAX]; +static t_ir_cycles *prot_cycles_data[IRDA_MAX]; static UINT8 prot_items_cnt = 0; -static ir_data_t *prot_items_data = NULL; -static ir_data_tv_t *remote_p; +static t_ir_data *prot_items_data = NULL; +static t_ir_data_tv *remote_p; static UINT8 *remote_pdata = NULL; static UINT16 time_index = 0; @@ -45,13 +44,13 @@ static BOOL get_ir_protocol(UINT8 encode_type); static BOOL get_ir_keymap(void); -static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time); +static void print_ir_time(t_ir_data *data, UINT8 key_index, UINT16 *ir_time); -static void process_decode_number(UINT8 keycode, ir_data_t *data, UINT8 valid_bits, UINT16 *ir_time); +static void process_decode_number(UINT8 keycode, t_ir_data *data, UINT8 valid_bits, UINT16 *ir_time); static void convert_to_ir_time(UINT8 value, UINT16 *ir_time); -static void replace_with(ir_cycles_t *pcycles_num, UINT16 *ir_time); +static void replace_with(t_ir_cycles *pcycles_num, UINT16 *ir_time); INT8 tv_lib_open(UINT8 *binary, UINT16 binary_length) @@ -109,8 +108,7 @@ static BOOL get_ir_protocol(UINT8 encode_type) pbuffer->offset = 0; - /* protocol name */ - // prot_name = pbuffer->data + pbuffer->offset; + /* t_ac_protocol name */ pbuffer->offset += name_size; /* cycles number */ @@ -145,7 +143,7 @@ static BOOL get_ir_protocol(UINT8 encode_type) { if (0 != prot_cycles_num[i]) { - prot_cycles_data[i] = (ir_cycles_t *) (&prot_cycles[sizeof(ir_cycles_t) * cycles_sum]); + prot_cycles_data[i] = (t_ir_cycles *) (&prot_cycles[sizeof(t_ir_cycles) * cycles_sum]); } else { @@ -153,15 +151,15 @@ static BOOL get_ir_protocol(UINT8 encode_type) } cycles_sum += prot_cycles_num[i]; } - pbuffer->offset += sizeof(ir_cycles_t) * cycles_sum; + pbuffer->offset += sizeof(t_ir_cycles) * cycles_sum; /* items count */ prot_items_cnt = pbuffer->data[pbuffer->offset]; pbuffer->offset += sizeof(UINT8); /* items data */ - prot_items_data = (ir_data_t *) (pbuffer->data + pbuffer->offset); - pbuffer->offset += prot_items_cnt * sizeof(ir_data_t); + prot_items_data = (t_ir_data *) (pbuffer->data + pbuffer->offset); + pbuffer->offset += prot_items_cnt * sizeof(t_ir_data); ir_toggle_bit = FALSE; @@ -170,8 +168,8 @@ static BOOL get_ir_protocol(UINT8 encode_type) static BOOL get_ir_keymap(void) { - remote_p = (ir_data_tv_t *) (pbuffer->data + pbuffer->offset); - pbuffer->offset += sizeof(ir_data_tv_t); + remote_p = (t_ir_data_tv *) (pbuffer->data + pbuffer->offset); + pbuffer->offset += sizeof(t_ir_data_tv); if (strncmp(remote_p->magic, "irda", 4) == 0) { @@ -182,11 +180,11 @@ static BOOL get_ir_keymap(void) return FALSE; } -static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time) +static void print_ir_time(t_ir_data *data, UINT8 key_index, UINT16 *ir_time) { UINT8 i = 0; UINT8 cycles_num = 0; - ir_cycles_t *pcycles = NULL; + t_ir_cycles *pcycles = NULL; UINT8 key_code = 0; if (NULL == data || NULL == ir_time) @@ -301,10 +299,7 @@ static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time) { break; } - else - { - pcycles++; - } + pcycles++; } } else @@ -331,7 +326,7 @@ static void print_ir_time(ir_data_t *data, UINT8 key_index, UINT16 *ir_time) } } -static void process_decode_number(UINT8 keycode, ir_data_t *data, UINT8 valid_bits, UINT16 *ir_time) +static void process_decode_number(UINT8 keycode, t_ir_data *data, UINT8 valid_bits, UINT16 *ir_time) { UINT8 i = 0; UINT8 value = 0; @@ -415,7 +410,7 @@ static void convert_to_ir_time(UINT8 value, UINT16 *ir_time) } } -static void replace_with(ir_cycles_t *pcycles_num, UINT16 *ir_time) +static void replace_with(t_ir_cycles *pcycles_num, UINT16 *ir_time) { if (NULL == pcycles_num || NULL == ir_time) { diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_utils.c b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_utils.c index bbe78c6..6867df7 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_utils.c +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/Irext/src/ir_utils.c @@ -23,7 +23,7 @@ UINT8 char_to_hex(char chr) return value; } -UINT8 chars_to_hex(UINT8 *p) +UINT8 chars_to_hex(const UINT8 *p) { return (char_to_hex(*p) << 4) + char_to_hex(*(p + 1)); } @@ -40,7 +40,7 @@ void string_to_hex_common(UINT8 *p, UINT8 *hex_data, UINT16 len) } } -void string_to_hex(UINT8 *p, ac_hex *pac_hex, UINT16 len) +void string_to_hex(UINT8 *p, t_ac_hex *pac_hex) { UINT8 i = 0; @@ -84,7 +84,7 @@ void hex_byte_to_double_char(char *dest, UINT8 length, UINT8 src) dest[1] = hex_half_byte_to_single_char(1, lo_num); } -BOOL isin(UINT8 array[], UINT8 value, UINT8 len) +BOOL is_in(const UINT8 *array, UINT8 value, UINT8 len) { UINT16 i = 0; for (i = 0; i < len; i++) diff --git a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/simpleBLEPeripheral.c b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/simpleBLEPeripheral.c index ef931a8..f57a7f6 100644 --- a/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/simpleBLEPeripheral.c +++ b/cc26xx-example/ti/BLE-CC264x/ble_cc26xx/Projects/ble/SimpleBLEPeripheral-IREXT/CC26xx/Source/Application/simpleBLEPeripheral.c @@ -140,16 +140,16 @@ static decode_control_block dccb = .decoded_length = 0, }; -static remote_ac_status_t ac_status = +static t_remote_ac_status ac_status = { - .acPower = AC_POWER_OFF, - .acTemp = AC_TEMP_24, - .acMode = AC_MODE_COOL, - .acWindDir = AC_SWING_ON, - .acWindSpeed = AC_WS_AUTO, - .acDisplay = 0, - .acSleep = 0, - .acTimer = 0, + .ac_power = AC_POWER_OFF, + .ac_temp = AC_TEMP_24, + .ac_mode = AC_MODE_COOL, + .ac_wind_dir = AC_SWING_ON, + .ac_wind_speed = AC_WS_AUTO, + .ac_display = 0, + .ac_sleep = 0, + .ac_timer = 0, }; diff --git a/pi3-smart-remote/.idea/misc.xml b/pi3-smart-remote/.idea/misc.xml index 5d19981..f3d13dd 100644 --- a/pi3-smart-remote/.idea/misc.xml +++ b/pi3-smart-remote/.idea/misc.xml @@ -27,17 +27,7 @@ - - - - - - - - - - - + diff --git a/pi3-smart-remote/app/build.gradle b/pi3-smart-remote/app/build.gradle index a46b939..f002f37 100644 --- a/pi3-smart-remote/app/build.gradle +++ b/pi3-smart-remote/app/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 26 - buildToolsVersion "26.0.0" + buildToolsVersion '26.0.2' defaultConfig { applicationId "net.irext.pi3sr" minSdkVersion 25 @@ -21,6 +21,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) + provided 'com.google.android.things:androidthings:0.5.1-devpreview' compile 'com.android.support:appcompat-v7:26.+' compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4' } diff --git a/pi3-smart-remote/app/src/main/AndroidManifest.xml b/pi3-smart-remote/app/src/main/AndroidManifest.xml index 5fd0694..1aaabc2 100644 --- a/pi3-smart-remote/app/src/main/AndroidManifest.xml +++ b/pi3-smart-remote/app/src/main/AndroidManifest.xml @@ -12,7 +12,7 @@ - + diff --git a/pi3-smart-remote/app/src/main/java/net/irext/pi3sr/Pi3SRApplication.java b/pi3-smart-remote/app/src/main/java/net/irext/pi3sr/Pi3SRApplication.java new file mode 100644 index 0000000..82c5cca --- /dev/null +++ b/pi3-smart-remote/app/src/main/java/net/irext/pi3sr/Pi3SRApplication.java @@ -0,0 +1,13 @@ +package net.irext.pi3sr; + +import android.app.Application; + +/** + * + * Pi3SRApplication + * + * created by strawmanbobi 2017-06-25 + */ +public class Pi3SRApplication extends Application { + +} diff --git a/pi3-smart-remote/app/src/main/java/net/irext/pi3sr/driver/HCSR501.java b/pi3-smart-remote/app/src/main/java/net/irext/pi3sr/driver/HCSR501.java new file mode 100644 index 0000000..74b958f --- /dev/null +++ b/pi3-smart-remote/app/src/main/java/net/irext/pi3sr/driver/HCSR501.java @@ -0,0 +1,63 @@ +package net.irext.pi3sr.driver; + +import android.util.Log; + +import com.google.android.things.pio.Gpio; +import com.google.android.things.pio.GpioCallback; + +import java.io.IOException; + +/** + * + * HC-SR501 driver + * + * created by strawmanbobi 2017-06-25 + */ +public class HCSR501 implements MotionSensor { + + private static final String TAG = HCSR501.class.getSimpleName(); + + private final Gpio bus; + + private final MotionSensor.Listener listener; + + public HCSR501(Gpio bus, Listener listener) { + this.bus = bus; + this.listener = listener; + } + + @Override + public void startup() { + try { + bus.setDirection(Gpio.DIRECTION_IN); + bus.setActiveType(Gpio.ACTIVE_HIGH); + bus.setEdgeTriggerType(Gpio.EDGE_RISING); + } catch (IOException e) { + throw new IllegalStateException("Sensor can't start - App is foobar'd", e); + } + try { + bus.registerGpioCallback(callback); + } catch (IOException e) { + throw new IllegalStateException("Sensor can't register callback", e); + } + } + + private final GpioCallback callback = new GpioCallback() { + @Override + public boolean onGpioEdge(Gpio gpio) { + listener.onMovement(); + return true; + } + }; + + @Override + public void shutdown() { + bus.unregisterGpioCallback(callback); + try { + bus.close(); + } catch (IOException e) { + Log.e(TAG, "Failed to shut down. You might get errors next time you try to start.", e); + } + } + +} diff --git a/pi3-smart-remote/app/src/main/java/net/irext/pi3sr/driver/MotionSensor.java b/pi3-smart-remote/app/src/main/java/net/irext/pi3sr/driver/MotionSensor.java new file mode 100644 index 0000000..c02676d --- /dev/null +++ b/pi3-smart-remote/app/src/main/java/net/irext/pi3sr/driver/MotionSensor.java @@ -0,0 +1,19 @@ +package net.irext.pi3sr.driver; + +/** + * + * motion sensor interface + * + * created by strawmanbobi 2017-06-25 + */ +public interface MotionSensor { + + void startup(); + + void shutdown(); + + public interface Listener { + void onMovement(); + } + +} diff --git a/pi3-smart-remote/app/src/main/java/net/irext/pi3sr/MainActivity.java b/pi3-smart-remote/app/src/main/java/net/irext/pi3sr/ui/MainActivity.java similarity index 71% rename from pi3-smart-remote/app/src/main/java/net/irext/pi3sr/MainActivity.java rename to pi3-smart-remote/app/src/main/java/net/irext/pi3sr/ui/MainActivity.java index c1546c5..dcaf926 100644 --- a/pi3-smart-remote/app/src/main/java/net/irext/pi3sr/MainActivity.java +++ b/pi3-smart-remote/app/src/main/java/net/irext/pi3sr/ui/MainActivity.java @@ -1,8 +1,16 @@ -package net.irext.pi3sr; +package net.irext.pi3sr.ui; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import net.irext.pi3sr.R; + +/** + * + * MainActivity + * + * created by strawmanbobi 2017-06-25 + */ public class MainActivity extends AppCompatActivity { @Override diff --git a/pi3-smart-remote/app/src/main/res/layout/activity_main.xml b/pi3-smart-remote/app/src/main/res/layout/activity_main.xml index 2eb84cf..722a2e0 100644 --- a/pi3-smart-remote/app/src/main/res/layout/activity_main.xml +++ b/pi3-smart-remote/app/src/main/res/layout/activity_main.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context="net.irext.pi3sr.MainActivity"> + tools:context="net.irext.pi3sr.ui.MainActivity"> ) +# find_package(AndroidThings REQUIRED) +# include_directories(${ANDROIDTHINGS_INCLUDE_DIRS}) +# target_link_libraries( ${ANDROIDTHINGS_LIBRARIES}) +# +# Finding the Source +# ------------------ +# Normally the libandroidthings headers and .so are expected to live in the +# same directory as this file, but if the ANDROIDTHINGS_DIR variable is +# provided in the app's build.gradle file, that path will be searched for the +# headers and .so first. For example: +# +# android { +# defaultConfig { +# externalNativeBuild { +# cmake { +# arguments "-DANDROIDTHINGS_DIR=" +# } +# } +# } +# +# ABI Specification +# ----------------- +# libandroidthings is only available for the ABIs supported by Android Things +# devices. By default, Android Studio attempts to build for all ABIs, which may +# lead to errors like: +# +# Could NOT find AndroidThings (missing: ANDROIDTHINGS_LIBRARY +# ANDROIDTHINGS_INCLUDE_DIR) +# +# To work around this, you will need to modify your app's build.gradle to +# only build the ABIs you need: +# +# android { +# defaultConfig { +# externalNativeBuild { +# cmake { +# abiFilters "", "", ... +# } +# } +# } + + +# Find the libandroidthings header files. +find_path(ANDROIDTHINGS_INCLUDE_DIR + NAMES pio/peripheral_manager_client.h + HINTS "${ANDROIDTHINGS_DIR}" "${CMAKE_CURRENT_LIST_DIR}" + PATH_SUFFIXES "${ANDROID_ABI}/include" + NO_CMAKE_FIND_ROOT_PATH) + +# Find the libandroidthings.so library. +find_library(ANDROIDTHINGS_LIBRARY + NAMES libandroidthings.so + HINTS "${ANDROIDTHINGS_DIR}" "${CMAKE_CURRENT_LIST_DIR}" + PATH_SUFFIXES "${ANDROID_ABI}/lib" + NO_CMAKE_FIND_ROOT_PATH) + +# Register the package and set ANDROIDTHINGS_FOUND. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(AndroidThings DEFAULT_MSG + ANDROIDTHINGS_LIBRARY + ANDROIDTHINGS_INCLUDE_DIR) + +# Hide these variables by default. +mark_as_advanced(ANDROIDTHINGS_INCLUDE_DIR ANDROIDTHINGS_LIBRARY) + +# Set the remaining variables we want to export. +set(ANDROIDTHINGS_LIBRARIES ${ANDROIDTHINGS_LIBRARY}) +set(ANDROIDTHINGS_INCLUDE_DIRS ${ANDROIDTHINGS_INCLUDE_DIR}) +set(ANDROIDTHINGS_DEFINITIONS "") + diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/LICENSE b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/LICENSE new file mode 100644 index 0000000..1af981f --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/README.md b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/README.md new file mode 100644 index 0000000..29d34cb --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/README.md @@ -0,0 +1,47 @@ +Android Things Native Library +============================= + +This repository contains the symbols and the headers for the Android Things +[Native PIO API](https://developer.android.com/things/sdk/pio/native.html) for the following architecture: +- `armeabi-v7a` +- `x86` + +Usage +===== + +- Unzip the latest [release](https://github.com/androidthings/native-libandroidthings/releases) in the native project directory (or in a shared location if you have many native projects). +- Add the following lines to the native project `CMakeLists.txt`: +``` +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ) +find_package(AndroidThings REQUIRED) +include_directories(${ANDROIDTHINGS_INCLUDE_DIRS}) +target_link_libraries( ${ANDROIDTHINGS_LIBRARIES}) +``` +- Add the following arch to the native module `build.gradle`: +``` +defaultConfig { + ndk { + abiFilters 'armeabi-v7a', 'x86' + } +} +``` + +License +======= + +Copyright 2016 The Android Open Source Project, Inc. + +Licensed to the Apache Software Foundation (ASF) under one or more contributor +license agreements. See the NOTICE file distributed with this work for +additional information regarding copyright ownership. The ASF licenses this +file to you under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations under +the License. diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/gpio.h b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/gpio.h new file mode 100644 index 0000000..653a4fe --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/gpio.h @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_PERIPHERALMANAGER_GPIO_H_ +#define SYSTEM_PERIPHERALMANAGER_GPIO_H_ + +#include +#include + +__BEGIN_DECLS + +/// @defgroup Gpio Gpio Interface +/// @brief Functions to control GPIO pins. +/// +/// These functions can be used to control GPIO. +/// @{ + +/// Edge trigger types. +typedef enum AGpioEdge { + AGPIO_EDGE_NONE = 0, /**< None */ + AGPIO_EDGE_RISING = 1, /**< Rising edge */ + AGPIO_EDGE_FALLING = 2, /**< Falling edge */ + AGPIO_EDGE_BOTH = 3 /**< Both edges */ +} AGpioEdge; + +/// GPIO direction types. +typedef enum AGpioDirection { + AGPIO_DIRECTION_IN = 0, /**< Input mode */ + AGPIO_DIRECTION_OUT_INITIALLY_HIGH = 1, /**< Output mode, initially high */ + AGPIO_DIRECTION_OUT_INITIALLY_LOW = 2 /**< Output mode, initially low */ +} AGpioDirection; + +/// Possible active types. +typedef enum AGpioActiveType { + AGPIO_ACTIVE_LOW = 0, /**< Active Low */ + AGPIO_ACTIVE_HIGH = 1 /**< Active High */ +} AGpioActiveType; + +typedef struct AGpio AGpio; + +/// Sets the GPIO direction to output. +/// @param gpio Pointer to the AGpio struct +/// @param direction One of DIRECTION_IN, +/// DIRECTION_OUT_INITIALLY_HIGH, DIRECTION_OUT_INITIALLY_LOW. +/// @return 0 on success, errno on error. +int AGpio_setDirection(const AGpio* gpio, AGpioDirection direction); + +/// Sets the interrupt edge trigger type. +/// @param gpio Pointer to the AGpio struct +/// @param type One of NONE_EDGE, RISING_EDGE, FALLING_EDGE or BOTH_EDGE. +/// @return 0 on success, errno on error. +int AGpio_setEdgeTriggerType(const AGpio* gpio, AGpioEdge type); + +/// Sets the GPIO’s active low/high status. +/// @param gpio Pointer to the AGpio struct. +/// @param type One of ACTIVE_HIGH, ACTIVE_LOW. +/// @return 0 on success, errno on error. +int AGpio_setActiveType(const AGpio* gpio, AGpioActiveType type); + +/// Sets the GPIO value (for output GPIO only). +/// @param gpio Pointer to the AGpio struct. +/// @param value Value to set. +/// @return 0 on success, errno on error. +int AGpio_setValue(const AGpio* gpio, int value); + +/// Gets the GPIO value (for input GPIO only). +/// @param gpio Pointer to the AGpio struct. +/// @param value Output pointer to the value of the GPIO. +/// @return 0 on success, errno on error. +int AGpio_getValue(const AGpio* gpio, int* value); + +/// Returns a file descriptor that can be used to poll on new data. +/// Can be passed to select/epoll to wait for data to become available. +/// @param gpio Pointer to the AGpio struct. +/// @param fd Output pointer to the file descriptor number. +/// @return 0 on success, errno on error. +int AGpio_getPollingFd(const AGpio* gpio, int* fd); + +/// Acknowledges the interrupt and resets the file descriptor. +/// This must be called after each event triggers in order to be able to +/// poll/select for another event. +/// @param fd Polling file descriptor to reset. +/// @return 0 on success, errno on error. +int AGpio_ackInterruptEvent(int fd); + +/// Destroys a AGpio struct. +/// @param gpio Pointer to the AGpio struct. +void AGpio_delete(AGpio* gpio); + +/// @} + +__END_DECLS + +#endif // SYSTEM_PERIPHERALMANAGER_GPIO_H_ diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/i2c_device.h b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/i2c_device.h new file mode 100644 index 0000000..8a5d890 --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/i2c_device.h @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_PERIPHERALMANAGER_I2C_DEVICE_H_ +#define SYSTEM_PERIPHERALMANAGER_I2C_DEVICE_H_ + +#include +#include + +__BEGIN_DECLS + +/// @defgroup I2c I2c device interface +/// @brief Functions to control an I2C device. +/// +/// These functions can be used to control an I2C device. +/// @{ + +typedef struct AI2cDevice AI2cDevice; + +/// Reads from the device. +/// @param device Pointer to the AI2cDevice struct. +/// @param data Output buffer to write the data to. +/// @param len Number of bytes to read. +/// @return 0 on success, errno on error +int AI2cDevice_read(const AI2cDevice* device, void* data, uint32_t len); + +/// Reads a byte from an I2C register. +/// @param device Pointer to the AI2cDevice struct. +/// @param reg Register to read from. +/// @param val Output pointer to value to read. +/// @return 0 on success, errno on error +int AI2cDevice_readRegByte(const AI2cDevice* device, uint8_t reg, uint8_t* val); + +/// Reads a word from an I2C register. +/// @param device Pointer to the AI2cDevice struct. +/// @param reg Register to read from. +/// @param val Output pointer to value to read. +/// @return 0 on success, errno on error +int AI2cDevice_readRegWord(const AI2cDevice* device, + uint8_t reg, + uint16_t* val); + +/// Reads from an I2C register. +/// @param device Pointer to the AI2cDevice struct. +/// @param reg Register to read from. +/// @param data Output buffer to write the data to. +/// @param len Number of bytes to read. +/// @return 0 on success, errno on error +int AI2cDevice_readRegBuffer(const AI2cDevice* device, + uint8_t reg, + void* data, + uint32_t len); + +/// Writes to the device. +/// @param device Pointer to the AI2cDevice struct. +/// @param data Buffer to write. +/// @param len Number of bytes to write. +/// @return 0 on success, errno on error +int AI2cDevice_write(const AI2cDevice* device, const void* data, uint32_t len); + +/// Writes a byte to an I2C register. +/// @param device Pointer to the AI2cDevice struct. +/// @param reg Register to write to. +/// @param val Value to write. +/// @return 0 on success, errno on error +int AI2cDevice_writeRegByte(const AI2cDevice* device, uint8_t reg, uint8_t val); + +/// Writes a word to an I2C register. +/// @param device Pointer to the AI2cDevice struct. +/// @param reg Register to write to. +/// @param val Value to write. +/// @return 0 on success, errno on error +int AI2cDevice_writeRegWord(const AI2cDevice* device, + uint8_t reg, + uint16_t val); + +/// Writes to an I2C register. +/// @param device Pointer to the AI2cDevice struct. +/// @param reg Register to write to. +/// @param data Data to write. +/// @param len Number of bytes to write. +/// @return 0 on success, errno on error +int AI2cDevice_writeRegBuffer(const AI2cDevice* device, + uint8_t reg, + const void* data, + uint32_t len); + +/// Destroys a AI2cDevice struct. +/// @param device Pointer to the AI2cDevice struct. +void AI2cDevice_delete(AI2cDevice* device); + +/// @} + +__END_DECLS + +#endif // SYSTEM_PERIPHERALMANAGER_I2C_DEVICE_H_ diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/i2s_device.h b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/i2s_device.h new file mode 100644 index 0000000..40f27ca --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/i2s_device.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_PERIPHERALMANAGER_I2S_H_ +#define SYSTEM_PERIPHERALMANAGER_I2S_H_ + +#include +#include + +__BEGIN_DECLS + +/// @defgroup I2s I2s Interface +/// @brief Functions to control I2S pins. +/// +/// These functions can be used to control I2S. +/// @{ + +/// Possible encodings +typedef enum AI2sEncoding { + AI2S_ENCODING_PCM_8_BIT, + AI2S_ENCODING_PCM_16_BIT, + AI2S_ENCODING_PCM_24_BIT, + AI2S_ENCODING_PCM_32_BIT +} AI2sEncoding; + +/// Flags to specify I2s bus direction. +typedef enum AI2sFlags { + AI2S_FLAG_DIRECTION_IN = 1 << 0, + AI2S_FLAG_DIRECTION_OUT = 1 << 1 +} AI2sFlags; + +typedef struct AI2sDevice AI2sDevice; + +/// Writes raw data to the I2S device. Multi-channel audio data is interleaved. +/// @param i2s Pointer to the AI2s struct. +/// @param data Data to write. +/// @param offset Offset to first byte in data. +/// @param size Number of bytes to write. +/// @param bytes_written Number of bytes written. +/// @return 0 on success, errno on error. +int AI2sDevice_write(const AI2sDevice* i2s, + const void* data, + int offset, + int size, + int* bytes_written); + +/// Reads raw data from the I2S device. Multi-channel audio data is interleaved. +/// @param i2s Pointer to the AI2s struct. +/// @param data Buffer to fill with data read. +/// @param offset Offset to first byte in data. +/// @param size Number of bytes to read. +/// @param bytes_read Number of bytes read. +/// @return 0 on success, errno on error. +int AI2sDevice_read( + const AI2sDevice* i2s, void* data, int offset, int size, int* bytes_read); + +/// Gets the timestamp when a specific sample entered the kernel. +/// @param i2s Pointer to the AI2s struct. +/// @param frame_position Output indicating number of frames read. +/// @param nano_time Output indicating time (ns) when the frame was read. +/// @param success Output indicating success (1) or failure (0). +/// @return 0 on success, errno on error. This will only be nonzero on a fatal +/// error such as the I2S device couldn't be found; in the normal case +/// that a timestamp isn't available the success param will be used. +int AI2sDevice_getInputTimestamp(const AI2sDevice* i2s, + int64_t* frame_position, + int64_t* nano_time, + int* success); + +/// Gets the timestamp when a specific sample exited the kernel. +/// @param i2s Pointer to the AI2s struct. +/// @param frame_position Output indicating number of frames written. +/// @param nano_time Output indicating time (ns) when the frame was written. +/// @param success Output indicating success (1) or failure (0). +/// @return 0 on success, errno on error. This will only be nonzero on a fatal +/// error such as the I2S device couldn't be found; in the normal case +/// that a timestamp isn't available the success param will be used. +int AI2sDevice_getOutputTimestamp(const AI2sDevice* i2s, + int64_t* frame_position, + int64_t* nano_time, + int* success); + +/// Destroys an AI2s struct. +/// @param i2s Pointer to the AI2s struct. +void AI2sDevice_delete(AI2sDevice* i2s); + +/// @} + +__END_DECLS + +#endif // SYSTEM_PERIPHERALMANAGER_I2S_H_ diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/peripheral_manager_client.h b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/peripheral_manager_client.h new file mode 100644 index 0000000..97202b0 --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/peripheral_manager_client.h @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_PERIPHERALMANAGER_PERIPHERAL_MANAGER_CLIENT_H_ +#define SYSTEM_PERIPHERALMANAGER_PERIPHERAL_MANAGER_CLIENT_H_ + +#include + +#include "gpio.h" +#include "i2c_device.h" +#include "i2s_device.h" +#include "pwm.h" +#include "spi_device.h" +#include "uart_device.h" + +__BEGIN_DECLS + +/// @defgroup PeripheralManagerClient Peripheral client functions +/// @brief Functions to access embedded peripherals +/// @{ + +typedef struct APeripheralManagerClient APeripheralManagerClient; + +/// Returns the list of GPIOs. +/// This does not take ownership into account. +/// The list must be freed by the caller. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param num_gpio Output pointer to the number of elements in the list. +/// @return The list of gpios. +char** APeripheralManagerClient_listGpio(const APeripheralManagerClient* client, + int* num_gpio); + +/// Opens a GPIO and takes ownership of it. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param name Name of the GPIO. +/// @param gpio Output pointer to the AGpio struct. Empty on error. +/// @return 0 on success, errno on error. +int APeripheralManagerClient_openGpio(const APeripheralManagerClient* client, + const char* name, + AGpio** gpio); + +/// Returns the list of PWMs. +/// This does not take ownership into account. +/// The list must be freed by the caller. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param num_gpio Output pointer to the number of elements in the list. +/// @return The list of pwms. +char** APeripheralManagerClient_listPwm(const APeripheralManagerClient* client, + int* num_pwm); + +/// Opens a PWM and takes ownership of it. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param name Name of the PWM. +/// @param gpio Output pointer to the AGpio struct. Empty on error. +/// @return 0 on success, errno on error. +int APeripheralManagerClient_openPwm(const APeripheralManagerClient* client, + const char* name, + APwm** pwm); + +/// Returns the list of SPI buses. +/// This does not take ownership into account. +/// The list must be freed by the caller. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param num_spi_buses Output pointer to the number of elements in the list. +/// @return The list of spi buses. +char** APeripheralManagerClient_listSpiBuses( + const APeripheralManagerClient* client, int* num_spi_buses); + +/// Opens a SPI device and takes ownership of it. +/// @oaram client Pointer to the APeripheralManagerClient struct. +/// @param name Name of the SPI device. +/// @param dev Output pointer to the ASpiDevice struct. Empty on error. +/// @return 0 on success, errno on error. +int APeripheralManagerClient_openSpiDevice( + const APeripheralManagerClient* client, const char* name, ASpiDevice** dev); + +/// Returns the list of I2C buses. +/// This does not take ownership into account. +/// The list must be freed by the caller. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param num_i2c_buses Output pointer to the number of elements in the list. +/// @return The list of i2c buses. +char** APeripheralManagerClient_listI2cBuses( + const APeripheralManagerClient* client, int* num_i2c_buses); + +/// Opens an I2C device and takes ownership of it. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param name Name of the I2C bus. +/// @param address Address of the I2C device. +/// @param dev Output pointer to the AI2cDevice struct. Empty on error. +/// @return 0 on success, errno on error +int APeripheralManagerClient_openI2cDevice( + const APeripheralManagerClient* client, + const char* name, + uint32_t address, + AI2cDevice** dev); + +/// Returns the list of UART buses. +/// This does not take ownership into account. +/// The list must be freed by the caller. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param num_uart_buses Output pointer to the number of elements in the list. +/// @return The list of uart buses. +char** APeripheralManagerClient_listUartDevices( + const APeripheralManagerClient* client, int* num_uart_buses); + +/// Opens an UART device and takes ownership of it. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param name Name of the UART device. +/// @param dev Output pointer to the AUartDevice struct. Empty on error. +/// @return 0 on success, errno on error +int APeripheralManagerClient_openUartDevice( + const APeripheralManagerClient* client, + const char* name, + AUartDevice** dev); + +/// Returns the list of I2S buses. +/// This does not take ownership into account. +/// The list must be freed by the caller. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param num_i2s_buses Output pointer to the number of elements in the list. +/// @return The list of I2S buses. +char** APeripheralManagerClient_listI2sDevices( + const APeripheralManagerClient* client, int* num_i2s_buses); + +/// Opens an I2S device and takes ownership of it. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param name Name of the I2S device. +/// @param encoding Device pcm encoding. +/// @param channels Number of channels. +/// @param rate Device rate in Hz. +/// @param flags Specify device supporting input, output or both. +/// @param dev Output pointer to the AI2sDevice struct. Empty on error. +/// @return 0 on success, errno on error +int APeripheralManagerClient_openI2sDevice( + const APeripheralManagerClient* client, + const char* name, + AI2sEncoding encoding, + int channels, + int rate, + int flags, + AI2sDevice** dev); + +/// Creates a new client. +/// @return A pointer to the created client. nullptr on errors. +APeripheralManagerClient* APeripheralManagerClient_new(); + +/// Destroys the peripheral manager client. +/// @param client Pointer to the APeripheralManagerClient struct. +void APeripheralManagerClient_delete(APeripheralManagerClient* client); + +/// @} + +__END_DECLS + +#endif // SYSTEM_PERIPHERALMANAGER_PERIPHERAL_MANAGER_CLIENT_H_ diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/pwm.h b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/pwm.h new file mode 100644 index 0000000..5dd3a51 --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/pwm.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_PERIPHERALMANAGER_PWM_H_ +#define SYSTEM_PERIPHERALMANAGER_PWM_H_ + +#include +#include + +__BEGIN_DECLS + +/// @defgroup Pwm Pwm Interface +/// @brief Functions to control PWM pins. +/// +/// These functions can be used to control PWM. +/// @{ + +typedef struct APwm APwm; + +/// Sets the PWM duty cycle. +/// @param gpio Pointer to the APwm struct. +/// @param duty_cycle Double between 0 and 100 inclusive. +/// @return 0 on success, errno on error. +int APwm_setDutyCycle(const APwm* pwm, double duty_cycle); + +/// Sets the PWM frequency. +/// @param gpio Pointer to the APwm struct. +/// @param freq Double denoting the frequency in Hz. +/// @return 0 on success, errno on error. +int APwm_setFrequencyHz(const APwm* pwm, double frequency); + +/// Enables the PWM. +/// @param gpio Pointer to the APwm struct. +/// @param enabled Non-zero to enable. +/// @return 0 on success, errno on error. +int APwm_setEnabled(const APwm* pwm, int enabled); + +/// Destroys a APwm struct. +/// @param pwm Pointer to the APwm struct. +void APwm_delete(APwm* pwm); + +/// @} + +__END_DECLS + +#endif // SYSTEM_PERIPHERALMANAGER_PWM_H_ diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/spi_device.h b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/spi_device.h new file mode 100644 index 0000000..51595d7 --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/spi_device.h @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_PERIPHERALMANAGER_SPI_DEVICE_H_ +#define SYSTEM_PERIPHERALMANAGER_SPI_DEVICE_H_ + +#include +#include + +__BEGIN_DECLS + +/// @defgroup Spi Spi device interface +/// @brief Functions to control an SPI device. +/// +/// These functions can be used to control an SPI device. +/// @{ + +/// Endianness. +typedef enum ASpiBitJustification { + ASPI_LSB_FIRST = 0, /**< Least significant bits first */ + ASPI_MSB_FIRST = 1 /**< Most significant bits first */ +} ASpiBitJustification; + +/// SPI modes (similar to the Linux kernel's modes). +typedef enum ASpiMode { + ASPI_MODE0 = 0, /**< CPHA=0, CPOL=0 */ + ASPI_MODE1 = 1, /**< CPHA=1, CPOL=0 */ + ASPI_MODE2 = 2, /**< CPHA=0, CPOL=1 */ + ASPI_MODE3 = 3 /**< CPHA=1, CPOL=1 */ +} ASpiMode; + +typedef struct ASpiDevice ASpiDevice; + +/// Writes a buffer to the device. +/// @param device Pointer to the ASpiDevice struct. +/// @param data Buffer to write. +/// @param len Length of the buffer. +/// @return 0 on success, errno on error. +int ASpiDevice_writeBuffer(const ASpiDevice* device, + const void* data, + size_t len); + +/// Reads a buffer from the device. +/// @param device Pointer to the ASpiDevice struct. +/// @param data Buffer to read into. +/// @param len Length of the buffer. +/// @return 0 on success, errno on error. +int ASpiDevice_readBuffer(const ASpiDevice* device, void* data, size_t len); + +/// Transfer data to the device. +/// @param device Pointer to the ASpiDevice struct. +/// @param tx_data Buffer to write. +/// @param rx_data Buffer to read data in. If NULL, no data will be read. +/// @param len Length of the buffers. +/// @return 0 on success, errno on error. +int ASpiDevice_transfer(const ASpiDevice* device, + const void* tx_data, + void* rx_data, + size_t len); + +/// Sets the frequency in Hertz. +/// @param device Pointer to the ASpiDevice struct. +/// @param freq_hz Frequency to set. +/// @return 0 on success, errno on error. +int ASpiDevice_setFrequency(const ASpiDevice* device, uint32_t freq_hz); + +/// Sets the SPI mode. +/// @param device Pointer to the ASpiDevice struct. +/// @param mode Mode to use. One of SPI_MODE0, SPI_MODE1, SPI_MODE2, SPI_MODE3. +/// @return 0 on success, errno on error. +int ASpiDevice_setMode(const ASpiDevice* device, ASpiMode mode); + +/// Sets the bit justification. +/// @param device Pointer to the ASpiDevice struct. +/// @param bit_justification One of SPI_LSB_FIRST OR SPI_MSB_FIRST. +/// @return 0 on success, errno on error. +int ASpiDevice_setBitJustification(const ASpiDevice* device, + ASpiBitJustification bit_justification); + +/// Sets the number of bits per words. +/// @param device Pointer to the ASpiDevice struct. +/// @param bits_per_word Number of bits per word. +/// @return 0 on success, errno on error. +int ASpiDevice_setBitsPerWord(const ASpiDevice* device, uint8_t bits_per_word); + +/// Sets the delay to wait after each transfer. +/// @param device Pointer to the ASpiDevice struct. +/// @param delay_usecs Delay in microseconds. +/// @return 0 on success, errno on error. +int ASpiDevice_setDelay(const ASpiDevice* device, uint16_t delay_usecs); + +/// Sets the chip select behavior after each transfer. +/// @param device Pointer to the ASpiDevice struct. +/// @param change If set, cs will be active between transfers. +/// @return 0 on success, errno on error. +int ASpiDevice_setCsChange(const ASpiDevice* device, int change); + +/// Destroys a ASpiDevice struct. +/// @param device Pointer to the ASpiDevice struct. +void ASpiDevice_delete(ASpiDevice* device); + +/// @} + +__END_DECLS + +#endif // SYSTEM_PERIPHERALMANAGER_SPI_DEVICE_H_ diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/uart_device.h b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/uart_device.h new file mode 100644 index 0000000..03ab6d7 --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/include/pio/uart_device.h @@ -0,0 +1,178 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_PERIPHERALMANAGER_UART_DEVICE_H_ +#define SYSTEM_PERIPHERALMANAGER_UART_DEVICE_H_ + +#include +#include + +__BEGIN_DECLS + +/// @defgroup Uart Uart device interface +/// @brief Functions to control an UART device. +/// +/// These functions can be used to control an UART device. +/// @{ + +/// UART Parity +typedef enum AUartParity { + AUART_PARITY_NONE = 0, /**< No parity */ + AUART_PARITY_EVEN = 1, /**< Even parity */ + AUART_PARITY_ODD = 2, /**< Odd parity */ + AUART_PARITY_MARK = 3, /**< Mark parity, always 1 */ + AUART_PARITY_SPACE = 4 /**< Space parity, always 0 */ +} AUartParity; + +/// Modem control lines. +typedef enum AUartModemControlLine { + AUART_MODEM_CONTROL_LE = 1 << 0, /**< Data set ready/Line enable */ + AUART_MODEM_CONTROL_DTR = 1 << 1, /**< Data terminal ready */ + AUART_MODEM_CONTROL_RTS = 1 << 2, /**< Request to send */ + AUART_MODEM_CONTROL_ST = 1 << 3, /**< Secondary TXD */ + AUART_MODEM_CONTROL_SR = 1 << 4, /**< Secondary RXD */ + AUART_MODEM_CONTROL_CTS = 1 << 5, /**< Clear to send */ + AUART_MODEM_CONTROL_CD = 1 << 6, /**< Data carrier detect */ + AUART_MODEM_CONTROL_RI = 1 << 7, /**< Ring */ + AUART_MODEM_CONTROL_DSR = 1 << 8 /**< Data set ready */ +} AUartModemControlLine; + +// Hardware Flow Control +typedef enum AUartHardwareFlowControl { + AUART_HARDWARE_FLOW_CONTROL_NONE = 0, /**< No hardware flow control */ + AUART_HARDWARE_FLOW_CONTROL_AUTO_RTSCTS = 1 /**< Auto RTS/CTS */ +} AUartHardwareFlowControl; + +/// Flush queue selection +typedef enum AUartFlushDirection { + AUART_FLUSH_IN = 0, /**< Flushes data received but not read */ + AUART_FLUSH_OUT = 1, /**< Flushes data written but not transmitted */ + AUART_FLUSH_IN_OUT = 2 /**< Flushes both in and out */ +} AUartFlushDirection; + +typedef struct AUartDevice AUartDevice; + +/// Writes to a UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param data Data to write. +/// @param len Size of the data to write. +/// @param bytes_written Output pointer to the number of bytes written. +/// @return 0 on success, errno on error. +int AUartDevice_write(const AUartDevice* device, + const void* data, + uint32_t len, + uint32_t* bytes_written); + +/// Reads from a UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param data Buffer to read the data into. +/// @param len Number of bytes to read. +/// @param bytes_read Output pointer to the number of bytes read. +/// @return 0 on success, errno on error. +int AUartDevice_read(const AUartDevice* device, + void* data, + uint32_t len, + uint32_t* bytes_read); + +/// Sets the input and output speed of a UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param baudrate Speed in baud. +/// @return 0 on success, errno on error. +int AUartDevice_setBaudrate(const AUartDevice* device, uint32_t baudrate); + +/// Sets number of stop bits for the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param stop_bits Number of stop bits. Typically 1 or 2. +/// @return 0 on success, errno on error. +int AUartDevice_setStopBits(const AUartDevice* device, uint32_t stop_bits); + +/// Sets the data size of a character for the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param data_size Number of bits per character. Typically between 5 and 8. +/// @return 0 on success, errno on error. +int AUartDevice_setDataSize(const AUartDevice* device, uint32_t data_size); + +/// Sets the parity mode for the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param mode Parity mode. +/// @return 0 on success, errno on error. +int AUartDevice_setParity(const AUartDevice* device, AUartParity mode); + +/// Sets the hardware flow control mode for the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param mode Flow control mode. +/// @return 0 on success, errno on error. +int AUartDevice_setHardwareFlowControl(const AUartDevice* device, + AUartHardwareFlowControl mode); + +/// Sets the modem control bits for the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param lines Lines to set. AUartModemControlLine values OR'ed together. +/// @return 0 on success, errno on error. +int AUartDevice_setModemControl(const AUartDevice* device, uint32_t lines); + +/// Clears the modem control bits for the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param lines Lines to clear. AUartModemControlLine values OR'ed together. +/// @return 0 on success, errno on error. +int AUartDevice_clearModemControl(const AUartDevice* device, uint32_t lines); + +/// Sends a break to the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param duration Duration of break transmission in milliseconds. If 0, +/// transmits zero-valued bits for at least 0.25 seconds, and not more +/// than 0.5 seconds. +/// @return 0 on success, errno on error. +int AUartDevice_sendBreak(const AUartDevice* device, uint32_t duration_msecs); + +/// Flushes specified queue for the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param direction Direction to flush. +/// @return 0 on success, errno on error. +int AUartDevice_flush(const AUartDevice* device, AUartFlushDirection direction); + +/// Gets a file descriptor to be notified when data can be read. +/// +/// You can use this file descriptor to poll on incoming data instead of +/// actively reading for new data. +/// +/// @param device Pointer to the AUartDevice struct. +/// @param fd Output pointer to the file descriptor. +/// @return 0 on success, errno on error. +int AUartDevice_getPollingFd(const AUartDevice* device, int* fd); + +/// Acknowledges an input event. +/// +/// This must be called after receiving an event notification on the polling +/// file descriptor. +/// If you don't acknowledge an event, peripheral manager will assume you are +/// still processing it and you will not receive any more events. +/// If you acknowledge an event before reading the data from the device, you +/// will receive an event immediately as there will still be data available. +/// +/// @param fd File descriptor to acknowledge the event on. +/// @return 0 on success, errno on error. +int AUartDevice_ackInputEvent(int fd); + +/// Destroys a AUartDevice struct. +/// @param device Pointer to the AUartDevice struct. +void AUartDevice_delete(AUartDevice* device); + +/// @} + +__END_DECLS + +#endif // SYSTEM_PERIPHERALMANAGER_UART_DEVICE_H_ diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/lib/libandroidthings.so b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/lib/libandroidthings.so new file mode 100644 index 0000000..fd485cb Binary files /dev/null and b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/armeabi-v7a/lib/libandroidthings.so differ diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/gpio.h b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/gpio.h new file mode 100644 index 0000000..653a4fe --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/gpio.h @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_PERIPHERALMANAGER_GPIO_H_ +#define SYSTEM_PERIPHERALMANAGER_GPIO_H_ + +#include +#include + +__BEGIN_DECLS + +/// @defgroup Gpio Gpio Interface +/// @brief Functions to control GPIO pins. +/// +/// These functions can be used to control GPIO. +/// @{ + +/// Edge trigger types. +typedef enum AGpioEdge { + AGPIO_EDGE_NONE = 0, /**< None */ + AGPIO_EDGE_RISING = 1, /**< Rising edge */ + AGPIO_EDGE_FALLING = 2, /**< Falling edge */ + AGPIO_EDGE_BOTH = 3 /**< Both edges */ +} AGpioEdge; + +/// GPIO direction types. +typedef enum AGpioDirection { + AGPIO_DIRECTION_IN = 0, /**< Input mode */ + AGPIO_DIRECTION_OUT_INITIALLY_HIGH = 1, /**< Output mode, initially high */ + AGPIO_DIRECTION_OUT_INITIALLY_LOW = 2 /**< Output mode, initially low */ +} AGpioDirection; + +/// Possible active types. +typedef enum AGpioActiveType { + AGPIO_ACTIVE_LOW = 0, /**< Active Low */ + AGPIO_ACTIVE_HIGH = 1 /**< Active High */ +} AGpioActiveType; + +typedef struct AGpio AGpio; + +/// Sets the GPIO direction to output. +/// @param gpio Pointer to the AGpio struct +/// @param direction One of DIRECTION_IN, +/// DIRECTION_OUT_INITIALLY_HIGH, DIRECTION_OUT_INITIALLY_LOW. +/// @return 0 on success, errno on error. +int AGpio_setDirection(const AGpio* gpio, AGpioDirection direction); + +/// Sets the interrupt edge trigger type. +/// @param gpio Pointer to the AGpio struct +/// @param type One of NONE_EDGE, RISING_EDGE, FALLING_EDGE or BOTH_EDGE. +/// @return 0 on success, errno on error. +int AGpio_setEdgeTriggerType(const AGpio* gpio, AGpioEdge type); + +/// Sets the GPIO’s active low/high status. +/// @param gpio Pointer to the AGpio struct. +/// @param type One of ACTIVE_HIGH, ACTIVE_LOW. +/// @return 0 on success, errno on error. +int AGpio_setActiveType(const AGpio* gpio, AGpioActiveType type); + +/// Sets the GPIO value (for output GPIO only). +/// @param gpio Pointer to the AGpio struct. +/// @param value Value to set. +/// @return 0 on success, errno on error. +int AGpio_setValue(const AGpio* gpio, int value); + +/// Gets the GPIO value (for input GPIO only). +/// @param gpio Pointer to the AGpio struct. +/// @param value Output pointer to the value of the GPIO. +/// @return 0 on success, errno on error. +int AGpio_getValue(const AGpio* gpio, int* value); + +/// Returns a file descriptor that can be used to poll on new data. +/// Can be passed to select/epoll to wait for data to become available. +/// @param gpio Pointer to the AGpio struct. +/// @param fd Output pointer to the file descriptor number. +/// @return 0 on success, errno on error. +int AGpio_getPollingFd(const AGpio* gpio, int* fd); + +/// Acknowledges the interrupt and resets the file descriptor. +/// This must be called after each event triggers in order to be able to +/// poll/select for another event. +/// @param fd Polling file descriptor to reset. +/// @return 0 on success, errno on error. +int AGpio_ackInterruptEvent(int fd); + +/// Destroys a AGpio struct. +/// @param gpio Pointer to the AGpio struct. +void AGpio_delete(AGpio* gpio); + +/// @} + +__END_DECLS + +#endif // SYSTEM_PERIPHERALMANAGER_GPIO_H_ diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/i2c_device.h b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/i2c_device.h new file mode 100644 index 0000000..8a5d890 --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/i2c_device.h @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_PERIPHERALMANAGER_I2C_DEVICE_H_ +#define SYSTEM_PERIPHERALMANAGER_I2C_DEVICE_H_ + +#include +#include + +__BEGIN_DECLS + +/// @defgroup I2c I2c device interface +/// @brief Functions to control an I2C device. +/// +/// These functions can be used to control an I2C device. +/// @{ + +typedef struct AI2cDevice AI2cDevice; + +/// Reads from the device. +/// @param device Pointer to the AI2cDevice struct. +/// @param data Output buffer to write the data to. +/// @param len Number of bytes to read. +/// @return 0 on success, errno on error +int AI2cDevice_read(const AI2cDevice* device, void* data, uint32_t len); + +/// Reads a byte from an I2C register. +/// @param device Pointer to the AI2cDevice struct. +/// @param reg Register to read from. +/// @param val Output pointer to value to read. +/// @return 0 on success, errno on error +int AI2cDevice_readRegByte(const AI2cDevice* device, uint8_t reg, uint8_t* val); + +/// Reads a word from an I2C register. +/// @param device Pointer to the AI2cDevice struct. +/// @param reg Register to read from. +/// @param val Output pointer to value to read. +/// @return 0 on success, errno on error +int AI2cDevice_readRegWord(const AI2cDevice* device, + uint8_t reg, + uint16_t* val); + +/// Reads from an I2C register. +/// @param device Pointer to the AI2cDevice struct. +/// @param reg Register to read from. +/// @param data Output buffer to write the data to. +/// @param len Number of bytes to read. +/// @return 0 on success, errno on error +int AI2cDevice_readRegBuffer(const AI2cDevice* device, + uint8_t reg, + void* data, + uint32_t len); + +/// Writes to the device. +/// @param device Pointer to the AI2cDevice struct. +/// @param data Buffer to write. +/// @param len Number of bytes to write. +/// @return 0 on success, errno on error +int AI2cDevice_write(const AI2cDevice* device, const void* data, uint32_t len); + +/// Writes a byte to an I2C register. +/// @param device Pointer to the AI2cDevice struct. +/// @param reg Register to write to. +/// @param val Value to write. +/// @return 0 on success, errno on error +int AI2cDevice_writeRegByte(const AI2cDevice* device, uint8_t reg, uint8_t val); + +/// Writes a word to an I2C register. +/// @param device Pointer to the AI2cDevice struct. +/// @param reg Register to write to. +/// @param val Value to write. +/// @return 0 on success, errno on error +int AI2cDevice_writeRegWord(const AI2cDevice* device, + uint8_t reg, + uint16_t val); + +/// Writes to an I2C register. +/// @param device Pointer to the AI2cDevice struct. +/// @param reg Register to write to. +/// @param data Data to write. +/// @param len Number of bytes to write. +/// @return 0 on success, errno on error +int AI2cDevice_writeRegBuffer(const AI2cDevice* device, + uint8_t reg, + const void* data, + uint32_t len); + +/// Destroys a AI2cDevice struct. +/// @param device Pointer to the AI2cDevice struct. +void AI2cDevice_delete(AI2cDevice* device); + +/// @} + +__END_DECLS + +#endif // SYSTEM_PERIPHERALMANAGER_I2C_DEVICE_H_ diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/i2s_device.h b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/i2s_device.h new file mode 100644 index 0000000..40f27ca --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/i2s_device.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_PERIPHERALMANAGER_I2S_H_ +#define SYSTEM_PERIPHERALMANAGER_I2S_H_ + +#include +#include + +__BEGIN_DECLS + +/// @defgroup I2s I2s Interface +/// @brief Functions to control I2S pins. +/// +/// These functions can be used to control I2S. +/// @{ + +/// Possible encodings +typedef enum AI2sEncoding { + AI2S_ENCODING_PCM_8_BIT, + AI2S_ENCODING_PCM_16_BIT, + AI2S_ENCODING_PCM_24_BIT, + AI2S_ENCODING_PCM_32_BIT +} AI2sEncoding; + +/// Flags to specify I2s bus direction. +typedef enum AI2sFlags { + AI2S_FLAG_DIRECTION_IN = 1 << 0, + AI2S_FLAG_DIRECTION_OUT = 1 << 1 +} AI2sFlags; + +typedef struct AI2sDevice AI2sDevice; + +/// Writes raw data to the I2S device. Multi-channel audio data is interleaved. +/// @param i2s Pointer to the AI2s struct. +/// @param data Data to write. +/// @param offset Offset to first byte in data. +/// @param size Number of bytes to write. +/// @param bytes_written Number of bytes written. +/// @return 0 on success, errno on error. +int AI2sDevice_write(const AI2sDevice* i2s, + const void* data, + int offset, + int size, + int* bytes_written); + +/// Reads raw data from the I2S device. Multi-channel audio data is interleaved. +/// @param i2s Pointer to the AI2s struct. +/// @param data Buffer to fill with data read. +/// @param offset Offset to first byte in data. +/// @param size Number of bytes to read. +/// @param bytes_read Number of bytes read. +/// @return 0 on success, errno on error. +int AI2sDevice_read( + const AI2sDevice* i2s, void* data, int offset, int size, int* bytes_read); + +/// Gets the timestamp when a specific sample entered the kernel. +/// @param i2s Pointer to the AI2s struct. +/// @param frame_position Output indicating number of frames read. +/// @param nano_time Output indicating time (ns) when the frame was read. +/// @param success Output indicating success (1) or failure (0). +/// @return 0 on success, errno on error. This will only be nonzero on a fatal +/// error such as the I2S device couldn't be found; in the normal case +/// that a timestamp isn't available the success param will be used. +int AI2sDevice_getInputTimestamp(const AI2sDevice* i2s, + int64_t* frame_position, + int64_t* nano_time, + int* success); + +/// Gets the timestamp when a specific sample exited the kernel. +/// @param i2s Pointer to the AI2s struct. +/// @param frame_position Output indicating number of frames written. +/// @param nano_time Output indicating time (ns) when the frame was written. +/// @param success Output indicating success (1) or failure (0). +/// @return 0 on success, errno on error. This will only be nonzero on a fatal +/// error such as the I2S device couldn't be found; in the normal case +/// that a timestamp isn't available the success param will be used. +int AI2sDevice_getOutputTimestamp(const AI2sDevice* i2s, + int64_t* frame_position, + int64_t* nano_time, + int* success); + +/// Destroys an AI2s struct. +/// @param i2s Pointer to the AI2s struct. +void AI2sDevice_delete(AI2sDevice* i2s); + +/// @} + +__END_DECLS + +#endif // SYSTEM_PERIPHERALMANAGER_I2S_H_ diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/peripheral_manager_client.h b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/peripheral_manager_client.h new file mode 100644 index 0000000..97202b0 --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/peripheral_manager_client.h @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_PERIPHERALMANAGER_PERIPHERAL_MANAGER_CLIENT_H_ +#define SYSTEM_PERIPHERALMANAGER_PERIPHERAL_MANAGER_CLIENT_H_ + +#include + +#include "gpio.h" +#include "i2c_device.h" +#include "i2s_device.h" +#include "pwm.h" +#include "spi_device.h" +#include "uart_device.h" + +__BEGIN_DECLS + +/// @defgroup PeripheralManagerClient Peripheral client functions +/// @brief Functions to access embedded peripherals +/// @{ + +typedef struct APeripheralManagerClient APeripheralManagerClient; + +/// Returns the list of GPIOs. +/// This does not take ownership into account. +/// The list must be freed by the caller. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param num_gpio Output pointer to the number of elements in the list. +/// @return The list of gpios. +char** APeripheralManagerClient_listGpio(const APeripheralManagerClient* client, + int* num_gpio); + +/// Opens a GPIO and takes ownership of it. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param name Name of the GPIO. +/// @param gpio Output pointer to the AGpio struct. Empty on error. +/// @return 0 on success, errno on error. +int APeripheralManagerClient_openGpio(const APeripheralManagerClient* client, + const char* name, + AGpio** gpio); + +/// Returns the list of PWMs. +/// This does not take ownership into account. +/// The list must be freed by the caller. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param num_gpio Output pointer to the number of elements in the list. +/// @return The list of pwms. +char** APeripheralManagerClient_listPwm(const APeripheralManagerClient* client, + int* num_pwm); + +/// Opens a PWM and takes ownership of it. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param name Name of the PWM. +/// @param gpio Output pointer to the AGpio struct. Empty on error. +/// @return 0 on success, errno on error. +int APeripheralManagerClient_openPwm(const APeripheralManagerClient* client, + const char* name, + APwm** pwm); + +/// Returns the list of SPI buses. +/// This does not take ownership into account. +/// The list must be freed by the caller. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param num_spi_buses Output pointer to the number of elements in the list. +/// @return The list of spi buses. +char** APeripheralManagerClient_listSpiBuses( + const APeripheralManagerClient* client, int* num_spi_buses); + +/// Opens a SPI device and takes ownership of it. +/// @oaram client Pointer to the APeripheralManagerClient struct. +/// @param name Name of the SPI device. +/// @param dev Output pointer to the ASpiDevice struct. Empty on error. +/// @return 0 on success, errno on error. +int APeripheralManagerClient_openSpiDevice( + const APeripheralManagerClient* client, const char* name, ASpiDevice** dev); + +/// Returns the list of I2C buses. +/// This does not take ownership into account. +/// The list must be freed by the caller. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param num_i2c_buses Output pointer to the number of elements in the list. +/// @return The list of i2c buses. +char** APeripheralManagerClient_listI2cBuses( + const APeripheralManagerClient* client, int* num_i2c_buses); + +/// Opens an I2C device and takes ownership of it. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param name Name of the I2C bus. +/// @param address Address of the I2C device. +/// @param dev Output pointer to the AI2cDevice struct. Empty on error. +/// @return 0 on success, errno on error +int APeripheralManagerClient_openI2cDevice( + const APeripheralManagerClient* client, + const char* name, + uint32_t address, + AI2cDevice** dev); + +/// Returns the list of UART buses. +/// This does not take ownership into account. +/// The list must be freed by the caller. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param num_uart_buses Output pointer to the number of elements in the list. +/// @return The list of uart buses. +char** APeripheralManagerClient_listUartDevices( + const APeripheralManagerClient* client, int* num_uart_buses); + +/// Opens an UART device and takes ownership of it. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param name Name of the UART device. +/// @param dev Output pointer to the AUartDevice struct. Empty on error. +/// @return 0 on success, errno on error +int APeripheralManagerClient_openUartDevice( + const APeripheralManagerClient* client, + const char* name, + AUartDevice** dev); + +/// Returns the list of I2S buses. +/// This does not take ownership into account. +/// The list must be freed by the caller. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param num_i2s_buses Output pointer to the number of elements in the list. +/// @return The list of I2S buses. +char** APeripheralManagerClient_listI2sDevices( + const APeripheralManagerClient* client, int* num_i2s_buses); + +/// Opens an I2S device and takes ownership of it. +/// @param client Pointer to the APeripheralManagerClient struct. +/// @param name Name of the I2S device. +/// @param encoding Device pcm encoding. +/// @param channels Number of channels. +/// @param rate Device rate in Hz. +/// @param flags Specify device supporting input, output or both. +/// @param dev Output pointer to the AI2sDevice struct. Empty on error. +/// @return 0 on success, errno on error +int APeripheralManagerClient_openI2sDevice( + const APeripheralManagerClient* client, + const char* name, + AI2sEncoding encoding, + int channels, + int rate, + int flags, + AI2sDevice** dev); + +/// Creates a new client. +/// @return A pointer to the created client. nullptr on errors. +APeripheralManagerClient* APeripheralManagerClient_new(); + +/// Destroys the peripheral manager client. +/// @param client Pointer to the APeripheralManagerClient struct. +void APeripheralManagerClient_delete(APeripheralManagerClient* client); + +/// @} + +__END_DECLS + +#endif // SYSTEM_PERIPHERALMANAGER_PERIPHERAL_MANAGER_CLIENT_H_ diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/pwm.h b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/pwm.h new file mode 100644 index 0000000..5dd3a51 --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/pwm.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_PERIPHERALMANAGER_PWM_H_ +#define SYSTEM_PERIPHERALMANAGER_PWM_H_ + +#include +#include + +__BEGIN_DECLS + +/// @defgroup Pwm Pwm Interface +/// @brief Functions to control PWM pins. +/// +/// These functions can be used to control PWM. +/// @{ + +typedef struct APwm APwm; + +/// Sets the PWM duty cycle. +/// @param gpio Pointer to the APwm struct. +/// @param duty_cycle Double between 0 and 100 inclusive. +/// @return 0 on success, errno on error. +int APwm_setDutyCycle(const APwm* pwm, double duty_cycle); + +/// Sets the PWM frequency. +/// @param gpio Pointer to the APwm struct. +/// @param freq Double denoting the frequency in Hz. +/// @return 0 on success, errno on error. +int APwm_setFrequencyHz(const APwm* pwm, double frequency); + +/// Enables the PWM. +/// @param gpio Pointer to the APwm struct. +/// @param enabled Non-zero to enable. +/// @return 0 on success, errno on error. +int APwm_setEnabled(const APwm* pwm, int enabled); + +/// Destroys a APwm struct. +/// @param pwm Pointer to the APwm struct. +void APwm_delete(APwm* pwm); + +/// @} + +__END_DECLS + +#endif // SYSTEM_PERIPHERALMANAGER_PWM_H_ diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/spi_device.h b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/spi_device.h new file mode 100644 index 0000000..51595d7 --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/spi_device.h @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_PERIPHERALMANAGER_SPI_DEVICE_H_ +#define SYSTEM_PERIPHERALMANAGER_SPI_DEVICE_H_ + +#include +#include + +__BEGIN_DECLS + +/// @defgroup Spi Spi device interface +/// @brief Functions to control an SPI device. +/// +/// These functions can be used to control an SPI device. +/// @{ + +/// Endianness. +typedef enum ASpiBitJustification { + ASPI_LSB_FIRST = 0, /**< Least significant bits first */ + ASPI_MSB_FIRST = 1 /**< Most significant bits first */ +} ASpiBitJustification; + +/// SPI modes (similar to the Linux kernel's modes). +typedef enum ASpiMode { + ASPI_MODE0 = 0, /**< CPHA=0, CPOL=0 */ + ASPI_MODE1 = 1, /**< CPHA=1, CPOL=0 */ + ASPI_MODE2 = 2, /**< CPHA=0, CPOL=1 */ + ASPI_MODE3 = 3 /**< CPHA=1, CPOL=1 */ +} ASpiMode; + +typedef struct ASpiDevice ASpiDevice; + +/// Writes a buffer to the device. +/// @param device Pointer to the ASpiDevice struct. +/// @param data Buffer to write. +/// @param len Length of the buffer. +/// @return 0 on success, errno on error. +int ASpiDevice_writeBuffer(const ASpiDevice* device, + const void* data, + size_t len); + +/// Reads a buffer from the device. +/// @param device Pointer to the ASpiDevice struct. +/// @param data Buffer to read into. +/// @param len Length of the buffer. +/// @return 0 on success, errno on error. +int ASpiDevice_readBuffer(const ASpiDevice* device, void* data, size_t len); + +/// Transfer data to the device. +/// @param device Pointer to the ASpiDevice struct. +/// @param tx_data Buffer to write. +/// @param rx_data Buffer to read data in. If NULL, no data will be read. +/// @param len Length of the buffers. +/// @return 0 on success, errno on error. +int ASpiDevice_transfer(const ASpiDevice* device, + const void* tx_data, + void* rx_data, + size_t len); + +/// Sets the frequency in Hertz. +/// @param device Pointer to the ASpiDevice struct. +/// @param freq_hz Frequency to set. +/// @return 0 on success, errno on error. +int ASpiDevice_setFrequency(const ASpiDevice* device, uint32_t freq_hz); + +/// Sets the SPI mode. +/// @param device Pointer to the ASpiDevice struct. +/// @param mode Mode to use. One of SPI_MODE0, SPI_MODE1, SPI_MODE2, SPI_MODE3. +/// @return 0 on success, errno on error. +int ASpiDevice_setMode(const ASpiDevice* device, ASpiMode mode); + +/// Sets the bit justification. +/// @param device Pointer to the ASpiDevice struct. +/// @param bit_justification One of SPI_LSB_FIRST OR SPI_MSB_FIRST. +/// @return 0 on success, errno on error. +int ASpiDevice_setBitJustification(const ASpiDevice* device, + ASpiBitJustification bit_justification); + +/// Sets the number of bits per words. +/// @param device Pointer to the ASpiDevice struct. +/// @param bits_per_word Number of bits per word. +/// @return 0 on success, errno on error. +int ASpiDevice_setBitsPerWord(const ASpiDevice* device, uint8_t bits_per_word); + +/// Sets the delay to wait after each transfer. +/// @param device Pointer to the ASpiDevice struct. +/// @param delay_usecs Delay in microseconds. +/// @return 0 on success, errno on error. +int ASpiDevice_setDelay(const ASpiDevice* device, uint16_t delay_usecs); + +/// Sets the chip select behavior after each transfer. +/// @param device Pointer to the ASpiDevice struct. +/// @param change If set, cs will be active between transfers. +/// @return 0 on success, errno on error. +int ASpiDevice_setCsChange(const ASpiDevice* device, int change); + +/// Destroys a ASpiDevice struct. +/// @param device Pointer to the ASpiDevice struct. +void ASpiDevice_delete(ASpiDevice* device); + +/// @} + +__END_DECLS + +#endif // SYSTEM_PERIPHERALMANAGER_SPI_DEVICE_H_ diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/uart_device.h b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/uart_device.h new file mode 100644 index 0000000..03ab6d7 --- /dev/null +++ b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/include/pio/uart_device.h @@ -0,0 +1,178 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_PERIPHERALMANAGER_UART_DEVICE_H_ +#define SYSTEM_PERIPHERALMANAGER_UART_DEVICE_H_ + +#include +#include + +__BEGIN_DECLS + +/// @defgroup Uart Uart device interface +/// @brief Functions to control an UART device. +/// +/// These functions can be used to control an UART device. +/// @{ + +/// UART Parity +typedef enum AUartParity { + AUART_PARITY_NONE = 0, /**< No parity */ + AUART_PARITY_EVEN = 1, /**< Even parity */ + AUART_PARITY_ODD = 2, /**< Odd parity */ + AUART_PARITY_MARK = 3, /**< Mark parity, always 1 */ + AUART_PARITY_SPACE = 4 /**< Space parity, always 0 */ +} AUartParity; + +/// Modem control lines. +typedef enum AUartModemControlLine { + AUART_MODEM_CONTROL_LE = 1 << 0, /**< Data set ready/Line enable */ + AUART_MODEM_CONTROL_DTR = 1 << 1, /**< Data terminal ready */ + AUART_MODEM_CONTROL_RTS = 1 << 2, /**< Request to send */ + AUART_MODEM_CONTROL_ST = 1 << 3, /**< Secondary TXD */ + AUART_MODEM_CONTROL_SR = 1 << 4, /**< Secondary RXD */ + AUART_MODEM_CONTROL_CTS = 1 << 5, /**< Clear to send */ + AUART_MODEM_CONTROL_CD = 1 << 6, /**< Data carrier detect */ + AUART_MODEM_CONTROL_RI = 1 << 7, /**< Ring */ + AUART_MODEM_CONTROL_DSR = 1 << 8 /**< Data set ready */ +} AUartModemControlLine; + +// Hardware Flow Control +typedef enum AUartHardwareFlowControl { + AUART_HARDWARE_FLOW_CONTROL_NONE = 0, /**< No hardware flow control */ + AUART_HARDWARE_FLOW_CONTROL_AUTO_RTSCTS = 1 /**< Auto RTS/CTS */ +} AUartHardwareFlowControl; + +/// Flush queue selection +typedef enum AUartFlushDirection { + AUART_FLUSH_IN = 0, /**< Flushes data received but not read */ + AUART_FLUSH_OUT = 1, /**< Flushes data written but not transmitted */ + AUART_FLUSH_IN_OUT = 2 /**< Flushes both in and out */ +} AUartFlushDirection; + +typedef struct AUartDevice AUartDevice; + +/// Writes to a UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param data Data to write. +/// @param len Size of the data to write. +/// @param bytes_written Output pointer to the number of bytes written. +/// @return 0 on success, errno on error. +int AUartDevice_write(const AUartDevice* device, + const void* data, + uint32_t len, + uint32_t* bytes_written); + +/// Reads from a UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param data Buffer to read the data into. +/// @param len Number of bytes to read. +/// @param bytes_read Output pointer to the number of bytes read. +/// @return 0 on success, errno on error. +int AUartDevice_read(const AUartDevice* device, + void* data, + uint32_t len, + uint32_t* bytes_read); + +/// Sets the input and output speed of a UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param baudrate Speed in baud. +/// @return 0 on success, errno on error. +int AUartDevice_setBaudrate(const AUartDevice* device, uint32_t baudrate); + +/// Sets number of stop bits for the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param stop_bits Number of stop bits. Typically 1 or 2. +/// @return 0 on success, errno on error. +int AUartDevice_setStopBits(const AUartDevice* device, uint32_t stop_bits); + +/// Sets the data size of a character for the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param data_size Number of bits per character. Typically between 5 and 8. +/// @return 0 on success, errno on error. +int AUartDevice_setDataSize(const AUartDevice* device, uint32_t data_size); + +/// Sets the parity mode for the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param mode Parity mode. +/// @return 0 on success, errno on error. +int AUartDevice_setParity(const AUartDevice* device, AUartParity mode); + +/// Sets the hardware flow control mode for the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param mode Flow control mode. +/// @return 0 on success, errno on error. +int AUartDevice_setHardwareFlowControl(const AUartDevice* device, + AUartHardwareFlowControl mode); + +/// Sets the modem control bits for the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param lines Lines to set. AUartModemControlLine values OR'ed together. +/// @return 0 on success, errno on error. +int AUartDevice_setModemControl(const AUartDevice* device, uint32_t lines); + +/// Clears the modem control bits for the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param lines Lines to clear. AUartModemControlLine values OR'ed together. +/// @return 0 on success, errno on error. +int AUartDevice_clearModemControl(const AUartDevice* device, uint32_t lines); + +/// Sends a break to the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param duration Duration of break transmission in milliseconds. If 0, +/// transmits zero-valued bits for at least 0.25 seconds, and not more +/// than 0.5 seconds. +/// @return 0 on success, errno on error. +int AUartDevice_sendBreak(const AUartDevice* device, uint32_t duration_msecs); + +/// Flushes specified queue for the UART device. +/// @param device Pointer to the AUartDevice struct. +/// @param direction Direction to flush. +/// @return 0 on success, errno on error. +int AUartDevice_flush(const AUartDevice* device, AUartFlushDirection direction); + +/// Gets a file descriptor to be notified when data can be read. +/// +/// You can use this file descriptor to poll on incoming data instead of +/// actively reading for new data. +/// +/// @param device Pointer to the AUartDevice struct. +/// @param fd Output pointer to the file descriptor. +/// @return 0 on success, errno on error. +int AUartDevice_getPollingFd(const AUartDevice* device, int* fd); + +/// Acknowledges an input event. +/// +/// This must be called after receiving an event notification on the polling +/// file descriptor. +/// If you don't acknowledge an event, peripheral manager will assume you are +/// still processing it and you will not receive any more events. +/// If you acknowledge an event before reading the data from the device, you +/// will receive an event immediately as there will still be data available. +/// +/// @param fd File descriptor to acknowledge the event on. +/// @return 0 on success, errno on error. +int AUartDevice_ackInputEvent(int fd); + +/// Destroys a AUartDevice struct. +/// @param device Pointer to the AUartDevice struct. +void AUartDevice_delete(AUartDevice* device); + +/// @} + +__END_DECLS + +#endif // SYSTEM_PERIPHERALMANAGER_UART_DEVICE_H_ diff --git a/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/lib/libandroidthings.so b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/lib/libandroidthings.so new file mode 100644 index 0000000..1ff0285 Binary files /dev/null and b/pi3-smart-remote/native-libandroidthings-0.5.1-devpreview/x86/lib/libandroidthings.so differ