Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename USB sources from .c to .cpp to enable C++ features #763

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
8 changes: 4 additions & 4 deletions teensy4/usb.c → teensy4/usb.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "usb_dev.h"
#define USB_DESC_LIST_DEFINE
#include "usb_desc.h"
#include "core_pins.h" // for delay()
#include "usb_serial.h"
#include "usb_seremu.h"
#include "usb_rawhid.h"
Expand All @@ -12,7 +13,6 @@
#include "usb_midi.h"
#include "usb_audio.h"
#include "usb_mtp.h"
#include "core_pins.h" // for delay()
#include "avr/pgmspace.h"
#include <string.h>
#include "debug/printf.h"
Expand Down Expand Up @@ -95,13 +95,13 @@ static uint8_t sof_usage = 0;
static uint8_t usb_reboot_timer = 0;

extern uint8_t usb_descriptor_buffer[]; // defined in usb_desc.c
extern const uint8_t usb_config_descriptor_480[];
extern const uint8_t usb_config_descriptor_12[];
extern "C" const uint8_t usb_config_descriptor_480[];
extern "C" const uint8_t usb_config_descriptor_12[];

void (*usb_timer0_callback)(void) = NULL;
void (*usb_timer1_callback)(void) = NULL;

void usb_isr(void);
extern "C" void usb_isr(void);
static void endpoint0_setup(uint64_t setupdata);
static void endpoint0_transmit(const void *data, uint32_t len, int notify);
static void endpoint0_receive(void *data, uint32_t len, int notify);
Expand Down
14 changes: 7 additions & 7 deletions teensy4/usb_desc.c → teensy4/usb_desc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ static uint8_t microsoft_os_compatible_id_desc[] = {
// USB Configuration Descriptor. This huge descriptor tells all
// of the devices capabilities.

PROGMEM const uint8_t usb_config_descriptor_480[CONFIG_DESC_SIZE] = {
extern "C" PROGMEM const uint8_t usb_config_descriptor_480[CONFIG_DESC_SIZE] = {
// configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
9, // bLength;
2, // bDescriptorType;
Expand Down Expand Up @@ -1682,7 +1682,7 @@ PROGMEM const uint8_t usb_config_descriptor_480[CONFIG_DESC_SIZE] = {
};


PROGMEM const uint8_t usb_config_descriptor_12[CONFIG_DESC_SIZE] = {
extern "C" PROGMEM const uint8_t usb_config_descriptor_12[CONFIG_DESC_SIZE] = {
// configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
9, // bLength;
2, // bDescriptorType;
Expand Down Expand Up @@ -2719,9 +2719,9 @@ struct usb_string_descriptor_struct {
};
*/

extern struct usb_string_descriptor_struct usb_string_manufacturer_name
extern const struct usb_string_descriptor_struct usb_string_manufacturer_name
__attribute__ ((weak, alias("usb_string_manufacturer_name_default")));
extern struct usb_string_descriptor_struct usb_string_product_name
extern const struct usb_string_descriptor_struct usb_string_product_name
__attribute__ ((weak, alias("usb_string_product_name_default")));
extern struct usb_string_descriptor_struct usb_string_serial_number
__attribute__ ((weak, alias("usb_string_serial_number_default")));
Expand All @@ -2732,12 +2732,12 @@ PROGMEM const struct usb_string_descriptor_struct string0 = {
{0x0409}
};

PROGMEM const struct usb_string_descriptor_struct usb_string_manufacturer_name_default = {
extern "C" PROGMEM const struct usb_string_descriptor_struct usb_string_manufacturer_name_default = {
2 + MANUFACTURER_NAME_LEN * 2,
3,
MANUFACTURER_NAME
};
PROGMEM const struct usb_string_descriptor_struct usb_string_product_name_default = {
extern "C" PROGMEM const struct usb_string_descriptor_struct usb_string_product_name_default = {
2 + PRODUCT_NAME_LEN * 2,
3,
PRODUCT_NAME
Expand All @@ -2755,7 +2755,7 @@ PROGMEM const struct usb_string_descriptor_struct usb_string_mtp = {
};
#endif

void usb_init_serialnumber(void)
extern "C" void usb_init_serialnumber(void)
{
char buf[11];
uint32_t i, num;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions teensy4/usb_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ struct usb_string_descriptor_struct {
uint16_t wString[];
};

extern struct usb_string_descriptor_struct usb_string_manufacturer_name;
extern struct usb_string_descriptor_struct usb_string_product_name;
extern const struct usb_string_descriptor_struct usb_string_manufacturer_name;
extern const struct usb_string_descriptor_struct usb_string_product_name;
extern struct usb_string_descriptor_struct usb_string_serial_number;

#ifdef __cplusplus
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions teensy4/usb_seremu.c → teensy4/usb_seremu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@
*/

#include "usb_dev.h"
#include "usb_seremu.h"
#include "core_pins.h" // for yield()
#include "usb_seremu.h"
#include <string.h> // for memcpy()
#include "avr/pgmspace.h" // for PROGMEM, DMAMEM, FASTRUN
#include "debug/printf.h"
#include "core_pins.h"

#if defined(SEREMU_INTERFACE) && !defined(CDC_STATUS_INTERFACE) && !defined(CDC_DATA_INTERFACE)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.