blob: 9fca7da0dd45d6eb642cc8077bd6a791569cea83 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/*
* SPDX-FileCopyrightText: Copyright (c) 2023 Ha Thach (tinyusb.org)
* SPDX-License-Identifier: MIT
*
* This file is part of the TinyUSB stack.
*/
#ifndef TUSB_UTCD_H_
#define TUSB_UTCD_H_
#include "common/tusb_common.h"
#include "pd_types.h"
#ifdef __cplusplus
extern "C" {
#endif
//--------------------------------------------------------------------+
// TypeC Configuration
//--------------------------------------------------------------------+
#ifndef CFG_TUC_TASK_QUEUE_SZ
#define CFG_TUC_TASK_QUEUE_SZ 8
#endif
//--------------------------------------------------------------------+
// Application API
//--------------------------------------------------------------------+
// Init typec stack on a port
bool tuc_init(uint8_t rhport, uint32_t port_type);
// Check if typec port is initialized
bool tuc_inited(uint8_t rhport);
// Enable Type-C port terminations
// Return false if port is not initialized
bool tuc_connect(uint8_t rhport);
// Disable Type-C port terminations
// Return false if port is not initialized
bool tuc_disconnect(uint8_t rhport);
// Task function should be called in main/rtos loop, extended version of tud_task()
// - timeout_ms: millisecond to wait, zero = no wait, 0xFFFFFFFF = wait forever
// - in_isr: if function is called in ISR
void tuc_task_ext(uint32_t timeout_ms, bool in_isr);
// Task function should be called in main/rtos loop
TU_ATTR_ALWAYS_INLINE static inline
void tuc_task (void) {
tuc_task_ext(UINT32_MAX, false);
}
#ifndef TUSB_TCD_H_
extern void tcd_int_handler(uint8_t rhport);
#endif
// Interrupt handler, name alias to TCD
#define tuc_int_handler tcd_int_handler
//--------------------------------------------------------------------+
// Callbacks
//--------------------------------------------------------------------+
bool tuc_pd_data_received_cb(uint8_t rhport, pd_header_t const* header, uint8_t const* dobj, uint8_t const* p_end);
bool tuc_pd_control_received_cb(uint8_t rhport, pd_header_t const* header);
//--------------------------------------------------------------------+
//
//--------------------------------------------------------------------+
bool tuc_msg_request(uint8_t rhport, void const* rdo);
#ifdef __cplusplus
}
#endif
#endif
|