source: firmware/FSC/src/muxer_fsc.c@ 19996

Last change on this file since 19996 was 17628, checked in by dneise, 11 years ago
many whitespace edits, and removed usart.h from includelist
File size: 1.9 KB
Line 
1#include "muxer_fsc.h"
2// Sets voltage Muxer to current channel
3// this is a Muxing, and therefor the adc might need some time to settle.
4// Since there are:
5// - 40 voltage monitor channels
6// - 40 current monitor channels
7// - 4 humidity monitor channels
8// the muxer is set as follows.
9// channel 00..39 --> looking at the voltage channels
10// channel 40..79 --> looking at the current channels
11// channel 80..83 --> looking at the humidities
12void Set_V_Muxer (U08 channel) {
13 U08 SB = 0;
14 // voltages
15 if (channel < 40) {
16 if (channel < 36)
17 SB = channel*2;
18 else
19 SB = (channel+1)*2;
20 }
21 // currents
22 else if (channel < 80) {
23 channel -= 40;
24 if (channel < 36)
25 SB = channel*2+1;
26 else
27 SB = (channel+1)*2+1;
28 }
29 // humidities
30 else if (channel < 84) {
31 channel -= 80;
32 switch (channel) {
33 case 0:
34 SB = 0x48; //0100.1000
35 break;
36 case 1:
37 SB = 0x49; //0100.1001
38 break;
39 case 2:
40 SB = 0x52; //0101.0010
41 break;
42 case 3:
43 SB = 0x53; //0101.0011
44 break;
45 } // end of switch-case
46 } // end of if (channel < some_number)
47
48 PORTC = (PORTC & 0x80) | (0x7F & SB); // Here the muxer is switched.
49}
50
51void Set_T_Muxer(U08 channel) {
52 U08 SA = 0x00;
53 switch (channel/16) {
54 case 0:
55 SA |= 1<<4; // 0001.0000
56 break;
57 case 1:
58 break; // 0000.0000
59 case 2:
60 SA |= (1<<4)|(1<<5); // 0011.0000
61 break;
62 case 3:
63 SA |= 1<<5; // 0010.0000
64 break;
65 }
66 SA = SA | (channel%16);
67 PORTA = (PORTA & 0xC0) | (0x3F & SA); // Here the muxer is switched.
68}
69
70
Note: See TracBrowser for help on using the repository browser.