am_hal_otp.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //*****************************************************************************
  2. //
  3. // am_hal_otp.h
  4. //! @file
  5. //!
  6. //! @brief Functions for handling the OTP interface.
  7. //
  8. //*****************************************************************************
  9. //*****************************************************************************
  10. //
  11. // Copyright (c) 2017, Ambiq Micro
  12. // All rights reserved.
  13. //
  14. // Redistribution and use in source and binary forms, with or without
  15. // modification, are permitted provided that the following conditions are met:
  16. //
  17. // 1. Redistributions of source code must retain the above copyright notice,
  18. // this list of conditions and the following disclaimer.
  19. //
  20. // 2. Redistributions in binary form must reproduce the above copyright
  21. // notice, this list of conditions and the following disclaimer in the
  22. // documentation and/or other materials provided with the distribution.
  23. //
  24. // 3. Neither the name of the copyright holder nor the names of its
  25. // contributors may be used to endorse or promote products derived from this
  26. // software without specific prior written permission.
  27. //
  28. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  29. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  31. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  32. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  34. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  35. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  36. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  37. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  38. // POSSIBILITY OF SUCH DAMAGE.
  39. //
  40. // This is part of revision 1.2.11 of the AmbiqSuite Development Package.
  41. //
  42. //*****************************************************************************
  43. #ifndef AM_HAL_OTP_H
  44. #define AM_HAL_OTP_H
  45. //*****************************************************************************
  46. //
  47. // Define some OTP values and macros.
  48. //
  49. //*****************************************************************************
  50. #define AM_HAL_OTP_SIG0 0x00
  51. #define AM_HAL_OTP_SIG1 0x04
  52. #define AM_HAL_OTP_SIG2 0x08
  53. #define AM_HAL_OTP_SIG3 0x0C
  54. #define AM_HAL_OTP_DBGR_O 0x10
  55. #define AM_HAL_OTP_WRITPROT0_O 0x20
  56. #define AM_HAL_OTP_WRITPROT1_O 0x24
  57. #define AM_HAL_OTP_COPYPROT0_O 0x30
  58. #define AM_HAL_OTP_COPYPROT1_O 0x34
  59. #define AM_HAL_OTP_ADDR 0x50020000
  60. #define AM_HAL_OTP_DBGRPROT_ADDR (AM_HAL_OTP_ADDR + AM_HAL_OTP_DBGR_O)
  61. #define AM_HAL_OTP_WRITPROT_ADDR (AM_HAL_OTP_ADDR + AM_HAL_OTP_WRITPROT0_O)
  62. #define AM_HAL_OTP_COPYPROT_ADDR (AM_HAL_OTP_ADDR + AM_HAL_OTP_COPYPROT0_O)
  63. #define AM_HAL_OTP_CHUNKSIZE (16*1024)
  64. //
  65. // Debugger port lockout macros.
  66. //
  67. #define AM_OTP_DBGR_LOCKOUT_S (0)
  68. #define AM_OTP_DBGR_LOCKOUT_M (0x1 << AM_OTP_DBGR_LOCKOUT_S)
  69. #define AM_OTP_STRM_LOCKOUT_S (1)
  70. #define AM_OTP_STRM_LOCKOUT_M (0x1 << AM_OTP_STRM_LOCKOUT_S)
  71. #define AM_OTP_SRAM_LOCKOUT_S (2)
  72. #define AM_OTP_SRAM_LOCKOUT_M (0x1 << AM_OTP_SRAM_LOCKOUT_S)
  73. #ifdef __cplusplus
  74. extern "C"
  75. {
  76. #endif
  77. //*****************************************************************************
  78. //
  79. // Function prototypes
  80. //
  81. //*****************************************************************************
  82. extern int am_hal_otp_is_debugger_lockedout(void);
  83. extern int am_hal_otp_debugger_lockout(void);
  84. extern int am_hal_otp_sram_lockout(void);
  85. extern int am_hal_otp_set_copy_protection(uint32_t u32BegAddr, uint32_t u32EndAddr);
  86. extern int am_hal_otp_set_write_protection(uint32_t u32BegAddr, uint32_t u32EndAddr);
  87. #ifdef __cplusplus
  88. }
  89. #endif
  90. #endif // AM_HAL_OTP_H
  91. //*****************************************************************************
  92. //
  93. // End Doxygen group.
  94. //! @}
  95. //
  96. //*****************************************************************************