SLVAFT2A May   2024  – July 2024 TPS2HCS10-Q1

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Software Ecosystem
  5. 2Platform Drivers
    1. 2.1 Driver Concept
    2. 2.2 Supported Platforms
    3. 2.3 Porting to Other Platforms
    4. 2.4 API Guide
      1. 2.4.1  tHCSResponseCode Union Reference
      2. 2.4.2  float_t HCS_convertCurrent (uint16_t rawValue, uint16_t ksnsVal, uint16_t snsRes)
      3. 2.4.3  float_t HCS_convertTemperature (uint16_t rawValue)
      4. 2.4.4  float_t HCS_convertVoltage (uint16_t rawValue)
      5. 2.4.5  tHCSResponseCode HCS_getChannelFaultStatus (uint8_t chanNum, uint16_t * fltStatus)
      6. 2.4.6  tHCSResponseCode HCS_getDeviceFaultSatus (uint16_t * fltStatus)
      7. 2.4.7  tHCSResponseCode HCS_gotoLPM (lpm_exit_curr_ch1_t ch1ExitCurrent, lpm_exit_curr_ch2_t ch2ExitCurrent)
      8. 2.4.8  tHCSResponseCode HCS_gotoSleep (void )
      9. 2.4.9  tHCSResponseCode HCS_initializeDevice (TPS2HCS10Q1_CONFIG * config)
      10. 2.4.10 tHCSResponseCode HCS_readRegister (uint8_t addr, uint16_t * readValue)
      11. 2.4.11 tHCSResponseCode HCS_setSwitchState (uint8_t swState)
      12. 2.4.12 tHCSResponseCode HCS_updateConfig (TPS2HCS10Q1_CONFIG * config)
      13. 2.4.13 tHCSResponseCode HCS_wakeupDevice (void )
      14. 2.4.14 tHCSResponseCode HCS_writeRegister (uint8_t addr, uint16_t payload)
  6. 3Configuration or Evaluation Tool
  7. 4Code Examples
    1. 4.1 Empty Example
    2. 4.2 I2T Trip Example
    3. 4.3 Low-Power Mode Example
    4. 4.4 Current Sense Example
  8. 5Summary
  9. 6References
  10. 7Revision History

Porting to Other Platforms

While a variety of example architecture implementations are provided, the HCS platform drivers are architected to be easily ported to any microprocessor or architecture that supports SPI and the C programming language. In the header file for the drivers (hcs_control_driver.h), the following two functions are declared with an external reference:

/* --------------------------- Porting Functions ---------------------------- */
/*
 * These functions need to be implemented by each individual device port. The functions
 * handle the low-level hardware specific implementation with the respective
 * architecture's specific hardware peripherals (SPI and GPIO)
 */
bool HCS_port_spiSendData(uint8_t *data, uint8_t len, uint8_t* respData);
void HCS_port_assertSPI(void);
void HCS_port_deassertSPI(void);

Porting is meant to be straight forward, however a description of each function and guidance for porting is shown in Table 2-2.

Table 2-2 Architecture Porting Functions
Function Description Return Value
HCS_port_spiSendData Performs a full-duplex SPI transaction. data represents the data to be sent and respData is the data that is received. len is the length of the transaction. The function needs to be blocking (either by sleeping or polling) until the entirety of the SPI transaction is complete. stdbool representation of result of transaction. true if transaction completed without issue, false otherwise.
HCS_port_assertSPI Sets the chip select (CS) line of the SPI bus low. This is used for both single and daisy chained transactions as well as used by the HCS_port_spiSendData function above. None
HCS_port_deassertSPI Sets the chip select (CS) line of the SPI bus high. This is used for both single and daisy chained transactions as well as used by the HCS_port_spiSendData function above. None