Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
TianYing_ty100
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
baizhengyuan
TianYing_ty100
Commits
d4a11690
Commit
d4a11690
authored
Oct 15, 2024
by
陈家乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
feat:GPIO库更新
parent
35da6730
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
49 deletions
+70
-49
gpio.h
.../Device/Cmsemicon/BAT32A239/Library/Driver/include/gpio.h
+21
-20
gpio.c
...urce/Device/Cmsemicon/BAT32A239/Library/Driver/src/gpio.c
+49
-29
No files found.
Firmware/Source/Device/Cmsemicon/BAT32A239/Library/Driver/include/gpio.h
View file @
d4a11690
...
...
@@ -12,33 +12,33 @@ typedef enum
GPIO_Control_DIG
=
0
,
/*!< GPIO Control Digital */
GPIO_Control_ANA
=
1
,
/*!< GPIO Control Analogy */
}
GPIOControl_TypeDef
;
#define IS_GPIO_Control(Ctrl) (((Ctrl) == GPIO_Control_ANA) || ((Ctrl) == GPIO_Control_DIG) )
? 1:0
#define IS_GPIO_Control(Ctrl) (((Ctrl) == GPIO_Control_ANA) || ((Ctrl) == GPIO_Control_DIG) )
typedef
enum
{
GPIO_Mode_OUT
=
0
,
/*!< GPIO Output Mode */
GPIO_Mode_IN
=
1
,
/*!< GPIO Input Mode */
}
GPIOMode_TypeDef
;
#define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_IN) || ((MODE) == GPIO_Mode_OUT) )
? 1:0
#define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_IN) || ((MODE) == GPIO_Mode_OUT) )
typedef
enum
{
GPIO_OType_PP
=
0
,
//普通输
?
GPIO_OType_OD
=
1
//开漏输
?
GPIO_OType_PP
=
0
,
//普通输
出
GPIO_OType_OD
=
1
//开漏输
出
}
GPIOOType_TypeDef
;
#define IS_GPIO_OTYPE(OTYPE) (((OTYPE) == GPIO_OType_PP) || ((OTYPE) == GPIO_OType_OD))
? 1:0
#define IS_GPIO_OTYPE(OTYPE) (((OTYPE) == GPIO_OType_PP) || ((OTYPE) == GPIO_OType_OD))
typedef
enum
{
GPIO_PuPd_NOPULL
=
0x00
,
GPIO_PuPd_UP
=
0x01
,
GPIO_PuPd_UP
=
0x01
,
GPIO_PuPd_DOWN
=
0x02
}
GPIOPuPd_TypeDef
;
#define IS_GPIO_PUPD(PUPD) (((PUPD) == GPIO_PuPd_NOPULL) || ((PUPD) == GPIO_PuPd_UP) || \
((PUPD) == GPIO_PuPd_DOWN))
? 1:0
((PUPD) == GPIO_PuPd_DOWN))
typedef
enum
{
GPIO_Level_LOW
=
0x00
,
GPIO_Level_HIGH
=
0x01
,
GPIO_Level_HIGH
=
0x01
}
GPIOInit_Level
;
typedef
enum
...
...
@@ -58,7 +58,7 @@ typedef enum
#endif
GPIO_PORT12
=
0x0C
,
GPIO_PORT13
=
0x0D
,
GPIO_PORT14
=
0x0E
,
GPIO_PORT14
=
0x0E
}
GPIO_Port_t
;
#ifdef BAT32G1XX_80PIN
...
...
@@ -97,7 +97,7 @@ typedef enum
#define GPIO_Pin_7 ((uint16_t)0x0080)
/* Pin 7 selected */
#define GPIO_PIN_MASK ((uint16_t)0x00FF)
/* PIN mask for assert test */
#define IS_GPIO_PIN(PIN) (((
PIN) & GPIO_PIN_MASK ) != (uint16_t)0x00) ? 1:0
#define IS_GPIO_PIN(PIN) (((
(PIN) & ~GPIO_PIN_MASK ) == (uint16_t)0x00) && ((PIN) != (uint16_t)0x00))
#define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || \
((PIN) == GPIO_Pin_1) || \
...
...
@@ -106,7 +106,7 @@ typedef enum
((PIN) == GPIO_Pin_4) || \
((PIN) == GPIO_Pin_5) || \
((PIN) == GPIO_Pin_6) || \
((PIN) == GPIO_Pin_7))
? 1:0
((PIN) == GPIO_Pin_7))
typedef
enum
...
...
@@ -176,8 +176,8 @@ typedef enum
GROUP_AF_SDA10
,
#endif
GROUP_AF_TAIO
,
//定时器A外部事件输入和脉冲输
?
GROUP_AF_TAO
,
//定时器A的脉冲输
?
GROUP_AF_TAIO
,
//定时器A外部事件输入和脉冲输
出
GROUP_AF_TAO
,
//定时器A的脉冲输
出
GROUP_AF_VCOUT0
,
GROUP_AF_VCOUT1
,
...
...
@@ -190,9 +190,10 @@ typedef enum
GROUP_AF_TMIOB0
,
GROUP_AF_CRXD
,
GROUP_AF_CTXD
,
GROUP_AF_CTXD
,
GROUP_AF_END
}
GROUP_AF_t
;
#define IS_GPIO_AF(GPIO_AF) (
(GPIO_AF) < GROUP_AF_CTXD || ((GPIO_AF) == GROUP_AF_CTXD)
)
#define IS_GPIO_AF(GPIO_AF) (
GPIO_AF < GROUP_AF_END
)
...
...
@@ -283,7 +284,7 @@ typedef enum
GPIO_P152
,
GPIO_P153
,
#endif
GPIO_PIN_END
,
GPIO_PIN_END
}
GPIO_Source_t
;
typedef
enum
...
...
@@ -292,7 +293,7 @@ typedef enum
GPIO_PIOR2
=
0
,
GPIO_PIOR0
=
2
,
GPIO_PIOR1
=
4
,
GPIO_PIOR3
=
7
,
GPIO_PIOR3
=
7
}
GPIO_PIOR_t
;
typedef
enum
...
...
@@ -305,8 +306,8 @@ typedef enum
PIOR_BIT5
,
PIOR_BIT6
,
PIOR_BIT7
,
PIOR_CBIT10
,
//组合bit位(bit1 bit0
?
PIOR_CBIT67
,
//组合bit位(bit6 bit7?
PIOR_CBIT10
,
//组合bit位(bit1 bit0
)
PIOR_CBIT67
//组合bit位(bit6 bit7)
}
PIOR_BIT_t
;
typedef
struct
...
...
@@ -355,6 +356,6 @@ void GPIO_ResetBits(GPIO_Port_t PORTx, uint16_t GPIO_Pin);
void
GPIO_ToggleBits
(
GPIO_Port_t
PORTx
,
uint16_t
GPIO_Pin
);
void
GPIO_Init
(
GPIO_Port_t
PORTx
,
GPIO_InitTypeDef
*
GPIO_InitStruct
);
in
t
GPIO_PinAFConfig
(
GPIO_Port_t
PORTx
,
uint16_t
GPIO_Pin
,
GPIO_Source_t
GPIO_Source_Grp
,
GROUP_AF_t
GPIO_AF
);
uint8_
t
GPIO_PinAFConfig
(
GPIO_Port_t
PORTx
,
uint16_t
GPIO_Pin
,
GPIO_Source_t
GPIO_Source_Grp
,
GROUP_AF_t
GPIO_AF
);
#endif
Firmware/Source/Device/Cmsemicon/BAT32A239/Library/Driver/src/gpio.c
View file @
d4a11690
...
...
@@ -19,7 +19,7 @@ void assert_failed(uint8_t* file, uint32_t line)
#if defined(BAT32G1XX_64PIN) || defined(BAT32G1XX_80PIN)
GPIO_PIN_AF_TABLE_t
funcAfTab
[]
=
const
GPIO_PIN_AF_TABLE_t
funcAfTab
[]
=
{
{
GROUP_AF_INTP1
,
{{
GPIO_PIOR0
,
PIOR_BIT0
,
GPIO_P52
},
{
PIOR_NONE
,
PIOR_BIT0
,
GPIO_DEF
},
{
PIOR_NONE
,
PIOR_BIT0
,
GPIO_DEF
}}},
{
GROUP_AF_INTP2
,
{{
GPIO_PIOR0
,
PIOR_BIT0
,
GPIO_P53
},
{
PIOR_NONE
,
PIOR_BIT0
,
GPIO_DEF
},
{
PIOR_NONE
,
PIOR_BIT0
,
GPIO_DEF
}}},
...
...
@@ -62,7 +62,7 @@ GPIO_PIN_AF_TABLE_t funcAfTab[] =
{
GROUP_AF_ODEFAULT
,{{
PIOR_NONE
,
PIOR_BIT0
,
GPIO_DEF
},
{
PIOR_NONE
,
PIOR_BIT0
,
GPIO_DEF
},
{
PIOR_NONE
,
PIOR_BIT0
,
GPIO_DEF
}}},
};
#elif defined BAT32G1XX_48PIN
GPIO_PIN_AF_TABLE_t
funcAfTab
[]
=
const
GPIO_PIN_AF_TABLE_t
funcAfTab
[]
=
{
{
GROUP_AF_INTP8
,
{{
PIOR_NONE
,
PIOR_BIT0
,
GPIO_DEF
},
{
GPIO_PIOR0
,
PIOR_BIT7
,
GPIO_P00
},
{
PIOR_NONE
,
PIOR_BIT0
,
GPIO_DEF
}}},
{
GROUP_AF_RXD1
,
{{
GPIO_PIOR0
,
PIOR_BIT5
,
GPIO_P73
},
{
PIOR_NONE
,
PIOR_BIT0
,
GPIO_DEF
},
{
PIOR_NONE
,
PIOR_BIT0
,
GPIO_DEF
}}},
...
...
@@ -166,7 +166,7 @@ void GPIO_Set_Value(__IO uint8_t *port, uint8_t value)
uint8_t
GPIO_Get_Value
(
__IO
uint8_t
*
port
)
{
// PORT->PMS = 0x01; /*!< Digital output level of the pin is read */
return
(
*
port
);
/*!< PL = value */
return
(
*
(
port
-
0x260
)
);
/*!< PL = value */
}
/**
...
...
@@ -175,8 +175,9 @@ uint8_t GPIO_Get_Value(__IO uint8_t *port)
* @param port, such as P0, P1, P2...
* @param pinMsk
* e.g., bit0: 0x01, bit1: 0x02, bit0~3: 0x0F, bit0~7: 0xFF
* @retval ERROR or NO_ERROR .
*/
in
t
GPIO_PinCheck
(
GPIO_Port_t
PORTx
,
uint16_t
GPIO_Pin
)
static
uint8_
t
GPIO_PinCheck
(
GPIO_Port_t
PORTx
,
uint16_t
GPIO_Pin
)
{
if
(
PORTx
==
GPIO_PORT0
)
{
...
...
@@ -235,41 +236,41 @@ void GPIO_Init(GPIO_Port_t PORTx,GPIO_InitTypeDef* GPIO_InitStruct)
if
(
GPIO_InitStruct
->
GPIO_Level
==
GPIO_Level_HIGH
)
{
*
((
volatile
uint8_t
*
)(
&
PORT
->
P0
+
PORTx
))
|=
(
1
<<
currentpin
);
*
((
volatile
uint8_t
*
)(
&
PORT
->
P0
+
(
uint8_t
)
PORTx
))
|=
(
1
<<
currentpin
);
}
else
{
*
((
volatile
uint8_t
*
)(
&
PORT
->
P0
+
PORTx
))
&=
~
(
1
<<
currentpin
);
*
((
volatile
uint8_t
*
)(
&
PORT
->
P0
+
(
uint8_t
)
PORTx
))
&=
~
(
uint8_t
)
(
1
<<
currentpin
);
}
if
(
GPIO_InitStruct
->
GPIO_Ctrl
==
GPIO_Control_DIG
)
/*digitial input/output*/
{
*
((
volatile
uint8_t
*
)(
&
PORT
->
PMC0
+
PORTx
))
&=
~
((
!
GPIO_InitStruct
->
GPIO_Ctrl
)
<<
currentpin
);
*
((
volatile
uint8_t
*
)(
&
PORT
->
PMC0
+
(
uint8_t
)
PORTx
))
&=
~
(
uint8_t
)((
!
(
GPIO_InitStruct
->
GPIO_Ctrl
)
)
<<
currentpin
);
if
(
GPIO_InitStruct
->
GPIO_Mode
==
GPIO_Mode_OUT
)
{
*
((
volatile
uint8_t
*
)(
&
PORT
->
PM0
+
PORTx
))
&=
~
((
!
GPIO_InitStruct
->
GPIO_Mode
)
<<
currentpin
);
*
((
volatile
uint8_t
*
)(
&
PORT
->
PM0
+
(
uint8_t
)
PORTx
))
&=
~
(
uint8_t
)(
!
(
GPIO_InitStruct
->
GPIO_Mode
)
<<
currentpin
);
assert_param
(
IS_GPIO_OTYPE
(
GPIO_InitStruct
->
GPIO_OType
));
if
(
GPIO_InitStruct
->
GPIO_OType
==
GPIO_OType_PP
)
{
*
((
volatile
uint8_t
*
)(
&
PORT
->
POM0
+
PORTx
))
&=
~
((
!
GPIO_InitStruct
->
GPIO_OType
)
<<
currentpin
);
*
((
volatile
uint8_t
*
)(
&
PORT
->
POM0
+
(
uint8_t
)
PORTx
))
&=
~
(
uint8_t
)
((
!
GPIO_InitStruct
->
GPIO_OType
)
<<
currentpin
);
}
else
{
*
((
volatile
uint8_t
*
)(
&
PORT
->
POM0
+
PORTx
))
|=
GPIO_InitStruct
->
GPIO_OType
<<
currentpin
;
*
((
volatile
uint8_t
*
)(
&
PORT
->
POM0
+
(
uint8_t
)
PORTx
))
|=
(
uint8_t
)(
GPIO_InitStruct
->
GPIO_OType
<<
currentpin
)
;
}
}
else
{
*
((
volatile
uint8_t
*
)(
&
PORT
->
PM0
+
PORTx
))
|=
(
GPIO_InitStruct
->
GPIO_Mode
<<
currentpin
);
*
((
volatile
uint8_t
*
)(
&
PORT
->
PM0
+
(
uint8_t
)
PORTx
))
|=
(
uint8_t
)
(
GPIO_InitStruct
->
GPIO_Mode
<<
currentpin
);
}
}
else
/*analogy input*/
{
*
((
volatile
uint8_t
*
)(
&
PORT
->
PMC0
+
PORTx
))
|=
GPIO_InitStruct
->
GPIO_Ctrl
<<
currentpin
;
*
((
volatile
uint8_t
*
)(
&
PORT
->
PMC0
+
(
uint8_t
)
PORTx
))
|=
(
uint8_t
)(
GPIO_InitStruct
->
GPIO_Ctrl
<<
currentpin
)
;
}
assert_param
(
IS_GPIO_PUPD
(
GPIO_InitStruct
->
GPIO_PuPd
));
if
(
GPIO_InitStruct
->
GPIO_PuPd
==
GPIO_PuPd_UP
)
{
*
((
volatile
uint8_t
*
)(
&
PORT
->
PU0
+
PORTx
))
|=
(
1
<<
currentpin
);
*
((
volatile
uint8_t
*
)(
&
PORT
->
PU0
+
(
uint8_t
)
PORTx
))
|=
(
uint8_t
)
(
1
<<
currentpin
);
}
else
if
(
GPIO_InitStruct
->
GPIO_PuPd
==
GPIO_PuPd_DOWN
)
{
...
...
@@ -297,7 +298,7 @@ void GPIO_SetBits(GPIO_Port_t PORTx, uint16_t GPIO_Pin)
assert_param
(
IS_GPIO_ALL_PERIPH
(
PORTx
));
assert_param
(
IS_GPIO_PIN
(
GPIO_Pin
));
*
((
volatile
uint8_t
*
)(
&
PORT
->
P
0
+
PORTx
))
|
=
GPIO_Pin
;
*
((
volatile
uint8_t
*
)(
&
PORT
->
P
SET0
+
(
uint8_t
)
PORTx
))
=
GPIO_Pin
;
}
...
...
@@ -316,7 +317,7 @@ void GPIO_ResetBits(GPIO_Port_t PORTx, uint16_t GPIO_Pin)
assert_param
(
IS_GPIO_ALL_PERIPH
(
PORTx
));
assert_param
(
IS_GPIO_PIN
(
GPIO_Pin
));
*
((
volatile
uint8_t
*
)(
&
PORT
->
P
0
+
PORTx
))
&=
~
GPIO_Pin
;
*
((
volatile
uint8_t
*
)(
&
PORT
->
P
CLR0
+
(
uint8_t
)
PORTx
))
=
GPIO_Pin
;
}
/**
...
...
@@ -334,7 +335,7 @@ void GPIO_ToggleBits(GPIO_Port_t PORTx, uint16_t GPIO_Pin)
assert_param
(
IS_GPIO_ALL_PERIPH
(
PORTx
));
assert_param
(
IS_GPIO_PIN
(
GPIO_Pin
));
*
((
volatile
uint8_t
*
)(
&
PORT
->
P0
+
PORTx
))
^=
GPIO_Pin
;
*
((
volatile
uint8_t
*
)(
&
PORT
->
P0
+
(
uint8_t
)
PORTx
))
^=
GPIO_Pin
;
}
/**
* @brief Reads the specified input port pin.
...
...
@@ -351,7 +352,7 @@ uint8_t GPIO_ReadInputDataBit(GPIO_Port_t PORTx, uint16_t GPIO_Pin)
assert_param
(
IS_GPIO_ALL_PERIPH
(
PORTx
));
assert_param
(
IS_GET_GPIO_PIN
(
GPIO_Pin
));
if
(((
*
((
volatile
uint8_t
*
)(
&
PORT
->
P
0
+
PORTx
)))
&
GPIO_Pin
)
!=
Bit_RESET
)
if
(((
*
((
volatile
uint8_t
*
)(
&
PORT
->
P
READ0
+
(
uint8_t
)
PORTx
)))
&
GPIO_Pin
)
!=
(
uint8_t
)
Bit_RESET
)
{
bitstatus
=
(
uint8_t
)
Bit_SET
;
}
...
...
@@ -379,7 +380,7 @@ uint8_t GPIO_ReadOutputDataBit(GPIO_Port_t PORTx, uint16_t GPIO_Pin)
assert_param
(
IS_GET_GPIO_PIN
(
GPIO_Pin
));
if
(((
*
((
volatile
uint8_t
*
)(
&
PORT
->
P0
+
PORTx
)))
&
GPIO_Pin
)
!=
Bit_RESET
)
if
(((
*
((
volatile
uint8_t
*
)(
&
PORT
->
P0
+
(
uint8_t
)
PORTx
)))
&
GPIO_Pin
)
!=
(
uint8_t
)
Bit_RESET
)
{
bitstatus
=
(
uint8_t
)
Bit_SET
;
}
...
...
@@ -396,23 +397,42 @@ void GPIO_SetPIOR(uint16_t idx,GPIO_Source_t GPIO_Source_Grp)
{
uint8_t
i
;
for
(
i
=
0
;
i
<
PIOR_MAX_NUM
;
i
++
)
for
(
i
=
0
;
i
<
sizeof
(
funcAfTab
[
idx
].
piorInfo
)
/
sizeof
(
PIOR_INFO_t
);
i
++
)
{
if
(
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
!=
PIOR_NONE
)
{
if
(
funcAfTab
[
idx
].
piorInfo
[
i
].
bitIndex
==
PIOR_CBIT10
)
{
*
((
volatile
uint8_t
*
)(
GPIO_PIOR_CFG_BASE
+
(
uint8_t
)
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
))
&=
~
(
1
<<
0
);
*
((
volatile
uint8_t
*
)(
GPIO_PIOR_CFG_BASE
+
(
uint8_t
)
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
))
&=
~
(
1
<<
1
);
}
else
if
(
funcAfTab
[
idx
].
piorInfo
[
i
].
bitIndex
==
PIOR_CBIT67
)
{
*
((
volatile
uint8_t
*
)(
GPIO_PIOR_CFG_BASE
+
(
uint8_t
)
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
))
&=
~
(
1
<<
6
);
*
((
volatile
uint8_t
*
)(
GPIO_PIOR_CFG_BASE
+
(
uint8_t
)
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
))
&=
~
(
1
<<
7
);
}
else
{
//Clear PIOR bit
*
((
volatile
uint8_t
*
)(
GPIO_PIOR_CFG_BASE
+
(
uint8_t
)
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
))
&=
~
(
1
<<
funcAfTab
[
idx
].
piorInfo
[
i
].
bitIndex
);
}
}
if
(
GPIO_Source_Grp
==
funcAfTab
[
idx
].
piorInfo
[
i
].
bitHigPin
)
{
if
(
funcAfTab
[
idx
].
piorInfo
[
i
].
bitIndex
==
PIOR_CBIT10
)
//只针对pior1 的pior11 pior10组合bit
if
(
funcAfTab
[
idx
].
piorInfo
[
i
].
bitIndex
==
PIOR_CBIT10
)
{
*
((
volatile
uint8_t
*
)(
GPIO_PIOR_CFG_BASE
+
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
))
|=
(
1
<<
0
);
*
((
volatile
uint8_t
*
)(
GPIO_PIOR_CFG_BASE
+
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
))
|=
(
1
<<
1
);
*
((
volatile
uint8_t
*
)(
GPIO_PIOR_CFG_BASE
+
(
uint8_t
)
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
))
|=
(
1
<<
0
);
*
((
volatile
uint8_t
*
)(
GPIO_PIOR_CFG_BASE
+
(
uint8_t
)
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
))
|=
(
1
<<
1
);
}
else
if
(
funcAfTab
[
idx
].
piorInfo
[
i
].
bitIndex
==
PIOR_CBIT67
)
//只针对pior3 的bit6 bit7组合bit
else
if
(
funcAfTab
[
idx
].
piorInfo
[
i
].
bitIndex
==
PIOR_CBIT67
)
{
*
((
volatile
uint8_t
*
)(
GPIO_PIOR_CFG_BASE
+
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
))
|=
(
1
<<
6
);
*
((
volatile
uint8_t
*
)(
GPIO_PIOR_CFG_BASE
+
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
))
&=
~
(
1
<<
7
);
*
((
volatile
uint8_t
*
)(
GPIO_PIOR_CFG_BASE
+
(
uint8_t
)
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
))
|=
(
1
<<
6
);
*
((
volatile
uint8_t
*
)(
GPIO_PIOR_CFG_BASE
+
(
uint8_t
)
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
))
&=
~
(
1
<<
7
);
}
else
{
*
((
volatile
uint8_t
*
)(
GPIO_PIOR_CFG_BASE
+
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
))
|=
(
1
<<
funcAfTab
[
idx
].
piorInfo
[
i
].
bitIndex
);
*
((
volatile
uint8_t
*
)(
GPIO_PIOR_CFG_BASE
+
(
uint8_t
)
funcAfTab
[
idx
].
piorInfo
[
i
].
pior
))
|=
(
1
<<
(
uint8_t
)
funcAfTab
[
idx
].
piorInfo
[
i
].
bitIndex
);
}
break
;
}
...
...
@@ -424,11 +444,11 @@ void GPIO_SetPIOR(uint16_t idx,GPIO_Source_t GPIO_Source_Grp)
* @param PORTx: where x can be (0..14) to select the GPIO peripheral for BAT32G137 devices
* @param GPIO_Pin: specifies the port bits to be written.
* This parameter can be any combination of GPIO_Pin_x where x can be (0..7).
* @param GPIO_Source_Grp: specifies the port bits and port,such as P70
、
P51......
* @param GPIO_Source_Grp: specifies the port bits and port,such as P70
��P
51......
* @param GPIO_AF: digital functions which can be mapped to any chip pin
* @retval error or success .
*/
in
t
GPIO_PinAFConfig
(
GPIO_Port_t
PORTx
,
uint16_t
GPIO_Pin
,
GPIO_Source_t
GPIO_Source_Grp
,
GROUP_AF_t
GPIO_AF
)
uint8_
t
GPIO_PinAFConfig
(
GPIO_Port_t
PORTx
,
uint16_t
GPIO_Pin
,
GPIO_Source_t
GPIO_Source_Grp
,
GROUP_AF_t
GPIO_AF
)
{
uint16_t
id
=
0
;
/* Check the parameters */
...
...
@@ -441,7 +461,7 @@ int GPIO_PinAFConfig(GPIO_Port_t PORTx, uint16_t GPIO_Pin, GPIO_Source_t GPIO_So
return
GPIO_ERR
;
}
for
(
id
=
0
;
funcAfTab
[
id
].
func
!=
0
;
id
++
)
for
(
id
=
0
;
id
<
sizeof
(
funcAfTab
)
/
sizeof
(
GPIO_PIN_AF_TABLE_t
)
;
id
++
)
{
if
(
funcAfTab
[
id
].
func
==
GPIO_AF
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment