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@32:bce180b544ed, 2016-03-30 (annotated)
- Committer:
- IanBenzMaxim
- Date:
- Wed Mar 30 16:50:29 2016 -0500
- Revision:
- 32:bce180b544ed
- Parent:
- 28:057bb14d3cee
- Child:
- 52:4cba20c21941
1. Move the implementation of OWSearch() into OneWireMaster since it is a fairly complex algorithm that shouldn?t be implemented over and over. It will also match all other ROM function that are implemented there.
2. Create a new member function, OWTriplet(), in OneWireMaster to handle the virtual section of OWSearch(). Create a default implementation of OWTriplet() that uses OWReadByte() and OWWriteByte(). Masters only need to implement this function if they have a search accelerator of some sort.
3. Create type SearchState that will encapsulate all persistent data used by the search ROM functions. This will also make it easy to not have the search state part of the permanent OneWireMaster class data.
4. Rename OWSpeed() to OWSetSpeed() and OWLevel() to OWSetLevel() for naming consistency.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| j3 | 3:644fc630f958 | 1 | /******************************************************************//** |
| j3 | 3:644fc630f958 | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
| j3 | 3:644fc630f958 | 3 | * |
| j3 | 3:644fc630f958 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| j3 | 3:644fc630f958 | 5 | * copy of this software and associated documentation files (the "Software"), |
| j3 | 3:644fc630f958 | 6 | * to deal in the Software without restriction, including without limitation |
| j3 | 3:644fc630f958 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| j3 | 3:644fc630f958 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| j3 | 3:644fc630f958 | 9 | * Software is furnished to do so, subject to the following conditions: |
| j3 | 3:644fc630f958 | 10 | * |
| j3 | 3:644fc630f958 | 11 | * The above copyright notice and this permission notice shall be included |
| j3 | 3:644fc630f958 | 12 | * in all copies or substantial portions of the Software. |
| j3 | 3:644fc630f958 | 13 | * |
| j3 | 3:644fc630f958 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| j3 | 3:644fc630f958 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| j3 | 3:644fc630f958 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| j3 | 3:644fc630f958 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
| j3 | 3:644fc630f958 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| j3 | 3:644fc630f958 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| j3 | 3:644fc630f958 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| j3 | 3:644fc630f958 | 21 | * |
| j3 | 3:644fc630f958 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
| j3 | 3:644fc630f958 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
| j3 | 3:644fc630f958 | 24 | * Products, Inc. Branding Policy. |
| j3 | 3:644fc630f958 | 25 | * |
| j3 | 3:644fc630f958 | 26 | * The mere transfer of this software does not imply any licenses |
| j3 | 3:644fc630f958 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
| j3 | 3:644fc630f958 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
| j3 | 3:644fc630f958 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
| j3 | 3:644fc630f958 | 30 | * ownership rights. |
| j3 | 3:644fc630f958 | 31 | **********************************************************************/ |
| j3 | 3:644fc630f958 | 32 | |
| j3 | 3:644fc630f958 | 33 | |
| j3 | 3:644fc630f958 | 34 | #ifndef OWGPIO_H |
| j3 | 3:644fc630f958 | 35 | #define OWGPIO_H |
| j3 | 3:644fc630f958 | 36 | |
| j3 | 3:644fc630f958 | 37 | |
| j3 | 10:0df2cc66fc47 | 38 | #if(TARGET_MAX32600) |
| j3 | 10:0df2cc66fc47 | 39 | |
| j3 | 10:0df2cc66fc47 | 40 | |
| j3 | 3:644fc630f958 | 41 | #include "mbed.h" |
| IanBenzMaxim | 24:8942d8478d68 | 42 | #include "OneWire_Masters/OneWireMaster.h" |
| j3 | 3:644fc630f958 | 43 | |
| j3 | 3:644fc630f958 | 44 | |
| j3 | 15:f6cb0d906fb6 | 45 | class OwGpio: public OneWireMaster |
| j3 | 3:644fc630f958 | 46 | { |
| IanBenzMaxim | 26:a361e3f42ba5 | 47 | public: |
| IanBenzMaxim | 28:057bb14d3cee | 48 | |
| IanBenzMaxim | 28:057bb14d3cee | 49 | struct OwTiming |
| IanBenzMaxim | 28:057bb14d3cee | 50 | { |
| IanBenzMaxim | 28:057bb14d3cee | 51 | uint16_t tRSTL, tMSP, tW0L, tW1L, tMSR, tSLOT; // All times are in terms of micro seconds |
| IanBenzMaxim | 28:057bb14d3cee | 52 | }; |
| j3 | 9:641516a3f0dc | 53 | |
| IanBenzMaxim | 28:057bb14d3cee | 54 | static const OwTiming stdTiming; |
| IanBenzMaxim | 28:057bb14d3cee | 55 | static const OwTiming odTiming; |
| IanBenzMaxim | 28:057bb14d3cee | 56 | |
| IanBenzMaxim | 28:057bb14d3cee | 57 | |
| j3 | 3:644fc630f958 | 58 | /**********************************************************//** |
| j3 | 10:0df2cc66fc47 | 59 | * @brief Owgpio constructor |
| j3 | 10:0df2cc66fc47 | 60 | * |
| j3 | 10:0df2cc66fc47 | 61 | * @details Initializes given pin for open-drain operation |
| j3 | 10:0df2cc66fc47 | 62 | * |
| j3 | 10:0df2cc66fc47 | 63 | * On Entry: |
| j3 | 10:0df2cc66fc47 | 64 | * |
| j3 | 10:0df2cc66fc47 | 65 | * @para[in] ow_gpio - GPIO pin to use for One Wire bus |
| j3 | 10:0df2cc66fc47 | 66 | * |
| j3 | 10:0df2cc66fc47 | 67 | * @param[in] ext_spu - GPIO pin to use for Strong Pull-Up |
| j3 | 10:0df2cc66fc47 | 68 | * |
| j3 | 10:0df2cc66fc47 | 69 | * On Exit: |
| j3 | 10:0df2cc66fc47 | 70 | * |
| j3 | 10:0df2cc66fc47 | 71 | * @return |
| j3 | 10:0df2cc66fc47 | 72 | **************************************************************/ |
| j3 | 10:0df2cc66fc47 | 73 | OwGpio(PinName ow_gpio, PinName ext_spu = NC); |
| j3 | 10:0df2cc66fc47 | 74 | |
| j3 | 10:0df2cc66fc47 | 75 | |
| j3 | 23:e8e403d61359 | 76 | //Part of OneWireMaster that should be implemented for each master |
| j3 | 23:e8e403d61359 | 77 | //See OneWireMaster.h for documentation |
| j3 | 15:f6cb0d906fb6 | 78 | |
| j3 | 23:e8e403d61359 | 79 | virtual OneWireMaster::CmdResult OWInitMaster(void); |
| j3 | 3:644fc630f958 | 80 | |
| j3 | 23:e8e403d61359 | 81 | virtual OneWireMaster::CmdResult OWReset(void); |
| j3 | 3:644fc630f958 | 82 | |
| IanBenzMaxim | 32:bce180b544ed | 83 | virtual OneWireMaster::CmdResult OWTouchBit(uint8_t & sendrecvbit, OWLevel after_level); |
| j3 | 17:b646b1e3970b | 84 | |
| IanBenzMaxim | 32:bce180b544ed | 85 | virtual OneWireMaster::CmdResult OWWriteByte(uint8_t sendbyte, OWLevel after_level); |
| j3 | 3:644fc630f958 | 86 | |
| IanBenzMaxim | 32:bce180b544ed | 87 | virtual OneWireMaster::CmdResult OWReadByte(uint8_t & recvbyte, OWLevel after_level); |
| j3 | 17:b646b1e3970b | 88 | |
| j3 | 23:e8e403d61359 | 89 | virtual OneWireMaster::CmdResult OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len); |
| j3 | 23:e8e403d61359 | 90 | |
| j3 | 23:e8e403d61359 | 91 | virtual OneWireMaster::CmdResult OWReadBlock(uint8_t *rx_buf, uint8_t rx_len); |
| j3 | 23:e8e403d61359 | 92 | |
| IanBenzMaxim | 32:bce180b544ed | 93 | virtual OneWireMaster::CmdResult OWSetSpeed(OWSpeed new_speed); |
| j3 | 3:644fc630f958 | 94 | |
| IanBenzMaxim | 32:bce180b544ed | 95 | virtual OneWireMaster::CmdResult OWSetLevel(OWLevel new_level); |
| IanBenzMaxim | 26:a361e3f42ba5 | 96 | |
| IanBenzMaxim | 26:a361e3f42ba5 | 97 | private: |
| j3 | 3:644fc630f958 | 98 | |
| IanBenzMaxim | 28:057bb14d3cee | 99 | const unsigned int _ow_port; |
| IanBenzMaxim | 28:057bb14d3cee | 100 | const unsigned int _ow_pin; |
| IanBenzMaxim | 28:057bb14d3cee | 101 | |
| j3 | 5:ce108eeb878d | 102 | DigitalOut _ext_spu; |
| IanBenzMaxim | 32:bce180b544ed | 103 | OWSpeed _ow_speed; |
| IanBenzMaxim | 32:bce180b544ed | 104 | OWLevel _ow_level; |
| j3 | 9:641516a3f0dc | 105 | |
| IanBenzMaxim | 28:057bb14d3cee | 106 | inline void write_ow_gpio_low(); |
| IanBenzMaxim | 28:057bb14d3cee | 107 | inline void write_ow_gpio_high(); |
| IanBenzMaxim | 28:057bb14d3cee | 108 | inline bool read_ow_gpio(); |
| IanBenzMaxim | 28:057bb14d3cee | 109 | inline void set_ow_gpio_mode(unsigned int mode); |
| j3 | 3:644fc630f958 | 110 | }; |
| j3 | 3:644fc630f958 | 111 | |
| j3 | 10:0df2cc66fc47 | 112 | #endif/* TARGET_MAX32600*/ |
| j3 | 3:644fc630f958 | 113 | #endif /*OWGPIO_H*/ |