foxBMS - Unit Tests
1.5.0
The foxBMS Unit Tests API Documentation
|
Header for the driver for the NXP PCA9539 port expander module. More...
Go to the source code of this file.
Macros | |
#define | PEX_PIN_LOW (0u) |
#define | PEX_PIN_HIGH (1u) |
Functions | |
void | PEX_Initialize (void) |
initialize local variable containing state of port expander. More... | |
void | PEX_SetPin (uint8_t portExpander, uint8_t pin) |
sets pin to high. More... | |
void | PEX_ResetPin (uint8_t portExpander, uint8_t pin) |
sets pin to low. More... | |
uint8_t | PEX_GetPin (uint8_t portExpander, uint8_t pin) |
get pin state of port expander pins. More... | |
void | PEX_SetPinDirectionInput (uint8_t portExpander, uint8_t pin) |
sets pin direction to input. More... | |
void | PEX_SetPinDirectionOutput (uint8_t portExpander, uint8_t pin) |
sets pin to input. More... | |
void | PEX_SetPinPolarityInverted (uint8_t portExpander, uint8_t pin) |
sets pin polarity to inverted. More... | |
void | PEX_SetPinPolarityRetained (uint8_t portExpander, uint8_t pin) |
sets pin polarity to retained. More... | |
void | PEX_Trigger (void) |
implements reading/writing to the port expander registers. More... | |
Header for the driver for the NXP PCA9539 port expander 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 pex.h.
#define PEX_PIN_HIGH (1u) |
#define PEX_PIN_LOW (0u) |
uint8_t PEX_GetPin | ( | uint8_t | portExpander, |
uint8_t | pin | ||
) |
get pin state of port expander pins.
Definition at line 366 of file pex.c.
void PEX_Initialize | ( | void | ) |
initialize local variable containing state of port expander.
In the data sheet, pins are grouped in two sets, numbered from 00 to 07 and from 10 to 17. Each set is handled by a separate register, so pin 00 is numbered 0, pin 01 is numbered 01, .., pin 07 is numbered 07. But also pin 10 is numbered 0, pin 11 is numbered 01, .., pin 17 is numbered 07. Using defines from 0 to 15, it is possible to get with pin number which register has to be addressed: 0 to 7 means register for 00 to 07, 8 to 15 means register for 10 to 17. Applying (pin%8) for 8 to 15 gives 0 to 7, so the numbering in register is obtained immediately.
Default state of output registers data sheet: Rev. 9 - 8 November 2017, Table 7 and 8
Default state of polarity inversion registers data sheet: Rev. 9 - 8 November 2017, Table 9 and 10
Default state of direction registers data sheet: Rev. 9 - 8 November 2017, Table 11 and 12
void PEX_ResetPin | ( | uint8_t | portExpander, |
uint8_t | pin | ||
) |
void PEX_SetPin | ( | uint8_t | portExpander, |
uint8_t | pin | ||
) |
void PEX_SetPinDirectionInput | ( | uint8_t | portExpander, |
uint8_t | pin | ||
) |
void PEX_SetPinDirectionOutput | ( | uint8_t | portExpander, |
uint8_t | pin | ||
) |
void PEX_SetPinPolarityInverted | ( | uint8_t | portExpander, |
uint8_t | pin | ||
) |
void PEX_SetPinPolarityRetained | ( | uint8_t | portExpander, |
uint8_t | pin | ||
) |
void PEX_Trigger | ( | void | ) |
implements reading/writing to the port expander registers.
This function reads the desired port expander state (outputs, configuration) from the externally available variables and stores it in the local variable. It then applies this state to the devices via the I2C bus. It reads the pin input state via the I2C bus and writes it to the externally available port expander state.
Definition at line 312 of file pex.c.