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/DS2480B/ds2480b.h
- Revision:
- 63:422be898443a
- Parent:
- 32:bce180b544ed
- Child:
- 65:a28ac52ca127
--- a/OneWire_Masters/DS2480B/ds2480b.h Thu Apr 14 14:38:42 2016 -0500 +++ b/OneWire_Masters/DS2480B/ds2480b.h Tue Apr 19 21:52:49 2016 +0000 @@ -43,6 +43,14 @@ { public: + enum DS2480B_BPS + { + BPS_9600 = 0, + BPS_19200 = 2, + BPS_57600 = 4, + BPS_115200 = 6 + }; + /**********************************************************//** * @brief Ds2480b constructor * @@ -71,7 +79,7 @@ * On Exit: * @return **************************************************************/ - Ds2480b(PinName tx, PinName rx, uint32_t baud); + Ds2480b(PinName tx, PinName rx); /**********************************************************//** @@ -86,6 +94,8 @@ **************************************************************/ virtual ~Ds2480b(); + OneWireMaster::CmdResult DS2480B_ChangeBaud(DS2480B_BPS newbaud); + //Part of OneWireMaster that should be implemented for each master //See OneWireMaster.h for documentation @@ -103,8 +113,6 @@ virtual OneWireMaster::CmdResult OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len); virtual OneWireMaster::CmdResult OWReadBlock(uint8_t *rx_buf, uint8_t rx_len); - - virtual OneWireMaster::CmdResult OWSearch(RomId & romId); virtual OneWireMaster::CmdResult OWSetSpeed(OWSpeed new_speed); @@ -112,8 +120,34 @@ private: + void rx_callback(void); + void tx_callback(void); + + OneWireMaster::CmdResult DS2480B_Detect(void); + OneWireMaster::CmdResult WriteCOM(uint32_t outlen, uint8_t *outbuf); + OneWireMaster::CmdResult ReadCOM(uint32_t inlen, uint8_t *inbuf); + void BreakCOM(void); + void FlushCOM(void); + void SetBaudCOM(uint8_t new_baud); + int32_t bitacc(uint32_t op, uint32_t state, uint32_t loc, uint8_t *buf); + Serial *_p_serial; bool _serial_owner; + + // DS2480B state + OWLevel _ULevel; // 1-Wire level + DS2480B_BPS _UBaud; // baud rate + uint8_t _UMode; // command or data mode state + uint8_t _USpeed; // 1-Wire communication speed + + static const size_t MAX_RX_BUFFER_LEN = 256; + struct ds2480b_circular_buff_s + { + uint8_t w_idx; + uint8_t r_idx; + bool wrap_error; + uint8_t buff[MAX_RX_BUFFER_LEN]; + }rx_buffer; }; #endif /*DS2480B_H*/