spacewire.c 3.53 KB
Newer Older
1
#if (defined (__PO_HI_NEED_DRIVER_SPACEWIRE_RASTA))\n
2
3
4
/*
Code automatically generated by asn1scc tool
*/
yoogx's avatar
yoogx committed
5
#include <limits.h>
6
7
8
#include <string.h>
#include <math.h>

9

Maxime Perrotin's avatar
Maxime Perrotin committed
10
11
#include "spacewire.h"

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const __po_hi_c_spacewire_conf_t leon_rasta_spw_sender = {
    .devname = "/dev/grspwrasta0",
    .nodeaddr = 11,
    .use_router = FALSE,
    .exist = {
        .corefreq = 0,
        .clockdiv = 0,
        .use_router = 0,
        .remove_prot_id = 0,
        .rxblock = 0,
        .txblock = 0
    }
};
const __po_hi_c_spacewire_conf_t leon_rasta_spw_receiver = {
    .devname = "/dev/grspwrasta0",
    .nodeaddr = 22,
    .use_router = FALSE,
    .exist = {
        .corefreq = 0,
        .clockdiv = 0,
        .use_router = 0,
        .remove_prot_id = 0,
        .rxblock = 0,
        .txblock = 0
    }
};


40
41
void __po_hi_c_Core_Frequence_T_Initialize(__po_hi_c_Core_Frequence_T* pVal)
{
Maxime Perrotin's avatar
Maxime Perrotin committed
42
43
	(void)pVal;

44
45

	(*(pVal)) = 0;
46
47
}

yoogx's avatar
yoogx committed
48
flag __po_hi_c_Core_Frequence_T_IsConstraintValid(const __po_hi_c_Core_Frequence_T* pVal, int* pErrCode)
49
{
yoogx's avatar
yoogx committed
50
    flag ret = TRUE;
Maxime Perrotin's avatar
Maxime Perrotin committed
51
	(void)pVal;
52
53
	
    ret = ((*(pVal)) <= 4294967295UL);
Maxime Perrotin's avatar
Maxime Perrotin committed
54
    *pErrCode = ret ? 0 :  ERR_CORE_FREQUENCE_T; 
55
56
57

	return ret;
}
58
59
60
61
62



void __po_hi_c_Node_Addr_T_Initialize(__po_hi_c_Node_Addr_T* pVal)
{
Maxime Perrotin's avatar
Maxime Perrotin committed
63
64
	(void)pVal;

65
66

	(*(pVal)) = 0;
67
68
}

yoogx's avatar
yoogx committed
69
flag __po_hi_c_Node_Addr_T_IsConstraintValid(const __po_hi_c_Node_Addr_T* pVal, int* pErrCode)
70
{
yoogx's avatar
yoogx committed
71
    flag ret = TRUE;
Maxime Perrotin's avatar
Maxime Perrotin committed
72
	(void)pVal;
73
74
	
    ret = ((*(pVal)) <= 255UL);
Maxime Perrotin's avatar
Maxime Perrotin committed
75
    *pErrCode = ret ? 0 :  ERR_NODE_ADDR_T; 
76

77
78
	return ret;
}
79
80


81

82
83
void __po_hi_c_Clock_Division_T_Initialize(__po_hi_c_Clock_Division_T* pVal)
{
Maxime Perrotin's avatar
Maxime Perrotin committed
84
85
	(void)pVal;

86
87

	(*(pVal)) = 0;
88
}
yoogx's avatar
yoogx committed
89
90
91
92

flag __po_hi_c_Clock_Division_T_IsConstraintValid(const __po_hi_c_Clock_Division_T* pVal, int* pErrCode)
{
    flag ret = TRUE;
Maxime Perrotin's avatar
Maxime Perrotin committed
93
	(void)pVal;
94
95
	
    ret = ((*(pVal)) <= 255UL);
Maxime Perrotin's avatar
Maxime Perrotin committed
96
    *pErrCode = ret ? 0 :  ERR_CLOCK_DIVISION_T; 
yoogx's avatar
yoogx committed
97
98
99

	return ret;
}
100
101
102
103
104



void __po_hi_c_spacewire_conf_t_devname_Initialize(__po_hi_c_spacewire_conf_t_devname val)
{
Maxime Perrotin's avatar
Maxime Perrotin committed
105
106
	(void)val;

107
108
109

	memset(val, 0x0, 21);

yoogx's avatar
yoogx committed
110
}
111
112
void __po_hi_c_spacewire_conf_t_Initialize(__po_hi_c_spacewire_conf_t* pVal)
{
Maxime Perrotin's avatar
Maxime Perrotin committed
113
114
	(void)pVal;

115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138


	/*set devname */
	__po_hi_c_spacewire_conf_t_devname_Initialize(pVal->devname);
	/*set nodeaddr */
	__po_hi_c_Node_Addr_T_Initialize((&(pVal->nodeaddr)));
	/*set corefreq */
	pVal->exist.corefreq = 1;
	__po_hi_c_Core_Frequence_T_Initialize((&(pVal->corefreq)));
	/*set clockdiv */
	pVal->exist.clockdiv = 1;
	__po_hi_c_Clock_Division_T_Initialize((&(pVal->clockdiv)));
	/*set use_router */
	pVal->exist.use_router = 1;
	pVal->use_router = FALSE;
	/*set remove_prot_id */
	pVal->exist.remove_prot_id = 1;
	pVal->remove_prot_id = FALSE;
	/*set rxblock */
	pVal->exist.rxblock = 1;
	pVal->rxblock = FALSE;
	/*set txblock */
	pVal->exist.txblock = 1;
	pVal->txblock = FALSE;
139
140
}

Maxime Perrotin's avatar
Maxime Perrotin committed
141
flag __po_hi_c_spacewire_conf_t_IsConstraintValid(const __po_hi_c_spacewire_conf_t* pVal, int* pErrCode)
142
{
yoogx's avatar
yoogx committed
143
    flag ret = TRUE;
Maxime Perrotin's avatar
Maxime Perrotin committed
144
	(void)pVal;
145
146
	
    ret = ((1 <= strlen(pVal->devname)) && (strlen(pVal->devname) <= 20));
Maxime Perrotin's avatar
Maxime Perrotin committed
147
    *pErrCode = ret ? 0 :  ERR_SPACEWIRE_CONF_T_DEVNAME; 
148
    if (ret) {
149
150
151
152
153
154
155
156
157
158
159
        ret = (pVal->nodeaddr <= 255UL);
        *pErrCode = ret ? 0 :  ERR_SPACEWIRE_CONF_T_NODEADDR; 
        if (ret) {
            if (pVal->exist.corefreq) {
            	ret = (pVal->corefreq <= 4294967295UL);
            	*pErrCode = ret ? 0 :  ERR_SPACEWIRE_CONF_T_COREFREQ; 
            }
            if (ret) {
                if (pVal->exist.clockdiv) {
                	ret = (pVal->clockdiv <= 255UL);
                	*pErrCode = ret ? 0 :  ERR_SPACEWIRE_CONF_T_CLOCKDIV; 
160
161
162
163
                }
            }
        }
    }
164

yoogx's avatar
yoogx committed
165
	return ret;
166
167
}

168
\n#endif