├── .gitignore
├── LICENSE
├── README.md
├── README_CN.md
├── bom
├── 2CAN+2UART.csv
└── 4CAN&2UART.csv
├── circuit
├── USB2CAN.PcbDoc
├── USB2CAN.PrjPcb
├── USB2CAN.SchDoc
└── USB2CAN.pdf
├── gerber
├── 2CAN+UART+DBUS
│ ├── Gerber_BoardOutline.GKO
│ ├── Gerber_BottomLayer.GBL
│ ├── Gerber_BottomPasteMaskLayer.GBP
│ ├── Gerber_BottomSilkLayer.GBO
│ ├── Gerber_BottomSolderMaskLayer.GBS
│ ├── Gerber_Drill_PTH.DRL
│ ├── Gerber_TopLayer.GTL
│ ├── Gerber_TopPasteMaskLayer.GTP
│ ├── Gerber_TopSilkLayer.GTO
│ ├── Gerber_TopSolderMaskLayer.GTS
│ └── ReadOnly.Mechanical
├── 4CAN
│ ├── USB2CAN.Cam
│ ├── usb2can.gbl
│ ├── usb2can.gbo
│ ├── usb2can.gbp
│ ├── usb2can.gbs
│ ├── usb2can.gko
│ ├── usb2can.gm13
│ ├── usb2can.gm15
│ ├── usb2can.gm6
│ ├── usb2can.gpb
│ ├── usb2can.gpt
│ ├── usb2can.gtl
│ ├── usb2can.gto
│ ├── usb2can.gtp
│ ├── usb2can.gts
│ └── usb2can.txt
└── UART+DBUS
│ ├── USB2UART.Cam
│ ├── usb2uart.gbl
│ ├── usb2uart.gbo
│ ├── usb2uart.gbp
│ ├── usb2uart.gbs
│ ├── usb2uart.gko
│ ├── usb2uart.gm13
│ ├── usb2uart.gm15
│ ├── usb2uart.gm6
│ ├── usb2uart.gpb
│ ├── usb2uart.gpt
│ ├── usb2uart.gtl
│ ├── usb2uart.gto
│ ├── usb2uart.gtp
│ ├── usb2uart.gts
│ └── usb2uart.txt
├── image
├── nuc_with_usb2can.jpg
├── stm32_can.png
├── stm32_programer_1.png
├── stm32_programer_2.png
├── stm32_programer_3.png
└── usb_hub.png
└── program
├── .gitignore
├── .idea
├── .gitignore
├── .name
├── candleLight_fw.iml
├── misc.xml
├── modules.xml
├── saveactions_settings.xml
└── vcs.xml
├── 70-candle-usb.rules
├── CMakeLists.txt
├── STM32F072XB.ld
├── gitversion.cmake
├── library
├── include
│ ├── Legacy
│ │ └── stm32_hal_legacy.h
│ ├── stm32f0xx_hal.h
│ ├── stm32f0xx_hal_can.h
│ ├── stm32f0xx_hal_cortex.h
│ ├── stm32f0xx_hal_def.h
│ ├── stm32f0xx_hal_flash.h
│ ├── stm32f0xx_hal_flash_ex.h
│ ├── stm32f0xx_hal_gpio.h
│ ├── stm32f0xx_hal_gpio_ex.h
│ ├── stm32f0xx_hal_pcd.h
│ ├── stm32f0xx_hal_pcd_ex.h
│ ├── stm32f0xx_hal_rcc.h
│ ├── stm32f0xx_hal_rcc_ex.h
│ ├── stm32f0xx_hal_tim.h
│ ├── stm32f0xx_hal_tim_ex.h
│ └── stm32f0xx_ll_usb.h
└── source
│ ├── stm32f0xx_hal.c
│ ├── stm32f0xx_hal_can.c
│ ├── stm32f0xx_hal_cortex.c
│ ├── stm32f0xx_hal_flash.c
│ ├── stm32f0xx_hal_flash_ex.c
│ ├── stm32f0xx_hal_gpio.c
│ ├── stm32f0xx_hal_pcd.c
│ ├── stm32f0xx_hal_pcd_ex.c
│ ├── stm32f0xx_hal_rcc.c
│ ├── stm32f0xx_hal_rcc_ex.c
│ ├── stm32f0xx_hal_tim.c
│ ├── stm32f0xx_hal_tim_ex.c
│ └── stm32f0xx_ll_usb.c
├── system
├── cmsis
│ ├── cmsis_compiler.h
│ ├── cmsis_device.h
│ ├── cmsis_gcc.h
│ ├── cmsis_version.h
│ └── core_cm0.h
├── hal_include.h
├── mpu_armv7.h
├── stm32f072xb.h
├── stm32f0xx.h
├── stm32f0xx_hal_conf.h
├── system_stm32f0xx.c
└── system_stm32f0xx.h
├── usb
├── usbd_conf.h
├── usbd_core.c
├── usbd_core.h
├── usbd_ctlreq.c
├── usbd_ctlreq.h
├── usbd_def.h
├── usbd_ioreq.c
└── usbd_ioreq.h
└── user
├── include
├── can.h
├── config.h
├── dfu.h
├── flash.h
├── gpio.h
├── gs_usb.h
├── led.h
├── queue.h
├── timer.h
├── usbd_desc.h
├── usbd_gs_can.h
└── util.h
└── src
├── can.c
├── dfu.c
├── flash.c
├── gpio.c
├── interrupts.c
├── led.c
├── main.c
├── queue.c
├── startup.c
├── syscalls.c
├── timer.c
├── usbd_conf.c
├── usbd_desc.c
├── usbd_gs_can.c
└── util.c
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Altium ###
2 | # Previews Folders
3 | **/__Previews/
4 |
5 | # History Folders
6 | **/History/*
7 |
8 | # Project Logs
9 | Project Logs*/
10 |
11 | # Project Outputs
12 | Project Outputs*/
13 |
14 | # Auto-conversion notices
15 | *.PcbDoc.htm
16 |
17 | # Access lock file for dbLib sources
18 | **/*.ldb
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Lao·Zhu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # rm_usb2can
2 |
3 |   
4 |
5 | English/[中文](https://github.com/rm-controls/rm_usb2can/blob/main/README_CN.md)
6 |
7 | ***
8 |
9 | ### Brief Introduction
10 |
11 | The purpose of this project is to provide [Intel® NUC](https://www.intel.com/content/www/us/en/products/details/nuc.html) and other x86 device with a CAN (Controller Area Network) peripheral interface. Since NUC and most x86 device does not have simple peripheral interfaces such as SPI (Serial Peripheral Interface), it is impossible to use SPI to can chips such as MCP2515. Therefore, the project is developed based on the open source solution [candleLight](https://github.com/candle-usb/candleLight_fw/tree/master) on GitHub, and STM32F072CBT6 is used as the main control chip to realize the function of USB (Universal Serial Bus) to can. STM32F072CBT6 has USB full speed peripherals and can peripherals that can work at the same time. It is packaged as QFP64 (Quad Flat Package) and is an excellent solution.The following figure shows the physical connection between Intel NUC and usb2can.
12 |
13 | 
14 |
15 | ***
16 |
17 | ### Develop Tools
18 |
19 | + EDA Tool: Altium Designer 20.0.13
20 | + Compiler: gcc-arm-none-eabi 8-2019-q3-update
21 | + Programming Tool: STM32CubeProgrammer v2.6.0
22 |
23 | ***
24 |
25 | ### Directory Structure
26 |
27 | + bom: three different versions of usb2can material forms.
28 | + candlelight: the repository of GitHub's open source solution [candleLight](https://github.com/candle-usb/candleLight_fw/tree/master).
29 | + circuit: circuit schematic diagram and PCB source file designed with Altium designer.
30 | + gerber: three different versions of usb2can manufacturing documents.
31 | + image: picture in readme.
32 | + firmware.bin: Compiled program binaries.
33 |
34 | **Note: the PCB and schematic diagram under the circuit folder are example circuits, which are directly used to manufacture products with production results other than those shown in the figure. If you want to directly reproduce the graphic version, please use the production file under the gerber folder.**
35 |
36 | ***
37 |
38 | ### Circuit Design
39 |
40 | #### Key Points Of Schematic Design
41 |
42 | USB HUB Circuit Design: since the whole vehicle needs at least two can buses to ensure the integrity of the data packet returned by the motor, we use GL850G as the USB HUB chip to realize the scheme of USB one driving four. In addition, we also use Schmidt trigger to realize the power on sequence to ensure that the enumeration sequence of USB devices is consistent after each power on.
43 |
44 | 
45 |
46 | USB To CAN Circuit Design: use STM32F072CBT6 to realize the function of USB to can. The can level conversion chip adopts MAX3051EKA chip, which uses 3.3V power supply and is packaged as SOT23-8 (Small Outline Transistor), which provides the basis for PCB miniaturization. The purpose of R6 and R7 resistors in the figure is to change the boot mode of STM32, so that STM32 can switch between DFU (Device Firmware Upgrade) burning mode and flash mode by changing the short circuit mode of R6 and R7, so as to facilitate firmware burning.
47 |
48 | 
49 |
50 | #### Key Points Of PCB Layout And Wiring
51 |
52 | 1. All USB buses need to be set as differential pairs, and the wiring rules of differential signals shall be strictly followed during wiring.
53 | 2. All CAN buses need to be set as differential pairs, and the wiring rules of differential signals shall be strictly followed during wiring.
54 | 3. The bottom of crystal oscillator and resonant capacitor should be hollowed out without copper.
55 | 4. The power line width shall be greater than 0.3mm as far as possible to ensure that the power track does not collapse.
56 |
57 | ***
58 |
59 | ### Circuit Making
60 |
61 | We provide three different versions of Gerber files for production: [two-way CAN + UART + DBUS](https://github.com/rm-controls/rm_usb2can/tree/main/gerber/2CAN%2BUART%2BDBUS), [four-way CAN](https://github.com/rm-controls/rm_usb2can/tree/main/gerber/4CAN), [UART + DBUS](https://github.com/rm-controls/rm_usb2can/tree/main/gerber/UART%2BDBUS).The circuits of these three versions are designed with two-layer PCB, with an area of about 20 * 30MM. You can directly submit the packaged Gerber file to a manufacturer (such as [jlc](https://www.jlc.com/#)) for production.
62 |
63 | You can find the BOM (Bill Of Material) table corresponding to the board [here](https://github.com/rm-controls/rm_usb2can/tree/main/bom) and weld the components to the fabricated PCB according to this table. After welding, please carefully check whether there is residual solder between the pins, which will lead to short circuit of the circuit board. At the same time, you should also check whether there is false soldering of the pins.
64 |
65 | After welding, use a multimeter to check whether there is a short circuit between 5V power interface and GND, and whether there is a short circuit between 3.3V power output and GND. When the above situation does not occur, connect the board to the USB port of the computer. At this time, you should see that the power indicator on the board is on, and the computer can recognize the USB HUB chip.
66 |
67 | **Note: do not weld the up / down resistance used to switch STM32 download mode at the same time, as it may cause a short circuit between the power supply and GND!**
68 |
69 | ***
70 |
71 | ### Firmware Programming
72 |
73 | You can [click here](https://github.com/rm-controls/rm_usb2can/releases/download/firmware_v1_0/candleLight.bin) to download the compiled firmware, or follow the [candlelight documentation](https://github.com/candle-usb/candleLight_fw/tree/master#building) to compile firmware by yourself. Finally, you will get the .bin file. We use [STM32CubeProgrammer](https://www.st.com/en/development-tools/stm32cubeprog.html) to burn the firmware into STM32 through USB. The steps to download firmware are shown below:
74 |
75 | 1. Remove the pull-down resistance of BOOT0 pin of STM32 and weld the pull-up resistance.
76 | 2. Connect the board to the USB port of the computer and open STM32CubeProgrammer.
77 | 3. Click the three buttons shown in the following figure in STM32CubeProgrammer to search for available STM32 devices.
78 |
79 | 
80 |
81 | 4. After successful connection, click the "Read" button to read the firmware and select the prepared firmware.
82 |
83 | 
84 |
85 | 5. Click "Download" to download the firmware. After the download is successful, you can see the successful information.
86 |
87 | 
88 |
89 | 6. Remove the pull-up resistance of BOOT0 pin on STM32 and weld the pull-down resistance. Power on again at this time, and the firmware will start running on STM32.
90 |
91 | ***
92 |
93 | ### Test Features On Ubuntu
94 |
95 | 1. Install dependent packages:
96 |
97 | ```bash
98 | $ sudo apt-get update && sudo apt-get -y upgrade
99 | $ sudo apt-get install -y can-utils net-tools
100 | ```
101 |
102 | 2. Check whether can device is detected:
103 |
104 | ```bash
105 | $ ifconfig -a
106 | # If a device with can name is found in the list, it means that the device can be recognized
107 | ```
108 |
109 | 3. Connect the two can ports with a **straight line** to facilitate loop back test.
110 | 4. Initialize CAN0 and CAN1 devices with a bit rate of 1Mbits:
111 |
112 | ```bash
113 | $ sudo ip link set can0 up type can bitrate 1000000
114 | $ sudo ip link set can1 up type can bitrate 1000000
115 | ```
116 |
117 | 5. Open a new terminal to monitor the information received by can0:
118 |
119 | ```bash
120 | $ candump can0
121 | ```
122 |
123 | 6. Sending information using can1 in a terminal:
124 |
125 | ```bash
126 | $ cansend can1 200#5A5A5A5A5A5A5A5A
127 | ```
128 |
129 | If you can see the following information from can1 in the terminal monitoring can0, it indicates that the communication is successful and the module works normally.
130 |
131 | ```bash
132 | can0 200 [8] 5A 5A 5A 5A 5A 5A 5A 5A
133 | ```
134 |
135 | ***
136 |
137 | ### License
138 |
139 | The source code is released under a [MIT License](https://github.com/rm-controls/rm_usb2can/blob/main/LICENSE).
140 |
141 | **Affiliation:DynamicX
142 | Maintainer:YanzhenZhu, 2208213223@qq.com**
143 |
144 | The product has been tested under Ubuntu 18.04 and 20.04. This is research code, expect that it changes often and any fitness for a particular purpose is disclaimed.
--------------------------------------------------------------------------------
/README_CN.md:
--------------------------------------------------------------------------------
1 | # rm_usb2can
2 |
3 |   
4 |
5 | [English](https://github.com/rm-controls/rm_usb2can/blob/main/README.md)/中文
6 |
7 | ***
8 |
9 | ### 简介
10 |
11 | 本项目的开发目的是为了给[英特尔® NUC](https://www.intel.cn/content/www/cn/zh/products/details/nuc.html)及其它x86架构的平台提供一个CAN (Controller Area Network)的外设接口。由于NUC及大部分x86不具有SPI等简单外设接口,故无法使用MCP2515等SPI (Serial Peripheral Interface) 转CAN芯片。为此,本项目基于github的开源方案[candleLight](https://github.com/candle-usb/candleLight_fw/tree/master)开发,采用STM32F072CBT6作为主控芯片,实现USB (Universal Serial Bus) 转CAN的功能。STM32F072CBT6具有能够同时工作的USB全速外设和CAN外设,封装为QFP64 (Quad Flat Package),是较为优秀的解决方案。下图为Intel NUC与USB2CAN连接实物图。
12 |
13 | 
14 |
15 | ***
16 |
17 | ### 开发工具
18 |
19 | + EDA工具: Altium Designer 20.0.13
20 | + 编译工具: gcc-arm-none-eabi 8-2019-q3-update
21 | + 烧录工具: STM32CubeProgrammer v2.6.0
22 |
23 | ***
24 |
25 | ### 目录结构
26 |
27 | + bom:三个不同版本的USB2CAN物料表单。
28 | + candlelight:github开源方案[candleLight](https://github.com/candle-usb/candleLight_fw/tree/master)的仓库。
29 | + circuit:用Altium Designer设计的电路原理图及PCB源文件。
30 | + gerber:三个不同版本的USB2CAN制造文件。
31 | + image:README中的图片。
32 | + firmware.bin:编译好的程序二进制文件。
33 |
34 | **注意:circuit文件夹下的PCB和原理图是示例电路,直接用它制造生产结果不是图示的产品。若想直接复现图示版本,请用gerber文件夹下的生产文件。**
35 |
36 | ***
37 |
38 | ### 电路设计
39 |
40 | #### 原理图设计要点
41 |
42 | USB HUB电路设计:由于整车需要至少2路CAN总线来保证电机回传数据包的完整性,所以我们采用了GL850G作为USB HUB芯片实现USB一拖四的方案。另外,我们还通过使用施密特触发器来实现上电时序,保证USB设备枚举的顺序在每次上电后都是一致的。
43 |
44 | 
45 |
46 | USB转CAN电路设计:用STM32F072CBT6实现USB转CAN功能。CAN电平转换芯片采用MAX3051EKA芯片,该芯片使用3.3V供电,且封装为SOT23-8 (Small Outline Transistor),为PCB小型化提供了基础。图中的R6、R7电阻用途为更改STM32的Boot模式,从而使STM32能够通过更改R6、R7的短接模式而在DFU (Device Firmware Upgrade) 烧录模式与Flash模式下切换,方便烧录固件。
47 |
48 | 
49 |
50 | #### PCB布局布线要点
51 |
52 | 1. 所有USB总线需要设置成差分对,在布线时严格遵循差分信号布线规则。
53 | 2. 所有CAN总线需要设置成差分对,在布线时严格遵循差分信号布线规则。
54 | 3. 晶振和谐振电容底部最好挖空不铺铜。
55 | 4. 电源线线宽应尽量大于0.3mm以保证电源轨道不塌陷。
56 |
57 | ***
58 |
59 | ### 电路制作
60 |
61 | 我们提供了三个不同版本的Gerber文件用于生产,分别是扩展:[两路CAN+UART+DBUS](https://github.com/rm-controls/rm_usb2can/tree/main/gerber/2CAN%2BUART%2BDBUS)、[四路CAN](https://github.com/rm-controls/rm_usb2can/tree/main/gerber/4CAN)、[UART+DBUS](https://github.com/rm-controls/rm_usb2can/tree/main/gerber/UART%2BDBUS)。这三种版本的电路均采用两层PCB进行设计,面积约为20*30mm。你可以直接将打包好的gerber文件提交个生产厂家(如:[嘉立创](https://www.jlc.com/#))进行生产。
62 |
63 | 你可以在[此处](https://github.com/rm-controls/rm_usb2can/tree/main/bom)找到该板对应的BOM (Bill Of Material) 表,并且依据这张表格将元器件焊接到已经制作好的PCB上。焊接完成后,请仔细检查是否有引脚之间有残余的焊锡,那将会导致电路板发生短路,同时你还要检查引脚是否有虚焊的现象发生。
64 |
65 | 焊接完成后,用万用表检查5V电源接口与GND之间是否短路、3.3V电源输出与GND之间是否短路。当确保上述情况没有出现时,再将板子连接电脑的USB口,此时应该可以看到板上的电源指示灯亮起,并且电脑能够识别到USB HUB芯片。
66 |
67 | **注意:请勿同时焊接用于切换STM32下载模式的上/下拉电阻,那样有可能使电源与GND之间出现短路!**
68 |
69 | ***
70 |
71 | ### 固件烧录
72 |
73 | 你可以[点击此处](https://github.com/rm-controls/rm_usb2can/releases/download/firmware_v1_0/candleLight.bin)下载已经编译好的固件,或者是跟随[candleLight文档](https://github.com/candle-usb/candleLight_fw/tree/master#building)自行编译固件。最终你会得到.bin文件,我们使用[STM32CubeProgrammer](https://www.st.com/zh/development-tools/stm32cubeprog.html)来将固件通过USB烧录到STM32中。下面展示了下载固件的步骤:
74 |
75 | 1. 将STM32上BOOT0引脚的下拉电阻取下,焊接上上拉电阻。
76 | 2. 将板子连接到电脑的USB口中,打开STM32CubeProgrammer。
77 | 3. 在STM32CubeProgrammer中点击下图所示的三个按钮,搜寻可用的STM32设备。
78 |
79 | 
80 |
81 | 4. 连接成功后点击“Read”按钮以读取固件,选择准备好的固件。
82 |
83 | 
84 |
85 | 5. 点击“Download”以下载固件。下载成功后,可以看到成功的标识。
86 |
87 | 
88 |
89 | 6. 将STM32上BOOT0引脚的上拉电阻取下,焊接上下拉电阻。此时再重新上电,固件将在STM32上开始运行。
90 |
91 | ***
92 |
93 | ### 在Ubuntu上测试功能
94 |
95 | 1. 安装依赖软件包:
96 |
97 | ```bash
98 | $ sudo apt-get update && sudo apt-get -y upgrade
99 | $ sudo apt-get install -y can-utils net-tools
100 | ```
101 |
102 | 2. 查看是否检测到CAN设备:
103 |
104 | ```bash
105 | $ ifconfig -a
106 | # 如果在列表中发现含有can名称的设备就说明该设备可以被识别到了
107 | ```
108 |
109 | 3. 用**直连线**将两个CAN口连接起来,便于进行回环测试。
110 | 4. 初始化CAN0和CAN1设备,比特率为1Mbits:
111 |
112 | ```bash
113 | $ sudo ip link set can0 up type can bitrate 1000000
114 | $ sudo ip link set can1 up type can bitrate 1000000
115 | ```
116 |
117 | 5. 打开一个新终端用于监测can0接收到的信息:
118 |
119 | ```bash
120 | $ candump can0
121 | ```
122 |
123 | 6. 在一个终端中使用can1发送信息:
124 |
125 | ```bash
126 | $ cansend can1 200#5A5A5A5A5A5A5A5A
127 | ```
128 |
129 | 若能在监测can0的终端中看到can1发来的信息如下,说明通信成功,模块工作正常。
130 |
131 | ```bash
132 | can0 200 [8] 5A 5A 5A 5A 5A 5A 5A 5A
133 | ```
134 |
135 | ***
136 |
137 | ### 许可证
138 |
139 | 源代码根据[MIT条款许可证](https://github.com/rm-controls/rm_usb2can/blob/main/LICENSE)发布。
140 |
141 | **组织:DynamicX
142 | 维护人:朱彦臻, 2208213223@qq.com**
143 |
144 | 该产品已经在Ubuntu 18.04和20.04下进行了测试。这是一个研究代码,希望它经常更改,并且不承认任何特定用途的适用性。
--------------------------------------------------------------------------------
/bom/2CAN+2UART.csv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rm-controls/rm_usb2can/d1b1335065ebdc5208f7ab43b1d73c406fbe0e91/bom/2CAN+2UART.csv
--------------------------------------------------------------------------------
/bom/4CAN&2UART.csv:
--------------------------------------------------------------------------------
1 | Comment,Description,Designator,Footprint,Quantity,value
2 | C,无极性贴片电容,"C1, C2, C3, C4, C11, C18, C19, C20",C 0402_L,8,10uF
3 | C,无极性贴片电容,"C5, C6, C7, C8, C12, C13, C14, C17, C21, C22, C23, C24, C25, C26, C27, C28, C29, C30, C31, C32, C33, C34, C35, C36, C37, C38, C39, C40, C41, C42, C43, C44",C 0402_L,32,100nF
4 | C,无极性贴片电容,"C9, C10",C 0402_L,2,18pF
5 | C,无极性贴片电容,"C15, C16",C 0402_L,2,10pF
6 | GH1.25-2P,2P接插件,"CAN1, CAN2, CAN3, CAN4",GH1.25-2P,4,
7 | ESDR0502NMUTBG,USB2.0 ESD保护,"D1, D7",UDFN-6,2,
8 | LED-SMD,贴片LED,"D2, D8",LED 0603R,2,
9 | PESD12VV1BL,双向ESD,5V关断电压 ,D3,SOD-882,1,
10 | PESD5V0F1BL,双向ESD,5V关断电压 ,"D4, D5, D6, D9, D10, D11, D12, D13, D14, D15, D16",SOD-882,11,
11 | GH1.25-3P,3P接插件,"J1, J2",GH1.25-3P,2,
12 | M2.5,铜柱孔,"M1, M2, M3, M4, M5, M6",M3 125X200,6,
13 | AO3400A,N沟道MOS管,"Q1, Q3, Q4, Q5",SOT23-3N,4,
14 | S8050,高频放大-NPN型,Q2,SOT23-3N,1,
15 | R,贴片电阻,"R1, R5, R7, R8, R12, R14, R15, R16, R22, R23, R30, R31",R 0402_L,12,10k
16 | R,贴片电阻,"R2, R10",R 0402_L,2,1k
17 | R,贴片电阻,"R3, R11",R 0402_L,2,680R
18 | R,贴片电阻,R4,R 0402_L,1,4.7k
19 | R,贴片电阻,"R6, R13",R 0402_L,2,100k
20 | R,贴片电阻,R9,R 0402_L,1,47k
21 | R,贴片电阻,R17,R 0402_L,1,51k
22 | R,贴片电阻,R18,R 0402_L,1,270k
23 | R,贴片电阻,"R19, R26, R27, R34",R 0402_L,4,120R
24 | R,贴片电阻,"R20, R21, R24, R25, R28, R29, R32, R33",R 0402_L,8,0R
25 | HX9193-33G,LDO 3V3,"U1, U6",SOT23-5N,2,
26 | 74LVC1G17,,"U2, U8, U9, U10",SOT23-5N,4,
27 | GL850G,USB-HUB 1拖4,"U3, U7",SSOP28_N,2,
28 | CH340E,USB转串口,"U4, U5",MSOP10_N,2,
29 | MAX3051,CAN收发器,"U11, U14, U15, U18",SOT23-8N,4,
30 | STM32F072CBT6,,"U12, U13, U16, U17",LQFP48 7X7_N,4,
31 | MX1.25-4P,4P接插件,"USB, USB1",MX 1.25-WI-4P,2,
32 | 12M,4脚无源晶振,"X1, X2",OSC 3225-4P,2,
33 |
--------------------------------------------------------------------------------
/circuit/USB2CAN.PcbDoc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rm-controls/rm_usb2can/d1b1335065ebdc5208f7ab43b1d73c406fbe0e91/circuit/USB2CAN.PcbDoc
--------------------------------------------------------------------------------
/circuit/USB2CAN.SchDoc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rm-controls/rm_usb2can/d1b1335065ebdc5208f7ab43b1d73c406fbe0e91/circuit/USB2CAN.SchDoc
--------------------------------------------------------------------------------
/circuit/USB2CAN.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rm-controls/rm_usb2can/d1b1335065ebdc5208f7ab43b1d73c406fbe0e91/circuit/USB2CAN.pdf
--------------------------------------------------------------------------------
/gerber/2CAN+UART+DBUS/Gerber_BoardOutline.GKO:
--------------------------------------------------------------------------------
1 | G04 Layer: BoardOutline*
2 | G04 EasyEDA v6.4.20.6, 2021-08-10T23:17:12+08:00*
3 | G04 038dca5a8d274e5a88e6f2799ec95489,d221c9f3c2774e99b69775551637dae4,10*
4 | G04 Gerber Generator version 0.2*
5 | G04 Scale: 100 percent, Rotated: No, Reflected: No *
6 | G04 Dimensions in millimeters *
7 | G04 leading zeros omitted , absolute positions ,4 integer and 5 decimal *
8 | %FSLAX45Y45*%
9 | %MOMM*%
10 |
11 | %ADD10C,0.2540*%
12 | D10*
13 | X3659596Y0D02*
14 | G01*
15 | X99595Y0D01*
16 | X-403Y99999D02*
17 | G01*
18 | X-403Y2180000D01*
19 | X3759596Y2180000D02*
20 | G01*
21 | X3759596Y99999D01*
22 | X99595Y2280000D02*
23 | G01*
24 | X3659596Y2280000D01*
25 | G75*
26 | G01*
27 | X-404Y2180001D02*
28 | G02*
29 | X99596Y2280001I100000J0D01*
30 | G75*
31 | G01*
32 | X99596Y0D02*
33 | G02*
34 | X-404Y100000I0J100000D01*
35 | G75*
36 | G01*
37 | X3759596Y100000D02*
38 | G02*
39 | X3659596Y0I-100000J0D01*
40 | G75*
41 | G01*
42 | X3659596Y2280001D02*
43 | G02*
44 | X3759596Y2180001I0J-100000D01*
45 |
46 | %LPD*%
47 | M02*
48 |
--------------------------------------------------------------------------------
/gerber/2CAN+UART+DBUS/Gerber_Drill_PTH.DRL:
--------------------------------------------------------------------------------
1 | M48
2 | METRIC,LZ,000.000
3 | ;FILE_FORMAT=3:3
4 | ;TYPE=PLATED
5 | ;Layer: Drill PTH
6 | ;EasyEDA v6.4.20.6, 2021-08-10T23:17:12+08:00
7 | ;038dca5a8d274e5a88e6f2799ec95489,d221c9f3c2774e99b69775551637dae4,10
8 | ;Gerber Generator version 0.2
9 | ;Holesize 1 = 0.305 mm
10 | T01C0.305
11 | ;Holesize 2 = 0.306 mm
12 | T02C0.306
13 | ;Holesize 3 = 0.501 mm
14 | T03C0.501
15 | ;Holesize 4 = 2.501 mm
16 | T04C2.501
17 | %
18 | G05
19 | G90
20 | T01
21 | X016637Y004318
22 | X016637Y006223
23 | X009652Y009271
24 | X010668Y009652
25 | X023622Y002921
26 | X027791Y004913
27 | X011698Y003697
28 | X012954Y003683
29 | X006858Y020193
30 | X007874Y019304
31 | X011938Y018758
32 | X013208Y018796
33 | X033782Y004572
34 | X033782Y003302
35 | X033782Y012700
36 | X033782Y011430
37 | X004572Y009652
38 | X002159Y017653
39 | X010922Y016256
40 | X017653Y020828
41 | X009144Y006604
42 | X015113Y009779
43 | X012954Y016129
44 | X014243Y013286
45 | X013716Y016383
46 | X008890Y016383
47 | X002159Y020320
48 | X004445Y021590
49 | X006096Y021717
50 | X019558Y003048
51 | X019304Y008763
52 | X025146Y002667
53 | X024892Y006985
54 | X022860Y002540
55 | X027940Y014986
56 | X027686Y018542
57 | X019304Y020066
58 | X019304Y014351
59 | X025085Y014036
60 | X024511Y018268
61 | X029210Y011684
62 | X012954Y011430
63 | X006731Y002667
64 | X027686Y017399
65 | X022860Y013970
66 | X029591Y020193
67 | X027559Y005842
68 | X016764Y011684
69 | X001270Y007239
70 | X000889Y016129
71 | X000889Y014224
72 | X000889Y017907
73 | X000889Y019685
74 | X000889Y021209
75 | X011557Y021717
76 | X012954Y021717
77 | X014351Y021717
78 | X011557Y020955
79 | X012954Y020955
80 | X014351Y020955
81 | X015494Y017653
82 | X016510Y017653
83 | X015494Y016510
84 | X017780Y011684
85 | X018669Y011684
86 | X016764Y010795
87 | X017780Y010795
88 | X018669Y010795
89 | X016764Y009779
90 | X017780Y009779
91 | X016764Y012573
92 | X017780Y012573
93 | X018669Y012573
94 | X016129Y008890
95 | X016129Y007874
96 | X011430Y001397
97 | X012446Y001397
98 | X013462Y001397
99 | X014478Y001397
100 | X020447Y007493
101 | X022860Y007493
102 | X020447Y005461
103 | X022860Y005461
104 | X021590Y018669
105 | X022733Y018669
106 | X021590Y017526
107 | X022733Y017526
108 | X021590Y016510
109 | X022860Y016510
110 | X029464Y009779
111 | X030734Y009779
112 | X032131Y009779
113 | X029464Y008509
114 | X030734Y008509
115 | X032131Y008382
116 | X030734Y007239
117 | X032131Y007239
118 | X028702Y001778
119 | X030099Y001778
120 | X031496Y001778
121 | X035814Y010922
122 | X035687Y012700
123 | X035560Y004572
124 | X035560Y002921
125 | X026924Y012065
126 | X019177Y015240
127 | X005080Y017653
128 | X005080Y019050
129 | X025146Y017653
130 | X031115Y018161
131 | X020447Y020066
132 | X004953Y014478
133 | X005588Y004699
134 | X005461Y007112
135 | X010287Y006350
136 | T02
137 | X026055Y021130
138 | X036215Y011918
139 | X001068Y006488
140 | T03
141 | X002924Y013422G85X002918Y013422
142 | X002924Y012172G85X002918Y012172
143 | X002924Y010922G85X002918Y010922
144 | X002924Y009672G85X002918Y009672
145 | T04
146 | X002921Y002921
147 | X034671Y019812
148 | M30
149 |
--------------------------------------------------------------------------------
/gerber/2CAN+UART+DBUS/ReadOnly.Mechanical:
--------------------------------------------------------------------------------
1 | G04 Layer: Mechanical*
2 | G04 EasyEDA v6.4.20.6, 2021-08-10T23:17:12+08:00*
3 | G04 038dca5a8d274e5a88e6f2799ec95489,d221c9f3c2774e99b69775551637dae4,10*
4 | G04 Gerber Generator version 0.2*
5 | G04 Scale: 100 percent, Rotated: No, Reflected: No *
6 | G04 Dimensions in millimeters *
7 | G04 leading zeros omitted , absolute positions ,4 integer and 5 decimal *
8 | %FSLAX45Y45*%
9 | %MOMM*%
10 |
11 | %ADD74C,0.0500*%
12 |
13 | %LPD*%
14 | D74*
15 | X372198Y918199D02*
16 | G01*
17 | X372198Y538200D01*
18 | X732200Y538200D01*
19 | X732200Y918199D01*
20 | X372198Y918199D01*
21 | X2790200Y2205901D02*
22 | G01*
23 | X3170199Y2205901D01*
24 | X3170199Y1845899D01*
25 | X2790200Y1845899D01*
26 | X2790200Y2205901D01*
27 | M02*
28 |
--------------------------------------------------------------------------------
/gerber/4CAN/USB2CAN.Cam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rm-controls/rm_usb2can/d1b1335065ebdc5208f7ab43b1d73c406fbe0e91/gerber/4CAN/USB2CAN.Cam
--------------------------------------------------------------------------------
/gerber/4CAN/usb2can.gbp:
--------------------------------------------------------------------------------
1 | %FSTAX23Y23*%
2 | %MOIN*%
3 | %SFA1B1*%
4 |
5 | %IPPOS*%
6 | %ADD20R,0.019680X0.047240*%
7 | %ADD51R,0.019680X0.015750*%
8 | %ADD52R,0.015750X0.019680*%
9 | %ADD53R,0.011810X0.023620*%
10 | %ADD54R,0.051180X0.047240*%
11 | %ADD55R,0.008820X0.023030*%
12 | %LNusb2can-1*%
13 | %LPD*%
14 | G54D20*
15 | X00626Y01725D03*
16 | X00551D03*
17 | X00588Y01635D03*
18 | X00213Y0063D03*
19 | X00138D03*
20 | X00176Y0054D03*
21 | X01041Y0064D03*
22 | X00966D03*
23 | X01003Y0055D03*
24 | G54D51*
25 | X00966Y0083D03*
26 | Y00795D03*
27 | X00961Y01275D03*
28 | Y0124D03*
29 | X00246Y00332D03*
30 | Y00365D03*
31 | X00181Y01419D03*
32 | Y01455D03*
33 | Y01336D03*
34 | Y0137D03*
35 | X00226Y01367D03*
36 | Y014D03*
37 | X00246Y01665D03*
38 | Y01698D03*
39 | X00491Y01665D03*
40 | Y017D03*
41 | X00696Y01697D03*
42 | X00696Y01662D03*
43 | X00941Y01692D03*
44 | Y01659D03*
45 | X00626Y01425D03*
46 | X00626Y0146D03*
47 | X00671Y0138D03*
48 | Y01413D03*
49 | X00626Y01346D03*
50 | Y0138D03*
51 | X00516Y01275D03*
52 | Y0124D03*
53 | X00151Y00895D03*
54 | Y00929D03*
55 | X00156Y0098D03*
56 | Y01015D03*
57 | X00201Y00931D03*
58 | Y00965D03*
59 | X00626Y00974D03*
60 | Y0101D03*
61 | Y00896D03*
62 | Y0093D03*
63 | X00671D03*
64 | Y00963D03*
65 | X00421Y00832D03*
66 | Y00797D03*
67 | X00941Y00378D03*
68 | Y00345D03*
69 | X00666Y00142D03*
70 | Y00177D03*
71 | X00786Y00142D03*
72 | Y00107D03*
73 | G54D52*
74 | X0013Y00465D03*
75 | X00166D03*
76 | X00206D03*
77 | X00239D03*
78 | X00378Y01525D03*
79 | X00411D03*
80 | X00376Y0148D03*
81 | X0034D03*
82 | X00286Y01525D03*
83 | X0025D03*
84 | X00731D03*
85 | X00696D03*
86 | X00812D03*
87 | X00846D03*
88 | X00811Y0148D03*
89 | X00775D03*
90 | X00523Y01525D03*
91 | X00558D03*
92 | Y0157D03*
93 | X00525D03*
94 | X00286Y012D03*
95 | X00251D03*
96 | X00377Y0104D03*
97 | X00411D03*
98 | X00378Y01085D03*
99 | X00413D03*
100 | X00286Y0108D03*
101 | X00251D03*
102 | X00726Y01195D03*
103 | X00691D03*
104 | X00812Y0104D03*
105 | X00846D03*
106 | X0081Y01085D03*
107 | X00846D03*
108 | X00726Y01075D03*
109 | X0069D03*
110 | X00288Y0074D03*
111 | X00253D03*
112 | X00333Y00635D03*
113 | X00298D03*
114 | X00586Y00705D03*
115 | X00621D03*
116 | X00546D03*
117 | X0051D03*
118 | X00467Y0061D03*
119 | X00501D03*
120 | X00721Y0077D03*
121 | X00685D03*
122 | X00733Y00635D03*
123 | X00768D03*
124 | X00697Y0059D03*
125 | X00731D03*
126 | X00883Y0063D03*
127 | X00848D03*
128 | X01053Y00465D03*
129 | X01018D03*
130 | X00976D03*
131 | X00942D03*
132 | X00706Y0044D03*
133 | X0067D03*
134 | X00739Y00395D03*
135 | X00706D03*
136 | X00671Y00315D03*
137 | X00637D03*
138 | X00594D03*
139 | X00561D03*
140 | X0052Y0027D03*
141 | X00556D03*
142 | X00721Y00035D03*
143 | X00754D03*
144 | G54D53*
145 | X00185Y0037D03*
146 | X00211D03*
147 | X00185Y00325D03*
148 | X00211D03*
149 | X00185Y01705D03*
150 | X00211D03*
151 | X00185Y0166D03*
152 | X00211D03*
153 | X01001Y01705D03*
154 | X00975D03*
155 | X01001Y01655D03*
156 | X00976D03*
157 | X01001Y0034D03*
158 | X00976D03*
159 | X01001Y00385D03*
160 | X00976D03*
161 | G54D54*
162 | X00524Y00766D03*
163 | X00607D03*
164 | Y00833D03*
165 | X00524D03*
166 | G54D55*
167 | X0047Y00115D03*
168 | X00486D03*
169 | X00501D03*
170 | Y00082D03*
171 | X00486D03*
172 | X0047D03*
173 | M02*
--------------------------------------------------------------------------------
/gerber/4CAN/usb2can.gbs:
--------------------------------------------------------------------------------
1 | %FSTAX23Y23*%
2 | %MOIN*%
3 | %SFA1B1*%
4 |
5 | %IPPOS*%
6 | %ADD32R,0.027690X0.055240*%
7 | %ADD42R,0.047370X0.047370*%
8 | %ADD43C,0.047370*%
9 | %ADD44C,0.208000*%
10 | %ADD56R,0.027690X0.023750*%
11 | %ADD57R,0.023750X0.027690*%
12 | %ADD58R,0.019810X0.031620*%
13 | %ADD59R,0.059180X0.055240*%
14 | %ADD60R,0.016820X0.031030*%
15 | %LNusb2can-1*%
16 | %LPD*%
17 | G54D32*
18 | X00626Y01725D03*
19 | X00551D03*
20 | X00588Y01635D03*
21 | X00213Y0063D03*
22 | X00138D03*
23 | X00176Y0054D03*
24 | X01041Y0064D03*
25 | X00966D03*
26 | X01003Y0055D03*
27 | G54D42*
28 | X00564Y0017D03*
29 | G54D43*
30 | X00515Y0017D03*
31 | X00466D03*
32 | X00417D03*
33 | G54D44*
34 | X00966Y00105D03*
35 | X00219Y00104D03*
36 | G54D56*
37 | X00966Y0083D03*
38 | Y00795D03*
39 | X00961Y01275D03*
40 | Y0124D03*
41 | X00246Y00332D03*
42 | Y00365D03*
43 | X00181Y01419D03*
44 | Y01455D03*
45 | Y01336D03*
46 | Y0137D03*
47 | X00226Y01367D03*
48 | Y014D03*
49 | X00246Y01665D03*
50 | Y01698D03*
51 | X00491Y01665D03*
52 | Y017D03*
53 | X00696Y01697D03*
54 | X00696Y01662D03*
55 | X00941Y01692D03*
56 | Y01659D03*
57 | X00626Y01425D03*
58 | X00626Y0146D03*
59 | X00671Y0138D03*
60 | Y01413D03*
61 | X00626Y01346D03*
62 | Y0138D03*
63 | X00516Y01275D03*
64 | Y0124D03*
65 | X00151Y00895D03*
66 | Y00929D03*
67 | X00156Y0098D03*
68 | Y01015D03*
69 | X00201Y00931D03*
70 | Y00965D03*
71 | X00626Y00974D03*
72 | Y0101D03*
73 | Y00896D03*
74 | Y0093D03*
75 | X00671D03*
76 | Y00963D03*
77 | X00421Y00832D03*
78 | Y00797D03*
79 | X00941Y00378D03*
80 | Y00345D03*
81 | X00666Y00142D03*
82 | Y00177D03*
83 | X00786Y00142D03*
84 | Y00107D03*
85 | G54D57*
86 | X0013Y00465D03*
87 | X00166D03*
88 | X00206D03*
89 | X00239D03*
90 | X00378Y01525D03*
91 | X00411D03*
92 | X00376Y0148D03*
93 | X0034D03*
94 | X00286Y01525D03*
95 | X0025D03*
96 | X00731D03*
97 | X00696D03*
98 | X00812D03*
99 | X00846D03*
100 | X00811Y0148D03*
101 | X00775D03*
102 | X00523Y01525D03*
103 | X00558D03*
104 | Y0157D03*
105 | X00525D03*
106 | X00286Y012D03*
107 | X00251D03*
108 | X00377Y0104D03*
109 | X00411D03*
110 | X00378Y01085D03*
111 | X00413D03*
112 | X00286Y0108D03*
113 | X00251D03*
114 | X00726Y01195D03*
115 | X00691D03*
116 | X00812Y0104D03*
117 | X00846D03*
118 | X0081Y01085D03*
119 | X00846D03*
120 | X00726Y01075D03*
121 | X0069D03*
122 | X00288Y0074D03*
123 | X00253D03*
124 | X00333Y00635D03*
125 | X00298D03*
126 | X00586Y00705D03*
127 | X00621D03*
128 | X00546D03*
129 | X0051D03*
130 | X00467Y0061D03*
131 | X00501D03*
132 | X00721Y0077D03*
133 | X00685D03*
134 | X00733Y00635D03*
135 | X00768D03*
136 | X00697Y0059D03*
137 | X00731D03*
138 | X00883Y0063D03*
139 | X00848D03*
140 | X01053Y00465D03*
141 | X01018D03*
142 | X00976D03*
143 | X00942D03*
144 | X00706Y0044D03*
145 | X0067D03*
146 | X00739Y00395D03*
147 | X00706D03*
148 | X00671Y00315D03*
149 | X00637D03*
150 | X00594D03*
151 | X00561D03*
152 | X0052Y0027D03*
153 | X00556D03*
154 | X00721Y00035D03*
155 | X00754D03*
156 | G54D58*
157 | X00185Y0037D03*
158 | X00211D03*
159 | X00185Y00325D03*
160 | X00211D03*
161 | X00185Y01705D03*
162 | X00211D03*
163 | X00185Y0166D03*
164 | X00211D03*
165 | X01001Y01705D03*
166 | X00975D03*
167 | X01001Y01655D03*
168 | X00976D03*
169 | X01001Y0034D03*
170 | X00976D03*
171 | X01001Y00385D03*
172 | X00976D03*
173 | G54D59*
174 | X00524Y00766D03*
175 | X00607D03*
176 | Y00833D03*
177 | X00524D03*
178 | G54D60*
179 | X0047Y00115D03*
180 | X00486D03*
181 | X00501D03*
182 | Y00082D03*
183 | X00486D03*
184 | X0047D03*
185 | M02*
--------------------------------------------------------------------------------
/gerber/4CAN/usb2can.gko:
--------------------------------------------------------------------------------
1 | %FSTAX23Y23*%
2 | %MOIN*%
3 | %SFA1B1*%
4 |
5 | %IPPOS*%
6 | %ADD12C,0.019680*%
7 | %LNusb2can-1*%
8 | %LPD*%
9 | G54D12*
10 | X01086Y01788D02*
11 | D01*
12 | X01085Y01791*
13 | X01085Y01795*
14 | X01085Y01798*
15 | X01084Y01802*
16 | X01083Y01805*
17 | X01081Y01808*
18 | X0108Y01811*
19 | X01078Y01814*
20 | X01076Y01817*
21 | X01074Y0182*
22 | X01072Y01823*
23 | X01069Y01825*
24 | X01066Y01827*
25 | X01064Y01829*
26 | X01061Y01831*
27 | X01058Y01833*
28 | X01054Y01834*
29 | X01051Y01836*
30 | X01048Y01837*
31 | X01044Y01837*
32 | X01041Y01838*
33 | X01037Y01838*
34 | X01036Y01838*
35 | X0015D02*
36 | D01*
37 | X00146Y01838*
38 | X00143Y01838*
39 | X00139Y01837*
40 | X00136Y01836*
41 | X00132Y01835*
42 | X00129Y01834*
43 | X00126Y01832*
44 | X00123Y0183*
45 | X0012Y01828*
46 | X00117Y01826*
47 | X00115Y01824*
48 | X00112Y01821*
49 | X0011Y01819*
50 | X00108Y01816*
51 | X00106Y01813*
52 | X00105Y0181*
53 | X00103Y01807*
54 | X00102Y01803*
55 | X00101Y018*
56 | X001Y01797*
57 | X001Y01793*
58 | X001Y0179*
59 | X001Y01788*
60 | Y00104D02*
61 | D01*
62 | X001Y00096*
63 | X00101Y00088*
64 | X00102Y00079*
65 | X00104Y00071*
66 | X00107Y00063*
67 | X0011Y00056*
68 | X00114Y00048*
69 | X00118Y00041*
70 | X00122Y00034*
71 | X00128Y00027*
72 | X00133Y00021*
73 | X00139Y00015*
74 | X00146Y0001*
75 | X00152Y00005*
76 | X00159Y00001*
77 | X00167Y-00002*
78 | X00174Y-00006*
79 | X00182Y-00009*
80 | X0019Y-00011*
81 | X00198Y-00013*
82 | X00207Y-00014*
83 | X00215Y-00014*
84 | X00219Y-00015*
85 | X0096D02*
86 | D01*
87 | X00969Y-00014*
88 | X00978Y-00013*
89 | X00986Y-00012*
90 | X00995Y-0001*
91 | X01003Y-00007*
92 | X01011Y-00004*
93 | X01019Y0*
94 | X01027Y00004*
95 | X01034Y00008*
96 | X01041Y00014*
97 | X01047Y0002*
98 | X01053Y00026*
99 | X01059Y00033*
100 | X01064Y0004*
101 | X01069Y00047*
102 | X01073Y00055*
103 | X01076Y00063*
104 | X01079Y00071*
105 | X01082Y0008*
106 | X01084Y00088*
107 | X01085Y00097*
108 | X01086Y00106*
109 | X01086Y0011*
110 | X01036Y01838D02*
111 | X0015D01*
112 | X01086Y01788D02*
113 | Y0011D01*
114 | X001Y01788D02*
115 | Y00104D01*
116 | X0096Y-00015D02*
117 | X00219D01*
118 | M02*
--------------------------------------------------------------------------------
/gerber/4CAN/usb2can.gpb:
--------------------------------------------------------------------------------
1 | %FSTAX23Y23*%
2 | %MOIN*%
3 | %SFA1B1*%
4 |
5 | %IPPOS*%
6 | %ADD20R,0.019680X0.047240*%
7 | %ADD47R,0.039370X0.039370*%
8 | %ADD48C,0.039370*%
9 | %ADD49C,0.200000*%
10 | %ADD51R,0.019680X0.015750*%
11 | %ADD52R,0.015750X0.019680*%
12 | %ADD53R,0.011810X0.023620*%
13 | %ADD54R,0.051180X0.047240*%
14 | %ADD55R,0.008820X0.023030*%
15 | %LNusb2can-1*%
16 | %LPD*%
17 | G54D20*
18 | X00626Y01725D03*
19 | X00551D03*
20 | X00588Y01635D03*
21 | X00213Y0063D03*
22 | X00138D03*
23 | X00176Y0054D03*
24 | X01041Y0064D03*
25 | X00966D03*
26 | X01003Y0055D03*
27 | G54D47*
28 | X00564Y0017D03*
29 | G54D48*
30 | X00515Y0017D03*
31 | X00466D03*
32 | X00417D03*
33 | G54D49*
34 | X00966Y00105D03*
35 | X00219Y00104D03*
36 | G54D51*
37 | X00966Y0083D03*
38 | Y00795D03*
39 | X00961Y01275D03*
40 | Y0124D03*
41 | X00246Y00332D03*
42 | Y00365D03*
43 | X00181Y01419D03*
44 | Y01455D03*
45 | Y01336D03*
46 | Y0137D03*
47 | X00226Y01367D03*
48 | Y014D03*
49 | X00246Y01665D03*
50 | Y01698D03*
51 | X00491Y01665D03*
52 | Y017D03*
53 | X00696Y01697D03*
54 | X00696Y01662D03*
55 | X00941Y01692D03*
56 | Y01659D03*
57 | X00626Y01425D03*
58 | X00626Y0146D03*
59 | X00671Y0138D03*
60 | Y01413D03*
61 | X00626Y01346D03*
62 | Y0138D03*
63 | X00516Y01275D03*
64 | Y0124D03*
65 | X00151Y00895D03*
66 | Y00929D03*
67 | X00156Y0098D03*
68 | Y01015D03*
69 | X00201Y00931D03*
70 | Y00965D03*
71 | X00626Y00974D03*
72 | Y0101D03*
73 | Y00896D03*
74 | Y0093D03*
75 | X00671D03*
76 | Y00963D03*
77 | X00421Y00832D03*
78 | Y00797D03*
79 | X00941Y00378D03*
80 | Y00345D03*
81 | X00666Y00142D03*
82 | Y00177D03*
83 | X00786Y00142D03*
84 | Y00107D03*
85 | G54D52*
86 | X0013Y00465D03*
87 | X00166D03*
88 | X00206D03*
89 | X00239D03*
90 | X00378Y01525D03*
91 | X00411D03*
92 | X00376Y0148D03*
93 | X0034D03*
94 | X00286Y01525D03*
95 | X0025D03*
96 | X00731D03*
97 | X00696D03*
98 | X00812D03*
99 | X00846D03*
100 | X00811Y0148D03*
101 | X00775D03*
102 | X00523Y01525D03*
103 | X00558D03*
104 | Y0157D03*
105 | X00525D03*
106 | X00286Y012D03*
107 | X00251D03*
108 | X00377Y0104D03*
109 | X00411D03*
110 | X00378Y01085D03*
111 | X00413D03*
112 | X00286Y0108D03*
113 | X00251D03*
114 | X00726Y01195D03*
115 | X00691D03*
116 | X00812Y0104D03*
117 | X00846D03*
118 | X0081Y01085D03*
119 | X00846D03*
120 | X00726Y01075D03*
121 | X0069D03*
122 | X00288Y0074D03*
123 | X00253D03*
124 | X00333Y00635D03*
125 | X00298D03*
126 | X00586Y00705D03*
127 | X00621D03*
128 | X00546D03*
129 | X0051D03*
130 | X00467Y0061D03*
131 | X00501D03*
132 | X00721Y0077D03*
133 | X00685D03*
134 | X00733Y00635D03*
135 | X00768D03*
136 | X00697Y0059D03*
137 | X00731D03*
138 | X00883Y0063D03*
139 | X00848D03*
140 | X01053Y00465D03*
141 | X01018D03*
142 | X00976D03*
143 | X00942D03*
144 | X00706Y0044D03*
145 | X0067D03*
146 | X00739Y00395D03*
147 | X00706D03*
148 | X00671Y00315D03*
149 | X00637D03*
150 | X00594D03*
151 | X00561D03*
152 | X0052Y0027D03*
153 | X00556D03*
154 | X00721Y00035D03*
155 | X00754D03*
156 | G54D53*
157 | X00185Y0037D03*
158 | X00211D03*
159 | X00185Y00325D03*
160 | X00211D03*
161 | X00185Y01705D03*
162 | X00211D03*
163 | X00185Y0166D03*
164 | X00211D03*
165 | X01001Y01705D03*
166 | X00975D03*
167 | X01001Y01655D03*
168 | X00976D03*
169 | X01001Y0034D03*
170 | X00976D03*
171 | X01001Y00385D03*
172 | X00976D03*
173 | G54D54*
174 | X00524Y00766D03*
175 | X00607D03*
176 | Y00833D03*
177 | X00524D03*
178 | G54D55*
179 | X0047Y00115D03*
180 | X00486D03*
181 | X00501D03*
182 | Y00082D03*
183 | X00486D03*
184 | X0047D03*
185 | M02*
--------------------------------------------------------------------------------
/gerber/4CAN/usb2can.gpt:
--------------------------------------------------------------------------------
1 | %FSTAX23Y23*%
2 | %MOIN*%
3 | %SFA1B1*%
4 |
5 | %IPPOS*%
6 | %AMD29*
7 | 4,1,8,-0.016200,-0.017500,0.016200,-0.017500,0.025000,-0.008700,0.025000,0.008700,0.016200,0.017500,-0.016200,0.017500,-0.025000,0.008700,-0.025000,-0.008700,-0.016200,-0.017500,0.0*
8 | %
9 | %ADD18R,0.066930X0.023620*%
10 | %ADD19R,0.110240X0.039370*%
11 | %ADD20R,0.019680X0.047240*%
12 | %ADD21R,0.047240X0.015750*%
13 | %ADD22O,0.011000X0.070870*%
14 | %ADD23O,0.070870X0.011000*%
15 | %ADD24R,0.013780X0.066930*%
16 | %ADD25O,0.013780X0.066930*%
17 | %ADD26R,0.015750X0.047240*%
18 | %ADD27R,0.047240X0.019680*%
19 | %ADD28R,0.050000X0.035000*%
20 | G04~CAMADD=29~4~0.0~0.0~500.0~350.0~0.0~87.5~0~0.0~0.0~0.0~0.0~0~0.0~0.0~0.0~0.0~0~0.0~0.0~0.0~180.0~500.0~350.0*
21 | %ADD29D29*%
22 | %ADD47R,0.039370X0.039370*%
23 | %ADD48C,0.039370*%
24 | %ADD49C,0.200000*%
25 | %LNusb2can-1*%
26 | %LPD*%
27 | G54D18*
28 | X00307Y01704D03*
29 | Y01655D03*
30 | X00879D03*
31 | Y01704D03*
32 | X00307Y00377D03*
33 | Y00327D03*
34 | X00879Y00337D03*
35 | Y00387D03*
36 | G54D19*
37 | X00176Y01777D03*
38 | Y01582D03*
39 | X01011D03*
40 | Y01777D03*
41 | X00176Y0045D03*
42 | Y00255D03*
43 | X01011Y00265D03*
44 | Y0046D03*
45 | G54D20*
46 | X00553Y01624D03*
47 | X00628D03*
48 | X00591D03*
49 | X00628Y01735D03*
50 | X00553D03*
51 | X00966Y00524D03*
52 | X01041D03*
53 | X01003D03*
54 | X01041Y00635D03*
55 | X00966D03*
56 | X00141Y00525D03*
57 | X00216D03*
58 | X00178D03*
59 | X00216Y00635D03*
60 | X00141D03*
61 | G54D21*
62 | X00381Y01718D03*
63 | Y01692D03*
64 | X00491Y01718D03*
65 | Y01692D03*
66 | Y01667D03*
67 | Y01641D03*
68 | X00381D03*
69 | Y01667D03*
70 | X00806Y01641D03*
71 | Y01667D03*
72 | X00696Y01641D03*
73 | Y01667D03*
74 | Y01692D03*
75 | Y01718D03*
76 | X00806D03*
77 | Y01692D03*
78 | G54D22*
79 | X00252Y0151D03*
80 | X00272D03*
81 | X00292D03*
82 | X00311D03*
83 | X00331D03*
84 | X00351D03*
85 | X0037D03*
86 | X0039D03*
87 | X0041D03*
88 | X0043D03*
89 | X00449D03*
90 | X00469D03*
91 | Y01189D03*
92 | X00449D03*
93 | X0043D03*
94 | X0041D03*
95 | X0039D03*
96 | X0037D03*
97 | X00351D03*
98 | X00331D03*
99 | X00311D03*
100 | X00292D03*
101 | X00272D03*
102 | X00252D03*
103 | X00692Y0151D03*
104 | X00712D03*
105 | X00732D03*
106 | X00751D03*
107 | X00771D03*
108 | X00791D03*
109 | X0081D03*
110 | X0083D03*
111 | X0085D03*
112 | X0087D03*
113 | X00889D03*
114 | X00909D03*
115 | Y01189D03*
116 | X00889D03*
117 | X0087D03*
118 | X0085D03*
119 | X0083D03*
120 | X0081D03*
121 | X00791D03*
122 | X00771D03*
123 | X00751D03*
124 | X00732D03*
125 | X00712D03*
126 | X00692D03*
127 | X00252Y01065D03*
128 | X00272D03*
129 | X00292D03*
130 | X00311D03*
131 | X00331D03*
132 | X00351D03*
133 | X0037D03*
134 | X0039D03*
135 | X0041D03*
136 | X0043D03*
137 | X00449D03*
138 | X00469D03*
139 | Y00744D03*
140 | X00449D03*
141 | X0043D03*
142 | X0041D03*
143 | X0039D03*
144 | X0037D03*
145 | X00351D03*
146 | X00331D03*
147 | X00311D03*
148 | X00292D03*
149 | X00272D03*
150 | X00252D03*
151 | X00692Y01065D03*
152 | X00712D03*
153 | X00732D03*
154 | X00751D03*
155 | X00771D03*
156 | X00791D03*
157 | X0081D03*
158 | X0083D03*
159 | X0085D03*
160 | X0087D03*
161 | X00889D03*
162 | X00909D03*
163 | Y00744D03*
164 | X00889D03*
165 | X0087D03*
166 | X0085D03*
167 | X0083D03*
168 | X0081D03*
169 | X00791D03*
170 | X00771D03*
171 | X00751D03*
172 | X00732D03*
173 | X00712D03*
174 | X00692D03*
175 | G54D23*
176 | X00521Y01458D03*
177 | Y01438D03*
178 | Y01418D03*
179 | Y01399D03*
180 | Y01379D03*
181 | Y01359D03*
182 | Y0134D03*
183 | Y0132D03*
184 | Y013D03*
185 | Y01281D03*
186 | Y01261D03*
187 | Y01241D03*
188 | X002D03*
189 | Y01261D03*
190 | Y01281D03*
191 | Y013D03*
192 | Y0132D03*
193 | Y0134D03*
194 | Y01359D03*
195 | Y01379D03*
196 | Y01399D03*
197 | Y01418D03*
198 | Y01438D03*
199 | Y01458D03*
200 | X00961D03*
201 | Y01438D03*
202 | Y01418D03*
203 | Y01399D03*
204 | Y01379D03*
205 | Y01359D03*
206 | Y0134D03*
207 | Y0132D03*
208 | Y013D03*
209 | Y01281D03*
210 | Y01261D03*
211 | Y01241D03*
212 | X0064D03*
213 | Y01261D03*
214 | Y01281D03*
215 | Y013D03*
216 | Y0132D03*
217 | Y0134D03*
218 | Y01359D03*
219 | Y01379D03*
220 | Y01399D03*
221 | Y01418D03*
222 | Y01438D03*
223 | Y01458D03*
224 | X00521Y01013D03*
225 | Y00993D03*
226 | Y00973D03*
227 | Y00954D03*
228 | Y00934D03*
229 | Y00914D03*
230 | Y00895D03*
231 | Y00875D03*
232 | Y00855D03*
233 | Y00836D03*
234 | Y00816D03*
235 | Y00796D03*
236 | X002D03*
237 | Y00816D03*
238 | Y00836D03*
239 | Y00855D03*
240 | Y00875D03*
241 | Y00895D03*
242 | Y00914D03*
243 | Y00934D03*
244 | Y00954D03*
245 | Y00973D03*
246 | Y00993D03*
247 | Y01013D03*
248 | X00961D03*
249 | Y00993D03*
250 | Y00973D03*
251 | Y00954D03*
252 | Y00934D03*
253 | Y00914D03*
254 | Y00895D03*
255 | Y00875D03*
256 | Y00855D03*
257 | Y00836D03*
258 | Y00816D03*
259 | Y00796D03*
260 | X0064D03*
261 | Y00816D03*
262 | Y00836D03*
263 | Y00855D03*
264 | Y00875D03*
265 | Y00895D03*
266 | Y00914D03*
267 | Y00934D03*
268 | Y00954D03*
269 | Y00973D03*
270 | Y00993D03*
271 | Y01013D03*
272 | G54D24*
273 | X00424Y00613D03*
274 | G54D25*
275 | X0045Y00613D03*
276 | X00475D03*
277 | X00501D03*
278 | X00527D03*
279 | X00552D03*
280 | X00578D03*
281 | X00603D03*
282 | X00629D03*
283 | X00655D03*
284 | X0068D03*
285 | X00706D03*
286 | X00731D03*
287 | X00757D03*
288 | Y00306D03*
289 | X00731D03*
290 | X00706D03*
291 | X0068D03*
292 | X00655D03*
293 | X00629D03*
294 | X00603D03*
295 | X00578D03*
296 | X00552D03*
297 | X00527D03*
298 | X00501D03*
299 | X00475D03*
300 | X0045D03*
301 | X00424D03*
302 | G54D26*
303 | X00827Y00525D03*
304 | X00853D03*
305 | X00827Y00635D03*
306 | X00853D03*
307 | X00878D03*
308 | X00904D03*
309 | Y00525D03*
310 | X00878D03*
311 | X00277D03*
312 | X00303D03*
313 | X00277Y00635D03*
314 | X00303D03*
315 | X00328D03*
316 | X00354D03*
317 | Y00525D03*
318 | X00328D03*
319 | G54D27*
320 | X00675Y00177D03*
321 | Y00102D03*
322 | Y0014D03*
323 | X00786Y00102D03*
324 | Y00177D03*
325 | G54D28*
326 | X00776Y00035D03*
327 | G54D29*
328 | X00706Y00035D03*
329 | G54D47*
330 | X00564Y0017D03*
331 | G54D48*
332 | X00515Y0017D03*
333 | X00466D03*
334 | X00417D03*
335 | G54D49*
336 | X00966Y00105D03*
337 | X00219Y00104D03*
338 | M02*
--------------------------------------------------------------------------------
/gerber/4CAN/usb2can.gtp:
--------------------------------------------------------------------------------
1 | %FSTAX23Y23*%
2 | %MOIN*%
3 | %SFA1B1*%
4 |
5 | %IPPOS*%
6 | %AMD29*
7 | 4,1,8,-0.016200,-0.017500,0.016200,-0.017500,0.025000,-0.008700,0.025000,0.008700,0.016200,0.017500,-0.016200,0.017500,-0.025000,0.008700,-0.025000,-0.008700,-0.016200,-0.017500,0.0*
8 | %
9 | %ADD18R,0.066930X0.023620*%
10 | %ADD19R,0.110240X0.039370*%
11 | %ADD20R,0.019680X0.047240*%
12 | %ADD21R,0.047240X0.015750*%
13 | %ADD22O,0.011000X0.070870*%
14 | %ADD23O,0.070870X0.011000*%
15 | %ADD24R,0.013780X0.066930*%
16 | %ADD25O,0.013780X0.066930*%
17 | %ADD26R,0.015750X0.047240*%
18 | %ADD27R,0.047240X0.019680*%
19 | %ADD28R,0.050000X0.035000*%
20 | G04~CAMADD=29~4~0.0~0.0~500.0~350.0~0.0~87.5~0~0.0~0.0~0.0~0.0~0~0.0~0.0~0.0~0.0~0~0.0~0.0~0.0~180.0~500.0~350.0*
21 | %ADD29D29*%
22 | %LNusb2can-1*%
23 | %LPD*%
24 | G54D18*
25 | X00307Y01704D03*
26 | Y01655D03*
27 | X00879D03*
28 | Y01704D03*
29 | X00307Y00377D03*
30 | Y00327D03*
31 | X00879Y00337D03*
32 | Y00387D03*
33 | G54D19*
34 | X00176Y01777D03*
35 | Y01582D03*
36 | X01011D03*
37 | Y01777D03*
38 | X00176Y0045D03*
39 | Y00255D03*
40 | X01011Y00265D03*
41 | Y0046D03*
42 | G54D20*
43 | X00553Y01624D03*
44 | X00628D03*
45 | X00591D03*
46 | X00628Y01735D03*
47 | X00553D03*
48 | X00966Y00524D03*
49 | X01041D03*
50 | X01003D03*
51 | X01041Y00635D03*
52 | X00966D03*
53 | X00141Y00525D03*
54 | X00216D03*
55 | X00178D03*
56 | X00216Y00635D03*
57 | X00141D03*
58 | G54D21*
59 | X00381Y01718D03*
60 | Y01692D03*
61 | X00491Y01718D03*
62 | Y01692D03*
63 | Y01667D03*
64 | Y01641D03*
65 | X00381D03*
66 | Y01667D03*
67 | X00806Y01641D03*
68 | Y01667D03*
69 | X00696Y01641D03*
70 | Y01667D03*
71 | Y01692D03*
72 | Y01718D03*
73 | X00806D03*
74 | Y01692D03*
75 | G54D22*
76 | X00252Y0151D03*
77 | X00272D03*
78 | X00292D03*
79 | X00311D03*
80 | X00331D03*
81 | X00351D03*
82 | X0037D03*
83 | X0039D03*
84 | X0041D03*
85 | X0043D03*
86 | X00449D03*
87 | X00469D03*
88 | Y01189D03*
89 | X00449D03*
90 | X0043D03*
91 | X0041D03*
92 | X0039D03*
93 | X0037D03*
94 | X00351D03*
95 | X00331D03*
96 | X00311D03*
97 | X00292D03*
98 | X00272D03*
99 | X00252D03*
100 | X00692Y0151D03*
101 | X00712D03*
102 | X00732D03*
103 | X00751D03*
104 | X00771D03*
105 | X00791D03*
106 | X0081D03*
107 | X0083D03*
108 | X0085D03*
109 | X0087D03*
110 | X00889D03*
111 | X00909D03*
112 | Y01189D03*
113 | X00889D03*
114 | X0087D03*
115 | X0085D03*
116 | X0083D03*
117 | X0081D03*
118 | X00791D03*
119 | X00771D03*
120 | X00751D03*
121 | X00732D03*
122 | X00712D03*
123 | X00692D03*
124 | X00252Y01065D03*
125 | X00272D03*
126 | X00292D03*
127 | X00311D03*
128 | X00331D03*
129 | X00351D03*
130 | X0037D03*
131 | X0039D03*
132 | X0041D03*
133 | X0043D03*
134 | X00449D03*
135 | X00469D03*
136 | Y00744D03*
137 | X00449D03*
138 | X0043D03*
139 | X0041D03*
140 | X0039D03*
141 | X0037D03*
142 | X00351D03*
143 | X00331D03*
144 | X00311D03*
145 | X00292D03*
146 | X00272D03*
147 | X00252D03*
148 | X00692Y01065D03*
149 | X00712D03*
150 | X00732D03*
151 | X00751D03*
152 | X00771D03*
153 | X00791D03*
154 | X0081D03*
155 | X0083D03*
156 | X0085D03*
157 | X0087D03*
158 | X00889D03*
159 | X00909D03*
160 | Y00744D03*
161 | X00889D03*
162 | X0087D03*
163 | X0085D03*
164 | X0083D03*
165 | X0081D03*
166 | X00791D03*
167 | X00771D03*
168 | X00751D03*
169 | X00732D03*
170 | X00712D03*
171 | X00692D03*
172 | G54D23*
173 | X00521Y01458D03*
174 | Y01438D03*
175 | Y01418D03*
176 | Y01399D03*
177 | Y01379D03*
178 | Y01359D03*
179 | Y0134D03*
180 | Y0132D03*
181 | Y013D03*
182 | Y01281D03*
183 | Y01261D03*
184 | Y01241D03*
185 | X002D03*
186 | Y01261D03*
187 | Y01281D03*
188 | Y013D03*
189 | Y0132D03*
190 | Y0134D03*
191 | Y01359D03*
192 | Y01379D03*
193 | Y01399D03*
194 | Y01418D03*
195 | Y01438D03*
196 | Y01458D03*
197 | X00961D03*
198 | Y01438D03*
199 | Y01418D03*
200 | Y01399D03*
201 | Y01379D03*
202 | Y01359D03*
203 | Y0134D03*
204 | Y0132D03*
205 | Y013D03*
206 | Y01281D03*
207 | Y01261D03*
208 | Y01241D03*
209 | X0064D03*
210 | Y01261D03*
211 | Y01281D03*
212 | Y013D03*
213 | Y0132D03*
214 | Y0134D03*
215 | Y01359D03*
216 | Y01379D03*
217 | Y01399D03*
218 | Y01418D03*
219 | Y01438D03*
220 | Y01458D03*
221 | X00521Y01013D03*
222 | Y00993D03*
223 | Y00973D03*
224 | Y00954D03*
225 | Y00934D03*
226 | Y00914D03*
227 | Y00895D03*
228 | Y00875D03*
229 | Y00855D03*
230 | Y00836D03*
231 | Y00816D03*
232 | Y00796D03*
233 | X002D03*
234 | Y00816D03*
235 | Y00836D03*
236 | Y00855D03*
237 | Y00875D03*
238 | Y00895D03*
239 | Y00914D03*
240 | Y00934D03*
241 | Y00954D03*
242 | Y00973D03*
243 | Y00993D03*
244 | Y01013D03*
245 | X00961D03*
246 | Y00993D03*
247 | Y00973D03*
248 | Y00954D03*
249 | Y00934D03*
250 | Y00914D03*
251 | Y00895D03*
252 | Y00875D03*
253 | Y00855D03*
254 | Y00836D03*
255 | Y00816D03*
256 | Y00796D03*
257 | X0064D03*
258 | Y00816D03*
259 | Y00836D03*
260 | Y00855D03*
261 | Y00875D03*
262 | Y00895D03*
263 | Y00914D03*
264 | Y00934D03*
265 | Y00954D03*
266 | Y00973D03*
267 | Y00993D03*
268 | Y01013D03*
269 | G54D24*
270 | X00424Y00613D03*
271 | G54D25*
272 | X0045Y00613D03*
273 | X00475D03*
274 | X00501D03*
275 | X00527D03*
276 | X00552D03*
277 | X00578D03*
278 | X00603D03*
279 | X00629D03*
280 | X00655D03*
281 | X0068D03*
282 | X00706D03*
283 | X00731D03*
284 | X00757D03*
285 | Y00306D03*
286 | X00731D03*
287 | X00706D03*
288 | X0068D03*
289 | X00655D03*
290 | X00629D03*
291 | X00603D03*
292 | X00578D03*
293 | X00552D03*
294 | X00527D03*
295 | X00501D03*
296 | X00475D03*
297 | X0045D03*
298 | X00424D03*
299 | G54D26*
300 | X00827Y00525D03*
301 | X00853D03*
302 | X00827Y00635D03*
303 | X00853D03*
304 | X00878D03*
305 | X00904D03*
306 | Y00525D03*
307 | X00878D03*
308 | X00277D03*
309 | X00303D03*
310 | X00277Y00635D03*
311 | X00303D03*
312 | X00328D03*
313 | X00354D03*
314 | Y00525D03*
315 | X00328D03*
316 | G54D27*
317 | X00675Y00177D03*
318 | Y00102D03*
319 | Y0014D03*
320 | X00786Y00102D03*
321 | Y00177D03*
322 | G54D28*
323 | X00776Y00035D03*
324 | G54D29*
325 | X00706Y00035D03*
326 | M02*
--------------------------------------------------------------------------------
/gerber/4CAN/usb2can.gts:
--------------------------------------------------------------------------------
1 | %FSTAX23Y23*%
2 | %MOIN*%
3 | %SFA1B1*%
4 |
5 | %IPPOS*%
6 | %AMD41*
7 | 4,1,8,-0.018200,-0.021500,0.018200,-0.021500,0.029000,-0.010700,0.029000,0.010700,0.018200,0.021500,-0.018200,0.021500,-0.029000,0.010700,-0.029000,-0.010700,-0.018200,-0.021500,0.0*
8 | %
9 | %ADD30R,0.074800X0.031500*%
10 | %ADD31R,0.118110X0.047240*%
11 | %ADD32R,0.027690X0.055240*%
12 | %ADD33R,0.055240X0.023750*%
13 | %ADD34O,0.019000X0.078870*%
14 | %ADD35O,0.078870X0.019000*%
15 | %ADD36R,0.021780X0.074930*%
16 | %ADD37O,0.021780X0.074930*%
17 | %ADD38R,0.023750X0.055240*%
18 | %ADD39R,0.055240X0.027690*%
19 | %ADD40R,0.058000X0.043000*%
20 | G04~CAMADD=41~4~0.0~0.0~580.0~430.0~0.0~107.5~0~0.0~0.0~0.0~0.0~0~0.0~0.0~0.0~0.0~0~0.0~0.0~0.0~180.0~580.0~430.0*
21 | %ADD41D41*%
22 | %ADD42R,0.047370X0.047370*%
23 | %ADD43C,0.047370*%
24 | %ADD44C,0.208000*%
25 | %LNusb2can-1*%
26 | %LPD*%
27 | G54D30*
28 | X00307Y01704D03*
29 | Y01655D03*
30 | X00879D03*
31 | Y01704D03*
32 | X00307Y00377D03*
33 | Y00327D03*
34 | X00879Y00337D03*
35 | Y00387D03*
36 | G54D31*
37 | X00176Y01777D03*
38 | Y01582D03*
39 | X01011D03*
40 | Y01777D03*
41 | X00176Y0045D03*
42 | Y00255D03*
43 | X01011Y00265D03*
44 | Y0046D03*
45 | G54D32*
46 | X00553Y01624D03*
47 | X00628D03*
48 | X00591D03*
49 | X00628Y01735D03*
50 | X00553D03*
51 | X00966Y00524D03*
52 | X01041D03*
53 | X01003D03*
54 | X01041Y00635D03*
55 | X00966D03*
56 | X00141Y00525D03*
57 | X00216D03*
58 | X00178D03*
59 | X00216Y00635D03*
60 | X00141D03*
61 | G54D33*
62 | X00381Y01718D03*
63 | Y01692D03*
64 | X00491Y01718D03*
65 | Y01692D03*
66 | Y01667D03*
67 | Y01641D03*
68 | X00381D03*
69 | Y01667D03*
70 | X00806Y01641D03*
71 | Y01667D03*
72 | X00696Y01641D03*
73 | Y01667D03*
74 | Y01692D03*
75 | Y01718D03*
76 | X00806D03*
77 | Y01692D03*
78 | G54D34*
79 | X00252Y0151D03*
80 | X00272D03*
81 | X00292D03*
82 | X00311D03*
83 | X00331D03*
84 | X00351D03*
85 | X0037D03*
86 | X0039D03*
87 | X0041D03*
88 | X0043D03*
89 | X00449D03*
90 | X00469D03*
91 | Y01189D03*
92 | X00449D03*
93 | X0043D03*
94 | X0041D03*
95 | X0039D03*
96 | X0037D03*
97 | X00351D03*
98 | X00331D03*
99 | X00311D03*
100 | X00292D03*
101 | X00272D03*
102 | X00252D03*
103 | X00692Y0151D03*
104 | X00712D03*
105 | X00732D03*
106 | X00751D03*
107 | X00771D03*
108 | X00791D03*
109 | X0081D03*
110 | X0083D03*
111 | X0085D03*
112 | X0087D03*
113 | X00889D03*
114 | X00909D03*
115 | Y01189D03*
116 | X00889D03*
117 | X0087D03*
118 | X0085D03*
119 | X0083D03*
120 | X0081D03*
121 | X00791D03*
122 | X00771D03*
123 | X00751D03*
124 | X00732D03*
125 | X00712D03*
126 | X00692D03*
127 | X00252Y01065D03*
128 | X00272D03*
129 | X00292D03*
130 | X00311D03*
131 | X00331D03*
132 | X00351D03*
133 | X0037D03*
134 | X0039D03*
135 | X0041D03*
136 | X0043D03*
137 | X00449D03*
138 | X00469D03*
139 | Y00744D03*
140 | X00449D03*
141 | X0043D03*
142 | X0041D03*
143 | X0039D03*
144 | X0037D03*
145 | X00351D03*
146 | X00331D03*
147 | X00311D03*
148 | X00292D03*
149 | X00272D03*
150 | X00252D03*
151 | X00692Y01065D03*
152 | X00712D03*
153 | X00732D03*
154 | X00751D03*
155 | X00771D03*
156 | X00791D03*
157 | X0081D03*
158 | X0083D03*
159 | X0085D03*
160 | X0087D03*
161 | X00889D03*
162 | X00909D03*
163 | Y00744D03*
164 | X00889D03*
165 | X0087D03*
166 | X0085D03*
167 | X0083D03*
168 | X0081D03*
169 | X00791D03*
170 | X00771D03*
171 | X00751D03*
172 | X00732D03*
173 | X00712D03*
174 | X00692D03*
175 | G54D35*
176 | X00521Y01458D03*
177 | Y01438D03*
178 | Y01418D03*
179 | Y01399D03*
180 | Y01379D03*
181 | Y01359D03*
182 | Y0134D03*
183 | Y0132D03*
184 | Y013D03*
185 | Y01281D03*
186 | Y01261D03*
187 | Y01241D03*
188 | X002D03*
189 | Y01261D03*
190 | Y01281D03*
191 | Y013D03*
192 | Y0132D03*
193 | Y0134D03*
194 | Y01359D03*
195 | Y01379D03*
196 | Y01399D03*
197 | Y01418D03*
198 | Y01438D03*
199 | Y01458D03*
200 | X00961D03*
201 | Y01438D03*
202 | Y01418D03*
203 | Y01399D03*
204 | Y01379D03*
205 | Y01359D03*
206 | Y0134D03*
207 | Y0132D03*
208 | Y013D03*
209 | Y01281D03*
210 | Y01261D03*
211 | Y01241D03*
212 | X0064D03*
213 | Y01261D03*
214 | Y01281D03*
215 | Y013D03*
216 | Y0132D03*
217 | Y0134D03*
218 | Y01359D03*
219 | Y01379D03*
220 | Y01399D03*
221 | Y01418D03*
222 | Y01438D03*
223 | Y01458D03*
224 | X00521Y01013D03*
225 | Y00993D03*
226 | Y00973D03*
227 | Y00954D03*
228 | Y00934D03*
229 | Y00914D03*
230 | Y00895D03*
231 | Y00875D03*
232 | Y00855D03*
233 | Y00836D03*
234 | Y00816D03*
235 | Y00796D03*
236 | X002D03*
237 | Y00816D03*
238 | Y00836D03*
239 | Y00855D03*
240 | Y00875D03*
241 | Y00895D03*
242 | Y00914D03*
243 | Y00934D03*
244 | Y00954D03*
245 | Y00973D03*
246 | Y00993D03*
247 | Y01013D03*
248 | X00961D03*
249 | Y00993D03*
250 | Y00973D03*
251 | Y00954D03*
252 | Y00934D03*
253 | Y00914D03*
254 | Y00895D03*
255 | Y00875D03*
256 | Y00855D03*
257 | Y00836D03*
258 | Y00816D03*
259 | Y00796D03*
260 | X0064D03*
261 | Y00816D03*
262 | Y00836D03*
263 | Y00855D03*
264 | Y00875D03*
265 | Y00895D03*
266 | Y00914D03*
267 | Y00934D03*
268 | Y00954D03*
269 | Y00973D03*
270 | Y00993D03*
271 | Y01013D03*
272 | G54D36*
273 | X00424Y00613D03*
274 | G54D37*
275 | X0045Y00613D03*
276 | X00475D03*
277 | X00501D03*
278 | X00527D03*
279 | X00552D03*
280 | X00578D03*
281 | X00603D03*
282 | X00629D03*
283 | X00655D03*
284 | X0068D03*
285 | X00706D03*
286 | X00731D03*
287 | X00757D03*
288 | Y00306D03*
289 | X00731D03*
290 | X00706D03*
291 | X0068D03*
292 | X00655D03*
293 | X00629D03*
294 | X00603D03*
295 | X00578D03*
296 | X00552D03*
297 | X00527D03*
298 | X00501D03*
299 | X00475D03*
300 | X0045D03*
301 | X00424D03*
302 | G54D38*
303 | X00827Y00525D03*
304 | X00853D03*
305 | X00827Y00635D03*
306 | X00853D03*
307 | X00878D03*
308 | X00904D03*
309 | Y00525D03*
310 | X00878D03*
311 | X00277D03*
312 | X00303D03*
313 | X00277Y00635D03*
314 | X00303D03*
315 | X00328D03*
316 | X00354D03*
317 | Y00525D03*
318 | X00328D03*
319 | G54D39*
320 | X00675Y00177D03*
321 | Y00102D03*
322 | Y0014D03*
323 | X00786Y00102D03*
324 | Y00177D03*
325 | G54D40*
326 | X00776Y00035D03*
327 | G54D41*
328 | X00706Y00035D03*
329 | G54D42*
330 | X00564Y0017D03*
331 | G54D43*
332 | X00515Y0017D03*
333 | X00466D03*
334 | X00417D03*
335 | G54D44*
336 | X00966Y00105D03*
337 | X00219Y00104D03*
338 | M02*
--------------------------------------------------------------------------------
/gerber/4CAN/usb2can.txt:
--------------------------------------------------------------------------------
1 | G54D9500*
2 | X0038Y00035D03*
3 | X004245Y001039D03*
4 | X00566Y000611D03*
5 | X006447D03*
6 | X008022D03*
7 | X00775Y0012D03*
8 | X0081Y0026D03*
9 | X0092Y0033D03*
10 | Y0037D03*
11 | X0102Y00385D03*
12 | Y0033D03*
13 | X0101Y00495D03*
14 | Y0061D03*
15 | X009244Y006379D03*
16 | X009136Y006986D03*
17 | X009289Y007961D03*
18 | X009991Y007697D03*
19 | X0105Y00855D03*
20 | X0093Y00905D03*
21 | X00895Y00945D03*
22 | X00915Y00985D03*
23 | X009469Y010174D03*
24 | X009991Y010847D03*
25 | X00995Y01165D03*
26 | X009597Y011634D03*
27 | X00885Y01125D03*
28 | X0085D03*
29 | X00815Y01005D03*
30 | X00775D03*
31 | X007235Y010059D03*
32 | X006841Y010847D03*
33 | X006054D03*
34 | X006447Y011634D03*
35 | X00566D03*
36 | X006054Y012422D03*
37 | X00485Y0125D03*
38 | X0047Y0138D03*
39 | X00495Y01465D03*
40 | X00375Y014547D03*
41 | X00335Y01455D03*
42 | X003691Y013996D03*
43 | X00365Y01325D03*
44 | X003298Y013209D03*
45 | X004085D03*
46 | X0029Y0125D03*
47 | X00251Y011634D03*
48 | X001723D03*
49 | X002117Y010847D03*
50 | X00165Y01025D03*
51 | Y00885D03*
52 | X00325Y00895D03*
53 | X00355Y0092D03*
54 | X0033Y0095D03*
55 | X00335Y00995D03*
56 | X003717Y010117D03*
57 | X00505Y01025D03*
58 | X00485Y0091D03*
59 | Y00865D03*
60 | Y0081D03*
61 | X00505Y00685D03*
62 | X0048Y0066D03*
63 | X00455Y0055D03*
64 | X00435Y0049D03*
65 | X00445Y00375D03*
66 | X004085Y00376D03*
67 | X0048Y00365D03*
68 | X0052D03*
69 | X00585D03*
70 | X0063Y00225D03*
71 | X0057Y0013D03*
72 | X0047Y00175D03*
73 | X003691Y001398D03*
74 | X003298Y002185D03*
75 | X00355Y00265D03*
76 | X003691Y002973D03*
77 | X00265Y0034D03*
78 | Y0038D03*
79 | X00165Y0039D03*
80 | Y0033D03*
81 | X001723Y002185D03*
82 | X001754Y004994D03*
83 | X00215Y0053D03*
84 | X0018Y00605D03*
85 | X001723Y00691D03*
86 | X00251D03*
87 | X0031Y00685D03*
88 | X003575Y006825D03*
89 | X0034Y0059D03*
90 | X00305D03*
91 | X00285Y00805D03*
92 | X00585Y00745D03*
93 | X00605Y0067D03*
94 | X00645D03*
95 | X00605Y00555D03*
96 | X00565D03*
97 | X0055Y00525D03*
98 | X00685Y0055D03*
99 | X0076Y0042D03*
100 | X00855Y00595D03*
101 | X0089Y00585D03*
102 | X0082Y00645D03*
103 | X00735Y00805D03*
104 | Y0125D03*
105 | X007235Y013209D03*
106 | X00785Y01305D03*
107 | X0075Y014D03*
108 | X00745Y0144D03*
109 | X00795Y014325D03*
110 | X00845Y01435D03*
111 | X0093Y0146D03*
112 | X009236Y013299D03*
113 | X0093Y01255D03*
114 | X01015Y01515D03*
115 | Y01655D03*
116 | X00915Y0166D03*
117 | X00875Y01595D03*
118 | X0081Y0161D03*
119 | X00735Y01665D03*
120 | X00695Y01595D03*
121 | X00595Y0157D03*
122 | X0066Y01495D03*
123 | X00445Y01655D03*
124 | X0027D03*
125 | X00315Y01595D03*
126 | X00235Y015D03*
127 | X00185D03*
128 | X00165Y0166D03*
129 | X00415Y0113D03*
130 | X0045Y01131D03*
131 | X0044Y0169D03*
132 | X004487Y0179D03*
133 | X005875D03*
134 | X00595Y01695D03*
135 | X0074Y017D03*
136 | X0076Y01735D03*
137 | X007262Y0179D03*
138 | X00865D03*
139 | X00915Y017D03*
140 | X01015Y0171D03*
141 | X0027Y017D03*
142 | X00165Y01705D03*
143 | X0031Y0179D03*
144 | G54D9501*
145 | X006212Y0017D03*
146 | X006704D03*
147 | X007196D03*
148 | X007688D03*
149 | G54D9502*
150 | X0022Y00105D03*
151 | X009663Y001048D03*
152 | M02*
--------------------------------------------------------------------------------
/gerber/UART+DBUS/USB2UART.Cam:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rm-controls/rm_usb2can/d1b1335065ebdc5208f7ab43b1d73c406fbe0e91/gerber/UART+DBUS/USB2UART.Cam
--------------------------------------------------------------------------------
/gerber/UART+DBUS/usb2uart.gbp:
--------------------------------------------------------------------------------
1 | %FSTAX23Y23*%
2 | %MOIN*%
3 | %SFA1B1*%
4 |
5 | %IPPOS*%
6 | %ADD20R,0.019680X0.047240*%
7 | %ADD47R,0.011810X0.023620*%
8 | %ADD48R,0.015750X0.019680*%
9 | %ADD49R,0.019680X0.015750*%
10 | %ADD50R,0.051180X0.047240*%
11 | %ADD51R,0.008820X0.023030*%
12 | %LNusb2uart-1*%
13 | %LPD*%
14 | G54D20*
15 | X00805Y00345D03*
16 | X00767Y00435D03*
17 | X00842D03*
18 | X00237Y005D03*
19 | X002Y0059D03*
20 | X00274D03*
21 | G54D47*
22 | X00241Y0093D03*
23 | X00267D03*
24 | X00267Y0088D03*
25 | X00242D03*
26 | X00642Y00925D03*
27 | X00616D03*
28 | X00642Y00875D03*
29 | X00617D03*
30 | G54D48*
31 | X00799Y00495D03*
32 | X00835D03*
33 | X00273Y00645D03*
34 | X00239D03*
35 | X00183Y0044D03*
36 | X00217D03*
37 | X00259Y0042D03*
38 | X00295D03*
39 | X00643Y0082D03*
40 | X00609D03*
41 | X00725D03*
42 | X00689D03*
43 | X00436D03*
44 | X00472D03*
45 | X0055D03*
46 | X00514D03*
47 | X00516Y00505D03*
48 | X0055D03*
49 | X00455D03*
50 | X00419D03*
51 | X00627D03*
52 | X0066D03*
53 | X00591Y0054D03*
54 | X00627D03*
55 | G54D49*
56 | X00817Y0028D03*
57 | Y00245D03*
58 | X00772D03*
59 | Y00278D03*
60 | X00372Y0087D03*
61 | Y00903D03*
62 | X00532Y00301D03*
63 | Y00335D03*
64 | X00697Y00283D03*
65 | Y0025D03*
66 | X00477Y00305D03*
67 | X00477Y0027D03*
68 | X00642Y00302D03*
69 | Y00267D03*
70 | G54D50*
71 | X00451Y00953D03*
72 | X00533D03*
73 | Y00886D03*
74 | X00451D03*
75 | G54D51*
76 | X00486Y0011D03*
77 | X00502D03*
78 | X00518D03*
79 | Y00077D03*
80 | X00502D03*
81 | X00486D03*
82 | M02*
--------------------------------------------------------------------------------
/gerber/UART+DBUS/usb2uart.gbs:
--------------------------------------------------------------------------------
1 | %FSTAX23Y23*%
2 | %MOIN*%
3 | %SFA1B1*%
4 |
5 | %IPPOS*%
6 | %ADD30R,0.027690X0.055240*%
7 | %ADD36C,0.204850*%
8 | %ADD37R,0.047370X0.047370*%
9 | %ADD38C,0.047370*%
10 | %ADD39C,0.208000*%
11 | %ADD52R,0.019810X0.031620*%
12 | %ADD53R,0.023750X0.027690*%
13 | %ADD54R,0.027690X0.023750*%
14 | %ADD55R,0.059180X0.055240*%
15 | %ADD56R,0.016820X0.031030*%
16 | %LNusb2uart-1*%
17 | %LPD*%
18 | G54D30*
19 | X00805Y00345D03*
20 | X00767Y00435D03*
21 | X00842D03*
22 | X00237Y005D03*
23 | X002Y0059D03*
24 | X00274D03*
25 | G54D36*
26 | X00782Y00115D03*
27 | G54D37*
28 | X00585Y0018D03*
29 | G54D38*
30 | X00535Y0018D03*
31 | X00486D03*
32 | X00437D03*
33 | G54D39*
34 | X00237Y012D03*
35 | X00783D03*
36 | X00237Y0012D03*
37 | G54D52*
38 | X00241Y0093D03*
39 | X00267D03*
40 | X00267Y0088D03*
41 | X00242D03*
42 | X00642Y00925D03*
43 | X00616D03*
44 | X00642Y00875D03*
45 | X00617D03*
46 | G54D53*
47 | X00799Y00495D03*
48 | X00835D03*
49 | X00273Y00645D03*
50 | X00239D03*
51 | X00183Y0044D03*
52 | X00217D03*
53 | X00259Y0042D03*
54 | X00295D03*
55 | X00643Y0082D03*
56 | X00609D03*
57 | X00725D03*
58 | X00689D03*
59 | X00436D03*
60 | X00472D03*
61 | X0055D03*
62 | X00514D03*
63 | X00516Y00505D03*
64 | X0055D03*
65 | X00455D03*
66 | X00419D03*
67 | X00627D03*
68 | X0066D03*
69 | X00591Y0054D03*
70 | X00627D03*
71 | G54D54*
72 | X00817Y0028D03*
73 | Y00245D03*
74 | X00772D03*
75 | Y00278D03*
76 | X00372Y0087D03*
77 | Y00903D03*
78 | X00532Y00301D03*
79 | Y00335D03*
80 | X00697Y00283D03*
81 | Y0025D03*
82 | X00477Y00305D03*
83 | X00477Y0027D03*
84 | X00642Y00302D03*
85 | Y00267D03*
86 | G54D55*
87 | X00451Y00953D03*
88 | X00533D03*
89 | Y00886D03*
90 | X00451D03*
91 | G54D56*
92 | X00486Y0011D03*
93 | X00502D03*
94 | X00518D03*
95 | Y00077D03*
96 | X00502D03*
97 | X00486D03*
98 | M02*
--------------------------------------------------------------------------------
/gerber/UART+DBUS/usb2uart.gko:
--------------------------------------------------------------------------------
1 | %FSTAX23Y23*%
2 | %MOIN*%
3 | %SFA1B1*%
4 |
5 | %IPPOS*%
6 | %ADD68C,0.019680*%
7 | %LNusb2uart-1*%
8 | %LPD*%
9 | G54D68*
10 | X00221Y01325D02*
11 | D01*
12 | X00213Y01324*
13 | X00206Y01323*
14 | X00199Y01322*
15 | X00191Y0132*
16 | X00184Y01318*
17 | X00178Y01315*
18 | X00171Y01312*
19 | X00164Y01308*
20 | X00158Y01304*
21 | X00152Y013*
22 | X00147Y01295*
23 | X00142Y01289*
24 | X00137Y01284*
25 | X00133Y01278*
26 | X00129Y01271*
27 | X00125Y01265*
28 | X00122Y01258*
29 | X0012Y01251*
30 | X00118Y01244*
31 | X00116Y01237*
32 | X00115Y01229*
33 | X00115Y01222*
34 | X00115Y01218*
35 | Y00093D02*
36 | D01*
37 | X00115Y00087*
38 | X00115Y0008*
39 | X00117Y00073*
40 | X00118Y00066*
41 | X0012Y0006*
42 | X00123Y00053*
43 | X00126Y00047*
44 | X0013Y00041*
45 | X00133Y00035*
46 | X00138Y0003*
47 | X00142Y00025*
48 | X00147Y0002*
49 | X00153Y00015*
50 | X00158Y00011*
51 | X00164Y00008*
52 | X0017Y00005*
53 | X00176Y00002*
54 | X00183Y0*
55 | X00189Y-00002*
56 | X00196Y-00003*
57 | X00203Y-00004*
58 | X0021Y-00004*
59 | X00213Y-00005*
60 | X00907Y0121D02*
61 | D01*
62 | X00906Y01218*
63 | X00906Y01226*
64 | X00904Y01234*
65 | X00902Y01241*
66 | X009Y01249*
67 | X00897Y01256*
68 | X00893Y01264*
69 | X00889Y01271*
70 | X00885Y01277*
71 | X0088Y01284*
72 | X00874Y01289*
73 | X00869Y01295*
74 | X00863Y013*
75 | X00856Y01305*
76 | X00849Y01309*
77 | X00842Y01313*
78 | X00835Y01316*
79 | X00827Y01319*
80 | X0082Y01321*
81 | X00812Y01323*
82 | X00804Y01324*
83 | X00796Y01324*
84 | X00792Y01325*
85 | X00797Y-00005D02*
86 | D01*
87 | X00805Y-00004*
88 | X00812Y-00003*
89 | X0082Y-00002*
90 | X00827Y0*
91 | X00834Y00001*
92 | X00842Y00004*
93 | X00848Y00007*
94 | X00855Y00011*
95 | X00861Y00015*
96 | X00867Y0002*
97 | X00873Y00025*
98 | X00878Y00031*
99 | X00883Y00037*
100 | X00888Y00043*
101 | X00892Y00049*
102 | X00896Y00056*
103 | X00899Y00063*
104 | X00901Y0007*
105 | X00903Y00078*
106 | X00905Y00085*
107 | X00906Y00093*
108 | X00907Y001*
109 | X00907Y00104*
110 | X00115Y00093D02*
111 | Y01218D01*
112 | X00792Y01325D02*
113 | X00221D01*
114 | X00797Y-00005D02*
115 | X00213D01*
116 | X00907Y00104D02*
117 | Y0121D01*
118 | M02*
--------------------------------------------------------------------------------
/gerber/UART+DBUS/usb2uart.gm6:
--------------------------------------------------------------------------------
1 | %FSTAX23Y23*%
2 | %MOIN*%
3 | %SFA1B1*%
4 |
5 | %IPPOS*%
6 | %ADD63C,0.002360*%
7 | %LNusb2uart-1*%
8 | %LPD*%
9 | G54D63*
10 | X00271Y00938D02*
11 | D01*
12 | X00271Y00938*
13 | X00271Y00938*
14 | X00271Y00938*
15 | X00271Y00938*
16 | X00272Y00938*
17 | X00272Y00938*
18 | X00272Y00938*
19 | X00272Y00938*
20 | X00272Y00938*
21 | X00272Y00938*
22 | X00272Y00938*
23 | X00272Y00937*
24 | X00272Y00937*
25 | X00272Y00937*
26 | X00272Y00937*
27 | X00272Y00937*
28 | X00272Y00937*
29 | X00272Y00937*
30 | X00272Y00937*
31 | X00272Y00937*
32 | X00272Y00937*
33 | X00273Y00937*
34 | X00273*
35 | X00273Y00937*
36 | X00273Y00937*
37 | X00273Y00937*
38 | X00273Y00937*
39 | X00273Y00937*
40 | X00273Y00937*
41 | X00273Y00937*
42 | X00273Y00937*
43 | X00273Y00937*
44 | X00273Y00937*
45 | X00273Y00938*
46 | X00274Y00938*
47 | X00274Y00938*
48 | X00274Y00938*
49 | X00274Y00938*
50 | X00274Y00938*
51 | X00274Y00938*
52 | X00274Y00938*
53 | X00274Y00938*
54 | X00274Y00938*
55 | X00274Y00938*
56 | X00274Y00938*
57 | X00274Y00938*
58 | X00274Y00939*
59 | X00274Y00939*
60 | X00274Y00939*
61 | X00274Y00939*
62 | X00274Y00939*
63 | X00274Y00939*
64 | X00274Y00939*
65 | X00274Y00939*
66 | X00274Y00939*
67 | X00273Y00939*
68 | X00273Y00939*
69 | X00273Y00939*
70 | X00273Y00939*
71 | X00273Y00939*
72 | X00273Y00939*
73 | X00273Y00939*
74 | X00273Y00939*
75 | X00273Y0094*
76 | X00273Y0094*
77 | X00273Y0094*
78 | X00273Y0094*
79 | X00273*
80 | X00272Y0094*
81 | X00272Y0094*
82 | X00272Y0094*
83 | X00272Y00939*
84 | X00272Y00939*
85 | X00272Y00939*
86 | X00272Y00939*
87 | X00272Y00939*
88 | X00272Y00939*
89 | X00272Y00939*
90 | X00272Y00939*
91 | X00272Y00939*
92 | X00272Y00939*
93 | X00272Y00939*
94 | X00272Y00939*
95 | X00272Y00939*
96 | X00272Y00939*
97 | X00271Y00939*
98 | X00271Y00939*
99 | X00271Y00939*
100 | X00271Y00938*
101 | X00271Y00938*
102 | X00235Y00871D02*
103 | D01*
104 | X00235Y00871*
105 | X00235Y0087*
106 | X00235Y0087*
107 | X00235Y0087*
108 | X00235Y0087*
109 | X00235Y0087*
110 | X00235Y0087*
111 | X00235Y0087*
112 | X00235Y0087*
113 | X00235Y0087*
114 | X00235Y0087*
115 | X00235Y0087*
116 | X00235Y0087*
117 | X00236Y0087*
118 | X00236Y0087*
119 | X00236Y0087*
120 | X00236Y0087*
121 | X00236Y0087*
122 | X00236Y00869*
123 | X00236Y00869*
124 | X00236Y00869*
125 | X00236Y00869*
126 | X00236*
127 | X00236Y00869*
128 | X00236Y00869*
129 | X00236Y00869*
130 | X00237Y0087*
131 | X00237Y0087*
132 | X00237Y0087*
133 | X00237Y0087*
134 | X00237Y0087*
135 | X00237Y0087*
136 | X00237Y0087*
137 | X00237Y0087*
138 | X00237Y0087*
139 | X00237Y0087*
140 | X00237Y0087*
141 | X00237Y0087*
142 | X00237Y0087*
143 | X00237Y0087*
144 | X00237Y0087*
145 | X00237Y0087*
146 | X00237Y0087*
147 | X00237Y00871*
148 | X00237Y00871*
149 | X00237Y00871*
150 | X00237Y00871*
151 | X00237Y00871*
152 | X00237Y00871*
153 | X00237Y00871*
154 | X00237Y00871*
155 | X00237Y00871*
156 | X00237Y00871*
157 | X00237Y00871*
158 | X00237Y00871*
159 | X00237Y00871*
160 | X00237Y00872*
161 | X00237Y00872*
162 | X00237Y00872*
163 | X00237Y00872*
164 | X00237Y00872*
165 | X00237Y00872*
166 | X00237Y00872*
167 | X00236Y00872*
168 | X00236Y00872*
169 | X00236Y00872*
170 | X00236Y00872*
171 | X00236*
172 | X00236Y00872*
173 | X00236Y00872*
174 | X00236Y00872*
175 | X00236Y00872*
176 | X00236Y00872*
177 | X00236Y00872*
178 | X00236Y00872*
179 | X00236Y00872*
180 | X00235Y00872*
181 | X00235Y00872*
182 | X00235Y00871*
183 | X00235Y00871*
184 | X00235Y00871*
185 | X00235Y00871*
186 | X00235Y00871*
187 | X00235Y00871*
188 | X00235Y00871*
189 | X00235Y00871*
190 | X00235Y00871*
191 | X00235Y00871*
192 | X00235Y00871*
193 | X00235Y00871*
194 | X00609Y00916D02*
195 | D01*
196 | X00609Y00916*
197 | X00609Y00915*
198 | X00609Y00915*
199 | X00609Y00915*
200 | X0061Y00915*
201 | X0061Y00915*
202 | X0061Y00915*
203 | X0061Y00915*
204 | X0061Y00915*
205 | X0061Y00915*
206 | X0061Y00915*
207 | X0061Y00915*
208 | X0061Y00915*
209 | X0061Y00915*
210 | X0061Y00915*
211 | X0061Y00915*
212 | X0061Y00915*
213 | X0061Y00915*
214 | X0061Y00914*
215 | X0061Y00914*
216 | X0061Y00914*
217 | X00611Y00914*
218 | X00611*
219 | X00611Y00914*
220 | X00611Y00914*
221 | X00611Y00914*
222 | X00611Y00915*
223 | X00611Y00915*
224 | X00611Y00915*
225 | X00611Y00915*
226 | X00611Y00915*
227 | X00611Y00915*
228 | X00611Y00915*
229 | X00611Y00915*
230 | X00612Y00915*
231 | X00612Y00915*
232 | X00612Y00915*
233 | X00612Y00915*
234 | X00612Y00915*
235 | X00612Y00915*
236 | X00612Y00915*
237 | X00612Y00915*
238 | X00612Y00915*
239 | X00612Y00916*
240 | X00612Y00916*
241 | X00612Y00916*
242 | X00612Y00916*
243 | X00612Y00916*
244 | X00612Y00916*
245 | X00612Y00916*
246 | X00612Y00916*
247 | X00612Y00916*
248 | X00612Y00916*
249 | X00612Y00916*
250 | X00612Y00916*
251 | X00611Y00916*
252 | X00611Y00917*
253 | X00611Y00917*
254 | X00611Y00917*
255 | X00611Y00917*
256 | X00611Y00917*
257 | X00611Y00917*
258 | X00611Y00917*
259 | X00611Y00917*
260 | X00611Y00917*
261 | X00611Y00917*
262 | X00611Y00917*
263 | X00611*
264 | X0061Y00917*
265 | X0061Y00917*
266 | X0061Y00917*
267 | X0061Y00917*
268 | X0061Y00917*
269 | X0061Y00917*
270 | X0061Y00917*
271 | X0061Y00917*
272 | X0061Y00917*
273 | X0061Y00917*
274 | X0061Y00916*
275 | X0061Y00916*
276 | X0061Y00916*
277 | X0061Y00916*
278 | X0061Y00916*
279 | X0061Y00916*
280 | X0061Y00916*
281 | X00609Y00916*
282 | X00609Y00916*
283 | X00609Y00916*
284 | X00609Y00916*
285 | X00609Y00916*
286 | X0061Y00866D02*
287 | D01*
288 | X0061Y00866*
289 | X0061Y00865*
290 | X0061Y00865*
291 | X0061Y00865*
292 | X0061Y00865*
293 | X0061Y00865*
294 | X0061Y00865*
295 | X0061Y00865*
296 | X0061Y00865*
297 | X0061Y00865*
298 | X0061Y00865*
299 | X0061Y00865*
300 | X0061Y00865*
301 | X00611Y00865*
302 | X00611Y00865*
303 | X00611Y00865*
304 | X00611Y00865*
305 | X00611Y00865*
306 | X00611Y00864*
307 | X00611Y00864*
308 | X00611Y00864*
309 | X00611Y00864*
310 | X00611*
311 | X00611Y00864*
312 | X00611Y00864*
313 | X00611Y00864*
314 | X00612Y00865*
315 | X00612Y00865*
316 | X00612Y00865*
317 | X00612Y00865*
318 | X00612Y00865*
319 | X00612Y00865*
320 | X00612Y00865*
321 | X00612Y00865*
322 | X00612Y00865*
323 | X00612Y00865*
324 | X00612Y00865*
325 | X00612Y00865*
326 | X00612Y00865*
327 | X00612Y00865*
328 | X00612Y00865*
329 | X00612Y00865*
330 | X00612Y00865*
331 | X00612Y00866*
332 | X00612Y00866*
333 | X00612Y00866*
334 | X00612Y00866*
335 | X00612Y00866*
336 | X00612Y00866*
337 | X00612Y00866*
338 | X00612Y00866*
339 | X00612Y00866*
340 | X00612Y00866*
341 | X00612Y00866*
342 | X00612Y00866*
343 | X00612Y00866*
344 | X00612Y00867*
345 | X00612Y00867*
346 | X00612Y00867*
347 | X00612Y00867*
348 | X00612Y00867*
349 | X00612Y00867*
350 | X00612Y00867*
351 | X00611Y00867*
352 | X00611Y00867*
353 | X00611Y00867*
354 | X00611Y00867*
355 | X00611*
356 | X00611Y00867*
357 | X00611Y00867*
358 | X00611Y00867*
359 | X00611Y00867*
360 | X00611Y00867*
361 | X00611Y00867*
362 | X00611Y00867*
363 | X00611Y00867*
364 | X0061Y00867*
365 | X0061Y00867*
366 | X0061Y00866*
367 | X0061Y00866*
368 | X0061Y00866*
369 | X0061Y00866*
370 | X0061Y00866*
371 | X0061Y00866*
372 | X0061Y00866*
373 | X0061Y00866*
374 | X0061Y00866*
375 | X0061Y00866*
376 | X0061Y00866*
377 | X0061Y00866*
378 | X00477Y00073D02*
379 | D01*
380 | X00477Y00073*
381 | X00477Y00073*
382 | X00477Y00073*
383 | X00477Y00073*
384 | X00477Y00073*
385 | X00477Y00073*
386 | X00477Y00073*
387 | X00477Y00073*
388 | X00477Y00073*
389 | X00477Y00073*
390 | X00477Y00073*
391 | X00477Y00072*
392 | X00478Y00072*
393 | X00478Y00072*
394 | X00478Y00072*
395 | X00478Y00072*
396 | X00478Y00072*
397 | X00478Y00072*
398 | X00478Y00072*
399 | X00478Y00072*
400 | X00478Y00072*
401 | X00478Y00072*
402 | X00478*
403 | X00478Y00072*
404 | X00478Y00072*
405 | X00479Y00072*
406 | X00479Y00072*
407 | X00479Y00072*
408 | X00479Y00072*
409 | X00479Y00072*
410 | X00479Y00072*
411 | X00479Y00072*
412 | X00479Y00072*
413 | X00479Y00073*
414 | X00479Y00073*
415 | X00479Y00073*
416 | X00479Y00073*
417 | X00479Y00073*
418 | X00479Y00073*
419 | X00479Y00073*
420 | X00479Y00073*
421 | X00479Y00073*
422 | X00479Y00073*
423 | X00479Y00073*
424 | X00479Y00073*
425 | X00479Y00073*
426 | X00479Y00074*
427 | X00479Y00074*
428 | X00479Y00074*
429 | X00479Y00074*
430 | X00479Y00074*
431 | X00479Y00074*
432 | X00479Y00074*
433 | X00479Y00074*
434 | X00479Y00074*
435 | X00479Y00074*
436 | X00479Y00074*
437 | X00479Y00074*
438 | X00479Y00074*
439 | X00479Y00074*
440 | X00479Y00074*
441 | X00479Y00074*
442 | X00479Y00074*
443 | X00479Y00075*
444 | X00478Y00075*
445 | X00478Y00075*
446 | X00478Y00075*
447 | X00478*
448 | X00478Y00075*
449 | X00478Y00075*
450 | X00478Y00075*
451 | X00478Y00074*
452 | X00478Y00074*
453 | X00478Y00074*
454 | X00478Y00074*
455 | X00478Y00074*
456 | X00478Y00074*
457 | X00477Y00074*
458 | X00477Y00074*
459 | X00477Y00074*
460 | X00477Y00074*
461 | X00477Y00074*
462 | X00477Y00074*
463 | X00477Y00074*
464 | X00477Y00074*
465 | X00477Y00074*
466 | X00477Y00074*
467 | X00477Y00074*
468 | X00477Y00073*
469 | X00477Y00073*
470 | M02*
--------------------------------------------------------------------------------
/gerber/UART+DBUS/usb2uart.gpb:
--------------------------------------------------------------------------------
1 | %FSTAX23Y23*%
2 | %MOIN*%
3 | %SFA1B1*%
4 |
5 | %IPPOS*%
6 | %ADD20R,0.019680X0.047240*%
7 | %ADD42C,0.196850*%
8 | %ADD43R,0.039370X0.039370*%
9 | %ADD44C,0.039370*%
10 | %ADD45C,0.200000*%
11 | %ADD47R,0.011810X0.023620*%
12 | %ADD48R,0.015750X0.019680*%
13 | %ADD49R,0.019680X0.015750*%
14 | %ADD50R,0.051180X0.047240*%
15 | %ADD51R,0.008820X0.023030*%
16 | %LNusb2uart-1*%
17 | %LPD*%
18 | G54D20*
19 | X00805Y00345D03*
20 | X00767Y00435D03*
21 | X00842D03*
22 | X00237Y005D03*
23 | X002Y0059D03*
24 | X00274D03*
25 | G54D42*
26 | X00782Y00115D03*
27 | G54D43*
28 | X00585Y0018D03*
29 | G54D44*
30 | X00535Y0018D03*
31 | X00486D03*
32 | X00437D03*
33 | G54D45*
34 | X00237Y012D03*
35 | X00783D03*
36 | X00237Y0012D03*
37 | G54D47*
38 | X00241Y0093D03*
39 | X00267D03*
40 | X00267Y0088D03*
41 | X00242D03*
42 | X00642Y00925D03*
43 | X00616D03*
44 | X00642Y00875D03*
45 | X00617D03*
46 | G54D48*
47 | X00799Y00495D03*
48 | X00835D03*
49 | X00273Y00645D03*
50 | X00239D03*
51 | X00183Y0044D03*
52 | X00217D03*
53 | X00259Y0042D03*
54 | X00295D03*
55 | X00643Y0082D03*
56 | X00609D03*
57 | X00725D03*
58 | X00689D03*
59 | X00436D03*
60 | X00472D03*
61 | X0055D03*
62 | X00514D03*
63 | X00516Y00505D03*
64 | X0055D03*
65 | X00455D03*
66 | X00419D03*
67 | X00627D03*
68 | X0066D03*
69 | X00591Y0054D03*
70 | X00627D03*
71 | G54D49*
72 | X00817Y0028D03*
73 | Y00245D03*
74 | X00772D03*
75 | Y00278D03*
76 | X00372Y0087D03*
77 | Y00903D03*
78 | X00532Y00301D03*
79 | Y00335D03*
80 | X00697Y00283D03*
81 | Y0025D03*
82 | X00477Y00305D03*
83 | X00477Y0027D03*
84 | X00642Y00302D03*
85 | Y00267D03*
86 | G54D50*
87 | X00451Y00953D03*
88 | X00533D03*
89 | Y00886D03*
90 | X00451D03*
91 | G54D51*
92 | X00486Y0011D03*
93 | X00502D03*
94 | X00518D03*
95 | Y00077D03*
96 | X00502D03*
97 | X00486D03*
98 | M02*
--------------------------------------------------------------------------------
/gerber/UART+DBUS/usb2uart.gpt:
--------------------------------------------------------------------------------
1 | %FSTAX23Y23*%
2 | %MOIN*%
3 | %SFA1B1*%
4 |
5 | %IPPOS*%
6 | %AMD24*
7 | 4,1,8,-0.017500,0.016200,-0.017500,-0.016200,-0.008700,-0.025000,0.008700,-0.025000,0.017500,-0.016200,0.017500,0.016200,0.008700,0.025000,-0.008700,0.025000,-0.017500,0.016200,0.0*
8 | %
9 | %ADD16R,0.010240X0.051180*%
10 | %ADD17O,0.010240X0.051180*%
11 | %ADD18R,0.110240X0.039370*%
12 | %ADD19R,0.066930X0.023620*%
13 | %ADD20R,0.019680X0.047240*%
14 | %ADD21R,0.013780X0.066930*%
15 | %ADD22O,0.013780X0.066930*%
16 | %ADD23R,0.035000X0.050000*%
17 | G04~CAMADD=24~4~0.0~0.0~500.0~350.0~0.0~87.5~0~0.0~0.0~0.0~0.0~0~0.0~0.0~0.0~0.0~0~0.0~0.0~0.0~90.0~350.0~500.0*
18 | %ADD24D24*%
19 | %ADD25R,0.047240X0.019680*%
20 | %ADD42C,0.196850*%
21 | %ADD43R,0.039370X0.039370*%
22 | %ADD44C,0.039370*%
23 | %ADD45C,0.200000*%
24 | %LNusb2uart-1*%
25 | %LPD*%
26 | G54D16*
27 | X00193Y00716D03*
28 | X00768Y00706D03*
29 | G54D17*
30 | X00212Y00716D03*
31 | X00232D03*
32 | X00252D03*
33 | X00271D03*
34 | Y00523D03*
35 | X00252D03*
36 | X00232D03*
37 | X00212D03*
38 | X00193D03*
39 | X00787Y00706D03*
40 | X00807D03*
41 | X00827D03*
42 | X00846D03*
43 | Y00513D03*
44 | X00827D03*
45 | X00807D03*
46 | X00787D03*
47 | X00768D03*
48 | G54D18*
49 | X00191Y01052D03*
50 | Y00807D03*
51 | X00828Y00802D03*
52 | Y01047D03*
53 | G54D19*
54 | X00323Y0093D03*
55 | Y00979D03*
56 | Y0088D03*
57 | X00696Y00925D03*
58 | Y00875D03*
59 | Y00974D03*
60 | G54D20*
61 | X00844Y00264D03*
62 | X0077D03*
63 | X00807Y00375D03*
64 | X0077D03*
65 | X00844D03*
66 | G54D21*
67 | X00351Y00733D03*
68 | G54D22*
69 | X00376Y00733D03*
70 | X00402D03*
71 | X00427D03*
72 | X00453D03*
73 | X00479D03*
74 | X00504D03*
75 | X0053D03*
76 | X00555D03*
77 | X00581D03*
78 | X00606D03*
79 | X00632D03*
80 | X00658D03*
81 | X00683D03*
82 | Y00426D03*
83 | X00658D03*
84 | X00632D03*
85 | X00606D03*
86 | X00581D03*
87 | X00555D03*
88 | X0053D03*
89 | X00504D03*
90 | X00479D03*
91 | X00453D03*
92 | X00427D03*
93 | X00402D03*
94 | X00376D03*
95 | X00351D03*
96 | G54D23*
97 | X00697Y0026D03*
98 | G54D24*
99 | X00697Y0033D03*
100 | G54D25*
101 | X00507Y00342D03*
102 | Y00267D03*
103 | Y00305D03*
104 | X00617Y00267D03*
105 | Y00342D03*
106 | G54D42*
107 | X00782Y00115D03*
108 | G54D43*
109 | X00585Y0018D03*
110 | G54D44*
111 | X00535Y0018D03*
112 | X00486D03*
113 | X00437D03*
114 | G54D45*
115 | X00237Y012D03*
116 | X00783D03*
117 | X00237Y0012D03*
118 | M02*
--------------------------------------------------------------------------------
/gerber/UART+DBUS/usb2uart.gtp:
--------------------------------------------------------------------------------
1 | %FSTAX23Y23*%
2 | %MOIN*%
3 | %SFA1B1*%
4 |
5 | %IPPOS*%
6 | %AMD24*
7 | 4,1,8,-0.017500,0.016200,-0.017500,-0.016200,-0.008700,-0.025000,0.008700,-0.025000,0.017500,-0.016200,0.017500,0.016200,0.008700,0.025000,-0.008700,0.025000,-0.017500,0.016200,0.0*
8 | %
9 | %ADD16R,0.010240X0.051180*%
10 | %ADD17O,0.010240X0.051180*%
11 | %ADD18R,0.110240X0.039370*%
12 | %ADD19R,0.066930X0.023620*%
13 | %ADD20R,0.019680X0.047240*%
14 | %ADD21R,0.013780X0.066930*%
15 | %ADD22O,0.013780X0.066930*%
16 | %ADD23R,0.035000X0.050000*%
17 | G04~CAMADD=24~4~0.0~0.0~500.0~350.0~0.0~87.5~0~0.0~0.0~0.0~0.0~0~0.0~0.0~0.0~0.0~0~0.0~0.0~0.0~90.0~350.0~500.0*
18 | %ADD24D24*%
19 | %ADD25R,0.047240X0.019680*%
20 | %LNusb2uart-1*%
21 | %LPD*%
22 | G54D16*
23 | X00193Y00716D03*
24 | X00768Y00706D03*
25 | G54D17*
26 | X00212Y00716D03*
27 | X00232D03*
28 | X00252D03*
29 | X00271D03*
30 | Y00523D03*
31 | X00252D03*
32 | X00232D03*
33 | X00212D03*
34 | X00193D03*
35 | X00787Y00706D03*
36 | X00807D03*
37 | X00827D03*
38 | X00846D03*
39 | Y00513D03*
40 | X00827D03*
41 | X00807D03*
42 | X00787D03*
43 | X00768D03*
44 | G54D18*
45 | X00191Y01052D03*
46 | Y00807D03*
47 | X00828Y00802D03*
48 | Y01047D03*
49 | G54D19*
50 | X00323Y0093D03*
51 | Y00979D03*
52 | Y0088D03*
53 | X00696Y00925D03*
54 | Y00875D03*
55 | Y00974D03*
56 | G54D20*
57 | X00844Y00264D03*
58 | X0077D03*
59 | X00807Y00375D03*
60 | X0077D03*
61 | X00844D03*
62 | G54D21*
63 | X00351Y00733D03*
64 | G54D22*
65 | X00376Y00733D03*
66 | X00402D03*
67 | X00427D03*
68 | X00453D03*
69 | X00479D03*
70 | X00504D03*
71 | X0053D03*
72 | X00555D03*
73 | X00581D03*
74 | X00606D03*
75 | X00632D03*
76 | X00658D03*
77 | X00683D03*
78 | Y00426D03*
79 | X00658D03*
80 | X00632D03*
81 | X00606D03*
82 | X00581D03*
83 | X00555D03*
84 | X0053D03*
85 | X00504D03*
86 | X00479D03*
87 | X00453D03*
88 | X00427D03*
89 | X00402D03*
90 | X00376D03*
91 | X00351D03*
92 | G54D23*
93 | X00697Y0026D03*
94 | G54D24*
95 | X00697Y0033D03*
96 | G54D25*
97 | X00507Y00342D03*
98 | Y00267D03*
99 | Y00305D03*
100 | X00617Y00267D03*
101 | Y00342D03*
102 | M02*
--------------------------------------------------------------------------------
/gerber/UART+DBUS/usb2uart.gts:
--------------------------------------------------------------------------------
1 | %FSTAX23Y23*%
2 | %MOIN*%
3 | %SFA1B1*%
4 |
5 | %IPPOS*%
6 | %AMD34*
7 | 4,1,8,-0.021500,0.018200,-0.021500,-0.018200,-0.010700,-0.029000,0.010700,-0.029000,0.021500,-0.018200,0.021500,0.018200,0.010700,0.029000,-0.010700,0.029000,-0.021500,0.018200,0.0*
8 | %
9 | %ADD26R,0.018240X0.059180*%
10 | %ADD27O,0.018240X0.059180*%
11 | %ADD28R,0.118110X0.047240*%
12 | %ADD29R,0.074800X0.031500*%
13 | %ADD30R,0.027690X0.055240*%
14 | %ADD31R,0.021780X0.074930*%
15 | %ADD32O,0.021780X0.074930*%
16 | %ADD33R,0.043000X0.058000*%
17 | G04~CAMADD=34~4~0.0~0.0~580.0~430.0~0.0~107.5~0~0.0~0.0~0.0~0.0~0~0.0~0.0~0.0~0.0~0~0.0~0.0~0.0~90.0~430.0~580.0*
18 | %ADD34D34*%
19 | %ADD35R,0.055240X0.027690*%
20 | %ADD36C,0.204850*%
21 | %ADD37R,0.047370X0.047370*%
22 | %ADD38C,0.047370*%
23 | %ADD39C,0.208000*%
24 | %LNusb2uart-1*%
25 | %LPD*%
26 | G54D26*
27 | X00193Y00716D03*
28 | X00768Y00706D03*
29 | G54D27*
30 | X00212Y00716D03*
31 | X00232D03*
32 | X00252D03*
33 | X00271D03*
34 | Y00523D03*
35 | X00252D03*
36 | X00232D03*
37 | X00212D03*
38 | X00193D03*
39 | X00787Y00706D03*
40 | X00807D03*
41 | X00827D03*
42 | X00846D03*
43 | Y00513D03*
44 | X00827D03*
45 | X00807D03*
46 | X00787D03*
47 | X00768D03*
48 | G54D28*
49 | X00191Y01052D03*
50 | Y00807D03*
51 | X00828Y00802D03*
52 | Y01047D03*
53 | G54D29*
54 | X00323Y0093D03*
55 | Y00979D03*
56 | Y0088D03*
57 | X00696Y00925D03*
58 | Y00875D03*
59 | Y00974D03*
60 | G54D30*
61 | X00844Y00264D03*
62 | X0077D03*
63 | X00807Y00375D03*
64 | X0077D03*
65 | X00844D03*
66 | G54D31*
67 | X00351Y00733D03*
68 | G54D32*
69 | X00376Y00733D03*
70 | X00402D03*
71 | X00427D03*
72 | X00453D03*
73 | X00479D03*
74 | X00504D03*
75 | X0053D03*
76 | X00555D03*
77 | X00581D03*
78 | X00606D03*
79 | X00632D03*
80 | X00658D03*
81 | X00683D03*
82 | Y00426D03*
83 | X00658D03*
84 | X00632D03*
85 | X00606D03*
86 | X00581D03*
87 | X00555D03*
88 | X0053D03*
89 | X00504D03*
90 | X00479D03*
91 | X00453D03*
92 | X00427D03*
93 | X00402D03*
94 | X00376D03*
95 | X00351D03*
96 | G54D33*
97 | X00697Y0026D03*
98 | G54D34*
99 | X00697Y0033D03*
100 | G54D35*
101 | X00507Y00342D03*
102 | Y00267D03*
103 | Y00305D03*
104 | X00617Y00267D03*
105 | Y00342D03*
106 | G54D36*
107 | X00782Y00115D03*
108 | G54D37*
109 | X00585Y0018D03*
110 | G54D38*
111 | X00535Y0018D03*
112 | X00486D03*
113 | X00437D03*
114 | G54D39*
115 | X00237Y012D03*
116 | X00783D03*
117 | X00237Y0012D03*
118 | M02*
--------------------------------------------------------------------------------
/gerber/UART+DBUS/usb2uart.txt:
--------------------------------------------------------------------------------
1 | G54D9500*
2 | X00145Y00315D03*
3 | X00185D03*
4 | X0022Y00465D03*
5 | X002947Y004083D03*
6 | X0036Y00485D03*
7 | X003931Y004809D03*
8 | X00445Y00505D03*
9 | X005434Y004884D03*
10 | X005309Y005658D03*
11 | X006096D03*
12 | X006884D03*
13 | X00649Y006445D03*
14 | X0065Y00835D03*
15 | X00735Y0088D03*
16 | Y0093D03*
17 | X008065Y009595D03*
18 | X008459Y008807D03*
19 | X007278Y010382D03*
20 | X006687Y011563D03*
21 | X0061Y01205D03*
22 | X003734Y011957D03*
23 | X003341Y011169D03*
24 | X002947Y010382D03*
25 | X002553Y009595D03*
26 | X002159Y008807D03*
27 | X0036Y00875D03*
28 | Y00925D03*
29 | X0044Y00885D03*
30 | X00435Y00795D03*
31 | X0051D03*
32 | X005467Y007967D03*
33 | X00365Y00785D03*
34 | X002947Y007232D03*
35 | Y005658D03*
36 | X004128Y006445D03*
37 | X00475Y0037D03*
38 | X00445Y00305D03*
39 | X0039Y00255D03*
40 | X00345Y0023D03*
41 | X003734Y000933D03*
42 | X004522D03*
43 | X006096D03*
44 | X006687Y002114D03*
45 | X006884Y002508D03*
46 | X007671D03*
47 | X008459D03*
48 | X008065Y003295D03*
49 | X007278D03*
50 | X00649D03*
51 | X00535Y0027D03*
52 | X007627Y00445D03*
53 | X008Y004711D03*
54 | X008459Y004083D03*
55 | X0064Y0127D03*
56 | X0056D03*
57 | X00485D03*
58 | X0042D03*
59 | G54D9501*
60 | X004374Y0018D03*
61 | X004866D03*
62 | X005358D03*
63 | X00585D03*
64 | G54D9502*
65 | X0024Y00115D03*
66 | X00785Y0012D03*
67 | Y012D03*
68 | X002384D03*
69 | M02*
--------------------------------------------------------------------------------
/image/nuc_with_usb2can.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rm-controls/rm_usb2can/d1b1335065ebdc5208f7ab43b1d73c406fbe0e91/image/nuc_with_usb2can.jpg
--------------------------------------------------------------------------------
/image/stm32_can.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rm-controls/rm_usb2can/d1b1335065ebdc5208f7ab43b1d73c406fbe0e91/image/stm32_can.png
--------------------------------------------------------------------------------
/image/stm32_programer_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rm-controls/rm_usb2can/d1b1335065ebdc5208f7ab43b1d73c406fbe0e91/image/stm32_programer_1.png
--------------------------------------------------------------------------------
/image/stm32_programer_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rm-controls/rm_usb2can/d1b1335065ebdc5208f7ab43b1d73c406fbe0e91/image/stm32_programer_2.png
--------------------------------------------------------------------------------
/image/stm32_programer_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rm-controls/rm_usb2can/d1b1335065ebdc5208f7ab43b1d73c406fbe0e91/image/stm32_programer_3.png
--------------------------------------------------------------------------------
/image/usb_hub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rm-controls/rm_usb2can/d1b1335065ebdc5208f7ab43b1d73c406fbe0e91/image/usb_hub.png
--------------------------------------------------------------------------------
/program/.gitignore:
--------------------------------------------------------------------------------
1 | /.vscode/
2 | /build/
3 | *.o
4 | *.d
5 | *.bin
6 | *.asmo
7 | *.elf
8 | *~
9 | .cache/
10 | compile_commands.json
11 | build
12 |
--------------------------------------------------------------------------------
/program/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/program/.idea/.name:
--------------------------------------------------------------------------------
1 | candleLight
--------------------------------------------------------------------------------
/program/.idea/candleLight_fw.iml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/program/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/program/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/program/.idea/saveactions_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
15 |
16 |
--------------------------------------------------------------------------------
/program/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/program/70-candle-usb.rules:
--------------------------------------------------------------------------------
1 | # Copy this file to /etc/udev/rules.d/
2 |
3 | # uses OpenMoko VID
4 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="606f", MODE="660", GROUP="users", TAG+="uaccess"
5 |
6 |
--------------------------------------------------------------------------------
/program/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | #THIS FILE IS AUTO GENERATED FROM THE TEMPLATE! DO NOT CHANGE!
2 | set(CMAKE_SYSTEM_NAME Generic)
3 | set(CMAKE_SYSTEM_VERSION 1)
4 | cmake_minimum_required(VERSION 3.22)
5 |
6 | # specify cross-compilers and tools
7 | set(CMAKE_C_COMPILER arm-none-eabi-gcc)
8 | set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
9 | set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
10 | set(CMAKE_AR arm-none-eabi-ar)
11 | set(CMAKE_OBJCOPY arm-none-eabi-objcopy)
12 | set(CMAKE_OBJDUMP arm-none-eabi-objdump)
13 | set(SIZE arm-none-eabi-size)
14 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
15 |
16 | # project settings
17 | project(candleLight C ASM)
18 | set(CMAKE_C_STANDARD 11)
19 |
20 | #Uncomment for software floating point
21 | add_compile_options(-mfloat-abi=soft)
22 | add_compile_options(-mcpu=cortex-m0 -mthumb -mthumb-interwork -Wno-unused-parameter)
23 | add_compile_options(
24 | -std=gnu11 -mthumb
25 | -Wall -Wextra -Werror
26 | -fmessage-length=0
27 | -fsigned-char
28 | -ffunction-sections -fdata-sections
29 | -ffreestanding
30 | -fno-move-loop-invariants
31 | -O2
32 | -flto -ffat-lto-objects
33 | --specs=nano.specs
34 | --specs=nosys.specs
35 | )
36 |
37 | # Enable assembler files preprocessing
38 | add_compile_options($<$:-x$assembler-with-cpp>)
39 |
40 | add_custom_target(version_h BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/version.h"
41 | COMMAND ${CMAKE_COMMAND}
42 | -D SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}"
43 | -P ${CMAKE_CURRENT_SOURCE_DIR}/gitversion.cmake)
44 |
45 | include_directories(library/include system user/include system/cmsis usb ${CMAKE_CURRENT_BINARY_DIR})
46 |
47 | add_definitions(-DDEBUG -DUSE_HAL_DRIVER -DSTM32F072xB)
48 |
49 | file(GLOB_RECURSE SOURCES "user/src/*.c" "library/source/*.c" "usb/*.c" "system/*.c")
50 |
51 | set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/STM32F072XB.ld)
52 |
53 | add_link_options(-Wl,-gc-sections,--print-memory-usage,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map)
54 | add_link_options(-mcpu=cortex-m0 -mthumb -mthumb-interwork)
55 | add_link_options(
56 | -mthumb -Wall -Wextra
57 | -Xlinker --gc-sections
58 | --specs=nano.specs
59 | --specs=nosys.specs
60 | )
61 | add_link_options(-T ${LINKER_SCRIPT})
62 |
63 | execute_process(
64 | COMMAND ${CMAKE_C_COMPILER} -dumpversion
65 | OUTPUT_VARIABLE GCC_VERSION_LOCAL
66 | )
67 | string(REGEX MATCH "[0-9]+" GCC_VERSION_LOCAL_MAJOR ${GCC_VERSION_LOCAL})
68 | if (GCC_VERSION_LOCAL_MAJOR GREATER 11)
69 | add_link_options(-Wl,--no-warn-rwx-segments)
70 | endif ()
71 |
72 | add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT})
73 | add_dependencies(${PROJECT_NAME}.elf version_h)
74 |
75 | set(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex)
76 | set(BIN_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.bin)
77 |
78 | add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
79 | COMMAND ${CMAKE_OBJCOPY} -Oihex $ ${HEX_FILE}
80 | COMMAND ${CMAKE_OBJCOPY} -Obinary $ ${BIN_FILE}
81 | COMMENT "Building ${HEX_FILE}
82 | Building ${BIN_FILE}")
83 |
--------------------------------------------------------------------------------
/program/STM32F072XB.ld:
--------------------------------------------------------------------------------
1 | __STACK_SIZE = 2K;
2 | __HEAP_SIZE = 10K;
3 |
4 | __FLASH_SIZE = 128K;
5 | __NVM_SIZE = 1K;
6 |
7 | MEMORY
8 | {
9 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = __FLASH_SIZE - __NVM_SIZE
10 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 16K
11 | DATA (xrw) : ORIGIN = 0x08000000 + __FLASH_SIZE - __NVM_SIZE, LENGTH = __NVM_SIZE
12 | }
13 |
14 |
15 | ENTRY(Reset_Handler)
16 |
17 | SECTIONS
18 | {
19 | .text :
20 | {
21 | KEEP(*(.vectors))
22 | *(.text*)
23 |
24 | KEEP(*(.init))
25 | KEEP(*(.fini))
26 |
27 | /* .ctors */
28 | *crtbegin.o(.ctors)
29 | *crtbegin?.o(.ctors)
30 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
31 | *(SORT(.ctors.*))
32 | *(.ctors)
33 |
34 | /* .dtors */
35 | *crtbegin.o(.dtors)
36 | *crtbegin?.o(.dtors)
37 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
38 | *(SORT(.dtors.*))
39 | *(.dtors)
40 |
41 | *(.rodata*)
42 |
43 | KEEP(*(.eh_frame*))
44 | } > FLASH
45 |
46 | .ARM.extab :
47 | {
48 | *(.ARM.extab* .gnu.linkonce.armextab.*)
49 | } > FLASH
50 |
51 | __exidx_start = .;
52 | .ARM.exidx :
53 | {
54 | *(.ARM.exidx* .gnu.linkonce.armexidx.*)
55 | } > FLASH
56 | __exidx_end = .;
57 |
58 | .copy.table :
59 | {
60 | . = ALIGN(4);
61 | __copy_table_start__ = .;
62 | LONG (__etext)
63 | LONG (__data_start__)
64 | LONG (__data_end__ - __data_start__)
65 | __copy_table_end__ = .;
66 | } > FLASH
67 |
68 | .zero.table :
69 | {
70 | . = ALIGN(4);
71 | __zero_table_start__ = .;
72 | __zero_table_end__ = .;
73 | } > FLASH
74 |
75 | __etext = ALIGN (4);
76 |
77 | .user_data :
78 | {
79 | . = ALIGN(4);
80 | *(.user_data)
81 | . = ALIGN(4);
82 | } > DATA
83 |
84 | .data : AT (__etext)
85 | {
86 | __data_start__ = .;
87 | *(vtable)
88 | *(.data)
89 | *(.data.*)
90 |
91 | . = ALIGN(4);
92 | /* preinit data */
93 | PROVIDE_HIDDEN (__preinit_array_start = .);
94 | KEEP(*(.preinit_array))
95 | PROVIDE_HIDDEN (__preinit_array_end = .);
96 |
97 | . = ALIGN(4);
98 | /* init data */
99 | PROVIDE_HIDDEN (__init_array_start = .);
100 | KEEP(*(SORT(.init_array.*)))
101 | KEEP(*(.init_array))
102 | PROVIDE_HIDDEN (__init_array_end = .);
103 |
104 |
105 | . = ALIGN(4);
106 | /* finit data */
107 | PROVIDE_HIDDEN (__fini_array_start = .);
108 | KEEP(*(SORT(.fini_array.*)))
109 | KEEP(*(.fini_array))
110 | PROVIDE_HIDDEN (__fini_array_end = .);
111 |
112 | KEEP(*(.jcr*))
113 | . = ALIGN(4);
114 | /* All data end */
115 | __data_end__ = .;
116 |
117 | } > RAM
118 |
119 | .bss :
120 | {
121 | . = ALIGN(4);
122 | __bss_start__ = .;
123 | *(.bss)
124 | *(.bss.*)
125 | *(COMMON)
126 | . = ALIGN(4);
127 | __bss_end__ = .;
128 | } > RAM AT > RAM
129 |
130 | .heap (COPY) :
131 | {
132 | . = ALIGN(8);
133 | __end__ = .;
134 | PROVIDE(end = .);
135 | . = . + __HEAP_SIZE;
136 | . = ALIGN(8);
137 | __HeapLimit = .;
138 | } > RAM
139 |
140 | .stack (ORIGIN(RAM) + LENGTH(RAM) - __STACK_SIZE) (COPY) :
141 | {
142 | . = ALIGN(8);
143 | __StackLimit = .;
144 | . = . + __STACK_SIZE;
145 | . = ALIGN(8);
146 | __StackTop = .;
147 | } > RAM
148 | PROVIDE(__stack = __StackTop);
149 |
150 | ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
151 | }
152 |
--------------------------------------------------------------------------------
/program/gitversion.cmake:
--------------------------------------------------------------------------------
1 | # source: adapted from
2 | # https://www.mattkeeter.com/blog/2018-01-06-versioning/
3 |
4 | find_package(Git)
5 |
6 | # quoting in execute_process is fragile... cmake encloses every arg with ' ' , but adding any kind of quoting to
7 | # e.g. add spaces in the format string, will not work easily.
8 |
9 | if (Git_FOUND)
10 | execute_process(COMMAND ${GIT_EXECUTABLE} log --pretty=format:fw_%h_%as -n 1
11 | OUTPUT_VARIABLE GIT_REV
12 | ERROR_QUIET
13 | WORKING_DIRECTORY ${SRCDIR}
14 | )
15 | endif()
16 |
17 | # Check whether we got any revision (which isn't
18 | # always the case, e.g. when someone downloaded a zip
19 | # file from Github instead of a checkout)
20 | if ("${GIT_REV}" STREQUAL "")
21 | set(GIT_REV "N/A")
22 | set(GIT_DIFF "")
23 | set(GIT_TAG "N/A")
24 | else()
25 | execute_process(
26 | COMMAND ${GIT_EXECUTABLE} diff --quiet --exit-code
27 | RESULT_VARIABLE GIT_DIRTY
28 | WORKING_DIRECTORY ${SRCDIR})
29 | execute_process(
30 | COMMAND git describe --exact-match --tags
31 | OUTPUT_VARIABLE GIT_TAG
32 | ERROR_QUIET
33 | WORKING_DIRECTORY ${SRCDIR})
34 | if (NOT "${GIT_DIRTY}" EQUAL 0)
35 | #append '+' if unclean tree
36 | set(GIT_DIFF "+")
37 | endif()
38 |
39 | string(STRIP "${GIT_REV}" GIT_REV)
40 | endif()
41 |
42 | set(VERSION "#define GIT_HASH \"${GIT_REV}${GIT_DIFF}\"\n")
43 |
44 | if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/version.h)
45 | file(READ ${CMAKE_CURRENT_SOURCE_DIR}/version.h VERSION_)
46 | else()
47 | set(VERSION_ "")
48 | endif()
49 |
50 | if (NOT "${VERSION}" STREQUAL "${VERSION_}")
51 | file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.h "${VERSION}")
52 | endif()
53 |
--------------------------------------------------------------------------------
/program/library/include/stm32f0xx_hal_cortex.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f0xx_hal_cortex.h
4 | * @author MCD Application Team
5 | * @brief Header file of CORTEX HAL module.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2016 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __STM32F0xx_HAL_CORTEX_H
22 | #define __STM32F0xx_HAL_CORTEX_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm32f0xx_hal_def.h"
30 |
31 | /** @addtogroup STM32F0xx_HAL_Driver
32 | * @{
33 | */
34 |
35 | /** @addtogroup CORTEX CORTEX
36 | * @{
37 | */
38 | /* Exported types ------------------------------------------------------------*/
39 | /* Exported constants --------------------------------------------------------*/
40 |
41 | /** @defgroup CORTEX_Exported_Constants CORTEX Exported Constants
42 | * @{
43 | */
44 |
45 | /** @defgroup CORTEX_SysTick_clock_source CORTEX SysTick clock source
46 | * @{
47 | */
48 | #define SYSTICK_CLKSOURCE_HCLK_DIV8 (0x00000000U)
49 | #define SYSTICK_CLKSOURCE_HCLK (0x00000004U)
50 |
51 | /**
52 | * @}
53 | */
54 |
55 | /**
56 | * @}
57 | */
58 |
59 | /* Exported Macros -----------------------------------------------------------*/
60 |
61 | /* Exported functions --------------------------------------------------------*/
62 | /** @addtogroup CORTEX_Exported_Functions CORTEX Exported Functions
63 | * @{
64 | */
65 | /** @addtogroup CORTEX_Exported_Functions_Group1 Initialization and de-initialization functions
66 | * @brief Initialization and Configuration functions
67 | * @{
68 | */
69 | /* Initialization and de-initialization functions *******************************/
70 | void HAL_NVIC_SetPriority(IRQn_Type IRQn,uint32_t PreemptPriority, uint32_t SubPriority);
71 | void HAL_NVIC_EnableIRQ(IRQn_Type IRQn);
72 | void HAL_NVIC_DisableIRQ(IRQn_Type IRQn);
73 | void HAL_NVIC_SystemReset(void);
74 | uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb);
75 | /**
76 | * @}
77 | */
78 |
79 | /** @addtogroup CORTEX_Exported_Functions_Group2 Peripheral Control functions
80 | * @brief Cortex control functions
81 | * @{
82 | */
83 |
84 | /* Peripheral Control functions *************************************************/
85 | uint32_t HAL_NVIC_GetPriority(IRQn_Type IRQn);
86 | uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn);
87 | void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn);
88 | void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn);
89 | void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource);
90 | void HAL_SYSTICK_IRQHandler(void);
91 | void HAL_SYSTICK_Callback(void);
92 | /**
93 | * @}
94 | */
95 |
96 | /**
97 | * @}
98 | */
99 |
100 | /* Private types -------------------------------------------------------------*/
101 | /* Private variables ---------------------------------------------------------*/
102 | /* Private constants ---------------------------------------------------------*/
103 | /* Private macros ------------------------------------------------------------*/
104 | /** @defgroup CORTEX_Private_Macros CORTEX Private Macros
105 | * @{
106 | */
107 | #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x4)
108 |
109 | #define IS_NVIC_DEVICE_IRQ(IRQ) ((IRQ) >= 0x00)
110 |
111 | #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SYSTICK_CLKSOURCE_HCLK) || \
112 | ((SOURCE) == SYSTICK_CLKSOURCE_HCLK_DIV8))
113 | /**
114 | * @}
115 | */
116 |
117 | /**
118 | * @}
119 | */
120 |
121 | /**
122 | * @}
123 | */
124 |
125 | #ifdef __cplusplus
126 | }
127 | #endif
128 |
129 | #endif /* __STM32F0xx_HAL_CORTEX_H */
130 |
131 |
132 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
133 |
134 |
--------------------------------------------------------------------------------
/program/library/include/stm32f0xx_hal_def.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f0xx_hal_def.h
4 | * @author MCD Application Team
5 | * @brief This file contains HAL common defines, enumeration, macros and
6 | * structures definitions.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2016 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under BSD 3-Clause license,
14 | * the "License"; You may not use this file except in compliance with the
15 | * License. You may obtain a copy of the License at:
16 | * opensource.org/licenses/BSD-3-Clause
17 | *
18 | ******************************************************************************
19 | */
20 |
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef __STM32F0xx_HAL_DEF
23 | #define __STM32F0xx_HAL_DEF
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Includes ------------------------------------------------------------------*/
30 | #include "stm32f0xx.h"
31 | #include "Legacy/stm32_hal_legacy.h"
32 | #include
33 |
34 | /* Exported types ------------------------------------------------------------*/
35 |
36 | /**
37 | * @brief HAL Status structures definition
38 | */
39 | typedef enum
40 | {
41 | HAL_OK = 0x00U,
42 | HAL_ERROR = 0x01U,
43 | HAL_BUSY = 0x02U,
44 | HAL_TIMEOUT = 0x03U
45 | } HAL_StatusTypeDef;
46 |
47 | /**
48 | * @brief HAL Lock structures definition
49 | */
50 | typedef enum
51 | {
52 | HAL_UNLOCKED = 0x00U,
53 | HAL_LOCKED = 0x01U
54 | } HAL_LockTypeDef;
55 |
56 | /* Exported macro ------------------------------------------------------------*/
57 |
58 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */
59 |
60 | #define HAL_MAX_DELAY 0xFFFFFFFFU
61 |
62 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT))
63 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U)
64 |
65 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
66 | do{ \
67 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
68 | (__DMA_HANDLE__).Parent = (__HANDLE__); \
69 | } while(0U)
70 |
71 | /** @brief Reset the Handle's State field.
72 | * @param __HANDLE__ specifies the Peripheral Handle.
73 | * @note This macro can be used for the following purpose:
74 | * - When the Handle is declared as local variable; before passing it as parameter
75 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
76 | * to set to 0 the Handle's "State" field.
77 | * Otherwise, "State" field may have any random value and the first time the function
78 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed
79 | * (i.e. HAL_PPP_MspInit() will not be executed).
80 | * - When there is a need to reconfigure the low level hardware: instead of calling
81 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
82 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function
83 | * HAL_PPP_MspInit() which will reconfigure the low level hardware.
84 | * @retval None
85 | */
86 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U)
87 |
88 | #if (USE_RTOS == 1U)
89 | /* Reserved for future use */
90 | #error " USE_RTOS should be 0 in the current HAL release "
91 | #else
92 | #define __HAL_LOCK(__HANDLE__) \
93 | do{ \
94 | if((__HANDLE__)->Lock == HAL_LOCKED) \
95 | { \
96 | return HAL_BUSY; \
97 | } \
98 | else \
99 | { \
100 | (__HANDLE__)->Lock = HAL_LOCKED; \
101 | } \
102 | }while (0U)
103 |
104 | #define __HAL_UNLOCK(__HANDLE__) \
105 | do{ \
106 | (__HANDLE__)->Lock = HAL_UNLOCKED; \
107 | }while (0U)
108 | #endif /* USE_RTOS */
109 |
110 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
111 | #ifndef __weak
112 | #define __weak __attribute__((weak))
113 | #endif
114 | #ifndef __packed
115 | #define __packed __attribute__((packed))
116 | #endif
117 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
118 | #ifndef __weak
119 | #define __weak __attribute__((weak))
120 | #endif /* __weak */
121 | #ifndef __packed
122 | #define __packed __attribute__((__packed__))
123 | #endif /* __packed */
124 | #endif /* __GNUC__ */
125 |
126 |
127 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
128 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
129 | #ifndef __ALIGN_BEGIN
130 | #define __ALIGN_BEGIN
131 | #endif
132 | #ifndef __ALIGN_END
133 | #define __ALIGN_END __attribute__ ((aligned (4)))
134 | #endif
135 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
136 | #ifndef __ALIGN_END
137 | #define __ALIGN_END __attribute__ ((aligned (4)))
138 | #endif /* __ALIGN_END */
139 | #ifndef __ALIGN_BEGIN
140 | #define __ALIGN_BEGIN
141 | #endif /* __ALIGN_BEGIN */
142 | #else
143 | #ifndef __ALIGN_END
144 | #define __ALIGN_END
145 | #endif /* __ALIGN_END */
146 | #ifndef __ALIGN_BEGIN
147 | #if defined (__CC_ARM) /* ARM Compiler V5*/
148 | #define __ALIGN_BEGIN __align(4)
149 | #elif defined (__ICCARM__) /* IAR Compiler */
150 | #define __ALIGN_BEGIN
151 | #endif /* __CC_ARM */
152 | #endif /* __ALIGN_BEGIN */
153 | #endif /* __GNUC__ */
154 |
155 | /**
156 | * @brief __NOINLINE definition
157 | */
158 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined ( __GNUC__ )
159 | /* ARM V4/V5 and V6 & GNU Compiler
160 | -------------------------------
161 | */
162 | #define __NOINLINE __attribute__ ( (noinline) )
163 |
164 | #elif defined ( __ICCARM__ )
165 | /* ICCARM Compiler
166 | ---------------
167 | */
168 | #define __NOINLINE _Pragma("optimize = no_inline")
169 |
170 | #endif
171 |
172 | #ifdef __cplusplus
173 | }
174 | #endif
175 |
176 | #endif /* ___STM32F0xx_HAL_DEF */
177 |
178 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
179 |
--------------------------------------------------------------------------------
/program/library/include/stm32f0xx_hal_pcd_ex.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f0xx_hal_pcd_ex.h
4 | * @author MCD Application Team
5 | * @brief Header file of PCD HAL Extension module.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2016 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef STM32F0xx_HAL_PCD_EX_H
22 | #define STM32F0xx_HAL_PCD_EX_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm32f0xx_hal_def.h"
30 |
31 | #if defined (USB)
32 | /** @addtogroup STM32F0xx_HAL_Driver
33 | * @{
34 | */
35 |
36 | /** @addtogroup PCDEx
37 | * @{
38 | */
39 | /* Exported types ------------------------------------------------------------*/
40 | /* Exported constants --------------------------------------------------------*/
41 | /* Exported macros -----------------------------------------------------------*/
42 | /* Exported functions --------------------------------------------------------*/
43 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions
44 | * @{
45 | */
46 | /** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions
47 | * @{
48 | */
49 |
50 |
51 |
52 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, uint16_t ep_addr,
53 | uint16_t ep_kind, uint32_t pmaadress);
54 |
55 |
56 | HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd);
57 | HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd);
58 |
59 |
60 | HAL_StatusTypeDef HAL_PCDEx_ActivateBCD(PCD_HandleTypeDef *hpcd);
61 | HAL_StatusTypeDef HAL_PCDEx_DeActivateBCD(PCD_HandleTypeDef *hpcd);
62 | void HAL_PCDEx_BCD_VBUSDetect(PCD_HandleTypeDef *hpcd);
63 |
64 | void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg);
65 | void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg);
66 |
67 | /**
68 | * @}
69 | */
70 |
71 | /**
72 | * @}
73 | */
74 |
75 | /**
76 | * @}
77 | */
78 |
79 | /**
80 | * @}
81 | */
82 | #endif /* defined (USB) */
83 |
84 | #ifdef __cplusplus
85 | }
86 | #endif
87 |
88 |
89 | #endif /* STM32F0xx_HAL_PCD_EX_H */
90 |
91 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
92 |
--------------------------------------------------------------------------------
/program/library/include/stm32f0xx_ll_usb.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f0xx_ll_usb.h
4 | * @author MCD Application Team
5 | * @brief Header file of USB Low Layer HAL module.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2016 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef STM32F0xx_LL_USB_H
22 | #define STM32F0xx_LL_USB_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm32f0xx_hal_def.h"
30 |
31 | #if defined (USB)
32 | /** @addtogroup STM32F0xx_HAL_Driver
33 | * @{
34 | */
35 |
36 | /** @addtogroup USB_LL
37 | * @{
38 | */
39 |
40 | /* Exported types ------------------------------------------------------------*/
41 |
42 | /**
43 | * @brief USB Mode definition
44 | */
45 |
46 |
47 |
48 | typedef enum
49 | {
50 | USB_DEVICE_MODE = 0
51 | } USB_ModeTypeDef;
52 |
53 | /**
54 | * @brief USB Initialization Structure definition
55 | */
56 | typedef struct
57 | {
58 | uint32_t dev_endpoints; /*!< Device Endpoints number.
59 | This parameter depends on the used USB core.
60 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
61 |
62 | uint32_t speed; /*!< USB Core speed.
63 | This parameter can be any value of @ref USB_Core_Speed */
64 |
65 | uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. */
66 |
67 | uint32_t phy_itface; /*!< Select the used PHY interface.
68 | This parameter can be any value of @ref USB_Core_PHY */
69 |
70 | uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */
71 |
72 | uint32_t low_power_enable; /*!< Enable or disable Low Power mode */
73 |
74 | uint32_t lpm_enable; /*!< Enable or disable Battery charging. */
75 |
76 | uint32_t battery_charging_enable; /*!< Enable or disable Battery charging. */
77 | } USB_CfgTypeDef;
78 |
79 | typedef struct
80 | {
81 | uint8_t num; /*!< Endpoint number
82 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
83 |
84 | uint8_t is_in; /*!< Endpoint direction
85 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
86 |
87 | uint8_t is_stall; /*!< Endpoint stall condition
88 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
89 |
90 | uint8_t type; /*!< Endpoint type
91 | This parameter can be any value of @ref USB_EP_Type */
92 |
93 | uint8_t data_pid_start; /*!< Initial data PID
94 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
95 |
96 | uint16_t pmaadress; /*!< PMA Address
97 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */
98 |
99 | uint16_t pmaaddr0; /*!< PMA Address0
100 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */
101 |
102 | uint16_t pmaaddr1; /*!< PMA Address1
103 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */
104 |
105 | uint8_t doublebuffer; /*!< Double buffer enable
106 | This parameter can be 0 or 1 */
107 |
108 | uint16_t tx_fifo_num; /*!< This parameter is not required by USB Device FS peripheral, it is used
109 | only by USB OTG FS peripheral
110 | This parameter is added to ensure compatibility across USB peripherals */
111 |
112 | uint32_t maxpacket; /*!< Endpoint Max packet size
113 | This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */
114 |
115 | uint8_t *xfer_buff; /*!< Pointer to transfer buffer */
116 |
117 | uint32_t xfer_len; /*!< Current transfer length */
118 |
119 | uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */
120 |
121 | uint32_t xfer_len_db; /*!< double buffer transfer length used with bulk double buffer in */
122 |
123 | uint8_t xfer_fill_db; /*!< double buffer Need to Fill new buffer used with bulk_in */
124 |
125 | } USB_EPTypeDef;
126 |
127 |
128 | /* Exported constants --------------------------------------------------------*/
129 |
130 | /** @defgroup PCD_Exported_Constants PCD Exported Constants
131 | * @{
132 | */
133 |
134 |
135 | /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS
136 | * @{
137 | */
138 | #define EP_MPS_64 0U
139 | #define EP_MPS_32 1U
140 | #define EP_MPS_16 2U
141 | #define EP_MPS_8 3U
142 | /**
143 | * @}
144 | */
145 |
146 | /** @defgroup USB_LL_EP_Type USB Low Layer EP Type
147 | * @{
148 | */
149 | #define EP_TYPE_CTRL 0U
150 | #define EP_TYPE_ISOC 1U
151 | #define EP_TYPE_BULK 2U
152 | #define EP_TYPE_INTR 3U
153 | #define EP_TYPE_MSK 3U
154 | /**
155 | * @}
156 | */
157 |
158 | /** @defgroup USB_LL Device Speed
159 | * @{
160 | */
161 | #define USBD_FS_SPEED 2U
162 | /**
163 | * @}
164 | */
165 |
166 | #define BTABLE_ADDRESS 0x000U
167 | #define PMA_ACCESS 1U
168 |
169 | #define EP_ADDR_MSK 0x7U
170 | /**
171 | * @}
172 | */
173 |
174 | /* Exported macro ------------------------------------------------------------*/
175 | /**
176 | * @}
177 | */
178 |
179 | /* Exported functions --------------------------------------------------------*/
180 | /** @addtogroup USB_LL_Exported_Functions USB Low Layer Exported Functions
181 | * @{
182 | */
183 |
184 |
185 | HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg);
186 | HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg);
187 | HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx);
188 | HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx);
189 | HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx, USB_ModeTypeDef mode);
190 | HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep);
191 | HAL_StatusTypeDef USB_DeactivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep);
192 | HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep);
193 | HAL_StatusTypeDef USB_EPSetStall(USB_TypeDef *USBx, USB_EPTypeDef *ep);
194 | HAL_StatusTypeDef USB_EPClearStall(USB_TypeDef *USBx, USB_EPTypeDef *ep);
195 | HAL_StatusTypeDef USB_SetDevAddress(USB_TypeDef *USBx, uint8_t address);
196 | HAL_StatusTypeDef USB_DevConnect(USB_TypeDef *USBx);
197 | HAL_StatusTypeDef USB_DevDisconnect(USB_TypeDef *USBx);
198 | HAL_StatusTypeDef USB_StopDevice(USB_TypeDef *USBx);
199 | uint32_t USB_ReadInterrupts(USB_TypeDef *USBx);
200 | HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_TypeDef *USBx);
201 | HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_TypeDef *USBx);
202 |
203 | void USB_WritePMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf,
204 | uint16_t wPMABufAddr, uint16_t wNBytes);
205 |
206 | void USB_ReadPMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf,
207 | uint16_t wPMABufAddr, uint16_t wNBytes);
208 |
209 | /**
210 | * @}
211 | */
212 |
213 | /**
214 | * @}
215 | */
216 |
217 | /**
218 | * @}
219 | */
220 |
221 | /**
222 | * @}
223 | */
224 | #endif /* defined (USB) */
225 |
226 | #ifdef __cplusplus
227 | }
228 | #endif
229 |
230 |
231 | #endif /* STM32F0xx_LL_USB_H */
232 |
233 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
234 |
--------------------------------------------------------------------------------
/program/system/cmsis/cmsis_device.h:
--------------------------------------------------------------------------------
1 | #include
2 |
--------------------------------------------------------------------------------
/program/system/cmsis/cmsis_version.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file cmsis_version.h
3 | * @brief CMSIS Core(M) Version definitions
4 | * @version V5.0.2
5 | * @date 19. April 2017
6 | ******************************************************************************/
7 | /*
8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
9 | *
10 | * SPDX-License-Identifier: Apache-2.0
11 | *
12 | * Licensed under the Apache License, Version 2.0 (the License); you may
13 | * not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | #if defined ( __ICCARM__ )
26 | #pragma system_include /* treat file as system include file for MISRA check */
27 | #elif defined (__clang__)
28 | #pragma clang system_header /* treat file as system include file */
29 | #endif
30 |
31 | #ifndef __CMSIS_VERSION_H
32 | #define __CMSIS_VERSION_H
33 |
34 | /* CMSIS Version definitions */
35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */
37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
39 | #endif
40 |
--------------------------------------------------------------------------------
/program/system/hal_include.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #pragma once
28 |
29 | # include "stm32f0xx_hal.h"
30 |
--------------------------------------------------------------------------------
/program/system/stm32f072xb.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rm-controls/rm_usb2can/d1b1335065ebdc5208f7ab43b1d73c406fbe0e91/program/system/stm32f072xb.h
--------------------------------------------------------------------------------
/program/system/stm32f0xx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rm-controls/rm_usb2can/d1b1335065ebdc5208f7ab43b1d73c406fbe0e91/program/system/stm32f0xx.h
--------------------------------------------------------------------------------
/program/system/system_stm32f0xx.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file system_stm32f0xx.h
4 | * @author MCD Application Team
5 | * @brief CMSIS Cortex-M0 Device System Source File for STM32F0xx devices.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2016 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /** @addtogroup CMSIS
21 | * @{
22 | */
23 |
24 | /** @addtogroup stm32f0xx_system
25 | * @{
26 | */
27 |
28 | /**
29 | * @brief Define to prevent recursive inclusion
30 | */
31 | #ifndef __SYSTEM_STM32F0XX_H
32 | #define __SYSTEM_STM32F0XX_H
33 |
34 | #ifdef __cplusplus
35 | extern "C" {
36 | #endif
37 |
38 | /** @addtogroup STM32F0xx_System_Includes
39 | * @{
40 | */
41 |
42 | /**
43 | * @}
44 | */
45 |
46 |
47 | /** @addtogroup STM32F0xx_System_Exported_types
48 | * @{
49 | */
50 | /* This variable is updated in three ways:
51 | 1) by calling CMSIS function SystemCoreClockUpdate()
52 | 3) by calling HAL API function HAL_RCC_GetHCLKFreq()
53 | 3) by calling HAL API function HAL_RCC_ClockConfig()
54 | Note: If you use this function to configure the system clock; then there
55 | is no need to call the 2 first functions listed above, since SystemCoreClock
56 | variable is updated automatically.
57 | */
58 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
59 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */
60 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */
61 |
62 | /**
63 | * @}
64 | */
65 |
66 | /** @addtogroup STM32F0xx_System_Exported_Constants
67 | * @{
68 | */
69 |
70 | /**
71 | * @}
72 | */
73 |
74 | /** @addtogroup STM32F0xx_System_Exported_Macros
75 | * @{
76 | */
77 |
78 | /**
79 | * @}
80 | */
81 |
82 | /** @addtogroup STM32F0xx_System_Exported_Functions
83 | * @{
84 | */
85 |
86 | extern void SystemInit(void);
87 | extern void SystemCoreClockUpdate(void);
88 | /**
89 | * @}
90 | */
91 |
92 | #ifdef __cplusplus
93 | }
94 | #endif
95 |
96 | #endif /*__SYSTEM_STM32F0XX_H */
97 |
98 | /**
99 | * @}
100 | */
101 |
102 | /**
103 | * @}
104 | */
105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
106 |
--------------------------------------------------------------------------------
/program/usb/usbd_conf.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #pragma once
28 |
29 | #include "hal_include.h"
30 |
31 | #define USBD_MAX_NUM_INTERFACES 1
32 | #define USBD_MAX_NUM_CONFIGURATION 1
33 | #define USBD_DESC_BUF_SIZE 192
34 | #define USBD_SUPPORT_USER_STRING_DESC 1
35 | #define USBD_SELF_POWERED 0
36 | #define DEVICE_FS 0
37 |
38 | #define USBD_ErrLog(...)
39 |
--------------------------------------------------------------------------------
/program/usb/usbd_core.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_core.h
4 | * @author MCD Application Team
5 | * @brief Header file for usbd_core.c file
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under Ultimate Liberty license
13 | * SLA0044, the "License"; You may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at:
15 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __USBD_CORE_H
22 | #define __USBD_CORE_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "usbd_conf.h"
30 | #include "usbd_def.h"
31 | #include "usbd_ioreq.h"
32 | #include "usbd_ctlreq.h"
33 |
34 | /** @addtogroup STM32_USB_DEVICE_LIBRARY
35 | * @{
36 | */
37 |
38 | /** @defgroup USBD_CORE
39 | * @brief This file is the Header file for usbd_core.c file
40 | * @{
41 | */
42 |
43 |
44 | /** @defgroup USBD_CORE_Exported_Defines
45 | * @{
46 | */
47 | #ifndef USBD_DEBUG_LEVEL
48 | #define USBD_DEBUG_LEVEL 0U
49 | #endif /* USBD_DEBUG_LEVEL */
50 | /**
51 | * @}
52 | */
53 |
54 |
55 | /** @defgroup USBD_CORE_Exported_TypesDefinitions
56 | * @{
57 | */
58 |
59 |
60 | /**
61 | * @}
62 | */
63 |
64 |
65 |
66 | /** @defgroup USBD_CORE_Exported_Macros
67 | * @{
68 | */
69 |
70 | /**
71 | * @}
72 | */
73 |
74 | /** @defgroup USBD_CORE_Exported_Variables
75 | * @{
76 | */
77 | #define USBD_SOF USBD_LL_SOF
78 | /**
79 | * @}
80 | */
81 |
82 | /** @defgroup USBD_CORE_Exported_FunctionsPrototype
83 | * @{
84 | */
85 | USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id);
86 | USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev);
87 | USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev);
88 | USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev);
89 | USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass);
90 |
91 | USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev);
92 | USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
93 | USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
94 |
95 | USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup);
96 | USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata);
97 | USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata);
98 |
99 | USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev);
100 | USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed);
101 | USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev);
102 | USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev);
103 |
104 | USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev);
105 | USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
106 | USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
107 |
108 | USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev);
109 | USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev);
110 |
111 | /* USBD Low Level Driver */
112 | USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev);
113 | USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev);
114 | USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev);
115 | USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev);
116 | USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev,
117 | uint8_t ep_addr,
118 | uint8_t ep_type,
119 | uint16_t ep_mps);
120 |
121 | USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
122 | USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
123 | USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
124 | USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
125 | uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
126 | USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr);
127 | USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev,
128 | uint8_t ep_addr,
129 | uint8_t *pbuf,
130 | uint16_t size);
131 |
132 | USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev,
133 | uint8_t ep_addr,
134 | uint8_t *pbuf,
135 | uint16_t size);
136 |
137 | uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
138 | void USBD_LL_Delay(uint32_t Delay);
139 |
140 | /**
141 | * @}
142 | */
143 |
144 | #ifdef __cplusplus
145 | }
146 | #endif
147 |
148 | #endif /* __USBD_CORE_H */
149 |
150 | /**
151 | * @}
152 | */
153 |
154 | /**
155 | * @}
156 | */
157 |
158 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
159 |
160 |
161 |
162 |
--------------------------------------------------------------------------------
/program/usb/usbd_ctlreq.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_req.h
4 | * @author MCD Application Team
5 | * @brief Header file for the usbd_req.c file
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under Ultimate Liberty license
13 | * SLA0044, the "License"; You may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at:
15 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __USB_REQUEST_H
22 | #define __USB_REQUEST_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "usbd_def.h"
30 |
31 |
32 | /** @addtogroup STM32_USB_DEVICE_LIBRARY
33 | * @{
34 | */
35 |
36 | /** @defgroup USBD_REQ
37 | * @brief header file for the usbd_req.c file
38 | * @{
39 | */
40 |
41 | /** @defgroup USBD_REQ_Exported_Defines
42 | * @{
43 | */
44 | /**
45 | * @}
46 | */
47 |
48 |
49 | /** @defgroup USBD_REQ_Exported_Types
50 | * @{
51 | */
52 | /**
53 | * @}
54 | */
55 |
56 |
57 |
58 | /** @defgroup USBD_REQ_Exported_Macros
59 | * @{
60 | */
61 | /**
62 | * @}
63 | */
64 |
65 | /** @defgroup USBD_REQ_Exported_Variables
66 | * @{
67 | */
68 | /**
69 | * @}
70 | */
71 |
72 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype
73 | * @{
74 | */
75 |
76 | USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
77 | USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
78 | USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
79 |
80 |
81 | void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
82 |
83 | void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata);
84 |
85 | void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len);
86 | /**
87 | * @}
88 | */
89 |
90 | #ifdef __cplusplus
91 | }
92 | #endif
93 |
94 | #endif /* __USB_REQUEST_H */
95 |
96 | /**
97 | * @}
98 | */
99 |
100 | /**
101 | * @}
102 | */
103 |
104 |
105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
106 |
--------------------------------------------------------------------------------
/program/usb/usbd_ioreq.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_ioreq.c
4 | * @author MCD Application Team
5 | * @brief This file provides the IO requests APIs for control endpoints.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under Ultimate Liberty license
13 | * SLA0044, the "License"; You may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at:
15 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "usbd_ioreq.h"
22 |
23 | /** @addtogroup STM32_USB_DEVICE_LIBRARY
24 | * @{
25 | */
26 |
27 |
28 | /** @defgroup USBD_IOREQ
29 | * @brief control I/O requests module
30 | * @{
31 | */
32 |
33 | /** @defgroup USBD_IOREQ_Private_TypesDefinitions
34 | * @{
35 | */
36 | /**
37 | * @}
38 | */
39 |
40 |
41 | /** @defgroup USBD_IOREQ_Private_Defines
42 | * @{
43 | */
44 |
45 | /**
46 | * @}
47 | */
48 |
49 |
50 | /** @defgroup USBD_IOREQ_Private_Macros
51 | * @{
52 | */
53 | /**
54 | * @}
55 | */
56 |
57 |
58 | /** @defgroup USBD_IOREQ_Private_Variables
59 | * @{
60 | */
61 |
62 | /**
63 | * @}
64 | */
65 |
66 |
67 | /** @defgroup USBD_IOREQ_Private_FunctionPrototypes
68 | * @{
69 | */
70 | /**
71 | * @}
72 | */
73 |
74 |
75 | /** @defgroup USBD_IOREQ_Private_Functions
76 | * @{
77 | */
78 |
79 | /**
80 | * @brief USBD_CtlSendData
81 | * send data on the ctl pipe
82 | * @param pdev: device instance
83 | * @param buff: pointer to data buffer
84 | * @param len: length of data to be sent
85 | * @retval status
86 | */
87 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
88 | uint8_t *pbuf, uint16_t len)
89 | {
90 | /* Set EP0 State */
91 | pdev->ep0_state = USBD_EP0_DATA_IN;
92 | pdev->ep_in[0].total_length = len;
93 | pdev->ep_in[0].rem_length = len;
94 |
95 | /* Start the transfer */
96 | USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
97 |
98 | return USBD_OK;
99 | }
100 |
101 | /**
102 | * @brief USBD_CtlContinueSendData
103 | * continue sending data on the ctl pipe
104 | * @param pdev: device instance
105 | * @param buff: pointer to data buffer
106 | * @param len: length of data to be sent
107 | * @retval status
108 | */
109 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev,
110 | uint8_t *pbuf, uint16_t len)
111 | {
112 | /* Start the next transfer */
113 | USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
114 |
115 | return USBD_OK;
116 | }
117 |
118 | /**
119 | * @brief USBD_CtlPrepareRx
120 | * receive data on the ctl pipe
121 | * @param pdev: device instance
122 | * @param buff: pointer to data buffer
123 | * @param len: length of data to be received
124 | * @retval status
125 | */
126 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
127 | uint8_t *pbuf, uint16_t len)
128 | {
129 | /* Set EP0 State */
130 | pdev->ep0_state = USBD_EP0_DATA_OUT;
131 | pdev->ep_out[0].total_length = len;
132 | pdev->ep_out[0].rem_length = len;
133 |
134 | /* Start the transfer */
135 | USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
136 |
137 | return USBD_OK;
138 | }
139 |
140 | /**
141 | * @brief USBD_CtlContinueRx
142 | * continue receive data on the ctl pipe
143 | * @param pdev: device instance
144 | * @param buff: pointer to data buffer
145 | * @param len: length of data to be received
146 | * @retval status
147 | */
148 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev,
149 | uint8_t *pbuf, uint16_t len)
150 | {
151 | USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
152 |
153 | return USBD_OK;
154 | }
155 |
156 | /**
157 | * @brief USBD_CtlSendStatus
158 | * send zero lzngth packet on the ctl pipe
159 | * @param pdev: device instance
160 | * @retval status
161 | */
162 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev)
163 | {
164 | /* Set EP0 State */
165 | pdev->ep0_state = USBD_EP0_STATUS_IN;
166 |
167 | /* Start the transfer */
168 | USBD_LL_Transmit(pdev, 0x00U, NULL, 0U);
169 |
170 | return USBD_OK;
171 | }
172 |
173 | /**
174 | * @brief USBD_CtlReceiveStatus
175 | * receive zero lzngth packet on the ctl pipe
176 | * @param pdev: device instance
177 | * @retval status
178 | */
179 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev)
180 | {
181 | /* Set EP0 State */
182 | pdev->ep0_state = USBD_EP0_STATUS_OUT;
183 |
184 | /* Start the transfer */
185 | USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
186 |
187 | return USBD_OK;
188 | }
189 |
190 | /**
191 | * @brief USBD_GetRxCount
192 | * returns the received data length
193 | * @param pdev: device instance
194 | * @param ep_addr: endpoint address
195 | * @retval Rx Data blength
196 | */
197 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
198 | {
199 | return USBD_LL_GetRxDataSize(pdev, ep_addr);
200 | }
201 |
202 | /**
203 | * @}
204 | */
205 |
206 |
207 | /**
208 | * @}
209 | */
210 |
211 |
212 | /**
213 | * @}
214 | */
215 |
216 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
217 |
--------------------------------------------------------------------------------
/program/usb/usbd_ioreq.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_ioreq.h
4 | * @author MCD Application Team
5 | * @brief Header file for the usbd_ioreq.c file
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under Ultimate Liberty license
13 | * SLA0044, the "License"; You may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at:
15 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __USBD_IOREQ_H
22 | #define __USBD_IOREQ_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "usbd_def.h"
30 | #include "usbd_core.h"
31 |
32 | /** @addtogroup STM32_USB_DEVICE_LIBRARY
33 | * @{
34 | */
35 |
36 | /** @defgroup USBD_IOREQ
37 | * @brief header file for the usbd_ioreq.c file
38 | * @{
39 | */
40 |
41 | /** @defgroup USBD_IOREQ_Exported_Defines
42 | * @{
43 | */
44 | /**
45 | * @}
46 | */
47 |
48 |
49 | /** @defgroup USBD_IOREQ_Exported_Types
50 | * @{
51 | */
52 |
53 |
54 | /**
55 | * @}
56 | */
57 |
58 |
59 |
60 | /** @defgroup USBD_IOREQ_Exported_Macros
61 | * @{
62 | */
63 |
64 | /**
65 | * @}
66 | */
67 |
68 | /** @defgroup USBD_IOREQ_Exported_Variables
69 | * @{
70 | */
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype
77 | * @{
78 | */
79 |
80 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
81 | uint8_t *pbuf,
82 | uint16_t len);
83 |
84 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev,
85 | uint8_t *pbuf,
86 | uint16_t len);
87 |
88 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
89 | uint8_t *pbuf,
90 | uint16_t len);
91 |
92 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev,
93 | uint8_t *pbuf,
94 | uint16_t len);
95 |
96 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev);
97 |
98 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev);
99 |
100 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
101 |
102 | /**
103 | * @}
104 | */
105 |
106 | #ifdef __cplusplus
107 | }
108 | #endif
109 |
110 | #endif /* __USBD_IOREQ_H */
111 |
112 | /**
113 | * @}
114 | */
115 |
116 | /**
117 | * @}
118 | */
119 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
120 |
--------------------------------------------------------------------------------
/program/user/include/can.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #pragma once
28 |
29 | #include
30 | #include
31 |
32 | #include "hal_include.h"
33 |
34 | #include
35 |
36 | typedef struct {
37 | CAN_TypeDef *instance;
38 | uint16_t brp;
39 | uint8_t phase_seg1;
40 | uint8_t phase_seg2;
41 | uint8_t sjw;
42 | } can_data_t;
43 |
44 | void can_init(can_data_t *hcan, CAN_TypeDef *instance);
45 | bool can_set_bittiming(can_data_t *hcan, uint16_t brp, uint8_t phase_seg1, uint8_t phase_seg2, uint8_t sjw);
46 | void can_enable(can_data_t *hcan, bool loop_back, bool listen_only, bool one_shot);
47 | void can_disable(can_data_t *hcan);
48 | bool can_is_enabled(can_data_t *hcan);
49 |
50 | bool can_receive(can_data_t *hcan, struct gs_host_frame *rx_frame);
51 | bool can_is_rx_pending(can_data_t *hcan);
52 |
53 | bool can_send(can_data_t *hcan, struct gs_host_frame *frame);
54 |
55 | /** return CAN->ESR register which contains tx/rx error counters and
56 | * LEC (last error code).
57 | */
58 | uint32_t can_get_error_status(can_data_t *hcan);
59 |
60 | #define CAN_ERRCOUNT_THRESHOLD 15 /* send an error frame if tx/rx counters increase by more than this amount */
61 |
62 | /** parse status value returned by can_get_error_status().
63 | * @param frame : will hold the generated error frame
64 | * @return 1 when status changes (if any) need a new error frame sent
65 | */
66 | bool can_parse_error_status(uint32_t err, uint32_t last_err, can_data_t *hcan, struct gs_host_frame *frame);
67 |
--------------------------------------------------------------------------------
/program/user/include/config.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | *
26 | *
27 | * Some board-specific defines here, such as :
28 | * - USB strings
29 | * - LED pin assignments and polarity
30 | * - other special pins to control CAN transceivers.
31 | *
32 | * CAN_S_PIN :Some CAN transceivers (e.g. TJA1050) have a "Silent mode in which the transmitter is disabled";
33 | * enabled with this 'S' pin. If undefined, the corresponding code will be disabled.
34 | *
35 | */
36 |
37 | #pragma once
38 |
39 | #include "version.h"
40 |
41 | #define CAN_QUEUE_SIZE 64
42 |
43 | #define USBD_VID 0x1d50
44 | #define USBD_PID_FS 0x606f
45 | #define USBD_LANGID_STRING 1033
46 | #define USBD_CONFIGURATION_STRING_FS (uint8_t*) GIT_HASH
47 | #define USBD_INTERFACE_STRING_FS (uint8_t*) "gs_usb interface"
48 |
49 | #define USBD_PRODUCT_STRING_FS (uint8_t*) "candleLight USB to CAN adapter"
50 | #define USBD_MANUFACTURER_STRING (uint8_t*) "bytewerk"
51 | #define DFU_INTERFACE_STRING_FS (uint8_t*) "candleLight firmware upgrade interface"
52 |
53 | #define LED1_Pin GPIO_PIN_0
54 | #define LED1_Mode GPIO_MODE_OUTPUT_OD
55 | #define LED1_GPIO_Port GPIOA
56 | #define LED1_Active_High 0
57 |
58 | #define LED2_GPIO_Port GPIOA
59 | #define LED2_Pin GPIO_PIN_1
60 | #define LED2_Mode GPIO_MODE_OUTPUT_OD
61 | #define LED2_Active_High 0
62 |
--------------------------------------------------------------------------------
/program/user/include/dfu.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #pragma once
28 |
29 | void dfu_run_bootloader();
30 |
--------------------------------------------------------------------------------
/program/user/include/flash.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #pragma once
28 |
29 | #include
30 | #include
31 |
32 | void flash_load();
33 | bool flash_set_user_id(uint8_t channel, uint32_t user_id);
34 | uint32_t flash_get_user_id(uint8_t channel);
35 | void flash_flush();
36 |
--------------------------------------------------------------------------------
/program/user/include/gpio.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #pragma once
28 |
29 | void gpio_init();
30 |
--------------------------------------------------------------------------------
/program/user/include/led.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #pragma once
28 |
29 | #include
30 | #include
31 |
32 | typedef enum {
33 | led_mode_off,
34 | led_mode_normal,
35 | led_mode_warn,
36 | led_mode_error,
37 | led_mode_sequence
38 | } led_mode_t;
39 |
40 | typedef enum {
41 | led_1,
42 | led_2
43 | } led_num_t;
44 |
45 | typedef struct {
46 | uint8_t state;
47 | uint8_t time_in_10ms;
48 | } led_seq_step_t;
49 |
50 | typedef struct {
51 | void* port;
52 | uint16_t pin;
53 | bool is_active_high;
54 | uint32_t on_until;
55 | uint32_t off_until;
56 | } led_state_t;
57 |
58 | typedef struct {
59 | led_mode_t mode;
60 | led_mode_t last_mode;
61 |
62 | led_seq_step_t *sequence;
63 | uint32_t sequence_step;
64 | uint32_t t_sequence_next;
65 | int32_t seq_num_repeat;
66 |
67 | led_state_t led_state[2];
68 | } led_data_t;
69 |
70 |
71 | void led_init(
72 | led_data_t *leds,
73 | void* led1_port, uint16_t led1_pin, bool led1_active_high,
74 | void* led2_port, uint16_t led2_pin, bool led2_active_high
75 | );
76 | void led_set_mode(led_data_t *leds,led_mode_t mode);
77 | void led_run_sequence(led_data_t *leds, led_seq_step_t *sequence, int32_t num_repeat);
78 | void led_indicate_trx(led_data_t *leds, led_num_t num);
79 | void led_update(led_data_t *leds);
80 |
--------------------------------------------------------------------------------
/program/user/include/queue.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #pragma once
28 |
29 | #include
30 | #include
31 |
32 | typedef struct {
33 | unsigned max_elements;
34 | unsigned first;
35 | unsigned size;
36 | void **buf;
37 | } queue_t;
38 |
39 | queue_t *queue_create(unsigned max_elements);
40 | void queue_free(queue_t *q);
41 |
42 | unsigned queue_size(queue_t *q);
43 | bool queue_is_empty(queue_t *q);
44 | bool queue_push_back(queue_t *q, void *el);
45 | bool queue_push_front(queue_t *q, void *el);
46 | void *queue_pop_front(queue_t *q);
47 |
48 | unsigned queue_size_i(queue_t *q);
49 | bool queue_is_empty_i(queue_t *q);
50 | bool queue_push_back_i(queue_t *q, void *el);
51 | bool queue_push_front_i(queue_t *q, void *el);
52 | void *queue_pop_front_i(queue_t *q);
53 |
--------------------------------------------------------------------------------
/program/user/include/timer.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #pragma once
28 |
29 | #include
30 |
31 | void timer_init();
32 | uint32_t timer_get();
33 |
--------------------------------------------------------------------------------
/program/user/include/usbd_desc.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #pragma once
28 |
29 | #include "usbd_def.h"
30 |
31 | extern const USBD_DescriptorsTypeDef FS_Desc;
32 | extern uint8_t USBD_DescBuf[USBD_DESC_BUF_SIZE];
33 |
34 |
--------------------------------------------------------------------------------
/program/user/include/usbd_gs_can.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #pragma once
28 |
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 |
36 | /* Define these here so they can be referenced in other files */
37 |
38 | #define CAN_DATA_MAX_PACKET_SIZE 32 /* Endpoint IN & OUT Packet size */
39 | #define CAN_CMD_PACKET_SIZE 64 /* Control Endpoint Packet size */
40 | #define USB_CAN_CONFIG_DESC_SIZ 50
41 | #define NUM_CAN_CHANNEL 1
42 | #define USBD_GS_CAN_VENDOR_CODE 0x20
43 | #define DFU_INTERFACE_NUM 1
44 | #define DFU_INTERFACE_STR_INDEX 0xE0
45 |
46 | extern USBD_ClassTypeDef USBD_GS_CAN;
47 |
48 | # define USB_INTERFACE USB
49 | # define USB_INTERRUPT USB_IRQn
50 | # define CAN_INTERFACE CAN
51 | # define CAN_CLOCK_SPEED 48000000
52 |
53 | uint8_t USBD_GS_CAN_Init(USBD_HandleTypeDef *pdev, queue_t *q_frame_pool, queue_t *q_from_host, led_data_t *leds);
54 | void USBD_GS_CAN_SetChannel(USBD_HandleTypeDef *pdev, uint8_t channel, can_data_t *handle);
55 | void USBD_GS_CAN_SuspendCallback(USBD_HandleTypeDef *pdev);
56 | void USBD_GS_CAN_ResumeCallback(USBD_HandleTypeDef *pdev);
57 | bool USBD_GS_CAN_TxReady(USBD_HandleTypeDef *pdev);
58 | uint8_t USBD_GS_CAN_PrepareReceive(USBD_HandleTypeDef *pdev);
59 | bool USBD_GS_CAN_CustomDeviceRequest(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
60 | bool USBD_GS_CAN_CustomInterfaceRequest(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
61 |
62 | bool USBD_GS_CAN_DfuDetachRequested(USBD_HandleTypeDef *pdev);
63 | uint8_t USBD_GS_CAN_SendFrame(USBD_HandleTypeDef *pdev, struct gs_host_frame *frame);
64 | uint8_t USBD_GS_CAN_Transmit(USBD_HandleTypeDef *pdev, uint8_t *buf, uint16_t len);
65 | uint8_t USBD_GS_CAN_GetProtocolVersion(USBD_HandleTypeDef *pdev);
66 | uint8_t USBD_GS_CAN_GetPadPacketsToMaxPacketSize(USBD_HandleTypeDef *pdev);
67 |
--------------------------------------------------------------------------------
/program/user/include/util.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016, 2019 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #pragma once
28 |
29 | #include
30 | #include
31 | #include
32 |
33 | void hex32(char *out, uint32_t val);
34 |
35 | // ARM's
36 | // "Application Note 321 ARM Cortex-M Programming Guide to Memory Barrier Instructions"
37 | // (from https://developer.arm.com/documentation/dai0321/latest) says that
38 | // the ISBs are actually necessary on Cortex-M0 to avoid a 2-instruction
39 | // delay in the effect of enabling and disabling interrupts.
40 | // That probably doesn't matter here, but it's hard to say what the compiler
41 | // will put in those 2 instructions so it's safer to leave it. The DSB isn't
42 | // necessary on Cortex-M0, but it's architecturally required so we'll
43 | // include it to be safe.
44 | //
45 | // The "memory" and "cc" clobbers tell GCC to avoid moving memory loads or
46 | // stores across the instructions. This is important when an interrupt and the
47 | // code calling disable_irq/enable_irq share memory. The fact that these are
48 | // non-inlined functions probably forces GCC to flush everything to memory
49 | // anyways, but trying to outsmart the compiler is a bad strategy (you never
50 | // know when somebody will turn on LTO or something).
51 |
52 | static inline bool is_irq_enabled(void)
53 | {
54 | return (__get_PRIMASK() & 1u) == 0u; // interrupts not prevented
55 | }
56 |
57 | static inline bool disable_irq(void)
58 | {
59 | bool was_enabled = is_irq_enabled();
60 | __disable_irq();
61 | __ISB();
62 | return was_enabled;
63 | }
64 |
65 | static inline void enable_irq()
66 | {
67 | __enable_irq();
68 | __ISB();
69 | }
70 |
71 | /* Lightweight assert macro to replace standard assert()
72 | *
73 | * Standard assert() needs fprint, __FILE__ , __LINE__ string consts etc.
74 | *
75 | * stm32's library has "USE_FULL_ASSERT" to enable some checks, but they have
76 | * their own assert_param() macro that also passes in __FILE__, __LINE__ so
77 | * I'm not sure if (and how) it'll be possible to combine both.
78 | *
79 | * Interesting notes on
80 | * https://barrgroup.com/embedded-systems/how-to/define-assert-macro
81 | *
82 | */
83 | #define assert_basic(exp) \
84 | if (exp) { \
85 | } else \
86 | assert_failed()
87 |
88 | /** halt / set core to debug state with BKPT.
89 | *
90 | * TODO : save extra info somewhere in RAM, and let WDT auto-reset ?
91 | */
92 | void assert_failed(void);
93 |
--------------------------------------------------------------------------------
/program/user/src/dfu.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #include "dfu.h"
28 | #include
29 | #include "hal_include.h"
30 |
31 | #define RESET_TO_BOOTLOADER_MAGIC_CODE 0xDEADBEEF
32 |
33 | #define SYSMEM_STM32F042 0x1FFFC400
34 | #define SYSMEM_STM32F072 0x1FFFC800
35 |
36 | static uint32_t dfu_reset_to_bootloader_magic;
37 |
38 | static void dfu_hack_boot_pin_f042();
39 | static void dfu_jump_to_bootloader();
40 |
41 | void dfu_run_bootloader() {
42 | dfu_reset_to_bootloader_magic = RESET_TO_BOOTLOADER_MAGIC_CODE;
43 | NVIC_SystemReset();
44 | }
45 |
46 | void __initialize_hardware_early(void) {
47 | if (dfu_reset_to_bootloader_magic == RESET_TO_BOOTLOADER_MAGIC_CODE) {
48 | switch (HAL_GetDEVID()) {
49 |
50 | case 0x445: // STM32F04x
51 | dfu_hack_boot_pin_f042();
52 | dfu_jump_to_bootloader(SYSMEM_STM32F042);
53 | break;
54 |
55 | case 0x448: // STM32F07x
56 | dfu_jump_to_bootloader(SYSMEM_STM32F072);
57 | break;
58 |
59 | }
60 | }
61 |
62 | SystemInit();
63 | }
64 |
65 | static void dfu_hack_boot_pin_f042() {
66 | __HAL_RCC_GPIOF_CLK_ENABLE();
67 | GPIO_InitTypeDef GPIO_InitStruct;
68 | GPIO_InitStruct.Pin = GPIO_PIN_11;
69 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
70 | GPIO_InitStruct.Pull = GPIO_PULLUP;
71 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
72 | HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
73 | HAL_GPIO_WritePin(GPIOF, GPIO_PIN_11, 1);
74 | }
75 |
76 | static void dfu_jump_to_bootloader(uint32_t sysmem_base) {
77 | void (*bootloader)(void) = (void (*)(void)) (*((uint32_t *) (sysmem_base + 4)));
78 |
79 | __set_MSP(*(__IO uint32_t *) sysmem_base);
80 | bootloader();
81 |
82 | while (42) {
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/program/user/src/flash.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 |
28 | #include "flash.h"
29 | #include
30 | #include "hal_include.h"
31 |
32 | #define NUM_CHANNEL 1
33 |
34 | typedef struct {
35 | uint32_t user_id[NUM_CHANNEL];
36 | } flash_data_t;
37 |
38 | static flash_data_t flash_data_ram;
39 | __attribute__((__section__(".user_data"))) const flash_data_t flash_data_rom;
40 |
41 | void flash_load() {
42 | memcpy(&flash_data_ram, &flash_data_rom, sizeof(flash_data_t));
43 | }
44 |
45 | bool flash_set_user_id(uint8_t channel, uint32_t user_id) {
46 | if (channel < NUM_CHANNEL) {
47 | if (flash_data_ram.user_id[channel] != user_id) {
48 | flash_data_ram.user_id[channel] = user_id;
49 | flash_flush();
50 | }
51 |
52 | return true;
53 | } else {
54 | return false;
55 | }
56 | }
57 |
58 | uint32_t flash_get_user_id(uint8_t channel) {
59 | if (channel < NUM_CHANNEL) {
60 | return flash_data_ram.user_id[channel];
61 | } else {
62 | return 0;
63 | }
64 | }
65 |
66 | void flash_flush() {
67 | FLASH_EraseInitTypeDef erase_pages;
68 |
69 | erase_pages.PageAddress = (uint32_t) &flash_data_rom;
70 | erase_pages.NbPages = 1;
71 | erase_pages.TypeErase = FLASH_TYPEERASE_PAGES;
72 |
73 | HAL_FLASH_Unlock();
74 |
75 | __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_SR_PGERR);
76 |
77 | uint32_t error = 0;
78 | HAL_FLASHEx_Erase(&erase_pages, &error);
79 | if (error == 0xFFFFFFFF) { // erase finished successfully
80 | HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, (uint32_t) &flash_data_rom.user_id[0], flash_data_ram.user_id[0]);
81 | }
82 |
83 | HAL_FLASH_Lock();
84 | }
85 |
--------------------------------------------------------------------------------
/program/user/src/gpio.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #include "config.h"
28 | #include "hal_include.h"
29 |
30 | // must run before can_init
31 | void gpio_init() {
32 | GPIO_InitTypeDef GPIO_InitStruct;
33 |
34 | __HAL_RCC_GPIOA_CLK_ENABLE();
35 | __HAL_RCC_GPIOB_CLK_ENABLE();
36 | __HAL_RCC_GPIOC_CLK_ENABLE();
37 |
38 | HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_SET);
39 | GPIO_InitStruct.Pin = LED1_Pin;
40 | GPIO_InitStruct.Mode = LED1_Mode;
41 | GPIO_InitStruct.Pull = GPIO_NOPULL;
42 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
43 | HAL_GPIO_Init(LED1_GPIO_Port, &GPIO_InitStruct);
44 |
45 | HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_SET);
46 | GPIO_InitStruct.Pin = LED2_Pin;
47 | GPIO_InitStruct.Mode = LED2_Mode;
48 | GPIO_InitStruct.Pull = GPIO_NOPULL;
49 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
50 | HAL_GPIO_Init(LED2_GPIO_Port, &GPIO_InitStruct);
51 | }
52 |
--------------------------------------------------------------------------------
/program/user/src/interrupts.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2019 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #include
28 | #include
29 | #include "hal_include.h"
30 |
31 | void NMI_Handler(void)
32 | {
33 | __asm__("BKPT");
34 | while (1);
35 | }
36 |
37 | void HardFault_Handler(void)
38 | {
39 | __asm__("BKPT");
40 | while (1);
41 | }
42 |
43 | void SysTick_Handler(void)
44 | {
45 | HAL_IncTick();
46 | HAL_SYSTICK_IRQHandler();
47 | }
48 |
49 | extern PCD_HandleTypeDef hpcd_USB_FS;
50 | void USB_Handler(void)
51 | {
52 | HAL_PCD_IRQHandler(&hpcd_USB_FS);
53 | }
54 |
55 | void Default_Handler()
56 | {
57 | __asm__("BKPT");
58 | while (1);
59 | }
60 |
61 | extern void Reset_Handler();
62 |
63 | typedef void(*pFunc)();
64 | extern uint32_t __StackTop;
65 |
66 | #if defined(STM32F0)
67 | __attribute__((used, section(".vectors")))
68 | const pFunc InterruptVectorTable[48] = {
69 | (pFunc)(&__StackTop), // initial stack pointer
70 | Reset_Handler, // reset handler
71 | NMI_Handler, // -14: NMI
72 | HardFault_Handler, // -13: HardFault
73 | 0, // -12: MemManage_Handler
74 | 0, // -11: BusFault_Handler
75 | 0, // -10: UsageFault_Handler
76 | 0, //
77 | 0, //
78 | 0, //
79 | 0, //
80 | 0, // -5: SVC_Handler
81 | 0, // -4: DebugMon_Handler
82 | 0, //
83 | 0, // -2: PendSV
84 | SysTick_Handler, // -1: SysTick
85 | // External Interrupts
86 | 0, // int 0: WWDG
87 | 0, // int 1: PVD
88 | 0, // int 2: RTC
89 | 0, // int 3: FLASH
90 | 0, // int 4: RCC_CRS
91 | 0, // int 5: EXTI0_1
92 | 0, // int 6: EXTI2_3
93 | 0, // int 7: EXTI4_15
94 | 0, // int 8: TSC
95 | 0, // int 9: DMA_CH1
96 | 0, // int 10: DMA_CH2_3
97 | 0, // int 11: DMA_CH4_5_6_7
98 | 0, // int 12: ADC_COMP
99 | 0, // int 13: TIM1_BRK_UP_TRG_COM
100 | 0, // int 14: TIM1_CC
101 | 0, // int 15: TIM2
102 | 0, // int 16: TIM3
103 | 0, // int 17: TIM6_DAC
104 | 0, // int 18: TIM7
105 | 0, // int 19: TIM14
106 | 0, // int 20: TIM15
107 | 0, // int 21: TIM16
108 | 0, // int 22: TIM17
109 | 0, // int 23: I2C1
110 | 0, // int 24: I2C2
111 | 0, // int 25: SPI1
112 | 0, // int 26: SPI2
113 | 0, // int 27: USART1
114 | 0, // int 28: USART2
115 | 0, // int 29: USART3_4
116 | 0, // int 30: CEC_CAN
117 | USB_Handler, // int 31: USB
118 | };
119 |
120 | #elif defined(STM32F4)
121 | __attribute__((used, section(".vectors")))
122 | const pFunc InterruptVectorTable[84] = {
123 | (pFunc)(&__StackTop), // initial stack pointer
124 | Reset_Handler, // reset handler
125 | NMI_Handler, // -14: NMI
126 | HardFault_Handler, // -13: HardFault
127 | 0, // -12: MemManage_Handler
128 | 0, // -11: BusFault_Handler
129 | 0, // -10: UsageFault_Handler
130 | 0, //
131 | 0, //
132 | 0, //
133 | 0, //
134 | 0, // -5: SVC_Handler
135 | 0, // -4: DebugMon_Handler
136 | 0, //
137 | 0, // -2: PendSV
138 | SysTick_Handler, // -1: SysTick
139 | // External Interrupts
140 | 0, // int 0: WWDG
141 | 0, // int 1: PVD
142 | 0, // int 2: tamper and timestamp, EXTI line
143 | 0, // int 3: RTC
144 | 0, // int 4: FLASH
145 | 0, // int 5: RCC
146 | 0, // int 6: EXTI Line 0
147 | 0, // int 7: EXTI Line 1
148 | 0, // int 8: EXTI Line 2
149 | 0, // int 9: EXTI Line 3
150 | 0, // int 10: EXTI Line 4
151 | 0, // int 11: DMA Stream 0
152 | 0, // int 12: DMA Stream 1
153 | 0, // int 13: DMA Stream 2
154 | 0, // int 14: DMA Stream 3
155 | 0, // int 15: DMA Stream 4
156 | 0, // int 16: DMA Stream 5
157 | 0, // int 17: DMA Stream 6
158 | 0, // int 18: ADCs
159 | 0, // int 19: CAN1 TX
160 | 0, // int 20: CAN1 RX0
161 | 0, // int 21: CAN1 RX1
162 | 0, // int 22: CAN1 SCE
163 | 0, // int 23: External Line [9:5]s
164 | 0, // int 24: TIM1 Break and TIM9
165 | 0, // int 25: TIM1 Update and TIM10
166 | 0, // int 26: TIM1 Trigger and Commutation and TIM11
167 | 0, // int 27: TIM1 Capture Compare
168 | 0, // int 28: TIM2
169 | 0, // int 29: TIM3
170 | 0, // int 30: TIM4
171 | 0, // int 31: I2C1 Event
172 | 0, // int 32: I2C1 Error
173 | 0, // int 33: I2C2 Event
174 | 0, // int 34: I2C2 Error
175 | 0, // int 35: SPI1
176 | 0, // int 36: SPI2
177 | 0, // int 36: USART1
178 | 0, // int 37: USART2
179 | 0, // int 38: USART3
180 | 0, // int 39: External Line [15:10]s
181 | 0, // int 40: RTC Alarm (A and B), EXTI Line
182 | 0, // int 41: USB OTG FS Wakeup, EXTI Line
183 | 0, // int 42: TIM8 Break and TIM12
184 | 0, // int 43: TIM8 Update and TIM13
185 | 0, // int 44: TIM8 Trigger and Commutation and TIM14
186 | 0, // int 45: TIM8 Capture Compare
187 | 0, // int 46: DMA1 Stream7
188 | 0, // int 47: FSMC
189 | 0, // int 48: SDIO
190 | 0, // int 49: TIM5
191 | 0, // int 50: SPI3
192 | 0, // int 51: UART4
193 | 0, // int 52: UART5
194 | 0, // int 53: TIM6 and DAC1&2 underrun errors
195 | 0, // int 54: TIM7
196 | 0, // int 55: DMA2 Stream 0
197 | 0, // int 56: DMA2 Stream 1
198 | 0, // int 57: DMA2 Stream 2
199 | 0, // int 58: DMA2 Stream 3
200 | 0, // int 59: DMA2 Stream 4
201 | 0, // int 60: Ethernet
202 | 0, // int 61: Ethernet Wakeup, EXTI Line
203 | 0, // int 62: CAN2 TX
204 | 0, // int 63: CAN2 RX0
205 | 0, // int 64: CAN2 RX1
206 | 0, // int 65: CAN2 SCE
207 | USB_Handler, // int 66: USB OTG FS
208 | // don't need to define any interrupts after this one
209 | };
210 | #endif
211 |
--------------------------------------------------------------------------------
/program/user/src/led.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #include "led.h"
28 | #include
29 | #include "hal_include.h"
30 |
31 | #define SEQ_ISPASSED(now, target) ((int32_t) ((now) - (target)) >= 0)
32 |
33 | void led_init(
34 | led_data_t *leds,
35 | void* led1_port, uint16_t led1_pin, bool led1_active_high,
36 | void* led2_port, uint16_t led2_pin, bool led2_active_high
37 | ) {
38 | memset(leds, 0, sizeof(led_data_t));
39 | leds->led_state[0].port = led1_port;
40 | leds->led_state[0].pin = led1_pin;
41 | leds->led_state[0].is_active_high = led1_active_high;
42 | leds->led_state[1].port = led2_port;
43 | leds->led_state[1].pin = led2_pin;
44 | leds->led_state[1].is_active_high = led2_active_high;
45 | }
46 |
47 | void led_set_mode(led_data_t *leds,led_mode_t mode)
48 | {
49 | leds->mode = mode;
50 | led_update(leds);
51 | }
52 |
53 | static void led_set(led_state_t *led, bool state)
54 | {
55 | if (!led->is_active_high) {
56 | state = !state;
57 | }
58 |
59 | HAL_GPIO_WritePin(led->port, led->pin, state ? GPIO_PIN_SET : GPIO_PIN_RESET);
60 | }
61 |
62 | static uint32_t led_set_sequence_step(led_data_t *leds, uint32_t step_num)
63 | {
64 | led_seq_step_t *step = &leds->sequence[step_num];
65 | leds->sequence_step = step_num;
66 | led_set(&leds->led_state[0], step->state & 0x01);
67 | led_set(&leds->led_state[1], step->state & 0x02);
68 | uint32_t delta = 10 * step->time_in_10ms;
69 | if (delta > INT32_MAX) {
70 | delta = INT32_MAX; //clamp
71 | }
72 | leds->t_sequence_next = HAL_GetTick() + delta;
73 | return delta;
74 | }
75 |
76 | void led_run_sequence(led_data_t *leds, led_seq_step_t *sequence, int32_t num_repeat)
77 | {
78 | leds->last_mode = leds->mode;
79 | leds->mode = led_mode_sequence;
80 | leds->sequence = sequence;
81 | leds->seq_num_repeat = num_repeat;
82 | led_set_sequence_step(leds, 0);
83 | led_update(leds);
84 | }
85 |
86 | void led_indicate_trx(led_data_t *leds, led_num_t num)
87 | {
88 | uint32_t now = HAL_GetTick();
89 | led_state_t *led = &leds->led_state[num];
90 |
91 | if ( SEQ_ISPASSED(now, led->on_until) &&
92 | SEQ_ISPASSED(now, led->off_until) ) {
93 | led->off_until = now + 30;
94 | led->on_until = now + 45;
95 | }
96 |
97 | led_update(leds);
98 | }
99 |
100 | static void led_update_normal_mode(led_state_t *led)
101 | {
102 | uint32_t now = HAL_GetTick();
103 | led_set(led, SEQ_ISPASSED(now, led->off_until));
104 | }
105 |
106 | static void led_update_sequence(led_data_t *leds)
107 | {
108 | if (leds->sequence == NULL) {
109 | return;
110 | }
111 |
112 | uint32_t now = HAL_GetTick();
113 | if (SEQ_ISPASSED(now, leds->t_sequence_next)) {
114 |
115 | uint32_t t = led_set_sequence_step(leds, ++leds->sequence_step);
116 |
117 | if (t > 0) { // the saga continues
118 |
119 | leds->t_sequence_next = now + t;
120 |
121 | } else { // end of sequence
122 |
123 | if (leds->seq_num_repeat != 0) {
124 |
125 | if (leds->seq_num_repeat > 0) {
126 | leds->seq_num_repeat--;
127 | }
128 |
129 | led_set_sequence_step(leds, 0);
130 |
131 | } else {
132 | leds->sequence = NULL;
133 | }
134 | }
135 | }
136 | }
137 |
138 | void led_update(led_data_t *leds)
139 | {
140 | switch (leds->mode) {
141 |
142 | case led_mode_off:
143 | led_set(&leds->led_state[0], false);
144 | led_set(&leds->led_state[1], false);
145 | break;
146 |
147 | case led_mode_normal:
148 | led_update_normal_mode(&leds->led_state[0]);
149 | led_update_normal_mode(&leds->led_state[1]);
150 | break;
151 |
152 | case led_mode_sequence:
153 | led_update_sequence(leds);
154 | break;
155 |
156 | default:
157 | led_set(&leds->led_state[0], false);
158 | led_set(&leds->led_state[1], true);
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/program/user/src/main.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #include
28 | #include "config.h"
29 | #include "hal_include.h"
30 | #include "usbd_def.h"
31 | #include "usbd_desc.h"
32 | #include "usbd_core.h"
33 | #include "usbd_gs_can.h"
34 | #include "gpio.h"
35 | #include "queue.h"
36 | #include "gs_usb.h"
37 | #include "can.h"
38 | #include "led.h"
39 | #include "dfu.h"
40 | #include "timer.h"
41 | #include "flash.h"
42 | #include "util.h"
43 |
44 | void SystemClock_Config(void);
45 | static bool send_to_host_or_enqueue(struct gs_host_frame *frame);
46 | static void send_to_host();
47 |
48 | can_data_t hCAN = {0};
49 | USBD_HandleTypeDef hUSB = {0};
50 | led_data_t hLED = {0};
51 |
52 | queue_t *q_frame_pool = NULL;
53 | queue_t *q_from_host = NULL;
54 | queue_t *q_to_host = NULL;
55 |
56 | uint32_t received_count = 0;
57 |
58 | int main(void) {
59 | uint32_t last_can_error_status = 0;
60 |
61 | HAL_Init();
62 | SystemClock_Config();
63 | flash_load();
64 | gpio_init();
65 | led_init(&hLED, LED1_GPIO_Port, LED1_Pin, LED1_Active_High, LED2_GPIO_Port, LED2_Pin, LED2_Active_High);
66 |
67 | /* nice wake-up pattern */
68 | for (uint8_t i = 0; i < 10; i++) {
69 | HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
70 | HAL_Delay(50);
71 | HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);
72 | }
73 |
74 | led_set_mode(&hLED, led_mode_off);
75 | timer_init();
76 |
77 | can_init(&hCAN, CAN_INTERFACE);
78 | can_disable(&hCAN);
79 |
80 | q_frame_pool = queue_create(CAN_QUEUE_SIZE);
81 | q_from_host = queue_create(CAN_QUEUE_SIZE);
82 | q_to_host = queue_create(CAN_QUEUE_SIZE);
83 | assert_basic(q_frame_pool && q_from_host && q_to_host);
84 |
85 | struct gs_host_frame *msgbuf = calloc(CAN_QUEUE_SIZE, sizeof(struct gs_host_frame));
86 | assert_basic(msgbuf);
87 |
88 | for (unsigned i = 0; i < CAN_QUEUE_SIZE; i++) {
89 | queue_push_back(q_frame_pool, &msgbuf[i]);
90 | }
91 |
92 | USBD_Init(&hUSB, (USBD_DescriptorsTypeDef *) &FS_Desc, DEVICE_FS);
93 | USBD_RegisterClass(&hUSB, &USBD_GS_CAN);
94 | USBD_GS_CAN_Init(&hUSB, q_frame_pool, q_from_host, &hLED);
95 | USBD_GS_CAN_SetChannel(&hUSB, 0, &hCAN);
96 | USBD_Start(&hUSB);
97 |
98 | while (1) {
99 | struct gs_host_frame *frame = queue_pop_front(q_from_host);
100 | if (frame != 0) { // send can message from host
101 | if (can_send(&hCAN, frame)) {
102 | // Echo sent frame back to host
103 | frame->flags = 0x0;
104 | frame->reserved = 0x0;
105 | frame->timestamp_us = timer_get();
106 | send_to_host_or_enqueue(frame);
107 |
108 | led_indicate_trx(&hLED, led_2);
109 | } else {
110 | queue_push_front(q_from_host, frame); // retry later
111 | }
112 | }
113 |
114 | if (USBD_GS_CAN_TxReady(&hUSB)) {
115 | send_to_host();
116 | }
117 |
118 | if (can_is_rx_pending(&hCAN)) {
119 | struct gs_host_frame *tx_frame = queue_pop_front(q_frame_pool);
120 | if (tx_frame != 0) {
121 | if (can_receive(&hCAN, tx_frame)) {
122 | received_count++;
123 |
124 | tx_frame->timestamp_us = timer_get();
125 | tx_frame->echo_id = 0xFFFFFFFF; // not a echo frame
126 | tx_frame->channel = 0;
127 | tx_frame->flags = 0;
128 | tx_frame->reserved = 0;
129 |
130 | send_to_host_or_enqueue(tx_frame);
131 | led_indicate_trx(&hLED, led_1);
132 | } else
133 | queue_push_back(q_frame_pool, tx_frame);
134 | }
135 | // If there are frames to receive, don't report any error frames. The
136 | // best we can localize the errors to is "after the last successfully
137 | // received frame", so wait until we get there. LEC will hold some error
138 | // to report even if multiple pass by.
139 | } else {
140 | uint32_t can_err = can_get_error_status(&hCAN);
141 | struct gs_host_frame *err_frame = queue_pop_front(q_frame_pool);
142 | if (err_frame != 0) {
143 | err_frame->timestamp_us = timer_get();
144 | if (can_parse_error_status(can_err, last_can_error_status, &hCAN, err_frame)) {
145 | send_to_host_or_enqueue(err_frame);
146 | last_can_error_status = can_err;
147 | } else
148 | queue_push_back(q_frame_pool, err_frame);
149 | }
150 | }
151 |
152 | led_update(&hLED);
153 |
154 | if (USBD_GS_CAN_DfuDetachRequested(&hUSB)) {
155 | dfu_run_bootloader();
156 | }
157 |
158 | }
159 | }
160 |
161 | void HAL_MspInit(void) {
162 | __HAL_RCC_SYSCFG_CLK_ENABLE();
163 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
164 | }
165 |
166 | void SystemClock_Config(void) {
167 | RCC_OscInitTypeDef RCC_OscInitStruct;
168 | RCC_ClkInitTypeDef RCC_ClkInitStruct;
169 |
170 | RCC_PeriphCLKInitTypeDef PeriphClkInit;
171 | RCC_CRSInitTypeDef RCC_CRSInitStruct;
172 |
173 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48;
174 | RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
175 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
176 | HAL_RCC_OscConfig(&RCC_OscInitStruct);
177 |
178 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1;
179 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI48;
180 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
181 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
182 | HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);
183 |
184 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
185 | PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
186 | HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
187 |
188 | __HAL_RCC_CRS_CLK_ENABLE();
189 | RCC_CRSInitStruct.Prescaler = RCC_CRS_SYNC_DIV1;
190 | RCC_CRSInitStruct.Source = RCC_CRS_SYNC_SOURCE_USB;
191 | RCC_CRSInitStruct.Polarity = RCC_CRS_SYNC_POLARITY_RISING;
192 | RCC_CRSInitStruct.ReloadValue = __HAL_RCC_CRS_RELOADVALUE_CALCULATE(48000000, 1000);
193 | RCC_CRSInitStruct.ErrorLimitValue = 34;
194 | RCC_CRSInitStruct.HSI48CalibrationValue = 32;
195 | HAL_RCCEx_CRSConfig(&RCC_CRSInitStruct);
196 |
197 | HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000);
198 | HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
199 |
200 | /* SysTick_IRQn interrupt configuration */
201 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
202 | }
203 |
204 | bool send_to_host_or_enqueue(struct gs_host_frame *frame) {
205 | queue_push_back(q_to_host, frame);
206 | return true;
207 | }
208 |
209 | void send_to_host() {
210 | struct gs_host_frame *frame = queue_pop_front(q_to_host);
211 |
212 | if (!frame)
213 | return;
214 |
215 | if (USBD_GS_CAN_SendFrame(&hUSB, frame) == USBD_OK)
216 | queue_push_back(q_frame_pool, frame);
217 | else
218 | queue_push_front(q_to_host, frame);
219 | }
220 |
221 |
--------------------------------------------------------------------------------
/program/user/src/queue.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #include
28 | #include
29 |
30 | queue_t *queue_create(unsigned max_elements){
31 | queue_t *q = calloc(1, sizeof(queue_t));
32 | q->buf = calloc(max_elements, sizeof(void*));
33 | q->max_elements = max_elements;
34 | return q;
35 | }
36 |
37 | void queue_destroy(queue_t *q)
38 | {
39 | free(q->buf);
40 | free(q);
41 | }
42 |
43 | unsigned queue_size(queue_t *q)
44 | {
45 | bool was_irq_enabled = disable_irq();
46 | unsigned retval = q->size;
47 | if (was_irq_enabled) enable_irq();
48 | return retval;
49 | }
50 |
51 | bool queue_is_empty(queue_t *q)
52 | {
53 | return queue_size(q)==0;
54 | }
55 |
56 | bool queue_push_back(queue_t *q, void *el)
57 | {
58 | bool retval = false;
59 | bool was_irq_enabled = disable_irq();
60 |
61 | if (q->size < q->max_elements) {
62 | unsigned pos = (q->first + q->size) % q->max_elements;
63 | q->buf[pos] = el;
64 | q->size += 1;
65 | retval = true;
66 | }
67 |
68 | if (was_irq_enabled) enable_irq();
69 | return retval;
70 | }
71 |
72 | bool queue_push_front(queue_t *q, void *el)
73 | {
74 | bool retval = false;
75 | bool was_irq_enabled = disable_irq();
76 | if (q->size < q->max_elements) {
77 | if (q->first==0) {
78 | q->first = q->max_elements - 1;
79 | } else {
80 | q->first = q->first - 1;
81 | }
82 | q->buf[q->first] = el;
83 | q->size += 1;
84 | retval = true;
85 | }
86 | if (was_irq_enabled) enable_irq();
87 | return retval;
88 | }
89 |
90 | void *queue_pop_front(queue_t *q)
91 | {
92 | bool was_irq_enabled = disable_irq();
93 | void *el = 0;
94 | if (q->size > 0) {
95 | el = q->buf[q->first];
96 | q->first = (q->first + 1) % q->max_elements;
97 | q->size -= 1;
98 | }
99 | if (was_irq_enabled) enable_irq();
100 | return el;
101 | }
102 |
103 | unsigned queue_size_i(queue_t *q)
104 | {
105 | return q->size;
106 | }
107 |
108 | bool queue_is_empty_i(queue_t *q)
109 | {
110 | return queue_size_i(q)==0;
111 | }
112 |
113 | bool queue_push_back_i(queue_t *q, void *el)
114 | {
115 | bool retval = false;
116 |
117 | if (q->size < q->max_elements) {
118 | unsigned pos = (q->first + q->size) % q->max_elements;
119 | q->buf[pos] = el;
120 | q->size += 1;
121 | retval = true;
122 | }
123 |
124 | return retval;
125 | }
126 |
127 | bool queue_push_front_i(queue_t *q, void *el)
128 | {
129 | bool retval = false;
130 | if (q->size < q->max_elements) {
131 | if (q->first==0) {
132 | q->first = q->max_elements - 1;
133 | } else {
134 | q->first = q->first - 1;
135 | }
136 | q->buf[q->first] = el;
137 | q->size += 1;
138 | retval = true;
139 | }
140 | return retval;
141 | }
142 |
143 | void *queue_pop_front_i(queue_t *q)
144 | {
145 | void *el = 0;
146 | if (q->size > 0) {
147 | el = q->buf[q->first];
148 | q->first = (q->first + 1) % q->max_elements;
149 | q->size -= 1;
150 | }
151 | return el;
152 | }
153 |
--------------------------------------------------------------------------------
/program/user/src/startup.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | typedef struct _copy_table_t
5 | {
6 | uint32_t const* src;
7 | uint32_t* dest;
8 | uint32_t wlen;
9 | } copy_table_t;
10 |
11 | typedef struct _zero_table_t
12 | {
13 | uint32_t* dest;
14 | uint32_t wlen;
15 | } zero_table_t;
16 |
17 | extern const copy_table_t __copy_table_start__;
18 | extern const copy_table_t __copy_table_end__;
19 | extern const zero_table_t __zero_table_start__;
20 | extern const zero_table_t __zero_table_end__;
21 |
22 | void __initialize_hardware_early();
23 | void _start() __attribute__((noreturn));
24 |
25 | void Reset_Handler()
26 | {
27 | __initialize_hardware_early();
28 |
29 | for (copy_table_t const* table = &__copy_table_start__; table < &__copy_table_end__; ++table)
30 | {
31 | for (size_t i=0; iwlen; ++i)
32 | {
33 | table->dest[i] = table->src[i];
34 | }
35 | }
36 |
37 | for (zero_table_t const* table = &__zero_table_start__; table < &__zero_table_end__; ++table)
38 | {
39 | for (size_t i=0; iwlen; ++i)
40 | {
41 | table->dest[i] = 0u;
42 | }
43 | }
44 |
45 | _start();
46 | }
47 |
48 |
49 | void _exit(int code)
50 | {
51 | (void) code;
52 | __asm__("BKPT");
53 | while (1);
54 | }
--------------------------------------------------------------------------------
/program/user/src/syscalls.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file syscalls.c
4 | * @author Auto-generated by STM32CubeIDE
5 | * @brief STM32CubeIDE Minimal System calls file
6 | *
7 | * For more information about which c-functions
8 | * need which of these lowlevel functions
9 | * please consult the Newlib libc-manual
10 | ******************************************************************************
11 | * @attention
12 | *
13 | * Copyright (c) 2020-2023 STMicroelectronics.
14 | * All rights reserved.
15 | *
16 | * This software is licensed under terms that can be found in the LICENSE file
17 | * in the root directory of this software component.
18 | * If no LICENSE file comes with this software, it is provided AS-IS.
19 | *
20 | ******************************************************************************
21 | */
22 |
23 | /* Includes */
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 |
33 | /* Variables */
34 | extern int __io_putchar(int ch) __attribute__((weak));
35 | extern int __io_getchar(void) __attribute__((weak));
36 |
37 | char *__env[1] = {0};
38 | char **environ = __env;
39 |
40 | /* Functions */
41 | void initialise_monitor_handles() {
42 | }
43 |
44 | int _getpid(void) {
45 | return 1;
46 | }
47 |
48 | int _kill(int pid, int sig) {
49 | (void) pid;
50 | (void) sig;
51 | errno = EINVAL;
52 | return -1;
53 | }
54 |
55 | __attribute__((weak)) int _read(int file, char *ptr, int len) {
56 | (void) file;
57 | int DataIdx;
58 |
59 | for (DataIdx = 0; DataIdx < len; DataIdx++) {
60 | *ptr++ = __io_getchar();
61 | }
62 |
63 | return len;
64 | }
65 |
66 | __attribute__((weak)) int _write(int file, char *ptr, int len) {
67 | (void) file;
68 | int DataIdx;
69 |
70 | for (DataIdx = 0; DataIdx < len; DataIdx++) {
71 | __io_putchar(*ptr++);
72 | }
73 | return len;
74 | }
75 |
76 | int _close(int file) {
77 | (void) file;
78 | return -1;
79 | }
80 |
81 | int _fstat(int file, struct stat *st) {
82 | (void) file;
83 | st->st_mode = S_IFCHR;
84 | return 0;
85 | }
86 |
87 | int _isatty(int file) {
88 | (void) file;
89 | return 1;
90 | }
91 |
92 | int _lseek(int file, int ptr, int dir) {
93 | (void) file;
94 | (void) ptr;
95 | (void) dir;
96 | return 0;
97 | }
98 |
99 | int _open(char *path, int flags, ...) {
100 | (void) path;
101 | (void) flags;
102 | /* Pretend like we always fail */
103 | return -1;
104 | }
105 |
106 | int _wait(int *status) {
107 | (void) status;
108 | errno = ECHILD;
109 | return -1;
110 | }
111 |
112 | int _unlink(char *name) {
113 | (void) name;
114 | errno = ENOENT;
115 | return -1;
116 | }
117 |
118 | int _times(struct tms *buf) {
119 | (void) buf;
120 | return -1;
121 | }
122 |
123 | int _stat(char *file, struct stat *st) {
124 | (void) file;
125 | st->st_mode = S_IFCHR;
126 | return 0;
127 | }
128 |
129 | int _link(char *old, char *new) {
130 | (void) old;
131 | (void) new;
132 | errno = EMLINK;
133 | return -1;
134 | }
135 |
136 | int _fork(void) {
137 | errno = EAGAIN;
138 | return -1;
139 | }
140 |
141 | int _execve(char *name, char **argv, char **env) {
142 | (void) name;
143 | (void) argv;
144 | (void) env;
145 | errno = ENOMEM;
146 | return -1;
147 | }
148 |
--------------------------------------------------------------------------------
/program/user/src/timer.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #include "timer.h"
28 | #include "hal_include.h"
29 |
30 | void timer_init()
31 | {
32 | __HAL_RCC_TIM2_CLK_ENABLE();
33 |
34 | TIM2->CR1 = 0;
35 | TIM2->CR2 = 0;
36 | TIM2->SMCR = 0;
37 | TIM2->DIER = 0;
38 | TIM2->CCMR1 = 0;
39 | TIM2->CCMR2 = 0;
40 | TIM2->CCER = 0;
41 | TIM2->PSC = 48-1; // run @48MHz/480 = 1MHz = 1us
42 | TIM2->ARR = 0xFFFFFFFF;
43 | TIM2->CR1 |= TIM_CR1_CEN;
44 | TIM2->EGR = TIM_EGR_UG;
45 | }
46 |
47 | uint32_t timer_get()
48 | {
49 | return TIM2->CNT;
50 | }
51 |
--------------------------------------------------------------------------------
/program/user/src/usbd_conf.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #include
28 | #include "usbd_core.h"
29 | #include "usbd_gs_can.h"
30 |
31 | PCD_HandleTypeDef hpcd_USB_FS;
32 |
33 | void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
34 | {
35 | if(hpcd->Instance==USB_INTERFACE) {
36 |
37 | #if defined(USB)
38 | __HAL_RCC_USB_CLK_ENABLE();
39 | #elif defined(USB_OTG_FS)
40 | __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
41 | #endif
42 | HAL_NVIC_SetPriority(USB_INTERRUPT, 1, 0);
43 | HAL_NVIC_EnableIRQ(USB_INTERRUPT);
44 | }
45 | }
46 |
47 | void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
48 | {
49 | if(hpcd->Instance==USB_INTERFACE) {
50 | #if defined(USB)
51 | __HAL_RCC_USB_CLK_DISABLE();
52 | #elif defined(USB_OTG_FS)
53 | __HAL_RCC_USB_OTG_FS_CLK_DISABLE();
54 | #endif
55 | HAL_NVIC_DisableIRQ(USB_INTERRUPT);
56 | }
57 | }
58 |
59 | void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
60 | {
61 | USBD_HandleTypeDef *pdev = (USBD_HandleTypeDef*)hpcd->pData;
62 | USBD_ParseSetupRequest((USBD_SetupReqTypedef*)&pdev->request, (uint8_t*)hpcd->Setup);
63 |
64 | bool request_was_handled = false;
65 |
66 | if ((pdev->request.bmRequest & 0x1F) == USB_REQ_RECIPIENT_DEVICE ) { // device request
67 | request_was_handled = USBD_GS_CAN_CustomDeviceRequest(pdev, &pdev->request);
68 | }
69 |
70 | if ((pdev->request.bmRequest & 0x1F) == USB_REQ_RECIPIENT_INTERFACE ) { // interface request
71 | request_was_handled = USBD_GS_CAN_CustomInterfaceRequest(pdev, &pdev->request);
72 | }
73 |
74 | if (!request_was_handled) {
75 | USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup);
76 | }
77 | }
78 |
79 | void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
80 | {
81 | USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff);
82 | }
83 |
84 | void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
85 | {
86 | USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff);
87 | }
88 |
89 | void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
90 | {
91 | USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData);
92 | }
93 |
94 | void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
95 | {
96 | USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, USBD_SPEED_FULL);
97 | USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData);
98 | }
99 |
100 | void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
101 | {
102 | USBD_GS_CAN_SuspendCallback((USBD_HandleTypeDef*)hpcd->pData);
103 | USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData);
104 | }
105 |
106 | void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd)
107 | {
108 | USBD_LL_Resume((USBD_HandleTypeDef*) hpcd->pData);
109 | USBD_GS_CAN_ResumeCallback((USBD_HandleTypeDef*)hpcd->pData);
110 | }
111 |
112 | USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev)
113 | {
114 | /* Init USB_IP */
115 | /* Link The driver to the stack */
116 | hpcd_USB_FS.pData = pdev;
117 | pdev->pData = &hpcd_USB_FS;
118 |
119 | hpcd_USB_FS.Instance = USB_INTERFACE;
120 | hpcd_USB_FS.Init.dev_endpoints = 5U;
121 | hpcd_USB_FS.Init.speed = PCD_SPEED_FULL;
122 | hpcd_USB_FS.Init.ep0_mps = EP_MPS_64;
123 | hpcd_USB_FS.Init.phy_itface = PCD_PHY_EMBEDDED;
124 | hpcd_USB_FS.Init.low_power_enable = DISABLE;
125 | hpcd_USB_FS.Init.lpm_enable = DISABLE;
126 | #if defined(STM32F4)
127 | hpcd_USB_FS.Init.dma_enable = DISABLE;
128 | hpcd_USB_FS.Init.Sof_enable = DISABLE;
129 | hpcd_USB_FS.Init.vbus_sensing_enable = DISABLE;
130 | hpcd_USB_FS.Init.use_dedicated_ep1 = DISABLE;
131 | #endif
132 | HAL_PCD_Init(&hpcd_USB_FS);
133 |
134 |
135 | /*
136 | * PMA layout
137 | * 0x00 - 0x17 (24 bytes) metadata?
138 | * 0x18 - 0x57 (64 bytes) EP0 OUT
139 | * 0x58 - 0x97 (64 bytes) EP0 IN
140 | * 0x98 - 0xD7 (64 bytes) EP1 IN
141 | * 0xD8 - 0x157 (128 bytes) EP1 OUT (buffer 1)
142 | * 0x158 - 0x1D7 (128 bytes) EP1 OUT (buffer 2)
143 | */
144 | #if defined(USB)
145 | HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x00 , PCD_SNG_BUF, 0x18);
146 | HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x80 , PCD_SNG_BUF, 0x58);
147 | HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x81 , PCD_SNG_BUF, 0x98);
148 | HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x02 , PCD_DBL_BUF, 0x00D80158);
149 | #elif defined(USB_OTG_FS)
150 | HAL_PCDEx_SetRxFiFo((PCD_HandleTypeDef*)pdev->pData, USB_RX_FIFO_SIZE); // shared RX FIFO
151 | HAL_PCDEx_SetTxFiFo((PCD_HandleTypeDef*)pdev->pData, 0U, 64U / 4U); // 0x80, 64 bytes (div by 4 for words)
152 | HAL_PCDEx_SetTxFiFo((PCD_HandleTypeDef*)pdev->pData, 1U, 64U / 4U); // 0x81, 64 bytes (div by 4 for words)
153 |
154 | #endif
155 |
156 | return USBD_OK;
157 | }
158 |
159 | USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev)
160 | {
161 | HAL_PCD_DeInit((PCD_HandleTypeDef*)pdev->pData);
162 | return USBD_OK;
163 | }
164 |
165 | USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev)
166 | {
167 | HAL_PCD_Start((PCD_HandleTypeDef*)pdev->pData);
168 | return USBD_OK;
169 | }
170 |
171 | USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev)
172 | {
173 | HAL_PCD_Stop((PCD_HandleTypeDef*) pdev->pData);
174 | return USBD_OK;
175 | }
176 |
177 | USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps)
178 | {
179 | HAL_PCD_EP_Open((PCD_HandleTypeDef*) pdev->pData, ep_addr, ep_mps, ep_type);
180 | return USBD_OK;
181 | }
182 |
183 | USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
184 | {
185 | HAL_PCD_EP_Close((PCD_HandleTypeDef*) pdev->pData, ep_addr);
186 | return USBD_OK;
187 | }
188 |
189 | USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
190 | {
191 | HAL_PCD_EP_Flush((PCD_HandleTypeDef*) pdev->pData, ep_addr);
192 | return USBD_OK;
193 | }
194 |
195 | USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
196 | {
197 | HAL_PCD_EP_SetStall((PCD_HandleTypeDef*) pdev->pData, ep_addr);
198 | return USBD_OK;
199 | }
200 |
201 | USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
202 | {
203 | HAL_PCD_EP_ClrStall((PCD_HandleTypeDef*) pdev->pData, ep_addr);
204 | return USBD_OK;
205 | }
206 |
207 | uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
208 | {
209 | PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData;
210 | return ((ep_addr & 0x80) == 0x80)
211 | ? hpcd->IN_ep[ep_addr & 0x7F].is_stall
212 | : hpcd->OUT_ep[ep_addr & 0x7F].is_stall;
213 | }
214 |
215 | USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr)
216 | {
217 | HAL_PCD_SetAddress((PCD_HandleTypeDef*) pdev->pData, dev_addr);
218 | return USBD_OK;
219 | }
220 |
221 | USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size)
222 | {
223 | HAL_PCD_EP_Transmit((PCD_HandleTypeDef*) pdev->pData, ep_addr, pbuf, size);
224 | return USBD_OK;
225 | }
226 |
227 | USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size)
228 | {
229 | HAL_PCD_EP_Receive((PCD_HandleTypeDef*) pdev->pData, ep_addr, pbuf, size);
230 | return USBD_OK;
231 | }
232 |
233 | uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
234 | {
235 | return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr);
236 | }
237 |
--------------------------------------------------------------------------------
/program/user/src/usbd_desc.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #include
28 | #include "usbd_core.h"
29 | #include "usbd_desc.h"
30 | #include "config.h"
31 | #include "util.h"
32 |
33 | uint8_t *USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
34 | uint8_t *USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
35 | uint8_t *USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
36 | uint8_t *USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
37 | uint8_t *USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
38 | uint8_t *USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
39 | uint8_t *USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
40 |
41 | #ifdef USB_SUPPORT_USER_STRING_DESC
42 | uint8_t *USBD_FS_USRStringDesc(USBD_SpeedTypeDef speed, uint8_t idx, uint16_t *length);
43 | #endif /* USB_SUPPORT_USER_STRING_DESC */
44 |
45 | const USBD_DescriptorsTypeDef FS_Desc = {
46 | USBD_FS_DeviceDescriptor,
47 | USBD_FS_LangIDStrDescriptor,
48 | USBD_FS_ManufacturerStrDescriptor,
49 | USBD_FS_ProductStrDescriptor,
50 | USBD_FS_SerialStrDescriptor,
51 | USBD_FS_ConfigStrDescriptor,
52 | USBD_FS_InterfaceStrDescriptor,
53 | };
54 |
55 | __ALIGN_BEGIN uint8_t USBD_DescBuf[USBD_DESC_BUF_SIZE] __ALIGN_END;
56 |
57 | /* USB_DeviceDescriptor */
58 | static const uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] = {
59 | 0x12, /* bLength */
60 | USB_DESC_TYPE_DEVICE, /* bDescriptorType */
61 | 0x00, /* bcdUSB */
62 | 0x02,
63 | 0x00, /* bDeviceClass */
64 | 0x00, /* bDeviceSubClass */
65 | 0x00, /* bDeviceProtocol */
66 | USB_MAX_EP0_SIZE, /* bMaxPacketSize */
67 | LOBYTE(USBD_VID), /* idVendor */
68 | HIBYTE(USBD_VID),
69 | LOBYTE(USBD_PID_FS), /* idProduct */
70 | HIBYTE(USBD_PID_FS),
71 | 0x00, /* bcdDevice rel. 0.00 */
72 | 0x00,
73 | USBD_IDX_MFC_STR, /* Index of manufacturer string */
74 | USBD_IDX_PRODUCT_STR, /* Index of product string */
75 | USBD_IDX_SERIAL_STR, /* Index of serial number string */
76 | USBD_MAX_NUM_CONFIGURATION /* bNumConfigurations */
77 | } ;
78 |
79 | /* USB Standard Device Descriptor */
80 | static const uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] =
81 | {
82 | USB_LEN_LANGID_STR_DESC,
83 | USB_DESC_TYPE_STRING,
84 | LOBYTE(USBD_LANGID_STRING),
85 | HIBYTE(USBD_LANGID_STRING),
86 | };
87 |
88 | uint8_t *USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
89 | {
90 | UNUSED(speed);
91 | *length = sizeof(USBD_FS_DeviceDesc);
92 | memcpy(USBD_DescBuf, USBD_FS_DeviceDesc, sizeof(USBD_FS_DeviceDesc));
93 | return USBD_DescBuf;
94 | }
95 |
96 | uint8_t *USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
97 | {
98 | UNUSED(speed);
99 | *length = sizeof(USBD_LangIDDesc);
100 | memcpy(USBD_DescBuf, USBD_LangIDDesc, sizeof(USBD_LangIDDesc));
101 | return USBD_DescBuf;
102 | }
103 |
104 | uint8_t *USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
105 | {
106 | UNUSED(speed);
107 | USBD_GetString(USBD_PRODUCT_STRING_FS, USBD_DescBuf, length);
108 | return USBD_DescBuf;
109 | }
110 |
111 | uint8_t *USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
112 | {
113 | UNUSED(speed);
114 | USBD_GetString (USBD_MANUFACTURER_STRING, USBD_DescBuf, length);
115 | return USBD_DescBuf;
116 | }
117 |
118 | uint8_t *USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
119 | {
120 | char buf[25];
121 |
122 | UNUSED(speed);
123 |
124 | hex32(buf , *(uint32_t*)(UID_BASE ));
125 | hex32(buf + 8, *(uint32_t*)(UID_BASE + 4));
126 | hex32(buf + 16, *(uint32_t*)(UID_BASE + 8));
127 |
128 | USBD_GetString((uint8_t*)buf, USBD_DescBuf, length);
129 | return USBD_DescBuf;
130 | }
131 |
132 | uint8_t *USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
133 | {
134 | UNUSED(speed);
135 | USBD_GetString(USBD_CONFIGURATION_STRING_FS, USBD_DescBuf, length);
136 | return USBD_DescBuf;
137 | }
138 |
139 | uint8_t *USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
140 | {
141 | UNUSED(speed);
142 | USBD_GetString(USBD_INTERFACE_STRING_FS, USBD_DescBuf, length);
143 | return USBD_DescBuf;
144 | }
145 |
--------------------------------------------------------------------------------
/program/user/src/util.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | The MIT License (MIT)
4 |
5 | Copyright (c) 2016 Hubert Denkmair
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
25 | */
26 |
27 | #include
28 | #include
29 |
30 | void hex32(char *out, uint32_t val)
31 | {
32 | char *p = out + 8;
33 |
34 | *p-- = 0;
35 |
36 | while (p >= out) {
37 | uint8_t nybble = val & 0x0F;
38 |
39 | if (nybble < 10)
40 | *p = '0' + nybble;
41 | else
42 | *p = 'A' + nybble - 10;
43 |
44 | val >>= 4;
45 | p--;
46 | }
47 | }
48 |
49 | void assert_failed(void) {
50 | /* for now, just halt and trigger debugger (if attached) */
51 | __BKPT(0);
52 | }
53 |
--------------------------------------------------------------------------------