foxBMS - Unit Tests  1.5.0
The foxBMS Unit Tests API Documentation
sps_cfg.h File Reference

Header for the configuration for the driver for the smart power switches. More...

#include "battery_system_cfg.h"
#include "sps_types.h"
#include <math.h>
#include <stdint.h>
Include dependency graph for sps_cfg.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SPS_CHANNEL_STATE_s
 
struct  SPS_CHANNEL_FEEDBACK_MAPPING_s
 

Macros

#define SPS_NR_CONTACTOR_PER_IC   (4u)
 
#define SPS_NR_OF_IC   (2u)
 
#define SPS_NR_OF_REQUIRED_CONTACTOR_CHANNELS   (BS_NR_OF_CONTACTORS)
 
#define SPS_NR_OF_AVAILABLE_SPS_CHANNELS   (SPS_NR_CONTACTOR_PER_IC * SPS_NR_OF_IC)
 
#define SPS_SPI_BUFFERSIZE   SPS_NR_OF_IC
 
#define SPS_RW_BIT_POSITION   (15u)
 
#define SPS_RW_READ   (0u)
 
#define SPS_RW_WRITE   (1u)
 
#define SPS_ADDRESS_BIT_START   (8u)
 
#define SPS_DIAG_CTRL_BIT_POSITION   (7u)
 
#define SPS_NORMAL_MODE   (0x01u)
 
#define SPS_STRONG_DRIVE   (0x00u)
 
#define SPS_MEDIUM_DRIVE   (0x01u)
 
#define SPS_MODE_BIT_START   (6u)
 
#define SPS_DRIVE_STRENGTH_BIT_START   (5u)
 
#define SPS_I_MEASUREMENT_LSB_mA   (0.98f)
 
#define SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA   (20.0f)
 
#define SPS_BITMASK_DIAGNOSTIC_ONDEMAND_OUTPUT_CURRENT   (0x1FFFu)
 
#define SPS_RESET_GIO_PORT   (hetREG2->DOUT)
 
#define SPS_RESET_GIO_PORT_DIR   (hetREG2->DIR)
 
#define SPS_RESET_PIN   (16u)
 
#define SPS_FEEDBACK_GIO_PORT   (hetREG2->DOUT)
 
#define SPS_FEEDBACK_GIO_PORT_DIR   (hetREG2->DIR)
 
#define SPS_FEEDBACK_PIN   (9u)
 
#define SPS_CHANNEL_0   ((SPS_CHANNEL_INDEX)0)
 
#define SPS_CHANNEL_1   ((SPS_CHANNEL_INDEX)1)
 
#define SPS_CHANNEL_2   ((SPS_CHANNEL_INDEX)2)
 
#define SPS_CHANNEL_3   ((SPS_CHANNEL_INDEX)3)
 
#define SPS_CHANNEL_4   ((SPS_CHANNEL_INDEX)4)
 
#define SPS_CHANNEL_5   ((SPS_CHANNEL_INDEX)5)
 
#define SPS_CHANNEL_6   ((SPS_CHANNEL_INDEX)6)
 
#define SPS_CHANNEL_7   ((SPS_CHANNEL_INDEX)7)
 
#define SPS_GLOBAL_CONTROL_REGISTER_ADDRESS   (0x00u)
 
#define SPS_OUTPUT_CONTROL_REGISTER_ADDRESS   (0x02u)
 
#define SPS_C_CONTROL_REGISTER_ADDRESS   (0x16u)
 
#define SPS_ISR_IRQ_DIAG_REGISTER_ADDRESS   (0x06u)
 
#define SPS_ISR_WARN_DIAG_REGISTER_ADDRESS   (0x07u)
 
#define SPS_OD_IOUT1_DIAG_REGISTER_ADDRESS   (0x08u)
 
#define SPS_OD_IOUT2_DIAG_REGISTER_ADDRESS   (0x09u)
 
#define SPS_OD_IOUT3_DIAG_REGISTER_ADDRESS   (0x0Au)
 
#define SPS_OD_IOUT4_DIAG_REGISTER_ADDRESS   (0x0Bu)
 

Enumerations

enum  SPS_WRITE_TYPE_e { SPS_replaceCurrentValue , SPS_orWithCurrentValue , SPS_andWithCurrentValue }
 
enum  SPS_READ_TYPE_e { SPS_READ_DIAGNOSTIC_REGISTER , SPS_READ_CONTROL_REGISTER }
 
enum  SPS_CHANNEL_FUNCTION_e { SPS_CHANNEL_OFF , SPS_CHANNEL_ON }
 
enum  SPS_STATE_e {
  SPS_START , SPS_RESET_LOW , SPS_RESET_HIGH , SPS_CONFIGURE_CONTROL_REGISTER ,
  SPS_TRIGGER_CURRENT_MEASUREMENT , SPS_READ_MEASURED_CURRENT1 , SPS_READ_MEASURED_CURRENT2 , SPS_READ_MEASURED_CURRENT3 ,
  SPS_READ_MEASURED_CURRENT4 , SPS_READ_EN_IRQ_PIN
}
 
enum  SPS_ACTION_e {
  SPS_ACTION_CONFIGURE_CONTROL_REGISTER , SPS_ACTION_TRIGGER_CURRENT_MEASUREMENT , SPS_ACTION_READ_CURRENT_MEASUREMENT1 , SPS_ACTION_READ_CURRENT_MEASUREMENT2 ,
  SPS_ACTION_READ_CURRENT_MEASUREMENT3 , SPS_ACTION_READ_CURRENT_MEASUREMENT4 , SPS_ACTION_READ_EN_IRQ_PIN
}
 

Variables

SPS_CHANNEL_STATE_s sps_channelStatus [SPS_NR_OF_AVAILABLE_SPS_CHANNELS]
 
const SPS_CHANNEL_FEEDBACK_MAPPING_s sps_kChannelFeedbackMapping [SPS_NR_OF_AVAILABLE_SPS_CHANNELS]
 

Detailed Description

Header for the configuration for the driver for the smart power switches.

SPDX-License-Identifier: BSD-3-Clause

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:

  • ″This product uses parts of foxBMS®″
  • ″This product includes parts of foxBMS®″
  • ″This product is derived from foxBMS®″
Author
foxBMS Team
Date
2020-10-14 (date of creation)
Updated
2023-02-03 (date of last update)
Version
v1.5.0
Prefix
SPS

Definition in file sps_cfg.h.

Macro Definition Documentation

◆ SPS_ADDRESS_BIT_START

#define SPS_ADDRESS_BIT_START   (8u)

In Tx SPI buffer, register address starts at bit 8

Definition at line 145 of file sps_cfg.h.

◆ SPS_BITMASK_DIAGNOSTIC_ONDEMAND_OUTPUT_CURRENT

#define SPS_BITMASK_DIAGNOSTIC_ONDEMAND_OUTPUT_CURRENT   (0x1FFFu)

bitmask for reading the on-demand output current from a SPI transaction

Definition at line 170 of file sps_cfg.h.

◆ SPS_C_CONTROL_REGISTER_ADDRESS

#define SPS_C_CONTROL_REGISTER_ADDRESS   (0x16u)

Addresses of used control registers

Definition at line 123 of file sps_cfg.h.

◆ SPS_CHANNEL_0

#define SPS_CHANNEL_0   ((SPS_CHANNEL_INDEX)0)

Defines for the individual SPS channels

Definition at line 88 of file sps_cfg.h.

◆ SPS_CHANNEL_1

#define SPS_CHANNEL_1   ((SPS_CHANNEL_INDEX)1)

Defines for the individual SPS channels

Definition at line 89 of file sps_cfg.h.

◆ SPS_CHANNEL_2

#define SPS_CHANNEL_2   ((SPS_CHANNEL_INDEX)2)

Defines for the individual SPS channels

Definition at line 90 of file sps_cfg.h.

◆ SPS_CHANNEL_3

#define SPS_CHANNEL_3   ((SPS_CHANNEL_INDEX)3)

Defines for the individual SPS channels

Definition at line 91 of file sps_cfg.h.

◆ SPS_CHANNEL_4

#define SPS_CHANNEL_4   ((SPS_CHANNEL_INDEX)4)

Defines for the individual SPS channels

Definition at line 92 of file sps_cfg.h.

◆ SPS_CHANNEL_5

#define SPS_CHANNEL_5   ((SPS_CHANNEL_INDEX)5)

Defines for the individual SPS channels

Definition at line 93 of file sps_cfg.h.

◆ SPS_CHANNEL_6

#define SPS_CHANNEL_6   ((SPS_CHANNEL_INDEX)6)

Defines for the individual SPS channels

Definition at line 94 of file sps_cfg.h.

◆ SPS_CHANNEL_7

#define SPS_CHANNEL_7   ((SPS_CHANNEL_INDEX)7)

Defines for the individual SPS channels

Definition at line 95 of file sps_cfg.h.

◆ SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA

#define SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA   (20.0f)

current threshold that recognizes a contactor as closed

Definition at line 167 of file sps_cfg.h.

◆ SPS_DIAG_CTRL_BIT_POSITION

#define SPS_DIAG_CTRL_BIT_POSITION   (7u)

This bit is set to 0 to read a diagnostic register, to 1 to read a control register

Definition at line 147 of file sps_cfg.h.

◆ SPS_DRIVE_STRENGTH_BIT_START

#define SPS_DRIVE_STRENGTH_BIT_START   (5u)

bitshift for the drive strength bit in the SPS

Definition at line 161 of file sps_cfg.h.

◆ SPS_FEEDBACK_GIO_PORT

#define SPS_FEEDBACK_GIO_PORT   (hetREG2->DOUT)

GIO defines for pin to drive feedback enable MOSFET of SPS

Definition at line 76 of file sps_cfg.h.

◆ SPS_FEEDBACK_GIO_PORT_DIR

#define SPS_FEEDBACK_GIO_PORT_DIR   (hetREG2->DIR)

GIO defines for pin to drive feedback enable MOSFET of SPS

Definition at line 77 of file sps_cfg.h.

◆ SPS_FEEDBACK_PIN

#define SPS_FEEDBACK_PIN   (9u)

GIO defines for pin to drive feedback enable MOSFET of SPS

Definition at line 78 of file sps_cfg.h.

◆ SPS_GLOBAL_CONTROL_REGISTER_ADDRESS

#define SPS_GLOBAL_CONTROL_REGISTER_ADDRESS   (0x00u)

Addresses of used control registers

Definition at line 121 of file sps_cfg.h.

◆ SPS_I_MEASUREMENT_LSB_mA

#define SPS_I_MEASUREMENT_LSB_mA   (0.98f)

LSB of current measurement of SPS channel in mA

Definition at line 164 of file sps_cfg.h.

◆ SPS_ISR_IRQ_DIAG_REGISTER_ADDRESS

#define SPS_ISR_IRQ_DIAG_REGISTER_ADDRESS   (0x06u)

Addresses of used diagnostic registers

Definition at line 126 of file sps_cfg.h.

◆ SPS_ISR_WARN_DIAG_REGISTER_ADDRESS

#define SPS_ISR_WARN_DIAG_REGISTER_ADDRESS   (0x07u)

Addresses of used diagnostic registers

Definition at line 127 of file sps_cfg.h.

◆ SPS_MEDIUM_DRIVE

#define SPS_MEDIUM_DRIVE   (0x01u)

value for the SPS medium drive

Definition at line 154 of file sps_cfg.h.

◆ SPS_MODE_BIT_START

#define SPS_MODE_BIT_START   (6u)

bitshift for the mode bit in the SPS

used for bitshifting SPS_NORMAL_MODE to the right position

Definition at line 159 of file sps_cfg.h.

◆ SPS_NORMAL_MODE

#define SPS_NORMAL_MODE   (0x01u)

value for the SPS normal mode

Definition at line 150 of file sps_cfg.h.

◆ SPS_NR_CONTACTOR_PER_IC

#define SPS_NR_CONTACTOR_PER_IC   (4u)

Each SPS IC has four outputs

Definition at line 82 of file sps_cfg.h.

◆ SPS_NR_OF_AVAILABLE_SPS_CHANNELS

#define SPS_NR_OF_AVAILABLE_SPS_CHANNELS   (SPS_NR_CONTACTOR_PER_IC * SPS_NR_OF_IC)

Calculate the number of available SPS channels

Definition at line 102 of file sps_cfg.h.

◆ SPS_NR_OF_IC

#define SPS_NR_OF_IC   (2u)

Number of SPS IC that are populated on the hardware (in daisy-chain)

Definition at line 85 of file sps_cfg.h.

◆ SPS_NR_OF_REQUIRED_CONTACTOR_CHANNELS

#define SPS_NR_OF_REQUIRED_CONTACTOR_CHANNELS   (BS_NR_OF_CONTACTORS)

One channel for each contactor is required in this application

Definition at line 99 of file sps_cfg.h.

◆ SPS_OD_IOUT1_DIAG_REGISTER_ADDRESS

#define SPS_OD_IOUT1_DIAG_REGISTER_ADDRESS   (0x08u)

Addresses of used diagnostic registers

Definition at line 128 of file sps_cfg.h.

◆ SPS_OD_IOUT2_DIAG_REGISTER_ADDRESS

#define SPS_OD_IOUT2_DIAG_REGISTER_ADDRESS   (0x09u)

Addresses of used diagnostic registers

Definition at line 129 of file sps_cfg.h.

◆ SPS_OD_IOUT3_DIAG_REGISTER_ADDRESS

#define SPS_OD_IOUT3_DIAG_REGISTER_ADDRESS   (0x0Au)

Addresses of used diagnostic registers

Definition at line 130 of file sps_cfg.h.

◆ SPS_OD_IOUT4_DIAG_REGISTER_ADDRESS

#define SPS_OD_IOUT4_DIAG_REGISTER_ADDRESS   (0x0Bu)

Addresses of used diagnostic registers

Definition at line 131 of file sps_cfg.h.

◆ SPS_OUTPUT_CONTROL_REGISTER_ADDRESS

#define SPS_OUTPUT_CONTROL_REGISTER_ADDRESS   (0x02u)

Addresses of used control registers

Definition at line 122 of file sps_cfg.h.

◆ SPS_RESET_GIO_PORT

#define SPS_RESET_GIO_PORT   (hetREG2->DOUT)

GIO defines for pin to drive reset line of SPS

Definition at line 70 of file sps_cfg.h.

◆ SPS_RESET_GIO_PORT_DIR

#define SPS_RESET_GIO_PORT_DIR   (hetREG2->DIR)

GIO defines for pin to drive reset line of SPS

Definition at line 71 of file sps_cfg.h.

◆ SPS_RESET_PIN

#define SPS_RESET_PIN   (16u)

GIO defines for pin to drive reset line of SPS

Definition at line 72 of file sps_cfg.h.

◆ SPS_RW_BIT_POSITION

#define SPS_RW_BIT_POSITION   (15u)

These bits and positions are defined in figure 7 page 10 in data sheet Rev. 2 - 11 September 2019 This bit is set to 0 for a read register access, to 1 for a write register access

Definition at line 139 of file sps_cfg.h.

◆ SPS_RW_READ

#define SPS_RW_READ   (0u)

Define for read register access

Definition at line 141 of file sps_cfg.h.

◆ SPS_RW_WRITE

#define SPS_RW_WRITE   (1u)

Define for write register access

Definition at line 143 of file sps_cfg.h.

◆ SPS_SPI_BUFFERSIZE

#define SPS_SPI_BUFFERSIZE   SPS_NR_OF_IC

Defines the buffer size to communicate with the SPS IC.

One 16 bit word per SPS IC so buffer size is equivalent to the number of SPS ICs.

  • 1 SPS IC -> Buffer size = 1
  • 2 SPS IC -> Buffer size = 2
  • 3 SPS IC -> Buffer size = 3

Definition at line 118 of file sps_cfg.h.

◆ SPS_STRONG_DRIVE

#define SPS_STRONG_DRIVE   (0x00u)

value for the SPS strong drive

Definition at line 152 of file sps_cfg.h.

Enumeration Type Documentation

◆ SPS_ACTION_e

Actions to do for the Smart Power Switch IC

Enumerator
SPS_ACTION_CONFIGURE_CONTROL_REGISTER 
SPS_ACTION_TRIGGER_CURRENT_MEASUREMENT 
SPS_ACTION_READ_CURRENT_MEASUREMENT1 
SPS_ACTION_READ_CURRENT_MEASUREMENT2 
SPS_ACTION_READ_CURRENT_MEASUREMENT3 
SPS_ACTION_READ_CURRENT_MEASUREMENT4 
SPS_ACTION_READ_EN_IRQ_PIN 

Definition at line 226 of file sps_cfg.h.

◆ SPS_CHANNEL_FUNCTION_e

functional state of a SPS channel

Enumerator
SPS_CHANNEL_OFF 

sps channel is switched off

SPS_CHANNEL_ON 

sps channel is switched on

Definition at line 186 of file sps_cfg.h.

◆ SPS_READ_TYPE_e

sps read types

Enumerator
SPS_READ_DIAGNOSTIC_REGISTER 

diagnostic register read

SPS_READ_CONTROL_REGISTER 

control register read

Definition at line 180 of file sps_cfg.h.

◆ SPS_STATE_e

State for the CONT handling

Enumerator
SPS_START 
SPS_RESET_LOW 
SPS_RESET_HIGH 
SPS_CONFIGURE_CONTROL_REGISTER 
SPS_TRIGGER_CURRENT_MEASUREMENT 
SPS_READ_MEASURED_CURRENT1 
SPS_READ_MEASURED_CURRENT2 
SPS_READ_MEASURED_CURRENT3 
SPS_READ_MEASURED_CURRENT4 
SPS_READ_EN_IRQ_PIN 

Definition at line 212 of file sps_cfg.h.

◆ SPS_WRITE_TYPE_e

spi block identification numbers

Enumerator
SPS_replaceCurrentValue 
SPS_orWithCurrentValue 
SPS_andWithCurrentValue 

Definition at line 173 of file sps_cfg.h.

Variable Documentation

◆ sps_channelStatus

channel states

Definition at line 68 of file sps_cfg.c.

◆ sps_kChannelFeedbackMapping

const SPS_CHANNEL_FEEDBACK_MAPPING_s sps_kChannelFeedbackMapping[SPS_NR_OF_AVAILABLE_SPS_CHANNELS]
extern

mapping of channel states to feedback pins

Definition at line 85 of file sps_cfg.c.