Functions | Variables

# bq_pack.c File Reference

this file contains all the definitions of the BQ76PL536 devices. More...

`#include <intrinsics.h>`
`#include <string.h>`
`#include <stdio.h>`
`#include "MSP430.h"`
`#include "main.h"`
`#include "bq_pack.h"`
`#include "spi_if.h"`
`#include "data_flash.h"`
`#include "USBCDC_constructs.h"`
`#include "Common\types.h"`
`#include "Common\hal_macros.h"`

Go to the source code of this file.

## Functions
short | bq_pack_address_discovery (void)
| Function Name: bq_pack_address_discovery .
short | bq_pack_init (void)
| Function Name: bq_pack_init.
void | update_bq_pack_data (void)
| Function Name: update_bq_pack_data.
void | bq_pack_start_conv (void)
| Function Name: bq_pack_start_conv .
void | CheckFaultConditions (void)
| Function Name: CheckFaultConditions.
void | CheckChargeDischargeModes (void)
| Function Name: CheckChargeDischargeModes.
void | CellBalancing (void)
| Function Name: CellBalancing.
void | CheckEndOfChargeOrDischargeModes (void)
| Function Name: CheckEndOfChargeOrDischargeModes .
void | BatteryPackManager (void)
| Function Name: BatteryPackManager .
unsigned short | get_bq_pack_voltage (void)
| Function Name: get_bq_pack_voltage.
unsigned short | get_bq_pack_timer (void)
| Function Name: get_bq_pack_timer.
void | update_bq_pack_timer (void)
| Function Name: update_bq_pack_timer .
op_modes_t | get_bq_pack_mode (void)
| Function Name: get_bq_pack_mode .
void | set_bq_pack_mode (op_modes_t mode)
void | conf_bq_dev (bq_dev_t *this)
| Function Name: conf_bq_dev .
void | init_bq_dev_data_structure (bq_dev_t *this)
| Function Name: init_bq_dev_data_structure .
short | bq_dev_read_cell_voltage (bq_dev_t *this)
| Function Name: bq_dev_read_cell_voltage.
void | bq_dev_clear_alerts (bq_dev_t *this)
| Function Name: bq_dev_clear_alerts .
void | bq_dev_clear_faults (bq_dev_t *this)
| Function Name: bq_dev_clear_faults.
short | bq_dev_read_errors (bq_dev_t *this)
| Function Name: bq_dev_read_errors.
short | bq_dev_read_temps (bq_dev_t *this)
| Function Name: bq_dev_read_temps.
short | bq_dev_read_status (bq_dev_t *this)
| Function Name: bq_dev_read_status.
void | update_op_mode (op_modes_t new_mode)
| Function Name: update_op_mode .
short | check_for_cov (void)
| Function Name: check_for_cov .
short | check_for_cuv (void)
| Function Name: check_for_cuv .
short | check_for_pot (void)
| Function Name: check_for_pot .
unsigned short | check_for_charge_op (void)
| Function Name: check_for_charge_op.
unsigned short | check_for_discharge_op (void)
| Function Name: check_for_discharge_op .
void | copy_cell_voltage_values (void)
| Function Name: copy_cell_voltage_values.
unsigned short | cell_imbalance_threshold_reached (void)
| Function Name: cell_imbalance_threshold_reached .
unsigned short | find_imbalanced_cell (unsigned short in_dev_id)
| Function Name: find_imbalanced_cell .
void | enable_bypass_resistor (unsigned short in_dev_id, unsigned short in_value)
| Function Name: enable_bypass_resistor.
void | disable_bypass_resistor (unsigned short in_dev_id, unsigned short in_value)
| Function Name: disable_bypass_resistor.
void | disable_all_bypass_resistors (void)
| Function Name: disable_all_bypass_resistors.
## Variables
bq_pack_t | bq_pack
unsigned char | HOST_CONTROL_IN = 0

## Detailed Description

this file contains all the definitions of the BQ76PL536 devices.

Author:
  Daniel T. & Marcin N. Texas Instruments, Inc

Date:
  November 2010

Version:
  1.0 Initial version

Note:
  Built with IAR for MSP430 Version: 5.10

Definition in file bq_pack.c.

## Function Documentation

void BatteryPackManager | ( | void |  | ) |

Function Name: BatteryPackManager .

Description : Battery Manger Function.

Parameters:

  | parameters | : none

Returns:
  Value : none

Definition at line 472 of file bq_pack.c.

void bq_dev_clear_alerts | ( | bq_dev_t * | this | ) |

Function Name: bq_dev_clear_alerts .

Description : Clear the alert flags on the BQ device.

Parameters:

  | parameters | : specific device ID

Returns:
  Value : none

Definition at line 711 of file bq_pack.c.

void bq_dev_clear_faults | ( | bq_dev_t * | this | ) |

Function Name: bq_dev_clear_faults.

Description : Clears the fault flags on the BQ device.

Parameters:

  | parameters | : Device ID

Returns:
  Value : none

Definition at line 744 of file bq_pack.c.

short bq_dev_read_cell_voltage | ( | bq_dev_t * | this | ) |

Function Name: bq_dev_read_cell_voltage.

Description : reads the cell voltage on a specific BQ device.

Parameters:

  | parameters | : BQ device number in the stack

Returns:
  Value : returns the cell voltage read from the BQ device

Definition at line 676 of file bq_pack.c.

short bq_dev_read_errors | ( | bq_dev_t * | this | ) |

Function Name: bq_dev_read_errors.

Description : Reads the device status, alert status, fault status, COV status, CUV status registers.

Parameters:

  | parameters | : Device ID

Returns:
  Value : zero when the BQ device was read sucessfully

Definition at line 779 of file bq_pack.c.

short bq_dev_read_status | ( | bq_dev_t * | this | ) |

Function Name: bq_dev_read_status.

Description : reads the devoce status register.

Parameters:

  | parameters | : Device ID

Returns:
  Value : zero when the BQ device was read sucessfully

Definition at line 824 of file bq_pack.c.

short bq_dev_read_temps | ( | bq_dev_t * | this | ) |

Function Name: bq_dev_read_temps.

Description : reads the temperature registers.

Parameters:

  | parameters | : Device ID

Returns:
  Value : zero when the BQ device was read sucessfully

Definition at line 802 of file bq_pack.c.

short bq_pack_address_discovery | ( | void |  | ) |

Function Name: bq_pack_address_discovery .

Description : BQ Pack address discovery and assignement algorithm .

Parameters:

  | parameters | : void

Returns:
  Value : number of stacked BQ76PL536 devices

Definition at line 102 of file bq_pack.c.

short bq_pack_init | ( | void |  | ) |

Function Name: bq_pack_init.

Description : Configure each BQ device in the stack and initialize data structures for whole BQ stack .

Parameters:

  | parameters | : none

Returns:
  Value : return if there isn't problems while init the pack

Definition at line 164 of file bq_pack.c.

void bq_pack_start_conv | ( | void |  | ) |

Function Name: bq_pack_start_conv .

Description : triggers the ADC on the BQ devices.

Parameters:

  | parameters | : none

Returns:
  Value : none

Definition at line 262 of file bq_pack.c.

unsigned short cell_imbalance_threshold_reached | ( | void |  | ) |

Function Name: cell_imbalance_threshold_reached .

Description : Checks if the cell imbalance threshold is reached

Parameters:

  | parameters | : none

Returns:
  Value : 1 when the condition exist, 0 when it doesn't

Definition at line 1193 of file bq_pack.c.

void CellBalancing | ( | void |  | ) |

Function Name: CellBalancing.

Description : Identify the unbalanced cells and enables the bypass resistors to balance the cells while in charging mode .

Parameters:

  | parameters | : none

Returns:
  Value : none

Definition at line 338 of file bq_pack.c.

unsigned short check_for_charge_op | ( | void |  | ) |

Function Name: check_for_charge_op.

Description : Checks if the battery pack is in charge mode by checking if the cell voltages have increased.

Parameters:

  | parameters | : none

Returns:
  Value : 1 when the condition exist, 0 when it doesn't

Definition at line 1104 of file bq_pack.c.

short check_for_cov | ( | void |  | ) |

Function Name: check_for_cov .

Description : Checks for COV conditions.

Parameters:

  | parameters | : none

Returns:
  Value : 1 when the COV condition exist, 0 when it doesn't

Definition at line 992 of file bq_pack.c.

short check_for_cuv | ( | void |  | ) |

Function Name: check_for_cuv .

Description : Checks for CUV conditions.

Parameters:

  | parameters | : none

Returns:
  Value : 1 when the condition exist, 0 when it doesn't

Definition at line 1039 of file bq_pack.c.

unsigned short check_for_discharge_op | ( | void |  | ) |

Function Name: check_for_discharge_op .

Description : Checks if the battery pack is in discharge mode by checking if the cell voltages have decreased.

Parameters:

  | parameters | : none

Returns:
  Value : 1 when the condition exist, 0 when it doesn't

Definition at line 1137 of file bq_pack.c.

short check_for_pot | ( | void |  | ) |

Function Name: check_for_pot .

Description : Checks for POT conditions.

Parameters:

  | parameters | : none

Returns:
  Value : 1 when the condition exist, 0 when it doesn't

Definition at line 1085 of file bq_pack.c.

void CheckChargeDischargeModes | ( | void |  | ) |

Function Name: CheckChargeDischargeModes.

Description : Check if the pack is in charge or discharge mode.

Parameters:

  | parameters | : none

Returns:
  Value : none

Definition at line 303 of file bq_pack.c.

void CheckEndOfChargeOrDischargeModes | ( | void |  | ) |

Function Name: CheckEndOfChargeOrDischargeModes .

Description : Identifies if the pack is in end of charge or end of discharge modes .

Parameters:

  | parameters | : none

Returns:
  Value : none

Definition at line 448 of file bq_pack.c.

void CheckFaultConditions | ( | void |  | ) |

Function Name: CheckFaultConditions.

Description : Check fault conditions on the pack.

Parameters:

  | parameters | : none

Returns:
  Value : none

Definition at line 275 of file bq_pack.c.

void conf_bq_dev | ( | bq_dev_t * | this | ) |

Function Name: conf_bq_dev .

Description : configures each BQ76PL536 included in the stack.

Parameters:

  | parameters | : number of BQ device in the stack

Returns:
  Value : none

Definition at line 583 of file bq_pack.c.

void copy_cell_voltage_values | ( | void |  | ) |

Function Name: copy_cell_voltage_values.

Description : creates a backup of the last known cells voltages.

Parameters:

  | parameters | : none

Returns:
  Value : none

Definition at line 1169 of file bq_pack.c.

void disable_all_bypass_resistors | ( | void |  | ) |

Function Name: disable_all_bypass_resistors.

Description : disable all battery pack bypass resistors by controlling the CB outputs .

Parameters:

  | parameters | : none

Returns:
  Value : none

Definition at line 1279 of file bq_pack.c.

void disable_bypass_resistor | ( | unsigned short | in_dev_id,
|  | unsigned short | in_value |
| ) |  |  |

Function Name: disable_bypass_resistor.

Description : disable bypass resistors by controlling the CB outputs .

Parameters:

  | parameters | : Device ID, CB outputs to be controlled

Returns:
  Value : none

Definition at line 1256 of file bq_pack.c.

void enable_bypass_resistor | ( | unsigned short | in_dev_id,
|  | unsigned short | in_value |
| ) |  |  |

Function Name: enable_bypass_resistor.

Description : Enable bypass resistors by controlling the CB outputs.

Parameters:

  | parameters | : Device ID, CB outputs to be controlled

Returns:
  Value : none

Definition at line 1239 of file bq_pack.c.

unsigned short find_imbalanced_cell | ( | unsigned short | in_dev_id | ) |

Function Name: find_imbalanced_cell .

Description : finds the imbalanced cells.

Parameters:

  | parameters | : device ID

Returns:
  Value : Returns 0 if cells are balanced and other if there are any imbalanced cells .

Definition at line 1209 of file bq_pack.c.

op_modes_t get_bq_pack_mode | ( | void |  | ) |

Function Name: get_bq_pack_mode .

Description : returns current pack mode.

Parameters:

  | parameters | : none

Returns:
  Value : returns the current value of the mode

Definition at line 561 of file bq_pack.c.

unsigned short get_bq_pack_timer | ( | void |  | ) |

Function Name: get_bq_pack_timer.

Description : Returns BQ Pack time counter (for End of Charge or End of Discharge).

Parameters:

  | parameters | : none

Returns:
  Value : returns the last known value of the pack timer

Definition at line 502 of file bq_pack.c.

unsigned short get_bq_pack_voltage | ( | void |  | ) |

Function Name: get_bq_pack_voltage.

Description : Returns Pack voltage parameter.

Parameters:

  | parameters | : none

Returns:
  Value : returns last known pack voltage

Definition at line 490 of file bq_pack.c.

void init_bq_dev_data_structure | ( | bq_dev_t * | this | ) |

Function Name: init_bq_dev_data_structure .

Description : initializes the structure that stores the information of each BQ device .

Parameters:

  | parameters | : number of BQ device in the stack

Returns:
  Value : none

Definition at line 642 of file bq_pack.c.

void update_bq_pack_data | ( | void |  | ) |

Function Name: update_bq_pack_data.

Description : Reads data from BQ DEV registers and updates BQ PACK structure

Parameters:

  | parameters | : none

Returns:
  Value : none

Definition at line 207 of file bq_pack.c.

void update_bq_pack_timer | ( | void |  | ) |

Function Name: update_bq_pack_timer .

Description : update the multiple pack virtual timers.

Parameters:

  | parameters | : none

Returns:
  Value : none

Definition at line 513 of file bq_pack.c.

void update_op_mode | ( | op_modes_t | new_mode | ) |

Function Name: update_op_mode .

Description : updates the battery pack status.

Parameters:

  | parameters | : new operating mode

Returns:
  Value : none

Definition at line 837 of file bq_pack.c.