chore: fix compile errors, simplified code.

This commit is contained in:
Gatsby Van
2024-12-24 15:12:51 +08:00
parent 3470b6f6dc
commit 250190baef
9 changed files with 53 additions and 143 deletions
+2 -2
View File
@@ -25,11 +25,11 @@
},
"build_config": {
"debug": {
"include-path": ["src/include"],
"include-path": ["src", "src/include"],
"libraries": ["m"]
},
"release": {
"include-path": ["src/include"],
"include-path": ["src", "src/include"],
"libraries": ["m"]
}
}
@@ -1,7 +1,7 @@
/***************************************************************************//**
* @file i2c.h
* @brief Header file of I2C Interface
* @author DBogdan (dragos.bogdan@analog.com)
* @file xilinx/xilinx_delay.c
* @brief Implementation of Xilinx Delay Functions.
* @author Antoniu Miclaus (antoniu.miclaus@analog.com)
********************************************************************************
* Copyright 2019(c) Analog Devices, Inc.
*
@@ -37,98 +37,64 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#ifndef _I2C_H_
#define _I2C_H_
/******************************************************************************/
/***************************** Include Files **********************************/
/******************************************************************************/
#include <stdint.h>
#include "delay.h"
#include <sleep.h>
#ifdef _XPARAMETERS_PS_H_
#include "util.h"
#include "xtime_l.h"
#endif
/******************************************************************************/
/*************************** Types Declarations *******************************/
/************************ Functions Definitions *******************************/
/******************************************************************************/
/**
* @struct i2c_platform_ops
* @brief Structure holding I2C function pointers that point to the platform
* specific function
* @brief Generate microseconds delay.
* @param usecs - Delay in microseconds.
* @return None.
*/
struct i2c_platform_ops ;
void udelay(uint32_t usecs)
{
#ifdef _XPARAMETERS_PS_H_
usleep(usecs);
#else
usleep_MB(usecs);
#endif
}
/**
* @struct i2c_init_param
* @brief Structure holding the parameters for I2C initialization.
* @brief Generate miliseconds delay.
* @param msecs - Delay in miliseconds.
* @return None.
*/
struct i2c_init_param {
/** Device ID */
uint32_t device_id;
/** I2C maximum transfer speed supported */
uint32_t max_speed_hz;
/** Slave address */
uint8_t slave_address;
/** I2C platform specific functions */
const struct i2c_platform_ops *platform_ops;
/** I2C extra parameters (device specific parameters) */
void *extra;
};
void mdelay(uint32_t msecs)
{
#ifdef _XPARAMETERS_PS_H_
usleep(msecs * 1000);
#else
usleep_MB(msecs * 1000);
#endif
}
/**
* @struct i2c_desc
* @brief Structure holding I2C descriptor
* @brief Get current time.
* @return Current time structure from system start (seconds, microseconds).
*/
struct i2c_desc {
/** Device ID */
uint32_t device_id;
/** I2C maximum transfer speed supported */
uint32_t max_speed_hz;
/** Slave address */
uint8_t slave_address;
/** I2C platform specific functions */
const struct i2c_platform_ops *platform_ops;
/** I2C extra parameters (device specific parameters) */
void *extra;
};
struct time get_time(void)
{
struct time t = {0, 0};
#ifdef _XPARAMETERS_PS_H_
unsigned long long Xtime_Global;
uint32_t rem;
/**
* @struct i2c_platform_ops
* @brief Structure holding i2c function pointers that point to the platform
* specific function
*/
struct i2c_platform_ops {
/** i2c initialization function pointer */
int32_t (*i2c_ops_init)(struct i2c_desc **,
const struct i2c_init_param *);
/** i2c write function pointer */
int32_t (*i2c_ops_write)(struct i2c_desc *, uint8_t *, uint8_t, uint8_t);
/** i2c write function pointer */
int32_t (*i2c_ops_read)(struct i2c_desc *, uint8_t *, uint8_t, uint8_t);
/** i2c remove function pointer */
int32_t (*i2c_ops_remove)(struct i2c_desc *);
};
XTime_GetTime(&Xtime_Global);
t.s = div_u64_rem(Xtime_Global, COUNTS_PER_SECOND, &rem);
t.us = div_u64((uint64_t)rem * 1000000, COUNTS_PER_SECOND);
#endif
/******************************************************************************/
/************************ Functions Declarations ******************************/
/******************************************************************************/
/* Initialize the I2C communication peripheral. */
int32_t i2c_init(struct i2c_desc **desc,
const struct i2c_init_param *param);
/* Free the resources allocated by i2c_init(). */
int32_t i2c_remove(struct i2c_desc *desc);
/* Write data to a slave device. */
int32_t i2c_write(struct i2c_desc *desc,
uint8_t *data,
uint8_t bytes_number,
uint8_t stop_bit);
/* Read data from a slave device. */
int32_t i2c_read(struct i2c_desc *desc,
uint8_t *data,
uint8_t bytes_number,
uint8_t stop_bit);
#endif // _I2C_H_
return t;
}
+1
View File
@@ -15,6 +15,7 @@
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
#include "delay.h"
#include "common.h"
#include "platform_drivers.h"
#include "parameters.h"
+1 -9
View File
@@ -37,6 +37,7 @@
/***************************** Include Files ********************************/
#include "headless.h"
#include "delay.h"
/************************** Constant Definitions *****************************/
@@ -46,9 +47,6 @@
/************************** Variable Definitions *****************************/
// XGpio GpioFreqCtrl;
// XGpio GpioGainCtrl;
// XGpio GpioAttnCtrl;
XScuGic Intc;
/************************** Function Prototypes ******************************/
@@ -284,12 +282,6 @@ int HW_adiCfgProfileInit(void)
return ADIERR_FAILED;
}
if (!&mykDevice)
{
HW_PRINT("Cannot find ad9371 configuration profile with name 'mykDevice'!");
return ADIERR_FAILED;
}
ad9528Init->spiSettings->chipSelectIndex = AD9528_CS;
mykDevice.spiSettings->chipSelectIndex = AD9371_CS;
+1 -1
View File
@@ -15,7 +15,7 @@
#include "xscugic.h"
//#include "xgpio.h"
#include "common.h"
#include "./common.h"
#include "./mykonos/ad9528.h"
#include "./mykonos/mykonos.h"
#include "./mykonos/Mykonos_M3.h"
+1 -1
View File
@@ -100,7 +100,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <stddef.h>
#include "common.h"
#include "./common.h"
#include "./mykonos/ad9528.h"
#include "./mykonos/t_ad9528.h"
+1 -1
View File
@@ -552,7 +552,7 @@ mykonosDevice_t mykDevice =
&rxSettings, /* Rx settings data structure pointer */
&txSettings, /* Tx settings data structure pointer */
&obsRxSettings, /* ObsRx settings data structure pointer */
&mykonosAuxIo, /* Auxiliary IO settings data structure pointer */
&mykonosAuxIo, /* Auxiliary IO settings data structure pointer */
&mykonosClocks, /* Holds settings for CLKPLL and reference clock */
0 /* Mykonos initialize function uses this as an output to remember which profile data structure pointers are valid */
};
-24
View File
@@ -369,27 +369,3 @@ int32_t gpio_get_value(struct gpio_desc *desc,
return 0;
}
/**
* @brief Generate microseconds delay.
* @param usecs - Delay in microseconds.
* @return None.
*/
void udelay(uint32_t usecs)
{
usleep(usecs);
}
/**
* @brief Generate miliseconds delay.
* @param msecs - Delay in miliseconds.
* @return None.
*/
void mdelay(uint32_t msecs)
{
#ifdef _XPARAMETERS_PS_H_
usleep(msecs * 1000);
#else
usleep(msecs * 50); // FIXME
#endif
}
-25
View File
@@ -75,25 +75,6 @@
/******************************************************************************/
/*************************** Types Declarations *******************************/
/******************************************************************************/
typedef enum i2c_type {
XILINX_I2C
} i2c_type;
typedef struct i2c_init_param {
enum i2c_type type;
uint32_t id;
uint32_t max_speed_hz;
uint8_t slave_address;
} i2c_init_param;
typedef struct i2c_desc {
enum i2c_type type;
uint32_t id;
uint32_t max_speed_hz;
uint8_t slave_address;
} i2c_desc;
typedef enum spi_type {
XILINX_SPI
} spi_type;
@@ -195,10 +176,4 @@ int32_t gpio_set_value(struct gpio_desc *desc,
int32_t gpio_get_value(struct gpio_desc *desc,
uint8_t *value);
/* Generate microseconds delay. */
void udelay(uint32_t usecs);
/* Generate miliseconds delay. */
void mdelay(uint32_t msecs);
#endif // PLATFORM_DRIVERS_H_