分支自 DSP/ADSP21569/DSP-21569

wanglei
2024-03-27 ec21e6d7b11751cba2501c690d0e16fcb0581d3c
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * gpio.h
 *
 *  Created on: 2021Äê6ÔÂ26ÈÕ
 *      Author: graydon
 */
 
#ifndef DRV_GPIO_H_
#define DRV_GPIO_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
 
struct gpio_regs;
typedef volatile struct gpio_regs GPIO_TypeDef;
 
#define GPIOA     ((GPIO_TypeDef*)0x31004000)
#define GPIOB     ((GPIO_TypeDef*)0x31004080)
#define GPIOC     ((GPIO_TypeDef*)0x31004100)
 
#define GPIO_Pin0  (1)
#define GPIO_Pin1  (1<<1)
#define GPIO_Pin2  (1<<2)
#define GPIO_Pin3  (1<<3)
#define GPIO_Pin4  (1<<4)
#define GPIO_Pin5  (1<<5)
#define GPIO_Pin6  (1<<6)
#define GPIO_Pin7  (1<<7)
#define GPIO_Pin8  (1<<8)
#define GPIO_Pin9  (1<<9)
#define GPIO_Pin10  (1<<10)
#define GPIO_Pin11  (1<<11)
#define GPIO_Pin12  (1<<12)
#define GPIO_Pin13  (1<<13)
#define GPIO_Pin14  (1<<14)
#define GPIO_Pin15  (1<<15)
 
/*
 * For single function ports (no
multiplexing is needed), leave the PORT_MUX bits at 0 (default).
For all PORT_MUX bit fields:
00 = default/reset peripheral option,
01 = first alternate peripheral option,
10 = second alternate peripheral option,
11 = third alternate peripheral option.
 */
typedef enum {
    MODE_0,//gpio_mode,
    MODE_1,//peripheral_mode
    MODE_2,
    MODE_3,
}GPIO_Pin_Mode;
 
typedef enum {
    GPIO_IN,
    GPIO_OUT
}GPIO_Direction;
 
typedef enum {
    GPIO_LOW,
    GPIO_HIGH
}GPIO_Level;
 
void GPIO_Init(GPIO_TypeDef* GPIOx , uint32_t GPIO_Pin, GPIO_Pin_Mode mode);
 
void GPIO_Set_Direction(GPIO_TypeDef* GPIOx , uint32_t GPIO_Pin, GPIO_Direction dir);
 
void GPIO_SetOutPut(GPIO_TypeDef* GPIOx , uint32_t GPIO_Pin, GPIO_Level value);
 
GPIO_Level GPIO_ToggleInput(GPIO_TypeDef* GPIOx, uint32_t GPIO_Pin);
 
#ifdef __cplusplus
}
#endif
#endif /* DRV_GPIO_H_ */