Skip to content

Commit 9affeb8

Browse files
author
Seppo Takalo
authored
Merge pull request #11071 from cypress-neil/pr/psoc6-usb
PSOC6: USB device implementation
2 parents 2c6280b + 2bf79c1 commit 9affeb8

File tree

3 files changed

+454
-2
lines changed

3 files changed

+454
-2
lines changed

targets/targets.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8381,6 +8381,7 @@
83818381
"SPISLAVE",
83828382
"STDIO_MESSAGES",
83838383
"TRNG",
8384+
"USBDEVICE",
83848385
"USTICKER"
83858386
],
83868387
"release_versions": ["5"],
@@ -8483,6 +8484,7 @@
84838484
},
84848485
"CY8CKIT_062_BLE": {
84858486
"inherits": ["MCU_PSOC6_M4"],
8487+
"device_has_remove": ["USBDEVICE"],
84868488
"supported_form_factors": ["ARDUINO"],
84878489
"extra_labels_add": [
84888490
"PSOC6_01",
@@ -8521,7 +8523,7 @@
85218523
"supported_form_factors": ["ARDUINO"],
85228524
"extra_labels_add": ["PSOC6_FUTURE", "CY8C63XX", "FUTURE_SEQUANA"],
85238525
"extra_labels_remove": ["PSOC6"],
8524-
"device_has_remove": ["TRNG", "CRC", "I2CSLAVE"],
8526+
"device_has_remove": ["TRNG", "CRC", "I2CSLAVE", "USBDEVICE"],
85258527
"macros_add": ["CY8C6347BZI_BLD53"],
85268528
"detect_code": ["6000"],
85278529
"post_binary_hook": {
@@ -8550,7 +8552,7 @@
85508552
"supported_form_factors": ["ARDUINO"],
85518553
"extra_labels_add": ["PSOC6_FUTURE", "CY8C63XX", "CORDIO"],
85528554
"extra_labels_remove": ["PSOC6"],
8553-
"device_has_remove": ["TRNG", "CRC", "I2CSLAVE"],
8555+
"device_has_remove": ["TRNG", "CRC", "I2CSLAVE", "USBDEVICE"],
85548556
"macros_add": ["CY8C6347BZI_BLD53"],
85558557
"detect_code": ["6000"],
85568558
"hex_filename": "psoc63_m0_default_1.03.hex",
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) 2019, Arm Limited and affiliates.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#ifndef USBPHYHW_H
19+
#define USBPHYHW_H
20+
21+
#include "USBPhy.h"
22+
#include "cyhal_usb_dev.h"
23+
24+
class USBPhyHw : public USBPhy {
25+
public:
26+
USBPhyHw();
27+
virtual ~USBPhyHw();
28+
virtual void init(USBPhyEvents *events);
29+
virtual void deinit();
30+
virtual bool powered();
31+
virtual void connect();
32+
virtual void disconnect();
33+
virtual void configure();
34+
virtual void unconfigure();
35+
virtual void sof_enable();
36+
virtual void sof_disable();
37+
virtual void set_address(uint8_t address);
38+
virtual void remote_wakeup();
39+
virtual const usb_ep_table_t *endpoint_table();
40+
virtual void suspend(bool suspended);
41+
42+
virtual uint32_t ep0_set_max_packet(uint32_t max_packet);
43+
virtual void ep0_setup_read_result(uint8_t *buffer, uint32_t size);
44+
virtual void ep0_read(uint8_t *data, uint32_t size);
45+
virtual uint32_t ep0_read_result();
46+
virtual void ep0_write(uint8_t *buffer, uint32_t size);
47+
virtual void ep0_stall();
48+
49+
virtual bool endpoint_add(usb_ep_t endpoint, uint32_t max_packet, usb_ep_type_t type);
50+
virtual void endpoint_remove(usb_ep_t endpoint);
51+
virtual void endpoint_stall(usb_ep_t endpoint);
52+
virtual void endpoint_unstall(usb_ep_t endpoint);
53+
54+
virtual bool endpoint_read(usb_ep_t endpoint, uint8_t *data, uint32_t size);
55+
virtual uint32_t endpoint_read_result(usb_ep_t endpoint);
56+
virtual bool endpoint_write(usb_ep_t endpoint, uint8_t *data, uint32_t size);
57+
virtual void endpoint_abort(usb_ep_t endpoint);
58+
59+
virtual void process();
60+
61+
USBPhyEvents *events;
62+
63+
uint8_t in_event_mask;
64+
uint8_t out_event_mask;
65+
66+
private:
67+
virtual void usb_dev_execute_ep_callbacks(void);
68+
static void _usbisr(void);
69+
cyhal_usb_dev_t obj;
70+
};
71+
72+
#endif

0 commit comments

Comments
 (0)