My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

eeprom_emul.h 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /**
  2. ******************************************************************************
  3. * @file EEPROM/EEPROM_Emulation/inc/eeprom.h
  4. * @author MCD Application Team
  5. * @version V1.2.6
  6. * @date 04-November-2016
  7. * @brief This file contains all the functions prototypes for the EEPROM
  8. * emulation firmware library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; Copyright © 2016 STMicroelectronics International N.V.
  13. * All rights reserved.</center></h2>
  14. *
  15. * Redistribution and use in source and binary forms, with or without
  16. * modification, are permitted, provided that the following conditions are met:
  17. *
  18. * 1. Redistribution of source code must retain the above copyright notice,
  19. * this list of conditions and the following disclaimer.
  20. * 2. Redistributions in binary form must reproduce the above copyright notice,
  21. * this list of conditions and the following disclaimer in the documentation
  22. * and/or other materials provided with the distribution.
  23. * 3. Neither the name of STMicroelectronics nor the names of other
  24. * contributors to this software may be used to endorse or promote products
  25. * derived from this software without specific written permission.
  26. * 4. This software, including modifications and/or derivative works of this
  27. * software, must execute solely and exclusively on microcontroller or
  28. * microprocessor devices manufactured by or for STMicroelectronics.
  29. * 5. Redistribution and use of this software other than as permitted under
  30. * this license is void and will automatically terminate your rights under
  31. * this license.
  32. *
  33. * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
  34. * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
  35. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  36. * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
  37. * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
  38. * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  39. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  40. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  41. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  42. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  43. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  44. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  45. *
  46. ******************************************************************************
  47. */
  48. /* Define to prevent recursive inclusion -------------------------------------*/
  49. #ifndef __EEEPROM_EMUL_H
  50. #define __EEEPROM_EMUL_H
  51. // --------------------------------------------------------------------------
  52. // Includes
  53. // --------------------------------------------------------------------------
  54. #include "../../../inc/MarlinConfig.h"
  55. #include "../../HAL.h"
  56. /* Exported constants --------------------------------------------------------*/
  57. /* EEPROM emulation firmware error codes */
  58. #define EE_OK (uint32_t)HAL_OK
  59. #define EE_ERROR (uint32_t)HAL_ERROR
  60. #define EE_BUSY (uint32_t)HAL_BUSY
  61. #define EE_TIMEOUT (uint32_t)HAL_TIMEOUT
  62. /* Define the size of the sectors to be used */
  63. #define PAGE_SIZE (uint32_t)0x4000 /* Page size = 16KByte */
  64. /* Device voltage range supposed to be [2.7V to 3.6V], the operation will
  65. be done by word */
  66. #define VOLTAGE_RANGE (uint8_t)VOLTAGE_RANGE_3
  67. /* EEPROM start address in Flash */
  68. #define EEPROM_START_ADDRESS ((uint32_t)0x08100000) /* EEPROM emulation start address:
  69. from sector2 : after 16KByte of used
  70. Flash memory */
  71. /* Pages 0 and 1 base and end addresses */
  72. #define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x0000))
  73. #define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1)))
  74. #define PAGE0_ID FLASH_SECTOR_1
  75. #define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x4000))
  76. #define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1)))
  77. #define PAGE1_ID FLASH_SECTOR_2
  78. /* Used Flash pages for EEPROM emulation */
  79. #define PAGE0 ((uint16_t)0x0000)
  80. #define PAGE1 ((uint16_t)0x0001) /* Page nb between PAGE0_BASE_ADDRESS & PAGE1_BASE_ADDRESS*/
  81. /* No valid page define */
  82. #define NO_VALID_PAGE ((uint16_t)0x00AB)
  83. /* Page status definitions */
  84. #define ERASED ((uint16_t)0xFFFF) /* Page is empty */
  85. #define RECEIVE_DATA ((uint16_t)0xEEEE) /* Page is marked to receive data */
  86. #define VALID_PAGE ((uint16_t)0x0000) /* Page containing valid data */
  87. /* Valid pages in read and write defines */
  88. #define READ_FROM_VALID_PAGE ((uint8_t)0x00)
  89. #define WRITE_IN_VALID_PAGE ((uint8_t)0x01)
  90. /* Page full define */
  91. #define PAGE_FULL ((uint8_t)0x80)
  92. /* Variables' number */
  93. #define NB_OF_VAR ((uint16_t)4096)
  94. /* Exported types ------------------------------------------------------------*/
  95. /* Exported macro ------------------------------------------------------------*/
  96. /* Exported functions ------------------------------------------------------- */
  97. uint16_t EE_Initialise(void);
  98. uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data);
  99. uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data);
  100. #endif /* __EEEPROM_H */
  101. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/