1
0

lpc_eeprom.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /**********************************************************************
  2. * $Id$ lpc_eeprom.h 2011-06-02
  3. *//**
  4. * @file lpc_eeprom.h
  5. * @brief Contains all macro definitions and function prototypes
  6. * support for EEPROM firmware library on LPC
  7. * @version 1.0
  8. * @date 02. June. 2011
  9. * @author NXP MCU SW Application Team
  10. *
  11. * Copyright(C) 2011, NXP Semiconductor
  12. * All rights reserved.
  13. *
  14. ***********************************************************************
  15. * Software that is described herein is for illustrative purposes only
  16. * which provides customers with programming information regarding the
  17. * products. This software is supplied "AS IS" without any warranties.
  18. * NXP Semiconductors assumes no responsibility or liability for the
  19. * use of the software, conveys no license or title under any patent,
  20. * copyright, or mask work right to the product. NXP Semiconductors
  21. * reserves the right to make changes in the software without
  22. * notification. NXP Semiconductors also make no representation or
  23. * warranty that such application will be suitable for the specified
  24. * use without further testing or modification.
  25. * Permission to use, copy, modify, and distribute this software and its
  26. * documentation is hereby granted, under NXP Semiconductors'
  27. * relevant copyright in the software, without fee, provided that it
  28. * is used in conjunction with NXP Semiconductors microcontrollers. This
  29. * copyright, permission, and disclaimer notice must appear in all copies of
  30. * this code.
  31. **********************************************************************/
  32. /* Peripheral group ----------------------------------------------------------- */
  33. /** @defgroup EEPROM EEPROM (Electrically Erasable Programmable Read-Only Memory)
  34. * @ingroup LPC_CMSIS_FwLib_Drivers
  35. * @{
  36. */
  37. #ifndef __LPC_EEPROM_H_
  38. #define __LPC_EEPROM_H_
  39. /* Includes ------------------------------------------------------------------- */
  40. #include "LPC407x_8x_177x_8x.h"
  41. #include "lpc_types.h"
  42. #ifdef __cplusplus
  43. extern "C"
  44. {
  45. #endif
  46. /* Private macros ------------------------------------------------------------- */
  47. /** @defgroup EEPROM_Private_Macros EEPROM Private Macros
  48. * @{
  49. */
  50. /* -------------------------- BIT DEFINITIONS --------------------------------- */
  51. /*********************************************************************//**
  52. * Macro defines for EEPROM command register
  53. **********************************************************************/
  54. #define EEPROM_CMD_8_BIT_READ (0)
  55. #define EEPROM_CMD_16_BIT_READ (1)
  56. #define EEPROM_CMD_32_BIT_READ (2)
  57. #define EEPROM_CMD_8_BIT_WRITE (3)
  58. #define EEPROM_CMD_16_BIT_WRITE (4)
  59. #define EEPROM_CMD_32_BIT_WRITE (5)
  60. #define EEPROM_CMD_ERASE_PRG_PAGE (6)
  61. #define EEPROM_CMD_RDPREFETCH (1<<3)
  62. #define EEPROM_PAGE_SIZE 64
  63. #define EEPROM_PAGE_NUM 63
  64. /*********************************************************************//**
  65. * Macro defines for EEPROM address register
  66. **********************************************************************/
  67. #define EEPROM_PAGE_OFFSET(n) (n&0x3F)
  68. #define EEPROM_PAGE_ADRESS(n) ((n&0x3F)<<6)
  69. /*********************************************************************//**
  70. * Macro defines for EEPROM write data register
  71. **********************************************************************/
  72. #define EEPROM_WDATA_8_BIT(n) (n&0x000000FF)
  73. #define EEPROM_WDATA_16_BIT(n) (n&0x0000FFFF)
  74. #define EEPROM_WDATA_32_BIT(n) (n&0xFFFFFFFF)
  75. /*********************************************************************//**
  76. * Macro defines for EEPROM read data register
  77. **********************************************************************/
  78. #define EEPROM_RDATA_8_BIT(n) (n&0x000000FF)
  79. #define EEPROM_RDATA_16_BIT(n) (n&0x0000FFFF)
  80. #define EEPROM_RDATA_32_BIT(n) (n&0xFFFFFFFF)
  81. /*********************************************************************//**
  82. * Macro defines for EEPROM power down register
  83. **********************************************************************/
  84. #define EEPROM_PWRDWN (1<<0)
  85. #define EEPROM_ENDOF_RW (26)
  86. #define EEPROM_ENDOF_PROG (28)
  87. /**
  88. * @}
  89. */
  90. /* Public Types --------------------------------------------------------------- */
  91. /** @defgroup EEPROM_Public_Types EEPROM Public Types
  92. * @{
  93. */
  94. typedef enum
  95. {
  96. MODE_8_BIT = 0,
  97. MODE_16_BIT,
  98. MODE_32_BIT
  99. }EEPROM_Mode_Type;
  100. /**
  101. * @}
  102. */
  103. /* Public Functions ----------------------------------------------------------- */
  104. /** @defgroup EEPROM_Public_Functions EEPROM Public Functions
  105. * @{
  106. */
  107. void EEPROM_Init(void);
  108. void EEPROM_Write(uint16_t page_offset, uint16_t page_address, void* data, EEPROM_Mode_Type mode, uint32_t size);
  109. void EEPROM_Read(uint16_t page_offset, uint16_t page_address, void* data, EEPROM_Mode_Type mode, uint32_t size);
  110. void EEPROM_Erase(uint16_t address);
  111. void EEPROM_PowerDown(FunctionalState NewState);
  112. /**
  113. * @}
  114. */
  115. #ifdef __cplusplus
  116. }
  117. #endif
  118. #endif /* __LPC_EEPROM_H_ */
  119. /**
  120. * @}
  121. */
  122. /* --------------------------------- End Of File ------------------------------ */