Change Headphone Volume of SGTL5000 by Source

      Change Headphone Volume of SGTL5000 by Source

      Example how to change the Headphone output volume for the SGT5000.

      Source Code

      1. #include "ni2cio.h"
      2. static NI2C_MSG_HEADER msg[] =
      3. {
      4. { 0x14, 0x00, 0x0004 } /* Send 1 byte to 0x14 = Device:0x0A Direction:WRITE */
      5. };
      6. static BYTE data[] =
      7. {
      8. 0x00, 0x22,0x10, 0x10 ,/* Message 1: CHIP_ANA_HP_CTRL 0x0022 Headphone Right & LEft Channel Volume */
      9. };
      10. void SetHeadPhoneVolume()
      11. {
      12. HANDLE hI2C;
      13. /* Open I2C device file */
      14. hI2C = CreateFile(TEXT("I2C1:"), GENERIC_READ | GENERIC_WRITE,0, NULL, OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH, 0);
      15. /* Schedule transmission request */
      16. DeviceIoControl(hI2C, IOCTL_NI2C_SCHEDULE, (LPBYTE)msg, sizeof(msg), data, sizeof(data), NULL, NULL);
      17. /* ... Do something else here ... */
      18. /* Retrieve and print result */
      19. DeviceIoControl(hI2C, IOCTL_NI2C_GET_RESULT, (LPBYTE)msg, sizeof(msg), data, sizeof(data), NULL, NULL);
      20. /* Close I2C device file */
      21. CloseHandle(hI2C);
      22. }

      Post was edited 1 time, last by “philipp.fister” ().