summaryrefslogtreecommitdiff
path: root/openpicc/application/main.c
diff options
context:
space:
mode:
authorhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2007-11-06 20:26:48 +0000
committerhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2007-11-06 20:26:48 +0000
commit633c646ab36368caf6eaeedd326d9f1835196afd (patch)
treefdd0f60747745d3e528c0f5d8f8895b26fb79633 /openpicc/application/main.c
parent3b41196cb6b64cf6ba8ba41d6995428f73d4764a (diff)
Initial import of FreeRTOS code for OpenPICC
git-svn-id: https://svn.openpcd.org:2342/trunk@311 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'openpicc/application/main.c')
-rw-r--r--openpicc/application/main.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/openpicc/application/main.c b/openpicc/application/main.c
new file mode 100644
index 0000000..6dc9637
--- /dev/null
+++ b/openpicc/application/main.c
@@ -0,0 +1,93 @@
+/***************************************************************
+ *
+ * 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"
+
+/**********************************************************************/
+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 ();
+
+ vLedInit();
+
+ xTaskCreate (vUSBCDCTask, (signed portCHAR *) "USB", TASK_USB_STACK,
+ NULL, TASK_USB_PRIORITY, NULL);
+
+ vCmdInit();
+
+ vLedSetGreen(1);
+
+ vTaskStartScheduler ();
+
+ return 0;
+}
personal git repositories of Harald Welte. Your mileage may vary