diff options
| author | Linus Nielsen Feltzing <linus@haxx.se> | 2005-07-12 07:25:01 +0000 |
|---|---|---|
| committer | Linus Nielsen Feltzing <linus@haxx.se> | 2005-07-12 07:25:01 +0000 |
| commit | 192a604cd4bee82d52826b7cab8f91bfc1d35ef4 (patch) | |
| tree | 6854e57eb3f03836a57f060cd3fa90657270317a /firmware/drivers/adc.c | |
| parent | d2ca7fc5de5e9a6aea09f4b97351bccd08a9bb38 (diff) | |
| download | rockbox-192a604cd4bee82d52826b7cab8f91bfc1d35ef4.zip rockbox-192a604cd4bee82d52826b7cab8f91bfc1d35ef4.tar.gz rockbox-192a604cd4bee82d52826b7cab8f91bfc1d35ef4.tar.bz2 rockbox-192a604cd4bee82d52826b7cab8f91bfc1d35ef4.tar.xz | |
Atomic GPIO access
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7114 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/adc.c')
| -rw-r--r-- | firmware/drivers/adc.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c index 69aeb29..1292548 100644 --- a/firmware/drivers/adc.c +++ b/firmware/drivers/adc.c @@ -18,6 +18,7 @@ ****************************************************************************/ #include "config.h" #include "cpu.h" +#include "system.h" #include "kernel.h" #include "thread.h" #include "adc.h" @@ -111,11 +112,11 @@ static unsigned char adcdata[NUM_ADC_CHANNELS]; #define CS_LO GPIO_OUT &= ~0x80 #define CS_HI GPIO_OUT |= 0x80 -#define CLK_LO GPIO_OUT &= ~0x00400000 -#define CLK_HI GPIO_OUT |= 0x00400000 +#define CLK_LO and_l(~0x00400000, &GPIO_OUT) +#define CLK_HI or_l(0x00400000, &GPIO_OUT) #define DO (GPIO_READ & 0x80000000) -#define DI_LO GPIO_OUT &= ~0x00200000 -#define DI_HI GPIO_OUT |= 0x00200000 +#define DI_LO and_l(~0x00200000, &GPIO_OUT) +#define DI_HI or_l(0x00200000, &GPIO_OUT) /* delay loop */ #define DELAY do { int _x; for(_x=0;_x<10;_x++);} while (0) @@ -194,13 +195,13 @@ static void adc_tick(void) void adc_init(void) { - GPIO_FUNCTION |= 0x80600080; /* GPIO7: CS - GPIO21: Data In (to the ADC) - GPIO22: CLK - GPIO31: Data Out (from the ADC) */ - GPIO_ENABLE |= 0x00600080; - GPIO_OUT |= 0x80; /* CS high */ - GPIO_OUT &= ~0x00400000; /* CLK low */ + or_l(0x80600080, &GPIO_FUNCTION); /* GPIO7: CS + GPIO21: Data In (to the ADC) + GPIO22: CLK + GPIO31: Data Out (from the ADC) */ + or_l(0x00600080, &GPIO_ENABLE); + or_l(0x80, &GPIO_OUT); /* CS high */ + and_l(~0x00400000, &GPIO_OUT); /* CLK low */ adc_scan(ADC_BATTERY); |