chap08_3.c

来自「it is a sample code for s3c2410 board.」· C语言 代码 · 共 98 行

C
98
字号
// --------------------------------------------------------------------
//
//   Title     :  MAIN
//             :
//   Library   :
//             :
//   Developers:  MICROTIME MDS group
//             :
//   Purpose   :  DEMO Program for Creator Board
//             :
//   Limitation:
//             :
//   Note      :
//             :
// --------------------------------------------------------------------
//   modification history :
// --------------------------------------------------------------------
//   Version| mod. date: |
//   V1.0   | 03/31/2003 | First release
// --------------------------------------------------------------------
//
// Note:
//
//       MICROTIME COMPUTER INC.
//
//

/*************************************************************************
Include files
*************************************************************************/
#include <stdio.h>
#include <inarm.h>
#include "isr.h"
#include "console.h"
#include "dma.h"



/*************************************************************************
MAIN Program 
************************************************************************/
int main(void)
{
    char strQUE[] = "\n\rQ:The S3C4510B has a two-channel general DMA controller,\n\rcalled the GDMA.'y' or 'n'?\n\r";
	char strQUE2[] = "\n\rPlease enter 'y' or 'n'\n\r";
    char strANS1[] = "\n\rYour answer is right\n\r";
    char strANS2[] = "\n\rYour answer is wrong\n\r";
    char strRec[1];

	//initial uart
	console_init();
	//clear interrupt status
	ClrIntStatus();
	//initial interrupt	for interrupt vector table
    InitialHandler_ISR();
	//enable system interrupt service
    __enable_interrupt();
	//enable register's interrupr service
	EnableInterrupt(BIT_GMASK);
   	// install interrupt source and its service function
    InstallHandler_ISR(GDMA0, UART_TX_DMA);
    InstallHandler_ISR(GDMA1, UART_RX_DMA);
	//clear interrupt pending 
	ClearPending(BIT_GDMA0);
	ClearPending(BIT_GDMA1);
	//enable interrupt service
	EnableInterrupt(BIT_GDMA0);
	EnableInterrupt(BIT_GDMA1);
	
	//ask question
    Console_Write(strQUE, sizeof(strQUE));
    while (!UART_TX_DMA_Finish());
	//for answer
	while(1) {
    	Console_Read(strRec, 1);
	    while (!UART_RX_DMA_Finish());
		if(strRec[0] == 'y' || strRec[0] == 'Y') {
    		Console_Write(strANS1, sizeof(strANS1));
	    	while (!UART_TX_DMA_Finish());
			break;
		}
		else if(strRec[0] == 'n' || strRec[0] == 'N') {
    		Console_Write(strANS2, sizeof(strANS2));
	    	while (!UART_TX_DMA_Finish());
			break;
		}
		else {
		    Console_Write(strQUE2, sizeof(strQUE2));
    		while (!UART_TX_DMA_Finish());
		}
	}

	while(1);	
    return(0);
}


⌨️ 快捷键说明

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