summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2014-02-21 16:59:58 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-03-20 23:51:26 +0000
commit6472ce964dba986907ee4b1a0250c8e27658a492 (patch)
treed336433bfd81295d0157ba60d6a1bbb779f9c911
parentdefaf5cdb5a44067ea0f2d7f18fd57e240d992a6 (diff)
downloadchrome-ec-6472ce964dba986907ee4b1a0250c8e27658a492.tar.gz
stm32: add analog GPIO configuration
Allow to setup a GPIO pin in analog mode on STM32 chips. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=run comparators with GPIOs in analog mode on STM32L151 and STM32F072. Change-Id: Ie11dd8711e39ab191c96478c6d8c7b7e0dfa7ea4 Reviewed-on: https://chromium-review.googlesource.com/189863 Reviewed-by: Vic Yang <victoryang@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--chip/stm32/gpio-stm32f.c5
-rw-r--r--chip/stm32/gpio-stm32f0.c4
-rw-r--r--chip/stm32/gpio-stm32l.c4
3 files changed, 12 insertions, 1 deletions
diff --git a/chip/stm32/gpio-stm32f.c b/chip/stm32/gpio-stm32f.c
index 9e6c6799b6..e9f7944354 100644
--- a/chip/stm32/gpio-stm32f.c
+++ b/chip/stm32/gpio-stm32f.c
@@ -81,7 +81,10 @@ void gpio_set_flags_by_mask(uint32_t port, uint32_t pmask, uint32_t flags)
* GPIOx_ODR determines which resistor to activate in
* input mode, see Table 16 (datasheet rm0041)
*/
- if (flags & GPIO_PULL_UP) {
+ if (flags & GPIO_ANALOG) {
+ /* Analog input, MODE=00 CNF=00 */
+ /* the 4 bits in mask are already reset above */
+ } else if (flags & GPIO_PULL_UP) {
mask |= 0x88888888 & cnf;
STM32_GPIO_BSRR(port) = pmask;
} else if (flags & GPIO_PULL_DOWN) {
diff --git a/chip/stm32/gpio-stm32f0.c b/chip/stm32/gpio-stm32f0.c
index 6933697c46..8e756ab183 100644
--- a/chip/stm32/gpio-stm32f0.c
+++ b/chip/stm32/gpio-stm32f0.c
@@ -67,6 +67,10 @@ void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags)
val |= 0x55555555 & mask2;
STM32_GPIO_MODER(port) = val;
+ } else if (flags & GPIO_ANALOG) {
+ /* Analog, MODE=11 */
+ val |= 0xFFFFFFFF & mask2;
+ STM32_GPIO_MODER(port) = val;
} else if (flags & GPIO_INPUT) {
/* Input, MODE=00 */
STM32_GPIO_MODER(port) = val;
diff --git a/chip/stm32/gpio-stm32l.c b/chip/stm32/gpio-stm32l.c
index 7283526d89..ca627dd701 100644
--- a/chip/stm32/gpio-stm32l.c
+++ b/chip/stm32/gpio-stm32l.c
@@ -67,6 +67,10 @@ void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags)
val |= 0x55555555 & mask2;
STM32_GPIO_MODER(port) = val;
+ } else if (flags & GPIO_ANALOG) {
+ /* Analog, MODE=11 */
+ val |= 0xFFFFFFFF & mask2;
+ STM32_GPIO_MODER(port) = val;
} else if (flags & GPIO_INPUT) {
/* Input, MODE=00 */
STM32_GPIO_MODER(port) = val;