/***************************************
STM3210E LED blinky
LED : PF6~PF9
*****************************************/
#include <stm32f10x.h>
int main(void)
{
GPIO_InitTypeDef GPIO_InitStructure; //구조체 변수 선언
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF, ENABLE); //클럭 연결
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //출력설정
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; //클럭속도
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9;
GPIO_Init(GPIOF, &GPIO_InitStructure);
GPIOF->ODR &= ~(GPIO_Pin_7|GPIO_Pin_8); //LED 7,8 off
GPIOF->ODR |= GPIO_Pin_6|GPIO_Pin_9; //LED 6,9 on
while(1){
GPIOF->ODR ^= GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9; //반전
for(vu32 t=0;t<1000000;t++); //delay
}
}
----------------------------------------------------------------------------------
RCC_APB1 및 APB2 클럭 명령 함수입니다.
void RCC_APB1PeriphClockCmd ( uint32_t RCC_APB1Periph, FunctionalState NewState)
☞Enables or disables the Low Speed APB (APB1) peripheral clock.
Parameters:
RCC_APB1Periph,: specifies the APB1 peripheral to gates its clock. This parameter can be any combination of the following values:
RCC_APB1Periph_TIM2, RCC_APB1Periph_TIM3, RCC_APB1Periph_TIM4, RCC_APB1Periph_TIM5, RCC_APB1Periph_TIM6, RCC_APB1Periph_TIM7, RCC_APB1Periph_WWDG, RCC_APB1Periph_SPI2, RCC_APB1Periph_SPI3, RCC_APB1Periph_USART2, RCC_APB1Periph_USART3, RCC_APB1Periph_USART4, RCC_APB1Periph_USART5, RCC_APB1Periph_I2C1, RCC_APB1Periph_I2C2, RCC_APB1Periph_USB, RCC_APB1Periph_CAN1, RCC_APB1Periph_BKP, RCC_APB1Periph_PWR, RCC_APB1Periph_DAC, RCC_APB1Periph_CEC, RCC_APB1Periph_TIM12, RCC_APB1Periph_TIM13, RCC_APB1Periph_TIM14
NewState,: new state of the specified peripheral clock. This parameter can be: ENABLE or DISABLE.
Return values:
None
void RCC_APB2PeriphClockCmd ( uint32_t RCC_APB2Periph, FunctionalState NewState )
☞Enables or disables the High Speed APB (APB2) peripheral clock.
Parameters:
RCC_APB2Periph,: specifies the APB2 peripheral to gates its clock. This parameter can be any combination of the following values:
RCC_APB2Periph_AFIO, RCC_APB2Periph_GPIOA, RCC_APB2Periph_GPIOB, RCC_APB2Periph_GPIOC, RCC_APB2Periph_GPIOD, RCC_APB2Periph_GPIOE, RCC_APB2Periph_GPIOF, RCC_APB2Periph_GPIOG, RCC_APB2Periph_ADC1, RCC_APB2Periph_ADC2, RCC_APB2Periph_TIM1, RCC_APB2Periph_SPI1, RCC_APB2Periph_TIM8, RCC_APB2Periph_USART1, RCC_APB2Periph_ADC3, RCC_APB2Periph_TIM15, RCC_APB2Periph_TIM16, RCC_APB2Periph_TIM17, RCC_APB2Periph_TIM9, RCC_APB2Periph_TIM10, RCC_APB2Periph_TIM11
NewState,: new state of the specified peripheral clock. This parameter can be: ENABLE or DISABLE.
Return values:
None
------------------------------------------------------------------------------
GPIO_InitTypeDef 구종체입니다.
Data Fields
GPIOMode_TypeDef GPIO_Mode
uint16_t GPIO_Pin
GPIOSpeed_TypeDef GPIO_Speed
Detailed Description
GPIO Init structure definition.
-------------------------------------------------------------------------------------
enum GPIOMode_TypeDef
Configuration Mode enumeration.
Enumerator:
GPIO_Mode_AIN
GPIO_Mode_IN_FLOATING
GPIO_Mode_IPD
GPIO_Mode_IPU
GPIO_Mode_Out_OD
GPIO_Mode_Out_PP
GPIO_Mode_AF_OD
GPIO_Mode_AF_PP
-------------------------------------------------------------------------------------------
enum GPIOSpeed_TypeDef
Output Maximum frequency selection.
Enumerator:
GPIO_Speed_10MHz
GPIO_Speed_2MHz
GPIO_Speed_50MHz
--------------------------------------------------------------------------------------
GPIO_pins_define
Defines
#define GPIO_Pin_0 ((uint16_t)0x0001)
#define GPIO_Pin_1 ((uint16_t)0x0002)
#define GPIO_Pin_10 ((uint16_t)0x0400)
#define GPIO_Pin_11 ((uint16_t)0x0800)
#define GPIO_Pin_12 ((uint16_t)0x1000)
#define GPIO_Pin_13 ((uint16_t)0x2000)
#define GPIO_Pin_14 ((uint16_t)0x4000)
#define GPIO_Pin_15 ((uint16_t)0x8000)
#define GPIO_Pin_2 ((uint16_t)0x0004)
#define GPIO_Pin_3 ((uint16_t)0x0008)
#define GPIO_Pin_4 ((uint16_t)0x0010)
#define GPIO_Pin_5 ((uint16_t)0x0020)
#define GPIO_Pin_6 ((uint16_t)0x0040)
#define GPIO_Pin_7 ((uint16_t)0x0080)
#define GPIO_Pin_8 ((uint16_t)0x0100)
#define GPIO_Pin_9 ((uint16_t)0x0200)
#define GPIO_Pin_All ((uint16_t)0xFFFF)
#define IS_GET_GPIO_PIN(PIN)
#define IS_GPIO_PIN(PIN) ((((PIN) & (uint16_t)0x00) == 0x00) && ((PIN) != (uint16_t)0x00))
------------------------------------------------------------------------------------------
void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
GPIO 입출력 구성
'컴퓨터 > Cortex-M3(STM32F103)' 카테고리의 다른 글
[STM3210B]TEXT LCD Module MLCD-100 기본 구동 프로그램 (0) | 2011.06.28 |
---|---|
myCortex(LM3S8962)에서 광전자도트매트릭스 테스트 프로그램 (0) | 2011.05.13 |
H-JTAG 개발환경 구축 (2) | 2011.05.03 |
AIJI OPENice-A1000 개발환경 구축 (0) | 2011.05.03 |
Cortex-M3(STM32F103) 실습을 위한 사전 준비 사항 (0) | 2011.05.02 |