1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/***************************************************************
*
* OpenBeacon.org - main entry for 2.4GHz RFID USB reader
*
* Copyright 2007 Milosch Meriac <meriac@openbeacon.de>
*
* basically starts the USB task, initializes all IO ports
* and introduces idle application hook to handle the HF traffic
* from the nRF24L01 chip
*
***************************************************************
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.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* Library includes. */
#include <string.h>
#include <stdio.h>
#include <FreeRTOS.h>
#include <AT91SAM7.h>
#include <USB-CDC.h>
#include <task.h>
#include "openpicc.h"
#include "board.h"
#include "led.h"
#include "env.h"
#include "cmd.h"
#include "da.h"
#include "adc.h"
#include "pll.h"
#include "pio_irq.h"
#include "ssc_picc.h"
#include "tc_cdiv.h"
#include "tc_cdiv_sync.h"
/**********************************************************************/
static inline void prvSetupHardware (void)
{
/* When using the JTAG debugger the hardware is not always initialised to
the correct default state. This line just ensures that this does not
cause all interrupts to be masked at the start. */
AT91C_BASE_AIC->AIC_EOICR = 0;
/* Enable the peripheral clock. */
AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_PIOA;
AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_PIOB;
/* initialize environment variables */
env_init();
if(!env_load())
{
env.e.mode=0;
env.e.reader_id=255;
env_store();
}
}
/**********************************************************************/
void vApplicationIdleHook(void)
{
static char disabled_green = 0;
/* Restart watchdog, has been enabled in Cstartup_SAM7.c */
AT91F_WDTRestart(AT91C_BASE_WDTC);
if(!disabled_green) {
//vLedSetGreen(0);
disabled_green = 1;
}
}
/**********************************************************************/
int main (void)
{
prvSetupHardware ();
pio_irq_init();
vLedInit();
da_init();
adc_init();
pll_init();
tc_cdiv_init();
tc_cdiv_sync_init();
ssc_tx_init();
//ssc_rx_init();
xTaskCreate (vUSBCDCTask, (signed portCHAR *) "USB", TASK_USB_STACK,
NULL, TASK_USB_PRIORITY, NULL);
vCmdInit();
//vLedSetGreen(1);
vTaskStartScheduler ();
return 0;
}
|