blob: 4394638c8794d97202c773232b1a145a58016199 [file] [log] [blame]
Sylvain Munautbc9f5c42020-09-14 10:22:29 +02001/*
2 * e1.h
3 *
4 * Copyright (C) 2019-2020 Sylvain Munaut <tnt@246tNt.com>
5 * SPDX-License-Identifier: GPL-3.0-or-later
6 */
7
8#pragma once
9
Harald Welte9469e042020-12-15 23:09:40 +010010void e1_init(uint16_t rx_cr, uint16_t tx_cr);
Sylvain Munautbc9f5c42020-09-14 10:22:29 +020011void e1_poll(void);
12void e1_debug_print(bool data);
13
Harald Welte6add0aa2020-12-16 00:02:11 +010014void e1_tx_config(uint16_t cr);
15void e1_rx_config(uint16_t cr);
16
Harald Welte805f2cf2020-12-14 17:31:03 +010017#define E1_ERR_F_ALIGN_ERR 0x01
18#define E1_ERR_F_LOS 0x02
Harald Welte51baa362022-01-01 15:22:25 +010019#define E1_ERR_F_RAI 0x04
Harald Welte805f2cf2020-12-14 17:31:03 +010020
21struct e1_error_count {
22 uint16_t crc;
23 uint16_t align;
24 uint16_t ovfl;
25 uint16_t unfl;
26 uint8_t flags;
27};
28
29const struct e1_error_count *e1_get_error_count(void);
30
Sylvain Munautbc9f5c42020-09-14 10:22:29 +020031volatile uint8_t *e1_data_ptr(int mf, int frame, int ts);
32unsigned int e1_data_ofs(int mf, int frame, int ts);
Harald Welte52765672020-12-15 18:35:42 +010033
34enum e1_platform_led {
35 E1P_LED_GREEN = 0,
36 E1P_LED_YELLOW = 1,
37};
38
39enum e1_platform_led_state {
40 E1P_LED_ST_OFF = 0,
41 E1P_LED_ST_ON = 1,
42 E1P_LED_ST_BLINK = 2,
43 E1P_LED_ST_BLINK_FAST = 3
44};
45
46/* external function provided by the platform; used by E1 driver to control LEDs */
47extern void e1_platform_led_set(uint8_t port, enum e1_platform_led led,
48 enum e1_platform_led_state state);