mcp794xx.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /****************************************************************************
  2. * include/nuttx/timers/mcp794xx.h
  3. *
  4. * Copyright (C) 2019 Abdelatif Guettouche. All rights reserved.
  5. * Author: 2019 Abdelatif Guettouche <abdelatif.guettouche@gmail.com>
  6. *
  7. * This file is a part of NuttX:
  8. *
  9. * Copyright (C) 2019 Gregory Nutt. All rights reserved.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. *
  15. * 1. Redistributions of source code must retain the above copyright
  16. * notice, this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright
  18. * notice, this list of conditions and the following disclaimer in
  19. * the documentation and/or other materials provided with the
  20. * distribution.
  21. * 3. Neither the name NuttX nor the names of its contributors may be
  22. * used to endorse or promote products derived from this software
  23. * without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  26. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  27. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  28. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  29. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  30. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  31. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  32. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  33. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  34. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  35. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. ****************************************************************************/
  39. #ifndef __INCLUDE_NUTTX_TIMERS_MCP794XX_H
  40. #define __INCLUDE_NUTTX_TIMERS_MCP794XX_H
  41. /****************************************************************************
  42. * Included Files
  43. ****************************************************************************/
  44. #include <nuttx/config.h>
  45. #ifdef CONFIG_RTC_MCP794XX
  46. /****************************************************************************
  47. * Public Function Prototypes
  48. ****************************************************************************/
  49. #ifdef __cplusplus
  50. #define EXTERN extern "C"
  51. extern "C"
  52. {
  53. #else
  54. #define EXTERN extern
  55. #endif
  56. /****************************************************************************
  57. * Name: mcp794xx_rtc_initialize
  58. *
  59. * Description:
  60. * Initialize the hardware RTC per the selected configuration. This
  61. * function is called once during the OS initialization sequence by board-
  62. * specific logic.
  63. *
  64. * After mcp794xx_rtc_initialize() is called, the OS function
  65. * clock_synchronize() should also be called to synchronize the system
  66. * timer to a hardware RTC. That operation is normally performed
  67. * automatically by the system during clock initialization. However, when
  68. * an external RTC is used, the board logic will need to explicitly re-
  69. * synchronize the system timer to the RTC when the RTC becomes available.
  70. *
  71. * Input Parameters:
  72. * i2c - An instance of the I2C interface used to access the MCP794XX
  73. * device
  74. * addr - The (7-bit) I2C address of the MCP794XX device
  75. *
  76. * Returned Value:
  77. * Zero (OK) on success; a negated errno on failure
  78. *
  79. ****************************************************************************/
  80. struct i2c_master_s; /* Forward reference */
  81. int mcp794xx_rtc_initialize(FAR struct i2c_master_s *i2c, uint8_t addr);
  82. #undef EXTERN
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif /* CONFIG_RTC_MCP794XX */
  87. #endif /* __INCLUDE_NUTTX_TIMERS_MCP794XX_H */