Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf8ddc9c

Browse files
ABOSTMfpistm
authored andcommitted
Manage dualpad analog switch
Currently only H7 is concerned.MP1 hardware also have dualpad analog switch but behavior is differentand in our case, switch should always remain open.Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
1 parent088209c commitf8ddc9c

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

‎libraries/SrcWrapper/src/stm32/pinmap.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,28 @@
2323
#include"lock_resource.h"
2424
#endif
2525

26+
typedefstruct {
27+
PinNamepin;
28+
uint32_tLL_AnalogSwitch;
29+
}PinAnalogSwitch;
30+
31+
#if defined(STM32H7xx)
32+
#defineDUALPAD_ANALOG_SWITCH
33+
constPinAnalogSwitchPinMapAnalogSwitch[]= {
34+
{PA_0,LL_SYSCFG_ANALOG_SWITCH_PA0},
35+
{PA_1,LL_SYSCFG_ANALOG_SWITCH_PA1},
36+
{PC_2,LL_SYSCFG_ANALOG_SWITCH_PC2},
37+
{PC_3,LL_SYSCFG_ANALOG_SWITCH_PC3},
38+
{NC,0}
39+
};
40+
#else
41+
/**
42+
* Even if MP1 support some dual pad (analog switch), we don't consider it
43+
* because its behavior is different from H7 and almost useless.
44+
* Switches remains open all the time. No need to configure it */
45+
#undef DUALPAD_ANALOG_SWITCH
46+
#endif
47+
2648
/* Map STM_PIN to LL */
2749
constuint32_tpin_map_ll[16]= {
2850
LL_GPIO_PIN_0,
@@ -43,6 +65,41 @@ const uint32_t pin_map_ll[16] = {
4365
LL_GPIO_PIN_15
4466
};
4567

68+
#if defined(DUALPAD_ANALOG_SWITCH)
69+
/**
70+
* Configure Analog dualpad switch if necessary
71+
*/
72+
voidconfigure_dualpad_switch(PinNamepin,intfunction)
73+
{
74+
PinAnalogSwitch*AnalogSwitch= (PinAnalogSwitch*)PinMapAnalogSwitch;
75+
76+
/* Read through PinMapAnalogSwitch array */
77+
while (AnalogSwitch->pin!=NC) {
78+
/* Check whether pin is or is associated to dualpad Analog Input */
79+
if ((AnalogSwitch->pin |PDUAL)== (pin |PDUAL)) {
80+
if (((function&STM_MODE_ANALOG)!=STM_MODE_ANALOG)
81+
&& ((pin&PDUAL)==PDUAL)) {
82+
/**
83+
* We don't configure an analog function but the pin is an analog pad
84+
* (Pxy_C, ANA0 ...) In this cases Analog switch should be closed
85+
*/
86+
LL_SYSCFG_CloseAnalogSwitch(AnalogSwitch->LL_AnalogSwitch);
87+
return ;
88+
}else {
89+
/**
90+
* Either we configure an analog function,
91+
* or it is not an analog function but it is not an analog pad
92+
* (not Pxy_C, ANA0 ...). In both cases Analog switch should be opened
93+
*/
94+
LL_SYSCFG_OpenAnalogSwitch(AnalogSwitch->LL_AnalogSwitch);
95+
return ;
96+
}
97+
}
98+
AnalogSwitch++;
99+
}
100+
}
101+
#endif/* DUALPAD_ANALOG_SWITCH */
102+
46103
boolpin_in_pinmap(PinNamepin,constPinMap*map)
47104
{
48105
if (pin!= (PinName)NC) {
@@ -177,6 +234,10 @@ void pin_function(PinName pin, int function)
177234

178235
pin_PullConfig(gpio,ll_pin,STM_PIN_PUPD(function));
179236

237+
#if defined(DUALPAD_ANALOG_SWITCH)
238+
configure_dualpad_switch(pin,function);
239+
#endif/* DUALPAD_ANALOG_SWITCH */
240+
180241
pin_DisconnectDebug(pin);
181242

182243
hsem_unlock(CFG_HW_GPIO_SEMID);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp