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.
 
 
 
 
 
 

100 lines
3.1 KiB

  1. /***************************************************************************
  2. * Copyright (C) 2005 by Dominic Rath *
  3. * Dominic.Rath@gmx.de *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation; either version 2 of the License, or *
  8. * (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License *
  16. * along with this program; if not, write to the *
  17. * Free Software Foundation, Inc., *
  18. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  19. ***************************************************************************/
  20. #ifndef STM32X_H
  21. #define STM32X_H
  22. #include "flash.h"
  23. #include "target.h"
  24. typedef struct stm32x_options_s
  25. {
  26. u16 RDP;
  27. u16 user_options;
  28. u16 protection[4];
  29. } stm32x_options_t;
  30. typedef struct stm32x_flash_bank_s
  31. {
  32. stm32x_options_t option_bytes;
  33. working_area_t *write_algorithm;
  34. int probed;
  35. } stm32x_flash_bank_t;
  36. /* stm32x register locations */
  37. #define STM32_FLASH_ACR 0x40022000
  38. #define STM32_FLASH_KEYR 0x40022004
  39. #define STM32_FLASH_OPTKEYR 0x40022008
  40. #define STM32_FLASH_SR 0x4002200C
  41. #define STM32_FLASH_CR 0x40022010
  42. #define STM32_FLASH_AR 0x40022014
  43. #define STM32_FLASH_OBR 0x4002201C
  44. #define STM32_FLASH_WRPR 0x40022020
  45. /* option byte location */
  46. #define STM32_OB_RDP 0x1FFFF800
  47. #define STM32_OB_USER 0x1FFFF802
  48. #define STM32_OB_DATA0 0x1FFFF804
  49. #define STM32_OB_DATA1 0x1FFFF806
  50. #define STM32_OB_WRP0 0x1FFFF808
  51. #define STM32_OB_WRP1 0x1FFFF80A
  52. #define STM32_OB_WRP2 0x1FFFF80C
  53. #define STM32_OB_WRP3 0x1FFFF80E
  54. /* FLASH_CR register bits */
  55. #define FLASH_PG (1<<0)
  56. #define FLASH_PER (1<<1)
  57. #define FLASH_MER (1<<2)
  58. #define FLASH_OPTPG (1<<4)
  59. #define FLASH_OPTER (1<<5)
  60. #define FLASH_STRT (1<<6)
  61. #define FLASH_LOCK (1<<7)
  62. #define FLASH_OPTWRE (1<<9)
  63. /* FLASH_SR regsiter bits */
  64. #define FLASH_BSY (1<<0)
  65. #define FLASH_PGERR (1<<2)
  66. #define FLASH_WRPRTERR (1<<4)
  67. #define FLASH_EOP (1<<5)
  68. /* STM32_FLASH_OBR bit definitions (reading) */
  69. #define OPT_ERROR 0
  70. #define OPT_READOUT 1
  71. #define OPT_RDWDGSW 2
  72. #define OPT_RDRSTSTOP 3
  73. #define OPT_RDRSTSTDBY 4
  74. /* register unlock keys */
  75. #define KEY1 0x45670123
  76. #define KEY2 0xCDEF89AB
  77. typedef struct stm32x_mem_layout_s {
  78. u32 sector_start;
  79. u32 sector_size;
  80. } stm32x_mem_layout_t;
  81. #endif /* STM32X_H */