Skip to content

Commit

Permalink
firmware: drivers: ds277Xg: Removed unused macros and functions relat…
Browse files Browse the repository at this point in the history
…ed to onewire #157
  • Loading branch information
ramonborba committed Aug 14, 2023
1 parent 3eca1e7 commit ff1cfc2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 25 deletions.
8 changes: 5 additions & 3 deletions firmware/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,18 @@
/* Tasks */
#define CONFIG_TASK_STARTUP_ENABLED 1
#define CONFIG_TASK_WATCHDOG_RESET_ENABLED 1
#define CONFIG_TASK_HEARTBEAT_ENABLED 1
#define CONFIG_TASK_SYSTEM_RESET_ENABLED 1
#define CONFIG_TASK_HEARTBEAT_ENABLED 1
#define CONFIG_TASK_SYSTEM_RESET_ENABLED 1
#define CONFIG_TASK_READ_SENSORS_ENABLED 1
#define CONFIG_TASK_PARAM_SERVER_ENABLED 1
#define CONFIG_TASK_MPPT_ALGORITHM_ENABLED 1
#define CONFIG_TASK_HEATER_CONTROLLER_ENABLED 1
#define CONFIG_TASK_TIME_CONTROL_ENABLED 1
#define CONFIG_TASK_DEVICE_RESPONSE_ENABLED 1

/* Tasks Debug Logs*/
#define CONFIG_TASK_READ_SENSORS_DEBUG_ENABLED 1

/* Devices */
#define CONFIG_SET_DUMMY_EPS 0
#define CONFIG_DEV_LEDS_ENABLED 1
Expand All @@ -71,7 +74,6 @@

/* Drivers */
#define CONFIG_DRIVERS_DEBUG_ENABLED 0
#define CONFIG_DRIVERS_DS277X_ONEWIRE_VERSION 0

#define MAX_BATTERY_CHARGE 2450 /* [mAh] */
#define BAT_MONITOR_CHARGE_VALUE (uint16_t)(MAX_BATTERY_CHARGE/0.625) /* 0.625 is a conversion factor for the battery monitor */
Expand Down
14 changes: 0 additions & 14 deletions firmware/drivers/ds277Xg/ds277Xg.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,28 +570,14 @@ int ds277Xg_read_cycle_counter(ds277Xg_config_t *config, uint16_t *cycles)

int ds277Xg_write_data(ds277Xg_config_t *config, uint8_t *data, const uint16_t len)
{
#if defined(CONFIG_DRIVERS_DS277X_ONEWIRE_VERSION) && (CONFIG_DRIVERS_DS277X_ONEWIRE_VERSION == 1)
if(onewire_reset(config->port) == 0) {return -1;}
if(onewire_write_byte(config->port, data, len) == -1) {return -1;}
return 0;
#else
return i2c_write(config->port, config->slave_adr, data, len);
#endif
}

int ds277Xg_read_data(ds277Xg_config_t *config, uint8_t target_reg, uint8_t *data, uint16_t len)
{
#if defined(CONFIG_DRIVERS_DS277X_ONEWIRE_VERSION) && (CONFIG_DRIVERS_DS277X_ONEWIRE_VERSION == 1)
uint8_t read_command[3] = {DS2775G_SKIP_ADDRESS, DS2775G_READ_DATA, target_reg};
if(ds277Xg_write_data(config, read_command, 0x3) == -1) {return -1;}
if(onewire_read_byte(config->port, data, len) == -1) {return -1;}
return 0;
#else
uint8_t reg[1] = {target_reg};

if (i2c_write(config->port, config->slave_adr, reg, 1) != 0) {return -1;}
return i2c_read(config->port, config->slave_adr, data, len);
#endif
}

/** \} End of ds277Xg group */
8 changes: 0 additions & 8 deletions firmware/drivers/ds277Xg/ds277Xg.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@

#include <config/config.h>

#if defined(CONFIG_DRIVERS_DS277X_ONEWIRE_VERSION) && (CONFIG_DRIVERS_DS277X_ONEWIRE_VERSION == 1)
#include <drivers/onewire/onewire.h>
#else
#include <drivers/i2c/i2c.h>
#endif

#define DS277XG_MODULE_NAME "DS277X"

Expand Down Expand Up @@ -268,12 +264,8 @@

typedef struct
{
#if defined(CONFIG_DRIVERS_DS277X_ONEWIRE_VERSION) && (CONFIG_DRIVERS_DS277X_ONEWIRE_VERSION == 1)
onewire_port_t port;
#else
i2c_port_t port;
i2c_slave_adr_t slave_adr;
#endif
} ds277Xg_config_t;

/**
Expand Down

0 comments on commit ff1cfc2

Please sign in to comment.