lm3s1968: integrate the hardware timer driver into the main timer module.
[bertos.git] / examples / lm3s1968 / lm3s1968.c
index 514f255ca5201c080cfd51e87ae3fc4448a1580f..9dfaf006a868f1cdb86b2fc2c0ae950c4ffc6466 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 <drv/timer.h>
+#include "io/lm3s.h"
+
+static void led_init(void)
+{
+       /* 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;
+}
+
+static void led_on(void)
+{
+       GPIO_PORTG_DATA_R |= 0x04;
+}
+
+static void led_off(void)
+{
+       GPIO_PORTG_DATA_R &= ~0x04;
+}
 
-int main (void)
+int main(void)
 {
-       int c;
+       IRQ_ENABLE;
+       kdbg_init();
+       timer_init();
+       led_init();
 
-       for (;;)
-               c++;
-       return 0;
+       while(1)
+       {
+               kputs("STATUS LED: on \r");
+               led_on();
+               timer_delay(1000);
+               kputs("STATUS LED: off\r");
+               led_off();
+               timer_delay(1000);
+       }
 }