cs2200.c File Reference


Detailed Description

Driver of the CS2200 cloking device chip.

The CS2200-CP is an extremely versatile system clocking device that utilizes a programmable phase lock loop. The CS2200-CP is based on an analog PLL architecture comprised of a Delta-Sigma Fractional-N Frequency Synthesizer. This architecture allows for frequency synthesis and clock generation from a stable reference clock.

The datasheet can be downloaded here: http://www.cirrus.com/en/pubs/proDatasheet/CS2200-CP_F1.pdf

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file cs2200.c.

#include <avr32/io.h>
#include "compiler.h"
#include "cs2200.h"
#include "gpio.h"
#include "board.h"

Go to the source code of this file.

Defines

Expected Protocol Version
#define CS2200_DEVICE_CTRL_LOCKED   0x00
#define CS2200_EXPECTED_DEVICE_ID   0x00
Device ID Register Bit-Masks
#define CS2200_DEVICE_CTRL_UNLOCK_REG_MASK   0x80
#define CS2200_DEVICE_CTRL_UNLOCK_REG_OFFSET   8
#define CS2200_DEVICE_ID_REG_MASK   0xF8
#define CS2200_DEVICE_ID_REG_OFFSET   3

Functions

void cs2200_enter_test_mode (void)
 Enter into the test mode.
void cs2200_freq_clk_adjust (U16 lsh_ratio)
 Function used to adjust the CLK_OUT frequency (LSW only).
void cs2200_freq_clk_out (U32 ratio)
 Function used to program the CLK_OUT frequency.
void cs2200_leave_test_mode (void)
 Leave the test mode.
Bool cs2200_setup (U32 out_freq)
 Function used to initialize the chip and communication interface.
void cs2200_switch_off (void)
void cs2200_switch_on (void)


Define Documentation

#define CS2200_DEVICE_CTRL_LOCKED   0x00

Definition at line 79 of file cs2200.c.

#define CS2200_DEVICE_CTRL_UNLOCK_REG_MASK   0x80

Definition at line 88 of file cs2200.c.

#define CS2200_DEVICE_CTRL_UNLOCK_REG_OFFSET   8

Definition at line 89 of file cs2200.c.

#define CS2200_DEVICE_ID_REG_MASK   0xF8

Definition at line 85 of file cs2200.c.

Referenced by cs2200_setup().

#define CS2200_DEVICE_ID_REG_OFFSET   3

Definition at line 86 of file cs2200.c.

Referenced by cs2200_setup().

#define CS2200_EXPECTED_DEVICE_ID   0x00

Definition at line 78 of file cs2200.c.

Referenced by cs2200_setup().


Function Documentation

void cs2200_enter_test_mode ( void   ) 

Enter into the test mode.

Definition at line 139 of file cs2200.c.

Referenced by cs2200_setup().

00140 {
00141   CS2200_WRITE_TEST_MODE_1(0x99); // Unlock
00142   CS2200_WRITE_TEST_MODE_2(0x80); // force_normal state
00143 }

void cs2200_freq_clk_adjust ( U16  lsh_ratio  ) 

Function used to adjust the CLK_OUT frequency (LSW only).

Definition at line 159 of file cs2200.c.

References CS2200_REG_LSW_RATIO_ADDR, and cs2200_write_ex().

Referenced by main().

00160 {
00161   static U16 s_ratio;
00162   s_ratio=lsh_ratio;
00163   cs2200_write_ex(CS2200_REG_LSW_RATIO_ADDR, &s_ratio, sizeof(lsh_ratio));
00164 }

void cs2200_freq_clk_out ( U32  ratio  ) 

Function used to program the CLK_OUT frequency.

Definition at line 153 of file cs2200.c.

Referenced by main().

00154 {
00155   CS2200_WRITE_32_BITS_RATIO(ratio);
00156 }

void cs2200_leave_test_mode ( void   ) 

Leave the test mode.

Definition at line 146 of file cs2200.c.

00147 {
00148   CS2200_WRITE_TEST_MODE_2(0x00); // test mode default setting
00149   CS2200_WRITE_TEST_MODE_1(0x00); // Lock
00150 }

Bool cs2200_setup ( U32  out_freq  ) 

Function used to initialize the chip and communication interface.

Definition at line 101 of file cs2200.c.

References _32_BITS_RATIO, CS2200_DEVICE_ID_REG_MASK, CS2200_DEVICE_ID_REG_OFFSET, cs2200_enter_test_mode(), CS2200_EXPECTED_DEVICE_ID, and CS2200_NB_TRIES.

Referenced by main().

00102 {
00103   int device_id;
00104   int nb_tries = CS2200_NB_TRIES;
00105 
00106   do
00107   {
00108     device_id = (CS2200_READ_DEVICE_ID() & CS2200_DEVICE_ID_REG_MASK) >> CS2200_DEVICE_ID_REG_OFFSET;
00109   // Make sure the chip is functional.
00110   } while ((device_id != CS2200_EXPECTED_DEVICE_ID)
00111          && --nb_tries);
00112 
00113   // If number of tries is over, return an error.
00114   if (!nb_tries)
00115     return FALSE;
00116 
00117   // Freeze chip during the programmation
00118   CS2200_WRITE_GLOBAL_CFG(1<<3);
00119 
00120   CS2200_WRITE_DEVICE_CTRL(0x00); // AUX_OUT output driver enabled. CLK_OUT output driver enabled.
00121   CS2200_WRITE_DEVICE_CFG_1( 0 << 5 // Left-shift R-value by 0 (x 1).
00122                            | 0 << 1 // RefClk: is the source of the AUX_OUT signal
00123                            );
00124   CS2200_WRITE_32_BITS_RATIO(_32_BITS_RATIO(out_freq)); // Program a default clock.
00125   CS2200_WRITE_FUNCT_CFG_1( 0x00 << 6 // Push-Pull, Active High (output ‘high’ for unlocked condition, ‘low’ for locked condition).
00126                           | 0x02 << 3 // Reference Clock Input Divider: ÷ 1 [8 MHz to 18.75 MHz]
00127                           );
00128   CS2200_WRITE_FUNCT_CFG_2( 0x00 << 4 // Clock outputs are driven ‘low’ when PLL is unlocked.
00129                           );
00130 
00131   // Unleash chip
00132   CS2200_WRITE_GLOBAL_CFG( 0x00 << 3 // Freeze
00133                          | 0x01 << 0 // EnDevCfg2
00134                          );
00135   cs2200_enter_test_mode();
00136   return TRUE;
00137 }

void cs2200_switch_off ( void   ) 

Definition at line 97 of file cs2200.c.

00098 {
00099 }

void cs2200_switch_on ( void   ) 

Definition at line 93 of file cs2200.c.

00094 {
00095 }


Generated on Thu Dec 17 19:57:30 2009 for AVR32 - CLOCK_SYNTHESIZER CS2200 by  doxygen 1.5.5