|
|
|
|
|
|
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef int16_t __attribute__((__may_alias__)) aliased_int16_t; |
|
|
|
|
|
|
|
|
void analogWriteDAC0(int val) |
|
|
void analogWriteDAC0(int val) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
if (val < 0) val = 0; // TODO: saturate instruction? |
|
|
if (val < 0) val = 0; // TODO: saturate instruction? |
|
|
else if (val > 4095) val = 4095; |
|
|
else if (val > 4095) val = 4095; |
|
|
*(int16_t *)&(DAC0_DAT0L) = val; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(volatile aliased_int16_t *)&(DAC0_DAT0L) = val; |
|
|
#elif defined(__MKL26Z64__) |
|
|
#elif defined(__MKL26Z64__) |
|
|
SIM_SCGC6 |= SIM_SCGC6_DAC0; |
|
|
SIM_SCGC6 |= SIM_SCGC6_DAC0; |
|
|
if (analog_reference_internal == 0) { |
|
|
if (analog_reference_internal == 0) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
if (val < 0) val = 0; |
|
|
if (val < 0) val = 0; |
|
|
else if (val > 4095) val = 4095; |
|
|
else if (val > 4095) val = 4095; |
|
|
*(int16_t *)&(DAC0_DAT0L) = val; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(volatile aliased_int16_t *)&(DAC0_DAT0L) = val; |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
if (val < 0) val = 0; // TODO: saturate instruction? |
|
|
if (val < 0) val = 0; // TODO: saturate instruction? |
|
|
else if (val > 4095) val = 4095; |
|
|
else if (val > 4095) val = 4095; |
|
|
*(int16_t *)&(DAC1_DAT0L) = val; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(volatile aliased_int16_t *)&(DAC1_DAT0L) = val; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|