onewire.c File Reference

1 wire protocol functions. Target: PIC16F876 More...

#include <app.h>
Include dependency graph for onewire.c:

Go to the source code of this file.

Macros

#define PWR_ON_PIN   RA1
 RA.1 - power to DS2401. More...
 
#define PWR_ON_DIR   TRISA1
 
#define ID_DQ_PIN   RB0
 RB.0 - DQ for DS2401. More...
 
#define ID_DQ_DIR   TRISB0
 
#define OneWire_PinHI()   TRISB0 = DIR_IN
 
#define OneWire_PinLO()   { RB0 = 0x00; TRISB0 = DIR_OUT; }
 
#define W_CELL   4
 
#define W_INIT   50
 
#define W_WAIT   2000
 

Functions

BYTE OneWire_GetID (BYTE *buff)
 
BYTE OneWire_Init (void)
 
BYTE OneWire_Read (void)
 
void OneWire_Write (BYTE d)
 
BYTE OneWire_Crc8 (BYTE Data, BYTE Accum)
 

Detailed Description

1 wire protocol functions. Target: PIC16F876

This file is part of JADEKU Portable ADQ device for Routines Control.

Copyright (C) 2002-2009, Hernan Monserrat hemonserrat<at>gmail<dot>com

This program 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 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/.

Definition in file onewire.c.

Macro Definition Documentation

◆ ID_DQ_DIR

#define ID_DQ_DIR   TRISB0

Definition at line 29 of file onewire.c.

◆ ID_DQ_PIN

#define ID_DQ_PIN   RB0

RB.0 - DQ for DS2401.

Definition at line 28 of file onewire.c.

◆ OneWire_PinHI

#define OneWire_PinHI ( )    TRISB0 = DIR_IN

Definition at line 31 of file onewire.c.

◆ OneWire_PinLO

#define OneWire_PinLO ( )    { RB0 = 0x00; TRISB0 = DIR_OUT; }

Definition at line 32 of file onewire.c.

◆ PWR_ON_DIR

#define PWR_ON_DIR   TRISA1

Definition at line 26 of file onewire.c.

◆ PWR_ON_PIN

#define PWR_ON_PIN   RA1

RA.1 - power to DS2401.

Definition at line 25 of file onewire.c.

◆ W_CELL

#define W_CELL   4

Definition at line 33 of file onewire.c.

◆ W_INIT

#define W_INIT   50

Definition at line 34 of file onewire.c.

◆ W_WAIT

#define W_WAIT   2000

Definition at line 35 of file onewire.c.

Function Documentation

◆ OneWire_Crc8()

BYTE OneWire_Crc8 ( BYTE  Data,
BYTE  Accum 
)

Computes CRC8.

Parameters
Data- data byte to compute.
Accum- accumulated result.
Returns
the CRC8 accumulated result based on the params.

Definition at line 154 of file onewire.c.

Here is the caller graph for this function:

◆ OneWire_GetID()

BYTE OneWire_GetID ( BYTE buff)

Test for the 1 wire device presence, read ROM code and calculates crc.

Parameters
buff- buffer to store read data.
Returns
TRUE on packet received, FALSE timeout.
Remarks
note that 8-byte ID is returned in array buff.

Definition at line 43 of file onewire.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OneWire_Init()

BYTE OneWire_Init ( void  )

Send initialization flags to the 1 wire network.

Returns
TRUE on device presence.

Definition at line 69 of file onewire.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OneWire_Read()

BYTE OneWire_Read ( void  )

Read a byte from the 1 wire network.

Returns
byte read.

Definition at line 93 of file onewire.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OneWire_Write()

void OneWire_Write ( BYTE  d)

Send a byte to the 1 wire network.

Parameters
d- data byte to send.
Returns
none.

Definition at line 124 of file onewire.c.

Here is the call graph for this function:
Here is the caller graph for this function: