### Set Minimum CMake Version Source: https://github.com/infineon/high-side-switch/blob/master/test/unit/CMakeLists.txt Specifies the minimum version of CMake required for this project. Ensure your CMake installation meets this requirement. ```cmake cmake_minimum_required(VERSION 3.12.4) ``` -------------------------------- ### Initialization Source: https://github.com/infineon/high-side-switch/wiki/Library-Details Initializes the PROFET-Board hardware components including GPIOs, ADCs, and Timers. ```APIDOC ## init() ### Description Initializes the PROFET-Board hardware. This must be called before any other library functions. ### Response - **Error_t** - Returns an error structure indicating the success or failure of the initialization. ``` -------------------------------- ### Configure Unit Test Directories and Labels Source: https://github.com/infineon/high-side-switch/blob/master/test/unit/CMakeLists.txt Sets up include directories and labels for C++ and C unit tests. Labels like 'CPP', 'unit', and 'coverage' help in organizing and filtering tests. ```cmake include_directories( ${CMAKE_SOURCE_DIR}/test/unit ) set( UNIT_TEST_CPP_LABELS "CPP;unit;coverage" ) set( UNIT_TEST_C_LABELS "C;unit;coverage" ) set( UNIT_TEST_CPP_LIBRARIES ${TEST_CPP_LIBRARIES} ) set( UNIT_TEST_C_LIBRARIES ${TEST_C_LIBRARIES} ) ``` -------------------------------- ### Initialize PROFET Board Source: https://github.com/infineon/high-side-switch/wiki/Library-Details Initializes all necessary hardware components for the PROFET board. This function must be called before any other PROFET library functions can be used. ```c++ Error_t init(); ``` -------------------------------- ### Compare Core Library and Arduino Wrapper Constructors Source: https://github.com/infineon/high-side-switch/blob/master/docs/lib-details/porting-guide.md The core library constructor requires PAL object instances, whereas the Arduino wrapper simplifies this by accepting native pin numbers. ```C Hss(GPIOPAL *den, GPIOPAL *in, ADCPAL *is, TimerPAL *timer, BtxVariants_t *btxVariant); ``` ```C HssIno(uint8_t den, uint8_t in0, uint8_t in1, uint8_t dsel, uint8_t is, BtxVariants_t * btxVariant); ``` -------------------------------- ### Define Test Libraries Source: https://github.com/infineon/high-side-switch/blob/master/test/unit/CMakeLists.txt Sets up the libraries required for testing, including Google Test and the high-side switch library itself. This ensures all necessary components are linked for test execution. ```cmake set( TEST_LIBRARIES ${GOOGLETEST_LINK_LIBRARIES} ${GOOGLETEST_LINK_LIBRARIES} high-side-switch ) set( TEST_CPP_LIBRARIES ${TEST_LIBRARIES} stdc++ ) set( TEST_C_LIBRARIES ${TEST_LIBRARIES} ) ``` -------------------------------- ### Configure platform.ini for high-side-switch Source: https://github.com/infineon/high-side-switch/blob/master/docs/sw-frmwk/arduino/arduino-platformio.md Add the library dependency to your platform.ini file to enable the high-side-switch library in your PlatformIO environment. ```ini [env:uno] platform = atmelavr board = uno framework = arduino lib_deps= # Using a library name high-side-switch-ino # Using the repository URL https://github.com/Infineon/arduino-high-side-switch ``` -------------------------------- ### Define Unit Test Source Files Source: https://github.com/infineon/high-side-switch/blob/master/test/unit/CMakeLists.txt Lists the C++ source files that constitute the unit tests for the high-side switch project. These files will be compiled and linked into test executables. ```cmake set ( TestNames "" test_hss.cpp test_hss-shield-btt60xx.cpp test_hss-shield-bts5001x.cpp test_hss-shield-bts700x.cpp test_hss-shield-bts500xx.cpp ) createSimpleTests( TESTS ${TestNames} LIBRARIES ${UNIT_TEST_CPP_LIBRARIES} LABELS ${UNIT_TEST_CPP_LABELS} SOURCES ${TestSources} ) add_dependencies(gcovr ${TestNames} ) ``` -------------------------------- ### Arduino API Classes Source: https://github.com/infineon/high-side-switch/blob/master/docs/api-reference/arduino-api.md Overview of the available classes for Infineon high-side switch shields in the Arduino framework. ```APIDOC ## Arduino API Classes ### Description The following classes are available for instance creation within the Arduino framework to control Infineon high-side switch hardware. ### Available Classes - **Bts700xShieldIno**: PROFET™+ 24V Shield - **Bts5001xShieldIno**: Power PROFET™ Shield - **Bts500xxShieldIno**: Power PROFET™ + 24/48V Shield - **Bth500xxShieldIno**: Power PROFET™ Shield - 1LUA - **Btt60xxShieldIno**: PROFET™+2 12V Shield ``` -------------------------------- ### Configure Include and Link Directories Source: https://github.com/infineon/high-side-switch/blob/master/test/unit/CMakeLists.txt Specifies the directories where CMake should look for header files and libraries. This is crucial for resolving dependencies during the build process. ```cmake include_directories( ${CMAKE_SOURCE_DIR}/src/pal /usr/local/include ) link_directories( ${CMAKE_SOURCE_DIR}/build/lib /usr/local/lib ) ``` -------------------------------- ### Platform Abstraction Layer (PAL) Interface Overview Source: https://github.com/infineon/high-side-switch/blob/master/docs/api-reference/pal-interface.md The high-side switch library relies on platform-specific implementations of ADC, GPIO, and Timer resources. The PAL defines abstract interfaces for these resources, allowing for framework-agnostic integration. ```APIDOC ## Platform Abstraction Layer (PAL) Interface ### Description The Platform Abstraction Layer (PAL) provides a set of abstract interfaces for accessing essential hardware resources such as Analog-to-Digital Converters (ADC), General Purpose Input/Output (GPIO), and Timers. These interfaces are crucial for the high-side switch library to function across different software frameworks and hardware platforms. ### Resources - **ADC PAL**: Interface for Analog-to-Digital Converter operations. - **GPIO PAL**: Interface for General Purpose Input/Output operations. - **Timer PAL**: Interface for Timer operations. ``` -------------------------------- ### Enable Multiple High-Side Switches Source: https://github.com/infineon/high-side-switch/wiki/Library-Details Enables multiple high-side switches simultaneously based on boolean flags. Switches not explicitly set to true remain in their previous state. Default values are NULL, effectively treated as false if not provided. ```c++ switchesHxOn(0,1,1,0); // This call will enable the switch 2 and 3. /** But it could have been also written like this. **/ switchesHxOn(0,1,1); // This is the same, because the last switch is by default set to 0 /** Here is another example **/ switchesHxOn(1,1); // Turn on switch 1 and 2 /** If you only want to switch on the last switch (4) you have to set the previous channels to 0, please keep that in mind **/ switchesHxOn(0,0,0,1) // This would only switch on the last switch (4) ``` ```c++ HssBoard::Error_t HssBoard::switchesHxOn(bool h1 = NULL, bool h2 = NULL, bool h3 = NULL, bool h4 = NULL) { if(h1 == true){ hss1->enable(); led1->enable(); } if(h2 == true){ hss2->enable(); led2->enable(); } if(h3 == true){ hss3->enable(); led3->enable(); } if(h4 == true){ hss4->enable(); led4->enable(); } return OK; } ``` -------------------------------- ### Create gcovr Coverage Target Source: https://github.com/infineon/high-side-switch/blob/master/test/unit/CMakeLists.txt Defines a custom CMake target named 'gcovr' that generates code coverage reports. It cleans previous reports, builds the project, runs tests, and then executes gcovr to produce HTML and SonarQube-compatible XML reports. ```cmake set( GCOV_FILES_DIR ${CMAKE_BINARY_DIR}/CMakeFiles/${corelib}.dir/src ) add_custom_target( gcovr COMMAND ${CMAKE_COMMAND} -E remove_directory coverage COMMAND ${CMAKE_COMMAND} -E make_directory coverage COMMAND ${CMAKE_MAKE_PROGRAM} test COMMAND ${CMAKE_COMMAND} -E echo "=================== GCOVR ===================" COMMAND gcovr -r ${CMAKE_SOURCE_DIR} ${GCOV_FILES_DIR} -b -k --gcov-ignore-parse-errors --html --html-details -o ${CMAKE_BINARY_DIR}/coverage/coverage.html --sonarqube ${CMAKE_BINARY_DIR}/coverage/coverage.xml COMMAND ${CMAKE_COMMAND} -E echo "-- Coverage files have been output to ${CMAKE_BINARY_DIR}/coverage" WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) ``` -------------------------------- ### Timer PAL Source: https://github.com/infineon/high-side-switch/blob/master/docs/api-reference/pal-interface.md Details the abstract interface for Timer operations. ```APIDOC ## Timer PAL ### Description The Timer PAL defines the abstract interface for utilizing timer peripherals. It includes methods for configuring timer modes, setting time intervals, starting, stopping, and handling timer interrupts. ### Parameters *No specific parameters are detailed in the provided text for the Timer PAL interface itself, but its usage implies the need for timer configuration and control.* ``` -------------------------------- ### Enable Single High-Side Switch Source: https://github.com/infineon/high-side-switch/wiki/Library-Details Enables a specific high-side switch channel and its corresponding LED indicator. The channel is selected by the `x` parameter. ```c++ HssBoard::Error_t HssBoard::switchHxOn(uint8_t x) { switch(x) { case 1: hss1->enable(); led1->enable(); break; case 2: hss2->enable(); led2->enable(); break; case 3: hss3->enable(); led3->enable(); break; case 4: hss4->enable(); led4->enable(); break; } return OK; } ``` -------------------------------- ### GPIO PAL Source: https://github.com/infineon/high-side-switch/blob/master/docs/api-reference/pal-interface.md Details the abstract interface for General Purpose Input/Output (GPIO) operations. ```APIDOC ## GPIO PAL ### Description The GPIO PAL defines the abstract interface for controlling General Purpose Input/Output pins. It outlines the methods necessary for configuring pin direction (input/output), setting pin states, and reading pin states. ### Parameters *No specific parameters are detailed in the provided text for the GPIO PAL interface itself, but its usage implies the need for pin configuration and state management.* ``` -------------------------------- ### Multi-Switch Control Source: https://github.com/infineon/high-side-switch/wiki/Library-Details Functions to enable or disable multiple switch channels simultaneously. ```APIDOC ## switchesHxOn(bool h1, bool h2, bool h3, bool h4) ### Description Enables multiple switches at once based on boolean flags. ### Parameters #### Request Body - **h1, h2, h3, h4** (bool) - Optional - Boolean flags for each channel. Defaults to NULL. ## switchesHxOff(bool h1, bool h2, bool h3, bool h4) ### Description Disables multiple switches at once based on boolean flags. ### Parameters #### Request Body - **h1, h2, h3, h4** (bool) - Optional - Boolean flags for each channel. Defaults to NULL. ``` -------------------------------- ### Current Sense Reading Source: https://github.com/infineon/high-side-switch/wiki/Library-Details Reads the current flowing through a specific switch channel. ```APIDOC ## readIsx(uint8_t x) ### Description Reads the current sense (IS) pin of the specified channel and returns the current value in mA. ### Parameters #### Request Body - **x** (uint8_t) - Required - The channel number (1-4) to read. ### Response - **float** - The current flowing through the channel in mA. ``` -------------------------------- ### Read Battery Voltage Source: https://github.com/infineon/high-side-switch/wiki/Library-Details Monitors the battery voltage by reading an ADC value and applying a voltage divider calculation. ```c++ float HssBoard::readVss() { uint16_t adcResult = 0; float voltage = 0.0; adcResult = vBat->ADCRead(); voltage = adcResult * ((float)5/(float)1024); // Vmax/1024 LSB = Resolution of the ADC, 57/10 = Reverse Voltage devider to get the Supplyvoltage voltage = (voltage - vBatOffset) * vBatGain; voltage = voltage * ((float)57/(float)10); filterVbat->input(voltage); return filterVbat->output(); } ``` -------------------------------- ### Read Diagnostic Status of a Switch Source: https://github.com/infineon/high-side-switch/wiki/Library-Details Determines the state of a specific switch by analyzing current flow, identifying conditions like short circuits or open loads. ```c++ HssBoard::DiagStatus_t HssBoard::readDiagx(uint8_t x) { DiagStatus_t diagStatus = NORMAL; float currentOn = 0.0; float currentOff = 0.0; switch(x) { case 1: hss1->enableDiag(); if(hss1->getSwitchStatus() == Hss::Status_t::POWER_ON){ diagStatus = hss1->diagRead(); } else{ oloff->enable(); timer->delayMicro(300); currentOn = hss1->readIs(); oloff->disable(); timer->delayMicro(400); currentOff = hss1->readIs(); diagStatus = diagnosisOff(currentOn, currentOff); } hss1->disableDiag(); break; case 2: hss2->enableDiag(); if(hss2->getSwitchStatus() == Hss::Status_t::POWER_ON){ diagStatus = hss2->diagRead(); } else{ oloff->enable(); timer->delayMicro(300); currentOn = hss2->readIs(); oloff->disable(); timer->delayMicro(400); currentOff = hss2->readIs(); diagStatus = diagnosisOff(currentOn, currentOff); } hss2->disableDiag(); break; case 3: hss3->enableDiag(); if(hss3->getSwitchStatus() == Hss::Status_t::POWER_ON){ diagStatus = hss3->diagRead(); } else{ oloff->enable(); timer->delayMicro(300); currentOn = hss3->readIs(); oloff->disable(); timer->delayMicro(400); currentOff = hss3->readIs(); diagStatus = diagnosisOff(currentOn, currentOff); } hss3->disableDiag(); break; case 4: hss4->enableDiag(); if(hss4->getSwitchStatus() == Hss::Status_t::POWER_ON){ diagStatus = hss4->diagRead(); } else{ oloff->enable(); timer->delayMicro(300); currentOn = hss4->readIs(); oloff->disable(); timer->delayMicro(400); currentOff = hss4->readIs(); diagStatus = diagnosisOff(currentOn, currentOff); } hss4->disableDiag(); break; } return diagStatus; } ``` -------------------------------- ### Switch Control Source: https://github.com/infineon/high-side-switch/wiki/Library-Details Functions to enable or disable specific high-side switch channels. ```APIDOC ## switchHxOn(uint8_t x) ### Description Enables a specific switch channel and its corresponding LED. ### Parameters #### Request Body - **x** (uint8_t) - Required - The channel number (1-4) to enable. ## switchHxOff(uint8_t x) ### Description Disables a specific switch channel and its corresponding LED. ### Parameters #### Request Body - **x** (uint8_t) - Required - The channel number (1-4) to disable. ``` -------------------------------- ### Read Current Sense from Switch Channel Source: https://github.com/infineon/high-side-switch/wiki/Library-Details Reads the current flowing through a specific high-side switch channel. It enables diagnostic mode, reads the current in mA, and then disables diagnostic mode. The `x` parameter specifies the channel. ```c++ float HssBoard::readIsx(uint8_t x) { float result; switch (x) { case 1: hss1->enableDiag(); result = hss1->readIs(); hss1->disableDiag(); break; case 2: hss2->enableDiag(); result = hss2->readIs(); hss2->disableDiag(); break; case 3: hss3->enableDiag(); result = hss3->readIs(); hss3->disableDiag(); break; case 4: hss4->enableDiag(); result = hss4->readIs(); hss4->disableDiag(); break; } return result; } ``` -------------------------------- ### ADC PAL Source: https://github.com/infineon/high-side-switch/blob/master/docs/api-reference/pal-interface.md Details the abstract interface for Analog-to-Digital Converter (ADC) operations. ```APIDOC ## ADC PAL ### Description The ADC PAL defines the abstract interface for interacting with Analog-to-Digital Converters. It specifies the methods required to configure and read analog values from the platform's ADC peripherals. ### Parameters *No specific parameters are detailed in the provided text for the ADC PAL interface itself, but its usage implies the need for configuration and read operations.* ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.