summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-07-02 12:18:10 +0000
committerJens Arnold <amiconn@rockbox.org>2005-07-02 12:18:10 +0000
commita8cadd8181e53320109d2af61f0c7edea262d325 (patch)
treea266393b2b784fd5b9639c1a326a602b1ef34498
parent8102f3da270ce5a442523a1738318493906bb86a (diff)
Iriver: atomic I/O port manipulation macros, to avoid interference between normal and interrupt code. Todo: all other places that do port manipulation on ports which may also be changed from an intterupt should use that as well. It even decreases binary size a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6985 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/backlight.c20
-rw-r--r--firmware/drivers/lcd-h100-remote.c34
-rw-r--r--firmware/export/system.h37
3 files changed, 57 insertions, 34 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 98b2d9a40d..d40f00f163 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -114,7 +114,7 @@ void TIMER1(void)
if (bl_dim_current > 0 && bl_dim_current < BL_PWM_COUNT)
{
- GPIO1_OUT &= ~0x00020000;
+ and_l(~0x00020000, &GPIO1_OUT);
bl_pwm_counter = bl_dim_current;
timer_period = timer_period * bl_pwm_counter / BL_PWM_COUNT;
bl_dim_state = DIM_STATE_MAIN;
@@ -122,9 +122,9 @@ void TIMER1(void)
else
{
if (bl_dim_current)
- GPIO1_OUT &= ~0x00020000;
+ and_l(~0x00020000, &GPIO1_OUT);
else
- GPIO1_OUT |= 0x00020000;
+ or_l(0x00020000, &GPIO1_OUT);
if (bl_dim_current == bl_dim_target)
idle = true;
}
@@ -133,7 +133,7 @@ void TIMER1(void)
/* Dim main screen */
case DIM_STATE_MAIN:
- GPIO1_OUT |= 0x00020000;
+ or_l(0x00020000, &GPIO1_OUT);
bl_dim_state = DIM_STATE_START;
timer_period = timer_period * (BL_PWM_COUNT - bl_pwm_counter) / BL_PWM_COUNT;
break ;
@@ -182,9 +182,9 @@ void backlight_allow_timer(bool on)
TMR1 = 0;
if (bl_dim_current)
- GPIO1_OUT &= ~0x00020000;
+ and_l(~0x00020000, &GPIO1_OUT);
else
- GPIO1_OUT |= 0x00020000;
+ or_l(0x00020000, &GPIO1_OUT);
}
}
@@ -207,7 +207,7 @@ static void __backlight_off(void)
else
{
bl_dim_target = bl_dim_current = 0;
- GPIO1_OUT |= 0x00020000;
+ or_l(0x00020000, &GPIO1_OUT);
}
#elif CONFIG_BACKLIGHT == BL_RTC
/* Disable square wave */
@@ -229,7 +229,7 @@ static void __backlight_on(void)
else
{
bl_dim_target = bl_dim_current = BL_PWM_COUNT;
- GPIO1_OUT &= ~0x00020000;
+ and_l(~0x00020000, &GPIO1_OUT);
}
#elif CONFIG_BACKLIGHT == BL_RTC
/* Enable square wave */
@@ -409,8 +409,8 @@ void backlight_init(void)
sizeof(backlight_stack), backlight_thread_name);
#if CONFIG_BACKLIGHT == BL_IRIVER
- GPIO1_ENABLE |= 0x00020000;
- GPIO1_FUNCTION |= 0x00020000;
+ or_l(0x00020000, &GPIO1_ENABLE);
+ or_l(0x00020000, &GPIO1_FUNCTION);
#elif CONFIG_BACKLIGHT == BL_PA14_LO || CONFIG_BACKLIGHT == BL_PA14_HI
PACR1 &= ~0x3000; /* Set PA14 (backlight control) to GPIO */
or_b(0x40, &PAIORH); /* ..and output */
diff --git a/firmware/drivers/lcd-h100-remote.c b/firmware/drivers/lcd-h100-remote.c
index af6a45c2c0..eaf61260cb 100644
--- a/firmware/drivers/lcd-h100-remote.c
+++ b/firmware/drivers/lcd-h100-remote.c
@@ -50,14 +50,14 @@
#define LCD_REMOTE_CNTL_HIGHCOL 0x10 /* Upper column address */
#define LCD_REMOTE_CNTL_LOWCOL 0x00 /* Lower column address */
-#define CS_LO GPIO1_OUT &= ~0x00000004
-#define CS_HI GPIO1_OUT |= 0x00000004
-#define CLK_LO GPIO_OUT &= ~0x10000000
-#define CLK_HI GPIO_OUT |= 0x10000000
-#define DATA_LO GPIO1_OUT &= ~0x00040000
-#define DATA_HI GPIO1_OUT |= 0x00040000
-#define RS_LO GPIO_OUT &= ~0x00010000
-#define RS_HI GPIO_OUT |= 0x00010000
+#define CS_LO and_l(~0x00000004, &GPIO1_OUT)
+#define CS_HI or_l(0x00000004, &GPIO1_OUT)
+#define CLK_LO and_l(~0x10000000, &GPIO_OUT)
+#define CLK_HI or_l(0x10000000, &GPIO_OUT)
+#define DATA_LO and_l(~0x00040000, &GPIO1_OUT)
+#define DATA_HI or_l(0x00040000, &GPIO1_OUT)
+#define RS_LO and_l(~0x00010000, &GPIO_OUT)
+#define RS_HI or_l(0x00010000, &GPIO_OUT)
/* delay loop */
#define DELAY do { int _x; for(_x=0;_x<3;_x++);} while (0)
@@ -115,12 +115,12 @@ static const char scroll_tick_table[16] = {
#ifndef SIMULATOR
void lcd_remote_backlight_on(void)
{
- GPIO_OUT &= ~0x00000800;
+ and_l(~0x00000800, &GPIO_OUT);
}
void lcd_remote_backlight_off(void)
{
- GPIO_OUT |= 0x00000800;
+ or_l(0x00000800, &GPIO_OUT);
}
void lcd_remote_write_command(int cmd)
@@ -363,14 +363,14 @@ static void remote_tick(void)
/* Initialise ports and kick off monitor */
void lcd_remote_init(void)
{
- GPIO_FUNCTION |= 0x10010800; /* GPIO11: Backlight
- GPIO16: RS
- GPIO28: CLK */
+ or_l(0x10010800, &GPIO_FUNCTION); /* GPIO11: Backlight
+ GPIO16: RS
+ GPIO28: CLK */
- GPIO1_FUNCTION |= 0x00040004; /* GPIO34: CS
- GPIO50: Data */
- GPIO_ENABLE |= 0x10010800;
- GPIO1_ENABLE |= 0x00040004;
+ or_l(0x00040004, &GPIO1_FUNCTION); /* GPIO34: CS
+ GPIO50: Data */
+ or_l(0x10010800, &GPIO_ENABLE);
+ or_l(0x00040004, &GPIO1_ENABLE);
lcd_remote_clear_display();
diff --git a/firmware/export/system.h b/firmware/export/system.h
index e98c362a8c..56fee6bdab 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -81,25 +81,48 @@ enum {
#if CONFIG_CPU == SH7034
#define or_b(mask, address) \
- asm \
- ("or.b\t%0,@(r0,gbr)" \
- : \
+ asm \
+ ("or.b %0,@(r0,gbr)" \
+ : \
: /* %0 */ I_CONSTRAINT((char)(mask)), \
/* %1 */ "z"(address-GBR))
#define and_b(mask, address) \
asm \
- ("and.b\t%0,@(r0,gbr)" \
+ ("and.b %0,@(r0,gbr)" \
: \
- : /* %0 */ I_CONSTRAINT((char)(mask)), \
+ : /* %0 */ I_CONSTRAINT((char)(mask)), \
/* %1 */ "z"(address-GBR))
#define xor_b(mask, address) \
asm \
- ("xor.b\t%0,@(r0,gbr)" \
+ ("xor.b %0,@(r0,gbr)" \
: \
- : /* %0 */ I_CONSTRAINT((char)(mask)), \
+ : /* %0 */ I_CONSTRAINT((char)(mask)), \
/* %1 */ "z"(address-GBR))
+
+#elif CONFIG_CPU == MCF5249
+#define or_l(mask, address) \
+ asm \
+ ("or.l %0,(%1)" \
+ : \
+ : /* %0 */ "d"(mask), \
+ /* %1 */ "a"(address))
+
+#define and_l(mask, address) \
+ asm \
+ ("and.l %0,(%1)" \
+ : \
+ : /* %0 */ "d"(mask), \
+ /* %1 */ "a"(address))
+
+#define eor_l(mask, address) \
+ asm \
+ ("eor.l %0,(%1)" \
+ : \
+ : /* %0 */ "d"(mask), \
+ /* %1 */ "a"(address))
+
#endif
#ifndef SIMULATOR