Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers USBPhyEvents.h Source File

USBPhyEvents.h

00001 /*
00002  * Copyright (c) 2018-2019, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef USBPHY_EVENTS_H
00019 #define USBPHY_EVENTS_H
00020 
00021 #include "USBPhyTypes.h"
00022 
00023 /** Event handler for USBPhy
00024  *
00025  * This class is the event handler for the USBPhy class. Any events generated
00026  * by USBPhy are passed to this class via the virtual functions.
00027  *
00028  * @ingroup usb_device_core
00029  *
00030  */
00031 class USBPhyEvents {
00032 public:
00033     USBPhyEvents() {};
00034     virtual ~USBPhyEvents() {};
00035 
00036     /**
00037      * Callback called when a bus reset occurs
00038      * @note called in the contex of USBPhy::process
00039      */
00040     virtual void reset() = 0;
00041 
00042     /**
00043      * Callback called when an endpoint 0 setup packet is received
00044      * @note called in the contex of USBPhy::process
00045      */
00046     virtual void ep0_setup() = 0;
00047 
00048     /**
00049      * Callback called when an endpoint 0 out packet is received
00050      * @note called in the contex of USBPhy::process
00051      */
00052     virtual void ep0_out() = 0;
00053 
00054     /**
00055      * Callback called when an endpoint 0 in packet is received
00056      * @note called in the contex of USBPhy::process
00057      */
00058     virtual void ep0_in() = 0;
00059 
00060     /**
00061      * Callback called USB power is applied or removed
00062      *
00063      * @param powered true if USB power is present, false otherwise
00064      * @note called in the contex of USBPhy::process
00065      */
00066     virtual void power(bool powered) = 0;
00067 
00068     /**
00069      * Callback called when entering or leaving suspend mode
00070      *
00071      * @param suspended true if entering suspend mode false otherwise
00072      * @note called in the contex of USBPhy::process
00073      */
00074     virtual void suspend(bool suspended) = 0;
00075 
00076     /**
00077      * Callback called on start of frame
00078      *
00079      * @param frame_number The current frame number
00080      * @note This callback is enabled/disabled by
00081      *  calling USBPhy::sof_enable / USBPhy::sof_disable
00082      * @note called in the contex of USBPhy::process
00083      */
00084     virtual void sof(int frame_number) = 0;
00085 
00086     /**
00087      * Callback called on the reception of an OUT packet
00088      *
00089      * @param endpoint Endpoint which received the OUT packet
00090      * @note called in the contex of USBPhy::process
00091      */
00092     virtual void out(usb_ep_t endpoint) = 0;
00093 
00094     /**
00095      * Callback called on the transmission of an IN packet
00096      *
00097      * @param endpoint Endpoint which sent the IN packet
00098      * @note called in the contex of USBPhy::process
00099      */
00100     virtual void in(usb_ep_t endpoint) = 0;
00101 
00102     /**
00103      * Callback called to indicate the USB processing needs to be done
00104      */
00105     virtual void start_process() = 0;
00106 };
00107 
00108 #endif