osal_snv.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /**************************************************************************************************
  2. Phyplus Microelectronics Limited confidential and proprietary.
  3. All rights reserved.
  4. IMPORTANT: All rights of this software belong to Phyplus Microelectronics
  5. Limited ("Phyplus"). Your use of this Software is limited to those
  6. specific rights granted under the terms of the business contract, the
  7. confidential agreement, the non-disclosure agreement and any other forms
  8. of agreements as a customer or a partner of Phyplus. You may not use this
  9. Software unless you agree to abide by the terms of these agreements.
  10. You acknowledge that the Software may not be modified, copied,
  11. distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
  12. (BLE) integrated circuit, either as a product or is integrated into your
  13. products. Other than for the aforementioned purposes, you may not use,
  14. reproduce, copy, prepare derivative works of, modify, distribute, perform,
  15. display or sell this Software and/or its documentation for any purposes.
  16. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  17. PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  18. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  19. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  20. PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
  21. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  22. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  23. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  24. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  25. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  26. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  27. **************************************************************************************************/
  28. /**************************************************************************************************
  29. Filename: osal_snv.h
  30. Revised:
  31. Revision:
  32. Description: This module defines the OSAL simple non-volatile memory functions.
  33. **************************************************************************************************/
  34. #ifndef OSAL_SNV_H
  35. #define OSAL_SNV_H
  36. #include "comdef.h"
  37. #ifdef __cplusplus
  38. extern "C"
  39. {
  40. #endif
  41. /*********************************************************************
  42. * INCLUDES
  43. */
  44. //#include "hal_types.h"
  45. /*********************************************************************
  46. * CONSTANTS
  47. */
  48. /*********************************************************************
  49. * MACROS
  50. */
  51. /*********************************************************************
  52. * TYPEDEFS
  53. */
  54. #ifdef OSAL_SNV_UINT16_ID
  55. typedef uint16 osalSnvId_t;
  56. typedef uint16 osalSnvLen_t;
  57. #else
  58. typedef uint8 osalSnvId_t;
  59. typedef uint8 osalSnvLen_t;
  60. #endif
  61. /*********************************************************************
  62. * GLOBAL VARIABLES
  63. */
  64. /*********************************************************************
  65. * FUNCTIONS
  66. */
  67. /*********************************************************************
  68. * @fn osal_snv_init
  69. *
  70. * @brief Initialize NV service.
  71. *
  72. * @return SUCCESS if initialization succeeds. FAILURE, otherwise.
  73. */
  74. extern uint8 osal_snv_init( void );
  75. /*********************************************************************
  76. * @fn osal_snv_read
  77. *
  78. * @brief Read data from NV.
  79. *
  80. * @param id - Valid NV item Id.
  81. * @param len - Length of data to read.
  82. * @param *pBuf - Data is read into this buffer.
  83. *
  84. * @return SUCCESS if successful.
  85. * Otherwise, NV_OPER_FAILED for failure.
  86. */
  87. extern uint8 osal_snv_read( osalSnvId_t id, osalSnvLen_t len, void *pBuf);
  88. /*********************************************************************
  89. * @fn osal_snv_write
  90. *
  91. * @brief Write a data item to NV.
  92. *
  93. * @param id - Valid NV item Id.
  94. * @param len - Length of data to write.
  95. * @param *pBuf - Data to write.
  96. *
  97. * @return SUCCESS if successful, NV_OPER_FAILED if failed.
  98. */
  99. extern uint8 osal_snv_write( osalSnvId_t id, osalSnvLen_t len, void *pBuf);
  100. /*********************************************************************
  101. * @fn osal_snv_compact
  102. *
  103. * @brief Compacts NV if its usage has reached a specific threshold.
  104. *
  105. * @param threshold - compaction threshold
  106. *
  107. * @return SUCCESS if successful,
  108. * NV_OPER_FAILED if failed, or
  109. * INVALIDPARAMETER if threshold invalid.
  110. */
  111. extern uint8 osal_snv_compact( uint8 threshold );
  112. /*********************************************************************
  113. *********************************************************************/
  114. #ifdef __cplusplus
  115. }
  116. #endif
  117. #endif /* OSAL_SNV.H */