mbed library sources. Supersedes mbed-src. Edited target satm32f446 for user USART3 pins
Fork of mbed-dev by
targets/TARGET_Maxim/TARGET_MAX32620C/mxc/owm.h@186:707f6e361f3e, 2018-06-22 (annotated)
- Committer:
- Anna Bridge
- Date:
- Fri Jun 22 16:45:37 2018 +0100
- Revision:
- 186:707f6e361f3e
mbed-dev library. Release version 162
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Anna Bridge |
186:707f6e361f3e | 1 | /** |
Anna Bridge |
186:707f6e361f3e | 2 | * @file |
Anna Bridge |
186:707f6e361f3e | 3 | * @brief Registers, Bit Masks and Bit Positions for the 1-Wire Master |
Anna Bridge |
186:707f6e361f3e | 4 | * peripheral module. |
Anna Bridge |
186:707f6e361f3e | 5 | */ |
Anna Bridge |
186:707f6e361f3e | 6 | /* **************************************************************************** |
Anna Bridge |
186:707f6e361f3e | 7 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
Anna Bridge |
186:707f6e361f3e | 8 | * |
Anna Bridge |
186:707f6e361f3e | 9 | * Permission is hereby granted, free of charge, to any person obtaining a |
Anna Bridge |
186:707f6e361f3e | 10 | * copy of this software and associated documentation files (the "Software"), |
Anna Bridge |
186:707f6e361f3e | 11 | * to deal in the Software without restriction, including without limitation |
Anna Bridge |
186:707f6e361f3e | 12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
Anna Bridge |
186:707f6e361f3e | 13 | * and/or sell copies of the Software, and to permit persons to whom the |
Anna Bridge |
186:707f6e361f3e | 14 | * Software is furnished to do so, subject to the following conditions: |
Anna Bridge |
186:707f6e361f3e | 15 | * |
Anna Bridge |
186:707f6e361f3e | 16 | * The above copyright notice and this permission notice shall be included |
Anna Bridge |
186:707f6e361f3e | 17 | * in all copies or substantial portions of the Software. |
Anna Bridge |
186:707f6e361f3e | 18 | * |
Anna Bridge |
186:707f6e361f3e | 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
Anna Bridge |
186:707f6e361f3e | 20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
Anna Bridge |
186:707f6e361f3e | 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
Anna Bridge |
186:707f6e361f3e | 22 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
Anna Bridge |
186:707f6e361f3e | 23 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
Anna Bridge |
186:707f6e361f3e | 24 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
Anna Bridge |
186:707f6e361f3e | 25 | * OTHER DEALINGS IN THE SOFTWARE. |
Anna Bridge |
186:707f6e361f3e | 26 | * |
Anna Bridge |
186:707f6e361f3e | 27 | * Except as contained in this notice, the name of Maxim Integrated |
Anna Bridge |
186:707f6e361f3e | 28 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
Anna Bridge |
186:707f6e361f3e | 29 | * Products, Inc. Branding Policy. |
Anna Bridge |
186:707f6e361f3e | 30 | * |
Anna Bridge |
186:707f6e361f3e | 31 | * The mere transfer of this software does not imply any licenses |
Anna Bridge |
186:707f6e361f3e | 32 | * of trade secrets, proprietary technology, copyrights, patents, |
Anna Bridge |
186:707f6e361f3e | 33 | * trademarks, maskwork rights, or any other form of intellectual |
Anna Bridge |
186:707f6e361f3e | 34 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
Anna Bridge |
186:707f6e361f3e | 35 | * ownership rights. |
Anna Bridge |
186:707f6e361f3e | 36 | * |
Anna Bridge |
186:707f6e361f3e | 37 | * $Date: 2016-03-14 10:08:53 -0500 (Mon, 14 Mar 2016) $ |
Anna Bridge |
186:707f6e361f3e | 38 | * $Revision: 21855 $ |
Anna Bridge |
186:707f6e361f3e | 39 | * |
Anna Bridge |
186:707f6e361f3e | 40 | **************************************************************************** */ |
Anna Bridge |
186:707f6e361f3e | 41 | |
Anna Bridge |
186:707f6e361f3e | 42 | /* Define to prevent redundant inclusion */ |
Anna Bridge |
186:707f6e361f3e | 43 | #ifndef _OWM_H_ |
Anna Bridge |
186:707f6e361f3e | 44 | #define _OWM_H_ |
Anna Bridge |
186:707f6e361f3e | 45 | |
Anna Bridge |
186:707f6e361f3e | 46 | /* **** Includes **** */ |
Anna Bridge |
186:707f6e361f3e | 47 | #include "mxc_config.h" |
Anna Bridge |
186:707f6e361f3e | 48 | #include "mxc_sys.h" |
Anna Bridge |
186:707f6e361f3e | 49 | #include "owm_regs.h" |
Anna Bridge |
186:707f6e361f3e | 50 | |
Anna Bridge |
186:707f6e361f3e | 51 | #ifdef __cplusplus |
Anna Bridge |
186:707f6e361f3e | 52 | extern "C" { |
Anna Bridge |
186:707f6e361f3e | 53 | #endif |
Anna Bridge |
186:707f6e361f3e | 54 | |
Anna Bridge |
186:707f6e361f3e | 55 | /** |
Anna Bridge |
186:707f6e361f3e | 56 | * @ingroup periphlibs |
Anna Bridge |
186:707f6e361f3e | 57 | * @defgroup owm 1-Wire Master (OWM) |
Anna Bridge |
186:707f6e361f3e | 58 | * @{ |
Anna Bridge |
186:707f6e361f3e | 59 | */ |
Anna Bridge |
186:707f6e361f3e | 60 | |
Anna Bridge |
186:707f6e361f3e | 61 | /* **** Definitions **** */ |
Anna Bridge |
186:707f6e361f3e | 62 | |
Anna Bridge |
186:707f6e361f3e | 63 | /** |
Anna Bridge |
186:707f6e361f3e | 64 | * Enumeration type for 1-Wire Overdrive Speed Options. |
Anna Bridge |
186:707f6e361f3e | 65 | */ |
Anna Bridge |
186:707f6e361f3e | 66 | typedef enum { |
Anna Bridge |
186:707f6e361f3e | 67 | OWM_OVERDRIVE_UNUSED = MXC_V_OWM_CTRL_STAT_OD_SPEC_MODE_12US, /**< 12us Overdrive Speed Select. */ |
Anna Bridge |
186:707f6e361f3e | 68 | OWM_OVERDRIVE_12US = MXC_V_OWM_CTRL_STAT_OD_SPEC_MODE_12US, /**< 12us Overdrive Speed Select. */ |
Anna Bridge |
186:707f6e361f3e | 69 | OWM_OVERDRIVE_10US = MXC_V_OWM_CTRL_STAT_OD_SPEC_MODE_10US /**< 10us Overdrive Speed Select. */ |
Anna Bridge |
186:707f6e361f3e | 70 | } owm_overdrive_t; |
Anna Bridge |
186:707f6e361f3e | 71 | |
Anna Bridge |
186:707f6e361f3e | 72 | /** |
Anna Bridge |
186:707f6e361f3e | 73 | * Enumeration type for specifying options for 1-Wire external pullup mode. |
Anna Bridge |
186:707f6e361f3e | 74 | */ |
Anna Bridge |
186:707f6e361f3e | 75 | typedef enum { |
Anna Bridge |
186:707f6e361f3e | 76 | OWM_EXT_PU_ACT_HIGH = 0, /**< Pullup pin is active high when enabled. */ |
Anna Bridge |
186:707f6e361f3e | 77 | OWM_EXT_PU_ACT_LOW = 1, /**< Pullup pin is active low when enabled. */ |
Anna Bridge |
186:707f6e361f3e | 78 | OWM_EXT_PU_UNUSED = 2, /**< Pullup pin is not used for an external pullup. */ |
Anna Bridge |
186:707f6e361f3e | 79 | } owm_ext_pu_t; |
Anna Bridge |
186:707f6e361f3e | 80 | |
Anna Bridge |
186:707f6e361f3e | 81 | /** |
Anna Bridge |
186:707f6e361f3e | 82 | * Structure type for 1-Wire Master configuration. |
Anna Bridge |
186:707f6e361f3e | 83 | */ |
Anna Bridge |
186:707f6e361f3e | 84 | typedef struct { |
Anna Bridge |
186:707f6e361f3e | 85 | uint8_t int_pu_en; /**< 1 = internal pullup on. */ |
Anna Bridge |
186:707f6e361f3e | 86 | owm_ext_pu_t ext_pu_mode; /**< See #owm_ext_pu_t. */ |
Anna Bridge |
186:707f6e361f3e | 87 | uint8_t long_line_mode; /**< 1 = long line mode enable. */ |
Anna Bridge |
186:707f6e361f3e | 88 | owm_overdrive_t overdrive_spec; /**< 0 = timeslot is 12us, 1 = timeslot is 10us. */ |
Anna Bridge |
186:707f6e361f3e | 89 | } owm_cfg_t; |
Anna Bridge |
186:707f6e361f3e | 90 | |
Anna Bridge |
186:707f6e361f3e | 91 | |
Anna Bridge |
186:707f6e361f3e | 92 | #define READ_ROM_COMMAND 0x33 /**< Read ROM Command */ |
Anna Bridge |
186:707f6e361f3e | 93 | #define MATCH_ROM_COMMAND 0x55 /**< Match ROM Command */ |
Anna Bridge |
186:707f6e361f3e | 94 | #define SEARCH_ROM_COMMAND 0xF0 /**< Search ROM Command */ |
Anna Bridge |
186:707f6e361f3e | 95 | #define SKIP_ROM_COMMAND 0xCC /**< Skip ROM Command */ |
Anna Bridge |
186:707f6e361f3e | 96 | #define OD_SKIP_ROM_COMMAND 0x3C /**< Overdrive Skip ROM Command */ |
Anna Bridge |
186:707f6e361f3e | 97 | #define OD_MATCH_ROM_COMMAND 0x69 /**< Overdrive Match ROM Command */ |
Anna Bridge |
186:707f6e361f3e | 98 | #define RESUME_COMMAND 0xA5 /**< Resume Command */ |
Anna Bridge |
186:707f6e361f3e | 99 | |
Anna Bridge |
186:707f6e361f3e | 100 | /* **** Globals **** */ |
Anna Bridge |
186:707f6e361f3e | 101 | |
Anna Bridge |
186:707f6e361f3e | 102 | /* **** Function Prototypes **** */ |
Anna Bridge |
186:707f6e361f3e | 103 | |
Anna Bridge |
186:707f6e361f3e | 104 | /** |
Anna Bridge |
186:707f6e361f3e | 105 | * @brief Initialize and enable OWM module. |
Anna Bridge |
186:707f6e361f3e | 106 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 107 | * @param cfg Pointer to OWM configuration. |
Anna Bridge |
186:707f6e361f3e | 108 | * @param sys_cfg Pointer to system configuration object |
Anna Bridge |
186:707f6e361f3e | 109 | * |
Anna Bridge |
186:707f6e361f3e | 110 | * @retval #E_NO_ERROR if everything is successful |
Anna Bridge |
186:707f6e361f3e | 111 | * @retval #E_NULL_PTR if parameter is a null pointer |
Anna Bridge |
186:707f6e361f3e | 112 | * @retval #E_BUSY if IOMAN was not configured correctly |
Anna Bridge |
186:707f6e361f3e | 113 | * @retval #E_UNINITIALIZED if OWM CLK disabled |
Anna Bridge |
186:707f6e361f3e | 114 | * @retval #E_NOT_SUPPORTED if 1MHz CLK cannot be created with given system and owm CLK |
Anna Bridge |
186:707f6e361f3e | 115 | * @retval #E_BAD_PARAM if bad cfg parameter passed in |
Anna Bridge |
186:707f6e361f3e | 116 | */ |
Anna Bridge |
186:707f6e361f3e | 117 | int OWM_Init(mxc_owm_regs_t *owm, const owm_cfg_t *cfg, const sys_cfg_owm_t *sys_cfg); |
Anna Bridge |
186:707f6e361f3e | 118 | |
Anna Bridge |
186:707f6e361f3e | 119 | /** |
Anna Bridge |
186:707f6e361f3e | 120 | * @brief Shutdown OWM module. |
Anna Bridge |
186:707f6e361f3e | 121 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 122 | * @retval #E_NO_ERROR if everything is successful |
Anna Bridge |
186:707f6e361f3e | 123 | * @retval #E_BUSY if IOMAN was not released |
Anna Bridge |
186:707f6e361f3e | 124 | */ |
Anna Bridge |
186:707f6e361f3e | 125 | int OWM_Shutdown(mxc_owm_regs_t *owm); |
Anna Bridge |
186:707f6e361f3e | 126 | |
Anna Bridge |
186:707f6e361f3e | 127 | /** |
Anna Bridge |
186:707f6e361f3e | 128 | * @brief Send 1-Wire reset pulse. Will block until transaction is complete. |
Anna Bridge |
186:707f6e361f3e | 129 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 130 | * @retval (0) = no presence pulse detected, (1) = presence pulse detected |
Anna Bridge |
186:707f6e361f3e | 131 | */ |
Anna Bridge |
186:707f6e361f3e | 132 | int OWM_Reset(mxc_owm_regs_t *owm); |
Anna Bridge |
186:707f6e361f3e | 133 | |
Anna Bridge |
186:707f6e361f3e | 134 | /** |
Anna Bridge |
186:707f6e361f3e | 135 | * @brief Send and receive one byte of data. Will block until transaction is complete. |
Anna Bridge |
186:707f6e361f3e | 136 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 137 | * @param data data to send |
Anna Bridge |
186:707f6e361f3e | 138 | * @retval data read (1 byte) |
Anna Bridge |
186:707f6e361f3e | 139 | */ |
Anna Bridge |
186:707f6e361f3e | 140 | int OWM_TouchByte(mxc_owm_regs_t *owm, uint8_t data); |
Anna Bridge |
186:707f6e361f3e | 141 | |
Anna Bridge |
186:707f6e361f3e | 142 | /** |
Anna Bridge |
186:707f6e361f3e | 143 | * @brief Write one byte of data. Will block until transaction is complete. |
Anna Bridge |
186:707f6e361f3e | 144 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 145 | * @param data data to send |
Anna Bridge |
186:707f6e361f3e | 146 | * @retval #E_NO_ERROR if everything is successful |
Anna Bridge |
186:707f6e361f3e | 147 | * @retval #E_COMM_ERR if data written != data parameter |
Anna Bridge |
186:707f6e361f3e | 148 | */ |
Anna Bridge |
186:707f6e361f3e | 149 | int OWM_WriteByte(mxc_owm_regs_t *owm, uint8_t data); |
Anna Bridge |
186:707f6e361f3e | 150 | |
Anna Bridge |
186:707f6e361f3e | 151 | /** |
Anna Bridge |
186:707f6e361f3e | 152 | * @brief Read one byte of data. Will block until transaction is complete. |
Anna Bridge |
186:707f6e361f3e | 153 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 154 | * @retval data read (1 byte) |
Anna Bridge |
186:707f6e361f3e | 155 | */ |
Anna Bridge |
186:707f6e361f3e | 156 | int OWM_ReadByte(mxc_owm_regs_t *owm); |
Anna Bridge |
186:707f6e361f3e | 157 | |
Anna Bridge |
186:707f6e361f3e | 158 | /** |
Anna Bridge |
186:707f6e361f3e | 159 | * @brief Send and receive one bit of data. Will block until transaction is complete. |
Anna Bridge |
186:707f6e361f3e | 160 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 161 | * @param bit bit to send |
Anna Bridge |
186:707f6e361f3e | 162 | * @retval bit read |
Anna Bridge |
186:707f6e361f3e | 163 | */ |
Anna Bridge |
186:707f6e361f3e | 164 | int OWM_TouchBit(mxc_owm_regs_t *owm, uint8_t bit); |
Anna Bridge |
186:707f6e361f3e | 165 | |
Anna Bridge |
186:707f6e361f3e | 166 | /** |
Anna Bridge |
186:707f6e361f3e | 167 | * @brief Write one bit of data. Will block until transaction is complete. |
Anna Bridge |
186:707f6e361f3e | 168 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 169 | * @param bit bit to send |
Anna Bridge |
186:707f6e361f3e | 170 | * @retval #E_NO_ERROR if everything is successful |
Anna Bridge |
186:707f6e361f3e | 171 | * @retval #E_COMM_ERR if bit written != bit parameter |
Anna Bridge |
186:707f6e361f3e | 172 | */ |
Anna Bridge |
186:707f6e361f3e | 173 | int OWM_WriteBit(mxc_owm_regs_t *owm, uint8_t bit); |
Anna Bridge |
186:707f6e361f3e | 174 | |
Anna Bridge |
186:707f6e361f3e | 175 | /** |
Anna Bridge |
186:707f6e361f3e | 176 | * @brief Read one bit of data. Will block until transaction is complete. |
Anna Bridge |
186:707f6e361f3e | 177 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 178 | * @retval bit read |
Anna Bridge |
186:707f6e361f3e | 179 | */ |
Anna Bridge |
186:707f6e361f3e | 180 | int OWM_ReadBit(mxc_owm_regs_t *owm); |
Anna Bridge |
186:707f6e361f3e | 181 | |
Anna Bridge |
186:707f6e361f3e | 182 | /** |
Anna Bridge |
186:707f6e361f3e | 183 | * @brief Write multiple bytes of data. Will block until transaction is complete. |
Anna Bridge |
186:707f6e361f3e | 184 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 185 | * @param data Pointer to buffer for write data. |
Anna Bridge |
186:707f6e361f3e | 186 | * @param len Number of bytes to write. |
Anna Bridge |
186:707f6e361f3e | 187 | * |
Anna Bridge |
186:707f6e361f3e | 188 | * @retval Number of bytes written if successful |
Anna Bridge |
186:707f6e361f3e | 189 | * @retval #E_COMM_ERR if line short detected before transaction |
Anna Bridge |
186:707f6e361f3e | 190 | */ |
Anna Bridge |
186:707f6e361f3e | 191 | int OWM_Write(mxc_owm_regs_t *owm, uint8_t* data, int len); |
Anna Bridge |
186:707f6e361f3e | 192 | |
Anna Bridge |
186:707f6e361f3e | 193 | /** |
Anna Bridge |
186:707f6e361f3e | 194 | * @brief Read multiple bytes of data. Will block until transaction is complete. |
Anna Bridge |
186:707f6e361f3e | 195 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 196 | * @param data Pointer to buffer for read data. |
Anna Bridge |
186:707f6e361f3e | 197 | * @param len Number of bytes to read. |
Anna Bridge |
186:707f6e361f3e | 198 | * |
Anna Bridge |
186:707f6e361f3e | 199 | * @retval Number of bytes read if successful |
Anna Bridge |
186:707f6e361f3e | 200 | * @retval #E_COMM_ERR if line short detected before transaction |
Anna Bridge |
186:707f6e361f3e | 201 | */ |
Anna Bridge |
186:707f6e361f3e | 202 | int OWM_Read(mxc_owm_regs_t *owm, uint8_t* data, int len); |
Anna Bridge |
186:707f6e361f3e | 203 | |
Anna Bridge |
186:707f6e361f3e | 204 | /** |
Anna Bridge |
186:707f6e361f3e | 205 | * @brief Starts 1-Wire communication with Read ROM command |
Anna Bridge |
186:707f6e361f3e | 206 | * @note Only use the Read ROM command with one slave on the bus |
Anna Bridge |
186:707f6e361f3e | 207 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 208 | * @param ROMCode Pointer to buffer for ROM code read |
Anna Bridge |
186:707f6e361f3e | 209 | * @retval #E_NO_ERROR if everything is successful |
Anna Bridge |
186:707f6e361f3e | 210 | * @retval #E_COMM_ERR if reset, read or write fails |
Anna Bridge |
186:707f6e361f3e | 211 | */ |
Anna Bridge |
186:707f6e361f3e | 212 | int OWM_ReadROM(mxc_owm_regs_t *owm, uint8_t* ROMCode); |
Anna Bridge |
186:707f6e361f3e | 213 | |
Anna Bridge |
186:707f6e361f3e | 214 | /** |
Anna Bridge |
186:707f6e361f3e | 215 | * @brief Starts 1-Wire communication with Match ROM command |
Anna Bridge |
186:707f6e361f3e | 216 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 217 | * @param ROMCode Pointer to buffer with ROM code to match |
Anna Bridge |
186:707f6e361f3e | 218 | * @retval #E_NO_ERROR if everything is successful |
Anna Bridge |
186:707f6e361f3e | 219 | * @retval #E_COMM_ERR if reset or write fails |
Anna Bridge |
186:707f6e361f3e | 220 | */ |
Anna Bridge |
186:707f6e361f3e | 221 | int OWM_MatchROM(mxc_owm_regs_t *owm, uint8_t* ROMCode); |
Anna Bridge |
186:707f6e361f3e | 222 | |
Anna Bridge |
186:707f6e361f3e | 223 | /** |
Anna Bridge |
186:707f6e361f3e | 224 | * @brief Starts 1-Wire communication with Overdrive Match ROM command |
Anna Bridge |
186:707f6e361f3e | 225 | * @note After Overdrive Match ROM command is sent, the OWM is set to |
Anna Bridge |
186:707f6e361f3e | 226 | * overdrive speed. To set back to standard speed use OWM_SetOverdrive. |
Anna Bridge |
186:707f6e361f3e | 227 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 228 | * @param ROMCode Pointer to buffer with ROM code to match |
Anna Bridge |
186:707f6e361f3e | 229 | * @retval #E_NO_ERROR if everything is successful |
Anna Bridge |
186:707f6e361f3e | 230 | * @retval #E_COMM_ERR if reset or write fails |
Anna Bridge |
186:707f6e361f3e | 231 | */ |
Anna Bridge |
186:707f6e361f3e | 232 | int OWM_ODMatchROM(mxc_owm_regs_t *owm, uint8_t* ROMCode); |
Anna Bridge |
186:707f6e361f3e | 233 | |
Anna Bridge |
186:707f6e361f3e | 234 | /** |
Anna Bridge |
186:707f6e361f3e | 235 | * @brief Starts 1-Wire communication with Skip ROM command |
Anna Bridge |
186:707f6e361f3e | 236 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 237 | * @retval #E_NO_ERROR if everything is successful |
Anna Bridge |
186:707f6e361f3e | 238 | * @retval #E_COMM_ERR if reset or write fails |
Anna Bridge |
186:707f6e361f3e | 239 | */ |
Anna Bridge |
186:707f6e361f3e | 240 | int OWM_SkipROM(mxc_owm_regs_t *owm); |
Anna Bridge |
186:707f6e361f3e | 241 | |
Anna Bridge |
186:707f6e361f3e | 242 | /** |
Anna Bridge |
186:707f6e361f3e | 243 | * @brief Starts 1-Wire communication with Overdrive Skip ROM command |
Anna Bridge |
186:707f6e361f3e | 244 | * @note After Overdrive Skip ROM command is sent, the OWM is set to |
Anna Bridge |
186:707f6e361f3e | 245 | * overdrive speed. To set back to standard speed use OWM_SetOverdrive |
Anna Bridge |
186:707f6e361f3e | 246 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 247 | * @retval #E_NO_ERROR if everything is successful |
Anna Bridge |
186:707f6e361f3e | 248 | * @retval #E_COMM_ERR if reset or write fails |
Anna Bridge |
186:707f6e361f3e | 249 | */ |
Anna Bridge |
186:707f6e361f3e | 250 | int OWM_ODSkipROM(mxc_owm_regs_t *owm); |
Anna Bridge |
186:707f6e361f3e | 251 | |
Anna Bridge |
186:707f6e361f3e | 252 | /** |
Anna Bridge |
186:707f6e361f3e | 253 | * @brief Starts 1-Wire communication with Resume command |
Anna Bridge |
186:707f6e361f3e | 254 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 255 | * @retval #E_NO_ERROR if everything is successful |
Anna Bridge |
186:707f6e361f3e | 256 | * @retval #E_COMM_ERR if reset or write fails |
Anna Bridge |
186:707f6e361f3e | 257 | */ |
Anna Bridge |
186:707f6e361f3e | 258 | int OWM_Resume(mxc_owm_regs_t *owm); |
Anna Bridge |
186:707f6e361f3e | 259 | |
Anna Bridge |
186:707f6e361f3e | 260 | /** |
Anna Bridge |
186:707f6e361f3e | 261 | * @brief Starts 1-Wire communication with Search ROM command |
Anna Bridge |
186:707f6e361f3e | 262 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 263 | * @param newSearch (1) = start new search, (0) = continue search for next ROM |
Anna Bridge |
186:707f6e361f3e | 264 | * @param ROMCode Pointer to buffer with ROM code found |
Anna Bridge |
186:707f6e361f3e | 265 | * @retval (1) = ROM found, (0) = no new ROM found, end of search |
Anna Bridge |
186:707f6e361f3e | 266 | */ |
Anna Bridge |
186:707f6e361f3e | 267 | int OWM_SearchROM(mxc_owm_regs_t *owm, int newSearch, uint8_t* ROMCode); |
Anna Bridge |
186:707f6e361f3e | 268 | |
Anna Bridge |
186:707f6e361f3e | 269 | /** |
Anna Bridge |
186:707f6e361f3e | 270 | * @brief Clear interrupt flags. |
Anna Bridge |
186:707f6e361f3e | 271 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 272 | * @param mask Mask of interrupts to clear. |
Anna Bridge |
186:707f6e361f3e | 273 | */ |
Anna Bridge |
186:707f6e361f3e | 274 | __STATIC_INLINE void OWM_ClearFlags(mxc_owm_regs_t *owm, uint32_t mask) |
Anna Bridge |
186:707f6e361f3e | 275 | { |
Anna Bridge |
186:707f6e361f3e | 276 | owm->intfl = mask; |
Anna Bridge |
186:707f6e361f3e | 277 | } |
Anna Bridge |
186:707f6e361f3e | 278 | |
Anna Bridge |
186:707f6e361f3e | 279 | /** |
Anna Bridge |
186:707f6e361f3e | 280 | * @brief Get interrupt flags. |
Anna Bridge |
186:707f6e361f3e | 281 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 282 | * @retval Mask of active flags. |
Anna Bridge |
186:707f6e361f3e | 283 | */ |
Anna Bridge |
186:707f6e361f3e | 284 | __STATIC_INLINE unsigned OWM_GetFlags(mxc_owm_regs_t *owm) |
Anna Bridge |
186:707f6e361f3e | 285 | { |
Anna Bridge |
186:707f6e361f3e | 286 | return (owm->intfl); |
Anna Bridge |
186:707f6e361f3e | 287 | } |
Anna Bridge |
186:707f6e361f3e | 288 | |
Anna Bridge |
186:707f6e361f3e | 289 | /** |
Anna Bridge |
186:707f6e361f3e | 290 | * @brief Enables/Disables the External pullup |
Anna Bridge |
186:707f6e361f3e | 291 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 292 | * @param enable (1) = enable, (0) = disable |
Anna Bridge |
186:707f6e361f3e | 293 | */ |
Anna Bridge |
186:707f6e361f3e | 294 | __STATIC_INLINE void OWM_SetExtPullup(mxc_owm_regs_t *owm, int enable) |
Anna Bridge |
186:707f6e361f3e | 295 | { |
Anna Bridge |
186:707f6e361f3e | 296 | if(enable) |
Anna Bridge |
186:707f6e361f3e | 297 | owm->cfg |= MXC_F_OWM_CFG_EXT_PULLUP_ENABLE; |
Anna Bridge |
186:707f6e361f3e | 298 | else |
Anna Bridge |
186:707f6e361f3e | 299 | owm->cfg &= ~(MXC_F_OWM_CFG_EXT_PULLUP_ENABLE); |
Anna Bridge |
186:707f6e361f3e | 300 | } |
Anna Bridge |
186:707f6e361f3e | 301 | |
Anna Bridge |
186:707f6e361f3e | 302 | /** |
Anna Bridge |
186:707f6e361f3e | 303 | * @brief Enables/Disables Overdrive speed |
Anna Bridge |
186:707f6e361f3e | 304 | * @param owm Pointer to OWM regs. |
Anna Bridge |
186:707f6e361f3e | 305 | * @param enable (1) = overdrive, (0) = standard |
Anna Bridge |
186:707f6e361f3e | 306 | */ |
Anna Bridge |
186:707f6e361f3e | 307 | __STATIC_INLINE void OWM_SetOverdrive(mxc_owm_regs_t *owm, int enable) |
Anna Bridge |
186:707f6e361f3e | 308 | { |
Anna Bridge |
186:707f6e361f3e | 309 | if(enable) |
Anna Bridge |
186:707f6e361f3e | 310 | owm->cfg |= MXC_F_OWM_CFG_OVERDRIVE; |
Anna Bridge |
186:707f6e361f3e | 311 | else |
Anna Bridge |
186:707f6e361f3e | 312 | owm->cfg &= ~(MXC_F_OWM_CFG_OVERDRIVE); |
Anna Bridge |
186:707f6e361f3e | 313 | } |
Anna Bridge |
186:707f6e361f3e | 314 | |
Anna Bridge |
186:707f6e361f3e | 315 | /**@} end of group owm */ |
Anna Bridge |
186:707f6e361f3e | 316 | #ifdef __cplusplus |
Anna Bridge |
186:707f6e361f3e | 317 | } |
Anna Bridge |
186:707f6e361f3e | 318 | #endif |
Anna Bridge |
186:707f6e361f3e | 319 | |
Anna Bridge |
186:707f6e361f3e | 320 | #endif /* _OWM_H_ */ |