termistor output to usb
This commit is contained in:
parent
34511983a8
commit
65515c7eca
4 changed files with 88 additions and 5 deletions
|
@ -9,15 +9,15 @@ VPATH = . ./$(TARGET) ./common
|
||||||
BLD = ./build/
|
BLD = ./build/
|
||||||
DFLAGS = -d
|
DFLAGS = -d
|
||||||
LFLAGS = -g
|
LFLAGS = -g
|
||||||
LDLIBS =
|
LDLIBS = -L./$(TARGET)/usbd -lusbd
|
||||||
BFLAGS = --strip-unneeded
|
BFLAGS = --strip-unneeded
|
||||||
|
|
||||||
CFLAGS = -MMD -Wall -Wno-parentheses -ggdb -fno-exceptions -ffunction-sections -fdata-sections
|
CFLAGS = -MMD -Wall -Wno-parentheses -ggdb -fno-exceptions -ffunction-sections -fdata-sections
|
||||||
CFLAGS+= -I. -I./$(TARGET) -I./common
|
CFLAGS+= -I. -I./$(TARGET) -I./$(TARGET)/usbd -I./common
|
||||||
DEL = rm -f
|
DEL = rm -f
|
||||||
|
|
||||||
# zdrojaky
|
# zdrojaky
|
||||||
OBJS = main.o usart.o adc.o hack.o
|
OBJS = main.o usb_desc.o adc.o hack.o
|
||||||
#OBJS +=
|
#OBJS +=
|
||||||
|
|
||||||
include $(TARGET)/$(TOOL).mk
|
include $(TARGET)/$(TOOL).mk
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
* Ukazuje se, že to sice funguje, ale ADC pak dost kecá - nějak mu tam to zvýšené
|
* Ukazuje se, že to sice funguje, ale ADC pak dost kecá - nějak mu tam to zvýšené
|
||||||
* napětí proniká. Stačí pak přizemnit Rx procesoru (PA3) přes odpor 1.5 až 2k a problém
|
* napětí proniká. Stačí pak přizemnit Rx procesoru (PA3) přes odpor 1.5 až 2k a problém
|
||||||
* zmizí.
|
* zmizí.
|
||||||
|
*
|
||||||
|
* 02.02.25 - výstup předělán na USB CDC (protože to jde, ne že by to mělo smysl).
|
||||||
**********************************************************************************/
|
**********************************************************************************/
|
||||||
static constexpr Pair measured [] = { // pár hodnota ADC, teplota ve °C
|
static constexpr Pair measured [] = { // pár hodnota ADC, teplota ve °C
|
||||||
{ +133.9, 125.000 },
|
{ +133.9, 125.000 },
|
||||||
|
@ -50,7 +52,7 @@ static constexpr Pair measured [] = { // pár hodnota ADC, teplota ve °C
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
static FIFO<uint32_t, FIFOLEN> termring;
|
static FIFO<uint32_t, FIFOLEN> termring;
|
||||||
static const GpioClass led (GPIOB, 8);
|
static const GpioClass led (GPIOB, 8);
|
||||||
static Usart serial (57600);
|
static cdc_class serial;
|
||||||
static RealOut cout;
|
static RealOut cout;
|
||||||
static AdcDma adc;
|
static AdcDma adc;
|
||||||
static Average avg (termring);
|
static Average avg (termring);
|
||||||
|
@ -58,6 +60,7 @@ static const SPLINE<array_size(measured)> spline (measured, false);
|
||||||
|
|
||||||
int main () {
|
int main () {
|
||||||
led << true;
|
led << true;
|
||||||
|
serial.init();
|
||||||
adc.attach(avg);
|
adc.attach(avg);
|
||||||
cout += serial;
|
cout += serial;
|
||||||
int passcnt = 0;
|
int passcnt = 0;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define MAIN_H_DEF
|
#define MAIN_H_DEF
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
#include "usart.h"
|
#include "cdc_class.h"
|
||||||
#include "adc.h"
|
#include "adc.h"
|
||||||
#include "spline.h"
|
#include "spline.h"
|
||||||
static constexpr unsigned FIFOLEN = 8u;
|
static constexpr unsigned FIFOLEN = 8u;
|
||||||
|
|
80
V203F6P6/termistor/usb_desc.cpp
Normal file
80
V203F6P6/termistor/usb_desc.cpp
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
/********************************** (C) COPYRIGHT *******************************
|
||||||
|
* File Name : usb_desc.c
|
||||||
|
* Author : WCH
|
||||||
|
* Version : V1.0.0
|
||||||
|
* Date : 2022/08/20
|
||||||
|
* Description : usb device descriptor,configuration descriptor,
|
||||||
|
* string descriptors and other descriptors.
|
||||||
|
*********************************************************************************
|
||||||
|
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||||
|
* Attention: This software (modified or not) and binary are used for
|
||||||
|
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "usb_desc.h"
|
||||||
|
|
||||||
|
/* Device Descriptor */
|
||||||
|
const uint8_t USBD_DeviceDescriptor[] =
|
||||||
|
{
|
||||||
|
0x12, // bLength
|
||||||
|
0x01, // bDescriptorType (Device)
|
||||||
|
0x10, 0x01, // bcdUSB 1.10
|
||||||
|
0x02, // bDeviceClass
|
||||||
|
0x00, // bDeviceSubClass
|
||||||
|
0x00, // bDeviceProtocol
|
||||||
|
DEF_USBD_UEP0_SIZE, // bMaxPacketSize0 64
|
||||||
|
(uint8_t)DEF_USB_VID, (uint8_t)(DEF_USB_VID >> 8), // idVendor 0x1A86
|
||||||
|
(uint8_t)DEF_USB_PID, (uint8_t)(DEF_USB_PID >> 8), // idProduct 0x5537
|
||||||
|
DEF_IC_PRG_VER, 0x00, // bcdDevice 0.01
|
||||||
|
0x01, // iManufacturer (String Index)
|
||||||
|
0x02, // iProduct (String Index)
|
||||||
|
0x03, // iSerialNumber (String Index)
|
||||||
|
0x01, // bNumConfigurations 1
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Configuration Descriptor */
|
||||||
|
const uint8_t USBD_ConfigDescriptor[] =
|
||||||
|
{
|
||||||
|
/* Configure descriptor */
|
||||||
|
0x09, 0x02, 0x43, 0x00, 0x02, 0x01, 0x00, 0x80, 0x32,
|
||||||
|
|
||||||
|
/* Interface 0 (CDC) descriptor */
|
||||||
|
0x09, 0x04, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00,
|
||||||
|
|
||||||
|
/* Functional Descriptors */
|
||||||
|
0x05, 0x24, 0x00, 0x10, 0x01,
|
||||||
|
|
||||||
|
/* Length/management descriptor (data class interface 1) */
|
||||||
|
0x05, 0x24, 0x01, 0x00, 0x01,
|
||||||
|
0x04, 0x24, 0x02, 0x02,
|
||||||
|
0x05, 0x24, 0x06, 0x00, 0x01,
|
||||||
|
|
||||||
|
/* Interrupt upload endpoint descriptor */
|
||||||
|
0x07, 0x05, 0x81, 0x03, (uint8_t)DEF_USBD_ENDP1_SIZE, (uint8_t)( DEF_USBD_ENDP1_SIZE >> 8 ), 0x01,
|
||||||
|
|
||||||
|
/* Interface 1 (data interface) descriptor */
|
||||||
|
0x09, 0x04, 0x01, 0x00, 0x02, 0x0A, 0x00, 0x00, 0x00,
|
||||||
|
|
||||||
|
/* Endpoint descriptor */
|
||||||
|
0x07, 0x05, 0x02, 0x02, (uint8_t)DEF_USBD_ENDP2_SIZE, (uint8_t)( DEF_USBD_ENDP2_SIZE >> 8 ), 0x00,
|
||||||
|
|
||||||
|
/* Endpoint descriptor */
|
||||||
|
0x07, 0x05, 0x83, 0x02, (uint8_t)DEF_USBD_ENDP3_SIZE, (uint8_t)( DEF_USBD_ENDP3_SIZE >> 8 ), 0x00,
|
||||||
|
};
|
||||||
|
#define DEF_STRDESC(p,n) w_text<(sizeof(p)>>1)>n={sizeof(n)-2u,3u,{p}}
|
||||||
|
template<const unsigned N> struct w_text {
|
||||||
|
uint8_t len, typ;
|
||||||
|
const char16_t str [N];
|
||||||
|
};
|
||||||
|
static const DEF_STRDESC((u"Kizarm Labs."), str_1);
|
||||||
|
static const DEF_STRDESC((u"USB Termistor"),str_2);
|
||||||
|
static const DEF_STRDESC((u"0001"), str_3);
|
||||||
|
/* Language Descriptor */
|
||||||
|
static const uint8_t LangDescr[] = {
|
||||||
|
0x04, 0x03, 0x09, 0x04
|
||||||
|
};
|
||||||
|
const uint8_t * USBD_StringLangID = reinterpret_cast<const uint8_t *>(LangDescr);
|
||||||
|
const uint8_t * USBD_StringVendor = reinterpret_cast<const uint8_t *>(&str_1);
|
||||||
|
const uint8_t * USBD_StringProduct = reinterpret_cast<const uint8_t *>(&str_2);
|
||||||
|
const uint8_t * USBD_StringSerial = reinterpret_cast<const uint8_t *>(&str_3);
|
||||||
|
|
Loading…
Add table
Reference in a new issue