preempt_forbid_cnt: make it of type cpuatomic_t
[bertos.git] / bertos / cpu / arm / drv / adc_at91.c
index eed5fac6e97258f7e88088b7e958c57263b0b8c2..b98e129025ea699195f501be839f617548f68856 100644 (file)
  *
  * -->
  *
- *
  * \brief ADC hardware-specific implementation
  *
  * This ADC module should be use both whit kernel or none.
  * If you are using a kernel, the adc drive does not wait the finish of
- * conversion but use a singal every time a required conversion are 
- * ended. This signal wake up a process that return a result of 
+ * conversion but use a singal every time a required conversion are
+ * ended. This signal wake up a process that return a result of
  * conversion. Otherwise, if you not use a kernl, this module wait
  * whit a loop the finishing of conversion.
  *
  *
  * \version $Id$
- * 
  * \author Daniele Basile <asterix@develer.com>
  */
 
+
 #include "adc_at91.h"
 
-#include <cfg/cfg_adc.h>
-#include <cfg/cfg_kern.h>
+#include <cpu/irq.h>
+
+#include "cfg/cfg_adc.h"
+#include "cfg/cfg_kern.h"
 #include <cfg/macros.h>
 #include <cfg/compiler.h>
 
+// Define log settings for cfg/log.h.
+#define LOG_LEVEL         ADC_LOG_LEVEL
+#define LOG_FORMAT        ADC_LOG_FORMAT
+#include <cfg/log.h>
+
 #include <drv/adc.h>
 
 #include <io/arm.h>
 
-#if CONFIG_KERNEL
+#if CONFIG_KERN
        #include <cfg/module.h>
        #include <kern/proc.h>
        #include <kern/signal.h>
                ADC_IER = BV(ADC_DRDY);
        }
 
-#endif /* CONFIG_KERNEL */
+#endif /* CONFIG_KERN */
 
 
 /**
@@ -125,16 +131,16 @@ INLINE uint16_t adc_hw_read(void)
 {
        ASSERT(!(ADC_SR & ADC_EOC_MASK));
 
-       #if CONFIG_KERNEL
+       #if CONFIG_KERN
                adc_process = proc_current();
        #endif
 
        // Start convertion
        ADC_CR = BV(ADC_START);
 
-       #if CONFIG_KERNEL
+       #if CONFIG_KERN
                // Ensure IRQs enabled.
-               ASSERT(IRQ_ENABLED());
+               IRQ_ASSERT_ENABLED();
                sig_wait(SIG_ADC_COMPLETE);
        #else
                //Wait in polling until is done
@@ -171,25 +177,25 @@ INLINE void adc_hw_init(void)
        #endif
        /* \} */
 
-       TRACEMSG("prescaler[%ld], stup[%ld], shtim[%ld]\n",ADC_COMPUTED_PRESCALER,ADC_COMPUTED_STARTUPTIME,ADC_COMPUTED_SHTIME);
+       LOG_INFO("prescaler[%ld], stup[%ld], shtim[%ld]\n",ADC_COMPUTED_PRESCALER, ADC_COMPUTED_STARTUPTIME,  ADC_COMPUTED_SHTIME);
 
 
        //Apply computed prescaler value
        ADC_MR &= ~ADC_PRESCALER_MASK;
        ADC_MR |= ((ADC_COMPUTED_PRESCALER << ADC_PRESCALER_SHIFT) & ADC_PRESCALER_MASK);
-       TRACEMSG("prescaler[%ld]\n", (ADC_COMPUTED_PRESCALER << ADC_PRESCALER_SHIFT) & ADC_PRESCALER_MASK);
+       LOG_INFO("prescaler[%ld]\n", (ADC_COMPUTED_PRESCALER << ADC_PRESCALER_SHIFT) & ADC_PRESCALER_MASK);
 
        //Apply computed start up time
        ADC_MR &= ~ADC_STARTUP_MASK;
        ADC_MR |= ((ADC_COMPUTED_STARTUPTIME << ADC_STARTUP_SHIFT) & ADC_STARTUP_MASK);
-       TRACEMSG("sttime[%ld]\n", (ADC_COMPUTED_STARTUPTIME << ADC_STARTUP_SHIFT) & ADC_STARTUP_MASK);
+       LOG_INFO("sttime[%ld]\n", (ADC_COMPUTED_STARTUPTIME << ADC_STARTUP_SHIFT) & ADC_STARTUP_MASK);
 
        //Apply computed sample and hold time
        ADC_MR &= ~ADC_SHTIME_MASK;
        ADC_MR |= ((ADC_COMPUTED_SHTIME << ADC_SHTIME_SHIFT) & ADC_SHTIME_MASK);
-       TRACEMSG("shtime[%ld]\n", (ADC_COMPUTED_SHTIME << ADC_SHTIME_SHIFT) & ADC_SHTIME_MASK);
+       LOG_INFO("shtime[%ld]\n", (ADC_COMPUTED_SHTIME << ADC_SHTIME_SHIFT) & ADC_SHTIME_MASK);
 
-       #if CONFIG_KERNEL
+       #if CONFIG_KERN
                //Register and enable irq for adc.
                adc_enable_irq();
        #endif