Skip to content

Commit 57871a0

Browse files
author
pchiacha
authored
list pwm/digital outputs
update read digital output command to distinguish pwm outputs from digital outputs
1 parent a671115 commit 57871a0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Tekdaqc_Firmware/src/Digital_Output.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,38 @@ Tekdaqc_Function_Error_t ReadDigitalOutput(void)
656656

657657
sprintf(TOSTRING_BUFFER, DIGITAL_OUTPUT_FORMATTER, uiOrigOutput, 0x1e);
658658
writer(TOSTRING_BUFFER);
659+
//print all active digital output
660+
sprintf(TOSTRING_BUFFER, "Digital Output: %04x\n\r"
661+
"%c\n\r", digiOutput, 0x1e);
662+
writer(TOSTRING_BUFFER);
663+
664+
//print all active pwm output
665+
uint8_t index[16] = {0};
666+
if (currentPwm) {
667+
for (uint8_t i = 0; i < 16; i++) {
668+
if (!index[i]) {
669+
if (pwmDutyCycle[i]) {
670+
uint8_t tempDutyCycle = pwmDutyCycle[i];
671+
uint16_t tempPwm = (0x0001 << i);
672+
for (uint8_t j = (i+1); j < 16; j++) {
673+
if (tempDutyCycle == pwmDutyCycle[j]) {
674+
index[j] = 1;
675+
tempPwm |= (0x0001 << j);
676+
}
677+
}
678+
679+
sprintf(TOSTRING_BUFFER, "\n\rPwm Output: %04x\n\r\tDutyCycle: %" PRIu8
680+
"%c\n\r", tempPwm, pwmDutyCycle[i], 0x1e);
681+
writer(TOSTRING_BUFFER);
682+
}
683+
}
684+
}
685+
}
686+
else {
687+
sprintf(TOSTRING_BUFFER, "\n\rPwm Output: 0000\n\r\tDutyCycle: 0"
688+
"%c\n\r", 0x1e);
689+
writer(TOSTRING_BUFFER);
690+
}
659691
return ERR_FUNCTION_OK;
660692
}
661693

0 commit comments

Comments
 (0)