air105_otp.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (c) 2022 OpenLuat & AirM2M
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  5. * this software and associated documentation files (the "Software"), to deal in
  6. * the Software without restriction, including without limitation the rights to
  7. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  8. * the Software, and to permit persons to whom the Software is furnished to do so,
  9. * subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in all
  12. * copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  16. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  17. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  18. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. */
  21. #ifndef __AIR105_OTP_H
  22. #define __AIR105_OTP_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "air105.h"
  28. /* Exported types ------------------------------------------------------------*/
  29. typedef enum
  30. {
  31. OTP_Complete = 0,
  32. OTP_ReadOnProgramOrSleep, //�ڱ�̡�����״̬�¶�OTP���ж�����
  33. OTP_ProgramIn_HiddenOrRO_Block, //��ֻ�������б��
  34. OTP_ProgramOutOfAddr, //��̷�Χ����OTP��Χ
  35. OTP_ProgramOnSleep, //������״̬���б�̲���
  36. OTP_WakeUpOnNoSleep, //�ڷ�����״̬�½��л��Ѳ���
  37. OTP_TimeOut, //OTP��ɱ�־λ��ʱû����λ
  38. OTP_DataWrong,
  39. }OTP_StatusTypeDef;
  40. #define IS_OTP_ADDRESS(ADDRESS) (((ADDRESS) > AIR105_OTP_SIZE - 1) && ((ADDRESS) < AIR105_OTP_BASE + AIR105_OTP_SIZE))
  41. void OTP_WakeUp(void);
  42. void OTP_Unlock(void);
  43. void OTP_Lock(void);
  44. void OTP_ClearStatus(void);
  45. void OTP_SetLatency(uint8_t u8_1UsClk, uint8_t u8_10NsCLK);
  46. void OTP_TimCmd(FunctionalState NewState);
  47. void OTP_SetProtect(uint32_t u32Addr);
  48. void OTP_SetProtectLock(uint32_t u32Addr);
  49. void OTP_UnProtect(uint32_t u32Addr);
  50. uint32_t OTP_GetProtect(void);
  51. uint32_t OTP_GetProtectLock(void);
  52. void OTP_PowerOn(void);
  53. Boolean OTP_IsReadReady(void);
  54. Boolean OTP_IsWriteDone(void);
  55. OTP_StatusTypeDef OTP_GetFlag(void);
  56. Boolean OTP_IsProtect(uint32_t u32Addr);
  57. Boolean OTP_IsProtectLock(uint32_t u32Addr);
  58. OTP_StatusTypeDef OTP_WriteWord(uint32_t addr, uint32_t w);
  59. #ifdef __cplusplus
  60. }
  61. #endif
  62. #endif