freemyipod r873 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r872‎ | r873 | r874 >
Date:11:43, 27 July 2013
Author:theseven
Status:new
Tags:
Comment:
emCORE: Reduce code duplication in iPod platform interrupt handlers
Modified paths:
  • /emcore/trunk/target/ipodnano2g/interrupt.c (modified) (history)
  • /emcore/trunk/target/ipodnano2g/s5l8701.h (modified) (history)
  • /emcore/trunk/target/ipodnano3g/interrupt.c (modified) (history)
  • /emcore/trunk/target/ipodnano3g/s5l8702.h (modified) (history)
  • /emcore/trunk/target/ipodnano4g/interrupt.c (modified) (history)
  • /emcore/trunk/target/ipodnano4g/s5l8720.h (modified) (history)

Diff [purge]

Index: emcore/trunk/target/ipodnano2g/s5l8701.h
@@ -248,6 +248,7 @@
249249
250250
251251 /////TIMER/////
 252+#define TCON(x) (*((uint32_t volatile*)(0x3C700000 + 0x20 * (x))))
252253 #define TACON (*((uint32_t volatile*)(0x3C700000)))
253254 #define TACMD (*((uint32_t volatile*)(0x3C700004)))
254255 #define TADATA0 (*((uint32_t volatile*)(0x3C700008)))
Index: emcore/trunk/target/ipodnano2g/interrupt.c
@@ -87,10 +87,12 @@
8888 void INT_TIMER(void) ICODE_ATTR;
8989 void INT_TIMER()
9090 {
91 - if (TACON & (TACON >> 4) & 0x7000) timervector[0]();
92 - if (TBCON & (TBCON >> 4) & 0x7000) timervector[1]();
93 - if (TCCON & (TCCON >> 4) & 0x7000) timervector[2]();
94 - if (TDCON & (TDCON >> 4) & 0x7000) timervector[3]();
 91+ int i;
 92+ for (i = 0; i < ARRAYLEN(timervector); i++)
 93+ {
 94+ int tcon = TCON(i);
 95+ if (tcon & (tcon >> 4) & 0x7000) timervector[i]();
 96+ }
9597 }
9698
9799 static void (* dmavector[])(void) IDATA_ATTR =
Index: emcore/trunk/target/ipodnano3g/s5l8702.h
@@ -37,6 +37,7 @@
3838
3939
4040 /////TIMER/////
 41+#define TCON(x) (*((uint32_t volatile*)(0x3C700000 + 0x20 * (x))))
4142 #define TACON (*((uint32_t volatile*)(0x3C700000)))
4243 #define TACMD (*((uint32_t volatile*)(0x3C700004)))
4344 #define TADATA0 (*((uint32_t volatile*)(0x3C700008)))
Index: emcore/trunk/target/ipodnano3g/interrupt.c
@@ -132,13 +132,12 @@
133133 void INT_TIMER(void) ICODE_ATTR;
134134 void INT_TIMER()
135135 {
136 - if (TACON & (TACON >> 4) & 0x7000) timervector[0]();
137 - if (TBCON & (TBCON >> 4) & 0x7000) timervector[1]();
138 - if (TCCON & (TCCON >> 4) & 0x7000) timervector[2]();
139 - if (TDCON & (TDCON >> 4) & 0x7000) timervector[3]();
140 - if (TFCON & (TFCON >> 4) & 0x7000) timervector[5]();
141 - if (TGCON & (TGCON >> 4) & 0x7000) timervector[6]();
142 - if (THCON & (THCON >> 4) & 0x7000) timervector[7]();
 136+ int i;
 137+ for (i = 0; i < ARRAYLEN(timervector); i++)
 138+ {
 139+ int tcon = TCON(i);
 140+ if (tcon & (tcon >> 4) & 0x7000) timervector[i]();
 141+ }
143142 }
144143
145144 static void (* dmavector[])(void) IDATA_ATTR =
Index: emcore/trunk/target/ipodnano4g/s5l8720.h
@@ -37,6 +37,7 @@
3838
3939
4040 /////TIMER/////
 41+#define TCON(x) (*((uint32_t volatile*)(0x3C700000 + 0x20 * (x))))
4142 #define TACON (*((uint32_t volatile*)(0x3C700000)))
4243 #define TACMD (*((uint32_t volatile*)(0x3C700004)))
4344 #define TADATA0 (*((uint32_t volatile*)(0x3C700008)))
Index: emcore/trunk/target/ipodnano4g/interrupt.c
@@ -132,13 +132,12 @@
133133 void INT_TIMER(void) ICODE_ATTR;
134134 void INT_TIMER()
135135 {
136 - if (TACON & (TACON >> 4) & 0x7000) timervector[0]();
137 - if (TBCON & (TBCON >> 4) & 0x7000) timervector[1]();
138 - if (TCCON & (TCCON >> 4) & 0x7000) timervector[2]();
139 - if (TDCON & (TDCON >> 4) & 0x7000) timervector[3]();
140 - if (TFCON & (TFCON >> 4) & 0x7000) timervector[5]();
141 - if (TGCON & (TGCON >> 4) & 0x7000) timervector[6]();
142 - if (THCON & (THCON >> 4) & 0x7000) timervector[7]();
 136+ int i;
 137+ for (i = 0; i < ARRAYLEN(timervector); i++)
 138+ {
 139+ int tcon = TCON(i);
 140+ if (tcon & (tcon >> 4) & 0x7000) timervector[i]();
 141+ }
143142 }
144143
145144 static void (* dmavector[])(void) IDATA_ATTR =