libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
st_usbfs_v2.h
Go to the documentation of this file.
1/** @addtogroup usb_defines
2 */
3/*
4 * This file is part of the libopencm3 project.
5 *
6 * This library is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this library. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY !
21 * Use top-level <libopencm3/stm32/st_usbfs.h>
22 *
23 * Additional definitions for F0 devices :
24 * -F0x0 (RM0360),
25 * -F04x, F0x2, F0x8 (RM0091)
26 */
27
28/** @cond */
29#ifdef LIBOPENCM3_ST_USBFS_H
30/** @endcond */
31#ifndef LIBOPENCM3_ST_USBFS_V2_H
32#define LIBOPENCM3_ST_USBFS_V2_H
33
35
36/*****************************************************************************/
37/* Module definitions */
38/*****************************************************************************/
39
40/*****************************************************************************/
41/* Register definitions */
42/*****************************************************************************/
43
44#define USB_LPMCSR_REG (&MMIO32(USB_DEV_FS_BASE + 0x54))
45#define USB_BCDR_REG (&MMIO32(USB_DEV_FS_BASE + 0x58))
46
47/*****************************************************************************/
48/* Register values */
49/*****************************************************************************/
50
51/* --- USB control register masks / bits ----------------------------------- */
52
53#define USB_CNTR_L1REQM (1 << 7)
54#define USB_CNTR_L1RESUME (1 << 5)
55
56/* --- USB interrupt status register masks / bits -------------------------- */
57
58#define USB_ISTR_L1REQ (1 << 7)
59
60/* --- LPM control and status register USB_LPMCSR Values --------------------*/
61
62#define USB_LPMCSR_BESL_SHIFT 4
63#define USB_LPMCSR_BESL (15 << USB_LPMCSR_BESL_SHIFT)
64
65#define USB_LPMCSR_REMWAKE (1 << 3)
66#define USB_LPMCSR_LPMACK (1 << 1)
67#define USB_LPMCSR_LPMEN (1 << 0)
68
69/* --- Battery Charging Detector Values ----------------------------------------------------------*/
70
71#define USB_BCDR_DPPU (1 << 15)
72#define USB_BCDR_PS2DET (1 << 7)
73#define USB_BCDR_SDET (1 << 6)
74#define USB_BCDR_PDET (1 << 5)
75#define USB_BCDR_DCDET (1 << 4)
76#define USB_BCDR_SDEN (1 << 3)
77#define USB_BCDR_PDEN (1 << 2)
78#define USB_BCDR_DCDEN (1 << 1)
79#define USB_BCDR_BCDEN (1 << 0)
80
81/* --- USB BTABLE registers ------------------------------------------------ */
82
83#define USB_EP_TX_ADDR(ep) \
84 ((uint16_t *)(USB_PMA_BASE + (USB_GET_BTABLE + (ep) * 8 + 0) * 1))
85
86#define USB_EP_TX_COUNT(ep) \
87 ((uint16_t *)(USB_PMA_BASE + (USB_GET_BTABLE + (ep) * 8 + 2) * 1))
88
89#define USB_EP_RX_ADDR(ep) \
90 ((uint16_t *)(USB_PMA_BASE + (USB_GET_BTABLE + (ep) * 8 + 4) * 1))
91
92#define USB_EP_RX_COUNT(ep) \
93 ((uint16_t *)(USB_PMA_BASE + (USB_GET_BTABLE + (ep) * 8 + 6) * 1))
94
95/* --- USB BTABLE manipulators --------------------------------------------- */
96
97#define USB_GET_EP_TX_BUFF(ep) \
98 (USB_PMA_BASE + (uint8_t *)(USB_GET_EP_TX_ADDR(ep) * 1))
99
100#define USB_GET_EP_RX_BUFF(ep) \
101 (USB_PMA_BASE + (uint8_t *)(USB_GET_EP_RX_ADDR(ep) * 1))
102
103#endif
104/** @cond */
105#else
106#error "st_usbfs_v2.h should not be included directly, only via st_usbfs.h"
107#endif
108/** @endcond */
109