1 // Copyright (C) 2022 Beken Corporation 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 #define IRDA_FAILURE (1) 22 #define IRDA_SUCCESS (0) 23 24 #define IRDA_DEV_NAME "irda" 25 26 #define IRDA_CMD_MAGIC (0xe290000) 27 enum 28 { 29 IRDA_CMD_ACTIVE = IRDA_CMD_MAGIC + 1, 30 IRDA_CMD_SET_POLARITY, 31 IRDA_CMD_SET_CLK, 32 IRDA_CMD_SET_INT_MASK, 33 }; 34 35 enum 36 { 37 IR_KEY_TYPE_SHORT = 0, 38 IR_KEY_TYPE_LONG, 39 IR_KEY_TYPE_HOLD, 40 IR_KEY_TYPE_MAX, 41 }; 42 43 #define USERCODE_MASK 0xffff 44 45 #define KEY_CODE_MASK 0xff0000 46 #define KEY_CODE_SHIFT 16 47 48 #define KEY_CODE_INVERS_MASK 0xff000000 49 #define KEY_CODE_INVERS_SHIFT 24 50 51 #define KEY_SHORT_CNT 3 52 #define KEY_LONG_CNT 8 53 #define KEY_HOLD_CNT 11 54 55 56 #define GENERATE_KEY(type,value) (((type) << 24) | (value)) 57 #define GET_KEY_TYPE(msg) (((msg) >> 24) & 0xff) 58 #define GET_KEY_VALUE(msg) ((msg) & 0xff) 59 60 /******************************************************************************* 61 * Function Declarations 62 *******************************************************************************/ 63 void irda_init(void); 64 void irda_exit(void); 65 void irda_isr(void); 66 void Irda_init_app(void); 67 void set_irda_usrcode(UINT16 ir_usercode); 68 long IR_get_key(void *buffer, unsigned long size, INT32 timeout); 69 70 #ifdef __cplusplus 71 } 72 #endif 73