Pārlūkot izejas kodu

Merge pull request #274 from shkshk90/Saturate-Instruction-in-DAC

Saturate instruction in dac
teensy4-core
Paul Stoffregen pirms 6 gadiem
vecāks
revīzija
966d74f9a9
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam
1 mainītis faili ar 3 papildinājumiem un 6 dzēšanām
  1. +3
    -6
      teensy3/analog.c

+ 3
- 6
teensy3/analog.c Parādīt failu

@@ -524,8 +524,7 @@ void analogWriteDAC0(int val)
} else {
DAC0_C0 = DAC_C0_DACEN | DAC_C0_DACRFS; // 3.3V VDDA is DACREF_2
}
if (val < 0) val = 0; // TODO: saturate instruction?
else if (val > 4095) val = 4095;
__asm__ ("usat %[value], #12, %[value]\n\t" : [value] "+r" (val)); // 0 <= val <= 4095

*(volatile aliased_int16_t *)&(DAC0_DAT0L) = val;
#elif defined(__MKL26Z64__)
@@ -537,8 +536,7 @@ void analogWriteDAC0(int val)
// use whatever voltage is on the AREF pin
DAC0_C0 = DAC_C0_DACEN | DAC_C0_DACSWTRG; // 3.3V VDDA
}
if (val < 0) val = 0;
else if (val > 4095) val = 4095;
__asm__ ("usat %[value], #12, %[value]\n\t" : [value] "+r" (val)); // 0 <= val <= 4095

*(volatile aliased_int16_t *)&(DAC0_DAT0L) = val;
#endif
@@ -554,8 +552,7 @@ void analogWriteDAC1(int val)
} else {
DAC1_C0 = DAC_C0_DACEN | DAC_C0_DACRFS; // 3.3V VDDA is DACREF_2
}
if (val < 0) val = 0; // TODO: saturate instruction?
else if (val > 4095) val = 4095;
__asm__ ("usat %[value], #12, %[value]\n\t" : [value] "+r" (val)); // 0 <= val <= 4095

*(volatile aliased_int16_t *)&(DAC1_DAT0L) = val;
}

Notiek ielāde…
Atcelt
Saglabāt