Project

General

Profile

Download (1.56 KB) Statistics
| Branch: | Tag: | Revision:
1 6304718e henryk
/***************************************************************
2
 *
3
 * OpenPICC - clock switch driver
4
 * 
5
 * Copyright 2008 Henryk Plötz <henryk@ploetzli.ch>
6
 *
7
 ***************************************************************
8
9
    This program is free software; you can redistribute it and/or modify
10
    it under the terms of the GNU General Public License as published by
11
    the Free Software Foundation; version 2.
12
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17
18
    You should have received a copy of the GNU General Public License along
19
    with this program; if not, write to the Free Software Foundation, Inc.,
20
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22
*/
23
24
#include <FreeRTOS.h>
25
#include <openpicc.h>
26
27
#include "clock_switch.h"
28
29
static int initialized = 0;
30
31
void clock_switch(enum clock_source clock)
32
{
33
	if(!OPENPICC->features.clock_switching) return;
34
	if(!initialized)
35
		AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, OPENPICC->CLOCK_SWITCH);
36
	
37
	switch(clock) {
38
	case CLOCK_SELECT_PLL:
39
		AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, OPENPICC->CLOCK_SWITCH);
40
		break;
41
	case CLOCK_SELECT_CARRIER:
42
		AT91F_PIO_SetOutput(AT91C_BASE_PIOA, OPENPICC->CLOCK_SWITCH);
43
		break;
44
	}
45
}
46
47
void clock_switch_init(void)
48
{
49
	if(!OPENPICC->features.clock_switching) return;
50
	AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, OPENPICC->CLOCK_SWITCH);
51
	clock_switch(OPENPICC->default_clock);
52
	initialized = 1;
53
}
Add picture from clipboard (Maximum size: 48.8 MB)