📄 submain.c
字号:
/*
** Copyright (C) ARM Limited, 2002. All rights reserved.
*/
/*
** $Sub$$main() is executed immediately before the user defined main() function.
** Compile this with -DUSE_SERIAL_PORT to initialize serial port on Integrator.
** For information on $Sub and $Super, see ADS 1.2 Linker and Utilities Guide
*/
#include "71x_lib.h"
__weak extern void cache_init(void);
extern void $Super$$main(void);
#ifdef USE_SERIAL_PORT
void init_serial(void);
#endif
#ifdef USE_LCD
void LCDInit(void);
#endif
void $Sub$$main(void)
{
int temp;
cache_init(); // enables caches
#ifdef DEBUG
debug();
#endif
#ifdef USE_SERIAL_PORT
init_serial(); // initialize the UART0
#endif
#ifdef USE_LCD
LCDInit();
#endif
__asm // enable IRQs
{
MRS temp, CPSR
BIC temp, temp, #0x80
MSR CPSR_c, temp
}
$Super$$main(); // calls the original function main()
}
#ifdef USE_SERIAL_PORT
void init_serial()
{
#define UART0_Rx_Pin (0x0001<<8)
#define UART0_Tx_Pin (0x0001<<9)
// Configure the GPIO pins
GPIO_Config(GPIO0, UART0_Tx_Pin, GPIO_AF_PP);
GPIO_Config(GPIO0, UART0_Rx_Pin, GPIO_IN_TRI_CMOS);
// Configure the UART 0
UART_OnOffConfig(UART0, ENABLE); // Turn UART0 on
UART_FifoConfig (UART0, ENABLE); // ENABLE FIFOs
UART_FifoReset (UART0 , UART_RxFIFO); // Reset the UART_RxFIFO
UART_FifoReset (UART0 , UART_TxFIFO); // Reset the UART_TxFIFO
UART_LoopBackConfig(UART0 , DISABLE); // Disable Loop Back
/* Configure the UART0 as following:
- Baudrate = 9600 Bps
- No parity
- 8 data bits
- 1 stop bit */
UART_Config(UART0,9600,UART_NO_PARITY,UART_1_StopBits,UARTM_8D);
UART_RxConfig(UART0 ,DISABLE); // DISABLE Rx
}
#endif
#ifdef USE_LCD
void LCDInit(void)
{
u8 characT[]={0x0E, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00};
u8 characM[]={0x1B, 0x15, 0x11, 0x00, 0x00, 0x00, 0x00};
// char szBuffer[16+1];
LCD_Init();
LCD_SetCursorHome();
LCD_CreateCharacter(0x1, characT);
LCD_CreateCharacter(0x2, characM);
LCD_UnderlineCursorOn();
gotoxy(1,1);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -