X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=examples%2Flm3s1968%2Flm3s1968.c;h=edf7211071c1951f4e4d385c7ae91d5f357b4193;hb=378957f3d75a6bfe1f449e43659c9e2871757491;hp=514f255ca5201c080cfd51e87ae3fc4448a1580f;hpb=24c21c92d29b76a3f0de0a107f4bafef7bb0f812;p=bertos.git diff --git a/examples/lm3s1968/lm3s1968.c b/examples/lm3s1968/lm3s1968.c index 514f255c..edf72110 100644 --- a/examples/lm3s1968/lm3s1968.c +++ b/examples/lm3s1968/lm3s1968.c @@ -26,24 +26,71 @@ * 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 - * - * \brief LM3S168 porting test. + * \author Andrea Righi */ -#include "bertos/cpu/detect.h" +#include +#include +#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; +} -int main (void) +static void led_off(void) { - int c; + GPIO_PORTG_DATA_R &= ~0x04; +} + +static NORETURN void spinner_thread(void) +{ + char spinner[] = {'/', '-', '\\', '|'}; + int i; + + kputs("\n"); + for(i = 0; ; i++) + { + kprintf("BeRTOS is up & running: %c\r", + spinner[i % countof(spinner)]); + timer_delay(100); + } +} + +int main(void) +{ + IRQ_ENABLE; + led_init(); + + proc_testSetup(); + proc_testRun(); - for (;;) - c++; - return 0; + proc_new(spinner_thread, NULL, KERN_MINSTACKSIZE, NULL); + while(1) + { + led_on(); + timer_delay(250); + led_off(); + timer_delay(250); + } }