Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/thirdpin/pastilda.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthirdpin <n_lazareva@mail.ru>2016-07-13 21:18:00 +0300
committerthirdpin <n_lazareva@mail.ru>2016-07-13 21:18:00 +0300
commitf3bc0a6b2c361c941d6cbd2700cdbaf305342cdc (patch)
tree2d7fcfd8e1fa33c8e787499e275b465cc1dbb56b
parent84ff767e27055b020d9fe5ffebcb7b5e2ace70f6 (diff)
add GPL to all files
-rw-r--r--emb/pastilda/app/app.cpp21
-rw-r--r--emb/pastilda/app/app.h21
-rw-r--r--emb/pastilda/app/leds.cpp21
-rw-r--r--emb/pastilda/app/leds.h21
-rw-r--r--emb/pastilda/app/usb_dispatcher.cpp21
-rw-r--r--emb/pastilda/app/usb_dispatcher.h21
-rw-r--r--emb/pastilda/hw/clock.h53
-rw-r--r--emb/pastilda/hw/usb_device/usbd_composite.cpp22
-rw-r--r--emb/pastilda/hw/usb_device/usbd_composite.h22
-rw-r--r--emb/pastilda/hw/usb_device/usbd_composite_desc.cpp21
-rw-r--r--emb/pastilda/hw/usb_device/usbd_composite_desc.h200
-rw-r--r--emb/pastilda/hw/usb_host/usbh_host.cpp21
-rw-r--r--emb/pastilda/hw/usb_host/usbh_host.h21
-rw-r--r--emb/pastilda/lib/libusbhost/usbh_config.h4
-rw-r--r--emb/pastilda/lib/libusbhost/usbh_driver_hid_kbd.c16
-rw-r--r--emb/pastilda/lib/libusbhost/usbh_driver_hid_kbd.h2
16 files changed, 386 insertions, 122 deletions
diff --git a/emb/pastilda/app/app.cpp b/emb/pastilda/app/app.cpp
index 851b564..68192be 100644
--- a/emb/pastilda/app/app.cpp
+++ b/emb/pastilda/app/app.cpp
@@ -1,3 +1,24 @@
+/*
+ * This file is part of the pastilda project.
+ * hosted at http://github.com/thirdpin/pastilda
+ *
+ * Copyright (C) 2016 Third Pin LLC
+ * Written by Anastasiia Lazareva <a.lazareva@thirdpin.ru>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include "app.h"
#include "stdio.h"
using namespace Application;
diff --git a/emb/pastilda/app/app.h b/emb/pastilda/app/app.h
index ef7f448..de77511 100644
--- a/emb/pastilda/app/app.h
+++ b/emb/pastilda/app/app.h
@@ -1,3 +1,24 @@
+/*
+ * This file is part of the pastilda project.
+ * hosted at http://github.com/thirdpin/pastilda
+ *
+ * Copyright (C) 2016 Third Pin LLC
+ * Written by Anastasiia Lazareva <a.lazareva@thirdpin.ru>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#ifndef APP_H
#define APP_H
diff --git a/emb/pastilda/app/leds.cpp b/emb/pastilda/app/leds.cpp
index e000c80..92907cf 100644
--- a/emb/pastilda/app/leds.cpp
+++ b/emb/pastilda/app/leds.cpp
@@ -1,3 +1,24 @@
+/*
+ * This file is part of the pastilda project.
+ * hosted at http://github.com/thirdpin/pastilda
+ *
+ * Copyright (C) 2016 Third Pin LLC
+ * Written by Anastasiia Lazareva <a.lazareva@thirdpin.ru>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include "leds.h"
using namespace LEDS_API;
diff --git a/emb/pastilda/app/leds.h b/emb/pastilda/app/leds.h
index a04600d..1bd3c74 100644
--- a/emb/pastilda/app/leds.h
+++ b/emb/pastilda/app/leds.h
@@ -1,3 +1,24 @@
+/*
+ * This file is part of the pastilda project.
+ * hosted at http://github.com/thirdpin/pastilda
+ *
+ * Copyright (C) 2016 Third Pin LLC
+ * Written by Anastasiia Lazareva <a.lazareva@thirdpin.ru>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#ifndef LEDS_API_H
#define LEDS_API_H
diff --git a/emb/pastilda/app/usb_dispatcher.cpp b/emb/pastilda/app/usb_dispatcher.cpp
index edb89e1..72614d3 100644
--- a/emb/pastilda/app/usb_dispatcher.cpp
+++ b/emb/pastilda/app/usb_dispatcher.cpp
@@ -1,3 +1,24 @@
+/*
+ * This file is part of the pastilda project.
+ * hosted at http://github.com/thirdpin/pastilda
+ *
+ * Copyright (C) 2016 Third Pin LLC
+ * Written by Anastasiia Lazareva <a.lazareva@thirdpin.ru>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include "usb_dispatcher.h"
USB_dispatcher *dispatcher_pointer;
diff --git a/emb/pastilda/app/usb_dispatcher.h b/emb/pastilda/app/usb_dispatcher.h
index ae748f5..d9d55a2 100644
--- a/emb/pastilda/app/usb_dispatcher.h
+++ b/emb/pastilda/app/usb_dispatcher.h
@@ -1,3 +1,24 @@
+/*
+ * This file is part of the pastilda project.
+ * hosted at http://github.com/thirdpin/pastilda
+ *
+ * Copyright (C) 2016 Third Pin LLC
+ * Written by Anastasiia Lazareva <a.lazareva@thirdpin.ru>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#ifndef USB_DISPATCHER_H
#define USB_DISPATCHER_H
diff --git a/emb/pastilda/hw/clock.h b/emb/pastilda/hw/clock.h
index 7cebfd2..57ea91a 100644
--- a/emb/pastilda/hw/clock.h
+++ b/emb/pastilda/hw/clock.h
@@ -1,30 +1,30 @@
+/*
+ * This file is part of the pastilda project.
+ * hosted at http://github.com/thirdpin/pastilda
+ *
+ * Copyright (C) 2016 Third Pin LLC
+ * Written by Anastasiia Lazareva <a.lazareva@thirdpin.ru>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#ifndef CLOCK_H
#define CLOCK_H
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/flash.h>
-#ifdef STM32F2
-static constexpr struct rcc_clock_scale rcc_hse_25mhz_to_hclk_120mhz =
-{
- 20 /*PLLM*/, 192 /*PLLN*/, 2 /*PLLP*/, 5 /*PLLQ*/,
- (FLASH_ACR_ICE | FLASH_ACR_DCE | FLASH_ACR_LATENCY_3WS) /*FLASH CONFIG*/,
- RCC_CFGR_HPRE_DIV_NONE /*HPRE*/,
- RCC_CFGR_PPRE_DIV_4 /*PPRE1*/, RCC_CFGR_PPRE_DIV_2 /*PPRE2*/,
- 30000000 /*APB1_FREQ*/, 60000000 /*APB2_FREQ*/
-};
-
-static constexpr struct rcc_clock_scale rcc_hse_8mhz_to_hclk_120mhz =
-{
- 8 /*PLLM*/, 120 /*PLLN*/, 2 /*PLLP*/, 5 /*PLLQ*/,
- FLASH_ACR_ICE | FLASH_ACR_DCE | FLASH_ACR_LATENCY_3WS /*FLASH CONFIG*/,
- RCC_CFGR_HPRE_DIV_NONE /*HPRE*/,
- RCC_CFGR_PPRE_DIV_4 /*PPRE1*/, RCC_CFGR_PPRE_DIV_2 /*PPRE2*/,
- 30000000 /*APB1_FREQ*/, 60000000 /*APB2_FREQ*/
-};
-#endif
-
-#ifdef STM32F4
static constexpr struct rcc_clock_scale rcc_hse_25mhz_to_hclk_120mhz =
{
15 /*PLLM*/, 144 /*PLLN*/, 2 /*PLLP*/, 5 /*PLLQ*/,
@@ -35,17 +35,6 @@ static constexpr struct rcc_clock_scale rcc_hse_25mhz_to_hclk_120mhz =
30000000 /*APB1_FREQ*/, 60000000 /*APB2_FREQ*/
};
-static constexpr struct rcc_clock_scale rcc_hse_8mhz_to_hclk_120mhz =
-{
- 4 /*PLLM*/, 120 /*PLLN*/, 2 /*PLLP*/, 5 /*PLLQ*/,
- FLASH_ACR_ICE | FLASH_ACR_DCE | FLASH_ACR_LATENCY_3WS /*FLASH CONFIG*/,
- RCC_CFGR_HPRE_DIV_NONE /*HPRE*/,
- RCC_CFGR_PPRE_DIV_4 /*PPRE1*/, RCC_CFGR_PPRE_DIV_2 /*PPRE2*/,
- 1 /*POWER SAVE*/, 120000000 /*AHB FREQ*/,
- 30000000 /*APB1_FREQ*/, 60000000 /*APB2_FREQ*/
-};
-#endif
-
static void clock_setup()
{
rcc_clock_setup_hse_3v3(&rcc_hse_25mhz_to_hclk_120mhz);
diff --git a/emb/pastilda/hw/usb_device/usbd_composite.cpp b/emb/pastilda/hw/usb_device/usbd_composite.cpp
index 2c2311a..aac38db 100644
--- a/emb/pastilda/hw/usb_device/usbd_composite.cpp
+++ b/emb/pastilda/hw/usb_device/usbd_composite.cpp
@@ -1,3 +1,24 @@
+/*
+ * This file is part of the pastilda project.
+ * hosted at http://github.com/thirdpin/pastilda
+ *
+ * Copyright (C) 2016 Third Pin LLC
+ * Written by Anastasiia Lazareva <a.lazareva@thirdpin.ru>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include "usbd_composite.h"
using namespace GPIO_CPP_Extension;
@@ -38,7 +59,6 @@ void USB_composite::usb_send_packet(const void *buf, int len)
void USB_OTG_IRQ()
{
usbd_poll(usb_pointer->my_usb_device);
- usb_pointer->last_usb_request_time = get_counter_ms();
}
int USB_composite::hid_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len,
diff --git a/emb/pastilda/hw/usb_device/usbd_composite.h b/emb/pastilda/hw/usb_device/usbd_composite.h
index b40fab8..0fa239f 100644
--- a/emb/pastilda/hw/usb_device/usbd_composite.h
+++ b/emb/pastilda/hw/usb_device/usbd_composite.h
@@ -1,3 +1,24 @@
+/*
+ * This file is part of the pastilda project.
+ * hosted at http://github.com/thirdpin/pastilda
+ *
+ * Copyright (C) 2016 Third Pin LLC
+ * Written by Anastasiia Lazareva <a.lazareva@thirdpin.ru>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#ifndef USB_MSC_H
#define USB_MSC_H
@@ -33,7 +54,6 @@ public:
uint8_t usbd_control_buffer[500];
UsbCompositeDescriptors *descriptors;
uint8_t usb_ready = 0;
- volatile uint32_t last_usb_request_time;
usbd_device *my_usb_device;
USB_composite();
diff --git a/emb/pastilda/hw/usb_device/usbd_composite_desc.cpp b/emb/pastilda/hw/usb_device/usbd_composite_desc.cpp
index cae2c24..daf025a 100644
--- a/emb/pastilda/hw/usb_device/usbd_composite_desc.cpp
+++ b/emb/pastilda/hw/usb_device/usbd_composite_desc.cpp
@@ -1,3 +1,24 @@
+/*
+ * This file is part of the pastilda project.
+ * hosted at http://github.com/thirdpin/pastilda
+ *
+ * Copyright (C) 2016 Third Pin LLC
+ * Written by Anastasiia Lazareva <a.lazareva@thirdpin.ru>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include "usbd_composite_desc.h"
constexpr uint8_t UsbCompositeDescriptors::keyboard_report_descriptor[];
diff --git a/emb/pastilda/hw/usb_device/usbd_composite_desc.h b/emb/pastilda/hw/usb_device/usbd_composite_desc.h
index d3d293f..2c09aa0 100644
--- a/emb/pastilda/hw/usb_device/usbd_composite_desc.h
+++ b/emb/pastilda/hw/usb_device/usbd_composite_desc.h
@@ -1,3 +1,24 @@
+/*
+ * This file is part of the pastilda project.
+ * hosted at http://github.com/thirdpin/pastilda
+ *
+ * Copyright (C) 2016 Third Pin LLC
+ * Written by Anastasiia Lazareva <a.lazareva@thirdpin.ru>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#ifndef USB_COMPOSITE_DESCRIPTORS
#define USB_COMPOSITE_DESCRIPTORS
@@ -15,8 +36,8 @@ typedef enum {
typedef enum : uint8_t {
E_KEYBOARD = 0x81,
- E_MASS_STORAGE_IN = 0x83,
- E_MASS_STORAGE_OUT = 0x03
+ E_MASS_STORAGE_IN = 0x83,
+ E_MASS_STORAGE_OUT = 0x03
} Endpoint;
typedef enum {
@@ -42,20 +63,27 @@ public:
static constexpr char usb_strings[][30] =
{
- "Third pin",
+ "Third Pin",
"Composite Device",
"Pastilda"
};
static constexpr struct usb_device_descriptor dev =
{
- USB_DT_DEVICE_SIZE,
- USB_DT_DEVICE,
- 0x0110,
- 0x0,
- 0x00, 0x00, 64,
- 0x0483, 0x5741, 0x0200,
- 1, 2, 3, 1
+ USB_DT_DEVICE_SIZE, //bLength
+ USB_DT_DEVICE, //bDescriptorType
+ 0x0110, //bcdUSB
+ 0x0, //bDeviceClass
+ 0x00, //bDeviceSubClass
+ 0x00, //bDeviceProtocol
+ 64, //bMaxPacketSize0
+ 0x0483, //idVendor
+ 0x5741, //idProduct
+ 0x0200, //bcdDevice
+ 1, //iManufacturer
+ 2, //iProduct
+ 3, //iSerialNumber
+ 1 //bNumConfigurations
};
typedef struct __attribute__((packed))
@@ -70,91 +98,109 @@ public:
static constexpr type_hid_function keyboard_hid_function =
{
- {
- 9,
- USB_DT_HID,
- 0x0111, 0, 1
- },
-
- {
- USB_DT_REPORT,
- sizeof(keyboard_report_descriptor)
- }
+ {
+ 9, //bLength
+ USB_DT_HID, //bDescriptorType
+ 0x0111, //bcdHID
+ 0, //bCountryCode
+ 1 //bNumDescriptors
+ },
+
+ {
+ USB_DT_REPORT,
+ sizeof(keyboard_report_descriptor)
+ }
};
static constexpr struct usb_endpoint_descriptor hid_endpoint =
{
- USB_DT_ENDPOINT_SIZE,
- USB_DT_ENDPOINT, Endpoint::E_KEYBOARD,
- USB_ENDPOINT_ATTR_INTERRUPT,
- 64, 0x20
+ USB_DT_ENDPOINT_SIZE, //bLength
+ USB_DT_ENDPOINT, //bDescriptorType
+ Endpoint::E_KEYBOARD, //bEndpointAddress
+ USB_ENDPOINT_ATTR_INTERRUPT, //bmAttributes
+ 64, //wMaxPacketSize
+ 0x20 //bInterval
};
static constexpr struct usb_endpoint_descriptor msc_endpoint[] =
{
- {
- USB_DT_ENDPOINT_SIZE,
- USB_DT_ENDPOINT,
- Endpoint::E_MASS_STORAGE_IN, USB_ENDPOINT_ATTR_BULK,
- 64, 0
- },
-
- {
- USB_DT_ENDPOINT_SIZE,
- USB_DT_ENDPOINT,
- Endpoint::E_MASS_STORAGE_OUT, USB_ENDPOINT_ATTR_BULK,
- 64, 0
- }
+ {
+ USB_DT_ENDPOINT_SIZE, //bLength
+ USB_DT_ENDPOINT, //bDescriptorType
+ Endpoint::E_MASS_STORAGE_IN, //bEndpointAddress
+ USB_ENDPOINT_ATTR_BULK, //bmAttributes
+ 64, //wMaxPacketSize
+ 0 //bInterval
+ },
+
+ {
+ USB_DT_ENDPOINT_SIZE, //bLength
+ USB_DT_ENDPOINT, //bDescriptorType
+ Endpoint::E_MASS_STORAGE_OUT, //bEndpointAddress
+ USB_ENDPOINT_ATTR_BULK, //bmAttributes
+ 64, //wMaxPacketSize
+ 0 //bInterval
+ }
};
static constexpr struct usb_interface_descriptor iface[] =
{
- {
- USB_DT_INTERFACE_SIZE,
- USB_DT_INTERFACE,
- Interface::I_KEYBOARD, 0, 1,
- USB_CLASS_HID,
- 1, 1, 0,
- &hid_endpoint, &keyboard_hid_function,
- sizeof(keyboard_hid_function)
- },
-
- {
- USB_DT_INTERFACE_SIZE,
- USB_DT_INTERFACE,
- Interface::I_MASS_STORAGE, 0, 2,
- USB_CLASS_MSC,
- USB_MSC_SUBCLASS_SCSI, USB_MSC_PROTOCOL_BBB, 0x00,
- msc_endpoint, 0, 0
- },
+ {
+ USB_DT_INTERFACE_SIZE, //bLength
+ USB_DT_INTERFACE, //bDescriptorType
+ Interface::I_KEYBOARD, //bInterfaceNumber
+ 0, //bAlternateSetting
+ 1, //bNumEndpoints
+ USB_CLASS_HID, //bInterfaceClass
+ 1, //bInterfaceSubClass
+ 1, //bInterfaceProtocol
+ 0, //iInterface
+ &hid_endpoint, &keyboard_hid_function,
+ sizeof(keyboard_hid_function)
+ },
+ {
+ USB_DT_INTERFACE_SIZE, //bLength
+ USB_DT_INTERFACE, //bDescriptorType
+ Interface::I_MASS_STORAGE, //bInterfaceNumber
+ 0, //bAlternateSetting
+ 2, //bNumEndpoints
+ USB_CLASS_MSC, //bInterfaceClass
+ USB_MSC_SUBCLASS_SCSI, //bInterfaceSubClass
+ USB_MSC_PROTOCOL_BBB, //bInterfaceProtocol
+ 0x00, //iInterface
+ msc_endpoint, 0, 0
+ },
};
- //array
+
static constexpr struct usb_config_descriptor::usb_interface ifaces[]
- {
- {
- (uint8_t *)0,
- 1,
- (usb_iface_assoc_descriptor*)0,
- &iface[Interface::I_KEYBOARD]
- },
-
- {
- (uint8_t *)0,
- 1,
- (usb_iface_assoc_descriptor*)0,
- &iface[Interface::I_MASS_STORAGE]
- },
-
- };
+ {
+ {
+ (uint8_t *)0, //cur_altsetting
+ 1, //num_altsetting
+ (usb_iface_assoc_descriptor*)0, //iface_assoc
+ &iface[Interface::I_KEYBOARD] //altsetting
+ },
+
+ {
+ (uint8_t *)0, //cur_altsetting
+ 1, //num_altsetting
+ (usb_iface_assoc_descriptor*)0, //iface_assoc
+ &iface[Interface::I_MASS_STORAGE] //altsetting
+ },
+ };
static constexpr struct usb_config_descriptor config_descr =
{
- USB_DT_CONFIGURATION_SIZE,
- USB_DT_CONFIGURATION,
- 0,
- 2, 1, 0, 0x80, 0x50,
- ifaces
+ USB_DT_CONFIGURATION_SIZE, //bLength
+ USB_DT_CONFIGURATION, //bDescriptorType
+ 0, //wTotalLength
+ 2, //bNumInterfaces
+ 1, //bConfigurationValue
+ 0, //iConfiguration
+ 0x80, //bmAttributes
+ 0x50, //bMaxPower
+ ifaces
};
UsbCompositeDescriptors() {}
diff --git a/emb/pastilda/hw/usb_host/usbh_host.cpp b/emb/pastilda/hw/usb_host/usbh_host.cpp
index 91604cc..b38a7e4 100644
--- a/emb/pastilda/hw/usb_host/usbh_host.cpp
+++ b/emb/pastilda/hw/usb_host/usbh_host.cpp
@@ -1,3 +1,24 @@
+/*
+ * This file is part of the pastilda project.
+ * hosted at http://github.com/thirdpin/pastilda
+ *
+ * Copyright (C) 2016 Third Pin LLC
+ * Written by Anastasiia Lazareva <a.lazareva@thirdpin.ru>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include "usbh_host.h"
constexpr hid_kbd_config_t USB_host::kbd_config;
diff --git a/emb/pastilda/hw/usb_host/usbh_host.h b/emb/pastilda/hw/usb_host/usbh_host.h
index 53efa89..868026b 100644
--- a/emb/pastilda/hw/usb_host/usbh_host.h
+++ b/emb/pastilda/hw/usb_host/usbh_host.h
@@ -1,3 +1,24 @@
+/*
+ * This file is part of the pastilda project.
+ * hosted at http://github.com/thirdpin/pastilda
+ *
+ * Copyright (C) 2016 Third Pin LLC
+ * Written by Anastasiia Lazareva <a.lazareva@thirdpin.ru>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#ifndef USBH_HOST_H
#define USBH_HOST_H
diff --git a/emb/pastilda/lib/libusbhost/usbh_config.h b/emb/pastilda/lib/libusbhost/usbh_config.h
index 7a7f8df..0d0f5b0 100644
--- a/emb/pastilda/lib/libusbhost/usbh_config.h
+++ b/emb/pastilda/lib/libusbhost/usbh_config.h
@@ -39,8 +39,12 @@
// MOUSE
#define USBH_HID_MOUSE_MAX_DEVICES (2)
+#define USBH_HID_KBD_MAX_DEVICES (1)
+
#define USBH_HID_MOUSE_BUFFER (32)
+#define USBH_HID_KBD_BUFFER (32)
+
// MIDI
// Maximal number of midi devices connected to whatever hub
#define USBH_AC_MIDI_MAX_DEVICES (4)
diff --git a/emb/pastilda/lib/libusbhost/usbh_driver_hid_kbd.c b/emb/pastilda/lib/libusbhost/usbh_driver_hid_kbd.c
index 010d3fa..2f68cef 100644
--- a/emb/pastilda/lib/libusbhost/usbh_driver_hid_kbd.c
+++ b/emb/pastilda/lib/libusbhost/usbh_driver_hid_kbd.c
@@ -1,9 +1,9 @@
#include "usbh_hubbed.h"
#include "usbh_device_driver.h"
#include "usbh_driver_hid_kbd.h"
-//#include "usart_helpers.h"
#include <libopencm3/usb/usbstd.h>
+#include <stdint.h>
enum STATES {
STATE_INACTIVE,
@@ -16,7 +16,7 @@ enum STATES {
struct _hid_kbd_device {
usbh_device_t *usbh_device;
- uint8_t buffer[USBH_HID_MOUSE_BUFFER];
+ uint8_t buffer[USBH_HID_KBD_BUFFER];
uint16_t endpoint_in_maxpacketsize;
uint8_t endpoint_in_address;
enum STATES state_next;
@@ -26,11 +26,9 @@ struct _hid_kbd_device {
};
typedef struct _hid_kbd_device hid_kbd_device_t;
-static hid_kbd_device_t kbd_device[USBH_HID_MOUSE_MAX_DEVICES];
+static hid_kbd_device_t kbd_device[USBH_HID_KBD_MAX_DEVICES];
static const hid_kbd_config_t *kbd_config;
-#include <stdint.h>
-
static bool initialized = false;
void hid_kbd_driver_init(const hid_kbd_config_t *config)
@@ -39,7 +37,7 @@ void hid_kbd_driver_init(const hid_kbd_config_t *config)
initialized = true;
kbd_config = config;
- for (i = 0; i < USBH_HID_MOUSE_MAX_DEVICES; i++) {
+ for (i = 0; i < USBH_HID_KBD_MAX_DEVICES; i++) {
kbd_device[i].state_next = STATE_INACTIVE;
}
}
@@ -54,7 +52,7 @@ static void *init(void *usbh_dev)
hid_kbd_device_t *drvdata = 0;
// find free data space for mouse device
- for (i = 0; i < USBH_HID_MOUSE_MAX_DEVICES; i++) {
+ for (i = 0; i < USBH_HID_KBD_MAX_DEVICES; i++) {
if (kbd_device[i].state_next == STATE_INACTIVE) {
drvdata = &kbd_device[i];
drvdata->device_id = i;
@@ -238,8 +236,8 @@ static const usbh_dev_driver_info_t driver_info = {
.idVendor = -1,
.idProduct = -1,
.ifaceClass = 0x03,
- .ifaceSubClass = 1, //-1
- .ifaceProtocol = 0x01 //0x02
+ .ifaceSubClass = 1,
+ .ifaceProtocol = 0x01
};
const usbh_dev_driver_t usbh_hid_kbd_driver = {
diff --git a/emb/pastilda/lib/libusbhost/usbh_driver_hid_kbd.h b/emb/pastilda/lib/libusbhost/usbh_driver_hid_kbd.h
index 43f29ac..a511afc 100644
--- a/emb/pastilda/lib/libusbhost/usbh_driver_hid_kbd.h
+++ b/emb/pastilda/lib/libusbhost/usbh_driver_hid_kbd.h
@@ -6,8 +6,6 @@
BEGIN_DECLS
-typedef void (*t_read_kbd)(void* data, uint8_t data_len);
-
struct _hid_kbd_config {
void (*kbd_in_message_handler)(uint8_t device_id, const uint8_t *data);
};