你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

【经验分享】STM32 FSMC相关函数和类型

[复制链接]
STMCU小助手 发布时间:2022-3-29 09:52
01. 概述% y' w! p. F& V5 P
FSMC 相关的库函数分布在 stm32f4xx_fsmc.c 文件和头文件 stm32f4xx_fsmc.h 中。
' k) y$ [2 p. `+ r/ Q& i, z
( H7 k+ c; W; f! `+ ?7 g02. 相关类型) S3 |+ q, ?* e
FSMC_NORSRAMTimingInitTypeDef类型
; g3 B! P! {; [: G4 Y; R, i
! U" q# H7 p1 ]' U/ d. h
  1. . o5 n$ J' }5 i/ q( ]# j/ e
  2. /** - s( b; J$ v% w2 `/ H' r) s6 ^
  3.   * @brief  Timing parameters For NOR/SRAM Banks  , A/ E2 I6 u  j  h
  4.   *// ^9 B. f/ {& w& m* A+ T
  5. typedef struct
    % _. H5 H- Y% v* V
  6. {
    5 R5 b' D# W% c" z5 v7 T1 A
  7.   uint32_t FSMC_AddressSetupTime;       /*!< Defines the number of HCLK cycles to configure
    # O$ z; g2 H: n) I+ d) S
  8.                                              the duration of the address setup time. ( |% C9 Y( Z2 j. e! V7 y' k
  9.                                              This parameter can be a value between 0 and 0xF.
    * m) H$ E2 z) y, K
  10.                                              @note This parameter is not used with synchronous NOR Flash memories. */
    5 T' o# B, |' s7 k0 E
  11. ) M7 E" r3 J5 F; k( W
  12.   uint32_t FSMC_AddressHoldTime;        /*!< Defines the number of HCLK cycles to configure" v9 ?* Q- ~  Q: B
  13.                                              the duration of the address hold time.$ {" |5 x0 u; [) K% z) `
  14.                                              This parameter can be a value between 0 and 0xF. ( ~6 E# K- ]2 A
  15.                                              @note This parameter is not used with synchronous NOR Flash memories.*/
    " x0 r; s: \$ H$ h5 p- T1 q' {
  16. 4 C  T$ V. h  N
  17.   uint32_t FSMC_DataSetupTime;          /*!< Defines the number of HCLK cycles to configure
    2 |* W2 D) ?, G
  18.                                              the duration of the data setup time.
    9 R/ o: p, N9 v" ~
  19.                                              This parameter can be a value between 0 and 0xFF.. u* e$ l9 a0 q+ k9 p$ Z
  20.                                              @note This parameter is used for SRAMs, ROMs and asynchronous multiplexed NOR Flash memories. */( H  ]# |: K# K, k. a' L

  21. & z! d1 `& L7 M/ z4 l
  22.   uint32_t FSMC_BusTurnAroundDuration;  /*!< Defines the number of HCLK cycles to configure
    $ o1 v- F+ g% W
  23.                                              the duration of the bus turnaround.
    ; J. I4 ~7 N1 z5 t
  24.                                              This parameter can be a value between 0 and 0xF.+ q" L, k; M+ h" a( e5 E# P% R2 A
  25.                                              @note This parameter is only used for multiplexed NOR Flash memories. */+ ^/ Q5 n/ P* K

  26. 8 F' T7 J( Q# d! C
  27.   uint32_t FSMC_CLKDivision;            /*!< Defines the period of CLK clock output signal, expressed in number of HCLK cycles.# P. w7 {0 j9 s
  28.                                              This parameter can be a value between 1 and 0xF.
    7 j- U: z, v7 `1 k% {- i. ^
  29.                                              @note This parameter is not used for asynchronous NOR Flash, SRAM or ROM accesses. */
    5 Q! C3 b# g6 x+ p

  30. 4 Q. C: s( y# Z% B. s( l
  31.   uint32_t FSMC_DataLatency;            /*!< Defines the number of memory clock cycles to issue: S4 v  g% k# n) s- n9 |9 O0 d
  32.                                              to the memory before getting the first data.0 b, \. H/ o0 r
  33.                                              The parameter value depends on the memory type as shown below:
    + t3 M5 B  L" |' H5 `- F4 b
  34.                                               - It must be set to 0 in case of a CRAM+ o! U5 f( N3 @5 ^
  35.                                               - It is don't care in asynchronous NOR, SRAM or ROM accesses+ G; D4 C0 P6 o; ~5 w  U- v
  36.                                               - It may assume a value between 0 and 0xF in NOR Flash memories
    ( F2 ~1 x* u% W  h( @. ]9 m
  37.                                                 with synchronous burst mode enable */8 q. N$ s* t  C9 |
  38. - [$ x) r, s# x* r
  39.   uint32_t FSMC_AccessMode;             /*!< Specifies the asynchronous access mode.
    % z. p: c$ f. s) L7 q( s5 u3 \
  40.                                              This parameter can be a value of @ref FSMC_Access_Mode */
      @% |6 F- Z0 s4 A9 _
  41. }FSMC_NORSRAMTimingInitTypeDef;
复制代码

% |; i$ S4 x9 C3 DFSMC_NORSRAMInitTypeDef类型2 j2 N3 g. N8 p. X: [$ |( K! y8 V* b
  V" B9 N3 d1 ^, k8 C: }" {
  1. /**
    # u' j& M0 p  W# V2 u
  2.   * @brief  FSMC NOR/SRAM Init structure definition; ?* X9 z, L3 z; [( F
  3.   */! g, `4 G: r$ W5 i9 k
  4. typedef struct( R2 Q( Y' ^/ ^$ U2 R7 `
  5. {
    ) w# K+ f3 p3 U' n9 n$ E1 y9 g% ?
  6.   uint32_t FSMC_Bank;                /*!< Specifies the NOR/SRAM memory bank that will be used.0 O6 P+ o! F  _9 f( E
  7.                                           This parameter can be a value of @ref FSMC_NORSRAM_Bank */! s3 n* Y5 I  S6 Z& l" `: K

  8. # ]; A/ n& X7 I. c" I5 O0 r# _
  9.   uint32_t FSMC_DataAddressMux;      /*!< Specifies whether the address and data values are/ R, @; ~% @, _7 @2 n( ~
  10.                                           multiplexed on the data bus or not.
    7 d2 i4 d7 _! t( u4 |- r% U+ H# B
  11.                                           This parameter can be a value of @ref FSMC_Data_Address_Bus_Multiplexing */
    7 Y; z6 [$ H0 G+ x5 ]6 K; _' X
  12. 3 {. V- h6 o/ Q- ^8 _3 ~
  13.   uint32_t FSMC_MemoryType;          /*!< Specifies the type of external memory attached to  `4 _9 u6 L: q: f
  14.                                           the corresponding memory bank.2 O7 r* m$ `* N5 Z' ?
  15.                                           This parameter can be a value of @ref FSMC_Memory_Type */" A/ }( z5 Y! V
  16. 9 g3 M0 l/ U( w# d3 ~
  17.   uint32_t FSMC_MemoryDataWidth;     /*!< Specifies the external memory device width.
    4 i; L- `8 ]0 K4 |! w: {
  18.                                           This parameter can be a value of @ref FSMC_Data_Width */
    $ P; f, i. ]% ^+ G( e

  19. ( W- v* s/ E) ^; q& l3 _
  20.   uint32_t FSMC_BurstAccessMode;     /*!< Enables or disables the burst access mode for Flash memory,* N: g9 D5 `& a$ V# l
  21.                                           valid only with synchronous burst Flash memories.
    6 n) J% `# M  F. j* `* ?  s+ V
  22.                                           This parameter can be a value of @ref FSMC_Burst_Access_Mode */
    8 `, D4 N# z, o+ M- G- Q) [
  23. ; p" ?5 v4 F3 G8 \+ B* K& a, V
  24.   uint32_t FSMC_AsynchronousWait;     /*!< Enables or disables wait signal during asynchronous transfers,- Y6 s: v0 p8 ^% r5 S# y8 o
  25.                                           valid only with asynchronous Flash memories.2 H* c2 B) I) ^% W. y2 p  S3 x2 j
  26.                                           This parameter can be a value of @ref FSMC_AsynchronousWait */                                          2 i) _! @2 h4 `  d& Q

  27. % G4 W' `: }" d, i; F
  28.   uint32_t FSMC_WaitSignalPolarity;  /*!< Specifies the wait signal polarity, valid only when accessing; C1 G* K7 g$ l5 t/ K$ J0 Q/ A- h  P
  29.                                           the Flash memory in burst mode." d# v9 R$ ^) U) Y% V
  30.                                           This parameter can be a value of @ref FSMC_Wait_Signal_Polarity */& i# a* ^' {+ f' T

  31. ' U5 M: |) l, A8 a$ }
  32.   uint32_t FSMC_WrapMode;            /*!< Enables or disables the Wrapped burst access mode for Flash) f( o% t' ]8 ]4 H9 T8 f. z
  33.                                           memory, valid only when accessing Flash memories in burst mode.  W; \9 W3 O' Q/ z
  34.                                           This parameter can be a value of @ref FSMC_Wrap_Mode */
    2 X# U+ S/ j$ t, @2 y

  35. % g/ V$ p* q# c) S( S' ^/ B6 }
  36.   uint32_t FSMC_WaitSignalActive;    /*!< Specifies if the wait signal is asserted by the memory one
    - {$ z2 C) C0 w" F- v6 E( i
  37.                                           clock cycle before the wait state or during the wait state,+ B/ {- E; p! w# {2 f
  38.                                           valid only when accessing memories in burst mode.
    3 B  g. K2 ]$ ~7 Y! B' g% }6 N
  39.                                           This parameter can be a value of @ref FSMC_Wait_Timing */
    $ L" ~$ F) r# ^: Z' l

  40. ! N4 s1 x8 D1 e( b0 _" Y
  41.   uint32_t FSMC_WriteOperation;      /*!< Enables or disables the write operation in the selected bank by the FSMC.
    9 S7 l' ]: q8 a3 L) ^( R  ~
  42.                                           This parameter can be a value of @ref FSMC_Write_Operation */
    ! \. N* \; x( k! u" y) p1 i& \

  43. & H' Q! i0 f" d  v% }5 }- [6 U
  44.   uint32_t FSMC_WaitSignal;          /*!< Enables or disables the wait state insertion via wait
    2 N2 O) C; V4 |$ j8 N2 s- a
  45.                                           signal, valid for Flash memory access in burst mode.
    0 m1 [9 G- \2 q% b4 B; Y
  46.                                           This parameter can be a value of @ref FSMC_Wait_Signal */! `8 J+ n8 A; M3 E5 `% T
  47. 9 J4 H/ Y) l& T! N' ^
  48.   uint32_t FSMC_ExtendedMode;        /*!< Enables or disables the extended mode.+ Q* E" N0 \, S6 u4 t0 g
  49.                                           This parameter can be a value of @ref FSMC_Extended_Mode */
    , ~/ f% Z0 G2 Y8 `5 o

  50. / I, _; i, @- K% o2 n" P. K' _$ J
  51.   uint32_t FSMC_WriteBurst;          /*!< Enables or disables the write burst operation.
    # S5 E# A+ Y& m/ \% o4 }0 G
  52.                                           This parameter can be a value of @ref FSMC_Write_Burst */ , G* w3 p: [. B- Z
  53. , \8 z1 s& c- ?
  54.   FSMC_NORSRAMTimingInitTypeDef* FSMC_ReadWriteTimingStruct; /*!< Timing Parameters for write and read access if the  Extended Mode is not used*/  
    - d& ?8 {( g1 q! P( @& T
  55. 0 p2 A% ^& u& F9 r8 S9 P6 |  |3 Z1 O0 |2 h
  56.   FSMC_NORSRAMTimingInitTypeDef* FSMC_WriteTimingStruct;     /*!< Timing Parameters for write access if the  Extended Mode is used*/      
    % W0 w& M# z4 Y7 F+ w
  57. }FSMC_NORSRAMInitTypeDef;
复制代码
& a0 w; @* E) L* c; Z; ~
FSMC_NAND_PCCARDTimingInitTypeDef类型
- O* D0 M; R% w* F  |2 O

+ Q5 X: h/ T/ m( a! w( b3 P
  1. /**
    * l4 O# {4 _9 e' T
  2.   * @brief  Timing parameters For FSMC NAND and PCCARD Banks0 O. B* n  u. L& X
  3.   */! T3 C. _  O! k4 R! }
  4. typedef struct
    . \. l# ?: Z# g0 G, y
  5. {( N+ B- q9 ~- U3 u" `+ H# G8 U1 b
  6.   uint32_t FSMC_SetupTime;      /*!< Defines the number of HCLK cycles to setup address before
    ' h" T7 l7 Q1 u4 p- h4 R& U& e
  7.                                      the command assertion for NAND Flash read or write access
    8 E9 y7 Z8 D  n8 q4 ~/ w4 ]( ?1 q
  8.                                      to common/Attribute or I/O memory space (depending on* Y$ ^& f, Y/ F4 y( }; {3 a# y
  9.                                      the memory space timing to be configured).& I% a" y2 S+ T$ Z
  10.                                      This parameter can be a value between 0 and 0xFF.*/
    : Z: M* k* [; }, z2 X2 v

  11. 3 G$ \" F- m2 m+ n
  12.   uint32_t FSMC_WaitSetupTime;  /*!< Defines the minimum number of HCLK cycles to assert the+ [1 A$ ^' F; @, D
  13.                                      command for NAND Flash read or write access to/ S4 `% K5 E7 u  Z; `7 q# e
  14.                                      common/Attribute or I/O memory space (depending on the0 c- ~+ O8 }# Z- X+ J. {
  15.                                      memory space timing to be configured).
    6 R/ ~: g  T! _
  16.                                      This parameter can be a number between 0x00 and 0xFF */" G$ U! l3 D: \7 z8 ~. f+ B& o
  17.   i. g+ J3 W" c0 ?. }8 q+ n, D. l
  18.   uint32_t FSMC_HoldSetupTime;  /*!< Defines the number of HCLK clock cycles to hold address, ^) T1 e; w- {$ K3 z- T
  19.                                      (and data for write access) after the command de-assertion
    ( m* ~' D* q& q1 M0 Z
  20.                                      for NAND Flash read or write access to common/Attribute3 q! A' w# z! h  q; p
  21.                                      or I/O memory space (depending on the memory space timing
    ( I- A5 `( O; j+ p+ m2 u
  22.                                      to be configured).. U+ [5 \$ G$ k
  23.                                      This parameter can be a number between 0x00 and 0xFF */$ W& g4 W* M+ `% a' P

  24. & }2 ^# q0 D' O. |
  25.   uint32_t FSMC_HiZSetupTime;   /*!< Defines the number of HCLK clock cycles during which the: `) `! p4 p1 |. j) N4 z! w
  26.                                      data bus is kept in HiZ after the start of a NAND Flash
    2 p; ]9 A- U1 z* E4 x# z7 M9 s
  27.                                      write access to common/Attribute or I/O memory space (depending# Z  m& q7 h, V5 _  K# B$ G+ \1 |6 n
  28.                                      on the memory space timing to be configured).
    + n: k- ^$ r  Y* p
  29.                                      This parameter can be a number between 0x00 and 0xFF */
    $ b3 K$ r2 ^: V$ F5 r" s; p2 I
  30. }FSMC_NAND_PCCARDTimingInitTypeDef;
复制代码

% g" b) T# B% n) D; }# b6 @FSMC_NANDInitTypeDef类型3 J+ f& W" `5 u- ~7 [) a
1 R' O! ?+ H* ^0 w
  1. /**
    $ A, u' E0 h: t/ b' }4 \. R
  2.   * @brief  FSMC NAND Init structure definition
    , w3 o1 E" O% w; r
  3.   */
    " Z3 g0 x& \# O" Y' A
  4. typedef struct
    ( d$ o1 D: _: j; G1 W. m' Y2 F
  5. {
    ( U9 X8 m; P* j5 h9 ], Y2 u$ D
  6.   uint32_t FSMC_Bank;              /*!< Specifies the NAND memory bank that will be used.) z, L0 _& T& O9 d5 N
  7.                                       This parameter can be a value of @ref FSMC_NAND_Bank */
    1 y( }2 y+ T/ i8 T& i* O: i
  8. ' g7 `! ~; S  [) s" N
  9.   uint32_t FSMC_Waitfeature;      /*!< Enables or disables the Wait feature for the NAND Memory Bank./ K( Y2 ^& W% @# x8 t- F
  10.                                        This parameter can be any value of @ref FSMC_Wait_feature */
    ( r- e  \7 I; D5 d  L* T

  11. * p2 q/ N2 ?4 P4 l
  12.   uint32_t FSMC_MemoryDataWidth;  /*!< Specifies the external memory device width.3 W$ Z) A' S6 X& A; v
  13.                                        This parameter can be any value of @ref FSMC_Data_Width */
    % @5 X' h. }" J
  14. 5 X& @5 t1 p3 d2 {% W1 [
  15.   uint32_t FSMC_ECC;              /*!< Enables or disables the ECC computation.
    + I$ C; E* {  N
  16.                                        This parameter can be any value of @ref FSMC_ECC */
    # ?$ L7 ~) B1 h
  17. ) Z; ^. o1 u- ~2 J0 V
  18.   uint32_t FSMC_ECCPageSize;      /*!< Defines the page size for the extended ECC.
    & }9 A: H- s7 C! _* `
  19.                                        This parameter can be any value of @ref FSMC_ECC_Page_Size */
    3 ?# ^& U$ K$ Y" E
  20. ; d, q8 z8 V1 {0 d0 X8 I- w3 V! r& j
  21.   uint32_t FSMC_TCLRSetupTime;    /*!< Defines the number of HCLK cycles to configure the
    3 z. O0 U- b7 i. t* l
  22.                                        delay between CLE low and RE low.4 R# h* n" p6 H6 |8 |9 O5 t
  23.                                        This parameter can be a value between 0 and 0xFF. */
    : N* k1 o. \  c! ?
  24. * [5 P3 N- R8 I& R" _/ g
  25.   uint32_t FSMC_TARSetupTime;     /*!< Defines the number of HCLK cycles to configure the  \: U, ?6 l: D
  26.                                        delay between ALE low and RE low.' D# v4 a+ S1 R
  27.                                        This parameter can be a number between 0x0 and 0xFF */ / m0 A! W/ O  x0 p( [" r

  28. 1 @& u0 V. a: M& M% v1 S  I
  29.   FSMC_NAND_PCCARDTimingInitTypeDef*  FSMC_CommonSpaceTimingStruct;   /*!< FSMC Common Space Timing */ & d6 `/ P( x0 H: W

  30. ( f2 |( v: k$ s: o# E
  31.   FSMC_NAND_PCCARDTimingInitTypeDef*  FSMC_AttributeSpaceTimingStruct; /*!< FSMC Attribute Space Timing */
    % u7 S: b6 d( C2 A
  32. }FSMC_NANDInitTypeDef;
复制代码

  [% z% E9 u$ Z+ X: C: S+ FFSMC_PCCARDInitTypeDef类型

8 ~0 e, E% z0 z/ Y
( ^" y7 u5 A2 j$ j2 i, {6 v
  1. /**
    $ O# ~# o4 B* d) G& c4 |: s
  2.   * @brief  FSMC PCCARD Init structure definition
    & L% |' T# i2 |, Q, s/ x0 o
  3.   */0 f8 p0 @/ ?% q

  4. 2 ?) v) }5 p7 j! |* B2 G" R
  5. typedef struct3 T1 C/ Y; e; g6 z# O$ C
  6. {! E3 R- c2 B+ G! I7 Q
  7.   uint32_t FSMC_Waitfeature;    /*!< Enables or disables the Wait feature for the Memory Bank.& Y4 a& @+ T- h3 p, X2 N0 c
  8.                                     This parameter can be any value of @ref FSMC_Wait_feature */
    $ n8 b# j4 C4 V! I8 x5 l) T  l2 K) T+ i

  9. % Q2 Q& z0 q' @9 Q3 H7 z! I
  10.   uint32_t FSMC_TCLRSetupTime;  /*!< Defines the number of HCLK cycles to configure the
    $ t) u: k4 E( F# Q! W3 v# L: z
  11.                                      delay between CLE low and RE low.
    ! B8 f3 N+ ^' {) C& ?' ?  B
  12.                                      This parameter can be a value between 0 and 0xFF. */
    " ~2 _, ~9 l  h# m$ q( l
  13. 6 d# N- v- d' v5 h$ O) P% v
  14.   uint32_t FSMC_TARSetupTime;   /*!< Defines the number of HCLK cycles to configure the; O& U. L1 E5 B. ~# L/ W
  15.                                      delay between ALE low and RE low.* v* R- Z4 G; y
  16.                                      This parameter can be a number between 0x0 and 0xFF */ / ^  |1 p, O" O" f6 g- h) I
  17. 7 d, x! h9 t# D4 |# F, u/ F. i/ N. J
  18. # ]- }4 S  M8 v* T; ?. q2 ^
  19.   FSMC_NAND_PCCARDTimingInitTypeDef*  FSMC_CommonSpaceTimingStruct; /*!< FSMC Common Space Timing */& u7 J1 [# N; Y3 m" E
  20. & y& z% o. _) t
  21.   FSMC_NAND_PCCARDTimingInitTypeDef*  FSMC_AttributeSpaceTimingStruct;  /*!< FSMC Attribute Space Timing */
    ; g* q) \, u* }+ H
  22. 3 K  E, e4 n" N) d7 t, Y
  23.   FSMC_NAND_PCCARDTimingInitTypeDef*  FSMC_IOSpaceTimingStruct; /*!< FSMC IO Space Timing */  
    0 V# Q% \4 _( z/ |- A- t
  24. }FSMC_PCCARDInitTypeDef;2 f" M6 ?# A/ U( I6 y5 r5 R
复制代码

* m" d* n- ~7 y4 v' \4 v6 J相关宏定义: d: Z6 ]9 S# _6 p7 V0 U5 J

+ ~8 l* X" s/ k4 f4 w* D
  1. /** @defgroup FSMC_Exported_Constants6 W0 q+ T7 g2 E( o+ j
  2.   * @{7 ?- ]: Q/ _" d
  3.   */
    9 o3 d( s. i- J+ U8 B' }5 M

  4. " K* ]9 x: V' Q5 }; q8 g2 p
  5. /** @defgroup FSMC_NORSRAM_Bank
    " W4 R/ B  c3 w* W! R0 `
  6.   * @{
    + w' _( Q, c6 j" ^. L- `! n
  7.   */
    , p( ?6 d7 Q" w+ |# \# g2 S% h
  8. #define FSMC_Bank1_NORSRAM1                      ((uint32_t)0x00000000)
    ) J+ r4 N0 C$ m9 N. X( b* a$ i
  9. #define FSMC_Bank1_NORSRAM2                      ((uint32_t)0x00000002)
    ; X) r( d% l, }% G% l( T
  10. #define FSMC_Bank1_NORSRAM3                      ((uint32_t)0x00000004)$ P* O3 M2 H8 t% ?
  11. #define FSMC_Bank1_NORSRAM4                      ((uint32_t)0x00000006)- t7 y  W. {* a$ y, _/ `: T( p% ^
  12. /**4 p& \" j- B- f- I% F' F# q
  13.   * @}
    4 M& `/ x) F" R
  14.   */
    1 I6 m/ \5 F. h) R/ E6 j0 k

  15. : [  e5 g9 e. R4 m8 V
  16. /** @defgroup FSMC_NAND_Bank / n* H, f+ e; f9 k& b# N( G
  17.   * @{5 n% i/ x9 t% ]8 W% ~0 }7 D
  18.   */  
    . B1 N, p7 \- `, i
  19. #define FSMC_Bank2_NAND                          ((uint32_t)0x00000010)4 H! @' N8 [! `* E  F: d4 S3 ^
  20. #define FSMC_Bank3_NAND                          ((uint32_t)0x00000100)
    " _' z; z! e0 K: k
  21. /**" I, i& `( g% z' L
  22.   * @}
    2 n8 X1 s9 ^9 g, R; C$ g! D; p
  23.   */
    0 i  d+ N: }5 H; ^& c+ h6 P: D: s

  24. " g" k! l3 x6 {9 E. ~6 E  g) m
  25. /** @defgroup FSMC_PCCARD_Bank
    8 _+ K4 [* v+ r6 v6 m7 `6 D7 T, U% s
  26.   * @{: \+ D- ~; a5 s/ Q
  27.   */   
    4 u* N8 u* k4 D- B7 N* [4 T6 n8 S# H# g
  28. #define FSMC_Bank4_PCCARD                        ((uint32_t)0x00001000)3 t; h" T7 @- J. \  o0 \% a
  29. /**
    5 m; v9 e! g) \5 D  }/ a& Z0 u5 p( x
  30.   * @}. ^/ y5 a, P0 @: R
  31.   */1 Y1 Q/ X' L/ |6 \7 x! \' y/ n
  32. . ^! g7 |1 g) H
  33. #define IS_FSMC_NORSRAM_BANK(BANK) (((BANK) == FSMC_Bank1_NORSRAM1) || \
    ( k7 o  ~$ Q/ C; E) a5 l: {
  34.                                     ((BANK) == FSMC_Bank1_NORSRAM2) || \$ K' c: j0 V6 e/ C3 r1 j# i0 m
  35.                                     ((BANK) == FSMC_Bank1_NORSRAM3) || \$ N& o7 H: Y9 a
  36.                                     ((BANK) == FSMC_Bank1_NORSRAM4))
    % M$ ?" i: Q3 F

  37.   }/ n9 M5 u6 z$ e% c, `) J
  38. #define IS_FSMC_NAND_BANK(BANK) (((BANK) == FSMC_Bank2_NAND) || \6 y% i( j$ d' p
  39.                                  ((BANK) == FSMC_Bank3_NAND))
    8 P- `$ U! W- v. s. o
  40. 6 X3 V6 ^0 {4 z6 F
  41. #define IS_FSMC_GETFLAG_BANK(BANK) (((BANK) == FSMC_Bank2_NAND) || \% |1 R/ I& }" ]5 S/ _$ u
  42.                                     ((BANK) == FSMC_Bank3_NAND) || \
    2 T3 q8 H( B3 c. p
  43.                                     ((BANK) == FSMC_Bank4_PCCARD))
    1 O' @0 j2 P8 V& z2 `; Y* C
  44. , J3 c- K5 g5 N, a8 k
  45. #define IS_FSMC_IT_BANK(BANK) (((BANK) == FSMC_Bank2_NAND) || \
    % x- X7 E0 ^2 o! J4 `/ _" M
  46.                                ((BANK) == FSMC_Bank3_NAND) || \# J6 y+ R/ _3 ~% A% F5 }
  47.                                ((BANK) == FSMC_Bank4_PCCARD))
    # M8 {7 t8 D1 C5 m4 Y- u

  48. % S/ W! s" a! ?6 o
  49. /** @defgroup FSMC_NOR_SRAM_Controller " k; O8 A2 e0 j4 q( U: c0 [& e
  50.   * @{' u3 H) r* [4 J5 n* i' K8 Y+ Q
  51.   */5 W: b5 @% t: l  B" O- K/ G
  52. ! ?) J' |" R6 M' A) ]
  53. /** @defgroup FSMC_Data_Address_Bus_Multiplexing
    * S& a4 t! s( P8 R. p6 \
  54.   * @{
    . O) _8 s3 }# F) s
  55.   */
    6 F$ Z0 U! L0 n6 e- X
  56. * o1 g; A( i% Q8 N5 ]5 D# V
  57. #define FSMC_DataAddressMux_Disable                ((uint32_t)0x00000000)
    * C( @; b8 L8 l3 {& O' ^
  58. #define FSMC_DataAddressMux_Enable                 ((uint32_t)0x00000002)' G  y  ]% U/ S
  59. #define IS_FSMC_MUX(MUX) (((MUX) == FSMC_DataAddressMux_Disable) || \6 O& C4 j7 c6 @* I& w; r5 Y" x
  60.                           ((MUX) == FSMC_DataAddressMux_Enable))
    . ]! {, W. t# b) U
  61. /**$ b) t% G5 Y# ^# X7 \$ j7 l
  62.   * @}. C) J. R6 H) \
  63.   */5 [& X, E/ A7 h( V

  64. - D; w6 n) J: U, d* y8 ?+ @
  65. /** @defgroup FSMC_Memory_Type
    7 \- I3 x, z. q) c4 X$ \- _. M
  66.   * @{
    $ A7 Y3 w* V$ Z! U6 }6 k5 q5 S
  67.   *// D/ @) T9 }3 }

  68. - l7 E3 d8 S! T2 x
  69. #define FSMC_MemoryType_SRAM                     ((uint32_t)0x00000000)
    2 {) b) W- a$ Y$ L5 |, n5 f
  70. #define FSMC_MemoryType_PSRAM                    ((uint32_t)0x00000004)
    0 B& j1 R* a7 t2 y' T
  71. #define FSMC_MemoryType_NOR                      ((uint32_t)0x00000008)5 t! f' i8 F* N3 |9 G
  72. #define IS_FSMC_MEMORY(MEMORY) (((MEMORY) == FSMC_MemoryType_SRAM) || \
    ) x$ q; M5 f9 |4 L9 X; y2 {
  73.                                 ((MEMORY) == FSMC_MemoryType_PSRAM)|| \" p4 J  a# s) e' h2 T
  74.                                 ((MEMORY) == FSMC_MemoryType_NOR))
    8 h9 I! b, K8 ]9 L; Z
  75. /**
    - I1 b9 [) f7 M5 I' S' `
  76.   * @}" R' p* C. h( l6 U$ [" Q+ j- H9 G
  77.   */$ S9 F6 e# q6 x: i" t$ H2 t* J

  78. % |  i+ y  s: ^/ U+ x4 a  Z
  79. /** @defgroup FSMC_Data_Width * R2 U! @, M% g  g1 W
  80.   * @{
    1 M2 L# v. h1 |" \5 n* c) G
  81.   */( V/ j5 y5 \5 ?" ?' |! N9 Z8 M, H

  82. " D2 r0 O; u* ~# V
  83. #define FSMC_MemoryDataWidth_8b                  ((uint32_t)0x00000000)
    ; P$ e+ E+ f! ?' {& t
  84. #define FSMC_MemoryDataWidth_16b                 ((uint32_t)0x00000010)3 [8 {3 t; P( O- ^( _$ r; Y
  85. #define IS_FSMC_MEMORY_WIDTH(WIDTH) (((WIDTH) == FSMC_MemoryDataWidth_8b) || \/ M$ k- }$ r6 A& w4 `! Y
  86.                                      ((WIDTH) == FSMC_MemoryDataWidth_16b))
    0 R& ?% m7 o" A# y8 x4 U
  87. /**
    : }' h$ X* f4 |9 R, u
  88.   * @}7 E0 s0 n3 D1 g; U, m
  89.   */
    3 |, O7 r) t! ?- m$ K+ k
  90. 3 y9 X; k3 y+ L; @8 ?5 E6 w
  91. /** @defgroup FSMC_Burst_Access_Mode
    9 K  U# n5 O' F7 S) Z" @
  92.   * @{
    ; U8 e4 b4 j8 X$ q# p
  93.   */# O+ g2 C. F6 D! h& h- V! I! V# C

  94. % f4 K( L/ @5 `, ~% o3 F
  95. #define FSMC_BurstAccessMode_Disable             ((uint32_t)0x00000000) 8 R4 H3 u6 Q. |$ G2 W( p
  96. #define FSMC_BurstAccessMode_Enable              ((uint32_t)0x00000100)# J+ F. A: c& L! Y$ o2 S* h6 e
  97. #define IS_FSMC_BURSTMODE(STATE) (((STATE) == FSMC_BurstAccessMode_Disable) || \3 n9 A1 Z. h9 }$ X% Z
  98.                                   ((STATE) == FSMC_BurstAccessMode_Enable))
    $ l1 J9 A7 x( u0 Q% @) P2 X. [
  99. /**
    $ P6 z9 a/ E4 e. N  Z6 |5 U% H
  100.   * @}
    : m# Z6 ^% H" ~7 b: ?/ b
  101.   */
    , U4 f# W* s$ g9 b3 x1 n

  102. + o9 n$ N% @1 |9 b9 Z; {1 X' P! ]
  103. /** @defgroup FSMC_AsynchronousWait
    , Y/ _! [" v- y! c4 v
  104.   * @{
    + W7 D0 Z5 }. G+ M$ ~
  105.   */6 Y3 o8 d. }: n: h- [4 z, w6 v. C
  106. #define FSMC_AsynchronousWait_Disable            ((uint32_t)0x00000000)- g, O* n' S. c' ?8 B$ p: Z
  107. #define FSMC_AsynchronousWait_Enable             ((uint32_t)0x00008000)1 L9 _( N( A% o
  108. #define IS_FSMC_ASYNWAIT(STATE) (((STATE) == FSMC_AsynchronousWait_Disable) || \
    , x4 o# g* n) y
  109.                                  ((STATE) == FSMC_AsynchronousWait_Enable))
    / I. a( w3 g( H0 a* N2 j1 A& w
  110. /**
    ) q" e* ?0 ^% s, A4 G; ?
  111.   * @}
    , R9 I3 o3 o9 F/ J. S3 \. x
  112.   */5 W- z% D( i9 o7 N, t$ r& e& _( u

  113. & Z, _4 F+ r8 _" P# b' n( E9 V
  114. /** @defgroup FSMC_Wait_Signal_Polarity 6 V$ L6 o2 P& E7 D5 E& h
  115.   * @{* M. ]$ D1 z, c
  116.   */# `8 S3 ~! |& j( o  W) I8 K
  117. #define FSMC_WaitSignalPolarity_Low              ((uint32_t)0x00000000)
    ' @& G& {( _4 m6 i3 f/ `
  118. #define FSMC_WaitSignalPolarity_High             ((uint32_t)0x00000200)1 |) s: T1 k0 D2 n
  119. #define IS_FSMC_WAIT_POLARITY(POLARITY) (((POLARITY) == FSMC_WaitSignalPolarity_Low) || \' I7 M( d2 e( u9 c& @
  120.                                          ((POLARITY) == FSMC_WaitSignalPolarity_High))
    3 b! ]7 S: b" h# c: T# l
  121. /**
    * R+ g9 A; u; h, D6 ~9 d. S& l
  122.   * @}
    # y8 z. J* Z, t3 I
  123.   *// v& E2 g# T) V; F" N7 c. a* g
  124. + v* W2 D1 ?2 L3 ?
  125. /** @defgroup FSMC_Wrap_Mode . p. V- D$ p0 W2 N9 p
  126.   * @{$ e# K4 `+ X7 n! B, r( O  I
  127.   */
    5 H- I) `, {8 ~6 D' p+ x/ z  P  H
  128. #define FSMC_WrapMode_Disable                    ((uint32_t)0x00000000)+ R' u# a0 Y6 g; \1 c! \
  129. #define FSMC_WrapMode_Enable                     ((uint32_t)0x00000400) 7 }4 \2 y6 R# U4 Y. e
  130. #define IS_FSMC_WRAP_MODE(MODE) (((MODE) == FSMC_WrapMode_Disable) || \/ Y+ h& @6 A! W! F- |
  131.                                  ((MODE) == FSMC_WrapMode_Enable))7 o  ?7 a, ^+ Y* b8 m5 D- x
  132. /**
    ' J, w' C: v$ U, ]6 P9 x
  133.   * @}& o7 s0 }' |- ^$ |: ]
  134.   */, `1 x- Y+ _' u3 c

  135. ( q0 a, F$ X  I: a
  136. /** @defgroup FSMC_Wait_Timing
    & C% e8 m* g: k( q, p
  137.   * @{% {4 W2 Q" b- I) M1 g
  138.   */
    3 R# h( p1 h8 s+ j2 d
  139. #define FSMC_WaitSignalActive_BeforeWaitState    ((uint32_t)0x00000000)
    - U, D% r! j/ b  `. V4 e
  140. #define FSMC_WaitSignalActive_DuringWaitState    ((uint32_t)0x00000800) 4 U8 m- r; s4 D
  141. #define IS_FSMC_WAIT_SIGNAL_ACTIVE(ACTIVE) (((ACTIVE) == FSMC_WaitSignalActive_BeforeWaitState) || \
    8 W& \5 H3 S3 ]
  142.                                             ((ACTIVE) == FSMC_WaitSignalActive_DuringWaitState))
    , E! h+ ]; n* n" Q$ o
  143. /**
    4 g* u& C# L9 q5 L6 w$ N% R+ l
  144.   * @}
    . i) f* o: F: Z
  145.   */
    " m+ c* E5 `) k/ G6 j% M. U7 u$ W

  146. 9 ~; F" B$ h) V& Q$ G) q
  147. /** @defgroup FSMC_Write_Operation + W0 V2 d, D" x+ c, s0 Q
  148.   * @{8 f0 f4 j6 J  I
  149.   */
    - y" J' [: t/ O9 B
  150. #define FSMC_WriteOperation_Disable                     ((uint32_t)0x00000000)) k5 b) P, p- t. N; O
  151. #define FSMC_WriteOperation_Enable                      ((uint32_t)0x00001000)
      _. G; R# U, V9 E& C
  152. #define IS_FSMC_WRITE_OPERATION(OPERATION) (((OPERATION) == FSMC_WriteOperation_Disable) || \
    . ^! f0 S. O2 j
  153.                                             ((OPERATION) == FSMC_WriteOperation_Enable))                        
    " w) K+ \4 S6 B9 {& y
  154. /**+ D/ j/ b6 \* V* [& {
  155.   * @}& @; P: U7 l3 k# M
  156.   */" T% X: m% R/ W0 x6 r

  157. 7 b1 M1 D0 \# a4 Q  i
  158. /** @defgroup FSMC_Wait_Signal
    " ^6 v, \: H7 ~
  159.   * @{7 `$ V6 @  D' b$ v
  160.   */0 q6 @* e% T( {# h' Q$ N
  161. #define FSMC_WaitSignal_Disable                  ((uint32_t)0x00000000)* T% m; T5 [4 x/ ?  O9 H
  162. #define FSMC_WaitSignal_Enable                   ((uint32_t)0x00002000) 3 ~9 T8 V/ o; w: F6 q( X% w5 a
  163. #define IS_FSMC_WAITE_SIGNAL(SIGNAL) (((SIGNAL) == FSMC_WaitSignal_Disable) || \
    / {, b2 l) ^1 _( s! x/ _% h& I
  164.                                       ((SIGNAL) == FSMC_WaitSignal_Enable))
    4 V7 ]5 T  v5 e
  165. /**5 O5 Z+ d) K/ v, p+ m/ F$ t& Y
  166.   * @}
    5 p0 s- g# d5 w6 T8 C
  167.   */
    2 r" R; {$ N! Z

  168. ( ^  I& h/ {2 j( M3 \6 z* b
  169. /** @defgroup FSMC_Extended_Mode $ d) G6 q2 ?, C  w* g& B
  170.   * @{% `4 @! Y/ c' f1 i* w' F
  171.   */
    % {& G/ A" K& W
  172. #define FSMC_ExtendedMode_Disable                ((uint32_t)0x00000000)& J1 @& l. w) l" P& w
  173. #define FSMC_ExtendedMode_Enable                 ((uint32_t)0x00004000)
    + E. A6 O8 S6 L; e: N% g7 n
  174. ! {; o7 ~3 W$ z5 g
  175. #define IS_FSMC_EXTENDED_MODE(MODE) (((MODE) == FSMC_ExtendedMode_Disable) || \# j( y2 ^2 ?, y" m" |, G1 d  N& m
  176.                                      ((MODE) == FSMC_ExtendedMode_Enable)) 4 K; g# J, Z3 K
  177. /**+ c4 V! I% I" c- k( M5 y
  178.   * @}
    . o% g% s+ Y! a
  179.   */. T! O7 @! l% d, A6 \

  180. . F- U/ W! B' F# ^1 g( Q& X8 g
  181. /** @defgroup FSMC_Write_Burst : L) Z/ x0 J9 C$ T& a
  182.   * @{" T7 Y2 O* z4 K) g  v7 \
  183.   */
    ( ^5 f8 I2 K  s" Y+ h5 v0 @" g

  184. 9 w! K. R9 X9 ?6 V1 a9 R3 b
  185. #define FSMC_WriteBurst_Disable                  ((uint32_t)0x00000000)
    7 R# r4 ^) D& f5 A
  186. #define FSMC_WriteBurst_Enable                   ((uint32_t)0x00080000)
    - v+ r  A$ T5 @: R* Z
  187. #define IS_FSMC_WRITE_BURST(BURST) (((BURST) == FSMC_WriteBurst_Disable) || \2 z9 p6 P: E* ~  x/ T3 q  ]8 I) a
  188.                                     ((BURST) == FSMC_WriteBurst_Enable))
    ( M* o# F7 ~) g9 L! {6 I" }
  189. /**2 }5 D& j2 g& `7 R6 \
  190.   * @}
    2 i: C: G+ t' p8 q9 F, [7 V
  191.   */
    ' g: Z4 D$ t8 a3 f: k4 Q
  192. 5 ?3 ~9 S' a4 D0 E( p$ ]
  193. /** @defgroup FSMC_Address_Setup_Time - C( u. p0 j/ G' B3 @
  194.   * @{
    0 b0 S; n$ `! d& \# ?
  195.   */* u, ~# ?2 L# L; U( A
  196. #define IS_FSMC_ADDRESS_SETUP_TIME(TIME) ((TIME) <= 0xF)
    ; V7 U! B" q7 l7 f( x
  197. /**
    0 E2 b5 e+ J& }0 p: @' C6 K
  198.   * @}
    ) X- X! B5 F1 O5 X7 o
  199.   */; X* @3 h1 `- a8 c( w* O' l- \  J
  200. % X6 `, {+ c! c% X
  201. /** @defgroup FSMC_Address_Hold_Time
    , @3 N2 \& b# Q% \! L/ p
  202.   * @{
    8 ~4 z" X* e8 c* U+ \# R
  203.   */% ~8 x3 p0 p! l/ K4 h
  204. #define IS_FSMC_ADDRESS_HOLD_TIME(TIME) ((TIME) <= 0xF)* f0 R% c/ W3 C$ k3 S$ n- r
  205. /**
    2 U: }0 W/ ~, U7 l
  206.   * @}2 e4 J6 g2 D5 T* O
  207.   */
    3 t" u0 z, D* I6 K

  208. 8 F" F: }  J9 |; {3 M
  209. /** @defgroup FSMC_Data_Setup_Time & b9 D8 K  ]" d7 Q5 t
  210.   * @{! g) ?- x6 \2 a1 z& Z0 P3 f7 j
  211.   */! h) g0 D( O' c+ _/ {
  212. #define IS_FSMC_DATASETUP_TIME(TIME) (((TIME) > 0) && ((TIME) <= 0xFF))4 }+ `0 C/ q, }! P, e
  213. /**
    6 k$ B3 {3 D& t4 G5 S- W
  214.   * @}3 }8 K3 N" y1 U0 F+ A0 C( h# k
  215.   */6 i/ m8 M* V' I, v9 l- z! i9 }
  216. , A% _. ~3 l- @: m7 f+ y2 \
  217. /** @defgroup FSMC_Bus_Turn_around_Duration
    . Q2 H: o$ D: ?+ }  L
  218.   * @{% U+ u/ G# E/ t" b
  219.   */
    3 W9 ~% t4 \5 A4 X4 w3 X8 B
  220. #define IS_FSMC_TURNAROUND_TIME(TIME) ((TIME) <= 0xF)8 t. U$ n: [7 e8 q$ B
  221. /**% H8 `( P; w. C4 ~2 k: p
  222.   * @}
    / V7 B8 {0 r  ^$ v9 V
  223.   */
    / @$ X1 u! k  X7 i
  224. : J8 D  z' g! i1 B" g4 q8 h0 L
  225. /** @defgroup FSMC_CLK_Division
    $ a& n9 G! b5 o! R9 e6 f
  226.   * @{
      m7 ?! \2 O4 M0 J( ?
  227.   */
    ! v( V: p! n# C  |( `
  228. #define IS_FSMC_CLK_DIV(DIV) ((DIV) <= 0xF)
    5 c& u" U4 p& \1 ?/ \& I
  229. /**
    6 P/ T+ e# I6 |7 ]" G: o1 ?
  230.   * @}$ {3 l5 e0 M+ W) A1 T& i* @
  231.   */2 G+ k5 g# m+ u1 A" A

  232. ( }/ O6 `, {+ G8 Q
  233. /** @defgroup FSMC_Data_Latency
    % j0 ~, x* w3 F  q' A% g* v1 A+ P
  234.   * @{
    " ?1 J0 o+ ?$ D  c5 Z% D
  235.   */
    + v" e/ m$ J$ ?8 L
  236. #define IS_FSMC_DATA_LATENCY(LATENCY) ((LATENCY) <= 0xF)- V( g" z1 J. h, B! J
  237. /**9 ]( N: `4 e5 t; H8 @4 c
  238.   * @}# ]/ s. D' `3 Y2 V6 J
  239.   */. i% j; N$ v- Q9 p! F$ h7 \

  240. 3 T3 D6 M. z. S7 i% E- ^
  241. /** @defgroup FSMC_Access_Mode 1 ?: ?% ?! A5 _% a$ q0 D
  242.   * @{
    4 I, F  h1 e7 y
  243.   */# M: x- @7 ~$ k$ T; ~! J; p: m2 o
  244. #define FSMC_AccessMode_A                        ((uint32_t)0x00000000)6 N% M% y( ]% v! ~+ X" t6 |1 Q4 D+ E! ]
  245. #define FSMC_AccessMode_B                        ((uint32_t)0x10000000) & c5 Y* X4 l1 z, v, a, F& l* w
  246. #define FSMC_AccessMode_C                        ((uint32_t)0x20000000)
    - \9 S5 R0 h" l+ k- w, q  i
  247. #define FSMC_AccessMode_D                        ((uint32_t)0x30000000)4 \" ~3 D, X, u% i) @1 r) N' U
  248. #define IS_FSMC_ACCESS_MODE(MODE) (((MODE) == FSMC_AccessMode_A) || \; J! g/ `1 {0 N8 [
  249.                                    ((MODE) == FSMC_AccessMode_B) || \9 I4 S- [: m* B5 ?
  250.                                    ((MODE) == FSMC_AccessMode_C) || \
    # Z6 A" |7 U: k
  251.                                    ((MODE) == FSMC_AccessMode_D))+ p" |( J5 e" ^. C
  252. /**# W4 Y6 q5 z- ]5 w8 F1 M8 Z
  253.   * @}8 U+ ?, L0 V; B+ X: T1 H6 x) v
  254.   */" p$ D, H% J* Z- K: j$ K

  255. 4 B. A, E% u8 j+ Y9 B+ }2 j* |
  256. /**
    1 G- M/ D; \+ A5 t/ \
  257.   * @}4 h% S6 Y3 q9 ~. {
  258.   */& `0 N' G1 c. G6 a
  259. 4 E' J! `- g0 q/ k* F( M) L$ b
  260. /** @defgroup FSMC_NAND_PCCARD_Controller ( `8 r8 P9 O6 p; f$ {) ]
  261.   * @{: O: d( i# \0 l/ V; ]* I5 H- x. z
  262.   */# O& l% Q9 S  q% ~* ]

  263. " h! R( K* {2 Z5 Z9 ?( A: m6 R
  264. /** @defgroup FSMC_Wait_feature 4 I" B* E/ U! w% k% Y/ ~
  265.   * @{$ ?7 F# e- z' A& X2 ~
  266.   */
    2 T! c& ]% X! b, @
  267. #define FSMC_Waitfeature_Disable                 ((uint32_t)0x00000000)" L0 l& G3 |$ {& B  w- I
  268. #define FSMC_Waitfeature_Enable                  ((uint32_t)0x00000002)# f7 Z; S3 a; c
  269. #define IS_FSMC_WAIT_FEATURE(FEATURE) (((FEATURE) == FSMC_Waitfeature_Disable) || \6 m" M; h3 R) r. }% p. a
  270.                                        ((FEATURE) == FSMC_Waitfeature_Enable))& I1 _' _' t( A
  271. /**  M9 x) F: x9 h8 o& [- R9 q5 R
  272.   * @}
    6 s# M  ~* g5 l) |/ w) l  ]
  273.   */1 Q7 d  E$ \8 d! B+ Z

  274. 4 g! l& q2 Y1 @* N5 G( j6 {# x
  275. , {, p/ u+ o( m7 v9 i: h$ D
  276. /** @defgroup FSMC_ECC
    : V) k. C* R8 J
  277.   * @{/ ^3 y2 Q5 {) W7 W- o
  278.   */8 k/ v6 e2 V( h$ w# |' m3 k4 \
  279. #define FSMC_ECC_Disable                         ((uint32_t)0x00000000)
    7 F! _3 e  s) }. G8 W9 k
  280. #define FSMC_ECC_Enable                          ((uint32_t)0x00000040)* ?4 c5 W) A# ^
  281. #define IS_FSMC_ECC_STATE(STATE) (((STATE) == FSMC_ECC_Disable) || \9 M2 r' h8 U5 |4 L
  282.                                   ((STATE) == FSMC_ECC_Enable))
    . S7 y  P% D% M
  283. /**  |" ]2 c( }- X0 i: W4 f2 L
  284.   * @}
    7 e) j# E4 d. ?% h5 T: h  Z
  285.   */
    ; T5 Z0 R5 j- _2 [# E4 Q' O6 g

  286. 8 G6 c' O# i1 N. m+ V" q6 z
  287. /** @defgroup FSMC_ECC_Page_Size % n: A! m5 E: E+ i3 g* y( L
  288.   * @{" p  u0 J. Y( K4 o; J
  289.   */
    2 B9 ~# T  D" k3 W* p& a
  290. #define FSMC_ECCPageSize_256Bytes                ((uint32_t)0x00000000), B' e% O; @% y6 e9 a
  291. #define FSMC_ECCPageSize_512Bytes                ((uint32_t)0x00020000)
    ; [9 \7 D8 C# G
  292. #define FSMC_ECCPageSize_1024Bytes               ((uint32_t)0x00040000)
    9 ^5 r8 a7 m. O0 h: P0 b9 I
  293. #define FSMC_ECCPageSize_2048Bytes               ((uint32_t)0x00060000)% \: x+ p7 {: Q, C- v! J7 @
  294. #define FSMC_ECCPageSize_4096Bytes               ((uint32_t)0x00080000)$ Q' @5 u2 ?: o' C% c) j
  295. #define FSMC_ECCPageSize_8192Bytes               ((uint32_t)0x000A0000)7 p7 t9 X" I8 W/ N# W1 R5 k8 D
  296. #define IS_FSMC_ECCPAGE_SIZE(SIZE) (((SIZE) == FSMC_ECCPageSize_256Bytes) || \
    2 T6 Q8 \: i" c2 c) G
  297.                                     ((SIZE) == FSMC_ECCPageSize_512Bytes) || \
    ' Q$ ?" d( P3 s7 K! q
  298.                                     ((SIZE) == FSMC_ECCPageSize_1024Bytes) || \* H0 g. J4 u6 f% |# X
  299.                                     ((SIZE) == FSMC_ECCPageSize_2048Bytes) || \' E7 G! r9 q5 }$ `5 c$ g
  300.                                     ((SIZE) == FSMC_ECCPageSize_4096Bytes) || \+ O9 N1 K5 ~( w5 o
  301.                                     ((SIZE) == FSMC_ECCPageSize_8192Bytes))
    : h+ q+ i3 H# l! Y: m
  302. /**
    # \% E; [& V6 o( a: @( q
  303.   * @}
    # X3 C. @/ C& B7 |
  304.   */6 C6 z! c$ Y1 q+ S! J
  305. 2 ]$ X! e: s' E% ?. W
  306. /** @defgroup FSMC_TCLR_Setup_Time
      {1 c8 H2 d3 v) t# ^) d0 p' b; O
  307.   * @{
    - q8 O7 X; N( A+ J# [, @; w1 Y
  308.   *// o' v% l) C& i; p; j( v, T+ L1 z5 L
  309. #define IS_FSMC_TCLR_TIME(TIME) ((TIME) <= 0xFF)
    ; A* A1 X! y1 m, N: N
  310. /**+ T8 N. S4 {6 q# x) d+ H
  311.   * @}' r2 A3 q+ K' R5 u
  312.   */% U) J. f- l. r
  313. , U4 k* Q& b3 R* k
  314. /** @defgroup FSMC_TAR_Setup_Time ; o: O# l: [9 o6 q2 G
  315.   * @{
    5 O2 u/ K  o1 I
  316.   */1 ]( X3 t- N5 T5 E2 ]9 u
  317. #define IS_FSMC_TAR_TIME(TIME) ((TIME) <= 0xFF)
    3 Z* J) ]( l7 ^, }
  318. /**3 L/ A/ w# k% G5 c
  319.   * @}
      S. m2 R, [  Y9 c
  320.   */4 g5 j4 G3 C( ^; C# Y) D; I

  321. 7 p" K) \# W7 V$ p8 v8 i# Y
  322. /** @defgroup FSMC_Setup_Time 2 u" W* q( m3 p8 i" g. R- v* o
  323.   * @{9 K6 @$ I' n. O# u
  324.   */
    0 i7 Z, e' M6 C7 z* i; O
  325. #define IS_FSMC_SETUP_TIME(TIME) ((TIME) <= 0xFF)
    , C' Q& g2 ]; X; Z( V
  326. /**
    4 T( j# G5 w. c$ }& B) `
  327.   * @}4 l9 I+ n% a' s  ]
  328.   */4 R# r+ w. o3 X2 g8 H! E% l
  329. . v5 m0 h, Y4 k
  330. /** @defgroup FSMC_Wait_Setup_Time ! z' P( [' n* _8 G
  331.   * @{
    8 n1 g1 P# s, F  `* L: V
  332.   */
    + k) Z/ K' j5 e* g0 k* s, w
  333. #define IS_FSMC_WAIT_TIME(TIME) ((TIME) <= 0xFF)
    7 g" s6 }. M' C+ l( B' V
  334. /**9 t/ D* a7 J, K9 O# N$ u, C
  335.   * @}8 t/ q' k8 ~3 T6 V
  336.   */$ j8 g/ E" v! ?+ X+ \9 N: a

  337. # e0 K3 B) k1 D  ~3 Z+ h
  338. /** @defgroup FSMC_Hold_Setup_Time $ _3 E+ r& t/ ]- K, ?- z7 ?2 A9 J
  339.   * @{' k; q* p* U# ]
  340.   */
    9 U1 Q% D! R( P, f; d
  341. #define IS_FSMC_HOLD_TIME(TIME) ((TIME) <= 0xFF)
    / a* ], E5 v- g
  342. /**3 `- A' q; O1 t; s0 y) r( d* j
  343.   * @}6 L& C" a: ?6 S) a" M
  344.   */
    0 A. ]1 r2 Y9 B

  345. 8 n+ l  v/ B. w: \( O7 _7 X% m
  346. /** @defgroup FSMC_HiZ_Setup_Time
    * Q! k; f! x$ D& Y& \
  347.   * @{
    . C* Y$ e1 m8 _! W/ G5 J
  348.   */( [; F: Y( \, L6 X
  349. #define IS_FSMC_HIZ_TIME(TIME) ((TIME) <= 0xFF)$ y1 V# S- B+ ~. m& K
  350. /**
      P0 C* ?9 l, Y6 ?  a3 x. W& I2 ^
  351.   * @}, X0 ^7 Z2 e4 A. b) y% h
  352.   */
    ' o: h7 s( i) {/ D" ]

  353. " O: z9 W& g* V) a! W
  354. /** @defgroup FSMC_Interrupt_sources
    ' ]8 N, c% {9 F+ _* w
  355.   * @{
    ( }# d1 C9 K  _
  356.   */
    ; N: n0 X; a, T1 N7 j4 B
  357. #define FSMC_IT_RisingEdge                       ((uint32_t)0x00000008)
    4 t. r/ b+ s! L0 ~0 n" j" Q
  358. #define FSMC_IT_Level                            ((uint32_t)0x00000010)
    - z1 T! D1 ]5 g7 ?$ z7 m
  359. #define FSMC_IT_FallingEdge                      ((uint32_t)0x00000020)
    1 ?  G' ^) H0 F$ J, d5 L
  360. #define IS_FSMC_IT(IT) ((((IT) & (uint32_t)0xFFFFFFC7) == 0x00000000) && ((IT) != 0x00000000))
    6 z" U# M5 L5 D0 e' U4 k' X; ?' }( }
  361. #define IS_FSMC_GET_IT(IT) (((IT) == FSMC_IT_RisingEdge) || \
    + X2 o7 n) g; P8 P# M* q9 M$ N
  362.                             ((IT) == FSMC_IT_Level) || \, V  v( v, M+ v/ H
  363.                             ((IT) == FSMC_IT_FallingEdge))
    ' \/ {; j1 Q; l2 F
  364. /**
    $ N6 A4 U& y) F$ F
  365.   * @}) G& E8 F2 L; A1 f1 h- w) W, z! }( {; O
  366.   */
    / S9 O6 B! Q: [& j0 j

  367. ' h+ K0 Q. d$ \
  368. /** @defgroup FSMC_Flags
      U2 D: Q% N  v
  369.   * @{
    4 `% o2 d8 u& O; ]
  370.   */6 S6 r% l' r. }( ~* m& t% L8 V: T. a
  371. #define FSMC_FLAG_RisingEdge                     ((uint32_t)0x00000001)! j0 Q1 L7 T/ ^- ~
  372. #define FSMC_FLAG_Level                          ((uint32_t)0x00000002)9 R# A1 ~" \( q5 X6 c; q
  373. #define FSMC_FLAG_FallingEdge                    ((uint32_t)0x00000004). `- t2 J( l: v5 h8 O7 T! x5 a
  374. #define FSMC_FLAG_FEMPT                          ((uint32_t)0x00000040); }2 S' V" E* l& k; f1 g. f
  375. #define IS_FSMC_GET_FLAG(FLAG) (((FLAG) == FSMC_FLAG_RisingEdge) || \0 l# m( r; a% O( v1 a: \6 U
  376.                                 ((FLAG) == FSMC_FLAG_Level) || \
    : X+ d% Y; ?" C, ]" h, \0 Q
  377.                                 ((FLAG) == FSMC_FLAG_FallingEdge) || \  D( X4 A6 G* E( i2 m$ R, ~3 f+ b
  378.                                 ((FLAG) == FSMC_FLAG_FEMPT))
    $ W& n0 a( }  Z) ~1 i' _8 ]
  379. # ^1 T5 [/ l5 r, H3 i8 `/ r
  380. #define IS_FSMC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFFF8) == 0x00000000) && ((FLAG) != 0x00000000))+ A% k. R4 Y* H" ^* y$ P7 a
复制代码
' n# i4 ?: l8 Q% D. o7 ^
03. 相关函数
! ]: F$ y8 C+ l, x2 V, k1 N! p! H
  1. /* NOR/SRAM Controller functions **********************************************/
    $ [0 j3 V- O/ m) q, E7 Z0 x0 O$ [
  2. void FSMC_NORSRAMDeInit(uint32_t FSMC_Bank);
    7 B9 S& U& Z5 I  N2 s
  3. void FSMC_NORSRAMInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct);( t# L/ X) _# y" s
  4. void FSMC_NORSRAMStructInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct);7 @" g6 f1 m6 A) x( v- d& k
  5. void FSMC_NORSRAMCmd(uint32_t FSMC_Bank, FunctionalState NewState);( k( S+ W) x  e# }7 M( G% |: `' J' j

  6. " D% k6 C& _. R. [; G+ h  Q
  7. /* NAND Controller functions **************************************************/
    $ B2 h* ^8 M" z3 B; l/ x$ |  z1 _8 W
  8. void FSMC_NANDDeInit(uint32_t FSMC_Bank);% O: z% X1 f% y) \& \
  9. void FSMC_NANDInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct);7 q3 p3 V/ y0 E/ {  @1 s
  10. void FSMC_NANDStructInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct);
    ! F9 w3 f4 U* l0 G/ T6 _1 M! ?9 F  J
  11. void FSMC_NANDCmd(uint32_t FSMC_Bank, FunctionalState NewState);& `6 C; D' H5 a
  12. void FSMC_NANDECCCmd(uint32_t FSMC_Bank, FunctionalState NewState);0 ]+ x. R$ P6 G3 ?( e& w: }, R
  13. uint32_t FSMC_GetECC(uint32_t FSMC_Bank);# |' c5 U+ Y8 ?) a/ W8 w/ w. G

  14. ! ~5 x4 A* N' Y+ U/ |
  15. /* PCCARD Controller functions ************************************************/9 A; s" t" o  N. V' j, H
  16. void FSMC_PCCARDDeInit(void);
    % ]9 K2 D1 X! T* x2 k5 I3 Q3 z
  17. void FSMC_PCCARDInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct);
    ) O8 q: F( ~$ z. [7 L) J. m* F' D
  18. void FSMC_PCCARDStructInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct);
    ' t1 T' ?4 x2 m5 s" r+ c: `
  19. void FSMC_PCCARDCmd(FunctionalState NewState);. H/ m7 Q& Z8 p& L

  20. ! d9 X4 }8 K! u2 x7 @3 ^/ f2 [
  21. /* Interrupts and flags management functions **********************************/
    9 E3 e& X0 j7 O5 e/ A2 `
  22. void FSMC_ITConfig(uint32_t FSMC_Bank, uint32_t FSMC_IT, FunctionalState NewState);
    $ \6 A- ?( n" g! A5 k
  23. FlagStatus FSMC_GetFlagStatus(uint32_t FSMC_Bank, uint32_t FSMC_FLAG);6 r' o7 }  P5 O9 C3 u  l1 i
  24. void FSMC_ClearFlag(uint32_t FSMC_Bank, uint32_t FSMC_FLAG);3 d6 s, Q6 D9 K, Q" P  g) |
  25. ITStatus FSMC_GetITStatus(uint32_t FSMC_Bank, uint32_t FSMC_IT);
    9 h. z6 }3 z$ u! O/ @
  26. void FSMC_ClearITPendingBit(uint32_t FSMC_Bank, uint32_t FSMC_IT);
复制代码

* C) {/ M0 H/ L: p* Y% o% o6 o04. 结构体封装
0 D& q$ B$ `! P# d. h
  1. typedef struct! n0 [' M& B! z+ W- g3 @
  2. {" S$ F' Y# Y$ b! j/ H6 w
  3.   __IO uint32_t BTCR[8];    /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */     d4 Z* ^' r6 V& e0 c# }0 j7 j
  4. } FSMC_Bank1_TypeDef;
    ' N! t8 T" P& M+ z; {2 g. L* q$ V

  5. 2 y+ T- a6 g! b
  6. /**
    2 M( l% j8 K# B9 U0 r  u
  7.   * @brief Flexible Static Memory Controller Bank1E4 G( E5 P% u1 h5 I+ ?4 _
  8.   */0 w* @7 G/ U: a. g6 E; ]
  9. . C2 Q7 Q4 O7 C6 m( ]; G1 w6 L6 o' @0 u
  10. typedef struct# ]: v7 u7 v: e0 g( T' ?& z0 q' o
  11. {
    & ]; O1 Y$ M0 M/ L( k+ M
  12.   __IO uint32_t BWTR[7];    /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */2 [6 v) F% l: x- \+ K" \" c
  13. } FSMC_Bank1E_TypeDef;
    4 I& m0 h$ Z9 M% m  G8 I5 Z
  14. 6 R2 o( a+ p  d/ @
  15. /**
    9 M5 b: W9 k/ ?1 n7 S
  16.   * @brief Flexible Static Memory Controller Bank2" ^* ^7 ^. L4 l$ R. _: t
  17.   *// L$ W0 \/ |) Z4 S& d+ y

  18. " g' {$ F4 E: V2 ~4 p+ ]! N
  19. typedef struct
    : E1 O. z0 p/ ^4 O4 g% ^
  20. {
    + Q2 c7 D9 A* Q$ ^8 o; x
  21.   __IO uint32_t PCR2;       /*!< NAND Flash control register 2,                       Address offset: 0x60 */
    / n& b* c% R, [
  22.   __IO uint32_t SR2;        /*!< NAND Flash FIFO status and interrupt register 2,     Address offset: 0x64 */
    6 y9 [7 i7 m9 n+ ~
  23.   __IO uint32_t PMEM2;      /*!< NAND Flash Common memory space timing register 2,    Address offset: 0x68 */
    * N& t4 P: ]! Q$ |; d( I+ n
  24.   __IO uint32_t PATT2;      /*!< NAND Flash Attribute memory space timing register 2, Address offset: 0x6C */5 U& H0 N  B/ O+ y7 {
  25.   uint32_t      RESERVED0;  /*!< Reserved, 0x70                                                            */: @/ Z5 O5 D; f1 g
  26.   __IO uint32_t ECCR2;      /*!< NAND Flash ECC result registers 2,                   Address offset: 0x74 */
    % _0 l3 |3 N6 R
  27. } FSMC_Bank2_TypeDef;
    + v) i9 e# V! X* ~8 S& C' `

  28. & T3 j- f1 p# Q5 U
  29. /**
      Q: G, u1 v8 |6 U5 w
  30.   * @brief Flexible Static Memory Controller Bank3# m& \" p7 u5 s# b
  31.   */. m- |) I9 b0 y/ z, \

  32. $ S# H3 J( S# _& o
  33. typedef struct* q* |# \3 i$ N6 J5 W4 P# W8 q
  34. {- S% w3 g' r7 k( y) }: k; Q7 ]
  35.   __IO uint32_t PCR3;       /*!< NAND Flash control register 3,                       Address offset: 0x80 */! G( p$ ?* L) D1 g2 {
  36.   __IO uint32_t SR3;        /*!< NAND Flash FIFO status and interrupt register 3,     Address offset: 0x84 */
    * L- D  C- W- \$ i1 q  y
  37.   __IO uint32_t PMEM3;      /*!< NAND Flash Common memory space timing register 3,    Address offset: 0x88 */5 y, O  v+ B% q# _5 v6 T
  38.   __IO uint32_t PATT3;      /*!< NAND Flash Attribute memory space timing register 3, Address offset: 0x8C */
    # N% S3 {% ]! l) s
  39.   uint32_t      RESERVED0;  /*!< Reserved, 0x90                                                            */
    ( U, N. [1 \" ]8 P
  40.   __IO uint32_t ECCR3;      /*!< NAND Flash ECC result registers 3,                   Address offset: 0x94 */
    - h4 X6 k/ f* ^* h+ Q
  41. } FSMC_Bank3_TypeDef;
    7 }6 I/ N. p4 f% b) G. r* D

  42. * {( A. d2 ^0 l1 x. N) ^4 K3 J
  43. /**
    ) g8 ]0 f" A/ q: s; ~3 D* c
  44.   * @brief Flexible Static Memory Controller Bank4
    ! L2 r; J" S- M" |1 m
  45.   */
    ' z4 |+ H5 F3 B. n8 n8 x& V
  46. / y- v6 S! I, y4 U9 N. z( ~
  47. typedef struct
    - C- ~& ]/ M' G
  48. {* E9 K9 @; i, s2 ^$ r2 g
  49.   __IO uint32_t PCR4;       /*!< PC Card  control register 4,                       Address offset: 0xA0 */6 S; w7 p$ J# l9 ^
  50.   __IO uint32_t SR4;        /*!< PC Card  FIFO status and interrupt register 4,     Address offset: 0xA4 */" C4 ?  }* {  i. I: ?
  51.   __IO uint32_t PMEM4;      /*!< PC Card  Common memory space timing register 4,    Address offset: 0xA8 */
    ) W* S. u8 r6 ^$ r( u
  52.   __IO uint32_t PATT4;      /*!< PC Card  Attribute memory space timing register 4, Address offset: 0xAC */
    # Q1 U; z: j) ?, @0 u# b
  53.   __IO uint32_t PIO4;       /*!< PC Card  I/O space timing register 4,              Address offset: 0xB0 */
    ; Y% l4 V" x5 I/ V6 T3 E) s
  54. } FSMC_Bank4_TypeDef;
    ; C) m/ @  q! h: X
  55. + j9 O4 P5 i: L
复制代码

1 v, I! J7 W- r0 V+ X2 t
赞 收藏 评论0 发布时间:2022-3-29 09:52

举报

0个回答

所属标签

相似技术帖

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版