From: asterix Date: Mon, 27 Apr 2009 14:17:01 +0000 (+0000) Subject: Use same main for both sam7 proj. X-Git-Tag: 2.1.0~4 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=c3940812348cdbd6ff4dd62a0577a97d75fe8765;p=bertos.git Use same main for both sam7 proj. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2678 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/examples/at91sam7/at91sam7.c b/examples/at91sam7/at91sam7.c new file mode 100644 index 00000000..04ee19f2 --- /dev/null +++ b/examples/at91sam7/at91sam7.c @@ -0,0 +1,189 @@ +/** + * \file + * + * + * \version $Id$ + * + * \author Francesco Sacchi + * \author Daniele Basile + * + * \brief Simple BeRTOS test on AT91SAM7X-EK evaluation board. + * + * This short program shows you a simple demo of some BeRTOS feature: + * + * - Debug system + * - Timer interrupt + * - Serial + * - Cooperative BeRTOS Kernel + * + */ + +#include "cfg/cfg_ser.h" +#include + +#include + +#include + +#include +#include +#include + +#include + +Timer leds_timer; +Serial ser_fd; + +enum +{ + FORWARD, + BACKWARD, +}; + +int direction = FORWARD; + +static void leds_init(void) +{ + #if CPU_ARM_AT91SAM7X256 + /* Set PB19..22 connected to PIOB */ + PIOB_PER = 0x780000; + /* Set PB19..22 as output */ + PIOB_OER = 0x780000; + + /* Set PB19..22 to 1 to turn off leds */ + PIOB_SODR = 0x780000; + + /* turn first led on (PB19) */ + PIOB_CODR = 0x80000; + #elif CPU_ARM_AT91SAM7S256 + /* Set PA0..3 connected to PIOA */ + PIOA_PER = 0x0000001f; + /* Set PA0..3 as output */ + PIOA_OER = 0x0000001f; + + /* Set PA0..3 to 1 to turn off leds */ + PIOA_SODR = 0x0000000f; + /* turn first led on (PA0) */ + PIOA_CODR = 0x00000001; + #endif +} + +#if CPU_ARM_AT91SAM7X256 + #define GET_PIO_STATUS() (~PIOB_ODSR & 0x780000) + #define LAST_LED 0x200000 + #define FIRST_LED 0x100000 + #define SET_PIO_BITS PIOB_SODR + #define CLEAR_PIO_BITS PIOB_CODR + #define AT91SAM7_MSG "BeRTOS is run on AT91SAM7X256..\n" +#elif CPU_ARM_AT91SAM7S256 + #define GET_PIO_STATUS() (~PIOA_ODSR & 0x0000000f) + #define LAST_LED 0x00000004 + #define FIRST_LED 0x00000002 + #define SET_PIO_BITS PIOA_SODR + #define CLEAR_PIO_BITS PIOA_CODR + #define AT91SAM7_MSG "BeRTOS is run on AT91SAM7S256..\n" +#endif + +/* + * Knight Rider leds effect.. + */ +static void leds_toggle(void) +{ + uint32_t led_status = GET_PIO_STATUS(); + + // Turn on led in forward direction + if (direction == FORWARD) + { + if(led_status == LAST_LED) + direction = BACKWARD; + + SET_PIO_BITS = led_status; + CLEAR_PIO_BITS = led_status << 1; + } + // Turn on led in backward direction + else if (direction == BACKWARD) + { + if(led_status == FIRST_LED) + direction = FORWARD; + + SET_PIO_BITS = led_status; + CLEAR_PIO_BITS = led_status >> 1; + } + + /* Wait for interval time */ + timer_setDelay(&leds_timer, ms_to_ticks(100)); + timer_add(&leds_timer); +} + +int main(void) +{ char msg[]="BeRTOS, be fast be beatiful be realtime"; + + + kdbg_init(); + timer_init(); + proc_init(); + leds_init(); + + ASSERT(!IRQ_ENABLED()); + + /* Open the main communication port */ + ser_init(&ser_fd, 0); + ser_setbaudrate(&ser_fd, 115200); + ser_setparity(&ser_fd, SER_PARITY_NONE); + + IRQ_ENABLE; + ASSERT(IRQ_ENABLED()); + + /* + * Register timer and arm timer interupt. + */ + timer_setSoftint(&leds_timer, (Hook)leds_toggle, 0); + timer_setDelay(&leds_timer, ms_to_ticks(100)); + timer_add(&leds_timer); + + /* + * Run process test. + */ + if(!proc_testRun()) + kfile_printf(&ser_fd.fd, "ProcTest..ok!\n"); + else + kfile_printf(&ser_fd.fd, "ProcTest..FAIL!\n"); + + + kputs(AT91SAM7_MSG); + + // Main loop + for(;;) + { + kfile_printf(&ser_fd.fd, "From serial 0: %s\r\n", msg); + } + return 0; +} diff --git a/examples/at91sam7/at91sam7s.c b/examples/at91sam7/at91sam7s.c deleted file mode 100644 index 04ee19f2..00000000 --- a/examples/at91sam7/at91sam7s.c +++ /dev/null @@ -1,189 +0,0 @@ -/** - * \file - * - * - * \version $Id$ - * - * \author Francesco Sacchi - * \author Daniele Basile - * - * \brief Simple BeRTOS test on AT91SAM7X-EK evaluation board. - * - * This short program shows you a simple demo of some BeRTOS feature: - * - * - Debug system - * - Timer interrupt - * - Serial - * - Cooperative BeRTOS Kernel - * - */ - -#include "cfg/cfg_ser.h" -#include - -#include - -#include - -#include -#include -#include - -#include - -Timer leds_timer; -Serial ser_fd; - -enum -{ - FORWARD, - BACKWARD, -}; - -int direction = FORWARD; - -static void leds_init(void) -{ - #if CPU_ARM_AT91SAM7X256 - /* Set PB19..22 connected to PIOB */ - PIOB_PER = 0x780000; - /* Set PB19..22 as output */ - PIOB_OER = 0x780000; - - /* Set PB19..22 to 1 to turn off leds */ - PIOB_SODR = 0x780000; - - /* turn first led on (PB19) */ - PIOB_CODR = 0x80000; - #elif CPU_ARM_AT91SAM7S256 - /* Set PA0..3 connected to PIOA */ - PIOA_PER = 0x0000001f; - /* Set PA0..3 as output */ - PIOA_OER = 0x0000001f; - - /* Set PA0..3 to 1 to turn off leds */ - PIOA_SODR = 0x0000000f; - /* turn first led on (PA0) */ - PIOA_CODR = 0x00000001; - #endif -} - -#if CPU_ARM_AT91SAM7X256 - #define GET_PIO_STATUS() (~PIOB_ODSR & 0x780000) - #define LAST_LED 0x200000 - #define FIRST_LED 0x100000 - #define SET_PIO_BITS PIOB_SODR - #define CLEAR_PIO_BITS PIOB_CODR - #define AT91SAM7_MSG "BeRTOS is run on AT91SAM7X256..\n" -#elif CPU_ARM_AT91SAM7S256 - #define GET_PIO_STATUS() (~PIOA_ODSR & 0x0000000f) - #define LAST_LED 0x00000004 - #define FIRST_LED 0x00000002 - #define SET_PIO_BITS PIOA_SODR - #define CLEAR_PIO_BITS PIOA_CODR - #define AT91SAM7_MSG "BeRTOS is run on AT91SAM7S256..\n" -#endif - -/* - * Knight Rider leds effect.. - */ -static void leds_toggle(void) -{ - uint32_t led_status = GET_PIO_STATUS(); - - // Turn on led in forward direction - if (direction == FORWARD) - { - if(led_status == LAST_LED) - direction = BACKWARD; - - SET_PIO_BITS = led_status; - CLEAR_PIO_BITS = led_status << 1; - } - // Turn on led in backward direction - else if (direction == BACKWARD) - { - if(led_status == FIRST_LED) - direction = FORWARD; - - SET_PIO_BITS = led_status; - CLEAR_PIO_BITS = led_status >> 1; - } - - /* Wait for interval time */ - timer_setDelay(&leds_timer, ms_to_ticks(100)); - timer_add(&leds_timer); -} - -int main(void) -{ char msg[]="BeRTOS, be fast be beatiful be realtime"; - - - kdbg_init(); - timer_init(); - proc_init(); - leds_init(); - - ASSERT(!IRQ_ENABLED()); - - /* Open the main communication port */ - ser_init(&ser_fd, 0); - ser_setbaudrate(&ser_fd, 115200); - ser_setparity(&ser_fd, SER_PARITY_NONE); - - IRQ_ENABLE; - ASSERT(IRQ_ENABLED()); - - /* - * Register timer and arm timer interupt. - */ - timer_setSoftint(&leds_timer, (Hook)leds_toggle, 0); - timer_setDelay(&leds_timer, ms_to_ticks(100)); - timer_add(&leds_timer); - - /* - * Run process test. - */ - if(!proc_testRun()) - kfile_printf(&ser_fd.fd, "ProcTest..ok!\n"); - else - kfile_printf(&ser_fd.fd, "ProcTest..FAIL!\n"); - - - kputs(AT91SAM7_MSG); - - // Main loop - for(;;) - { - kfile_printf(&ser_fd.fd, "From serial 0: %s\r\n", msg); - } - return 0; -} diff --git a/examples/at91sam7/at91sam7s.mk b/examples/at91sam7/at91sam7s.mk index d4585d27..55fc19cf 100644 --- a/examples/at91sam7/at91sam7s.mk +++ b/examples/at91sam7/at91sam7s.mk @@ -16,7 +16,7 @@ at91sam7s_DEBUG = 1 TRG += at91sam7s at91sam7s_CSRC = \ - examples/at91sam7s/at91sam7s.c \ + examples/at91sam7/at91sam7.c \ bertos/drv/timer.c \ bertos/drv/ser.c \ bertos/cpu/arm/drv/sysirq_at91.c \ diff --git a/examples/at91sam7/at91sam7x.mk b/examples/at91sam7/at91sam7x.mk index 2a3bcfc8..404d92da 100644 --- a/examples/at91sam7/at91sam7x.mk +++ b/examples/at91sam7/at91sam7x.mk @@ -16,7 +16,7 @@ at91sam7x_DEBUG = 1 TRG += at91sam7x at91sam7x_CSRC = \ - examples/at91sam7x/at91sam7x.c \ + examples/at91sam7/at91sam7.c \ bertos/drv/timer.c \ bertos/drv/ser.c \ bertos/cpu/arm/drv/sysirq_at91.c \