main.c

来自「UART ADI example 简单的例子 练练手」· C语言 代码 · 共 97 行

C
97
字号
/****************************************Copyright (c)****************************************************
**                            Guangzhou ZHIYUAN electronics Co.,LTD.
**                                      
**                                 http://www.embedtools.com
**
**--------------File Info---------------------------------------------------------------------------------
** File name:               main.c
** Latest modified Date:    2008-8-18
** Latest Version:          1.0
** Descriptions:            用户程序主文件
**
**--------------------------------------------------------------------------------------------------------
** Created by:              CaiWenqi
** Created date:            2008-8-18
** Version:                 1.0
** Descriptions:            UART的DMA样例
**
**--------------------------------------------------------------------------------------------------------
** Modified by:             
** Modified date:           
** Version:                 
** Descriptions:            
**
*********************************************************************************************************/
#include "config.h"

/*********************************************************************************************************
** Function name:       sysDelay
** Descriptions:        主程序
** Input parameters:    uiT 数值越大,延时越长
** Output parameters:   NONE
** Returned value:      NONE
*********************************************************************************************************/
void sysDelay(uint16 uiT)
{
    uint16 i,j;
    for(j = 0; j < uiT; j++)
    for(i = 0; i < 0x0fff; i++);
}

/*********************************************************************************************************
** Function name:       main
** Descriptions:        主程序
** Input parameters:    NONE
** Output parameters:   NONE
** Returned value:      NONE
*********************************************************************************************************/
void main(void)
{
    CreatDescLMode a1,a2,a3;
    
    char *str1 = "/************************/\n";
    char *str2 = "/* BeiJing huanying ni! */\n";
    char *str3 = "/**********OVER**********/\n";
    
    uartConfig(9600, 8, 1, PARITY_DIS);
    *pUART_IER |= 0x0002;
    ssync();

    a1.uiNextDescPtr    = (uint32)&a2;
    a1.uiStartAddr      = (uint32)(str1);
    a1.ucDmaConfig      = 0x0001|(7<<12)|(7<<8);
    a1.ucXCount         = strlen(str1);
    a1.ucXModify        = 1;

    a2.uiNextDescPtr    = (uint32)&a3;
    a2.uiStartAddr      = (uint32)(str2);
    a2.ucDmaConfig      = 0x0001|(7<<12)|(7<<8);
    a2.ucXCount         = strlen(str2);
    a2.ucXModify        = 1;  
      
    a3.uiNextDescPtr    = 0;
    a3.uiStartAddr      = (uint32)(str3);
    a3.ucDmaConfig      = 0x0001;
    a3.ucXCount         = strlen(str3);
    a3.ucXModify        = 1;
    ssync();
    
    *pDMA7_PERIPHERAL_MAP = 7 << 12;                                    /* 配置外设映射                 */
    ssync();
    *pDMA7_NEXT_DESC_PTR = (&a1);
    ssync();

    *pDMA7_CONFIG = 0x0001|(7<<12)|(7<<8)|(1<<5);                       /* 启动传输                     */
    ssync();

    while (1) {
    }
}




/*********************************************************************************************************
  END FILE
*********************************************************************************************************/

⌨️ 快捷键说明

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