Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
usbdev_stm32.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2019 Koen Zandberg
3
*
4
* This file is subject to the terms and conditions of the GNU Lesser
5
* General Public License v2.1. See the file LICENSE in the top level
6
* directory for more details.
7
*/
8
38
#ifndef USBDEV_STM32_H
39
#define USBDEV_STM32_H
40
41
#include <stdint.h>
42
#include <stdlib.h>
43
#include "
periph_cpu.h
"
44
#include "
periph/usbdev.h
"
45
46
#ifdef __cplusplus
47
extern
"C"
{
48
#endif
49
50
/* Detect the IP version based on the available register define */
51
#if defined(USB_OTG_GCCFG_NOVBUSSENS)
52
#define STM32_USB_OTG_CID_1x
53
#elif defined(USB_OTG_GCCFG_VBDEN)
54
#define STM32_USB_OTG_CID_2x
55
#else
56
#error Unknown USB peripheral version
57
#endif
58
62
#ifndef STM32_USB_OTG_BUF_SPACE
63
#define STM32_USB_OTG_BUF_SPACE USBDEV_EP_BUF_SPACE
64
#endif
65
70
#ifdef STM32_USB_OTG_CID_1x
71
#define STM32_USB_OTG_FS_NUM_EP (4)
72
#elif defined(STM32_USB_OTG_CID_2x)
73
#define STM32_USB_OTG_FS_NUM_EP (6)
74
#endif
75
80
#ifdef STM32_USB_OTG_CID_1x
81
#define STM32_USB_OTG_HS_NUM_EP (6)
82
#elif defined(STM32_USB_OTG_CID_2x)
83
#define STM32_USB_OTG_HS_NUM_EP (9)
84
#endif
85
94
#ifndef STM32_USB_OTG_FS_RX_FIFO_SIZE
95
#define STM32_USB_OTG_FS_RX_FIFO_SIZE (128U)
96
#endif
97
103
#ifndef STM32_USB_OTG_HS_RX_FIFO_SIZE
104
#define STM32_USB_OTG_HS_RX_FIFO_SIZE (512U)
105
#endif
106
110
#ifndef STM32_USB_OTG_HS_USE_DMA
111
#ifdef STM32_USB_OTG_CID_1x
112
/* FIXME: It should be possible to use DMA with the 1.x version of the *
113
* peripheral, but somehow it doesn't work. */
114
#define STM32_USB_OTG_HS_USE_DMA (0)
115
#else
116
#define STM32_USB_OTG_HS_USE_DMA (1)
117
#endif
118
#endif
119
123
typedef
struct
{
124
usbdev_t
usbdev
;
125
const
stm32_usb_otg_fshs_config_t
*
config
;
126
uint8_t buffer[
STM32_USB_OTG_BUF_SPACE
];
127
size_t
occupied
;
128
size_t
fifo_pos
;
129
usbdev_ep_t
*
in
;
130
usbdev_ep_t
*
out
;
131
bool
suspend
;
132
}
stm32_usb_otg_fshs_t
;
133
134
#ifdef __cplusplus
135
}
136
#endif
137
#endif
/* USBDEV_STM32_H */
138
stm32_usb_otg_fshs_t::suspend
bool suspend
Suspend status.
Definition:
usbdev_stm32.h:131
usbdev.h
Definitions low-level USB driver interface.
usbdev
usbdev device descriptor
Definition:
usbdev.h:217
usbdev_ep
usbdev endpoint descriptor
Definition:
usbdev.h:229
stm32_usb_otg_fshs_t::in
usbdev_ep_t * in
In endpoints.
Definition:
usbdev_stm32.h:129
stm32_usb_otg_fshs_config_t
stm32 USB OTG configuration
Definition:
periph_cpu.h:827
stm32_usb_otg_fshs_t::usbdev
usbdev_t usbdev
Inherited usbdev struct.
Definition:
usbdev_stm32.h:124
stm32_usb_otg_fshs_t::fifo_pos
size_t fifo_pos
FIFO space occupied.
Definition:
usbdev_stm32.h:128
stm32_usb_otg_fshs_t
stm32 USB OTG peripheral device context
Definition:
usbdev_stm32.h:123
STM32_USB_OTG_BUF_SPACE
#define STM32_USB_OTG_BUF_SPACE
Buffer space available for endpoint TX/RX data.
Definition:
usbdev_stm32.h:63
periph_cpu.h
Shared CPU specific definitions for the STM32 family.
stm32_usb_otg_fshs_t::config
const stm32_usb_otg_fshs_config_t * config
USB peripheral config
Definition:
usbdev_stm32.h:125
stm32_usb_otg_fshs_t::occupied
size_t occupied
Buffer space occupied.
Definition:
usbdev_stm32.h:127
stm32_usb_otg_fshs_t::out
usbdev_ep_t * out
Out endpoints.
Definition:
usbdev_stm32.h:130
Generated on Tue Nov 24 2020 19:46:50 by
1.8.17