From 0404da840332858afad5ecbfcba1290c191f0078 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 22 Dec 2011 03:09:25 +0000 Subject: Disable interrupts while accessing the APB2RTSR register git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4212 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/arch/arm/src/stm32/stm32_adc.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'nuttx/arch/arm/src/stm32/stm32_adc.c') diff --git a/nuttx/arch/arm/src/stm32/stm32_adc.c b/nuttx/arch/arm/src/stm32/stm32_adc.c index 5cd22582d..b71ef6df9 100644 --- a/nuttx/arch/arm/src/stm32/stm32_adc.c +++ b/nuttx/arch/arm/src/stm32/stm32_adc.c @@ -823,6 +823,7 @@ static void adc_startconv(struct stm32_dev_s *priv, bool enable) static void adc_rccreset(struct stm32_dev_s *priv, bool reset) { + irqstate_t flags; uint32_t regval; uint32_t adcbit; @@ -860,6 +861,12 @@ static void adc_rccreset(struct stm32_dev_s *priv, bool reset) adcbit = RCC_APB2RSTR_ADCRST; #endif + /* Disable interrupts. This is necessary because the APB2RTSR register + * is used by several different drivers. + */ + + flags = irqsave(); + /* Set or clear the selected bit in the APB2 reset register */ regval = getreg32(STM32_RCC_APB2RSTR); @@ -876,6 +883,7 @@ static void adc_rccreset(struct stm32_dev_s *priv, bool reset) regval &= ~adcbit; } putreg32(regval, STM32_RCC_APB2RSTR); + irqrestore(flags); } /******************************************************************************* -- cgit v1.2.3