# clock.h File Reference

Support for changing/setting the system clock speed. More...

`#include "SFBTypes.h"`

Include dependency graph for clock.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures
struct | clockConfiguration
| The internal hardware parameters associated with a given CPU clock speed. More...
## Typedefs
typedef struct clockConfiguration | ClockConfiguration
| The internal hardware parameters associated with a given CPU clock speed.
typedef void(* | ClockSpeedChangeCallback )(u32 newClockSpeed)
| Declaration for a handler function to be called after a clock speed change has occurred.
## Enumerations
enum | ClockSpeedCode { CSC_UNSET = 0, CSC_12MHZ = 1, CSC_24MHZ = 2, CSC_36MHZ = 3, CSC_48MHZ = 4, CSC_60MHZ = 5, CSC_72MHZ = 6, CSC_MAX = 7, CSC_MIN_MHZ = CSC_12MHZ, CSC_MAX_MHZ = CSC_72MHZ, CSC_AUTO = 8 }
| The possible 'speed code' values for setting the CPU clock speed, as used by SFBProcessor::getCode and SFBProcessor::setCode. More...
## Functions
const ClockConfiguration * | getCurrentClockConfiguration ()
| Access the parameters of the current clock configuration.
const ClockConfiguration * | getClockConfigurationForCode (u32 code)
| Access the parameters of the clock configuration associated with code.
u32 | getCCLK ()
| Return the current clock speed in Hz.
u8 | getCCLKCode ()
| Return the current clock speed code.
void | setClockSpeed (u32 code)
| Set the clock speed to code.
ClockSpeedChangeCallback | setClockSpeedChangeCallback (ClockSpeedChangeCallback callback)
| Set the handler function to be called after a clock speed change has occurred to callback.

## Detailed Description

Support for changing/setting the system clock speed.

Author:
  David H. Ackley.

Date:
  (C) 2009 All rights reserved.

Code License:
  The GNU Lesser General Public License

License Note:
  All code samples shown in documentation are placed into the public domain.

## Typedef Documentation

typedef struct clockConfiguration ClockConfiguration

The internal hardware parameters associated with a given CPU clock speed.

Primarily intended for internal use.

typedef void(* ClockSpeedChangeCallback)(u32 newClockSpeed)

Declaration for a handler function to be called after a clock speed change has occurred.

## Enumeration Type Documentation

enum ClockSpeedCode

The possible 'speed code' values for setting the CPU clock speed, as used by SFBProcessor::getCode and SFBProcessor::setCode.

Enumerator:

  CSC_12MHZ | Code representing 12MHz processor speed.
  CSC_24MHZ | Code representing 24MHz processor speed.
  CSC_36MHZ | Code representing 36MHz processor speed.
  CSC_48MHZ | Code representing 48MHz processor speed.
  CSC_60MHZ | Code representing 60MHz processor speed.
  CSC_72MHZ | Code representing 72MHz processor speed.
  CSC_MIN_MHZ | Code representing the slowest supported processor speed.
  CSC_MAX_MHZ | Code representing the fastest supported processor speed.

## Function Documentation

u32 getCCLK | ( |  | ) |

Return the current clock speed in Hz.

u8 getCCLKCode | ( |  | ) |

Return the current clock speed code.

const ClockConfiguration* getClockConfigurationForCode | ( | u32 | code | ) |

Access the parameters of the clock configuration associated with code.

Primarily intended for internal use.

const ClockConfiguration* getCurrentClockConfiguration | ( |  | ) |

Access the parameters of the current clock configuration.

Primarily intended for internal use.

void setClockSpeed | ( | u32 | code | ) |

Set the clock speed to code.

ClockSpeedChangeCallback setClockSpeedChangeCallback | ( | ClockSpeedChangeCallback | callback | ) |

Set the handler function to be called after a clock speed change has occurred to callback.

Avoid using this callback mechanism if possible! It is dangerous!

Would-be users of this mechanism be aware of the following:

1. The supplied callback function will be called with interrupts disabled, and for successful use the callback function should not reenable them, should not perform any operations depending on interrupts, and should not take very much time to execute.
2. The supplied callback function may be called multiple times as the result of a single setClockSpeed call, due to intermediate speed changes on the way to the final value.

Parameters:

  | callback | Pointer to handler function, or 0 to specify no function should be called back

Returns:
  The previous values of the handler.