OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [devs/] [i2c/] [cortexm/] [a2fxxx/] [current/] [include/] [i2c_a2fxxx.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      i2c_a2fxxx.h
4
//
5
//      I2C driver for Smartfusion Cortex M3 microcontroller
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):     ccoutand
43
// Contributors:
44
// Date:          2011-01-18
45
// Original:      Bart Veer
46
//                I2C driver for motorola coldfire processor
47
// Description:   I2C driver for Smartfusion Cortex M3 microcontroller
48
//####DESCRIPTIONEND####
49
//==========================================================================
50
 
51
#ifndef CYGONCE_I2C_A2FXXX_H
52
# define CYGONCE_I2C_A2FXXX_H
53
 
54
# include <pkgconf/devs_i2c_cortexm_a2fxxx.h>
55
# include <cyg/infra/cyg_type.h>
56
# include <cyg/hal/drv_api.h>
57
 
58
typedef enum a2fxxx_i2c_xfer_mode {
59
    A2FXXX_I2C_XFER_MODE_INVALID = 0x00,
60
    A2FXXX_I2C_XFER_MODE_TX = 0x01,
61
    A2FXXX_I2C_XFER_MODE_RX = 0x02
62
} a2fxxx_i2c_xfer_mode;
63
 
64
typedef struct a2fxxx_i2c_extra {
65
    cyg_uint32      i2c_base;          // I2C base address
66
    cyg_uint32      i2c_base_bb;       // I2C base address (Bit-band)
67
    cyg_uint32      i2c_periph;        // I2C peripheral bit mask
68
    cyg_uint8       i2c_owner;         // We have bus ownership
69
    cyg_uint8       i2c_lost_arb;      // Error condition leading to loss of
70
    // bus ownership
71
    cyg_uint8       i2c_send_nack;     // As per rx send_nack argument
72
    cyg_uint8       i2c_got_nack;      // The last tx resulted in a nack
73
    cyg_uint8       i2c_completed;     // Set by DSR, checked by thread
74
 
75
    union {
76
        const cyg_uint8 *i2c_tx_data;
77
        cyg_uint8      *i2c_rx_data;
78
    } i2c_data;                        // The current buffer for rx or tx
79
    cyg_uint32      i2c_count;         // Number of bytes left in buffer
80
    a2fxxx_i2c_xfer_mode i2c_mode;     // TX, RX, ...
81
 
82
    cyg_bool        send_stop;
83
    cyg_bool        send_start;
84
    cyg_uint8       slave_addr;
85
    cyg_drv_mutex_t i2c_lock;          // For synchronizing between DSR and
86
    // foreground
87
    cyg_drv_cond_t  i2c_wait;
88
    // For initializing the interrupt
89
    cyg_handle_t    i2c_interrupt_handle;
90
    cyg_interrupt   i2c_interrupt_data;
91
    cyg_uint32      i2c_isr_id;
92
    cyg_uint32      i2c_isr_pri;
93
    cyg_uint32      i2c_isr_mask;
94
} a2fxxx_i2c_extra;
95
 
96
externC void    a2fxxx_i2c_init(struct cyg_i2c_bus *);
97
externC cyg_uint32 a2fxxx_i2c_tx(const cyg_i2c_device *, cyg_bool,
98
                                 const cyg_uint8 *, cyg_uint32, cyg_bool);
99
externC cyg_uint32 a2fxxx_i2c_rx(const cyg_i2c_device *, cyg_bool,
100
                                 cyg_uint8 *, cyg_uint32, cyg_bool, cyg_bool);
101
externC void    a2fxxx_i2c_stop(const cyg_i2c_device *);
102
 
103
# define CYG_A2FXXX_I2C_BUS(                            \
104
        _name_,                                         \
105
        _init_fn_,                                      \
106
        _base_,                                         \
107
        _base_bb_,                                      \
108
        _periph_,                                       \
109
        _isr_vec_,                                      \
110
        _isr_pri_)                                      \
111
    static a2fxxx_i2c_extra _name_ ## _extra = {        \
112
       .i2c_base    = _base_,                           \
113
       .i2c_base_bb = _base_bb_,                        \
114
       .i2c_periph  = _periph_,                         \
115
       .i2c_isr_id  = _isr_vec_,                        \
116
       .i2c_isr_pri = _isr_pri_                         \
117
    };                                                  \
118
    CYG_I2C_BUS(_name_,                                 \
119
                _init_fn_,                              \
120
                a2fxxx_i2c_tx,                          \
121
                a2fxxx_i2c_rx,                          \
122
                a2fxxx_i2c_stop,                        \
123
                (void*) & ( _name_ ## _extra)) ;
124
 
125
#endif // CYGONCE_I2C_A2FXXX_H
126
 
127
// -------------------------------------------------------------------------
128
// EOF i2c_a2fxxx.h

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.