Skip to content

Commit

Permalink
Merge branch 'main' of github.com:uhi22/ccs32clara
Browse files Browse the repository at this point in the history
# Conflicts:
#	ccs/pevStateMachine.cpp
#	include/param_prj.h
  • Loading branch information
jsphuebner committed Dec 12, 2023
2 parents d77fd16 + c7c101b commit baac4d6
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 20 deletions.
1 change: 1 addition & 0 deletions ccs/ccs32_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <libopencm3/stm32/spi.h>
#include <libopencm3/stm32/timer.h>
#include <libopencm3/stm32/dma.h>
#include "myLogging.h"
#include "configuration.h"
#include "printf.h"
#include "connMgr.h"
Expand Down
18 changes: 5 additions & 13 deletions ccs/myHelpers.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@

/* Interface header for myHelpers.c */

#ifndef MY_HELPERS_H
#define MY_HELPERS_H

/* Global Defines */

#define STR_TMP_SIZE 400
#define MY_SERIAL_PRINTBUFFERLEN 400

enum Module
{
MOD_CONNMGR = 1,
MOD_HWIF = 2,
MOD_HOMEPLUG = 4,
MOD_PEV = 8,
MOD_QCA = 16,
MOD_TCP = 32,
MOD_TCPTRAFFIC = 64,
MOD_IPV6 = 128,
MOD_MODEMFINDER = 256
};

extern uint16_t checkpointNumber;

/* Global Functions */
Expand All @@ -28,3 +18,5 @@ extern void showAsHex(uint8_t *data, uint16_t len, const char *description);
extern void sanityCheck(const char *hint);
extern void mySerialPrint(void);
extern void setCheckpoint(uint16_t newcheckpoint);

#endif
23 changes: 23 additions & 0 deletions ccs/myLogging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

/* definitions for logging */

#ifndef MY_LOGGING_H
#define MY_LOGGING_H

enum Module
{
MOD_CONNMGR = 1,
MOD_HWIF = 2,
MOD_HOMEPLUG = 4,
MOD_PEV = 8,
MOD_QCA = 16,
MOD_TCP = 32,
MOD_TCPTRAFFIC = 64,
MOD_IPV6 = 128,
MOD_MODEMFINDER = 256
};

/* Here we define, which logging data is produced after power-on */
#define DEFAULT_LOGGINGMASK (MOD_TCPTRAFFIC | MOD_HOMEPLUG | MOD_PEV)

#endif
5 changes: 5 additions & 0 deletions ccs/pevStateMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,13 @@ void stateFunctionWaitForPreChargeResponse(void)
EVSEPresentVoltage = combineValueAndMultiplier(dinDocDec.V2G_Message.Body.PreChargeRes.EVSEPresentVoltage.Value,
dinDocDec.V2G_Message.Body.PreChargeRes.EVSEPresentVoltage.Multiplier);
Param::SetInt(Param::evsevtg, EVSEPresentVoltage);

uint16_t inletVtg = hardwareInterface_getInletVoltage();
uint16_t batVtg = hardwareInterface_getAccuVoltage();

if (Param::GetInt(Param::logging) & MOD_PEV) {
printf("Inlet %dV, accu %dV\r\n", inletVtg, batVtg);
}
if (ABS(inletVtg - batVtg) < PARAM_U_DELTA_MAX_FOR_END_OF_PRECHARGE && batVtg > EVSEMinimumVoltage)
{
addToTrace(MOD_PEV, "Difference between accu voltage and inlet voltage is small. Sending PowerDeliveryReq.");
Expand Down
18 changes: 13 additions & 5 deletions ccs/tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,19 @@ void tcp_transmit(void)
tcpHeaderLen = 20; /* 20 bytes normal header, no options */
if (tcpPayloadLen+tcpHeaderLen<TCP_TRANSMIT_PACKET_LEN)
{
memcpy(&TcpTransmitPacket[tcpHeaderLen], tcpPayload, tcpPayloadLen);
tcp_prepareTcpHeader(TCP_FLAG_PSH + TCP_FLAG_ACK); /* data packets are always sent with flags PUSH and ACK. */
tcp_packRequestIntoIp();
lastUnackTransmissionTime = rtc_get_ms(); /* record the time of transmission, to be able to detect the timeout */
retryCounter = TCP_MAX_NUMBER_OF_RETRANSMISSIONS; /* Allow n retries of the same packet */
/* The packet fits into our transmit buffer. */
if (Param::GetInt(Param::logging) & MOD_TCPTRAFFIC) {
printf("[%u] TCP will transmit: ", rtc_get_ms());
for (uint16_t i=0; i < tcpPayloadLen; i++) {
printf("%02x", tcpPayload[i]);
}
printf("\r\n");
}
memcpy(&TcpTransmitPacket[tcpHeaderLen], tcpPayload, tcpPayloadLen);
tcp_prepareTcpHeader(TCP_FLAG_PSH + TCP_FLAG_ACK); /* data packets are always sent with flags PUSH and ACK. */
tcp_packRequestIntoIp();
lastUnackTransmissionTime = rtc_get_ms(); /* record the time of transmission, to be able to detect the timeout */
retryCounter = TCP_MAX_NUMBER_OF_RETRANSMISSIONS; /* Allow n retries of the same packet */
}
else
{
Expand Down
13 changes: 12 additions & 1 deletion doc/clara_user_manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ after around 30s, the modem will go to sleep:
[34090] [ModemFinder] Number of modems: 0
```

The amount of logged data can be configured with the parameter "logging" using the web interface (see below).

## How to setup the build chain?

There are two totally different tool chains for Clara: The old one, until November 2023, uses the STM32 CubeIDE. The new one comes with a classical make file, and offers full flexibility regarding which editor/IDE is used. The description below is valid for the new variant.
Expand All @@ -61,5 +63,14 @@ C:\ST\STM32CubeIDE_1.12.1\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.external
- As soon as the bootloader is on the board, you have three options to flash:
- JTAG/SWD adapter (STLink, with the command line mentioned above)
- can-updater.py script (todo: more details)
- the esp32 web interface (todo: more details)
- the esp32 web interface (see below)

## How to use Clara with the openinverter web interface?

The esp32-web-interface (from openinverter shop or https://github.com/jsphuebner/esp32-web-interface) is able to talk to Clara via CAN.
Both using 500kBaud. Select the NodeID 22 in the web interface to connect to Clara.

Using the web interface, it is possible e.g.
- to change parameters and store them into flash memory, so that they are surviving power-cycles.
- to view spot values and to graph them
- to add and change the CAN mapping, which defines which signals are transmitted and received in which CAN messages
4 changes: 3 additions & 1 deletion include/param_prj.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
//Define a version string of your firmware here
#define VER 0.22.B

#include "myLogging.h"

/* Entries must be ordered as follows:
1. Saveable parameters (id != 0)
2. Temporary parameters (id = 0)
Expand All @@ -65,7 +67,7 @@
TESTP_ENTRY(CAT_CHARGE, soc, "%", 0, 100, 0, 5 ) \
TESTP_ENTRY(CAT_CHARGE, batvtg, "V", 0, 1000, 0, 6 ) \
TESTP_ENTRY(CAT_TEST, locktest, LOCK, 0, 2, 0, 9 ) \
TESTP_ENTRY(CAT_TEST, logging, MODULES, 0, 511, 0, 15 ) \
TESTP_ENTRY(CAT_TEST, logging, MODULES, 0, 511, DEFAULT_LOGGINGMASK, 15 ) \
VALUE_ENTRY(opmode, OPMODES, 2000 ) \
VALUE_ENTRY(version, VERSTR, 2001 ) \
VALUE_ENTRY(lasterr, errorListString, 2002 ) \
Expand Down

0 comments on commit baac4d6

Please sign in to comment.