| 1 | /* |
|---|
| 2 | DHL_UIO_Platform.c |
|---|
| 3 | |
|---|
| 4 | BU2 HAL library |
|---|
| 5 | |
|---|
| 6 | User I/O module platform implementation. |
|---|
| 7 | Supports IR, GPIO button, and KeyPad input directly or via MICOM. |
|---|
| 8 | Supports LED (indivisual or Segment), VFD. |
|---|
| 9 | |
|---|
| 10 | Copyright 2006~2010 Digital STREAM Technology, Inc. |
|---|
| 11 | All Rights Reserved |
|---|
| 12 | */ |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | #include "DHL_OSAL.h" |
|---|
| 18 | #include "DHL_DBG.h" |
|---|
| 19 | #include "DHL_SYS.h" |
|---|
| 20 | #include "DHL_SYS_Config.h" |
|---|
| 21 | |
|---|
| 22 | #include "DHL_UIO_Priv.h" |
|---|
| 23 | |
|---|
| 24 | #include "UioFilter.h" |
|---|
| 25 | #include "bapp.h" |
|---|
| 26 | |
|---|
| 27 | /* |
|---|
| 28 | DHL µð¹ö±× ¸ðµâ À̸§ Á¤ÀÇ ·ê Âü°í: |
|---|
| 29 | |
|---|
| 30 | DHL ¸ðµâµéÀº ¸ðµÎ * ·Î ½ÃÀÛ. |
|---|
| 31 | API´Â ´ë¹®ÀÚ, Platform ¹× ±âŸ´Â ¼Ò¹®ÀÚ »ç¿ë. |
|---|
| 32 | |
|---|
| 33 | µðÆúÆ® ·¹º§Àº 0À¸·Î ¼³Á¤ÇÑ´Ù. (0: ¿¡·¯ ¸Þ½ÃÁö¸¸ Ãâ·Â) |
|---|
| 34 | |
|---|
| 35 | */ |
|---|
| 36 | #if COMMENT |
|---|
| 37 | ____DBG____(){} |
|---|
| 38 | #endif |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | //DHL_MODULE("*uiop", 0); |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | #if COMMENT |
|---|
| 46 | ____Config____(){} |
|---|
| 47 | #endif |
|---|
| 48 | |
|---|
| 49 | /* |
|---|
| 50 | ÀÌ ¸ðµâ ³»ºÎ¿¡¼ »ç¿ëµÇ´Â °¢Á¾ configuration Á¤ÀÇ. |
|---|
| 51 | */ |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | #if COMMENT |
|---|
| 55 | ____Types____(){} |
|---|
| 56 | #endif |
|---|
| 57 | |
|---|
| 58 | /* |
|---|
| 59 | ÀÌ ¸ðµâ ³»ºÎ¿¡¼ »ç¿ëµÇ´Â structure ¹× enumerations. |
|---|
| 60 | */ |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | #if COMMENT |
|---|
| 64 | ____Variables____(){} |
|---|
| 65 | #endif |
|---|
| 66 | |
|---|
| 67 | extern brfm_t g_sys_rfm; |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | /* |
|---|
| 71 | global·Î Àû¿ëµÇ´Â variable Á¤ÀÇ. |
|---|
| 72 | °¢ function º°·Î Ư¼öÇÑ ¿ëµµÀÇ variableÀº °¢ functionX block ¿¡¼ Á¤ÀÇ °¡´É. |
|---|
| 73 | */ |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | #if COMMENT |
|---|
| 77 | _____Functions_____(){} |
|---|
| 78 | #endif |
|---|
| 79 | |
|---|
| 80 | /* |
|---|
| 81 | Msg queue ·Î data Àü´ÞÀ» ÇϱâÀü ´Ü¼ø 󸮸¦ ÇÔ¼ö. |
|---|
| 82 | |
|---|
| 83 | repeat value º¯È¯, Release value º¯È¯, stamp(data°¡ ÀԷµǾî Àü´ÞÇÏ´Â ¼ø°£ÀÇ tick °ª) ó¸®. |
|---|
| 84 | |
|---|
| 85 | ÇöÀç Å©°Ô ó¸®ÇÏ´Â ³»¿ëÀº ¾øÀ½ !!! |
|---|
| 86 | |
|---|
| 87 | */ |
|---|
| 88 | void p_uio_process(tDHL_UIO_Type source, UINT32 data, BOOL bRepeat, BOOL bReleased) |
|---|
| 89 | { |
|---|
| 90 | UIOFILTER_TIMESTAMP stamp = UioFilter_GetStamp(); // Keycode °¡ ÀÔ·ÂµÈ ¶§ÀÇ ½Ã°£°ª ÀúÀå.(ms) |
|---|
| 91 | tDHL_UIO_Flag flag = 0; |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | flag |= bRepeat ? DHL_UIO_FLAG_IsRepeat : 0; |
|---|
| 95 | flag |= bReleased ? DHL_UIO_FLAG_Released : 0; |
|---|
| 96 | |
|---|
| 97 | UioFilter_Feed(source, data, flag, stamp); |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | #if COMMENT |
|---|
| 102 | ____IR____(){} |
|---|
| 103 | #endif |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | #if COMMENT |
|---|
| 107 | ____Defines____(){} |
|---|
| 108 | #endif |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | #if COMMENT |
|---|
| 112 | ____Types____(){} |
|---|
| 113 | #endif |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | #if COMMENT |
|---|
| 117 | ____Variables____(){} |
|---|
| 118 | #endif |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | #if COMMENT |
|---|
| 122 | ____Functions____(){} |
|---|
| 123 | #endif |
|---|
| 124 | |
|---|
| 125 | |
|---|
| 126 | |
|---|
| 127 | static void dhl_ir_init(void) |
|---|
| 128 | { |
|---|
| 129 | //ir kpd config ¹× control ÃʱâÈ ÇÔ¼öµé |
|---|
| 130 | //DHL_SYS_Init ¿¡¼ ¿Ï·á |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | static void dhl_ir_uninit(void) |
|---|
| 134 | { |
|---|
| 135 | |
|---|
| 136 | } |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | #if COMMENT |
|---|
| 140 | ____GPB____(){} |
|---|
| 141 | #endif |
|---|
| 142 | |
|---|
| 143 | |
|---|
| 144 | #if COMMENT |
|---|
| 145 | ____Defines____(){} |
|---|
| 146 | #endif |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | #define DHL_GPB_NUM_BUTTONS (int)(sizeof(s_gpb_map)/sizeof(s_gpb_map[0])) |
|---|
| 150 | |
|---|
| 151 | #define DHL_GPB_TASK_PRIORITY TASK_PRI_DRV_GPB |
|---|
| 152 | #define DHL_GPB_TASK_STACKSIZE 4096 |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | #if COMMENT |
|---|
| 156 | ____Types____(){} |
|---|
| 157 | #endif |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | |
|---|
| 161 | #if COMMENT |
|---|
| 162 | ____Variables____(){} |
|---|
| 163 | #endif |
|---|
| 164 | |
|---|
| 165 | |
|---|
| 166 | |
|---|
| 167 | |
|---|
| 168 | |
|---|
| 169 | #if COMMENT |
|---|
| 170 | ____Functions____(){} |
|---|
| 171 | #endif |
|---|
| 172 | |
|---|
| 173 | |
|---|
| 174 | #if 1 |
|---|
| 175 | //static void dhl_gpb_task(UINT32 arg) |
|---|
| 176 | //{ |
|---|
| 177 | // |
|---|
| 178 | //} |
|---|
| 179 | // |
|---|
| 180 | static void dhl_gpb_init(void) |
|---|
| 181 | { |
|---|
| 182 | |
|---|
| 183 | } |
|---|
| 184 | |
|---|
| 185 | #else |
|---|
| 186 | static void dhl_gpb_cb(MS_U8 u8Key, MS_U8 u8RepeatFlag) |
|---|
| 187 | { |
|---|
| 188 | static tDHL_UIO_Key prevKey = eDHL_KEY_NONE; |
|---|
| 189 | tDHL_UIO_Key key = eDHL_KEY_NONE; |
|---|
| 190 | int i; |
|---|
| 191 | |
|---|
| 192 | DHL_OS_Printf("|%s| key = %x, rtp = %x\n", __FUNCTION__, u8Key, u8RepeatFlag); |
|---|
| 193 | |
|---|
| 194 | return; |
|---|
| 195 | } |
|---|
| 196 | |
|---|
| 197 | static void dhl_gpb_init(void) |
|---|
| 198 | { |
|---|
| 199 | SAR_RegCfg sarCfg; |
|---|
| 200 | int i; |
|---|
| 201 | |
|---|
| 202 | DHL_OS_Printf("|%s, %d|\n", __FUNCTION__, __LINE__); |
|---|
| 203 | DHL_OS_Delay(1000); |
|---|
| 204 | if (MDrv_SAR_Init() != E_SAR_OK) |
|---|
| 205 | { |
|---|
| 206 | DHL_OS_Printf("|%s| fail to init sar.\n", __FUNCTION__); |
|---|
| 207 | } |
|---|
| 208 | memset(&sarCfg, 0, sizeof(sarCfg)); |
|---|
| 209 | sarCfg.u8SARChID = 0; |
|---|
| 210 | sarCfg.u8LoBnd = 0xf0; |
|---|
| 211 | sarCfg.u8UpBnd = 0xff; |
|---|
| 212 | sarCfg.u8KeyLevelNum = DHL_GPB_NUM_BUTTONS; |
|---|
| 213 | for (i = 0; i < DHL_GPB_NUM_BUTTONS; i++) |
|---|
| 214 | { |
|---|
| 215 | sarCfg.u8KeyThreshold[i] = s_gpb_map[i].voltage; |
|---|
| 216 | sarCfg.u8KeyCode[i] = s_gpb_map[i].code; |
|---|
| 217 | } |
|---|
| 218 | DHL_OS_Printf("|%s, %d|\n", __FUNCTION__, __LINE__); |
|---|
| 219 | DHL_OS_Delay(1000); |
|---|
| 220 | if (MDrv_SAR_Config(&sarCfg) != E_SAR_OK) |
|---|
| 221 | { |
|---|
| 222 | DHL_OS_Printf("|%s| fail to set sar config.\n", __FUNCTION__); |
|---|
| 223 | } |
|---|
| 224 | DHL_OS_Printf("|%s, %d|\n", __FUNCTION__, __LINE__); |
|---|
| 225 | DHL_OS_Delay(1000); |
|---|
| 226 | if (MDrv_SAR_SetCallback(dhl_gpb_cb) != E_SAR_OK) |
|---|
| 227 | { |
|---|
| 228 | DHL_OS_Printf("|%s| fail to set sar callback.\n", __FUNCTION__); |
|---|
| 229 | } |
|---|
| 230 | DHL_OS_Printf("|%s, %d|\n", __FUNCTION__, __LINE__); |
|---|
| 231 | DHL_OS_Delay(1000); |
|---|
| 232 | if (MDrv_SAR_Enable(TRUE) != E_SAR_OK) |
|---|
| 233 | { |
|---|
| 234 | DHL_OS_Printf("|%s| fail to enable sar.\n", __FUNCTION__); |
|---|
| 235 | } |
|---|
| 236 | DHL_OS_Printf("|%s, %d|\n", __FUNCTION__, __LINE__); |
|---|
| 237 | DHL_OS_Delay(1000); |
|---|
| 238 | } |
|---|
| 239 | #endif |
|---|
| 240 | |
|---|
| 241 | static void dhl_gpb_uninit(void) |
|---|
| 242 | { |
|---|
| 243 | |
|---|
| 244 | } |
|---|
| 245 | |
|---|
| 246 | |
|---|
| 247 | #if COMMENT |
|---|
| 248 | ____KPD____(){} |
|---|
| 249 | #endif |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | #if COMMENT |
|---|
| 253 | ____LED____(){} |
|---|
| 254 | #endif |
|---|
| 255 | |
|---|
| 256 | /* |
|---|
| 257 | Á÷Á¢ LED ¿¡ ÇÒ´çµÈ GPIO ¹øÈ£¸¦ ÀÌ¿ëÇÏ¿© LED ÄÁÆ®·Ñ. |
|---|
| 258 | led_id : GPIO Number |
|---|
| 259 | onoff : 0 (Off), 1 (On) |
|---|
| 260 | */ |
|---|
| 261 | DHL_RESULT dhl_led_control(UINT32 led_id, UINT32 onoff) |
|---|
| 262 | { |
|---|
| 263 | DHL_RESULT result = DHL_OK; |
|---|
| 264 | |
|---|
| 265 | if(onoff != 0) // On |
|---|
| 266 | buser_AOV_input_LED(g_sys_rfm, eLED_Status_G); |
|---|
| 267 | else // Off |
|---|
| 268 | buser_AOV_input_LED(g_sys_rfm, eLED_Status_OFF); |
|---|
| 269 | |
|---|
| 270 | return result; |
|---|
| 271 | } |
|---|
| 272 | |
|---|
| 273 | void dhl_led_control2(UINT32 onoff) |
|---|
| 274 | { |
|---|
| 275 | buser_AOV_input_LED(g_sys_rfm, onoff); |
|---|
| 276 | } |
|---|
| 277 | |
|---|
| 278 | static void p_uio_set_indicator(tDHL_UIO_IndicatorType id, UINT32 param) |
|---|
| 279 | { |
|---|
| 280 | switch (id) |
|---|
| 281 | { |
|---|
| 282 | case eDHL_UIO_IT_Power: |
|---|
| 283 | if (param == 0) |
|---|
| 284 | { |
|---|
| 285 | buser_AOV_input_LED(g_sys_rfm, eLED_Status_OFF); // Blue Off |
|---|
| 286 | } |
|---|
| 287 | else if (param == 1) // standby |
|---|
| 288 | { |
|---|
| 289 | buser_AOV_input_LED(g_sys_rfm, eLED_Status_OFF); // Blue Off |
|---|
| 290 | buser_AOV_input_LED(g_sys_rfm, eLED_Status_R); // Red On |
|---|
| 291 | } |
|---|
| 292 | else // full power on |
|---|
| 293 | { |
|---|
| 294 | buser_AOV_input_LED(g_sys_rfm, eLED_Status_OFF); // Blue Off |
|---|
| 295 | buser_AOV_input_LED(g_sys_rfm, eLED_Status_G); // Blue On |
|---|
| 296 | } |
|---|
| 297 | |
|---|
| 298 | break; |
|---|
| 299 | |
|---|
| 300 | default: |
|---|
| 301 | break; |
|---|
| 302 | } |
|---|
| 303 | } |
|---|
| 304 | |
|---|
| 305 | |
|---|
| 306 | #if COMMENT |
|---|
| 307 | ____7SEG____(){} |
|---|
| 308 | #endif |
|---|
| 309 | |
|---|
| 310 | |
|---|
| 311 | #if COMMENT |
|---|
| 312 | ____VFD____(){} |
|---|
| 313 | #endif |
|---|
| 314 | |
|---|
| 315 | |
|---|
| 316 | #if COMMENT |
|---|
| 317 | ____Symbol____(){} |
|---|
| 318 | #endif |
|---|
| 319 | |
|---|
| 320 | |
|---|
| 321 | |
|---|
| 322 | #if COMMENT |
|---|
| 323 | ____API____(){} |
|---|
| 324 | #endif |
|---|
| 325 | |
|---|
| 326 | |
|---|
| 327 | void dhl_uio_init(void) |
|---|
| 328 | { |
|---|
| 329 | dhl_ir_init(); |
|---|
| 330 | dhl_gpb_init(); |
|---|
| 331 | } |
|---|
| 332 | |
|---|
| 333 | void dhl_uio_config(tDHL_UIO_ConfigType type, void *param) |
|---|
| 334 | { |
|---|
| 335 | if (type == eDHL_UIO_Cfg_Debounce) |
|---|
| 336 | { |
|---|
| 337 | // TODO |
|---|
| 338 | } |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | DHL_RESULT dhl_uio_control(tDHL_UIO_ControlType type, UINT32 id, UINT32 param) |
|---|
| 342 | { |
|---|
| 343 | DHL_RESULT result = DHL_OK; |
|---|
| 344 | |
|---|
| 345 | switch(type) |
|---|
| 346 | { |
|---|
| 347 | |
|---|
| 348 | case eDHL_UIO_CT_LED: |
|---|
| 349 | result = dhl_led_control(id, param); |
|---|
| 350 | break; |
|---|
| 351 | |
|---|
| 352 | case eDHL_UIO_CT_7SEG: |
|---|
| 353 | case eDHL_UIO_CT_VFD: |
|---|
| 354 | printf("!! not supported uio display type\n"); |
|---|
| 355 | result = DHL_FAIL_INVALID_PARAM; |
|---|
| 356 | break; |
|---|
| 357 | |
|---|
| 358 | case eDHL_UIO_CT_Indicator: |
|---|
| 359 | p_uio_set_indicator((tDHL_UIO_IndicatorType)id, param); |
|---|
| 360 | break; |
|---|
| 361 | |
|---|
| 362 | default: |
|---|
| 363 | break; |
|---|
| 364 | |
|---|
| 365 | |
|---|
| 366 | } |
|---|
| 367 | |
|---|
| 368 | |
|---|
| 369 | return result; |
|---|
| 370 | } |
|---|
| 371 | |
|---|
| 372 | void dhl_uio_uninit(void) |
|---|
| 373 | { |
|---|
| 374 | dhl_gpb_uninit(); |
|---|
| 375 | dhl_ir_uninit(); |
|---|
| 376 | } |
|---|
| 377 | |
|---|
| 378 | |
|---|
| 379 | #if COMMENT |
|---|
| 380 | ____TEST____(){} |
|---|
| 381 | #endif |
|---|
| 382 | |
|---|
| 383 | |
|---|
| 384 | void ir_test(void) |
|---|
| 385 | { |
|---|
| 386 | |
|---|
| 387 | } |
|---|