RTEMS
6.1-rc2
Loading...
Searching...
No Matches
bsps
include
grlib
canbtrs.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
9
/*
10
* Copyright (C) 2019, 2020 Cobham Gaisler AB
11
*
12
* Redistribution and use in source and binary forms, with or without
13
* modification, are permitted provided that the following conditions
14
* are met:
15
* 1. Redistributions of source code must retain the above copyright
16
* notice, this list of conditions and the following disclaimer.
17
* 2. Redistributions in binary form must reproduce the above copyright
18
* notice, this list of conditions and the following disclaimer in the
19
* documentation and/or other materials provided with the distribution.
20
*
21
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
* POSSIBILITY OF SUCH DAMAGE.
32
*/
33
34
#ifndef __GRLIB_CANBTRS_H__
35
#define __GRLIB_CANBTRS_H__
36
47
#ifdef __cplusplus
48
extern
"C"
{
49
#endif
50
51
/* CAN Baud-rate parameters, range of valid parameter values */
52
struct
grlib_canbtrs_ranges
{
53
unsigned
int
max_scaler;
54
char
has_bpr;
55
unsigned
char
divfactor;
56
unsigned
char
min_tseg1;
57
unsigned
char
max_tseg1;
58
unsigned
char
min_tseg2;
59
unsigned
char
max_tseg2;
60
};
61
62
struct
grlib_canbtrs_timing
{
63
unsigned
char
scaler;
64
unsigned
char
ps1;
65
unsigned
char
ps2;
66
unsigned
char
rsj;
67
unsigned
char
bpr;
68
};
69
70
/* @brief Calculate CAN baud-rate generation parameters from requested baud-rate
71
*
72
* @param baud The CAN baud rate requested
73
* @param core_hz Input clock [Hz] to CAN core
74
* @param sampl_pt CAN sample point in %, 80 means 80%
75
* @param br CAN Baud-rate parameters limitations
76
* @param[out] timing result is placed here
77
*
78
* @retval 0 Baud-rate parameters sucessfully calculated
79
* @retval negative Failure to generate parameters with less than 5% error
80
* margin from requested baud-rate
81
*/
82
int
grlib_canbtrs_calc_timing(
83
unsigned
int
baud,
84
unsigned
int
core_hz,
85
unsigned
int
sampl_pt,
86
struct
grlib_canbtrs_ranges
*br,
87
struct
grlib_canbtrs_timing
*timing
88
);
89
90
#ifdef __cplusplus
91
}
92
#endif
93
94
#endif
grlib_canbtrs_ranges
Definition:
canbtrs.h:52
grlib_canbtrs_timing
Definition:
canbtrs.h:62
Generated by
1.9.6