⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 get_usart.c

📁 ARM入门的好帮手.包含了从简单到相对较复杂的程序.
💻 C
字号:
//*----------------------------------------------------------------------------
//*      ATMEL Microcontroller Software Support  -  ROUSSET  -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name           : get_usart.c
//* Object              : Get USART address depending to the chip architechture
//*
//* 1.0 05/11/00 JPP    : Creation
//*----------------------------------------------------------------------------

//* --------------------------- include file ----------------------------------

#include "get_usart.h"

//* --------------------------- Constant definition ---------------------------


//* ------------------------------  Local variable ----------------------------
//* Global PIO description to Architecture 40, 55 and 63
PioCtrlDesc GPIO_DESC ;
UsartDesc USART0_DESCRIPTOR ;
UsartDesc USART1_DESCRIPTOR ;

//*----------------------------------------------------------------------------
//* Function Name       : get_usart0_desc
//* Object              : Get the descriptor for USART 0 and mcki
//* Input Parameters    : <mcki> mcki Address for update
//* Output Parameters   : usart descriptor
//*                       <mcki> mcki updated
//*----------------------------------------------------------------------------
UsartDesc * get_usart0_desc ( int *mcki )
//* Begin
{
    int         chip_arch;
    TimeDescRtc rtc;            //* 55 achitecture only

    //* Get Id chip for get mcki evaluation board
    chip_arch = at91_read_chip_id(0);

    //*  Chip Architecture
    chip_arch = (SF_ARCH & chip_arch);

    //* Common values
    USART0_DESCRIPTOR.pio_ctrl  = &GPIO_DESC;		/* IO controller descriptor */
    USART0_DESCRIPTOR.periph_id = 2;               /* USART Peripheral Identifier */

    if ( chip_arch == SF_ARCH_AT91x40)
    {   //* AT9140800
        *mcki = 32768000;					/* EB 40 And EB 01*/
        //* define Usart
        USART0_DESCRIPTOR.usart_base = ((StructUSART*) 0xFFFD0000); /* Peripheral base */
        USART0_DESCRIPTOR.pin_rxd = 15;                  /* RXD pin number in the PIO */
        USART0_DESCRIPTOR.pin_txd = 14;                  /* TXD pin number in the PIO */
        USART0_DESCRIPTOR.pin_sck = 13;                  /* SCK pin number in the PIO */

        GPIO_DESC.pio_base = ((StructPIO*) 0xFFFF0000); /* Base Address */
        GPIO_DESC.periph_id  = 8;                 /* Peripheral Identifier */
        GPIO_DESC.pio_number = 31;                /* Total Pin Number */

    }
    else if  ( chip_arch == SF_ARCH_AT91x63)
    {   //* AT9163200
        *mcki = 25000000;					/* EB 63*/

        USART0_DESCRIPTOR.usart_base = ((StructUSART*)0xFFFC0000) ;      /* Peripheral base */
        USART0_DESCRIPTOR.pin_rxd = 16;                  /* RXD pin number in the PIO */
        USART0_DESCRIPTOR.pin_txd = 15;                  /* TXD pin number in the PIO */
        USART0_DESCRIPTOR.pin_sck = 14;                  /* SCK pin number in the PIO */

        GPIO_DESC.pio_base = ((StructPIO *) 0xFFFEC000); /* PIOA_DESC Base Address */
        GPIO_DESC.periph_id  = 14;                /* Peripheral Identifier */
        GPIO_DESC.pio_number = 30;                /* Total Pin Number */

    }
    else if ( chip_arch == SF_ARCH_AT91x55)
    {   //* AT9155800

        //* Open the RTC time
        rtc.rtc_desc=&RTC_DESC;
        at91_time_rtc_open(&rtc);

        // get the mcki
        *mcki = at91_time_rtc_mcki(&rtc, &TCB0_DESC );

        USART0_DESCRIPTOR.usart_base = ((StructUSART *)0xFFFC0000); /* Peripheral base */
        USART0_DESCRIPTOR.pin_rxd = 16;                  /* RXD pin number in the PIO */
        USART0_DESCRIPTOR.pin_txd = 15;                  /* TXD pin number in the PIO */
        USART0_DESCRIPTOR.pin_sck = 14;                  /* SCK pin number in the PIO */

        GPIO_DESC.pio_base = ((StructPIO *)0xFFFEC000); /* PIOA_DESC Base Address */
        GPIO_DESC.periph_id  = 14;                /* Peripheral Identifier */
        GPIO_DESC.pio_number = 30;                /* Total Pin Number */
    }

    return ( &USART0_DESCRIPTOR);
//* End
}
//*----------------------------------------------------------------------------
//* Function Name       : get_usart1_desc
//* Object              : Get the descriptor for USART 1
//* Input Parameters    : none
//* Output Parameters   : usart descriptor
//*----------------------------------------------------------------------------
UsartDesc * get_usart1_desc ( void )
//* Begin
{
    int         chip_arch;

    //* Get Id chip for get mcki evaluation board
    chip_arch = at91_read_chip_id(0);

    //*  Chip Architecture
    chip_arch = (SF_ARCH & chip_arch);

    //* Common values
    USART1_DESCRIPTOR.pio_ctrl  = &GPIO_DESC;		/* IO controller descriptor */
    USART1_DESCRIPTOR.periph_id = 3;               /* USART Peripheral Identifier */

    if ( chip_arch == SF_ARCH_AT91x40)
    {   //* AT9140800
        //* define Usart
        USART1_DESCRIPTOR.usart_base = ((StructUSART*)0xFFFCC000); /* Peripheral base */
        USART1_DESCRIPTOR.pin_rxd = 22;                  /* RXD pin number in the PIO */
        USART1_DESCRIPTOR.pin_txd = 21;                  /* TXD pin number in the PIO */
        USART1_DESCRIPTOR.pin_sck = 20;                  /* SCK pin number in the PIO */

        GPIO_DESC.pio_base = ((StructPIO*) 0xFFFF0000); /* Base Address */
        GPIO_DESC.periph_id  = 8;                 /* Peripheral Identifier */
        GPIO_DESC.pio_number = 31;                /* Total Pin Number */

    }
    else if  ( chip_arch == SF_ARCH_AT91x63)
    {   //* AT9163200

        USART1_DESCRIPTOR.usart_base = ((StructUSART*)0xFFFC4000) ;      /* Peripheral base */
        USART1_DESCRIPTOR.pin_rxd = 19;                  /* RXD pin number in the PIO */
        USART1_DESCRIPTOR.pin_txd = 18;                  /* TXD pin number in the PIO */
        USART1_DESCRIPTOR.pin_sck = 17;                  /* SCK pin number in the PIO */

        GPIO_DESC.pio_base = ((StructPIO *) 0xFFFEC000); /* PIOA_DESC Base Address */
        GPIO_DESC.periph_id  = 14;                /* Peripheral Identifier */
        GPIO_DESC.pio_number = 30;                /* Total Pin Number */

    }
    else if ( chip_arch == SF_ARCH_AT91x55)
    {   //* AT9155800

        USART1_DESCRIPTOR.usart_base = ((StructUSART*)0xFFFC4000); /* Peripheral base */
        USART1_DESCRIPTOR.pin_rxd = 19;                  /* RXD pin number in the PIO */
        USART1_DESCRIPTOR.pin_txd = 18;                  /* TXD pin number in the PIO */
        USART1_DESCRIPTOR.pin_sck = 17;                  /* SCK pin number in the PIO */

        GPIO_DESC.pio_base = ((StructPIO *)0xFFFEC000); /* PIOA_DESC Base Address */
        GPIO_DESC.periph_id  = 14;                /* Peripheral Identifier */
        GPIO_DESC.pio_number = 30;                /* Total Pin Number */
    }

    return ( &USART1_DESCRIPTOR);
//* End
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -