blob: 862d56877a8f217ac3006ce23b4e05a753238eb8 [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
Sylvain Munaut2c0c1362022-01-03 18:48:08 +010010
11/* control */
12
Harald Welte9469e042020-12-15 23:09:40 +010013void e1_init(uint16_t rx_cr, uint16_t tx_cr);
Sylvain Munautbc9f5c42020-09-14 10:22:29 +020014void e1_poll(void);
15void e1_debug_print(bool data);
16
Harald Welte6add0aa2020-12-16 00:02:11 +010017void e1_tx_config(uint16_t cr);
18void e1_rx_config(uint16_t cr);
19
Sylvain Munaut2c0c1362022-01-03 18:48:08 +010020
21/* data flow */
22
23unsigned int e1_rx_need_data(unsigned int usb_addr, unsigned int max_len, unsigned int *pos);
24unsigned int e1_tx_feed_data(unsigned int usb_addr, unsigned int len);
25unsigned int e1_tx_level(void);
26unsigned int e1_rx_level(void);
27
28
29/* error reporting */
30
Harald Welte805f2cf2020-12-14 17:31:03 +010031#define E1_ERR_F_ALIGN_ERR 0x01
32#define E1_ERR_F_LOS 0x02
Harald Welte51baa362022-01-01 15:22:25 +010033#define E1_ERR_F_RAI 0x04
Harald Welte805f2cf2020-12-14 17:31:03 +010034
35struct e1_error_count {
36 uint16_t crc;
37 uint16_t align;
38 uint16_t ovfl;
39 uint16_t unfl;
40 uint8_t flags;
41};
42
43const struct e1_error_count *e1_get_error_count(void);
44
Sylvain Munaut2c0c1362022-01-03 18:48:08 +010045
46/* external function provided by the platform; used by E1 driver to control LEDs */
47
Harald Welte52765672020-12-15 18:35:42 +010048enum e1_platform_led {
49 E1P_LED_GREEN = 0,
50 E1P_LED_YELLOW = 1,
51};
52
53enum e1_platform_led_state {
54 E1P_LED_ST_OFF = 0,
55 E1P_LED_ST_ON = 1,
56 E1P_LED_ST_BLINK = 2,
57 E1P_LED_ST_BLINK_FAST = 3
58};
59
Sylvain Munaut8f31a9e2022-01-03 22:09:03 +010060extern void e1_platform_led_set(int port, enum e1_platform_led led,
Harald Welte52765672020-12-15 18:35:42 +010061 enum e1_platform_led_state state);