-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlab1-3
More file actions
59 lines (52 loc) · 2.04 KB
/
lab1-3
File metadata and controls
59 lines (52 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "stm32f769xx.h"
#include<stdlib.h>
#include<stdint.h>
#include "init.h"
// push-pull 1
// open-drain 0
GPIO_InitTypeDef GPIO_InitStructure;
int main(void)
{
while(1)
{
__HAL_RCC_GPIOJ_CLK_ENABLE();// enable clock J, LD1&LD2&D2
GPIO_InitStructure.Pin = GPIO_PIN_13;//LD1
GPIO_InitStructure.Pin = GPIO_PIN_5;//LD2
GPIO_InitStructure.Pin = GPIO_PIN_1;//Arduino D2 input
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStructure.Pull = GPIO_PULLUP;
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOJ, &GPIO_InitStructure);
__HAL_RCC_GPIOA_CLK_ENABLE();//enable CLK A, LD3
GPIO_InitStructure.Pin = GPIO_PIN_12;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStructure.Pull = GPIO_PULLUP;
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
__HAL_RCC_GPIOD_CLK_ENABLE();//enable CLK D, LD4
GPIO_InitStructure.Pin = GPIO_PIN_4;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStructure.Pull = GPIO_PULLUP;
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);
//GPIOJ->MODER |= 1024U;
__HAL_RCC_GPIOC_CLK_ENABLE();//enable CLK C, D0&D1
GPIO_InitStructure.Pin = GPIO_PIN_6;//Arduino D1 input
GPIO_InitStructure.Pin = GPIO_PIN_7;//Arduino D0 input
GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
GPIO_InitStructure.Pull = GPIO_PULLUP;
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);
__HAL_RCC_GPIOF_CLK_ENABLE();//enable CLK F, D3
GPIO_InitStructure.Pin = GPIO_PIN_6;//Arduino D3 input
GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
GPIO_InitStructure.Pull = GPIO_PULLUP;
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);
HAL_GPIO_WritePin(GPIOJ, GPIO_PIN_13, GPIO_PIN_RESET);//LIGHT UP LD1
HAL_GPIO_WritePin(GPIOJ, GPIO_PIN_5, GPIO_PIN_RESET);//LIGHT UP LD2
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_SET);//LIGHT UP LD2
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_4, GPIO_PIN_SET);//LIGHT UP LD2
HAL_Delay(1000);
}
}