Nut/OS  5.0.5
API Reference
owibus.h
Go to the documentation of this file.
00001 #ifndef _OWIBUS_H_
00002 #define _OWIBUS_H_
00003 
00004 /*
00005  * Copyright (C) 2012 by Uwe Bonnes(bon@elektron.ikp.physik.tu-darmstadt.de)
00006  *
00007  * All rights reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions
00011  * are met:
00012  *
00013  * 1. Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in the
00017  *    documentation and/or other materials provided with the distribution.
00018  * 3. Neither the name of the copyright holders nor the names of
00019  *    contributors may be used to endorse or promote products derived
00020  *    from this software without specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00029  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00030  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00031  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00032  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00033  * SUCH DAMAGE.
00034  *
00035  * For additional information see http://www.ethernut.de/
00036  */
00037 
00047 #include <cfg/arch.h>
00048 #include <stdint.h>
00049 
00054 
00055 /* Overdrive Commands as in
00056  * http://www.ovro.caltech.edu/~dwh/correlator/pdf/onewire.pdf
00057  */
00061 #define OWI_READ_ROM            0x33    
00062 #define OWI_OVERDRIVE_SKIP_ROM  0x3c    
00063 #define OWI_CONVERT_T           0x44    
00064 #define OWI_MATCH_ROM           0x55    
00065 #define OWI_OVERDRIVE_MATCH_ROM 0x69    
00066 #define OWI_SKIP_ROM            0xCC    
00067 #define OWI_READ                0xBE    
00068 #define OWI_SEARCH_ROM          0xF0    
00073 #define OWI_LAST_DEVICE     0x00        
00074 #define OWI_SEARCH_FIRST    0xFF        
00081 enum OWI_ERRORS {
00082     OWI_SUCCESS = 0,            
00083     OWI_PRESENCE_ERR = -1,      
00084     OWI_INVALID_HW = -2,        
00085     OWI_OUT_OF_MEM = -3,        
00086     OWI_HW_ERROR = -4,          
00087     OWI_DATA_ERROR = -5,        
00088     OWI_NOT_IMPLEMENTED = -6,   
00089 };
00090 
00096 enum OWIBUS_MODE {
00097     OWI_MODE_NORMAL = 0,        
00098     OWI_MODE_OVERDRIVE = 1,     
00099     OWI_MODE_NONE = 2,          
00100 };
00101 
00107 enum STM32_OWITIMER_COMMANDS {
00108     OWI_CMD_RESET = 0,          
00109     OWI_CMD_RWBIT = 1,          
00110     OWI_CMD_NONE = 2,           
00111 };
00112 
00118 enum STM32_OWITIMER_PHASES {
00119     OWI_PHASE_SETUP = 0,        
00120     OWI_PHASE_SYNC_PULSE = 1,   
00121     OWI_PHASE_RW = 2,           
00122     OWI_PHASE_RELEASE = 3,      
00123     OWI_PHASE_NONE = 4,         
00124 };
00125 
00129 #define OWI_OVERDRIVE 0x1       
00130 #define OWI_PULLUP    0x2       
00132 typedef struct _NUTOWIBUS NUTOWIBUS;
00133 
00134 #include "owibus_bbif.h"
00135 #include "owibus_uartif.h"
00136 
00137 /* Include possible architecture specific OWI implementation here. */
00138 #if defined(MCU_STM32)
00139 #endif
00140 
00146 struct _NUTOWIBUS {
00147     uintptr_t owibus_info;
00148     uint32_t mode;
00149     int(*OwiTouchReset) (NUTOWIBUS *);
00150     int(*OwiReadBlock) (NUTOWIBUS *bus, uint8_t *data, uint_fast8_t);
00151     int(*OwiWriteBlock) (NUTOWIBUS *bus, uint8_t *data, uint_fast8_t);
00152 };
00153 
00154 int OwiRomSearch(NUTOWIBUS *bus, uint8_t *diff, uint64_t *hid);
00155 int OwiCommand(NUTOWIBUS *bus, uint8_t cmd, uint64_t *hid);
00156 int OwiReadBlock(NUTOWIBUS *bus, uint8_t *data, uint_fast8_t len);
00157 int OwiWriteBlock(NUTOWIBUS *bus, uint8_t *data, uint_fast8_t len);
00158 int OwiSetMode(NUTOWIBUS *bus, uint_fast8_t mode);
00159 int OwiGetMode(NUTOWIBUS *bus);
00160 
00163 #endif