808
Dependents: Chromatograph_Mobile
LT1446.cpp@0:4ca9c83d7e14, 2020-06-22 (annotated)
- Committer:
- vitlog
- Date:
- Mon Jun 22 09:52:25 2020 +0000
- Revision:
- 0:4ca9c83d7e14
- Child:
- 1:b456fe5494fe
DAC
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vitlog | 0:4ca9c83d7e14 | 1 | #include "LT1446.h" |
vitlog | 0:4ca9c83d7e14 | 2 | //повторное объявление из-за использования внешней переменной и ошибки множественного объявления |
vitlog | 0:4ca9c83d7e14 | 3 | LT1446_MEM_t LT1446_MEM; |
vitlog | 0:4ca9c83d7e14 | 4 | //экземпляр по умолчанию |
vitlog | 0:4ca9c83d7e14 | 5 | LT1446_t LT1446_0; |
vitlog | 0:4ca9c83d7e14 | 6 | |
vitlog | 0:4ca9c83d7e14 | 7 | void LT1446_CalibrateCh(LT1446_Calibr_t *dac,float k, float b) |
vitlog | 0:4ca9c83d7e14 | 8 | { |
vitlog | 0:4ca9c83d7e14 | 9 | dac->k=k; |
vitlog | 0:4ca9c83d7e14 | 10 | dac->b=b; |
vitlog | 0:4ca9c83d7e14 | 11 | } |
vitlog | 0:4ca9c83d7e14 | 12 | //Вычислить значение для передачи в ЦАП |
vitlog | 0:4ca9c83d7e14 | 13 | void LT1446_CalculateCh(LT1446_Calibr_t *dac) |
vitlog | 0:4ca9c83d7e14 | 14 | { |
vitlog | 0:4ca9c83d7e14 | 15 | dac->Code=(uint16_t)(dac->k*dac->Volts+dac->b); |
vitlog | 0:4ca9c83d7e14 | 16 | if (dac->Code>4095) dac->Code=4095; |
vitlog | 0:4ca9c83d7e14 | 17 | } |
vitlog | 0:4ca9c83d7e14 | 18 | |
vitlog | 0:4ca9c83d7e14 | 19 | void LT1446_Write(LT1446_t *chip) |
vitlog | 0:4ca9c83d7e14 | 20 | { |
vitlog | 0:4ca9c83d7e14 | 21 | |
vitlog | 0:4ca9c83d7e14 | 22 | |
vitlog | 0:4ca9c83d7e14 | 23 | LT1446_MEM.DACA=chip->dacA.Code; |
vitlog | 0:4ca9c83d7e14 | 24 | LT1446_MEM.DACB=chip->dacB.Code; |
vitlog | 0:4ca9c83d7e14 | 25 | Cs=0; |
vitlog | 0:4ca9c83d7e14 | 26 | TED2.write(LT1446_MEM.b3); |
vitlog | 0:4ca9c83d7e14 | 27 | TED2.write(LT1446_MEM.b2); |
vitlog | 0:4ca9c83d7e14 | 28 | TED2.write(LT1446_MEM.b1); |
vitlog | 0:4ca9c83d7e14 | 29 | Cs=1; |
vitlog | 0:4ca9c83d7e14 | 30 | } |
vitlog | 0:4ca9c83d7e14 | 31 | |
vitlog | 0:4ca9c83d7e14 | 32 | |
vitlog | 0:4ca9c83d7e14 | 33 |