src: use new libosmogsm and include/osmocom/[gsm|core] path to headers
[osmocom-bb.git] / src / target / firmware / layer1 / prim_utils.c
1 /* Layer 1 Various primitive utilities */
2
3 /* (C) 2010 by Sylvain Munaut <tnt@246tNt.com>
4  *
5  * All Rights Reserved
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  */
22
23 #include <stdint.h>
24
25 #include <osmocom/core/msgb.h>
26 #include <layer1/sync.h>
27
28
29 static const uint8_t ubUui[23] = {
30         /* dummy lapdm header */
31         0x01, 0x03, 0x01,
32
33         /* fill bytes */
34         0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b,
35         0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b,
36         0x2b, 0x2b, 0x2b, 0x2b
37 };
38
39 static uint8_t ubMeas[23] = {
40         /* L1 SAACH pseudo-header */
41         0x0f, 0x00,
42
43         /* lapdm header */
44         0x01, 0x03, 0x49,
45
46         /* Measurement report */
47         0x06, 0x15, 0x36, 0x36, 0x01, 0xC0, 0x00, 0x00,
48         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49         0x00, 0x00
50 };
51
52
53 const uint8_t *pu_get_idle_frame(void)
54 {
55         return ubUui;
56 }
57
58 void pu_update_rx_level(uint8_t rx_level)
59 {
60         ubMeas[7] = ubMeas[8] = rx_level;
61 }
62
63 const uint8_t *pu_get_meas_frame(void)
64 {
65         if (l1s.tx_meas) {
66                 return l1s.tx_meas->l3h;
67         } else {
68                 /* Update L1 SAACH pseudo-header */
69                 ubMeas[0] = l1s.tx_power;
70                 ubMeas[1] = l1s.ta;
71
72                 return ubMeas;
73         }
74 }