1-Wire® library for mbed. Complete 1-Wire library that supports our silicon masters along with a bit-bang master on the MAX32600MBED platform with one common interface for mbed. Slave support has also been included and more slaves will be added as time permits.
Dependents: MAXREFDES131_Qt_Demo MAX32630FTHR_iButton_uSD_Logger MAX32630FTHR_DS18B20_uSD_Logger MAXREFDES130_131_Demo ... more
Superseded by MaximInterface.
Diff: OneWire_Masters/OneWireMaster.h
- Revision:
- 17:b646b1e3970b
- Parent:
- 15:f6cb0d906fb6
- Child:
- 21:00c94aeb533e
--- a/OneWire_Masters/OneWireMaster.h Wed Mar 16 19:10:19 2016 +0000 +++ b/OneWire_Masters/OneWireMaster.h Fri Mar 18 20:21:05 2016 +0000 @@ -1,17 +1,4 @@ /******************************************************************//** -* @file OneWireMaster.h -* -* @author Justin Jordan -* -* @version 0.0.0 -* -* Started: 08FEB16 -* -* Updated: -* -* @brief Header file for functions shared between masters, that should -* be implemented only once. -*********************************************************************** * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -52,59 +39,65 @@ #include "OneWireInterface.h" +//This class is an abstract class type that can not be instaniated + +//OneWireMaster is the first derived class of OneWireInterface that +//defines implementations of common functions between masters and adds +//support for CRC16. + +//OneWireMaster should be inherited by your OW master declaration + + class OneWireMaster: public OneWireInterface { public: + static uint16_t calculateCRC16(uint16_t CRC16, uint16_t data); + + static uint16_t calculateCRC16(const uint8_t * data, size_t data_offset, size_t data_len, uint16_t crc); + //Part of OneWireInterface that should only be implemented once //See OneWireInterface.h for documentation - virtual void OWWriteBit(uint8_t sendbit); - - virtual uint8_t OWReadBit(); - - 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 OneWireInterface::CmdResult OWWriteBit(uint8_t sendbit); - virtual void OWReadBlock(uint8_t *recv_buf, uint8_t recv_len); + virtual OneWireInterface::CmdResult OWReadBit(uint8_t & recvbit); - virtual bool OWFirst(void); + virtual OneWireInterface::CmdResult OWTouchByte(uint8_t & sendrecvbyte); + + virtual OneWireInterface::CmdResult OWBlock(uint8_t *tran_buf, uint8_t tran_len); - virtual bool OWNext(void); + virtual OneWireInterface::CmdResult OWFirst(RomId & romId); + + virtual OneWireInterface::CmdResult OWNext(RomId & romId); - virtual bool OWVerify(void); + virtual OneWireInterface::CmdResult OWVerify(const RomId & romId); - virtual void OWTargetSetup(uint8_t family_code); + virtual void OWTargetSetup(RomId & romId); virtual void OWFamilySkipSetup(void); - virtual bool OWReadROM(void); - - virtual bool OWSkipROM(void); + virtual OneWireInterface::CmdResult OWReadROM(RomId & romId); - virtual bool OWMatchROM(void); + virtual OneWireInterface::CmdResult OWSkipROM(void); - virtual bool OWOverdriveSkipROM(void); + virtual OneWireInterface::CmdResult OWMatchROM(const RomId & romId); - virtual bool OWOverdriveMatchROM(void); + virtual OneWireInterface::CmdResult OWOverdriveSkipROM(void); - virtual bool OWResume(void); - - virtual const uint8_t (&OWgetROMnumber() const)[ROMnumberLen]; + virtual OneWireInterface::CmdResult OWOverdriveMatchROM(const RomId & romId); - static uint8_t OWCalc_crc8(uint8_t data, uint8_t crc8); + virtual OneWireInterface::CmdResult OWResume(void); protected: // Search state - uint8_t _rom_number[ROMnumberLen]; uint8_t _last_discrepancy; uint8_t _last_family_discrepancy; uint8_t _last_device_flag; uint8_t _crc8; + + static const uint16_t _oddparity[16]; };