4 * This file is part of BeRTOS.
\r
6 * Bertos is free software; you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation; either version 2 of the License, or
\r
9 * (at your option) any later version.
\r
11 * This program is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with this program; if not, write to the Free Software
\r
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\r
20 * As a special exception, you may use this file as part of a free software
\r
21 * library without restriction. Specifically, if other files instantiate
\r
22 * templates or use macros or inline functions from this file, or you compile
\r
23 * this file and link it with other files to produce an executable, this
\r
24 * file does not by itself cause the resulting executable to be covered by
\r
25 * the GNU General Public License. This exception does not however
\r
26 * invalidate any other reasons why the executable file might be covered by
\r
27 * the GNU General Public License.
\r
29 * Copyright 2009 Develer S.r.l. (http://www.develer.com/)
\r
33 * \version $Id: at91sam7s.c 2663 2009-04-24 16:30:11Z asterix $
\r
35 * \author Francesco Sacchi <batt@develer.com>
\r
36 * \author Daniele Basile <asterix@develer.com>
\r
38 * \brief Simple BeRTOS test on AT91SAM7X-EK evaluation board.
\r
40 * This short program shows you a simple demo of some BeRTOS feature:
\r
45 * - Cooperative BeRTOS Kernel
\r
49 #include "cfg/cfg_ser.h"
\r
50 #include <cfg/macros.h>
\r
52 #include <kern/proc.h>
\r
54 #include <drv/timer.h>
\r
55 #include <drv/sysirq_at91.h>
\r
56 #include <drv/ser.h>
\r
65 * Supercar leds effect..
\r
67 static void leds_toggle(void)
\r
69 uint32_t a = (~PIOB_ODSR & 0x780000);
\r
71 // Turn on led in forward direction
\r
80 // Turn on led in backward direction
\r
89 // Start to turn on first led
\r
92 PIOB_SODR = 0x780000;
\r
93 /* turn first led on */
\r
94 PIOB_CODR = 0x80000;
\r
98 /* Wait for interval time */
\r
99 timer_setDelay(&leds_timer, ms_to_ticks(100));
\r
100 timer_add(&leds_timer);
\r
104 { char msg[]="BeRTOS, be fast be beatiful be realtime";
\r
111 ASSERT(!IRQ_ENABLED());
\r
113 /* Open the main communication port */
\r
114 ser_init(&ser_fd, 0);
\r
115 ser_setbaudrate(&ser_fd, 115200);
\r
116 ser_setparity(&ser_fd, SER_PARITY_NONE);
\r
119 ASSERT(IRQ_ENABLED());
\r
121 /* Disable all pullups */
\r
122 PIOB_PUDR = 0xffffffff;
\r
123 /* Set PB0..3 connected to PIOA */
\r
124 PIOB_PER = 0x780000;
\r
125 /* Set PB0..3 as output */
\r
126 PIOB_OER = 0x780000;
\r
127 /* Disable multidrive on all pins */
\r
128 PIOB_MDDR = 0xffffffff;
\r
130 /* Set PA0..3 to 1 to turn off leds */
\r
131 PIOB_SODR = 0x780000;
\r
133 /* turn first led on */
\r
134 PIOB_CODR = 0x80000;
\r
137 * Register timer and arm timer interupt.
\r
139 timer_setSoftint(&leds_timer, (Hook)leds_toggle, 0);
\r
140 timer_setDelay(&leds_timer, ms_to_ticks(100));
\r
141 timer_add(&leds_timer);
\r
144 * Run process test.
\r
146 if(!proc_testRun())
\r
147 kfile_printf(&ser_fd.fd, "ProcTest..ok!\n");
\r
149 kfile_printf(&ser_fd.fd, "ProcTest..FAIL!\n");
\r
154 kfile_printf(&ser_fd.fd, "From serial 0: %s\r\n", msg);
\r