Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Max32630_One_Wire_Interface
OneWire_Masters/GPIO/owgpio.h
- Committer:
- j3
- Date:
- 2016-03-05
- Revision:
- 10:0df2cc66fc47
- Parent:
- 9:641516a3f0dc
- Child:
- 11:2833f27ba319
File content as of revision 10:0df2cc66fc47:
/******************************************************************//**
* @file owgpio.h
*
* @author Justin Jordan
*
* @version 0.0.0
*
* Started: 31JAN16
*
* Updated:
*
* @brief Header file for bit-banging a 1-wire master
***********************************************************************
* Copyright (C) 2016 Maxim Integrated Products, Inc., 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 MAXIM INTEGRATED 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 Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
**********************************************************************/
#ifndef OWGPIO_H
#define OWGPIO_H
#if(TARGET_MAX32600)
#include "mbed.h"
#include "OneWireInterface.h"
#include "OneWireMastersShared.h"
class OwGpio: public OneWireInterface
{
public:
//1-wire timming constants for bit-bang.
//Bit-Bang Master only supported on MAX32600MBED board
//All times are in terms of micro seconds
static const uint16_t TRSTL_STD = 560;
static const uint16_t TRSTL_OVD = 56;
//Master sample time for PD
static const uint16_t TMSP_STD = 68;
static const uint16_t TMSP_OVD = 8;
//Write 0
static const uint16_t TW0L_STD = 64;
static const uint16_t TW0L_OVD = 8;
//Write 1, Read low time
static const uint16_t TW1L_STD = 8;
static const uint16_t TW1L_OVD = 1;
//Master sample time for bit
static const uint16_t TMSR_STD = 12;
static const uint16_t TMSR_OVD = 1;
//make sure to use TSLOT for recoveries
static const uint16_t TSLOT_STD = 70;
static const uint16_t TSLOT_OVD = 10;
/**********************************************************//**
* @brief Owgpio constructor
*
* @details Initializes given pin for open-drain operation
*
* On Entry:
*
* @para[in] ow_gpio - GPIO pin to use for One Wire bus
*
* @param[in] ext_spu - GPIO pin to use for Strong Pull-Up
*
* On Exit:
*
* @return
**************************************************************/
OwGpio(PinName ow_gpio, PinName ext_spu = NC);
/**********************************************************//**
* @brief OwGpio destructor
*
* @details
*
* On Entry:
*
* On Exit:
*
* @return
**************************************************************/
virtual ~OwGpio();
/**********************************************************//**
* @brief initializes 16-bit counter_0 of TMR3 on MAX32600MBED
*
* @details
*
* On Entry:
*
* On Exit:
*
* @return
**************************************************************/
static void init_ow_timer(void);
/***** OW API ****************************************************/
virtual bool OWReset();
virtual void OWWriteBit(uint8_t sendbit);
virtual uint8_t OWReadBit();
virtual uint8_t OWTouchBit(uint8_t sendbit);
virtual bool OWWriteByte(uint8_t sendbyte);
virtual uint8_t OWReadByte(void);
virtual uint8_t OWTouchByte(uint8_t sendbyte);
virtual void OWBlock(uint8_t *tran_buf, uint8_t tran_len);
virtual void OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len);
virtual void OWReadBlock(uint8_t *recv_buf, uint8_t recv_len);
virtual bool OWFirst(void);
virtual bool OWNext(void);
virtual bool OWVerify(void);
virtual void OWTargetSetup(uint8_t family_code);
virtual void OWFamilySkipSetup(void);
virtual bool OWSearch(void);
virtual bool OWReadROM(void);
virtual bool OWSkipROM(void);
virtual bool OWMatchROM(void);
virtual bool OWOverdriveSkipROM(void);
virtual bool OWOverdriveMatchROM(void);
virtual bool OWResume(void);
virtual uint8_t OWSpeed(OW_SPEED new_speed);
virtual uint8_t OWLevel(OW_LEVEL new_level);
virtual bool OWWriteBytePower(uint8_t sendbyte);
virtual bool OWReadBitPower(uint8_t applyPowerResponse);
virtual const uint8_t (&OWgetROMnumber() const)[ROMnumberLen];
private:
void init_ow_gpio(PinName ow_gpio);
DigitalOut _ext_spu;
OW_SPEED _ow_speed;
OW_LEVEL _ow_level;
uint32_t _ow_port;
uint32_t _ow_pin;
// Search state
uint8_t _rom_number[ROMnumberLen];
uint8_t _last_discrepancy;
uint8_t _last_family_discrepancy;
uint8_t _last_device_flag;
uint8_t _crc8;
};
#endif/* TARGET_MAX32600*/
#endif /*OWGPIO_H*/