hen configuring a GPIO via stm32_configgpio() the function will first set the mode to output and then set the initial state of the gpio later on. If you have an application with an externaly pulled-up pin, this would lead to a glitch on the line that may be dangerous in some applications (e.G. Reset Line for other chips, etc). This changes sets the output state before configuring the pin as an output.
This commit is contained in:
parent
d3b8c03a8a
commit
794a64a99b
@ -702,7 +702,7 @@ static bool sam_checkreg(struct sam_tc_s *tc, bool wr, uint32_t regaddr,
|
||||
{
|
||||
/* Yes... show how many times we did it */
|
||||
|
||||
tmrinfo("...[Repeats %d times]...\n", tc->ntimes);
|
||||
tmrllinfo("...[Repeats %d times]...\n", tc->ntimes);
|
||||
}
|
||||
|
||||
/* Save information about the new access */
|
||||
@ -737,7 +737,7 @@ static inline uint32_t sam_tc_getreg(struct sam_chan_s *chan,
|
||||
#ifdef CONFIG_SAMV7_TC_REGDEBUG
|
||||
if (sam_checkreg(tc, false, regaddr, regval))
|
||||
{
|
||||
tmrinfo("%08x->%08x\n", regaddr, regval);
|
||||
tmrllinfo("%08x->%08x\n", regaddr, regval);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -761,7 +761,7 @@ static inline void sam_tc_putreg(struct sam_chan_s *chan, uint32_t regval,
|
||||
#ifdef CONFIG_SAMV7_TC_REGDEBUG
|
||||
if (sam_checkreg(tc, true, regaddr, regval))
|
||||
{
|
||||
tmrinfo("%08x<-%08x\n", regaddr, regval);
|
||||
tmrllinfo("%08x<-%08x\n", regaddr, regval);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -785,7 +785,7 @@ static inline uint32_t sam_chan_getreg(struct sam_chan_s *chan,
|
||||
#ifdef CONFIG_SAMV7_TC_REGDEBUG
|
||||
if (sam_checkreg(chan->tc, false, regaddr, regval))
|
||||
{
|
||||
tmrinfo("%08x->%08x\n", regaddr, regval);
|
||||
tmrllinfo("%08x->%08x\n", regaddr, regval);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -808,7 +808,7 @@ static inline void sam_chan_putreg(struct sam_chan_s *chan, unsigned int offset,
|
||||
#ifdef CONFIG_SAMV7_TC_REGDEBUG
|
||||
if (sam_checkreg(chan->tc, true, regaddr, regval))
|
||||
{
|
||||
tmrinfo("%08x<-%08x\n", regaddr, regval);
|
||||
tmrllinfo("%08x<-%08x\n", regaddr, regval);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -845,8 +845,8 @@ static int sam_tc_interrupt(struct sam_tc_s *tc, struct sam_chan_s *chan)
|
||||
imr = sam_chan_getreg(chan, SAM_TC_IMR_OFFSET);
|
||||
pending = sr & imr;
|
||||
|
||||
tcllinfo("TC%d Channel %d: pending=%08lx\n",
|
||||
tc->tc, chan->chan, (unsigned long)pending);
|
||||
tmrllinfo("TC%d Channel %d: pending=%08lx\n",
|
||||
tc->tc, chan->chan, (unsigned long)pending);
|
||||
|
||||
/* Are there any pending interrupts for this channel? */
|
||||
|
||||
|
@ -469,6 +469,7 @@ int stm32_configgpio(uint32_t cfgset)
|
||||
break;
|
||||
|
||||
case GPIO_OUTPUT: /* General purpose output mode */
|
||||
stm32_gpiowrite(cfgset, (cfgset & GPIO_OUTPUT_SET) != 0); /* Set the initial output value */
|
||||
pinmode = GPIO_MODER_OUTPUT;
|
||||
break;
|
||||
|
||||
@ -619,17 +620,9 @@ int stm32_configgpio(uint32_t cfgset)
|
||||
|
||||
putreg32(regval, base + STM32_GPIO_OTYPER_OFFSET);
|
||||
|
||||
/* If it is an output... set the pin to the correct initial state. */
|
||||
|
||||
if (pinmode == GPIO_MODER_OUTPUT)
|
||||
{
|
||||
bool value = ((cfgset & GPIO_OUTPUT_SET) != 0);
|
||||
stm32_gpiowrite(cfgset, value);
|
||||
}
|
||||
|
||||
/* Otherwise, it is an input pin. Should it configured as an EXTI interrupt? */
|
||||
|
||||
else if ((cfgset & GPIO_EXTI) != 0)
|
||||
if (pinmode != GPIO_MODER_OUTPUT && (cfgset & GPIO_EXTI) != 0)
|
||||
{
|
||||
/* "In STM32 F1 the selection of the EXTI line source is performed through
|
||||
* the EXTIx bits in the AFIO_EXTICRx registers, while in F2 series this
|
||||
|
Loading…
Reference in New Issue
Block a user