serial_bsp_stm3240x.c 23 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692
/*
*********************************************************************************************************
*                                     SERIAL (BYTE) COMMUNICATION
*
*                         (c) Copyright 2007-2009; Micrium, Inc.; Weston, FL
*
*               All rights reserved.  Protected by international copyright laws.
*               Knowledge of the source code may NOT be used to develop a similar product.
*               Please help us continue to provide the Embedded community with the finest
*               software available.  Your honesty is greatly appreciated.
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*
*                                     SERIAL (BYTE) COMMUNICATION
*                                            DEVICE DRIVER
*
*                                                STM32
*                                          BSP FOR STM3240x
*
* Filename      : serial_bsp_stm3240x.c
* Version       : V2.00
* Programmer(s) : FGK
*                 FF
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                            INCLUDE FILES
*********************************************************************************************************
*/

#include  <stm32f4xx_gpio.h>
#include  <serial_bsp_stm3240x.h>


/*
*********************************************************************************************************
*                                            LOCAL DEFINES
*********************************************************************************************************
*/

                                                                /* ----------- REGISTER BASE SPECIFICATIONS ----------- */
#define  SERIAL_BSP_STM32_USART1_BASE     ((void *)0x40011000)
#define  SERIAL_BSP_STM32_USART2_BASE     ((void *)0x40004400)
#define  SERIAL_BSP_STM32_USART3_BASE     ((void *)0x40004800)
#define  SERIAL_BSP_STM32_USART4_BASE     ((void *)0x40004C00)
#define  SERIAL_BSP_STM32_USART5_BASE     ((void *)0x40005000)
#define  SERIAL_BSP_STM32_USART6_BASE     ((void *)0x40011400)


/*
*********************************************************************************************************
*                                               EXTERNS
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                      LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/
                                                                /* ------------------ USART1 BSP API ------------------ */
static  void        SerialBSP_STM32_USART1_ClkEn       (SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART1_ClkDis      (SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART1_CfgGPIO     (CPU_BOOLEAN   flow_ctrl,
                                                        SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART1_CfgInt      (SERIAL_DEV   *pdev,
                                                        SERIAL_ERR   *perr);
static  CPU_INT32U  SerialBSP_STM32_USART1_ClkFreqGet  (void);

                                                                /* ------------------ USART2 BSP API ------------------ */
static  void        SerialBSP_STM32_USART2_ClkEn       (SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART2_ClkDis      (SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART2_CfgGPIO     (CPU_BOOLEAN   flow_ctrl,
                                                        SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART2_CfgInt      (SERIAL_DEV   *pdev,
                                                        SERIAL_ERR   *perr);
static  CPU_INT32U  SerialBSP_STM32_USART2_ClkFreqGet  (void);

                                                                /* ------------------ USART3 BSP API ------------------ */
static  void        SerialBSP_STM32_USART3_ClkEn       (SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART3_ClkDis      (SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART3_CfgGPIO     (CPU_BOOLEAN   flow_ctrl,
                                                        SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART3_CfgInt      (SERIAL_DEV   *pdev,
                                                        SERIAL_ERR   *perr);
static  CPU_INT32U  SerialBSP_STM32_USART3_ClkFreqGet  (void);

                                                                /* ------------------- USART4 BSP API ----------------- */
static  void        SerialBSP_STM32_USART4_ClkEn       (SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART4_ClkDis      (SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART4_CfgGPIO     (CPU_BOOLEAN   flow_ctrl,
                                                        SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART4_CfgInt      (SERIAL_DEV   *pdev,
                                                        SERIAL_ERR   *perr);
static  CPU_INT32U  SerialBSP_STM32_USART4_ClkFreqGet  (void);

                                                                /* ------------------- USART5 BSP API ----------------- */
static  void        SerialBSP_STM32_USART5_ClkEn       (SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART5_ClkDis      (SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART5_CfgGPIO     (CPU_BOOLEAN   flow_ctrl,
                                                        SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART5_CfgInt      (SERIAL_DEV   *pdev,
                                                        SERIAL_ERR   *perr);
static  CPU_INT32U  SerialBSP_STM32_USART5_ClkFreqGet  (void);

                                                                /* ------------------ USART6 BSP API ------------------ */
static  void        SerialBSP_STM32_USART6_ClkEn       (SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART6_ClkDis      (SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART6_CfgGPIO     (CPU_BOOLEAN   flow_ctrl,
                                                        SERIAL_ERR   *perr);
static  void        SerialBSP_STM32_USART6_CfgInt      (SERIAL_DEV   *pdev,
                                                        SERIAL_ERR   *perr);
static  CPU_INT32U  SerialBSP_STM32_USART6_ClkFreqGet  (void);


static  void        SerialBSP_STM32_USART1_IntHandler    (void);
static  void        SerialBSP_STM32_USART2_IntHandler    (void);
static  void        SerialBSP_STM32_USART3_IntHandler    (void);
static  void        SerialBSP_STM32_USART4_IntHandler    (void);
static  void        SerialBSP_STM32_USART5_IntHandler    (void);
static  void        SerialBSP_STM32_USART6_IntHandler    (void);

/*
*********************************************************************************************************
*                                   SERIAL INTERFACE DEVICE BSP API
*********************************************************************************************************
*/

static  SERIAL_BSP_API  SerialBSP_STM32_USART1 = {
    SerialBSP_STM32_USART1_ClkEn,
    SerialBSP_STM32_USART1_ClkDis,
    SerialBSP_STM32_USART1_CfgGPIO,
    SerialBSP_STM32_USART1_CfgInt,
    SerialBSP_STM32_USART1_ClkFreqGet
};

static  SERIAL_BSP_API  SerialBSP_STM32_USART2 = {
    SerialBSP_STM32_USART2_ClkEn,
    SerialBSP_STM32_USART2_ClkDis,
    SerialBSP_STM32_USART2_CfgGPIO,
    SerialBSP_STM32_USART2_CfgInt,
    SerialBSP_STM32_USART2_ClkFreqGet
};

static  SERIAL_BSP_API  SerialBSP_STM32_USART3 = {
    SerialBSP_STM32_USART3_ClkEn,
    SerialBSP_STM32_USART3_ClkDis,
    SerialBSP_STM32_USART3_CfgGPIO,
    SerialBSP_STM32_USART3_CfgInt,
    SerialBSP_STM32_USART3_ClkFreqGet
};

static  SERIAL_BSP_API  SerialBSP_STM32_USART4 = {
    SerialBSP_STM32_USART4_ClkEn,
    SerialBSP_STM32_USART4_ClkDis,
    SerialBSP_STM32_USART4_CfgGPIO,
    SerialBSP_STM32_USART4_CfgInt,
    SerialBSP_STM32_USART4_ClkFreqGet
};

static  SERIAL_BSP_API  SerialBSP_STM32_USART5 = {
    SerialBSP_STM32_USART5_ClkEn,
    SerialBSP_STM32_USART5_ClkDis,
    SerialBSP_STM32_USART5_CfgGPIO,
    SerialBSP_STM32_USART5_CfgInt,
    SerialBSP_STM32_USART5_ClkFreqGet
};

static  SERIAL_BSP_API  SerialBSP_STM32_USART6 = {
    SerialBSP_STM32_USART6_ClkEn,
    SerialBSP_STM32_USART6_ClkDis,
    SerialBSP_STM32_USART6_CfgGPIO,
    SerialBSP_STM32_USART6_CfgInt,
    SerialBSP_STM32_USART6_ClkFreqGet
};


/*
*********************************************************************************************************
*********************************************************************************************************
*                                      SERIAL INTERFACE DEVICES
*********************************************************************************************************
*********************************************************************************************************
*/

SERIAL_DEV_CFG  SerialDevCfg_STM32_USART1 = {
     SERIAL_BSP_STM32_USART1_BASE,
    &SerialDrv_STM32_API,
    &SerialBSP_STM32_USART1
};

SERIAL_DEV_CFG  SerialDevCfg_STM32_USART2 = {
     SERIAL_BSP_STM32_USART2_BASE,
    &SerialDrv_STM32_API,
    &SerialBSP_STM32_USART2
};

SERIAL_DEV_CFG  SerialDevCfg_STM32_USART3 = {
     SERIAL_BSP_STM32_USART3_BASE,
    &SerialDrv_STM32_API,
    &SerialBSP_STM32_USART3
};

SERIAL_DEV_CFG  SerialDevCfg_STM32_USART4 = {
     SERIAL_BSP_STM32_USART4_BASE,
    &SerialDrv_STM32_API,
    &SerialBSP_STM32_USART4
};

SERIAL_DEV_CFG  SerialDevCfg_STM32_USART5 = {
     SERIAL_BSP_STM32_USART5_BASE,
    &SerialDrv_STM32_API,
    &SerialBSP_STM32_USART5
};

SERIAL_DEV_CFG  SerialDevCfg_STM32_USART6 = {
     SERIAL_BSP_STM32_USART6_BASE,
    &SerialDrv_STM32_API,
    &SerialBSP_STM32_USART6
};

/*
*********************************************************************************************************
*                                   SERIAL INTERFACE DEVICE POINTER
*
* Note(s) : (1) A serial interface device pointer is required to be passed to the serial interface device
*               driver api ISR_Handler(). 
*********************************************************************************************************
*/

static  SERIAL_DEV  *SerialDev_STM32_USART1_DevPtr;
static  SERIAL_DEV  *SerialDev_STM32_USART2_DevPtr;
static  SERIAL_DEV  *SerialDev_STM32_USART3_DevPtr;
static  SERIAL_DEV  *SerialDev_STM32_USART4_DevPtr;
static  SERIAL_DEV  *SerialDev_STM32_USART5_DevPtr;
static  SERIAL_DEV  *SerialDev_STM32_USART6_DevPtr;

/*$PAGE*/
/*
*********************************************************************************************************
*                                       SerialBSP_STM32_USARTx_ClkEn()
*
* Description : Enable device/peripheral clock.
*
* Argument(s) : perr        Pointer to variable that will receive the return error code from this function :
*
*                               SERIAL_ERR_NONE                 Device/peripheral clock enabled successfully.
*
* Return(s)   : none.
*
* Caller(s)   : SerialDrv_Open() via 'pdev->BSP_API->ClkEn()'.
*
* Note(s)     : none.
*********************************************************************************************************
*/


static  void  SerialBSP_STM32_USART1_ClkEn (SERIAL_ERR  *perr)
{
   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART2_ClkEn (SERIAL_ERR  *perr)
{
   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART3_ClkEn (SERIAL_ERR  *perr)
{
    BSP_PeriphEn(BSP_PERIPH_ID_GPIOC);                          /* Enable GPIOC clock.                                  */
    BSP_PeriphEn(BSP_PERIPH_ID_USART3);                         /* Enable UART clock.                                   */
}

static  void  SerialBSP_STM32_USART4_ClkEn (SERIAL_ERR  *perr)
{
   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART5_ClkEn (SERIAL_ERR  *perr)
{
   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART6_ClkEn (SERIAL_ERR  *perr)
{
   *perr = SERIAL_ERR_NONE;
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                         SerialBSP_STM32_USARTx_ClkDis()
*
* Description : Disable device/peripheral clock.
*
* Argument(s) : perr        Pointer to variable that will receive the return error code from this function :
*
*                               SERIAL_ERR_NONE                 Device/peripheral clock disabled successfully.
*
* Return(s)   : none.
*
* Caller(s)   : SerialDrv_Close() via 'pdev->BSP_API->ClkDis()'.
*
* Note(s)     : none.
*********************************************************************************************************
*/


static  void  SerialBSP_STM32_USART1_ClkDis (SERIAL_ERR  *perr)
{
   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART2_ClkDis (SERIAL_ERR  *perr)
{
   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART3_ClkDis (SERIAL_ERR  *perr)
{
    BSP_PeriphDis(BSP_PERIPH_ID_USART3);                        /* Disable UART clock.                                   */
    
   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART4_ClkDis (SERIAL_ERR  *perr)
{
   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART5_ClkDis (SERIAL_ERR  *perr)
{
   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART6_ClkDis (SERIAL_ERR  *perr)
{
   *perr = SERIAL_ERR_NONE;
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                       SerialBSP_STM32_USARTx_CfgGPIO()
*
* Description : Configure device/peripheral input/output pins.
*
* Argument(s) : flow_ctrl   Flow control enabled.
*
*               perr        Pointer to variable that will receive the return error code from this function :
*
*                               SERIAL_ERR_NONE                 Device/peripheral GPIO configured successfully.
*                               SERIAL_ERR_DRV_INVALID          Device configuration invalid.
*
* Return(s)   : none.
*
* Caller(s)   : SerialDrv_Open() via 'pdev->BSP_API->CfgGPIO()'.
*
* Note(s)     : none.
*********************************************************************************************************
*/

static  void  SerialBSP_STM32_USART1_CfgGPIO (CPU_BOOLEAN   flow_ctrl,
                                              SERIAL_ERR   *perr)
{
    if (flow_ctrl == DEF_ENABLED) {
        *perr = SERIAL_ERR_DRV_INVALID;
         return;
    }

   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART2_CfgGPIO (CPU_BOOLEAN   flow_ctrl,
                                              SERIAL_ERR   *perr)
{
    if (flow_ctrl == DEF_ENABLED) {
        *perr = SERIAL_ERR_DRV_INVALID;
         return;
    }

   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART3_CfgGPIO (CPU_BOOLEAN   flow_ctrl,
                                              SERIAL_ERR   *perr)
{
    GPIO_InitTypeDef  GPIO_InitStructure;

    
    if (flow_ctrl == DEF_ENABLED) {
        *perr = SERIAL_ERR_DRV_INVALID;
         return;
    }
    
                                                                /* Configure GPIOC.10 as push-pull.                     */
    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_10;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;
    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
    GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP;
    GPIO_Init(GPIOC, &GPIO_InitStructure);
    GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_USART3);

                                                                /* Configure GPIOC.11 as input floating.                 */
    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_11;
    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;
    GPIO_Init(GPIOC, &GPIO_InitStructure);
    GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_USART3);    

   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART4_CfgGPIO (CPU_BOOLEAN   flow_ctrl,
                                              SERIAL_ERR   *perr)
{
    if (flow_ctrl == DEF_ENABLED) {
        *perr = SERIAL_ERR_DRV_INVALID;
         return;
    }

   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART5_CfgGPIO (CPU_BOOLEAN   flow_ctrl,
                                              SERIAL_ERR   *perr)
{
    if (flow_ctrl == DEF_ENABLED) {
        *perr = SERIAL_ERR_DRV_INVALID;
         return;
    }

   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART6_CfgGPIO (CPU_BOOLEAN   flow_ctrl,
                                              SERIAL_ERR   *perr)
{
    if (flow_ctrl == DEF_ENABLED) {
        *perr = SERIAL_ERR_DRV_INVALID;
         return;
    }

   *perr = SERIAL_ERR_NONE;
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                       SerialBSP_STM32_USARTx_CfgInt()
*
* Description : Configure device/peripheral interrupt.
*
* Argument(s) : pdev        Pointer to device.
*
*               perr        Pointer to variable that will receive the return error code from this function :
*
*                               SERIAL_ERR_NONE                 Device/peripheral interrupt configured successfully.
*
* Return(s)   : none.
*
* Caller(s)   : SerialDrv_Open() via 'pdev->BSP_API->CfgInt()'.
*
* Note(s)     : none.
*********************************************************************************************************
*/

static  void  SerialBSP_STM32_USART1_CfgInt (SERIAL_DEV  *pdev,
                                             SERIAL_ERR  *perr)
{
    SerialDev_STM32_USART1_DevPtr = pdev;  

    BSP_IntVectSet(BSP_INT_ID_USART1, SerialBSP_STM32_USART1_IntHandler);
    BSP_IntEn(BSP_INT_ID_USART1);
    
   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART2_CfgInt (SERIAL_DEV  *pdev,
                                             SERIAL_ERR  *perr)
{
    SerialDev_STM32_USART2_DevPtr = pdev;

    BSP_IntVectSet(BSP_INT_ID_USART2, SerialBSP_STM32_USART2_IntHandler);
    BSP_IntEn(BSP_INT_ID_USART2);
    
   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART3_CfgInt (SERIAL_DEV  *pdev,
                                             SERIAL_ERR  *perr)
{
    SerialDev_STM32_USART3_DevPtr = pdev;
    
    BSP_IntVectSet(BSP_INT_ID_USART3, SerialBSP_STM32_USART3_IntHandler);
    BSP_IntEn(BSP_INT_ID_USART3);    

   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART4_CfgInt (SERIAL_DEV  *pdev,
                                             SERIAL_ERR  *perr)
{
    SerialDev_STM32_USART4_DevPtr = pdev;

    BSP_IntVectSet(BSP_INT_ID_USART4, SerialBSP_STM32_USART4_IntHandler);
    BSP_IntEn(BSP_INT_ID_USART4);
    
   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART5_CfgInt (SERIAL_DEV  *pdev,
                                             SERIAL_ERR  *perr)
{
    SerialDev_STM32_USART5_DevPtr = pdev;

    BSP_IntVectSet(BSP_INT_ID_USART5, SerialBSP_STM32_USART5_IntHandler);
    BSP_IntEn(BSP_INT_ID_USART5);
    
   *perr = SERIAL_ERR_NONE;
}

static  void  SerialBSP_STM32_USART6_CfgInt (SERIAL_DEV  *pdev,
                                             SERIAL_ERR  *perr)
{
    SerialDev_STM32_USART6_DevPtr = pdev;

    BSP_IntVectSet(BSP_INT_ID_USART6, SerialBSP_STM32_USART6_IntHandler);
    BSP_IntEn(BSP_INT_ID_USART6);
    
   *perr = SERIAL_ERR_NONE;
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                     SerialBSP_STM32_USARTx_ClkFreqGet()
*
* Description : Get peripheral clock frequency.
*
* Argument(s) : none.
*
* Return(s)   : Peripheral clock frequency, in Hz.
*
* Caller(s)   : SerialDrv_Open() via 'pdev->BSP_API->ClkFreqGet()'.
*
* Note(s)     : none.
*********************************************************************************************************
*/

static  CPU_INT32U  SerialBSP_STM32_USART1_ClkFreqGet (void)
{
    CPU_INT32U  clk_freq;


    clk_freq = BSP_PeriphClkFreqGet(BSP_PERIPH_ID_USART1);
    return (clk_freq);
}

static  CPU_INT32U  SerialBSP_STM32_USART2_ClkFreqGet (void)
{
    CPU_INT32U  clk_freq;


    clk_freq = BSP_PeriphClkFreqGet(BSP_PERIPH_ID_USART2);
    return (clk_freq);
}

static  CPU_INT32U  SerialBSP_STM32_USART3_ClkFreqGet (void)
{
    CPU_INT32U  clk_freq;


    clk_freq = BSP_PeriphClkFreqGet(BSP_PERIPH_ID_USART3);
    return (clk_freq);
}

static  CPU_INT32U  SerialBSP_STM32_USART4_ClkFreqGet (void)
{
    CPU_INT32U  clk_freq;


    clk_freq = BSP_PeriphClkFreqGet(BSP_PERIPH_ID_USART4);
    return (clk_freq);
}

static  CPU_INT32U  SerialBSP_STM32_USART5_ClkFreqGet (void)
{
    CPU_INT32U  clk_freq;


    clk_freq = BSP_PeriphClkFreqGet(BSP_PERIPH_ID_USART5);
    return (clk_freq);
}

static  CPU_INT32U  SerialBSP_STM32_USART6_ClkFreqGet (void)
{
    CPU_INT32U  clk_freq;


    clk_freq = BSP_PeriphClkFreqGet(BSP_PERIPH_ID_USART6);
    return (clk_freq);
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                     SerialBSP_STM32_USARTx_IntHandler()
*
* Description : Handle serial port interrupt.
*
* Argument(s) : none.
*
* Return(s)   : none.
*
* Caller(s)   : This is an ISR.
*
* Note(s)     : none.
*********************************************************************************************************
*/

void  SerialBSP_STM32_USART1_IntHandler (void)
{
    SERIAL_DEV      *p_dev;
    SERIAL_DEV_CFG  *p_cfg;


    p_dev = (SERIAL_DEV *)SerialDev_STM32_USART1_DevPtr;
    p_cfg = p_dev->Dev_Cfg;
    p_cfg->Drv_API->ISR_Handler(p_dev, SERIAL_ISR_TYPE_UNKNOWN);
}

void  SerialBSP_STM32_USART2_IntHandler (void)
{
    SERIAL_DEV      *p_dev;
    SERIAL_DEV_CFG  *p_cfg;


    p_dev = (SERIAL_DEV *)SerialDev_STM32_USART2_DevPtr;
    p_cfg = p_dev->Dev_Cfg;
    p_cfg->Drv_API->ISR_Handler(p_dev, SERIAL_ISR_TYPE_UNKNOWN);
}

void  SerialBSP_STM32_USART3_IntHandler (void)
{
    SERIAL_DEV      *p_dev;
    SERIAL_DEV_CFG  *p_cfg;


    p_dev = (SERIAL_DEV *)SerialDev_STM32_USART3_DevPtr;
    p_cfg = p_dev->Dev_Cfg;
    p_cfg->Drv_API->ISR_Handler(p_dev, SERIAL_ISR_TYPE_UNKNOWN);
}

void  SerialBSP_STM32_USART4_IntHandler (void)
{
    SERIAL_DEV      *p_dev;
    SERIAL_DEV_CFG  *p_cfg;


    p_dev = (SERIAL_DEV *)SerialDev_STM32_USART4_DevPtr;
    p_cfg = p_dev->Dev_Cfg;
    p_cfg->Drv_API->ISR_Handler(p_dev, SERIAL_ISR_TYPE_UNKNOWN);
}

void  SerialBSP_STM32_USART5_IntHandler (void)
{
    SERIAL_DEV      *p_dev;
    SERIAL_DEV_CFG  *p_cfg;


    p_dev = (SERIAL_DEV *)SerialDev_STM32_USART5_DevPtr;
    p_cfg = p_dev->Dev_Cfg;
    p_cfg->Drv_API->ISR_Handler(p_dev, SERIAL_ISR_TYPE_UNKNOWN);
}

void  SerialBSP_STM32_USART6_IntHandler (void)
{
    SERIAL_DEV      *p_dev;
    SERIAL_DEV_CFG  *p_cfg;


    p_dev = (SERIAL_DEV *)SerialDev_STM32_USART6_DevPtr;
    p_cfg = p_dev->Dev_Cfg;
    p_cfg->Drv_API->ISR_Handler(p_dev, SERIAL_ISR_TYPE_UNKNOWN);
}