Skip to content

Commit

Permalink
RN8209 addresses from datasheet + cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
openshwprojects committed Nov 30, 2023
1 parent c687236 commit 0738bfe
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/driver/drv_rn8209.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,26 @@
#include "drv_bl_shared.h"
#include "drv_uart.h"

#define BL0942_UART_PACKET_LEN 12
#define BL0942_UART_PACKET_HEAD 12


static void UART_WriteReg(byte reg, byte *data, int len) {
#define RN8209_RMS_CURRENT_A 0x22
#define RN8209_RMS_CURRENT_A_SIZE 3
#define RN8209_RMS_CURRENT_B 0x23
#define RN8209_RMS_CURRENT_B_SIZE 3
#define RN8209_RMS_VOLTAGE 0x24
#define RN8209_RMS_VOLTAGE_SIZE 3
#define RN8209_RMS_FREQUENCY 0x25
#define RN8209_RMS_FREQUENCY_SIZE 2
#define RN8209_AVG_ACTIVEPOWER_A 0x26
#define RN8209_AVG_ACTIVEPOWER_A_SIZE 4
#define RN8209_AVG_ACTIVEPOWER_B 0x27
#define RN8209_AVG_ACTIVEPOWER_B_SIZE 4
#define RN8209_AVG_REACTIVEPOWER 0x28
#define RN8209_AVG_REACTIVEPOWER_SIZE 4
#define RN8209_AVG_REACTIVEENERGY_1 0x29
#define RN8209_AVG_REACTIVEENERGY_1_SIZE 3
#define RN8209_AVG_REACTIVEENERGY_2 0x2A
#define RN8209_AVG_REACTIVEENERGY_2_SIZE 3

static void RN8209_WriteReg(byte reg, byte *data, int len) {
byte crc;

reg = reg | 0x80;
Expand All @@ -25,7 +40,7 @@ static void UART_WriteReg(byte reg, byte *data, int len) {

UART_SendByte(crc);
}
static void UART_ReadReg(byte reg) {
static void RN8029_ReadReg(byte reg) {
byte crc;
byte data[32];
int size, i;
Expand Down Expand Up @@ -66,7 +81,7 @@ void RN8209_Init(void) {
}

void RN8029_RunEverySecond(void) {
UART_ReadReg(0x24);
RN8029_ReadReg(0x24);

}
/*
Expand Down

0 comments on commit 0738bfe

Please sign in to comment.