CHAdeMO
Loading...
Searching...
No Matches
chademo_se.h File Reference

CHAdeMO power supply equipment (SE) Logic (Hardware-Agnostic) More...

#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  chademo_xx_can_frame
struct  chademo_se_vsensors
struct  chademo_se_psuctl_inputs
struct  chademo_se_psuctl_outputs
struct  chademo_se_vgpio
struct  chademo_se

Macros

#define chademo_se_can_frame   chademo_xx_can_frame
#define chademo_ev_can_frame   chademo_xx_can_frame

Enumerations

enum  chademo_se_psuctl_event {
  CHADEMO_SE_PSUCTL_EVENT_NONE , CHADEMO_SE_PSUCTL_EVENT_PLEASE_PROVIDE_INPUTS , CHADEMO_SE_PSUCTL_EVENT_PSU_CAN_BE_POWERED , CHADEMO_SE_PSUCTL_EVENT_PSU_CAN_PROVIDE_POWER ,
  CHADEMO_SE_PSUCTL_EVENT_PSU_MUST_SHUTDOWN
}
enum  chademo_se_psuctl_flags_fault {
  CHADEMO_SE_PSUCTL_FLAGS_FAULT_OVERVOLTAGE = 1u , CHADEMO_SE_PSUCTL_FLAGS_FAULT_OVERCURRENT = 2u , CHADEMO_SE_PSUCTL_FLAGS_FAULT_OVERTEMP = 4u , CHADEMO_SE_PSUCTL_FLAGS_FAULT_MALFUNCTION = 8u ,
  CHADEMO_SE_PSUCTL_FLAGS_FAULT_OTHER = 16u , CHADEMO_SE_PSUCTL_FLAGS_FAULT_API = 16u
}
enum  chademo_se_event {
  CHADEMO_SE_EVENT_NONE , CHADEMO_SE_EVENT_CHARGE_START_BUTTON_PRESSED , CHADEMO_SE_EVENT_GOT_EV_INITIAL_PARAMS , CHADEMO_SE_EVENT_INFO_BEFORE_CHARGING_IS_PROCESSED ,
  CHADEMO_SE_EVENT_VEHICLE_CHARGE_PERMISSION , CHADEMO_SE_EVENT_EV_CONTACTORS_ARE_OPEN
}

Functions

void chademo_se_init (struct chademo_se *self)
void chademo_se_get_vgpio_inputs (struct chademo_se *self, struct chademo_se_vgpio *dst)
void chademo_se_set_vgpio_inputs (struct chademo_se *self, struct chademo_se_vgpio *src)
void chademo_se_get_vgpio_outputs (struct chademo_se *self, struct chademo_se_vgpio *dst)
void chademo_se_set_vsensors_inputs (struct chademo_se *self, struct chademo_se_vsensors *src)
void chademo_se_get_psuctl_outputs (struct chademo_se *self, struct chademo_se_psuctl_outputs *dst)
bool chademo_se_push_vcan_frame (struct chademo_se *self, struct chademo_se_can_frame *f)
bool chademo_se_pop_vcan_frame (struct chademo_se *self, struct chademo_se_can_frame *f)
enum chademo_se_event chademo_se_step (struct chademo_se *self, uint32_t delta_time_ms)

Detailed Description

CHAdeMO power supply equipment (SE) Logic (Hardware-Agnostic)

This file contains the software implementation of the CHAdeMO EVSE logic. The design is hardware-agnostic, requiring an external adaptation layer for hardware interaction.

Reference Specification: Implemented based on the technical specifications outlined in IEEE Std 2030.1.1™-2015. The specification is not included in this repository due to legal reasons.

Important IP Notice: This implementation utilizes the CHAdeMO protocol, which is subject to Patents (SEPs) and Trade Secrets held by the CHAdeMO Association.

  • Users intending to manufacture or commercially distribute hardware derived from this software must secure the necessary licenses and permissions from the CHAdeMO Association.
  • The author claims no ownership over these third-party intellectual property rights and provides this code without warranty against third-party infringement.

Conventions: C89, Linux kernel style, MISRA, rule of 10, No hardware specific code, only generic C and some binding layer. Be extra specific about types.

Scientific units where posible at end of the names, for example:

  • timer_10s (timer_10s has a resolution of 10s per bit)
  • power_150w (power 150W per bit or 0.15kw per bit)

Keep variables without units if they're unknown or not specified or hard to define with short notation.

Copyright (c) 2025 furdog <https://github.com/furdog>
SPDX-License-Identifier: 0BSD

Macro Definition Documentation

◆ chademo_se_can_frame

#define chademo_se_can_frame   chademo_xx_can_frame

◆ chademo_ev_can_frame

#define chademo_ev_can_frame   chademo_xx_can_frame

Enumeration Type Documentation

◆ chademo_se_psuctl_event

Events emited by PSU controller

Enumerator
CHADEMO_SE_PSUCTL_EVENT_NONE 

No events emited by PSU controller

CHADEMO_SE_PSUCTL_EVENT_PLEASE_PROVIDE_INPUTS 

Virtual PSU controller awaits inputs to be configured

CHADEMO_SE_PSUCTL_EVENT_PSU_CAN_BE_POWERED 

Virtual PSU controller tells that PSU can be powered

CHADEMO_SE_PSUCTL_EVENT_PSU_CAN_PROVIDE_POWER 

Virtual PSU controller tells that PSU can provide power

CHADEMO_SE_PSUCTL_EVENT_PSU_MUST_SHUTDOWN 

Virtual PSU controller tells that PSU must be shutdown

◆ chademo_se_psuctl_flags_fault

PSU controller fault flags (must be mapped from real PSU by USER)

Enumerator
CHADEMO_SE_PSUCTL_FLAGS_FAULT_API 

API fault, set by default (indicates user API usage error)

◆ chademo_se_event

Events emited by main instance FSM

Function Documentation

◆ chademo_se_init()

void chademo_se_init ( struct chademo_se * self)

Initializes main instance (must be done before anything else)

◆ chademo_se_get_vgpio_inputs()

void chademo_se_get_vgpio_inputs ( struct chademo_se * self,
struct chademo_se_vgpio * dst )

Reads vgpio inputs and stores result into a destination dst

◆ chademo_se_set_vgpio_inputs()

void chademo_se_set_vgpio_inputs ( struct chademo_se * self,
struct chademo_se_vgpio * src )

Sets vgpio inputs from source src

◆ chademo_se_get_vgpio_outputs()

void chademo_se_get_vgpio_outputs ( struct chademo_se * self,
struct chademo_se_vgpio * dst )

Gets vgpio outputs and stores result into a destination dst

◆ chademo_se_set_vsensors_inputs()

void chademo_se_set_vsensors_inputs ( struct chademo_se * self,
struct chademo_se_vsensors * src )

Sets vsensors inputs from source src

◆ chademo_se_get_psuctl_outputs()

void chademo_se_get_psuctl_outputs ( struct chademo_se * self,
struct chademo_se_psuctl_outputs * dst )

Gets psuctl outputs and stores result into a destination dst

◆ chademo_se_push_vcan_frame()

bool chademo_se_push_vcan_frame ( struct chademo_se * self,
struct chademo_se_can_frame * f )

CAN2.0 frames from EV must go here. Returns true if frame has been consumed. Frame may not be consumed if charger is not in LISTEN mode.

◆ chademo_se_pop_vcan_frame()

bool chademo_se_pop_vcan_frame ( struct chademo_se * self,
struct chademo_se_can_frame * f )

CAN2.0 frames from charger emited here (popped from internal TX buffer). Returns true if frame has been returned. Frame may not be returned if internal buffer is empty.

◆ chademo_se_step()

enum chademo_se_event chademo_se_step ( struct chademo_se * self,
uint32_t delta_time_ms )

Main instance FSM. Must be called inside main loop.