]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/src/rpp/rpp.c
Merge branch 'can'
[pes-rpp/rpp-lib.git] / rpp / src / rpp / rpp.c
1 /* Copyright (C) 2013 Czech Technical University in Prague
2  *
3  * Authors:
4  *     - Carlos Jenkins <carlos@jenkins.co.cr>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  * File : rpp.c
20  * Abstract:
21  *     RPP API library implementation file.
22  *
23  * References:
24  *     rpp.h
25  *     RPP API documentation.
26  */
27
28
29 #include "rpp/rpp.h"
30
31 #if rppCONFIG_DRV == 1
32 #include "drv/drv.h"
33 #endif
34
35 boolean_t initialized = FALSE;
36
37 int8_t rpp_init() {
38
39     if(initialized) {
40         return FAILURE;
41     }
42     initialized = TRUE;
43
44     // FIXME This is horrible
45     #if rppCONFIG_DRV == 1
46     dmmInit();
47     gioInit();
48     hetInit();
49     canInit();
50     linInit();
51     spi_tms570_init();
52     #endif
53
54     #if rppCONFIG_INCLUDE_DIN == 1
55     rpp_din_init();
56     #endif
57
58     #if rppCONFIG_INCLUDE_LOUT == 1
59     rpp_lout_init();
60     #endif
61
62     #if rppCONFIG_INCLUDE_ADC == 1
63     rpp_adc_init();
64     #endif
65
66     #if rppCONFIG_INCLUDE_DAC == 1
67     rpp_dac_init();
68     #endif
69
70     #if rppCONFIG_INCLUDE_HBR == 1
71     rpp_hbr_init();
72     #endif
73
74     #if rppCONFIG_INCLUDE_MOUT == 1
75     rpp_mout_init();
76     #endif
77
78     #if rppCONFIG_INCLUDE_HOUT == 1
79     rpp_hout_init();
80     #endif
81
82     #if rppCONFIG_INCLUDE_CAN == 1
83     struct rpp_can_config can_config;
84     struct rpp_can_tx_config can_tx_config[1];
85     struct rpp_can_rx_config can_rx_config[1];
86
87     can_config.num_tx_obj = 1;
88     can_config.num_rx_obj = 1;
89     can_config.tx_config = can_tx_config;
90     can_config.rx_config = can_rx_config;
91
92     can_config.tx_config[0].type = RPP_CAN_EXTENDED;
93     can_config.tx_config[0].controller = 2;
94     can_config.tx_config[0].msg_obj = 1;
95
96     can_config.rx_config[0].type = RPP_CAN_EXTENDED;
97     can_config.rx_config[0].controller = 2;
98     can_config.rx_config[0].msg_obj = 2;
99     can_config.rx_config[0].id = 2;
100     can_config.rx_config[0].mask = 0;
101     
102     rpp_can_init(&can_config);
103     #endif
104
105     #if rppCONFIG_INCLUDE_LIN == 1
106     rpp_lin_init();
107     #endif
108
109     #if rppCONFIG_INCLUDE_SCI == 1
110     rpp_sci_init();
111     #endif
112
113     #if rppCONFIG_INCLUDE_ETH == 1
114     rpp_eth_init();
115     #endif
116
117     #if rppCONFIG_INCLUDE_SDC == 1
118     rpp_sdc_init();
119     #endif
120
121     #if rppCONFIG_INCLUDE_SDR == 1
122     rpp_sdr_init();
123     #endif
124
125     #if rppCONFIG_DRV == 1
126     _enable_IRQ();
127     #endif
128
129    return SUCCESS;
130 }