first commit
This commit is contained in:
70
include/si5351_driver.h
Normal file
70
include/si5351_driver.h
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* si5351_driver.h
|
||||||
|
*
|
||||||
|
* Created on: 16. aug. 2024
|
||||||
|
* Author: Christian L. V. Madsen (OZ1CM)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SI5351_DRIVER_INCLUDE_SI5351_DRIVER_H_
|
||||||
|
#define SI5351_DRIVER_INCLUDE_SI5351_DRIVER_H_
|
||||||
|
|
||||||
|
#include "stdio.h"
|
||||||
|
#include "stdint.h"
|
||||||
|
|
||||||
|
typedef int (*setGet_I2C_Event_fpt)(void *inst, uint8_t *data, uint32_t len, uint8_t set_get);
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
|
||||||
|
uint8_t SYS_INIT : 1; // System Initialization Status
|
||||||
|
uint8_t LOL_A : 1; // PLLB Loss Of Lock Status.
|
||||||
|
uint8_t LOL_B : 1; // PLL A Loss Of Lock Status.
|
||||||
|
uint8_t LOS_CLKIN : 1; // CLKIN Loss Of Signal (Si5351C Only).
|
||||||
|
uint8_t LOS_XTAL : 1; // Crystal Loss of Signal
|
||||||
|
uint8_t RESERVED : 1;
|
||||||
|
uint8_t REVID : 2; // Revision number of the device.
|
||||||
|
|
||||||
|
|
||||||
|
}__attribute__((packed)) si5351_deviceStat;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
|
||||||
|
uint8_t SYS_INIT_STKY : 1; // System Calibration Status Sticky Bit
|
||||||
|
uint8_t LOL_A_STKY : 1; // PLLB Loss Of Lock Status Sticky Bit
|
||||||
|
uint8_t LOL_B_STKY : 1; // PLL A Loss Of Lock Status Sticky Bit.
|
||||||
|
uint8_t LOS_CLKIN_STKY : 1; // CLKIN Loss Of Signal (Si5351C Only) Sticky Bit.
|
||||||
|
uint8_t LOS_XTAL_STKY : 1; // Crystal Loss of Signal Sticky Bit.
|
||||||
|
uint8_t RESERVED : 3;
|
||||||
|
|
||||||
|
|
||||||
|
}__attribute__((packed)) si5351_interruptStatusSticky;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}__attribute__((packed)) si5351_outputEnableControl;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
|
||||||
|
si5351_deviceStat deviceStatus;
|
||||||
|
si5351_interruptStatusSticky ISR_StatusSticky;
|
||||||
|
|
||||||
|
|
||||||
|
}__attribute__((packed)) si5351_data;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
|
||||||
|
void *i2c_transfer_inst;
|
||||||
|
setGet_I2C_Event_fpt i2c_transfer_evt;
|
||||||
|
|
||||||
|
si5351_data device_data;
|
||||||
|
|
||||||
|
|
||||||
|
}__attribute__((packed)) si5351_driver;
|
||||||
|
|
||||||
|
int cm_si5351_init(si5351_driver *inst, void *i2c_transfer_inst, setGet_I2C_Event_fpt i2c_transfer_evt);
|
||||||
|
uint8_t cm_si5351_getRevisionNumber(si5351_driver *inst);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SI5351_DRIVER_INCLUDE_SI5351_DRIVER_H_ */
|
||||||
45
si5351_driver.c
Normal file
45
si5351_driver.c
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* si5351_driver.c
|
||||||
|
*
|
||||||
|
* Created on: 16. aug. 2024
|
||||||
|
* Author: Christian L. V. Madsen (OZ1CM)
|
||||||
|
*/
|
||||||
|
#include "include/si5351_driver.h"
|
||||||
|
|
||||||
|
enum{
|
||||||
|
SI5351_I2C_GET = 0,
|
||||||
|
SI5351_I2C_SET = 1,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
return inst->device_data.deviceStatus.REVID;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cm_si5351_init(si5351_driver *inst, void *i2c_transfer_inst, setGet_I2C_Event_fpt i2c_transfer_evt){
|
||||||
|
|
||||||
|
if(inst == NULL)return -1;
|
||||||
|
if(i2c_transfer_inst == NULL)return -1;
|
||||||
|
if(i2c_transfer_evt == NULL)return -1;
|
||||||
|
|
||||||
|
inst->i2c_transfer_inst = i2c_transfer_inst;
|
||||||
|
inst->i2c_transfer_evt = i2c_transfer_evt;
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
// SW Reset device.
|
||||||
|
//ret = cm_ltr390_SWreset(inst);
|
||||||
|
|
||||||
|
// ret = ltr390_readAllReg(inst);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user