sam7fc/main.c

72 lines
2.5 KiB
C

/***************************************************************************
* Copyright (C) 01/2008 by Olaf Rempel *
* razzor@kopf-tisch.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; version 2 of the License *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "AT91SAM7S256.h"
#include "board.h"
#include "at91_sysc.h"
#include "at91_dbgu.h"
#include "at91_pio.h"
#include "rtos/context.h"
#include "rtos/semaphore.h"
static struct semaphore sem;
void testisr(uint32_t status, uint32_t input)
{
printf("testisr: sem_post()\n\r");
sem_post(&sem);
}
void testfunc(void *p)
{
while (1) {
printf("testfunc(%ld): sem_wait()\n\r", (uint32_t)p);
sem_wait(&sem);
}
}
int main(void)
{
/* LED outputs */
*AT91C_PIOA_PER = LED_GREEN | LED_ORANGE;
*AT91C_PIOA_OER = LED_GREEN | LED_ORANGE;
at91_sysc_init();
at91_dbgu_init();
at91_dbgu_puts("==========================================================\n\rGood morning Dave\n\r");
at91_pio_init();
struct context *text_ctx1 = create_ctx(512, 0x80, testfunc, (void *)1);
printf("test_ctx(1)=%p\n\r", text_ctx1);
struct context *text_ctx2 = create_ctx(512, 0x80, testfunc, (void *)2);
printf("test_ctx(2)=%p\n\r", text_ctx2);
sem_init(&sem, 0);
init_context();
}
PIO_PINCHANGE_ISR(TAST1, testisr);