# clock.h

Go to the documentation of this file.

    00001 /*                                             -*- mode:C++; fill-column:100  -*-
    00002   clock.h Support for changing/setting the system clock speed
    00003   Copyright (C) 2010 The Regents of the University of New Mexico.  All rights reserved.
    00004
    00005   This library is free software; you can redistribute it and/or
    00006   modify it under the terms of the GNU Lesser General Public
    00007   License as published by the Free Software Foundation; either
    00008   version 2.1 of the License, or (at your option) any later version.
    00009
    00010   This library is distributed in the hope that it will be useful,
    00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013   Lesser General Public License for more details.
    00014
    00015   You should have received a copy of the GNU General Public License
    00016   along with this library; if not, write to the Free Software
    00017   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
    00018   USA
    00019 */
    00027 #ifndef CLOCK_H_
    00028 #define CLOCK_H_
    00029
    00030 #include "SFBTypes.h"
    00031
    00032 #ifdef __cplusplus
    00033 extern "C"{
    00034 #endif
    00035
    00040 enum ClockSpeedCode {
    00041   CSC_UNSET = 0,
    00042   CSC_12MHZ = 1,
    00043   CSC_24MHZ = 2,
    00044   CSC_36MHZ = 3,
    00045   CSC_48MHZ = 4,
    00046   CSC_60MHZ = 5,
    00047   CSC_72MHZ = 6,
    00049   CSC_MAX = 7,
    00050
    00051   CSC_MIN_MHZ = CSC_12MHZ,
    00052   CSC_MAX_MHZ = CSC_72MHZ,
    00054   CSC_AUTO = 8
    00055 };
    00056
    00059 typedef struct clockConfiguration {
    00060   u8 pllMulM;
    00061   u8 pllDivN;
    00062   u8 clkDiv;
    00063   u8 mamtim;
    00064   u8 pclkDiv;
    00065   u8 pclkMHz;
    00066 } ClockConfiguration;
    00067
    00070 extern const ClockConfiguration * getCurrentClockConfiguration() ;
    00071
    00074 extern const ClockConfiguration * getClockConfigurationForCode(u32 code) ;
    00075
    00077 extern u32 getCCLK() ;
    00078
    00080 extern u8 getCCLKCode() ;
    00081
    00083 extern void setClockSpeed(u32 code) ;
    00084
    00086 typedef void (*ClockSpeedChangeCallback)(u32 newClockSpeed);
    00087
    00103 extern ClockSpeedChangeCallback setClockSpeedChangeCallback(ClockSpeedChangeCallback callback) ;
    00104
    00105 #ifdef __cplusplus
    00106 } /* extern "C" */
    00107 #endif
    00108
    00109 #endif /*CLOCK_H_*/