mirror of
https://github.com/eddyem/stm32samples.git
synced 2026-03-21 17:21:04 +03:00
starting CAN-GPIO, have a lot of errors
This commit is contained in:
69
F0:F030,F042,F072/usbcan_gpio/usb_dev.h
Normal file
69
F0:F030,F042,F072/usbcan_gpio/usb_dev.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright 2024 Edward V. Emelianov <edward.emelianoff@gmail.com>.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "usb_lib.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t dwDTERate;
|
||||
uint8_t bCharFormat;
|
||||
#define USB_CDC_1_STOP_BITS 0
|
||||
#define USB_CDC_1_5_STOP_BITS 1
|
||||
#define USB_CDC_2_STOP_BITS 2
|
||||
uint8_t bParityType;
|
||||
#define USB_CDC_NO_PARITY 0
|
||||
#define USB_CDC_ODD_PARITY 1
|
||||
#define USB_CDC_EVEN_PARITY 2
|
||||
#define USB_CDC_MARK_PARITY 3
|
||||
#define USB_CDC_SPACE_PARITY 4
|
||||
uint8_t bDataBits;
|
||||
} __attribute__ ((packed)) usb_LineCoding;
|
||||
|
||||
extern volatile uint8_t CDCready[];
|
||||
|
||||
void break_handler(uint8_t ifno);
|
||||
void clstate_handler(uint8_t ifno, uint16_t val);
|
||||
void linecoding_handler(uint8_t ifno, usb_LineCoding *lc);
|
||||
|
||||
// as ugly CDC have no BREAK after disconnected client in non-canonical mode, we should use timeout - near 2s
|
||||
#define DISCONN_TMOUT (2)
|
||||
|
||||
// sizes of ringbuffers for outgoing and incoming data
|
||||
#define RBOUTSZ (1024)
|
||||
#define RBINSZ (1024)
|
||||
|
||||
#define newline(ifno) USB_putbyte(ifno, '\n')
|
||||
#define USND(ifno, s) do{USB_sendstr(ifno, s); USB_putbyte(ifno, '\n');}while(0)
|
||||
// 'shortcuts' for files used only one interface "USBIF"
|
||||
#ifdef USBIF
|
||||
#define SEND(x) USB_sendstr(USBIF, x)
|
||||
#define RECV(b,l) USB_receivestr(USBIF, b, l)
|
||||
#define PUTCHAR(x) USB_putbyte(USBIF, x)
|
||||
#define SENDn(x) do{USB_sendstr(USBIF, x); USB_putbyte(USBIF, '\n');}while(0)
|
||||
#define NL(x) USB_putbyte(USBIF, '\n')
|
||||
#endif
|
||||
|
||||
int USB_sendbufspace(uint8_t ifno);
|
||||
int USB_sendall(uint8_t ifno);
|
||||
int USB_send(uint8_t ifno, const uint8_t *buf, int len);
|
||||
int USB_putbyte(uint8_t ifno, uint8_t byte);
|
||||
int USB_sendstr(uint8_t ifno, const char *string);
|
||||
int USB_rcvlen(uint8_t ifno);
|
||||
int USB_receive(uint8_t ifno, uint8_t *buf, int len);
|
||||
int USB_receivestr(uint8_t ifno, char *buf, int len);
|
||||
uint8_t IFconfig(uint8_t ifno, usb_LineCoding *l);
|
||||
Reference in New Issue
Block a user