blob: 8ba983828048258016e37e6e4aaa51f763f1cba5 [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
19
20struct e1_error_count {
21 uint16_t crc;
22 uint16_t align;
23 uint16_t ovfl;
24 uint16_t unfl;
25 uint8_t flags;
26};
27
28const struct e1_error_count *e1_get_error_count(void);
29
Sylvain Munautbc9f5c42020-09-14 10:22:29 +020030volatile uint8_t *e1_data_ptr(int mf, int frame, int ts);
31unsigned int e1_data_ofs(int mf, int frame, int ts);
Harald Welte52765672020-12-15 18:35:42 +010032
33enum e1_platform_led {
34 E1P_LED_GREEN = 0,
35 E1P_LED_YELLOW = 1,
36};
37
38enum e1_platform_led_state {
39 E1P_LED_ST_OFF = 0,
40 E1P_LED_ST_ON = 1,
41 E1P_LED_ST_BLINK = 2,
42 E1P_LED_ST_BLINK_FAST = 3
43};
44
45/* external function provided by the platform; used by E1 driver to control LEDs */
46extern void e1_platform_led_set(uint8_t port, enum e1_platform_led led,
47 enum e1_platform_led_state state);