DSP 之中断控制(Interrupt)

DSP 之中断控制(Interrupt)DSP 之中断控制 Interrupt Copyright C 2004TexasIns AllRightsRes include include mmc0 从 cslmem 中分配内存 pragmaDATA SECTION mmc0 cslmem MMC Hand

DSP 之中断控制(Interrupt):

DSP 之中断控制(Interrupt)

/* * Copyright (C) 2004 Texas Instruments Incorporated * All Rights Reserved */ #include <csl_mmc.h> #include <stdio.h> /* mmc0 从cslmem中分配内存 */ #pragma DATA_SECTION(mmc0, "cslmem") MMC_Handle mmc0; MMC_CardObj *card, cardalloc; MMC_CardIdObj *cid, cardid; int retVal,count; Uint16 rca; Uint16 cardtype; /* Because of different operating clock frequencies, the Init structure for c5509 * * and c5509a have different values for memory and function clock divide down values */ #if CHIP_5509A /* Native mode Initialization Structure * 本机模式初始化 */ MMC_SetupNative Init = { 0, /* disable DMA for data read/write */ 0, /* Set level of edge detection for DAT3 pin */ 0, /* Determines if MMC goes IDLE during IDLE instr */ 1, /* Memory clk reflected on CLK Pin */ 7, /* CPU CLK to MMC function clk divide down */ 5, /* MMC function clk to memory clk divide down */ 0, /* No. memory clks to wait before response timeout */ 0, /* No. memory clks to wait before data timeout */ 512, /* Block Length must be same as CSD */ }; #else MMC_SetupNative Init = { 0, /* disable DMA for data read/write */ 0, /* Set level of edge detection for DAT3 pin */ 0, /* Determines if MMC goes IDLE during IDLE instr */ 1, /* Memory clk reflected on CLK Pin */ 3, /* CPU CLK to MMC function clk divide down */ 3, /* MMC function clk to memory clk divide down */ 0, /* No. memory clks to wait before response timeout */ 0, /* No. memory clks to wait before data timeout */ 512, /* Block Length must be same as CSD */ }; #endif /* read with write function allocate in .text */ #pragma CODE_SECTION(read_interrupt,".text") #pragma CODE_SECTION(write_interrupt,".text") /* These are the interrupts to be called for each write and read */ void read_interrupt(); void write_interrupt(); /* * * How MMC interrupts work. * * MMC Registers for interrupts * - MMCIE : MMC Interrupt Enable Register * - MMCST0: MMC Status 0 Register * * Structures * - MMC_CallBackObj : Has the call back table for interrupts for different * MMC operations * * Functions * - MMC_dispatch0 : * - MMC_dispatch1 : Functions plugged in to service the MMC interrupt * generated by the CPU * - MMC_setCallBack : Sets the functions to be called as ISRs for MMC * events (e.g. read, write interrupts) into the * MMC_CallBackObj structure * - MMC_intEnable : Write to the MMCIE to enable the interrupt for a * particular MMC event * * Working * The MMC device (in this case device 1) has an associated MMC_dispatch function * (defined in mmc_disp1.c) which is the ISR. This is plugged in to service * interrupts for the MMC. When an interrupt is triggered, the MMC_dispatch checks * the MMCIE and MMCST0 and decodes which event (read, write, etc.) the MMC interrupt * is triggered for and calls the service function for the event from the entries in * the call back structure. * */ #pragma DATA_SECTION(cback, ".csldata"); /* Call back structure: This holds the functions to be called when an interrupt for a * particular MMC event is triggered */ MMC_CallBackObj cback = { (MMC_CallBackPtr)0x0000, /* Callback for Data Transfer Done */ (MMC_CallBackPtr)0x0000, /* Callback for Busy Done */ (MMC_CallBackPtr)0x0000, /* Callback for response Done */ (MMC_CallBackPtr)0x0000, /* Callback for Read-data time-out */ (MMC_CallBackPtr)0x0000, /* Callback for Response time-out */ (MMC_CallBackPtr)0x0000, /* Callback for write-data CRC error */ (MMC_CallBackPtr)0x0000, /* Callback for read-data CRC error */ (MMC_CallBackPtr)0x0000, /* Callback for response CRC error */ (MMC_CallBackPtr)0x0000, /* This is never used */ write_interrupt, /* Callback for data xmt ready */ read_interrupt, /* Callback for data rcv ready */ (MMC_CallBackPtr)0x0000 /* Callback for DAT3 edge */ } ; volatile int reads_done = 0; volatile int writes_done = 0; Uint16 datasend[512]; Uint16 datareceive[512]; /* Function to be called on data receive ready */ void read_interrupt(void) { ++reads_done; return; } /* Function to be called on data transmit ready */ void write_interrupt(void) { ++writes_done; return; } void main() { Uint16 old_intm; /* CSL libary initialize */ CSL_init(); /* Clear all interrupt register */ IRQ_globalDisable(); /* Set interrupt vector table */ IRQ_setVecs(0x10000); printf ("\nStarting interrupt test...\n"); /* Fill in source and destination buffers */ for (count=0; count<=256; count++) { datasend[count] = count; datareceive[count] = 0xFFFF; } /* Refer to mmc_setup example for explanation * Reserves the MMC device as specified by device */ mmc0 = MMC_open(MMC_DEV1); /* Native mode Initialization Structure */ MMC_setupNative(mmc0,&Init); /* Sends a broadcast GO_IDLE command */ MMC_sendGoIdle(mmc0); for (retVal=0; retVal<4016; retVal++) asm(" NOP"); /* Sets the operating voltage window while in Native mode * 设置操作电压窗口,为本机模式 */ cardtype = MMC_sendOpCond(mmc0,0x00); if (cardtype == 0xFFFF){ printf ("Card not recognized\n"); exit(0); } if (cardtype == MMC_CARD){ cid = &cardid; /* Sends a broadcast command to all cards to identify themselves */ MMC_sendAllCID(mmc0,cid); // get the CID structure for all cards. card = &cardalloc; /* Sets the relative card address of an attatched memory card */ retVal = MMC_setRca(mmc0,card,10); } else { cid = &cardid; /* Sends a broadcast command to all cards to identify themselves */ SD_sendAllCID(mmc0,cid); // get the CID structure for all cards. card = &cardalloc; /* Sets the relative card address of an attatched memory card */ rca = SD_sendRca(mmc0,card); printf ("RCA sent is 0x%x\n", rca); } /* Refer to mmc_setup example for explanation of the above code */ /* Fill in the handle's callback function structure with contents of the cback * * structure. These will be the functions called when the MMC interrupt occurs * 给中断安装调度程序 */ MMC_setCallBack(mmc0, &cback); /* Write to the MMCIE register to enable interrupts for particular events * 0x200 enables an interrupt on data transmit ready * Enables interrupts by writing to the MMCIE register */ MMC_intEnable(mmc0, 0x200); /* IRQ Enable interrupt register */ IRQ_globalEnable(); /* pick the card to transfer data to/from */ retVal = MMC_selectCard(mmc0, card); /* start data write. mmc_read_write example provides a more detailed explanation */ printf ("Writing data to card...\n"); /* Writes a block of data to a pre-selected memory card */ retVal = MMC_write(mmc0, /* MMC Handle returned by call to MMC_open */ 0x00000000,/* Address on card where read begins */ datasend, /* Pointer to buffer where received data should be stored */ 512); /* number of bytes to store in buffer */ for (retVal = 0; retVal <= 256; ++retVal) asm(" NOP"); /* Globally disables interrupts */ old_intm = IRQ_globalDisable(); /* Enable interrupts for data recieve ready now */ MMC_intEnable(mmc0, 0x400); /* Restores the global interrupt mask state */ IRQ_globalRestore(old_intm); /* delay before we start reading the data */ for (retVal = 0; retVal <= 25000; ++retVal) asm(" NOP"); for (retVal = 0; retVal <= 25000; ++retVal) asm(" NOP"); #if CHIP_5509A /* This requires a longer delay */ for (retVal = 0; retVal <= 25000; ++retVal) asm(" NOP"); for (retVal = 0; retVal <= 25000; ++retVal) asm(" NOP"); #endif printf ("Reading data from card...\n"); /* Reads a block of data from a pre-selected memory card */ retVal = MMC_read(mmc0,0x00000000,datareceive,512); /* check if data has been tranmitted and received correctly */ for (count = 0; count < 256; ++count) if (datasend[count] != datareceive[count]) break; if (count < 256) printf ("\nNot all data was transferred/read successfully!\n"); else printf ("\nData transfer successful\n"); if (writes_done != 256) printf ("Not all data writes triggered interrupts\n"); else printf ("Interrupts triggered for each data transmit ready\n"); if (reads_done != 256) printf ("Not all data reads triggered interrupts\n"); else printf ("Interrupts triggered for each data receive ready\n"); if ((reads_done == 256) && (writes_done == 256)) printf ("TEST PASSED"); else printf ("TEST FAILED"); } 
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/232447.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 渗透测试工具——SET「建议收藏」

    渗透测试工具——SET「建议收藏」社会工程学使用计谋、假情报或人际关系去获得利益和其他敏感信息。 攻击对象一-一人一-秘密信息的保存者,信息安全链中最薄弱的环节。 利用受害者的本能反应、好奇心、信任、贪婪等心理弱点进行欺骗、伤害。常见的社会工程学攻击方式环境渗透:对特定的环境进行渗透,是社会工程学为了获得所需的情报或敏感信息经常采用的手段之一。社会工程学攻击者通过观察目标对电子邮件的响应速度、重视程度以及可能提供的相关资料,比如一个人的姓名、生日、ID电话号码、管理员的IP地址、邮箱等,通过这些收集信息来判断目标的网

    2022年8月12日
    7
  • C语言的seekg函数,c++ fstream中seekg()和seekp()的用法[通俗易懂]

    C语言的seekg函数,c++ fstream中seekg()和seekp()的用法[通俗易懂]先说一下C语言中fseek()的功能:函数原型:intfseek(FILE*fp,LONGoffset,intorigin)参数含义:fp文件指针offset相对于origin规定的偏移位置量origin指针移动的起始位置,可设置为以下三种情况:SEEK_SET文件开始位置SEEK_CUR文件当前位置SEEK_END文件结束位置C++中seep()和seekg()…

    2022年6月7日
    83
  • C#使用ManagementObjectSearcher获取本计算机CPU,硬盘,内存条等相关设备信息

    C#使用ManagementObjectSearcher获取本计算机CPU,硬盘,内存条等相关设备信息C#获取本操作系统显卡,CPU,硬盘等信息

    2022年10月2日
    3
  • 首选DNS服务器地址不显示,首选dns服务器如何设置?如何设置DNS地址

    首选DNS服务器地址不显示,首选dns服务器如何设置?如何设置DNS地址首选dns服务器如何设置?如何设置DNS地址分类:云服务资讯编辑:聊聊云计算浏览量:1652021-01-2915:18:29现在有很多朋友对于首选dns服务器的设置方法不是很了解,不知道如何操作,今天新网就给大家详细的介绍下首选dns服务器如何设置以及如何设置DNS地址等问题,希望提供些帮助。首选dns服务器怎么设置?在“开始”中找到“运行”或者直接【Win】+【R】,然后输入“cmd”进入管…

    2022年6月13日
    27
  • 15种手机游戏引擎和开发工具介绍

    15种手机游戏引擎和开发工具介绍工欲善其事,必先利其器。对移动游戏开发者来说,高效实用的开发工具必不可少。近日,英国著名产业杂志《Develop》刊出了一篇文章,作者艾伦·李在文中推荐了15种移动游戏开发工具,从游戏引擎,到音效制作、推广等工具都有涉及。以下为原文主要内容编译。引擎和移动开发工具包Marmalade简介:Marmalade被很多人认为是跨平台制作C++游戏的最佳平台。通过MarmaladeSDK,开发者可以在单一的Marmalade项目文件夹中打开Xcode或VisualStudio,将

    2022年5月22日
    138
  • python后端框架有哪些_后端框架有哪些?五款优秀的web开源后端框架推荐

    python后端框架有哪些_后端框架有哪些?五款优秀的web开源后端框架推荐作为一个web开发人员,下面五款优秀的开源框架一定要了解一下。PHP篇作为全球最好的web开发编程语言,PHP的框架非常多。下面重点介绍2款:Laravelhttps://laravel.comLaravel最大的优势就是:简洁和优雅。能迅速的让大家从杂乱无章的代码中解脱出来。拥抱PHP7基于composer全栈型框架灵活的路由配置仅仅通过配置文件就可以切换缓存、会话的存储介质,包括(file、r…

    2022年6月8日
    39

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号