openpilot v0.9.6 release
date: 2024-01-12T10:13:37 master commit: ba792d576a49a0899b88a753fa1c52956bedf9e6
This commit is contained in:
16
panda/board/stm32fx/lldac.h
Normal file
16
panda/board/stm32fx/lldac.h
Normal file
@@ -0,0 +1,16 @@
|
||||
void dac_init(void) {
|
||||
// No buffers required since we have an opamp
|
||||
register_set(&(DAC->DHR12R1), 0U, 0xFFFU);
|
||||
register_set(&(DAC->DHR12R2), 0U, 0xFFFU);
|
||||
register_set(&(DAC->CR), DAC_CR_EN1 | DAC_CR_EN2, 0x3FFF3FFFU);
|
||||
}
|
||||
|
||||
void dac_set(int channel, uint32_t value) {
|
||||
if (channel == 0) {
|
||||
register_set(&(DAC->DHR12R1), value, 0xFFFU);
|
||||
} else if (channel == 1) {
|
||||
register_set(&(DAC->DHR12R2), value, 0xFFFU);
|
||||
} else {
|
||||
print("Failed to set DAC: invalid channel value: 0x"); puth(value); print("\n");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user