mikroSDK Reference Manual
usbc.h
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2023 Ha Thach (tinyusb.org)
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 *
24 * This file is part of the TinyUSB stack.
25 */
26
27#ifndef _TUSB_UTCD_H_
28#define _TUSB_UTCD_H_
29
30#include "common/tusb_common.h"
31#include "pd_types.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37//--------------------------------------------------------------------+
38// TypeC Configuration
39//--------------------------------------------------------------------+
40
41#ifndef CFG_TUC_TASK_QUEUE_SZ
42#define CFG_TUC_TASK_QUEUE_SZ 8
43#endif
44
45//--------------------------------------------------------------------+
46// Application API
47//--------------------------------------------------------------------+
48
49// Init typec stack on a port
50bool tuc_init(uint8_t rhport, uint32_t port_type);
51
52// Check if typec port is initialized
53bool tuc_inited(uint8_t rhport);
54
55// Task function should be called in main/rtos loop, extended version of tud_task()
56// - timeout_ms: millisecond to wait, zero = no wait, 0xFFFFFFFF = wait forever
57// - in_isr: if function is called in ISR
58void tuc_task_ext(uint32_t timeout_ms, bool in_isr);
59
60// Task function should be called in main/rtos loop
61TU_ATTR_ALWAYS_INLINE static inline
62void tuc_task (void) {
63 tuc_task_ext(UINT32_MAX, false);
64}
65
66#ifndef _TUSB_TCD_H_
67extern void tcd_int_handler(uint8_t rhport);
68#endif
69
70// Interrupt handler, name alias to TCD
71#define tuc_int_handler tcd_int_handler
72
73//--------------------------------------------------------------------+
74// Callbacks
75//--------------------------------------------------------------------+
76
77TU_ATTR_WEAK bool tuc_pd_data_received_cb(uint8_t rhport, pd_header_t const* header, uint8_t const* dobj, uint8_t const* p_end);
78TU_ATTR_WEAK bool tuc_pd_control_received_cb(uint8_t rhport, pd_header_t const* header);
79
80//--------------------------------------------------------------------+
81//
82//--------------------------------------------------------------------+
83
84bool tuc_msg_request(uint8_t rhport, void const* rdo);
85
86
87#ifdef __cplusplus
88}
89#endif
90
91#endif
AUDIO Channel Cluster Descriptor (4.1)
Definition audio.h:647