⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hello.cpp

📁 转载: DSP串口硬件SPI接口LCD12864显示C++程序代码 细描述: 终于把5409的McBSP的配置搞清楚了!现在就把我做的写出来
💻 CPP
字号:
/*
 *  Copyright 2001 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  U.S. Patent Nos. 5,283,900  5,392,448
 */
/* "@(#) DSP/BIOS 4.51.0 05-23-01 (barracuda-i10)" */
/***************************************************************************/
/*                                                                         */
/*     H E L L O . C                                                       */
/*                                                                         */
/*     Basic C standard I/O from main.                                     */
/*                                                                         */
/*                                                                         */
/***************************************************************************/

#include <cstdio> //stdio.h
#include <cstring>//string.h
//#include <regs.h>
#include "C5402DEF.h"//

volatile bool IOXF;
volatile unsigned int SystemRamTest;

extern "C" interrupt void Timer0Isr();


/*
 *  ======== main ========
 */


class SystemObj {//系统类
public:
  SystemObj(void);
public:
  inline void SystemInit(void);
private:
  unsigned int SystemRamTest;
};

SystemObj::SystemObj(void)
{
volatile unsigned int start;
  Disable();//关中断
  for (start = 0; start < 10000; start ++);
  SystemInit();
}

void SystemObj::SystemInit(void)
{
  if (::SystemRamTest != 0x55aa) {
    ::SystemRamTest = 0x55aa;
  }
  if (SystemRamTest != 0x55aa) {
    SystemRamTest = 0x55aa;
  }
  IOXF = 0;
}


SystemObj Sys;

int main(void)
{
unsigned int j = 1;
  Sys.SystemInit();
  SREG->ST1 |= (1 << CPL);

  SREG->ST1 &= ~(1 << CPL);

  SREG->ST1 |= (1 << XF);

  SREG->ST1 &= ~(1 << XF);
  SREG->ST1 |= (1 << XF);

  SREG->ST1 &= ~(1 << XF);

  SREG->ST1 |= (1 << INTM);
  SREG->ST1 &= ~(1 << INTM);

  TIMER0->TCR |= (1 << TSS);
  SREG->IMR = 0x0000;
  SREG->IFR = 0xffff;
  Enable();//开中断
  TI_BASE_SREG->IMR = 0x9876;
  TI_BASE_SREG->IFR = 0x1234;
  SREG->IMR = 0x4321;
  SREG->IFR = 0xffff;
  for(int i = 0; i < 8; i ++) {
    SREG->IMR |= j;
    SREG->IFR &= ~j;
    j <<= 1;
    SREG->IMR = 0x4321;
    SREG->IFR = 0xffff;
  }
  SREG->IMR = (1 << TINT0);//允许TINT0中断
  TIMER0->PRD = 5000;
  TIMER0->TCR &= ~(1 << TSS);
  while(1)
  {
    if (::IOXF) {
      SREG->ST1 |= (1 << XF);
    }
    else {
      SREG->ST1 &= ~(1 << XF);
    }
  }
}

interrupt void Timer0Isr() {
  ::IOXF = !::IOXF;
//  TIMER0->TCR |= (1 << TSS);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -