📄 main.c
字号:
//=============================================================================
// Filename: main.c
//
// Description: A sample driver application for the bootloader.
//
// Copyright (C) 2000 - 2002 Texas Instruments Incorporated
//
//============================================================================
#include "arm_boot.h"
#include "dsp_proj_code.h"
#include "dsp_proj_data.h"
#include <stdio.h>
// ---------------------- Interrupt Setup --------------------------------
#define SWI_CMD_SETSTK 1
#define SWI_MODE_FIQ 0x11
#define SWI_MODE_IRQ 0x12
#define SWI_MODE_SVC 0x13
#define SWI_CMD_SETCPSR 2
#define SWI_MASK_IRQ 0x80
#define SWI_IRQENABLE 0x00
#define ENABLE_IRQ_INTERRUPTS SWI_Command(SWI_CMD_SETCPSR, \
SWI_MASK_IRQ, \
SWI_IRQENABLE)
int SWI_cmd, SWI_arg1, SWI_arg2;
static void SWI_Command(int cmd, unsigned long arg1, unsigned long arg2)
{
SWI_cmd = cmd;
SWI_arg1 = arg1;
SWI_arg2 = arg2;
asm(" SWIAL #0");
}
// ---------------------- Stack Setup -------------------------------
#define SVC_STACK_SIZE 128
#define IRQ_STACK_SIZE 128
#define FIQ_STACK_SIZE 128
static unsigned long _svc_stack[SVC_STACK_SIZE];
static unsigned long _irq_stack[IRQ_STACK_SIZE];
static unsigned long _fiq_stack[FIQ_STACK_SIZE];
static void setupstacks()
{
SWI_Command(SWI_CMD_SETSTK, SWI_MODE_SVC,
(unsigned long) _svc_stack + SVC_STACK_SIZE);
SWI_Command(SWI_CMD_SETSTK, SWI_MODE_IRQ,
(unsigned long) _irq_stack + IRQ_STACK_SIZE);
SWI_Command(SWI_CMD_SETSTK, SWI_MODE_FIQ,
(unsigned long) _fiq_stack + FIQ_STACK_SIZE);
}
// ---------------------- Clock Setup --------------------------------
#define DSPCLK_ENABLE 0x00004000
#define MCLK_ENABLE 0x00008000
#define KBDIO_IO ((unsigned long *)0xFFFF2900)
#define KBDIO_CIO ((unsigned long *)0xFFFF2904)
#define KBDIO_EN ((unsigned long *)0xFFFF2914)
#define KBDIO_IO1 0x00000002
static unsigned long nandgpio( unsigned long *addr, unsigned long Data )
{
unsigned long readback;
readback = *addr;
readback &= ~(Data);
*addr = readback;
return( readback );
}
static void EnableDSPCLK(void)
{
nandgpio(KBDIO_EN, DSPCLK_ENABLE);
}
static void EnableMCLK(void)
{
nandgpio(KBDIO_EN, MCLK_ENABLE);
}
// ---------------------- Main Driver --------------------------------
// set up a structure to represent the DSP program and data to be loaded
#define PMST 0xFF88
static dsp_app_struct test_dsp_app =
{dsp_proj_program, dsp_proj_data, PMST};
main()
{
resetinterrupts();
setupstacks();
pll_init(44, 100); // setup arm and dsp PLLs
EnableMCLK(); // enable external arm clock
EnableDSPCLK(); // enable dsp clkout
// enable DSP_XF output on KBGPIO1
nandgpio(KBDIO_CIO, KBDIO_IO1);
nandgpio(KBDIO_EN, KBDIO_IO1);
// load the DSP with the program and data
if (dsp_load(&test_dsp_app) != LOAD_OK) {
while (1) {
}
}
ENABLE_IRQ_INTERRUPTS;
// set ILR__IRQ_15 to edge sensitive interrupt
*((long *)0xffff2d58) = 0x00000020;
// start the DSP
dsp_start() ;
// loop infinitely
while (1) {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -