freemyipod r78 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r77‎ | r78 | r79 >
Date:04:07, 10 August 2010
Author:theseven
Status:new
Tags:
Comment:
Make the tick timer tick on the 4g
Modified paths:
  • /embios/branches/4g_compat/init.c (modified) (history)
  • /embios/branches/4g_compat/target/ipodnano4g/crt0.S (modified) (history)
  • /embios/branches/4g_compat/target/ipodnano4g/interrupt.c (modified) (history)
  • /embios/branches/4g_compat/target/ipodnano4g/s5l8720.h (modified) (history)
  • /embios/branches/4g_compat/target/ipodnano4g/timer.c (modified) (history)

Diff [purge]

Index: embios/branches/4g_compat/init.c
@@ -28,6 +28,8 @@
2929
3030 static const char welcomestring[] INITCONST_ATTR = "emBIOS v" VERSION "\n";
3131
 32+#include "s5l8720.h"
 33+
3234 void init() INITCODE_ATTR;
3335 void init()
3436 {
@@ -36,10 +38,7 @@
3739 cputs(1, welcomestring);
3840 while(1)
3941 {
40 - uint8_t x = accel_get_axis(0);
41 - uint8_t y = accel_get_axis(1);
42 - uint8_t z = accel_get_axis(2);
43 - cprintf(1, "x:%d y:%d z:%d\n", x, y, z);
 42+ cprintf(1, "TBCNT: %d \n", TBCNT);
4443 }
4544
4645 }
Index: embios/branches/4g_compat/target/ipodnano4g/timer.c
@@ -29,5 +29,30 @@
3030
3131 void setup_tick()
3232 {
 33+ int cycles = SYSTEM_TICK / 100;
 34+
 35+ TACMD = (1 << 1); /* TA_CLR */
 36+ TBCMD = (1 << 1); /* TB_CLR */
 37+ TCCMD = (1 << 1); /* TC_CLR */
 38+ TDCMD = (1 << 1); /* TD_CLR */
 39+ TECMD = (1 << 1); /* TE_CLR */
 40+ TFCMD = (1 << 1); /* TF_CLR */
 41+ TGCMD = (1 << 1); /* TG_CLR */
 42+ THCMD = (1 << 1); /* TH_CLR */
 43+
 44+ /* configure timer for 10 kHz */
 45+ TBPRE = 208 - 1; /* prescaler */
 46+ TBCON = (0 << 13) | /* TB_INT1_EN */
 47+ (1 << 12) | /* TB_INT0_EN */
 48+ (0 << 11) | /* TB_START */
 49+ (3 << 8) | /* TB_CS = PCLK / 64 */
 50+ (0 << 4); /* TB_MODE_SEL = interval mode */
 51+ TBDATA0 = cycles; /* set interval period */
 52+ TBCMD = (1 << 0); /* TB_EN */
3353 }
3454
 55+void INT_TIMERB(void)
 56+{
 57+ TBCON = TBCON;
 58+ scheduler_switch(-1);
 59+}
Index: embios/branches/4g_compat/target/ipodnano4g/crt0.S
@@ -84,7 +84,7 @@
8585 ldr sp, =_abortstackend
8686 msr cpsr_c, #0xdb
8787 ldr sp, =_abortstackend
88 - msr cpsr_c, #0xd3
 88+ msr cpsr_c, #0xdf
8989 ldr sp, =_initstackend
9090 bl init
9191 bl context_switch
Index: embios/branches/4g_compat/target/ipodnano4g/s5l8720.h
@@ -269,6 +269,30 @@
270270 #define TDDATA1 (*((volatile uint32_t*)(0x3C70006C)))
271271 #define TDPRE (*((volatile uint32_t*)(0x3C700070)))
272272 #define TDCNT (*((volatile uint32_t*)(0x3C700074)))
 273+#define TECON (*((volatile uint32_t*)(0x3C7000A0)))
 274+#define TECMD (*((volatile uint32_t*)(0x3C7000A4)))
 275+#define TEDATA0 (*((volatile uint32_t*)(0x3C7000A8)))
 276+#define TEDATA1 (*((volatile uint32_t*)(0x3C7000AC)))
 277+#define TEPRE (*((volatile uint32_t*)(0x3C7000B0)))
 278+#define TECNT (*((volatile uint32_t*)(0x3C7000B4)))
 279+#define TFCON (*((volatile uint32_t*)(0x3C7000C0)))
 280+#define TFCMD (*((volatile uint32_t*)(0x3C7000C4)))
 281+#define TFDATA0 (*((volatile uint32_t*)(0x3C7000C8)))
 282+#define TFDATA1 (*((volatile uint32_t*)(0x3C7000CC)))
 283+#define TFPRE (*((volatile uint32_t*)(0x3C7000D0)))
 284+#define TFCNT (*((volatile uint32_t*)(0x3C7000D4)))
 285+#define TGCON (*((volatile uint32_t*)(0x3C7000E0)))
 286+#define TGCMD (*((volatile uint32_t*)(0x3C7000E4)))
 287+#define TGDATA0 (*((volatile uint32_t*)(0x3C7000E8)))
 288+#define TGDATA1 (*((volatile uint32_t*)(0x3C7000EC)))
 289+#define TGPRE (*((volatile uint32_t*)(0x3C7000F0)))
 290+#define TGCNT (*((volatile uint32_t*)(0x3C7000F4)))
 291+#define THCON (*((volatile uint32_t*)(0x3C700100)))
 292+#define THCMD (*((volatile uint32_t*)(0x3C700104)))
 293+#define THDATA0 (*((volatile uint32_t*)(0x3C700108)))
 294+#define THDATA1 (*((volatile uint32_t*)(0x3C70010C)))
 295+#define THPRE (*((volatile uint32_t*)(0x3C700110)))
 296+#define THCNT (*((volatile uint32_t*)(0x3C700114)))
273297 uint64_t read_5usec_timer();
274298 #define FIVE_USEC_TIMER (read_5usec_timer()) /* 64bit 5usec timer */
275299
Index: embios/branches/4g_compat/target/ipodnano4g/interrupt.c
@@ -38,6 +38,10 @@
3939 default_interrupt(INT_TIMERB);
4040 default_interrupt(INT_TIMERC);
4141 default_interrupt(INT_TIMERD);
 42+default_interrupt(INT_TIMERE);
 43+default_interrupt(INT_TIMERF);
 44+default_interrupt(INT_TIMERG);
 45+default_interrupt(INT_TIMERH);
4246 default_interrupt(INT_DMA0);
4347 default_interrupt(INT_DMA1);
4448 default_interrupt(INT_DMA2);
@@ -80,7 +84,7 @@
8185
8286 static void (* const timervector[])(void) IDATA_ATTR =
8387 {
84 - INT_TIMERA,INT_TIMERB,INT_TIMERC,INT_TIMERD
 88+ INT_TIMERA,INT_TIMERB,INT_TIMERC,INT_TIMERD,INT_TIMERE,INT_TIMERF,INT_TIMERG,INT_TIMERH
8589 };
8690
8791 void INT_TIMER(void) ICODE_ATTR;
@@ -90,6 +94,10 @@
9195 if (TBCON & 0x00038000) timervector[1]();
9296 if (TCCON & 0x00038000) timervector[2]();
9397 if (TDCON & 0x00038000) timervector[3]();
 98+ if (TECON & 0x00038000) timervector[4]();
 99+ if (TFCON & 0x00038000) timervector[5]();
 100+ if (TGCON & 0x00038000) timervector[6]();
 101+ if (THCON & 0x00038000) timervector[7]();
94102 }
95103
96104 static void (* const dmavector[])(void) IDATA_ATTR =