Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions SPARK_Firmware_Driver/inc/hw_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "cc3000_common.h"
#include "usb_type.h"
#include "rgbled.h"
#include "usb_hal.h"

enum SpiBusOwner {
BUS_OWNER_NONE = 0,
Expand Down Expand Up @@ -129,18 +130,6 @@ typedef struct ServerAddress {
| FLASH_WRProt_Pages8to11 \
| FLASH_WRProt_Pages12to15 )

/* USB Config : IMR_MSK */
/* mask defining which events has to be handled */
/* by the device application software */
#define IMR_MSK (CNTR_CTRM | \
CNTR_WKUPM | \
CNTR_SUSPM | \
CNTR_ERRM | \
CNTR_SOFM | \
CNTR_ESOFM | \
CNTR_RESETM \
)

#define TIMING_IWDG_RELOAD 1000 //1sec

#define SYSTEM_US_TICKS (SystemCoreClock / 1000000)//cycles per microsecond
Expand Down
134 changes: 134 additions & 0 deletions SPARK_Firmware_Driver/inc/usb_conf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/**
******************************************************************************
* @file usb_conf.h
* @author Satish Nair
* @version V1.0.0
* @date 24-April-2013
* @brief USB CDC-HID configuration header
******************************************************************************
Copyright (c) 2013-14 Spark Labs, Inc. All rights reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
******************************************************************************
*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_CONF_H
#define __USB_CONF_H

/* Includes ------------------------------------------------------------------*/
#include "usb_hal.h"

/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/* External variables --------------------------------------------------------*/

#if !defined (SPARK_USB_SERIAL) && !defined (SPARK_USB_MOUSE) && !defined (SPARK_USB_KEYBOARD)
#define USB_CDC_ENABLE //Use USB Serial feature by default if none is defined
#elif defined (SPARK_USB_SERIAL)
#define USB_CDC_ENABLE //Enable USB CDC code
#elif defined (SPARK_USB_MOUSE) || defined (SPARK_USB_KEYBOARD)
#define USB_HID_ENABLE //Enable USB HID code
#endif

/*-------------------------------------------------------------*/
/* EP_NUM */
/* defines how many endpoints are used by the device */
/*-------------------------------------------------------------*/

#ifdef USB_CDC_ENABLE
#define EP_NUM (4)
#endif

#ifdef USB_HID_ENABLE
#define EP_NUM (2)
#endif

/*-------------------------------------------------------------*/
/* -------------- Buffer Description Table -----------------*/
/*-------------------------------------------------------------*/
/* buffer table base address */
/* buffer table base address */
#define BTABLE_ADDRESS (0x00)

#ifdef USB_CDC_ENABLE
/* EP0 */
/* rx/tx buffer base address */
#define ENDP0_RXADDR (0x40)
#define ENDP0_TXADDR (0x80)

/* EP1 */
/* tx buffer base address */
#define ENDP1_TXADDR (0xC0)
#define ENDP2_TXADDR (0x100)
#define ENDP3_RXADDR (0x110)
#endif

#ifdef USB_HID_ENABLE
/* EP0 */
/* rx/tx buffer base address */
#define ENDP0_RXADDR (0x18)
#define ENDP0_TXADDR (0x58)

/* EP1 */
/* tx buffer base address */
#define ENDP1_TXADDR (0x100)
#endif

/*-------------------------------------------------------------*/
/* ------------------- ISTR events -------------------------*/
/*-------------------------------------------------------------*/
/* IMR_MSK defined in hw_config.h */

/*#define CTR_CALLBACK*/
/*#define DOVR_CALLBACK*/
/*#define ERR_CALLBACK*/
/*#define WKUP_CALLBACK*/
/*#define SUSP_CALLBACK*/
/*#define RESET_CALLBACK*/
#ifdef USB_CDC_ENABLE
#define SOF_CALLBACK
#endif
/*#define ESOF_CALLBACK*/
/* CTR service routines */
/* associated to defined endpoints */
#ifdef USB_CDC_ENABLE
/*#define EP1_IN_Callback NOP_Process*/
#endif
#ifdef USB_HID_ENABLE
/*#define EP1_IN_Callback NOP_Process*/
#endif
#define EP2_IN_Callback NOP_Process
#define EP3_IN_Callback NOP_Process
#define EP4_IN_Callback NOP_Process
#define EP5_IN_Callback NOP_Process
#define EP6_IN_Callback NOP_Process
#define EP7_IN_Callback NOP_Process

#define EP1_OUT_Callback NOP_Process
#define EP2_OUT_Callback NOP_Process
#ifdef USB_CDC_ENABLE
/*#define EP3_OUT_Callback NOP_Process*/
#endif
#ifdef USB_HID_ENABLE
#define EP3_OUT_Callback NOP_Process
#endif
#define EP4_OUT_Callback NOP_Process
#define EP5_OUT_Callback NOP_Process
#define EP6_OUT_Callback NOP_Process
#define EP7_OUT_Callback NOP_Process

#endif /* __USB_CONF_H */
88 changes: 88 additions & 0 deletions SPARK_Firmware_Driver/inc/usb_desc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
******************************************************************************
* @file usb_desc.h
* @author Satish Nair
* @version V1.0.0
* @date 24-April-2013
* @brief Descriptor Header for USB CDC-HID Device
******************************************************************************
Copyright (c) 2013-14 Spark Labs, Inc. All rights reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
******************************************************************************
*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_DESC_H
#define __USB_DESC_H

/* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported define -----------------------------------------------------------*/
#define USB_DEVICE_DESCRIPTOR_TYPE 0x01
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
#define USB_STRING_DESCRIPTOR_TYPE 0x03
#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05

#define CDC_DATA_SIZE 64
#define CDC_INT_SIZE 8

#ifdef USB_CDC_ENABLE
#define CDC_SIZ_DEVICE_DESC 18
#define CDC_SIZ_CONFIG_DESC 67
#endif

#define HID_DESCRIPTOR_TYPE 0x21
#define HID_SIZ_HID_DESC 0x09
#define HID_OFF_HID_DESC 0x12

#ifdef USB_HID_ENABLE
#define HID_SIZ_DEVICE_DESC 18
#define HID_SIZ_CONFIG_DESC 34

#if defined (SPARK_USB_MOUSE)
#define HID_SIZ_REPORT_DESC 52
#elif defined (SPARK_USB_KEYBOARD)
#define HID_SIZ_REPORT_DESC 45
#endif
#endif

#define USB_SIZ_STRING_LANGID 4
#define USB_SIZ_STRING_VENDOR 38
#define USB_SIZ_STRING_PRODUCT 50
#define USB_SIZ_STRING_SERIAL 26

#define STANDARD_ENDPOINT_DESC_SIZE 0x09

/* Exported functions ------------------------------------------------------- */
#ifdef USB_CDC_ENABLE
extern const uint8_t CDC_DeviceDescriptor[CDC_SIZ_DEVICE_DESC];
extern const uint8_t CDC_ConfigDescriptor[CDC_SIZ_CONFIG_DESC];
#endif

#ifdef USB_HID_ENABLE
extern const uint8_t HID_DeviceDescriptor[HID_SIZ_DEVICE_DESC];
extern const uint8_t HID_ConfigDescriptor[HID_SIZ_CONFIG_DESC];
extern const uint8_t HID_ReportDescriptor[HID_SIZ_REPORT_DESC];
#endif

extern const uint8_t USB_StringLangID[USB_SIZ_STRING_LANGID];
extern const uint8_t USB_StringVendor[USB_SIZ_STRING_VENDOR];
extern const uint8_t USB_StringProduct[USB_SIZ_STRING_PRODUCT];
extern uint8_t USB_StringSerial[USB_SIZ_STRING_SERIAL];

#endif /* __USB_DESC_H */
102 changes: 102 additions & 0 deletions SPARK_Firmware_Driver/inc/usb_istr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/**
******************************************************************************
* @file usb_istr.h
* @author Satish Nair
* @version V1.0.0
* @date 24-April-2013
* @brief This file includes the peripherals header files in the user application.
******************************************************************************
Copyright (c) 2013-14 Spark Labs, Inc. All rights reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
******************************************************************************
*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_ISTR_H
#define __USB_ISTR_H

/* Includes ------------------------------------------------------------------*/
#include "usb_conf.h"

/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */

void USB_Istr(void);

/* function prototypes Automatically built defining related macros */

#ifdef USB_CDC_ENABLE
void EP1_IN_Callback(void);
#endif
#ifdef USB_HID_ENABLE
void EP1_IN_Callback(void);
#endif
void EP2_IN_Callback(void);
void EP3_IN_Callback(void);
void EP4_IN_Callback(void);
void EP5_IN_Callback(void);
void EP6_IN_Callback(void);
void EP7_IN_Callback(void);

void EP1_OUT_Callback(void);
void EP2_OUT_Callback(void);
#ifdef USB_CDC_ENABLE
void EP3_OUT_Callback(void);
#endif
#ifdef USB_HID_ENABLE
void EP3_OUT_Callback(void);
#endif
void EP4_OUT_Callback(void);
void EP5_OUT_Callback(void);
void EP6_OUT_Callback(void);
void EP7_OUT_Callback(void);

#ifdef CTR_CALLBACK
void CTR_Callback(void);
#endif

#ifdef DOVR_CALLBACK
void DOVR_Callback(void);
#endif

#ifdef ERR_CALLBACK
void ERR_Callback(void);
#endif

#ifdef WKUP_CALLBACK
void WKUP_Callback(void);
#endif

#ifdef SUSP_CALLBACK
void SUSP_Callback(void);
#endif

#ifdef RESET_CALLBACK
void RESET_Callback(void);
#endif

#ifdef SOF_CALLBACK
#ifdef USB_CDC_ENABLE
void SOF_Callback(void);
#endif
#endif

#ifdef ESOF_CALLBACK
void ESOF_Callback(void);
#endif
#endif /*__USB_ISTR_H*/

Loading