亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sja1000.c

?? 含有完整TCP/IP PPP協議的嵌入式操作系統
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* * Copyright (C) 2004 by Ole Reinhardt <ole.reinhardt@kernelconcepts.de>, *                       Kernelconcepts http://www.kernelconcepts.de * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of *    contributors may be used to endorse or promote products derived *    from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * For additional information see http://www.ethernut.de/ * *//*! * \file dev/sja1000.c * \brief Driver for SJA1000 CAN-Bus controller *  * * The SJA1000 controller is connected to the memory bus. It's base * address and interrupt is set by NutRegisterDevice. * * Have a look to our m-can board if you have questions. *//* * $Log: sja1000.c,v $ * Revision 1.2  2005/10/24 18:02:34  haraldkipp * Fixes for ATmega103. * * Revision 1.1  2005/07/26 18:02:40  haraldkipp * Moved from dev. * * Revision 1.8  2005/05/27 14:09:56  olereinhardt * Fixed a bug in irq initialisation * * Revision 1.7  2005/01/24 21:12:04  freckle * renamed NutEventPostFromIRQ into NutEventPostFromIrq * * Revision 1.6  2005/01/21 16:49:45  freckle * Seperated calls to NutEventPostAsync between Threads and IRQs * * Revision 1.5  2004/11/12 16:27:42  olereinhardt * Added critical section around NutEventPostAsync * * Revision 1.4  2004/09/17 14:31:37  olereinhardt * Compile only if __GNUC__ defined * * Revision 1.3  2004/06/08 14:50:25  olereinhardt * Removed receive thread and moved input data handling into irq handler. Much faster now on reception. * * Revision 1.1  2004/06/07 15:11:49  olereinhardt * Initial checkin * *//*! * \addtogroup xgCanSJA1000 *//*@{*//* Not ported. */#ifdef __GNUC__#include <string.h>#include <sys/heap.h>#include <sys/thread.h>#include <sys/event.h>#include <sys/atom.h>#include <sys/timer.h>#include <sys/semaphore.h>#include <sys/nutconfig.h>#include <dev/irqreg.h>#include <dev/can_dev.h>#include <dev/sja1000.h>#ifndef SJA_SIGNAL#define SJA_SIGNAL     sig_INTERRUPT7#endif#ifndef SJA_EICR#define SJA_EICR       EICRB#endif#ifndef SJA_SIGNAL_BIT#define SJA_SIGNAL_BIT 7#endifCANINFO dcb_sja1000;volatile u_short sja_base = 0x0000;struct _CANBuffer {    CANFRAME *dataptr;          // the physical memory address where the buffer is stored    u_short size;               // the allocated size of the buffer    u_short datalength;         // the length of the data currently in the buffer    u_short dataindex;          // the index into the buffer where the data starts    SEM empty;    SEM full;};typedef struct _CANBuffer CANBuffer;#ifndef CAN_BufSize#define CAN_BufSize 64#endifCANBuffer CAN_RX_BUF;CANBuffer CAN_TX_BUF;void CANBufferInit(CANBuffer * buffer,u_short size){    NutSemInit(&buffer->full, 0);    NutSemInit(&buffer->empty, CAN_BufSize - 1);    // set start pointer of the buffer    buffer->dataptr = NutHeapAlloc(size * sizeof(CANFRAME));    buffer->size = size;    // initialize index and length    buffer->dataindex = 0;    buffer->datalength = 0;}// access routinesCANFRAME CANBufferGetMutex(CANBuffer * buffer){    CANFRAME data;    NutSemWait(&buffer->full);//    NutSemWait(&buffer->mutex);    // check to see if there's data in the buffer    if (buffer->datalength) {        // get the first frame from buffer        data = buffer->dataptr[buffer->dataindex];        // move index down and decrement length        buffer->dataindex++;        if (buffer->dataindex >= buffer->size) {            buffer->dataindex %= buffer->size;        }        buffer->datalength--;    }//    NutSemPost(&buffer->mutex);    NutSemPost(&buffer->empty);    // return    return data;}void CANBufferPutMutex(CANBuffer * buffer, CANFRAME * data){    NutSemWait(&buffer->empty);//    NutSemWait(&buffer->mutex);    // make sure the buffer has room    if (buffer->datalength < buffer->size) {        // save frame at end of buffer        buffer->dataptr[(buffer->dataindex + buffer->datalength) % buffer->size] = *data;        // increment the length        buffer->datalength++;        // return success    }//    NutSemPost(&buffer->mutex);    NutSemPost(&buffer->full);}CANFRAME CANBufferGet(CANBuffer * buffer){    CANFRAME data;    // check to see if there's data in the buffer    if (buffer->datalength) {        // get the first frame from buffer        data = buffer->dataptr[buffer->dataindex];        // move index down and decrement length        buffer->dataindex++;        if (buffer->dataindex >= buffer->size) {            buffer->dataindex %= buffer->size;        }        buffer->datalength--;    }    // return    return data;}void CANBufferPut(CANBuffer * buffer, CANFRAME * data){    // make sure the buffer has room    if (buffer->datalength < buffer->size) {        // save frame at end of buffer        buffer->dataptr[(buffer->dataindex + buffer->datalength) % buffer->size] = *data;        // increment the length        buffer->datalength++;        // return success    }}u_short CANBufferFree(CANBuffer * buffer){    // check to see if the buffer has room    // return true if there is room    return (buffer->size - buffer->datalength);}/*! * \fn    SJARxAvail(NUTDEVICE * dev) * \brief checks if data is available in input buffer * * \param dev Pointer to the device structure */inline u_char SJARxAvail(NUTDEVICE * dev){    return CAN_RX_BUF.datalength;}/*! * \fn    SJATxAvail(NUTDEVICE * dev) * \brief checks if there's still space in output buffer * * \param dev Pointer to the device structure */inline u_char SJATxFree(NUTDEVICE * dev){    return CANBufferFree(&CAN_TX_BUF);}/*! * \fn    SJAOutput(NUTDEVICE * dev, CANFRAME * frame) * \brief Write a frame from to output buffer * * This function writes a frame to the output buffer. If the output buffer * is full the function will block until frames are send. * * \param dev Pointer to the device structure *  * \param frame Pointer to the receive frame */void SJAOutput(NUTDEVICE * dev, CANFRAME * frame){    CANINFO *ci;    ci = (CANINFO *) dev->dev_dcb;    CANBufferPutMutex(&CAN_TX_BUF, frame);    NutEventPostAsync(&ci->can_tx_rdy);}/*! * \fn    SJAInput(NUTDEVICE * dev, CANFRAME * frame) * \brief Reads a frame from input buffer * * This function reads a frame from the input buffer. If the input buffer * is empty the function will block unitl new frames are received. * * \param dev Pointer to the device structure *  * \param frame Pointer to the receive frame */void SJAInput(NUTDEVICE * dev, CANFRAME * frame){    u_char ready = 0;    CANINFO *ci;        ci = (CANINFO *) dev->dev_dcb;    while (!ready)    {        if (CAN_RX_BUF.datalength==0)             NutEventWait(&ci->can_rx_rdy, NUT_WAIT_INFINITE);        NutEnterCritical();        if (CAN_RX_BUF.datalength)        {            *frame = CANBufferGet(&CAN_RX_BUF);            ready  = 1;        }        NutExitCritical();    }    SJA1000_IEN |= (RIE_Bit);       // enables IRQ since buffer has space}/*! * \fn    SJASetAccCode(NUTDEVICE * dev, u_char * ac) * \brief Sets the acceptance code * * * \param dev Pointer to the device structure *  * \param ac 4 byte char array with the acceptance code */void SJASetAccCode(NUTDEVICE * dev, u_char * ac){    memcpy(((IFCAN *) (dev->dev_icb))->can_acc_code, ac, 4);    while ((SJA1000_MODECTRL & RM_RR_Bit) == 0x00)      // enter reset state        SJA1000_MODECTRL = (RM_RR_Bit | SJA1000_MODECTRL);    SJA1000_AC0 = ac[0];    SJA1000_AC1 = ac[1];    SJA1000_AC2 = ac[2];    SJA1000_AC3 = ac[3];    SJA1000_MODECTRL = (AFM_Bit);    //*** Note - if you change SJA1000_MODECTRL, change it in    // functions CAN_Init and CAN_SetAccMask also.    do {        SJA1000_MODECTRL = 0x00;    }    while ((SJA1000_MODECTRL & RM_RR_Bit) != 0x00);     // leave reset state}/*! * \fn    SJASetAccMask(NUTDEVICE * dev, u_char * am) * \brief Sets the acceptance mask * * * \param dev Pointer to the device structure *  * \param am 4 byte char array with the acceptance mask */void SJASetAccMask(NUTDEVICE * dev, u_char * am){    memcpy(((IFCAN *) (dev->dev_icb))->can_acc_mask, am, 4);    while ((SJA1000_MODECTRL & RM_RR_Bit) == 0x00)      // enter reset state        SJA1000_MODECTRL = (RM_RR_Bit | SJA1000_MODECTRL);    SJA1000_AM0 = am[0];    SJA1000_AM1 = am[1];        // mask off lower nibble (SJA manual p44)    SJA1000_AM2 = am[2];    SJA1000_AM3 = am[3];    SJA1000_MODECTRL = (AFM_Bit);    //*** Note - if you change SJA1000_MODECTRL, change it in    // functions CAN_Init and CAN_SetAccCode also.    do {        SJA1000_MODECTRL = 0x00;    }    while ((SJA1000_MODECTRL & RM_RR_Bit) != 0x00);     // leave reset state}/*! * \fn    SJASetBaudrate(NUTDEVICE * dev, u_long baudrate) * \brief Sets the baudrate  * * * \param dev Pointer to the device structure *  * \param baudrate Baudrate (One of the defined baudrates. See sja1000.h) */u_char SJASetBaudrate(NUTDEVICE * dev, u_long baudrate){    u_char result = 0;    ((IFCAN *) (dev->dev_icb))->can_baudrate = baudrate;    while ((SJA1000_MODECTRL & RM_RR_Bit) == 0x00)      // enter reset state        SJA1000_MODECTRL = (RM_RR_Bit | SJA1000_MODECTRL);    switch (baudrate)           // setting actual bustiming    {                           // all @ 16 Mhz    case CAN_SPEED_10K:        SJA1000_BT0 = 113;        SJA1000_BT1 = 28;        break;    case CAN_SPEED_20K:        SJA1000_BT0 = 88;        SJA1000_BT1 = 28;        break;    case CAN_SPEED_50K:

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人一级视频在线观看| 美日韩一级片在线观看| 精品国产一区二区在线观看| 欧美丝袜丝交足nylons图片| 成人av第一页| 成人h动漫精品| 91亚洲永久精品| 在线一区二区三区做爰视频网站| 成人深夜视频在线观看| 波多野结衣中文一区| 91香蕉视频在线| 欧美日韩精品电影| 91精品国产综合久久精品性色| 日韩午夜精品电影| 国产亚洲精品精华液| 国产精品国产成人国产三级| 一区二区三区在线不卡| 午夜视频久久久久久| 喷水一区二区三区| 国产v综合v亚洲欧| 色婷婷激情综合| 欧美一级免费观看| 国产天堂亚洲国产碰碰| 亚洲免费观看高清完整版在线观看 | 日韩成人伦理电影在线观看| 欧美96一区二区免费视频| 国产在线精品免费av| 成人免费观看男女羞羞视频| 欧美在线色视频| 日韩欧美国产一二三区| 国产精品亲子伦对白| 亚洲国产欧美在线人成| 激情文学综合网| 色噜噜狠狠成人网p站| 日韩精品一区二区三区在线| 国产精品久久久久影视| 奇米色777欧美一区二区| 成人激情文学综合网| 欧美精品777| 综合欧美一区二区三区| 毛片一区二区三区| 91国产福利在线| 国产日韩欧美制服另类| 午夜国产精品一区| aaa亚洲精品一二三区| 日韩欧美国产综合在线一区二区三区| 国产精品久久久久久久第一福利 | 538在线一区二区精品国产| 久久久美女毛片| 日本午夜一区二区| 日本道色综合久久| 国产精品天美传媒| 麻豆精品一区二区综合av| 在线观看91精品国产入口| 国产人妖乱国产精品人妖| 青草av.久久免费一区| 色综合久久久久久久久| 久久精品欧美日韩精品| 青青草成人在线观看| 91豆麻精品91久久久久久| 一区二区三区免费观看| 国产精品自拍av| 日韩精品一区二区三区在线 | 久久精品国产**网站演员| 欧美亚洲高清一区二区三区不卡| 国产日韩欧美一区二区三区乱码 | 欧美不卡一二三| 日日夜夜免费精品| 欧美日韩亚洲国产综合| 亚洲一区二区视频| 91精彩视频在线观看| 亚洲人成人一区二区在线观看| 成人一区二区三区视频| 久久久久久一级片| 国产精品资源站在线| 久久久久久久久久久99999| 国内欧美视频一区二区| 久久只精品国产| 国产精品 欧美精品| 久久九九影视网| 国产69精品久久99不卡| 最新日韩在线视频| 色综合久久天天| 亚洲国产成人tv| 欧美一级理论片| 国产成人在线视频免费播放| 亚洲国产精品av| 91欧美激情一区二区三区成人| 一区二区三区影院| 欧美亚洲日本一区| 免费成人美女在线观看| 久久久久成人黄色影片| 本田岬高潮一区二区三区| 亚洲精品视频免费看| 欧日韩精品视频| 麻豆精品视频在线观看视频| 欧美精品一区二区三区很污很色的| 国产一区二三区| 亚洲情趣在线观看| 91精品国产高清一区二区三区| 狠狠色丁香婷综合久久| 国产精品卡一卡二| 欧美日本一道本| 国产精品一区二区免费不卡| 亚洲激情图片qvod| 91精品国产色综合久久不卡电影 | 久久夜色精品国产欧美乱极品| 夫妻av一区二区| 亚洲午夜久久久| 久久久久久久综合色一本| 91网址在线看| 国模无码大尺度一区二区三区| 亚洲视频一二三区| 久久一二三国产| 欧美日韩中文另类| www.欧美精品一二区| 美女一区二区视频| 亚洲精品视频免费看| 国产亚洲视频系列| 欧美一区二区三区小说| 不卡的av在线| 国内外成人在线| 日韩专区欧美专区| 亚洲免费av高清| 久久网站最新地址| 欧美高清dvd| 91久久精品一区二区三区| 国产在线精品一区二区夜色| 午夜精品123| 亚洲另类在线视频| 国产精品麻豆欧美日韩ww| 欧美一级夜夜爽| 欧美日韩美女一区二区| 一本色道久久综合亚洲aⅴ蜜桃| 国产伦精品一区二区三区视频青涩 | 精品福利一二区| 欧美伦理电影网| 日本韩国精品在线| 波多野结衣欧美| 国产成人激情av| 国产一区二区三区高清播放| 亚洲一区二区中文在线| 亚洲男同1069视频| 综合久久国产九一剧情麻豆| 亚洲国产经典视频| 国产欧美一区二区三区鸳鸯浴| 欧美mv日韩mv亚洲| 日韩免费观看高清完整版在线观看| 欧美人妖巨大在线| 欧美日韩亚洲不卡| 欧美日韩日日摸| 欧美日韩亚洲综合| 欧美精品自拍偷拍| 91精品免费在线观看| 欧美二区乱c少妇| 欧美一级在线视频| 亚洲精品一区二区三区香蕉| 欧美mv日韩mv国产网站| wwwwww.欧美系列| 欧美国产一区二区在线观看| 国产日韩高清在线| 国产精品久久久久久久久免费相片 | 亚洲123区在线观看| 三级久久三级久久| 日本中文字幕一区二区视频 | 欧美国产精品久久| 中文字幕一区二区三区不卡在线| 国产精品久久久久久久久动漫 | 国产精品福利电影一区二区三区四区| 久久久三级国产网站| 国产欧美一区二区精品忘忧草 | 视频一区视频二区在线观看| 视频一区二区国产| 蜜臀久久99精品久久久久宅男| 国内精品伊人久久久久av影院| 国产jizzjizz一区二区| 一本在线高清不卡dvd| 欧美日韩成人综合| 久久久久久久久伊人| 中文字幕亚洲一区二区av在线| 亚洲香肠在线观看| 激情文学综合网| 91浏览器打开| 精品国产一区二区三区av性色| 久久久久久一二三区| 一区二区三区四区在线播放| 丝袜诱惑亚洲看片| 床上的激情91.| 91精品国产91久久久久久一区二区| 久久青草欧美一区二区三区| 亚洲美女屁股眼交3| 狠狠网亚洲精品| 欧美综合天天夜夜久久| 精品国产成人系列| 亚洲高清三级视频| 成人国产精品免费| 日韩精品一区二区在线观看| 亚洲激情自拍偷拍| 国产精品一级二级三级| 欧美日韩在线亚洲一区蜜芽|