808
Dependents: Chromatograph_Mobile
LT1446.cpp@3:fe564cf39107, 2020-08-14 (annotated)
- Committer:
- nikmaos
- Date:
- Fri Aug 14 14:15:24 2020 +0000
- Revision:
- 3:fe564cf39107
- Parent:
- 2:09948f1c22bc
1408
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 | |
nikmaos | 3:fe564cf39107 | 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; |
nikmaos | 2:09948f1c22bc | 26 | TED2.write(LT1446_MEM.b3); |
vitlog | 0:4ca9c83d7e14 | 27 | TED2.write(LT1446_MEM.b2); |
nikmaos | 2:09948f1c22bc | 28 | TED2.write(LT1446_MEM.b1); |
nikmaos | 3:fe564cf39107 | 29 | Cs=1;*/ |
vitlog | 0:4ca9c83d7e14 | 30 | } |
nikmaos | 1:b456fe5494fe | 31 | void LTCwrite(LT1446_t *chip) |
nikmaos | 1:b456fe5494fe | 32 | { |
nikmaos | 3:fe564cf39107 | 33 | LTC1446_CS=0; |
nikmaos | 3:fe564cf39107 | 34 | LTC1446_CLK=0; |
nikmaos | 1:b456fe5494fe | 35 | /*Записываем канал B*/ |
nikmaos | 1:b456fe5494fe | 36 | uint8_t b=12; |
nikmaos | 1:b456fe5494fe | 37 | while(b--) |
nikmaos | 1:b456fe5494fe | 38 | { |
nikmaos | 3:fe564cf39107 | 39 | LTC1446_DOUT=chip->dacB.Code&(1<<b); |
nikmaos | 3:fe564cf39107 | 40 | LTC1446_CLK=1; |
nikmaos | 3:fe564cf39107 | 41 | LTC1446_DOUT=0; |
nikmaos | 3:fe564cf39107 | 42 | LTC1446_CLK=0; |
nikmaos | 1:b456fe5494fe | 43 | } |
nikmaos | 1:b456fe5494fe | 44 | /*Канал А */ |
nikmaos | 1:b456fe5494fe | 45 | b=12; |
nikmaos | 1:b456fe5494fe | 46 | while(b--) |
nikmaos | 1:b456fe5494fe | 47 | { |
nikmaos | 3:fe564cf39107 | 48 | LTC1446_DOUT=chip->dacA.Code&(1<<b); |
nikmaos | 3:fe564cf39107 | 49 | LTC1446_CLK=1; |
nikmaos | 3:fe564cf39107 | 50 | LTC1446_DOUT=0; |
nikmaos | 3:fe564cf39107 | 51 | LTC1446_CLK=0; |
nikmaos | 1:b456fe5494fe | 52 | } |
nikmaos | 3:fe564cf39107 | 53 | LTC1446_CS=1; |
nikmaos | 1:b456fe5494fe | 54 | } |
vitlog | 0:4ca9c83d7e14 | 55 | |
vitlog | 0:4ca9c83d7e14 | 56 | |
vitlog | 0:4ca9c83d7e14 | 57 |