1 //<MStar Software> 2 //****************************************************************************** 3 // MStar Software 4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved. 5 // All software, firmware and related documentation herein ("MStar Software") are 6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by 7 // law, including, but not limited to, copyright law and international treaties. 8 // Any use, modification, reproduction, retransmission, or republication of all 9 // or part of MStar Software is expressly prohibited, unless prior written 10 // permission has been granted by MStar. 11 // 12 // By accessing, browsing and/or using MStar Software, you acknowledge that you 13 // have read, understood, and agree, to be bound by below terms ("Terms") and to 14 // comply with all applicable laws and regulations: 15 // 16 // 1. MStar shall retain any and all right, ownership and interest to MStar 17 // Software and any modification/derivatives thereof. 18 // No right, ownership, or interest to MStar Software and any 19 // modification/derivatives thereof is transferred to you under Terms. 20 // 21 // 2. You understand that MStar Software might include, incorporate or be 22 // supplied together with third party`s software and the use of MStar 23 // Software may require additional licenses from third parties. 24 // Therefore, you hereby agree it is your sole responsibility to separately 25 // obtain any and all third party right and license necessary for your use of 26 // such third party`s software. 27 // 28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as 29 // MStar`s confidential information and you agree to keep MStar`s 30 // confidential information in strictest confidence and not disclose to any 31 // third party. 32 // 33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any 34 // kind. Any warranties are hereby expressly disclaimed by MStar, including 35 // without limitation, any warranties of merchantability, non-infringement of 36 // intellectual property rights, fitness for a particular purpose, error free 37 // and in conformity with any international standard. You agree to waive any 38 // claim against MStar for any loss, damage, cost or expense that you may 39 // incur related to your use of MStar Software. 40 // In no event shall MStar be liable for any direct, indirect, incidental or 41 // consequential damages, including without limitation, lost of profit or 42 // revenues, lost or damage of data, and unauthorized system use. 43 // You agree that this Section 4 shall still apply without being affected 44 // even if MStar Software has been modified by MStar in accordance with your 45 // request or instruction for your use, except otherwise agreed by both 46 // parties in writing. 47 // 48 // 5. If requested, MStar may from time to time provide technical supports or 49 // services in relation with MStar Software to you for your use of 50 // MStar Software in conjunction with your or your customer`s product 51 // ("Services"). 52 // You understand and agree that, except otherwise agreed by both parties in 53 // writing, Services are provided on an "AS IS" basis and the warranty 54 // disclaimer set forth in Section 4 above shall apply. 55 // 56 // 6. Nothing contained herein shall be construed as by implication, estoppels 57 // or otherwise: 58 // (a) conferring any license or right to use MStar name, trademark, service 59 // mark, symbol or any other identification; 60 // (b) obligating MStar or any of its affiliates to furnish any person, 61 // including without limitation, you and your customers, any assistance 62 // of any kind whatsoever, or any information; or 63 // (c) conferring any license or right under any intellectual property right. 64 // 65 // 7. These terms shall be governed by and construed in accordance with the laws 66 // of Taiwan, R.O.C., excluding its conflict of law rules. 67 // Any and all dispute arising out hereof or related hereto shall be finally 68 // settled by arbitration referred to the Chinese Arbitration Association, 69 // Taipei in accordance with the ROC Arbitration Law and the Arbitration 70 // Rules of the Association by three (3) arbitrators appointed in accordance 71 // with the said Rules. 72 // The place of arbitration shall be in Taipei, Taiwan and the language shall 73 // be English. 74 // The arbitration award shall be final and binding to both parties. 75 // 76 //****************************************************************************** 77 //<MStar Software> 78 //////////////////////////////////////////////////////////////////////////////// 79 // 80 // Copyright (c) 2008-2009 MStar Semiconductor, Inc. 81 // All rights reserved. 82 // 83 // Unless otherwise stipulated in writing, any and all information contained 84 // herein regardless in any format shall remain the sole proprietary of 85 // MStar Semiconductor Inc. and be kept in strict confidence 86 // ("MStar Confidential Information") by the recipient. 87 // Any unauthorized act including without limitation unauthorized disclosure, 88 // copying, use, reproduction, sale, distribution, modification, disassembling, 89 // reverse engineering and compiling of the contents of MStar Confidential 90 // Information is unlawful and strictly prohibited. MStar hereby reserves the 91 // rights to any and all damages, losses, costs and expenses resulting therefrom. 92 // 93 //////////////////////////////////////////////////////////////////////////////// 94 95 /////////////////////////////////////////////////////////////////////////////////////////////////// 96 /// 97 /// @file drvUART.h 98 /// @brief UART Driver Interface 99 /// @author MStar Semiconductor Inc. 100 /////////////////////////////////////////////////////////////////////////////////////////////////// 101 102 /*! \defgroup G_UART UART interface 103 \ingroup G_PERIPHERAL 104 105 \brief 106 107 UART is a piece of computer hardware that translates data between parallel and serial forms. 108 UARTs are commonly used in conjunction with communication standards such as EIA, RS-232, RS-422 or RS-485. 109 The universal designation indicates that the data format and transmission speeds are configurable. 110 The electric signaling levels and methods are handled by a driver circuit external to the UART. 111 112 <b>Features</b> 113 114 - A clock generator, usually a multiple of the bit rate to allow sampling in the middle of a bit period. 115 - Input and Output shift registers 116 - Transmit/Receive control 117 - Read/Write control logic 118 - Transmit/Receive buffers (optional) 119 - Parallel data bus buffer (optional) 120 - First-in, first-out (FIFO) buffer memory (optional) 121 122 <b> UART Block Diagram: </b> \n 123 \image html drvUART_pic1.png 124 125 <b> Operation Code Flow: </b> \n 126 -# Prepare UART setting for each operation 127 -# Set and start UART in command handle 128 -# Trigger UART 129 130 \defgroup G_UART_INIT Initialization Task relative 131 \ingroup G_UART 132 \defgroup G_UART_TXRX Transmit/Receive control Task relative 133 \ingroup G_UART 134 \defgroup G_UART_OTHER other relative 135 \ingroup G_UART 136 */ 137 138 #ifndef __MDRV_UART_H__ 139 #define __MDRV_UART_H__ 140 141 /// 142 /// @file drvUART.h 143 /// @brief MStar driver for UART devices 144 /// 145 /// @par Example: connect AEON uart to UART port0, output message 146 /// @code 147 /// ms_uart_dev_t uart; 148 /// 149 /// mdrv_uart_connect(E_UART_PORT0, E_UART_AEON); 150 /// uart = mdrv_uart_open(E_UART_AEON); 151 /// if (uart != UART_DEV_NULL) 152 /// { 153 /// mdrv_uart_set_baudrate(uart, 38400); // must do this after base clock changed 154 /// setconsole(uart); // set this uart device as console 155 /// } 156 /// printf("uart test"); 157 /// mdrv_uart_close(uart); 158 /// @endcode 159 /// 160 /// 161 /// @par Example: use buffered output 162 /// @code 163 /// ms_uart_dev_t uart; 164 /// char tx_buffer[1024]; 165 /// 166 /// uart = mdrv_uart_open(E_UART_PIU_UART0); 167 /// if (uart != UART_DEV_NULL) 168 /// { 169 /// mdrv_uart_set_tx_buffer(uart, tx_buffer, sizeof(tx_buffer)); 170 /// } 171 /// @endcode 172 173 174 175 #ifdef __cplusplus 176 extern "C" 177 { 178 #endif 179 180 #include "MsTypes.h" 181 #include "MsDevice.h" 182 //------------------------------------------------------------------------------------------------- 183 // Driver Capability 184 //------------------------------------------------------------------------------------------------- 185 #define UART_CAPS_AEON 0x00000001 186 #define UART_CAPS_PIU 0x00000002 187 188 189 //------------------------------------------------------------------------------------------------- 190 // Macro and Define 191 //------------------------------------------------------------------------------------------------- 192 193 // #define UART_TYPE_DEF 194 /// Version string. 195 #define UART_DRV_VERSION /* Character String for DRV/API version */ \ 196 MSIF_TAG, /* 'MSIF' */ \ 197 MSIF_CLASS, /* '00' */ \ 198 MSIF_CUS, /* 0x0000 */ \ 199 MSIF_MOD, /* 0x0000 */ \ 200 MSIF_CHIP, \ 201 MSIF_CPU, \ 202 {'U','A','R','T'}, /* IP__ */ \ 203 {'0','1'}, /* 0.0 ~ Z.Z */ \ 204 {'0','6'}, /* 00 ~ 99 */ \ 205 {'0','0','3','1','0','0','5','0'}, /* CL# */ \ 206 MSIF_OS 207 208 #define UART_TYPE_AEON 0x10 209 #define UART_TYPE_PIU 0x20 210 #define UART_TYPE_EYWA 0 211 212 213 // Baud rate 214 //#define UART_BAUD_RATE 38400 //9600 //19200 //38400 //57600 //115200 =>too frequent Rx INT 215 #define UART_BAUD_RATE 115200 216 217 #define UART_DEV_NULL ((ms_uart_dev_t)0) 218 219 220 //------------------------------------------------------------------------------------------------- 221 // Type and Structure 222 //------------------------------------------------------------------------------------------------- 223 224 typedef enum 225 { 226 E_UART_OK, 227 E_UART_FAIL, 228 } UART_Result; 229 230 typedef struct _UART_DrvInfo 231 { 232 MS_BOOL Init; 233 MS_U32 Caps; 234 } UART_DrvInfo; 235 236 typedef struct _UART_DrvStatus 237 { 238 MS_BOOL HwBusy; 239 } UART_DrvStatus; 240 241 /// UART devices, not all of them can be access directly 242 typedef enum 243 { 244 E_UART_INVALID = -1, ///< INVALID 245 E_UART_AEON, ///< AEON 246 E_UART_VDEC, ///< VD_MHEG5 (only used in mdrv_uart_connect()) 247 E_UART_TSP, ///< TSP (only used in mdrv_uart_connect()) 248 E_UART_PIU_UART0, ///< PIU0 249 E_UART_PIU_UART1, ///< PIU1 (only available for some chips) 250 E_UART_PIU_UART2, ///< PIU2 (only available for some chips) 251 E_UART_PIU_FUART0, ///< PIU Fast UART (only available for some chips) 252 E_UART_HK51_UART0, ///< HK51 UART0 (only used in mdrv_uart_connect()) 253 E_UART_HK51_UART1, ///< HK51 UART1 (only used in mdrv_uart_connect()) 254 E_UART_VD51_UART0, ///< VD51 UART0 (only used in mdrv_uart_connect()) 255 E_UART_VD51_UART1, ///< VD51 UART1 (only used in mdrv_uart_connect()) 256 ///< (only available for some chips) 257 E_UART_AEON_R2, ///< AEON_R2 for HK 258 E_UART_AEON_AUDIO_R2, ///< AEON_R2 for Audio 259 E_UART_DMD51_UART0, ///< DMD51 UART0 (only used in mdrv_uart_connect()) 260 E_UART_DMD51_UART1, ///< DMD51 UART1 (only used in mdrv_uart_connect()) 261 E_UART_SECURE_R2, ///< SECURE_R2 (only available for some chips) 262 E_UART_OFF, ///< UART Disable 263 } UART_DEVICE_TYPE; 264 265 /// UART port 266 /// different port have different pad mux, please check package spec. 267 /// sometimes the net name will mislead the real port number 268 typedef enum 269 { 270 E_UART_PORT_INVALID = -1,///< invalid uart port 271 E_UART_PORT0, ///< usually muxed with DDCA 272 E_UART_PORT1, ///< port 1 273 E_UART_PORT2, ///< port 2 274 E_UART_PORT3, ///< port 3 275 E_UART_PORT4, ///< port 4 276 } UART_PORT_TYPE; 277 278 /// UART Pad 279 /// different port have different pad mux 280 /// sometimes the net name will mislead the real pad number 281 typedef enum 282 { 283 //<< port 0 pad default with DDCA 284 //port1 --> second uart mode 285 E_UART_PAD_1_0, ///<disable port 1 pad 286 E_UART_PAD_1_1, ///<port1 pad 1 287 E_UART_PAD_1_2, ///<port1 pad 2 288 E_UART_PAD_1_3, ///<port1 pad 3 289 //port2 --> third uart mode 290 E_UART_PAD_2_0, ///<disable port 2 pad 291 E_UART_PAD_2_1, ///<port2 pad 1 292 E_UART_PAD_2_2, ///<port2 pad 2 293 E_UART_PAD_2_3, ///<port2 pad 3 294 //port3 --> fourth uart mode 295 E_UART_PAD_3_0, ///<disable port 3 pad 296 E_UART_PAD_3_1, ///<port3 pad 1 297 E_UART_PAD_3_2, ///<port3 pad 2 298 E_UART_PAD_3_3, ///<port3 pad 3 299 //port4 --> fast uart mode 300 E_UART_PAD_4_0, ///<disable port 4 pad 301 E_UART_PAD_4_1, ///<port4 pad 1 302 E_UART_PAD_4_2, ///<port4 pad 2 303 E_UART_PAD_4_3, ///<port4 pad 3 304 }UART_PAD_TYPE; 305 306 typedef enum _UART_DbgLv 307 { 308 E_UART_DBGLV_NONE //no debug message 309 ,E_UART_DBGLV_ERR_ONLY //show error only 310 ,E_UART_DBGLV_INFO //show error & informaiton 311 ,E_UART_DBGLV_ALL //show error, information & funciton name 312 }UART_DbgLv; 313 314 315 /// prototypr of UART rx callback 316 typedef void (*ms_uart_rx_callback)(int c); // TODO: add user data? 317 318 /// prototypr of UART rx callback 319 typedef void (*ms_uart_rx_callback_halreg)(int c, MS_U32 pHalReg); 320 321 //------------------------------------------------------------------------------------------------- 322 // Function and Variable 323 //------------------------------------------------------------------------------------------------- 324 325 /////////////////////////////////////////////////////////////////////////////// 326 /// @brief open UART device, both rx/tx is enabled after this 327 /// @ingroup G_UART_INIT 328 /// @param uart_dev: uart device instance to open (AEON / PIU_UARTx) 329 /// @return uart handle. when failed, it returns UART_DEV_NULL 330 /////////////////////////////////////////////////////////////////////////////// 331 MS_U32 mdrv_uart_open(UART_DEVICE_TYPE uart_dev); 332 333 // control power state for fast booting 334 MS_U32 MDrv_UART_SetPowerState(EN_POWER_MODE u16PowerState); 335 336 /////////////////////////////////////////////////////////////////////////////// 337 /// @brief close a UART device handle 338 /// @ingroup G_UART_INIT 339 /// @param uart \b uart handle to close 340 /// @return 0 if sucess, -1 if failed 341 /////////////////////////////////////////////////////////////////////////////// 342 MS_U16 mdrv_uart_close(MS_VIRT uart); 343 344 /////////////////////////////////////////////////////////////////////////////// 345 /// Please note the connectivity should be a one-to-one mapping 346 /// @ingroup G_UART_INIT 347 /// @brief connect a UART device to a UART port 348 /// @param uart_port: uart port 349 /// @param uart_dev: uart device 350 /// @return 0: sucess, -1: failed 351 /////////////////////////////////////////////////////////////////////////////// 352 MS_U16 mdrv_uart_connect(UART_PORT_TYPE uart_port, UART_DEVICE_TYPE uart_dev); 353 354 /////////////////////////////////////////////////////////////////////////////// 355 /// @brief get the connection of UART port to UART device, (get device by port) 356 /// @ingroup G_UART_INIT 357 /// @param uart_port: uart port 358 /// @return enum UART_DEVICE_TYPE, E_UART_INVALID if error occurs 359 /////////////////////////////////////////////////////////////////////////////// 360 UART_DEVICE_TYPE mdrv_uart_get_connection(UART_PORT_TYPE uart_port); 361 362 /////////////////////////////////////////////////////////////////////////////// 363 /// Please note the connectivity should be a one-to-one mapping 364 /// @brief connect a UART device to a UART port , which connect to a UART port pad 365 /// @ingroup G_UART_INIT 366 /// @param uart_port: uart port 367 /// @param uart_dev: uart device 368 /// @param uart_dev: uart device 369 /// @return 0: sucess, -1: failed 370 /////////////////////////////////////////////////////////////////////////////// 371 MS_U16 mdrv_uart_connect_mux(UART_DEVICE_TYPE uart_dev, UART_PORT_TYPE uart_port, UART_PAD_TYPE uart_pad); 372 373 /////////////////////////////////////////////////////////////////////////////// 374 /// @brief Invert the signal polarity of UART 375 /// @ingroup G_UART_OTHER 376 /// @param uart_port: uart device 377 /// @param bInv: 0: not invert, 1 invert 378 /// @return 0: sucess -1: failed (uart_port out of range) 379 /////////////////////////////////////////////////////////////////////////////// 380 MS_U16 mdrv_uart_invert(UART_PORT_TYPE uart_port, MS_BOOL bInv); 381 382 /////////////////////////////////////////////////////////////////////////////// 383 /// Set the baudrate of the UART device, the base clock must be set before set 384 /// baudrate. If the clock is changed (like CKG_MCU change for E_UART_AEON), 385 /// this function must be called again for 386 /// @ingroup G_UART_INIT 387 /// @brief Set the baudrate of the UART device 388 /// @param uart: uart device handle 389 /// @param baudrate: baudrate 390 /// @return 0: success, -1: failed 391 /////////////////////////////////////////////////////////////////////////////// 392 MS_U16 mdrv_uart_set_baudrate(MS_VIRT uart, MS_U32 baudrate); 393 394 /////////////////////////////////////////////////////////////////////////////// 395 /// The rx_cb will be called every incoming byte is received 396 /// @ingroup G_UART_INIT 397 /// @brief Set RX callback by interrupt serive routine 398 /// @param uart: uart device handle 399 /// @param rx_cb: rx callback, 0 to disable the rx callback 400 /// @return 0: success, -1: failed 401 /////////////////////////////////////////////////////////////////////////////// 402 MS_U16 mdrv_uart_set_rx_callback(MS_VIRT uart, ms_uart_rx_callback rx_cb); 403 404 /////////////////////////////////////////////////////////////////////////////// 405 /// If tx_buffer is not NULL, uart tx will use buffered mode, otherwise use polling mode 406 /// For Fast UART DMA mode, the buffer and len must aligned to MIU unit size 407 /// @ingroup G_UART_INIT 408 /// @brief set tx buffer for buffered mode 409 /// @param uart: uart device handle 410 /// @param tx_buffer: pointer to tx buffer 411 /// @param len: tx buffer size 412 /// @return 0: success, -1: failed 413 /////////////////////////////////////////////////////////////////////////////// 414 MS_U16 mdrv_uart_set_tx_buffer(MS_VIRT uart, void *tx_buffer, MS_U16 len); 415 416 /////////////////////////////////////////////////////////////////////////////// 417 /// If tx_buffer is not NULL, uart tx will use buffered mode, otherwise use polling mode 418 /// For Fast UART DMA mode, the buffer and len must aligned to MIU unit size 419 /// @ingroup G_UART_INIT 420 /// @brief set tx buffer for buffered mode 421 /// @param uart: uart device handle 422 /// @param rx_buffer: pointer to tx buffer 423 /// @param len: tx buffer size 424 /// @return 0: success, -1: failed 425 /////////////////////////////////////////////////////////////////////////////// 426 MS_U16 mdrv_uart_set_rx_buffer(MS_VIRT uart, void *rx_buffer, MS_U16 len); 427 428 /////////////////////////////////////////////////////////////////////////////// 429 /// @ingroup G_UART_TXRX 430 /// @brief enable uart rx 431 /// @param uart: uart device handle 432 /// @return 0: success, -1: failed 433 /////////////////////////////////////////////////////////////////////////////// 434 MS_U16 mdrv_uart_rx_enable(MS_VIRT uart); 435 436 /////////////////////////////////////////////////////////////////////////////// 437 /// @ingroup G_UART_TXRX 438 /// @brief enable uart tx 439 /// @param uart: uart device handle 440 /// @return 0: success, -1: failed 441 /////////////////////////////////////////////////////////////////////////////// 442 MS_U16 mdrv_uart_tx_enable(MS_VIRT uart); 443 444 /////////////////////////////////////////////////////////////////////////////// 445 /// @ingroup G_UART_TXRX 446 /// @brief disable uart rx 447 /// @param uart: uart device handle 448 /// @return 0: success, -1: failed 449 /////////////////////////////////////////////////////////////////////////////// 450 MS_U16 mdrv_uart_rx_disable(MS_VIRT uart); 451 452 /////////////////////////////////////////////////////////////////////////////// 453 /// @ingroup G_UART_TXRX 454 /// @brief disable uart tx 455 /// @param uart: uart device handle 456 /// @return 0: success, -1: failed 457 /////////////////////////////////////////////////////////////////////////////// 458 MS_U16 mdrv_uart_tx_disable(MS_VIRT uart); 459 460 /////////////////////////////////////////////////////////////////////////////// 461 /// @ingroup G_UART_TXRX 462 /// @brief read data from uart 463 /// @param uart: uart device handle 464 /// @param buf: buffer to store read data 465 /// @param len: buffer length 466 /// @return -1: failed, others: bytes read 467 /////////////////////////////////////////////////////////////////////////////// 468 MS_U16 mdrv_uart_read(MS_VIRT uart, MS_U8 *buf, MS_U32 len); 469 470 /////////////////////////////////////////////////////////////////////////////// 471 /// @ingroup G_UART_TXRX 472 /// @brief write data to uart 473 /// @param uart: uart device handle 474 /// @param buf: buffer for write data 475 /// @param len: data length 476 /// @return -1: failed, others: bytes written 477 /////////////////////////////////////////////////////////////////////////////// 478 MS_U16 mdrv_uart_write(MS_VIRT uart, const MS_U8 *buf, MS_U16 len); 479 //------------------------------------------------------------------------------------------------- 480 /// MOBF Encrypt 481 /// @ingroup G_UART_OTHER 482 /// @param u32Key \b IN: Key 483 /// @param bEnable \b IN: TRUE/FLASE 484 /// @return DRVAESDMA_OK : Success 485 /// @return Others : Fail 486 //------------------------------------------------------------------------------------------------- 487 MS_U16 mdrv_uart_poll(MS_VIRT hUart, int types); 488 //------------------------------------------------------------------------------------------------- 489 /// MOBF Encrypt 490 /// @ingroup G_UART_INIT 491 /// @param u32Key \b IN: Key 492 /// @param bEnable \b IN: TRUE/FLASE 493 /// @return DRVAESDMA_OK : Success 494 /// @return Others : Fail 495 //------------------------------------------------------------------------------------------------- 496 MS_U16 mdrv_uart_set_rx_callback_halreg(MS_VIRT uart, ms_uart_rx_callback_halreg rx_cb); 497 498 /// UART callback function used in interrupt context 499 //------------------------------------------------------------------------------------------------- 500 /// MOBF Encrypt 501 /// @ingroup G_UART_INIT 502 /// @param u32Key \b IN: Key 503 /// @param bEnable \b IN: TRUE/FLASE 504 /// @return DRVAESDMA_OK : Success 505 /// @return Others : Fail 506 //------------------------------------------------------------------------------------------------- 507 typedef void(*P_UART_ISR_Proc)(MS_U8 u8UARTID); 508 //------------------------------------------------------------------------------------------------- 509 /// MOBF Encrypt 510 /// @ingroup G_UART_INIT 511 /// @param u32Key \b IN: Key 512 /// @param bEnable \b IN: TRUE/FLASE 513 /// @return DRVAESDMA_OK : Success 514 /// @return Others : Fail 515 //------------------------------------------------------------------------------------------------- 516 UART_Result MDrv_UART_SetIOMapBase(void); 517 //------------------------------------------------------------------------------------------------- 518 /// MOBF Encrypt 519 /// @ingroup G_UART_INIT 520 /// @param u32Key \b IN: Key 521 /// @param bEnable \b IN: TRUE/FLASE 522 /// @return DRVAESDMA_OK : Success 523 /// @return Others : Fail 524 //------------------------------------------------------------------------------------------------- 525 void MDrv_UART_Init(UART_DEVICE_TYPE uart_dev, MS_U32 baudrate); 526 //------------------------------------------------------------------------------------------------- 527 /// MOBF Encrypt 528 /// @ingroup G_UART_INIT 529 /// @param u32Key \b IN: Key 530 /// @param bEnable \b IN: TRUE/FLASE 531 /// @return DRVAESDMA_OK : Success 532 /// @return Others : Fail 533 //------------------------------------------------------------------------------------------------- 534 void MDrv_UART_Standby_Init (void); 535 //------------------------------------------------------------------------------------------------- 536 /// MOBF Encrypt 537 /// @ingroup G_UART_OTHER 538 /// @param u32Key \b IN: Key 539 /// @param bEnable \b IN: TRUE/FLASE 540 /// @return DRVAESDMA_OK : Success 541 /// @return Others : Fail 542 //------------------------------------------------------------------------------------------------- 543 void MDrv_UART_PutChar(MS_U8 u8Ch); 544 //------------------------------------------------------------------------------------------------- 545 /// MOBF Encrypt 546 /// @ingroup G_UART_OTHER 547 /// @param u32Key \b IN: Key 548 /// @param bEnable \b IN: TRUE/FLASE 549 /// @return DRVAESDMA_OK : Success 550 /// @return Others : Fail 551 //------------------------------------------------------------------------------------------------- 552 void MDrv_UART_PutString(char *u8str); 553 //------------------------------------------------------------------------------------------------- 554 /// MOBF Encrypt 555 /// @ingroup G_UART_OTHER 556 /// @param u32Key \b IN: Key 557 /// @param bEnable \b IN: TRUE/FLASE 558 /// @return DRVAESDMA_OK : Success 559 /// @return Others : Fail 560 //------------------------------------------------------------------------------------------------- 561 MS_U8 MDrv_UART_GetChar(void); 562 //------------------------------------------------------------------------------------------------- 563 /// MOBF Encrypt 564 /// @ingroup G_UART_OTHER 565 /// @param u32Key \b IN: Key 566 /// @param bEnable \b IN: TRUE/FLASE 567 /// @return DRVAESDMA_OK : Success 568 /// @return Others : Fail 569 //------------------------------------------------------------------------------------------------- 570 void MDrv_UART_GetFile(MS_U8 *pu8Buf, MS_U32 u32Len); 571 //------------------------------------------------------------------------------------------------- 572 /// MOBF Encrypt 573 /// @ingroup G_UART_OTHER 574 /// @param u32Key \b IN: Key 575 /// @param bEnable \b IN: TRUE/FLASE 576 /// @return DRVAESDMA_OK : Success 577 /// @return Others : Fail 578 //------------------------------------------------------------------------------------------------- 579 const UART_DrvInfo* MDrv_UART_GetInfo(void); 580 //------------------------------------------------------------------------------------------------- 581 /// MOBF Encrypt 582 /// @ingroup G_UART_ToBeRemove 583 /// @param u32Key \b IN: Key 584 /// @param bEnable \b IN: TRUE/FLASE 585 /// @return DRVAESDMA_OK : Success 586 /// @return Others : Fail 587 //------------------------------------------------------------------------------------------------- 588 struct device* MDrv_UART_GetDev(UART_DEVICE_TYPE uart_dev); 589 //------------------------------------------------------------------------------------------------- 590 /// MOBF Encrypt 591 /// @ingroup G_UART_OTHER 592 /// @param u32Key \b IN: Key 593 /// @param bEnable \b IN: TRUE/FLASE 594 /// @return DRVAESDMA_OK : Success 595 /// @return Others : Fail 596 //------------------------------------------------------------------------------------------------- 597 UART_Result MDrv_UART_GetLibVer(const MSIF_Version **ppVersion); 598 //------------------------------------------------------------------------------------------------- 599 /// MOBF Encrypt 600 /// @ingroup G_UART_OTHER 601 /// @param u32Key \b IN: Key 602 /// @param bEnable \b IN: TRUE/FLASE 603 /// @return DRVAESDMA_OK : Success 604 /// @return Others : Fail 605 //------------------------------------------------------------------------------------------------- 606 UART_Result MDrv_UART_GetStatus(UART_DrvStatus *pStatus); 607 //------------------------------------------------------------------------------------------------- 608 /// MOBF Encrypt 609 /// @ingroup G_UART_OTHER 610 /// @param u32Key \b IN: Key 611 /// @param bEnable \b IN: TRUE/FLASE 612 /// @return DRVAESDMA_OK : Success 613 /// @return Others : Fail 614 //------------------------------------------------------------------------------------------------- 615 void MDrv_UART_SetDbgLevel(MS_U8 level); 616 //------------------------------------------------------------------------------------------------- 617 /// MOBF Encrypt 618 /// @ingroup G_UART_OTHER 619 /// @param u32Key \b IN: Key 620 /// @param bEnable \b IN: TRUE/FLASE 621 /// @return DRVAESDMA_OK : Success 622 /// @return Others : Fail 623 //------------------------------------------------------------------------------------------------- 624 UART_Result MDrv_UART_SetPMRxEnable(MS_BOOL bEnable); 625 void MDrv_UART_SetUARTSecurityBank(UART_DEVICE_TYPE uart_dev); 626 627 #if UART_TYPE_EYWA 628 #define EYWA_PAYLOAD_LEN 8 629 #define EYWA_DEFAULT_PARITY 0 630 631 typedef struct _Eywa_FastUart_struct 632 { 633 MS_U8 data_type; 634 MS_U8 data_type_inv; 635 MS_U16 len; 636 MS_U8 payload[EYWA_PAYLOAD_LEN]; 637 MS_U8 parity; 638 } Eywa_FastUart_struct; 639 640 typedef enum 641 { 642 E_EYWA_INVALID = 0, 643 E_EYWA_KEYPAD, 644 E_EYWA_VOICE, 645 E_EYWA_GYROSCOPE, 646 E_EYWA_GSENSOR, 647 E_EYWA_TOUCHPAD 648 } EYWA_DATATYPE; 649 650 typedef enum 651 { 652 E_EYWA_INV_INVALID = 0xFF, 653 E_EYWA_INV_KEYPAD = 0xFE, 654 E_EYWA_INV_VOICE = 0xFD, 655 E_EYWA_INV_GYROSCOPE = 0xFC, 656 E_EYWA_INV_GSENSOR = 0xFB, 657 E_EYWA_INV_TOUCHPAD = 0xFA 658 } EYWA_DATATYPE_INV; 659 660 void Eywa_UART_RecvHandler(MS_U8); 661 MS_U8 Eywa_Cal8BitsChecksum(MS_U8 *, MS_U32); 662 void Eywa_UART_Init(void); 663 664 #endif 665 666 667 #ifdef __cplusplus 668 } 669 #endif 670 671 #endif /* __MDRV_UART_H__ */ 672