📄 main.c
字号:
/****************************************************************************/
/* TEXAS INSTRUMENTS PROPRIETARY INFORMATION */
/* */
/* (c) Copyright, Texas Instruments Incorporated, 2006. */
/* All Rights Reserved. */
/* */
/* Property of Texas Instruments Incorporated. Restricted Rights - */
/* Use, duplication, or disclosure is subject to restrictions set */
/* forth in TI's program license agreement and associated documentation. */
/****************************************************************************/
/****************************************************************************/
/* main.c */
/****************************************************************************/
#include "common.h"
#include "ddp2230_rtos_include.h"
#include "flash_table.h"
#include "ddp.h"
#include "int.h"
#include "tmr.h"
#include "usb.h"
#include "gpio.h"
#include "main.h"
#include "global.h"
#include "taskParm.h"
#include "sysmon.h"
#include "gpioFunction.h"
extern uint32 Image$$RWDATA$$ZI$$Limit;
extern uint32 HEAP_End;
uint32 rtosInitCallback( void ); /* RTOS initialization callback */
extern void sysmonTask( void ); /* system initialization/monitor task */
/****************************************************/
/* LED Fault interface. */
/****************************************************/
static void delay( int count, BOOL isLowPower ); /* loop-based delay timer */
static void digit( BOOL isLowPower ); /* loop-based digit blinker */
#define CNT_BLINK 500000 /* on/off blink time */
#define CNT_DIGIT 3000000 /* inter-digit delay time */
#define CNT_CODE 8000000 /* inter-codegroup delay time */
/****************************************************************************/
/* Application entry point. */
/****************************************************************************/
void C_Entry( void )
{
/****************************************************/
/* Ensure interrupts are turned off. This avoids */
/* potential problems during reload/restart of the */
/* application with the debugger. Interrupts are */
/* guaranteed to be off after a power-up reset. */
/****************************************************/
INT_DisableIRQ( 0xfffffffful );
/****************************************************/
/* Start the RTOS. Low-level initialization is done */
/* in the rtosInitCallback function, called during */
/* RTOS startup. */
/****************************************************/
if( FLASHTABLE_APP_SIGNATURE != ((FLASH_TABLE*)( FLASH_TABLEADDR )) -> Signature )
llFault( LLFAULT_MAIN_FLASHTABLE, TRUE );
RTA_Init(); /* RTOS initialization */
FLASH_SetTableAddr( FLASH_TABLEADDR ); /* define flash table address */
/****************************************************/
/* __RO_SDRAM indicates that read-only data is to */
/* moved to SDRAM. The target will execute with no */
/* flash ROM access, with the exception of splash */
/* screen image. This allows splash screen update */
/* on a running projector. */
/****************************************************/
#ifdef __RO_SDRAM
FLASH_MoveData( SDRAM_TABLEADDR, FLASH_MOVE_ASIC_CONFIG | FLASH_MOVE_SEQUENCE | FLASH_MOVE_APPL_CONFIG | FLASH_MOVE_OSD_CONFIG, FLASH_DATA_VARIATION_1 | FLASH_DATA_VARIATION_2 );
FLASH_SetTableAddr( SDRAM_TABLEADDR );/* define flash table address */
#endif
RTA_InstallInitCallback( rtosInitCallback ); /* app init callback */
RTA_Start(); /* start */
for(;;);
}
/****************************************************************************/
/* RTOS initialization callback. */
/****************************************************************************/
uint32 rtosInitCallback( void )
{
DDP_GetRevInfo revInfo; /* ASIC revision info */
uint32 t32; /* temp; memory pool size */
/****************************************************/
/* Initialize the memory pool. */
/****************************************************/
t32 = ((uint32)&HEAP_End - (uint32)&Image$$RWDATA$$ZI$$Limit) & 0xfffffffc;
if( RTA_SUCCESS != RTA_MemPoolCreate( &gID_MemPool, t32, (void *)&Image$$RWDATA$$ZI$$Limit, "MEM0" ))
llFault( LLFAULT_MAIN_MEMPOOL, TRUE );
/****************************************************/
/* Validate ASIC configuration. */
/****************************************************/
if( PASS != DDP_SetAsicConfigNum( CONFIGNO_SEQ, CONFIGNO_SWASIC ))
{
revInfo.SeqAsicConfigNum = CONFIGNO_SEQ;
revInfo.SwAsicConfigNum = CONFIGNO_SWASIC;
DDP_GetAsicConfigRevision( &revInfo );
if( revInfo.SeqConfigRevision != revInfo.SeqExpectedRevision )
llFault( LLFAULT_MAIN_SEQCFG, TRUE );
if( revInfo.SwConfigRevision != revInfo.SwExpectedRevision )
llFault( LLFAULT_MAIN_ASICCFG, TRUE );
}
/****************************************************/
/* Initialize the ARM and peripherals. */
/****************************************************/
if( 0 != DDP_Init( DDP_FN_ARM ))
llFault( LLFAULT_MAIN_ARMINIT, TRUE );
/****************************************************/
/* Start the RTOS timer. */
/****************************************************/
TMR_CfgRTOSTick( RTA_KernelSysTickHandler, RTOS_MS_PER_TICK ); /* clock */
TMR_StartRTOSTick(); /* Start RTOS clock */
/****************************************************/
/* Create the startup/system monitor task. */
/****************************************************/
if( RTA_SUCCESS != RTA_TaskCreate( sysmonTask, &t32, PRIORITY_SYSINIT, STACK_SYSMON, "INIT", 0))
llFault(LLFAULT_MAIN_INITTASK, TRUE );
return gID_MemPool;
}
/****************************************************************************/
/* Low-level fault */
/* */
/* Blink an LED to indicate an initialization error. */
/* */
/* Note that this function may be called prior to establishing the flash */
/* configuration or prior to starting the RTOS. Since GPIO does not use any */
/* configuration parameters, the GPIO pin is configured as expected. */
/****************************************************************************/
void llFault( uint08 faultType, BOOL isLowPower )
{
uint08 fcode;
DDP_Init( DDP_FN_GPIO );
GPIO_SetPinConfig( LLFAULT_GPIO, GIOCFG_OUTPUT, FALSE, GIOCFG_ACTIVE );
for(;;)
{
fcode = faultType;
while( 0xf0 & fcode ) { digit( isLowPower ); fcode -= 0x10; }
delay( CNT_DIGIT, isLowPower );
while( 0x0f & fcode ) { digit( isLowPower ); fcode -= 0x01; }
delay( CNT_CODE, isLowPower );
}
}
/****************************************************************************/
/* Generate a blink code. faultType is broken into 2 hex digits. Each digit */
/* causes the indicated number of blinks. Gaps in time are inserted to */
/* separate the two digits of a code and sets of the code. */
/****************************************************************************/
static void delay( int count, BOOL isLowPower )
{
if( isLowPower ) count /= 10; /* fewer loops in low-power mode */
while( count-- );
}
/****************************************************************************/
static void digit( BOOL isLowPower )
{
GPIO_SetPin( LLFAULT_GPIO, TRUE );
delay( CNT_BLINK, isLowPower );
GPIO_SetPin( LLFAULT_GPIO, FALSE );
delay( CNT_BLINK * 2, isLowPower );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -