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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /******************************************************************************
  2. * @file eeprom_emul.h
  3. * @author MCD Application Team
  4. * @version V1.2.6
  5. * @date 04-November-2016
  6. * @brief This file contains all the functions prototypes for the EEPROM
  7. * emulation firmware library.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * Copyright © 2016 STMicroelectronics International N.V.
  12. * All rights reserved.</center></h2>
  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. Redistribution of source code must retain the above copyright notice,
  18. * this list of conditions and the following disclaimer.
  19. * 2. Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * 3. Neither the name of STMicroelectronics nor the names of other
  23. * contributors to this software may be used to endorse or promote products
  24. * derived from this software without specific written permission.
  25. * 4. This software, including modifications and/or derivative works of this
  26. * software, must execute solely and exclusively on microcontroller or
  27. * microprocessor devices manufactured by or for STMicroelectronics.
  28. * 5. Redistribution and use of this software other than as permitted under
  29. * this license is void and will automatically terminate your rights under
  30. * this license.
  31. *
  32. * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
  33. * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
  34. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  35. * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
  36. * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
  37. * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  38. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  39. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  40. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  41. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  42. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  43. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44. *
  45. ******************************************************************************/
  46. #pragma once
  47. // ------------------------
  48. // Includes
  49. // ------------------------
  50. #include "../../inc/MarlinConfig.h"
  51. /* Exported constants --------------------------------------------------------*/
  52. /* EEPROM emulation firmware error codes */
  53. #define EE_OK uint32_t(HAL_OK)
  54. #define EE_ERROR uint32_t(HAL_ERROR)
  55. #define EE_BUSY uint32_t(HAL_BUSY)
  56. #define EE_TIMEOUT uint32_t(HAL_TIMEOUT)
  57. /* Define the size of the sectors to be used */
  58. #define PAGE_SIZE uint32_t(0x4000) /* Page size = 16KByte */
  59. /* Device voltage range supposed to be [2.7V to 3.6V], the operation will
  60. be done by word */
  61. #define VOLTAGE_RANGE uint8_t(VOLTAGE_RANGE_3)
  62. /* EEPROM start address in Flash */
  63. #ifdef STM32F7
  64. #define EEPROM_START_ADDRESS uint32_t(0x08100000) /* EEPROM emulation start address:
  65. from sector2 : after 16KByte of used
  66. Flash memory */
  67. #else
  68. #define EEPROM_START_ADDRESS uint32_t(0x08078000) /* EEPROM emulation start address:
  69. after 480KByte of used Flash memory */
  70. #endif
  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 functions ------------------------------------------------------- */
  95. uint16_t EE_Initialize();
  96. uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data);
  97. uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data);
  98. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/