summaryrefslogtreecommitdiff
path: root/openpicc/application/clock_switch.c
diff options
context:
space:
mode:
authorhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2008-03-05 05:03:36 +0000
committerhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2008-03-05 05:03:36 +0000
commit6304718e371e590b09e176c05df21fc5fb631cec (patch)
tree49004ef275322a779594d8ebd5d69c9da8ba1d4e /openpicc/application/clock_switch.c
parent3ee3c4a649545d1f132bca61cc7484f0d5c92638 (diff)
Port over the differential miller decoder from the sniffonly host tool
Move clock switch to its own header file Specify default (and for non-clock switching capable hardware: single) clock source in hardware definitions git-svn-id: https://svn.openpcd.org:2342/trunk@443 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'openpicc/application/clock_switch.c')
-rw-r--r--openpicc/application/clock_switch.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/openpicc/application/clock_switch.c b/openpicc/application/clock_switch.c
new file mode 100644
index 0000000..16c1bf1
--- /dev/null
+++ b/openpicc/application/clock_switch.c
@@ -0,0 +1,53 @@
+/***************************************************************
+ *
+ * OpenPICC - clock switch driver
+ *
+ * Copyright 2008 Henryk Plötz <henryk@ploetzli.ch>
+ *
+ ***************************************************************
+
+ 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.
+
+*/
+
+#include <FreeRTOS.h>
+#include <openpicc.h>
+
+#include "clock_switch.h"
+
+static int initialized = 0;
+
+void clock_switch(enum clock_source clock)
+{
+ if(!OPENPICC->features.clock_switching) return;
+ if(!initialized)
+ AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, OPENPICC->CLOCK_SWITCH);
+
+ switch(clock) {
+ case CLOCK_SELECT_PLL:
+ AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, OPENPICC->CLOCK_SWITCH);
+ break;
+ case CLOCK_SELECT_CARRIER:
+ AT91F_PIO_SetOutput(AT91C_BASE_PIOA, OPENPICC->CLOCK_SWITCH);
+ break;
+ }
+}
+
+void clock_switch_init(void)
+{
+ if(!OPENPICC->features.clock_switching) return;
+ AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, OPENPICC->CLOCK_SWITCH);
+ clock_switch(OPENPICC->default_clock);
+ initialized = 1;
+}
personal git repositories of Harald Welte. Your mileage may vary