]> rtime.felk.cvut.cz Git - sysless.git/commitdiff
Deleted Jirks's 1-wire library
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 31 Jan 2010 19:56:34 +0000 (20:56 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 31 Jan 2010 19:56:34 +0000 (20:56 +0100)
On Sunday 31 January 2010 13:09:44 jiri.kubias@gmail.com (sysless@pandora.cz) wrote:
> Ahoj,
> smazte knihovnu arch/arm/mach-lpc23xx/libs/1-wire  ted koukam ze tam > jeste
> smrdi. Je v ni pomerne dost chyb a rozhodne by zatim nemela byt > uverejnena
> v syslessu. Az bude rozumne funkcni tak ji znova dodam.

arch/arm/mach-lpc23xx/libs/1-wire/1-wire-drv.c [deleted file]
arch/arm/mach-lpc23xx/libs/1-wire/1-wire-drv.h [deleted file]
arch/arm/mach-lpc23xx/libs/1-wire/Makefile [deleted file]
arch/arm/mach-lpc23xx/libs/1-wire/Makefile.omk [deleted file]
arch/arm/mach-lpc23xx/libs/1-wire/ds18s20.c [deleted file]
arch/arm/mach-lpc23xx/libs/1-wire/ds18s20.h [deleted file]

diff --git a/arch/arm/mach-lpc23xx/libs/1-wire/1-wire-drv.c b/arch/arm/mach-lpc23xx/libs/1-wire/1-wire-drv.c
deleted file mode 100644 (file)
index 7c2defc..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-
-/**
- *     @file   1-wire-drv.c
- *     @author Bc. Jiri Kubias jiri.kubias@gmail.com 
- *
- *     @brief  Software common 1wire driver
- *     This driver is based on Maxim implementation. The driver supports
- *     one (one pin is used for IO operation) or two pin implementation 
- *     (one pin as input, and second pin as output). External pullup is mandatory 
- *     for output pin. When hi level driver is done the driver can be reinitiated 
- *     for another pin sets. The bus is always left in HI state. 
- *
- *     @note   This driver uses TIMER3 
- *             
- */
-
-
-#include <lpc2xxx.h>                    /* LPC23xx definitions                */
-#include <types.h>
-
-typedef uint32_t reg_size;     ///< reg_size must be the addres size of register 
-static reg_size dir;           ///< GPIO DIRX register
-static reg_size set;           ///< GPIO SETX register
-static reg_size clr;           ///< GPIO CLRX register
-static reg_size port_wire;     ///< GPIO PORTX register
-static uint8_t pin_read;       ///< place where the 1-wire is connected for reading
-static uint8_t pin_write;      ///< place where the 1-wire is connected for writing
-static uint32_t tim_1us;
-
-
-
-
-
-/**
- *  Wait specified time in ms
- *  @param tim_ms      time to wait
- *
- */
-void inline wire_delay(uint32_t tim_ms)        
-{
-       T3TCR = 1; 
-       while(T3TC < ( tim_1us * (tim_ms))); 
-       T3TCR = 3;
-}
-
-
-/**
- *  Sets the output pin to output and drive it low
- *
- */
-static inline void wire_low (void)
-{
-       *((reg_size *)dir) |= (1<<pin_write);           
-       *((reg_size *)clr) = (1<<pin_write);
-}
-
-/**
- *  Release the pin and sets it as input. The high level is produced by pullup
- *
- */
-static inline void wire_high (void)
-{
-       *((reg_size *)dir) &= ~(1<<pin_write);     
-}
-
-/**
- *  Setrs the pin as input and return its value
- *
- */
-static inline uint8_t wire_read (void)
-{
-       
-       *((reg_size *)dir) &= ~(1<<pin_read);   
-       return (unsigned char) ((*((reg_size *)port_wire) >> pin_read) & 1);
-}
-
-/**
- *  Reset the 1wire bus, read and return the presence bit
- *     @return         presence detect state
- */
-uint8_t wire_reset(void)
-
-{
-       uint8_t presence_detect = 0;;
-       
-       wire_low();                     // Drive the bus low
-       wire_delay(480);
-       wire_read();                    // Release the bus
-       wire_delay(70); 
-       presence_detect = wire_read();  //Sample for presence pulse from slave
-       wire_delay(410);
-       wire_high ();                   // Release the bus
-       
-       return presence_detect;
-}      
-
-/**
- *     Write one bit to 1-wire 
- *     @param  write_bit value to write 
- */
-static void wire_write_bit (uint8_t write_bit)
-{
-       if (write_bit)
-       {
-               wire_low();                             // Drive the bus low
-               wire_delay(6);
-               wire_high ();                           // Release the bus
-               wire_delay(64);
-       }
-       else
-       {
-               wire_low();                             // Drive the bus low
-               wire_delay(60); // delay 60 microsecond (us)
-               wire_high ();                           // Release the bus
-               wire_delay(10); // delay 10 microsecond (us)
-       }
-}      
-
-
-/**
- *     Read one bit from 1-wire 
- *     @return         readed bit state
- */
-static uint8_t wire_read_bit (void)
-{
-       uint8_t read_data;  
-       wire_low();
-       wire_delay(6);
-       wire_high ();
-       wire_delay(9);
-       read_data = wire_read();
-       wire_delay(55);
-       return read_data;
-}
-
-/**
- *     Write one byte to 1-wire 
- *     @param  write_data value to write 
- */
-void wire_write_byte(uint8_t write_data)
-{
-       uint8_t loop;
-       
-       for (loop = 0; loop < 8; loop++)
-       {
-               wire_write_bit(write_data & 0x01);      //Sending LS-bit first
-               write_data >>= 1;                                       // shift the data byte for the next bit to send
-       }       
-}      
-
-/**
- *     Read one byte from 1-wire 
- *     @return         readed byte from 1wire
- */
-uint8_t wire_read_byte(void)
-{
-       unsigned char loop, result=0;
-       
-       for (loop = 0; loop < 8; loop++)
-       {
-               
-               result >>= 1;                           // shift the result to get it ready for the next bit to receive
-               if (wire_read_bit())
-               result |= 0x80;                         // if result is one, then set MS-bit
-       }
-       return result;
-}      
-
-
-/**
- *     Initialize the 1wire driver for given parameters
- *     @param  port    The the port where the IO pins are located
- *     @param  pin_in_num      The number of input pin
- *     @param  pin_out_num     The number of output pin
- *     @param  f_tim   The frequency which is set for timer3
- *
- *     @example init_1_wire(FIO1, 10, 10, 72000000);   // when the input and output pin is the same
- *     @example init_1_wire(FIO1, 10, 11, 72000000);   // when the input and output pin are different
- */
-void init_1_wire(uint8_t port, uint8_t pin_in_num, uint8_t pin_out_num, uint32_t f_tim)
-{
-       dir = (uint32_t) &FIO0DIR + port * 0x20;
-       set = (uint32_t) &FIO0SET + port * 0x20;
-       clr = (uint32_t) &FIO0CLR + port * 0x20;
-       port_wire = (uint32_t) &FIO0PIN + port * 0x20;
-       pin_read  = pin_in_num;
-       pin_write = pin_out_num;
-
-       PCONP |= (1<<23);
-       T3TCR = 3; // Enable and reset, timer is set as free runing
-       T3CTCR = 0;
-       T3PR = 0;
-       
-       tim_1us = f_tim / 1000000;
-}      
-
-
-/**
- *     Reset 1-wire  and test for presence bit
- *     @return         1 if no device found
- */
-uint8_t wire_detect_device(void)
-{
-       if (wire_reset())               
-               return 1;
-       else            
-               return 0;
-}
-
diff --git a/arch/arm/mach-lpc23xx/libs/1-wire/1-wire-drv.h b/arch/arm/mach-lpc23xx/libs/1-wire/1-wire-drv.h
deleted file mode 100644 (file)
index 385298e..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-// 1-wire driver
-
-#ifndef __1_WIRE_DRW_H 
-#define __1_WIRE_DRW_H   
-
-#include <types.h>
-
-/**
- *     Initialize the 1wire driver for given parameters
- *     @param  port    The the port where the IO pins are located
- *     @param  pin_in_num      The number of input pin
- *     @param  pin_out_num     The number of output pin
- *     @param  f_tim   The frequency which is set for timer3
- *
- *     @example init_1_wire(FIO1, 10, 10, 72000000);   // when the input and output pin is the same
- *     @example init_1_wire(FIO1, 10, 11, 72000000);   // when the input and output pin are different
- */
-void init_1_wire(uint8_t port, uint8_t pin_in_num, uint8_t pin_out_num, uint32_t f_tim);
-
-/**
- *  Reset the 1wire bus, read and return the presence bit
- *     @return         presence detect state
- */
-uint8_t wire_detect_device(void);
-
-/**
- *     Reset 1-wire  and test for presence bit
- *     @return         1 if no device found
- */
-uint8_t wire_reset(void);
-
-/**
- *     Write one byte to 1-wire 
- *     @param  write_data value to write 
- */
-void wire_write_byte(uint8_t write_data);
-
-/**
- *     Read one byte from 1-wire 
- *     @return         readed byte from 1wire
- */
-uint8_t wire_read_byte(void);
-
-/**
- *  Wait specified time in ms
- *  @param tim_ms      time to wait
- *
- */
-void inline wire_delay(uint32_t tim_ms);
-
-#endif //__1-WIRE-DRW_H
diff --git a/arch/arm/mach-lpc23xx/libs/1-wire/Makefile b/arch/arm/mach-lpc23xx/libs/1-wire/Makefile
deleted file mode 100644 (file)
index 76b56fd..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# Generic directory or leaf node makefile for OCERA make framework
-
-ifndef MAKERULES_DIR
-MAKERULES_DIR := $(shell ( old_pwd="" ;  while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd`  ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
-endif
-
-ifeq ($(MAKERULES_DIR),)
-all : default
-.DEFAULT::
-       @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
-else
-include $(MAKERULES_DIR)/Makefile.rules
-endif
-
diff --git a/arch/arm/mach-lpc23xx/libs/1-wire/Makefile.omk b/arch/arm/mach-lpc23xx/libs/1-wire/Makefile.omk
deleted file mode 100644 (file)
index 11c65c2..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-# -*- makefile -*-
-
-lib_LIBRARIES = 1wire-drv ds18s20
-
-1wire-drv_SOURCES = 1-wire-drv.c
-
-ds18s20_SOURCES = ds18s20.c
-ds18s20_libs = 1wire-drv
-
-include_HEADERS = 1-wire-drv.h ds18s20.h
diff --git a/arch/arm/mach-lpc23xx/libs/1-wire/ds18s20.c b/arch/arm/mach-lpc23xx/libs/1-wire/ds18s20.c
deleted file mode 100644 (file)
index f6db496..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-#include "ds18s20.h"
-#include "1-wire-drv.h"
-#include <lpc23xx.h>                    /* LPC23xx definitions                */
-
-
-
-
-
-
-/* Update 8-bit CRC value
-  using polynomial  X^8 + X^5 + X^4 + 1 */
-
-#define POLYVAL 0x8C
-
-void update_crc(unsigned char new, unsigned char *crc)
-{
-  unsigned char c, i;
-
-  c = *crc;
-  for (i = 0; i < 8; i++) 
-  {
-     if ((c ^ new) & 1) 
-       c = (c >> 1 ) ^ POLYVAL;
-     else 
-       c >>= 1;
-     new >>= 1;
-  }
- *crc = c;
-}
-
-
-
-uint8_t read_temp(struct ds18s20_dev * dev)
-{
-       uint8_t i, crc =0, data[9];
-       int16_t temp =0;
-
-       init_1_wire(dev->port, dev->pin_read, dev->pin_write, 72000000/4);
-               
-       if(  wire_detect_device())
-               return DEVICE_NOT_FOUND;
-               
-       
-       wire_reset();
-       wire_write_byte (0xCC);         // Send a command to prepare read temp
-       wire_write_byte (0x44);
-
-       wire_delay(6);
-
-       wire_reset();
-       wire_write_byte (0xCC);         // Read temp
-       wire_write_byte (0xBE); 
-
-       for(i = 0; i < 9; i++)
-                       data[i] = wire_read_byte();     // Read 64-bit registration (48-bit serial number) number from 1-wire Slave Device
-
-       for(i = 0; i < 8; i++)
-               update_crc(data[i], &crc);
-
-
-       if(crc != data[8])
-               return DEVICE_CRC_FAIL; 
-               
-       temp = ((uint16_t)(data[7] - data[6]) * 100)/data[7] - 25; 
-       temp = (temp + 5) / 10; 
-       temp += ((data[0] | ((uint16_t)data[1] << 8)) & ~(0x0001)) * 5;
-       dev->temp = temp;
-
-
-       
-       return 0;
-}      
-
-
-
diff --git a/arch/arm/mach-lpc23xx/libs/1-wire/ds18s20.h b/arch/arm/mach-lpc23xx/libs/1-wire/ds18s20.h
deleted file mode 100644 (file)
index ecd1b87..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef __DS18S20_H
-#define __DS18S20_H
-
-#include <types.h>
-
-#define DEVICE_OK                      0
-#define DEVICE_NOT_FOUND               1
-#define DEVICE_CRC_FAIL                        2
-#define DEVICE_SHORT_CIRCUIT           3       // kdyz je zkrat na lince (prectou se samy nuly)
-
-
-struct ds18s20_dev 
-{
-       uint8_t port;           // 0 for P0, 1 for P1 ...
-       uint8_t pin_read;
-       uint8_t pin_write;
-       int16_t temp;
-};     
-
-
-
-uint8_t read_temp(struct ds18s20_dev * dev);
-
-#endif //__DS18S20_H