po_hi_driver_serial_common.c 1.97 KB
Newer Older
1
2
3
4
5
/*
 * This is a part of PolyORB-HI-C distribution, a minimal
 * middleware written for generated code from AADL models.
 * You should use it with the Ocarina toolsuite.
 *
jhugues's avatar
jhugues committed
6
 * For more informations, please visit http://assert-project.net/taste
7
 *
jhugues's avatar
jhugues committed
8
 * Copyright (C) 2011-2012 ESA & ISAE.
9
10
11
12
13
14
 */


#include <deployment.h>

#include <drivers/po_hi_driver_serial_common.h>
15
#include <drivers/configuration/serial.h>
16
17
18
19
20
21
22
23
24
25
26
27
28
29

#if defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX) || \
    defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_RECEIVER) || \
    defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_SENDER) || \
    defined (__PO_HI_NEED_DRIVER_SERIAL_RASTA) || \
    defined (__PO_HI_NEED_DRIVER_SERIAL_LEON) || \
    defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_SENDER) || \
    defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_RECEIVER)

#include <po_hi_transport.h>
#include <po_hi_debug.h>

int __po_hi_c_driver_serial_common_get_speed (const __po_hi_device_id id)
{
30
   __po_hi_c_serial_conf_t*   serialconf;
31
   
32
   serialconf = (__po_hi_c_serial_conf_t*)__po_hi_get_device_configuration (id);
33

34
   switch (serialconf->speed)
35
   {
36
      case __po_hi_c_b115200:
37
38
39
40
         __PO_HI_DEBUG_INFO ("Get speed 115200 for device %d\n", id);
         return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_115200;
         break;

41
      case __po_hi_c_b57600:
42
43
44
45
         __PO_HI_DEBUG_INFO ("Get speed 57600 for device %d\n", id);
         return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_57600;
         break;

46
      case __po_hi_c_b38400:
47
48
49
50
         __PO_HI_DEBUG_INFO ("Get speed 38400 for device %d\n", id);
         return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_38400;
         break;

51
      case __po_hi_c_b19200:
52
53
54
55
56
57
58
59
60
61
62
63
64
65
         __PO_HI_DEBUG_INFO ("Get speed 19200 for device %d\n", id);
         return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_19200;
         break;

      default:
         __PO_HI_DEBUG_INFO ("Unknown speed for device %d\n", id);
         return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_UNKNWON;
         break;
   }

   return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_DEFAULT;
}

#endif