fix Canon managing to new USB (CDC ACM)

This commit is contained in:
2025-03-11 16:17:43 +03:00
parent f656b64eec
commit 40a22864df
24 changed files with 1412 additions and 1160 deletions

View File

@@ -1,6 +1,5 @@
/*
* This file is part of the canonmanage project.
* Copyright 2022 Edward V. Emelianov <edward.emelianoff@gmail.com>.
* Copyright 2023 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
@@ -17,17 +16,26 @@
*/
#pragma once
#ifndef RINGBUFFER_H__
#define RINGBUFFER_H__
#include "usbhw.h" // for USB_TXBUFSZ
#if defined STM32F0
#include <stm32f0.h>
#elif defined STM32F1
#include <stm32f1.h>
#elif defined STM32F3
#include <stm32f3.h>
#endif
// ring buffer size in bytes
#define RBSIZE (512)
// max reading portion size
#define BLOCKSIZE (USB_TXBUFSZ)
typedef struct{
uint8_t *data; // data buffer
const int length; // its length
int head; // head index
int tail; // tail index
volatile int busy; // == TRUE if buffer is busy now
} ringbuffer;
int RB_read(char s[BLOCKSIZE]);
int RB_write(const char *str, int l);
#endif // RINGBUFFER_H__
int RB_read(ringbuffer *b, uint8_t *s, int len);
int RB_readto(ringbuffer *b, uint8_t byte, uint8_t *s, int len);
int RB_hasbyte(ringbuffer *b, uint8_t byte);
int RB_write(ringbuffer *b, const uint8_t *str, int l);
int RB_datalen(ringbuffer *b);
int RB_clearbuf(ringbuffer *b);