projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lm3s1968: return the correct CPU frequency in clock_get_rate().
[bertos.git]
/
bertos
/
cpu
/
arm
/
drv
/
adc_at91.c
diff --git
a/bertos/cpu/arm/drv/adc_at91.c
b/bertos/cpu/arm/drv/adc_at91.c
index bb6a8d11ffd1409fe86d557a86d31e6d233714f1..fadaa4bebeec70a37fba9506af604ec1f05a3ecb 100644
(file)
--- a/
bertos/cpu/arm/drv/adc_at91.c
+++ b/
bertos/cpu/arm/drv/adc_at91.c
@@
-84,9
+84,9
@@
* ADC ISR.
* Simply signal the adc process that convertion is complete.
*/
* ADC ISR.
* Simply signal the adc process that convertion is complete.
*/
- static
void ISR_FUNC adc_conversion_end_irq(void
)
+ static
DECLARE_ISR(adc_conversion_end_irq
)
{
{
- sig_
signal
(adc_process, SIG_ADC_COMPLETE);
+ sig_
post
(adc_process, SIG_ADC_COMPLETE);
/* Inform hw that we have served the IRQ */
AIC_EOICR = 0;
/* Inform hw that we have served the IRQ */
AIC_EOICR = 0;
@@
-126,13
+126,13
@@
void adc_hw_select_ch(uint8_t ch)
/**
* Start an ADC convertion.
* If a kernel is present, preempt until convertion is complete, otherwise
/**
* Start an ADC convertion.
* If a kernel is present, preempt until convertion is complete, otherwise
- * a busy wait on ADC
S
bit is done.
+ * a busy wait on ADC
_DRDY
bit is done.
*/
uint16_t adc_hw_read(void)
{
*/
uint16_t adc_hw_read(void)
{
- ASSERT(!(ADC_SR & ADC_EOC_MASK));
-
#if CONFIG_KERN
#if CONFIG_KERN
+ /* Ensure ADC is not already in use by another process */
+ ASSERT(adc_process == NULL);
adc_process = proc_current();
#endif
adc_process = proc_current();
#endif
@@
-143,13
+143,19
@@
uint16_t adc_hw_read(void)
// Ensure IRQs enabled.
IRQ_ASSERT_ENABLED();
sig_wait(SIG_ADC_COMPLETE);
// Ensure IRQs enabled.
IRQ_ASSERT_ENABLED();
sig_wait(SIG_ADC_COMPLETE);
+
+ /* Prevent race condition in case of preemptive kernel */
+ uint16_t ret = ADC_LCDR;
+ MEMORY_BARRIER;
+ adc_process = NULL;
+ return ret;
#else
//Wait in polling until is done
while (!(ADC_SR & BV(ADC_DRDY)));
#else
//Wait in polling until is done
while (!(ADC_SR & BV(ADC_DRDY)));
- #endif
- //Return the last converted data
- return(ADC_LCDR);
+ //Return the last converted data
+ return(ADC_LCDR);
+ #endif
}
/**
}
/**