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