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

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

?? fec.c

?? Modbus協議的源代碼 Modbus協議的源代碼、 Modbus協議的源代碼 Modbus協議的源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
 * Copyright (c) 2006 Christian Walter
 * All rights reserved.
 *
 * 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. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
 *
 * Author: Christian Walter <wolti@sil.at>
 *
 * TODO:
 *  - Introduce another task create function in the sys_arch layer which allows
 *    for passing the stack size.
 *  - Avoid copying the buffers - this requires changeing the nbuf driver code
 *    to use the lwIP pbuf buffer implementation.
 *
 * File: $Id: fec.c,v 1.1 2006/08/30 23:18:07 wolti Exp $
 */

/* ------------------------ System includes ------------------------------- */
#include <stdlib.h>

/* ------------------------ Platform includes ----------------------------- */
#include "mcf5xxx.h"
#include "mcf523x.h"

#include "nbuf.h"

/* ------------------------ lwIP includes --------------------------------- */
#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/pbuf.h"
#include "lwip/sys.h"
#include "lwip/stats.h"
#include "lwip/debug.h"
#include "netif/etharp.h"

/* ------------------------ Defines --------------------------------------- */
#ifdef FEC_DEBUG
#define FEC_DEBUG_INIT \
    do \
    { \
        MCF_GPIO_PDDR_FECI2C = ( MCF_GPIO_PDDR_FECI2C_PDDR_FECI2C0 | \
                                 MCF_GPIO_PDDR_FECI2C_PDDR_FECI2C1 ); \
    } while( 0 )

#define FEC_DEBUG_RX_TIMING( x ) \
    do \
    { \
        if( x ) \
            MCF_GPIO_PPDSDR_FECI2C = MCF_GPIO_PDDR_FECI2C_PDDR_FECI2C0; \
        else \
            MCF_GPIO_PCLRR_FECI2C = ~( MCF_GPIO_PDDR_FECI2C_PDDR_FECI2C0 ); \
    } while( 0 )

#define FEC_DEBUG_TX_TIMING( x ) \
    do \
    { \
        if( x ) \
            MCF_GPIO_PPDSDR_FECI2C = MCF_GPIO_PDDR_FECI2C_PDDR_FECI2C1; \
        else \
            MCF_GPIO_PCLRR_FECI2C = ~( MCF_GPIO_PDDR_FECI2C_PDDR_FECI2C1 ); \
    } while( 0 )

#else
#define FEC_DEBUG               DBG_OFF
#define FEC_DEBUG_INIT
#define FEC_DEBUG_RX_TIMING( x )
#define FEC_DEBUG_TX_TIMING( x )
#endif

#define MCF_FEC_INT_LEVEL       ( 6 )
#define MCF_FEC_INT_PRIORITY    ( 0 )
#define MCF_FEC_VEC_RXF         ( 64 + 27 )
#define MCF_FEC_MTU             ( 1518 )

#define ETH_ADDR_LEN            ( 6 )

#define TASK_PRIORITY           ( configMAX_PRIORITIES - 1 )

/* ------------------------ Type definitions ------------------------------ */
typedef struct
{
    struct netif   *netif;      /* lwIP network interface. */
    struct eth_addr *self;      /* MAC address of FEC interface. */
    sys_sem_t       tx_sem;     /* Control access to transmitter. */
    sys_sem_t       rx_sem;     /* Semaphore to signal receive thread. */
} mcf523xfec_if_t;

/* ------------------------ Static variables ------------------------------ */
static mcf523xfec_if_t *fecif_g;

/* ------------------------ Static functions ------------------------------ */
static err_t    mcf523xfec_output( struct netif *, struct pbuf *, struct ip_addr * );
static err_t    mcf523xfec_output_raw( struct netif *, struct pbuf * );

static void     mcf523xfec_reset( mcf523xfec_if_t * fecif );
static void     mcf523xfec_enable( mcf523xfec_if_t * fecif );
static void     mcf523xfec_disable( mcf523xfec_if_t * fecif );
static void     mcf523xfec_get_mac( mcf523xfec_if_t * fecif, struct eth_addr *mac );
static void     mcf523xfec_rx_irq( void );
static void     mcf523xfec_rx_task( void *arg );

static void     arp_timer( void *arg );
static void     eth_input( struct netif *netif, struct pbuf *p );

/* ------------------------ Start implementation -------------------------- */

static void
arp_timer( void *arg )
{
    ( void )arg;
    etharp_tmr(  );
    sys_timeout( ARP_TMR_INTERVAL, arp_timer, NULL );
}

err_t
mcf523xfec_output_raw( struct netif *netif, struct pbuf *p )
{
    err_t           res;
    nbuf_t         *pNBuf;
    mcf523xfec_if_t *fecif = netif->state;
    int             i;
    struct pbuf    *q;

#if ETH_PAD_SIZE
    pbuf_header( p, -ETH_PAD_SIZE );    /* drop the padding word */
#endif


    /* Test if we can handle such big frames. If not drop it. */
    if( p->tot_len > MCF_FEC_MTU )
    {
#if LINK_STATS
        lwip_stats.link.lenerr++;
#endif
        res = ERR_BUF;
    }
    /* Test if our network buffer scheme can handle a packet of this size. If
     * not drop it and return a memory error. */
    else if( p->tot_len > TX_BUFFER_SIZE )
    {
#ifdef LINK_STATS
        lwip_stats.link.memerr++;
#endif
        res = ERR_MEM;
    }
    /* Allocate a transmit buffer. If no buffer is available drop the frame. */
    else if( ( pNBuf = nbuf_tx_allocate(  ) ) == NULL )
    {
        LWIP_ASSERT( "mcf523xfec_output_raw: pNBuf != NULL\n", pNBuf != NULL );
#ifdef LINK_STATS
        lwip_stats.link.memerr++;
#endif
        res = ERR_MEM;
    }
    else
    {
        q = p;
        i = 0;
        do
        {
            memcpy( &pNBuf->data[i], q->payload, q->len );
            i += q->len;
        }
        while( ( q = q->next ) != NULL );
        pNBuf->length = p->tot_len;

        /* Set Frame ready for transmission. */
        pNBuf->status |= TX_BD_R;
        /* Mark the buffer as not in use so the FEC can take it. */
        nbuf_tx_release( pNBuf );
        /* Indicate that a new transmit buffer has been produced. */
        MCF_FEC_TDAR = 1;
#if LINK_STATS
        lwip_stats.link.xmit++;
#endif
        res = ERR_OK;
    }

    sys_sem_signal( fecif->tx_sem );
#if ETH_PAD_SIZE
    buf_header( p, ETH_PAD_SIZE );
#endif

    return res;
}

/* This function is called by the TCP/IP stack when an IP packet should be
 * sent. It uses the ethernet ARP module provided by lwIP to resolve the
 * destination MAC address. The ARP module will later call our low level
 * output function mcf523xfec_output_raw.
 */
err_t
mcf523xfec_output( struct netif * netif, struct pbuf * p, struct ip_addr * ipaddr )
{
    err_t           res;
    mcf523xfec_if_t *fecif = netif->state;

    FEC_DEBUG_TX_TIMING( 1 );
    /* Make sure only one thread is in this function. */
    sys_sem_wait( fecif->tx_sem );
    res = etharp_output( netif, ipaddr, p );
    FEC_DEBUG_TX_TIMING( 0 );
    return res;
}

void
mcf523xfec_rx_task( void *arg )
{
    mcf523xfec_if_t *fecif = arg;
    struct pbuf    *p, *q;
    nbuf_t         *pNBuf;
    uint8          *pPayLoad;

    do
    {
        sys_sem_wait( fecif->rx_sem );
        while( nbuf_rx_next_ready(  ) )
        {
            pNBuf = nbuf_rx_allocate(  );
            if( pNBuf != NULL )
            {
                LWIP_ASSERT( "mcf523xfec_rx_task: pNBuf->status & RX_BD_L ",
                             pNBuf->status & RX_BD_L );

                /* This flags indicate that the frame has been damaged. In
                 * this case we must update the link stats if enabled and
                 * remove the frame from the FEC. */
                if( pNBuf->status & ( RX_BD_LG | RX_BD_NO | RX_BD_CR | RX_BD_OV ) )
                {
#ifdef LINK_STATS
                    lwip_stats.link.drop++;
                    if( pNBuf->status & RX_BD_LG )
                    {
                        lwip_stats.link.lenerr++;
                    }
                    else if( pNBuf->status & ( RX_BD_NO | RX_BD_OV ) )
                    {
                        lwip_stats.link.err++;
                    }
                    else
                    {
                        lwip_stats.link.chkerr++;
                    }
#endif
                }
                else
                {
                    /* The frame must no be valid. Perform some checks to see if the FEC
                     * driver is working correctly.
                     */
                    LWIP_ASSERT( "mcf523xfec_rx_task: pNBuf->length != 0", pNBuf->length != 0 );
                    p = pbuf_alloc( PBUF_RAW, pNBuf->length, PBUF_POOL );
                    if( p != NULL )
                    {
#if ETH_PAD_SIZE
                        pbuf_header( p, -ETH_PAD_SIZE );
#endif
                        pPayLoad = pNBuf->data;
                        for( q = p; q != NULL; q = q->next )
                        {
                            memcpy( q->payload, pPayLoad, q->len );
                            pPayLoad += q->len;
                        }
#if ETH_PAD_SIZE
                        pbuf_header( p, ETH_PAD_SIZE );
#endif

                        /* Ethernet frame received. Handling it is not device
                         * dependent and therefore done in another function.
                         */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本成人在线一区| 欧美主播一区二区三区| 久久99精品久久久久久国产越南| 亚洲午夜久久久久久久久电影院 | 久久人人超碰精品| 欧美mv日韩mv国产网站app| 91精品国产色综合久久不卡蜜臀| 欧美日韩在线三级| 国产精品国产三级国产aⅴ原创 | 久久久久久免费毛片精品| 欧美成人精品3d动漫h| 精品乱人伦小说| 久久综合色一综合色88| 国产亚洲欧美色| 国产精品美女www爽爽爽| 日韩理论片中文av| 亚洲综合视频网| 午夜精品久久久久久久99水蜜桃| 视频在线观看国产精品| 麻豆精品国产传媒mv男同| 激情图片小说一区| 波多野结衣在线aⅴ中文字幕不卡| 成人动漫在线一区| 色偷偷88欧美精品久久久| 欧美日韩你懂得| 日韩一区二区免费电影| 久久精品夜夜夜夜久久| 亚洲欧洲精品天堂一级| 亚洲第一综合色| 久久国产三级精品| 99久久精品国产一区| 欧美日韩一级二级| 欧美精品一区二区不卡| 国产精品理论片| 丝袜a∨在线一区二区三区不卡| 久久99精品久久久久| 成人av电影在线| 欧美日韩三级一区二区| 亚洲国产精品综合小说图片区| 亚洲va欧美va国产va天堂影院| 蜜臀av亚洲一区中文字幕| 成人影视亚洲图片在线| 欧美日韩成人高清| 国产亚洲精品精华液| 亚洲综合清纯丝袜自拍| 国内久久婷婷综合| 一本久道久久综合中文字幕| 欧美一区二区黄| 亚洲视频网在线直播| 青青草97国产精品免费观看 | 国产一区高清在线| 欧美亚洲尤物久久| 亚洲精品在线免费观看视频| 亚洲欧美在线另类| 另类小说欧美激情| 91啪九色porn原创视频在线观看| 欧美一区二区三区在线观看视频| 国产精品毛片久久久久久| 奇米精品一区二区三区在线观看 | 欧美日韩一区二区三区视频| 国产视频一区不卡| 三级欧美韩日大片在线看| 成人黄色软件下载| 日韩一区二区不卡| 亚洲精品国产a久久久久久| 国产美女精品在线| 欧美电影一区二区| 亚洲婷婷综合久久一本伊一区| 麻豆国产欧美一区二区三区| 在线免费不卡视频| 欧美国产精品久久| 精品一区二区免费看| 欧美日韩免费不卡视频一区二区三区| 国产日韩欧美制服另类| 日韩—二三区免费观看av| 色视频成人在线观看免| 麻豆成人av在线| 在线观看日韩毛片| 国产精品久久久久一区二区三区 | 蜜桃免费网站一区二区三区| 欧洲视频一区二区| 中文字幕色av一区二区三区| 国产在线观看免费一区| 日韩一级免费观看| 天天综合色天天综合| 在线观看中文字幕不卡| 国产精品免费免费| 国产大陆a不卡| 精品国产髙清在线看国产毛片| 日韩精品成人一区二区在线| 色久综合一二码| 亚洲靠逼com| 日本二三区不卡| 亚洲精品中文字幕乱码三区| 91视视频在线观看入口直接观看www | 99久久99久久免费精品蜜臀| 国产三级精品视频| 国产一区高清在线| 久久综合资源网| 久久99精品久久只有精品| 亚洲一区二区三区四区在线免费观看| av在线播放成人| 亚洲欧洲美洲综合色网| 波多野结衣在线aⅴ中文字幕不卡| 国产情人综合久久777777| 国产乱国产乱300精品| 亚洲精品一区二区三区蜜桃下载| 久久国产精品72免费观看| 欧美成人乱码一区二区三区| 久久99国产精品尤物| 精品国产乱码久久久久久免费| 久久99蜜桃精品| 久久久久国产成人精品亚洲午夜| 国产一区美女在线| 国产日产欧美一区二区视频| 国产成a人无v码亚洲福利| 国产精品乱子久久久久| 色综合网站在线| 亚洲国产精品一区二区www在线| 精品视频一区三区九区| 婷婷激情综合网| 日韩欧美123| 国产福利一区在线观看| 日韩美女久久久| 欧美日韩一区二区三区不卡| 奇米精品一区二区三区四区| 久久色成人在线| 99国产欧美久久久精品| 亚洲成av人影院在线观看网| 91精品国产一区二区| 国产高清久久久| 亚洲精品国产精品乱码不99| 欧美狂野另类xxxxoooo| 久久精品国产99久久6| 国产精品青草久久| 欧美视频完全免费看| 毛片基地黄久久久久久天堂| 久久精品人人爽人人爽| 色综合天天做天天爱| 偷拍亚洲欧洲综合| 久久久精品欧美丰满| 色哟哟精品一区| 久久精品国产精品亚洲红杏| 国产精品久久久久久久久图文区| 欧美视频完全免费看| 国产毛片精品一区| 亚洲综合一二三区| 久久免费视频色| 91国产丝袜在线播放| 精品制服美女丁香| 亚洲欧美电影一区二区| 精品三级在线观看| 国产日韩欧美不卡在线| 在线免费观看视频一区| 激情综合亚洲精品| 亚洲欧美激情插| 精品国产乱码久久久久久1区2区| 色婷婷综合久色| 国产精品综合视频| 五月开心婷婷久久| 国产精品每日更新在线播放网址| 欧美丰满高潮xxxx喷水动漫| 成人午夜激情影院| 日本不卡一二三区黄网| 成人免费在线视频| 精品国一区二区三区| 欧美少妇bbb| 成人免费视频国产在线观看| 琪琪一区二区三区| 亚洲一二三四在线| 亚洲国产精品成人综合色在线婷婷 | 欧美日韩午夜在线视频| 不卡一区中文字幕| 久久er99精品| 亚洲国产精品自拍| 亚洲欧美电影院| 欧美国产精品劲爆| 精品日韩一区二区| 欧美日韩成人在线一区| 91色视频在线| 成人午夜av电影| 国产在线一区二区| 日韩精品一二三区| 亚洲欧美国产三级| 国产精品毛片高清在线完整版| 精品电影一区二区| 日韩一区二区免费在线观看| 欧美三级蜜桃2在线观看| 91色porny蝌蚪| 波多野结衣精品在线| 久久精品国产一区二区三区免费看| 亚洲一本大道在线| 亚洲精品欧美激情| 亚洲男人的天堂在线观看| 国产精品毛片高清在线完整版| 日本麻豆一区二区三区视频| 一区二区三区四区五区视频在线观看| 国产精品―色哟哟| 国产精品久久久久久久第一福利 | 紧缚捆绑精品一区二区|