Skip to content

PSOC6: USB device implementation #11071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions targets/targets.json
Original file line number Diff line number Diff line change
Expand Up @@ -8381,6 +8381,7 @@
"SPISLAVE",
"STDIO_MESSAGES",
"TRNG",
"USBDEVICE",
"USTICKER"
],
"release_versions": ["5"],
Expand Down Expand Up @@ -8457,6 +8458,7 @@
},
"CY8CKIT_062_BLE": {
"inherits": ["MCU_PSOC6_M4"],
"device_has_remove": ["USBDEVICE"],
"supported_form_factors": ["ARDUINO"],
"extra_labels_add": [
"PSOC6_01",
Expand Down Expand Up @@ -8495,7 +8497,7 @@
"supported_form_factors": ["ARDUINO"],
"extra_labels_add": ["PSOC6_FUTURE", "CY8C63XX", "FUTURE_SEQUANA"],
"extra_labels_remove": ["PSOC6"],
"device_has_remove": ["TRNG", "CRC", "I2CSLAVE"],
"device_has_remove": ["TRNG", "CRC", "I2CSLAVE", "USBDEVICE"],
"macros_add": ["CY8C6347BZI_BLD53"],
"detect_code": ["6000"],
"post_binary_hook": {
Expand Down Expand Up @@ -8524,7 +8526,7 @@
"supported_form_factors": ["ARDUINO"],
"extra_labels_add": ["PSOC6_FUTURE", "CY8C63XX", "CORDIO"],
"extra_labels_remove": ["PSOC6"],
"device_has_remove": ["TRNG", "CRC", "I2CSLAVE"],
"device_has_remove": ["TRNG", "CRC", "I2CSLAVE", "USBDEVICE"],
"macros_add": ["CY8C6347BZI_BLD53"],
"detect_code": ["6000"],
"hex_filename": "psoc63_m0_default_1.03.hex",
Expand Down
72 changes: 72 additions & 0 deletions usb/device/targets/TARGET_Cypress/TARGET_PSOC6/USBPhyHw.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2019, Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef USBPHYHW_H
#define USBPHYHW_H

#include "USBPhy.h"
#include "cyhal_usb_dev.h"

class USBPhyHw : public USBPhy {
public:
USBPhyHw();
virtual ~USBPhyHw();
virtual void init(USBPhyEvents *events);
virtual void deinit();
virtual bool powered();
virtual void connect();
virtual void disconnect();
virtual void configure();
virtual void unconfigure();
virtual void sof_enable();
virtual void sof_disable();
virtual void set_address(uint8_t address);
virtual void remote_wakeup();
virtual const usb_ep_table_t *endpoint_table();
virtual void suspend(bool suspended);

virtual uint32_t ep0_set_max_packet(uint32_t max_packet);
virtual void ep0_setup_read_result(uint8_t *buffer, uint32_t size);
virtual void ep0_read(uint8_t *data, uint32_t size);
virtual uint32_t ep0_read_result();
virtual void ep0_write(uint8_t *buffer, uint32_t size);
virtual void ep0_stall();

virtual bool endpoint_add(usb_ep_t endpoint, uint32_t max_packet, usb_ep_type_t type);
virtual void endpoint_remove(usb_ep_t endpoint);
virtual void endpoint_stall(usb_ep_t endpoint);
virtual void endpoint_unstall(usb_ep_t endpoint);

virtual bool endpoint_read(usb_ep_t endpoint, uint8_t *data, uint32_t size);
virtual uint32_t endpoint_read_result(usb_ep_t endpoint);
virtual bool endpoint_write(usb_ep_t endpoint, uint8_t *data, uint32_t size);
virtual void endpoint_abort(usb_ep_t endpoint);

virtual void process();

USBPhyEvents *events;

uint8_t in_event_mask;
uint8_t out_event_mask;

private:
virtual void usb_dev_execute_ep_callbacks(void);
static void _usbisr(void);
cyhal_usb_dev_t obj;
};

#endif
Loading