examples: add a simple LM3S1968 Cortex-M3 testcase.
[bertos.git] / examples / lm3s1968 / lm3s1968.c
index 514f255ca5201c080cfd51e87ae3fc4448a1580f..6316ad18373e09b0c9c1e795c35538b945f2c255 100644 (file)
  * invalidate any other reasons why the executable file might be covered by
  * the GNU General Public License.
  *
- * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2010 Develer S.r.l. (http://www.develer.com/)
  *
  * -->
  *
- * \version $Id$
+ * \brief LM3S1968 Cortex-M3 testcase
  *
- * \author Manuele Fanelli <qwert@develer.com>
- *
- * \brief LM3S168 porting test.
+ * \author Andrea Righi <arighi@develer.com>
  */
 
-#include "bertos/cpu/detect.h"
+#include <cpu/irq.h>
+#include "io/lm3s.h"
+#include "drv/timer.h"
+
+extern unsigned long ticks;
 
-int main (void)
+int main(void)
 {
-       int c;
+       timer_hw_init();
+
+       /* Enable the GPIO port that is used for the on-board LED */
+       SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOG;
+       /*
+        * Perform a dummy read to insert a few cycles delay before enabling
+        * the peripheral.
+        */
+       (void)SYSCTL_RCGC2_R;
+       /* Enable the GPIO pin for the LED */
+       GPIO_PORTG_DIR_R = 0x04;
+       GPIO_PORTG_DEN_R = 0x04;
 
-       for (;;)
-               c++;
-       return 0;
+       while(1)
+       {
+               /* Turn on the LED */
+               if ((ticks & 0x04) == 0x04)
+                       GPIO_PORTG_DATA_R |= 0x04;
+               /* Turn off the LED */
+               else if ((ticks & 0x04) == 0)
+                       GPIO_PORTG_DATA_R &= ~0x04;
+       }
 }