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

Subversion Repositories sockit_owm

[/] [sockit_owm/] [trunk/] [HAL/] [inc/] [sockit_owm.h] - Diff between revs 2 and 3

Show entire file | Details | Blame | View Log

Rev 2 Rev 3
Line 1... Line 1...
/******************************************************************************
/******************************************************************************
*                                                                             *
*                                                                             *
 
* Minimalistic 1-wire (onewire) master with Avalon MM bus interface           *
 
* Copyright (C) 2010  Iztok Jeras                                             *
 
* Since the code is based on an Altera app note, I kept their license.        *
 
*                                                                             *
* License Agreement                                                           *
* License Agreement                                                           *
*                                                                             *
*                                                                             *
* Copyright (c) 2008 Altera Corporation, San Jose, California, USA.           *
* Copyright (c) 2008 Altera Corporation, San Jose, California, USA.           *
* All rights reserved.                                                        *
* All rights reserved.                                                        *
*                                                                             *
*                                                                             *
Line 27... Line 31...
* of California and by the laws of the United States of America.              *
* of California and by the laws of the United States of America.              *
*                                                                             *
*                                                                             *
******************************************************************************/
******************************************************************************/
 
 
 
 
//////////////////////////////////////////////////////////////////////////////
 
//                                                                          //
 
//  Minimalistic 1-wire (onewire) master with Avalon MM bus interface       //
 
//                                                                          //
 
//  Copyright (C) 2010  Iztok Jeras                                         //
 
//                                                                          //
 
//////////////////////////////////////////////////////////////////////////////
 
//                                                                          //
 
//  This program is free software: you can redistribute it and/or modify    //
 
//  it under the terms of the GNU Lesser General Public License             //
 
//  as published by the Free Software Foundation, either                    //
 
//  version 3 of the License, or (at your option) any later version.        //
 
//                                                                          //
 
//  This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.   //
 
//                                                                          //
 
//////////////////////////////////////////////////////////////////////////////
 
 
 
 
 
#ifndef __SOCKIT_OWM_H__
#ifndef __SOCKIT_OWM_H__
#define __SOCKIT_OWM_H__
#define __SOCKIT_OWM_H__
 
 
#include <stddef.h>
#include <stddef.h>
 
 
Line 65... Line 45...
#include "alt_types.h"
#include "alt_types.h"
 
 
#ifdef __cplusplus
#ifdef __cplusplus
extern "C"
extern "C"
{
{
#endif /* __cplusplus */
#endif // __cplusplus
 
 
/*
//////////////////////////////////////////////////////////////////////////////
 * The sockit_owm_state structure is used to hold device specific data.
// global structure containing the current state of the sockit_owm driver
 * This includes the transmit and receive buffers.
//////////////////////////////////////////////////////////////////////////////
 *
 
 * An instance of this structure is created in the auto-generated
 
 * alt_sys_init.c file for each UART listed in the systems SOPC file. This is
 
 * done using the SOCKIT_OWM_STATE_INSTANCE macro given below.
 
 */
 
 
 
typedef struct sockit_owm_state_s
typedef struct sockit_owm_state_s
{
{
  // constants
 
  void*            base;            // The base address of the device
  void*            base;            // The base address of the device
  alt_u32          own;             // Number of onewire ports
  // constants
  alt_u32          ovd_e;           // Overdrive mode implementation enable
  alt_u32          ovd_e;           // Overdrive mode implementation enable
 
  alt_u32          cdr_e;           // Clock divider ratio register implementation enable
 
  alt_u32          own;             // Number of onewire ports
 
  char             btp_n[3];        // base time period for normal    mode
 
  char             btp_o[3];        // base time period for overdrive mode
 
  // clock divider ratio
 
  alt_u32          cdr_n;           // cdr for normal    mode
 
  alt_u32          cdr_o;           // cdr for overdrive mode
 
  alt_u32          f_dly;           // u16.16 1/ms (inverse of delay time)
  // status
  // status
  alt_u32          ena;             // interrupt enable status
  alt_u32          ien;             // interrupt enable status
  alt_u32          use;             // Aquire status
  alt_u32          use;             // Aquire status
  alt_u32          ovd;             // Overdrive status
  alt_u32          ovd;             // Overdrive status
  alt_u32          pwr;             // Power status
  alt_u32          pwr;             // Power status
  // OS multitasking features
  // OS multitasking features
//ALT_FLAG_GRP    (srx)             // receive event flag
  ALT_FLAG_GRP    (irq)             // interrupt event flag
  ALT_FLAG_GRP    (irq)             // transmit event flag
  ALT_SEM         (cyc)             // transfer lock semaphore
  ALT_SEM         (trn)             // transfer lock semaphore
 
} sockit_owm_state;
} sockit_owm_state;
 
 
/*
//////////////////////////////////////////////////////////////////////////////
 * The macro ALTERA_AVALON_UART_INSTANCE is used by the auto-generated file
// instantiation macro
 * alt_sys_init.c to create an instance of this device driver state.
// can be used oly once, since the driver is based on global variables
 * ALTERA_AVALON_UART_INSTANCE is mapped below to SOCKIT_OWM_STATE_INSTANCE.
//////////////////////////////////////////////////////////////////////////////
 */
 
 
 
#define SOCKIT_OWM_INSTANCE(name, state) \
#define SOCKIT_OWM_INSTANCE(name, state) \
  sockit_owm_state sockit_owm = { (void*) name##_BASE, name##_OWN, name##_OVD_E, 0, 0, 0, 0}; \
  sockit_owm_state sockit_owm = { (void*) name##_BASE,  \
 
                                          name##_OVD_E, \
 
                                          name##_CDR_E, \
 
                                          name##_OWN,   \
 
                                          name##_BTP_N, \
 
                                          name##_BTP_O, \
 
                                          name##_CDR_N, \
 
                                          name##_CDR_O, \
 
                                          name##_F_DLY, \
 
                                          0, 0, 0, 0};  \
  void* state = (void*) name##_BASE
  void* state = (void*) name##_BASE
/*
 
 * sockit_owm_init() is called by the auto-generated function
//////////////////////////////////////////////////////////////////////////////
 * alt_sys_init() for each UART in the system. This is done using the
// initialization function, registers the interrupt handler
 * SOCKIT_OWM_INIT macro given below.
//////////////////////////////////////////////////////////////////////////////
 *
 
 * This function is responsible for performing all the run time initialization
 
 * for a device instance, i.e. registering the interrupt handler, and
 
 * regestering the device with the system.
 
 */
 
 
 
extern void sockit_owm_init(alt_u32 irq);
extern void sockit_owm_init(alt_u32 irq);
 
 
/*
//////////////////////////////////////////////////////////////////////////////
 * The macro SOCKIT_OWM_STATE_INIT is used by the auto-generated file
// initialization macro
 * alt_sys_init.c to initialize an instance of the device driver state.
//////////////////////////////////////////////////////////////////////////////
 *
 
 * This macro performs a sanity check to ensure that the interrupt has been
 
 * connected for this device. If not, then an appropriate error message is
 
 * generated at build time.
 
 */
 
#ifndef SOCKIT_OWM_POLLING
#ifndef SOCKIT_OWM_POLLING
#define SOCKIT_OWM_INIT(name, state)                                       \
#define SOCKIT_OWM_INIT(name, state)                                       \
  if (name##_IRQ == ALT_IRQ_NOT_CONNECTED)                                 \
  if (name##_IRQ == ALT_IRQ_NOT_CONNECTED)                                 \
  {                                                                        \
  {                                                                        \
    ALT_LINK_ERROR ("Error: Interrupt not connected for " #name ". "       \
    ALT_LINK_ERROR ("Error: Interrupt not connected for " #name ". "       \
                    "You have selected the interrupt driven version of "   \
                    "You have selected the interrupt driven version of "   \
                    "the SocKit Avalon 1-wire master (mini) driver, but "  \
                    "the sockit_owm (SoCkit 1-wire master) driver, but "   \
                    "the interrupt is not connected for this device. You " \
                    "the interrupt is not connected for this device. You " \
                    "can select a polled mode driver by checking the "     \
                    "can select a polled mode driver by checking the "     \
                    "'small driver' option in the HAL configuration "      \
                    "'small driver' option in the HAL configuration "      \
                    " window, or by using the -DSOCKIT_OWM_SMALL "         \
                    "window, or by using the -DSOCKIT_OWM_POLLING "        \
                    "preprocessor flag.");                                 \
                    "preprocessor flag.");                                 \
  }                                                                        \
  }                                                                        \
  else                                                                     \
  else                                                                     \
  {                                                                        \
  {                                                                        \
    sockit_owm_init(name##_IRQ);                                           \
    sockit_owm_init(name##_IRQ);                                           \
Line 145... Line 125...
#define SOCKIT_OWM_INIT(name, state)
#define SOCKIT_OWM_INIT(name, state)
#endif
#endif
 
 
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif /* __cplusplus */
#endif // __cplusplus
 
 
#endif /* __SOCKIT_OWM_H__ */
#endif // __SOCKIT_OWM_H__
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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