Skip to content

Commit b50b54a

Browse files
committed
add ir example
1 parent 4bb1591 commit b50b54a

6 files changed

Lines changed: 432 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
##
2+
# @file CMakeLists.txt
3+
# @brief
4+
#/
5+
6+
# APP_PATH
7+
set(APP_PATH ${CMAKE_CURRENT_LIST_DIR})
8+
9+
# APP_NAME
10+
get_filename_component(APP_NAME ${APP_PATH} NAME)
11+
12+
# APP_SRC
13+
aux_source_directory(${APP_PATH}/src APP_SRC)
14+
15+
# APP_INC
16+
set(APP_INC ${APP_PATH}/include)
17+
18+
# APP_OPTIONS
19+
set(APP_OPTIONS "-W")
20+
list(APPEND APP_OPTIONS "-Wall")
21+
list(APPEND APP_OPTIONS "-DSTATIC_IN_RELEASE=static")
22+
list(APPEND APP_OPTIONS -DEXAMPLE_VER="${EXAMPLE_VER}")
23+
add_definitions(-DMAJOR_VERSION=4 -DMINOR_VERSION=1 -DMICRO_VERSION=1 -DVERSION=\"4.1.1\")
24+
25+
########################################
26+
# Target Configure
27+
########################################
28+
add_library(${EXAMPLE_LIB})
29+
message(STATUS "EXAMPLE_LIB:${APP_PATH}")
30+
31+
target_sources(${EXAMPLE_LIB}
32+
PRIVATE
33+
${APP_SRC}
34+
)
35+
36+
target_include_directories(${EXAMPLE_LIB}
37+
PRIVATE
38+
${APP_INC}
39+
)
40+
41+
target_compile_options(${EXAMPLE_LIB}
42+
PRIVATE
43+
${APP_OPTIONS}
44+
)

examples/peripherals/ir/Kconfig

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
menu "Application config"
2+
config EXAMPLE_IR
3+
bool
4+
default y
5+
select ENABLE_IR
6+
7+
config EXAMPLE_IR_ENABLE_NEC
8+
bool "Enable NEC demo"
9+
default y
10+
help
11+
Enable the NEC demo.
12+
13+
config EXAMPLE_IR_SEND_TIMER
14+
int "IR send timer"
15+
default 3
16+
range 0 3
17+
help
18+
Select the timer for IR send driver.
19+
20+
config EXAMPLE_IR_RECV_TIMER
21+
int "IR recv timer"
22+
default 3
23+
range 0 3
24+
help
25+
Select the timer for IR recv driver.
26+
27+
config EXAMPLE_IR_TX_PIN
28+
int "IR tx pin"
29+
default 24
30+
range 0 63
31+
help
32+
Select the TX pin for IR driver.
33+
34+
config EXAMPLE_IR_RX_PIN
35+
int "IR rx pin"
36+
default 26
37+
range 0 63
38+
help
39+
Select the RX pin for IR driver.
40+
endmenu
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_BOARD_CHOICE_T5AI=y
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_BOARD_CHOICE_T5AI=y
2+
CONFIG_TUYA_T5AI_BOARD_EX_MODULE_NONE=y
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**
2+
* @file example_drv_ir.h
3+
* @brief Infrared communication example driver interface for Tuya IoT devices.
4+
*
5+
* This header file provides the interface definitions for demonstrating
6+
* infrared communication capabilities using Tuya's IR peripheral drivers.
7+
* It serves as an educational and testing framework for developers to
8+
* understand and implement IR functionality in their Tuya IoT applications.
9+
*
10+
* The example demonstrates:
11+
* - Hardware registration and configuration for IR devices
12+
* - Driver initialization and setup procedures
13+
* - Basic IR transmission and reception operations
14+
* - Integration with Tuya's TDD (Tuya Device Driver) and TDL (Tuya Device Layer) systems
15+
*
16+
* This interface abstracts the complexity of IR hardware management and
17+
* provides simple functions for registering IR hardware, opening drivers,
18+
* and running IR communication examples. It supports multiple hardware
19+
* platforms and can be configured for different IR protocols including
20+
* NEC protocol and raw timecode transmission.
21+
*
22+
* The example is designed to work with various Tuya-supported microcontroller
23+
* platforms and provides a foundation for developing custom IR-enabled
24+
* IoT applications.
25+
*
26+
* @copyright Copyright (c) 2021-2025 Tuya Inc. All Rights Reserved.
27+
*
28+
*/
29+
30+
#ifndef __EXAMPLE_IR_H__
31+
#define __EXAMPLE_IR_H__
32+
33+
#include "tuya_cloud_types.h"
34+
35+
#ifdef __cplusplus
36+
extern "C" {
37+
#endif
38+
39+
/***********************************************************
40+
*********************** macro define ***********************
41+
***********************************************************/
42+
43+
44+
/***********************************************************
45+
********************** typedef define **********************
46+
***********************************************************/
47+
48+
49+
/***********************************************************
50+
******************* function declaration *******************
51+
***********************************************************/
52+
/**
53+
* @brief register hardware
54+
*
55+
* @param[in] : the name of the driver
56+
*
57+
* @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
58+
*/
59+
OPERATE_RET reg_ir_hardware(char *device_name);
60+
61+
/**
62+
* @brief open driver
63+
*
64+
* @param[in] : the name of the driver
65+
*
66+
* @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
67+
*/
68+
OPERATE_RET open_ir_driver(char *device_name);
69+
70+
#ifdef __cplusplus
71+
}
72+
#endif
73+
74+
#endif /* __EXAMPLE_IR_H__ */

0 commit comments

Comments
 (0)