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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Python分布式爬虫原理[通俗易懂]

    转载请注明出处:http://blog.csdn.net/yiliumu/article/details/21335245首先,我们先来看看,如果是人正常的行为,是如何获取网页内容的。(1)打开浏览器,输入URL,打开源网页(2)选取我们想要的内容,包括标题,作者,摘要,正文等信息(3)存储到硬盘中上面的三个过程,映射到技术层面上,其实就是:网络请求,抓取结构化数据,数据存

    2022年4月8日
    54
  • sftp上传本地文件_sftp连接超时原因

    sftp上传本地文件_sftp连接超时原因关键:(1)sftp的测试指令:sftp-oPort=2125meituan@220.248.104.170(2)让上海那边自己试了一下,也不行,他们自己重置了一下sftp的密码,我们可以登录了;上海那边反应,在10月10号早上,大量重复数据发送到上海政府端,查询后发现在:dx-qcs-regulation-shanghai06这个主机有问题:里面有大量的…

    2025年11月14日
    5
  • 一致性hash算法 java实现_信息的一致性

    一致性hash算法 java实现_信息的一致性介绍一致性Hash算法是实现负载均衡的一种策略,后续会写如何实现负载均衡一致哈希是一种特殊的哈希算法。在使用一致哈希算法后,哈希表槽位数(大小)的改变平均只需要对K/n个关键字重新映射,其中K是关键字的数量,n是槽位数量。然而在传统的哈希表中,添加或删除一个槽位的几乎需要对所有关键字进行重新映射。强哈希考虑到单服务器不能承载,因此使用了分布式架构,最初的算法为hash()modn,hash()通常取用户ID,n为节点数。此方法容易实现且能够满足运营要求。缺点是当单点发

    2022年9月27日
    5
  • SAPI5_SAP-ERP

    SAPI5_SAP-ERP转载自:http://blog.csdn.net/stone0823/article/details/70339694SAPWebIDE是基于Eclipse内核的在线开发IDE,可以使用在线的试用版本,但服务器在德国,访问的网速特别慢。也可以使用PersonalEdition,在本机启动和编写代码。与Eclipse相比,SAPWebIDE有几个

    2022年10月17日
    2
  • 学习多线程随笔。同时引出模板方法设计模式和回顾学习过的策略模式解决多重if–else

    学习多线程随笔。同时引出模板方法设计模式和回顾学习过的策略模式解决多重if–else

    2021年7月12日
    70
  • 记一次使用策略模式优化代码的经历[通俗易懂]

    记一次使用策略模式优化代码的经历[通俗易懂]一、背景之前接手了一个springboot项目。在我负责的模块中,有一块用户注册的功能,但是比较特别的是这个注册并不是重新注册,而是从以前的旧系统的数据库中同步旧数据到新系统的数据库中。由于这些

    2022年8月16日
    6

发表回复

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

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