107 int8_t address_shift;
110 address_shift =(address << 1) | 0x01;
127 int bit_shift,
i, num_reg;
128 long field_val, maskbits, pow2;
135 bit_shift = (MSB_loc+1)- (numbits-num_reg*8);
136 field_val=
LTC6954_read(cs, (address+num_reg))+(field_val<<8);
139 while ((bit_shift<0) && (num_reg<4));
144 for (i=1, maskbits=1; i<numbits; i++)
147 maskbits = maskbits+pow2;
150 field_val=(field_val >>bit_shift) &maskbits;
176 address=address << 1;
190 long current_content, desired_content, reg_val;
191 int LSB_loc,
i, j, num_reg, bit_shift;
194 for (i=0; i<32 ; i++) temp_arr[i]=0;
201 bit_shift=(MSB_loc+1)-(numbits-num_reg*8);
202 current_content=
LTC6954_read(cs, (address+num_reg)) + (current_content<<8);
206 while ((bit_shift<0) && (num_reg<4));
207 for (i=0; i<(8*num_reg); i++)
209 temp_arr[
i]=(current_content>>
i) & 1;
213 LSB_loc = 8*(num_reg-1)+MSB_loc-numbits+1;
214 for (i=LSB_loc, j=0; i<=(MSB_loc+(num_reg-1)*8); i++, j++)
216 temp_arr[
i] = (field_data>>j) &1;
221 for (i=0; i<(8*num_reg); i++)
223 desired_content = desired_content | (temp_arr[
i]<<
i);
227 for (i=0; i<num_reg; i++)
229 reg_val = (desired_content >> 8*(num_reg-1-
i)) & 0xff;
282 void set_LTC6954_ALLREGS(uint8_t cs, uint8_t reg00, uint8_t reg01, uint8_t reg02, uint8_t reg03, uint8_t reg04, uint8_t reg05, uint8_t reg06)
uint8_t LTC6954_reg[LTC6954_NUM_REGADDR]
number of LTC6954 spi addresses
uint8_t LTC6954_read(uint8_t cs, int8_t address)
LTC6954 Read Single Address reads 8 bit Data field to LTC6954.
#define LTC6954_PD_DIV1
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6954_PDALL
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6954_SYNC_EN0
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6954_M2
for spi_map array, defines location for field specific information used to create the spi map ...
LTC6954: Low Phase Noise, Triple Output Clock Distribution Divider/Driver.
long LTC6954_read_field(uint8_t cs, uint8_t address, uint8_t MSB_loc, uint8_t numbits)
LTC6954 Read Single Field For SPI FIELDS located in 1 or multiple address locations reads specific ad...
Header File for Linduino Libraries and Demo Code.
#define LTC6954_PD_OUT0
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6954_LVCS1
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6954_NUM_REGADDR
Defines number of LTC6954 SPI registers, used in spi_map array.
#define LTC6954_NUM_REGFIELD
Defines number of LTC6954 SPI fields, used in spi_map array.
#define LTC6954_SYNC_EN1
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6954_LVCS2
for spi_map array, defines location for field specific information used to create the spi map ...
uint8_t LTC6954_spi_map[(LTC6954_NUM_REGFIELD+1)][4]
LTC6954 spi map, stores MSB address location, MSB bit location, field length in bits, and R or RW capability.
uint8_t LTC6954_write_field(uint8_t cs, long field_data, uint8_t address, uint8_t MSB_loc, uint8_t numbits)
LTC6954 Write Single Field For SPI FIELDS in 1 or multiple address locations reads specific address/f...
#define LTC6954_PART
for spi_map array, defines location for field specific information used to create the spi map ...
void LTC6954_init()
Initializes the SPI MAP arrays The values set in initialization are used all the LTC6954 SPI/WRITE an...
#define LTC6954_CMSINV0
for spi_map array, defines location for field specific information used to create the spi map ...
uint8_t get_LTC6954_REGSIZE()
returns # of addresses in parts register map (array size)
#define LTC6954_PD_OUT2
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6954_DEL1
for spi_map array, defines location for field specific information used to create the spi map ...
uint8_t get_LTC6954_SPI_FIELD_RW(uint8_t f)
returns if the given field name is (0)read/write or (1)read_only field
uint16_t LT_uint16
16-bit unsigned integer to be converted to two bytes
#define R_ONLY
used for 2nd dim of 2d spi_map array
void spi_transfer_word(uint8_t cs_pin, uint16_t tx, uint16_t *rx)
Reads and sends a word.
#define LTC6954_PD_DIV2
for spi_map array, defines location for field specific information used to create the spi map ...
long get_LTC6954_SPI_FIELD(uint8_t cs, uint8_t f)
Gets the LTC6954 SPI field value calls function LTC6954_read_field, which reads specific address loca...
#define LTC6954_M1
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6954_PD_OUT1
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6954_SYNC_EN2
for spi_map array, defines location for field specific information used to create the spi map ...
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
#define ADDRx
used for 2nd dim of 2d spi_map array
void set_LTC6954_SPI_FIELD(uint8_t cs, uint8_t f, long field_data)
Sets the LTC6954 SPI field value calls function LTC6954_read_field, which reads specific address/fiel...
void LTC6954_write(uint8_t cs, uint8_t address, uint8_t Data)
LTC6954 Write Single Address writes 8 bit Data field to LTC6954.
#define LTC6954_PD_DIV0
for spi_map array, defines location for field specific information used to create the spi map ...
This union splits one int16_t (16-bit signed integer) or uint16_t (16-bit unsigned integer) into two ...
#define LTC6954_DEL0
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6954_REV
for spi_map array, defines location for field specific information used to create the spi map ...
void set_LTC6954_ALLREGS(uint8_t cs, uint8_t reg00, uint8_t reg01, uint8_t reg02, uint8_t reg03, uint8_t reg04, uint8_t reg05, uint8_t reg06)
Writes values to ALL LTC6954 RW address.
#define LTC6954_CMSINV1
for spi_map array, defines location for field specific information used to create the spi map ...
uint8_t LT_byte[2]
2 bytes (unsigned 8-bit integers) to be converted to a 16-bit signed or unsigned integer ...
#define LTC6954_LVCS0
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6954_DEL2
for spi_map array, defines location for field specific information used to create the spi map ...
uint8_t get_LTC6954_SPI_FIELD_NUMBITS(uint8_t f)
returns the number of bits for a given field name in the SPI map
#define LTC6954_M0
for spi_map array, defines location for field specific information used to create the spi map ...
#define LTC6954_CMSINV2
for spi_map array, defines location for field specific information used to create the spi map ...
#define DxMSB
used for 2nd dim of 2d spi_map array