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

📄 i2c_mcf54xx.h

📁 实现快速傅立叶变换算法,provides test framwork for FFT testing
💻 H
字号:
//==========================================================================
//
//      devs/i2c/clodfire/mcf54xx/current/src/i2c_mcf54xx.h
//
//      I2C driver for coldfire mcf54xx
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 2005, 2006 eCosCentric Ltd.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s):     wanglei
// Contributors:  
// Date:          2007-06-21
// Description:   I2C driver for coldfire processor
//####DESCRIPTIONEND####
//==========================================================================
#ifndef _I2C_MCF54XX_H_
#define _I2C_MCF54XX_H_

#include <pkgconf/devs_i2c_mcf54.h>
#include <cyg/infra/cyg_type.h>
#include <cyg/hal/drv_api.h>

//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
#define HAL_MCF54xx_I2C_ISRVEC     CYGNUM_HAL_INTERRUPT_I2C
#define HAL_MCF54xx_I2C_ISRPRI     ((5<<3)|5)  // level:5, priority:5
#define HAL_MCF54xx_I2C_FDR        0x3F        // 0x37:195k 0x33: 390k

#define CYGNUM_HAL_MCF54xx_SR_INT_MASKALL            0x07 //0b0111
#define CYGNUM_HAL_INTERRUPT_DEFAULT_IPL_LEVEL       (CYGNUM_HAL_MCF54xx_SR_INT_MASKALL - 1)

#define I2C_TRANSFER_TIMEOUT    100 //ticks
//---------------------------------------------------------------------------
// types
//---------------------------------------------------------------------------
typedef enum cyg_mcf54xx_i2c_xfer_mode {
    CYG_MCF54xx_I2C_XFER_MODE_INVALID   = 0x00,
    CYG_MCF54xx_I2C_XFER_MODE_TX        = 0x01,
    CYG_MCF54xx_I2C_XFER_MODE_RX        = 0x02,
    CYG_MCF54xx_I2C_XFER_MODE_STARTRX   = 0x03
} cyg_mcf54xx_i2c_xfer_mode;

typedef struct cyg_mcf54xx_i2c_extra { 
    // Put statically initialized fields first.
    mcf5484_i2c_t               *i2c_base;       // Per-bus h/w details
    cyg_vector_t                i2c_isrvec;
    int                         i2c_isrpri;
    int                         i2c_fdr;

    cyg_uint8                   i2c_owner;      // We have bus ownership
    cyg_uint8                   i2c_lost_arb;   // Error condition leading to loss of bus ownership
    cyg_uint8                   i2c_send_nack;  // As per rx send_nack argument
    cyg_uint8                   i2c_got_nack;   // The last tx resulted in a nack
    cyg_uint8                   i2c_completed;  // Set by DSR, checked by thread
    
    union {
        const cyg_uint8*        i2c_tx_data;
        cyg_uint8*              i2c_rx_data;
    } i2c_data;                                 // The current buffer for rx or tx
    cyg_uint32                  i2c_count;      // Number of bytes left in buffer
    
    cyg_mcf54xx_i2c_xfer_mode   i2c_mode;       // TX, RX, ...

    cyg_drv_mutex_t             i2c_lock;       // For synchronizing between DSR and foreground
    cyg_drv_cond_t              i2c_wait;
    cyg_handle_t                i2c_interrupt_handle;   // For initializing the interrupt
    cyg_interrupt               i2c_interrupt_data;
} cyg_mcf54xx_i2c_extra;

//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
externC void        cyg_mcf54xx_i2c_init(struct cyg_i2c_bus*);
externC cyg_uint32  cyg_mcf54xx_i2c_tx(const cyg_i2c_device*, cyg_bool, const cyg_uint8*, cyg_uint32, cyg_bool);
externC cyg_uint32  cyg_mcf54xx_i2c_rx(const cyg_i2c_device*, cyg_bool, cyg_uint8*, cyg_uint32, cyg_bool, cyg_bool);
externC void        cyg_mcf54xx_i2c_stop(const cyg_i2c_device*);

#define CYG_MCF54xx_I2C_BUS(_name_, _init_fn_, _base_, _isr_vec_, _isr_pri_, _fdr_)    \
    static cyg_mcf54xx_i2c_extra _name_ ## _extra = {                                   \
        (mcf5484_i2c_t *)_base_,                                                                         \
        _isr_vec_,                                                                      \
        _isr_pri_,                                                                      \
        _fdr_                                                                           \
    } ;                                                                                 \
    CYG_I2C_BUS(_name_,                                                                 \
                _init_fn_,                                                              \
                &cyg_mcf54xx_i2c_tx,                                                    \
                &cyg_mcf54xx_i2c_rx,                                                    \
                &cyg_mcf54xx_i2c_stop,                                                  \
                (void*) & ( _name_ ## _extra)) ;

#endif //_I2C_MCF54XX_H_

⌨️ 快捷键说明

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