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

Subversion Repositories sockit_owm

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /sockit_owm/trunk/HAL
    from Rev 2 to Rev 3
    Reverse comparison

Rev 2 → Rev 3

/src/owerr.c
30,17 → 30,12
//
 
#include <string.h>
#ifndef _WIN32_WCE
#include <stdio.h>
#endif
#ifdef _WIN64
#include <stdio.h>
#endif
#include "ownet.h"
 
#ifndef SIZE_OWERROR_STACK
#ifdef SMALL_MEMORY_TARGET
//for small memory, only hole 1 error
#ifdef SOCKIT_OWM_ERR_SMALL
//for small memory, only hold 1 error
#define SIZE_OWERROR_STACK 1
#else
#define SIZE_OWERROR_STACK 10
81,7 → 76,7
#else
void owRaiseError(int);
#endif
#ifndef SMALL_MEMORY_TARGET
#ifndef SOCKIT_OWM_ERR_SMALL
void owPrintErrorMsg(FILE *);
void owPrintErrorMsgStd();
char *owGetErrorMsg(int);
163,9 → 158,9
#endif
 
 
// SMALL_MEMORY_TARGET - embedded microcontrollers, where these
// SOCKIT_OWM_ERR_SMALL - embedded microcontrollers, where these
// messaging functions might not make any sense.
#ifndef SMALL_MEMORY_TARGET
#ifndef SOCKIT_OWM_ERR_SMALL
//Array of meaningful error messages to associate with codes.
//Not used on targets with low memory (i.e. PIC).
static char *owErrorMsg[125] =
302,7 → 297,6
return owErrorMsg[err];
}
 
#ifndef __C51__
//--------------------------------------------------------------------------
// The 'owPrintErrorMsg' is the method for printing an error from the stack.
// The destination for the print is specified by the argument, fileno, which
329,7 → 323,6
fprintf(filenum,"Error %d: %s\r\n",err,owErrorMsg[err]);
#endif
}
#endif //__C51__
 
// Same as above, except uses default printf output
void owPrintErrorMsgStd()
/src/sockit_owm.c
1,5 → 1,9
/******************************************************************************
* *
* 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 *
* *
* Copyright (c) 2008 Altera Corporation, San Jose, California, USA. *
29,30 → 33,6
******************************************************************************/
 
 
//////////////////////////////////////////////////////////////////////////////
// //
// 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/>. //
// //
//////////////////////////////////////////////////////////////////////////////
 
 
#include <fcntl.h>
 
#include "sys/alt_dev.h"
80,14 → 60,13
void sockit_owm_init (alt_u32 irq)
{
int error;
// initialize semaphore for transfer locking
// TODO there is a warning to fix here
// initialize semaphore for 1-wire cycle locking
error = ALT_FLAG_CREATE (sockit_owm.irq, 0) ||
ALT_SEM_CREATE (sockit_owm.trn, 1);
ALT_SEM_CREATE (sockit_owm.cyc, 1);
 
if (!error) {
// enable TX interrupt, RX is unused
sockit_owm.ena = 0x1;
// enable interrupt
sockit_owm.ien = 0x1;
// register the interrupt handler
#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT
alt_ic_isr_register (0, irq, sockit_owm_irq, NULL, 0x0);
105,7 → 84,7
{
// clear onewire interrupts
IORD_SOCKIT_OWM (sockit_owm.base);
// set the flag indicating a completed transfer
// set the flag indicating a completed 1-wire cycle
ALT_FLAG_POST (sockit_owm.irq, 0x1, OS_FLAG_SET);
}
#else
/src/temp28.c
0,0 → 1,129
//---------------------------------------------------------------------------
// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// Except as contained in this notice, the name of Dallas Semiconductor
// shall not be used except as stated in the Dallas Semiconductor
// Branding Policy.
// ---------------------------------------------------------------------------
//
// temp28.C - Module to read the DS18B20 - temperature measurement.
//
// ---------------------------------------------------------------------------
//
//
#include "ownet.h"
#include "temp28.h"
 
//----------------------------------------------------------------------
// Read the temperature of a DS18B20 (family code 0x28)
//
// 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to
// OpenCOM to indicate the port number.
// 'SerialNum' - Serial Number of DS18B20 to read temperature from
// 'Temp ' - pointer to variable where that temperature will be
// returned
//
// Returns: TRUE(1) temperature has been read and verified
// FALSE(0) could not read the temperature, perhaps device is not
// in contact
//
int ReadTemperature28(int portnum, uchar *SerialNum, float *Temp)
{
uchar rt=FALSE;
uchar send_block[30],lastcrc8;
int send_cnt, tsht, i, loop=0;
int power;
 
// set the device serial number to the counter device
owSerialNum(portnum,SerialNum,FALSE);
 
for (loop = 0; loop < 2; loop ++)
{
// check if the chip is connected to VDD
if (owAccess(portnum))
{
owWriteByte(portnum,0xB4);
power = owReadByte(portnum);
}
 
// access the device
if (owAccess(portnum))
{
// send the convert command and if nesessary start power delivery
if (power) {
if (!owWriteBytePower(portnum,0x44))
return FALSE;
} else {
if (!owWriteByte(portnum,0x44))
return FALSE;
}
 
// sleep for 1 second
msDelay(1000);
 
// turn off the 1-Wire Net strong pull-up
if (power) {
if (owLevel(portnum,MODE_NORMAL) != MODE_NORMAL)
return FALSE;
}
 
// access the device
if (owAccess(portnum))
{
// create a block to send that reads the temperature
// read scratchpad command
send_cnt = 0;
send_block[send_cnt++] = 0xBE;
// now add the read bytes for data bytes and crc8
for (i = 0; i < 9; i++)
send_block[send_cnt++] = 0xFF;
 
// now send the block
if (owBlock(portnum,FALSE,send_block,send_cnt))
{
// initialize the CRC8
setcrc8(portnum,0);
// perform the CRC8 on the last 8 bytes of packet
for (i = send_cnt - 9; i < send_cnt; i++)
lastcrc8 = docrc8(portnum,send_block[i]);
 
// verify CRC8 is correct
if (lastcrc8 == 0x00)
{
// calculate the high-res temperature
tsht = send_block[2] << 8;
tsht = tsht | send_block[1];
if (tsht & 0x00001000)
tsht = tsht | 0xffff0000;
*Temp = ((float) tsht)/16;
// success
rt = TRUE;
break;
}
}
}
}
 
}
 
// return the result flag rt
return rt;
}
src/temp28.c Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: src/temp10.c =================================================================== --- src/temp10.c (nonexistent) +++ src/temp10.c (revision 3) @@ -0,0 +1,139 @@ +//--------------------------------------------------------------------------- +// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES +// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// Except as contained in this notice, the name of Dallas Semiconductor +// shall not be used except as stated in the Dallas Semiconductor +// Branding Policy. +// --------------------------------------------------------------------------- +// +// temp10.C - Module to read the DS1920/DS1820 - temperature measurement. +// +// --------------------------------------------------------------------------- +// +// +#include "ownet.h" +#include "temp10.h" + +//---------------------------------------------------------------------- +// Read the temperature of a DS1920/DS1820 (family code 0x10) +// +// 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to +// OpenCOM to indicate the port number. +// 'SerialNum' - Serial Number of DS1920/DS1820 to read temperature from +// 'Temp ' - pointer to variable where that temperature will be +// returned +// +// Returns: TRUE(1) temperature has been read and verified +// FALSE(0) could not read the temperature, perhaps device is not +// in contact +// +int ReadTemperature10(int portnum, uchar *SerialNum, float *Temp) +{ + uchar rt=FALSE; + uchar send_block[30],lastcrc8; + int send_cnt, tsht, i, loop=0; + float tmp,cr,cpc; + int power; + + // set the device serial number to the counter device + owSerialNum(portnum,SerialNum,FALSE); + + for (loop = 0; loop < 2; loop ++) + { + // check if the chip is connected to VDD + if (owAccess(portnum)) + { + owWriteByte(portnum,0xB4); + power = owReadByte(portnum); + } + + // access the device + if (owAccess(portnum)) + { + // send the convert command and if nesessary start power delivery + if (power) { + if (!owWriteBytePower(portnum,0x44)) + return FALSE; + } else { + if (!owWriteByte(portnum,0x44)) + return FALSE; + } + + // sleep for 1 second + msDelay(1000); + + // turn off the 1-Wire Net strong pull-up + if (power) { + if (owLevel(portnum,MODE_NORMAL) != MODE_NORMAL) + return FALSE; + } + + // access the device + if (owAccess(portnum)) + { + // create a block to send that reads the temperature + // read scratchpad command + send_cnt = 0; + send_block[send_cnt++] = 0xBE; + // now add the read bytes for data bytes and crc8 + for (i = 0; i < 9; i++) + send_block[send_cnt++] = 0xFF; + + // now send the block + if (owBlock(portnum,FALSE,send_block,send_cnt)) + { + // initialize the CRC8 + setcrc8(portnum,0); + // perform the CRC8 on the last 8 bytes of packet + for (i = send_cnt - 9; i < send_cnt; i++) + lastcrc8 = docrc8(portnum,send_block[i]); + + // verify CRC8 is correct + if (lastcrc8 == 0x00) + { + // calculate the high-res temperature + tsht = send_block[1]/2; + if (send_block[2] & 0x01) + tsht |= -128; + tmp = (float)(tsht); + cr = send_block[7]; + cpc = send_block[8]; + if (((cpc - cr) == 1) && (loop == 0)) + continue; + if (cpc == 0) + return FALSE; + else + tmp = tmp - (float)0.25 + (cpc - cr)/cpc; + + *Temp = tmp; + // success + rt = TRUE; + break; + } + } + } + } + + } + + // return the result flag rt + return rt; +}
src/temp10.c Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: src/owlnk.c =================================================================== --- src/owlnk.c (revision 2) +++ src/owlnk.c (revision 3) @@ -76,25 +76,26 @@ int ovd = (sockit_owm.ovd >> portnum) & 0x1; // lock transfer - ALT_SEM_PEND (sockit_owm.trn, 0); + ALT_SEM_PEND (sockit_owm.cyc, 0); - // write RST - IOWR_SOCKIT_OWM (sockit_owm.base, (sockit_owm.pwr << SOCKIT_OWM_POWER_OFST) - | (portnum << SOCKIT_OWM_SEL_OFST) - | (sockit_owm.ena << SOCKIT_OWM_ETX_OFST) - | (ovd << SOCKIT_OWM_OVD_OFST) - | SOCKIT_OWM_RST_MSK); + // reset pulse + IOWR_SOCKIT_OWM_CTL (sockit_owm.base, (sockit_owm.pwr << SOCKIT_OWM_CTL_POWER_OFST ) + | (portnum << SOCKIT_OWM_CTL_SEL_OFST ) + | (sockit_owm.ien ? SOCKIT_OWM_CTL_IEN_MSK : 0x00) + | ( SOCKIT_OWM_CTL_CYC_MSK ) + | (ovd ? SOCKIT_OWM_CTL_OVD_MSK : 0x00) + | ( SOCKIT_OWM_CTL_RST_MSK )); // wait for irq to set the transfer end flag ALT_FLAG_PEND (sockit_owm.irq, 0x1, OS_FLAG_WAIT_SET_ANY + OS_FLAG_CONSUME, 0); // wait for STX (end of transfer cycle) and read the presence status - while ((reg = IORD_SOCKIT_OWM (sockit_owm.base)) & SOCKIT_OWM_TRN_MSK); + while ((reg = IORD_SOCKIT_OWM_CTL (sockit_owm.base)) & SOCKIT_OWM_CTL_CYC_MSK); // release transfer lock - ALT_SEM_POST (sockit_owm.trn); + ALT_SEM_POST (sockit_owm.cyc); - // return DRX (presence detect) - return (~reg >> SOCKIT_OWM_DAT_OFST) & 0x1; + // return negated DAT (presence detect) + return (~reg & SOCKIT_OWM_CTL_DAT_MSK); // NOTE the shortcut } //-------------------------------------------------------------------------- @@ -116,25 +117,26 @@ int ovd = (sockit_owm.ovd >> portnum) & 0x1; // lock transfer - ALT_SEM_PEND (sockit_owm.trn, 0); + ALT_SEM_PEND (sockit_owm.cyc, 0); - // write RST - IOWR_SOCKIT_OWM (sockit_owm.base, (sockit_owm.pwr << SOCKIT_OWM_POWER_OFST) - | (portnum << SOCKIT_OWM_SEL_OFST) - | (sockit_owm.ena << SOCKIT_OWM_ETX_OFST) - | (ovd << SOCKIT_OWM_OVD_OFST) - | ((sendbit & 0x1) << SOCKIT_OWM_DAT_OFST)); + // read/write data + IOWR_SOCKIT_OWM_CTL (sockit_owm.base, (sockit_owm.pwr << SOCKIT_OWM_CTL_POWER_OFST ) + | (portnum << SOCKIT_OWM_CTL_SEL_OFST ) + | (sockit_owm.ien ? SOCKIT_OWM_CTL_IEN_MSK : 0x00) + | ( SOCKIT_OWM_CTL_CYC_MSK ) + | (ovd ? SOCKIT_OWM_CTL_OVD_MSK : 0x00) + | (sendbit & SOCKIT_OWM_CTL_DAT_MSK )); // NOTE the shortcut // wait for irq to set the transfer end flag ALT_FLAG_PEND (sockit_owm.irq, 0x1, OS_FLAG_WAIT_SET_ANY + OS_FLAG_CONSUME, 0); // wait for STX (end of transfer cycle) and read the read data bit - while ((reg = IORD_SOCKIT_OWM (sockit_owm.base)) & SOCKIT_OWM_TRN_MSK); + while ((reg = IORD_SOCKIT_OWM_CTL (sockit_owm.base)) & SOCKIT_OWM_CTL_CYC_MSK); // release transfer lock - ALT_SEM_POST (sockit_owm.trn); + ALT_SEM_POST (sockit_owm.cyc); - // return DRX (read bit) - return (reg >> SOCKIT_OWM_DAT_OFST) & 0x1; + // return DAT (read bit) + return (reg & SOCKIT_OWM_CTL_DAT_MSK); // NOTE the shortcut } //-------------------------------------------------------------------------- @@ -205,10 +207,15 @@ // SMALLINT owSpeed(int portnum, SMALLINT new_speed) { - if (new_speed == MODE_OVERDRIVE) sockit_owm.ovd |= (1 << portnum); - if (new_speed == MODE_NORMAL ) sockit_owm.ovd &= ~(1 << portnum); + int select; + select = 0x1 << portnum; + // if overdrive is implemented use it + if (sockit_owm.ovd_e) { + if (new_speed == MODE_OVERDRIVE) sockit_owm.ovd |= select; + if (new_speed == MODE_NORMAL ) sockit_owm.ovd &= ~select; + } // return the current port state - return ((sockit_owm.ovd >> portnum) & 0x1) ? MODE_OVERDRIVE : MODE_NORMAL; + return (sockit_owm.ovd & select) ? MODE_OVERDRIVE : MODE_NORMAL; } //-------------------------------------------------------------------------- @@ -230,15 +237,12 @@ if (new_level == MODE_STRONG5) { // set the power bit sockit_owm.pwr |= (1 << portnum); - IOWR_SOCKIT_OWM (sockit_owm.base, (sockit_owm.pwr << SOCKIT_OWM_POWER_OFST) - | SOCKIT_OWM_PWR_MSK - | SOCKIT_OWM_IDL_MSK); + IOWR_SOCKIT_OWM_CTL (sockit_owm.base, (sockit_owm.pwr << SOCKIT_OWM_CTL_POWER_OFST) | SOCKIT_OWM_CTL_PWR_MSK); } if (new_level == MODE_NORMAL) { // clear the power bit sockit_owm.pwr &= ~(1 << portnum); - IOWR_SOCKIT_OWM (sockit_owm.base, (sockit_owm.pwr << SOCKIT_OWM_POWER_OFST) - | SOCKIT_OWM_IDL_MSK); + IOWR_SOCKIT_OWM_CTL (sockit_owm.base, (sockit_owm.pwr << SOCKIT_OWM_CTL_POWER_OFST)); } // return the current port state return ((sockit_owm.pwr >> portnum) & 0x1) ? MODE_STRONG5 : MODE_NORMAL; @@ -268,23 +272,27 @@ #if SOCKIT_OWM_HW_DLY int i; + // compute the number delay cycles depending on delay time + len = (len * sockit_owm.f_dly) >> 16; + // lock transfer - ALT_SEM_PEND (sockit_owm.trn, 0); + ALT_SEM_PEND (sockit_owm.cyc, 0); for (i=0; i
/src/temp42.c
0,0 → 1,129
//---------------------------------------------------------------------------
// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// Except as contained in this notice, the name of Dallas Semiconductor
// shall not be used except as stated in the Dallas Semiconductor
// Branding Policy.
// ---------------------------------------------------------------------------
//
// temp42.C - Module to read the DS28EA00 - temperature measurement.
//
// ---------------------------------------------------------------------------
//
//
#include "ownet.h"
#include "temp42.h"
 
//----------------------------------------------------------------------
// Read the temperature of a DS28EA00 (family code 0x42)
//
// 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to
// OpenCOM to indicate the port number.
// 'SerialNum' - Serial Number of DS18B20 to read temperature from
// 'Temp ' - pointer to variable where that temperature will be
// returned
//
// Returns: TRUE(1) temperature has been read and verified
// FALSE(0) could not read the temperature, perhaps device is not
// in contact
//
int ReadTemperature42(int portnum, uchar *SerialNum, float *Temp)
{
uchar rt=FALSE;
uchar send_block[30],lastcrc8;
int send_cnt, tsht, i, loop=0;
int power;
 
// set the device serial number to the counter device
owSerialNum(portnum,SerialNum,FALSE);
 
for (loop = 0; loop < 2; loop ++)
{
// check if the chip is connected to VDD
if (owOverdriveAccess(portnum))
{
owWriteByte(portnum,0xB4);
power = owReadByte(portnum);
}
 
// access the device
if (owOverdriveAccess(portnum))
{
// send the convert command and if nesessary start power delivery
if (power) {
if (!owWriteBytePower(portnum,0x44))
return FALSE;
} else {
if (!owWriteByte(portnum,0x44))
return FALSE;
}
 
// sleep for 1 second
msDelay(1000);
 
// turn off the 1-Wire Net strong pull-up
if (power) {
if (owLevel(portnum,MODE_NORMAL) != MODE_NORMAL)
return FALSE;
}
 
// access the device
if (owOverdriveAccess(portnum))
{
// create a block to send that reads the temperature
// read scratchpad command
send_cnt = 0;
send_block[send_cnt++] = 0xBE;
// now add the read bytes for data bytes and crc8
for (i = 0; i < 9; i++)
send_block[send_cnt++] = 0xFF;
 
// now send the block
if (owBlock(portnum,FALSE,send_block,send_cnt))
{
// initialize the CRC8
setcrc8(portnum,0);
// perform the CRC8 on the last 8 bytes of packet
for (i = send_cnt - 9; i < send_cnt; i++)
lastcrc8 = docrc8(portnum,send_block[i]);
 
// verify CRC8 is correct
if (lastcrc8 == 0x00)
{
// calculate the high-res temperature
tsht = send_block[2] << 8;
tsht = tsht | send_block[1];
if (tsht & 0x00001000)
tsht = tsht | 0xffff0000;
*Temp = ((float) tsht)/16;
// success
rt = TRUE;
break;
}
}
}
}
}
// exit overdrive mode
owSpeed(portnum, MODE_NORMAL);
// return the result flag rt
return rt;
}
src/temp42.c Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: inc/temp42.h =================================================================== --- inc/temp42.h (nonexistent) +++ inc/temp42.h (revision 3) @@ -0,0 +1,31 @@ +//--------------------------------------------------------------------------- +// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES +// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// Except as contained in this notice, the name of Dallas Semiconductor +// shall not be used except as stated in the Dallas Semiconductor +// Branding Policy. +// --------------------------------------------------------------------------- +// +// temp42.h - Header to read the DS28EA00 - temperature measurement. +// +// --------------------------------------------------------------------------- + +int ReadTemperature42(int,uchar *,float *);
inc/temp42.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: inc/ownet.h =================================================================== --- inc/ownet.h (revision 2) +++ inc/ownet.h (revision 3) @@ -43,64 +43,17 @@ // Common Includes to ownet applications //--------------------------------------------------------------// #include +#include - //--------------------------------------------------------------// // Target Specific Information //--------------------------------------------------------------// -//--------------------------------------------------------------// -// Handhelds (PalmOS, WinCE) -//--------------------------------------------------------------// -#ifdef __MC68K__ - //MC68K is the type of processor in the PILOT - //Metrowerk's CodeWarrior defines this symbol - #include - #ifndef strcmp - #include - #define strcmp StrCompare - #endif - #include -#endif -#ifdef _WIN32_WCE - //All of our projects had this flag defined by default (_WIN32_WCE), - //but I'm not 100% positive that this is _the_ definitive - //flag to use to identify a WinCE system. - #include "WinCElnk.h" - #ifndef FILE - #define FILE int - extern int sprintf(char *buffer, char *format,...); - extern void fprintf(FILE *fp, char *format,...); - extern void printf(char *format,...); - #endif -#endif +// Altera Nios II + uCOS II +// configuration options available in: sockit_owm_sw.tcl +//#define SOCKIT_OWM_ERR_ENABLE +//#define SOCKIT_OWM_ERR_SMALL -#if !defined(_WIN32_WCE) && !defined(__MC68K__) - #include -#endif - -#ifdef __C51__ - #define FILE int - #define exit(c) return - typedef unsigned int ushort; - typedef unsigned long ulong; - #define SMALLINT uchar -#endif - -#ifdef __ICCMAXQ__ - #define FILE int - #define stdout 0 - #define stdin 1 - #define stderr 2 - typedef unsigned int ushort; - typedef unsigned long ulong; - #define SMALLINT short - #define main micro_main - #define real_main main - #define SMALL_MEMORY_TARGET -#endif - - //--------------------------------------------------------------// // Typedefs //--------------------------------------------------------------// @@ -128,15 +81,6 @@ #define SMALLINT int #endif -// setting max baud -#ifdef _WINDOWS - // 0x02 = PARAMSET_19200 -#define MAX_BAUD 0x02 -#else - // 0x06 = PARMSET_115200 -#define MAX_BAUD 0x06 -#endif - #ifndef OW_UCHAR #define OW_UCHAR typedef unsigned char uchar; @@ -197,6 +141,9 @@ //--------------------------------------------------------------// // Error handling //--------------------------------------------------------------// + +#ifdef SOCKIT_OWM_ERR_ENABLE + extern int owGetErrorNum(void); extern int owHasErrors(void); @@ -215,7 +162,7 @@ #define OWASSERT(s,err,ret) if(!(s)){owRaiseError((err));return (ret);} #endif -#ifdef SMALL_MEMORY_TARGET +#ifdef SOCKIT_OWM_ERR_SMALL #define OWERROR_DUMP(fileno) /*no-op*/; #else //Prints the stack out to the given file. @@ -225,6 +172,14 @@ extern char *owGetErrorMsg(int); #endif +#else + +#define OWERROR_CLEAR() /*no-op*/; +#define OWERROR(err) /*no-op*/; +#define OWERROR_DUMP(fileno) /*no-op*/; + +#endif + #define OWERROR_NO_ERROR_SET 0 #define OWERROR_NO_DEVICES_ON_NET 1 #define OWERROR_RESET_FAILED 2
/inc/sockit_owm.h
1,5 → 1,9
/******************************************************************************
* *
* 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 *
* *
* Copyright (c) 2008 Altera Corporation, San Jose, California, USA. *
29,30 → 33,6
******************************************************************************/
 
 
//////////////////////////////////////////////////////////////////////////////
// //
// 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__
#define __SOCKIT_OWM_H__
 
67,63 → 47,63
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#endif // __cplusplus
 
/*
* The sockit_owm_state structure is used to hold device specific data.
* 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.
*/
//////////////////////////////////////////////////////////////////////////////
// global structure containing the current state of the sockit_owm driver
//////////////////////////////////////////////////////////////////////////////
 
typedef struct sockit_owm_state_s
{
void* base; // The base address of the device
// constants
void* base; // The base address of the device
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
alt_u32 ovd_e; // Overdrive mode implementation enable
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
alt_u32 ena; // interrupt enable status
alt_u32 ien; // interrupt enable status
alt_u32 use; // Aquire status
alt_u32 ovd; // Overdrive status
alt_u32 pwr; // Power status
// OS multitasking features
//ALT_FLAG_GRP (srx) // receive event flag
ALT_FLAG_GRP (irq) // transmit event flag
ALT_SEM (trn) // transfer lock semaphore
ALT_FLAG_GRP (irq) // interrupt event flag
ALT_SEM (cyc) // transfer lock semaphore
} sockit_owm_state;
 
/*
* The macro ALTERA_AVALON_UART_INSTANCE is used by the auto-generated file
* alt_sys_init.c to create an instance of this device driver state.
* ALTERA_AVALON_UART_INSTANCE is mapped below to SOCKIT_OWM_STATE_INSTANCE.
*/
//////////////////////////////////////////////////////////////////////////////
// instantiation macro
// can be used oly once, since the driver is based on global variables
//////////////////////////////////////////////////////////////////////////////
 
#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
/*
* sockit_owm_init() is called by the auto-generated function
* alt_sys_init() for each UART in the system. This is done using the
* 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.
*/
 
//////////////////////////////////////////////////////////////////////////////
// initialization function, registers the interrupt handler
//////////////////////////////////////////////////////////////////////////////
 
extern void sockit_owm_init(alt_u32 irq);
 
/*
* The macro SOCKIT_OWM_STATE_INIT is used by the auto-generated file
* 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.
*/
//////////////////////////////////////////////////////////////////////////////
// initialization macro
//////////////////////////////////////////////////////////////////////////////
 
#ifndef SOCKIT_OWM_POLLING
#define SOCKIT_OWM_INIT(name, state) \
if (name##_IRQ == ALT_IRQ_NOT_CONNECTED) \
130,11 → 110,11
{ \
ALT_LINK_ERROR ("Error: Interrupt not connected for " #name ". " \
"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 " \
"can select a polled mode driver by checking the " \
"'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."); \
} \
else \
147,6 → 127,6
 
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // __cplusplus
 
#endif /* __SOCKIT_OWM_H__ */
#endif // __SOCKIT_OWM_H__
/inc/temp28.h
0,0 → 1,31
//---------------------------------------------------------------------------
// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// Except as contained in this notice, the name of Dallas Semiconductor
// shall not be used except as stated in the Dallas Semiconductor
// Branding Policy.
// ---------------------------------------------------------------------------
//
// temp28.h - Header to read the DS18B20 - temperature measurement.
//
// ---------------------------------------------------------------------------
 
int ReadTemperature28(int,uchar *,float *);
inc/temp28.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: inc/temp10.h =================================================================== --- inc/temp10.h (nonexistent) +++ inc/temp10.h (revision 3) @@ -0,0 +1,31 @@ +//--------------------------------------------------------------------------- +// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES +// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// Except as contained in this notice, the name of Dallas Semiconductor +// shall not be used except as stated in the Dallas Semiconductor +// Branding Policy. +// --------------------------------------------------------------------------- +// +// temp10.h - Header to read the DS1920/DS1820 - temperature measurement. +// +// --------------------------------------------------------------------------- + +int ReadTemperature10(int,uchar *,float *);
inc/temp10.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property

powered by: WebSVN 2.1.0

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