From 6be95bdab934f0ea7d2662c98c8b0afdec07191f Mon Sep 17 00:00:00 2001 From: eddyem Date: Sun, 11 Nov 2018 15:44:12 +0300 Subject: [PATCH] fix bug with receiving a lot of data from USB --- F0-nolib/Readme.md | 2 +- .../stm32-2018-10-23-16-51-39.pro | 67 + .../stm32-2018-10-23-16-51-39.sch | 1737 +++++++++++++++++ .../stm32-cache-2018-10-23-16-51-39.lib | 764 ++++++++ .../stm32-rescue-2018-10-23-16-51-39.lib | 45 + F0-nolib/canbus/kicad/sym-lib-table | 8 + F0-nolib/ch340/Readme.md | 5 - F0-nolib/ch340/ch340.sublime-project | 8 - F0-nolib/ch340/ch340.sublime-workspace | 548 ------ F0-nolib/ch340/ch340emul.bin | Bin 4936 -> 0 bytes F0-nolib/ch340/lsusb_log | 69 - F0-nolib/{ch340 => pl2303}/Makefile | 2 +- F0-nolib/pl2303/Readme.md | 1 + F0-nolib/{ch340 => pl2303}/hardware.c | 0 F0-nolib/{ch340 => pl2303}/hardware.h | 0 F0-nolib/{ch340 => pl2303}/main.c | 47 +- F0-nolib/pl2303/pl2303.bin | Bin 0 -> 5576 bytes F0-nolib/{ch340 => pl2303}/usart.c | 15 +- F0-nolib/{ch340 => pl2303}/usart.h | 1 + F0-nolib/{ch340 => pl2303}/usb.c | 107 +- F0-nolib/{ch340 => pl2303}/usb.h | 2 + F0-nolib/{ch340 => pl2303}/usb_defs.h | 0 F0-nolib/{ch340 => pl2303}/usb_lib.c | 137 +- F0-nolib/{ch340 => pl2303}/usb_lib.h | 21 +- F0-nolib/usbcdc/Readme.md | 4 +- 25 files changed, 2841 insertions(+), 749 deletions(-) create mode 100644 F0-nolib/canbus/kicad/rescue-backup/stm32-2018-10-23-16-51-39.pro create mode 100644 F0-nolib/canbus/kicad/rescue-backup/stm32-2018-10-23-16-51-39.sch create mode 100644 F0-nolib/canbus/kicad/rescue-backup/stm32-cache-2018-10-23-16-51-39.lib create mode 100644 F0-nolib/canbus/kicad/rescue-backup/stm32-rescue-2018-10-23-16-51-39.lib create mode 100644 F0-nolib/canbus/kicad/sym-lib-table delete mode 100644 F0-nolib/ch340/Readme.md delete mode 100644 F0-nolib/ch340/ch340.sublime-project delete mode 100644 F0-nolib/ch340/ch340.sublime-workspace delete mode 100755 F0-nolib/ch340/ch340emul.bin delete mode 100644 F0-nolib/ch340/lsusb_log rename F0-nolib/{ch340 => pl2303}/Makefile (99%) create mode 100644 F0-nolib/pl2303/Readme.md rename F0-nolib/{ch340 => pl2303}/hardware.c (100%) rename F0-nolib/{ch340 => pl2303}/hardware.h (100%) rename F0-nolib/{ch340 => pl2303}/main.c (77%) create mode 100755 F0-nolib/pl2303/pl2303.bin rename F0-nolib/{ch340 => pl2303}/usart.c (95%) rename F0-nolib/{ch340 => pl2303}/usart.h (97%) rename F0-nolib/{ch340 => pl2303}/usb.c (60%) rename F0-nolib/{ch340 => pl2303}/usb.h (94%) rename F0-nolib/{ch340 => pl2303}/usb_defs.h (100%) rename F0-nolib/{ch340 => pl2303}/usb_lib.c (86%) rename F0-nolib/{ch340 => pl2303}/usb_lib.h (91%) diff --git a/F0-nolib/Readme.md b/F0-nolib/Readme.md index 26f55fa..eaccc7d 100644 --- a/F0-nolib/Readme.md +++ b/F0-nolib/Readme.md @@ -12,4 +12,4 @@ This directory contains examples for F0 without any library - uart_blink - code for STM32F030F4, echo data on USART1 and blink LEDS on PA4 and PA5 - uart_nucleo - USART over DMA for STM32F042-nucleo - usbcdc - CDC for STM32F042 (emulation of PL2303) with working CAN bus -- ch340 - another CDC (emulation of ch340) +- pl2303 - CDC template (emulation of PL2303) diff --git a/F0-nolib/canbus/kicad/rescue-backup/stm32-2018-10-23-16-51-39.pro b/F0-nolib/canbus/kicad/rescue-backup/stm32-2018-10-23-16-51-39.pro new file mode 100644 index 0000000..39fd092 --- /dev/null +++ b/F0-nolib/canbus/kicad/rescue-backup/stm32-2018-10-23-16-51-39.pro @@ -0,0 +1,67 @@ +update=Чт 11 янв 2018 23:12:54 +version=1 +last_client=kicad +[pcbnew] +version=1 +LastNetListRead= +UseCmpFile=1 +PadDrill=0.600000000000 +PadDrillOvalY=0.600000000000 +PadSizeH=1.500000000000 +PadSizeV=1.500000000000 +PcbTextSizeV=1.500000000000 +PcbTextSizeH=1.500000000000 +PcbTextThickness=0.300000000000 +ModuleTextSizeV=1.000000000000 +ModuleTextSizeH=1.000000000000 +ModuleTextSizeThickness=0.150000000000 +SolderMaskClearance=0.000000000000 +SolderMaskMinWidth=0.000000000000 +DrawSegmentWidth=0.200000000000 +BoardOutlineThickness=0.100000000000 +ModuleOutlineThickness=0.150000000000 +[cvpcb] +version=1 +NetIExt=net +[general] +version=1 +[eeschema] +version=1 +LibDir=/home/eddy/kicad/Kicad-Libraries/library +[eeschema/libraries] +LibName1=stm32-rescue +LibName2=power +LibName3=device +LibName4=transistors +LibName5=conn +LibName6=linear +LibName7=regul +LibName8=74xx +LibName9=cmos4000 +LibName10=adc-dac +LibName11=memory +LibName12=xilinx +LibName13=microcontrollers +LibName14=dsp +LibName15=microchip +LibName16=analog_switches +LibName17=motorola +LibName18=texas +LibName19=intel +LibName20=audio +LibName21=interface +LibName22=digital-audio +LibName23=philips +LibName24=display +LibName25=cypress +LibName26=siliconi +LibName27=opto +LibName28=atmel +LibName29=contrib +LibName30=valves +LibName31=stm32 +LibName32=vreg +LibName33=elements +LibName34=ESD_Protection +LibName35=switches +LibName36=acs712 diff --git a/F0-nolib/canbus/kicad/rescue-backup/stm32-2018-10-23-16-51-39.sch b/F0-nolib/canbus/kicad/rescue-backup/stm32-2018-10-23-16-51-39.sch new file mode 100644 index 0000000..79f1677 --- /dev/null +++ b/F0-nolib/canbus/kicad/rescue-backup/stm32-2018-10-23-16-51-39.sch @@ -0,0 +1,1737 @@ +EESchema Schematic File Version 2 +LIBS:stm32-rescue +LIBS:power +LIBS:device +LIBS:transistors +LIBS:conn +LIBS:linear +LIBS:regul +LIBS:74xx +LIBS:cmos4000 +LIBS:adc-dac +LIBS:memory +LIBS:xilinx +LIBS:microcontrollers +LIBS:dsp +LIBS:microchip +LIBS:analog_switches +LIBS:motorola +LIBS:texas +LIBS:intel +LIBS:audio +LIBS:interface +LIBS:digital-audio +LIBS:philips +LIBS:display +LIBS:cypress +LIBS:siliconi +LIBS:opto +LIBS:atmel +LIBS:contrib +LIBS:valves +LIBS:stm32 +LIBS:vreg +LIBS:elements +LIBS:ESD_Protection +LIBS:switches +LIBS:acs712 +LIBS:stm32-cache +EELAYER 25 0 +EELAYER END +$Descr A3 16535 11693 +encoding utf-8 +Sheet 1 1 +Title "" +Date "" +Rev "" +Comp "" +Comment1 "" +Comment2 "" +Comment3 "" +Comment4 "" +$EndDescr +$Comp +L C C11 +U 1 1 58C42D39 +P 8150 9950 +F 0 "C11" H 8175 10050 50 0000 L CNN +F 1 "0.1" H 8175 9850 50 0000 L CNN +F 2 "Capacitors_SMD.pretty:C_0603_HandSoldering" H 8188 9800 50 0001 C CNN +F 3 "" H 8150 9950 50 0000 C CNN + 1 8150 9950 + 1 0 0 -1 +$EndComp +$Comp +L LM1117-3.3-RESCUE-stm32 U2 +U 1 1 58C431FC +P 2350 4900 +F 0 "U2" H 2450 4650 50 0000 C CNN +F 1 "LM1117-3.3" H 2350 5150 50 0000 C CNN +F 2 "TO_SOT_Packages_SMD.pretty:SOT-223" H 2350 4900 50 0001 C CNN +F 3 "" H 2350 4900 50 0000 C CNN + 1 2350 4900 + 1 0 0 -1 +$EndComp +$Comp +L MCP2551-I/SN U4 +U 1 1 58C43297 +P 3550 1550 +F 0 "U4" H 3150 1900 50 0000 L CNN +F 1 "MCP2551-I/SN" H 3650 1900 50 0000 L CNN +F 2 "Housings_SOIC.pretty:SOIC-8_3.9x4.9mm_Pitch1.27mm" H 3550 1050 50 0001 C CIN +F 3 "" H 3550 1550 50 0000 C CNN + 1 3550 1550 + 1 0 0 -1 +$EndComp +$Comp +L USB_A-RESCUE-stm32 P13 +U 1 1 58C433D0 +P 14300 8950 +F 0 "P13" H 14500 8750 50 0000 C CNN +F 1 "USB_A" H 14250 9150 50 0000 C CNN +F 2 "Connect.pretty:USB_Mini-B" V 14250 8850 50 0001 C CNN +F 3 "" V 14250 8850 50 0000 C CNN + 1 14300 8950 + 0 1 1 0 +$EndComp +$Comp +L GND #PWR01 +U 1 1 58C43B9F +P 1600 3750 +F 0 "#PWR01" H 1600 3500 50 0001 C CNN +F 1 "GND" H 1600 3600 50 0000 C CNN +F 2 "" H 1600 3750 50 0000 C CNN +F 3 "" H 1600 3750 50 0000 C CNN + 1 1600 3750 + 1 0 0 -1 +$EndComp +Text Notes 1000 3100 0 60 ~ 0 +5V power source +$Comp +L +5V #PWR02 +U 1 1 58C45269 +P 1800 4900 +F 0 "#PWR02" H 1800 4750 50 0001 C CNN +F 1 "+5V" H 1800 5040 50 0000 C CNN +F 2 "" H 1800 4900 50 0000 C CNN +F 3 "" H 1800 4900 50 0000 C CNN + 1 1800 4900 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR03 +U 1 1 58C453C7 +P 2350 5250 +F 0 "#PWR03" H 2350 5000 50 0001 C CNN +F 1 "GND" H 2350 5100 50 0000 C CNN +F 2 "" H 2350 5250 50 0000 C CNN +F 3 "" H 2350 5250 50 0000 C CNN + 1 2350 5250 + 1 0 0 -1 +$EndComp +$Comp +L CP C2 +U 1 1 58C454F6 +P 2750 5050 +F 0 "C2" H 2775 5150 50 0000 L CNN +F 1 "47u" H 2775 4950 50 0000 L CNN +F 2 "Capacitors_Tantalum_SMD.pretty:Tantalum_Case-A_EIA-3216-18_Hand" H 2788 4900 50 0001 C CNN +F 3 "" H 2750 5050 50 0000 C CNN + 1 2750 5050 + 1 0 0 -1 +$EndComp +$Comp +L +3.3V #PWR04 +U 1 1 58C455CB +P 2950 4900 +F 0 "#PWR04" H 2950 4750 50 0001 C CNN +F 1 "+3.3V" H 2950 5040 50 0000 C CNN +F 2 "" H 2950 4900 50 0000 C CNN +F 3 "" H 2950 4900 50 0000 C CNN + 1 2950 4900 + 1 0 0 -1 +$EndComp +$Comp +L PESD1CAN D3 +U 1 1 58C46522 +P 4550 2450 +F 0 "D3" H 4550 2100 50 0000 C CNN +F 1 "PESD1CAN" H 4600 2600 50 0000 C CNN +F 2 "TO_SOT_Packages_SMD.pretty:SOT-23" H 4550 2450 50 0001 C CNN +F 3 "" H 4550 2450 50 0000 C CNN + 1 4550 2450 + 0 1 1 0 +$EndComp +$Comp +L GND #PWR05 +U 1 1 58C47600 +P 4450 2900 +F 0 "#PWR05" H 4450 2650 50 0001 C CNN +F 1 "GND" H 4450 2750 50 0000 C CNN +F 2 "" H 4450 2900 50 0000 C CNN +F 3 "" H 4450 2900 50 0000 C CNN + 1 4450 2900 + 1 0 0 -1 +$EndComp +$Comp +L +5V #PWR06 +U 1 1 58C47B3E +P 3550 1100 +F 0 "#PWR06" H 3550 950 50 0001 C CNN +F 1 "+5V" H 3550 1240 50 0000 C CNN +F 2 "" H 3550 1100 50 0000 C CNN +F 3 "" H 3550 1100 50 0000 C CNN + 1 3550 1100 + 1 0 0 -1 +$EndComp +$Comp +L R R8 +U 1 1 58C47F04 +P 3000 1950 +F 0 "R8" V 3080 1950 50 0000 C CNN +F 1 "4k7" V 3000 1950 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 2930 1950 50 0001 C CNN +F 3 "" H 3000 1950 50 0000 C CNN + 1 3000 1950 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR07 +U 1 1 58C4802D +P 3550 2050 +F 0 "#PWR07" H 3550 1800 50 0001 C CNN +F 1 "GND" H 3550 1900 50 0000 C CNN +F 2 "" H 3550 2050 50 0000 C CNN +F 3 "" H 3550 2050 50 0000 C CNN + 1 3550 2050 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR08 +U 1 1 58C4805F +P 3000 2150 +F 0 "#PWR08" H 3000 1900 50 0001 C CNN +F 1 "GND" H 3000 2000 50 0000 C CNN +F 2 "" H 3000 2150 50 0000 C CNN +F 3 "" H 3000 2150 50 0000 C CNN + 1 3000 2150 + 1 0 0 -1 +$EndComp +$Comp +L R R9 +U 1 1 58C488C6 +P 4900 1800 +F 0 "R9" V 4980 1800 50 0000 C CNN +F 1 "120" V 4900 1800 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 4830 1800 50 0001 C CNN +F 3 "" H 4900 1800 50 0000 C CNN + 1 4900 1800 + 0 -1 -1 0 +$EndComp +$Comp +L Jumper_NO_Small JP1 +U 1 1 58C4940D +P 4950 1200 +F 0 "JP1" H 4950 1280 50 0000 C CNN +F 1 "Terminal" H 4960 1140 50 0000 C CNN +F 2 "Pin_Headers.pretty:Pin_Header_Straight_1x02" H 4950 1200 50 0001 C CNN +F 3 "" H 4950 1200 50 0000 C CNN + 1 4950 1200 + 1 0 0 -1 +$EndComp +Text Notes 3100 1000 2 60 ~ 0 +CAN module +Text Label 5450 7350 2 60 ~ 0 +LED0 +Text Label 5450 7450 2 60 ~ 0 +LED1 +Text Label 4450 3650 2 60 ~ 0 +LED0 +Text Label 4450 3950 2 60 ~ 0 +LED1 +$Comp +L LED-RESCUE-stm32 D5 +U 1 1 5908EA64 +P 4750 3650 +F 0 "D5" H 4750 3750 50 0000 C CNN +F 1 "LED0" H 4750 3550 50 0000 C CNN +F 2 "LEDs.pretty:LED_0805" H 4750 3650 50 0001 C CNN +F 3 "" H 4750 3650 50 0000 C CNN + 1 4750 3650 + 1 0 0 -1 +$EndComp +$Comp +L R R29 +U 1 1 5908EB17 +P 5150 3650 +F 0 "R29" V 5230 3650 50 0000 C CNN +F 1 "330" V 5150 3650 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 5080 3650 50 0001 C CNN +F 3 "" H 5150 3650 50 0000 C CNN + 1 5150 3650 + 0 -1 -1 0 +$EndComp +$Comp +L +3.3V #PWR09 +U 1 1 5908F9F4 +P 5450 3650 +F 0 "#PWR09" H 5450 3500 50 0001 C CNN +F 1 "+3.3V" H 5450 3790 50 0000 C CNN +F 2 "" H 5450 3650 50 0000 C CNN +F 3 "" H 5450 3650 50 0000 C CNN + 1 5450 3650 + 1 0 0 -1 +$EndComp +$Comp +L C C12 +U 1 1 590935EA +P 8450 9950 +F 0 "C12" H 8475 10050 50 0000 L CNN +F 1 "0.1" H 8475 9850 50 0000 L CNN +F 2 "Capacitors_SMD.pretty:C_0603_HandSoldering" H 8488 9800 50 0001 C CNN +F 3 "" H 8450 9950 50 0000 C CNN + 1 8450 9950 + 1 0 0 -1 +$EndComp +$Comp +L C C13 +U 1 1 59093675 +P 8750 9950 +F 0 "C13" H 8775 10050 50 0000 L CNN +F 1 "0.1" H 8775 9850 50 0000 L CNN +F 2 "Capacitors_SMD.pretty:C_0603_HandSoldering" H 8788 9800 50 0001 C CNN +F 3 "" H 8750 9950 50 0000 C CNN + 1 8750 9950 + 1 0 0 -1 +$EndComp +Text Label 8450 5900 0 60 ~ 0 +VDD +$Comp +L USB6B1 D7 +U 1 1 59098D4D +P 12950 8900 +F 0 "D7" H 12950 8450 50 0000 C CNN +F 1 "USB6B1" H 12950 9300 50 0000 C CNN +F 2 "Housings_SOIC.pretty:SOIC-8_3.9x4.9mm_Pitch1.27mm" V 13150 8800 50 0001 C CNN +F 3 "" V 13150 8800 50 0000 C CNN + 1 12950 8900 + -1 0 0 -1 +$EndComp +$Comp +L LED-RESCUE-stm32 D6 +U 1 1 5909AF9A +P 4750 3950 +F 0 "D6" H 4750 4050 50 0000 C CNN +F 1 "LED1" H 4750 3850 50 0000 C CNN +F 2 "LEDs.pretty:LED_0805" H 4750 3950 50 0001 C CNN +F 3 "" H 4750 3950 50 0000 C CNN + 1 4750 3950 + 1 0 0 -1 +$EndComp +$Comp +L R R30 +U 1 1 5909AFA0 +P 5150 3950 +F 0 "R30" V 5230 3950 50 0000 C CNN +F 1 "330" V 5150 3950 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 5080 3950 50 0001 C CNN +F 3 "" H 5150 3950 50 0000 C CNN + 1 5150 3950 + 0 -1 -1 0 +$EndComp +$Comp +L +3.3V #PWR010 +U 1 1 5909AFA6 +P 5450 3950 +F 0 "#PWR010" H 5450 3800 50 0001 C CNN +F 1 "+3.3V" H 5450 4090 50 0000 C CNN +F 2 "" H 5450 3950 50 0000 C CNN +F 3 "" H 5450 3950 50 0000 C CNN + 1 5450 3950 + 1 0 0 -1 +$EndComp +Text Notes 4300 3400 0 60 ~ 0 +LED indicators +$Comp +L LED-RESCUE-stm32 D2 +U 1 1 5909BFFC +P 3100 5050 +F 0 "D2" H 3100 5150 50 0000 C CNN +F 1 "LED" H 3100 4950 50 0000 C CNN +F 2 "LEDs.pretty:LED_0805" H 3100 5050 50 0001 C CNN +F 3 "" H 3100 5050 50 0000 C CNN + 1 3100 5050 + 0 -1 -1 0 +$EndComp +$Comp +L R R5 +U 1 1 5909C002 +P 2850 5350 +F 0 "R5" V 2930 5350 50 0000 C CNN +F 1 "330" V 2850 5350 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 2780 5350 50 0001 C CNN +F 3 "" H 2850 5350 50 0000 C CNN + 1 2850 5350 + 0 -1 -1 0 +$EndComp +Text Notes 1000 4600 0 60 ~ 0 +3.3V MCU power source +NoConn ~ 3050 1650 +$Comp +L +3.3V #PWR011 +U 1 1 590A0C2D +P 9450 10100 +F 0 "#PWR011" H 9450 9950 50 0001 C CNN +F 1 "+3.3V" H 9450 10240 50 0000 C CNN +F 2 "" H 9450 10100 50 0000 C CNN +F 3 "" H 9450 10100 50 0000 C CNN + 1 9450 10100 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR012 +U 1 1 590A1958 +P 7800 9800 +F 0 "#PWR012" H 7800 9550 50 0001 C CNN +F 1 "GND" H 7800 9650 50 0000 C CNN +F 2 "" H 7800 9800 50 0000 C CNN +F 3 "" H 7800 9800 50 0000 C CNN + 1 7800 9800 + 1 0 0 -1 +$EndComp +Text Label 9550 10100 0 60 ~ 0 +VDD +$Comp +L GND #PWR013 +U 1 1 590A6FD0 +P 12450 9300 +F 0 "#PWR013" H 12450 9050 50 0001 C CNN +F 1 "GND" H 12450 9150 50 0000 C CNN +F 2 "" H 12450 9300 50 0000 C CNN +F 3 "" H 12450 9300 50 0000 C CNN + 1 12450 9300 + 1 0 0 -1 +$EndComp +$Comp +L C C14 +U 1 1 590A8102 +P 9050 9950 +F 0 "C14" H 9075 10050 50 0000 L CNN +F 1 "0.1" H 9075 9850 50 0000 L CNN +F 2 "Capacitors_SMD.pretty:C_0603_HandSoldering" H 9088 9800 50 0001 C CNN +F 3 "" H 9050 9950 50 0000 C CNN + 1 9050 9950 + 1 0 0 -1 +$EndComp +NoConn ~ 5450 6750 +$Comp +L CONN_01X03 P12 +U 1 1 590AD3A7 +P 12200 9600 +F 0 "P12" H 12200 9800 50 0000 C CNN +F 1 "USART_BOOT" V 12300 9600 50 0000 C CNN +F 2 "Pin_Headers.pretty:Pin_Header_Straight_1x03" H 12200 9600 50 0001 C CNN +F 3 "" H 12200 9600 50 0000 C CNN + 1 12200 9600 + 1 0 0 1 +$EndComp +$Comp +L GND #PWR014 +U 1 1 590AD6E0 +P 12000 9750 +F 0 "#PWR014" H 12000 9500 50 0001 C CNN +F 1 "GND" H 12000 9600 50 0000 C CNN +F 2 "" H 12000 9750 50 0000 C CNN +F 3 "" H 12000 9750 50 0000 C CNN + 1 12000 9750 + -1 0 0 -1 +$EndComp +Text Label 2850 1350 2 60 ~ 0 +CAN_Tx +Text Label 2850 1450 2 60 ~ 0 +CAN_Rx +Text Label 5450 8650 2 60 ~ 0 +CAN_Tx +Text Label 5450 8550 2 60 ~ 0 +CAN_Rx +Text Label 6350 2900 0 60 ~ 0 +12Vin +$Comp +L Q_PMOS_GSD Q1 +U 1 1 5910E2F2 +P 5500 2700 +F 0 "Q1" H 5700 2750 50 0000 L CNN +F 1 "AO3407" H 5700 2650 50 0000 L CNN +F 2 "TO_SOT_Packages_SMD.pretty:SOT-23_Handsoldering" H 5700 2800 50 0001 C CNN +F 3 "" H 5500 2700 50 0000 C CNN + 1 5500 2700 + 1 0 0 -1 +$EndComp +Text Label 11650 7750 0 60 ~ 0 +V12 +Text Label 11650 7850 0 60 ~ 0 +V5 +Text Notes 11900 7750 0 60 ~ 0 +External 12V voltage control +Text Notes 11900 7850 0 60 ~ 0 +External 5V voltage control +$Comp +L R R3 +U 1 1 590A6DD4 +P 1600 6050 +F 0 "R3" V 1680 6050 50 0000 C CNN +F 1 "220k" V 1600 6050 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 1530 6050 50 0001 C CNN +F 3 "" H 1600 6050 50 0000 C CNN + 1 1600 6050 + 1 0 0 -1 +$EndComp +$Comp +L R R4 +U 1 1 590A6DDA +P 1600 6450 +F 0 "R4" V 1680 6450 50 0000 C CNN +F 1 "56k" V 1600 6450 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 1530 6450 50 0001 C CNN +F 3 "" H 1600 6450 50 0000 C CNN + 1 1600 6450 + 1 0 0 -1 +$EndComp +$Comp +L R R6 +U 1 1 590A6F68 +P 2400 6050 +F 0 "R6" V 2480 6050 50 0000 C CNN +F 1 "47k" V 2400 6050 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 2330 6050 50 0001 C CNN +F 3 "" H 2400 6050 50 0000 C CNN + 1 2400 6050 + 1 0 0 -1 +$EndComp +$Comp +L R R7 +U 1 1 590A6F6E +P 2400 6450 +F 0 "R7" V 2480 6450 50 0000 C CNN +F 1 "47k" V 2400 6450 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 2330 6450 50 0001 C CNN +F 3 "" H 2400 6450 50 0000 C CNN + 1 2400 6450 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR015 +U 1 1 590A7717 +P 1600 6650 +F 0 "#PWR015" H 1600 6400 50 0001 C CNN +F 1 "GND" H 1600 6500 50 0000 C CNN +F 2 "" H 1600 6650 50 0000 C CNN +F 3 "" H 1600 6650 50 0000 C CNN + 1 1600 6650 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR016 +U 1 1 590A77FA +P 2400 6650 +F 0 "#PWR016" H 2400 6400 50 0001 C CNN +F 1 "GND" H 2400 6500 50 0000 C CNN +F 2 "" H 2400 6650 50 0000 C CNN +F 3 "" H 2400 6650 50 0000 C CNN + 1 2400 6650 + 1 0 0 -1 +$EndComp +Text Label 1450 5900 2 60 ~ 0 +12Vin +$Comp +L +5V #PWR017 +U 1 1 590AA81F +P 2400 5850 +F 0 "#PWR017" H 2400 5700 50 0001 C CNN +F 1 "+5V" H 2400 5990 50 0000 C CNN +F 2 "" H 2400 5850 50 0000 C CNN +F 3 "" H 2400 5850 50 0000 C CNN + 1 2400 5850 + 1 0 0 -1 +$EndComp +Text Label 1950 6250 0 60 ~ 0 +V12 +Text Label 2750 6250 0 60 ~ 0 +V5 +Text Notes 1350 7000 0 60 ~ 0 +V12 = 12Vin/4.93 +Text Notes 2350 7000 0 60 ~ 0 +V5 = U5/2 +Text Notes 1100 5700 0 60 ~ 0 +ADC block (voltage) +Text Notes 1050 950 0 60 ~ 0 +Bootloader init +Text Label 5450 6550 2 60 ~ 0 +NRST +Text Label 1350 2000 2 60 ~ 0 +NRST +Text Label 5450 7150 2 60 ~ 0 +BOOT0 +Text Label 1350 1100 0 60 ~ 0 +BOOT0 +$Comp +L R R27 +U 1 1 590D30C8 +P 1350 1400 +F 0 "R27" V 1430 1400 50 0000 C CNN +F 1 "10k" V 1350 1400 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 1280 1400 50 0001 C CNN +F 3 "" H 1350 1400 50 0000 C CNN + 1 1350 1400 + 1 0 0 -1 +$EndComp +$Comp +L R R28 +U 1 1 590D3334 +P 1350 2250 +F 0 "R28" V 1430 2250 50 0000 C CNN +F 1 "10k" V 1350 2250 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 1280 2250 50 0001 C CNN +F 3 "" H 1350 2250 50 0000 C CNN + 1 1350 2250 + 1 0 0 -1 +$EndComp +$Comp +L C C6 +U 1 1 590D4150 +P 1950 1400 +F 0 "C6" H 1975 1500 50 0000 L CNN +F 1 "0.1" H 1975 1300 50 0000 L CNN +F 2 "Capacitors_SMD.pretty:C_0603_HandSoldering" H 1988 1250 50 0001 C CNN +F 3 "" H 1950 1400 50 0000 C CNN + 1 1950 1400 + 1 0 0 -1 +$EndComp +$Comp +L C C5 +U 1 1 590D4832 +P 1900 2250 +F 0 "C5" H 1925 2350 50 0000 L CNN +F 1 "0.1" H 1925 2150 50 0000 L CNN +F 2 "Capacitors_SMD.pretty:C_0603_HandSoldering" H 1938 2100 50 0001 C CNN +F 3 "" H 1900 2250 50 0000 C CNN + 1 1900 2250 + 1 0 0 -1 +$EndComp +$Comp +L SW_Push SW2 +U 1 1 5909F6B6 +P 1650 1400 +F 0 "SW2" H 1700 1500 50 0000 L CNN +F 1 "Boot" H 1650 1340 50 0000 C CNN +F 2 "Buttons_Switches_SMD.pretty:SW_SPST_FSMSM" H 1650 1600 50 0001 C CNN +F 3 "" H 1650 1600 50 0000 C CNN + 1 1650 1400 + 0 1 1 0 +$EndComp +$Comp +L SW_Push SW1 +U 1 1 590A0134 +P 1600 2250 +F 0 "SW1" H 1650 2350 50 0000 L CNN +F 1 "Reset" H 1600 2190 50 0000 C CNN +F 2 "Buttons_Switches_SMD.pretty:SW_SPST_FSMSM" H 1600 2450 50 0001 C CNN +F 3 "" H 1600 2450 50 0000 C CNN + 1 1600 2250 + 0 1 1 0 +$EndComp +$Comp +L GND #PWR018 +U 1 1 590A03AF +P 1350 1600 +F 0 "#PWR018" H 1350 1350 50 0001 C CNN +F 1 "GND" H 1350 1450 50 0000 C CNN +F 2 "" H 1350 1600 50 0000 C CNN +F 3 "" H 1350 1600 50 0000 C CNN + 1 1350 1600 + 1 0 0 -1 +$EndComp +$Comp +L +3.3V #PWR019 +U 1 1 590A1E6C +P 1800 1650 +F 0 "#PWR019" H 1800 1500 50 0001 C CNN +F 1 "+3.3V" H 1800 1790 50 0000 C CNN +F 2 "" H 1800 1650 50 0000 C CNN +F 3 "" H 1800 1650 50 0000 C CNN + 1 1800 1650 + -1 0 0 1 +$EndComp +$Comp +L +3.3V #PWR020 +U 1 1 590A465B +P 1350 2500 +F 0 "#PWR020" H 1350 2350 50 0001 C CNN +F 1 "+3.3V" H 1350 2640 50 0000 C CNN +F 2 "" H 1350 2500 50 0000 C CNN +F 3 "" H 1350 2500 50 0000 C CNN + 1 1350 2500 + -1 0 0 1 +$EndComp +$Comp +L GND #PWR021 +U 1 1 590A509B +P 1750 2500 +F 0 "#PWR021" H 1750 2250 50 0001 C CNN +F 1 "GND" H 1750 2350 50 0000 C CNN +F 2 "" H 1750 2500 50 0000 C CNN +F 3 "" H 1750 2500 50 0000 C CNN + 1 1750 2500 + 1 0 0 -1 +$EndComp +$Comp +L PWR_FLAG #FLG022 +U 1 1 590C1070 +P 6250 2900 +F 0 "#FLG022" H 6250 2995 50 0001 C CNN +F 1 "PWR_FLAG" H 6250 3080 50 0000 C CNN +F 2 "" H 6250 2900 50 0000 C CNN +F 3 "" H 6250 2900 50 0000 C CNN + 1 6250 2900 + -1 0 0 1 +$EndComp +$Comp +L PWR_FLAG #FLG023 +U 1 1 590CEE5E +P 14000 8600 +F 0 "#FLG023" H 14000 8695 50 0001 C CNN +F 1 "PWR_FLAG" H 14000 8780 50 0000 C CNN +F 2 "" H 14000 8600 50 0000 C CNN +F 3 "" H 14000 8600 50 0000 C CNN + 1 14000 8600 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR024 +U 1 1 590CF25B +P 14400 9300 +F 0 "#PWR024" H 14400 9050 50 0001 C CNN +F 1 "GND" H 14400 9150 50 0000 C CNN +F 2 "" H 14400 9300 50 0000 C CNN +F 3 "" H 14400 9300 50 0000 C CNN + 1 14400 9300 + 1 0 0 -1 +$EndComp +$Comp +L PWR_FLAG #FLG025 +U 1 1 590D075A +P 13450 9350 +F 0 "#FLG025" H 13450 9445 50 0001 C CNN +F 1 "PWR_FLAG" H 13450 9530 50 0000 C CNN +F 2 "" H 13450 9350 50 0000 C CNN +F 3 "" H 13450 9350 50 0000 C CNN + 1 13450 9350 + -1 0 0 1 +$EndComp +$Comp +L CONN_01X01 P15 +U 1 1 59143415 +P 15700 8850 +F 0 "P15" H 15700 8950 50 0000 C CNN +F 1 "Hole" V 15800 8850 50 0000 C CNN +F 2 "my_footprints:Hole_3mm" H 15700 8850 50 0001 C CNN +F 3 "" H 15700 8850 50 0000 C CNN + 1 15700 8850 + 1 0 0 -1 +$EndComp +$Comp +L CONN_01X01 P16 +U 1 1 5914456D +P 15700 9100 +F 0 "P16" H 15700 9200 50 0000 C CNN +F 1 "Hole" V 15800 9100 50 0000 C CNN +F 2 "my_footprints:Hole_3mm" H 15700 9100 50 0001 C CNN +F 3 "" H 15700 9100 50 0000 C CNN + 1 15700 9100 + 1 0 0 -1 +$EndComp +$Comp +L CONN_01X01 P17 +U 1 1 591446F3 +P 15700 9350 +F 0 "P17" H 15700 9450 50 0000 C CNN +F 1 "Hole" V 15800 9350 50 0000 C CNN +F 2 "my_footprints:Hole_3mm" H 15700 9350 50 0001 C CNN +F 3 "" H 15700 9350 50 0000 C CNN + 1 15700 9350 + 1 0 0 -1 +$EndComp +$Comp +L CONN_01X01 P18 +U 1 1 591446F9 +P 15700 9600 +F 0 "P18" H 15700 9700 50 0000 C CNN +F 1 "Hole" V 15800 9600 50 0000 C CNN +F 2 "my_footprints:Hole_3mm" H 15700 9600 50 0001 C CNN +F 3 "" H 15700 9600 50 0000 C CNN + 1 15700 9600 + 1 0 0 -1 +$EndComp +NoConn ~ 15500 8850 +NoConn ~ 15500 9100 +NoConn ~ 15500 9350 +NoConn ~ 15500 9600 +$Comp +L C C15 +U 1 1 596772D4 +P 1350 3600 +F 0 "C15" H 1375 3700 50 0000 L CNN +F 1 "0.1" H 1375 3500 50 0000 L CNN +F 2 "Capacitors_SMD.pretty:C_0603_HandSoldering" H 1388 3450 50 0001 C CNN +F 3 "" H 1350 3600 50 0000 C CNN + 1 1350 3600 + 1 0 0 -1 +$EndComp +$Comp +L D_Zener D9 +U 1 1 5968325A +P 2650 6450 +F 0 "D9" H 2650 6550 50 0000 C CNN +F 1 "SMAJ5.0A" H 2650 6350 50 0000 C CNN +F 2 "Diode_SMD.pretty:D_SMA" H 2650 6450 50 0001 C CNN +F 3 "" H 2650 6450 50 0000 C CNN + 1 2650 6450 + 0 1 1 0 +$EndComp +$Comp +L D_Zener D8 +U 1 1 59684468 +P 1850 6450 +F 0 "D8" H 1850 6550 50 0000 C CNN +F 1 "SMAJ5.0A" H 1850 6350 50 0000 C CNN +F 2 "Diode_SMD.pretty:D_SMA" H 1850 6450 50 0001 C CNN +F 3 "" H 1850 6450 50 0000 C CNN + 1 1850 6450 + 0 1 1 0 +$EndComp +$Comp +L R R34 +U 1 1 5968E385 +P 12200 8800 +F 0 "R34" V 12280 8800 50 0000 C CNN +F 1 "22" V 12200 8800 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 12130 8800 50 0001 C CNN +F 3 "" H 12200 8800 50 0001 C CNN + 1 12200 8800 + 0 1 1 0 +$EndComp +$Comp +L R R35 +U 1 1 5968E83B +P 12200 9000 +F 0 "R35" V 12280 9000 50 0000 C CNN +F 1 "22" V 12200 9000 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 12130 9000 50 0001 C CNN +F 3 "" H 12200 9000 50 0001 C CNN + 1 12200 9000 + 0 1 1 0 +$EndComp +Text Label 5450 9150 2 60 ~ 0 +brdaddr0 +Text Label 5450 9250 2 60 ~ 0 +brdaddr1 +Text Label 11650 8550 0 60 ~ 0 +brdaddr2 +$Comp +L CONN_02X03 J1 +U 1 1 5A50A198 +P 6600 3650 +F 0 "J1" H 6600 3850 50 0000 C CNN +F 1 "CONN_02X03" H 6600 3450 50 0000 C CNN +F 2 "Pin_Headers.pretty:Pin_Header_Straight_2x03_Pitch2.54mm" H 6600 2450 50 0001 C CNN +F 3 "" H 6600 2450 50 0001 C CNN + 1 6600 3650 + 1 0 0 -1 +$EndComp +Text Notes 6300 3400 0 60 ~ 0 +Board address +Text Label 6850 3550 0 60 ~ 0 +brdaddr0 +Text Label 6850 3650 0 60 ~ 0 +brdaddr1 +Text Label 6850 3750 0 60 ~ 0 +brdaddr2 +$Comp +L GND #PWR026 +U 1 1 5A50D34D +P 6250 3800 +F 0 "#PWR026" H 6250 3550 50 0001 C CNN +F 1 "GND" H 6250 3650 50 0000 C CNN +F 2 "" H 6250 3800 50 0000 C CNN +F 3 "" H 6250 3800 50 0000 C CNN + 1 6250 3800 + 1 0 0 -1 +$EndComp +NoConn ~ 5450 9050 +NoConn ~ 5450 7550 +Text Label 12450 8600 2 60 ~ 0 +5Vusb +Text Label 1300 5150 2 60 ~ 0 +5Vusb +Text Label 1300 4900 2 60 ~ 0 +5Vreg +$Comp +L D_Schottky D4 +U 1 1 5A545B43 +P 1500 5150 +F 0 "D4" H 1500 5250 50 0000 C CNN +F 1 "MBRS130L" H 1500 5050 50 0000 C CNN +F 2 "Diodes_SMD.pretty:D_SMB_Handsoldering" H 1500 5150 50 0001 C CNN +F 3 "" H 1500 5150 50 0001 C CNN + 1 1500 5150 + -1 0 0 1 +$EndComp +$Comp +L LM1117-3.3-RESCUE-stm32 U1 +U 1 1 5A5866DE +P 2000 3400 +F 0 "U1" H 2100 3150 50 0000 C CNN +F 1 "LM1117-5.0" H 2000 3650 50 0000 C CNN +F 2 "TO_SOT_Packages_SMD.pretty:SOT-223" H 2000 3400 50 0001 C CNN +F 3 "" H 2000 3400 50 0000 C CNN + 1 2000 3400 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR027 +U 1 1 5A586C06 +P 2000 3800 +F 0 "#PWR027" H 2000 3550 50 0001 C CNN +F 1 "GND" H 2000 3650 50 0000 C CNN +F 2 "" H 2000 3800 50 0000 C CNN +F 3 "" H 2000 3800 50 0000 C CNN + 1 2000 3800 + 1 0 0 -1 +$EndComp +$Comp +L C C1 +U 1 1 5A586F5C +P 2400 3550 +F 0 "C1" H 2425 3650 50 0000 L CNN +F 1 "0.1" H 2425 3450 50 0000 L CNN +F 2 "Capacitors_SMD.pretty:C_0603_HandSoldering" H 2438 3400 50 0001 C CNN +F 3 "" H 2400 3550 50 0000 C CNN + 1 2400 3550 + 1 0 0 -1 +$EndComp +$Comp +L +5V #PWR028 +U 1 1 5A5881A0 +P 2700 3400 +F 0 "#PWR028" H 2700 3250 50 0001 C CNN +F 1 "+5V" H 2700 3540 50 0000 C CNN +F 2 "" H 2700 3400 50 0000 C CNN +F 3 "" H 2700 3400 50 0000 C CNN + 1 2700 3400 + 1 0 0 -1 +$EndComp +NoConn ~ 11650 8050 +NoConn ~ 11650 7950 +NoConn ~ 5450 8950 +Text Label 1250 3400 0 60 ~ 0 +12Vin +$Comp +L DB9_Female J2 +U 1 1 5A5935B2 +P 6000 1650 +F 0 "J2" H 6000 2300 50 0000 C CNN +F 1 "DB9_Female" H 6000 2225 50 0000 C CNN +F 2 "Connectors.pretty:DB9FC" H 6000 1650 50 0001 C CNN +F 3 "" H 6000 1650 50 0001 C CNN + 1 6000 1650 + 1 0 0 -1 +$EndComp +$Comp +L DB9_Male J3 +U 1 1 5A59367B +P 7100 1650 +F 0 "J3" H 7100 2300 50 0000 C CNN +F 1 "DB9_Male" H 7100 2225 50 0000 C CNN +F 2 "Connectors.pretty:DB9MC" H 7100 1650 50 0001 C CNN +F 3 "" H 7100 1650 50 0001 C CNN + 1 7100 1650 + 1 0 0 -1 +$EndComp +Wire Wire Line + 1250 3400 1700 3400 +Wire Wire Line + 1600 3750 1600 3700 +Wire Notes Line + 950 2950 950 4250 +Wire Notes Line + 950 4250 3850 4250 +Wire Notes Line + 3850 4250 3850 2950 +Wire Notes Line + 3850 2950 950 2950 +Wire Wire Line + 1300 4900 2050 4900 +Wire Wire Line + 2350 5250 2350 5200 +Wire Wire Line + 2350 5200 2750 5200 +Wire Wire Line + 2650 4900 3100 4900 +Connection ~ 2750 4900 +Wire Wire Line + 4350 1650 4350 2150 +Wire Wire Line + 4450 2900 4450 2850 +Wire Wire Line + 3550 1100 3550 1150 +Wire Wire Line + 3000 1800 3000 1750 +Wire Wire Line + 3000 1750 3050 1750 +Wire Wire Line + 3000 2150 3000 2100 +Wire Wire Line + 3550 1950 3550 2050 +Connection ~ 4350 1650 +Wire Wire Line + 5050 1200 5050 1800 +Wire Wire Line + 4750 1800 4750 1650 +Connection ~ 4750 1650 +Wire Wire Line + 4850 1450 4850 1200 +Connection ~ 4850 1450 +Wire Wire Line + 3050 1350 2850 1350 +Wire Wire Line + 3050 1450 2850 1450 +Wire Wire Line + 8350 9650 8650 9650 +Connection ~ 8450 9650 +Wire Wire Line + 8450 9800 8450 9650 +Wire Wire Line + 8350 6050 8650 6050 +Connection ~ 8450 6050 +Wire Wire Line + 8450 6050 8450 5900 +Wire Wire Line + 11650 8850 12000 8850 +Wire Wire Line + 12000 8850 12000 8800 +Wire Wire Line + 12000 9000 12000 8950 +Wire Wire Line + 12000 8950 11650 8950 +Wire Wire Line + 13450 9000 13650 9000 +Wire Wire Line + 13650 9000 13650 8950 +Wire Wire Line + 13650 8950 14000 8950 +Wire Wire Line + 14000 8850 13650 8850 +Wire Wire Line + 13650 8850 13650 8800 +Wire Wire Line + 13650 8800 13450 8800 +Wire Wire Line + 4450 3650 4600 3650 +Wire Wire Line + 4900 3650 5000 3650 +Wire Wire Line + 5300 3650 5450 3650 +Wire Wire Line + 4450 3950 4600 3950 +Wire Wire Line + 4900 3950 5000 3950 +Wire Wire Line + 5300 3950 5450 3950 +Wire Notes Line + 4150 3300 4150 4100 +Wire Notes Line + 4150 4100 5650 4100 +Wire Notes Line + 5650 4100 5650 3300 +Wire Notes Line + 5650 3300 4150 3300 +Wire Wire Line + 3000 5350 3100 5350 +Wire Wire Line + 3100 5350 3100 5200 +Wire Wire Line + 2700 5350 2700 5200 +Connection ~ 2700 5200 +Connection ~ 2950 4900 +Wire Notes Line + 950 4450 3850 4450 +Wire Notes Line + 3850 4450 3850 5500 +Wire Notes Line + 3850 5500 950 5500 +Wire Notes Line + 950 5500 950 4450 +Wire Wire Line + 7800 9800 9050 9800 +Connection ~ 8450 9800 +Wire Wire Line + 8150 10100 9550 10100 +Connection ~ 8450 10100 +Connection ~ 8150 9800 +Connection ~ 8750 10100 +Connection ~ 9450 10100 +Connection ~ 8550 6050 +Connection ~ 8550 9650 +Wire Wire Line + 14000 8750 14000 8600 +Wire Wire Line + 14000 8600 13450 8600 +Wire Wire Line + 14000 9050 14000 9200 +Wire Wire Line + 14000 9200 13450 9200 +Wire Wire Line + 12450 9300 12450 9200 +Connection ~ 8750 9800 +Wire Wire Line + 9050 10100 8750 10100 +Connection ~ 9050 10100 +Wire Wire Line + 12000 9700 12000 9750 +Wire Wire Line + 5600 2900 6350 2900 +Wire Wire Line + 2400 5900 2400 5850 +Wire Wire Line + 2400 6200 2400 6300 +Wire Wire Line + 2400 6600 2400 6650 +Wire Wire Line + 1450 5900 1600 5900 +Wire Wire Line + 1600 6200 1600 6300 +Wire Wire Line + 1600 6600 1600 6650 +Wire Wire Line + 1600 6250 1950 6250 +Connection ~ 1600 6250 +Wire Wire Line + 2400 6250 2750 6250 +Connection ~ 2400 6250 +Wire Notes Line + 950 5600 3950 5600 +Wire Notes Line + 3950 5600 3950 7050 +Wire Notes Line + 3950 7050 950 7050 +Wire Notes Line + 950 7050 950 5600 +Wire Wire Line + 1350 1600 1350 1550 +Wire Wire Line + 1350 1100 1350 1250 +Wire Wire Line + 1950 1200 1950 1250 +Wire Wire Line + 1350 1200 1950 1200 +Connection ~ 1650 1200 +Connection ~ 1350 1200 +Wire Wire Line + 1650 1600 1950 1600 +Wire Wire Line + 1950 1600 1950 1550 +Wire Wire Line + 1800 1650 1800 1600 +Connection ~ 1800 1600 +Wire Wire Line + 1350 2000 1350 2100 +Wire Wire Line + 1350 2500 1350 2400 +Wire Wire Line + 1350 2050 1900 2050 +Connection ~ 1350 2050 +Wire Wire Line + 1900 2050 1900 2100 +Connection ~ 1600 2050 +Wire Wire Line + 1600 2450 1900 2450 +Wire Wire Line + 1900 2450 1900 2400 +Wire Wire Line + 1750 2500 1750 2450 +Connection ~ 1750 2450 +Wire Notes Line + 950 800 950 2750 +Wire Notes Line + 950 2750 2300 2750 +Wire Notes Line + 2300 2750 2300 800 +Wire Notes Line + 2300 800 950 800 +Connection ~ 6250 2900 +Connection ~ 14000 8600 +Wire Wire Line + 14400 9300 14400 9250 +Wire Wire Line + 13450 9200 13450 9350 +Connection ~ 13450 9200 +Wire Wire Line + 1350 3450 1350 3400 +Connection ~ 1350 3400 +Wire Wire Line + 1350 3750 1600 3750 +Connection ~ 1600 3750 +Wire Wire Line + 2650 6300 2650 6250 +Connection ~ 2650 6250 +Wire Wire Line + 2400 6650 2650 6650 +Wire Wire Line + 2650 6650 2650 6600 +Wire Wire Line + 1600 6650 1850 6650 +Wire Wire Line + 1850 6650 1850 6600 +Connection ~ 2400 6650 +Connection ~ 1600 6650 +Wire Wire Line + 1850 6300 1850 6250 +Connection ~ 1850 6250 +Wire Wire Line + 12000 8800 12050 8800 +Wire Wire Line + 12350 8800 12450 8800 +Wire Wire Line + 12450 9000 12350 9000 +Wire Wire Line + 12050 9000 12000 9000 +Wire Wire Line + 5450 1650 4050 1650 +Wire Wire Line + 6250 3800 6250 3750 +Wire Wire Line + 6250 3750 6350 3750 +Wire Wire Line + 6350 3750 6350 3550 +Connection ~ 6350 3650 +Connection ~ 6350 3750 +Wire Notes Line + 6100 3300 7300 3300 +Wire Notes Line + 7300 3300 7300 4100 +Wire Notes Line + 7300 4100 6100 4100 +Wire Notes Line + 6100 4100 6100 3300 +Wire Wire Line + 1800 5150 1800 4900 +Connection ~ 1800 4900 +Wire Wire Line + 1650 5150 1800 5150 +Wire Wire Line + 1350 5150 1300 5150 +Wire Wire Line + 2650 4850 2650 4950 +Connection ~ 2650 4900 +Connection ~ 2350 5200 +Wire Wire Line + 2000 3700 2000 3800 +Wire Wire Line + 2300 3350 2300 3450 +Wire Wire Line + 2300 3400 2850 3400 +Connection ~ 2300 3400 +Wire Wire Line + 2000 3750 2400 3750 +Wire Wire Line + 2400 3750 2400 3700 +Connection ~ 2000 3750 +Connection ~ 2400 3400 +Wire Wire Line + 5450 900 5450 1650 +Wire Wire Line + 5450 1450 5700 1450 +Wire Wire Line + 5450 900 6500 900 +Wire Wire Line + 6500 900 6500 1850 +Wire Wire Line + 6500 1850 6800 1850 +Connection ~ 5450 1450 +Wire Wire Line + 5250 850 5250 1550 +Wire Wire Line + 5250 1550 5700 1550 +Wire Wire Line + 6800 1750 6550 1750 +Wire Wire Line + 6550 1750 6550 850 +Wire Wire Line + 6550 850 5250 850 +Connection ~ 5250 1450 +Wire Wire Line + 6650 1350 6650 2500 +Wire Wire Line + 6650 1350 6800 1350 +Wire Wire Line + 5700 1950 5600 1950 +Wire Wire Line + 5600 1950 5600 2500 +Wire Wire Line + 5600 2350 6650 2350 +Connection ~ 5600 2350 +Wire Wire Line + 5700 1650 5550 1650 +Wire Wire Line + 5550 1650 5550 1750 +$Comp +L GND #PWR029 +U 1 1 5A597EA9 +P 5550 1750 +F 0 "#PWR029" H 5550 1500 50 0001 C CNN +F 1 "GND" H 5550 1600 50 0000 C CNN +F 2 "" H 5550 1750 50 0000 C CNN +F 3 "" H 5550 1750 50 0000 C CNN + 1 5550 1750 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR030 +U 1 1 5A597F41 +P 6300 1650 +F 0 "#PWR030" H 6300 1400 50 0001 C CNN +F 1 "GND" H 6300 1500 50 0000 C CNN +F 2 "" H 6300 1650 50 0000 C CNN +F 3 "" H 6300 1650 50 0000 C CNN + 1 6300 1650 + 1 0 0 -1 +$EndComp +Wire Wire Line + 6300 1650 6800 1650 +$Comp +L GND #PWR031 +U 1 1 5A598436 +P 5300 2750 +F 0 "#PWR031" H 5300 2500 50 0001 C CNN +F 1 "GND" H 5300 2600 50 0000 C CNN +F 2 "" H 5300 2750 50 0000 C CNN +F 3 "" H 5300 2750 50 0000 C CNN + 1 5300 2750 + 1 0 0 -1 +$EndComp +Wire Wire Line + 5300 2750 5300 2700 +NoConn ~ 6800 2050 +NoConn ~ 6800 1950 +NoConn ~ 6800 1550 +NoConn ~ 6800 1450 +NoConn ~ 6800 1250 +NoConn ~ 5700 1250 +NoConn ~ 5700 1350 +NoConn ~ 5700 1750 +NoConn ~ 5700 1850 +NoConn ~ 5700 2050 +Wire Notes Line + 2450 800 7650 800 +Wire Notes Line + 7650 800 7650 3150 +Wire Notes Line + 7650 3150 4150 3150 +Wire Notes Line + 4150 3150 4150 2450 +Wire Notes Line + 4150 2450 2450 2450 +Wire Notes Line + 2450 2450 2450 800 +$Comp +L PWR_FLAG #FLG032 +U 1 1 5A59F726 +P 5300 1850 +F 0 "#FLG032" H 5300 1925 50 0001 C CNN +F 1 "PWR_FLAG" H 5300 2000 50 0000 C CNN +F 2 "" H 5300 1850 50 0001 C CNN +F 3 "" H 5300 1850 50 0001 C CNN + 1 5300 1850 + -1 0 0 1 +$EndComp +$Comp +L Q_NMOS_GSD Q2 +U 1 1 5A5A1353 +P 8800 1200 +F 0 "Q2" H 9000 1250 50 0000 L CNN +F 1 "SI2300" H 9000 1150 50 0000 L CNN +F 2 "TO_SOT_Packages_SMD.pretty:SOT-23_Handsoldering" H 9000 1300 50 0001 C CNN +F 3 "" H 8800 1200 50 0001 C CNN + 1 8800 1200 + 1 0 0 -1 +$EndComp +$Comp +L R R1 +U 1 1 5A5A1F28 +P 8350 1200 +F 0 "R1" V 8430 1200 50 0000 C CNN +F 1 "330" V 8350 1200 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 8280 1200 50 0001 C CNN +F 3 "" H 8350 1200 50 0000 C CNN + 1 8350 1200 + 0 -1 -1 0 +$EndComp +Wire Wire Line + 8500 1200 8600 1200 +$Comp +L GND #PWR033 +U 1 1 5A5A2353 +P 8900 1450 +F 0 "#PWR033" H 8900 1200 50 0001 C CNN +F 1 "GND" H 8900 1300 50 0000 C CNN +F 2 "" H 8900 1450 50 0000 C CNN +F 3 "" H 8900 1450 50 0000 C CNN + 1 8900 1450 + 1 0 0 -1 +$EndComp +Wire Wire Line + 8900 1450 8900 1400 +$Comp +L Conn_01x07 J4 +U 1 1 5A5A2990 +P 10450 2100 +F 0 "J4" H 10450 2500 50 0000 C CNN +F 1 "Conn_01x07" H 10450 1700 50 0000 C CNN +F 2 "Pin_Headers.pretty:Pin_Header_Straight_1x07_Pitch2.54mm" H 10450 2100 50 0001 C CNN +F 3 "" H 10450 2100 50 0001 C CNN + 1 10450 2100 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR034 +U 1 1 5A5A2ECA +P 10150 2500 +F 0 "#PWR034" H 10150 2250 50 0001 C CNN +F 1 "GND" H 10150 2350 50 0000 C CNN +F 2 "" H 10150 2500 50 0000 C CNN +F 3 "" H 10150 2500 50 0000 C CNN + 1 10150 2500 + 1 0 0 -1 +$EndComp +Wire Wire Line + 10150 2500 10150 2400 +Wire Wire Line + 10150 2400 10250 2400 +$Comp +L +3.3V #PWR035 +U 1 1 5A5A3661 +P 10150 1250 +F 0 "#PWR035" H 10150 1100 50 0001 C CNN +F 1 "+3.3V" H 10150 1390 50 0000 C CNN +F 2 "" H 10150 1250 50 0000 C CNN +F 3 "" H 10150 1250 50 0000 C CNN + 1 10150 1250 + 1 0 0 -1 +$EndComp +$Comp +L R R13 +U 1 1 5A5A3B4E +P 10150 1450 +F 0 "R13" V 10230 1450 50 0000 C CNN +F 1 "4.7" V 10150 1450 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 10080 1450 50 0001 C CNN +F 3 "" H 10150 1450 50 0000 C CNN + 1 10150 1450 + 1 0 0 -1 +$EndComp +Wire Wire Line + 10150 1300 10150 1250 +Wire Wire Line + 10150 1600 10150 1800 +Wire Wire Line + 10150 1800 10250 1800 +Text Label 8900 1000 0 60 ~ 0 +OUTP1 +Text Label 10250 1900 2 60 ~ 0 +OUTP1 +$Comp +L Q_NMOS_GSD Q3 +U 1 1 5A5A57A1 +P 8800 2000 +F 0 "Q3" H 9000 2050 50 0000 L CNN +F 1 "SI2300" H 9000 1950 50 0000 L CNN +F 2 "TO_SOT_Packages_SMD.pretty:SOT-23_Handsoldering" H 9000 2100 50 0001 C CNN +F 3 "" H 8800 2000 50 0001 C CNN + 1 8800 2000 + 1 0 0 -1 +$EndComp +$Comp +L R R2 +U 1 1 5A5A57A7 +P 8350 2000 +F 0 "R2" V 8430 2000 50 0000 C CNN +F 1 "330" V 8350 2000 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 8280 2000 50 0001 C CNN +F 3 "" H 8350 2000 50 0000 C CNN + 1 8350 2000 + 0 -1 -1 0 +$EndComp +Wire Wire Line + 8500 2000 8600 2000 +$Comp +L GND #PWR036 +U 1 1 5A5A57AE +P 8900 2250 +F 0 "#PWR036" H 8900 2000 50 0001 C CNN +F 1 "GND" H 8900 2100 50 0000 C CNN +F 2 "" H 8900 2250 50 0000 C CNN +F 3 "" H 8900 2250 50 0000 C CNN + 1 8900 2250 + 1 0 0 -1 +$EndComp +Wire Wire Line + 8900 2250 8900 2200 +Text Label 8900 1800 0 60 ~ 0 +OUTP2 +$Comp +L Q_NMOS_GSD Q4 +U 1 1 5A5A5C15 +P 8800 2750 +F 0 "Q4" H 9000 2800 50 0000 L CNN +F 1 "SI2300" H 9000 2700 50 0000 L CNN +F 2 "TO_SOT_Packages_SMD.pretty:SOT-23_Handsoldering" H 9000 2850 50 0001 C CNN +F 3 "" H 8800 2750 50 0001 C CNN + 1 8800 2750 + 1 0 0 -1 +$EndComp +$Comp +L R R10 +U 1 1 5A5A5C1B +P 8350 2750 +F 0 "R10" V 8430 2750 50 0000 C CNN +F 1 "330" V 8350 2750 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 8280 2750 50 0001 C CNN +F 3 "" H 8350 2750 50 0000 C CNN + 1 8350 2750 + 0 -1 -1 0 +$EndComp +Wire Wire Line + 8500 2750 8600 2750 +$Comp +L GND #PWR037 +U 1 1 5A5A5C22 +P 8900 3000 +F 0 "#PWR037" H 8900 2750 50 0001 C CNN +F 1 "GND" H 8900 2850 50 0000 C CNN +F 2 "" H 8900 3000 50 0000 C CNN +F 3 "" H 8900 3000 50 0000 C CNN + 1 8900 3000 + 1 0 0 -1 +$EndComp +Wire Wire Line + 8900 3000 8900 2950 +Text Label 8900 2550 0 60 ~ 0 +OUTP3 +Text Label 10250 2100 2 60 ~ 0 +OUTP3 +Text Label 10250 2000 2 60 ~ 0 +OUTP2 +Text Label 9500 2200 2 60 ~ 0 +INP1 +Text Label 9500 2400 2 60 ~ 0 +INP2 +$Comp +L R R11 +U 1 1 5A5A929C +P 9850 2200 +F 0 "R11" V 9930 2200 50 0000 C CNN +F 1 "330" V 9850 2200 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 9780 2200 50 0001 C CNN +F 3 "" H 9850 2200 50 0000 C CNN + 1 9850 2200 + 0 -1 -1 0 +$EndComp +$Comp +L R R12 +U 1 1 5A5A93D0 +P 9850 2400 +F 0 "R12" V 9930 2400 50 0000 C CNN +F 1 "330" V 9850 2400 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0603_HandSoldering" V 9780 2400 50 0001 C CNN +F 3 "" H 9850 2400 50 0000 C CNN + 1 9850 2400 + 0 -1 -1 0 +$EndComp +Wire Wire Line + 10000 2400 10000 2300 +Wire Wire Line + 10000 2300 10250 2300 +Wire Wire Line + 10250 2200 10000 2200 +Text Label 11650 8150 0 60 ~ 0 +INP1 +Text Label 11650 8250 0 60 ~ 0 +INP2 +Text Label 8200 2750 2 60 ~ 0 +O3 +Text Label 8200 2000 2 60 ~ 0 +O2 +Text Label 8200 1200 2 60 ~ 0 +O1 +Wire Notes Line + 7850 800 10750 800 +Wire Notes Line + 10750 800 10750 3250 +Wire Notes Line + 10750 3250 7850 3250 +Wire Notes Line + 7850 3250 7850 800 +Text Notes 7950 950 0 60 ~ 0 +Input/output +Text Label 5450 7950 2 60 ~ 0 +O1 +Text Label 5450 7850 2 60 ~ 0 +O2 +Text Label 5450 7750 2 60 ~ 0 +O3 +$Comp +L Conn_01x02 J5 +U 1 1 5A5B6143 +P 7050 2500 +F 0 "J5" H 7050 2600 50 0000 C CNN +F 1 "12v" H 7050 2300 50 0000 C CNN +F 2 "Connectors_Terminal_Blocks.pretty:TerminalBlock_Pheonix_MKDS1.5-2pol" H 7050 2500 50 0001 C CNN +F 3 "" H 7050 2500 50 0001 C CNN + 1 7050 2500 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR038 +U 1 1 5A5B6FD3 +P 6800 2750 +F 0 "#PWR038" H 6800 2500 50 0001 C CNN +F 1 "GND" H 6800 2600 50 0000 C CNN +F 2 "" H 6800 2750 50 0000 C CNN +F 3 "" H 6800 2750 50 0000 C CNN + 1 6800 2750 + 1 0 0 -1 +$EndComp +Wire Wire Line + 6800 2750 6800 2600 +Wire Wire Line + 6800 2600 6850 2600 +Wire Wire Line + 6650 2500 6850 2500 +Connection ~ 6650 2350 +$Comp +L SP0502BAHT D1 +U 1 1 5A5D29E2 +P 9650 2800 +F 0 "D1" H 9850 2800 50 0000 L CNN +F 1 "SP0502BAHT" H 9750 2650 50 0000 L CNN +F 2 "TO_SOT_Packages_SMD.pretty:SOT-23" H 9875 2750 50 0001 L CNN +F 3 "" H 9775 2925 50 0001 C CNN + 1 9650 2800 + 1 0 0 -1 +$EndComp +$Comp +L GND #PWR039 +U 1 1 5A5D32F5 +P 9650 3050 +F 0 "#PWR039" H 9650 2800 50 0001 C CNN +F 1 "GND" H 9650 2900 50 0000 C CNN +F 2 "" H 9650 3050 50 0000 C CNN +F 3 "" H 9650 3050 50 0000 C CNN + 1 9650 3050 + 1 0 0 -1 +$EndComp +Wire Wire Line + 9650 3050 9650 3000 +Wire Wire Line + 9550 2600 9550 2200 +Wire Wire Line + 9500 2200 9700 2200 +Wire Wire Line + 9750 2600 9700 2600 +Wire Wire Line + 9700 2600 9700 2400 +Connection ~ 9550 2200 +Wire Wire Line + 9700 2400 9500 2400 +Connection ~ 9700 2400 +$Comp +L R R14 +U 1 1 5A5D5996 +P 4650 1450 +F 0 "R14" V 4730 1450 50 0000 C CNN +F 1 "0" V 4650 1450 50 0000 C CNN +F 2 "Resistors_SMD.pretty:R_0805_HandSoldering" V 4580 1450 50 0001 C CNN +F 3 "" H 4650 1450 50 0001 C CNN + 1 4650 1450 + 0 1 1 0 +$EndComp +Wire Wire Line + 4800 1450 5250 1450 +Wire Wire Line + 4050 1450 4500 1450 +Wire Wire Line + 4550 2150 4550 1850 +Wire Wire Line + 4550 1850 4450 1850 +Wire Wire Line + 4450 1850 4450 1450 +Connection ~ 4450 1450 +Wire Wire Line + 5300 1850 5300 1700 +Wire Wire Line + 5300 1700 5550 1700 +Connection ~ 5550 1700 +NoConn ~ 11650 9050 +$Comp +L STM32F042C6Tx U7 +U 1 1 58C42C0E +P 8550 7850 +F 0 "U7" H 5550 9575 50 0000 L BNN +F 1 "STM32F042C6Tx" H 11550 9575 50 0000 R BNN +F 2 "Housings_QFP.pretty:LQFP-48_7x7mm_Pitch0.5mm" H 11550 9525 50 0001 R TNN +F 3 "" H 8550 7850 50 0000 C CNN + 1 8550 7850 + 1 0 0 -1 +$EndComp +NoConn ~ 5450 8050 +NoConn ~ 5450 8150 +NoConn ~ 5450 8250 +NoConn ~ 5450 8750 +NoConn ~ 5450 8850 +NoConn ~ 11650 9150 +NoConn ~ 11650 9250 +NoConn ~ 5450 8350 +NoConn ~ 5450 8450 +Text Label 11650 8650 0 60 ~ 0 +Tx +Text Label 11650 8750 0 60 ~ 0 +Rx +Wire Wire Line + 11650 8750 11800 8750 +Wire Wire Line + 11800 8750 11800 9600 +Wire Wire Line + 11800 9600 12000 9600 +Wire Wire Line + 12000 9500 11900 9500 +Wire Wire Line + 11900 9500 11900 8650 +Wire Wire Line + 11900 8650 11650 8650 +NoConn ~ 11650 8450 +NoConn ~ 5450 6950 +NoConn ~ 5450 7050 +NoConn ~ 11650 8350 +$Comp +L Conn_01x01 J6 +U 1 1 5A6066AA +P 3050 3400 +F 0 "J6" H 3050 3500 50 0000 C CNN +F 1 "Conn_01x01" H 3050 3300 50 0000 C CNN +F 2 "Pin_Headers.pretty:Pin_Header_Straight_1x01_Pitch2.54mm" H 3050 3400 50 0001 C CNN +F 3 "" H 3050 3400 50 0001 C CNN + 1 3050 3400 + 1 0 0 -1 +$EndComp +Connection ~ 2700 3400 +$EndSCHEMATC diff --git a/F0-nolib/canbus/kicad/rescue-backup/stm32-cache-2018-10-23-16-51-39.lib b/F0-nolib/canbus/kicad/rescue-backup/stm32-cache-2018-10-23-16-51-39.lib new file mode 100644 index 0000000..56c4116 --- /dev/null +++ b/F0-nolib/canbus/kicad/rescue-backup/stm32-cache-2018-10-23-16-51-39.lib @@ -0,0 +1,764 @@ +EESchema-LIBRARY Version 2.3 +#encoding utf-8 +# +# +3V3 +# +DEF +3V3 #PWR 0 0 Y Y 1 F P +F0 "#PWR" 0 -150 50 H I C CNN +F1 "+3V3" 0 140 50 H V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +ALIAS +3.3V +DRAW +P 2 0 1 0 -30 50 0 100 N +P 2 0 1 0 0 0 0 100 N +P 2 0 1 0 0 100 30 50 N +X +3V3 1 0 0 0 U 50 50 1 1 W N +ENDDRAW +ENDDEF +# +# +5V +# +DEF +5V #PWR 0 0 Y Y 1 F P +F0 "#PWR" 0 -150 50 H I C CNN +F1 "+5V" 0 140 50 H V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +DRAW +P 2 0 1 0 -30 50 0 100 N +P 2 0 1 0 0 0 0 100 N +P 2 0 1 0 0 100 30 50 N +X +5V 1 0 0 0 U 50 50 1 1 W N +ENDDRAW +ENDDEF +# +# C +# +DEF C C 0 10 N Y 1 F N +F0 "C" 25 100 50 H V L CNN +F1 "C" 25 -100 50 H V L CNN +F2 "" 38 -150 50 H I C CNN +F3 "" 0 0 50 H I C CNN +$FPLIST + C_* +$ENDFPLIST +DRAW +P 2 0 1 20 -80 -30 80 -30 N +P 2 0 1 20 -80 30 80 30 N +X ~ 1 0 150 110 D 50 50 1 1 P +X ~ 2 0 -150 110 U 50 50 1 1 P +ENDDRAW +ENDDEF +# +# CONN_01X01 +# +DEF CONN_01X01 J 0 40 Y N 1 F N +F0 "J" 0 100 50 H V C CNN +F1 "CONN_01X01" 100 0 50 V V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +$FPLIST + Pin_Header_Straight_1X* + Pin_Header_Angled_1X* + Socket_Strip_Straight_1X* + Socket_Strip_Angled_1X* +$ENDFPLIST +DRAW +S -50 5 10 -5 0 1 0 N +S -50 50 50 -50 0 1 0 N +X P1 1 -200 0 150 R 50 50 1 1 P +ENDDRAW +ENDDEF +# +# CONN_01X03 +# +DEF CONN_01X03 J 0 40 Y N 1 F N +F0 "J" 0 200 50 H V C CNN +F1 "CONN_01X03" 100 0 50 V V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +$FPLIST + Pin_Header_Straight_1X* + Pin_Header_Angled_1X* + Socket_Strip_Straight_1X* + Socket_Strip_Angled_1X* +$ENDFPLIST +DRAW +S -50 -95 10 -105 0 1 0 N +S -50 5 10 -5 0 1 0 N +S -50 105 10 95 0 1 0 N +S -50 150 50 -150 0 1 0 N +X P1 1 -200 100 150 R 50 50 1 1 P +X P2 2 -200 0 150 R 50 50 1 1 P +X P3 3 -200 -100 150 R 50 50 1 1 P +ENDDRAW +ENDDEF +# +# CONN_02X03 +# +DEF CONN_02X03 J 0 1 Y N 1 F N +F0 "J" 0 200 50 H V C CNN +F1 "CONN_02X03" 0 -200 50 H V C CNN +F2 "" 0 -1200 50 H I C CNN +F3 "" 0 -1200 50 H I C CNN +$FPLIST + Pin_Header_Straight_2X* + Pin_Header_Angled_2X* + Socket_Strip_Straight_2X* + Socket_Strip_Angled_2X* + IDC_Header_Straight_* +$ENDFPLIST +DRAW +S -100 -95 -50 -105 0 1 0 N +S -100 5 -50 -5 0 1 0 N +S -100 105 -50 95 0 1 0 N +S -100 150 100 -150 0 1 0 N +S 50 -95 100 -105 0 1 0 N +S 50 5 100 -5 0 1 0 N +S 50 105 100 95 0 1 0 N +X P1 1 -250 100 150 R 50 50 1 1 P +X P2 2 250 100 150 L 50 50 1 1 P +X P3 3 -250 0 150 R 50 50 1 1 P +X P4 4 250 0 150 L 50 50 1 1 P +X P5 5 -250 -100 150 R 50 50 1 1 P +X P6 6 250 -100 150 L 50 50 1 1 P +ENDDRAW +ENDDEF +# +# CP +# +DEF CP C 0 10 N Y 1 F N +F0 "C" 25 100 50 H V L CNN +F1 "CP" 25 -100 50 H V L CNN +F2 "" 38 -150 50 H I C CNN +F3 "" 0 0 50 H I C CNN +$FPLIST + CP_* +$ENDFPLIST +DRAW +S -90 20 -90 40 0 1 0 N +S -90 20 90 20 0 1 0 N +S 90 -20 -90 -40 0 1 0 F +S 90 40 -90 40 0 1 0 N +S 90 40 90 20 0 1 0 N +P 2 0 1 0 -70 90 -30 90 N +P 2 0 1 0 -50 110 -50 70 N +X ~ 1 0 150 110 D 50 50 1 1 P +X ~ 2 0 -150 110 U 50 50 1 1 P +ENDDRAW +ENDDEF +# +# Conn_01x01 +# +DEF Conn_01x01 J 0 40 Y N 1 F N +F0 "J" 0 100 50 H V C CNN +F1 "Conn_01x01" 0 -100 50 H V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +$FPLIST + Connector*:*_??x*mm* + Connector*:*1x??x*mm* + Pin?Header?Straight?1X* + Pin?Header?Angled?1X* + Socket?Strip?Straight?1X* + Socket?Strip?Angled?1X* +$ENDFPLIST +DRAW +S -50 5 0 -5 1 1 6 N +S -50 50 50 -50 1 1 10 f +X Pin_1 1 -200 0 150 R 50 50 1 1 P +ENDDRAW +ENDDEF +# +# Conn_01x02 +# +DEF Conn_01x02 J 0 40 Y N 1 F N +F0 "J" 0 100 50 H V C CNN +F1 "Conn_01x02" 0 -200 50 H V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +$FPLIST + Connector*:*_??x*mm* + Connector*:*1x??x*mm* + Pin?Header?Straight?1X* + Pin?Header?Angled?1X* + Socket?Strip?Straight?1X* + Socket?Strip?Angled?1X* +$ENDFPLIST +DRAW +S -50 -95 0 -105 1 1 6 N +S -50 5 0 -5 1 1 6 N +S -50 50 50 -150 1 1 10 f +X Pin_1 1 -200 0 150 R 50 50 1 1 P +X Pin_2 2 -200 -100 150 R 50 50 1 1 P +ENDDRAW +ENDDEF +# +# Conn_01x07 +# +DEF Conn_01x07 J 0 40 Y N 1 F N +F0 "J" 0 400 50 H V C CNN +F1 "Conn_01x07" 0 -400 50 H V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +$FPLIST + Connector*:*_??x*mm* + Connector*:*1x??x*mm* + Pin?Header?Straight?1X* + Pin?Header?Angled?1X* + Socket?Strip?Straight?1X* + Socket?Strip?Angled?1X* +$ENDFPLIST +DRAW +S -50 -295 0 -305 1 1 6 N +S -50 -195 0 -205 1 1 6 N +S -50 -95 0 -105 1 1 6 N +S -50 5 0 -5 1 1 6 N +S -50 105 0 95 1 1 6 N +S -50 205 0 195 1 1 6 N +S -50 305 0 295 1 1 6 N +S -50 350 50 -350 1 1 10 f +X Pin_1 1 -200 300 150 R 50 50 1 1 P +X Pin_2 2 -200 200 150 R 50 50 1 1 P +X Pin_3 3 -200 100 150 R 50 50 1 1 P +X Pin_4 4 -200 0 150 R 50 50 1 1 P +X Pin_5 5 -200 -100 150 R 50 50 1 1 P +X Pin_6 6 -200 -200 150 R 50 50 1 1 P +X Pin_7 7 -200 -300 150 R 50 50 1 1 P +ENDDRAW +ENDDEF +# +# DB9_Female +# +DEF DB9_Female J 0 40 Y N 1 F N +F0 "J" 0 550 50 H V C CNN +F1 "DB9_Female" 0 -575 50 H V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +$FPLIST + DB*F* +$ENDFPLIST +DRAW +C -70 -400 30 0 1 0 N +C -70 -200 30 0 1 0 N +C -70 0 30 0 1 0 N +C -70 200 30 0 1 0 N +C -70 400 30 0 1 0 N +C 50 -300 30 0 1 0 N +C 50 -100 30 0 1 0 N +C 50 100 30 0 1 0 N +C 50 300 30 0 1 0 N +P 2 0 1 0 -150 -400 -100 -400 N +P 2 0 1 0 -150 -300 20 -300 N +P 2 0 1 0 -150 -200 -100 -200 N +P 2 0 1 0 -150 -100 20 -100 N +P 2 0 1 0 -150 0 -100 0 N +P 2 0 1 0 -150 100 20 100 N +P 2 0 1 0 -150 200 -100 200 N +P 2 0 1 0 -150 300 20 300 N +P 2 0 1 0 -150 400 -100 400 N +P 5 0 1 10 -150 525 -150 -525 150 -375 150 375 -150 525 f +X 1 1 -300 400 150 R 50 50 1 1 P +X 2 2 -300 200 150 R 50 50 1 1 P +X 3 3 -300 0 150 R 50 50 1 1 P +X 4 4 -300 -200 150 R 50 50 1 1 P +X 5 5 -300 -400 150 R 50 50 1 1 P +X 6 6 -300 300 150 R 50 50 1 1 P +X 7 7 -300 100 150 R 50 50 1 1 P +X 8 8 -300 -100 150 R 50 50 1 1 P +X 9 9 -300 -300 150 R 50 50 1 1 P +ENDDRAW +ENDDEF +# +# DB9_Male +# +DEF DB9_Male J 0 40 Y N 1 F N +F0 "J" 0 550 50 H V C CNN +F1 "DB9_Male" 0 -575 50 H V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +$FPLIST + DB*M* +$ENDFPLIST +DRAW +C -70 -400 30 0 1 0 F +C -70 -200 30 0 1 0 F +C -70 0 30 0 1 0 F +C -70 200 30 0 1 0 F +C -70 400 30 0 1 0 F +C 50 -300 30 0 1 0 F +C 50 -100 30 0 1 0 F +C 50 100 30 0 1 0 F +C 50 300 30 0 1 0 F +P 2 0 1 0 -150 -400 -100 -400 N +P 2 0 1 0 -150 -300 20 -300 N +P 2 0 1 0 -150 -200 -100 -200 N +P 2 0 1 0 -150 -100 20 -100 N +P 2 0 1 0 -150 0 -100 0 N +P 2 0 1 0 -150 100 20 100 N +P 2 0 1 0 -150 200 -100 200 N +P 2 0 1 0 -150 300 20 300 N +P 2 0 1 0 -150 400 -100 400 N +P 5 0 1 10 -150 -525 -150 525 150 375 150 -375 -150 -525 f +X 1 1 -300 -400 150 R 50 50 1 1 P +X 2 2 -300 -200 150 R 50 50 1 1 P +X 3 3 -300 0 150 R 50 50 1 1 P +X 4 4 -300 200 150 R 50 50 1 1 P +X 5 5 -300 400 150 R 50 50 1 1 P +X 6 6 -300 -300 150 R 50 50 1 1 P +X 7 7 -300 -100 150 R 50 50 1 1 P +X 8 8 -300 100 150 R 50 50 1 1 P +X 9 9 -300 300 150 R 50 50 1 1 P +ENDDRAW +ENDDEF +# +# D_Schottky +# +DEF D_Schottky D 0 40 N N 1 F N +F0 "D" 0 100 50 H V C CNN +F1 "D_Schottky" 0 -100 50 H V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +$FPLIST + TO-???* + *SingleDiode + *_Diode_* + *SingleDiode* + D_* +$ENDFPLIST +DRAW +P 2 0 1 0 50 0 -50 0 N +P 4 0 1 8 50 50 50 -50 -50 0 50 50 N +P 6 0 1 8 -75 25 -75 50 -50 50 -50 -50 -25 -50 -25 -25 N +X K 1 -150 0 100 R 50 50 1 1 P +X A 2 150 0 100 L 50 50 1 1 P +ENDDRAW +ENDDEF +# +# D_Zener +# +DEF D_Zener D 0 40 N N 1 F N +F0 "D" 0 100 50 H V C CNN +F1 "D_Zener" 0 -100 50 H V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +$FPLIST + TO-???* + *SingleDiode + *_Diode_* + *SingleDiode* + D_* +$ENDFPLIST +DRAW +P 2 0 1 0 50 0 -50 0 N +P 3 0 1 8 -50 -50 -50 50 -30 50 N +P 4 0 1 8 50 -50 50 50 -50 0 50 -50 N +X K 1 -150 0 100 R 50 50 1 1 P +X A 2 150 0 100 L 50 50 1 1 P +ENDDRAW +ENDDEF +# +# GND +# +DEF GND #PWR 0 0 Y Y 1 F P +F0 "#PWR" 0 -250 50 H I C CNN +F1 "GND" 0 -150 50 H V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +DRAW +P 6 0 1 0 0 0 0 -50 50 -50 0 -100 -50 -50 0 -50 N +X GND 1 0 0 0 D 50 50 1 1 W N +ENDDRAW +ENDDEF +# +# Jumper_NO_Small +# +DEF Jumper_NO_Small JP 0 30 N N 1 F N +F0 "JP" 0 80 50 H V C CNN +F1 "Jumper_NO_Small" 10 -60 50 H V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +DRAW +C -40 0 20 0 1 0 N +C 40 0 20 0 1 0 N +X 1 1 -100 0 40 R 50 50 0 1 P +X 2 2 100 0 40 L 50 50 0 1 P +ENDDRAW +ENDDEF +# +# LED-RESCUE-stm32 +# +DEF LED-RESCUE-stm32 D 0 40 Y N 1 F N +F0 "D" 0 100 50 H V C CNN +F1 "LED-RESCUE-stm32" 0 -100 50 H V C CNN +F2 "" 0 0 50 H V C CNN +F3 "" 0 0 50 H V C CNN +$FPLIST + LED* +$ENDFPLIST +DRAW +P 2 0 1 8 -50 -50 -50 50 N +P 2 0 1 0 -50 0 50 0 N +P 4 0 1 8 50 -50 50 50 -50 0 50 -50 N +P 5 0 1 0 -120 -30 -180 -90 -150 -90 -180 -90 -180 -60 N +P 5 0 1 0 -70 -30 -130 -90 -100 -90 -130 -90 -130 -60 N +X K 1 -150 0 100 R 50 50 1 1 P +X A 2 150 0 100 L 50 50 1 1 P +ENDDRAW +ENDDEF +# +# LM1117-3.3-RESCUE-stm32 +# +DEF LM1117-3.3-RESCUE-stm32 U 0 30 Y Y 1 F N +F0 "U" 100 -250 50 H V C CNN +F1 "LM1117-3.3-RESCUE-stm32" 0 250 50 H V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +$FPLIST + SOT-223* + TO-263* + TO-252* +$ENDFPLIST +DRAW +S -200 -200 200 200 0 1 10 f +X GND/ADJ 1 0 -300 100 U 50 50 1 1 W +X VO 2 300 50 100 L 50 50 1 1 P +X VI 3 -300 0 100 R 50 50 1 1 W +X VO 4 300 -50 100 L 50 50 1 1 w +ENDDRAW +ENDDEF +# +# MCP2551-I/SN +# +DEF MCP2551-I/SN U 0 40 Y Y 1 F N +F0 "U" -400 350 50 H V L CNN +F1 "MCP2551-I/SN" 100 350 50 H V L CNN +F2 "Housings_SOIC:SOIC-8_3.9x4.9mm_Pitch1.27mm" 0 -500 50 H I C CIN +F3 "" 0 0 50 H I C CNN +$FPLIST + SOIC*Pitch1.27mm* +$ENDFPLIST +DRAW +S -400 300 400 -300 0 1 10 f +X TXD 1 -500 200 100 R 50 50 1 1 I +X VSS 2 0 -400 100 U 50 50 1 1 W +X VDD 3 0 400 100 D 50 50 1 1 W +X RXD 4 -500 100 100 R 50 50 1 1 O +X Vref 5 -500 -100 100 R 50 50 1 1 w +X CANL 6 500 -100 100 L 50 50 1 1 B +X CANH 7 500 100 100 L 50 50 1 1 B +X Rs 8 -500 -200 100 R 50 50 1 1 I +ENDDRAW +ENDDEF +# +# PESD1CAN +# +DEF PESD1CAN D 0 30 Y N 1 F N +F0 "D" 0 -350 50 H V C CNN +F1 "PESD1CAN" 50 150 50 H V C CNN +F2 "" 0 0 50 H V C CNN +F3 "" 0 0 50 H V C CNN +$FPLIST + SOT23 +$ENDFPLIST +DRAW +S -200 100 300 -300 0 1 0 N +P 2 0 1 0 -140 -200 150 -200 N +P 2 0 1 0 -140 0 150 0 N +P 3 0 1 8 -150 -150 -150 -250 -150 -250 N +P 3 0 1 8 -150 50 -150 -50 -150 -50 N +P 3 0 1 8 150 -150 150 -250 150 -250 N +P 3 0 1 8 150 50 150 -50 150 -50 N +P 4 0 1 8 -150 -150 -170 -150 -170 -160 -170 -160 N +P 4 0 1 8 -150 50 -170 50 -170 40 -170 40 N +P 4 0 1 8 150 -250 170 -250 170 -240 170 -240 N +P 4 0 1 8 150 -150 130 -150 130 -160 130 -160 N +P 4 0 1 8 150 -50 170 -50 170 -40 170 -40 N +P 4 0 1 0 150 0 250 0 250 -200 150 -200 N +P 4 0 1 8 150 50 130 50 130 40 130 40 N +P 5 0 1 8 -130 -240 -130 -250 -150 -250 -150 -250 -150 -250 N +P 5 0 1 8 -130 -40 -130 -50 -150 -50 -150 -50 -150 -50 N +P 6 0 1 8 -50 -250 -150 -200 -50 -150 -50 -250 -50 -250 -50 -250 N +P 6 0 1 8 -50 -50 -150 0 -50 50 -50 -50 -50 -50 -50 -50 N +P 6 0 1 8 50 -150 150 -200 50 -250 50 -150 50 -150 50 -150 N +P 6 0 1 8 50 50 150 0 50 -50 50 50 50 50 50 50 N +X K 1 -300 0 150 R 50 50 0 1 P +X K 2 -300 -200 150 R 50 50 0 1 P +X O 3 400 -100 150 L 50 50 0 1 P +ENDDRAW +ENDDEF +# +# PWR_FLAG +# +DEF PWR_FLAG #FLG 0 0 N N 1 F P +F0 "#FLG" 0 75 50 H I C CNN +F1 "PWR_FLAG" 0 150 50 H V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +DRAW +X pwr 1 0 0 0 U 50 50 0 0 w +P 6 0 1 0 0 0 0 50 -40 75 0 100 40 75 0 50 N +ENDDRAW +ENDDEF +# +# Q_NMOS_GSD +# +DEF Q_NMOS_GSD Q 0 0 Y N 1 F N +F0 "Q" 200 50 50 H V L CNN +F1 "Q_NMOS_GSD" 200 -50 50 H V L CNN +F2 "" 200 100 50 H I C CNN +F3 "" 0 0 50 H I C CNN +DRAW +C 65 0 111 0 1 10 N +C 100 -70 11 0 1 0 F +C 100 70 11 0 1 0 F +P 2 0 1 0 2 0 10 0 N +P 2 0 1 0 30 -70 100 -70 N +P 2 0 1 10 30 -50 30 -90 N +P 2 0 1 0 30 0 100 0 N +P 2 0 1 10 30 20 30 -20 N +P 2 0 1 0 30 70 100 70 N +P 2 0 1 10 30 90 30 50 N +P 2 0 1 0 100 -70 100 -100 N +P 2 0 1 0 100 -70 100 0 N +P 2 0 1 0 100 100 100 70 N +P 3 0 1 10 10 75 10 -75 10 -75 N +P 4 0 1 0 40 0 80 15 80 -15 40 0 F +P 4 0 1 0 100 -70 130 -70 130 70 100 70 N +P 4 0 1 0 110 20 115 15 145 15 150 10 N +P 4 0 1 0 130 15 115 -10 145 -10 130 15 N +X G 1 -200 0 200 R 50 50 1 1 I +X S 2 100 -200 100 U 50 50 1 1 P +X D 3 100 200 100 D 50 50 1 1 P +ENDDRAW +ENDDEF +# +# Q_PMOS_GSD +# +DEF Q_PMOS_GSD Q 0 0 Y N 1 F N +F0 "Q" 200 50 50 H V L CNN +F1 "Q_PMOS_GSD" 200 -50 50 H V L CNN +F2 "" 200 100 50 H I C CNN +F3 "" 0 0 50 H I C CNN +DRAW +C 65 0 111 0 1 10 N +C 100 -70 11 0 1 0 F +C 100 70 11 0 1 0 F +P 2 0 1 0 2 0 10 0 N +P 2 0 1 0 30 -70 100 -70 N +P 2 0 1 10 30 -50 30 -90 N +P 2 0 1 0 30 0 100 0 N +P 2 0 1 10 30 20 30 -20 N +P 2 0 1 0 30 70 100 70 N +P 2 0 1 10 30 90 30 50 N +P 2 0 1 0 100 -70 100 -100 N +P 2 0 1 0 100 -70 100 0 N +P 2 0 1 0 100 100 100 70 N +P 3 0 1 10 10 75 10 -75 10 -75 N +P 4 0 1 0 90 0 50 -15 50 15 90 0 F +P 4 0 1 0 100 -70 130 -70 130 70 100 70 N +P 4 0 1 0 110 -20 115 -15 145 -15 150 -10 N +P 4 0 1 0 130 -15 115 10 145 10 130 -15 N +X G 1 -200 0 200 R 50 50 1 1 I +X S 2 100 -200 100 U 50 50 1 1 P +X D 3 100 200 100 D 50 50 1 1 P +ENDDRAW +ENDDEF +# +# R +# +DEF R R 0 0 N Y 1 F N +F0 "R" 80 0 50 V V C CNN +F1 "R" 0 0 50 V V C CNN +F2 "" -70 0 50 V I C CNN +F3 "" 0 0 50 H I C CNN +$FPLIST + R_* + R_* +$ENDFPLIST +DRAW +S -40 -100 40 100 0 1 10 N +X ~ 1 0 150 50 D 50 50 1 1 P +X ~ 2 0 -150 50 U 50 50 1 1 P +ENDDRAW +ENDDEF +# +# SP0502BAHT +# +DEF SP0502BAHT D 0 40 Y N 1 F N +F0 "D" 225 100 50 H V L CNN +F1 "SP0502BAHT" 225 25 50 H V L CNN +F2 "TO_SOT_Packages_SMD:SOT-23" 225 -50 50 H I L CNN +F3 "" 125 125 50 H I C CNN +$FPLIST + SOT?23* +$ENDFPLIST +DRAW +X A 3 0 -200 100 U 50 50 0 0 I +S -175 100 175 -100 0 1 10 f +P 2 0 1 0 -100 100 -100 50 N +P 2 0 1 0 0 -50 0 -100 N +P 2 0 1 0 100 100 100 50 N +P 4 0 1 0 -150 75 -125 50 -75 50 -50 25 N +P 4 0 1 0 -100 0 -100 -50 100 -50 100 0 N +P 4 0 1 0 -100 50 -75 0 -125 0 -100 50 F +P 4 0 1 0 50 75 75 50 125 50 150 25 N +P 4 0 1 0 100 50 75 0 125 0 100 50 F +X K 1 -100 200 100 D 50 50 1 1 I +X K 2 100 200 100 D 50 50 1 1 I +ENDDRAW +ENDDEF +# +# STM32F042C4Tx +# +DEF STM32F042C4Tx U 0 40 Y Y 1 L N +F0 "U" -3000 1725 50 H V L BNN +F1 "STM32F042C4Tx" 3000 1725 50 H V R BNN +F2 "LQFP48" 3000 1675 50 H V R TNN +F3 "" 0 0 50 H V C CNN +ALIAS STM32F042C6Tx +DRAW +S -3000 -1700 3000 1700 0 1 10 f +X VBAT 1 -3100 1100 100 R 50 50 1 1 W +X PC13/RTC_OUT_ALARM/RTC_OUT_CALIB/RTC_TAMP1/RTC_TS/SYS_WKUP2 2 -3100 500 100 R 50 50 1 1 B +X PC14/RCC_OSC32_IN 3 -3100 400 100 R 50 50 1 1 B +X PC15/RCC_OSC32_OUT 4 -3100 300 100 R 50 50 1 1 B +X PF0/CRS_SYNC/I2C1_SDA/RCC_OSC_IN 5 -3100 900 100 R 50 50 1 1 I +X PF1/I2C1_SCL/RCC_OSC_OUT 6 -3100 800 100 R 50 50 1 1 I +X NRST 7 -3100 1300 100 R 50 50 1 1 I +X VSSA 8 100 -1800 100 U 50 50 1 1 W +X VDDA 9 0 1800 100 D 50 50 1 1 W +X ADC_IN0/RTC_TAMP2/SYS_WKUP1/TIM2_CH1/TIM2_ETR/TSC_G1_IO1/USART2_CTS/PA0 10 3100 100 100 L 50 50 1 1 B +X PB2/TSC_G3_IO4 20 -3100 -100 100 R 50 50 1 1 B +X I2C1_SCL/TIM1_CH2/TSC_G4_IO1/USART1_TX/PA9 30 3100 -800 100 L 50 50 1 1 B +X PB4/I2S1_MCK/SPI1_MISO/TIM17_BKIN/TIM3_CH1/TSC_G5_IO2 40 -3100 -300 100 R 50 50 1 1 B +X ADC_IN1/TIM2_CH2/TSC_G1_IO2/USART2_DE/USART2_RTS/PA1 11 3100 0 100 L 50 50 1 1 B +X PB10/CEC/I2C1_SCL/SPI2_SCK/TIM2_CH3/TSC_SYNC 21 -3100 -900 100 R 50 50 1 1 B +X I2C1_SDA/TIM17_BKIN/TIM1_CH3/TSC_G4_IO2/USART1_RX/PA10 31 3100 -900 100 L 50 50 1 1 B +X PB5/I2C1_SMBA/I2S1_SD/SPI1_MOSI/SYS_WKUP6/TIM16_BKIN/TIM3_CH2 41 -3100 -400 100 R 50 50 1 1 B +X ADC_IN2/SYS_WKUP4/TIM2_CH3/TSC_G1_IO3/USART2_TX/PA2 12 3100 -100 100 L 50 50 1 1 B +X PB11/I2C1_SDA/TIM2_CH4 22 -3100 -1000 100 R 50 50 1 1 B +X CAN_RX/I2C1_SCL/TIM1_CH4/TSC_G4_IO3/USART1_CTS/USB_DM/PA11 32 3100 -1000 100 L 50 50 1 1 B +X PB6/I2C1_SCL/TIM16_CH1N/TSC_G5_IO3/USART1_TX 42 -3100 -500 100 R 50 50 1 1 B +X ADC_IN3/TIM2_CH4/TSC_G1_IO4/USART2_RX/PA3 13 3100 -200 100 L 50 50 1 1 B +X VSS 23 -200 -1800 100 U 50 50 1 1 W +X CAN_TX/I2C1_SDA/TIM1_ETR/TSC_G4_IO4/USART1_DE/USART1_RTS/USB_DP/PA12 33 3100 -1100 100 L 50 50 1 1 B +X PB7/I2C1_SDA/TIM17_CH1N/TSC_G5_IO4/USART1_RX 43 -3100 -600 100 R 50 50 1 1 B +X ADC_IN4/I2S1_WS/SPI1_NSS/TIM14_CH1/TSC_G2_IO1/USART2_CK/USB_OE/PA4 14 3100 -300 100 L 50 50 1 1 B +X VDD 24 -200 1800 100 D 50 50 1 1 W +X IR_OUT/SYS_SWDIO/USB_OE/PA13 34 3100 -1200 100 L 50 50 1 1 B +X PF11 44 -3100 700 100 R 50 50 1 1 B +X ADC_IN5/CEC/I2S1_CK/SPI1_SCK/TIM2_CH1/TIM2_ETR/TSC_G2_IO2/PA5 15 3100 -400 100 L 50 50 1 1 B +X PB12/SPI2_NSS/TIM1_BKIN 25 -3100 -1100 100 R 50 50 1 1 B +X VSS 35 -100 -1800 100 U 50 50 1 1 W +X PB8/CAN_RX/CEC/I2C1_SCL/TIM16_CH1/TSC_SYNC 45 -3100 -700 100 R 50 50 1 1 B +X ADC_IN6/I2S1_MCK/SPI1_MISO/TIM16_CH1/TIM1_BKIN/TIM3_CH1/TSC_G2_IO3/PA6 16 3100 -500 100 L 50 50 1 1 B +X PB13/I2C1_SCL/SPI2_SCK/TIM1_CH1N 26 -3100 -1200 100 R 50 50 1 1 B +X VDDIO2 36 100 1800 100 D 50 50 1 1 W +X PB9/CAN_TX/I2C1_SDA/IR_OUT/SPI2_NSS/TIM17_CH1 46 -3100 -800 100 R 50 50 1 1 B +X ADC_IN7/I2S1_SD/SPI1_MOSI/TIM14_CH1/TIM17_CH1/TIM1_CH1N/TIM3_CH2/TSC_G2_IO4/PA7 17 3100 -600 100 L 50 50 1 1 B +X PB14/I2C1_SDA/SPI2_MISO/TIM1_CH2N 27 -3100 -1300 100 R 50 50 1 1 B +X SYS_SWCLK/USART2_TX/PA14 37 3100 -1300 100 L 50 50 1 1 B +X VSS 47 0 -1800 100 U 50 50 1 1 W +X PB0/ADC_IN8/TIM1_CH2N/TIM3_CH3/TSC_G3_IO2 18 -3100 100 100 R 50 50 1 1 B +X PB15/RTC_REFIN/SPI2_MOSI/SYS_WKUP7/TIM1_CH3N 28 -3100 -1400 100 R 50 50 1 1 B +X I2S1_WS/SPI1_NSS/TIM2_CH1/TIM2_ETR/USART2_RX/USB_OE/PA15 38 3100 -1400 100 L 50 50 1 1 B +X VDD 48 -100 1800 100 D 50 50 1 1 W +X PB1/ADC_IN9/TIM14_CH1/TIM1_CH3N/TIM3_CH4/TSC_G3_IO3 19 -3100 0 100 R 50 50 1 1 B +X CRS_SYNC/RCC_MCO/TIM1_CH1/USART1_CK/PA8 29 3100 -700 100 L 50 50 1 1 B +X PB3/I2S1_CK/SPI1_SCK/TIM2_CH2/TSC_G5_IO1 39 -3100 -200 100 R 50 50 1 1 B +ENDDRAW +ENDDEF +# +# SW_Push +# +DEF SW_Push SW 0 40 N N 1 F N +F0 "SW" 50 100 50 H V L CNN +F1 "SW_Push" 0 -60 50 H V C CNN +F2 "" 0 200 50 H I C CNN +F3 "" 0 200 50 H I C CNN +DRAW +C -80 0 20 0 1 0 N +C 80 0 20 0 1 0 N +P 2 0 1 0 0 50 0 120 N +P 2 0 1 0 100 50 -100 50 N +X 1 1 -200 0 100 R 50 50 0 1 P +X 2 2 200 0 100 L 50 50 0 1 P +ENDDRAW +ENDDEF +# +# USB6B1 +# +DEF USB6B1 D 0 30 Y N 1 F N +F0 "D" 0 -450 50 H V C CNN +F1 "USB6B1" 0 400 50 H V C CNN +F2 "" 200 -100 50 V V C CNN +F3 "" 200 -100 50 V V C CNN +$FPLIST + SO8 +$ENDFPLIST +DRAW +C -150 -300 7 0 1 0 N +C -150 100 7 0 1 0 N +C -150 300 7 0 1 0 N +C 0 -300 7 0 1 0 N +C 0 -100 7 0 1 0 N +C 0 300 7 0 1 0 N +C 200 -300 7 0 1 0 N +C 200 300 7 0 1 0 N +S -300 -100 300 -100 0 1 0 N +S -300 300 300 300 0 1 0 N +S -200 -150 -100 -150 0 1 0 N +S -200 250 -100 250 0 1 0 N +S -150 300 -150 -300 0 1 0 N +S -50 -150 50 -150 0 1 0 N +S -50 250 50 250 0 1 0 N +S 0 300 0 -300 0 1 0 N +S 200 300 200 -300 0 1 0 N +S 300 -300 -300 -300 0 1 0 N +S 300 100 -300 100 0 1 0 N +P 3 0 1 8 150 50 250 50 250 50 N +P 4 0 1 8 150 50 150 30 160 30 160 30 N +P 4 0 1 8 250 50 250 70 240 70 240 70 N +P 5 0 1 0 -250 350 300 350 300 -350 -250 -350 -250 350 N +P 6 0 1 8 -200 -250 -150 -150 -100 -250 -200 -250 -200 -250 -200 -250 N +P 6 0 1 8 -200 150 -150 250 -100 150 -200 150 -200 150 -200 150 N +P 6 0 1 8 -50 -250 0 -150 50 -250 -50 -250 -50 -250 -50 -250 N +P 6 0 1 8 -50 150 0 250 50 150 -50 150 -50 150 -50 150 N +P 6 0 1 8 150 -50 200 50 250 -50 150 -50 150 -50 150 -50 N +X VCC 1 -500 300 200 R 50 50 1 1 P +X I/O1 2 -500 100 200 R 50 50 1 1 P +X I/O2 3 -500 -100 200 R 50 50 1 1 P +X GND 4 -500 -300 200 R 50 50 1 1 P +X GND 5 500 -300 200 L 50 50 1 1 P +X I/O2 6 500 -100 200 L 50 50 1 1 P +X I/O1 7 500 100 200 L 50 50 1 1 P +X VCC 8 500 300 200 L 50 50 1 1 P +ENDDRAW +ENDDEF +# +# USB_A-RESCUE-stm32 +# +DEF USB_A-RESCUE-stm32 P 0 40 Y Y 1 F N +F0 "P" 200 -200 50 H V C CNN +F1 "USB_A-RESCUE-stm32" -50 200 50 H V C CNN +F2 "" -50 -100 50 V V C CNN +F3 "" -50 -100 50 V V C CNN +$FPLIST + USB* +$ENDFPLIST +DRAW +S -250 -150 150 150 0 1 0 N +S -205 -150 -195 -120 0 1 0 N +S -105 -150 -95 -120 0 1 0 N +S -5 -150 5 -120 0 1 0 N +S 95 -150 105 -120 0 1 0 N +X VBUS 1 -200 -300 150 U 50 50 1 1 W +X D- 2 -100 -300 150 U 50 50 1 1 P +X D+ 3 0 -300 150 U 50 50 1 1 P +X GND 4 100 -300 150 U 50 50 1 1 W +X shield 5 300 100 150 L 50 50 1 1 P +ENDDRAW +ENDDEF +# +#End Library diff --git a/F0-nolib/canbus/kicad/rescue-backup/stm32-rescue-2018-10-23-16-51-39.lib b/F0-nolib/canbus/kicad/rescue-backup/stm32-rescue-2018-10-23-16-51-39.lib new file mode 100644 index 0000000..4df6a8b --- /dev/null +++ b/F0-nolib/canbus/kicad/rescue-backup/stm32-rescue-2018-10-23-16-51-39.lib @@ -0,0 +1,45 @@ +EESchema-LIBRARY Version 2.3 +#encoding utf-8 +# +# LM1117-3.3-RESCUE-stm32 +# +DEF LM1117-3.3-RESCUE-stm32 U 0 30 Y Y 1 F N +F0 "U" 100 -250 50 H V C CNN +F1 "LM1117-3.3-RESCUE-stm32" 0 250 50 H V C CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +$FPLIST + SOT-223* + TO-263* + TO-252* +$ENDFPLIST +DRAW +S -200 -200 200 200 0 1 10 f +X GND/ADJ 1 0 -300 100 U 50 50 1 1 W +X VO 2 300 50 100 L 50 50 1 1 P +X VI 3 -300 0 100 R 50 50 1 1 W +X VO 4 300 -50 100 L 50 50 1 1 w +ENDDRAW +ENDDEF +# +# MAX471-RESCUE-stm32 +# +DEF MAX471-RESCUE-stm32 U 0 40 Y Y 1 F N +F0 "U" -300 350 50 H V L CNN +F1 "MAX471-RESCUE-stm32" -300 -350 50 H V L CNN +F2 "" 0 0 50 H I C CNN +F3 "" 0 0 50 H I C CNN +DRAW +S -300 300 300 -300 0 1 10 f +X SHDN 1 -400 -100 100 R 50 50 1 1 I +X RS+ 2 -400 200 100 R 50 50 1 1 W +X RS+ 3 -400 100 100 R 50 50 1 1 P +X GND 4 -400 -200 100 R 50 50 1 1 W +X SIGN 5 400 -100 100 L 50 50 1 1 C +X RS- 6 400 200 100 L 50 50 1 1 w +X RS- 7 400 100 100 L 50 50 1 1 P +X OUT 8 400 -200 100 L 50 50 1 1 O +ENDDRAW +ENDDEF +# +#End Library diff --git a/F0-nolib/canbus/kicad/sym-lib-table b/F0-nolib/canbus/kicad/sym-lib-table new file mode 100644 index 0000000..366fae1 --- /dev/null +++ b/F0-nolib/canbus/kicad/sym-lib-table @@ -0,0 +1,8 @@ +(sym_lib_table + (lib (name stm32-rescue)(type Legacy)(uri ${KIPRJMOD}/stm32-rescue.lib)(options "")(descr "")) + (lib (name stm32)(type Legacy)(uri /home/eddy/kicad/Kicad-Libraries/library/stm32.lib)(options "")(descr "")) + (lib (name vreg)(type Legacy)(uri /home/eddy/kicad/Kicad-Libraries/library/vreg.lib)(options "")(descr "")) + (lib (name elements)(type Legacy)(uri ${KIPRJMOD}/elements.lib)(options "")(descr "")) + (lib (name switches)(type Legacy)(uri /home/eddy/kicad/Kicad-Libraries/library/switches.lib)(options "")(descr "")) + (lib (name acs712)(type Legacy)(uri ${KIPRJMOD}/acs712.lib)(options "")(descr "")) +) diff --git a/F0-nolib/ch340/Readme.md b/F0-nolib/ch340/Readme.md deleted file mode 100644 index 3cdb82d..0000000 --- a/F0-nolib/ch340/Readme.md +++ /dev/null @@ -1,5 +0,0 @@ -Simple code for USB development board, emulates ch340 - - - -USB: https://github.com/majbthrd/CDCHIDwidget/blob/master/src/main.c \ No newline at end of file diff --git a/F0-nolib/ch340/ch340.sublime-project b/F0-nolib/ch340/ch340.sublime-project deleted file mode 100644 index 24db303..0000000 --- a/F0-nolib/ch340/ch340.sublime-project +++ /dev/null @@ -1,8 +0,0 @@ -{ - "folders": - [ - { - "path": "." - } - ] -} diff --git a/F0-nolib/ch340/ch340.sublime-workspace b/F0-nolib/ch340/ch340.sublime-workspace deleted file mode 100644 index d46294b..0000000 --- a/F0-nolib/ch340/ch340.sublime-workspace +++ /dev/null @@ -1,548 +0,0 @@ -{ - "auto_complete": - { - "selected_items": - [ - [ - "usb", - "usb_device\t(ch341.c)" - ] - ] - }, - "buffers": - [ - { - "file": "/home/eddy/C-files/stm32samples/F0-nolib/Snippets/fallthru", - "settings": - { - "buffer_size": 30, - "line_ending": "Unix" - } - }, - { - "contents": "// SPDX-License-Identifier: GPL-2.0\n/*\n * Copyright 2007, Frank A Kingswood \n * Copyright 2007, Werner Cornelius \n * Copyright 2009, Boris Hajduk \n *\n * ch341.c implements a serial port driver for the Winchiphead CH341.\n *\n * The CH341 device can be used to implement an RS232 asynchronous\n * serial port, an IEEE-1284 parallel printer port or a memory-like\n * interface. In all cases the CH341 supports an I2C interface as well.\n * This driver only supports the asynchronous serial interface.\n */\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define DEFAULT_BAUD_RATE 9600\n#define DEFAULT_TIMEOUT 1000\n\n/* flags for IO-Bits */\n#define CH341_BIT_RTS (1 << 6)\n#define CH341_BIT_DTR (1 << 5)\n\n/******************************/\n/* interrupt pipe definitions */\n/******************************/\n/* always 4 interrupt bytes */\n/* first irq byte normally 0x08 */\n/* second irq byte base 0x7d + below */\n/* third irq byte base 0x94 + below */\n/* fourth irq byte normally 0xee */\n\n/* second interrupt byte */\n#define CH341_MULT_STAT 0x04 /* multiple status since last interrupt event */\n\n/* status returned in third interrupt answer byte, inverted in data\n from irq */\n#define CH341_BIT_CTS 0x01\n#define CH341_BIT_DSR 0x02\n#define CH341_BIT_RI 0x04\n#define CH341_BIT_DCD 0x08\n#define CH341_BITS_MODEM_STAT 0x0f /* all bits */\n\n/*******************************/\n/* baudrate calculation factor */\n/*******************************/\n#define CH341_BAUDBASE_FACTOR 1532620800\n#define CH341_BAUDBASE_DIVMAX 3\n\n/* Break support - the information used to implement this was gleaned from\n * the Net/FreeBSD uchcom.c driver by Takanori Watanabe. Domo arigato.\n */\n\n#define CH341_REQ_READ_VERSION 0x5F\n#define CH341_REQ_WRITE_REG 0x9A\n#define CH341_REQ_READ_REG 0x95\n#define CH341_REQ_SERIAL_INIT 0xA1\n#define CH341_REQ_MODEM_CTRL 0xA4\n\n#define CH341_REG_BREAK 0x05\n#define CH341_REG_LCR 0x18\n#define CH341_NBREAK_BITS 0x01\n\n#define CH341_LCR_ENABLE_RX 0x80\n#define CH341_LCR_ENABLE_TX 0x40\n#define CH341_LCR_MARK_SPACE 0x20\n#define CH341_LCR_PAR_EVEN 0x10\n#define CH341_LCR_ENABLE_PAR 0x08\n#define CH341_LCR_STOP_BITS_2 0x04\n#define CH341_LCR_CS8 0x03\n#define CH341_LCR_CS7 0x02\n#define CH341_LCR_CS6 0x01\n#define CH341_LCR_CS5 0x00\n\nstatic const struct usb_device_id id_table[] = {\n\t{ USB_DEVICE(0x4348, 0x5523) },\n\t{ USB_DEVICE(0x1a86, 0x7523) },\n\t{ USB_DEVICE(0x1a86, 0x5523) },\n\t{ },\n};\nMODULE_DEVICE_TABLE(usb, id_table);\n\nstruct ch341_private {\n\tspinlock_t lock; /* access lock */\n\tunsigned baud_rate; /* set baud rate */\n\tu8 mcr;\n\tu8 msr;\n\tu8 lcr;\n};\n\nstatic void ch341_set_termios(struct tty_struct *tty,\n\t\t\t struct usb_serial_port *port,\n\t\t\t struct ktermios *old_termios);\n\nstatic int ch341_control_out(struct usb_device *dev, u8 request,\n\t\t\t u16 value, u16 index)\n{\n\tint r;\n\n\tdev_dbg(&dev->dev, \"%s - (%02x,%04x,%04x)\\n\", __func__,\n\t\trequest, value, index);\n\n\tr = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request,\n\t\t\t USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,\n\t\t\t value, index, NULL, 0, DEFAULT_TIMEOUT);\n\tif (r < 0)\n\t\tdev_err(&dev->dev, \"failed to send control message: %d\\n\", r);\n\n\treturn r;\n}\n\nstatic int ch341_control_in(struct usb_device *dev,\n\t\t\t u8 request, u16 value, u16 index,\n\t\t\t char *buf, unsigned bufsize)\n{\n\tint r;\n\n\tdev_dbg(&dev->dev, \"%s - (%02x,%04x,%04x,%u)\\n\", __func__,\n\t\trequest, value, index, bufsize);\n\n\tr = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request,\n\t\t\t USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,\n\t\t\t value, index, buf, bufsize, DEFAULT_TIMEOUT);\n\tif (r < bufsize) {\n\t\tif (r >= 0) {\n\t\t\tdev_err(&dev->dev,\n\t\t\t\t\"short control message received (%d < %u)\\n\",\n\t\t\t\tr, bufsize);\n\t\t\tr = -EIO;\n\t\t}\n\n\t\tdev_err(&dev->dev, \"failed to receive control message: %d\\n\",\n\t\t\tr);\n\t\treturn r;\n\t}\n\n\treturn 0;\n}\n\nstatic int ch341_set_baudrate_lcr(struct usb_device *dev,\n\t\t\t\t struct ch341_private *priv, u8 lcr)\n{\n\tshort a;\n\tint r;\n\tunsigned long factor;\n\tshort divisor;\n\n\tif (!priv->baud_rate)\n\t\treturn -EINVAL;\n\tfactor = (CH341_BAUDBASE_FACTOR / priv->baud_rate);\n\tdivisor = CH341_BAUDBASE_DIVMAX;\n\n\twhile ((factor > 0xfff0) && divisor) {\n\t\tfactor >>= 3;\n\t\tdivisor--;\n\t}\n\n\tif (factor > 0xfff0)\n\t\treturn -EINVAL;\n\n\tfactor = 0x10000 - factor;\n\ta = (factor & 0xff00) | divisor;\n\n\t/*\n\t * CH341A buffers data until a full endpoint-size packet (32 bytes)\n\t * has been received unless bit 7 is set.\n\t */\n\ta |= BIT(7);\n\n\tr = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x1312, a);\n\tif (r)\n\t\treturn r;\n\n\tr = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x2518, lcr);\n\tif (r)\n\t\treturn r;\n\n\treturn r;\n}\n\nstatic int ch341_set_handshake(struct usb_device *dev, u8 control)\n{\n\treturn ch341_control_out(dev, CH341_REQ_MODEM_CTRL, ~control, 0);\n}\n\nstatic int ch341_get_status(struct usb_device *dev, struct ch341_private *priv)\n{\n\tconst unsigned int size = 2;\n\tchar *buffer;\n\tint r;\n\tunsigned long flags;\n\n\tbuffer = kmalloc(size, GFP_KERNEL);\n\tif (!buffer)\n\t\treturn -ENOMEM;\n\n\tr = ch341_control_in(dev, CH341_REQ_READ_REG, 0x0706, 0, buffer, size);\n\tif (r < 0)\n\t\tgoto out;\n\n\tspin_lock_irqsave(&priv->lock, flags);\n\tpriv->msr = (~(*buffer)) & CH341_BITS_MODEM_STAT;\n\tspin_unlock_irqrestore(&priv->lock, flags);\n\nout:\tkfree(buffer);\n\treturn r;\n}\n\n/* -------------------------------------------------------------------------- */\n\nstatic int ch341_configure(struct usb_device *dev, struct ch341_private *priv)\n{\n\tconst unsigned int size = 2;\n\tchar *buffer;\n\tint r;\n\n\tbuffer = kmalloc(size, GFP_KERNEL);\n\tif (!buffer)\n\t\treturn -ENOMEM;\n\n\t/* expect two bytes 0x27 0x00 */\n\tr = ch341_control_in(dev, CH341_REQ_READ_VERSION, 0, 0, buffer, size);\n\tif (r < 0)\n\t\tgoto out;\n\tdev_dbg(&dev->dev, \"Chip version: 0x%02x\\n\", buffer[0]);\n\n\tr = ch341_control_out(dev, CH341_REQ_SERIAL_INIT, 0, 0);\n\tif (r < 0)\n\t\tgoto out;\n\n\tr = ch341_set_baudrate_lcr(dev, priv, priv->lcr);\n\tif (r < 0)\n\t\tgoto out;\n\n\tr = ch341_set_handshake(dev, priv->mcr);\n\nout:\tkfree(buffer);\n\treturn r;\n}\n\nstatic int ch341_port_probe(struct usb_serial_port *port)\n{\n\tstruct ch341_private *priv;\n\tint r;\n\n\tpriv = kzalloc(sizeof(struct ch341_private), GFP_KERNEL);\n\tif (!priv)\n\t\treturn -ENOMEM;\n\n\tspin_lock_init(&priv->lock);\n\tpriv->baud_rate = DEFAULT_BAUD_RATE;\n\t/*\n\t * Some CH340 devices appear unable to change the initial LCR\n\t * settings, so set a sane 8N1 default.\n\t */\n\tpriv->lcr = CH341_LCR_ENABLE_RX | CH341_LCR_ENABLE_TX | CH341_LCR_CS8;\n\n\tr = ch341_configure(port->serial->dev, priv);\n\tif (r < 0)\n\t\tgoto error;\n\n\tusb_set_serial_port_data(port, priv);\n\treturn 0;\n\nerror:\tkfree(priv);\n\treturn r;\n}\n\nstatic int ch341_port_remove(struct usb_serial_port *port)\n{\n\tstruct ch341_private *priv;\n\n\tpriv = usb_get_serial_port_data(port);\n\tkfree(priv);\n\n\treturn 0;\n}\n\nstatic int ch341_carrier_raised(struct usb_serial_port *port)\n{\n\tstruct ch341_private *priv = usb_get_serial_port_data(port);\n\tif (priv->msr & CH341_BIT_DCD)\n\t\treturn 1;\n\treturn 0;\n}\n\nstatic void ch341_dtr_rts(struct usb_serial_port *port, int on)\n{\n\tstruct ch341_private *priv = usb_get_serial_port_data(port);\n\tunsigned long flags;\n\n\t/* drop DTR and RTS */\n\tspin_lock_irqsave(&priv->lock, flags);\n\tif (on)\n\t\tpriv->mcr |= CH341_BIT_RTS | CH341_BIT_DTR;\n\telse\n\t\tpriv->mcr &= ~(CH341_BIT_RTS | CH341_BIT_DTR);\n\tspin_unlock_irqrestore(&priv->lock, flags);\n\tch341_set_handshake(port->serial->dev, priv->mcr);\n}\n\nstatic void ch341_close(struct usb_serial_port *port)\n{\n\tusb_serial_generic_close(port);\n\tusb_kill_urb(port->interrupt_in_urb);\n}\n\n\n/* open this device, set default parameters */\nstatic int ch341_open(struct tty_struct *tty, struct usb_serial_port *port)\n{\n\tstruct ch341_private *priv = usb_get_serial_port_data(port);\n\tint r;\n\n\tif (tty)\n\t\tch341_set_termios(tty, port, NULL);\n\n\tdev_dbg(&port->dev, \"%s - submitting interrupt urb\\n\", __func__);\n\tr = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);\n\tif (r) {\n\t\tdev_err(&port->dev, \"%s - failed to submit interrupt urb: %d\\n\",\n\t\t\t__func__, r);\n\t\treturn r;\n\t}\n\n\tr = ch341_get_status(port->serial->dev, priv);\n\tif (r < 0) {\n\t\tdev_err(&port->dev, \"failed to read modem status: %d\\n\", r);\n\t\tgoto err_kill_interrupt_urb;\n\t}\n\n\tr = usb_serial_generic_open(tty, port);\n\tif (r)\n\t\tgoto err_kill_interrupt_urb;\n\n\treturn 0;\n\nerr_kill_interrupt_urb:\n\tusb_kill_urb(port->interrupt_in_urb);\n\n\treturn r;\n}\n\n/* Old_termios contains the original termios settings and\n * tty->termios contains the new setting to be used.\n */\nstatic void ch341_set_termios(struct tty_struct *tty,\n\t\tstruct usb_serial_port *port, struct ktermios *old_termios)\n{\n\tstruct ch341_private *priv = usb_get_serial_port_data(port);\n\tunsigned baud_rate;\n\tunsigned long flags;\n\tu8 lcr;\n\tint r;\n\n\t/* redundant changes may cause the chip to lose bytes */\n\tif (old_termios && !tty_termios_hw_change(&tty->termios, old_termios))\n\t\treturn;\n\n\tbaud_rate = tty_get_baud_rate(tty);\n\n\tlcr = CH341_LCR_ENABLE_RX | CH341_LCR_ENABLE_TX;\n\n\tswitch (C_CSIZE(tty)) {\n\tcase CS5:\n\t\tlcr |= CH341_LCR_CS5;\n\t\tbreak;\n\tcase CS6:\n\t\tlcr |= CH341_LCR_CS6;\n\t\tbreak;\n\tcase CS7:\n\t\tlcr |= CH341_LCR_CS7;\n\t\tbreak;\n\tcase CS8:\n\t\tlcr |= CH341_LCR_CS8;\n\t\tbreak;\n\t}\n\n\tif (C_PARENB(tty)) {\n\t\tlcr |= CH341_LCR_ENABLE_PAR;\n\t\tif (C_PARODD(tty) == 0)\n\t\t\tlcr |= CH341_LCR_PAR_EVEN;\n\t\tif (C_CMSPAR(tty))\n\t\t\tlcr |= CH341_LCR_MARK_SPACE;\n\t}\n\n\tif (C_CSTOPB(tty))\n\t\tlcr |= CH341_LCR_STOP_BITS_2;\n\n\tif (baud_rate) {\n\t\tpriv->baud_rate = baud_rate;\n\n\t\tr = ch341_set_baudrate_lcr(port->serial->dev, priv, lcr);\n\t\tif (r < 0 && old_termios) {\n\t\t\tpriv->baud_rate = tty_termios_baud_rate(old_termios);\n\t\t\ttty_termios_copy_hw(&tty->termios, old_termios);\n\t\t} else if (r == 0) {\n\t\t\tpriv->lcr = lcr;\n\t\t}\n\t}\n\n\tspin_lock_irqsave(&priv->lock, flags);\n\tif (C_BAUD(tty) == B0)\n\t\tpriv->mcr &= ~(CH341_BIT_DTR | CH341_BIT_RTS);\n\telse if (old_termios && (old_termios->c_cflag & CBAUD) == B0)\n\t\tpriv->mcr |= (CH341_BIT_DTR | CH341_BIT_RTS);\n\tspin_unlock_irqrestore(&priv->lock, flags);\n\n\tch341_set_handshake(port->serial->dev, priv->mcr);\n}\n\nstatic void ch341_break_ctl(struct tty_struct *tty, int break_state)\n{\n\tconst uint16_t ch341_break_reg =\n\t\t\t((uint16_t) CH341_REG_LCR << 8) | CH341_REG_BREAK;\n\tstruct usb_serial_port *port = tty->driver_data;\n\tint r;\n\tuint16_t reg_contents;\n\tuint8_t *break_reg;\n\n\tbreak_reg = kmalloc(2, GFP_KERNEL);\n\tif (!break_reg)\n\t\treturn;\n\n\tr = ch341_control_in(port->serial->dev, CH341_REQ_READ_REG,\n\t\t\tch341_break_reg, 0, break_reg, 2);\n\tif (r < 0) {\n\t\tdev_err(&port->dev, \"%s - USB control read error (%d)\\n\",\n\t\t\t\t__func__, r);\n\t\tgoto out;\n\t}\n\tdev_dbg(&port->dev, \"%s - initial ch341 break register contents - reg1: %x, reg2: %x\\n\",\n\t\t__func__, break_reg[0], break_reg[1]);\n\tif (break_state != 0) {\n\t\tdev_dbg(&port->dev, \"%s - Enter break state requested\\n\", __func__);\n\t\tbreak_reg[0] &= ~CH341_NBREAK_BITS;\n\t\tbreak_reg[1] &= ~CH341_LCR_ENABLE_TX;\n\t} else {\n\t\tdev_dbg(&port->dev, \"%s - Leave break state requested\\n\", __func__);\n\t\tbreak_reg[0] |= CH341_NBREAK_BITS;\n\t\tbreak_reg[1] |= CH341_LCR_ENABLE_TX;\n\t}\n\tdev_dbg(&port->dev, \"%s - New ch341 break register contents - reg1: %x, reg2: %x\\n\",\n\t\t__func__, break_reg[0], break_reg[1]);\n\treg_contents = get_unaligned_le16(break_reg);\n\tr = ch341_control_out(port->serial->dev, CH341_REQ_WRITE_REG,\n\t\t\tch341_break_reg, reg_contents);\n\tif (r < 0)\n\t\tdev_err(&port->dev, \"%s - USB control write error (%d)\\n\",\n\t\t\t\t__func__, r);\nout:\n\tkfree(break_reg);\n}\n\nstatic int ch341_tiocmset(struct tty_struct *tty,\n\t\t\t unsigned int set, unsigned int clear)\n{\n\tstruct usb_serial_port *port = tty->driver_data;\n\tstruct ch341_private *priv = usb_get_serial_port_data(port);\n\tunsigned long flags;\n\tu8 control;\n\n\tspin_lock_irqsave(&priv->lock, flags);\n\tif (set & TIOCM_RTS)\n\t\tpriv->mcr |= CH341_BIT_RTS;\n\tif (set & TIOCM_DTR)\n\t\tpriv->mcr |= CH341_BIT_DTR;\n\tif (clear & TIOCM_RTS)\n\t\tpriv->mcr &= ~CH341_BIT_RTS;\n\tif (clear & TIOCM_DTR)\n\t\tpriv->mcr &= ~CH341_BIT_DTR;\n\tcontrol = priv->mcr;\n\tspin_unlock_irqrestore(&priv->lock, flags);\n\n\treturn ch341_set_handshake(port->serial->dev, control);\n}\n\nstatic void ch341_update_status(struct usb_serial_port *port,\n\t\t\t\t\tunsigned char *data, size_t len)\n{\n\tstruct ch341_private *priv = usb_get_serial_port_data(port);\n\tstruct tty_struct *tty;\n\tunsigned long flags;\n\tu8 status;\n\tu8 delta;\n\n\tif (len < 4)\n\t\treturn;\n\n\tstatus = ~data[2] & CH341_BITS_MODEM_STAT;\n\n\tspin_lock_irqsave(&priv->lock, flags);\n\tdelta = status ^ priv->msr;\n\tpriv->msr = status;\n\tspin_unlock_irqrestore(&priv->lock, flags);\n\n\tif (data[1] & CH341_MULT_STAT)\n\t\tdev_dbg(&port->dev, \"%s - multiple status change\\n\", __func__);\n\n\tif (!delta)\n\t\treturn;\n\n\tif (delta & CH341_BIT_CTS)\n\t\tport->icount.cts++;\n\tif (delta & CH341_BIT_DSR)\n\t\tport->icount.dsr++;\n\tif (delta & CH341_BIT_RI)\n\t\tport->icount.rng++;\n\tif (delta & CH341_BIT_DCD) {\n\t\tport->icount.dcd++;\n\t\ttty = tty_port_tty_get(&port->port);\n\t\tif (tty) {\n\t\t\tusb_serial_handle_dcd_change(port, tty,\n\t\t\t\t\t\tstatus & CH341_BIT_DCD);\n\t\t\ttty_kref_put(tty);\n\t\t}\n\t}\n\n\twake_up_interruptible(&port->port.delta_msr_wait);\n}\n\nstatic void ch341_read_int_callback(struct urb *urb)\n{\n\tstruct usb_serial_port *port = urb->context;\n\tunsigned char *data = urb->transfer_buffer;\n\tunsigned int len = urb->actual_length;\n\tint status;\n\n\tswitch (urb->status) {\n\tcase 0:\n\t\t/* success */\n\t\tbreak;\n\tcase -ECONNRESET:\n\tcase -ENOENT:\n\tcase -ESHUTDOWN:\n\t\t/* this urb is terminated, clean up */\n\t\tdev_dbg(&urb->dev->dev, \"%s - urb shutting down: %d\\n\",\n\t\t\t__func__, urb->status);\n\t\treturn;\n\tdefault:\n\t\tdev_dbg(&urb->dev->dev, \"%s - nonzero urb status: %d\\n\",\n\t\t\t__func__, urb->status);\n\t\tgoto exit;\n\t}\n\n\tusb_serial_debug_data(&port->dev, __func__, len, data);\n\tch341_update_status(port, data, len);\nexit:\n\tstatus = usb_submit_urb(urb, GFP_ATOMIC);\n\tif (status) {\n\t\tdev_err(&urb->dev->dev, \"%s - usb_submit_urb failed: %d\\n\",\n\t\t\t__func__, status);\n\t}\n}\n\nstatic int ch341_tiocmget(struct tty_struct *tty)\n{\n\tstruct usb_serial_port *port = tty->driver_data;\n\tstruct ch341_private *priv = usb_get_serial_port_data(port);\n\tunsigned long flags;\n\tu8 mcr;\n\tu8 status;\n\tunsigned int result;\n\n\tspin_lock_irqsave(&priv->lock, flags);\n\tmcr = priv->mcr;\n\tstatus = priv->msr;\n\tspin_unlock_irqrestore(&priv->lock, flags);\n\n\tresult = ((mcr & CH341_BIT_DTR)\t\t? TIOCM_DTR : 0)\n\t\t | ((mcr & CH341_BIT_RTS)\t? TIOCM_RTS : 0)\n\t\t | ((status & CH341_BIT_CTS)\t? TIOCM_CTS : 0)\n\t\t | ((status & CH341_BIT_DSR)\t? TIOCM_DSR : 0)\n\t\t | ((status & CH341_BIT_RI)\t? TIOCM_RI : 0)\n\t\t | ((status & CH341_BIT_DCD)\t? TIOCM_CD : 0);\n\n\tdev_dbg(&port->dev, \"%s - result = %x\\n\", __func__, result);\n\n\treturn result;\n}\n\nstatic int ch341_reset_resume(struct usb_serial *serial)\n{\n\tstruct usb_serial_port *port = serial->port[0];\n\tstruct ch341_private *priv = usb_get_serial_port_data(port);\n\tint ret;\n\n\t/* reconfigure ch341 serial port after bus-reset */\n\tch341_configure(serial->dev, priv);\n\n\tif (tty_port_initialized(&port->port)) {\n\t\tret = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);\n\t\tif (ret) {\n\t\t\tdev_err(&port->dev, \"failed to submit interrupt urb: %d\\n\",\n\t\t\t\tret);\n\t\t\treturn ret;\n\t\t}\n\n\t\tret = ch341_get_status(port->serial->dev, priv);\n\t\tif (ret < 0) {\n\t\t\tdev_err(&port->dev, \"failed to read modem status: %d\\n\",\n\t\t\t\tret);\n\t\t}\n\t}\n\n\treturn usb_serial_generic_resume(serial);\n}\n\nstatic struct usb_serial_driver ch341_device = {\n\t.driver = {\n\t\t.owner\t= THIS_MODULE,\n\t\t.name\t= \"ch341-uart\",\n\t},\n\t.id_table = id_table,\n\t.num_ports = 1,\n\t.open = ch341_open,\n\t.dtr_rts\t = ch341_dtr_rts,\n\t.carrier_raised\t = ch341_carrier_raised,\n\t.close = ch341_close,\n\t.set_termios = ch341_set_termios,\n\t.break_ctl = ch341_break_ctl,\n\t.tiocmget = ch341_tiocmget,\n\t.tiocmset = ch341_tiocmset,\n\t.tiocmiwait = usb_serial_generic_tiocmiwait,\n\t.read_int_callback = ch341_read_int_callback,\n\t.port_probe = ch341_port_probe,\n\t.port_remove = ch341_port_remove,\n\t.reset_resume = ch341_reset_resume,\n};\n\nstatic struct usb_serial_driver * const serial_drivers[] = {\n\t&ch341_device, NULL\n};\n\nmodule_usb_serial_driver(serial_drivers, id_table);\n\nMODULE_LICENSE(\"GPL v2\");\n", - "file": "/usr/src/linux/drivers/usb/serial/ch341.c", - "file_size": 16239, - "file_write_time": 131616480330000000, - "settings": - { - "buffer_size": 16239, - "line_ending": "Unix" - } - }, - { - "file": "/home/eddy/C-files/stm32samples/F1-nolib/led_blink/Makefile", - "settings": - { - "buffer_size": 3346, - "line_ending": "Unix" - } - }, - { - "file": "/usr/src/linux/drivers/usb/serial/pl2303.c", - "settings": - { - "buffer_size": 27410, - "line_ending": "Unix" - } - }, - { - "file": "main.c", - "settings": - { - "buffer_size": 4104, - "encoding": "UTF-8", - "line_ending": "Unix" - } - }, - { - "file": "usb.c", - "settings": - { - "buffer_size": 4371, - "encoding": "UTF-8", - "line_ending": "Unix" - } - }, - { - "file": "usb.h", - "settings": - { - "buffer_size": 1129, - "line_ending": "Unix" - } - }, - { - "file": "usb_lib.c", - "settings": - { - "buffer_size": 18311, - "encoding": "Cyrillic (KOI8-R)", - "line_ending": "Windows" - } - }, - { - "file": "usb_lib.h", - "settings": - { - "buffer_size": 7155, - "line_ending": "Windows" - } - } - ], - "build_system": "", - "build_system_choices": - [ - ], - "build_varint": "", - "command_palette": - { - "height": 0.0, - "last_filter": "", - "selected_items": - [ - [ - "Package Control: inst", - "Package Control: Install Package" - ], - [ - "Package Control: in", - "Package Control: Install Package" - ], - [ - "Package Control: install", - "Package Control: Install Package" - ], - [ - "Package Control: ", - "Package Control: Install Package" - ], - [ - "inst", - "Package Control: Install Package" - ] - ], - "width": 0.0 - }, - "console": - { - "height": 143.0, - "history": - [ - "import urllib.request,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by) " - ] - }, - "distraction_free": - { - "menu_visible": true, - "show_minimap": false, - "show_open_files": false, - "show_tabs": false, - "side_bar_visible": false, - "status_bar_visible": false - }, - "expanded_folders": - [ - "/home/eddy/C-files/stm32samples/F0-nolib/ch340" - ], - "file_history": - [ - "/home/eddy/C-files/stm32samples/.c", - "/home/eddy/.config/sublime-text-3/Packages/All Autocomplete/All Autocomplete.sublime-settings", - "/home/eddy/.config/sublime-text-3/Packages/Package Control/Package Control.sublime-settings", - "/home/eddy/C-files/stm32samples/F0-nolib/ch340/usb_defs.h", - "/home/eddy/C-files/stm32samples/F0-nolib/ch340/hardware.h", - "/home/eddy/C-files/stm32samples/F0-nolib/ch340/hardware.c", - "/home/eddy/C-files/stm32samples/F0-nolib/usbcdc/can.c", - "/home/eddy/C-files/stm32samples/F0-nolib/ch340/usart.c", - "/home/eddy/C-files/stm32samples/F0-nolib/usbcdc/can.h", - "/home/eddy/C-files/stm32samples/F0-nolib/ch340/Readme.md" - ], - "find": - { - "height": 43.0 - }, - "find_in_files": - { - "height": 0.0, - "where_history": - [ - ] - }, - "find_state": - { - "case_sensitive": false, - "find_history": - [ - ], - "highlight": true, - "in_selection": false, - "preserve_case": false, - "regex": false, - "replace_history": - [ - ], - "reverse": false, - "show_context": true, - "use_buffer2": true, - "whole_word": false, - "wrap": true - }, - "groups": - [ - { - "selected": 2, - "sheets": - [ - { - "buffer": 0, - "file": "/home/eddy/C-files/stm32samples/F0-nolib/Snippets/fallthru", - "semi_transient": false, - "settings": - { - "buffer_size": 30, - "regions": - { - }, - "selection": - [ - [ - 30, - 30 - ] - ], - "settings": - { - "syntax": "Packages/Text/Plain text.tmLanguage" - }, - "translation.x": 0.0, - "translation.y": 0.0, - "zoom_level": 1.0 - }, - "stack_index": 4, - "type": "text" - }, - { - "buffer": 1, - "file": "/usr/src/linux/drivers/usb/serial/ch341.c", - "semi_transient": false, - "settings": - { - "buffer_size": 16239, - "regions": - { - }, - "selection": - [ - [ - 4745, - 4745 - ] - ], - "settings": - { - "syntax": "Packages/C++/C.sublime-syntax", - "translate_tabs_to_spaces": false - }, - "translation.x": 0.0, - "translation.y": 3426.0, - "zoom_level": 1.0 - }, - "stack_index": 1, - "type": "text" - }, - { - "buffer": 2, - "file": "/home/eddy/C-files/stm32samples/F1-nolib/led_blink/Makefile", - "semi_transient": false, - "settings": - { - "buffer_size": 3346, - "regions": - { - }, - "selection": - [ - [ - 0, - 0 - ] - ], - "settings": - { - "syntax": "Packages/Makefile/Makefile.sublime-syntax" - }, - "translation.x": 0.0, - "translation.y": 0.0, - "zoom_level": 1.0 - }, - "stack_index": 0, - "type": "text" - }, - { - "buffer": 3, - "file": "/usr/src/linux/drivers/usb/serial/pl2303.c", - "semi_transient": false, - "settings": - { - "buffer_size": 27410, - "regions": - { - }, - "selection": - [ - [ - 6587, - 6587 - ] - ], - "settings": - { - "syntax": "Packages/C++/C.sublime-syntax", - "translate_tabs_to_spaces": false - }, - "translation.x": 0.0, - "translation.y": 3822.0, - "zoom_level": 1.0 - }, - "stack_index": 2, - "type": "text" - }, - { - "buffer": 4, - "file": "main.c", - "semi_transient": false, - "settings": - { - "buffer_size": 4104, - "regions": - { - }, - "selection": - [ - [ - 1948, - 1948 - ] - ], - "settings": - { - "syntax": "Packages/C++/C.sublime-syntax", - "tab_size": 4, - "translate_tabs_to_spaces": true - }, - "translation.x": 0.0, - "translation.y": 330.0, - "zoom_level": 1.0 - }, - "stack_index": 8, - "type": "text" - }, - { - "buffer": 5, - "file": "usb.c", - "semi_transient": false, - "settings": - { - "buffer_size": 4371, - "regions": - { - }, - "selection": - [ - [ - 1781, - 1781 - ] - ], - "settings": - { - "syntax": "Packages/C++/C.sublime-syntax", - "tab_size": 4, - "translate_tabs_to_spaces": true - }, - "translation.x": 0.0, - "translation.y": 818.0, - "zoom_level": 1.0 - }, - "stack_index": 7, - "type": "text" - }, - { - "buffer": 6, - "file": "usb.h", - "semi_transient": false, - "settings": - { - "buffer_size": 1129, - "regions": - { - }, - "selection": - [ - [ - 0, - 0 - ] - ], - "settings": - { - "syntax": "Packages/C++/C++.sublime-syntax" - }, - "translation.x": 0.0, - "translation.y": 0.0, - "zoom_level": 1.0 - }, - "stack_index": 6, - "type": "text" - }, - { - "buffer": 7, - "file": "usb_lib.c", - "semi_transient": false, - "settings": - { - "buffer_size": 18311, - "regions": - { - }, - "selection": - [ - [ - 6489, - 6489 - ] - ], - "settings": - { - "syntax": "Packages/C++/C.sublime-syntax", - "tab_size": 4, - "translate_tabs_to_spaces": true - }, - "translation.x": 0.0, - "translation.y": 4469.0, - "zoom_level": 1.0 - }, - "stack_index": 5, - "type": "text" - }, - { - "buffer": 8, - "file": "usb_lib.h", - "semi_transient": false, - "settings": - { - "buffer_size": 7155, - "regions": - { - }, - "selection": - [ - [ - 1925, - 1925 - ] - ], - "settings": - { - "syntax": "Packages/C++/C++.sublime-syntax", - "tab_size": 4, - "translate_tabs_to_spaces": true - }, - "translation.x": 0.0, - "translation.y": 727.0, - "zoom_level": 1.0 - }, - "stack_index": 3, - "type": "text" - } - ] - } - ], - "incremental_find": - { - "height": 0.0 - }, - "input": - { - "height": 37.0 - }, - "layout": - { - "cells": - [ - [ - 0, - 0, - 1, - 1 - ] - ], - "cols": - [ - 0.0, - 1.0 - ], - "rows": - [ - 0.0, - 1.0 - ] - }, - "menu_visible": true, - "output.find_results": - { - "height": 0.0 - }, - "output.unsaved_changes": - { - "height": 114.0 - }, - "pinned_build_system": "", - "project": "ch340.sublime-project", - "replace": - { - "height": 0.0 - }, - "save_all_on_build": true, - "select_file": - { - "height": 0.0, - "last_filter": "", - "selected_items": - [ - ], - "width": 0.0 - }, - "select_project": - { - "height": 0.0, - "last_filter": "", - "selected_items": - [ - ], - "width": 0.0 - }, - "select_symbol": - { - "height": 0.0, - "last_filter": "", - "selected_items": - [ - ], - "width": 0.0 - }, - "selected_group": 0, - "settings": - { - }, - "show_minimap": true, - "show_open_files": false, - "show_tabs": true, - "side_bar_visible": true, - "side_bar_width": 217.0, - "status_bar_visible": true, - "template_settings": - { - } -} diff --git a/F0-nolib/ch340/ch340emul.bin b/F0-nolib/ch340/ch340emul.bin deleted file mode 100755 index 5c9e5cbd2ea21282c4aec1cd8ef589bc1ac03855..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4936 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 B;U541 diff --git a/F0-nolib/ch340/lsusb_log b/F0-nolib/ch340/lsusb_log deleted file mode 100644 index 50bde2d..0000000 --- a/F0-nolib/ch340/lsusb_log +++ /dev/null @@ -1,69 +0,0 @@ - -Bus 002 Device 005: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.10 - bDeviceClass 255 Vendor Specific Class - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 8 - idVendor 0x1a86 QinHeng Electronics - idProduct 0x7523 HL-340 USB-Serial adapter - bcdDevice 2.54 - iManufacturer 0 - iProduct 2 USB2.0-Serial - iSerial 0 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 39 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 96mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 3 - bInterfaceClass 255 Vendor Specific Class - bInterfaceSubClass 1 - bInterfaceProtocol 2 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0020 1x 32 bytes - bInterval 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0020 1x 32 bytes - bInterval 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0008 1x 8 bytes - bInterval 1 -Device Status: 0x0000 - (Bus Powered) diff --git a/F0-nolib/ch340/Makefile b/F0-nolib/pl2303/Makefile similarity index 99% rename from F0-nolib/ch340/Makefile rename to F0-nolib/pl2303/Makefile index 2e59822..02b3f5f 100644 --- a/F0-nolib/ch340/Makefile +++ b/F0-nolib/pl2303/Makefile @@ -1,4 +1,4 @@ -BINARY = ch340emul +BINARY = pl2303 BOOTPORT ?= /dev/ttyUSB0 BOOTSPEED ?= 57600 # MCU FAMILY diff --git a/F0-nolib/pl2303/Readme.md b/F0-nolib/pl2303/Readme.md new file mode 100644 index 0000000..8e5c1db --- /dev/null +++ b/F0-nolib/pl2303/Readme.md @@ -0,0 +1 @@ +Simple CDC for USB development board, emulates PL2303 diff --git a/F0-nolib/ch340/hardware.c b/F0-nolib/pl2303/hardware.c similarity index 100% rename from F0-nolib/ch340/hardware.c rename to F0-nolib/pl2303/hardware.c diff --git a/F0-nolib/ch340/hardware.h b/F0-nolib/pl2303/hardware.h similarity index 100% rename from F0-nolib/ch340/hardware.h rename to F0-nolib/pl2303/hardware.h diff --git a/F0-nolib/ch340/main.c b/F0-nolib/pl2303/main.c similarity index 77% rename from F0-nolib/ch340/main.c rename to F0-nolib/pl2303/main.c index ef74b0c..9ada7e6 100644 --- a/F0-nolib/ch340/main.c +++ b/F0-nolib/pl2303/main.c @@ -18,7 +18,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ - #include "hardware.h" #include "usart.h" #include "usb.h" @@ -54,19 +53,32 @@ void iwdg_setup(){ IWDG->KR = IWDG_REFRESH; /* (6) */ } +void linecoding_handler(usb_LineCoding *lc){ + SEND("got new linecoding:"); + SEND(" baudrate="); printu(lc->dwDTERate); + SEND(", charFormat="); printu(lc->bCharFormat); + SEND(", parityType="); printu(lc->bParityType); + SEND(", dataBits="); printu(lc->bDataBits); + usart_putchar('\n'); +} + +void clstate_handler(uint16_t val){ + SEND("change control line state to "); + printu(val); + usart_putchar('\n'); +} + int main(void){ uint32_t lastT = 0; int L; char *txt; + char tmpbuf[129]; sysreset(); SysTick_Config(6000, 1); gpio_setup(); usart_setup(); - //iwdg_setup(); - SEND("Greetings! My address is "); - printuhex(getBRDaddr()); - newline(); + SEND("Hello!\n"); if(RCC->CSR & RCC_CSR_IWDGRSTF){ // watchdog reset occured SEND("WDGRESET=1\n"); @@ -77,6 +89,7 @@ int main(void){ RCC->CSR |= RCC_CSR_RMVF; // remove reset flags USB_setup(); + //iwdg_setup(); while (1){ IWDG->KR = IWDG_REFRESH; // refresh watchdog @@ -84,18 +97,32 @@ int main(void){ LED_blink(LED0); lastT = Tms; transmit_tbuf(); // non-blocking transmission of data from UART buffer every 0.5s + /*uint8_t r = 0; + if((r = USB_receive(tmpbuf, 128))){ + tmpbuf[r] = 0; + SEND("Received data over USB:\n"); + SEND(tmpbuf); + newline(); + }*/ } usb_proc(); + uint8_t r = 0; + if((r = USB_receive(tmpbuf, 128))){ + tmpbuf[r] = 0; + SEND("Received data over USB:\n"); + SEND(tmpbuf); + newline(); + } if(usartrx()){ // usart1 received data, store in in buffer L = usart_getline(&txt); char _1st = txt[0]; if(L == 2 && txt[1] == '\n'){ L = 0; switch(_1st){ - case 'A': - SEND("Board address: "); - printuhex(getBRDaddr()); - newline(); + case 'C': + SEND("USB "); + if(!USB_configured()) SEND("dis"); + SEND("connected\n"); break; case 'R': SEND("Soft reset\n"); @@ -110,7 +137,7 @@ int main(void){ break; default: // help SEND( - "'A' - get CAN address\n" + "'C' - test is USB configured\n" "'R' - software reset\n" "'U' - send test string over USB\n" "'W' - test watchdog\n" diff --git a/F0-nolib/pl2303/pl2303.bin b/F0-nolib/pl2303/pl2303.bin new file mode 100755 index 0000000000000000000000000000000000000000..0f23439b3d8de51843a7a04aea1de7335ec1b721 GIT binary patch literal 5576 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[_B`cgdAqVjeo=W|))mifAIqMi*TNSQ89Bs?r9^39F26cJEm?35 zxc94mzus2#IZfSi=`6+B?!FQOnqL}74M2e%&z|>ceupPd7tT64Xa^|xL*lY-$KA@p zB*r&6&=Gc>>+~NEJBBM3LII_{TXV9KxNB-SIhaw9de)S<^k-VW*1z?7@l~&HCGPcm zzL%>kl(#7l$UjqlEPsw(e}rDY@xQ#z{7$b;pK1PW^zLo+?j+V{g0nN+K0>8-hPRAR zuFi1r2<7e!=Z{cno#FHmgH0v9zc6uf#OqBZ>os#UFaqPLu2YB+Bd4h$x_s4M3-7dW z!NMgAH@S%sw}qcV?Z{7B{1)D6;ev%r7H)cg{1*Q2!>7VhnP~k zV|zUlYuVA>*3!&0H|(fqcDC2H*E8)c3?|_AmUd=G{iD`Etfj7D$M%)LY^{B`t_^wa z0a(JIhBmRK?ZMi1B#~~dZEI-XRk^Fx97ejXw!Jpo(7y8?D5-C5ZV9?zQ}LSe)fKBN z?^))8igjY;bprXz>tpo|kJQ&$Vob{;^=-_?ittJo4gn&J+154e1ax>ueXPB{4o50l zwzV^D^*ig^T~JxSvmGbUhK@4ZS}b8pc2jLbyVcQFzqO?W8S$4VoDzL-qZ-MQw3wukEj=?P`w}jdV6%dA{_^n6j2B<}O1_b2a W0qs}yHCtmg3X98=rZuN&9{vY)Cl%TN literal 0 HcmV?d00001 diff --git a/F0-nolib/ch340/usart.c b/F0-nolib/pl2303/usart.c similarity index 95% rename from F0-nolib/ch340/usart.c rename to F0-nolib/pl2303/usart.c index f00f10b..ccc8d63 100644 --- a/F0-nolib/ch340/usart.c +++ b/F0-nolib/pl2303/usart.c @@ -89,6 +89,13 @@ void usart_send(const char *str){ } } +void usart_sendn(const char *str, uint8_t L){ + for(uint8_t i = 0; i < L; ++i){ + if(odatalen[tbufno] == UARTBUFSZO) transmit_tbuf(); + tbuf[tbufno][odatalen[tbufno]++] = *str++; + } +} + void newline(){ usart_putchar('\n'); transmit_tbuf(); @@ -223,15 +230,21 @@ void printu(uint32_t val){ // print 32bit unsigned int as hex void printuhex(uint32_t val){ usart_send("0x"); - uint8_t *ptr = (uint8_t*)&val + 3; + uint8_t *ptr = (uint8_t*)&val + 3, start = 1; int i, j; for(i = 0; i < 4; ++i, --ptr){ + if(!*ptr && start) continue; for(j = 1; j > -1; --j){ + start = 0; register uint8_t half = (*ptr >> (4*j)) & 0x0f; if(half < 10) usart_putchar(half + '0'); else usart_putchar(half - 10 + 'a'); } } + if(start){ + usart_putchar('0'); + usart_putchar('0'); + } } // dump memory buffer diff --git a/F0-nolib/ch340/usart.h b/F0-nolib/pl2303/usart.h similarity index 97% rename from F0-nolib/ch340/usart.h rename to F0-nolib/pl2303/usart.h index b717165..fc9c5ff 100644 --- a/F0-nolib/ch340/usart.h +++ b/F0-nolib/pl2303/usart.h @@ -50,6 +50,7 @@ void transmit_tbuf(); void usart_setup(); int usart_getline(char **line); void usart_send(const char *str); +void usart_sendn(const char *str, uint8_t L); void newline(); void usart_putchar(const char ch); void printu(uint32_t val); diff --git a/F0-nolib/ch340/usb.c b/F0-nolib/pl2303/usb.c similarity index 60% rename from F0-nolib/ch340/usb.c rename to F0-nolib/pl2303/usb.c index 019db2f..3509f88 100644 --- a/F0-nolib/ch340/usb.c +++ b/F0-nolib/pl2303/usb.c @@ -24,20 +24,23 @@ #include "usb.h" #include "usb_lib.h" #include "usart.h" +#include // memcpy, memmove - - -static uint8_t buffer[BUFFSIZE+1]; -static uint8_t len, rcvflag = 0; +// incoming buffer size +#define IDATASZ (256) +static uint8_t incoming_data[IDATASZ]; +static uint8_t ovfl = 0; +static uint16_t idatalen = 0; +static int8_t usbON = 0; // ==1 when USB fully configured // interrupt IN handler (never used?) static uint16_t EP1_Handler(ep_t ep){ + uint8_t ep0buf[11]; if (ep.rx_flag){ - EP_Read(1, buffer); + EP_Read(1, ep0buf); ep.status = SET_VALID_TX(ep.status); ep.status = KEEP_STAT_RX(ep.status); - } else - if (ep.tx_flag){ + }else if (ep.tx_flag){ ep.status = SET_VALID_RX(ep.status); ep.status = SET_STALL_TX(ep.status); } @@ -46,16 +49,31 @@ static uint16_t EP1_Handler(ep_t ep){ // data IN/OUT handler static uint16_t EP2_Handler(ep_t ep){ + MSG("EP2\n"); if(ep.rx_flag){ - if(ep.rx_cnt > 0 && ep.rx_cnt < BUFFSIZE){ - rcvflag = 1; - len = EP_Read(2, buffer); - buffer[len] = 0; - #ifdef EBUG - MSG("read: "); - if(len) SEND((char*)buffer); - #endif + int rd = ep.rx_cnt, rest = IDATASZ - idatalen; + if(rd){ + if(rd <= rest){ + idatalen += EP_Read(2, &incoming_data[idatalen]); + ovfl = 0; + }else{ + ep.status = SET_NAK_RX(ep.status); + ovfl = 1; + return ep.status; + } } +#ifdef EBUG + SEND("receive "); + printu(ep.rx_cnt); + SEND(" bytes, idatalen="); + printu(idatalen); + SEND(" , rest="); + printu(rest); + incoming_data[idatalen] = 0; + SEND(" , the buffer now:\n"); + SEND((char*)incoming_data); + usart_putchar('\n'); +#endif // end of transaction: clear DTOGs ep.status = CLEAR_DTOG_RX(ep.status); ep.status = CLEAR_DTOG_TX(ep.status); @@ -80,16 +98,15 @@ void USB_setup(){ CRS->CR |= CRS_CR_CEN; // enable freq counter & block CRS->CFGR as read-only RCC->CFGR |= RCC_CFGR_SW; // allow RESET and CTRM interrupts - USB->CNTR = USB_CNTR_RESETM | USB_CNTR_CTRM; + USB -> CNTR = USB_CNTR_RESETM | USB_CNTR_CTRM; // clear flags - USB->ISTR = 0; + USB -> ISTR = 0; // and activate pullup - USB->BCDR |= USB_BCDR_DPPU; + USB -> BCDR |= USB_BCDR_DPPU; NVIC_EnableIRQ(USB_IRQn); } void usb_proc(){ - static int8_t usbON = 0; if(USB_GetState() == USB_CONFIGURE_STATE){ // USB configured - activate other endpoints if(!usbON){ // endpoints not activated MSG("Configured; activate other endpoints\n"); @@ -97,23 +114,11 @@ void usb_proc(){ // Buffer have 1024 bytes, but last 256 we use for CAN bus // 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) + // (first 64 are control registers, up to 192 - buffer for EP0) EP_Init(1, EP_TYPE_INTERRUPT, 192, 192, EP1_Handler); - EP_Init(2, EP_TYPE_BULK, 256, 320, EP2_Handler); // IN/OUT + 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){ - /* - * 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; @@ -126,3 +131,37 @@ void USB_send(char *buf){ while(*p++) ++l; EP_Write(3, (uint8_t*)buf, l); } + +/** + * @brief USB_receive + * @param buf (i) - buffer for received data + * @param bufsize - its size + * @return amount of received bytes + */ +int USB_receive(char *buf, int bufsize){ + if(!bufsize || !idatalen) return 0; + USB->CNTR = 0; + int sz = (idatalen > bufsize) ? bufsize : idatalen, rest = idatalen - sz; + memcpy(buf, incoming_data, sz); + if(rest > 0){ + memmove(incoming_data, &incoming_data[sz], rest); + idatalen = rest; + }else idatalen = 0; + if(ovfl){ + EP2_Handler(endpoints[2]); + uint16_t epstatus = USB->EPnR[2]; + epstatus = CLEAR_DTOG_RX(epstatus); + epstatus = SET_VALID_RX(epstatus); + USB->EPnR[2] = epstatus; + } + USB->CNTR = USB_CNTR_RESETM | USB_CNTR_CTRM; + return sz; +} + +/** + * @brief USB_configured + * @return 1 if USB is in configured state + */ +int USB_configured(){ + return usbON; +} diff --git a/F0-nolib/ch340/usb.h b/F0-nolib/pl2303/usb.h similarity index 94% rename from F0-nolib/ch340/usb.h rename to F0-nolib/pl2303/usb.h index c977ca4..0d5831a 100644 --- a/F0-nolib/ch340/usb.h +++ b/F0-nolib/pl2303/usb.h @@ -31,5 +31,7 @@ void USB_setup(); void usb_proc(); void USB_send(char *buf); +int USB_receive(char *buf, int bufsize); +int USB_configured(); #endif // __USB_H__ diff --git a/F0-nolib/ch340/usb_defs.h b/F0-nolib/pl2303/usb_defs.h similarity index 100% rename from F0-nolib/ch340/usb_defs.h rename to F0-nolib/pl2303/usb_defs.h diff --git a/F0-nolib/ch340/usb_lib.c b/F0-nolib/pl2303/usb_lib.c similarity index 86% rename from F0-nolib/ch340/usb_lib.c rename to F0-nolib/pl2303/usb_lib.c index fafcd91..df71bbd 100644 --- a/F0-nolib/ch340/usb_lib.c +++ b/F0-nolib/pl2303/usb_lib.c @@ -36,7 +36,6 @@ 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;} @@ -45,18 +44,18 @@ const uint8_t USB_DeviceDescriptor[] = { 0x01, // bDescriptorType - USB_DEVICE_DESC_TYPE 0x10, // bcdUSB_L - 1.10 0x01, // bcdUSB_H - 0xff, // bDeviceClass - Vendor Specific Class + 0x00, // bDeviceClass - USB_COMM 0x00, // bDeviceSubClass 0x00, // bDeviceProtocol - 0x08, // bMaxPacketSize - 0x86, // idVendor_L ch340: VID=0x1a86, PID=0x7523 - 0x1a, // idVendor_H - 0x23, // idProduct_L - 0x75, // idProduct_H - 0x36, // bcdDevice_Ver_L - 0x02, // bcdDevice_Ver_H - 0x00, // iManufacturer - 0x02, // iProduct USB2.0-Serial + 0x40, // bMaxPacketSize + 0x7b, // idVendor_L PL2303: VID=0x067b, PID=0x2303 + 0x06, // idVendor_H + 0x03, // idProduct_L + 0x23, // idProduct_H + 0x00, // bcdDevice_Ver_L + 0x03, // bcdDevice_Ver_H + 0x01, // iManufacturer + 0x02, // iProduct 0x00, // iSerialNumber 0x01 // bNumConfigurations }; @@ -66,10 +65,10 @@ const uint8_t USB_DeviceQualifierDescriptor[] = { 0x06, // bDescriptorType 0x10, // bcdUSB_L 0x01, // bcdUSB_H - 0xff, // bDeviceClass + 0x00, // bDeviceClass 0x00, // bDeviceSubClass 0x00, // bDeviceProtocol - 0x08, // bMaxPacketSize0 + 0x40, // bMaxPacketSize0 0x01, // bNumConfigurations 0x00 // Reserved }; @@ -83,7 +82,7 @@ const uint8_t USB_ConfigDescriptor[] = { 0x01, /* bNumInterfaces: 1 interface */ 0x01, /* bConfigurationValue: Configuration value */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */ - 0x80, /* bmAttributes - Bus powered */ + 0xa0, /* bmAttributes - Bus powered, Remote wakeup */ 0x32, /* MaxPower 100 mA */ /*---------------------------------------------------------------------------*/ @@ -95,68 +94,57 @@ const uint8_t USB_ConfigDescriptor[] = { 0x00, /* bAlternateSetting: Alternate setting */ 0x03, /* bNumEndpoints: 3 endpoints used */ 0xff, /* bInterfaceClass */ - 0x01, /* bInterfaceSubClass */ - 0x02, /* bInterfaceProtocol */ + 0x00, /* bInterfaceSubClass */ + 0x00, /* bInterfaceProtocol */ 0x00, /* iInterface: */ /////////////////////////////////////////////////// - /*Endpoint IN2 Descriptor*/ - 0x07, /* bLength: Endpoint Descriptor size */ - 0x05, /* bDescriptorType: Endpoint */ - 0x82, /* bEndpointAddress IN2 */ - 0x02, /* bmAttributes: Bulk */ - 0x20, /* wMaxPacketSize: 64 */ - 0x00, - 0x00, /* bInterval: ignore for Bulk transfer */ - /*Endpoint OUT2 Descriptor*/ - 0x07, /* bLength: Endpoint Descriptor size */ - 0x05, /* bDescriptorType: Endpoint */ - 0x02, /* bEndpointAddress: OUT2 */ - 0x02, /* bmAttributes: Bulk */ - 0x20, /* wMaxPacketSize: */ - 0x00, - 0x00, /* bInterval: ignore for Bulk transfer */ /*Endpoint 1 Descriptor*/ 0x07, /* bLength: Endpoint Descriptor size */ 0x05, /* bDescriptorType: Endpoint */ 0x81, /* bEndpointAddress IN1 */ 0x03, /* bmAttributes: Interrupt */ - 0x08, /* wMaxPacketSize LO: */ + 0x0a, /* wMaxPacketSize LO: */ 0x00, /* wMaxPacketSize HI: */ - 0x01, /* bInterval: */ -}; - -const uint8_t USB_StringLangDescriptor[] = { - STRING_LANG_DESCRIPTOR_SIZE_BYTE, // bLength - 0x03, // bDescriptorType - 0x09, // wLANGID_L - 0x04 // wLANGID_H + 0x01, /* bInterval: */ + + /*Endpoint OUT2 Descriptor*/ + 0x07, /* bLength: Endpoint Descriptor size */ + 0x05, /* bDescriptorType: Endpoint */ + 0x02, /* bEndpointAddress: OUT2 */ + 0x02, /* bmAttributes: Bulk */ + 0x40, /* wMaxPacketSize: */ + 0x00, + 0x00, /* bInterval: ignore for Bulk transfer */ + + /*Endpoint IN3 Descriptor*/ + 0x07, /* bLength: Endpoint Descriptor size */ + 0x05, /* bDescriptorType: Endpoint */ + 0x83, /* bEndpointAddress IN3 */ + 0x02, /* bmAttributes: Bulk */ + 0x40, /* wMaxPacketSize: 64 */ + 0x00, + 0x00, /* bInterval: ignore for Bulk transfer */ }; +_USB_LANG_ID_(LANG_US); // 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_STRING_(USB_StringSerialDescriptor, u"0") +_USB_STRING_(USB_StringManufacturingDescriptor, u"Prolific Technology Inc.") +_USB_STRING_(USB_StringProdDescriptor, u"USB-Serial Controller") static usb_dev_t USB_Dev; -static ep_t endpoints[MAX_ENDPOINTS]; +ep_t endpoints[MAX_ENDPOINTS]; /* * 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; +void WEAK linecoding_handler(usb_LineCoding __attribute__((unused)) *lc){ + MSG("linecoding"); } // SET_CONTROL_LINE_STATE -void WEAK clstate_handler(__attribute__((unused)) uint16_t val){ +void WEAK clstate_handler(uint16_t __attribute__((unused)) val){ #ifdef EBUG SEND("change state to "); printu(val); @@ -171,8 +159,26 @@ void WEAK break_handler(){ // handler of vendor requests void WEAK vendor_handler(config_pack_t *packet){ + /*SEND("Vendor, reqt="); + printuhex(packet->bmRequestType); + SEND(", wval="); + printuhex(packet->wValue); + usart_putchar('\n');*/ if(packet->bmRequestType & 0x80){ // read - uint8_t c = '?'; + uint8_t c; + switch(packet->wValue){ + case 0x8484: + c = 2; + break; + case 0x0080: + c = 1; + break; + case 0x8686: + c = 0xaa; + break; + default: + c = 0; + } EP_WriteIRQ(0, &c, 1); }else{ // write ZLP EP_WriteIRQ(0, (uint8_t *)0, 0); @@ -216,7 +222,7 @@ uint16_t EP0_Handler(ep_t ep){ wr0(USB_ConfigDescriptor, sizeof(USB_ConfigDescriptor)); break; case STRING_LANG_DESCRIPTOR: - wr0(USB_StringLangDescriptor, STRING_LANG_DESCRIPTOR_SIZE_BYTE); + wr0((const uint8_t *)&USB_StringLangDescriptor, STRING_LANG_DESCRIPTOR_SIZE_BYTE); break; case STRING_MAN_DESCRIPTOR: wr0((const uint8_t *)&USB_StringManufacturingDescriptor, USB_StringManufacturingDescriptor.bLength); @@ -278,7 +284,6 @@ uint16_t EP0_Handler(ep_t ep){ } }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 @@ -304,7 +309,7 @@ uint16_t EP0_Handler(ep_t ep){ }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"); + //WRITEDUMP("SET_LINE_CODING"); linecoding_handler((usb_LineCoding*)ep0databuf); } EP_WriteIRQ(0, (uint8_t *)0, 0); @@ -354,6 +359,8 @@ uint16_t EP0_Handler(ep_t ep){ return epstatus; } +// TODO: change initialisation with different buffer size! (EP0 have 8 bytes per buffer, EP1 - 10 bytes!) + /** * Endpoint initialisation, size of input buffer fixed to 64 bytes * @param number - EP num (0...7) @@ -388,7 +395,7 @@ void usb_isr(){ // state is default - wait for enumeration USB_Dev.USB_Status = USB_DEFAULT_STATE; } - while(USB->ISTR & USB_ISTR_CTR){ + if(USB->ISTR & USB_ISTR_CTR){ // EP number n = USB->ISTR & USB_ISTR_EPID; // copy status register @@ -426,7 +433,6 @@ void usb_isr(){ epstatus = CLEAR_CTR_TX(epstatus); // refresh EPnR USB->EPnR[n] = epstatus; - USB_BTABLE->EP[n].USB_COUNT_RX = 0x8400; } } @@ -469,9 +475,12 @@ void EP_Write(uint8_t number, const uint8_t *buf, uint16_t size){ * @return amount of data read */ 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; + int n = endpoints[number].rx_cnt; + if(n){ + for(int i = 0; i < n; ++i) + buf[i] = endpoints[number].rx_buf[i]; + } + return n; } // USB status diff --git a/F0-nolib/ch340/usb_lib.h b/F0-nolib/pl2303/usb_lib.h similarity index 91% rename from F0-nolib/ch340/usb_lib.h rename to F0-nolib/pl2303/usb_lib.h index 50c2cf7..f08d28c 100644 --- a/F0-nolib/ch340/usb_lib.h +++ b/F0-nolib/pl2303/usb_lib.h @@ -109,16 +109,29 @@ #define EP_TYPE_ISO 0x02 #define EP_TYPE_INTERRUPT 0x03 +#define LANG_US (uint16_t)0x0409 + #define _USB_STRING_(name, str) \ -const struct name \ +static const struct name \ { \ uint8_t bLength; \ uint8_t bDescriptorType; \ - wchar_t bString[(sizeof(str) - 2) / 2]; \ + uint16_t bString[(sizeof(str) - 2) / 2]; \ \ } \ name = {sizeof(name), 0x03, str}; +#define _USB_LANG_ID_(lng_id) \ + \ +static const struct USB_StringLangDescriptor \ +{ \ + uint8_t bLength; \ + uint8_t bDescriptorType; \ + uint16_t bString; \ + \ +} \ +USB_StringLangDescriptor = {0x04, 0x03, lng_id}; + // EP0 configuration packet typedef struct { uint8_t bmRequestType; @@ -169,9 +182,7 @@ typedef struct { uint16_t wLength; } __attribute__ ((packed)) usb_cdc_notification; -extern uint8_t setlinecoding; -#define SETLINECODING() (setlinecoding) -#define CLRLINECODING() do{setlinecoding = 0;}while(0) +extern ep_t endpoints[]; void USB_Init(); uint8_t USB_GetState(); diff --git a/F0-nolib/usbcdc/Readme.md b/F0-nolib/usbcdc/Readme.md index 42c2d9b..1d58cb1 100644 --- a/F0-nolib/usbcdc/Readme.md +++ b/F0-nolib/usbcdc/Readme.md @@ -1,5 +1,3 @@ Simple code for CAN/USB development board +Simultaneous work of USB CDC (PL2303 emulation) and CAN - - -USB: https://github.com/majbthrd/CDCHIDwidget/blob/master/src/main.c \ No newline at end of file