MAX32665 Peripheral Driver API
Peripheral Driver API for the MAX32665
owm.h
1 
7 /* ****************************************************************************
8 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
24 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 * OTHER DEALINGS IN THE SOFTWARE.
27 *
28 * Except as contained in this notice, the name of Maxim Integrated
29 * Products, Inc. shall not be used except as stated in the Maxim Integrated
30 * Products, Inc. Branding Policy.
31 *
32 * The mere transfer of this software does not imply any licenses
33 * of trade secrets, proprietary technology, copyrights, patents,
34 * trademarks, maskwork rights, or any other form of intellectual
35 * property whatsoever. Maxim Integrated Products, Inc. retains all
36 * ownership rights.
37 *
38 **************************************************************************** */
39 
40 /* Define to prevent redundant inclusion */
41 #ifndef _OWM_H_
42 #define _OWM_H_
43 
44 /* **** Includes **** */
45 #include "mxc_device.h"
46 #include "mxc_sys.h"
47 #include "owm_regs.h"
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
59 /* **** Definitions **** */
60 
64 typedef enum {
69 
73 typedef struct {
74  uint8_t int_pu_en;
76  uint8_t long_line_mode;
77  // mxc_owm_overdrive_t overdrive_spec; /**< 0 = timeslot is 12us, 1 = timeslot is 10us. */
79 
80 
81 #define READ_ROM_COMMAND 0x33
82 #define MATCH_ROM_COMMAND 0x55
83 #define SEARCH_ROM_COMMAND 0xF0
84 #define SKIP_ROM_COMMAND 0xCC
85 #define OD_SKIP_ROM_COMMAND 0x3C
86 #define OD_MATCH_ROM_COMMAND 0x69
87 #define RESUME_COMMAND 0xA5
89 /* **** Globals **** */
90 
91 /* **** Function Prototypes **** */
92 
104 int MXC_OWM_Init (const mxc_owm_cfg_t *cfg);
105 
110 void MXC_OWM_Shutdown (void);
111 
117 int MXC_OWM_Reset (void);
118 
126 int MXC_OWM_TouchByte (uint8_t data);
127 
136 int MXC_OWM_WriteByte (uint8_t data);
137 
143 int MXC_OWM_ReadByte (void);
144 
152 int MXC_OWM_TouchBit (uint8_t bit);
153 
162 int MXC_OWM_WriteBit (uint8_t bit);
163 
169 int MXC_OWM_ReadBit (void);
170 
180 int MXC_OWM_Write (uint8_t* data, int len);
181 
191 int MXC_OWM_Read (uint8_t* data, int len);
192 
202 int MXC_OWM_ReadROM (uint8_t* ROMCode);
203 
212 int MXC_OWM_MatchROM (uint8_t* ROMCode);
213 
224 int MXC_OWM_ODMatchROM (uint8_t* ROMCode);
225 
232 int MXC_OWM_SkipROM (void);
233 
242 int MXC_OWM_ODSkipROM (void);
243 
250 int MXC_OWM_Resume (void);
251 
260 int MXC_OWM_SearchROM (int newSearch, uint8_t* ROMCode);
261 
267 void MXC_OWM_ClearFlags (uint32_t mask);
268 
274 unsigned MXC_OWM_GetFlags (void);
275 
281 void MXC_OWM_SetExtPullup (int enable);
282 
288 void MXC_OWM_SetOverdrive (int enable);
289 
295 void MXC_OWM_EnableInt (int flags);
296 
302 void MXC_OWM_DisableInt (int flags);
303 
312 
320 int MXC_OWM_SetInternalPullup (int enable);
321 
330 
337 
346 
354 int MXC_OWM_BitBang_Init (int initialState);
355 
362 
370 int MXC_OWM_BitBang_Write (int state);
371 
378 
379 
381 #ifdef __cplusplus
382 }
383 #endif
384 
385 #endif /* _OWM_H_ */
MXC_OWM_SetInternalPullup
int MXC_OWM_SetInternalPullup(int enable)
Enables/Disables the Internal pullup.
MXC_OWM_MatchROM
int MXC_OWM_MatchROM(uint8_t *ROMCode)
Starts 1-Wire communication with Match ROM command.
mxc_owm_cfg_t::long_line_mode
uint8_t long_line_mode
Definition: owm.h:76
MXC_OWM_EXT_PU_UNUSED
@ MXC_OWM_EXT_PU_UNUSED
Definition: owm.h:67
MXC_OWM_ReadBit
int MXC_OWM_ReadBit(void)
Read one bit of data. Will block until transaction is complete.
MXC_OWM_BitBang_Disable
int MXC_OWM_BitBang_Disable(void)
Disable Bit Bang mode.
MXC_OWM_TouchBit
int MXC_OWM_TouchBit(uint8_t bit)
Send and receive one bit of data. Will block until transaction is complete.
MXC_OWM_WriteByte
int MXC_OWM_WriteByte(uint8_t data)
Write one byte of data. Will block until transaction is complete.
mxc_owm_cfg_t
Structure type for 1-Wire Master configuration.
Definition: owm.h:73
MXC_OWM_Resume
int MXC_OWM_Resume(void)
Starts 1-Wire communication with Resume command.
MXC_OWM_Reset
int MXC_OWM_Reset(void)
Send 1-Wire reset pulse. Will block until transaction is complete.
MXC_OWM_ClearFlags
void MXC_OWM_ClearFlags(uint32_t mask)
Clear interrupt flags.
MXC_OWM_BitBang_Init
int MXC_OWM_BitBang_Init(int initialState)
Prepare OWM for bit bang mode.
MXC_OWM_Read
int MXC_OWM_Read(uint8_t *data, int len)
Read multiple bytes of data. Will block until transaction is complete.
MXC_OWM_SearchROM
int MXC_OWM_SearchROM(int newSearch, uint8_t *ROMCode)
Starts 1-Wire communication with Search ROM command.
MXC_OWM_ODMatchROM
int MXC_OWM_ODMatchROM(uint8_t *ROMCode)
Starts 1-Wire communication with Overdrive Match ROM command.
MXC_OWM_BitBang_Read
int MXC_OWM_BitBang_Read(void)
Read current value of wire.
MXC_OWM_TouchByte
int MXC_OWM_TouchByte(uint8_t data)
Send and receive one byte of data. Will block until transaction is complete.
MXC_OWM_EXT_PU_ACT_LOW
@ MXC_OWM_EXT_PU_ACT_LOW
Definition: owm.h:66
MXC_OWM_EnableInt
void MXC_OWM_EnableInt(int flags)
Enables interrupts.
MXC_OWM_Shutdown
void MXC_OWM_Shutdown(void)
Shutdown OWM module.
MXC_OWM_ODSkipROM
int MXC_OWM_ODSkipROM(void)
Starts 1-Wire communication with Overdrive Skip ROM command.
MXC_OWM_BitBang_Write
int MXC_OWM_BitBang_Write(int state)
Set value of wire.
MXC_OWM_ReadROM
int MXC_OWM_ReadROM(uint8_t *ROMCode)
Starts 1-Wire communication with Read ROM command.
mxc_owm_ext_pu_t
mxc_owm_ext_pu_t
Enumeration type for specifying options for 1-Wire external pullup mode.
Definition: owm.h:64
mxc_owm_cfg_t::ext_pu_mode
mxc_owm_ext_pu_t ext_pu_mode
Definition: owm.h:75
MXC_OWM_SetSearchROMAccelerator
int MXC_OWM_SetSearchROMAccelerator(int enable)
Enable/Disable Search ROM Accelerator mode.
MXC_OWM_WriteBit
int MXC_OWM_WriteBit(uint8_t bit)
Write one bit of data. Will block until transaction is complete.
MXC_OWM_SetForcePresenceDetect
int MXC_OWM_SetForcePresenceDetect(int enable)
Enables/Disables driving of OWM_IO low during presence detection.
MXC_OWM_SetExternalPullup
int MXC_OWM_SetExternalPullup(mxc_owm_ext_pu_t ext_pu_mode)
Enables/Disables the External pullup.
MXC_OWM_SetExtPullup
void MXC_OWM_SetExtPullup(int enable)
Enables/Disables the External pullup.
MXC_OWM_SkipROM
int MXC_OWM_SkipROM(void)
Starts 1-Wire communication with Skip ROM command.
MXC_OWM_SetOverdrive
void MXC_OWM_SetOverdrive(int enable)
Enables/Disables Overdrive speed.
MXC_OWM_EXT_PU_ACT_HIGH
@ MXC_OWM_EXT_PU_ACT_HIGH
Definition: owm.h:65
MXC_OWM_SystemClockUpdated
int MXC_OWM_SystemClockUpdated(void)
Call to correct divider if system clock has changed.
MXC_OWM_GetFlags
unsigned MXC_OWM_GetFlags(void)
Get interrupt flags.
MXC_OWM_ReadByte
int MXC_OWM_ReadByte(void)
Read one byte of data. Will block until transaction is complete.
MXC_OWM_DisableInt
void MXC_OWM_DisableInt(int flags)
Disables interrupts.
MXC_OWM_Write
int MXC_OWM_Write(uint8_t *data, int len)
Write multiple bytes of data. Will block until transaction is complete.
mxc_owm_cfg_t::int_pu_en
uint8_t int_pu_en
Definition: owm.h:74
MXC_OWM_Init
int MXC_OWM_Init(const mxc_owm_cfg_t *cfg)
Initialize and enable OWM module.