sam7fc/main.c

113 lines
3.1 KiB
C
Raw Normal View History

2008-02-03 21:41:39 +01:00
/***************************************************************************
* 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 "AT91SAM7S256.h"
#include "at91_sysc.h"
#include "at91_dbgu.h"
#include "at91_pitc.h"
2008-03-10 21:37:56 +01:00
#include "at91_adc.h"
2008-02-03 21:41:39 +01:00
#include "at91_tests.h"
#include "at91_udp.h"
#include "at91_pio.h"
#include "at91_twi.h"
#include "at91_tc1.h"
2008-02-06 14:20:47 +01:00
#include "memalloc.h"
2008-02-03 21:41:39 +01:00
#include "board.h"
#include <stdio.h>
#include <string.h>
static uint32_t pitc_test(struct pitc_timer *timer)
2008-02-04 18:19:25 +01:00
{
2008-02-03 21:41:39 +01:00
static uint32_t i;
*AT91C_PIOA_SODR = i;
i = i ^ LED_GREEN;
*AT91C_PIOA_CODR = i;
2008-02-06 22:18:33 +01:00
/*
2008-02-03 21:41:39 +01:00
struct rc_values rc;
2008-02-04 18:19:25 +01:00
uint32_t count = rcontrol_getvalues(&rc);
printf("%ld channels: ", count);
2008-02-03 21:41:39 +01:00
uint32_t j;
2008-02-04 18:19:25 +01:00
for (j = 0; j < count; j++)
2008-02-04 19:00:32 +01:00
printf("%+5d ", rc.chan[j]);
2008-02-04 18:19:25 +01:00
2008-02-04 19:00:32 +01:00
printf("\r");
2008-03-05 15:33:44 +01:00
2008-03-10 21:37:56 +01:00
static uint32_t cnt;
if (cnt++ == 300) {
rcontrol_calibrate(RC_CAL_END);
printf("\n\r");
rcontrol_print_cal();
}
*/
/*
2008-03-05 19:35:00 +01:00
static uint8_t data[4] = { 0x00, 0x00, 0x00, 0x00 };
2008-03-05 15:33:44 +01:00
twi_setpwm(data);
2008-03-10 21:37:56 +01:00
*/
adc_trigger();
2008-03-05 15:33:44 +01:00
2008-02-04 18:19:25 +01:00
return PITC_RESTART_TIMER;
2008-02-03 21:41:39 +01:00
}
2008-02-06 17:56:27 +01:00
static struct pitc_timer pitc_test_timer = {
2008-03-10 21:37:56 +01:00
.interval = 20,
2008-02-06 17:56:27 +01:00
.func = &pitc_test,
};
2008-02-03 21:41:39 +01:00
int main(void)
{
/* LED outputs */
*AT91C_PIOA_PER = LED_GREEN | LED_ORANGE;
*AT91C_PIOA_OER = LED_GREEN | LED_ORANGE;
/* needed for dbgu */
at91_sysc_init();
2008-02-04 18:19:25 +01:00
2008-02-03 21:41:39 +01:00
at91_dbgu_init();
at91_dbgu_puts("==========================================================\n\rGood morning Dave\n\r");
2008-02-04 18:19:25 +01:00
/* triggers pinchange-isrs */
at91_pio_init();
2008-02-03 21:41:39 +01:00
/* timer */
at91_pitc_init();
at91_rttc_test_init();
at91_tc1_init();
/* twi */
at91_twi_init();
2008-03-10 21:37:56 +01:00
at91_twi_test();
2008-02-04 18:19:25 +01:00
2008-02-03 21:41:39 +01:00
/* usb */
2008-02-06 22:18:33 +01:00
at91_udp_init();
2008-02-03 21:41:39 +01:00
printf("static alloc: %5ld bytes\n\r", static_alloc_used());
2008-03-05 15:33:44 +01:00
/* adc, need timer */
2008-03-10 21:37:56 +01:00
at91_adc_init();
2008-03-05 19:35:00 +01:00
2008-03-10 21:37:56 +01:00
pitc_schedule_timer(&pitc_test_timer);
2008-02-06 17:56:27 +01:00
2008-03-10 21:37:56 +01:00
// rcontrol_calibrate(RC_CAL_START);
2008-02-03 21:41:39 +01:00
while (1);
}