Microchip® Advanced Software Framework

cs2200.c File Reference
#include <avr32/io.h>
#include "compiler.h"
#include "cs2200.h"
#include "twi.h"
#include "gpio.h"
#include "board.h"

Macros

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

Functions

void cs2200_enter_test_mode (void)
 Enter into the test mode. More...
 
void cs2200_freq_clk_adjust (uint16_t lsh_ratio)
 Function used to adjust the CLK_OUT frequency (LSW only). More...
 
void cs2200_freq_clk_out (uint32_t ratio)
 Function used to program the CLK_OUT frequency. More...
 
void cs2200_leave_test_mode (void)
 Leave the test mode. More...
 
void cs2200_read (uint8_t address, void *buffer, uint8_t len)
 Reads data from the CS2200 chip. More...
 
bool cs2200_setup (uint32_t out_freq, uint32_t fosc)
 Function used to initialize the chip and communication interface. More...
 
void cs2200_switch_off (void)
 
void cs2200_switch_on (void)
 
void cs2200_write (uint8_t address, const void *buffer, uint8_t len)
 Writes data into the CS2200 chip. More...
 
int cs2200_write_ex (uint8_t address, const void *buffer, uint8_t len)
 Writes data into the CS2200 chip using the non blocking release of the TWI driver. More...
 

#define CS2200_DEVICE_CTRL_LOCKED   0x00
#define CS2200_DEVICE_CTRL_UNLOCK_REG_MASK   0x80
#define CS2200_DEVICE_CTRL_UNLOCK_REG_OFFSET   8
#define CS2200_DEVICE_ID_REG_MASK   0xF8

Referenced by cs2200_setup().

#define CS2200_DEVICE_ID_REG_OFFSET   3

Referenced by cs2200_setup().

#define CS2200_EXPECTED_DEVICE_ID   0x00

Referenced by cs2200_setup().

void cs2200_enter_test_mode ( void  )

Enter into the test mode.

Referenced by cs2200_setup().

void cs2200_freq_clk_adjust ( uint16_t  lsh_ratio)

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

References CS2200_REG_LSW_RATIO_ADDR, and cs2200_write_ex().

Referenced by usb_stream_resync().

void cs2200_freq_clk_out ( uint32_t  ratio)

Function used to program the CLK_OUT frequency.

Referenced by aic23b_codec_setup(), and usb_stream_input().

void cs2200_leave_test_mode ( void  )

Leave the test mode.

void cs2200_read ( uint8_t  address,
void *  buffer,
uint8_t  len 
)

Reads data from the CS2200 chip.

TWI chip address to communicate with.

Register address/commands inside the slave chip.

Length of the TWI data address segment (1-3 bytes).

Where to find the data to be written.

How many bytes do we want to write.

References twi_package_t::addr, twi_package_t::addr_length, twi_package_t::buffer, twi_package_t::chip, CS2200_TWI, CS2200_TWI_SLAVE_ADDRESS, twi_package_t::length, twi_master_read(), and TWI_SUCCESS.

bool cs2200_setup ( uint32_t  out_freq,
uint32_t  fosc 
)

Function used to initialize the chip and communication interface.

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().

void cs2200_switch_off ( void  )
void cs2200_switch_on ( void  )
void cs2200_write ( uint8_t  address,
const void *  buffer,
uint8_t  len 
)

Writes data into the CS2200 chip.

TWI chip address to communicate with.

Register address/commands inside the slave chip + auto increment.

Length of the TWI data address segment (1-3 bytes).

Where to find the data to be written.

How many bytes do we want to write.

References twi_package_t::addr, twi_package_t::addr_length, twi_package_t::buffer, twi_package_t::chip, CS2200_TWI, CS2200_TWI_SLAVE_ADDRESS, twi_package_t::length, twi_master_write(), and TWI_SUCCESS.

int cs2200_write_ex ( uint8_t  address,
const void *  buffer,
uint8_t  len 
)

Writes data into the CS2200 chip using the non blocking release of the TWI driver.

TWI chip address to communicate with.

Register address/commands inside the slave chip + auto increment.

Length of the TWI data address segment (1-3 bytes).

Where to find the data to be written.

How many bytes do we want to write.

References twi_package_t::addr, twi_package_t::addr_length, twi_package_t::buffer, twi_package_t::chip, CS2200_TWI, CS2200_TWI_SLAVE_ADDRESS, twi_package_t::length, and twi_master_write_ex().

Referenced by cs2200_freq_clk_adjust().