src
ros_lib
ChibiOSHardware.h
Go to the documentation of this file.
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Copyright (c) 2020, Willow Garage, Inc.
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
9
* are met:
10
*
11
* * Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* * Redistributions in binary form must reproduce the above
14
* copyright notice, this list of conditions and the following
15
* disclaimer in the documentation and/or other materials provided
16
* with the distribution.
17
* * Neither the name of Willow Garage, Inc. nor the names of its
18
* contributors may be used to endorse or promote prducts derived
19
* from this software without specific prior written permission.
20
*
21
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
* POSSIBILITY OF SUCH DAMAGE.
33
*/
34
35
#ifndef ROS_CHIBIOS_HARDWARE_H_
36
#define ROS_CHIBIOS_HARDWARE_H_
37
38
#include <hal.h>
39
40
class
ChibiOSHardware
{
41
public
:
42
void
setPort
(BaseChannel* io)
43
{
44
io_
= io;
45
}
46
47
BaseChannel*
getPort
()
48
{
49
return
io_
;
50
}
51
52
void
init
()
53
{
54
}
55
56
int
read
()
57
{
58
return
chnGetTimeout(
io_
, TIME_IMMEDIATE);
59
}
60
61
void
write
(uint8_t* data,
int
length)
62
{
63
chnWrite(
io_
, data,
length
);
64
}
65
66
unsigned
long
time
()
67
{
68
#if defined(OSAL_I2MS)
69
return
OSAL_I2MS(osalOsGetSystemTimeX());
70
#elif defined(TIME_I2MS)
71
return
TIME_I2MS(osalOsGetSystemTimeX());
72
#else
73
return
(osalOsGetSystemTimeX() *
static_cast<
systime_t
>
(1000)) / OSAL_ST_FREQUENCY;
74
#endif
75
}
76
77
protected
:
78
BaseChannel*
io_
=
nullptr
;
79
};
80
81
#endif
ChibiOSHardware::write
void write(uint8_t *data, int length)
Definition:
ChibiOSHardware.h:61
ChibiOSHardware::init
void init()
Definition:
ChibiOSHardware.h:52
ChibiOSHardware::getPort
BaseChannel * getPort()
Definition:
ChibiOSHardware.h:47
ChibiOSHardware::setPort
void setPort(BaseChannel *io)
Definition:
ChibiOSHardware.h:42
ChibiOSHardware::time
unsigned long time()
Definition:
ChibiOSHardware.h:66
ChibiOSHardware::read
int read()
Definition:
ChibiOSHardware.h:56
length
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
ChibiOSHardware
Definition:
ChibiOSHardware.h:40
ChibiOSHardware::io_
BaseChannel * io_
Definition:
ChibiOSHardware.h:78
rosserial_chibios
Author(s): Hermann von Kleist
autogenerated on Wed Mar 2 2022 00:58:04