POK
sampling.c
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Thu Jan 15 23:34:13 2009
15  */
16 
17 
18 #ifdef POK_NEEDS_ARINC653_SAMPLING
19 
20 #include <types.h>
21 #include <middleware/port.h>
22 #include <arinc653/types.h>
23 #include <arinc653/sampling.h>
24 
25 void CREATE_SAMPLING_PORT (
26  /*in */ SAMPLING_PORT_NAME_TYPE SAMPLING_PORT_NAME,
27  /*in */ MESSAGE_SIZE_TYPE MAX_MESSAGE_SIZE,
28  /*in */ PORT_DIRECTION_TYPE PORT_DIRECTION,
29  /*in */ SYSTEM_TIME_TYPE REFRESH_PERIOD,
30  /*out*/ SAMPLING_PORT_ID_TYPE *SAMPLING_PORT_ID,
31  /*out*/ RETURN_CODE_TYPE *RETURN_CODE )
32 {
33  pok_port_direction_t core_direction;
34  pok_port_id_t core_id;
35  pok_ret_t core_ret;
36 
37  switch (PORT_DIRECTION)
38  {
39  case SOURCE:
40  core_direction = POK_PORT_DIRECTION_OUT;
41  break;
42 
43  case DESTINATION:
44  core_direction = POK_PORT_DIRECTION_IN;
45  break;
46 
47  default:
48  *RETURN_CODE = INVALID_PARAM;
49  return;
50  }
51 
52  core_ret = pok_port_sampling_create (SAMPLING_PORT_NAME, MAX_MESSAGE_SIZE, core_direction, REFRESH_PERIOD, &core_id);
53 
54  *SAMPLING_PORT_ID = core_id;
55 
56  *RETURN_CODE = core_ret;
57 }
58 
59 void WRITE_SAMPLING_MESSAGE (
60  /*in */ SAMPLING_PORT_ID_TYPE SAMPLING_PORT_ID,
61  /*in */ MESSAGE_ADDR_TYPE MESSAGE_ADDR, /* by reference */
62  /*in */ MESSAGE_SIZE_TYPE LENGTH,
63  /*out*/ RETURN_CODE_TYPE *RETURN_CODE )
64 {
65  pok_ret_t core_ret;
66  core_ret = pok_port_sampling_write (SAMPLING_PORT_ID, MESSAGE_ADDR, LENGTH);
67  *RETURN_CODE = core_ret;
68 }
69 
70 void READ_SAMPLING_MESSAGE (
71  /*in */ SAMPLING_PORT_ID_TYPE SAMPLING_PORT_ID,
72  /*out*/ MESSAGE_ADDR_TYPE MESSAGE_ADDR,
73  /*out*/ MESSAGE_SIZE_TYPE *LENGTH,
74  /*out*/ VALIDITY_TYPE *VALIDITY,
75  /*out*/ RETURN_CODE_TYPE *RETURN_CODE )
76 {
77  pok_ret_t core_ret;
78  core_ret = pok_port_sampling_read (SAMPLING_PORT_ID, MESSAGE_ADDR, (pok_port_size_t*) LENGTH, (pok_bool_t*) VALIDITY);
79  *RETURN_CODE = core_ret;
80 }
81 
82 void GET_SAMPLING_PORT_ID (
83  /*in */ SAMPLING_PORT_NAME_TYPE SAMPLING_PORT_NAME,
84  /*out*/ SAMPLING_PORT_ID_TYPE *SAMPLING_PORT_ID,
85  /*out*/ RETURN_CODE_TYPE *RETURN_CODE )
86 {
87  (void) SAMPLING_PORT_NAME;
88  (void) SAMPLING_PORT_ID;
89  *RETURN_CODE = NOT_AVAILABLE;
90 }
91 
92 void GET_SAMPLING_PORT_STATUS (
93  /*in */ SAMPLING_PORT_ID_TYPE SAMPLING_PORT_ID,
94  /*out*/ SAMPLING_PORT_STATUS_TYPE *SAMPLING_PORT_STATUS,
95  /*out*/ RETURN_CODE_TYPE *RETURN_CODE )
96 {
97  (void) SAMPLING_PORT_ID;
98  (void) SAMPLING_PORT_STATUS;
99  *RETURN_CODE = NOT_AVAILABLE;
100 }
101 
102 #endif