diff --git a/F0-nolib/usbcdc/Makefile b/F0-nolib/usbcdc/Makefile index e1c0cfb..92fccb8 100644 --- a/F0-nolib/usbcdc/Makefile +++ b/F0-nolib/usbcdc/Makefile @@ -8,7 +8,7 @@ MCU = F042x6 # hardware definitions DEFS += -DUSARTNUM=1 #DEFS += -DCHECK_TMOUT -DEFS += -DEBUG +#DEFS += -DEBUG # change this linking script depending on particular MCU model, # for example, if you have STM32F103VBT6, you should write: LDSCRIPT = ld/stm32f042k.ld @@ -48,7 +48,7 @@ STARTUP = $(OBJDIR)/startup.o OBJS += $(STARTUP) DEPS := $(OBJS:.o=.d) -INC_DIR ?= ../inc +INC_DIR ?= ../../inc INCLUDE := -I$(INC_DIR)/F0 -I$(INC_DIR)/cm LIB_DIR := $(INC_DIR)/ld diff --git a/F0-nolib/usbcdc/can.c b/F0-nolib/usbcdc/can.c index 9b3d84d..43e242a 100644 --- a/F0-nolib/usbcdc/can.c +++ b/F0-nolib/usbcdc/can.c @@ -106,6 +106,7 @@ void CAN_reinit(){ } void CAN_setup(){ + uint32_t tmout = 16000000; if(CANID == 0xFFFF) readCANID(); // Configure GPIO: PB8 - CAN_Rx, PB9 - CAN_Tx /* (1) Select AF mode (10) on PB8 and PB9 */ @@ -132,16 +133,17 @@ void CAN_setup(){ CAN->MCR |= CAN_MCR_INRQ; /* (1) */ while((CAN->MSR & CAN_MSR_INAK)!=CAN_MSR_INAK) /* (2) */ { - /* add time out here for a robust application */ + if(--tmout == 0) break; } CAN->MCR &=~ CAN_MCR_SLEEP; /* (3) */ CAN->MCR |= CAN_MCR_ABOM; CAN->BTR |= 2 << 20 | 3 << 16 | 59 << 0; /* (4) */ CAN->MCR &=~ CAN_MCR_INRQ; /* (5) */ + tmout = 16000000; while((CAN->MSR & CAN_MSR_INAK)==CAN_MSR_INAK) /* (6) */ { - /* add time out here for a robust application */ + if(--tmout == 0) break; } CAN->FMR = CAN_FMR_FINIT; /* (7) */ CAN->FA1R = CAN_FA1R_FACT0; /* (8) */ diff --git a/F0-nolib/usbcdc/main.c b/F0-nolib/usbcdc/main.c index 8b59dde..a77c04c 100644 --- a/F0-nolib/usbcdc/main.c +++ b/F0-nolib/usbcdc/main.c @@ -33,11 +33,12 @@ void sys_tick_handler(void){ } void iwdg_setup(){ + uint32_t tmout = 16000000; /* Enable the peripheral clock RTC */ /* (1) Enable the LSI (40kHz) */ /* (2) Wait while it is not ready */ RCC->CSR |= RCC_CSR_LSION; /* (1) */ - while((RCC->CSR & RCC_CSR_LSIRDY) != RCC_CSR_LSIRDY); /* (2) */ + while((RCC->CSR & RCC_CSR_LSIRDY) != RCC_CSR_LSIRDY){if(--tmout == 0) break;} /* (2) */ /* Configure IWDG */ /* (1) Activate IWDG (not needed if done in option bytes) */ /* (2) Enable write access to IWDG registers */ @@ -49,7 +50,8 @@ void iwdg_setup(){ IWDG->KR = IWDG_WRITE_ACCESS; /* (2) */ IWDG->PR = IWDG_PR_PR_1; /* (3) */ IWDG->RLR = 1250; /* (4) */ - while(IWDG->SR); /* (5) */ + tmout = 16000000; + while(IWDG->SR){if(--tmout == 0) break;} /* (5) */ IWDG->KR = IWDG_REFRESH; /* (6) */ } @@ -134,6 +136,9 @@ int main(void){ printuhex(getCANID()); newline(); break; + case 'U': + USB_send("Test string for USB\n"); + break; case 'W': SEND("Wait for reboot\n"); while(1){nop();}; @@ -146,11 +151,13 @@ int main(void){ "'G' - get CAN address\n" "'R' - software reset\n" "'S' - reinit CAN (with new address)\n" + "'U' - send test string over USB\n" "'W' - test watchdog\n" ); break; } } + transmit_tbuf(); } if(L){ // text waits for sending txt[L] = 0; diff --git a/F0-nolib/usbcdc/usart.c b/F0-nolib/usbcdc/usart.c index 8e1dcab..f00f10b 100644 --- a/F0-nolib/usbcdc/usart.c +++ b/F0-nolib/usbcdc/usart.c @@ -1,4 +1,4 @@ -/*us +/* * usart.c * * Copyright 2017 Edward V. Emelianoff @@ -54,7 +54,8 @@ int usart_getline(char **line){ // transmit current tbuf and swap buffers void transmit_tbuf(){ - while(!txrdy); // wait for previos buffer transmission + uint32_t tmout = 16000000; + while(!txrdy){if(--tmout == 0) break;}; // wait for previos buffer transmission register int l = odatalen[tbufno]; if(!l) return; txrdy = 0; @@ -81,7 +82,8 @@ void usart_putchar(const char ch){ } void usart_send(const char *str){ - while(*str){ + uint32_t x = 512; + while(*str && --x){ if(odatalen[tbufno] == UARTBUFSZO) transmit_tbuf(); tbuf[tbufno][odatalen[tbufno]++] = *str++; } @@ -95,6 +97,7 @@ void newline(){ void usart_setup(){ // Nucleo's USART2 connected to VCP proxy of st-link + uint32_t tmout = 16000000; #if USARTNUM == 2 // setup pins: PA2 (Tx - AF1), PA15 (Rx - AF1) // AF mode (AF1) @@ -116,7 +119,7 @@ void usart_setup(){ USART2->BRR = 480000 / 1152; USART2->CR3 = USART_CR3_DMAT; // enable DMA Tx USART2->CR1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_UE; // 1start,8data,nstop; enable Rx,Tx,USART - while(!(USART2->ISR & USART_ISR_TC)); // polling idle frame Transmission + while(!(USART2->ISR & USART_ISR_TC)){if(--tmout == 0) break;} // polling idle frame Transmission USART2->ICR |= USART_ICR_TCCF; // clear TC flag USART2->CR1 |= USART_CR1_RXNEIE; NVIC_EnableIRQ(USART2_IRQn); @@ -140,7 +143,7 @@ void usart_setup(){ USART1->BRR = 480000 / 1152; USART1->CR3 = USART_CR3_DMAT; // enable DMA Tx USART1->CR1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_UE; // 1start,8data,nstop; enable Rx,Tx,USART - while(!(USART1->ISR & USART_ISR_TC)); // polling idle frame Transmission + while(!(USART1->ISR & USART_ISR_TC)){if(--tmout == 0) break;} // polling idle frame Transmission USART1->ICR |= USART_ICR_TCCF; // clear TC flag USART1->CR1 |= USART_CR1_RXNEIE; NVIC_EnableIRQ(USART1_IRQn); @@ -224,13 +227,26 @@ void printuhex(uint32_t val){ int i, j; for(i = 0; i < 4; ++i, --ptr){ for(j = 1; j > -1; --j){ - uint8_t half = (*ptr >> (4*j)) & 0x0f; + register uint8_t half = (*ptr >> (4*j)) & 0x0f; if(half < 10) usart_putchar(half + '0'); else usart_putchar(half - 10 + 'a'); } } } +// dump memory buffer +void hexdump(uint8_t *arr, uint16_t len){ + for(uint16_t l = 0; l < len; ++l, ++arr){ + for(int16_t j = 1; j > -1; --j){ + register uint8_t half = (*arr >> (4*j)) & 0x0f; + if(half < 10) usart_putchar(half + '0'); + else usart_putchar(half - 10 + 'a'); + } + if(l % 16 == 15) usart_putchar('\n'); + else if(l & 1) usart_putchar(' '); + } +} + #if USARTNUM == 2 void dma1_channel4_5_isr(){ if(DMA1->ISR & DMA_ISR_TCIF4){ // Tx diff --git a/F0-nolib/usbcdc/usart.h b/F0-nolib/usbcdc/usart.h index 15e9187..b717165 100644 --- a/F0-nolib/usbcdc/usart.h +++ b/F0-nolib/usbcdc/usart.h @@ -40,11 +40,6 @@ #else #define MSG(str) #endif -/* -typedef enum{ - ALL_OK, - LINE_BUSY -} TXstatus;*/ #define usartrx() (linerdy) #define usartovr() (bufovr) @@ -59,5 +54,6 @@ void newline(); void usart_putchar(const char ch); void printu(uint32_t val); void printuhex(uint32_t val); +void hexdump(uint8_t *arr, uint16_t len); #endif // __USART_H__ diff --git a/F0-nolib/usbcdc/usb.c b/F0-nolib/usbcdc/usb.c index edf2473..33ffd58 100644 --- a/F0-nolib/usbcdc/usb.c +++ b/F0-nolib/usbcdc/usb.c @@ -23,95 +23,67 @@ #include "usb.h" #include "usb_lib.h" -#ifdef EBUG #include "usart.h" -#endif -static uint8_t buffer[64]; + +static uint8_t buffer[BUFFSIZE+1]; static uint8_t len, rcvflag = 0; +// interrupt IN handler (never used?) static uint16_t EP1_Handler(ep_t ep){ - if (ep.rx_flag){ //Пришли новые данные - MSG("read\n"); + if (ep.rx_flag){ EP_Read(1, buffer); - //EP_WriteIRQ(1, buffer, ep.rx_cnt); - ep.status = SET_VALID_TX(ep.status); //TX - ep.status = KEEP_STAT_RX(ep.status); //RX оставляем в NAK + ep.status = SET_VALID_TX(ep.status); + ep.status = KEEP_STAT_RX(ep.status); } else - if (ep.tx_flag){ //Данные успешно переданы - MSG("write\n"); - ep.status = SET_VALID_RX(ep.status); //RX в VALID - ep.status = SET_STALL_TX(ep.status); //TX в STALL + if (ep.tx_flag){ + ep.status = SET_VALID_RX(ep.status); + ep.status = SET_STALL_TX(ep.status); } return ep.status; } -// write handler +// data IN/OUT handler static uint16_t EP2_Handler(ep_t ep){ if(ep.rx_flag){ - MSG("RX\n"); - if(ep.rx_cnt > 0){ - len = ep.rx_cnt; + if(ep.rx_cnt > 0 && ep.rx_cnt < BUFFSIZE){ rcvflag = 1; - EP_Read(2, buffer); + len = EP_Read(2, buffer); buffer[len] = 0; + #ifdef EBUG + MSG("read: "); + if(len) SEND((char*)buffer); + #endif } - //Так как потверждение от хоста завершает транзакцию - //то сбрасываем DTOGи + // end of transaction: clear DTOGs ep.status = CLEAR_DTOG_RX(ep.status); ep.status = CLEAR_DTOG_TX(ep.status); - //Так как мы ожидаем новый запрос от хоста, устанавливаем - //ep.status = SET_VALID_RX(ep.status); ep.status = SET_STALL_TX(ep.status); }else if (ep.tx_flag){ - MSG("TX\n"); ep.status = KEEP_STAT_TX(ep.status); - /* //Ожидаем новый запрос, или повторное чтение данных (ошибка при передаче) - //поэтому Rx и Tx в VALID - ep.status = SET_VALID_RX(ep.status); - ep.status = SET_STALL_TX(ep.status);*/ } ep.status = SET_VALID_RX(ep.status); return ep.status; } -/* -// read handler -static uint16_t EP3_Handler(ep_t ep){ - MSG("EP3 "); - if (ep.rx_flag){ //Пришли новые данные - MSG("read"); - //EP_Read(3, buffer); - ep.status = SET_VALID_TX(ep.status); //TX - ep.status = KEEP_STAT_RX(ep.status); //RX оставляем в NAK - } else - if (ep.tx_flag){ //Данные успешно переданы - MSG("write"); - ep.status = SET_STALL_TX(ep.status); - //ep.status = SET_VALID_RX(ep.status); //RX в VALID - //ep.status = SET_STALL_TX(ep.status); //TX в STALL - } - MSG("; end\n"); - return ep.status; -}*/ - void USB_setup(){ RCC->APB1ENR |= RCC_APB1ENR_CRSEN | RCC_APB1ENR_USBEN; // enable CRS (hsi48 sync) & USB RCC->CFGR3 &= ~RCC_CFGR3_USBSW; // reset USB RCC->CR2 |= RCC_CR2_HSI48ON; // turn ON HSI48 - while(!(RCC->CR2 & RCC_CR2_HSI48RDY)); + uint32_t tmout = 16000000; + while(!(RCC->CR2 & RCC_CR2_HSI48RDY)){if(--tmout == 0) break;} FLASH->ACR = FLASH_ACR_PRFTBE | FLASH_ACR_LATENCY; CRS->CFGR &= ~CRS_CFGR_SYNCSRC; CRS->CFGR |= CRS_CFGR_SYNCSRC_1; // USB SOF selected as sync source CRS->CR |= CRS_CR_AUTOTRIMEN; // enable auto trim CRS->CR |= CRS_CR_CEN; // enable freq counter & block CRS->CFGR as read-only RCC->CFGR |= RCC_CFGR_SW; - //Разрешаем прерывания по RESET и CTRM + // allow RESET and CTRM interrupts USB -> CNTR = USB_CNTR_RESETM | USB_CNTR_CTRM; - //Сбрасываем флаги + // clear flags USB -> ISTR = 0; - //Включаем подтяжку на D+ + // and activate pullup USB -> BCDR |= USB_BCDR_DPPU; NVIC_EnableIRQ(USB_IRQn); } @@ -126,20 +98,32 @@ void usb_proc(){ // first free is 64; 768 - CAN data // free: 64 128 192 256 320 384 448 512 576 640 704 // (first 192 free bytes are for EP0) - EP_Init(1, EP_TYPE_INTERRUPT, 256, 320, EP1_Handler); - EP_Init(2, EP_TYPE_BULK, 384, 448, EP2_Handler); // out - EP_Init(3, EP_TYPE_BULK, 512, 576, EP2_Handler); // in + EP_Init(1, EP_TYPE_INTERRUPT, 192, 192, EP1_Handler); + EP_Init(2, EP_TYPE_BULK, 256, 256, EP2_Handler); // OUT - receive data + EP_Init(3, EP_TYPE_BULK, 320, 320, EP2_Handler); // IN - transmit data usbON = 1; }else{ if(rcvflag){ - MSG("read: "); - if(len) SEND((char*)buffer); - SEND("\nNow write the data back\n"); - EP_Write(3, buffer, len); + /* + * don't process received data here: if it would come too fast you will loose a part + * It would be a good idea to collect incoming data in greater buffer and process it + * later (EX: echo "text" > /dev/ttyUSB1 will split into two writings! + */ rcvflag = 0; } + if(SETLINECODING()){ + SEND("got new linecoding"); + CLRLINECODING(); + } } }else{ usbON = 0; } } + +void USB_send(char *buf){ + uint16_t l = 0; + char *p = buf; + while(*p++) ++l; + EP_Write(3, (uint8_t*)buf, l); +} diff --git a/F0-nolib/usbcdc/usb.h b/F0-nolib/usbcdc/usb.h index e52aeec..c977ca4 100644 --- a/F0-nolib/usbcdc/usb.h +++ b/F0-nolib/usbcdc/usb.h @@ -26,7 +26,10 @@ #include "hardware.h" +#define BUFFSIZE (64) + void USB_setup(); void usb_proc(); +void USB_send(char *buf); #endif // __USB_H__ diff --git a/F0-nolib/usbcdc/usb_defs.h b/F0-nolib/usbcdc/usb_defs.h index 975d79d..0c86de0 100644 --- a/F0-nolib/usbcdc/usb_defs.h +++ b/F0-nolib/usbcdc/usb_defs.h @@ -1,3 +1,26 @@ +/* + * geany_encoding=koi8-r + * usb_defs.h + * + * Copyright 2018 Edward V. Emelianov + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + */ + #pragma once #ifndef __USB_DEFS_H__ #define __USB_DEFS_H__ diff --git a/F0-nolib/usbcdc/usb_lib.c b/F0-nolib/usbcdc/usb_lib.c index cb7b4e6..d4fb0b1 100644 --- a/F0-nolib/usbcdc/usb_lib.c +++ b/F0-nolib/usbcdc/usb_lib.c @@ -1,16 +1,44 @@ +/* + * geany_encoding=koi8-r + * usb_lib.c + * + * Copyright 2018 Edward V. Emelianov + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + */ + #include -#include #include "usb_lib.h" -#ifdef EBUG #include // memcpy #include "usart.h" -#endif + +#define EP0DATABUF_SIZE (64) #define DEVICE_DESCRIPTOR_SIZE_BYTE (18) #define DEVICE_QALIFIER_SIZE_BYTE (10) #define STRING_LANG_DESCRIPTOR_SIZE_BYTE (4) static usb_LineCoding lineCoding = {115200, 0, 0, 8}; +static config_pack_t setup_packet; +static uint8_t ep0databuf[EP0DATABUF_SIZE]; +static uint8_t ep0dbuflen = 0; +uint8_t setlinecoding = 0; + +usb_LineCoding getLineCoding(){return lineCoding;} const uint8_t USB_DeviceDescriptor[] = { DEVICE_DESCRIPTOR_SIZE_BYTE, // bLength @@ -66,12 +94,9 @@ const uint8_t USB_ConfigDescriptor[] = { 0x00, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ 0x03, /* bNumEndpoints: 3 endpoints used */ - //0x02, /* bInterfaceClass: Communication Interface Class */ - //0x02, /* bInterfaceSubClass: Abstract Control Model */ - //0x01, /* bInterfaceProtocol: Common AT commands */ - 0xff, - 0x00, - 0x00, + 0xff, /* bInterfaceClass */ + 0x00, /* bInterfaceSubClass */ + 0x00, /* bInterfaceProtocol */ 0x00, /* iInterface: */ /////////////////////////////////////////////////// /*Endpoint 1 Descriptor*/ @@ -79,13 +104,9 @@ const uint8_t USB_ConfigDescriptor[] = { 0x05, /* bDescriptorType: Endpoint */ 0x81, /* bEndpointAddress IN1 */ 0x03, /* bmAttributes: Interrupt */ - //0x40, /* wMaxPacketSize LO: */ - //0x00, /* wMaxPacketSize HI: */ - 0x0a, - 0x00, - //0x10, /* bInterval: */ - 0x01, - /*---------------------------------------------------------------------------*/ + 0x0a, /* wMaxPacketSize LO: */ + 0x00, /* wMaxPacketSize HI: */ + 0x01, /* bInterval: */ /*Endpoint OUT2 Descriptor*/ 0x07, /* bLength: Endpoint Descriptor size */ @@ -99,76 +120,64 @@ const uint8_t USB_ConfigDescriptor[] = { /*Endpoint IN3 Descriptor*/ 0x07, /* bLength: Endpoint Descriptor size */ 0x05, /* bDescriptorType: Endpoint */ - //0x82, /* bEndpointAddress IN2 */ - 0x83, // IN3 + 0x83, /* bEndpointAddress IN3 */ 0x02, /* bmAttributes: Bulk */ 0x40, /* wMaxPacketSize: 64 */ 0x00, 0x00, /* bInterval: ignore for Bulk transfer */ }; -#if 0 - /*Header Functional Descriptor*/ - 0x05, /* bLength: Endpoint Descriptor size */ - 0x24, /* bDescriptorType: CS_INTERFACE */ - 0x00, /* bDescriptorSubtype: Header Func Desc */ - 0x10, /* bcdCDC: spec release number */ - 0x01, - - /*Call Management Functional Descriptor*/ - 0x05, /* bFunctionLength */ - 0x24, /* bDescriptorType: CS_INTERFACE */ - 0x01, /* bDescriptorSubtype: Call Management Func Desc */ - 0x00, /* bmCapabilities: D0+D1 */ - 0x01, /* bDataInterface: 1 */ - - /*ACM Functional Descriptor*/ - 0x04, /* bFunctionLength */ - 0x24, /* bDescriptorType: CS_INTERFACE */ - 0x02, /* bDescriptorSubtype: Abstract Control Management desc */ - 0x02, /* bmCapabilities */ -#endif - const uint8_t USB_StringLangDescriptor[] = { - STRING_LANG_DESCRIPTOR_SIZE_BYTE, //bLength - 0x03, //bDescriptorType - 0x09, //wLANGID_L - 0x04 //wLANGID_H + STRING_LANG_DESCRIPTOR_SIZE_BYTE, // bLength + 0x03, // bDescriptorType + 0x09, // wLANGID_L + 0x04 // wLANGID_H }; -#define _USB_STRING_(name, str) \ -const struct name \ -{ \ - uint8_t bLength; \ - uint8_t bDescriptorType; \ - wchar_t bString[(sizeof(str) - 2) / 2]; \ - \ -} \ -name = {sizeof(name), 0x03, str}; - +// these descriptors are not used in PL2303 emulator! _USB_STRING_(USB_StringSerialDescriptor, L"0.01") _USB_STRING_(USB_StringManufacturingDescriptor, L"Russia, SAO RAS") _USB_STRING_(USB_StringProdDescriptor, L"TSYS01 sensors controller") -usb_dev_t USB_Dev; -ep_t endpoints[MAX_ENDPOINTS]; +static usb_dev_t USB_Dev; +static ep_t endpoints[MAX_ENDPOINTS]; -static void EP_Readx(uint8_t number, uint8_t *buf){ - uint32_t timeout = 100000; - uint16_t status, i; - status = USB -> EPnR[number]; - status = SET_VALID_RX(status); - status = SET_NAK_TX(status); - status = KEEP_DTOG_TX(status); - status = KEEP_DTOG_RX(status); - USB -> EPnR[number] = status; - endpoints[number].rx_flag = 0; - while (!endpoints[number].rx_flag){ - if (timeout) timeout--; - else break; - } - for (i = 0; i < endpoints[number].rx_cnt; i++){ - buf[i] = endpoints[number].rx_buf[i]; +/* + * default handlers + */ +// SET_LINE_CODING +void WEAK linecoding_handler(__attribute__((unused)) usb_LineCoding *lc){ + #ifdef EBUG + SEND("Want baudrate: "); printu(lc->dwDTERate); + SEND(", charFormat: "); printu(lc->bCharFormat); + SEND(", parityType: "); printu(lc->bParityType); + SEND(", dataBits: "); printu(lc->bDataBits); + usart_putchar('\n'); + #endif + setlinecoding = 1; +} + +// SET_CONTROL_LINE_STATE +void WEAK clstate_handler(__attribute__((unused)) uint16_t val){ + #ifdef EBUG + SEND("change state to "); + printu(val); + usart_putchar('\n'); + #endif +} + +// SEND_BREAK +void WEAK break_handler(){ + MSG("Break\n"); +} + +// handler of vendor requests +void WEAK vendor_handler(config_pack_t *packet){ + if(packet->bmRequestType & 0x80){ // read + uint8_t c = '?'; + EP_WriteIRQ(0, &c, 1); + }else{ // write ZLP + EP_WriteIRQ(0, (uint8_t *)0, 0); } } @@ -183,21 +192,25 @@ bmRequestType: 76543210 * @param ep - endpoint state * @return data written to EP0R */ -uint16_t Enumerate_Handler(ep_t ep){ - config_pack_t *packet = (config_pack_t *)ep.rx_buf; +uint16_t EP0_Handler(ep_t ep){ uint16_t status = 0; // bus powered + uint16_t epstatus = ep.status; // EP0R on input -> return this value after modifications + static uint8_t configuration = 0; // reply for GET_CONFIGURATION (==1 if configured) void wr0(const uint8_t *buf, uint16_t size){ - if(packet->wLength < size) size = packet->wLength; + if(setup_packet.wLength < size) size = setup_packet.wLength; EP_WriteIRQ(0, buf, size); } - -uint8_t _2wr = 0; - +#ifdef EBUG + uint8_t _2wr = 0; + #define WRITEDUMP(str) do{MSG(str); _2wr = 1;}while(0) +#else + #define WRITEDUMP(str) +#endif if ((ep.rx_flag) && (ep.setup_flag)){ - if (packet -> bmRequestType == 0x80){ // standard device request (device to host) - switch(packet->bRequest){ + if (setup_packet.bmRequestType == 0x80){ // standard device request (device to host) + switch(setup_packet.bRequest){ case GET_DESCRIPTOR: - switch(packet->wValue){ + switch(setup_packet.wValue){ case DEVICE_DESCRIPTOR: wr0(USB_DeviceDescriptor, sizeof(USB_DeviceDescriptor)); break; @@ -220,290 +233,250 @@ uint8_t _2wr = 0; wr0(USB_DeviceQualifierDescriptor, DEVICE_QALIFIER_SIZE_BYTE); break; default: -SEND("UNK_DES"); -_2wr = 1; + WRITEDUMP("UNK_DES"); break; } break; case GET_STATUS: EP_WriteIRQ(0, (uint8_t *)&status, 2); // send status: Bus Powered break; + case GET_CONFIGURATION: + WRITEDUMP("GET_CONFIGURATION"); + EP_WriteIRQ(0, &configuration, 1); + break; default: -SEND("80:WR_REQ"); -_2wr = 1; + WRITEDUMP("80:WR_REQ"); break; } - // , - ep.status = SET_NAK_RX(ep.status); - ep.status = SET_VALID_TX(ep.status); - }else if(packet->bmRequestType == 0x00){ // standard device request (host to device) - switch(packet->bRequest){ + epstatus = SET_NAK_RX(epstatus); + epstatus = SET_VALID_TX(epstatus); + }else if(setup_packet.bmRequestType == 0x00){ // standard device request (host to device) + switch(setup_packet.bRequest){ case SET_ADDRESS: - // DADDR , - // - USB_Dev.USB_Addr = packet -> wValue; + // new address will be assigned later - after acknowlegement or request to host + USB_Dev.USB_Addr = setup_packet.wValue; break; case SET_CONFIGURATION: - // "" + // Now device configured USB_Dev.USB_Status = USB_CONFIGURE_STATE; + configuration = setup_packet.wValue; break; default: -SEND("0:WR_REQ"); -_2wr = 1; + WRITEDUMP("0:WR_REQ"); break; } - // + // send ZLP EP_WriteIRQ(0, (uint8_t *)0, 0); - // , - ep.status = SET_NAK_RX(ep.status); - ep.status = SET_VALID_TX(ep.status); - }else if(packet -> bmRequestType == 0x02){ // standard endpoint request (host to device) - if (packet->bRequest == CLEAR_FEATURE){ - // + epstatus = SET_NAK_RX(epstatus); + epstatus = SET_VALID_TX(epstatus); + }else if(setup_packet.bmRequestType == 0x02){ // standard endpoint request (host to device) + if (setup_packet.bRequest == CLEAR_FEATURE){ + // send ZLP EP_WriteIRQ(0, (uint8_t *)0, 0); - // , - ep.status = SET_NAK_RX(ep.status); - ep.status = SET_VALID_TX(ep.status); + epstatus = SET_NAK_RX(epstatus); + epstatus = SET_VALID_TX(epstatus); }else{ -SEND("02:WR_REQ"); -_2wr = 1; + WRITEDUMP("02:WR_REQ"); } - }else if((packet->bmRequestType & VENDOR_MASK_REQUEST) == VENDOR_MASK_REQUEST){ // vendor request -SEND("vendor "); - if(packet->bmRequestType & 0x80){ // read -SEND("read: "); - uint8_t c = '?'; - EP_WriteIRQ(0, &c, 1); - }else{ // write -SEND("write: "); - EP_WriteIRQ(0, (uint8_t *)0, 0); - } -printuhex(packet->wValue); -_2wr = 1; - ep.status = SET_NAK_RX(ep.status); - ep.status = SET_VALID_TX(ep.status); - }else if((packet->bmRequestType & 0x7f) == CONTROL_REQUEST_TYPE){ // control request -_2wr = 1; - //usb_LineCoding c; - //uint8_t lbuf[10]; - //usb_cdc_notification *notif = (usb_cdc_notification*) lbuf; - switch(packet->bRequest){ + }else if((setup_packet.bmRequestType & VENDOR_MASK_REQUEST) == VENDOR_MASK_REQUEST){ // vendor request + vendor_handler(&setup_packet); + WRITEDUMP("VENDOR"); + epstatus = SET_NAK_RX(epstatus); + epstatus = SET_VALID_TX(epstatus); + }else if((setup_packet.bmRequestType & 0x7f) == CONTROL_REQUEST_TYPE){ // control request + switch(setup_packet.bRequest){ case GET_LINE_CODING: -SEND("GET_LINE_CODING"); EP_WriteIRQ(0, (uint8_t*)&lineCoding, sizeof(lineCoding)); break; case SET_LINE_CODING: -SEND("SET_LINE_CODING"); - EP_Readx(0, (uint8_t*)&lineCoding); -printuhex(lineCoding.dwDTERate); - //EP_WriteIRQ(0, (uint8_t*)&lineCoding, sizeof(lineCoding)); - //memcpy(&c, endpoints[0].rx_buf, sizeof(usb_LineCoding)); -/*SEND("len: "); -printu(endpoints[0].rx_cnt); -printu(endpoints[0].rx_buf[6]); -SEND(", want baudrate: "); printuhex(c.dwDTERate); -SEND(", charFormat: "); printu(c.bCharFormat); -SEND(", parityType: "); printu(c.bParityType); -SEND(", dataBits: "); printu(c.bDataBits);*/ break; case SET_CONTROL_LINE_STATE: -SEND("SET_CONTROL_LINE_STATE"); - /* - * This Linux cdc_acm driver requires this to be implemented - * even though it's optional in the CDC spec, and we don't - * advertise it in the ACM functional descriptor. - */ - /* We echo signals back to host as notification. * - notif->bmRequestType = CONTROL_REQUEST_TYPE | 0x80; - notif->bNotificationType = SET_LINE_CODING; - notif->wValue = 0; - notif->wIndex = 0; - notif->wLength = 2; - lbuf[8] = packet->wValue & 3; - lbuf[9] = 0; - EP_WriteIRQ(3, lbuf, 10);*/ - //EP_WriteIRQ(0, (uint8_t *)0, 0); + clstate_handler(setup_packet.wValue); break; case SEND_BREAK: -SEND("SEND_BREAK"); + break_handler(); break; default: -SEND("undef control req"); + WRITEDUMP("undef control req"); } - if((packet->bmRequestType & 0x80) == 0) EP_WriteIRQ(0, (uint8_t *)0, 0); // write acknowledgement - ep.status = SET_NAK_RX(ep.status); - ep.status = SET_VALID_TX(ep.status); + if((setup_packet.bmRequestType & 0x80) == 0) EP_WriteIRQ(0, (uint8_t *)0, 0); // write acknowledgement + epstatus = SET_VALID_RX(epstatus); + epstatus = SET_VALID_TX(epstatus); } - } else if (ep.rx_flag){ // - // - // DTOG - ep.status = CLEAR_DTOG_RX(ep.status); - ep.status = CLEAR_DTOG_TX(ep.status); - // , - ep.status = SET_VALID_RX(ep.status); - ep.status = SET_STALL_TX(ep.status); - } else if (ep.tx_flag){ // - // - if ((USB -> DADDR & USB_DADDR_ADD) != USB_Dev.USB_Addr){ - // - USB -> DADDR = USB_DADDR_EF | USB_Dev.USB_Addr; - // "" + }else if (ep.rx_flag){ // got data over EP0 or host acknowlegement + if(ep.rx_cnt){ + if(setup_packet.bRequest == SET_LINE_CODING){ + WRITEDUMP("SET_LINE_CODING"); + linecoding_handler((usb_LineCoding*)ep0databuf); + } + EP_WriteIRQ(0, (uint8_t *)0, 0); + } + // Close transaction + epstatus = CLEAR_DTOG_RX(epstatus); + epstatus = CLEAR_DTOG_TX(epstatus); + // wait for new data from host + epstatus = SET_VALID_RX(epstatus); + epstatus = SET_STALL_TX(epstatus); + } else if (ep.tx_flag){ // package transmitted + // now we can change address after enumeration + if ((USB->DADDR & USB_DADDR_ADD) != USB_Dev.USB_Addr){ + USB->DADDR = USB_DADDR_EF | USB_Dev.USB_Addr; + // change state to ADRESSED USB_Dev.USB_Status = USB_ADRESSED_STATE; } - // , DTOG - ep.status = CLEAR_DTOG_RX(ep.status); - ep.status = CLEAR_DTOG_TX(ep.status); - // , ( ) - // Rx Tx VALID - ep.status = SET_VALID_RX(ep.status); - ep.status = SET_VALID_TX(ep.status); + // end of transaction + epstatus = CLEAR_DTOG_RX(epstatus); + epstatus = CLEAR_DTOG_TX(epstatus); + epstatus = SET_VALID_RX(epstatus); + epstatus = SET_VALID_TX(epstatus); } -if(_2wr){ - usart_putchar(' '); - if (ep.rx_flag) usart_putchar('r'); - else usart_putchar('t'); - printu(packet->wLength); - if(ep.setup_flag) usart_putchar('s'); - usart_putchar(' '); - usart_putchar('R'); - printu(packet->bRequest); - usart_putchar('V'); - printu(packet->wValue); - usart_putchar('T'); - printu(packet->bmRequestType); - usart_putchar('\n'); -} - // ep.status EPnR - // - return ep.status; +#ifdef EBUG + if(_2wr){ + usart_putchar(' '); + if (ep.rx_flag) usart_putchar('r'); + else usart_putchar('t'); + printu(setup_packet.wLength); + if(ep.setup_flag) usart_putchar('s'); + usart_putchar(' '); + usart_putchar('I'); + printu(setup_packet.wIndex); + usart_putchar('V'); + printu(setup_packet.wValue); + usart_putchar('R'); + printu(setup_packet.bRequest); + usart_putchar('T'); + printu(setup_packet.bmRequestType); + usart_putchar(' '); + usart_putchar('0' + ep0dbuflen); + usart_putchar(' '); + hexdump(ep0databuf, ep0dbuflen); + usart_putchar('\n'); + } +#endif + return epstatus; } -/* - * - * number - (0...7) - * type - (EP_TYPE_BULK, EP_TYPE_CONTROL, EP_TYPE_ISO, EP_TYPE_INTERRUPT) - * addr_tx - USB - * addr_rx - USB - * - 64 - * uint16_t (*func)(ep_t *ep) - () +/** + * Endpoint initialisation, size of input buffer fixed to 64 bytes + * @param number - EP num (0...7) + * @param type - EP type (EP_TYPE_BULK, EP_TYPE_CONTROL, EP_TYPE_ISO, EP_TYPE_INTERRUPT) + * @param addr_tx - transmission buffer address @ USB/CAN buffer + * @param addr_rx - reception buffer address @ USB/CAN buffer + * @param uint16_t (*func)(ep_t *ep) - EP handler function */ void EP_Init(uint8_t number, uint8_t type, uint16_t addr_tx, uint16_t addr_rx, uint16_t (*func)(ep_t ep)){ - USB -> EPnR[number] = (type << 9) | (number & USB_EPnR_EA); - USB -> EPnR[number] ^= USB_EPnR_STAT_RX | USB_EPnR_STAT_TX_1; - USB_BTABLE -> EP[number].USB_ADDR_TX = addr_tx; - USB_BTABLE -> EP[number].USB_COUNT_TX = 0; - USB_BTABLE -> EP[number].USB_ADDR_RX = addr_rx; - USB_BTABLE -> EP[number].USB_COUNT_RX = 0x8400; // buffer size (64 bytes): Table127 of RM: BL_SIZE=1, NUM_BLOCK=1 + USB->EPnR[number] = (type << 9) | (number & USB_EPnR_EA); + USB->EPnR[number] ^= USB_EPnR_STAT_RX | USB_EPnR_STAT_TX_1; + USB_BTABLE->EP[number].USB_ADDR_TX = addr_tx; + USB_BTABLE->EP[number].USB_COUNT_TX = 0; + USB_BTABLE->EP[number].USB_ADDR_RX = addr_rx; + USB_BTABLE->EP[number].USB_COUNT_RX = 0x8400; // buffer size (64 bytes): Table127 of RM: BL_SIZE=1, NUM_BLOCK=1 endpoints[number].func = func; endpoints[number].tx_buf = (uint16_t *)(USB_BTABLE_BASE + addr_tx); endpoints[number].rx_buf = (uint8_t *)(USB_BTABLE_BASE + addr_rx); } -// USB +// standard IRQ handler void usb_isr(){ uint8_t n; - if (USB -> ISTR & USB_ISTR_RESET){ + if (USB->ISTR & USB_ISTR_RESET){ // Reinit registers - USB -> CNTR = USB_CNTR_RESETM | USB_CNTR_CTRM; - USB -> ISTR = 0; - // Endpoint 0 - CONTROL (128 bytes for TX and 64 for RX) - EP_Init(0, EP_TYPE_CONTROL, 64, 192, Enumerate_Handler); - // - USB -> DADDR = USB_DADDR_EF; - // DEFAULT ( ) + USB->CNTR = USB_CNTR_RESETM | USB_CNTR_CTRM; + USB->ISTR = 0; + // Endpoint 0 - CONTROL + EP_Init(0, EP_TYPE_CONTROL, 64, 128, EP0_Handler); + // clear address, leave only enable bit + USB->DADDR = USB_DADDR_EF; + // state is default - wait for enumeration USB_Dev.USB_Status = USB_DEFAULT_STATE; } - if (USB -> ISTR & USB_ISTR_CTR){ - // , - n = USB -> ISTR & USB_ISTR_EPID; - // - endpoints[n].rx_cnt = USB_BTABLE -> EP[n].USB_COUNT_RX; - // EPnR - endpoints[n].status = USB -> EPnR[n]; - // - endpoints[n].rx_flag = 0; - endpoints[n].tx_flag = 0; - endpoints[n].setup_flag = 0; - // - if (endpoints[n].status & USB_EPnR_CTR_RX) endpoints[n].rx_flag = 1; - if (endpoints[n].status & USB_EPnR_SETUP) endpoints[n].setup_flag = 1; - if (endpoints[n].status & USB_EPnR_CTR_TX) endpoints[n].tx_flag = 1; - // - - // EPnR - endpoints[n].status = endpoints[n].func(endpoints[n]); - // DTOG - endpoints[n].status = KEEP_DTOG_TX(endpoints[n].status); - endpoints[n].status = KEEP_DTOG_RX(endpoints[n].status); - // - endpoints[n].status = CLEAR_CTR_RX(endpoints[n].status); - endpoints[n].status = CLEAR_CTR_TX(endpoints[n].status); - USB -> EPnR[n] = endpoints[n].status; + while(USB->ISTR & USB_ISTR_CTR){ + // EP number + n = USB->ISTR & USB_ISTR_EPID; + // copy status register + uint16_t epstatus = USB->EPnR[n]; + // Calculate flags + endpoints[n].rx_flag = (epstatus & USB_EPnR_CTR_RX) ? 1 : 0; + endpoints[n].setup_flag = (epstatus & USB_EPnR_SETUP) ? 1 : 0; + endpoints[n].tx_flag = (epstatus & USB_EPnR_CTR_TX) ? 1 : 0; + // copy received bytes amount + endpoints[n].rx_cnt = USB_BTABLE->EP[n].USB_COUNT_RX; + // check direction + if(USB->ISTR & USB_ISTR_DIR){ // OUT interrupt - receive data, CTR_RX==1 (if CTR_TX == 1 - two pending transactions: receive following by transmit) + if(n == 0){ // control endpoint + if(epstatus & USB_EPnR_SETUP){ // setup packet -> copy data to conf_pack + memcpy(&setup_packet, endpoints[0].rx_buf, sizeof(setup_packet)); + ep0dbuflen = 0; + // interrupt handler will be called later + }else if(epstatus & USB_EPnR_CTR_RX){ // data packet -> push received data to ep0databuf + ep0dbuflen = endpoints[0].rx_cnt; + memcpy(ep0databuf, endpoints[0].rx_buf, ep0dbuflen); + } + } + }else{ // IN interrupt - transmit data, only CTR_TX == 1 + // enumeration end could be here (if EP0) + } + // prepare status field for EP handler + endpoints[n].status = epstatus; + // call EP handler (even if it will change EPnR, it should return new status) + epstatus = endpoints[n].func(endpoints[n]); + // keep DTOG state + epstatus = KEEP_DTOG_TX(epstatus); + epstatus = KEEP_DTOG_RX(epstatus); + // clear all RX/TX flags + epstatus = CLEAR_CTR_RX(epstatus); + epstatus = CLEAR_CTR_TX(epstatus); + // refresh EPnR + USB->EPnR[n] = epstatus; + USB_BTABLE->EP[n].USB_COUNT_RX = 0x8400; } } -/* - * ( ) - * number - - * *buf - - * size - + +/** + * Write data to EP buffer (called from IRQ handler) + * @param number - EP number + * @param *buf - array with data + * @param size - its size */ void EP_WriteIRQ(uint8_t number, const uint8_t *buf, uint16_t size){ uint8_t i; -/* - * - * - USB/CAN SRAM 8- - * 16-, - * 2, , 2 + 1 - */ - uint16_t temp = (size & 0x0001) ? (size + 1) / 2 : size / 2; + uint16_t N2 = (size + 1) >> 1; + // the buffer is 16-bit, so we should copy data as it would be uint16_t uint16_t *buf16 = (uint16_t *)buf; - for (i = 0; i < temp; i++){ + for (i = 0; i < N2; i++){ endpoints[number].tx_buf[i] = buf16[i]; } - // - USB_BTABLE -> EP[number].USB_COUNT_TX = size; + USB_BTABLE->EP[number].USB_COUNT_TX = size; } -/* - * ( ) - * number - - * *buf - - * size - + +/** + * Write data to EP buffer (called outside IRQ handler) + * @param number - EP number + * @param *buf - array with data + * @param size - its size */ void EP_Write(uint8_t number, const uint8_t *buf, uint16_t size){ - uint8_t i; - uint16_t status = USB -> EPnR[number]; -/* - * - * - USB/CAN SRAM 8- - * 16-, - * 2, , 2 + 1 - */ - uint16_t temp = (size & 0x0001) ? (size + 1) / 2 : size / 2; - uint16_t *buf16 = (uint16_t *)buf; - for (i = 0; i < temp; i++){ - endpoints[number].tx_buf[i] = buf16[i]; - } - // - USB_BTABLE -> EP[number].USB_COUNT_TX = size; - - status = SET_NAK_RX(status); //RX NAK - status = SET_VALID_TX(status); //TX VALID + uint16_t status = USB->EPnR[number]; + EP_WriteIRQ(number, buf, size); + status = SET_NAK_RX(status); + status = SET_VALID_TX(status); status = KEEP_DTOG_TX(status); status = KEEP_DTOG_RX(status); - USB -> EPnR[number] = status; + USB->EPnR[number] = status; } /* - * - * number - - * *buf - + * Copy data from EP buffer into user buffer area + * @param *buf - user array for data + * @return amount of data read */ -void EP_Read(uint8_t number, uint8_t *buf){ - uint16_t i; - for (i = 0; i < endpoints[number].rx_cnt; i++){ - buf[i] = endpoints[number].rx_buf[i]; - } +int EP_Read(uint8_t number, uint8_t *buf){ + int i = endpoints[number].rx_cnt; + if(i) memcpy(buf, endpoints[number].rx_buf, i); + return i; } -// USB + +// USB status uint8_t USB_GetState(){ return USB_Dev.USB_Status; } diff --git a/F0-nolib/usbcdc/usb_lib.h b/F0-nolib/usbcdc/usb_lib.h index 605e421..50c2cf7 100644 --- a/F0-nolib/usbcdc/usb_lib.h +++ b/F0-nolib/usbcdc/usb_lib.h @@ -1,27 +1,51 @@ +/* + * geany_encoding=koi8-r + * usb_lib.h + * + * Copyright 2018 Edward V. Emelianov + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + */ + #pragma once #ifndef __USB_LIB_H__ #define __USB_LIB_H__ +#include #include "usb_defs.h" -// +// Max EP amount (EP0 + other used) #define MAX_ENDPOINTS 4 // bRequest, standard; for bmRequestType == 0x80 #define GET_STATUS 0x00 #define GET_DESCRIPTOR 0x06 -#define GET_CONFIGURATION 0x08 // +#define GET_CONFIGURATION 0x08 // for bmRequestType == 0 #define CLEAR_FEATURE 0x01 -#define SET_FEATURE 0x03 // +#define SET_FEATURE 0x03 // unused #define SET_ADDRESS 0x05 -#define SET_DESCRIPTOR 0x07 // +#define SET_DESCRIPTOR 0x07 // unused #define SET_CONFIGURATION 0x09 // for bmRequestType == 0x81, 1 or 0xB2 -#define GET_INTERFACE 0x0A // -#define SET_INTERFACE 0x0B // -#define SYNC_FRAME 0x0C // +#define GET_INTERFACE 0x0A // unused +#define SET_INTERFACE 0x0B // unused +#define SYNC_FRAME 0x0C // unused -// vendor +// vendor requests #define VENDOR_MASK_REQUEST 0x40 #define VENDOR_READ_REQUEST_TYPE 0xc0 #define VENDOR_WRITE_REQUEST_TYPE 0x40 @@ -30,38 +54,19 @@ #define CONTROL_REQUEST_TYPE 0x21 // Class-Specific Control Requests -#define SEND_ENCAPSULATED_COMMAND 0x00 -#define GET_ENCAPSULATED_RESPONSE 0x01 -#define SET_COMM_FEATURE 0x02 -#define GET_COMM_FEATURE 0x03 -#define CLEAR_COMM_FEATURE 0x04 -#define SET_LINE_CODING 0x20 -#define GET_LINE_CODING 0x21 -#define SET_CONTROL_LINE_STATE 0x22 -#define SEND_BREAK 0x23 +#define SEND_ENCAPSULATED_COMMAND 0x00 +#define GET_ENCAPSULATED_RESPONSE 0x01 +#define SET_COMM_FEATURE 0x02 +#define GET_COMM_FEATURE 0x03 +#define CLEAR_COMM_FEATURE 0x04 +#define SET_LINE_CODING 0x20 +#define GET_LINE_CODING 0x21 +#define SET_CONTROL_LINE_STATE 0x22 +#define SEND_BREAK 0x23 // control line states -#define CONTROL_DTR 0x01 -#define CONTROL_RTS 0x02 - -/* Line Coding Structure from CDC spec 6.2.13 -struct usb_cdc_line_coding { - __le32 dwDTERate; - __u8 bCharFormat; -#define USB_CDC_1_STOP_BITS 0 -#define USB_CDC_1_5_STOP_BITS 1 -#define USB_CDC_2_STOP_BITS 2 - - __u8 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 - - __u8 bDataBits; -} __attribute__ ((packed)); -*/ +#define CONTROL_DTR 0x01 +#define CONTROL_RTS 0x02 // wValue #define DEVICE_DESCRIPTOR 0x100 @@ -71,7 +76,8 @@ struct usb_cdc_line_coding { #define STRING_PROD_DESCRIPTOR 0x302 #define STRING_SN_DESCRIPTOR 0x303 #define DEVICE_QALIFIER_DESCRIPTOR 0x600 -// / EPnR + +// EPnR bits manipulation #define CLEAR_DTOG_RX(R) (R & USB_EPnR_DTOG_RX) ? R : (R & (~USB_EPnR_DTOG_RX)) #define SET_DTOG_RX(R) (R & USB_EPnR_DTOG_RX) ? (R & (~USB_EPnR_DTOG_RX)) : R #define TOGGLE_DTOG_RX(R) (R | USB_EPnR_DTOG_RX) @@ -91,17 +97,29 @@ struct usb_cdc_line_coding { #define CLEAR_CTR_RX(R) (R & (~USB_EPnR_CTR_RX)) #define CLEAR_CTR_TX(R) (R & (~USB_EPnR_CTR_TX)) #define CLEAR_CTR_RX_TX(R) (R & (~(USB_EPnR_CTR_TX | USB_EPnR_CTR_RX))) -// USB + +// USB state: uninitialized, addressed, ready for use #define USB_DEFAULT_STATE 0 #define USB_ADRESSED_STATE 1 #define USB_CONFIGURE_STATE 2 -// + +// EP types #define EP_TYPE_BULK 0x00 #define EP_TYPE_CONTROL 0x01 #define EP_TYPE_ISO 0x02 #define EP_TYPE_INTERRUPT 0x03 -// +#define _USB_STRING_(name, str) \ +const struct name \ +{ \ + uint8_t bLength; \ + uint8_t bDescriptorType; \ + wchar_t bString[(sizeof(str) - 2) / 2]; \ + \ +} \ +name = {sizeof(name), 0x03, str}; + +// EP0 configuration packet typedef struct { uint8_t bmRequestType; uint8_t bRequest; @@ -109,7 +127,8 @@ typedef struct { uint16_t wIndex; uint16_t wLength; } config_pack_t; -// + +// endpoints state typedef struct __ep_t{ uint16_t *tx_buf; uint8_t *rx_buf; @@ -120,7 +139,8 @@ typedef struct __ep_t{ unsigned rx_flag : 1; unsigned setup_flag : 1; } ep_t; -// USB + +// USB status & its address typedef struct { uint8_t USB_Status; uint16_t USB_Addr; @@ -149,17 +169,22 @@ typedef struct { uint16_t wLength; } __attribute__ ((packed)) usb_cdc_notification; -// USB +extern uint8_t setlinecoding; +#define SETLINECODING() (setlinecoding) +#define CLRLINECODING() do{setlinecoding = 0;}while(0) + void USB_Init(); -// USB uint8_t USB_GetState(); -// void EP_Init(uint8_t number, uint8_t type, uint16_t addr_tx, uint16_t addr_rx, uint16_t (*func)(ep_t ep)); -// void EP_WriteIRQ(uint8_t number, const uint8_t *buf, uint16_t size); -// void EP_Write(uint8_t number, const uint8_t *buf, uint16_t size); -// -void EP_Read(uint8_t number, uint8_t *buf); +int EP_Read(uint8_t number, uint8_t *buf); +usb_LineCoding getLineCoding(); + + +void WEAK linecoding_handler(usb_LineCoding *lc); +void WEAK clstate_handler(uint16_t val); +void WEAK break_handler(); +void WEAK vendor_handler(config_pack_t *packet); #endif // __USB_LIB_H__ diff --git a/F0-nolib/usbcdc/usbcan.bin b/F0-nolib/usbcdc/usbcan.bin index a2d4e71..5e9a7c5 100755 Binary files a/F0-nolib/usbcdc/usbcan.bin and b/F0-nolib/usbcdc/usbcan.bin differ diff --git a/F0-nolib/usbcdc/canbus.c.tags b/F0-nolib/usbcdc/usbcan.c.tags similarity index 89% rename from F0-nolib/usbcdc/canbus.c.tags rename to F0-nolib/usbcdc/usbcan.c.tags index 5bd97c6..d74137b 100644 --- a/F0-nolib/usbcdc/canbus.c.tags +++ b/F0-nolib/usbcdc/usbcan.c.tags @@ -94,9 +94,11 @@ ADC_TR_HT ADC_TR_LT655360 AHB2PERIPH_BASE655360 AHBPERIPH_BASE655360 -ALL_OK4anon_enum_00 APBPERIPH_BASE655360 BCAST_ID655360 +BCDR64anon_struct_00volatile uint32_t +BTABLE64anon_struct_00volatile uint32_t +BUFFSIZE655360 CAN655360 CANID163840uint16_t CAN_BASE655360 @@ -115,7 +117,7 @@ CAN_BTR_TS2 CAN_BTR_TS2_0655360 CAN_BTR_TS2_1655360 CAN_BTR_TS2_2655360 -CAN_BUSY4anon_enum_20 +CAN_BUSY4anon_enum_40 CAN_ESR_BOFF655360 CAN_ESR_EPVF655360 CAN_ESR_EWGF655360 @@ -1051,7 +1053,7 @@ CAN_FFA1R_FFA6 CAN_FFA1R_FFA7655360 CAN_FFA1R_FFA8655360 CAN_FFA1R_FFA9655360 -CAN_FIFO_OVERRUN4anon_enum_20 +CAN_FIFO_OVERRUN4anon_enum_40 CAN_FLAG_GOTDUMMY655360 CAN_FM1R_FBM655360 CAN_FM1R_FBM0655360 @@ -1119,7 +1121,7 @@ CAN_MSR_SLAK CAN_MSR_SLAKI655360 CAN_MSR_TXM655360 CAN_MSR_WKUI655360 -CAN_OK4anon_enum_20 +CAN_OK4anon_enum_40 CAN_RDH0R_DATA4655360 CAN_RDH0R_DATA5655360 CAN_RDH0R_DATA6655360 @@ -1142,7 +1144,7 @@ CAN_RDT0R_TIME CAN_RDT1R_DLC655360 CAN_RDT1R_FMI655360 CAN_RDT1R_TIME655360 -CAN_READY4anon_enum_20 +CAN_READY4anon_enum_40 CAN_RF0R_FMP0655360 CAN_RF0R_FOVR0655360 CAN_RF0R_FULL0655360 @@ -1159,7 +1161,7 @@ CAN_RI1R_EXID CAN_RI1R_IDE655360 CAN_RI1R_RTR655360 CAN_RI1R_STID655360 -CAN_STOP4anon_enum_20 +CAN_STOP4anon_enum_40 CAN_TDH0R_DATA4655360 CAN_TDH0R_DATA5655360 CAN_TDH0R_DATA6655360 @@ -1234,7 +1236,7 @@ CAN_TSR_TXOK1 CAN_TSR_TXOK2655360 CAN_get_status16()0CAN_status CAN_get_status1024()0CAN_status -CAN_message40960anon_struct_1 +CAN_message40960anon_struct_3 CAN_messagebuf_pop16()0CAN_message * CAN_messagebuf_pop1024()0CAN_message * CAN_messagebuf_push16(CAN_message *msg)0int @@ -1242,7 +1244,7 @@ CAN_reinit CAN_reinit1024()0void CAN_setup16()0void CAN_setup1024()0void -CAN_status40960anon_enum_2 +CAN_status40960anon_enum_4 CEC655360 CEC_BASE655360 CEC_CFGR_BRDNOGEN655360 @@ -1286,10 +1288,23 @@ CEC_ISR_TXUDR CEC_TXDR_RXD655360 CEC_TXDR_TXD655360 CLEAR_BIT131072(REG,BIT)0 +CLEAR_COMM_FEATURE655360 +CLEAR_CTR_RX131072(R)0 +CLEAR_CTR_RX_TX131072(R)0 +CLEAR_CTR_TX131072(R)0 +CLEAR_DTOG_RX131072(R)0 +CLEAR_DTOG_TX131072(R)0 +CLEAR_FEATURE655360 CLEAR_REG131072(REG)0 +CLRLINECODING131072()0 CMD_BCAST655360 CMD_TOGGLE655360 +CNTR64anon_struct_00volatile uint32_t CONCAT131072(a,b)0 +CONFIGURATION_DESCRIPTOR655360 +CONTROL_DTR655360 +CONTROL_REQUEST_TYPE655360 +CONTROL_RTS655360 CRC655360 CRC_BASE655360 CRC_CR_RESET655360 @@ -1333,6 +1348,7 @@ CRS_ISR_SYNCMISS CRS_ISR_SYNCOKF655360 CRS_ISR_SYNCWARNF655360 CRS_ISR_TRIMOVF655360 +DADDR64anon_struct_00volatile uint32_t DBGMCU655360 DBGMCU_APB1_FZ_DBG_CAN_STOP655360 DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT655360 @@ -1366,6 +1382,10 @@ DBGMCU_IDCODE_REV_ID_6 DBGMCU_IDCODE_REV_ID_7655360 DBGMCU_IDCODE_REV_ID_8655360 DBGMCU_IDCODE_REV_ID_9655360 +DEVICE_DESCRIPTOR655360 +DEVICE_DESCRIPTOR_SIZE_BYTE655360 +DEVICE_QALIFIER_DESCRIPTOR655360 +DEVICE_QALIFIER_SIZE_BYTE655360 DMA1655360 DMA1_BASE655360 DMA1_Channel1655360 @@ -1461,7 +1481,24 @@ DMA_ISR_TEIF4 DMA_ISR_TEIF5655360 DMA_ISR_TEIF6655360 DMA_ISR_TEIF7655360 -EBUG655360 +EP64anon_struct_20volatile USB_EPDATA_TypeDef +EP0DATABUF_SIZE655360 +EP0_Handler16(ep_t ep)0uint16_t +EP1_Handler16(ep_t ep)0uint16_t +EP2_Handler16(ep_t ep)0uint16_t +EP_Init16(uint8_t number, uint8_t type, uint16_t addr_tx, uint16_t addr_rx, uint16_t (*func)(ep_t ep))0void +EP_Init1024(uint8_t number, uint8_t type, uint16_t addr_tx, uint16_t addr_rx, uint16_t (*func)(ep_t ep))0void +EP_Read16(uint8_t number, uint8_t *buf)0int +EP_Read1024(uint8_t number, uint8_t *buf)0int +EP_TYPE_BULK655360 +EP_TYPE_CONTROL655360 +EP_TYPE_INTERRUPT655360 +EP_TYPE_ISO655360 +EP_Write16(uint8_t number, const uint8_t *buf, uint16_t size)0void +EP_Write1024(uint8_t number, const uint8_t *buf, uint16_t size)0void +EP_WriteIRQ16(uint8_t number, const uint8_t *buf, uint16_t size)0void +EP_WriteIRQ1024(uint8_t number, const uint8_t *buf, uint16_t size)0void +EPnR64anon_struct_00volatile uint32_t EXTI655360 EXTI_BASE655360 EXTI_EMR_MR0655360 @@ -1588,6 +1625,7 @@ EXTI_SWIER_SWIER6 EXTI_SWIER_SWIER7655360 EXTI_SWIER_SWIER8655360 EXTI_SWIER_SWIER9655360 +FILE40960_IO_FILE FLASH655360 FLASH_ACR_LATENCY655360 FLASH_ACR_PRFTBE655360 @@ -1629,7 +1667,15 @@ FLASH_SR_PGERR FLASH_SR_WRPERR655360 FLASH_SR_WRPRTERR655360 FLASH_WRPR_WRP655360 +FNR64anon_struct_00volatile uint32_t FORMUSART131072(X)0 +GET_COMM_FEATURE655360 +GET_CONFIGURATION655360 +GET_DESCRIPTOR655360 +GET_ENCAPSULATED_RESPONSE655360 +GET_INTERFACE655360 +GET_LINE_CODING655360 +GET_STATUS655360 GPIOA655360 GPIOA_BASE655360 GPIOB655360 @@ -2133,6 +2179,7 @@ INT_LEAST64_WIDTH INT_LEAST8_MAX655360 INT_LEAST8_MIN655360 INT_LEAST8_WIDTH655360 +ISTR64anon_struct_00volatile uint32_t IS_ADC_ALL_INSTANCE131072(INSTANCE)0 IS_ADC_COMMON_INSTANCE131072(INSTANCE)0 IS_CAN_ALL_INSTANCE131072(INSTANCE)0 @@ -2211,6 +2258,10 @@ IWDG_SR_WVU IWDG_START655360 IWDG_WINR_WIN655360 IWDG_WRITE_ACCESS655360 +KEEP_DTOG_RX131072(R)0 +KEEP_DTOG_TX131072(R)0 +KEEP_STAT_RX131072(R)0 +KEEP_STAT_TX131072(R)0 LED0_pin655360 LED0_port655360 LED1_pin655360 @@ -2218,7 +2269,8 @@ LED1_port LED_blink131072(x)0 LED_off131072(x)0 LED_on131072(x)0 -LINE_BUSY4anon_enum_00 +LPMCSR64anon_struct_00volatile uint32_t +MAX_ENDPOINTS655360 MODIFY_REG131072(REG,CLEARMASK,SETMASK)0 MSG131072(str)0 NULL655360 @@ -2569,6 +2621,14 @@ RCC_IRQn READ_BIT131072(REG,BIT)0 READ_CAN_INV_ADDR131072()0 READ_REG131072(REG)0 +RESERVED164anon_struct_00volatile uint32_t +RESERVED264anon_struct_00volatile uint32_t +RESERVED364anon_struct_00volatile uint32_t +RESERVED464anon_struct_00volatile uint32_t +RESERVED564anon_struct_00volatile uint32_t +RESERVED664anon_struct_00volatile uint32_t +RESERVED764anon_struct_00volatile uint32_t +RESERVED864anon_struct_00volatile uint32_t RTC655360 RTC_ALRMAR_DT655360 RTC_ALRMAR_DT_0655360 @@ -2844,7 +2904,26 @@ SCB_SHCSR_SVCALLPENDED_Msk SCB_SHCSR_SVCALLPENDED_Pos655360 SCS_BASE655360 SEND131072(str)0 +SEND_BREAK655360 +SEND_ENCAPSULATED_COMMAND655360 +SETLINECODING131072()0 +SET_ADDRESS655360 SET_BIT131072(REG,BIT)0 +SET_COMM_FEATURE655360 +SET_CONFIGURATION655360 +SET_CONTROL_LINE_STATE655360 +SET_DESCRIPTOR655360 +SET_DTOG_RX131072(R)0 +SET_DTOG_TX131072(R)0 +SET_FEATURE655360 +SET_INTERFACE655360 +SET_LINE_CODING655360 +SET_NAK_RX131072(R)0 +SET_NAK_TX131072(R)0 +SET_STALL_RX131072(R)0 +SET_STALL_TX131072(R)0 +SET_VALID_RX131072(R)0 +SET_VALID_TX131072(R)0 SIG_ATOMIC_MAX655360 SIG_ATOMIC_MIN655360 SIG_ATOMIC_WIDTH655360 @@ -2927,8 +3006,13 @@ SRAM_BASE STM32F0655360 STM32F042x6655360 STR131072(s)0 +STRING_LANG_DESCRIPTOR655360 +STRING_LANG_DESCRIPTOR_SIZE_BYTE655360 +STRING_MAN_DESCRIPTOR655360 +STRING_PROD_DESCRIPTOR655360 +STRING_SN_DESCRIPTOR655360 STR_HELPER131072(s)0 -STR_TOO_LONG4anon_enum_00 +SYNC_FRAME655360 SYSCFG655360 SYSCFG_BASE655360 SYSCFG_CFGR1_ADC_DMA_RMP655360 @@ -3309,6 +3393,8 @@ TIM_SR_CC4OF TIM_SR_COMIF655360 TIM_SR_TIF655360 TIM_SR_UIF655360 +TOGGLE_DTOG_RX131072(R)0 +TOGGLE_DTOG_TX131072(R)0 TRUE_INLINE655360 TSC655360 TSC_BASE655360 @@ -3496,10 +3582,10 @@ TSC_IOSCR_G8_IO3 TSC_IOSCR_G8_IO4655360 TSC_ISR_EOAF655360 TSC_ISR_MCEF655360 -TXstatus40960anon_enum_0 Tms163840volatile uint32_t Tms327680volatile uint32_t -UARTBUFSZ655360 +UARTBUFSZI655360 +UARTBUFSZO655360 UINT16_C131072(c)0 UINT16_MAX655360 UINT16_WIDTH655360 @@ -3667,6 +3753,10 @@ USART_RTOR_BLEN USART_RTOR_RTO655360 USART_TDR_TDR655360 USB655360 +USB_ADDR_RX64anon_struct_10volatile uint16_t +USB_ADDR_TX64anon_struct_10volatile uint16_t +USB_ADRESSED_STATE655360 +USB_Addr64anon_struct_80uint16_t USB_BASE655360 USB_BCDR655360 USB_BCDR_BCDEN655360 @@ -3679,6 +3769,16 @@ USB_BCDR_PS2DET USB_BCDR_SDEN655360 USB_BCDR_SDET655360 USB_BTABLE655360 +USB_BTABLE_BASE655360 +USB_BtableDef40960anon_struct_2 +USB_CDC_1_5_STOP_BITS655360 +USB_CDC_1_STOP_BITS655360 +USB_CDC_2_STOP_BITS655360 +USB_CDC_EVEN_PARITY655360 +USB_CDC_MARK_PARITY655360 +USB_CDC_NO_PARITY655360 +USB_CDC_ODD_PARITY655360 +USB_CDC_SPACE_PARITY655360 USB_CLR_CTR655360 USB_CLR_ERR655360 USB_CLR_ESOF655360 @@ -3704,9 +3804,20 @@ USB_CNTR_RESUME USB_CNTR_SOFM655360 USB_CNTR_SUSPM655360 USB_CNTR_WKUPM655360 +USB_CONFIGURE_STATE655360 +USB_COUNT_RX64anon_struct_10volatile uint16_t +USB_COUNT_TX64anon_struct_10volatile uint16_t +USB_COUNTn_NUM_BLOCK655360 +USB_COUNTn_RX655360 +USB_COUNTn_RX_BLSIZE655360 +USB_ConfigDescriptor163840const uint8_t USB_DADDR655360 USB_DADDR_ADD655360 USB_DADDR_EF655360 +USB_DEFAULT_STATE655360 +USB_Dev163840usb_dev_t +USB_DeviceDescriptor163840const uint8_t +USB_DeviceQualifierDescriptor163840const uint8_t USB_EP0R655360 USB_EP1R655360 USB_EP2R655360 @@ -3716,6 +3827,7 @@ USB_EP5R USB_EP6R655360 USB_EP7R655360 USB_EPADDR_FIELD655360 +USB_EPDATA_TypeDef40960anon_struct_1 USB_EPKIND_MASK655360 USB_EPREG_MASK655360 USB_EPRX_DTOG1655360 @@ -3747,15 +3859,36 @@ USB_EP_TX_VALID USB_EP_TYPE_MASK655360 USB_EP_T_FIELD655360 USB_EP_T_MASK655360 +USB_EPnR_CTR_RX655360 +USB_EPnR_CTR_TX655360 +USB_EPnR_DTOG_RX655360 +USB_EPnR_DTOG_TX655360 +USB_EPnR_EA655360 +USB_EPnR_EP_KIND655360 +USB_EPnR_EP_TYPE655360 +USB_EPnR_EP_TYPE_0655360 +USB_EPnR_EP_TYPE_1655360 +USB_EPnR_SETUP655360 +USB_EPnR_STAT_RX655360 +USB_EPnR_STAT_RX_0655360 +USB_EPnR_STAT_RX_1655360 +USB_EPnR_STAT_TX655360 +USB_EPnR_STAT_TX_0655360 +USB_EPnR_STAT_TX_1655360 USB_FNR655360 USB_FNR_FN655360 USB_FNR_LCK655360 USB_FNR_LSOF655360 +USB_FNR_LSOF_0655360 USB_FNR_RXDM655360 USB_FNR_RXDP655360 +USB_FNR_lSOF_1655360 +USB_GetState16()0uint8_t +USB_GetState1024()0uint8_t USB_ISTR655360 USB_ISTR_CTR655360 USB_ISTR_DIR655360 +USB_ISTR_EPID655360 USB_ISTR_EP_ID655360 USB_ISTR_ERR655360 USB_ISTR_ESOF655360 @@ -3765,22 +3898,47 @@ USB_ISTR_RESET USB_ISTR_SOF655360 USB_ISTR_SUSP655360 USB_ISTR_WKUP655360 +USB_Init1024()0void USB_LPMCSR655360 USB_LPMCSR_BESL655360 +USB_LPMCSR_BESL_0655360 +USB_LPMCSR_BESL_1655360 +USB_LPMCSR_BESL_2655360 +USB_LPMCSR_BESL_3655360 USB_LPMCSR_LMPEN655360 USB_LPMCSR_LPMACK655360 USB_LPMCSR_REMWAKE655360 USB_PMAADDR655360 +USB_Status64anon_struct_80uint8_t +USB_StringLangDescriptor163840const uint8_t +USB_StringManufacturingDescriptor20480 +USB_StringManufacturingDescriptor163840 +USB_StringProdDescriptor20480 +USB_StringProdDescriptor163840 +USB_StringSerialDescriptor20480 +USB_StringSerialDescriptor163840 +USB_TypeDef655360 +USB_TypeDef_custom40960anon_struct_0 +USB_send16(char *buf)0void +USB_send1024(char *buf)0void +USB_setup16()0void +USB_setup1024()0void VDDIO2_IRQHandler655360 VDDIO2_IRQn655360 +VENDOR_MASK_REQUEST655360 +VENDOR_READ_REQUEST_TYPE655360 +VENDOR_REQUEST655360 +VENDOR_WRITE_REQUEST_TYPE655360 VREFINT_CAL_ADDR655360 WCHAR_MAX655360 WCHAR_MIN655360 WCHAR_WIDTH655360 WEAK655360 +WEOF655360 WINT_MAX655360 WINT_MIN655360 WINT_WIDTH655360 +WRITEDUMP131072(str)0 WRITE_REG131072(REG,VAL)0 WWDG655360 WWDG_BASE655360 @@ -3807,6 +3965,8 @@ WWDG_CR_T6 WWDG_CR_WDGA655360 WWDG_SR_EWIF655360 _ATFILE_SOURCE655360 +_BITS_FLOATN_COMMON_H655360 +_BITS_FLOATN_H655360 _BITS_STDINT_INTN_H655360 _BITS_STDINT_UINTN_H655360 _BITS_STRING_FORTIFIED_H655360 @@ -3818,12 +3978,20 @@ _BITS_WCHAR_H _BIT_SHIFT131072(IRQn)0 _BSD_SIZE_T_655360 _BSD_SIZE_T_DEFINED_655360 +_BSD_WCHAR_T_655360 _DEFAULT_SOURCE655360 _FEATURES_H655360 _FORTIFY_SOURCE655360 +_Float12840960__float128 +_Float3240960float +_Float32x40960double +_Float6440960double +_Float64x40960long double _GCC_SIZE_T655360 +_GCC_WCHAR_T655360 _GCC_WRAP_STDINT_H655360 _GNU_SOURCE655360 +_IO_FILE327680 _IP_IDX131072(IRQn)0 _ISOC11_SOURCE655360 _ISOC95_SOURCE655360 @@ -3848,6 +4016,17 @@ _SYS_CDEFS_H _SYS_SIZE_T_H655360 _T_SIZE655360 _T_SIZE_655360 +_T_WCHAR655360 +_T_WCHAR_655360 +_USB_STRING_131072(name,str)0 +_WCHAR_H655360 +_WCHAR_T655360 +_WCHAR_T_655360 +_WCHAR_T_DECLARED655360 +_WCHAR_T_DEFINED655360 +_WCHAR_T_DEFINED_655360 +_WCHAR_T_H655360 +_WINT_T655360 _XOPEN_SOURCE655360 _XOPEN_SOURCE_EXTENDED655360 __ASM655360 @@ -3869,6 +4048,11 @@ __BLKCNT_T_TYPE __BLKSIZE_T_TYPE655360 __BYTE_ORDER__655360 __CAN_H__655360 +__CFLOAT128655360 +__CFLOAT32655360 +__CFLOAT32X655360 +__CFLOAT64655360 +__CFLOAT64X655360 __CHAR16_TYPE__655360 __CHAR32_TYPE__655360 __CHAR_BIT__655360 @@ -3887,6 +4071,7 @@ __CORE_CMFUNC_H __CORE_CMINSTR_H655360 __CORRECT_ISO_CPP_STRINGS_H_PROTO655360 __CORRECT_ISO_CPP_STRING_H_PROTO655360 +__CORRECT_ISO_CPP_WCHAR_H_PROTO655360 __CORTEX_M655360 __CPU_MASK_TYPE655360 __DADDR_T_TYPE655360 @@ -3934,12 +4119,85 @@ __ELF__ __END_DECLS655360 __EXCEPTIONS655360 __FD_SETSIZE655360 +__FILE40960_IO_FILE +__FILE_defined655360 __FINITE_MATH_ONLY__655360 __FLOAT_WORD_ORDER__655360 +__FLT128_DECIMAL_DIG__655360 +__FLT128_DENORM_MIN__655360 +__FLT128_DIG__655360 +__FLT128_EPSILON__655360 +__FLT128_HAS_DENORM__655360 +__FLT128_HAS_INFINITY__655360 +__FLT128_HAS_QUIET_NAN__655360 +__FLT128_MANT_DIG__655360 +__FLT128_MAX_10_EXP__655360 +__FLT128_MAX_EXP__655360 +__FLT128_MAX__655360 +__FLT128_MIN_10_EXP__655360 +__FLT128_MIN_EXP__655360 +__FLT128_MIN__655360 +__FLT32X_DECIMAL_DIG__655360 +__FLT32X_DENORM_MIN__655360 +__FLT32X_DIG__655360 +__FLT32X_EPSILON__655360 +__FLT32X_HAS_DENORM__655360 +__FLT32X_HAS_INFINITY__655360 +__FLT32X_HAS_QUIET_NAN__655360 +__FLT32X_MANT_DIG__655360 +__FLT32X_MAX_10_EXP__655360 +__FLT32X_MAX_EXP__655360 +__FLT32X_MAX__655360 +__FLT32X_MIN_10_EXP__655360 +__FLT32X_MIN_EXP__655360 +__FLT32X_MIN__655360 +__FLT32_DECIMAL_DIG__655360 +__FLT32_DENORM_MIN__655360 +__FLT32_DIG__655360 +__FLT32_EPSILON__655360 +__FLT32_HAS_DENORM__655360 +__FLT32_HAS_INFINITY__655360 +__FLT32_HAS_QUIET_NAN__655360 +__FLT32_MANT_DIG__655360 +__FLT32_MAX_10_EXP__655360 +__FLT32_MAX_EXP__655360 +__FLT32_MAX__655360 +__FLT32_MIN_10_EXP__655360 +__FLT32_MIN_EXP__655360 +__FLT32_MIN__655360 +__FLT64X_DECIMAL_DIG__655360 +__FLT64X_DENORM_MIN__655360 +__FLT64X_DIG__655360 +__FLT64X_EPSILON__655360 +__FLT64X_HAS_DENORM__655360 +__FLT64X_HAS_INFINITY__655360 +__FLT64X_HAS_QUIET_NAN__655360 +__FLT64X_MANT_DIG__655360 +__FLT64X_MAX_10_EXP__655360 +__FLT64X_MAX_EXP__655360 +__FLT64X_MAX__655360 +__FLT64X_MIN_10_EXP__655360 +__FLT64X_MIN_EXP__655360 +__FLT64X_MIN__655360 +__FLT64_DECIMAL_DIG__655360 +__FLT64_DENORM_MIN__655360 +__FLT64_DIG__655360 +__FLT64_EPSILON__655360 +__FLT64_HAS_DENORM__655360 +__FLT64_HAS_INFINITY__655360 +__FLT64_HAS_QUIET_NAN__655360 +__FLT64_MANT_DIG__655360 +__FLT64_MAX_10_EXP__655360 +__FLT64_MAX_EXP__655360 +__FLT64_MAX__655360 +__FLT64_MIN_10_EXP__655360 +__FLT64_MIN_EXP__655360 +__FLT64_MIN__655360 __FLT_DECIMAL_DIG__655360 __FLT_DENORM_MIN__655360 __FLT_DIG__655360 __FLT_EPSILON__655360 +__FLT_EVAL_METHOD_TS_18661_3__655360 __FLT_EVAL_METHOD__655360 __FLT_HAS_DENORM__655360 __FLT_HAS_INFINITY__655360 @@ -3996,6 +4254,7 @@ __GNUC_MINOR__ __GNUC_PATCHLEVEL__655360 __GNUC_PREREQ131072(maj,min)0 __GNUC_STDC_INLINE__655360 +__GNUC_VA_LIST655360 __GNUC__655360 __GNUG__655360 __GNU_LIBRARY__655360 @@ -4004,6 +4263,22 @@ __GXX_EXPERIMENTAL_CXX0X__ __GXX_RTTI655360 __GXX_WEAK__655360 __HARDWARE_H__655360 +__HAVE_DISTINCT_FLOAT128655360 +__HAVE_DISTINCT_FLOAT128X655360 +__HAVE_DISTINCT_FLOAT16655360 +__HAVE_DISTINCT_FLOAT32655360 +__HAVE_DISTINCT_FLOAT32X655360 +__HAVE_DISTINCT_FLOAT64655360 +__HAVE_DISTINCT_FLOAT64X655360 +__HAVE_FLOAT128655360 +__HAVE_FLOAT128X655360 +__HAVE_FLOAT16655360 +__HAVE_FLOAT32655360 +__HAVE_FLOAT32X655360 +__HAVE_FLOAT64655360 +__HAVE_FLOAT64X655360 +__HAVE_FLOAT64X_LONG_DOUBLE655360 +__HAVE_FLOATN_NOT_TYPEDEF655360 __HAVE_GENERIC_SELECTION655360 __I655360 __ID_T_TYPE655360 @@ -4026,28 +4301,41 @@ __INT8_TYPE__ __INTMAX_C131072(c)0 __INTMAX_MAX__655360 __INTMAX_TYPE__655360 +__INTMAX_WIDTH__655360 __INTPTR_MAX__655360 __INTPTR_TYPE__655360 +__INTPTR_WIDTH__655360 __INT_FAST16_MAX__655360 __INT_FAST16_TYPE__655360 +__INT_FAST16_WIDTH__655360 __INT_FAST32_MAX__655360 __INT_FAST32_TYPE__655360 +__INT_FAST32_WIDTH__655360 __INT_FAST64_MAX__655360 __INT_FAST64_TYPE__655360 +__INT_FAST64_WIDTH__655360 __INT_FAST8_MAX__655360 __INT_FAST8_TYPE__655360 +__INT_FAST8_WIDTH__655360 __INT_LEAST16_MAX__655360 __INT_LEAST16_TYPE__655360 +__INT_LEAST16_WIDTH__655360 __INT_LEAST32_MAX__655360 __INT_LEAST32_TYPE__655360 +__INT_LEAST32_WIDTH__655360 __INT_LEAST64_MAX__655360 __INT_LEAST64_TYPE__655360 +__INT_LEAST64_WIDTH__655360 __INT_LEAST8_MAX__655360 __INT_LEAST8_TYPE__655360 +__INT_LEAST8_WIDTH__655360 __INT_MAX__655360 +__INT_WCHAR_T_H655360 +__INT_WIDTH__655360 __IO655360 __KERNEL_STRICT_NAMES655360 __KEY_T_TYPE655360 +__LDBL_DECIMAL_DIG__655360 __LDBL_DENORM_MIN__655360 __LDBL_DIG__655360 __LDBL_EPSILON__655360 @@ -4069,7 +4357,9 @@ __LDBL_REDIR_NTH __LEAF655360 __LEAF_ATTR655360 __LONG_LONG_MAX__655360 +__LONG_LONG_WIDTH__655360 __LONG_MAX__655360 +__LONG_WIDTH__655360 __LP64__655360 __MMX__655360 __MODE_T_TYPE655360 @@ -4096,6 +4386,7 @@ __PMT __PRAGMA_REDEFINE_EXTNAME655360 __PTRDIFF_MAX__655360 __PTRDIFF_TYPE__655360 +__PTRDIFF_WIDTH__655360 __REDIRECT131072(name,proto,alias)0 __REDIRECT_LDBL131072(name,proto,alias)0 __REDIRECT_NTH131072(name,proto,alias)0 @@ -4109,12 +4400,15 @@ __S16_TYPE __S32_TYPE655360 __S64_TYPE655360 __SCHAR_MAX__655360 +__SCHAR_WIDTH__655360 __SEG_FS655360 __SEG_GS655360 __SHRT_MAX__655360 +__SHRT_WIDTH__655360 __SIG_ATOMIC_MAX__655360 __SIG_ATOMIC_MIN__655360 __SIG_ATOMIC_TYPE__655360 +__SIG_ATOMIC_WIDTH__655360 __SIZEOF_DOUBLE__655360 __SIZEOF_FLOAT128__655360 __SIZEOF_FLOAT80__655360 @@ -4134,6 +4428,7 @@ __SIZE_MAX__ __SIZE_T655360 __SIZE_TYPE__655360 __SIZE_T__655360 +__SIZE_WIDTH__655360 __SLONG32_TYPE655360 __SLONGWORD_TYPE655360 __SQUAD_TYPE655360 @@ -4215,6 +4510,9 @@ __ULONG32_TYPE __ULONGWORD_TYPE655360 __UQUAD_TYPE655360 __USART_H__655360 +__USB_DEFS_H__655360 +__USB_H__655360 +__USB_LIB_H__655360 __USECONDS_T_TYPE655360 __USER_LABEL_PREFIX__655360 __USE_ATFILE655360 @@ -4245,15 +4543,23 @@ __VERSION__ __Vendor_SysTickConfig655360 __WCHAR_MAX655360 __WCHAR_MAX__655360 +__WCHAR_MB_LEN_MAX655360 __WCHAR_MIN655360 __WCHAR_MIN__655360 +__WCHAR_T655360 __WCHAR_TYPE__655360 +__WCHAR_T__655360 +__WCHAR_WIDTH__655360 __WINT_MAX__655360 __WINT_MIN__655360 __WINT_TYPE__655360 +__WINT_WIDTH__655360 __WORDSIZE655360 __WORDSIZE_TIME64_COMPAT32655360 +____FILE_defined655360 +____mbstate_t_defined655360 ___int_size_t_h655360 +___int_wchar_t_h655360 __always_inline655360 __amd64655360 __amd64__655360 @@ -4272,7 +4578,9 @@ __attribute_used__ __attribute_warn_unused_result__655360 __bos131072(ptr)0 __bos0131072(ptr)0 +__cfloat12840960_Complex float __code_model_small__655360 +__count64anon_struct_50int __cplusplus655360 __cpp_aggregate_nsdmi655360 __cpp_alias_templates655360 @@ -4301,14 +4609,24 @@ __cpp_rvalue_reference __cpp_rvalue_references655360 __cpp_sized_deallocation655360 __cpp_static_assert655360 +__cpp_threadsafe_static_init655360 __cpp_unicode_characters655360 __cpp_unicode_literals655360 __cpp_user_defined_literals655360 __cpp_variable_templates655360 __cpp_variadic_templates655360 +__ctype_b64__locale_struct0const unsigned short int * +__ctype_tolower64__locale_struct0const int * +__ctype_toupper64__locale_struct0const int * +__ep_t20480 __errordecl131072(name,msg)0 __extern_always_inline655360 __extern_inline655360 +__f128131072(x)0 +__f32131072(x)0 +__f32x131072(x)0 +__f64131072(x)0 +__f64x131072(x)0 __flexarr655360 __fortify_function655360 __glibc_c99_flexarr_available655360 @@ -4319,6 +4637,7 @@ __glibc_macro_warning __glibc_macro_warning1131072(message)0 __glibc_unlikely131072(cond)0 __gnu_linux__655360 +__gnuc_va_list40960__builtin_va_list __has_include131072(STR)0 __has_include_next131072(STR)0 __intptr_t_defined655360 @@ -4326,8 +4645,16 @@ __k8 __k8__655360 __linux655360 __linux__655360 +__locale_struct20480 +__locale_t40960__locale_struct +__locales64__locale_struct0__locale_data +__mbstate_t40960anon_struct_5 +__mbstate_t_defined655360 +__names64__locale_struct0const char * __need_NULL655360 +__need___va_list655360 __need_size_t655360 +__need_wchar_t655360 __nonnull131072(params)0 __pic__655360 __pie__655360 @@ -4354,14 +4681,46 @@ __unix __unix__655360 __va_arg_pack131072()0 __va_arg_pack_len131072()0 +__value64anon_struct_50anon_union_6 __warnattr131072(msg)0 __warndecl131072(name,msg)0 +__wch64anon_struct_5::anon_union_60unsigned int +__wchar_t__655360 +__wchb64anon_struct_5::anon_union_60char +__wint_t_defined655360 __wur655360 __x86_64655360 __x86_64__655360 -anon_enum_020 -anon_enum_220 +anon_enum_420 +anon_struct_020480 anon_struct_120480 +anon_struct_1020480 +anon_struct_220480 +anon_struct_320480 +anon_struct_520480 +anon_struct_720480 +anon_struct_820480 +anon_struct_920480 +anon_union_68192anon_struct_50 +bCharFormat64anon_struct_90uint8_t +bDataBits64anon_struct_90uint8_t +bDescriptorType64USB_StringManufacturingDescriptor0uint8_t +bDescriptorType64USB_StringProdDescriptor0uint8_t +bDescriptorType64USB_StringSerialDescriptor0uint8_t +bLength64USB_StringManufacturingDescriptor0uint8_t +bLength64USB_StringProdDescriptor0uint8_t +bLength64USB_StringSerialDescriptor0uint8_t +bNotificationType64anon_struct_100uint8_t +bParityType64anon_struct_90uint8_t +bRequest64anon_struct_70uint8_t +bString64USB_StringManufacturingDescriptor0wchar_t +bString64USB_StringProdDescriptor0wchar_t +bString64USB_StringSerialDescriptor0wchar_t +bmRequestType64anon_struct_100uint8_t +bmRequestType64anon_struct_70uint8_t +break_handler16()0void +break_handler1024()0void +buffer163840uint8_t bufovr163840int bufovr327680int can_proc16()0void @@ -4375,27 +4734,47 @@ can_send_dummy can_send_dummy1024()0void can_status163840CAN_status cec_can_isr16()0void -data64anon_struct_10uint8_t -datalen163840int +clstate_handler16(__attribute__((unused)) uint16_t val)0void +clstate_handler1024(uint16_t val)0void +config_pack_t40960anon_struct_7 +data64anon_struct_30uint8_t dlen163840int dma1_channel2_3_isr16()0void +dwDTERate64anon_struct_90uint32_t +endpoints163840ep_t +ep0databuf163840uint8_t +ep0dbuflen163840uint8_t +ep_t40960__ep_t first_free_idx163840uint8_t first_nonfree_idx163840int8_t +func1024()__ep_t0uint16_t getCANID16()0uint16_t getCANID1024()0uint16_t +getLineCoding16()0usb_LineCoding +getLineCoding1024()0usb_LineCoding gpio_setup16(void)0void gpio_setup1024(void)0void +hexdump16(uint8_t *arr, uint16_t len)0void +hexdump1024(uint8_t *arr, uint16_t len)0void +idatalen163840volatile int iwdg_setup16()0void last_err_code163840uint32_t -length64anon_struct_10uint8_t +len163840uint8_t +length64anon_struct_30uint8_t +lineCoding163840usb_LineCoding +linecoding_handler16(__attribute__((unused)) usb_LineCoding *lc)0void +linecoding_handler1024(usb_LineCoding *lc)0void linerdy163840volatile int linerdy327680volatile int linux655360 +locale_t40960__locale_t main16(void)0int +mbstate_t40960__mbstate_t messages163840CAN_message newline16()0void newline1024()0void nop131072()0 +odatalen163840volatile int pin_clear131072(gpioport,gpios)0 pin_read131072(gpioport,gpios)0 pin_set131072(gpioport,gpios)0 @@ -4407,14 +4786,29 @@ printuhex printuhex1024(uint32_t val)0void rbuf163840char rbufno163840int +rcvflag163840uint8_t readCANID16()0void readCANID1024()0void recvdata163840char * +rx_buf64__ep_t0uint8_t * +rx_cnt64__ep_t0 +rx_flag64__ep_t0 +setlinecoding163840uint8_t +setlinecoding327680uint8_t +setup_flag64__ep_t0 +setup_packet163840config_pack_t +size_t40960long unsigned int +status64__ep_t0uint16_t strdupa131072(s)0 strndupa131072(s,n)0 sys_tick_handler16(void)0void sysreset16(void)0inline void tbuf163840char +tbufno163840int +transmit_tbuf16()0void +transmit_tbuf1024()0void +tx_buf64__ep_t0uint16_t * +tx_flag64__ep_t0 txrdy163840int txrdy327680int unix655360 @@ -4423,11 +4817,24 @@ usart_getline usart_getline1024(char **line)0int usart_putchar16(const char ch)0void usart_putchar1024(const char ch)0void -usart_send16(const char *str, int len)0TXstatus -usart_send1024(const char *str, int len)0TXstatus -usart_send_blocking16(const char *str, int len)0TXstatus -usart_send_blocking1024(const char *str, int len)0TXstatus +usart_send16(const char *str)0void +usart_send1024(const char *str)0void usart_setup16()0void usart_setup1024()0void usartovr131072()0 usartrx131072()0 +usb_LineCoding40960anon_struct_9 +usb_cdc_notification40960anon_struct_10 +usb_dev_t40960anon_struct_8 +usb_isr16()0void +usb_proc16()0void +usb_proc1024()0void +vendor_handler16(config_pack_t *packet)0void +vendor_handler1024(config_pack_t *packet)0void +wIndex64anon_struct_100uint16_t +wIndex64anon_struct_70uint16_t +wLength64anon_struct_100uint16_t +wLength64anon_struct_70uint16_t +wValue64anon_struct_100uint16_t +wValue64anon_struct_70uint16_t +wint_t40960unsigned int