/* ###################################################################
**     This component module is generated by Processor Expert. Do not modify it.
**     Filename    : McuOneWire.h
**     CDE edition : Community
**     Project     : FRDM-K64F_Generator
**     Processor   : MK64FN1M0VLL12
**     Component   : OneWire
**     Version     : Component 01.154, Driver 01.00, CPU db: 3.00.000
**     Compiler    : GNU C Compiler
**     Date/Time   : 2020-01-29, 06:51, # CodeGen: 595
**     Abstract    :
**          This is a component implementing the 1-Wire protocol.
**     Settings    :
**          Component Name                                 : McuOneWire
**          Data Pin I/O                                   : SDK_BitIO
**          Write Pin                                      : Disabled
**          Timing                                         : 
**            A: Write 1 Low time (us)                     : 6
**            B: Write 1 High time (us)                    : 64
**            C: Write 0 Low time (us)                     : 60
**            D: Write 0 High time (us)                    : 10
**            E: Read delay time (us)                      : 3
**            A: Read Low time (us)                        : 6
**            F: Read delay time                           : 55
**            H: Reset low time (us)                       : 480
**            I: Reset response time (us)                  : 70
**            J: Reset wait time after reading device presence (us) : 410
**            Total slot time (us)                         : 100
**          Buffers                                        : 
**            Input                                        : RBInput
**          Debug                                          : Enabled
**            Debug Read Pin                               : SDK_BitIO
**          CriticalSection                                : McuCriticalSection
**          Utility                                        : McuUtility
**          Wait                                           : McuWait
**          SDK                                            : McuLib
**          RTOS                                           : Enabled
**            RTOS                                         : McuRTOS
**          Shell                                          : Enabled
**            Shell                                        : McuShell
**     Contents    :
**         CalcCRC       - uint8_t McuOneWire_CalcCRC(uint8_t *data, uint8_t dataSize);
**         SendByte      - uint8_t McuOneWire_SendByte(uint8_t data);
**         SendBytes     - uint8_t McuOneWire_SendBytes(uint8_t *data, uint8_t count);
**         Receive       - uint8_t McuOneWire_Receive(uint8_t counter);
**         SendReset     - uint8_t McuOneWire_SendReset(void);
**         Count         - uint8_t McuOneWire_Count(void);
**         GetBytes      - uint8_t McuOneWire_GetBytes(uint8_t *data, uint8_t count);
**         GetByte       - uint8_t McuOneWire_GetByte(uint8_t *data);
**         strcatRomCode - uint8_t McuOneWire_strcatRomCode(uint8_t *buf, size_t bufSize, uint8_t...
**         ReadRomCode   - uint8_t McuOneWire_ReadRomCode(uint8_t *romCodeBuffer);
**         ResetSearch   - void McuOneWire_ResetSearch(void);
**         TargetSearch  - void McuOneWire_TargetSearch(uint8_t familyCode);
**         Search        - bool McuOneWire_Search(uint8_t *newAddr, bool search_mode);
**         ParseCommand  - uint8_t McuOneWire_ParseCommand(const unsigned char* cmd, bool *handled,...
**         Deinit        - void McuOneWire%.Init(void) McuOneWire_Deinit(void);
**         Init          - void McuOneWire%.Init(void) McuOneWire_Init(void);
**
** * Copyright (c) Original implementation: Omar Isaí Pinales Ayala, 2014, all rights reserved.
**  * Updated and maintained by Erich Styger, 2014-2020
**  * Web:         https://mcuoneclipse.com
**  * SourceForge: https://sourceforge.net/projects/mcuoneclipse
**  * Git:         https://github.com/ErichStyger/McuOnEclipse_PEx
**  * All rights reserved.
**  *
**  * Redistribution and use in source and binary forms, with or without modification,
**  * are permitted provided that the following conditions are met:
**  *
**  * - Redistributions of source code must retain the above copyright notice, this list
**  *   of conditions and the following disclaimer.
**  *
**  * - Redistributions in binary form must reproduce the above copyright notice, this
**  *   list of conditions and the following disclaimer in the documentation and/or
**  *   other materials provided with the distribution.
**  *
**  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
**  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
**  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
**  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
**  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
**  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
**  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
**  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
**  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
**  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
** ###################################################################*/
/*!
** @file McuOneWire.h
** @version 01.00
** @brief
**          This is a component implementing the 1-Wire protocol.
*/         
/*!
**  @addtogroup McuOneWire_module McuOneWire module documentation
**  @{
*/         

#ifndef __McuOneWire_H
#define __McuOneWire_H

/* MODULE McuOneWire. */
#include "McuLib.h" /* SDK and API used */
#include "McuOneWireconfig.h" /* configuration */
#include "McuShell.h" /* Shell */
#include <stddef.h> /* for size_t */

#ifdef __cplusplus
extern "C" {
#endif

#define McuOneWire_ROM_CODE_SIZE   (8)
  /*!< Number of bytes for ROM code */

#define McuOneWire_PARSE_COMMAND_ENABLED    McuOneWire_CONFIG_PARSE_COMMAND_ENABLED
  /*!< set to 1 if method ParseCommand() is present, 0 otherwise */

/*
** ===================================================================
**     Method      :  Count (component OneWire)
**
**     Description :
**         Returns the number of elements stored on input buffer that
**         are ready to read.
**     Parameters  : None
**     Returns     :
**         ---             - number of elements
** ===================================================================
*/
uint8_t McuOneWire_Count(void);
/*
** ===================================================================
**     Method      :  Receive (component OneWire)
**
**     Description :
**         Programs a read operation after the master send all in
**         output buffer. Don't use a SendReset while the data is
**         coming.
**     Parameters  :
**         NAME            - DESCRIPTION
**         counter         - Number of bytes to receive from
**                           slave
**     Returns     :
**         ---             - error code
** ===================================================================
*/
uint8_t McuOneWire_Receive(uint8_t counter);
/*
** ===================================================================
**     Method      :  SendByte (component OneWire)
**
**     Description :
**         Sends a single byte
**     Parameters  :
**         NAME            - DESCRIPTION
**         data            - the data byte to be sent
**     Returns     :
**         ---             - error code
** ===================================================================
*/
uint8_t McuOneWire_SendByte(uint8_t data);
/*
** ===================================================================
**     Method      :  SendBytes (component OneWire)
**
**     Description :
**         Sends multiple bytes
**     Parameters  :
**         NAME            - DESCRIPTION
**       * data            - Pointer to the array of bytes
**         count           - Number of bytes to be sent
**     Returns     :
**         ---             - error code
** ===================================================================
*/
uint8_t McuOneWire_SendBytes(uint8_t *data, uint8_t count);
/*
** ===================================================================
**     Method      :  SendReset (component OneWire)
**
**     Description :
**         Sends a reset to the bus
**     Parameters  : None
**     Returns     :
**         ---             - error code
** ===================================================================
*/
uint8_t McuOneWire_SendReset(void);
/*
** ===================================================================
**     Method      :  GetByte (component OneWire)
**
**     Description :
**         Get a single byte from the bus
**     Parameters  :
**         NAME            - DESCRIPTION
**       * data            - Pointer to were to store the data
**     Returns     :
**         ---             - error code
** ===================================================================
*/
uint8_t McuOneWire_GetByte(uint8_t *data);
/*
** ===================================================================
**     Method      :  GetBytes (component OneWire)
**
**     Description :
**         Gets multiple bytes from the bus
**     Parameters  :
**         NAME            - DESCRIPTION
**       * data            - Pointer to where to store the data
**         count           - Number of bytes
**     Returns     :
**         ---             - error code
** ===================================================================
*/
uint8_t McuOneWire_GetBytes(uint8_t *data, uint8_t count);
/*
** ===================================================================
**     Method      :  Init (component OneWire)
**
**     Description :
**         Initializes this device.
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
void McuOneWire_Init(void);
void McuOneWire_Deinit(void);
/*
** ===================================================================
**     Method      :  Deinit (component OneWire)
**
**     Description :
**         Driver de-initialization
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/

uint8_t McuOneWire_CalcCRC(uint8_t *data, uint8_t dataSize);
/*
** ===================================================================
**     Method      :  CalcCRC (component OneWire)
**
**     Description :
**         Calculates the CRC over a number of bytes
**     Parameters  :
**         NAME            - DESCRIPTION
**       * data            - Pointer to data
**         dataSize        - number of data bytes
**     Returns     :
**         ---             - calculated CRC
** ===================================================================
*/

uint8_t McuOneWire_ParseCommand(const unsigned char* cmd, bool *handled, const McuShell_StdIOType *io);
/*
** ===================================================================
**     Method      :  ParseCommand (component OneWire)
**
**     Description :
**         Shell Command Line parser. Method is only available if Shell
**         is enabled in the component properties.
**     Parameters  :
**         NAME            - DESCRIPTION
**         cmd             - command string
**       * handled         - Pointer to variable which tells if
**                           the command has been handled or not
**         io              - Pointer to I/O structure
**     Returns     :
**         ---             - Error code
** ===================================================================
*/

uint8_t McuOneWire_ReadRomCode(uint8_t *romCodeBuffer);
/*
** ===================================================================
**     Method      :  ReadRomCode (component OneWire)
**
**     Description :
**         Read the ROM code. Only works with one device on the bus.
**     Parameters  :
**         NAME            - DESCRIPTION
**       * romCodeBuffer   - Pointer to a buffer
**                           with 8 bytes where the ROM code gets stored
**     Returns     :
**         ---             - Error code
** ===================================================================
*/

uint8_t McuOneWire_strcatRomCode(uint8_t *buf, size_t bufSize, uint8_t *romCode);
/*
** ===================================================================
**     Method      :  strcatRomCode (component OneWire)
**
**     Description :
**         Appends the ROM code to a string.
**     Parameters  :
**         NAME            - DESCRIPTION
**       * buf             - Pointer to zero terminated buffer
**         bufSize         - size of buffer
**       * romCode         - Pointer to 8 bytes of ROM Code
**     Returns     :
**         ---             - error code
** ===================================================================
*/

void McuOneWire_ResetSearch(void);
/*
** ===================================================================
**     Method      :  ResetSearch (component OneWire)
**
**     Description :
**         Reset the search state
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/

void McuOneWire_TargetSearch(uint8_t familyCode);
/*
** ===================================================================
**     Method      :  TargetSearch (component OneWire)
**
**     Description :
**         
**     Parameters  :
**         NAME            - DESCRIPTION
**         familyCode      - family code to restrict
**                           search for
**     Returns     : Nothing
** ===================================================================
*/

bool McuOneWire_Search(uint8_t *newAddr, bool search_mode);
/*
** ===================================================================
**     Method      :  Search (component OneWire)
**
**     Description :
**         
**     Parameters  :
**         NAME            - DESCRIPTION
**       * newAddr         - Pointer to 8 bytes of data where
**                           to store the new address
**         search_mode     - 
**     Returns     :
**         ---             - TRUE if new device has been found, FALSE
**                           otherwise.
** ===================================================================
*/

/* END McuOneWire. */

#ifdef __cplusplus
}  /* extern "C" */
#endif

#endif
/* ifndef __McuOneWire_H */
/*!
** @}
*/

