📄 keil_iodemo.c
字号:
/*
* IODEMO.C: Demonstrates usage of printf, scanf and malloc with
* GNU Compiler (on ADuC7024)
* Copyright KEIL ELEKTRONIK GmbH and KEIL SOFTWARE, Inc. 2003 - 2004
*
* This file may be compiled in ARM or Thumb Mode
*/
#include <ADuC7024.H>
#include <stdio.h>
#include <stdlib.h>
unsigned char memory_pool[0x400];
int main (void) {
int iIterator;
int iUserVar1 = 0;
int *iArray;
GP1CON = 0x011; // Setup tx & rx pins on P1.0 and P1.1
// Start setting up UART at 9600bps
COMCON0 = 0x80; // Setting DLAB
COMDIV0 = 0x93;
COMDIV1 = 0x00;
COMCON0 = 0x07; // Clearing DLAB
// initialize memory pool
init_mempool (memory_pool, sizeof(memory_pool));
// create an array big enough to hold 10 integers
iArray = malloc (10*sizeof(int));
if(iArray == NULL) {
printf("Malloc failed!\n");
}
else {
for(iIterator = 0; iIterator<10; iIterator++) {
iArray[iIterator] = iIterator*2;
}
}
// demonstrate user input via scanf
// an alternative to scanf is gets and sscanf
printf("please enter a number: ");
scanf("%i", &iUserVar1);
printf("\nUser Input: %i\n", iUserVar1);
while (1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -