mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
clean up
This commit is contained in:
parent
92646ebadb
commit
15c80a9580
@ -1,149 +1,140 @@
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@file cdc_serial_app.c
|
@file cdc_serial_app.c
|
||||||
@author hathach (tinyusb.org)
|
@author hathach (tinyusb.org)
|
||||||
|
|
||||||
@section LICENSE
|
@section LICENSE
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
Software License Agreement (BSD License)
|
||||||
|
|
||||||
Copyright (c) 2013, hathach (tinyusb.org)
|
Copyright (c) 2013, hathach (tinyusb.org)
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
1. Redistributions of source code must retain the above copyright
|
1. Redistributions of source code must retain the above copyright
|
||||||
notice, this list of conditions and the following disclaimer.
|
notice, this list of conditions and the following disclaimer.
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
3. Neither the name of the copyright holders nor the
|
3. Neither the name of the copyright holders nor the
|
||||||
names of its contributors may be used to endorse or promote products
|
names of its contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior written permission.
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
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
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
This file is part of the tinyusb stack.
|
This file is part of the tinyusb stack.
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#include "cdc_serial_app.h"
|
#include "cdc_serial_app.h"
|
||||||
|
|
||||||
#if TUSB_CFG_OS != TUSB_OS_NONE
|
#if TUSB_CFG_OS != TUSB_OS_NONE
|
||||||
#include "app_os_prio.h"
|
#include "app_os_prio.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TUSB_CFG_HOST_CDC
|
#if TUSB_CFG_HOST_CDC
|
||||||
|
|
||||||
#define QUEUE_SERIAL_DEPTH 100
|
#define QUEUE_SERIAL_DEPTH 100
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO CONSTANT TYPEDEF
|
// MACRO CONSTANT TYPEDEF
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
OSAL_TASK_DEF(cdc_serial_app_task, 128, CDC_SERIAL_APP_TASK_PRIO);
|
OSAL_TASK_DEF(cdc_serial_app_task, 128, CDC_SERIAL_APP_TASK_PRIO);
|
||||||
OSAL_QUEUE_DEF(queue_def, QUEUE_SERIAL_DEPTH, uint8_t);
|
OSAL_QUEUE_DEF(queue_def, QUEUE_SERIAL_DEPTH, uint8_t);
|
||||||
|
|
||||||
static osal_queue_handle_t queue_hdl;
|
static osal_queue_handle_t queue_hdl;
|
||||||
static uint8_t buffer_in[64] TUSB_CFG_ATTR_USBRAM;
|
static uint8_t buffer_in[64] TUSB_CFG_ATTR_USBRAM;
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// tinyusb Callbacks
|
// tinyusb Callbacks
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void tusbh_cdc_mounted_cb(uint8_t dev_addr)
|
void tusbh_cdc_mounted_cb(uint8_t dev_addr)
|
||||||
{
|
{
|
||||||
// application set-up
|
// application set-up
|
||||||
|
|
||||||
printf("\na CDC device is mounted\n");
|
printf("\na CDC device is mounted\n");
|
||||||
|
|
||||||
osal_queue_flush(queue_hdl);
|
osal_queue_flush(queue_hdl);
|
||||||
tusbh_cdc_receive(dev_addr, buffer_in, sizeof(buffer_in), true); // first report
|
tusbh_cdc_receive(dev_addr, buffer_in, sizeof(buffer_in), true); // first report
|
||||||
}
|
}
|
||||||
|
|
||||||
void tusbh_cdc_unmounted_cb(uint8_t dev_addr)
|
void tusbh_cdc_unmounted_cb(uint8_t dev_addr)
|
||||||
{
|
{
|
||||||
// application tear-down
|
// application tear-down
|
||||||
printf("\na CDC device is unmounted\n");
|
printf("\na CDC device is unmounted\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes)
|
void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes)
|
||||||
{
|
{
|
||||||
if ( pipe_id == CDC_PIPE_DATA_IN )
|
if ( pipe_id == CDC_PIPE_DATA_IN )
|
||||||
{
|
{
|
||||||
switch(event)
|
switch(event)
|
||||||
{
|
{
|
||||||
case TUSB_EVENT_XFER_COMPLETE:
|
case TUSB_EVENT_XFER_COMPLETE:
|
||||||
for(uint32_t i=0; i<xferred_bytes; i++)
|
for(uint32_t i=0; i<xferred_bytes; i++)
|
||||||
{
|
{
|
||||||
osal_queue_send(queue_hdl, buffer_in+i);
|
osal_queue_send(queue_hdl, buffer_in+i);
|
||||||
}
|
}
|
||||||
tusbh_cdc_receive(dev_addr, buffer_in, sizeof(buffer_in), true);
|
tusbh_cdc_receive(dev_addr, buffer_in, sizeof(buffer_in), true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TUSB_EVENT_XFER_ERROR:
|
case TUSB_EVENT_XFER_ERROR:
|
||||||
tusbh_cdc_receive(dev_addr, buffer_in, sizeof(buffer_in), true); // ignore & continue
|
tusbh_cdc_receive(dev_addr, buffer_in, sizeof(buffer_in), true); // ignore & continue
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TUSB_EVENT_XFER_STALLED:
|
case TUSB_EVENT_XFER_STALLED:
|
||||||
default :
|
default :
|
||||||
ASSERT(false, VOID_RETURN); // error
|
ASSERT(false, VOID_RETURN); // error
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else if (pipe_id == CDC_PIPE_DATA_OUT)
|
}else if (pipe_id == CDC_PIPE_DATA_OUT)
|
||||||
{
|
{
|
||||||
|
|
||||||
}else if (pipe_id == CDC_PIPE_NOTIFICATION)
|
}else if (pipe_id == CDC_PIPE_NOTIFICATION)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// APPLICATION
|
// APPLICATION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void cdc_serial_app_init(void)
|
void cdc_serial_app_init(void)
|
||||||
{
|
{
|
||||||
memclr_(buffer_in, sizeof(buffer_in));
|
memclr_(buffer_in, sizeof(buffer_in));
|
||||||
|
|
||||||
queue_hdl = osal_queue_create( OSAL_QUEUE_REF(queue_def) );
|
queue_hdl = osal_queue_create( OSAL_QUEUE_REF(queue_def) );
|
||||||
ASSERT_PTR( queue_hdl, VOID_RETURN);
|
ASSERT_PTR( queue_hdl, VOID_RETURN);
|
||||||
|
|
||||||
ASSERT( TUSB_ERROR_NONE == osal_task_create(OSAL_TASK_REF(cdc_serial_app_task)), VOID_RETURN);
|
ASSERT( TUSB_ERROR_NONE == osal_task_create(OSAL_TASK_REF(cdc_serial_app_task)), VOID_RETURN);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------- main task -------------//
|
//------------- main task -------------//
|
||||||
OSAL_TASK_FUNCTION( cdc_serial_app_task ) (void* p_task_para)
|
OSAL_TASK_FUNCTION( cdc_serial_app_task ) (void* p_task_para)
|
||||||
{
|
{
|
||||||
tusb_error_t error;
|
tusb_error_t error;
|
||||||
uint8_t c = 0;
|
uint8_t c = 0;
|
||||||
|
|
||||||
OSAL_TASK_LOOP_BEGIN
|
OSAL_TASK_LOOP_BEGIN
|
||||||
|
|
||||||
osal_queue_receive(queue_hdl, &c, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
osal_queue_receive(queue_hdl, &c, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||||
|
|
||||||
if (c)
|
if (c)
|
||||||
{
|
{
|
||||||
printf("%c", c);
|
printf("%c", c);
|
||||||
}
|
}
|
||||||
|
|
||||||
OSAL_TASK_LOOP_END
|
OSAL_TASK_LOOP_END
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
|
#endif
|
||||||
// dummy implementation to remove #ifdef in main.c
|
|
||||||
void cdc_serial_app_init(void) { }
|
|
||||||
OSAL_TASK_FUNCTION( cdc_serial_app_task ) (void* p_task_para)
|
|
||||||
{
|
|
||||||
OSAL_TASK_LOOP_BEGIN
|
|
||||||
OSAL_TASK_LOOP_END
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -1,66 +1,74 @@
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@file cdc_serial_app.h
|
@file cdc_serial_app.h
|
||||||
@author hathach (tinyusb.org)
|
@author hathach (tinyusb.org)
|
||||||
|
|
||||||
@section LICENSE
|
@section LICENSE
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
Software License Agreement (BSD License)
|
||||||
|
|
||||||
Copyright (c) 2013, hathach (tinyusb.org)
|
Copyright (c) 2013, hathach (tinyusb.org)
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
1. Redistributions of source code must retain the above copyright
|
1. Redistributions of source code must retain the above copyright
|
||||||
notice, this list of conditions and the following disclaimer.
|
notice, this list of conditions and the following disclaimer.
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
3. Neither the name of the copyright holders nor the
|
3. Neither the name of the copyright holders nor the
|
||||||
names of its contributors may be used to endorse or promote products
|
names of its contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior written permission.
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
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
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
This file is part of the tinyusb stack.
|
This file is part of the tinyusb stack.
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
/** \ingroup TBD
|
/** \ingroup TBD
|
||||||
* \defgroup TBD
|
* \defgroup TBD
|
||||||
* \brief TBD
|
* \brief TBD
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TUSB_CDC_SERIAL_APP_H_
|
#ifndef _TUSB_CDC_SERIAL_APP_H_
|
||||||
#define _TUSB_CDC_SERIAL_APP_H_
|
#define _TUSB_CDC_SERIAL_APP_H_
|
||||||
|
|
||||||
#include "boards/board.h"
|
#include "boards/board.h"
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void cdc_serial_app_init(void);
|
#if TUSB_CFG_HOST_CDC
|
||||||
OSAL_TASK_FUNCTION( cdc_serial_app_task ) (void* p_task_para);
|
|
||||||
|
void cdc_serial_app_init(void);
|
||||||
|
OSAL_TASK_FUNCTION( cdc_serial_app_task ) (void* p_task_para);
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
#else
|
||||||
#endif
|
|
||||||
|
#define cdc_serial_app_init()
|
||||||
#endif /* _TUSB_CDC_SERIAL_APP_H_ */
|
#define cdc_serial_app_task(x)
|
||||||
|
|
||||||
/** @} */
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _TUSB_CDC_SERIAL_APP_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
@ -1,191 +1,182 @@
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@file keyboard_app.c
|
@file keyboard_app.c
|
||||||
@author hathach (tinyusb.org)
|
@author hathach (tinyusb.org)
|
||||||
|
|
||||||
@section LICENSE
|
@section LICENSE
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
Software License Agreement (BSD License)
|
||||||
|
|
||||||
Copyright (c) 2013, hathach (tinyusb.org)
|
Copyright (c) 2013, hathach (tinyusb.org)
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
1. Redistributions of source code must retain the above copyright
|
1. Redistributions of source code must retain the above copyright
|
||||||
notice, this list of conditions and the following disclaimer.
|
notice, this list of conditions and the following disclaimer.
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
3. Neither the name of the copyright holders nor the
|
3. Neither the name of the copyright holders nor the
|
||||||
names of its contributors may be used to endorse or promote products
|
names of its contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior written permission.
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
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
|
INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
This file is part of the tinyusb stack.
|
This file is part of the tinyusb stack.
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// INCLUDE
|
// INCLUDE
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#include "keyboard_app.h"
|
#include "keyboard_app.h"
|
||||||
|
|
||||||
#if TUSB_CFG_OS != TUSB_OS_NONE
|
#if TUSB_CFG_OS != TUSB_OS_NONE
|
||||||
#include "app_os_prio.h"
|
#include "app_os_prio.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TUSB_CFG_HOST_HID_KEYBOARD
|
#if TUSB_CFG_HOST_HID_KEYBOARD
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO CONSTANT TYPEDEF
|
// MACRO CONSTANT TYPEDEF
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#define QUEUE_KEYBOARD_REPORT_DEPTH 4
|
#define QUEUE_KEYBOARD_REPORT_DEPTH 4
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
OSAL_TASK_DEF(keyboard_app_task, 128, KEYBOARD_APP_TASK_PRIO);
|
OSAL_TASK_DEF(keyboard_app_task, 128, KEYBOARD_APP_TASK_PRIO);
|
||||||
OSAL_QUEUE_DEF(queue_kbd_def, QUEUE_KEYBOARD_REPORT_DEPTH, tusb_keyboard_report_t);
|
OSAL_QUEUE_DEF(queue_kbd_def, QUEUE_KEYBOARD_REPORT_DEPTH, tusb_keyboard_report_t);
|
||||||
|
|
||||||
static osal_queue_handle_t queue_kbd_hdl;
|
static osal_queue_handle_t queue_kbd_hdl;
|
||||||
static tusb_keyboard_report_t usb_keyboard_report TUSB_CFG_ATTR_USBRAM;
|
static tusb_keyboard_report_t usb_keyboard_report TUSB_CFG_ATTR_USBRAM;
|
||||||
|
|
||||||
static inline uint8_t keycode_to_ascii(uint8_t modifier, uint8_t keycode) ATTR_CONST ATTR_ALWAYS_INLINE;
|
static inline uint8_t keycode_to_ascii(uint8_t modifier, uint8_t keycode) ATTR_CONST ATTR_ALWAYS_INLINE;
|
||||||
static inline void process_kbd_report(tusb_keyboard_report_t const * report);
|
static inline void process_kbd_report(tusb_keyboard_report_t const * report);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// tinyusb callback (ISR context)
|
// tinyusb callback (ISR context)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void tusbh_hid_keyboard_mounted_cb(uint8_t dev_addr)
|
void tusbh_hid_keyboard_mounted_cb(uint8_t dev_addr)
|
||||||
{
|
{
|
||||||
// application set-up
|
// application set-up
|
||||||
|
|
||||||
puts("\na Keyboard device is mounted");
|
puts("\na Keyboard device is mounted");
|
||||||
|
|
||||||
osal_queue_flush(queue_kbd_hdl);
|
osal_queue_flush(queue_kbd_hdl);
|
||||||
tusbh_hid_keyboard_get_report(dev_addr, (uint8_t*) &usb_keyboard_report); // first report
|
tusbh_hid_keyboard_get_report(dev_addr, (uint8_t*) &usb_keyboard_report); // first report
|
||||||
}
|
}
|
||||||
|
|
||||||
void tusbh_hid_keyboard_unmounted_cb(uint8_t dev_addr)
|
void tusbh_hid_keyboard_unmounted_cb(uint8_t dev_addr)
|
||||||
{
|
{
|
||||||
// application tear-down
|
// application tear-down
|
||||||
puts("\na Keyboard device is unmounted");
|
puts("\na Keyboard device is unmounted");
|
||||||
}
|
}
|
||||||
|
|
||||||
void tusbh_hid_keyboard_isr(uint8_t dev_addr, tusb_event_t event)
|
void tusbh_hid_keyboard_isr(uint8_t dev_addr, tusb_event_t event)
|
||||||
{
|
{
|
||||||
switch(event)
|
switch(event)
|
||||||
{
|
{
|
||||||
case TUSB_EVENT_XFER_COMPLETE:
|
case TUSB_EVENT_XFER_COMPLETE:
|
||||||
osal_queue_send(queue_kbd_hdl, &usb_keyboard_report);
|
osal_queue_send(queue_kbd_hdl, &usb_keyboard_report);
|
||||||
tusbh_hid_keyboard_get_report(dev_addr, (uint8_t*) &usb_keyboard_report);
|
tusbh_hid_keyboard_get_report(dev_addr, (uint8_t*) &usb_keyboard_report);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TUSB_EVENT_XFER_ERROR:
|
case TUSB_EVENT_XFER_ERROR:
|
||||||
tusbh_hid_keyboard_get_report(dev_addr, (uint8_t*) &usb_keyboard_report); // ignore & continue
|
tusbh_hid_keyboard_get_report(dev_addr, (uint8_t*) &usb_keyboard_report); // ignore & continue
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// APPLICATION
|
// APPLICATION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void keyboard_app_init(void)
|
void keyboard_app_init(void)
|
||||||
{
|
{
|
||||||
memclr_(&usb_keyboard_report, sizeof(tusb_keyboard_report_t));
|
memclr_(&usb_keyboard_report, sizeof(tusb_keyboard_report_t));
|
||||||
|
|
||||||
queue_kbd_hdl = osal_queue_create( OSAL_QUEUE_REF(queue_kbd_def) );
|
queue_kbd_hdl = osal_queue_create( OSAL_QUEUE_REF(queue_kbd_def) );
|
||||||
ASSERT_PTR( queue_kbd_hdl, VOID_RETURN );
|
ASSERT_PTR( queue_kbd_hdl, VOID_RETURN );
|
||||||
|
|
||||||
ASSERT( TUSB_ERROR_NONE == osal_task_create( OSAL_TASK_REF(keyboard_app_task) ) ,
|
ASSERT( TUSB_ERROR_NONE == osal_task_create( OSAL_TASK_REF(keyboard_app_task) ) ,
|
||||||
VOID_RETURN);
|
VOID_RETURN);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------- main task -------------//
|
//------------- main task -------------//
|
||||||
OSAL_TASK_FUNCTION( keyboard_app_task ) (void* p_task_para)
|
OSAL_TASK_FUNCTION( keyboard_app_task ) (void* p_task_para)
|
||||||
{
|
{
|
||||||
tusb_error_t error;
|
tusb_error_t error;
|
||||||
tusb_keyboard_report_t kbd_report;
|
tusb_keyboard_report_t kbd_report;
|
||||||
|
|
||||||
OSAL_TASK_LOOP_BEGIN
|
OSAL_TASK_LOOP_BEGIN
|
||||||
|
|
||||||
osal_queue_receive(queue_kbd_hdl, &kbd_report, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
osal_queue_receive(queue_kbd_hdl, &kbd_report, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||||
|
|
||||||
process_kbd_report(&kbd_report);
|
process_kbd_report(&kbd_report);
|
||||||
|
|
||||||
OSAL_TASK_LOOP_END
|
OSAL_TASK_LOOP_END
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// HELPER
|
// HELPER
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// look up new key in previous keys
|
// look up new key in previous keys
|
||||||
static inline bool is_key_in_report(tusb_keyboard_report_t const *p_report, uint8_t modifier, uint8_t keycode)
|
static inline bool is_key_in_report(tusb_keyboard_report_t const *p_report, uint8_t modifier, uint8_t keycode)
|
||||||
{
|
{
|
||||||
for(uint8_t i=0; i<6; i++)
|
for(uint8_t i=0; i<6; i++)
|
||||||
{
|
{
|
||||||
if (p_report->keycode[i] == keycode)
|
if (p_report->keycode[i] == keycode)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void process_kbd_report(tusb_keyboard_report_t const *p_new_report)
|
static inline void process_kbd_report(tusb_keyboard_report_t const *p_new_report)
|
||||||
{
|
{
|
||||||
static tusb_keyboard_report_t prev_report = { 0 }; // previous report to check key released
|
static tusb_keyboard_report_t prev_report = { 0 }; // previous report to check key released
|
||||||
|
|
||||||
//------------- example code ignore control (non-printable) key affects -------------//
|
//------------- example code ignore control (non-printable) key affects -------------//
|
||||||
for(uint8_t i=0; i<6; i++)
|
for(uint8_t i=0; i<6; i++)
|
||||||
{
|
{
|
||||||
if ( p_new_report->keycode[i] )
|
if ( p_new_report->keycode[i] )
|
||||||
{
|
{
|
||||||
if ( is_key_in_report(&prev_report, p_new_report->modifier, p_new_report->keycode[i]) )
|
if ( is_key_in_report(&prev_report, p_new_report->modifier, p_new_report->keycode[i]) )
|
||||||
{
|
{
|
||||||
// previously existed means holding
|
// previously existed means holding
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
// previously non-existed means key is pressed
|
// previously non-existed means key is pressed
|
||||||
printf("%c", keycode_to_ascii(p_new_report->modifier, p_new_report->keycode[i]) );
|
printf("%c", keycode_to_ascii(p_new_report->modifier, p_new_report->keycode[i]) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO example skips key released
|
// TODO example skips key released
|
||||||
}
|
}
|
||||||
|
|
||||||
prev_report = *p_new_report;
|
prev_report = *p_new_report;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint8_t keycode_to_ascii(uint8_t modifier, uint8_t keycode)
|
static inline uint8_t keycode_to_ascii(uint8_t modifier, uint8_t keycode)
|
||||||
{
|
{
|
||||||
// TODO max of keycode_ascii_tbl
|
// TODO max of keycode_ascii_tbl
|
||||||
return keycode > 128 ? 0 :
|
return keycode > 128 ? 0 :
|
||||||
hid_keycode_to_ascii_tbl [modifier & (KEYBOARD_MODIFIER_LEFTSHIFT | KEYBOARD_MODIFIER_RIGHTSHIFT) ? 1 : 0] [keycode];
|
hid_keycode_to_ascii_tbl [modifier & (KEYBOARD_MODIFIER_LEFTSHIFT | KEYBOARD_MODIFIER_RIGHTSHIFT) ? 1 : 0] [keycode];
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
// dummy implementation to remove #ifdef in main.c
|
|
||||||
void keyboard_app_init(void) { }
|
|
||||||
OSAL_TASK_FUNCTION( keyboard_app_task ) (void* p_task_para)
|
|
||||||
{
|
|
||||||
OSAL_TASK_LOOP_BEGIN
|
|
||||||
OSAL_TASK_LOOP_END
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
@ -1,72 +1,80 @@
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@file keyboard_app.h
|
@file keyboard_app.h
|
||||||
@author hathach (tinyusb.org)
|
@author hathach (tinyusb.org)
|
||||||
|
|
||||||
@section LICENSE
|
@section LICENSE
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
Software License Agreement (BSD License)
|
||||||
|
|
||||||
Copyright (c) 2013, hathach (tinyusb.org)
|
Copyright (c) 2013, hathach (tinyusb.org)
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
1. Redistributions of source code must retain the above copyright
|
1. Redistributions of source code must retain the above copyright
|
||||||
notice, this list of conditions and the following disclaimer.
|
notice, this list of conditions and the following disclaimer.
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
3. Neither the name of the copyright holders nor the
|
3. Neither the name of the copyright holders nor the
|
||||||
names of its contributors may be used to endorse or promote products
|
names of its contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior written permission.
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
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
|
INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
This file is part of the tinyusb stack.
|
This file is part of the tinyusb stack.
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \brief TBD
|
* \brief TBD
|
||||||
*
|
*
|
||||||
* \note TBD
|
* \note TBD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup TBD
|
/** \ingroup TBD
|
||||||
* \defgroup TBD
|
* \defgroup TBD
|
||||||
* \brief TBD
|
* \brief TBD
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TUSB_KEYBOARD_APP_H_
|
#ifndef _TUSB_KEYBOARD_APP_H_
|
||||||
#define _TUSB_KEYBOARD_APP_H_
|
#define _TUSB_KEYBOARD_APP_H_
|
||||||
|
|
||||||
#include "boards/board.h"
|
#include "boards/board.h"
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if TUSB_CFG_HOST_HID_KEYBOARD
|
||||||
void keyboard_app_init(void);
|
|
||||||
OSAL_TASK_FUNCTION( keyboard_app_task ) (void* p_task_para);
|
void keyboard_app_init(void);
|
||||||
|
OSAL_TASK_FUNCTION( keyboard_app_task ) (void* p_task_para);
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
#else
|
||||||
#endif
|
|
||||||
|
#define keyboard_app_init()
|
||||||
#endif /* _TUSB_KEYBOARD_APP_H_ */
|
#define keyboard_app_task(x)
|
||||||
|
|
||||||
/** @} */
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _TUSB_KEYBOARD_APP_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
@ -182,14 +182,4 @@ static inline void process_mouse_report(tusb_mouse_report_t const * p_report)
|
|||||||
cursor_movement(p_report->x, p_report->y, p_report->wheel);
|
cursor_movement(p_report->x, p_report->y, p_report->wheel);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// dummy implementation to remove #ifdef in main.c
|
|
||||||
void mouse_app_init(void) { }
|
|
||||||
OSAL_TASK_FUNCTION( mouse_app_task ) (void* p_task_para)
|
|
||||||
{
|
|
||||||
OSAL_TASK_LOOP_BEGIN
|
|
||||||
OSAL_TASK_LOOP_END
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,74 +1,83 @@
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@file mouse_app.h
|
@file mouse_app.h
|
||||||
@author hathach (tinyusb.org)
|
@author hathach (tinyusb.org)
|
||||||
|
|
||||||
@section LICENSE
|
@section LICENSE
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
Software License Agreement (BSD License)
|
||||||
|
|
||||||
Copyright (c) 2013, hathach (tinyusb.org)
|
Copyright (c) 2013, hathach (tinyusb.org)
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
1. Redistributions of source code must retain the above copyright
|
1. Redistributions of source code must retain the above copyright
|
||||||
notice, this list of conditions and the following disclaimer.
|
notice, this list of conditions and the following disclaimer.
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
3. Neither the name of the copyright holders nor the
|
3. Neither the name of the copyright holders nor the
|
||||||
names of its contributors may be used to endorse or promote products
|
names of its contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior written permission.
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
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
|
INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
This file is part of the tinyusb stack.
|
This file is part of the tinyusb stack.
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \brief TBD
|
* \brief TBD
|
||||||
*
|
*
|
||||||
* \note TBD
|
* \note TBD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup TBD
|
/** \ingroup TBD
|
||||||
* \defgroup TBD
|
* \defgroup TBD
|
||||||
* \brief TBD
|
* \brief TBD
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TUSB_MOUSE_APP_H_
|
#ifndef _TUSB_MOUSE_APP_H_
|
||||||
#define _TUSB_MOUSE_APP_H_
|
#define _TUSB_MOUSE_APP_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "boards/board.h"
|
#include "boards/board.h"
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void mouse_app_init(void);
|
#if TUSB_CFG_HOST_HID_MOUSE
|
||||||
OSAL_TASK_FUNCTION( mouse_app_task ) (void* p_task_para);
|
|
||||||
|
void mouse_app_init(void);
|
||||||
#ifdef __cplusplus
|
OSAL_TASK_FUNCTION( mouse_app_task ) (void* p_task_para);
|
||||||
}
|
|
||||||
#endif
|
#else
|
||||||
|
|
||||||
#endif /* _TUSB_MOUSE_APP_H_ */
|
#define mouse_app_init()
|
||||||
|
#define mouse_app_task(x)
|
||||||
/** @} */
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _TUSB_MOUSE_APP_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
@ -1,186 +1,176 @@
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@file msc_app.c
|
@file msc_app.c
|
||||||
@author hathach (tinyusb.org)
|
@author hathach (tinyusb.org)
|
||||||
|
|
||||||
@section LICENSE
|
@section LICENSE
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
Software License Agreement (BSD License)
|
||||||
|
|
||||||
Copyright (c) 2013, hathach (tinyusb.org)
|
Copyright (c) 2013, hathach (tinyusb.org)
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
1. Redistributions of source code must retain the above copyright
|
1. Redistributions of source code must retain the above copyright
|
||||||
notice, this list of conditions and the following disclaimer.
|
notice, this list of conditions and the following disclaimer.
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
3. Neither the name of the copyright holders nor the
|
3. Neither the name of the copyright holders nor the
|
||||||
names of its contributors may be used to endorse or promote products
|
names of its contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior written permission.
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
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
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
This file is part of the tinyusb stack.
|
This file is part of the tinyusb stack.
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// INCLUDE
|
// INCLUDE
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#include "mouse_app.h"
|
#include "mouse_app.h"
|
||||||
|
|
||||||
#if TUSB_CFG_OS != TUSB_OS_NONE
|
#if TUSB_CFG_OS != TUSB_OS_NONE
|
||||||
#include "app_os_prio.h"
|
#include "app_os_prio.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TUSB_CFG_HOST_MSC
|
#if TUSB_CFG_HOST_MSC
|
||||||
|
|
||||||
#include "cli.h"
|
#include "cli.h"
|
||||||
#include "ff.h"
|
#include "ff.h"
|
||||||
#include "diskio.h"
|
#include "diskio.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO CONSTANT TYPEDEF
|
// MACRO CONSTANT TYPEDEF
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
static FATFS fatfs[TUSB_CFG_HOST_DEVICE_MAX] TUSB_CFG_ATTR_USBRAM;
|
static FATFS fatfs[TUSB_CFG_HOST_DEVICE_MAX] TUSB_CFG_ATTR_USBRAM;
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// tinyusb callback (ISR context)
|
// tinyusb callback (ISR context)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void tusbh_msc_mounted_cb(uint8_t dev_addr)
|
void tusbh_msc_mounted_cb(uint8_t dev_addr)
|
||||||
{
|
{
|
||||||
puts("\na MassStorage device is mounted");
|
puts("\na MassStorage device is mounted");
|
||||||
|
|
||||||
//------------- Disk Information -------------//
|
//------------- Disk Information -------------//
|
||||||
// SCSI VendorID[8] & ProductID[16] from Inquiry Command
|
// SCSI VendorID[8] & ProductID[16] from Inquiry Command
|
||||||
uint8_t const* p_vendor = tusbh_msc_get_vendor_name(dev_addr);
|
uint8_t const* p_vendor = tusbh_msc_get_vendor_name(dev_addr);
|
||||||
uint8_t const* p_product = tusbh_msc_get_product_name(dev_addr);
|
uint8_t const* p_product = tusbh_msc_get_product_name(dev_addr);
|
||||||
|
|
||||||
for(uint8_t i=0; i<8; i++) putchar(p_vendor[i]);
|
for(uint8_t i=0; i<8; i++) putchar(p_vendor[i]);
|
||||||
|
|
||||||
printf(" ");
|
printf(" ");
|
||||||
for(uint8_t i=0; i<16; i++) putchar(p_product[i]);
|
for(uint8_t i=0; i<16; i++) putchar(p_product[i]);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
|
|
||||||
uint32_t last_lba, block_size;
|
uint32_t last_lba, block_size;
|
||||||
tusbh_msc_get_capacity(dev_addr, &last_lba, &block_size);
|
tusbh_msc_get_capacity(dev_addr, &last_lba, &block_size);
|
||||||
printf("Disk Size: %d MB\n", (last_lba+1)/ ((1024*1024)/block_size) );
|
printf("Disk Size: %d MB\n", (last_lba+1)/ ((1024*1024)/block_size) );
|
||||||
printf("LBA 0-0x%X Block Size: %d\n", last_lba, block_size);
|
printf("LBA 0-0x%X Block Size: %d\n", last_lba, block_size);
|
||||||
|
|
||||||
//------------- file system (only 1 LUN support) -------------//
|
//------------- file system (only 1 LUN support) -------------//
|
||||||
uint8_t phy_disk = dev_addr-1;
|
uint8_t phy_disk = dev_addr-1;
|
||||||
disk_initialize(phy_disk);
|
disk_initialize(phy_disk);
|
||||||
|
|
||||||
if ( disk_is_ready(phy_disk) )
|
if ( disk_is_ready(phy_disk) )
|
||||||
{
|
{
|
||||||
if ( f_mount(phy_disk, &fatfs[phy_disk]) != FR_OK )
|
if ( f_mount(phy_disk, &fatfs[phy_disk]) != FR_OK )
|
||||||
{
|
{
|
||||||
puts("mount failed");
|
puts("mount failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts("-------------------------------------------------------------------");
|
puts("-------------------------------------------------------------------");
|
||||||
puts("- MASSSTORAGE CLASS CLI IS A IMMATURE CODE. DISK-WRITING COMMANDS -");
|
puts("- MASSSTORAGE CLASS CLI IS A IMMATURE CODE. DISK-WRITING COMMANDS -");
|
||||||
puts("- SUCH AS cp(COPY), mkdir(MAKE DIRECTORY) ARE POTENTIAL TO DAMAGE -");
|
puts("- SUCH AS cp(COPY), mkdir(MAKE DIRECTORY) ARE POTENTIAL TO DAMAGE -");
|
||||||
puts("- YOUR USB THUMBDRIVE. USING THOSE COMMANDS ARE AT YOUR OWN RISK. -");
|
puts("- YOUR USB THUMBDRIVE. USING THOSE COMMANDS ARE AT YOUR OWN RISK. -");
|
||||||
puts("- THE AUTHOR HAS NO RESPONSIBILITY WITH YOUR DEVICE NOR ITS DATA -");
|
puts("- THE AUTHOR HAS NO RESPONSIBILITY WITH YOUR DEVICE NOR ITS DATA -");
|
||||||
puts("---------------------------------------------------------------------");
|
puts("---------------------------------------------------------------------");
|
||||||
|
|
||||||
f_chdrive(phy_disk); // change to newly mounted drive
|
f_chdrive(phy_disk); // change to newly mounted drive
|
||||||
f_chdir("/"); // root as current dir
|
f_chdir("/"); // root as current dir
|
||||||
|
|
||||||
cli_init();
|
cli_init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tusbh_msc_unmounted_cb(uint8_t dev_addr)
|
void tusbh_msc_unmounted_cb(uint8_t dev_addr)
|
||||||
{
|
{
|
||||||
puts("\na MassStorage device is unmounted");
|
puts("\na MassStorage device is unmounted");
|
||||||
|
|
||||||
uint8_t phy_disk = dev_addr-1;
|
uint8_t phy_disk = dev_addr-1;
|
||||||
|
|
||||||
f_mount(phy_disk, NULL); // unmount disk
|
f_mount(phy_disk, NULL); // unmount disk
|
||||||
disk_deinitialize(phy_disk);
|
disk_deinitialize(phy_disk);
|
||||||
|
|
||||||
if ( phy_disk == f_get_current_drive() )
|
if ( phy_disk == f_get_current_drive() )
|
||||||
{ // active drive is unplugged --> change to other drive
|
{ // active drive is unplugged --> change to other drive
|
||||||
for(uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX; i++)
|
for(uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX; i++)
|
||||||
{
|
{
|
||||||
if ( disk_is_ready(i) )
|
if ( disk_is_ready(i) )
|
||||||
{
|
{
|
||||||
f_chdrive(i);
|
f_chdrive(i);
|
||||||
cli_init(); // refractor, rename
|
cli_init(); // refractor, rename
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tusbh_msc_isr(uint8_t dev_addr, tusb_event_t event, uint32_t xferred_bytes)
|
void tusbh_msc_isr(uint8_t dev_addr, tusb_event_t event, uint32_t xferred_bytes)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// IMPLEMENTATION
|
// IMPLEMENTATION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void msc_app_init(void)
|
void msc_app_init(void)
|
||||||
{
|
{
|
||||||
diskio_init();
|
diskio_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------- main task -------------//
|
//------------- main task -------------//
|
||||||
OSAL_TASK_FUNCTION( msc_app_task ) (void* p_task_para)
|
OSAL_TASK_FUNCTION( msc_app_task ) (void* p_task_para)
|
||||||
{
|
{
|
||||||
OSAL_TASK_LOOP_BEGIN
|
OSAL_TASK_LOOP_BEGIN
|
||||||
|
|
||||||
osal_task_delay(10);
|
osal_task_delay(10);
|
||||||
|
|
||||||
bool is_any_disk_mounted = false;
|
bool is_any_disk_mounted = false;
|
||||||
for(uint8_t phy_disk=0; phy_disk < TUSB_CFG_HOST_DEVICE_MAX; phy_disk++)
|
for(uint8_t phy_disk=0; phy_disk < TUSB_CFG_HOST_DEVICE_MAX; phy_disk++)
|
||||||
{
|
{
|
||||||
if ( disk_is_ready(phy_disk) )
|
if ( disk_is_ready(phy_disk) )
|
||||||
{
|
{
|
||||||
is_any_disk_mounted = true;
|
is_any_disk_mounted = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_any_disk_mounted )
|
if ( is_any_disk_mounted )
|
||||||
{
|
{
|
||||||
int ch = getchar();
|
int ch = getchar();
|
||||||
if ( ch > 0 )
|
if ( ch > 0 )
|
||||||
{
|
{
|
||||||
cli_poll( (char) ch);
|
cli_poll( (char) ch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OSAL_TASK_LOOP_END
|
OSAL_TASK_LOOP_END
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#endif
|
||||||
// dummy implementation to remove #ifdef in main.c
|
|
||||||
void msc_app_init(void) { }
|
|
||||||
OSAL_TASK_FUNCTION( msc_app_task ) (void* p_task_para)
|
|
||||||
{
|
|
||||||
OSAL_TASK_LOOP_BEGIN
|
|
||||||
OSAL_TASK_LOOP_END
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -1,71 +1,78 @@
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@file msc_app.h
|
@file msc_app.h
|
||||||
@author hathach (tinyusb.org)
|
@author hathach (tinyusb.org)
|
||||||
|
|
||||||
@section LICENSE
|
@section LICENSE
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
Software License Agreement (BSD License)
|
||||||
|
|
||||||
Copyright (c) 2013, hathach (tinyusb.org)
|
Copyright (c) 2013, hathach (tinyusb.org)
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
1. Redistributions of source code must retain the above copyright
|
1. Redistributions of source code must retain the above copyright
|
||||||
notice, this list of conditions and the following disclaimer.
|
notice, this list of conditions and the following disclaimer.
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
3. Neither the name of the copyright holders nor the
|
3. Neither the name of the copyright holders nor the
|
||||||
names of its contributors may be used to endorse or promote products
|
names of its contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior written permission.
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
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
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
This file is part of the tinyusb stack.
|
This file is part of the tinyusb stack.
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
/** \ingroup TBD
|
/** \ingroup TBD
|
||||||
* \defgroup TBD
|
* \defgroup TBD
|
||||||
* \brief TBD
|
* \brief TBD
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TUSB_MSC_APP_H_
|
#ifndef _TUSB_MSC_APP_H_
|
||||||
#define _TUSB_MSC_APP_H_
|
#define _TUSB_MSC_APP_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "boards/board.h"
|
#include "boards/board.h"
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if TUSB_CFG_HOST_MSC
|
||||||
void msc_app_init(void);
|
|
||||||
OSAL_TASK_FUNCTION( msc_app_task ) (void* p_task_para);
|
void msc_app_init(void);
|
||||||
|
OSAL_TASK_FUNCTION( msc_app_task ) (void* p_task_para);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#else
|
||||||
}
|
|
||||||
#endif
|
#define msc_app_init()
|
||||||
|
#define msc_app_task(x)
|
||||||
#endif /* _TUSB_MSC_APP_H_ */
|
|
||||||
|
#endif
|
||||||
/** @} */
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _TUSB_MSC_APP_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
@ -1,89 +1,79 @@
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@file rndis_app.c
|
@file rndis_app.c
|
||||||
@author hathach (tinyusb.org)
|
@author hathach (tinyusb.org)
|
||||||
|
|
||||||
@section LICENSE
|
@section LICENSE
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
Software License Agreement (BSD License)
|
||||||
|
|
||||||
Copyright (c) 2013, hathach (tinyusb.org)
|
Copyright (c) 2013, hathach (tinyusb.org)
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
1. Redistributions of source code must retain the above copyright
|
1. Redistributions of source code must retain the above copyright
|
||||||
notice, this list of conditions and the following disclaimer.
|
notice, this list of conditions and the following disclaimer.
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
3. Neither the name of the copyright holders nor the
|
3. Neither the name of the copyright holders nor the
|
||||||
names of its contributors may be used to endorse or promote products
|
names of its contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior written permission.
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
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
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
This file is part of the tinyusb stack.
|
This file is part of the tinyusb stack.
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#include "rndis_app.h"
|
#include "rndis_app.h"
|
||||||
|
|
||||||
#if TUSB_CFG_OS != TUSB_OS_NONE
|
#if TUSB_CFG_OS != TUSB_OS_NONE
|
||||||
#include "app_os_prio.h"
|
#include "app_os_prio.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TUSB_CFG_HOST_CDC && TUSB_CFG_HOST_CDC_RNDIS
|
#if TUSB_CFG_HOST_CDC && TUSB_CFG_HOST_CDC_RNDIS
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO CONSTANT TYPEDEF
|
// MACRO CONSTANT TYPEDEF
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void tusbh_cdc_rndis_mounted_cb(uint8_t dev_addr)
|
void tusbh_cdc_rndis_mounted_cb(uint8_t dev_addr)
|
||||||
{ // application set-up
|
{ // application set-up
|
||||||
uint8_t mac_address[6];
|
uint8_t mac_address[6];
|
||||||
|
|
||||||
printf("\nan RNDIS device is mounted\n");
|
printf("\nan RNDIS device is mounted\n");
|
||||||
tusbh_cdc_rndis_get_mac_addr(dev_addr, mac_address);
|
tusbh_cdc_rndis_get_mac_addr(dev_addr, mac_address);
|
||||||
|
|
||||||
printf("MAC Address ");
|
printf("MAC Address ");
|
||||||
for(uint8_t i=0; i<6; i++) printf("%X ", mac_address[i]);
|
for(uint8_t i=0; i<6; i++) printf("%X ", mac_address[i]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void tusbh_cdc_rndis_unmounted_cb(uint8_t dev_addr)
|
void tusbh_cdc_rndis_unmounted_cb(uint8_t dev_addr)
|
||||||
{
|
{
|
||||||
// application tear-down
|
// application tear-down
|
||||||
printf("\nan RNDIS device is unmounted\n");
|
printf("\nan RNDIS device is unmounted\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void rndis_app_init(void)
|
void rndis_app_init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OSAL_TASK_FUNCTION( rndis_app_task ) (void* p_task_para)
|
OSAL_TASK_FUNCTION( rndis_app_task ) (void* p_task_para)
|
||||||
{
|
{
|
||||||
OSAL_TASK_LOOP_BEGIN
|
OSAL_TASK_LOOP_BEGIN
|
||||||
OSAL_TASK_LOOP_END
|
OSAL_TASK_LOOP_END
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
// dummy implementation to remove #ifdef in main.c
|
|
||||||
void rndis_app_init(void) { }
|
|
||||||
OSAL_TASK_FUNCTION( rndis_app_task ) (void* p_task_para)
|
|
||||||
{
|
|
||||||
OSAL_TASK_LOOP_BEGIN
|
|
||||||
OSAL_TASK_LOOP_END
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -1,65 +1,75 @@
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@file rndis_app.h
|
@file rndis_app.h
|
||||||
@author hathach (tinyusb.org)
|
@author hathach (tinyusb.org)
|
||||||
|
|
||||||
@section LICENSE
|
@section LICENSE
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
Software License Agreement (BSD License)
|
||||||
|
|
||||||
Copyright (c) 2013, hathach (tinyusb.org)
|
Copyright (c) 2013, hathach (tinyusb.org)
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
1. Redistributions of source code must retain the above copyright
|
1. Redistributions of source code must retain the above copyright
|
||||||
notice, this list of conditions and the following disclaimer.
|
notice, this list of conditions and the following disclaimer.
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
3. Neither the name of the copyright holders nor the
|
3. Neither the name of the copyright holders nor the
|
||||||
names of its contributors may be used to endorse or promote products
|
names of its contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior written permission.
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
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
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
This file is part of the tinyusb stack.
|
This file is part of the tinyusb stack.
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
/** \ingroup TBD
|
/** \ingroup TBD
|
||||||
* \defgroup TBD
|
* \defgroup TBD
|
||||||
* \brief TBD
|
* \brief TBD
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TUSB_RNDIS_APP_H_
|
#ifndef _TUSB_RNDIS_APP_H_
|
||||||
#define _TUSB_RNDIS_APP_H_
|
#define _TUSB_RNDIS_APP_H_
|
||||||
|
|
||||||
#include "boards/board.h"
|
#include "boards/board.h"
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void rndis_app_init(void);
|
#if TUSB_CFG_HOST_CDC && TUSB_CFG_HOST_CDC_RNDIS
|
||||||
OSAL_TASK_FUNCTION( rndis_app_task ) (void* p_task_para);
|
|
||||||
|
void rndis_app_init(void);
|
||||||
#ifdef __cplusplus
|
OSAL_TASK_FUNCTION( rndis_app_task ) (void* p_task_para);
|
||||||
}
|
|
||||||
#endif
|
#else
|
||||||
|
|
||||||
#endif /* _TUSB_RNDIS_APP_H_ */
|
#define rndis_app_init()
|
||||||
|
#define rndis_app_task(x)
|
||||||
/** @} */
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _TUSB_RNDIS_APP_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
@ -1,129 +1,129 @@
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@file tusb_config.h
|
@file tusb_config.h
|
||||||
@author hathach (tinyusb.org)
|
@author hathach (tinyusb.org)
|
||||||
|
|
||||||
@section LICENSE
|
@section LICENSE
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
Software License Agreement (BSD License)
|
||||||
|
|
||||||
Copyright (c) 2013, hathach (tinyusb.org)
|
Copyright (c) 2013, hathach (tinyusb.org)
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
1. Redistributions of source code must retain the above copyright
|
1. Redistributions of source code must retain the above copyright
|
||||||
notice, this list of conditions and the following disclaimer.
|
notice, this list of conditions and the following disclaimer.
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
3. Neither the name of the copyright holders nor the
|
3. Neither the name of the copyright holders nor the
|
||||||
names of its contributors may be used to endorse or promote products
|
names of its contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior written permission.
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
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
|
INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
This file is part of the tinyusb stack.
|
This file is part of the tinyusb stack.
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \brief TBD
|
* \brief TBD
|
||||||
*
|
*
|
||||||
* \note TBD
|
* \note TBD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup TBD
|
/** \ingroup TBD
|
||||||
* \defgroup TBD
|
* \defgroup TBD
|
||||||
* \brief TBD
|
* \brief TBD
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TUSB_TUSB_CONFIG_H_
|
#ifndef _TUSB_TUSB_CONFIG_H_
|
||||||
#define _TUSB_TUSB_CONFIG_H_
|
#define _TUSB_TUSB_CONFIG_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// CONTROLLER CONFIGURATION
|
// CONTROLLER CONFIGURATION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#define TUSB_CFG_CONTROLLER0_MODE (TUSB_MODE_HOST)
|
#define TUSB_CFG_CONTROLLER0_MODE (TUSB_MODE_HOST)
|
||||||
#define TUSB_CFG_CONTROLLER1_MODE (TUSB_MODE_NONE)
|
#define TUSB_CFG_CONTROLLER1_MODE (TUSB_MODE_NONE)
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// HOST CONFIGURATION
|
// HOST CONFIGURATION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#define TUSB_CFG_HOST_DEVICE_MAX 3
|
#define TUSB_CFG_HOST_DEVICE_MAX 3
|
||||||
#define TUSB_CFG_CONFIGURATION_MAX 1
|
#define TUSB_CFG_CONFIGURATION_MAX 1
|
||||||
|
|
||||||
//------------- USBD -------------//
|
//------------- USBD -------------//
|
||||||
#define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 255
|
#define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 255
|
||||||
|
|
||||||
//------------- CLASS -------------//
|
//------------- CLASS -------------//
|
||||||
#define TUSB_CFG_HOST_HUB 1
|
#define TUSB_CFG_HOST_HUB 1
|
||||||
#define TUSB_CFG_HOST_HID_KEYBOARD 1
|
#define TUSB_CFG_HOST_HID_KEYBOARD 1
|
||||||
#define TUSB_CFG_HOST_HID_MOUSE 1
|
#define TUSB_CFG_HOST_HID_MOUSE 0
|
||||||
#define TUSB_CFG_HOST_HID_GENERIC 0
|
#define TUSB_CFG_HOST_HID_GENERIC 0
|
||||||
#define TUSB_CFG_HOST_MSC 1
|
#define TUSB_CFG_HOST_MSC 1
|
||||||
#define TUSB_CFG_HOST_CDC 0
|
#define TUSB_CFG_HOST_CDC 0
|
||||||
#define TUSB_CFG_HOST_CDC_RNDIS 0
|
#define TUSB_CFG_HOST_CDC_RNDIS 0
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// DEVICE CONFIGURATION
|
// DEVICE CONFIGURATION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
//#define TUSB_CFG_DEVICE
|
//#define TUSB_CFG_DEVICE
|
||||||
|
|
||||||
//------------- CORE/CONTROLLER -------------//
|
//------------- CORE/CONTROLLER -------------//
|
||||||
|
|
||||||
//------------- CLASS -------------//
|
//------------- CLASS -------------//
|
||||||
//#define TUSB_CFG_DEVICE_CDC
|
//#define TUSB_CFG_DEVICE_CDC
|
||||||
//#define TUSB_CFG_DEVICE_HID_KEYBOARD 1
|
//#define TUSB_CFG_DEVICE_HID_KEYBOARD 1
|
||||||
//#define TUSB_CFG_DEVICE_HID_MOUSE 1
|
//#define TUSB_CFG_DEVICE_HID_MOUSE 1
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// COMMON CONFIGURATION
|
// COMMON CONFIGURATION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
#define TUSB_CFG_DEBUG 3
|
#define TUSB_CFG_DEBUG 3
|
||||||
|
|
||||||
//#define TUSB_CFG_OS TUSB_OS_NONE // defined using eclipse build
|
//#define TUSB_CFG_OS TUSB_OS_NONE // defined using eclipse build
|
||||||
//#define TUSB_CFG_OS_TASK_PRIO
|
//#define TUSB_CFG_OS_TASK_PRIO
|
||||||
|
|
||||||
#define TUSB_CFG_OS_TICKS_PER_SECOND 1000
|
#define TUSB_CFG_OS_TICKS_PER_SECOND 1000
|
||||||
|
|
||||||
#ifdef __CODE_RED // make use of code red's support for ram region macros
|
#ifdef __CODE_RED // make use of code red's support for ram region macros
|
||||||
#if (MCU == MCU_LPC11UXX) || (MCU == MCU_LPC13UXX)
|
#if (MCU == MCU_LPC11UXX) || (MCU == MCU_LPC13UXX)
|
||||||
#define TUSB_RAM_SECTION ".data.$RAM2"
|
#define TUSB_RAM_SECTION ".data.$RAM2"
|
||||||
#elif (MCU == MCU_LPC43XX)
|
#elif (MCU == MCU_LPC43XX)
|
||||||
#define TUSB_RAM_SECTION ".data.$RAM3"
|
#define TUSB_RAM_SECTION ".data.$RAM3"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TUSB_CFG_ATTR_USBRAM __attribute__ ((section(TUSB_RAM_SECTION)))
|
#define TUSB_CFG_ATTR_USBRAM __attribute__ ((section(TUSB_RAM_SECTION)))
|
||||||
#elif defined __CC_ARM // Compiled with Keil armcc
|
#elif defined __CC_ARM // Compiled with Keil armcc
|
||||||
#define TUSB_CFG_ATTR_USBRAM
|
#define TUSB_CFG_ATTR_USBRAM
|
||||||
#elif __ICCARM__ // compiled with IAR
|
#elif __ICCARM__ // compiled with IAR
|
||||||
#define TUSB_CFG_ATTR_USBRAM @ ".ahb_sram1"
|
#define TUSB_CFG_ATTR_USBRAM @ ".ahb_sram1"
|
||||||
#else
|
#else
|
||||||
#error compiler not specified
|
#error compiler not specified
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _TUSB_TUSB_CONFIG_H_ */
|
#endif /* _TUSB_TUSB_CONFIG_H_ */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -1,49 +1,48 @@
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@file errors.c
|
@file errors.c
|
||||||
@author hathach (tinyusb.org)
|
@author hathach (tinyusb.org)
|
||||||
|
|
||||||
@section LICENSE
|
@section LICENSE
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
Software License Agreement (BSD License)
|
||||||
|
|
||||||
Copyright (c) 2013, hathach (tinyusb.org)
|
Copyright (c) 2013, hathach (tinyusb.org)
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
1. Redistributions of source code must retain the above copyright
|
1. Redistributions of source code must retain the above copyright
|
||||||
notice, this list of conditions and the following disclaimer.
|
notice, this list of conditions and the following disclaimer.
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
3. Neither the name of the copyright holders nor the
|
3. Neither the name of the copyright holders nor the
|
||||||
names of its contributors may be used to endorse or promote products
|
names of its contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior written permission.
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
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
|
INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
This file is part of the tinyusb stack.
|
This file is part of the tinyusb stack.
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
|
|
||||||
#if TUSB_CFG_DEBUG == 3
|
#if TUSB_CFG_DEBUG == 3
|
||||||
|
|
||||||
char const* const TUSB_ErrorStr[TUSB_ERROR_COUNT] =
|
char const* const TUSB_ErrorStr[TUSB_ERROR_COUNT] =
|
||||||
{
|
{
|
||||||
ERROR_TABLE(ERROR_STRING)
|
ERROR_TABLE(ERROR_STRING)
|
||||||
0
|
};
|
||||||
};
|
|
||||||
|
#endif
|
||||||
#endif
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user