add extern "C" for cpp

start to work on hal layer
This commit is contained in:
hathach 2012-12-02 11:07:59 +07:00
parent a636d75fc6
commit b36a85ad36
10 changed files with 60 additions and 51 deletions

View File

@ -1,27 +1,27 @@
# License
Software License Agreement (BSD License)<br>
Copyright (c) 2012, hathach (tinyusb.net)<br>
All rights reserved.<br>
<pre>Software License Agreement (BSD License)
Copyright (c) 2012, hathach (tinyusb.net)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,<br>
are permitted provided that the following conditions are met:<br>
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,<br>
this list of conditions and the following disclaimer.<br>
2. Redistributions in binary form must reproduce the above copyright notice,<br>
this list of conditions and the following disclaimer in the documentation<br>
and/or other materials provided with the distribution.<br>
3. The name of the author may not be used to endorse or promote products<br>
derived from this software without specific prior written permission.<br>
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 the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED<br>
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF<br>
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT<br>
SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,<br>
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT<br>
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br>
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br>
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING<br>
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY<br>
OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE AUTHOR 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.</pre>

View File

@ -54,7 +54,7 @@
#include "arm_mx.h"
#include "LPC13Uxx.h"
#include "system_LPC13Uxx.h"
#endif /* _TUSB_ARCH_LPC134_X_H_ */

View File

@ -51,6 +51,10 @@
#ifndef _TUSB_COMMON_H_
#define _TUSB_COMMON_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include <stdbool.h>
#include <string.h>
@ -89,6 +93,10 @@
#define ASSERT_ERROR(sts) ASSERT_ERROR_MESSAGE(sts, NULL)
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_COMMON_H_ */
/** @} */

View File

@ -49,6 +49,10 @@
#ifndef _TUSB_COMPILER_GCC_H_
#define _TUSB_COMPILER_GCC_H_
#ifdef __cplusplus
extern "C" {
#endif
/// Normally, the compiler places the objects it generates in sections like data or bss & function in text. Sometimes, however, you need additional sections, or you need certain particular variables to appear in special sections, for example to map to special hardware. The section attribute specifies that a variable (or function) lives in a particular section
#define ATTR_SECTION(section) __attribute__ ((#section))
@ -117,6 +121,10 @@
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_COMPILER_GCC_H_ */
/// @}

View File

@ -49,6 +49,10 @@
#ifndef _TUSB_ERRORS_H_
#define _TUSB_ERRORS_H_
#ifdef __cplusplus
extern "C" {
#endif
/** \enum TUSB_Error_t
* \brief Error Code returned
*/
@ -60,10 +64,6 @@ typedef enum {
ERROR_COUNT
}TUSB_Error_t;
#ifdef __cplusplus
extern "C" {
#endif
/// Enum to String for debugging purposes. Only available if \ref CFG_TUSB_DEBUG_LEVEL > 0
extern char const* const TUSB_ErrorStr[];

View File

@ -51,6 +51,10 @@
#include "common/common.h"
#ifdef __cplusplus
extern "C" {
#endif
/** \struct fifo_t
* \brief Simple Circular FIFO
*/
@ -65,9 +69,6 @@ typedef struct _fifo_t
IRQn_Type irq; ///< interrupt used to lock fifo
} fifo_t;
#ifdef __cplusplus
extern "C" {
#endif
void fifo_init(fifo_t* f, uint8_t* buffer, uint16_t size, bool overwritable, IRQn_Type irq);
bool fifo_write(fifo_t* f, uint8_t data);

View File

@ -51,6 +51,9 @@
#ifndef _TUSB_DCD_H_
#define _TUSB_DCD_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "common/common.h"
@ -60,9 +63,6 @@
#define USBD_API ((*(ROM **)(0x1FFF1FF8))->pUSBD) // TODO HAL
#endif
#ifdef __cplusplus
extern "C" {
#endif
/** \brief Initialize DCD
*

View File

@ -51,12 +51,12 @@
#ifndef _TUSB_HCD_H_
#define _TUSB_HCD_H_
#include "common/common.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "common/common.h"
/** \brief Initialize HCD
*
* \param[in] para1

View File

@ -37,22 +37,6 @@
#include "tusb.h"
TUSB_Error_t hal_init()
{
// TODO usb abstract later
/* Enable AHB clock to the USB block and USB RAM. */
LPC_SYSCON->SYSAHBCLKCTRL |= ((0x1<<14) | (0x1<<27));
/* Pull-down is needed, or internally, VBUS will be floating. This is to
address the wrong status in VBUSDebouncing bit in CmdStatus register. */
LPC_IOCON->PIO0_3 &= ~0x1F;
LPC_IOCON->PIO0_3 |= (0x01<<0); /* Secondary function VBUS */
LPC_IOCON->PIO0_6 &= ~0x07;
LPC_IOCON->PIO0_6 |= (0x01<<0); /* Secondary function SoftConn */
return tERROR_NONE;
}
TUSB_Error_t tusb_init(void)
{
ASSERT_ERROR( hal_init() ) ; /* HARDWARE INIT */

View File

@ -46,6 +46,10 @@
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _TUSB_CFG_H_
#define _TUSB_CFG_H_
@ -92,6 +96,10 @@
#define CDC_NOTIFICATION_EP_MAXPACKETSIZE 8
#define CDC_DATA_EP_MAXPACKET_SIZE 16
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_CFG_H_ */
/** @} */