-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcdcacm.h
133 lines (108 loc) · 3.18 KB
/
cdcacm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/** @defgroup 09 USB USB_Group
*
* @ingroup infrastructure_apis
*
* @file cdcacm.h USB Support routines group on STM32F4 and STM32F1.
*
* @brief <b>USB Support routines group on STM32F4 and STM32F1. Header file of cdcacm.c.</b>
*
* @version 1.0.0
*
* @author @htmlonly © @endhtmlonly 2022
* Evandro Souza <[email protected]>
* @author @htmlonly © @endhtmlonly 2010
* Gareth McMullin <[email protected]>
*
* @date 01 September 2022
*
* This library supports the USB in the STM32F4 and STM32F1
* series of ARM Cortex Microcontrollers by ST Microelectronics.
*
* LGPL License Terms ref lgpl_license
*/
/*
* This file is part of the PS/2 to MSX keyboard Converter and
* MSX Keyboard Subsystem Emulator projects, based on libopencm3 project.
*
* Copyright (C) 2022 Evandro Souza <[email protected]>
*
* Based on CDCACM example of:
* Copyright (C) 2010 Gareth McMullin <[email protected]>
*
* 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/>.
*/
#if !defined CDCACM_H
#define CDCACM_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/usb/usbd.h>
#include <libopencm3/cm3/scb.h>
#include "system.h"
#include "serial.h"
#include "hr_timer.h"
#include "serial_no.h"
/**
* @brief Defines line_coding structure.
*
*/
static const struct usb_cdc_line_coding line_coding = {
.dwDTERate = 115200,
.bCharFormat = USB_CDC_1_STOP_BITS,
.bParityType = USB_CDC_NO_PARITY,
.bDataBits = 8
};
/**
* @brief Inits the cdcacm sub system.
*
*/
void cdcacm_init(void);
/**
* @brief Sets the specified endpoint to Not Acknowledge, to disables communication.
*
* @param ep endpoint with direction bit.
*/
void set_nak_endpoint(uint8_t ep);
/**
* @brief Clears the specified endpoint Not Acknowledg, to allow communication.
*
* @param ep endpoint with direction bit.
*/
void clear_nak_endpoint(uint8_t ep);
/**
* @brief Starts a communication pipe with an IN Endpoint, to allow that the USB callbacks can take control of the pipe.
*
* @param ring pointer to struct sring.
* @param ep endpoint with direction bit.
*/
void first_put_ring_content_onto_ep(struct sring* ring, uint8_t ep);
/**
* @brief Returns current usb configuration, or 0 if not configured.
*
* @returns Returns current usb configuration, or 0 if not configured.
*/
int cdcacm_get_config(void);
/**
* @brief Disables the USB to make host disconnect.
*
*/
void disable_usb(void);
#ifdef __cplusplus
}
#endif
#endif //#if !defined CDCACM_H