-
.pdf. (LED) (USER & WAKE-UP Button) (. 6). , .
: (A, B, C ). 16 , . .. 12 D PORTD 12.
- , , . , , .. . :
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOx, ENABLE);
, .
-
- . :
GPIO_InitTypeDef PORT_init_struct;
GPIO_InitTypeDef , PORT_init_struct . .
:
PORT_init_struct.GPIO_Pin .
:
PORT_init_struct.GPIO_Pin = GPIO_Pin_x;
( , 0 15).
PORT_init_struct.GPIO_Mode ( ).
, , :
PORT_init_struct.GPIO_Mode = GPIO_Mode_OUT; //
// .
PORT_init_struct.GPIO_Mode = GPIO_Mode_IN; //
// .
PORT_init_struct.GPIO_Speed .
, :
PORT_init_struct.GPIO_Speed = GPIO_Speed_2MHz;
2 :
PORT_init_struct.GPIO_OType = GPIO_OType_PP;
PORT_init_struct.GPIO_PuPd = GPIO_PuPd_NOPULL;
:
PORT_init_struct.GPIO_Pin = GPIO_Pin_12;
PORT_init_struct.GPIO_Mode = GPIO_Mode_OUT;
PORT_init_struct.GPIO_Speed = GPIO_Speed_2MHz;
PORT_init_struct.GPIO_OType = GPIO_OType_PP;
PORT_init_struct.GPIO_PuPd = GPIO_PuPd_NOPULL;
:
GPIO_Init(GPIOx, &PORT_init_struct);
, .
.
:
GPIO_SetBits(GPIOx, GPIO_Pin_y)
. y , .
:
GPIO_ResetBits(GPIOx, GPIO_Pin_y)
. y , .
(.. , , ) :
|
|
GPIO_ToggleBits(GPIOx, GPIO_Pin_y)
. y , .
:
Button_state = GPIO_ReadInputDataBit(GPIOx, GPIO_Pin_y)
. y , .
Button_state , 0, 1, . . , .
:
uint32_t i=0;
for (i=0;i<3000000;i++) {}
, .