資源描述:
《STM32 固件庫的使用.doc》由會員上傳分享,免費在線閱讀,更多相關內容在行業(yè)資料-天天文庫。
1、2012-03-1410:40iarforstm32固件庫的學習筆記系統(tǒng)、源程序文件和頭文件命名都以“stm32f10x-”作為開頭寄存器作為常量處理外設函數(shù)的命名以外設的縮寫加下劃線開頭每個單詞的開頭字母大寫每個函數(shù)名只有一個下劃線分隔外設縮寫和函數(shù)名的其他部分ppp_Init:::根據(jù)PPP_InitTypeDef中指定的參數(shù),初始化外設PPP。PPP_DeInit::::復位外設PPP的所有寄存器至缺省值PPP_StructInit:::其功能為通過設置PPP_InitTypeDef結構中的各種參數(shù)來定義外設的功能PPP_Cmd:::使能或失能外設PPPPPP_ITConfig:::為
2、使能或者失能來自外設PPP某中斷源PPP_DMAConfig:::失能或者使能外設PPP的DMA接口用以配置外設功能的函數(shù)總是以字符串“Config”結尾PPP_GetFlagStatus:::檢查外設PPP某標志位被設置與否PPP_ClearFlag:::清楚外設PPP標志位PPP_GetITStatus:::判斷來自外設PPP的中斷發(fā)生與否PPP_ClearITPendingBit:::清除外設PPP中斷待處理標志位typedefsignedlongs32;typedefsignedshorts16;typedefsignedchars8;typedefsignedlongconstsc
3、32;/*ReadOnly*/typedefsignedshortconstsc16;/*ReadOnly*/typedefsignedcharconstsc8;/*ReadOnly*/typedefvolatilesignedlongvs32;typedefvolatilesignedshortvs16;typedefvolatilesignedcharvs8;typedefvolatilesignedlongconstvsc32;/*ReadOnly*/typedefvolatilesignedshortconstvsc16;/*ReadOnly*/typedefvolatilesign
4、edcharconstvsc8;/*ReadOnly*/typedefunsignedlongu32;typedefunsignedshortu16;typedefunsignedcharu8;typedefunsignedlongconstuc32;/*ReadOnly*/typedefunsignedshortconstuc16;/*ReadOnly*/typedefunsignedcharconstuc8;/*ReadOnly*/typedefvolatileunsignedlongvu32;typedefvolatileunsignedshortvu16;typedefvolatil
5、eunsignedcharvu8;typedefvolatileunsignedlongconstvuc32;/*ReadOnly*/typedefvolatileunsignedshortconstvuc16;/*ReadOnly*/typedefvolatileunsignedcharconstvuc8;/*ReadOnly*/stm32f10x_type.h文件中布爾型變量typedefenum{FALSE=0,TRUE=!FALSE}bool;標志位狀態(tài)類型SET&RESETtypedefenum{RESET=0,SET=!RESET}FlagStatus;功能狀態(tài)類型ENABLE&
6、DISABLEtypedefenum{DISABLE=0,ENABLE=!DISABLE}FunctionalState;錯誤狀態(tài)類型SUCCESSorERRORtypedefenum{ERROR=0,SUCCESS=!ERROR}ErrorStatus;stm32f10x_map.h文件包含了所有外設控制寄存器的結構,下例為SPI寄存器結構的聲明:/*------------------SerialPeripheralInterface----------------*/typedefstruct{vu16CR1;u16RESERVED0;vu16CR2;u16RESERVED1;vu16
7、SR;u16RESERVED2;vu16DR;u16RESERVED3;vu16CRCPR;u16RESERVED4;vu16RXCRCR;u16RESERVED5;vu16TXCRCR;u16RESERVED6;}SPI_TypeDef;RESERVEDi(i為一個整數(shù)索引值)表示被保留區(qū)域stm32f10x_map.h函數(shù)包含了所有的外設聲明,下例為spi外設的聲明:#ifndefEXT#DefineEX