-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev/ade7978 #2400
base: main
Are you sure you want to change the base?
Dev/ade7978 #2400
Conversation
08f443c
to
dcc7207
Compare
drivers/meter/ade7978/ade7978.c
Outdated
if ((reg_addr >= ADE7978_REG_MMODE && reg_addr <= ADE7978_REG_LAST_RWDATA8) || | ||
(reg_addr >= ADE7978_REG_CONFIG2 && reg_addr <= ADE7978_SET_SPI_ADDR)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would define a macro for these conditions, since they do repeat.
|
||
/* Hard reset the device */ | ||
if (!init_param.reset_desc) | ||
goto error_dev; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ret
is not initialized at this moment.
drivers/meter/ade7978/ade7978.c
Outdated
if (!dev) | ||
return -ENODEV; | ||
if (!status) | ||
return -EINVAL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove these, since they are checked in the ade7978_read()
call below.
temperature = (float) 8.72101 * (float)(0.00001) * | ||
(float) dev->temperature - (float) 306.47; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to cast anything here.
drivers/meter/ade7978/ade7978.h
Outdated
/******************************************************************************/ | ||
/********************** Macros and Constants Definitions **********************/ | ||
/******************************************************************************/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We try to not have these comments in new drivers, since they don't really add any value.
if (val == NO_OS_GPIO_LOW) | ||
val = NO_OS_GPIO_HIGH; | ||
else | ||
val = NO_OS_GPIO_LOW; | ||
|
||
return no_os_gpio_set_value(gpio_led_desc, val); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be replaced with
return no_os_gpio_set_value(gpio_led_desc, !val);
drivers/meter/ade7978/ade7978.c
Outdated
return ret; | ||
|
||
// /* Enable the DSP */ | ||
// return ade7978_write(dev, ADE7978_REG_RUN, ADE7978_RUN_ON); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this line.
drivers/meter/ade7978/ade7978.c
Outdated
return ret; | ||
} | ||
|
||
// Dumb read of energy registers to erase their contents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment style should be consistent throughout No-OS. Use /**/
instead.
projects/eval-ade7978/src.mk
Outdated
INCS += $(INCLUDE)/no_os_alloc.h \ | ||
$(INCLUDE)/no_os_delay.h \ | ||
$(INCLUDE)/no_os_error.h \ | ||
$(INCLUDE)/no_os_gpio.h \ | ||
$(INCLUDE)/no_os_print_log.h \ | ||
$(INCLUDE)/no_os_spi.h \ | ||
$(INCLUDE)/no_os_timer.h \ | ||
$(INCLUDE)/no_os_mutex.h \ | ||
$(INCLUDE)/no_os_util.h \ | ||
$(INCLUDE)/no_os_lf256fifo.h \ | ||
$(INCLUDE)/no_os_list.h \ | ||
$(INCLUDE)/no_os_irq.h \ | ||
$(INCLUDE)/no_os_units.h \ | ||
$(INCLUDE)/no_os_init.h \ | ||
$(INCLUDE)/no_os_alloc.h \ | ||
$(INCLUDE)/no_os_crc8.h \ | ||
$(INCLUDE)/no_os_crc16.h \ | ||
$(INCLUDE)/no_os_uart.h \ | ||
$(INCLUDE)/no_os_pwm.h \ | ||
$(INCLUDE)/no_os_dma.h \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The NO_OS_INC_DIRS
variable can be used to avoid adding all these explicitly.
The ADE7978, the ADE7933/ADE7932, and ADE7923 form a chipset dedicated to measuring 3-phase electrical energy using shunts as current sensors. The ADE7933/ADE7932 are isolated, sigma-delta analog-to-digital converters. The ADE7923 is a nonisolated, 3-channel Σ-Δ ADC. ADE7933 has 3 channels and ADE7932 2 channels. The ADE7978 is a high accuracy, 3-phase electrical energy measurement IC with serial interfaces and three flexible pulse outputs. This is a basic driver implementation with communication done on SPI. Signed-off-by: Radu Etz <[email protected]>
Example project for ADE7978 in chipset configuration with ADE7933/ADE7932, and ADE7923. Tested using the EVAL-ADE7978EBZ. The example includes measurments of the rms values. The example is tested with the AD-APARD32690-SL. Signed-off-by: Radu Etz <[email protected]>
v2 change log:
|
*/ | ||
struct measurements { | ||
/* I rms value */ | ||
float i_rms; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it is a good idea to have float values in the driver.
Pull Request Description
Basic driver for ADE7978 with SPI communication.
The ADE7978 communicates via a digital interface with ADE7933/ADE7932, or ADE7923 forming a
chipset dedicated to measuring 3-phase electrical energy using shunts as current sensors.
PR Type
PR Checklist