26 constexpr uint8_t StatusInputCommand[] = {0x05, 0xFF, 0xDA};
34 if(memcmp(buf + 1, StatusInputCommand,
sizeof (StatusInputCommand)) == 0) {
38 const auto newVolume = buf[
sizeof (StatusInputCommand) + 1];
39 const auto newIsMuted = (bool)buf[
sizeof (StatusInputCommand) + 2];
41 const auto volumeChanged = newVolume != volume;
42 const auto mutedChanged = newIsMuted != muted;
49 if(pFuncOnVolumeChange !=
nullptr && volumeChanged)
50 pFuncOnVolumeChange(volume);
52 if(pFuncOnMutedChange !=
nullptr && mutedChanged)
53 pFuncOnMutedChange(muted);
65 if(pFuncOnInit !=
nullptr)
71 uint8_t MiniDSP::Checksum(
const uint8_t *data, uint8_t data_length)
const {
73 for(uint8_t i = 0; i < data_length; i++)
79 void MiniDSP::SendCommand(uint8_t *command, uint8_t command_length)
const {
81 if(command_length > 63)
91 buf[0] = command_length + 1;
94 memcpy(&buf[1], command, command_length);
96 const auto checksumOffset = command_length + 1;
99 buf[checksumOffset] = Checksum(buf, command_length + 1);
102 memset(&buf[checksumOffset + 1], 0xFF,
sizeof (buf) - checksumOffset - 1);
107 void MiniDSP::RequestStatus()
const {
108 uint8_t RequestStatusOutputCommand[] = {0x05, 0xFF, 0xDA, 0x02};
110 SendCommand(RequestStatusOutputCommand,
sizeof (RequestStatusOutputCommand));
EpInfo epInfo[totalEndpoints]
uint8_t OnInitSuccessful()
void ParseHIDData(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
static const uint8_t epInterruptOutIndex
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)