]> rtime.felk.cvut.cz Git - eurobot/public.git/blob - src/eb_pwr/pwrstep.h
Merge branch 'maint-demo'
[eurobot/public.git] / src / eb_pwr / pwrstep.h
1 #ifndef PWRSTEP_H\r
2 #define PWRSTEP_H\r
3 \r
4 #define PWR_ON  1\r
5 #define PWR_OFF 0\r
6 \r
7 #define ADC_DIV         10\r
8 #define ADC_CON_CONST   322\r
9 #define ADC_OFFSET      2000\r
10 \r
11 #define PWR33   (1<<22)\r
12 #define PWR50   (1<<24)\r
13 #define PWR80   (1<<23)\r
14 \r
15 #define ADC0    (1<<27)\r
16 #define ADC1    (1<<28)\r
17 #define ADC2    (1<<29)\r
18 #define ADC3    (1<<30)\r
19 \r
20 #define ADCCH0 22\r
21 #define ADCCH1 24\r
22 #define ADCCH2 26\r
23 #define ADCCH3 28\r
24 \r
25 #define ADC_PIN_0   0x1\r
26 #define ADC_PIN_1   0x2\r
27 #define ADC_PIN_2   0x4\r
28 #define ADC_PIN_3   0x8\r
29 \r
30 #define ADC_CR_ADC0 0x1\r
31 #define ADC_CR_ADC1 0x2\r
32 #define ADC_CR_ADC2 0x4\r
33 #define ADC_CR_ADC3 0x8\r
34 \r
35 #define ADC_CR_CLK_DIV_1        (1<<8)  // this nuber should be multipied  sampe\r
36                                                                 // requested divisor 4  ---- clk_div = 4 * ADC_CR_CLK_DIV_1\r
37 #define ADC_CR_BURST            (1<<16)\r
38 #define ADC_CR_CLKS_11          (0<<17)\r
39 #define ADC_CR_CLKS_10          (1<<17)\r
40 #define ADC_CR_CLKS_9           (2<<17)\r
41 #define ADC_CR_CLKS_8           (3<<17)\r
42 #define ADC_CR_CLKS_7           (4<<17)\r
43 #define ADC_CR_CLKS_6           (5<<17)\r
44 #define ADC_CR_CLKS_5           (6<<17)\r
45 #define ADC_CR_CLKS_4           (7<<17)\r
46 \r
47 #define ADC_CR_PDN_ON           (1<<21)\r
48 \r
49 #define ADC_CR_START_OFF        (0<<24)\r
50 #define ADC_CR_START_NOW        (1<<24)\r
51 #define ADC_CR_START_P016       (2<<24)\r
52 #define ADC_CR_START_P022       (3<<24)\r
53 #define ADC_CR_START_MAT01      (4<<24)\r
54 #define ADC_CR_START_MAT03      (5<<24)\r
55 #define ADC_CR_START_MAT10      (6<<24)\r
56 #define ADC_CR_START_MAT11      (7<<24)\r
57 \r
58 #define ADC_CR_EDGE_RISING      (0<<27)\r
59 #define ADC_CR_EDGE_FALLING     (1<<27)\r
60 \r
61 #define BATTERY_CH      adc_val[0]\r
62 #define V33_CH          adc_val[1]\r
63 #define V50_CH          adc_val[2]\r
64 #define V80_CH          adc_val[3]\r
65 \r
66 volatile unsigned int adc_val[4];\r
67 \r
68 struct power {\r
69         char can_33v_req;\r
70         char can_80v_req;\r
71         char can_50v_req;\r
72         char pwr_33v_state;\r
73         char pwr_50v_state;\r
74         char pwr_80v_state;\r
75         char battery_state;\r
76         char alert;\r
77 };\r
78 \r
79 /**     pwr_33 Switch on/off 3,3V power line\r
80  *  @param mode  -  PWR_ON/PWR_OFF\r
81  */\r
82 void pwr_33(char mode, struct power *pwr);\r
83 \r
84 /**     pwr_50 Switch on/off 5,0V power line\r
85  *  @param mode  -  PWR_ON/PWR_OFF\r
86  */\r
87 void pwr_50(char mode, struct power *pwr);\r
88 \r
89 /**     pwr_80 Switch on/off 8,0V power line\r
90  *  @param mode  -  PWR_ON/PWR_OFF\r
91  */\r
92 void pwr_80(char mode, struct power *pwr);\r
93 \r
94 /**     init_pwr  inicializes power lines - default: all lines is off\r
95  */\r
96 void init_pwr(struct power *pwr);\r
97 \r
98 /**     inicializes ADC lines and starts converion (use ISR)\r
99  *  @param rx_isr_vect  ISR vector\r
100  */\r
101 void init_adc(unsigned rx_isr_vect);\r
102 \r
103 \r
104 #endif\r