2017-12-21 06:42:46 +01:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
*
|
|
|
|
* \brief Declaration of main function used by Composite example 4
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* \asf_license_start
|
|
|
|
*
|
|
|
|
* \page License
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* 3. The name of Atmel may not be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* 4. This software may only be redistributed and used in connection with an
|
|
|
|
* Atmel microcontroller product.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
|
|
|
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* \asf_license_stop
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/*
|
2020-07-24 03:46:11 +02:00
|
|
|
* Support and FAQ: visit <a href="https://www.atmel.com/design-support/">Atmel Support</a>
|
2017-12-21 06:42:46 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _USB_TASK_H_
|
|
|
|
#define _USB_TASK_H_
|
|
|
|
|
|
|
|
#include "usb_protocol_cdc.h"
|
|
|
|
|
2018-03-22 01:04:45 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-12-21 06:42:46 +01:00
|
|
|
/*! \brief Called by MSC interface
|
|
|
|
* Callback running when USB Host enable MSC interface
|
|
|
|
*
|
|
|
|
* \retval true if MSC startup is ok
|
|
|
|
*/
|
2019-09-27 21:02:35 +02:00
|
|
|
bool usb_task_msc_enable(void);
|
2017-12-21 06:42:46 +01:00
|
|
|
|
|
|
|
/*! \brief Called by MSC interface
|
|
|
|
* Callback running when USB Host disable MSC interface
|
|
|
|
*/
|
2019-09-27 21:02:35 +02:00
|
|
|
void usb_task_msc_disable(void);
|
2017-12-21 06:42:46 +01:00
|
|
|
|
|
|
|
/*! \brief Opens the communication port
|
|
|
|
* This is called by CDC interface when USB Host enable it.
|
|
|
|
*
|
|
|
|
* \retval true if cdc startup is successfully done
|
|
|
|
*/
|
2017-12-28 07:32:46 +01:00
|
|
|
bool usb_task_cdc_enable(const uint8_t port);
|
2017-12-21 06:42:46 +01:00
|
|
|
|
|
|
|
/*! \brief Closes the communication port
|
|
|
|
* This is called by CDC interface when USB Host disable it.
|
|
|
|
*/
|
2017-12-28 07:32:46 +01:00
|
|
|
void usb_task_cdc_disable(const uint8_t port);
|
2017-12-21 06:42:46 +01:00
|
|
|
|
|
|
|
/*! \brief Save new DTR state to change led behavior.
|
|
|
|
* The DTR notify that the terminal have open or close the communication port.
|
|
|
|
*/
|
2017-12-28 07:32:46 +01:00
|
|
|
void usb_task_cdc_set_dtr(const uint8_t port, const bool b_enable);
|
2017-12-21 06:42:46 +01:00
|
|
|
|
2018-03-15 04:56:28 +01:00
|
|
|
/*! \brief Check if MSC is enumerated and configured on the PC side
|
|
|
|
*/
|
2019-09-27 21:02:35 +02:00
|
|
|
bool usb_task_msc_isenabled(void);
|
2018-03-15 04:56:28 +01:00
|
|
|
|
|
|
|
/*! \brief Check if CDC is enumerated and configured on the PC side
|
|
|
|
*/
|
2019-09-27 21:02:35 +02:00
|
|
|
bool usb_task_cdc_isenabled(void);
|
2018-03-15 04:56:28 +01:00
|
|
|
|
|
|
|
/*! \brief Check if CDC is actually OPEN by an application on the PC side
|
|
|
|
* assuming DTR signal means a program is listening to messages
|
|
|
|
*/
|
2019-09-27 21:02:35 +02:00
|
|
|
bool usb_task_cdc_dtr_active(void);
|
2018-03-15 04:56:28 +01:00
|
|
|
|
2017-12-21 06:42:46 +01:00
|
|
|
/*! \brief Called by UDC when USB Host request a extra string different
|
|
|
|
* of this specified in USB device descriptor
|
|
|
|
*/
|
2019-09-27 21:02:35 +02:00
|
|
|
bool usb_task_extra_string(void);
|
2017-12-21 06:42:46 +01:00
|
|
|
|
2017-12-28 07:32:46 +01:00
|
|
|
/*! \brief Called by UDC when USB Host performs unknown requests
|
|
|
|
*/
|
2019-09-27 21:02:35 +02:00
|
|
|
bool usb_task_other_requests(void);
|
2017-12-28 07:32:46 +01:00
|
|
|
|
2017-12-21 06:42:46 +01:00
|
|
|
/*! \brief Called by CDC interface
|
|
|
|
* Callback running when CDC device have received data
|
|
|
|
*/
|
2017-12-28 07:32:46 +01:00
|
|
|
void usb_task_cdc_rx_notify(const uint8_t port);
|
2017-12-21 06:42:46 +01:00
|
|
|
|
|
|
|
/*! \brief Configures communication line
|
|
|
|
*
|
|
|
|
* \param cfg line configuration
|
|
|
|
*/
|
2017-12-28 07:32:46 +01:00
|
|
|
void usb_task_cdc_config(const uint8_t port, usb_cdc_line_coding_t *cfg);
|
2017-12-21 06:42:46 +01:00
|
|
|
|
2018-03-22 01:04:45 +01:00
|
|
|
/*! \brief The USB device interrupt
|
2017-12-21 06:42:46 +01:00
|
|
|
*/
|
2019-09-27 21:02:35 +02:00
|
|
|
void USBD_ISR(void);
|
2017-12-21 06:42:46 +01:00
|
|
|
|
2018-03-22 01:04:45 +01:00
|
|
|
/*! \brief USB task init
|
|
|
|
*/
|
2019-09-27 21:02:35 +02:00
|
|
|
void usb_task_init(void);
|
2018-03-22 01:04:45 +01:00
|
|
|
|
|
|
|
/*! \brief USB task idle
|
|
|
|
*/
|
2019-09-27 21:02:35 +02:00
|
|
|
void usb_task_idle(void);
|
2018-03-22 01:04:45 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // _USB_TASK_H_
|