📄 sdk7a404_simple_startup.c
字号:
/***********************************************************************
* $Workfile: sdk7a404_simple_startup.c $
* $Revision: 1.2 $
* $Author: WellsK $
* $Date: Sep 08 2003 14:05:54 $
*
* Project: SDK7A404 simple startup example
*
* Description:
* This file contains a simple startup code example that will
* generate a 'heartbeat' indicator on the LED.
*
* Revision History:
* $Log: //smaicnt2/pvcs/VM/sharpmcu/archives/sharpmcu/software/csps/lh7a404/bsps/sdk7a404/startup/examples/simple/sdk7a404_simple_startup.c-arc $
*
* Rev 1.2 Sep 08 2003 14:05:54 WellsK
* Added support for virtual MMU table location.
*
* Rev 1.1 Sep 08 2003 10:19:38 WellsK
* Added default vector for vic_initialize(). Updated the background
* comment. Added the TIMER_MSEC macro value.
*
* Rev 1.0 Jul 01 2003 12:31:20 WellsK
* Initial revision.
*
*
***********************************************************************
* SHARP MICROELECTRONICS OF THE AMERICAS MAKES NO REPRESENTATION
* OR WARRANTIES WITH RESPECT TO THE PERFORMANCE OF THIS SOFTWARE,
* AND SPECIFICALLY DISCLAIMS ANY RESPONSIBILITY FOR ANY DAMAGES,
* SPECIAL OR CONSEQUENTIAL, CONNECTED WITH THE USE OF THIS SOFTWARE.
*
* SHARP MICROELECTRONICS OF THE AMERICAS PROVIDES THIS SOFTWARE SOLELY
* FOR THE PURPOSE OF SOFTWARE DEVELOPMENT INCORPORATING THE USE OF A
* SHARP MICROCONTROLLER OR SYSTEM-ON-CHIP PRODUCT. USE OF THIS SOURCE
* FILE IMPLIES ACCEPTANCE OF THESE CONDITIONS.
*
* COPYRIGHT (C) 2001 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
* CAMAS, WA
**********************************************************************/
#include "abl_types.h"
#include "abl_arm922t_cp15_driver.h"
#include "abl_irq_fiq.h"
#include "lh7a404_vic_driver.h"
#include "lh7a404_timer_driver.h"
#include "sdk7a404_cpld_driver.h"
/* Timer device handle */
INT_32 timer1dev;
/* Timer count value */
volatile UNS_32 t1count;
/***********************************************************************
*
* Function: timer1_user_interrupt
*
* Purpose: Timer 1 interrupt handler
*
* Processing:
* Clear the timer interrupt and increment the interrupt count.
* Perform some basic LED toggling logic based on the interrupt
* count.
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void timer1_user_interrupt(void)
{
static BOOL_32 gpio_led_state = FALSE;
/* Clear the interrupt and increment count */
timer_ioctl(timer1dev, TIMER_INT_CLEAR, 0);
t1count++;
switch (t1count)
{
case 3:
/* Turn on first LED */
gpio_led_state = TRUE;
break;
case 8:
/* Turn off first LED */
gpio_led_state = FALSE;
break;
default:
if (t1count >= 13)
{
t1count = 0;
}
break;
}
cpld_enable_led(gpio_led_state);
}
/***********************************************************************
*
* Function: c_entry
*
* Purpose: Application entry point from the startup code
*
* Processing:
* Clear t1count and disable IRQ and FIQ interrupts in the ARM core.
* Initialize the interrupt driver with a call to int_initialize.
* Install the IRQ dispatcher at the ARM vector address with a call
* to int_install_handler. Install the timer interrupt handler in
* the IRQ dispatcher with a call to vic_install_irq_handler.
* Initialize timer 1 for a periodic 100mS underflow and enable the
* timer 1 interrupt in the interrupt controller. Enable interrupts
* in the ARM core. Wait in a endless loop as the timer 1 interrupt
* will handle the blinking of the LEDs.
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void c_entry(void)
{
/* Clear initial state of interrupt count */
t1count = 0;
/* Disable interrupts in ARM core */
disable_irq_fiq();
/* Set virtual address of MMU table (needed for VIC driver
functions) */
cp15_set_vmmu_addr((UNS_32 *)
(0xC1C00000 + (0xCD3E0000- 0xCD000000)));
/* Initialize interrupt system */
vic_initialize(0xFFFFFFFF);
/* Install standard IRQ dispatcher at ARM IRQ vector */
vic_install_arm_handler(IRQ_VEC, (PFV) vic_arm_irq_dispatcher);
/* Install VIC1 and VIC2 handlers */
vic_install_arm_handler(VIC1_IRQ_VEC, (PFV) vic1_irq_dispatcher);
vic_install_arm_handler(VIC2_IRQ_VEC, (PFV) vic2_irq_dispatcher);
/* Install timer handler as a vectored interrupt */
vic_install_handler(VIC_TC1UINTR,
VIC_VECTORED, (PFV) timer1_user_interrupt);
/* Open timer 1 */
timer1dev = timer_open(TIMER1, 0);
/* Setup timer 1 for a 10Hz tick */
timer_ioctl(timer1dev, TIMER_SET_USECS, (100 * TIMER_MSEC));
/* Enable timer (starts counting) */
timer_ioctl(timer1dev, TIMER_ENABLE, 1);
/* Clear any latched timer 1 interrupts */
timer_ioctl(timer1dev, TIMER_INT_CLEAR, 0);
/* Enable timer 1 interrupts in the interrupt controller */
vic_int_enable(VIC_TC1UINTR, TRUE);
/* Enable IRQ interrupts in the ARM core */
enable_irq();
/* Loop forever and let interrupts toggle the LEDs */
while (1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -