owibus_uart.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef _OWI_UART_H_
  2. #define _OWI_UART_H_
  3. /*
  4. * Copyright (C) 2012/14 by Uwe Bonnes(bon@elektron.ikp.physik.tu-darmstadt.de)
  5. *
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. Neither the name of the copyright holders nor the names of
  18. * contributors may be used to endorse or promote products derived
  19. * from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  31. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. *
  34. * For additional information see http://www.ethernut.de/
  35. */
  36. /*!
  37. * \file dev/owibus_uartif.c
  38. * \brief Header for the One-Wire API over UART Implementation.
  39. *
  40. * \verbatim
  41. * $Id: owibus_uart.h 5528 2014-01-07 18:17:58Z u_bonnes $
  42. * \endverbatim
  43. */
  44. #include <sys/device.h>
  45. /*!
  46. * \addtogroup xgOwibusUart
  47. */
  48. /*@{*/
  49. /*!
  50. * \brief Data to send on the UART for the OWI primitives.
  51. */
  52. #define OWI_UART_WRITE_RST 0xf0 /*!< \brief UART data for presence impulse. */
  53. #define OWI_UART_WRITE_ONE 0xff /*!< \brief UART data for write '1' and read. */
  54. #define OWI_UART_WRITE_ZERO 0x00 /*!< \brief UART data for write '0'. */
  55. /*!
  56. * \brief Data to expect from the UART for the OWI primitives.
  57. */
  58. #define OWI_UART_READ_ONE 0x01 /*!< \brief UART data received for read '1'. */
  59. /*! * \brief Baud rates to use for OWI primitives.
  60. */
  61. #define OWI_UART_BAUD_RESET 9600 /*!< \brief UART baudrate for presence impulse. */
  62. #define OWI_UART_BAUD_RWBIT 115200 /*!< \brief UART baudrate for RW bit. */
  63. /*!
  64. * \brief OWI runtime control block container.
  65. *
  66. * This is installed in heap at initialization.
  67. */
  68. struct _NUTOWIINFO_UART {
  69. int uart_fd;
  70. int pp_port;
  71. int pp_pin;
  72. };
  73. typedef struct _NUTOWIINFO_UART NUTOWIINFO_UART;
  74. int Uart_OwiInit(NUTOWIINFO_UART *owcb, NUTDEVICE *uart, int mode);
  75. int Uart_OwiTouchReset(NUTOWIBUS *bus);
  76. int Uart_OwiRWBit(NUTOWIBUS *bus, uint_fast8_t bit);
  77. int Uart_OwiWriteBlock(NUTOWIBUS *bus, uint8_t *data, uint_fast8_t len);
  78. int Uart_OwiReadBlock(NUTOWIBUS *bus, uint8_t *data, uint_fast8_t len);
  79. /*@}*/
  80. #endif