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

Subversion Repositories sockit_owm

[/] [sockit_owm/] [trunk/] [HAL/] [inc/] [sockit_owm.h] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 iztok
/******************************************************************************
2
*                                                                             *
3
* License Agreement                                                           *
4
*                                                                             *
5
* Copyright (c) 2008 Altera Corporation, San Jose, California, USA.           *
6
* All rights reserved.                                                        *
7
*                                                                             *
8
* Permission is hereby granted, free of charge, to any person obtaining a     *
9
* copy of this software and associated documentation files (the "Software"),  *
10
* to deal in the Software without restriction, including without limitation   *
11
* the rights to use, copy, modify, merge, publish, distribute, sublicense,    *
12
* and/or sell copies of the Software, and to permit persons to whom the       *
13
* Software is furnished to do so, subject to the following conditions:        *
14
*                                                                             *
15
* The above copyright notice and this permission notice shall be included in  *
16
* all copies or substantial portions of the Software.                         *
17
*                                                                             *
18
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  *
19
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,    *
20
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      *
22
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING     *
23
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER         *
24
* DEALINGS IN THE SOFTWARE.                                                   *
25
*                                                                             *
26
* This agreement shall be governed in all respects by the laws of the State   *
27
* of California and by the laws of the United States of America.              *
28
*                                                                             *
29
******************************************************************************/
30
 
31
 
32
//////////////////////////////////////////////////////////////////////////////
33
//                                                                          //
34
//  Minimalistic 1-wire (onewire) master with Avalon MM bus interface       //
35
//                                                                          //
36
//  Copyright (C) 2010  Iztok Jeras                                         //
37
//                                                                          //
38
//////////////////////////////////////////////////////////////////////////////
39
//                                                                          //
40
//  This program is free software: you can redistribute it and/or modify    //
41
//  it under the terms of the GNU Lesser General Public License             //
42
//  as published by the Free Software Foundation, either                    //
43
//  version 3 of the License, or (at your option) any later version.        //
44
//                                                                          //
45
//  This program is distributed in the hope that it will be useful,         //
46
//  but WITHOUT ANY WARRANTY; without even the implied warranty of          //
47
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
48
//  GNU General Public License for more details.                            //
49
//                                                                          //
50
//  You should have received a copy of the GNU General Public License       //
51
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.   //
52
//                                                                          //
53
//////////////////////////////////////////////////////////////////////////////
54
 
55
 
56
#ifndef __SOCKIT_OWM_H__
57
#define __SOCKIT_OWM_H__
58
 
59
#include <stddef.h>
60
 
61
#include "sys/alt_warning.h"
62
 
63
#include "os/alt_sem.h"
64
#include "os/alt_flag.h"
65
#include "alt_types.h"
66
 
67
#ifdef __cplusplus
68
extern "C"
69
{
70
#endif /* __cplusplus */
71
 
72
/*
73
 * The sockit_owm_state structure is used to hold device specific data.
74
 * This includes the transmit and receive buffers.
75
 *
76
 * An instance of this structure is created in the auto-generated
77
 * alt_sys_init.c file for each UART listed in the systems SOPC file. This is
78
 * done using the SOCKIT_OWM_STATE_INSTANCE macro given below.
79
 */
80
 
81
typedef struct sockit_owm_state_s
82
{
83
  // constants
84
  void*            base;            // The base address of the device
85
  alt_u32          own;             // Number of onewire ports
86
  alt_u32          ovd_e;           // Overdrive mode implementation enable
87
  // status
88
  alt_u32          ena;             // interrupt enable status
89
  alt_u32          use;             // Aquire status
90
  alt_u32          ovd;             // Overdrive status
91
  alt_u32          pwr;             // Power status
92
  // OS multitasking features
93
//ALT_FLAG_GRP    (srx)             // receive event flag
94
  ALT_FLAG_GRP    (irq)             // transmit event flag
95
  ALT_SEM         (trn)             // transfer lock semaphore
96
} sockit_owm_state;
97
 
98
/*
99
 * The macro ALTERA_AVALON_UART_INSTANCE is used by the auto-generated file
100
 * alt_sys_init.c to create an instance of this device driver state.
101
 * ALTERA_AVALON_UART_INSTANCE is mapped below to SOCKIT_OWM_STATE_INSTANCE.
102
 */
103
 
104
#define SOCKIT_OWM_INSTANCE(name, state) \
105
  sockit_owm_state sockit_owm = { (void*) name##_BASE, name##_OWN, name##_OVD_E, 0, 0, 0, 0}; \
106
  void* state = (void*) name##_BASE
107
/*
108
 * sockit_owm_init() is called by the auto-generated function
109
 * alt_sys_init() for each UART in the system. This is done using the
110
 * SOCKIT_OWM_INIT macro given below.
111
 *
112
 * This function is responsible for performing all the run time initialization
113
 * for a device instance, i.e. registering the interrupt handler, and
114
 * regestering the device with the system.
115
 */
116
 
117
extern void sockit_owm_init(alt_u32 irq);
118
 
119
/*
120
 * The macro SOCKIT_OWM_STATE_INIT is used by the auto-generated file
121
 * alt_sys_init.c to initialize an instance of the device driver state.
122
 *
123
 * This macro performs a sanity check to ensure that the interrupt has been
124
 * connected for this device. If not, then an appropriate error message is
125
 * generated at build time.
126
 */
127
#ifndef SOCKIT_OWM_POLLING
128
#define SOCKIT_OWM_INIT(name, state)                                       \
129
  if (name##_IRQ == ALT_IRQ_NOT_CONNECTED)                                 \
130
  {                                                                        \
131
    ALT_LINK_ERROR ("Error: Interrupt not connected for " #name ". "       \
132
                    "You have selected the interrupt driven version of "   \
133
                    "the SocKit Avalon 1-wire master (mini) driver, but "  \
134
                    "the interrupt is not connected for this device. You " \
135
                    "can select a polled mode driver by checking the "     \
136
                    "'small driver' option in the HAL configuration "      \
137
                    " window, or by using the -DSOCKIT_OWM_SMALL "         \
138
                    "preprocessor flag.");                                 \
139
  }                                                                        \
140
  else                                                                     \
141
  {                                                                        \
142
    sockit_owm_init(name##_IRQ);                                           \
143
  }
144
#else
145
#define SOCKIT_OWM_INIT(name, state)
146
#endif
147
 
148
#ifdef __cplusplus
149
}
150
#endif /* __cplusplus */
151
 
152
#endif /* __SOCKIT_OWM_H__ */

powered by: WebSVN 2.1.0

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