forked from len0rd/rockbox
Further lockdown of multipart i2c operations that must be done without intrusion.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15823 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
b9b736fa39
commit
7126d64820
1 changed files with 6 additions and 0 deletions
|
|
@ -24,6 +24,7 @@
|
|||
#include "string.h"
|
||||
#include "adc.h"
|
||||
#include "pcf50605.h"
|
||||
#include "i2c-pp.h"
|
||||
|
||||
struct adc_struct {
|
||||
long timeout;
|
||||
|
|
@ -39,6 +40,9 @@ static unsigned short _adc_read(struct adc_struct *adc)
|
|||
if (adc->timeout < current_tick) {
|
||||
unsigned char data[2];
|
||||
unsigned short value;
|
||||
|
||||
i2c_lock();
|
||||
|
||||
/* 5x per 2 seconds */
|
||||
adc->timeout = current_tick + (HZ * 2 / 5);
|
||||
|
||||
|
|
@ -53,6 +57,8 @@ static unsigned short _adc_read(struct adc_struct *adc)
|
|||
adc->conversion(&value);
|
||||
}
|
||||
adc->data = value;
|
||||
|
||||
i2c_unlock();
|
||||
return value;
|
||||
} else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue