SLVUCR9B August 2023 – January 2024 TPS2HCS10-Q1
The Smart Fuse Configurator comes with a C header file that was generated from the register map of each supported high-side switch. Initially, this includes the TPS2HCS10-Q1 device. The header files are available on the product page and includes functionality such as:
This header file is meant to be used to enable software development on an embedded C platform. An excerpt of the SW_STATE register can be seen below.
/* --------- TPS2HC10S_SW_STATE (0x07) ----------*/
/* DESCRIPTION: */
#define TPS2HC10S_SW_STATE_REG 0x07
typedef union
{
uint16_t bytes;
struct
{
/* Set this bit to 1 to turn on the FET and CH1 output ON */
unsigned CH1_ON : 1;
/* Set this bit to 1 to turn on the FET and CH2 output ON */
unsigned CH2_ON : 1;
/* Reserved */
unsigned RESERVED_14 : 14;
} bits;
} TPS2HC10S_SW_STATE;
#define TPS2HC10S_SW_STATE_CH1_ON_MASK 0x01
#define TPS2HC10S_SW_STATE_CH1_ON_OFS 0
typedef enum {
ch1_on_en_1_0x1 = 0x1,
ch1_on_en_2_0x3 = 0x3,
} ch1_on_t;
#define TPS2HC10S_SW_STATE_CH2_ON_MASK 0x02
#define TPS2HC10S_SW_STATE_CH2_ON_OFS 1
typedef enum {
ch2_on_en_1_0x1 = 0x2,
ch2_on_en_2_0x2 = 0x4,
} ch2_on_t;
An example of using the bit-wise operation to set CH1 to enabled can be seen below.
int main()
{
TPS2HC10S_SW_STATE enableReg;
enableReg.bits.CH1_ON = 1;
printf("\nChannel Enable: 0x%x\n", enableReg.byte);
return 0;
}
A byte-wise example can be seen below.
#include "tps2hcs10.h"
#include <stdio.h>
int main()
{
TPS2HC10S_SW_STATE enableReg;
enableReg.byte = 0x01;
printf("\nChannel Enable: 0x%x\n", enableReg.byte);
return 0;
}