works
This commit is contained in:
@@ -15,6 +15,12 @@ enum{
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int clear_buffer(si5351_driver *inst){
|
||||||
|
|
||||||
|
memset(inst->device_data,0, sizeof(inst->device_data));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static int readRegister(si5351_driver *inst,uint8_t data_addr, uint8_t *data, uint32_t len){
|
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:
|
// Write what kind of addr we would like to read from:
|
||||||
@@ -32,6 +38,7 @@ static int writeRegister(si5351_driver *inst,uint8_t data_addr, uint32_t len){
|
|||||||
// Set address
|
// Set address
|
||||||
inst->device_data[0] = data_addr;
|
inst->device_data[0] = data_addr;
|
||||||
inst->i2c_transfer_evt(inst->i2c_transfer_inst,&inst->device_data[0],len+1, SI5351_I2C_SET);
|
inst->i2c_transfer_evt(inst->i2c_transfer_inst,&inst->device_data[0],len+1, SI5351_I2C_SET);
|
||||||
|
clear_buffer(inst);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,6 +47,7 @@ static int writeRegisterbyte(si5351_driver *inst,uint8_t data_addr, uint8_t data
|
|||||||
// Set address
|
// Set address
|
||||||
uint8_t buff[2] = {data_addr,data};
|
uint8_t buff[2] = {data_addr,data};
|
||||||
inst->i2c_transfer_evt(inst->i2c_transfer_inst,&buff[0],2, SI5351_I2C_SET);
|
inst->i2c_transfer_evt(inst->i2c_transfer_inst,&buff[0],2, SI5351_I2C_SET);
|
||||||
|
clear_buffer(inst);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,10 +153,6 @@ int cm_setOutputEnable(si5351_driver *inst,si5351_Outputs clk_output, si5351_Out
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
outputEnableControl->CLK0_OEB = 0;
|
|
||||||
outputEnableControl->CLK1_OEB = 0;
|
|
||||||
outputEnableControl->CLK2_OEB = 0;
|
|
||||||
|
|
||||||
writeRegister(inst,SI5351_REG_OUTPUT_ENABLE_CONTROL, sizeof(si5351_outputEnableControl_t));
|
writeRegister(inst,SI5351_REG_OUTPUT_ENABLE_CONTROL, sizeof(si5351_outputEnableControl_t));
|
||||||
|
|
||||||
@@ -161,7 +165,7 @@ int cm_setCLKControl(si5351_driver *inst, si5351_Outputs clk_output, si5351_CLK_
|
|||||||
si5351_CLK_Control_t *CLKx_control = (void*)&inst->device_data[1];
|
si5351_CLK_Control_t *CLKx_control = (void*)&inst->device_data[1];
|
||||||
|
|
||||||
CLKx_control->CLK_PDN = clk_pdn;
|
CLKx_control->CLK_PDN = clk_pdn;
|
||||||
|
CLKx_control->CLK_INV = 0;
|
||||||
CLKx_control->CLK_IDRV = SI5351_DRIVE_STRENGTH_8MA;
|
CLKx_control->CLK_IDRV = SI5351_DRIVE_STRENGTH_8MA;
|
||||||
|
|
||||||
switch (clk_output)
|
switch (clk_output)
|
||||||
@@ -239,14 +243,6 @@ int cm_resetPLLs(si5351_driver *inst, uint8_t reset_PLLA, uint8_t reset_PLLB){
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
uint8_t cm_si5351_getRevisionNumber(si5351_driver *inst){
|
|
||||||
|
|
||||||
// Read Device Status register:
|
|
||||||
readRegister(inst,0x00, (uint8_t *) &inst->device_data.deviceStatus, sizeof(si5351_deviceStat_t));
|
|
||||||
|
|
||||||
return inst->device_data.deviceStatus.REVID;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
int cm_si5351_init(si5351_driver *inst, void *i2c_transfer_inst, setGet_I2C_Event_fpt i2c_transfer_evt){
|
int cm_si5351_init(si5351_driver *inst, void *i2c_transfer_inst, setGet_I2C_Event_fpt i2c_transfer_evt){
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user