foxBMS
1.1.0
The foxBMS Battery Management System API Documentation
|
Driver for the ADC module. More...
#include "adc.h"
#include "beta.h"
#include "database.h"
#include "epcos_b57251v5103j060.h"
#include "io.h"
#include "spi.h"
Go to the source code of this file.
Macros | |
#define | ADC_TEMPERATURE_FACTOR (10.0f) |
Typedefs | |
typedef enum ADC_TEMPERATURE_SENSOR_TYPE | ADC_TEMPERATURE_SENSOR_TYPE_e |
Enumerations | |
enum | ADC_TEMPERATURE_SENSOR_TYPE { ADC0_TEMPERATURE_SENSOR , ADC1_TEMPERATURE_SENSOR } |
Functions | |
static STD_RETURN_TYPE_e | ADC_Transmit (uint32 blocksize, uint16 *pTxBuffer, uint16 *pRxBuffer, SPI_INTERFACE_CONFIG_s *pSpiInterface) |
static float | ADC_ConvertVoltagesToTemperatures (float v_adc_V, ADC_TEMPERATURE_SENSOR_TYPE_e TsensorType) |
converts a raw voltage from ADC to a temperature value in Celsius. More... | |
void | ADC_Initialize (void) |
initializes the ADC devices. It is called during startup. More... | |
void | ADC_Control (void) |
determines which ADC is measured and stores result in database. More... | |
Variables | |
static uint8_t | adc_conversionState = ADC_INIT |
describes the current state of the conversion More... | |
static uint16_t | adc_txNull [SINGLE_MESSAGE_LENGTH] = {0x0000u, 0x0000u} |
static uint16_t | adc_txUnlockCommand [SINGLE_MESSAGE_LENGTH] = {0x0655u, 0x0000u} |
static uint16_t | adc_txLockCommand [SINGLE_MESSAGE_LENGTH] = {0x0555u, 0x0000u} |
static uint16_t | adc_txWakeupCommand [SINGLE_MESSAGE_LENGTH] = {0x0033u, 0x0000u} |
static uint16_t | adc_txReadRegisterCommand [SINGLE_MESSAGE_LENGTH] = {0x2F00u, 0x0000u} |
static uint16_t | adc_txWriteRegisterCommand [SINGLE_MESSAGE_LENGTH] = {0x4F0Fu, 0x0000u} |
static uint16_t | adc_rxReadSingleMessage [SINGLE_MESSAGE_LENGTH] = {0x0000u, 0x0000u} |
static uint16_t | adc_txConvert [CONVERT_LENGTH] |
static uint16_t | adc_rxConvert [CONVERT_LENGTH] |
static float | adc_adc0Voltage [4] = {0.0f, 0.0f, 0.0f, 0.0f} |
static float | adc_adc1Voltage [4] = {0.0f, 0.0f, 0.0f, 0.0f} |
static float | adc_lsb1 = 0.0f |
static float | adc_lsb2 = 0.0f |
static DATA_BLOCK_ADC_TEMPERATURE_s | adc_tableTemperature = {.header.uniqueId = DATA_BLOCK_ID_ADC_TEMPERATURE} |
Driver for the ADC module.
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:
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:
Definition in file adc.c.
#define ADC_TEMPERATURE_FACTOR (10.0f) |
typedef enum ADC_TEMPERATURE_SENSOR_TYPE ADC_TEMPERATURE_SENSOR_TYPE_e |
Type of temperature sensors
void ADC_Control | ( | void | ) |
|
static |
converts a raw voltage from ADC to a temperature value in Celsius.
The temperatures are read from NTC elements via voltage dividers. This function implements the look-up table between voltage and temperature, taking into account the NTC characteristics and the voltage divider.
v_adc_V | voltage read from ADC in V |
TsensorType | sensor type, dependent on ADC used (ADC0 or ADC1) |
Definition at line 179 of file adc.c.
void ADC_Initialize | ( | void | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
This message is used to read conversion results It consists of NULL commands. When receiving NULL commands, the ADC outputs conversion data on the MasterInSlaveOut line.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |