comm working
This commit is contained in:
@@ -12,11 +12,55 @@ enum{
|
||||
|
||||
};
|
||||
|
||||
static int readRegister(si5351_driver *inst,uint8_t data_addr, uint8_t *data, uint32_t len){
|
||||
|
||||
// Write what kind of addr we would like to read from:
|
||||
inst->i2c_transfer_evt(inst->i2c_transfer_inst,&data_addr,1, SI5351_I2C_SET);
|
||||
|
||||
// Read data:
|
||||
inst->i2c_transfer_evt(inst->i2c_transfer_inst,data,len, SI5351_I2C_GET);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writeRegister(si5351_driver *inst,uint8_t data_addr, uint8_t *data, uint32_t len){
|
||||
|
||||
// Write what kind of addr we would like to read from:
|
||||
inst->i2c_transfer_evt(inst->i2c_transfer_inst,&data_addr,1, SI5351_I2C_SET);
|
||||
|
||||
// Write data:
|
||||
inst->i2c_transfer_evt(inst->i2c_transfer_inst,data,len, SI5351_I2C_SET);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cm_setInputSource(si5351_driver *inst, si5351_ClkSource clk_source){
|
||||
|
||||
switch(clk_source){
|
||||
|
||||
case SI5351_CLK_SOURCE_XTAL:
|
||||
inst->device_data.pllInputSource.PLLA_SRC = 1;
|
||||
break;
|
||||
|
||||
case SI5351_CLK_SOURCE_CLOCKSOURCE:
|
||||
inst->device_data.pllInputSource.PLLA_SRC = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// Write to register:
|
||||
writeRegister(inst,SI5351_REG_PLL_INPUT_SOURCE, (uint8_t*) &inst->device_data.pllInputSource, sizeof(si5351_PLLInputSource_t));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t cm_si5351_getRevisionNumber(si5351_driver *inst){
|
||||
|
||||
// Read Device Status register:
|
||||
inst->i2c_transfer_evt(inst->i2c_transfer_inst,(uint8_t*) &(inst->device_data.deviceStatus),sizeof(inst->device_data.deviceStatus), SI5351_I2C_GET);
|
||||
|
||||
readRegister(inst,0x00, (uint8_t *) &inst->device_data.deviceStatus, sizeof(si5351_deviceStat_t));
|
||||
|
||||
return inst->device_data.deviceStatus.REVID;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user