00001 00020 /* 00021 * INCLUDE FILES 00022 **************************************************************************************** 00023 */ 00024 #include "button.h" 00025 #include "intc.h" 00026 #include "rwnx_config.h" 00027 #include <stddef.h> 00028 00029 #if (NX_PLF_VER >= 30) 00030 #include "reg_karst_if.h" 00031 #endif //(NX_PLF_VER >= 30) 00032 00033 /* 00034 * GLOBAL VARIABLES 00035 **************************************************************************************** 00036 */ 00038 struct button_cb_tag 00039 { 00041 button_cb cb; 00043 void *env; 00044 }; 00045 00047 struct button_cb_tag button_cb_env; 00048 00049 /* 00050 * FUNCTION DEFINITIONS 00051 **************************************************************************************** 00052 */ 00053 void button_register(button_cb cb, void* env) 00054 { 00055 button_cb_env.cb = cb; 00056 button_cb_env.env = env; 00057 } 00058 00059 void button_unregister() 00060 { 00061 button_cb_env.cb = NULL; 00062 button_cb_env.env = NULL; 00063 } 00064 00065 void button_enable() 00066 { 00067 #if (NX_PLF_VER >= 30) 00068 karst_doorbell_int_clear_setf(1); 00069 karst_doorbell_int_mask_setf(1); 00070 #endif //(NX_PLF_VER >= 30) 00071 } 00072 00073 void button_disable() 00074 { 00075 #if (NX_PLF_VER >= 30) 00076 karst_doorbell_int_mask_setf(0); 00077 #endif //(NX_PLF_VER >= 30) 00078 } 00079 00080 void button_isr() 00081 { 00082 if (button_cb_env.cb) 00083 button_cb_env.cb(button_cb_env.env); 00084 } 00085 00086 void button_init() 00087 { 00088 button_unregister(); 00089 button_disable(); 00090 } 00091
1.6.1