├── .github └── workflows │ └── build.yml ├── .gitignore ├── 01_canSniffer_Arduino ├── MCP2515.cpp ├── MCP2515.h └── canSniffer │ └── canSniffer.ino ├── 02_canSniffer_GUI ├── FileLoader.py ├── HideOldPackets.py ├── SerialReader.py ├── SerialWriter.py ├── canSniffer.ui ├── canSniffer_ui.py ├── main.py ├── main.spec ├── requirements.txt ├── save │ ├── decodedPackets.csv │ └── labelDict.csv └── ui_converter.py ├── 03_canSniffer_hw ├── board1 │ ├── canDrive_hw_board1_v2.PcbDoc │ ├── canDrive_hw_board1_v2.PrjPcb │ ├── canDrive_hw_board1_v2.PrjPcbStructure │ ├── canDrive_hw_board1_v2.SchDoc │ └── canDrive_hw_board1_v2.pdf ├── board2 │ ├── canDrive_hw_board2_v2.PcbDoc │ ├── canDrive_hw_board2_v2.PrjPcb │ ├── canDrive_hw_board2_v2.PrjPcbStructure │ ├── canDrive_hw_board2_v2.SchDoc │ └── canDrive_hw_board2_v2.pdf └── common │ ├── canDrive_comp_pcb_lib.PcbLib │ └── canDrive_comp_sch_lib.SchLib ├── 04_canSniffer_FW └── board1_STM │ ├── .cproject │ ├── .mxproject │ ├── .project │ ├── Application │ ├── dc_ble.c │ ├── dc_ble.h │ ├── dc_buzzer.c │ ├── dc_buzzer.h │ ├── dc_can.c │ ├── dc_can.h │ ├── dc_can_defines.h │ ├── dc_controller.c │ ├── dc_controller.h │ ├── dc_forwarder_module.c │ ├── dc_forwarder_module.h │ ├── dc_infocollector_module.c │ ├── dc_infocollector_module.h │ ├── dc_main.c │ ├── dc_main.h │ ├── dc_packet_processor.c │ ├── dc_packet_processor.h │ ├── dc_transmitter_module.c │ ├── dc_transmitter_module.h │ ├── dc_usb.c │ ├── dc_usb.h │ ├── dc_wifi.c │ ├── dc_wifi.h │ ├── dc_wifi_packet_descriptor.h │ ├── printf-stdarg.c │ └── printf-stdarg.h │ ├── Core │ ├── Inc │ │ ├── main.h │ │ ├── stm32f4xx_hal_conf.h │ │ └── stm32f4xx_it.h │ └── Src │ │ ├── main.c │ │ ├── stm32f4xx_hal_msp.c │ │ ├── stm32f4xx_hal_timebase_tim.c │ │ ├── stm32f4xx_it.c │ │ ├── syscalls.c │ │ └── system_stm32f4xx.c │ ├── Drivers │ ├── CMSIS │ │ ├── Device │ │ │ └── ST │ │ │ │ └── STM32F4xx │ │ │ │ ├── Include │ │ │ │ ├── stm32f413xx.h │ │ │ │ ├── stm32f4xx.h │ │ │ │ └── system_stm32f4xx.h │ │ │ │ └── LICENSE.txt │ │ ├── Include │ │ │ ├── cmsis_armcc.h │ │ │ ├── cmsis_armclang.h │ │ │ ├── cmsis_compiler.h │ │ │ ├── cmsis_gcc.h │ │ │ ├── cmsis_iccarm.h │ │ │ ├── cmsis_version.h │ │ │ ├── core_armv8mbl.h │ │ │ ├── core_armv8mml.h │ │ │ ├── core_cm0.h │ │ │ ├── core_cm0plus.h │ │ │ ├── core_cm1.h │ │ │ ├── core_cm23.h │ │ │ ├── core_cm3.h │ │ │ ├── core_cm33.h │ │ │ ├── core_cm4.h │ │ │ ├── core_cm7.h │ │ │ ├── core_sc000.h │ │ │ ├── core_sc300.h │ │ │ ├── mpu_armv7.h │ │ │ ├── mpu_armv8.h │ │ │ └── tz_context.h │ │ └── LICENSE.txt │ └── STM32F4xx_HAL_Driver │ │ ├── Inc │ │ ├── Legacy │ │ │ └── stm32_hal_legacy.h │ │ ├── stm32f4xx_hal.h │ │ ├── stm32f4xx_hal_adc.h │ │ ├── stm32f4xx_hal_adc_ex.h │ │ ├── stm32f4xx_hal_can.h │ │ ├── stm32f4xx_hal_cortex.h │ │ ├── stm32f4xx_hal_def.h │ │ ├── stm32f4xx_hal_dma.h │ │ ├── stm32f4xx_hal_dma_ex.h │ │ ├── stm32f4xx_hal_exti.h │ │ ├── stm32f4xx_hal_flash.h │ │ ├── stm32f4xx_hal_flash_ex.h │ │ ├── stm32f4xx_hal_flash_ramfunc.h │ │ ├── stm32f4xx_hal_gpio.h │ │ ├── stm32f4xx_hal_gpio_ex.h │ │ ├── stm32f4xx_hal_pcd.h │ │ ├── stm32f4xx_hal_pcd_ex.h │ │ ├── stm32f4xx_hal_pwr.h │ │ ├── stm32f4xx_hal_pwr_ex.h │ │ ├── stm32f4xx_hal_rcc.h │ │ ├── stm32f4xx_hal_rcc_ex.h │ │ ├── stm32f4xx_hal_rtc.h │ │ ├── stm32f4xx_hal_rtc_ex.h │ │ ├── stm32f4xx_hal_tim.h │ │ ├── stm32f4xx_hal_tim_ex.h │ │ ├── stm32f4xx_hal_uart.h │ │ ├── stm32f4xx_ll_adc.h │ │ ├── stm32f4xx_ll_bus.h │ │ ├── stm32f4xx_ll_cortex.h │ │ ├── stm32f4xx_ll_dma.h │ │ ├── stm32f4xx_ll_exti.h │ │ ├── stm32f4xx_ll_gpio.h │ │ ├── stm32f4xx_ll_pwr.h │ │ ├── stm32f4xx_ll_rcc.h │ │ ├── stm32f4xx_ll_rtc.h │ │ ├── stm32f4xx_ll_system.h │ │ ├── stm32f4xx_ll_tim.h │ │ ├── stm32f4xx_ll_usart.h │ │ ├── stm32f4xx_ll_usb.h │ │ └── stm32f4xx_ll_utils.h │ │ ├── LICENSE.txt │ │ └── Src │ │ ├── stm32f4xx_hal.c │ │ ├── stm32f4xx_hal_adc.c │ │ ├── stm32f4xx_hal_adc_ex.c │ │ ├── stm32f4xx_hal_can.c │ │ ├── stm32f4xx_hal_cortex.c │ │ ├── stm32f4xx_hal_dma.c │ │ ├── stm32f4xx_hal_dma_ex.c │ │ ├── stm32f4xx_hal_exti.c │ │ ├── stm32f4xx_hal_flash.c │ │ ├── stm32f4xx_hal_flash_ex.c │ │ ├── stm32f4xx_hal_flash_ramfunc.c │ │ ├── stm32f4xx_hal_gpio.c │ │ ├── stm32f4xx_hal_pcd.c │ │ ├── stm32f4xx_hal_pcd_ex.c │ │ ├── stm32f4xx_hal_pwr.c │ │ ├── stm32f4xx_hal_pwr_ex.c │ │ ├── stm32f4xx_hal_rcc.c │ │ ├── stm32f4xx_hal_rcc_ex.c │ │ ├── stm32f4xx_hal_rtc.c │ │ ├── stm32f4xx_hal_rtc_ex.c │ │ ├── stm32f4xx_hal_tim.c │ │ ├── stm32f4xx_hal_tim_ex.c │ │ ├── stm32f4xx_hal_uart.c │ │ ├── stm32f4xx_ll_adc.c │ │ └── stm32f4xx_ll_usb.c │ ├── Middlewares │ └── ST │ │ └── STM32_USB_Device_Library │ │ ├── Class │ │ └── CDC │ │ │ ├── Inc │ │ │ └── usbd_cdc.h │ │ │ └── Src │ │ │ └── usbd_cdc.c │ │ ├── Core │ │ ├── Inc │ │ │ ├── usbd_core.h │ │ │ ├── usbd_ctlreq.h │ │ │ ├── usbd_def.h │ │ │ └── usbd_ioreq.h │ │ └── Src │ │ │ ├── usbd_core.c │ │ │ ├── usbd_ctlreq.c │ │ │ └── usbd_ioreq.c │ │ └── LICENSE.txt │ ├── STM32F413RG_FLASH.ld │ ├── USB_DEVICE │ ├── App │ │ ├── usb_device.c │ │ ├── usb_device.h │ │ ├── usbd_cdc_if.c │ │ ├── usbd_cdc_if.h │ │ ├── usbd_desc.c │ │ └── usbd_desc.h │ └── Target │ │ ├── usbd_conf.c │ │ └── usbd_conf.h │ ├── dipCAN.elf.launch │ ├── dipCAN.ioc │ ├── freeRTOS │ ├── croutine.c │ ├── event_groups.c │ ├── include │ │ ├── FreeRTOS.h │ │ ├── FreeRTOSConfig.h │ │ ├── StackMacros.h │ │ ├── croutine.h │ │ ├── deprecated_definitions.h │ │ ├── event_groups.h │ │ ├── list.h │ │ ├── message_buffer.h │ │ ├── mpu_prototypes.h │ │ ├── mpu_wrappers.h │ │ ├── portable.h │ │ ├── projdefs.h │ │ ├── queue.h │ │ ├── semphr.h │ │ ├── stack_macros.h │ │ ├── stdint.readme │ │ ├── stream_buffer.h │ │ ├── task.h │ │ └── timers.h │ ├── list.c │ ├── portable │ │ ├── GCC │ │ │ └── ARM_CM4F │ │ │ │ ├── port.c │ │ │ │ └── portmacro.h │ │ └── MemMang │ │ │ ├── ReadMe.url │ │ │ └── heap_4.c │ ├── queue.c │ ├── readme.txt │ ├── stream_buffer.c │ ├── tasks.c │ └── timers.c │ ├── startup │ └── startup_stm32f413xx.s │ └── syscalls.c ├── LICENSE └── README.md /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build GUI Application 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*.*.*' 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - name: Get Tag 14 | id: vars 15 | run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} 16 | - name: Build Application 17 | uses: JackMcKew/pyinstaller-action-windows@main 18 | with: 19 | path: 02_canSniffer_GUI 20 | spec: main.spec 21 | - name: Rename Application 22 | run: mv 02_canSniffer_GUI/dist/windows/main.exe 02_canSniffer_GUI/dist/windows/canDrive-${{ steps.vars.outputs.tag }}.exe 23 | - name: Release 24 | uses: softprops/action-gh-release@v1 25 | with: 26 | name: canDrive-${{ steps.vars.outputs.tag }}-windows 27 | files: 02_canSniffer_GUI/dist/windows/canDrive-${{ steps.vars.outputs.tag }}.exe 28 | env: 29 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /02_canSniffer_GUI/venv 2 | /02_canSniffer_GUI/.idea 3 | /02_canSniffer_GUI/__pycache__ 4 | /02_canSniffer_GUI/build 5 | /02_canSniffer_GUI/dist 6 | /03_canSniffer_hw/board1/History 7 | /03_canSniffer_hw/board2/History 8 | -------------------------------------------------------------------------------- /01_canSniffer_Arduino/MCP2515.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Sandeep Mistry. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #ifndef ARDUINO_ARCH_ESP32 5 | 6 | #ifndef MCP2515_H 7 | #define MCP2515_H 8 | 9 | #include 10 | 11 | #include "CANController.h" 12 | 13 | #define MCP2515_DEFAULT_CLOCK_FREQUENCY 8e6 14 | 15 | #if defined(ARDUINO_ARCH_SAMD) && defined(PIN_SPI_MISO) && defined(PIN_SPI_MOSI) && defined(PIN_SPI_SCK) && (PIN_SPI_MISO == 10) && (PIN_SPI_MOSI == 8) && (PIN_SPI_SCK == 9) 16 | // Arduino MKR board: MKR CAN shield CS is pin 3, INT is pin 7 17 | #define MCP2515_DEFAULT_CS_PIN 3 18 | #define MCP2515_DEFAULT_INT_PIN 7 19 | #else 20 | #define MCP2515_DEFAULT_CS_PIN 10 21 | #define MCP2515_DEFAULT_INT_PIN 2 22 | #endif 23 | 24 | class MCP2515Class : public CANControllerClass { 25 | 26 | public: 27 | MCP2515Class(); 28 | virtual ~MCP2515Class(); 29 | 30 | virtual int begin(long baudRate); 31 | virtual void end(); 32 | 33 | virtual int endPacket(); 34 | 35 | virtual int parsePacket(); 36 | 37 | virtual void onReceive(void(*callback)(int)); 38 | 39 | using CANControllerClass::filter; 40 | virtual int filter(int id, int mask); 41 | using CANControllerClass::filterExtended; 42 | virtual int filterExtended(long id, long mask); 43 | 44 | virtual int observe(); 45 | virtual int loopback(); 46 | virtual int sleep(); 47 | virtual int wakeup(); 48 | 49 | void setPins(int cs = MCP2515_DEFAULT_CS_PIN, int irq = MCP2515_DEFAULT_INT_PIN); 50 | void setSPIFrequency(uint32_t frequency); 51 | void setClockFrequency(long clockFrequency); 52 | 53 | void dumpRegisters(Stream& out); 54 | 55 | private: 56 | void reset(); 57 | 58 | void handleInterrupt(); 59 | 60 | uint8_t readRegister(uint8_t address); 61 | void modifyRegister(uint8_t address, uint8_t mask, uint8_t value); 62 | void writeRegister(uint8_t address, uint8_t value); 63 | 64 | static void onInterrupt(); 65 | 66 | private: 67 | SPISettings _spiSettings; 68 | int _csPin; 69 | int _intPin; 70 | long _clockFrequency; 71 | }; 72 | 73 | extern MCP2515Class CAN; 74 | 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /01_canSniffer_Arduino/canSniffer/canSniffer.ino: -------------------------------------------------------------------------------- 1 | // Developer: 2 | // Adam Varga, 2020, All rights reserved. 3 | // Licence: 4 | // Licenced under the MIT licence. See LICENCE file in the project root. 5 | // Usage of this code: 6 | // This code creates the interface between the car 7 | // and the canSniffer_GUI application. If the RANDOM_CAN 8 | // define is set to 1, this code is generating random 9 | // CAN packets in order to test the higher level code. 10 | // The received packets will be echoed back. If the 11 | // RANDOM_CAN define is set to 0, the CAN_SPEED define 12 | // has to match the speed of the desired CAN channel in 13 | // order to receive and transfer from and to the CAN bus. 14 | // Serial speed is 250000baud <- might need to be increased. 15 | // Required arduino packages: 16 | // - CAN by Sandeep Mistry (https://github.com/sandeepmistry/arduino-CAN) 17 | // Required modifications: 18 | // - MCP2515.h: 16e6 clock frequency reduced to 8e6 (depending on MCP2515 clock) 19 | // - MCP2515.cpp: extend CNF_MAPPER with your desired CAN speeds 20 | //------------------------------------------------------------------------------ 21 | #include 22 | //------------------------------------------------------------------------------ 23 | // Settings 24 | #define RANDOM_CAN 1 25 | #define CAN_SPEED (500E3) //LOW=33E3, MID=95E3, HIGH=500E3 (for Vectra) 26 | //------------------------------------------------------------------------------ 27 | // Inits, globals 28 | typedef struct { 29 | long id; 30 | byte rtr; 31 | byte ide; 32 | byte dlc; 33 | byte dataArray[20]; 34 | } packet_t; 35 | 36 | const char SEPARATOR = ','; 37 | const char TERMINATOR = '\n'; 38 | const char RXBUF_LEN = 100; 39 | //------------------------------------------------------------------------------ 40 | // Printing a packet to serial 41 | void printHex(long num) { 42 | if ( num < 0x10 ){ Serial.print("0"); } 43 | Serial.print(num, HEX); 44 | } 45 | 46 | void printPacket(packet_t * packet) { 47 | // packet format (hex string): [ID],[RTR],[IDE],[DATABYTES 0..8B]\n 48 | // example: 014A,00,00,1A002B003C004D\n 49 | printHex(packet->id); 50 | Serial.print(SEPARATOR); 51 | printHex(packet->rtr); 52 | Serial.print(SEPARATOR); 53 | printHex(packet->ide); 54 | Serial.print(SEPARATOR); 55 | // DLC is determinded by number of data bytes, format: [00] 56 | for (int i = 0; i < packet->dlc; i++) { 57 | printHex(packet->dataArray[i]); 58 | } 59 | Serial.print(TERMINATOR); 60 | } 61 | //------------------------------------------------------------------------------ 62 | // CAN packet simulator 63 | void CANsimulate(void) { 64 | packet_t txPacket; 65 | 66 | long sampleIdList[] = {0x110, 0x18DAF111, 0x23A, 0x257, 0x412F1A1, 0x601, 0x18EA0C11}; 67 | int idIndex = random (sizeof(sampleIdList) / sizeof(sampleIdList[0])); 68 | int sampleData[] = {0xA, 0x1B, 0x2C, 0x3D, 0x4E, 0x5F, 0xA0, 0xB1}; 69 | 70 | txPacket.id = sampleIdList[idIndex]; 71 | txPacket.ide = txPacket.id > 0x7FF ? 1 : 0; 72 | txPacket.rtr = 0; //random(2); 73 | txPacket.dlc = random(1, 9); 74 | 75 | for (int i = 0; i < txPacket.dlc ; i++) { 76 | int changeByte = random(4); 77 | if (changeByte == 0) { 78 | sampleData[i] = random(256); 79 | } 80 | txPacket.dataArray[i] = sampleData[i]; 81 | } 82 | 83 | printPacket(&txPacket); 84 | } 85 | //------------------------------------------------------------------------------ 86 | // CAN RX, TX 87 | void onCANReceive(int packetSize) { 88 | // received a CAN packet 89 | packet_t rxPacket; 90 | rxPacket.id = CAN.packetId(); 91 | rxPacket.rtr = CAN.packetRtr() ? 1 : 0; 92 | rxPacket.ide = CAN.packetExtended() ? 1 : 0; 93 | rxPacket.dlc = CAN.packetDlc(); 94 | byte i = 0; 95 | while (CAN.available()) { 96 | rxPacket.dataArray[i++] = CAN.read(); 97 | if (i >= (sizeof(rxPacket.dataArray) / (sizeof(rxPacket.dataArray[0])))) { 98 | break; 99 | } 100 | } 101 | printPacket(&rxPacket); 102 | } 103 | 104 | void sendPacketToCan(packet_t * packet) { 105 | for (int retries = 10; retries > 0; retries--) { 106 | bool rtr = packet->rtr ? true : false; 107 | if (packet->ide){ 108 | CAN.beginExtendedPacket(packet->id, packet->dlc, rtr); 109 | } else { 110 | CAN.beginPacket(packet->id, packet->dlc, rtr); 111 | } 112 | CAN.write(packet->dataArray, packet->dlc); 113 | if (CAN.endPacket()) { 114 | // success 115 | break; 116 | } else if (retries <= 1) { 117 | return; 118 | } 119 | } 120 | } 121 | //------------------------------------------------------------------------------ 122 | // Serial parser 123 | char getNum(char c) { 124 | if (c >= '0' && c <= '9') { return c - '0'; } 125 | if (c >= 'a' && c <= 'f') { return c - 'a' + 10; } 126 | if (c >= 'A' && c <= 'F') { return c - 'A' + 10; } 127 | return 0; 128 | } 129 | 130 | char * strToHex(char * str, byte * hexArray, byte * len) { 131 | byte *ptr = hexArray; 132 | char * idx; 133 | for (idx = str ; *idx != SEPARATOR && *idx != TERMINATOR; ++idx, ++ptr ) { 134 | *ptr = (getNum( *idx++ ) << 4) + getNum( *idx ); 135 | } 136 | *len = ptr - hexArray; 137 | return idx; 138 | } 139 | 140 | void rxParse(char * buf, int len) { 141 | packet_t rxPacket; 142 | char * ptr = buf; 143 | // All elements have to have leading zero! 144 | 145 | // ID 146 | byte idTempArray[8], tempLen; 147 | ptr = strToHex(ptr, idTempArray, &tempLen); 148 | rxPacket.id = 0; 149 | for (int i = 0; i < tempLen; i++) { 150 | rxPacket.id |= (long)idTempArray[i] << ((tempLen - i - 1) * 8); 151 | } 152 | 153 | // RTR 154 | ptr = strToHex(ptr + 1, &rxPacket.rtr, &tempLen); 155 | 156 | // IDE 157 | ptr = strToHex(ptr + 1, &rxPacket.ide, &tempLen); 158 | 159 | // DATA 160 | ptr = strToHex(ptr + 1, rxPacket.dataArray, &rxPacket.dlc); 161 | 162 | #if RANDOM_CAN == 1 163 | // echo back 164 | printPacket(&rxPacket); 165 | #else 166 | sendPacketToCan(&rxPacket); 167 | #endif 168 | } 169 | 170 | void RXcallback(void) { 171 | static int rxPtr = 0; 172 | static char rxBuf[RXBUF_LEN]; 173 | 174 | while (Serial.available() > 0) { 175 | if (rxPtr >= RXBUF_LEN) { 176 | rxPtr = 0; 177 | } 178 | char c = Serial.read(); 179 | rxBuf[rxPtr++] = c; 180 | if (c == TERMINATOR) { 181 | rxParse(rxBuf, rxPtr); 182 | rxPtr = 0; 183 | } 184 | } 185 | } 186 | 187 | //------------------------------------------------------------------------------ 188 | // Setup 189 | void setup() { 190 | Serial.begin(250000); 191 | while (!Serial) { 192 | ; // wait for serial port to connect. Needed for native USB port only 193 | } 194 | 195 | #if RANDOM_CAN == 1 196 | randomSeed(12345); 197 | Serial.println("randomCAN Started"); 198 | #else 199 | if (!CAN.begin(CAN_SPEED)) { 200 | Serial.println("Starting CAN failed!"); 201 | while (1); 202 | } 203 | // register the receive callback 204 | CAN.onReceive(onCANReceive); 205 | Serial.println("CAN RX TX Started"); 206 | #endif 207 | } 208 | //------------------------------------------------------------------------------ 209 | // Main 210 | void loop() { 211 | RXcallback(); 212 | #if RANDOM_CAN == 1 213 | CANsimulate(); 214 | delay(100); 215 | #endif 216 | } 217 | -------------------------------------------------------------------------------- /02_canSniffer_GUI/FileLoader.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtCore import QThread, pyqtSignal 2 | import csv 3 | 4 | 5 | class FileLoaderThread(QThread): 6 | newRowSignal = pyqtSignal(list) 7 | loadingFinishedSignal = pyqtSignal() 8 | path = None 9 | delayMs = 0 10 | 11 | def __init__(self): 12 | super(FileLoaderThread, self).__init__() 13 | self.isRunning = False 14 | 15 | def enable(self, path, delayMs): 16 | self.isRunning = True 17 | self.path = path 18 | self.delayMs = delayMs 19 | 20 | def stop(self): 21 | self.isRunning = False 22 | self.path = None 23 | 24 | def run(self): 25 | while self.isRunning: 26 | if self.path is not None: 27 | try: 28 | with open(str(self.path), 'r') as stream: 29 | for rowData in csv.reader(stream): 30 | if not self.isRunning: 31 | break 32 | self.newRowSignal.emit(rowData) 33 | self.msleep(self.delayMs) 34 | self.loadingFinishedSignal.emit() 35 | except OSError: 36 | print("file not found: " + self.path) 37 | self.stop() 38 | -------------------------------------------------------------------------------- /02_canSniffer_GUI/HideOldPackets.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtCore import QThread, pyqtSignal 2 | 3 | 4 | class HideOldPacketsThread(QThread): 5 | hideOldPacketsSignal = pyqtSignal() 6 | 7 | def __init__(self): 8 | super(HideOldPacketsThread, self).__init__() 9 | self.isRunning = False 10 | self.period = 5 11 | 12 | def stop(self): 13 | self.isRunning = False 14 | 15 | def enable(self, _period): 16 | self.isRunning = True 17 | self.period = _period 18 | 19 | def run(self): 20 | while self.isRunning: 21 | self.sleep(self.period) 22 | self.hideOldPacketsSignal.emit() 23 | -------------------------------------------------------------------------------- /02_canSniffer_GUI/SerialReader.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtCore import QThread, pyqtSignal 2 | import serial 3 | import time 4 | 5 | 6 | class SerialReaderThread(QThread): 7 | receivedPacketSignal = pyqtSignal(str, float) 8 | buf = bytearray() 9 | 10 | def __init__(self, serial=None): 11 | super(SerialReaderThread, self).__init__() 12 | self.serial = serial 13 | self.isRunning = False 14 | 15 | def stop(self): 16 | self.isRunning = False 17 | 18 | def run(self): 19 | self.isRunning = True 20 | while self.isRunning: 21 | # Because of the high transmission speed, we shouldn't assume that the internal serial buffer 22 | # will only contain one package at a time, so I split that buffer by end line characters. 23 | i = self.buf.find(b"\n") 24 | if i >= 0: 25 | r = self.buf[:i + 1] 26 | self.buf = self.buf[i + 1:] 27 | # print(r.decode("utf-8")) 28 | try: 29 | decodedData = r.decode("utf-8") 30 | self.receivedPacketSignal.emit(decodedData, time.time()) 31 | except UnicodeDecodeError as e: 32 | print(e) 33 | try: 34 | incomingBytesNum = max(1, min(2048, self.serial.in_waiting)) 35 | data = self.serial.read(incomingBytesNum) 36 | except serial.SerialException as e: 37 | print(e) 38 | pass 39 | # There is no new data from serial port 40 | except TypeError as e: 41 | # Disconnect of USB->UART occured 42 | print("Serial disconnected") 43 | print(e) 44 | self.port.close() 45 | else: 46 | if len(data): 47 | self.buf.extend(data) 48 | self.msleep(100) -------------------------------------------------------------------------------- /02_canSniffer_GUI/SerialWriter.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtCore import QThread, pyqtSignal 2 | import queue 3 | 4 | 5 | class SerialWriterThread(QThread): 6 | packetSentSignal = pyqtSignal() 7 | writerQ = queue.Queue() 8 | tempQ = queue.Queue() 9 | repeatedWriteDelay = 0 10 | normalWriteDelay = 0 11 | 12 | def __init__(self, serial=None): 13 | super(SerialWriterThread, self).__init__() 14 | self.serial = serial 15 | self.isRunning = False 16 | 17 | def clearQueues(self): 18 | self.writerQ.queue.clear() 19 | self.tempQ.queue.clear() 20 | 21 | def stop(self): 22 | self.isRunning = False 23 | self.clearQueues() 24 | 25 | def write(self, packet): 26 | self.writerQ.put(packet) 27 | 28 | def setRepeatedWriteDelay(self, delay): 29 | self.repeatedWriteDelay = delay 30 | with self.tempQ.mutex: 31 | self.tempQ.queue.clear() 32 | 33 | def setNormalWriteDelay(self, delay): 34 | self.normalWriteDelay = delay 35 | 36 | def run(self): 37 | self.isRunning = True 38 | while self.isRunning: 39 | if not self.writerQ.empty(): 40 | element = self.writerQ.get() 41 | if isinstance(element, list): 42 | num = self.serial.write(bytearray(element)) 43 | #print(bytearray(element)) 44 | else: 45 | num = self.serial.write(element.encode("utf-8")) 46 | #print(element.encode("utf-8")) 47 | 48 | if self.normalWriteDelay != 0: 49 | self.msleep(self.normalWriteDelay) 50 | self.normalWriteDelay = 0 51 | 52 | if self.repeatedWriteDelay != 0: 53 | self.tempQ.put(element) 54 | 55 | self.packetSentSignal.emit() 56 | else: 57 | if self.repeatedWriteDelay != 0 and not self.tempQ.empty(): 58 | self.msleep(self.repeatedWriteDelay) 59 | while not self.tempQ.empty(): 60 | self.writerQ.put(self.tempQ.get()) 61 | else: 62 | self.msleep(1) 63 | -------------------------------------------------------------------------------- /02_canSniffer_GUI/main.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python ; coding: utf-8 -*- 2 | import os 3 | from PyInstaller.utils.hooks import collect_data_files 4 | 5 | spec_root = os.path.abspath(SPECPATH) 6 | qtmodern_data = collect_data_files('qtmodern') 7 | 8 | block_cipher = None 9 | 10 | a = Analysis(['main.py'], 11 | pathex=[spec_root], 12 | binaries=[], 13 | datas= qtmodern_data, 14 | hiddenimports=['PyQt5', 'Pyserial', 'PyQt5-tools', 'qtmodern'], 15 | hookspath=[], 16 | runtime_hooks=[], 17 | excludes=[], 18 | win_no_prefer_redirects=False, 19 | win_private_assemblies=False, 20 | cipher=block_cipher, 21 | noarchive=False) 22 | pyz = PYZ(a.pure, a.zipped_data, 23 | cipher=block_cipher) 24 | exe = EXE(pyz, 25 | a.scripts, 26 | a.binaries, 27 | a.zipfiles, 28 | a.datas, 29 | [], 30 | name='main', 31 | debug=False, 32 | bootloader_ignore_signals=False, 33 | strip=False, 34 | upx=True, 35 | upx_exclude=[], 36 | runtime_tmpdir=None, 37 | console=False ) 38 | -------------------------------------------------------------------------------- /02_canSniffer_GUI/requirements.txt: -------------------------------------------------------------------------------- 1 | PySerial 2 | PyQt5 3 | PyQt5-tools 4 | qtmodern -------------------------------------------------------------------------------- /02_canSniffer_GUI/save/decodedPackets.csv: -------------------------------------------------------------------------------- 1 | cabin light on,252,00,00,08,07,AE,03,80,00,00,00,00 2 | front left window up,259,00,00,08,04,AE,02,08,08,00,00,00 3 | front left window down,259,00,00,08,04,AE,02,08,10,00,00,00 4 | front left window stop,259,00,00,08,04,AE,02,08,00,00,00,00 5 | rear right door,230 (RearLeftDoor),00,00,05,00,10,10,00,00,,, 6 | exit test mode,255,00,00,08,02,AA,00,00,00,00,00,00 7 | fuel indicator min,255,00,00,08,07,AE,01,04,04,00,82,00 8 | windows locked,415 (RightWindow),00,00,05,80,00,00,00,00,,, 9 | windows not locked (idle),415 (RightWindow),00,00,05,00,00,00,00,00,,, 10 | right mirror left,405 (FrontLeftDoor),00,00,06,00,01,00,10,00,00,, 11 | right mirror right,405 (FrontLeftDoor),00,00,06,00,02,00,10,00,00,, 12 | right mirror up,405 (FrontLeftDoor),00,00,06,00,04,00,10,00,00,, 13 | righ mirror down,405 (FrontLeftDoor),00,00,06,00,08,00,10,00,00,, 14 | left mirror active,405 (FrontLeftDoor),00,00,06,00,00,00,08,00,00,, 15 | right mirror active,405 (FrontLeftDoor),00,00,06,00,00,00,10,00,00,, 16 | rear left window up,415 (RightWindow),00,00,05,00,00,20,1B,F0,,, 17 | rear left window down,415 (RightWindow),00,00,05,00,00,40,1B,F0,,, 18 | rear right window,415 (RightWindow),00,00,05,00,00,02,1B,F0,,, 19 | rear right window up,415 (RightWindow),00,00,05,00,00,04,1B,F0,,, 20 | front right window up,415 (RightWindow),00,00,05,00,02,00,1B,F0,,, 21 | front right window down,415 (RightWindow),00,00,05,00,04,00,1B,F0,,, 22 | right window idle,415 (RightWindow),00,00,05,00,00,00,00,00,,, 23 | rear left door close,230 (RearLeftDoor),00,00,05,00,00,00,00,00,,, 24 | rear left door open,230 (RearLeftDoor),00,00,05,00,40,00,00,00,,, 25 | front right close,420 (FrontRightDoor),00,00,05,00,00,00,00,00,,, 26 | front right open,420 (FrontRightDoor),00,00,05,00,00,40,00,00,,, 27 | front left open,405 (FrontLeftDoor),00,00,06,00,00,20,00,00,00,, 28 | front left close,405 (FrontLeftDoor),00,00,06,00,00,00,00,00,00,, 29 | lights low beam,350 (FrontFogLight),00,00,02,06,00,,,,,, 30 | lights off,23A (LightSwitch),00,00,03,00,00,00,,,,, 31 | lights pos indicator,23A (LightSwitch),00,00,03,00,20,00,,,,, 32 | lights low beam,23A (LightSwitch),00,00,03,00,A0,00,,,,, 33 | lights auto,23A (LightSwitch),00,00,03,04,00,00,,,,, 34 | lights high beam,350 (FrontFogLight),00,00,02,46,00,,,,,, 35 | turning light left,260 (TurningLight),00,00,03,25,40,80,,,,, 36 | turning light right,260 (TurningLight),00,00,03,3A,40,80,,,,, 37 | jam indicator,260 (TurningLight),00,00,03,1F,40,80,,,,, 38 | turning light idle,260 (TurningLight),00,00,03,00,40,80,,,,, 39 | window cleaner roller min,175 (WheelJoys),00,00,08,00,00,00,00,33,00,00,00 40 | window cleaner roller max,175 (WheelJoys),00,00,08,00,00,00,00,CC,00,00,00 41 | break idle,360 (Break),00,00,03,00,00,00,,,,, 42 | break pushed,360 (Break),00,00,03,00,00,40,,,,, 43 | Pedals idle(d2 increment),115 (Pedals),00,00,03,20,FF,50,,,,, 44 | Pedals break,115 (Pedals),00,00,03,28,FF,60,,,,, 45 | Pedals clutch,115 (Pedals),00,00,03,24,FF,10,,,,, 46 | handbreak released,220 (Handbreak),00,00,01,08,,,,,,, 47 | handbreak locked,220 (Handbreak),00,00,01,18,,,,,,, 48 | window heating,23A (LightSwitch),00,00,03,00,03,00,,,,, 49 | 850,108 (RPM),00,00,08,11,0D,44,00,00,00,00,00 50 | 1500,108 (RPM),00,00,08,21,18,78,00,00,00,00,00 51 | AC ON,155 (Climate),00,00,03,80,00,30,,,,, 52 | AC OFF,155 (Climate),00,00,03,00,00,2C,,,,, 53 | wheel right vol down,175 (WheelJoys),00,00,08,00,00,00,00,CC,02,00,1F 54 | wheel right vol up,175 (WheelJoys),00,00,08,00,00,00,00,CC,01,00,01 55 | wheel right btn down,175 (WheelJoys),00,00,08,00,00,00,00,CC,05,00,00 56 | wheel right btn up,175 (WheelJoys),00,00,08,00,00,00,00,CC,04,00,00 57 | wheel left select up,175 (WheelJoys),00,00,08,00,00,00,00,CC,10,1F,00 58 | wheel left select down,175 (WheelJoys),00,00,08,00,00,00,00,CC,20,01,00 59 | wheel left select push,175 (WheelJoys),00,00,08,00,00,00,00,CC,30,00,00 60 | wheel left lower btn,175 (WheelJoys),00,00,08,00,00,00,00,CC,50,00,00 61 | wheel left upper btn,175 (WheelJoys),00,00,08,00,00,00,00,CC,40,00,00 62 | doors locked,230 (RearLeftDoor),00,00,05,05,00,00,00,00,,, 63 | dorrs unlocked,230 (RearLeftDoor),00,00,05,00,00,00,00,00,,, 64 | trunk unlock short,405 (FrontLeftDoor),00,00,06,00,00,00,04,00,00,, 65 | trunk unlock long,405 (FrontLeftDoor),00,00,06,00,00,00,06,00,00,, 66 | wheel joys idle,175 (WheelJoys),00,00,08,00,00,00,00,CC,00,00,00 67 | right front window up btn,415 (RightWindow),00,00,05,00,00,00,00,00,,, 68 | right front window down btn,415 (RightWindow),00,00,05,00,04,00,1B,F0,,, 69 | right rear window down btn,415 (RightWindow),00,00,05,00,00,04,1B,F0,,, 70 | right rear window up btn,415 (RightWindow),00,00,05,00,00,02,1B,F0,,, 71 | left rear window down btn,415 (RightWindow),00,00,05,00,00,40,1B,F0,,, 72 | left rear window up btn,415 (RightWindow),00,00,05,00,00,20,1B,F0,,, 73 | brightness_value(0-ff),235 (brightness),00,00,02,00,6A,,,,,, 74 | front fog on,350 (FrontFogLight),00,00,02,26,00,,,,,, 75 | front fog off,350 (FrontFogLight),00,00,02,06,00,,,,,, 76 | MSpeed middle knob left,201,00,00,03,08,6A,FF,,,,, 77 | MSpeed middle knob right,201,00,00,03,08,6A,01,,,,, 78 | MSpeed middle knob pushed_D2:inkrement,201,00,00,03,01,6B,2A,,,,, 79 | MSpeed NAVI btn,201,00,00,03,01,E0,0B,,,,, 80 | RPM,255,00,00,08,07,AE,01,02,02,00,17,70 81 | RPM,255,00,00,08,07,AE,01,01,01,00,00,F9 82 | coolant,255,00,00,08,07,AE,01,08,08,00,A7,00 83 | fuel indicator max,255,08,07,AE,01,04,04,00,28,00,, 84 | symbol test lock,255,00,00,08,07,AE,06,01,01,00,08,00 85 | front right window full down,258,00,00,08,04,AE,02,08,08,00,00,00 86 | front right window full up,258,00,00,08,04,AE,02,08,10,00,00,00 87 | position indicator light test ON,253 (UEC),00,00,08,06,AE,02,0C,00,0C,00,00 88 | position indicator light test OFF,253 (UEC),00,00,08,06,AE,02,0C,00,00,00,00 89 | low beam light test ON,253 (UEC),00,00,08,06,AE,02,C0,00,C0,00,00 90 | low beam light test ON,253 (UEC),00,00,08,06,AE,02,C0,00,00,00,00 91 | fog light test ON,253 (UEC),00,00,08,06,AE,02,00,0C,00,0C,00 92 | fog light test OFF,253 (UEC),00,00,08,06,AE,02,00,0C,00,00,00 93 | high beam light test ON,253 (UEC),00,00,08,06,AE,02,30,00,30,00,00 94 | high beam light test OFF,253 (UEC),00,00,08,06,AE,02,30,00,00,00,00 95 | turning light test ON,253 (UEC),00,00,08,06,AE,02,03,00,03,00,00 96 | turning light test OFF,253 (UEC),00,00,08,06,AE,02,03,00,00,00,00 97 | open - only front left,160 (Remote),00,00,04,01,10,7D,28,,,, 98 | doors close,160 (Remote),00,00,04,01,40,7D,28,,,, 99 | all doors open,160 (Remote),00,00,04,01,20,7D,28,,,, 100 | long press close,160 (Remote),00,00,04,01,C0,7D,28,,,, 101 | long press open,160 (Remote),00,00,04,01,30,7D,28,,,, 102 | trunk open 1x,160 (Remote),00,00,04,01,04,7D,28,,,, 103 | trunk open 2x,160 (Remote),00,00,04,01,08,7D,28,,,, 104 | trunk open long press,160 (Remote),00,00,04,01,0C,7D,28,,,, 105 | Immo ignition,621 (Immo),00,00,08,00,48,50,00,00,00,00,00 106 | before ignition,621 (Immo),00,00,08,00,20,00,00,00,00,00,00 107 | -------------------------------------------------------------------------------- /02_canSniffer_GUI/save/labelDict.csv: -------------------------------------------------------------------------------- 1 | 201,BC_inc 2 | 621,Immo 3 | 160,Remote 4 | 257,SDM 5 | 252,BCM 6 | 254,REC 7 | 253,UEC 8 | 155,Climate 9 | 108,RPM 10 | 220,Handbreak 11 | 115,Pedals 12 | 360,Break 13 | 260,Turninglight 14 | 175,WheelJoys 15 | 415,RightWindow 16 | 235,Brightness 17 | 350,FrontFogLight 18 | 23A,LightSwitch 19 | 500,WheelPos? 20 | 420,FrontRightDoor 21 | 405,FrontLeftDoor 22 | 230,RearLeftDoor 23 | 4E8,REC 24 | 506,BCM 25 | -------------------------------------------------------------------------------- /02_canSniffer_GUI/ui_converter.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | subprocess.check_output(['pyuic5', '-o', 'canSniffer_ui.py', 'canSniffer.ui']) 4 | -------------------------------------------------------------------------------- /03_canSniffer_hw/board1/canDrive_hw_board1_v2.PcbDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamtheone/canDrive/852130fa063dad53efef13b41540af7bbe70c265/03_canSniffer_hw/board1/canDrive_hw_board1_v2.PcbDoc -------------------------------------------------------------------------------- /03_canSniffer_hw/board1/canDrive_hw_board1_v2.PrjPcbStructure: -------------------------------------------------------------------------------- 1 | Record=TopLevelDocument|FileName=canDrive_hw_board1_v2.SchDoc|SheetNumber= 2 | -------------------------------------------------------------------------------- /03_canSniffer_hw/board1/canDrive_hw_board1_v2.SchDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamtheone/canDrive/852130fa063dad53efef13b41540af7bbe70c265/03_canSniffer_hw/board1/canDrive_hw_board1_v2.SchDoc -------------------------------------------------------------------------------- /03_canSniffer_hw/board1/canDrive_hw_board1_v2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamtheone/canDrive/852130fa063dad53efef13b41540af7bbe70c265/03_canSniffer_hw/board1/canDrive_hw_board1_v2.pdf -------------------------------------------------------------------------------- /03_canSniffer_hw/board2/canDrive_hw_board2_v2.PcbDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamtheone/canDrive/852130fa063dad53efef13b41540af7bbe70c265/03_canSniffer_hw/board2/canDrive_hw_board2_v2.PcbDoc -------------------------------------------------------------------------------- /03_canSniffer_hw/board2/canDrive_hw_board2_v2.PrjPcbStructure: -------------------------------------------------------------------------------- 1 | Record=TopLevelDocument|FileName=canDrive_hw_board2_v2.SchDoc|SheetNumber= 2 | -------------------------------------------------------------------------------- /03_canSniffer_hw/board2/canDrive_hw_board2_v2.SchDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamtheone/canDrive/852130fa063dad53efef13b41540af7bbe70c265/03_canSniffer_hw/board2/canDrive_hw_board2_v2.SchDoc -------------------------------------------------------------------------------- /03_canSniffer_hw/board2/canDrive_hw_board2_v2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamtheone/canDrive/852130fa063dad53efef13b41540af7bbe70c265/03_canSniffer_hw/board2/canDrive_hw_board2_v2.pdf -------------------------------------------------------------------------------- /03_canSniffer_hw/common/canDrive_comp_pcb_lib.PcbLib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamtheone/canDrive/852130fa063dad53efef13b41540af7bbe70c265/03_canSniffer_hw/common/canDrive_comp_pcb_lib.PcbLib -------------------------------------------------------------------------------- /03_canSniffer_hw/common/canDrive_comp_sch_lib.SchLib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamtheone/canDrive/852130fa063dad53efef13b41540af7bbe70c265/03_canSniffer_hw/common/canDrive_comp_sch_lib.SchLib -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | dipCAN 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | ?children? 14 | ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\|| 15 | 16 | 17 | ?name? 18 | 19 | 20 | 21 | org.eclipse.cdt.make.core.append_environment 22 | true 23 | 24 | 25 | org.eclipse.cdt.make.core.buildArguments 26 | 27 | 28 | 29 | org.eclipse.cdt.make.core.buildCommand 30 | make 31 | 32 | 33 | org.eclipse.cdt.make.core.buildLocation 34 | ${workspace_loc:/STM32100B-EVAL/Debug} 35 | 36 | 37 | org.eclipse.cdt.make.core.contents 38 | org.eclipse.cdt.make.core.activeConfigSettings 39 | 40 | 41 | org.eclipse.cdt.make.core.enableAutoBuild 42 | false 43 | 44 | 45 | org.eclipse.cdt.make.core.enableCleanBuild 46 | true 47 | 48 | 49 | org.eclipse.cdt.make.core.enableFullBuild 50 | true 51 | 52 | 53 | org.eclipse.cdt.make.core.stopOnError 54 | true 55 | 56 | 57 | org.eclipse.cdt.make.core.useDefaultBuildCmd 58 | true 59 | 60 | 61 | 62 | 63 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 64 | 65 | 66 | 67 | 68 | 69 | com.st.stm32cube.ide.mcu.MCUProjectNature 70 | org.eclipse.cdt.core.cnature 71 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 72 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 73 | com.st.stm32cube.ide.mcu.MCUTSConvertedProjectNature 74 | 75 | 76 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_ble.c: -------------------------------------------------------------------------------- 1 | #include "dc_ble.h" 2 | #include "FreeRTOS.h" 3 | #include "task.h" 4 | #include 5 | #include "dc_can.h" 6 | #include "dc_main.h" 7 | //--------------------------------------------------------------------------------------------------------------------- 8 | extern UART_HandleTypeDef huart3; 9 | //--------------------------------------------------------------------------------------------------------------------- 10 | #define RX_BUFFER_LEN 255 11 | //--------------------------------------------------------------------------------------------------------------------- 12 | static TaskHandle_t xTaskToNotify = NULL; 13 | static uint8_t rxBuffer[RX_BUFFER_LEN], rxPtr; 14 | static bool bleDfuIsActive = false; 15 | //--------------------------------------------------------------------------------------------------------------------- 16 | const uint8_t DFU_INIT_ARRAY[] = {0x09, 0x01, 0xC0}; 17 | const uint8_t DFU_END_ARRAY[] = "DipCan Started\r\n"; 18 | uint8_t dfuEndArrayPtr = 0; 19 | uint8_t START_NRF_BL_CMD[] = "NRF_BL\r"; 20 | //--------------------------------------------------------------------------------------------------------------------- 21 | bool dc_ble_dfu_is_active(void){ 22 | return bleDfuIsActive; 23 | } 24 | 25 | void dc_ble_init(void){ 26 | rxPtr = 0; 27 | HAL_UART_Receive_IT(&huart3, &rxBuffer[rxPtr], 1); 28 | } 29 | 30 | void dc_ble_task(void * pvParameters){ 31 | xTaskToNotify = xTaskGetCurrentTaskHandle(); 32 | dc_usb_packet_t txPacket; 33 | 34 | dc_ble_init(); 35 | 36 | for(;;){ 37 | ulTaskNotifyTake(pdTRUE, portMAX_DELAY); 38 | while (ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(5))) {} 39 | 40 | txPacket.len = rxPtr; 41 | memcpy(txPacket.data, rxBuffer, rxPtr); 42 | HAL_UART_AbortReceive_IT(&huart3); 43 | dc_ble_init(); 44 | dc_usb_send_data(&txPacket); 45 | } 46 | } 47 | 48 | void dc_ble_check_dfu_end(uint8_t lastByte){ 49 | dfuEndArrayPtr = lastByte == DFU_END_ARRAY[dfuEndArrayPtr] ? dfuEndArrayPtr+1 : 0; 50 | if ( dfuEndArrayPtr == strlen((char*)DFU_END_ARRAY) ){ 51 | dfuEndArrayPtr = 0; 52 | bleDfuIsActive = false; 53 | dc_main_led_off(); 54 | } 55 | } 56 | 57 | void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){ 58 | if (huart == &huart3){ 59 | rxPtr++; 60 | 61 | if (rxPtr >= RX_BUFFER_LEN){ 62 | rxPtr = 0; 63 | } 64 | dc_ble_check_dfu_end(rxBuffer[rxPtr-1]); 65 | 66 | HAL_UART_Receive_IT(&huart3, &rxBuffer[rxPtr], 1); 67 | 68 | BaseType_t xHigherPriorityTaskWoken = pdFALSE; 69 | vTaskNotifyGiveFromISR(xTaskToNotify, &xHigherPriorityTaskWoken); 70 | portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); 71 | } 72 | } 73 | 74 | HAL_StatusTypeDef dc_ble_send(uint8_t * pData, uint8_t len){ 75 | return HAL_UART_Transmit(&huart3, pData, len, 10); 76 | } 77 | 78 | void dc_ble_usb_rx(dc_usb_packet_t *rxPacket){ 79 | if (!bleDfuIsActive) { 80 | if ( rxPacket->len == sizeof(DFU_INIT_ARRAY) && 81 | !memcmp( rxPacket->data, DFU_INIT_ARRAY, sizeof(DFU_INIT_ARRAY) ) && 82 | !dc_can_is_active(CAN_MAX_CH) ) 83 | { 84 | dc_ble_send(START_NRF_BL_CMD, strlen((char*)START_NRF_BL_CMD)); 85 | vTaskDelay(pdMS_TO_TICKS(100)); 86 | bleDfuIsActive = true; 87 | dc_main_led_on(); 88 | } else { 89 | return; 90 | } 91 | } 92 | 93 | 94 | uint8_t maxRetries = 10; 95 | while (maxRetries && HAL_OK != dc_ble_send(rxPacket->data, rxPacket->len)){ 96 | maxRetries--; 97 | } 98 | } 99 | 100 | void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart){ 101 | } 102 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_ble.h: -------------------------------------------------------------------------------- 1 | #ifndef DC_BLE_H_ 2 | #define DC_BLE_H_ 3 | //--------------------------------------------------------------------------------------------------------------------- 4 | #include "dc_usb.h" 5 | #include "main.h" 6 | //--------------------------------------------------------------------------------------------------------------------- 7 | void dc_ble_task(void * pvParameters); 8 | void dc_ble_usb_rx(dc_usb_packet_t *rxPacket); 9 | bool dc_ble_dfu_is_active(void); 10 | HAL_StatusTypeDef dc_ble_send(uint8_t * pData, uint8_t len); 11 | //--------------------------------------------------------------------------------------------------------------------- 12 | #endif /* DC_BLE_H_ */ 13 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_buzzer.c: -------------------------------------------------------------------------------- 1 | #include "dc_buzzer.h" 2 | #include "dc_main.h" 3 | #include "main.h" 4 | //--------------------------------------------------------------------------------------------------------------------- 5 | extern TIM_HandleTypeDef htim12; 6 | //--------------------------------------------------------------------------------------------------------------------- 7 | void dc_buzzer_init(void){ 8 | for (uint8_t i = 0; i < 2; i++){ 9 | HAL_TIM_PWM_Start(&htim12, TIM_CHANNEL_2); 10 | HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET); 11 | vTaskDelay(pdMS_TO_TICKS(50)); 12 | HAL_TIM_PWM_Stop(&htim12, TIM_CHANNEL_2); 13 | HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET); 14 | vTaskDelay(pdMS_TO_TICKS(50)); 15 | } 16 | } 17 | 18 | //--------------------------------------------------------------------------------------------------------------------- 19 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_buzzer.h: -------------------------------------------------------------------------------- 1 | #ifndef DC_BUZZER_H_ 2 | #define DC_BUZZER_H_ 3 | //--------------------------------------------------------------------------------------------------------------------- 4 | 5 | //--------------------------------------------------------------------------------------------------------------------- 6 | void dc_buzzer_init(void); 7 | //--------------------------------------------------------------------------------------------------------------------- 8 | #endif /* DC_BUZZER_H_ */ 9 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_can.h: -------------------------------------------------------------------------------- 1 | #ifndef DC_CAN_H_ 2 | #define DC_CAN_H_ 3 | //-------------------------------------------------------------------------------------------------------------------- 4 | #include "main.h" 5 | #include "dc_usb.h" 6 | //--------------------------------------------------------------------------------------------------------------------- 7 | extern CAN_HandleTypeDef * canHandles[]; 8 | //--------------------------------------------------------------------------------------------------------------------- 9 | #define DC_CAN_TX_BUFFER_SIZE 50 10 | #define DC_CAN_RX_BUFFER_SIZE 50 11 | 12 | #define DC_CAN_MAX_DATA_LEN 8 13 | //--------------------------------------------------------------------------------------------------------------------- 14 | #define filterConfigDefaults { \ 15 | .FilterMode = CAN_FILTERMODE_IDMASK, \ 16 | .FilterIdHigh = 0x0000, \ 17 | .FilterIdLow = 0x0000, \ 18 | .FilterMaskIdHigh = 0x0000, \ 19 | .FilterMaskIdLow = 0x0000, \ 20 | .FilterFIFOAssignment = CAN_RX_FIFO0, \ 21 | .FilterActivation = ENABLE \ 22 | } 23 | 24 | 25 | //--------------------------------------------------------------------------------------------------------------------- 26 | #define CHECK_CAN_CH(x) (x < CAN_MAX_CH) 27 | 28 | typedef enum{ 29 | CAN_H = 0, 30 | CAN_M, 31 | CAN_L, 32 | CAN_MAX_CH, 33 | } dc_can_ch_t; 34 | //--------------------------------------------------------------------------------------------------------------------- 35 | typedef struct{ 36 | dc_can_ch_t canCh; 37 | uint32_t id; 38 | uint8_t dlc; 39 | bool rtr; 40 | bool ide; 41 | uint8_t data[DC_CAN_MAX_DATA_LEN]; 42 | } dc_can_packet_t; 43 | //--------------------------------------------------------------------------------------------------------------------- 44 | #define CHECK_CAN_PRESCALER(x) (x >= 1 && x <= 1024) 45 | #define CHECK_CAN_SYNCJUMPWIDTH(x) (x >= 1 && x <= 4) 46 | #define CHECK_CAN_BS1(x) (x >= 1 && x <= 16) 47 | #define CHECK_CAN_BS2(x) (x >= 1 && x <= 8) 48 | 49 | 50 | typedef struct{ 51 | uint32_t prescaler, syncJumpWidth, timeSeg1, timeSeg2; 52 | CAN_HandleTypeDef *handle; 53 | bool isInited, isActive; 54 | TickType_t lastPacket; 55 | } dc_can_handle_t; 56 | //--------------------------------------------------------------------------------------------------------------------- 57 | #define GET_CAN_CH(x) (x->data[1]) 58 | #define GET_PRESCALER(x) (x->data[2]) 59 | #define GET_JUMPWIDTH(x) (x->data[3]) 60 | #define GET_TIMESEG1(x) (x->data[4]) 61 | #define GET_TIMESEG2(x) (x->data[5]) 62 | 63 | //--------------------------------------------------------------------------------------------------------------------- 64 | void dc_can_init(void); 65 | void dc_can_rx_task(void * pvParameters); 66 | void dc_can_tx_task(void * pvParameters); 67 | void dc_can_rx_handler(CAN_HandleTypeDef *hcan); 68 | void dc_can_send_packet(dc_can_ch_t _canChannel, uint32_t _id, bool _rtr, bool _ide, uint8_t _dlc, uint8_t * _pData); 69 | void dc_can_controller(dc_usb_packet_t * packet); 70 | bool dc_can_is_active(dc_can_ch_t can); 71 | //--------------------------------------------------------------------------------------------------------------------- 72 | #endif /* DC_CAN_H_ */ 73 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_can_defines.h: -------------------------------------------------------------------------------- 1 | #ifndef DC_CAN_DEFINES_H_ 2 | #define DC_CAN_DEFINES_H_ 3 | //-------------------------------------------------------------------------------------------------------------------- 4 | typedef enum { 5 | HS_PID_ENGINE_LOAD = 0x04, 6 | HS_PID_ENGINE_COOLANT_TEMP = 0x05, 7 | HS_PID_INTAKE_MANIFOLD_PRESSURE = 0x0b, 8 | HS_PID_ENGINE_RPM = 0x0c, 9 | HS_PID_VEHICLE_SPEED = 0x0d, 10 | HS_PID_INTAKE_AIR_TEMP = 0x0f, 11 | HS_PID_MAF_AIRFLOW_RATE = 0x10, 12 | HS_PID_FUEL_RAIL_GAUGE_PRESSURE = 0x23, 13 | } hs_pid_t; 14 | //-------------------------------------------------------------------------------------------------------------------- 15 | typedef enum{ 16 | HS_ECU_SHOW_CURRENT_DATA = 0x01, 17 | HS_ECU_RESP_CURRENT_DATA = 0x41, 18 | HS_ECU_SHOW_DTC_DATA = 0x03, 19 | HS_ECU_RESP_DTC_DATA = 0x43, 20 | } hs_pid_response_t; 21 | //-------------------------------------------------------------------------------------------------------------------- 22 | typedef enum{ 23 | HS_ID_ECU = 0x7DF, 24 | HS_ID_ECU_RESP = 0x7E8, 25 | } hs_id_t; 26 | //-------------------------------------------------------------------------------------------------------------------- 27 | /*typedef enum{ 28 | 29 | } ms_id_t;*/ 30 | //-------------------------------------------------------------------------------------------------------------------- 31 | typedef enum{ 32 | LS_ID_FRONT_LEFT_DOOR_STATUS = 0x405, 33 | LS_ID_FRONT_RIGHT_DOOR_STATUS = 0x420, 34 | LS_ID_REAR_DOORS_STATUS = 0x230, 35 | LS_ID_LIGHT_SWITCH = 0x23A, 36 | LS_ID_TURNING_LIGHTS = 0x260, 37 | LS_ID_PEDALS = 0x115, 38 | LS_ID_HANDBRAKE = 0x220, 39 | LS_ID_IMMO = 0x621, 40 | LS_ID_REMOTE = 0x160, 41 | LS_ID_BCM = 0x252, 42 | LS_ID_INSTRUMENT_CLUSTER = 0x255, 43 | LS_ID_BRIGHTNESS = 0x235, 44 | LS_ID_REC = 0x254, 45 | LS_ID_SDM = 0x257, 46 | 47 | LS_ID_UEC = 0x253, 48 | LS_ID_WHEEL = 0x175, 49 | LS_ID_DRIVER_DOOR_MODULE = 0x415, 50 | LS_ID_FRONT_WINDOW_PASSANGER = 0x258, 51 | LS_ID_FRONT_WINDOWS_DRIVER = 0x259, 52 | } ls_id_t; 53 | //-------------------------------------------------------------------------------------------------------------------- 54 | typedef enum{ 55 | FRONT_LEFT_DOOR_BITMAP = 0x01,// bit 1. 56 | FRONT_RIGHT_DOOR_BITMAP = 0x02,// bit 2. 57 | REAR_LEFT_DOOR_BITMAP = 0x04,// bit 3. 58 | REAR_RIGHT_DOOR_BITMAP = 0x08,// bit 4. 59 | DOORS_LOCKED_BITMAP = 0x10,// bit 5. 60 | 61 | LIGHT_SWITCH_AUTO_BITMAP = 0x01,// bit 1. 62 | LIGHT_SWITCH_PARK_BITMAP = 0x02,// bit 2. 63 | LIGHT_SWITCH_LOWBEAM_BITMAP = 0x04,// bit 3. 64 | TURNING_LIGHT_LEFT_BITMAP = 0x08,// bit 4. 65 | TURNING_LIGHT_RIGHT_BITMAP = 0x10,// bit 5. 66 | INTERIOR_LED_BRIGHTNESS_OFFSET = 8,// bit 8-15. 67 | 68 | PEDALS_CLUTCH_BITMAP = 0x01,// bit 0. 69 | PEDALS_BREAK_BITMAP = 0x02,// bit 1. 70 | PEDALS_HANDBREAK_BITMAP = 0x04,// bit 2. 71 | } info_offset_t; 72 | //-------------------------------------------------------------------------------------------------------------------- 73 | typedef enum{ 74 | CTRL_DASHBOARD_TEST, //0 75 | CTRL_COOLANT_TEMP_GAUGE, //1 76 | CTRL_RPM_GAUGE, //2 77 | CTRL_SPEED_GAUGE, //3 78 | CTRL_FUEL_GAUGE, //4 79 | CTRL_GAUGES_DEFAULT, //5 80 | CTRL_TURNING_LIGHT_ON, //6 81 | CTRL_LOWBEAM_LIGHT_ON, //7 82 | CTRL_FOG_LIGHT_ON, //8 83 | CTRL_HIGHBEAM_LIGHT_ON, //9 84 | CTRL_PARK_LIGHT_ON, //10 85 | CTRL_VOLUME_DOWN, //11 86 | CTRL_VOLUME_UP, //12 87 | CTRL_NEXT_SONG, //13 88 | CTRL_PREV_SONG, //14 89 | CTRL_MENU_UP, //15 90 | CTRL_MENU_DOWN, //16 91 | CTRL_MENU_PUSH, //17 92 | CTRL_MENU_BACK, //18 93 | CTRL_RL_WINDOW_UP, //19 94 | CTRL_RR_WINDOW_UP, //20 95 | CTRL_FL_WINDOW_UP, //21 96 | CTRL_FR_WINDOW_UP, //22 97 | CTRL_RL_WINDOW_DOWN, //23 98 | CTRL_RR_WINDOW_DOWN, //24 99 | CTRL_FL_WINDOW_DOWN, //25 100 | CTRL_FR_WINDOW_DOWN, //26 101 | 102 | CTRL_BCM_FAULT, //27 103 | CTRL_INSTRUMENT_CLUSTER_FAULT,//28 104 | CTRL_DRIVER_DOOR_FAULT, //29 105 | CTRL_PASSANGER_DOOR_FAULT, //30 106 | CTRL_REC_FAULT, //31 107 | CTRL_SDM_FAULT, //32 108 | CTRL_UEC_FAULT //33 109 | 110 | } dc_control_t; 111 | //-------------------------------------------------------------------------------------------------------------------- 112 | typedef struct { 113 | uint16_t engine_load; 114 | uint16_t cooland_temp; 115 | uint16_t manifold_pressure; 116 | uint16_t engine_rpm; 117 | uint16_t speed; 118 | uint16_t intake_air_temp; 119 | uint16_t maf_airflow_rate; 120 | uint16_t fuel_rail_gauge_pressure; 121 | 122 | uint16_t doors_state; 123 | uint16_t lights_state; 124 | uint16_t pedals_state; 125 | 126 | uint16_t battery_voltage; 127 | } dc_info_struct_t; 128 | //-------------------------------------------------------------------------------------------------------------------- 129 | typedef struct{ 130 | char dtc[10]; 131 | } dc_dtc_struct_t; 132 | //--------------------------------------------------------------------------------------------------------------------- 133 | #endif /* DC_CAN_DEFINES_H_ */ 134 | 135 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_controller.h: -------------------------------------------------------------------------------- 1 | #ifndef DC_CONTROLLER_H_ 2 | #define DC_CONTROLLER_H_ 3 | //--------------------------------------------------------------------------------------------------------------------- 4 | #include "stdint.h" 5 | #include 6 | #include "stm32f4xx.h" 7 | //--------------------------------------------------------------------------------------------------------------------- 8 | typedef enum { 9 | CTRL_SRC_USB, 10 | CTRL_SRC_WIFI, 11 | } dc_controller_source_t; 12 | //--------------------------------------------------------------------------------------------------------------------- 13 | bool dc_controller_processControlPacket(uint8_t *pData, uint8_t len, dc_controller_source_t source); 14 | bool dc_controller_fault_code_reader_callback(CAN_HandleTypeDef * canHandle, CAN_RxHeaderTypeDef *rxHeader, uint8_t *pData); 15 | void dc_controller_task(void * pvParameters); 16 | void dc_controller_init(void); 17 | //--------------------------------------------------------------------------------------------------------------------- 18 | #endif /* DC_CONTROLLER_H_ */ 19 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_forwarder_module.c: -------------------------------------------------------------------------------- 1 | #include "dc_forwarder_module.h" 2 | #include "dc_main.h" 3 | #include "dc_usb.h" 4 | #include "dc_can_defines.h" 5 | #include "dc_ble.h" 6 | #include 7 | //-------------------------------------------------------------------------------------------------------------------- 8 | static bool canRxForwardList[CAN_MAX_CH]; 9 | static dc_can_ch_t canTxForwardCh = CAN_H; 10 | static bool format_realdash = false; 11 | //-------------------------------------------------------------------------------------------------------------------- 12 | void dc_forwarder_init(void){ 13 | canRxForwardList[CAN_L] = false; 14 | canRxForwardList[CAN_M] = false; 15 | canRxForwardList[CAN_H] = false; 16 | } 17 | //-------------------------------------------------------------------------------------------------------------------- 18 | bool dc_forwarder_check_if_valid_usb_packet(dc_usb_packet_t * usbPacket){ 19 | uint8_t separator_cnt = 0; 20 | 21 | if (usbPacket->len < 9) { return false; } 22 | 23 | for (uint8_t i = 0; i < usbPacket->len; i++){ 24 | switch (usbPacket->data[i]){ 25 | case SEPARATOR_CHAR: 26 | separator_cnt++; 27 | continue; 28 | case TERMINATOR_CHAR: 29 | if (i != usbPacket->len - 1){ return false; } 30 | break; 31 | case '0' ... '9': 32 | case 'A' ... 'F': 33 | case 'a' ... 'f': 34 | continue; 35 | default: return false; 36 | } 37 | } 38 | return separator_cnt == SEPARATOR_NUM && usbPacket->data[usbPacket->len - 1] == TERMINATOR_CHAR; 39 | } 40 | //-------------------------------------------------------------------------------------------------------------------- 41 | uint8_t dc_forwarder_parse_bytes(char ** startPtr, uint8_t *buff, uint8_t maxSize){ 42 | uint8_t i = 0, tmp; 43 | char * ptr = *startPtr; 44 | memset(buff, 0, maxSize); 45 | while ( (ptr[i] != SEPARATOR_CHAR) && (ptr[i] != TERMINATOR_CHAR) && (i < 2 * maxSize) ){ 46 | tmp = 0; 47 | switch (ptr[i]){ 48 | case '0' ... '9': tmp = ptr[i] - '0'; break; 49 | case 'A' ... 'F': tmp = ptr[i] - 'A' + 10; break; 50 | case 'a' ... 'f': tmp = ptr[i] - 'a' + 10; break; 51 | default: break; 52 | } 53 | buff[(uint8_t)i/2] |= i % 2 ? tmp & 0x0F : tmp << 4; 54 | i++; 55 | } 56 | *startPtr += i; // 2nd char after last valid hex char 57 | return (uint8_t)i / 2; 58 | } 59 | 60 | //-------------------------------------------------------------------------------------------------------------------- 61 | void dc_forwarder_usb_rx(dc_usb_packet_t * usbPacket){ 62 | if (usbPacket->data[0] == T_FORWARDER_RX_SET && usbPacket->len >= 2){ 63 | canRxForwardList[CAN_L] = usbPacket->data[1] & 0x01 ? true : false; 64 | canRxForwardList[CAN_M] = usbPacket->data[1] & 0x02 ? true : false; 65 | canRxForwardList[CAN_H] = usbPacket->data[1] & 0x04 ? true : false; 66 | 67 | if (usbPacket->len >= 3){ 68 | format_realdash = usbPacket->data[2] == 0x01; 69 | } 70 | char str[200]; 71 | sprintf(str, "- forwarder rx L/M/H: %d %d %d\r\n", canRxForwardList[CAN_L], canRxForwardList[CAN_M], canRxForwardList[CAN_H]); 72 | dc_usb_send_str(str); 73 | } 74 | 75 | if (usbPacket->data[0] == T_FORWARDER_TX_SET && usbPacket->len >= 2){ 76 | switch (usbPacket->data[1]){ 77 | case 0: canTxForwardCh = CAN_L; break; 78 | case 1: canTxForwardCh = CAN_M; break; 79 | case 2: canTxForwardCh = CAN_H; break; 80 | default: break; 81 | } 82 | dc_usb_send_str("- forwarder tx setter\r\n"); 83 | } 84 | 85 | if (dc_forwarder_check_if_valid_usb_packet(usbPacket)){ 86 | dc_can_packet_t canPacket = { 87 | .dlc = 0, 88 | }; 89 | 90 | char * ptr = NULL; 91 | uint8_t tmp; 92 | 93 | canPacket.id = (uint32_t)strtol((char*)usbPacket->data, &ptr, 16); 94 | if ( (ptr == NULL) || (*ptr != SEPARATOR_CHAR) ) { return; } 95 | ptr++; 96 | 97 | dc_forwarder_parse_bytes(&ptr, &tmp, 1); 98 | if (*ptr != SEPARATOR_CHAR) { return; } else { ptr++; } 99 | canPacket.rtr = tmp ? true : false; 100 | 101 | dc_forwarder_parse_bytes(&ptr, &tmp, 1); 102 | if (*ptr != SEPARATOR_CHAR) { return; } else { ptr++; } 103 | canPacket.ide = tmp ? true : false; 104 | 105 | canPacket.dlc = dc_forwarder_parse_bytes(&ptr, canPacket.data, 8); 106 | if (*ptr != TERMINATOR_CHAR) { return; } 107 | 108 | if (canPacket.dlc > 8) { return; } 109 | dc_can_send_packet(canTxForwardCh, canPacket.id, canPacket.rtr, canPacket.ide, canPacket.dlc, canPacket.data); 110 | } 111 | } 112 | //-------------------------------------------------------------------------------------------------------------------- 113 | void dc_forwarder_convert_can_to_dipcan(dc_can_packet_t * canPacket, dc_usb_packet_t * usbPacket){ 114 | sprintf((char*)usbPacket->data, "%X,%02X,%02X,", (unsigned int)canPacket->id, canPacket->rtr, canPacket->ide); 115 | for (uint8_t i = 0; i < canPacket->dlc; i++){ 116 | sprintf((char*)usbPacket->data + strlen((char*)usbPacket->data), "%02X", canPacket->data[i]); 117 | } 118 | sprintf((char*)usbPacket->data + strlen((char*)usbPacket->data), "\n"); 119 | usbPacket->len = strlen((char*)usbPacket->data); 120 | } 121 | //-------------------------------------------------------------------------------------------------------------------- 122 | void dc_forwarder_convert_can_to_realdash(dc_can_packet_t * canPacket, dc_usb_packet_t * usbPacket){ 123 | const uint8_t serialBlockTag[4] = { 0x44, 0x33, 0x22, 0x11 }; 124 | memset(usbPacket->data, 0, sizeof(usbPacket->data)); 125 | memcpy(usbPacket->data, serialBlockTag, sizeof(serialBlockTag)); 126 | usbPacket->data[4] = (canPacket->id >> 0) & 0xFF; 127 | usbPacket->data[5] = (canPacket->id >> 8) & 0xFF; 128 | usbPacket->data[6] = (canPacket->id >> 16) & 0xFF; 129 | usbPacket->data[7] = (canPacket->id >> 24) & 0xFF; 130 | memcpy(&usbPacket->data[8], canPacket->data, canPacket->dlc); 131 | usbPacket->len = 16; 132 | } 133 | //-------------------------------------------------------------------------------------------------------------------- 134 | void dc_forwarder_can_rx(dc_can_packet_t * canPacket){ 135 | if (canRxForwardList[canPacket->canCh]){ 136 | dc_usb_packet_t usbPacket; 137 | 138 | if (format_realdash){ 139 | switch (canPacket->id){ 140 | case HS_ID_ECU_RESP: 141 | dc_forwarder_convert_can_to_realdash(canPacket, &usbPacket); 142 | dc_ble_send(usbPacket.data, usbPacket.len); 143 | break; 144 | default: break; 145 | } 146 | } else { 147 | dc_forwarder_convert_can_to_dipcan(canPacket, &usbPacket); 148 | dc_usb_send_data(&usbPacket); 149 | } 150 | } 151 | } 152 | //-------------------------------------------------------------------------------------------------------------------- 153 | 154 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_forwarder_module.h: -------------------------------------------------------------------------------- 1 | #ifndef DC_FORWARDER_MODULE_H_ 2 | #define DC_FORWARDER_MODULE_H_ 3 | //-------------------------------------------------------------------------------------------------------------------- 4 | #include "dc_can.h" 5 | #include "dc_usb.h" 6 | //-------------------------------------------------------------------------------------------------------------------- 7 | void dc_forwarder_init(void); 8 | void dc_forwarder_usb_rx(dc_usb_packet_t * usbPacket); 9 | void dc_forwarder_can_rx(dc_can_packet_t * canPacket); 10 | //-------------------------------------------------------------------------------------------------------------------- 11 | #endif /* DC_FORWARDER_MODULE_H_ */ 12 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_infocollector_module.h: -------------------------------------------------------------------------------- 1 | #ifndef DC_INFOCOLLECTOR_MODULE_H_ 2 | #define DC_INFOCOLLECTOR_MODULE_H_ 3 | //-------------------------------------------------------------------------------------------------------------------- 4 | #include "dc_can.h" 5 | #include "dc_can_defines.h" 6 | #include "dc_usb.h" 7 | //-------------------------------------------------------------------------------------------------------------------- 8 | void dc_infocollector_can_rx(dc_can_packet_t * canPacket); 9 | void dc_infocollector_commander(dc_usb_packet_t * usbPacket); 10 | void dc_infocollector_task(void * pvParameters); 11 | //-------------------------------------------------------------------------------------------------------------------- 12 | #endif /* DC_INFOCOLLECTOR_MODULE_H_ */ 13 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_main.c: -------------------------------------------------------------------------------- 1 | #include "dc_main.h" 2 | #include "main.h" 3 | #include "dc_usb.h" 4 | #include "dc_can.h" 5 | #include "usb_device.h" 6 | #include "dc_wifi.h" 7 | #include "dc_controller.h" 8 | #include "dc_packet_processor.h" 9 | #include "dc_buzzer.h" 10 | #include "dc_infocollector_module.h" 11 | #include "dc_ble.h" 12 | //--------------------------------------------------------------------------------------------------------------------- 13 | TaskHandle_t dc_wifi_txTaskHandle; 14 | extern RTC_HandleTypeDef hrtc; 15 | //--------------------------------------------------------------------------------------------------------------------- 16 | void dc_main_led_on(void){ HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET); } 17 | void dc_main_led_off(void){ HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET); } 18 | //--------------------------------------------------------------------------------------------------------------------- 19 | void JumpToBootloader(void) { 20 | void (*SysMemBootJump)(void); 21 | volatile uint32_t addr = 0x1FFF0000; 22 | HAL_RCC_DeInit(); 23 | SysTick->CTRL = 0; 24 | SysTick->LOAD = 0; 25 | SysTick->VAL = 0; 26 | //__disable_irq(); // <-- irq cannot be disable for USB bootloader 27 | __DSB(); // ARM Cortex-M Programming Guide to Memory Barrier Instructions. 28 | __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH(); 29 | __DSB(); 30 | __ISB(); 31 | SysMemBootJump = (void (*)(void)) (*((uint32_t *)(addr + 4))); 32 | __set_MSP(*(uint32_t *)addr); 33 | SysMemBootJump(); 34 | } 35 | 36 | void dc_bootloader_check_and_jump(void){ 37 | bool jump_to_bl = false; 38 | 39 | HAL_PWR_EnableBkUpAccess(); 40 | HAL_PWREx_EnableBkUpReg(); 41 | 42 | if ( HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR1) == BOOTLOADER_JUMP_VALUE){ 43 | HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR1, BOOTLOADER_CLEAR_VALUE); 44 | jump_to_bl = true; 45 | } 46 | 47 | if (jump_to_bl) { 48 | JumpToBootloader(); 49 | } 50 | } 51 | 52 | void dc_bootloader_set_and_restart(void){ 53 | HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR1, BOOTLOADER_JUMP_VALUE); 54 | NVIC_SystemReset(); 55 | } 56 | //--------------------------------------------------------------------------------------------------------------------- 57 | void dc_main_commander (dc_usb_packet_t * packet){ 58 | if ( !IS_TARGET_IN_GROUP(packet->data[0], T_MAIN_CTRL_GROUP)) { return; } 59 | 60 | switch (packet->data[0]){ 61 | case T_MAIN_CTRL_RESTART: 62 | NVIC_SystemReset(); 63 | break; 64 | case T_MAIN_CTRL_BOOTLOADER: 65 | dc_bootloader_set_and_restart(); 66 | break; 67 | } 68 | } 69 | //--------------------------------------------------------------------------------------------------------------------- 70 | void dc_initTask( void *pvParameters ){ 71 | // peripheral init functions 72 | dc_usb_init(); 73 | //dc_wifi_init(); 74 | //dc_controller_init(); 75 | //dc_packet_processor_init(); 76 | dc_buzzer_init(); 77 | 78 | 79 | vTaskDelay(pdMS_TO_TICKS(500)); 80 | 81 | // creating tasks 82 | xTaskCreate( dc_usb_tx_task, "usbTxTask", configMINIMAL_STACK_SIZE, NULL, 1, NULL ); 83 | xTaskCreate( dc_usb_rx_task, "usbRxTask", 256, NULL, 3, NULL ); 84 | 85 | xTaskCreate( dc_can_rx_task, "canRxTask", configMINIMAL_STACK_SIZE, NULL, 1, NULL ); 86 | xTaskCreate( dc_can_tx_task, "canTxTask", configMINIMAL_STACK_SIZE, NULL, 1, NULL ); 87 | 88 | xTaskCreate( dc_infocollector_task, "collectorTask", 512, NULL, 1, NULL ); 89 | 90 | xTaskCreate( dc_ble_task, "bleTask", 512, NULL, 1, NULL ); 91 | 92 | //xTaskCreate( dc_controller_task, "control", 256, NULL, 3, NULL); 93 | 94 | dc_can_init(); 95 | 96 | // hello world 97 | dc_usb_send_str("I am alive!\r\n"); 98 | 99 | //dc_initial_dashboard_test(); 100 | 101 | vTaskDelete(NULL); 102 | } 103 | 104 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_main.h: -------------------------------------------------------------------------------- 1 | #ifndef DC_MAIN_H_ 2 | #define DC_MAIN_H_ 3 | #include "FreeRTOS.h" 4 | #include "task.h" 5 | #include "queue.h" 6 | #include "timers.h" 7 | #include "printf-stdarg.h" 8 | #include 9 | #include 10 | #include "dc_usb.h" 11 | //--------------------------------------------------------------------------------------------------------------------- 12 | #define BOOTLOADER_JUMP_VALUE 0xBEEF 13 | #define BOOTLOADER_CLEAR_VALUE 0x0000 14 | //--------------------------------------------------------------------------------------------------------------------- 15 | #define IS_VALID_HEX_CHAR(x) ((x >= '0' && x <= '9') || (x >= 'A' && x <= 'F') || (x >= 'a' && x <= 'f')) 16 | #define SEPARATOR_CHAR (',') 17 | #define TERMINATOR_CHAR ('\n') 18 | #define SEPARATOR_NUM (3) 19 | #define MIN_LEN (10) // 0A,01,00,\n 20 | //-------------------------------------------------------------------------------------------------------------------- 21 | typedef enum{ 22 | T_TARGET_MASK = 0xF0, 23 | 24 | T_MAIN_CTRL_GROUP = 0xA0, 25 | T_MAIN_CTRL_RESTART = 0xA1, 26 | T_MAIN_CTRL_BOOTLOADER = 0xA2, 27 | 28 | T_FORWARDER_GROUP = 0xB0, 29 | T_FORWARDER_RX_SET = 0xB1, 30 | T_FORWARDER_TX_SET = 0xB2, 31 | 32 | T_TRANSMITTER_CTRL = 0xC0, 33 | 34 | T_INFOCOLLECTOR_CTRL = 0xD0, 35 | 36 | T_CAN_CTRL_GROUP = 0xE0, 37 | T_CAN_CTRL_SET_TIMING = 0xE1, 38 | T_CAN_CTRL_START = 0xE2, 39 | T_CAN_CTRL_STOP = 0xE3, 40 | 41 | } dc_target_t; 42 | //--------------------------------------------------------------------------------------------------------------------- 43 | #define IS_TARGET_IN_GROUP(target,group) ((target & T_TARGET_MASK) == group) 44 | #define GET_TARGET(x) (x->data[0]) 45 | //--------------------------------------------------------------------------------------------------------------------- 46 | void dc_bootloader_check_and_jump(void); 47 | void dc_bootloader_set_and_restart(void); 48 | 49 | void dc_initTask( void *pvParameters ); 50 | void dc_main_commander (dc_usb_packet_t * packet); 51 | 52 | void dc_main_led_on(void); 53 | void dc_main_led_off(void); 54 | //--------------------------------------------------------------------------------------------------------------------- 55 | #endif /* DC_MAIN_H_ */ 56 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_packet_processor.h: -------------------------------------------------------------------------------- 1 | #ifndef DC_PACKET_PROCESSOR_H_ 2 | #define DC_PACKET_PROCESSOR_H_ 3 | //--------------------------------------------------------------------------------------------------------------------- 4 | #include "stm32f4xx.h" 5 | //--------------------------------------------------------------------------------------------------------------------- 6 | #define UNKNOWN_QUERY 0xFF 7 | #define SHOW_CURRENT_DATA 0x01 8 | #define CURRENT_DATA_RESP 0x41 9 | #define SHOW_DTC_CODES 0x03 10 | #define DTC_CODES_RESP 0x43 11 | #define ECU_ADDR 0x7DF 12 | #define ECU_RESP_ADDR 0x7E8 13 | //--------------------------------------------------------------------------------------------------------------------- 14 | typedef enum { 15 | PID_ENGINE_LOAD = 0x04,// A/2.55 [%] 16 | PID_ENGINE_COOLANT_TEMP = 0x05,// A-40 [C] 17 | PID_INTAKE_MANIFOLD_PRESSURE = 0x0b,// A [kPa] 18 | PID_ENGINE_RPM = 0x0c,// (256A+B)/4 [rpm] 19 | PID_VEHICLE_SPEED = 0x0d,// A [kmph] 20 | PID_INTAKE_AIR_TEMP = 0x0f,// A-40 [C] 21 | PID_MAF_AIRFLOW_RATE = 0x10,// (256A+B)/100 [g/sec] 22 | PID_FUEL_RAIL_GAUGE_PRESSURE = 0x23,// 10(256A + B) [kPa] 23 | //--------------------------------------------------------------- 24 | PID_LS_FRONT_LEFT_DOOR_STATUS = 0x405, 25 | PID_LS_FRONT_RIGHT_DOOR_STATUS = 0x420, 26 | PID_LS_REAR_DOORS_STATUS = 0x230, 27 | PID_LS_LIGHT_SWITCH = 0x23A, 28 | PID_LS_TURNING_LIGHTS = 0x260, 29 | PID_LS_PEDALS = 0x115, 30 | PID_LS_HANDBRAKE = 0x220, 31 | PID_LS_IMMO = 0x621, 32 | PID_LS_REMOTE = 0x160, 33 | //--------------------------------------------------------------- 34 | PID_LS_INTERIOR_LIGHT = 0x252, 35 | PID_LS_INSTRUMENT_CLUSTER = 0x255, 36 | PID_LS_BRIGHTNESS = 0x235, 37 | } PID_t; 38 | 39 | typedef enum{ 40 | MID_SDM = 0x257, 41 | MIS_DIS = 0x246, 42 | MID_REC = 0x254, 43 | MID_DASHBOARD = 0x255, 44 | MID_COMFORTMODULE = 0x252, 45 | MID_PASSANGER_SIDE_DOOR = 0x258, 46 | MID_DRIVER_SIDE_DOOR = 0x259, 47 | MID_UEC = 0x253, 48 | } modul_id_t; 49 | 50 | 51 | enum{ 52 | PID_NAME, 53 | PID_LEN, 54 | }; 55 | //--------------------------------------------------------------------------------------------------------------------- 56 | void dc_packet_processor_print(CAN_RxHeaderTypeDef *rxHeader, uint8_t *pData); 57 | void dc_packet_processor_ls(CAN_RxHeaderTypeDef *rxHeader, uint8_t *pData); 58 | void dc_packet_processor_ms(CAN_RxHeaderTypeDef *rxHeader, uint8_t *pData); 59 | void dc_packet_processor_hs(CAN_RxHeaderTypeDef *rxHeader, uint8_t *pData); 60 | void dc_packet_processor_query_loop(void); 61 | void dc_packet_processor_init(void); 62 | //--------------------------------------------------------------------------------------------------------------------- 63 | #endif /* DC_PACKET_PROCESSOR_H_ */ 64 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_transmitter_module.h: -------------------------------------------------------------------------------- 1 | #ifndef DC_TRANSMITTER_MODULE_H_ 2 | #define DC_TRANSMITTER_MODULE_H_ 3 | //-------------------------------------------------------------------------------------------------------------------- 4 | #include "dc_can.h" 5 | //-------------------------------------------------------------------------------------------------------------------- 6 | void dc_transmitter_send_command(uint8_t * pData, uint8_t len); 7 | //-------------------------------------------------------------------------------------------------------------------- 8 | 9 | 10 | 11 | #endif /* DC_TRANSMITTER_MODULE_H_ */ 12 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_usb.c: -------------------------------------------------------------------------------- 1 | #include "dc_usb.h" 2 | #include "dc_can.h" 3 | #include "dc_main.h" 4 | #include "main.h" 5 | #include "usbd_def.h" 6 | #include "usbd_cdc_if.h" 7 | #include "dc_forwarder_module.h" 8 | #include "dc_infocollector_module.h" 9 | #include "dc_transmitter_module.h" 10 | #include "dc_ble.h" 11 | //--------------------------------------------------------------------------------------------------------------------- 12 | static QueueHandle_t txBufferQueue; 13 | static QueueHandle_t rxBufferQueue; 14 | //--------------------------------------------------------------------------------------------------------------------- 15 | void dc_usb_init(void){ 16 | HAL_GPIO_WritePin(USB_EN_GPIO_Port, USB_EN_Pin, GPIO_PIN_SET); 17 | 18 | txBufferQueue = xQueueCreate( DC_USB_TX_QUEUE_SIZE, sizeof(dc_usb_packet_t)); 19 | rxBufferQueue = xQueueCreate( DC_USB_RX_QUEUE_SIZE, sizeof(dc_usb_packet_t)); 20 | } 21 | //--------------------------------------------------------------------------------------------------------------------- 22 | // Sending 23 | //--------------------------------------------------------------------------------------------------------------------- 24 | void dc_usb_send_str(char * cPtr){ 25 | dc_usb_packet_t txPacket; 26 | txPacket.len = strlen(cPtr) > DC_USB_PACKET_SIZE ? DC_USB_PACKET_SIZE : strlen(cPtr); 27 | memcpy(txPacket.data, (uint8_t*)cPtr, txPacket.len); 28 | 29 | dc_usb_send_data(&txPacket); 30 | } 31 | //--------------------------------------------------------------------------------------------------------------------- 32 | void dc_usb_send_data(const dc_usb_packet_t * txPacket){ 33 | if (is_handler_mode()){ 34 | BaseType_t xHigherPriorityTaskWoken = pdFALSE; 35 | if ( xQueueSendFromISR( txBufferQueue, txPacket, &xHigherPriorityTaskWoken) != pdTRUE ){ 36 | // error 37 | } 38 | portYIELD_FROM_ISR(xHigherPriorityTaskWoken); 39 | } else { 40 | if ( xQueueSend(txBufferQueue, txPacket, 50) != pdTRUE ){ 41 | // error 42 | } 43 | } 44 | } 45 | //--------------------------------------------------------------------------------------------------------------------- 46 | void dc_usb_tx_task(void * pvParameters){ 47 | dc_usb_packet_t txPacket; 48 | uint32_t failCounter = 0; 49 | 50 | for(;;){ 51 | if ( xQueueReceive(txBufferQueue, &txPacket, portMAX_DELAY) == pdTRUE ){ 52 | while (CDC_Transmit_FS(txPacket.data, txPacket.len) == USBD_BUSY){ 53 | vTaskDelay(pdMS_TO_TICKS(2)); 54 | if (failCounter++ > 10){ 55 | break; 56 | } 57 | } 58 | } 59 | } 60 | } 61 | //--------------------------------------------------------------------------------------------------------------------- 62 | void dc_usb_rx_task(void * pvParameters){ 63 | dc_usb_packet_t rxPacket; 64 | for(;;){ 65 | if ( xQueueReceive(rxBufferQueue, &rxPacket, portMAX_DELAY) == pdTRUE ){ 66 | // Sharing the incoming packet with the modules 67 | dc_ble_usb_rx(&rxPacket); 68 | dc_can_controller(&rxPacket); 69 | dc_forwarder_usb_rx(&rxPacket); 70 | dc_infocollector_commander(&rxPacket); 71 | dc_transmitter_send_command(rxPacket.data, rxPacket.len); 72 | dc_main_commander(&rxPacket); 73 | } 74 | } 75 | } 76 | //--------------------------------------------------------------------------------------------------------------------- 77 | void dc_usb_rx_handler(uint8_t * pData, uint32_t len){ 78 | dc_usb_packet_t rxPacket; 79 | if (len > DC_USB_PACKET_SIZE){ 80 | Error_Handler(); 81 | } 82 | 83 | memcpy(rxPacket.data, pData, len); 84 | rxPacket.len = len; 85 | 86 | if ( dc_ble_dfu_is_active() ){ 87 | dc_ble_usb_rx(&rxPacket); 88 | return; // BLE DFU is active 89 | } 90 | 91 | if (is_handler_mode()){ 92 | BaseType_t xHigherPriorityTaskWoken = pdFALSE; 93 | if ( xQueueSendFromISR( rxBufferQueue, &rxPacket, &xHigherPriorityTaskWoken) != pdTRUE ){ 94 | // error 95 | } 96 | portYIELD_FROM_ISR(xHigherPriorityTaskWoken); 97 | } else { 98 | if ( xQueueSend(rxBufferQueue, &rxPacket, 50) != pdTRUE ){ 99 | // error 100 | } 101 | } 102 | } 103 | //--------------------------------------------------------------------------------------------------------------------- 104 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_usb.h: -------------------------------------------------------------------------------- 1 | #ifndef DC_USB_H_ 2 | #define DC_USB_H_ 3 | //--------------------------------------------------------------------------------------------------------------------- 4 | #include 5 | //--------------------------------------------------------------------------------------------------------------------- 6 | #define DC_USB_RX_QUEUE_SIZE 10 7 | #define DC_USB_TX_QUEUE_SIZE 20 8 | #define DC_USB_PACKET_SIZE 200 9 | //--------------------------------------------------------------------------------------------------------------------- 10 | typedef struct{ 11 | uint8_t data[DC_USB_PACKET_SIZE]; 12 | uint8_t len; 13 | } dc_usb_packet_t; 14 | //--------------------------------------------------------------------------------------------------------------------- 15 | void dc_usb_init(void); 16 | void dc_usb_send_str(char * cPtr); 17 | void dc_usb_send_data(const dc_usb_packet_t * txPacket); 18 | void dc_usb_rx_handler(uint8_t * pData, uint32_t len); 19 | void dc_usb_tx_task(void * pvParameters); 20 | void dc_usb_rx_task(void * pvParameters); 21 | //--------------------------------------------------------------------------------------------------------------------- 22 | #endif /* DC_USB_H_ */ 23 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_wifi.c: -------------------------------------------------------------------------------- 1 | #include "dc_wifi.h" 2 | #include "dc_main.h" 3 | #include "stm32f4xx.h" 4 | #include "main.h" 5 | #include "dc_usb.h" 6 | #include "string.h" 7 | #include "dc_wifi_packet_descriptor.h" 8 | #include "dc_usb.h" 9 | #include "usbd_def.h" 10 | #include "usbd_cdc_if.h" 11 | #include "dc_controller.h" 12 | //--------------------------------------------------------------------------------------------------------------------- 13 | extern UART_HandleTypeDef huart3; 14 | extern xTaskHandle dc_wifi_txTaskHandle; 15 | //--------------------------------------------------------------------------------------------------------------------- 16 | QueueHandle_t dc_wifi_txQueue; 17 | #define DC_WIFI_TX_QUEUE_SIZE 10 18 | 19 | QueueHandle_t dc_wifi_rxQueue; 20 | #define DC_WIFI_RX_QUEUE_SIZE 10 21 | //--------------------------------------------------------------------------------------------------------------------- 22 | static dc_usb_packet_t wifi_rx_usb_tx_packet; 23 | static uint8_t rxTempByte; 24 | //--------------------------------------------------------------------------------------------------------------------- 25 | static bool dc_wifi_isBootloaderModeActive = false; 26 | const char machine[] = "started"; 27 | uint8_t machinePtr = 0; 28 | //--------------------------------------------------------------------------------------------------------------------- 29 | bool dc_wifi_isBootloaderMode(void){ 30 | return dc_wifi_isBootloaderModeActive; 31 | } 32 | //--------------------------------------------------------------------------------------------------------------------- 33 | void dc_wifi_init(void){ 34 | dc_wifi_normalStart(); 35 | //dc_wifi_triggerBootloader(); 36 | 37 | dc_wifi_txQueue = xQueueCreate( DC_WIFI_TX_QUEUE_SIZE, sizeof(uint8_t) * INFO_PACKET_LEN); 38 | dc_wifi_rxQueue = xQueueCreate( DC_WIFI_RX_QUEUE_SIZE, sizeof(uint8_t) * CTRL_PACKET_LEN); 39 | 40 | wifi_rx_usb_tx_packet.len = 0; 41 | HAL_UART_Receive_DMA(&huart3, &rxTempByte, 1); 42 | } 43 | //---------------------------------------------------------------------------------------------------------------------- 44 | void dc_wifi_triggerBootloader(void){ 45 | 46 | } 47 | //---------------------------------------------------------------------------------------------------------------------- 48 | void dc_wifi_normalStart(void){ 49 | 50 | } 51 | //---------------------------------------------------------------------------------------------------------------------- 52 | void dc_wifi_update_finished_observer(uint8_t chr){ 53 | machinePtr = machine[machinePtr] == (char)chr ? machinePtr + 1 : 0; 54 | if (machinePtr == strlen(machine)){ 55 | dc_wifi_isBootloaderModeActive = false; 56 | machinePtr = 0; 57 | NVIC_SystemReset(); 58 | } 59 | } 60 | //---------------------------------------------------------------------------------------------------------------------- 61 | void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){ 62 | static uint8_t startIndex = INVALID_INDEX; 63 | static uint8_t endIndex = INVALID_INDEX; 64 | 65 | if (huart == &huart3){ 66 | wifi_rx_usb_tx_packet.data[wifi_rx_usb_tx_packet.len] = rxTempByte; 67 | wifi_rx_usb_tx_packet.len++; 68 | 69 | if (!dc_wifi_isBootloaderModeActive){ 70 | if (rxTempByte == CTRL_PACKET_START_CHAR){ 71 | startIndex = wifi_rx_usb_tx_packet.len - 1; 72 | } 73 | if (rxTempByte == CTRL_PACKET_END_CHAR){ 74 | endIndex = wifi_rx_usb_tx_packet.len - 1; 75 | if (startIndex != INVALID_INDEX && endIndex - startIndex + 1 == CTRL_PACKET_LEN){ 76 | BaseType_t xHigherPriorityTaskWoken = pdFALSE; 77 | if ( xQueueSendFromISR( dc_wifi_rxQueue, &(wifi_rx_usb_tx_packet.data[startIndex]), &xHigherPriorityTaskWoken) != pdTRUE ){ 78 | // error 79 | } 80 | portYIELD_FROM_ISR(xHigherPriorityTaskWoken); 81 | } 82 | wifi_rx_usb_tx_packet.len = 0; 83 | startIndex = INVALID_INDEX; 84 | endIndex = INVALID_INDEX; 85 | } 86 | } else { 87 | dc_wifi_update_finished_observer(rxTempByte); 88 | } 89 | 90 | if ( wifi_rx_usb_tx_packet.len == DC_USB_PACKET_SIZE){ 91 | Error_Handler(); // overflow 92 | } 93 | 94 | HAL_UART_Receive_DMA(huart, &rxTempByte, 1); 95 | } 96 | } 97 | //---------------------------------------------------------------------------------------------------------------------- 98 | void dc_wifi_rxTask(void * pvParameters){ 99 | uint8_t rxData[CTRL_PACKET_LEN]; 100 | 101 | for(;;){ 102 | if (dc_wifi_isBootloaderModeActive){ 103 | TickType_t xLastWakeTime = xTaskGetTickCount(); 104 | vTaskDelayUntil( &xLastWakeTime, pdMS_TO_TICKS(10) ); 105 | if ( wifi_rx_usb_tx_packet.len ){ 106 | taskENTER_CRITICAL(); 107 | dc_usb_packet_t tempPacket = { .len = wifi_rx_usb_tx_packet.len }; 108 | memcpy(tempPacket.data, wifi_rx_usb_tx_packet.data, tempPacket.len); 109 | wifi_rx_usb_tx_packet.len = 0; 110 | taskEXIT_CRITICAL(); 111 | dc_usb_send_data(&tempPacket); 112 | } 113 | } else { 114 | if ( xQueueReceive(dc_wifi_rxQueue, rxData, 500) == pdTRUE ) { 115 | dc_controller_processControlPacket(rxData, CTRL_PACKET_DATA_LEN, CTRL_SRC_WIFI); 116 | } 117 | } 118 | } 119 | } 120 | //--------------------------------------------------------------------------------------------------------------------- 121 | void dc_wifi_txTask(void * pvParameters){ 122 | uint8_t txData[INFO_PACKET_LEN]; 123 | for (;;){ 124 | if ( xQueueReceive(dc_wifi_txQueue, txData, portMAX_DELAY) == pdTRUE ) { 125 | if (!dc_wifi_isBootloaderModeActive){ 126 | HAL_UART_Transmit_DMA(&huart3, txData, INFO_PACKET_LEN); 127 | } 128 | } 129 | } 130 | } 131 | //--------------------------------------------------------------------------------------------------------------------- 132 | void dc_wifi_directTx(uint8_t * pData, uint8_t len){ 133 | static uint8_t txBuffer[255]; 134 | if (len > 255) { 135 | Error_Handler(); 136 | } 137 | memcpy(txBuffer, pData, len); 138 | HAL_UART_Transmit_DMA(&huart3, pData, len); 139 | } 140 | 141 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_wifi.h: -------------------------------------------------------------------------------- 1 | #ifndef DC_WIFI_H_ 2 | #define DC_WIFI_H_ 3 | //--------------------------------------------------------------------------------------------------------------------- 4 | #include 5 | #include 6 | //--------------------------------------------------------------------------------------------------------------------- 7 | void dc_wifi_init(void); 8 | void dc_wifi_triggerBootloader(void); 9 | void dc_wifi_normalStart(void); 10 | void dc_wifi_txTask(void * pvParameters); 11 | void dc_wifi_rxTask(void * pvParameters); 12 | void dc_wifi_directTx(uint8_t * pData, uint8_t len); 13 | void dc_wifi_saveToTxBuffer(uint8_t * pData, uint8_t len); 14 | bool dc_wifi_isBootloaderMode(void); 15 | //--------------------------------------------------------------------------------------------------------------------- 16 | #endif /* DC_WIFI_H_ */ 17 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/dc_wifi_packet_descriptor.h: -------------------------------------------------------------------------------- 1 | #ifndef DC_WIFI_PACKET_DESCRIPTOR_H_ 2 | #define DC_WIFI_PACKET_DESCRIPTOR_H_ 3 | //--------------------------------------------------------------------------------------------------------------------- 4 | 5 | typedef enum{ 6 | CTRL_PACKET_START = 0, 7 | //-------------------- 8 | CTRL_VOLUME_DOWN = 1, 9 | CTRL_VOLUME_UP = 2, 10 | CTRL_NEXT_SONG = 3, 11 | CTRL_PREV_SONG = 4, 12 | CTRL_MENU_UP = 5, 13 | CTRL_MENU_DOWN = 6, 14 | CTRL_MENU_PUSH = 7, 15 | CTRL_MENU_BACK = 8, 16 | CTRL_REAR_WINDOWS = 9, 17 | CTRL_FRONT_WINDOWS = 10, 18 | CTRL_LEFT_MIRROR = 11, 19 | CTRL_RIGHT_MIRROR = 12, 20 | CTRL_METERS_TEST = 13, 21 | CTRL_LIGHTS = 14, 22 | CTRL_GETFAULTCODES = 15, 23 | //-------------------- 24 | CTRL_PACKET_END, 25 | CTRL_PACKET_LEN 26 | } dc_wifi_control_packet_t; 27 | 28 | #define CTRL_PACKET_START_CHAR '[' 29 | #define CTRL_PACKET_END_CHAR ']' 30 | #define CTRL_PACKET_DATA_LEN (CTRL_PACKET_LEN - 2) 31 | 32 | //--------------------------------------------------------------------------------------------------------------------- 33 | 34 | typedef enum{ 35 | INFO_PACKET_START = 0, 36 | //-------------------- 37 | INFO_ENGINE_LOAD = 1, 38 | INFO_COOLANT_TEMP = 2, 39 | INFO_INMANIF_PRESS = 3, 40 | INFO_ENGINE_RPM = 4,//5 41 | INFO_SPEED = 6, 42 | INFO_INAIR_TEMP = 7, 43 | INFO_MAF_RATE = 8,//9 44 | INFO_FUELGAUGE_PRESS = 10,//11 45 | INFO_BRIGHTNESS = 12, 46 | INFO_INCREMENT = 13, 47 | INFO_DOORS_STATE = 14,// 000[L] [RR][RL][FR][FL] 48 | INFO_LIGHTS = 15,// 00[RI][LI] [R][LB][P][A] 49 | INFO_PEDALS = 16,// 0000 0[HB][B][C] 50 | INFO_FAULT1 = 17, 51 | INFO_FAULT2 = 18, 52 | INFO_FAULT3 = 19, 53 | INFO_VOLTAGE = 20, 54 | //-------------------- 55 | INFO_PACKET_END, 56 | INFO_PACKET_LEN 57 | } dc_wifi_info_packet_t; 58 | 59 | #define INFO_PACKET_START_CHAR '{' 60 | #define INFO_PACKET_END_CHAR '}' 61 | #define INFO_PACKET_DATA_LEN (INFO_PACKET_LEN - 2) 62 | 63 | #define FAULT_CODE_LEN 3 64 | //--------------------------------------------------------------------------------------------------------------------- 65 | #endif /* DC_WIFI_PACKET_DESCRIPTOR_H_ */ 66 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Application/printf-stdarg.h: -------------------------------------------------------------------------------- 1 | #ifndef PRINTF_STDARG_H_ 2 | #define PRINTF_STDARG_H_ 3 | 4 | int sprintf(char *out, const char *format, ...); 5 | 6 | #endif /* PRINTF_STDARG_H_ */ 7 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | ** This notice applies to any and all portions of this file 9 | * that are not between comment pairs USER CODE BEGIN and 10 | * USER CODE END. Other portions of this file, whether 11 | * inserted by the user or by software development tools 12 | * are owned by their respective copyright owners. 13 | * 14 | * COPYRIGHT(c) 2019 STMicroelectronics 15 | * 16 | * Redistribution and use in source and binary forms, with or without modification, 17 | * are permitted provided that the following conditions are met: 18 | * 1. Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, 21 | * this list of conditions and the following disclaimer in the documentation 22 | * and/or other materials provided with the distribution. 23 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 24 | * may be used to endorse or promote products derived from this software 25 | * without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 30 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 33 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 34 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 35 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | ****************************************************************************** 39 | */ 40 | /* USER CODE END Header */ 41 | 42 | /* Define to prevent recursive inclusion -------------------------------------*/ 43 | #ifndef __MAIN_H 44 | #define __MAIN_H 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | /* Includes ------------------------------------------------------------------*/ 51 | #include "stm32f4xx_hal.h" 52 | 53 | /* Private includes ----------------------------------------------------------*/ 54 | /* USER CODE BEGIN Includes */ 55 | #include "freeRTOS.h" 56 | #include 57 | /* USER CODE END Includes */ 58 | 59 | /* Exported types ------------------------------------------------------------*/ 60 | /* USER CODE BEGIN ET */ 61 | 62 | /* USER CODE END ET */ 63 | 64 | /* Exported constants --------------------------------------------------------*/ 65 | /* USER CODE BEGIN EC */ 66 | 67 | /* USER CODE END EC */ 68 | 69 | /* Exported macro ------------------------------------------------------------*/ 70 | /* USER CODE BEGIN EM */ 71 | 72 | /* USER CODE END EM */ 73 | 74 | void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); 75 | 76 | /* Exported functions prototypes ---------------------------------------------*/ 77 | void Error_Handler(void); 78 | void MX_CAN1_Init(void); 79 | void MX_CAN2_Init(void); 80 | void MX_CAN3_Init(void); 81 | 82 | /* USER CODE BEGIN EFP */ 83 | extern int is_handler_mode (void); 84 | /* USER CODE END EFP */ 85 | 86 | /* Private defines -----------------------------------------------------------*/ 87 | #define OSC_IN_Pin GPIO_PIN_0 88 | #define OSC_IN_GPIO_Port GPIOH 89 | #define OSC_OUT_Pin GPIO_PIN_1 90 | #define OSC_OUT_GPIO_Port GPIOH 91 | #define HS_CAN_RS_Pin GPIO_PIN_2 92 | #define HS_CAN_RS_GPIO_Port GPIOA 93 | #define BAT_MEAS_Pin GPIO_PIN_3 94 | #define BAT_MEAS_GPIO_Port GPIOA 95 | #define MS_CAN_RS_Pin GPIO_PIN_7 96 | #define MS_CAN_RS_GPIO_Port GPIOA 97 | #define LS_CAN_RS_Pin GPIO_PIN_12 98 | #define LS_CAN_RS_GPIO_Port GPIOB 99 | #define LED_Pin GPIO_PIN_14 100 | #define LED_GPIO_Port GPIOB 101 | #define BUZZER_Pin GPIO_PIN_15 102 | #define BUZZER_GPIO_Port GPIOB 103 | #define USB_EN_Pin GPIO_PIN_10 104 | #define USB_EN_GPIO_Port GPIOA 105 | #define USB_DM_Pin GPIO_PIN_11 106 | #define USB_DM_GPIO_Port GPIOA 107 | #define USB_DP_Pin GPIO_PIN_12 108 | #define USB_DP_GPIO_Port GPIOA 109 | #define ST_SWDIO_Pin GPIO_PIN_13 110 | #define ST_SWDIO_GPIO_Port GPIOA 111 | #define ST_SWCLK_Pin GPIO_PIN_14 112 | #define ST_SWCLK_GPIO_Port GPIOA 113 | #define COMM_TX_Pin GPIO_PIN_10 114 | #define COMM_TX_GPIO_Port GPIOC 115 | #define COMM_RX_Pin GPIO_PIN_11 116 | #define COMM_RX_GPIO_Port GPIOC 117 | #define LS_CAN_RX_Pin GPIO_PIN_3 118 | #define LS_CAN_RX_GPIO_Port GPIOB 119 | #define LS_CAN_TX_Pin GPIO_PIN_4 120 | #define LS_CAN_TX_GPIO_Port GPIOB 121 | #define MS_CAN_RX_Pin GPIO_PIN_5 122 | #define MS_CAN_RX_GPIO_Port GPIOB 123 | #define MS_CAN_TX_Pin GPIO_PIN_6 124 | #define MS_CAN_TX_GPIO_Port GPIOB 125 | #define HS_CAN_RX_Pin GPIO_PIN_8 126 | #define HS_CAN_RX_GPIO_Port GPIOB 127 | #define HS_CAN_TX_Pin GPIO_PIN_9 128 | #define HS_CAN_TX_GPIO_Port GPIOB 129 | 130 | /* USER CODE BEGIN Private defines */ 131 | 132 | /* USER CODE END Private defines */ 133 | 134 | #ifdef __cplusplus 135 | } 136 | #endif 137 | 138 | #endif /* __MAIN_H */ 139 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Core/Inc/stm32f4xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f4xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2019 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | /* USER CODE END Header */ 35 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ 37 | #ifndef __STM32F4xx_IT_H 38 | #define __STM32F4xx_IT_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /* Private includes ----------------------------------------------------------*/ 45 | /* USER CODE BEGIN Includes */ 46 | 47 | /* USER CODE END Includes */ 48 | 49 | /* Exported types ------------------------------------------------------------*/ 50 | /* USER CODE BEGIN ET */ 51 | 52 | /* USER CODE END ET */ 53 | 54 | /* Exported constants --------------------------------------------------------*/ 55 | /* USER CODE BEGIN EC */ 56 | 57 | /* USER CODE END EC */ 58 | 59 | /* Exported macro ------------------------------------------------------------*/ 60 | /* USER CODE BEGIN EM */ 61 | 62 | /* USER CODE END EM */ 63 | 64 | /* Exported functions prototypes ---------------------------------------------*/ 65 | void NMI_Handler(void); 66 | void HardFault_Handler(void); 67 | void MemManage_Handler(void); 68 | void BusFault_Handler(void); 69 | void UsageFault_Handler(void); 70 | void SVC_Handler(void); 71 | void DebugMon_Handler(void); 72 | void PendSV_Handler(void); 73 | void SysTick_Handler(void); 74 | void ADC_IRQHandler(void); 75 | void CAN1_RX0_IRQHandler(void); 76 | void CAN1_RX1_IRQHandler(void); 77 | void CAN1_SCE_IRQHandler(void); 78 | void TIM2_IRQHandler(void); 79 | void USART3_IRQHandler(void); 80 | void TIM7_IRQHandler(void); 81 | void CAN2_RX0_IRQHandler(void); 82 | void CAN2_RX1_IRQHandler(void); 83 | void CAN2_SCE_IRQHandler(void); 84 | void OTG_FS_IRQHandler(void); 85 | void CAN3_RX0_IRQHandler(void); 86 | void CAN3_RX1_IRQHandler(void); 87 | void CAN3_SCE_IRQHandler(void); 88 | /* USER CODE BEGIN EFP */ 89 | 90 | /* USER CODE END EFP */ 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __STM32F4xx_IT_H */ 97 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Core/Src/stm32f4xx_hal_timebase_tim.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f4xx_hal_timebase_TIM.c 5 | * @brief HAL time base based on the hardware TIM. 6 | ****************************************************************************** 7 | ** This notice applies to any and all portions of this file 8 | * that are not between comment pairs USER CODE BEGIN and 9 | * USER CODE END. Other portions of this file, whether 10 | * inserted by the user or by software development tools 11 | * are owned by their respective copyright owners. 12 | * 13 | * COPYRIGHT(c) 2019 STMicroelectronics 14 | * 15 | * Redistribution and use in source and binary forms, with or without modification, 16 | * are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************** 38 | */ 39 | /* USER CODE END Header */ 40 | 41 | /* Includes ------------------------------------------------------------------*/ 42 | #include "stm32f4xx_hal.h" 43 | #include "stm32f4xx_hal_tim.h" 44 | 45 | /* Private typedef -----------------------------------------------------------*/ 46 | /* Private define ------------------------------------------------------------*/ 47 | /* Private macro -------------------------------------------------------------*/ 48 | /* Private variables ---------------------------------------------------------*/ 49 | TIM_HandleTypeDef htim2; 50 | /* Private function prototypes -----------------------------------------------*/ 51 | /* Private functions ---------------------------------------------------------*/ 52 | 53 | /** 54 | * @brief This function configures the TIM2 as a time base source. 55 | * The time source is configured to have 1ms time base with a dedicated 56 | * Tick interrupt priority. 57 | * @note This function is called automatically at the beginning of program after 58 | * reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig(). 59 | * @param TickPriority: Tick interrupt priority. 60 | * @retval HAL status 61 | */ 62 | HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) 63 | { 64 | RCC_ClkInitTypeDef clkconfig; 65 | uint32_t uwTimclock, uwAPB1Prescaler = 0U; 66 | 67 | uint32_t uwPrescalerValue = 0U; 68 | uint32_t pFLatency; 69 | HAL_StatusTypeDef status; 70 | 71 | /* Enable TIM2 clock */ 72 | __HAL_RCC_TIM2_CLK_ENABLE(); 73 | 74 | /* Get clock configuration */ 75 | HAL_RCC_GetClockConfig(&clkconfig, &pFLatency); 76 | 77 | /* Get APB1 prescaler */ 78 | uwAPB1Prescaler = clkconfig.APB1CLKDivider; 79 | /* Compute TIM2 clock */ 80 | if (uwAPB1Prescaler == RCC_HCLK_DIV1) 81 | { 82 | uwTimclock = HAL_RCC_GetPCLK1Freq(); 83 | } 84 | else 85 | { 86 | uwTimclock = 2UL * HAL_RCC_GetPCLK1Freq(); 87 | } 88 | 89 | /* Compute the prescaler value to have TIM2 counter clock equal to 1MHz */ 90 | uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U); 91 | 92 | /* Initialize TIM2 */ 93 | htim2.Instance = TIM2; 94 | 95 | /* Initialize TIMx peripheral as follow: 96 | 97 | + Period = [(TIM2CLK/1000) - 1]. to have a (1/1000) s time base. 98 | + Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock. 99 | + ClockDivision = 0 100 | + Counter direction = Up 101 | */ 102 | htim2.Init.Period = (1000000U / 1000U) - 1U; 103 | htim2.Init.Prescaler = uwPrescalerValue; 104 | htim2.Init.ClockDivision = 0; 105 | htim2.Init.CounterMode = TIM_COUNTERMODE_UP; 106 | htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; 107 | 108 | status = HAL_TIM_Base_Init(&htim2); 109 | if (status == HAL_OK) 110 | { 111 | /* Start the TIM time Base generation in interrupt mode */ 112 | status = HAL_TIM_Base_Start_IT(&htim2); 113 | if (status == HAL_OK) 114 | { 115 | /* Enable the TIM2 global Interrupt */ 116 | HAL_NVIC_EnableIRQ(TIM2_IRQn); 117 | /* Configure the SysTick IRQ priority */ 118 | if (TickPriority < (1UL << __NVIC_PRIO_BITS)) 119 | { 120 | /* Configure the TIM IRQ priority */ 121 | HAL_NVIC_SetPriority(TIM2_IRQn, TickPriority, 0U); 122 | uwTickPrio = TickPriority; 123 | } 124 | else 125 | { 126 | status = HAL_ERROR; 127 | } 128 | } 129 | } 130 | 131 | /* Return function status */ 132 | return status; 133 | } 134 | 135 | /** 136 | * @brief Suspend Tick increment. 137 | * @note Disable the tick increment by disabling TIM2 update interrupt. 138 | * @param None 139 | * @retval None 140 | */ 141 | void HAL_SuspendTick(void) 142 | { 143 | /* Disable TIM2 update Interrupt */ 144 | __HAL_TIM_DISABLE_IT(&htim2, TIM_IT_UPDATE); 145 | } 146 | 147 | /** 148 | * @brief Resume Tick increment. 149 | * @note Enable the tick increment by Enabling TIM2 update interrupt. 150 | * @param None 151 | * @retval None 152 | */ 153 | void HAL_ResumeTick(void) 154 | { 155 | /* Enable TIM2 Update interrupt */ 156 | __HAL_TIM_ENABLE_IT(&htim2, TIM_IT_UPDATE); 157 | } 158 | 159 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Core/Src/syscalls.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adamtheone/canDrive/852130fa063dad53efef13b41540af7bbe70c265/04_canSniffer_FW/board1_STM/Core/Src/syscalls.c -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f4xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /** @addtogroup CMSIS 20 | * @{ 21 | */ 22 | 23 | /** @addtogroup stm32f4xx_system 24 | * @{ 25 | */ 26 | 27 | /** 28 | * @brief Define to prevent recursive inclusion 29 | */ 30 | #ifndef __SYSTEM_STM32F4XX_H 31 | #define __SYSTEM_STM32F4XX_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @addtogroup STM32F4xx_System_Includes 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @} 43 | */ 44 | 45 | 46 | /** @addtogroup STM32F4xx_System_Exported_types 47 | * @{ 48 | */ 49 | /* This variable is updated in three ways: 50 | 1) by calling CMSIS function SystemCoreClockUpdate() 51 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 52 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 53 | Note: If you use this function to configure the system clock; then there 54 | is no need to call the 2 first functions listed above, since SystemCoreClock 55 | variable is updated automatically. 56 | */ 57 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 58 | 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 STM32F4xx_System_Exported_Constants 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @addtogroup STM32F4xx_System_Exported_Macros 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @addtogroup STM32F4xx_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_STM32F4XX_H */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /** 103 | * @} 104 | */ 105 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Drivers/CMSIS/Device/ST/STM32F4xx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Drivers/CMSIS/Include/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 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Drivers/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file tz_context.h 3 | * @brief Context Management for Armv8-M TrustZone 4 | * @version V1.0.1 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 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 TZ_CONTEXT_H 32 | #define TZ_CONTEXT_H 33 | 34 | #include 35 | 36 | #ifndef TZ_MODULEID_T 37 | #define TZ_MODULEID_T 38 | /// \details Data type that identifies secure software modules called by a process. 39 | typedef uint32_t TZ_ModuleId_t; 40 | #endif 41 | 42 | /// \details TZ Memory ID identifies an allocated memory slot. 43 | typedef uint32_t TZ_MemoryId_t; 44 | 45 | /// Initialize secure context memory system 46 | /// \return execution status (1: success, 0: error) 47 | uint32_t TZ_InitContextSystem_S (void); 48 | 49 | /// Allocate context memory for calling secure software modules in TrustZone 50 | /// \param[in] module identifies software modules called from non-secure mode 51 | /// \return value != 0 id TrustZone memory slot identifier 52 | /// \return value 0 no memory available or internal error 53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 54 | 55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 56 | /// \param[in] id TrustZone memory slot identifier 57 | /// \return execution status (1: success, 0: error) 58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 59 | 60 | /// Load secure context (called on RTOS thread context switch) 61 | /// \param[in] id TrustZone memory slot identifier 62 | /// \return execution status (1: success, 0: error) 63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 64 | 65 | /// Store secure context (called on RTOS thread context switch) 66 | /// \param[in] id TrustZone memory slot identifier 67 | /// \return execution status (1: success, 0: error) 68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 69 | 70 | #endif // TZ_CONTEXT_H 71 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_dma_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of DMA HAL extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32F4xx_HAL_DMA_EX_H 21 | #define __STM32F4xx_HAL_DMA_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f4xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F4xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup DMAEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /** @defgroup DMAEx_Exported_Types DMAEx Exported Types 40 | * @brief DMAEx Exported types 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief HAL DMA Memory definition 46 | */ 47 | typedef enum 48 | { 49 | MEMORY0 = 0x00U, /*!< Memory 0 */ 50 | MEMORY1 = 0x01U /*!< Memory 1 */ 51 | }HAL_DMA_MemoryTypeDef; 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | /* Exported functions --------------------------------------------------------*/ 58 | /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions 59 | * @brief DMAEx Exported functions 60 | * @{ 61 | */ 62 | 63 | /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions 64 | * @brief Extended features functions 65 | * @{ 66 | */ 67 | 68 | /* IO operation functions *******************************************************/ 69 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 70 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 71 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory); 72 | 73 | /** 74 | * @} 75 | */ 76 | /** 77 | * @} 78 | */ 79 | 80 | /* Private functions ---------------------------------------------------------*/ 81 | /** @defgroup DMAEx_Private_Functions DMAEx Private Functions 82 | * @brief DMAEx Private functions 83 | * @{ 84 | */ 85 | /** 86 | * @} 87 | */ 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /*__STM32F4xx_HAL_DMA_EX_H*/ 102 | 103 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_flash_ramfunc.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH RAMFUNC driver. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | ****************************************************************************** 16 | */ 17 | 18 | /* Define to prevent recursive inclusion -------------------------------------*/ 19 | #ifndef __STM32F4xx_FLASH_RAMFUNC_H 20 | #define __STM32F4xx_FLASH_RAMFUNC_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\ 26 | defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f4xx_hal_def.h" 30 | 31 | /** @addtogroup STM32F4xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup FLASH_RAMFUNC 36 | * @{ 37 | */ 38 | 39 | /* Exported types ------------------------------------------------------------*/ 40 | /* Exported macro ------------------------------------------------------------*/ 41 | /* Exported functions --------------------------------------------------------*/ 42 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions 43 | * @{ 44 | */ 45 | 46 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group1 47 | * @{ 48 | */ 49 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StopFlashInterfaceClk(void); 50 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StartFlashInterfaceClk(void); 51 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableFlashSleepMode(void); 52 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableFlashSleepMode(void); 53 | /** 54 | * @} 55 | */ 56 | 57 | /** 58 | * @} 59 | */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | /** 66 | * @} 67 | */ 68 | 69 | #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | 75 | #endif /* __STM32F4xx_FLASH_RAMFUNC_H */ 76 | 77 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_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 is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32F4xx_HAL_PCD_EX_H 21 | #define STM32F4xx_HAL_PCD_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif /* __cplusplus */ 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f4xx_hal_def.h" 29 | 30 | #if defined (USB_OTG_FS) || defined (USB_OTG_HS) 31 | /** @addtogroup STM32F4xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup PCDEx 36 | * @{ 37 | */ 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* Exported macros -----------------------------------------------------------*/ 41 | /* Exported functions --------------------------------------------------------*/ 42 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions 43 | * @{ 44 | */ 45 | /** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 46 | * @{ 47 | */ 48 | 49 | #if defined (USB_OTG_FS) || defined (USB_OTG_HS) 50 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size); 51 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size); 52 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */ 53 | 54 | #if defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 55 | HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd); 56 | HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd); 57 | #endif /* defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) */ 58 | #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 59 | HAL_StatusTypeDef HAL_PCDEx_ActivateBCD(PCD_HandleTypeDef *hpcd); 60 | HAL_StatusTypeDef HAL_PCDEx_DeActivateBCD(PCD_HandleTypeDef *hpcd); 61 | void HAL_PCDEx_BCD_VBUSDetect(PCD_HandleTypeDef *hpcd); 62 | #endif /* defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) */ 63 | void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg); 64 | void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg); 65 | 66 | /** 67 | * @} 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */ 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif /* __cplusplus */ 86 | 87 | 88 | #endif /* STM32F4xx_HAL_PCD_EX_H */ 89 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Drivers/STM32F4xx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_flash_ramfunc.c 4 | * @author MCD Application Team 5 | * @brief FLASH RAMFUNC module driver. 6 | * This file provides a FLASH firmware functions which should be 7 | * executed from internal SRAM 8 | * + Stop/Start the flash interface while System Run 9 | * + Enable/Disable the flash sleep while System Run 10 | @verbatim 11 | ============================================================================== 12 | ##### APIs executed from Internal RAM ##### 13 | ============================================================================== 14 | [..] 15 | *** ARM Compiler *** 16 | -------------------- 17 | [..] RAM functions are defined using the toolchain options. 18 | Functions that are be executed in RAM should reside in a separate 19 | source module. Using the 'Options for File' dialog you can simply change 20 | the 'Code / Const' area of a module to a memory space in physical RAM. 21 | Available memory areas are declared in the 'Target' tab of the 22 | Options for Target' dialog. 23 | 24 | *** ICCARM Compiler *** 25 | ----------------------- 26 | [..] RAM functions are defined using a specific toolchain keyword "__ramfunc". 27 | 28 | *** GNU Compiler *** 29 | -------------------- 30 | [..] RAM functions are defined using a specific toolchain attribute 31 | "__attribute__((section(".RamFunc")))". 32 | 33 | @endverbatim 34 | ****************************************************************************** 35 | * @attention 36 | * 37 | * Copyright (c) 2017 STMicroelectronics. 38 | * All rights reserved. 39 | * 40 | * This software is licensed under terms that can be found in the LICENSE file in 41 | * the root directory of this software component. 42 | * If no LICENSE file comes with this software, it is provided AS-IS. 43 | ****************************************************************************** 44 | */ 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f4xx_hal.h" 48 | 49 | /** @addtogroup STM32F4xx_HAL_Driver 50 | * @{ 51 | */ 52 | 53 | /** @defgroup FLASH_RAMFUNC FLASH RAMFUNC 54 | * @brief FLASH functions executed from RAM 55 | * @{ 56 | */ 57 | #ifdef HAL_FLASH_MODULE_ENABLED 58 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \ 59 | defined(STM32F412Rx) || defined(STM32F412Cx) 60 | 61 | /* Private typedef -----------------------------------------------------------*/ 62 | /* Private define ------------------------------------------------------------*/ 63 | /* Private macro -------------------------------------------------------------*/ 64 | /* Private variables ---------------------------------------------------------*/ 65 | /* Private function prototypes -----------------------------------------------*/ 66 | /* Exported functions --------------------------------------------------------*/ 67 | /** @defgroup FLASH_RAMFUNC_Exported_Functions FLASH RAMFUNC Exported Functions 68 | * @{ 69 | */ 70 | 71 | /** @defgroup FLASH_RAMFUNC_Exported_Functions_Group1 Peripheral features functions executed from internal RAM 72 | * @brief Peripheral Extended features functions 73 | * 74 | @verbatim 75 | 76 | =============================================================================== 77 | ##### ramfunc functions ##### 78 | =============================================================================== 79 | [..] 80 | This subsection provides a set of functions that should be executed from RAM 81 | transfers. 82 | 83 | @endverbatim 84 | * @{ 85 | */ 86 | 87 | /** 88 | * @brief Stop the flash interface while System Run 89 | * @note This mode is only available for STM32F41xxx/STM32F446xx devices. 90 | * @note This mode couldn't be set while executing with the flash itself. 91 | * It should be done with specific routine executed from RAM. 92 | * @retval HAL status 93 | */ 94 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StopFlashInterfaceClk(void) 95 | { 96 | /* Enable Power ctrl clock */ 97 | __HAL_RCC_PWR_CLK_ENABLE(); 98 | /* Stop the flash interface while System Run */ 99 | SET_BIT(PWR->CR, PWR_CR_FISSR); 100 | 101 | return HAL_OK; 102 | } 103 | 104 | /** 105 | * @brief Start the flash interface while System Run 106 | * @note This mode is only available for STM32F411xx/STM32F446xx devices. 107 | * @note This mode couldn't be set while executing with the flash itself. 108 | * It should be done with specific routine executed from RAM. 109 | * @retval HAL status 110 | */ 111 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_StartFlashInterfaceClk(void) 112 | { 113 | /* Enable Power ctrl clock */ 114 | __HAL_RCC_PWR_CLK_ENABLE(); 115 | /* Start the flash interface while System Run */ 116 | CLEAR_BIT(PWR->CR, PWR_CR_FISSR); 117 | 118 | return HAL_OK; 119 | } 120 | 121 | /** 122 | * @brief Enable the flash sleep while System Run 123 | * @note This mode is only available for STM32F41xxx/STM32F446xx devices. 124 | * @note This mode could n't be set while executing with the flash itself. 125 | * It should be done with specific routine executed from RAM. 126 | * @retval HAL status 127 | */ 128 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableFlashSleepMode(void) 129 | { 130 | /* Enable Power ctrl clock */ 131 | __HAL_RCC_PWR_CLK_ENABLE(); 132 | /* Enable the flash sleep while System Run */ 133 | SET_BIT(PWR->CR, PWR_CR_FMSSR); 134 | 135 | return HAL_OK; 136 | } 137 | 138 | /** 139 | * @brief Disable the flash sleep while System Run 140 | * @note This mode is only available for STM32F41xxx/STM32F446xx devices. 141 | * @note This mode couldn't be set while executing with the flash itself. 142 | * It should be done with specific routine executed from RAM. 143 | * @retval HAL status 144 | */ 145 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableFlashSleepMode(void) 146 | { 147 | /* Enable Power ctrl clock */ 148 | __HAL_RCC_PWR_CLK_ENABLE(); 149 | /* Disable the flash sleep while System Run */ 150 | CLEAR_BIT(PWR->CR, PWR_CR_FMSSR); 151 | 152 | return HAL_OK; 153 | } 154 | 155 | /** 156 | * @} 157 | */ 158 | 159 | /** 160 | * @} 161 | */ 162 | 163 | #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 164 | #endif /* HAL_FLASH_MODULE_ENABLED */ 165 | /** 166 | * @} 167 | */ 168 | 169 | /** 170 | * @} 171 | */ 172 | 173 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc/usbd_cdc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_cdc.h 4 | * @author MCD Application Team 5 | * @brief header file for the usbd_cdc.c file. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2015 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __USB_CDC_H 21 | #define __USB_CDC_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbd_ioreq.h" 29 | 30 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 31 | * @{ 32 | */ 33 | 34 | /** @defgroup usbd_cdc 35 | * @brief This file is the Header file for usbd_cdc.c 36 | * @{ 37 | */ 38 | 39 | 40 | /** @defgroup usbd_cdc_Exported_Defines 41 | * @{ 42 | */ 43 | #ifndef CDC_IN_EP 44 | #define CDC_IN_EP 0x81U /* EP1 for data IN */ 45 | #endif /* CDC_IN_EP */ 46 | #ifndef CDC_OUT_EP 47 | #define CDC_OUT_EP 0x01U /* EP1 for data OUT */ 48 | #endif /* CDC_OUT_EP */ 49 | #ifndef CDC_CMD_EP 50 | #define CDC_CMD_EP 0x82U /* EP2 for CDC commands */ 51 | #endif /* CDC_CMD_EP */ 52 | 53 | #ifndef CDC_HS_BINTERVAL 54 | #define CDC_HS_BINTERVAL 0x10U 55 | #endif /* CDC_HS_BINTERVAL */ 56 | 57 | #ifndef CDC_FS_BINTERVAL 58 | #define CDC_FS_BINTERVAL 0x10U 59 | #endif /* CDC_FS_BINTERVAL */ 60 | 61 | /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ 62 | #define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */ 63 | #define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */ 64 | #define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */ 65 | 66 | #define USB_CDC_CONFIG_DESC_SIZ 67U 67 | #define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE 68 | #define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE 69 | 70 | #define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE 71 | #define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE 72 | 73 | #define CDC_REQ_MAX_DATA_SIZE 0x7U 74 | /*---------------------------------------------------------------------*/ 75 | /* CDC definitions */ 76 | /*---------------------------------------------------------------------*/ 77 | #define CDC_SEND_ENCAPSULATED_COMMAND 0x00U 78 | #define CDC_GET_ENCAPSULATED_RESPONSE 0x01U 79 | #define CDC_SET_COMM_FEATURE 0x02U 80 | #define CDC_GET_COMM_FEATURE 0x03U 81 | #define CDC_CLEAR_COMM_FEATURE 0x04U 82 | #define CDC_SET_LINE_CODING 0x20U 83 | #define CDC_GET_LINE_CODING 0x21U 84 | #define CDC_SET_CONTROL_LINE_STATE 0x22U 85 | #define CDC_SEND_BREAK 0x23U 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | 92 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 93 | * @{ 94 | */ 95 | 96 | /** 97 | * @} 98 | */ 99 | typedef struct 100 | { 101 | uint32_t bitrate; 102 | uint8_t format; 103 | uint8_t paritytype; 104 | uint8_t datatype; 105 | } USBD_CDC_LineCodingTypeDef; 106 | 107 | typedef struct _USBD_CDC_Itf 108 | { 109 | int8_t (* Init)(void); 110 | int8_t (* DeInit)(void); 111 | int8_t (* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length); 112 | int8_t (* Receive)(uint8_t *Buf, uint32_t *Len); 113 | int8_t (* TransmitCplt)(uint8_t *Buf, uint32_t *Len, uint8_t epnum); 114 | } USBD_CDC_ItfTypeDef; 115 | 116 | 117 | typedef struct 118 | { 119 | uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32-bit alignment */ 120 | uint8_t CmdOpCode; 121 | uint8_t CmdLength; 122 | uint8_t *RxBuffer; 123 | uint8_t *TxBuffer; 124 | uint32_t RxLength; 125 | uint32_t TxLength; 126 | 127 | __IO uint32_t TxState; 128 | __IO uint32_t RxState; 129 | } USBD_CDC_HandleTypeDef; 130 | 131 | 132 | 133 | /** @defgroup USBD_CORE_Exported_Macros 134 | * @{ 135 | */ 136 | 137 | /** 138 | * @} 139 | */ 140 | 141 | /** @defgroup USBD_CORE_Exported_Variables 142 | * @{ 143 | */ 144 | 145 | extern USBD_ClassTypeDef USBD_CDC; 146 | #define USBD_CDC_CLASS &USBD_CDC 147 | /** 148 | * @} 149 | */ 150 | 151 | /** @defgroup USB_CORE_Exported_Functions 152 | * @{ 153 | */ 154 | uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev, 155 | USBD_CDC_ItfTypeDef *fops); 156 | 157 | uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, 158 | uint32_t length); 159 | 160 | uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff); 161 | uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev); 162 | uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev); 163 | /** 164 | * @} 165 | */ 166 | 167 | #ifdef __cplusplus 168 | } 169 | #endif 170 | 171 | #endif /* __USB_CDC_H */ 172 | /** 173 | * @} 174 | */ 175 | 176 | /** 177 | * @} 178 | */ 179 | 180 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/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 is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __USBD_CORE_H 21 | #define __USBD_CORE_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbd_conf.h" 29 | #include "usbd_def.h" 30 | #include "usbd_ioreq.h" 31 | #include "usbd_ctlreq.h" 32 | 33 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 34 | * @{ 35 | */ 36 | 37 | /** @defgroup USBD_CORE 38 | * @brief This file is the Header file for usbd_core.c file 39 | * @{ 40 | */ 41 | 42 | 43 | /** @defgroup USBD_CORE_Exported_Defines 44 | * @{ 45 | */ 46 | #ifndef USBD_DEBUG_LEVEL 47 | #define USBD_DEBUG_LEVEL 0U 48 | #endif /* USBD_DEBUG_LEVEL */ 49 | /** 50 | * @} 51 | */ 52 | 53 | 54 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 55 | * @{ 56 | */ 57 | 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | 64 | 65 | /** @defgroup USBD_CORE_Exported_Macros 66 | * @{ 67 | */ 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup USBD_CORE_Exported_Variables 74 | * @{ 75 | */ 76 | #define USBD_SOF USBD_LL_SOF 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @defgroup USBD_CORE_Exported_FunctionsPrototype 82 | * @{ 83 | */ 84 | USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id); 85 | USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev); 86 | USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev); 87 | USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev); 88 | USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass); 89 | 90 | #ifdef USE_USBD_COMPOSITE 91 | USBD_StatusTypeDef USBD_RegisterClassComposite(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass, 92 | USBD_CompositeClassTypeDef classtype, uint8_t *EpAddr); 93 | 94 | USBD_StatusTypeDef USBD_UnRegisterClassComposite(USBD_HandleTypeDef *pdev); 95 | uint8_t USBD_CoreGetEPAdd(USBD_HandleTypeDef *pdev, uint8_t ep_dir, uint8_t ep_type); 96 | #endif /* USE_USBD_COMPOSITE */ 97 | 98 | uint8_t USBD_CoreFindIF(USBD_HandleTypeDef *pdev, uint8_t index); 99 | uint8_t USBD_CoreFindEP(USBD_HandleTypeDef *pdev, uint8_t index); 100 | 101 | USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev); 102 | USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 103 | USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 104 | 105 | USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup); 106 | USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata); 107 | USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata); 108 | 109 | USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev); 110 | USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed); 111 | USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev); 112 | USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev); 113 | 114 | USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev); 115 | USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 116 | USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 117 | 118 | USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev); 119 | USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev); 120 | 121 | /* USBD Low Level Driver */ 122 | USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev); 123 | USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev); 124 | USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev); 125 | USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev); 126 | 127 | USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, 128 | uint8_t ep_type, uint16_t ep_mps); 129 | 130 | USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 131 | USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 132 | USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 133 | USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 134 | USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr); 135 | 136 | USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, 137 | uint8_t *pbuf, uint32_t size); 138 | 139 | USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, 140 | uint8_t *pbuf, uint32_t size); 141 | 142 | #ifdef USBD_HS_TESTMODE_ENABLE 143 | USBD_StatusTypeDef USBD_LL_SetTestMode(USBD_HandleTypeDef *pdev, uint8_t testmode); 144 | #endif /* USBD_HS_TESTMODE_ENABLE */ 145 | 146 | uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 147 | uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 148 | 149 | void USBD_LL_Delay(uint32_t Delay); 150 | 151 | void *USBD_GetEpDesc(uint8_t *pConfDesc, uint8_t EpAddr); 152 | USBD_DescHeaderTypeDef *USBD_GetNextDesc(uint8_t *pbuf, uint16_t *ptr); 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | #ifdef __cplusplus 159 | } 160 | #endif 161 | 162 | #endif /* __USBD_CORE_H */ 163 | 164 | /** 165 | * @} 166 | */ 167 | 168 | /** 169 | * @} 170 | */ 171 | 172 | 173 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/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 is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __USB_REQUEST_H 21 | #define __USB_REQUEST_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbd_def.h" 29 | 30 | 31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 32 | * @{ 33 | */ 34 | 35 | /** @defgroup USBD_REQ 36 | * @brief header file for the usbd_req.c file 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USBD_REQ_Exported_Defines 41 | * @{ 42 | */ 43 | /** 44 | * @} 45 | */ 46 | 47 | 48 | /** @defgroup USBD_REQ_Exported_Types 49 | * @{ 50 | */ 51 | /** 52 | * @} 53 | */ 54 | 55 | 56 | 57 | /** @defgroup USBD_REQ_Exported_Macros 58 | * @{ 59 | */ 60 | /** 61 | * @} 62 | */ 63 | 64 | /** @defgroup USBD_REQ_Exported_Variables 65 | * @{ 66 | */ 67 | /** 68 | * @} 69 | */ 70 | 71 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 72 | * @{ 73 | */ 74 | 75 | USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 76 | USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 77 | USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 78 | 79 | void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 80 | void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata); 81 | void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len); 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* __USB_REQUEST_H */ 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | 102 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/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 is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __USBD_IOREQ_H 21 | #define __USBD_IOREQ_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbd_def.h" 29 | #include "usbd_core.h" 30 | 31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 32 | * @{ 33 | */ 34 | 35 | /** @defgroup USBD_IOREQ 36 | * @brief header file for the usbd_ioreq.c file 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USBD_IOREQ_Exported_Defines 41 | * @{ 42 | */ 43 | /** 44 | * @} 45 | */ 46 | 47 | 48 | /** @defgroup USBD_IOREQ_Exported_Types 49 | * @{ 50 | */ 51 | 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | 58 | 59 | /** @defgroup USBD_IOREQ_Exported_Macros 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup USBD_IOREQ_Exported_Variables 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype 76 | * @{ 77 | */ 78 | 79 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev, 80 | uint8_t *pbuf, uint32_t len); 81 | 82 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, 83 | uint8_t *pbuf, uint32_t len); 84 | 85 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, 86 | uint8_t *pbuf, uint32_t len); 87 | 88 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, 89 | uint8_t *pbuf, uint32_t len); 90 | 91 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev); 92 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev); 93 | 94 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr); 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | #endif /* __USBD_IOREQ_H */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** 111 | * @} 112 | */ 113 | 114 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Middlewares/ST/STM32_USB_Device_Library/Core/Src/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 is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Includes ------------------------------------------------------------------*/ 20 | #include "usbd_ioreq.h" 21 | 22 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 23 | * @{ 24 | */ 25 | 26 | 27 | /** @defgroup USBD_IOREQ 28 | * @brief control I/O requests module 29 | * @{ 30 | */ 31 | 32 | /** @defgroup USBD_IOREQ_Private_TypesDefinitions 33 | * @{ 34 | */ 35 | /** 36 | * @} 37 | */ 38 | 39 | 40 | /** @defgroup USBD_IOREQ_Private_Defines 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @defgroup USBD_IOREQ_Private_Macros 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_IOREQ_Private_Variables 58 | * @{ 59 | */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | 66 | /** @defgroup USBD_IOREQ_Private_FunctionPrototypes 67 | * @{ 68 | */ 69 | /** 70 | * @} 71 | */ 72 | 73 | 74 | /** @defgroup USBD_IOREQ_Private_Functions 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @brief USBD_CtlSendData 80 | * send data on the ctl pipe 81 | * @param pdev: device instance 82 | * @param buff: pointer to data buffer 83 | * @param len: length of data to be sent 84 | * @retval status 85 | */ 86 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev, 87 | uint8_t *pbuf, uint32_t len) 88 | { 89 | /* Set EP0 State */ 90 | pdev->ep0_state = USBD_EP0_DATA_IN; 91 | pdev->ep_in[0].total_length = len; 92 | 93 | #ifdef USBD_AVOID_PACKET_SPLIT_MPS 94 | pdev->ep_in[0].rem_length = 0U; 95 | #else 96 | pdev->ep_in[0].rem_length = len; 97 | #endif /* USBD_AVOID_PACKET_SPLIT_MPS */ 98 | 99 | /* Start the transfer */ 100 | (void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len); 101 | 102 | return USBD_OK; 103 | } 104 | 105 | /** 106 | * @brief USBD_CtlContinueSendData 107 | * continue sending data on the ctl pipe 108 | * @param pdev: device instance 109 | * @param buff: pointer to data buffer 110 | * @param len: length of data to be sent 111 | * @retval status 112 | */ 113 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, 114 | uint8_t *pbuf, uint32_t len) 115 | { 116 | /* Start the next transfer */ 117 | (void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len); 118 | 119 | return USBD_OK; 120 | } 121 | 122 | /** 123 | * @brief USBD_CtlPrepareRx 124 | * receive data on the ctl pipe 125 | * @param pdev: device instance 126 | * @param buff: pointer to data buffer 127 | * @param len: length of data to be received 128 | * @retval status 129 | */ 130 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, 131 | uint8_t *pbuf, uint32_t len) 132 | { 133 | /* Set EP0 State */ 134 | pdev->ep0_state = USBD_EP0_DATA_OUT; 135 | pdev->ep_out[0].total_length = len; 136 | 137 | #ifdef USBD_AVOID_PACKET_SPLIT_MPS 138 | pdev->ep_out[0].rem_length = 0U; 139 | #else 140 | pdev->ep_out[0].rem_length = len; 141 | #endif /* USBD_AVOID_PACKET_SPLIT_MPS */ 142 | 143 | /* Start the transfer */ 144 | (void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); 145 | 146 | return USBD_OK; 147 | } 148 | 149 | /** 150 | * @brief USBD_CtlContinueRx 151 | * continue receive data on the ctl pipe 152 | * @param pdev: device instance 153 | * @param buff: pointer to data buffer 154 | * @param len: length of data to be received 155 | * @retval status 156 | */ 157 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, 158 | uint8_t *pbuf, uint32_t len) 159 | { 160 | (void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); 161 | 162 | return USBD_OK; 163 | } 164 | 165 | /** 166 | * @brief USBD_CtlSendStatus 167 | * send zero lzngth packet on the ctl pipe 168 | * @param pdev: device instance 169 | * @retval status 170 | */ 171 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev) 172 | { 173 | /* Set EP0 State */ 174 | pdev->ep0_state = USBD_EP0_STATUS_IN; 175 | 176 | /* Start the transfer */ 177 | (void)USBD_LL_Transmit(pdev, 0x00U, NULL, 0U); 178 | 179 | return USBD_OK; 180 | } 181 | 182 | /** 183 | * @brief USBD_CtlReceiveStatus 184 | * receive zero lzngth packet on the ctl pipe 185 | * @param pdev: device instance 186 | * @retval status 187 | */ 188 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev) 189 | { 190 | /* Set EP0 State */ 191 | pdev->ep0_state = USBD_EP0_STATUS_OUT; 192 | 193 | /* Start the transfer */ 194 | (void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U); 195 | 196 | return USBD_OK; 197 | } 198 | 199 | /** 200 | * @brief USBD_GetRxCount 201 | * returns the received data length 202 | * @param pdev: device instance 203 | * @param ep_addr: endpoint address 204 | * @retval Rx Data blength 205 | */ 206 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr) 207 | { 208 | return USBD_LL_GetRxDataSize(pdev, ep_addr); 209 | } 210 | 211 | /** 212 | * @} 213 | */ 214 | 215 | 216 | /** 217 | * @} 218 | */ 219 | 220 | 221 | /** 222 | * @} 223 | */ 224 | 225 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/Middlewares/ST/STM32_USB_Device_Library/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the SLA0044 license shall apply and are fully reproduced below: 5 | 6 | SLA0044 Rev5/February 2018 7 | 8 | Software license agreement 9 | 10 | ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT 11 | 12 | BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE 13 | OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS 14 | INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES 15 | (STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON 16 | BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES 17 | TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT. 18 | 19 | Under STMicroelectronics’ intellectual property rights, the redistribution, 20 | reproduction and use in source and binary forms of the software or any part 21 | thereof, with or without modification, are permitted provided that the following 22 | conditions are met: 23 | 24 | 1. Redistribution of source code (modified or not) must retain any copyright 25 | notice, this list of conditions and the disclaimer set forth below as items 10 26 | and 11. 27 | 28 | 2. Redistributions in binary form, except as embedded into microcontroller or 29 | microprocessor device manufactured by or for STMicroelectronics or a software 30 | update for such device, must reproduce any copyright notice provided with the 31 | binary code, this list of conditions, and the disclaimer set forth below as 32 | items 10 and 11, in documentation and/or other materials provided with the 33 | distribution. 34 | 35 | 3. Neither the name of STMicroelectronics nor the names of other contributors to 36 | this software may be used to endorse or promote products derived from this 37 | software or part thereof without specific written permission. 38 | 39 | 4. This software or any part thereof, including modifications and/or derivative 40 | works of this software, must be used and execute solely and exclusively on or in 41 | combination with a microcontroller or microprocessor device manufactured by or 42 | for STMicroelectronics. 43 | 44 | 5. No use, reproduction or redistribution of this software partially or totally 45 | may be done in any manner that would subject this software to any Open Source 46 | Terms. “Open Source Terms” shall mean any open source license which requires as 47 | part of distribution of software that the source code of such software is 48 | distributed therewith or otherwise made available, or open source license that 49 | substantially complies with the Open Source definition specified at 50 | www.opensource.org and any other comparable open source license such as for 51 | example GNU General Public License (GPL), Eclipse Public License (EPL), Apache 52 | Software License, BSD license or MIT license. 53 | 54 | 6. STMicroelectronics has no obligation to provide any maintenance, support or 55 | updates for the software. 56 | 57 | 7. The software is and will remain the exclusive property of STMicroelectronics 58 | and its licensors. The recipient will not take any action that jeopardizes 59 | STMicroelectronics and its licensors' proprietary rights or acquire any rights 60 | in the software, except the limited rights specified hereunder. 61 | 62 | 8. The recipient shall comply with all applicable laws and regulations affecting 63 | the use of the software or any part thereof including any applicable export 64 | control law or regulation. 65 | 66 | 9. Redistribution and use of this software or any part thereof other than as 67 | permitted under this license is void and will automatically terminate your 68 | rights under this license. 69 | 70 | 10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND 71 | ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 72 | IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 73 | NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE 74 | DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL 75 | STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 76 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 77 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 78 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 79 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 80 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 81 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 82 | 83 | 11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER 84 | EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY 85 | RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY. 86 | 87 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/STM32F413RG_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ***************************************************************************** 3 | ** 4 | 5 | ** File : stm32_flash.ld 6 | ** 7 | ** Author : Auto-generated by TrueSTUDIO for STM32 8 | ** 9 | ** Abstract : Linker script for STM32F413RG Device with 10 | ** 1024KByte FLASH, 320KByte RAM 11 | ** 12 | ** Set heap size, stack size and stack location according 13 | ** to application requirements. 14 | ** 15 | ** Set memory bank area and size if external memory is used. 16 | ** 17 | ** Target : STMicroelectronics STM32 18 | ** 19 | ** Distribution: The file is distributed as is, without any warranty 20 | ** of any kind. 21 | ** 22 | ***************************************************************************** 23 | ** @attention 24 | ** 25 | **

© COPYRIGHT(c) 2019 STMicroelectronics

26 | ** 27 | ** Redistribution and use in source and binary forms, with or without modification, 28 | ** are permitted provided that the following conditions are met: 29 | ** 1. Redistributions of source code must retain the above copyright notice, 30 | ** this list of conditions and the following disclaimer. 31 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 32 | ** this list of conditions and the following disclaimer in the documentation 33 | ** and/or other materials provided with the distribution. 34 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors 35 | ** may be used to endorse or promote products derived from this software 36 | ** without specific prior written permission. 37 | ** 38 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 41 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 42 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 43 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 44 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 45 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 47 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | ** 49 | ***************************************************************************** 50 | */ 51 | 52 | /* Entry Point */ 53 | ENTRY(Reset_Handler) 54 | 55 | /* Highest address of the user mode stack */ 56 | _estack = 0x20050000; /* end of RAM */ 57 | /* Generate a link error if heap and stack don't fit into RAM */ 58 | _Min_Heap_Size = 0x200; /* required amount of heap */ 59 | _Min_Stack_Size = 0x400; /* required amount of stack */ 60 | 61 | /* Specify the memory areas */ 62 | MEMORY 63 | { 64 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K 65 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K 66 | } 67 | 68 | /* Define output sections */ 69 | SECTIONS 70 | { 71 | /* The startup code goes first into FLASH */ 72 | .isr_vector : 73 | { 74 | . = ALIGN(4); 75 | KEEP(*(.isr_vector)) /* Startup code */ 76 | . = ALIGN(4); 77 | } >FLASH 78 | 79 | /* The program code and other data goes into FLASH */ 80 | .text : 81 | { 82 | . = ALIGN(4); 83 | *(.text) /* .text sections (code) */ 84 | *(.text*) /* .text* sections (code) */ 85 | *(.glue_7) /* glue arm to thumb code */ 86 | *(.glue_7t) /* glue thumb to arm code */ 87 | *(.eh_frame) 88 | 89 | KEEP (*(.init)) 90 | KEEP (*(.fini)) 91 | 92 | . = ALIGN(4); 93 | _etext = .; /* define a global symbols at end of code */ 94 | } >FLASH 95 | 96 | /* Constant data goes into FLASH */ 97 | .rodata : 98 | { 99 | . = ALIGN(4); 100 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 101 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 102 | . = ALIGN(4); 103 | } >FLASH 104 | 105 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 106 | .ARM : { 107 | __exidx_start = .; 108 | *(.ARM.exidx*) 109 | __exidx_end = .; 110 | } >FLASH 111 | 112 | .preinit_array : 113 | { 114 | PROVIDE_HIDDEN (__preinit_array_start = .); 115 | KEEP (*(.preinit_array*)) 116 | PROVIDE_HIDDEN (__preinit_array_end = .); 117 | } >FLASH 118 | .init_array : 119 | { 120 | PROVIDE_HIDDEN (__init_array_start = .); 121 | KEEP (*(SORT(.init_array.*))) 122 | KEEP (*(.init_array*)) 123 | PROVIDE_HIDDEN (__init_array_end = .); 124 | } >FLASH 125 | .fini_array : 126 | { 127 | PROVIDE_HIDDEN (__fini_array_start = .); 128 | KEEP (*(SORT(.fini_array.*))) 129 | KEEP (*(.fini_array*)) 130 | PROVIDE_HIDDEN (__fini_array_end = .); 131 | } >FLASH 132 | 133 | /* used by the startup to initialize data */ 134 | _sidata = LOADADDR(.data); 135 | 136 | /* Initialized data sections goes into RAM, load LMA copy after code */ 137 | .data : 138 | { 139 | . = ALIGN(4); 140 | _sdata = .; /* create a global symbol at data start */ 141 | *(.data) /* .data sections */ 142 | *(.data*) /* .data* sections */ 143 | 144 | . = ALIGN(4); 145 | _edata = .; /* define a global symbol at data end */ 146 | } >RAM AT> FLASH 147 | 148 | 149 | /* Uninitialized data section */ 150 | . = ALIGN(4); 151 | .bss : 152 | { 153 | /* This is used by the startup in order to initialize the .bss secion */ 154 | _sbss = .; /* define a global symbol at bss start */ 155 | __bss_start__ = _sbss; 156 | *(.bss) 157 | *(.bss*) 158 | *(COMMON) 159 | 160 | . = ALIGN(4); 161 | _ebss = .; /* define a global symbol at bss end */ 162 | __bss_end__ = _ebss; 163 | } >RAM 164 | 165 | /* User_heap_stack section, used to check that there is enough RAM left */ 166 | ._user_heap_stack : 167 | { 168 | . = ALIGN(4); 169 | PROVIDE ( end = . ); 170 | PROVIDE ( _end = . ); 171 | . = . + _Min_Heap_Size; 172 | . = . + _Min_Stack_Size; 173 | . = ALIGN(4); 174 | } >RAM 175 | 176 | 177 | 178 | /* Remove information from the standard libraries */ 179 | /DISCARD/ : 180 | { 181 | libc.a ( * ) 182 | libm.a ( * ) 183 | libgcc.a ( * ) 184 | } 185 | 186 | .ARM.attributes 0 : { *(.ARM.attributes) } 187 | } 188 | 189 | 190 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/USB_DEVICE/App/usb_device.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usb_device.c 5 | * @version : v1.0_Cube 6 | * @brief : This file implements the USB Device 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2019 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | 24 | #include "usb_device.h" 25 | #include "usbd_core.h" 26 | #include "usbd_desc.h" 27 | #include "usbd_cdc.h" 28 | #include "usbd_cdc_if.h" 29 | 30 | /* USER CODE BEGIN Includes */ 31 | 32 | /* USER CODE END Includes */ 33 | 34 | /* USER CODE BEGIN PV */ 35 | /* Private variables ---------------------------------------------------------*/ 36 | 37 | /* USER CODE END PV */ 38 | 39 | /* USER CODE BEGIN PFP */ 40 | /* Private function prototypes -----------------------------------------------*/ 41 | 42 | /* USER CODE END PFP */ 43 | 44 | /* USB Device Core handle declaration. */ 45 | USBD_HandleTypeDef hUsbDeviceFS; 46 | 47 | /* 48 | * -- Insert your variables declaration here -- 49 | */ 50 | /* USER CODE BEGIN 0 */ 51 | 52 | /* USER CODE END 0 */ 53 | 54 | /* 55 | * -- Insert your external function declaration here -- 56 | */ 57 | /* USER CODE BEGIN 1 */ 58 | 59 | /* USER CODE END 1 */ 60 | 61 | /** 62 | * Init USB device Library, add supported class and start the library 63 | * @retval None 64 | */ 65 | void MX_USB_DEVICE_Init(void) 66 | { 67 | /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ 68 | 69 | /* USER CODE END USB_DEVICE_Init_PreTreatment */ 70 | 71 | /* Init Device Library, add supported class and start the library. */ 72 | if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) 73 | { 74 | Error_Handler(); 75 | } 76 | if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) 77 | { 78 | Error_Handler(); 79 | } 80 | if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) 81 | { 82 | Error_Handler(); 83 | } 84 | if (USBD_Start(&hUsbDeviceFS) != USBD_OK) 85 | { 86 | Error_Handler(); 87 | } 88 | 89 | /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ 90 | 91 | /* USER CODE END USB_DEVICE_Init_PostTreatment */ 92 | } 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/USB_DEVICE/App/usb_device.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usb_device.h 5 | * @version : v1.0_Cube 6 | * @brief : Header for usb_device.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2019 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USB_DEVICE__H__ 24 | #define __USB_DEVICE__H__ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f4xx.h" 32 | #include "stm32f4xx_hal.h" 33 | #include "usbd_def.h" 34 | 35 | /* USER CODE BEGIN INCLUDE */ 36 | 37 | /* USER CODE END INCLUDE */ 38 | 39 | /** @addtogroup USBD_OTG_DRIVER 40 | * @{ 41 | */ 42 | 43 | /** @defgroup USBD_DEVICE USBD_DEVICE 44 | * @brief Device file for Usb otg low level driver. 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables 49 | * @brief Public variables. 50 | * @{ 51 | */ 52 | 53 | /* Private variables ---------------------------------------------------------*/ 54 | /* USER CODE BEGIN PV */ 55 | 56 | /* USER CODE END PV */ 57 | 58 | /* Private function prototypes -----------------------------------------------*/ 59 | /* USER CODE BEGIN PFP */ 60 | 61 | /* USER CODE END PFP */ 62 | 63 | /* 64 | * -- Insert your variables declaration here -- 65 | */ 66 | /* USER CODE BEGIN VARIABLES */ 67 | 68 | /* USER CODE END VARIABLES */ 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype 74 | * @brief Declaration of public functions for Usb device. 75 | * @{ 76 | */ 77 | 78 | /** USB Device initialization function. */ 79 | void MX_USB_DEVICE_Init(void); 80 | 81 | /* 82 | * -- Insert functions declaration here -- 83 | */ 84 | /* USER CODE BEGIN FD */ 85 | 86 | /* USER CODE END FD */ 87 | /** 88 | * @} 89 | */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | #ifdef __cplusplus 100 | } 101 | #endif 102 | 103 | #endif /* __USB_DEVICE__H__ */ 104 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/USB_DEVICE/App/usbd_cdc_if.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_cdc_if.h 5 | * @version : v1.0_Cube 6 | * @brief : Header for usbd_cdc_if.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2019 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USBD_CDC_IF_H__ 24 | #define __USBD_CDC_IF_H__ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "usbd_cdc.h" 32 | 33 | /* USER CODE BEGIN INCLUDE */ 34 | 35 | /* USER CODE END INCLUDE */ 36 | 37 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 38 | * @brief For Usb device. 39 | * @{ 40 | */ 41 | 42 | /** @defgroup USBD_CDC_IF USBD_CDC_IF 43 | * @brief Usb VCP device module 44 | * @{ 45 | */ 46 | 47 | /** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines 48 | * @brief Defines. 49 | * @{ 50 | */ 51 | /* Define size for the receive and transmit buffer over CDC */ 52 | #define APP_RX_DATA_SIZE 2048 53 | #define APP_TX_DATA_SIZE 2048 54 | /* USER CODE BEGIN EXPORTED_DEFINES */ 55 | 56 | /* USER CODE END EXPORTED_DEFINES */ 57 | 58 | /** 59 | * @} 60 | */ 61 | 62 | /** @defgroup USBD_CDC_IF_Exported_Types USBD_CDC_IF_Exported_Types 63 | * @brief Types. 64 | * @{ 65 | */ 66 | 67 | /* USER CODE BEGIN EXPORTED_TYPES */ 68 | 69 | /* USER CODE END EXPORTED_TYPES */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBD_CDC_IF_Exported_Macros USBD_CDC_IF_Exported_Macros 76 | * @brief Aliases. 77 | * @{ 78 | */ 79 | 80 | /* USER CODE BEGIN EXPORTED_MACRO */ 81 | 82 | /* USER CODE END EXPORTED_MACRO */ 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables 89 | * @brief Public variables. 90 | * @{ 91 | */ 92 | 93 | /** CDC Interface callback. */ 94 | extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS; 95 | 96 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 97 | 98 | /* USER CODE END EXPORTED_VARIABLES */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /** @defgroup USBD_CDC_IF_Exported_FunctionsPrototype USBD_CDC_IF_Exported_FunctionsPrototype 105 | * @brief Public functions declaration. 106 | * @{ 107 | */ 108 | 109 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len); 110 | 111 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */ 112 | 113 | /* USER CODE END EXPORTED_FUNCTIONS */ 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /** 120 | * @} 121 | */ 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | #ifdef __cplusplus 128 | } 129 | #endif 130 | 131 | #endif /* __USBD_CDC_IF_H__ */ 132 | 133 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/USB_DEVICE/App/usbd_desc.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_desc.c 5 | * @version : v1.0_Cube 6 | * @brief : Header for usbd_conf.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2019 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __USBD_DESC__C__ 23 | #define __USBD_DESC__C__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "usbd_def.h" 31 | 32 | /* USER CODE BEGIN INCLUDE */ 33 | 34 | /* USER CODE END INCLUDE */ 35 | 36 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USBD_DESC USBD_DESC 41 | * @brief Usb device descriptors module. 42 | * @{ 43 | */ 44 | 45 | /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants 46 | * @brief Constants. 47 | * @{ 48 | */ 49 | #define DEVICE_ID1 (UID_BASE) 50 | #define DEVICE_ID2 (UID_BASE + 0x4) 51 | #define DEVICE_ID3 (UID_BASE + 0x8) 52 | 53 | #define USB_SIZ_STRING_SERIAL 0x1A 54 | 55 | /* USER CODE BEGIN EXPORTED_CONSTANTS */ 56 | 57 | /* USER CODE END EXPORTED_CONSTANTS */ 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | /** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines 64 | * @brief Defines. 65 | * @{ 66 | */ 67 | 68 | /* USER CODE BEGIN EXPORTED_DEFINES */ 69 | 70 | /* USER CODE END EXPORTED_DEFINES */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions 77 | * @brief Types. 78 | * @{ 79 | */ 80 | 81 | /* USER CODE BEGIN EXPORTED_TYPES */ 82 | 83 | /* USER CODE END EXPORTED_TYPES */ 84 | 85 | /** 86 | * @} 87 | */ 88 | 89 | /** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros 90 | * @brief Aliases. 91 | * @{ 92 | */ 93 | 94 | /* USER CODE BEGIN EXPORTED_MACRO */ 95 | 96 | /* USER CODE END EXPORTED_MACRO */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables 103 | * @brief Public variables. 104 | * @{ 105 | */ 106 | 107 | /** Descriptor for the Usb device. */ 108 | extern USBD_DescriptorsTypeDef FS_Desc; 109 | 110 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 111 | 112 | /* USER CODE END EXPORTED_VARIABLES */ 113 | 114 | /** 115 | * @} 116 | */ 117 | 118 | /** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype 119 | * @brief Public functions declaration. 120 | * @{ 121 | */ 122 | 123 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */ 124 | 125 | /* USER CODE END EXPORTED_FUNCTIONS */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | /** 136 | * @} 137 | */ 138 | 139 | #ifdef __cplusplus 140 | } 141 | #endif 142 | 143 | #endif /* __USBD_DESC__C__ */ 144 | 145 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/USB_DEVICE/Target/usbd_conf.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_conf.h 5 | * @version : v1.0_Cube 6 | * @brief : Header for usbd_conf.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2019 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USBD_CONF__H__ 24 | #define __USBD_CONF__H__ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include 32 | #include 33 | #include 34 | #include "main.h" 35 | #include "stm32f4xx.h" 36 | #include "stm32f4xx_hal.h" 37 | 38 | /* USER CODE BEGIN INCLUDE */ 39 | // avoiding dynamic memory allocation: ST UM1734 40 | extern void * USBD_static_malloc(uint32_t size); 41 | extern void USBD_static_free(void *p); 42 | /* USER CODE END INCLUDE */ 43 | 44 | /** @addtogroup USBD_OTG_DRIVER 45 | * @brief Driver for Usb device. 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_CONF USBD_CONF 50 | * @brief Configuration file for Usb otg low level driver. 51 | * @{ 52 | */ 53 | 54 | /** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables 55 | * @brief Public variables. 56 | * @{ 57 | */ 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | /** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines 64 | * @brief Defines for configuration of the Usb device. 65 | * @{ 66 | */ 67 | 68 | /*---------- -----------*/ 69 | #define USBD_MAX_NUM_INTERFACES 1U 70 | /*---------- -----------*/ 71 | #define USBD_MAX_NUM_CONFIGURATION 1U 72 | /*---------- -----------*/ 73 | #define USBD_MAX_STR_DESC_SIZ 512U 74 | /*---------- -----------*/ 75 | #define USBD_DEBUG_LEVEL 0U 76 | /*---------- -----------*/ 77 | #define USBD_LPM_ENABLED 0U 78 | /*---------- -----------*/ 79 | #define USBD_SELF_POWERED 1U 80 | 81 | /****************************************/ 82 | /* #define for FS and HS identification */ 83 | #define DEVICE_FS 0 84 | #define DEVICE_HS 1 85 | 86 | /** 87 | * @} 88 | */ 89 | 90 | /** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros 91 | * @brief Aliases. 92 | * @{ 93 | */ 94 | /* Memory management macros make sure to use static memory allocation */ 95 | /** Alias for memory allocation. */ 96 | 97 | #define USBD_malloc (void *)USBD_static_malloc 98 | 99 | /** Alias for memory release. */ 100 | #define USBD_free USBD_static_free 101 | 102 | /** Alias for memory set. */ 103 | #define USBD_memset memset 104 | 105 | /** Alias for memory copy. */ 106 | #define USBD_memcpy memcpy 107 | 108 | /** Alias for delay. */ 109 | #define USBD_Delay HAL_Delay 110 | 111 | /* DEBUG macros */ 112 | 113 | #if (USBD_DEBUG_LEVEL > 0) 114 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\ 115 | printf("\n"); 116 | #else 117 | #define USBD_UsrLog(...) 118 | #endif /* (USBD_DEBUG_LEVEL > 0U) */ 119 | 120 | #if (USBD_DEBUG_LEVEL > 1) 121 | 122 | #define USBD_ErrLog(...) printf("ERROR: ");\ 123 | printf(__VA_ARGS__);\ 124 | printf("\n"); 125 | #else 126 | #define USBD_ErrLog(...) 127 | #endif /* (USBD_DEBUG_LEVEL > 1U) */ 128 | 129 | #if (USBD_DEBUG_LEVEL > 2) 130 | #define USBD_DbgLog(...) printf("DEBUG : ");\ 131 | printf(__VA_ARGS__);\ 132 | printf("\n"); 133 | #else 134 | #define USBD_DbgLog(...) 135 | #endif /* (USBD_DEBUG_LEVEL > 2U) */ 136 | 137 | /** 138 | * @} 139 | */ 140 | 141 | /** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types 142 | * @brief Types. 143 | * @{ 144 | */ 145 | 146 | /** 147 | * @} 148 | */ 149 | 150 | /** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype 151 | * @brief Declaration of public functions for Usb device. 152 | * @{ 153 | */ 154 | 155 | /* Exported functions -------------------------------------------------------*/ 156 | void *USBD_static_malloc(uint32_t size); 157 | void USBD_static_free(void *p); 158 | 159 | /** 160 | * @} 161 | */ 162 | 163 | /** 164 | * @} 165 | */ 166 | 167 | /** 168 | * @} 169 | */ 170 | 171 | #ifdef __cplusplus 172 | } 173 | #endif 174 | 175 | #endif /* __USBD_CONF__H__ */ 176 | 177 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/dipCAN.elf.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/freeRTOS/include/FreeRTOSConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.2.0 3 | * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * 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, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | 29 | #ifndef FREERTOS_CONFIG_H 30 | #define FREERTOS_CONFIG_H 31 | 32 | /*----------------------------------------------------------- 33 | * Application specific definitions. 34 | * 35 | * These definitions should be adjusted for your particular hardware and 36 | * application requirements. 37 | * 38 | * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE 39 | * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. 40 | * 41 | * See http://www.freertos.org/a00110.html 42 | *----------------------------------------------------------*/ 43 | 44 | /* Ensure stdint is only used by the compiler, and not the assembler. */ 45 | #include 46 | extern uint32_t SystemCoreClock; 47 | 48 | #define configUSE_PREEMPTION 1 49 | #define configUSE_IDLE_HOOK 0 50 | #define configUSE_TICK_HOOK 0 51 | #define configCPU_CLOCK_HZ ( SystemCoreClock ) 52 | #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) 53 | #define configMAX_PRIORITIES ( 5 ) 54 | #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 130 ) 55 | #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 75 * 1024 ) ) 56 | #define configMAX_TASK_NAME_LEN ( 10 ) 57 | #define configUSE_TRACE_FACILITY 1 58 | #define configUSE_16_BIT_TICKS 0 59 | #define configIDLE_SHOULD_YIELD 1 60 | #define configUSE_MUTEXES 1 61 | #define configQUEUE_REGISTRY_SIZE 8 62 | #define configCHECK_FOR_STACK_OVERFLOW 0 63 | #define configUSE_RECURSIVE_MUTEXES 0 64 | #define configUSE_MALLOC_FAILED_HOOK 0 65 | #define configUSE_APPLICATION_TASK_TAG 0 66 | #define configUSE_COUNTING_SEMAPHORES 0 67 | #define configGENERATE_RUN_TIME_STATS 1 68 | 69 | /* Run-time statistics */ 70 | void SetupRunTimeStatsTimer(void); 71 | extern volatile unsigned long ulHighFrequencyTimerTicks; 72 | // 73 | #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() SetupRunTimeStatsTimer() 74 | #define portGET_RUN_TIME_COUNTER_VALUE() ulHighFrequencyTimerTicks 75 | 76 | /* Co-routine definitions. */ 77 | #define configUSE_CO_ROUTINES 0 78 | #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) 79 | 80 | /* Software timer definitions. */ 81 | #define configUSE_TIMERS 1 82 | #define configTIMER_TASK_PRIORITY ( 2 ) 83 | #define configTIMER_QUEUE_LENGTH 10 84 | #define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 ) 85 | 86 | /* Set the following definitions to 1 to include the API function, or zero 87 | to exclude the API function. */ 88 | #define INCLUDE_vTaskPrioritySet 1 89 | #define INCLUDE_uxTaskPriorityGet 1 90 | #define INCLUDE_vTaskDelete 1 91 | #define INCLUDE_vTaskCleanUpResources 1 92 | #define INCLUDE_vTaskSuspend 1 93 | #define INCLUDE_vTaskDelayUntil 1 94 | #define INCLUDE_vTaskDelay 1 95 | 96 | /* Cortex-M specific definitions. */ 97 | #ifdef __NVIC_PRIO_BITS 98 | /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ 99 | #define configPRIO_BITS __NVIC_PRIO_BITS 100 | #else 101 | #define configPRIO_BITS 4 /* 15 priority levels */ 102 | #endif 103 | 104 | /* The lowest interrupt priority that can be used in a call to a "set priority" 105 | function. */ 106 | #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0xf 107 | 108 | /* The highest interrupt priority that can be used by any interrupt service 109 | routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL 110 | INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER 111 | PRIORITY THAN THIS! (higher priorities are lower numeric values. */ 112 | #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 113 | 114 | /* Interrupt priorities used by the kernel port layer itself. These are generic 115 | to all Cortex-M ports, and do not rely on any particular library functions. */ 116 | #define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) 117 | /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! 118 | See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ 119 | #define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) 120 | 121 | /* Normal assert() semantics without relying on the provision of an assert.h 122 | header file. */ 123 | #define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); } 124 | 125 | /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS 126 | standard names. */ 127 | #define vPortSVCHandler SVC_Handler 128 | #define xPortPendSVHandler PendSV_Handler 129 | #define xPortSysTickHandler SysTick_Handler 130 | 131 | #endif /* FREERTOS_CONFIG_H */ 132 | 133 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/freeRTOS/include/StackMacros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.2.0 3 | * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * 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, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | #ifndef STACK_MACROS_H 29 | #define STACK_MACROS_H 30 | 31 | #ifndef _MSC_VER /* Visual Studio doesn't support #warning. */ 32 | #warning The name of this file has changed to stack_macros.h. Please update your code accordingly. This source file (which has the original name) will be removed in future released. 33 | #endif 34 | 35 | /* 36 | * Call the stack overflow hook function if the stack of the task being swapped 37 | * out is currently overflowed, or looks like it might have overflowed in the 38 | * past. 39 | * 40 | * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check 41 | * the current stack state only - comparing the current top of stack value to 42 | * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 43 | * will also cause the last few stack bytes to be checked to ensure the value 44 | * to which the bytes were set when the task was created have not been 45 | * overwritten. Note this second test does not guarantee that an overflowed 46 | * stack will always be recognised. 47 | */ 48 | 49 | /*-----------------------------------------------------------*/ 50 | 51 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) ) 52 | 53 | /* Only the current stack state is to be checked. */ 54 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 55 | { \ 56 | /* Is the currently saved stack pointer within the stack limit? */ \ 57 | if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ 58 | { \ 59 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 60 | } \ 61 | } 62 | 63 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 64 | /*-----------------------------------------------------------*/ 65 | 66 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) ) 67 | 68 | /* Only the current stack state is to be checked. */ 69 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 70 | { \ 71 | \ 72 | /* Is the currently saved stack pointer within the stack limit? */ \ 73 | if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ 74 | { \ 75 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 76 | } \ 77 | } 78 | 79 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 80 | /*-----------------------------------------------------------*/ 81 | 82 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) 83 | 84 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 85 | { \ 86 | const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \ 87 | const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \ 88 | \ 89 | if( ( pulStack[ 0 ] != ulCheckValue ) || \ 90 | ( pulStack[ 1 ] != ulCheckValue ) || \ 91 | ( pulStack[ 2 ] != ulCheckValue ) || \ 92 | ( pulStack[ 3 ] != ulCheckValue ) ) \ 93 | { \ 94 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 95 | } \ 96 | } 97 | 98 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 99 | /*-----------------------------------------------------------*/ 100 | 101 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) 102 | 103 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 104 | { \ 105 | int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \ 106 | static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 107 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 108 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 109 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 110 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ 111 | \ 112 | \ 113 | pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ 114 | \ 115 | /* Has the extremity of the task stack ever been written over? */ \ 116 | if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ 117 | { \ 118 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 119 | } \ 120 | } 121 | 122 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 123 | /*-----------------------------------------------------------*/ 124 | 125 | /* Remove stack overflow macro if not being used. */ 126 | #ifndef taskCHECK_FOR_STACK_OVERFLOW 127 | #define taskCHECK_FOR_STACK_OVERFLOW() 128 | #endif 129 | 130 | 131 | 132 | #endif /* STACK_MACROS_H */ 133 | 134 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/freeRTOS/include/portable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.2.0 3 | * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * 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, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | /*----------------------------------------------------------- 29 | * Portable layer API. Each function must be defined for each port. 30 | *----------------------------------------------------------*/ 31 | 32 | #ifndef PORTABLE_H 33 | #define PORTABLE_H 34 | 35 | /* Each FreeRTOS port has a unique portmacro.h header file. Originally a 36 | pre-processor definition was used to ensure the pre-processor found the correct 37 | portmacro.h file for the port being used. That scheme was deprecated in favour 38 | of setting the compiler's include path such that it found the correct 39 | portmacro.h file - removing the need for the constant and allowing the 40 | portmacro.h file to be located anywhere in relation to the port being used. 41 | Purely for reasons of backward compatibility the old method is still valid, but 42 | to make it clear that new projects should not use it, support for the port 43 | specific constants has been moved into the deprecated_definitions.h header 44 | file. */ 45 | #include "deprecated_definitions.h" 46 | 47 | /* If portENTER_CRITICAL is not defined then including deprecated_definitions.h 48 | did not result in a portmacro.h header file being included - and it should be 49 | included here. In this case the path to the correct portmacro.h header file 50 | must be set in the compiler's include path. */ 51 | #ifndef portENTER_CRITICAL 52 | #include "portmacro.h" 53 | #endif 54 | 55 | #if portBYTE_ALIGNMENT == 32 56 | #define portBYTE_ALIGNMENT_MASK ( 0x001f ) 57 | #endif 58 | 59 | #if portBYTE_ALIGNMENT == 16 60 | #define portBYTE_ALIGNMENT_MASK ( 0x000f ) 61 | #endif 62 | 63 | #if portBYTE_ALIGNMENT == 8 64 | #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) 65 | #endif 66 | 67 | #if portBYTE_ALIGNMENT == 4 68 | #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) 69 | #endif 70 | 71 | #if portBYTE_ALIGNMENT == 2 72 | #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) 73 | #endif 74 | 75 | #if portBYTE_ALIGNMENT == 1 76 | #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) 77 | #endif 78 | 79 | #ifndef portBYTE_ALIGNMENT_MASK 80 | #error "Invalid portBYTE_ALIGNMENT definition" 81 | #endif 82 | 83 | #ifndef portNUM_CONFIGURABLE_REGIONS 84 | #define portNUM_CONFIGURABLE_REGIONS 1 85 | #endif 86 | 87 | #ifdef __cplusplus 88 | extern "C" { 89 | #endif 90 | 91 | #include "mpu_wrappers.h" 92 | 93 | /* 94 | * Setup the stack of a new task so it is ready to be placed under the 95 | * scheduler control. The registers have to be placed on the stack in 96 | * the order that the port expects to find them. 97 | * 98 | */ 99 | #if( portUSING_MPU_WRAPPERS == 1 ) 100 | #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) 101 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; 102 | #else 103 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; 104 | #endif 105 | #else 106 | #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) 107 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; 108 | #else 109 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; 110 | #endif 111 | #endif 112 | 113 | /* Used by heap_5.c. */ 114 | typedef struct HeapRegion 115 | { 116 | uint8_t *pucStartAddress; 117 | size_t xSizeInBytes; 118 | } HeapRegion_t; 119 | 120 | /* 121 | * Used to define multiple heap regions for use by heap_5.c. This function 122 | * must be called before any calls to pvPortMalloc() - not creating a task, 123 | * queue, semaphore, mutex, software timer, event group, etc. will result in 124 | * pvPortMalloc being called. 125 | * 126 | * pxHeapRegions passes in an array of HeapRegion_t structures - each of which 127 | * defines a region of memory that can be used as the heap. The array is 128 | * terminated by a HeapRegions_t structure that has a size of 0. The region 129 | * with the lowest start address must appear first in the array. 130 | */ 131 | void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION; 132 | 133 | 134 | /* 135 | * Map to the memory management routines required for the port. 136 | */ 137 | void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; 138 | void vPortFree( void *pv ) PRIVILEGED_FUNCTION; 139 | void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; 140 | size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; 141 | size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; 142 | 143 | /* 144 | * Setup the hardware ready for the scheduler to take control. This generally 145 | * sets up a tick interrupt and sets timers for the correct tick frequency. 146 | */ 147 | BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION; 148 | 149 | /* 150 | * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so 151 | * the hardware is left in its original condition after the scheduler stops 152 | * executing. 153 | */ 154 | void vPortEndScheduler( void ) PRIVILEGED_FUNCTION; 155 | 156 | /* 157 | * The structures and methods of manipulating the MPU are contained within the 158 | * port layer. 159 | * 160 | * Fills the xMPUSettings structure with the memory region information 161 | * contained in xRegions. 162 | */ 163 | #if( portUSING_MPU_WRAPPERS == 1 ) 164 | struct xMEMORY_REGION; 165 | void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) PRIVILEGED_FUNCTION; 166 | #endif 167 | 168 | #ifdef __cplusplus 169 | } 170 | #endif 171 | 172 | #endif /* PORTABLE_H */ 173 | 174 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/freeRTOS/include/projdefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.2.0 3 | * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * 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, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | #ifndef PROJDEFS_H 29 | #define PROJDEFS_H 30 | 31 | /* 32 | * Defines the prototype to which task functions must conform. Defined in this 33 | * file to ensure the type is known before portable.h is included. 34 | */ 35 | typedef void (*TaskFunction_t)( void * ); 36 | 37 | /* Converts a time in milliseconds to a time in ticks. This macro can be 38 | overridden by a macro of the same name defined in FreeRTOSConfig.h in case the 39 | definition here is not suitable for your application. */ 40 | #ifndef pdMS_TO_TICKS 41 | #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) 42 | #endif 43 | 44 | #define pdFALSE ( ( BaseType_t ) 0 ) 45 | #define pdTRUE ( ( BaseType_t ) 1 ) 46 | 47 | #define pdPASS ( pdTRUE ) 48 | #define pdFAIL ( pdFALSE ) 49 | #define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) 50 | #define errQUEUE_FULL ( ( BaseType_t ) 0 ) 51 | 52 | /* FreeRTOS error definitions. */ 53 | #define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) 54 | #define errQUEUE_BLOCKED ( -4 ) 55 | #define errQUEUE_YIELD ( -5 ) 56 | 57 | /* Macros used for basic data corruption checks. */ 58 | #ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 59 | #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 60 | #endif 61 | 62 | #if( configUSE_16_BIT_TICKS == 1 ) 63 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a 64 | #else 65 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL 66 | #endif 67 | 68 | /* The following errno values are used by FreeRTOS+ components, not FreeRTOS 69 | itself. */ 70 | #define pdFREERTOS_ERRNO_NONE 0 /* No errors */ 71 | #define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ 72 | #define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ 73 | #define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ 74 | #define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ 75 | #define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ 76 | #define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ 77 | #define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ 78 | #define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ 79 | #define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ 80 | #define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ 81 | #define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ 82 | #define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ 83 | #define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ 84 | #define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ 85 | #define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ 86 | #define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ 87 | #define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ 88 | #define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ 89 | #define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ 90 | #define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ 91 | #define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ 92 | #define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ 93 | #define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ 94 | #define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ 95 | #define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ 96 | #define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ 97 | #define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ 98 | #define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ 99 | #define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ 100 | #define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ 101 | #define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ 102 | #define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ 103 | #define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ 104 | #define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ 105 | #define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ 106 | #define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ 107 | #define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ 108 | #define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ 109 | #define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ 110 | 111 | /* The following endian values are used by FreeRTOS+ components, not FreeRTOS 112 | itself. */ 113 | #define pdFREERTOS_LITTLE_ENDIAN 0 114 | #define pdFREERTOS_BIG_ENDIAN 1 115 | 116 | /* Re-defining endian values for generic naming. */ 117 | #define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN 118 | #define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN 119 | 120 | 121 | #endif /* PROJDEFS_H */ 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/freeRTOS/include/stack_macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.2.0 3 | * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * 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, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | #ifndef STACK_MACROS_H 29 | #define STACK_MACROS_H 30 | 31 | /* 32 | * Call the stack overflow hook function if the stack of the task being swapped 33 | * out is currently overflowed, or looks like it might have overflowed in the 34 | * past. 35 | * 36 | * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check 37 | * the current stack state only - comparing the current top of stack value to 38 | * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 39 | * will also cause the last few stack bytes to be checked to ensure the value 40 | * to which the bytes were set when the task was created have not been 41 | * overwritten. Note this second test does not guarantee that an overflowed 42 | * stack will always be recognised. 43 | */ 44 | 45 | /*-----------------------------------------------------------*/ 46 | 47 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) ) 48 | 49 | /* Only the current stack state is to be checked. */ 50 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 51 | { \ 52 | /* Is the currently saved stack pointer within the stack limit? */ \ 53 | if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ 54 | { \ 55 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 56 | } \ 57 | } 58 | 59 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 60 | /*-----------------------------------------------------------*/ 61 | 62 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) ) 63 | 64 | /* Only the current stack state is to be checked. */ 65 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 66 | { \ 67 | \ 68 | /* Is the currently saved stack pointer within the stack limit? */ \ 69 | if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ 70 | { \ 71 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 72 | } \ 73 | } 74 | 75 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 76 | /*-----------------------------------------------------------*/ 77 | 78 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) 79 | 80 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 81 | { \ 82 | const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \ 83 | const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \ 84 | \ 85 | if( ( pulStack[ 0 ] != ulCheckValue ) || \ 86 | ( pulStack[ 1 ] != ulCheckValue ) || \ 87 | ( pulStack[ 2 ] != ulCheckValue ) || \ 88 | ( pulStack[ 3 ] != ulCheckValue ) ) \ 89 | { \ 90 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 91 | } \ 92 | } 93 | 94 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 95 | /*-----------------------------------------------------------*/ 96 | 97 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) 98 | 99 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 100 | { \ 101 | int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \ 102 | static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 103 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 104 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 105 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 106 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ 107 | \ 108 | \ 109 | pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ 110 | \ 111 | /* Has the extremity of the task stack ever been written over? */ \ 112 | if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ 113 | { \ 114 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 115 | } \ 116 | } 117 | 118 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 119 | /*-----------------------------------------------------------*/ 120 | 121 | /* Remove stack overflow macro if not being used. */ 122 | #ifndef taskCHECK_FOR_STACK_OVERFLOW 123 | #define taskCHECK_FOR_STACK_OVERFLOW() 124 | #endif 125 | 126 | 127 | 128 | #endif /* STACK_MACROS_H */ 129 | 130 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/freeRTOS/include/stdint.readme: -------------------------------------------------------------------------------- 1 | 2 | #ifndef FREERTOS_STDINT 3 | #define FREERTOS_STDINT 4 | 5 | /******************************************************************************* 6 | * THIS IS NOT A FULL stdint.h IMPLEMENTATION - It only contains the definitions 7 | * necessary to build the FreeRTOS code. It is provided to allow FreeRTOS to be 8 | * built using compilers that do not provide their own stdint.h definition. 9 | * 10 | * To use this file: 11 | * 12 | * 1) Copy this file into the directory that contains your FreeRTOSConfig.h 13 | * header file, as that directory will already be in the compilers include 14 | * path. 15 | * 16 | * 2) Rename the copied file stdint.h. 17 | * 18 | */ 19 | 20 | typedef signed char int8_t; 21 | typedef unsigned char uint8_t; 22 | typedef short int16_t; 23 | typedef unsigned short uint16_t; 24 | typedef long int32_t; 25 | typedef unsigned long uint32_t; 26 | 27 | #endif /* FREERTOS_STDINT */ 28 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/freeRTOS/portable/MemMang/ReadMe.url: -------------------------------------------------------------------------------- 1 | [{000214A0-0000-0000-C000-000000000046}] 2 | Prop3=19,2 3 | [InternetShortcut] 4 | URL=http://www.freertos.org/a00111.html 5 | IDList= 6 | -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/freeRTOS/readme.txt: -------------------------------------------------------------------------------- 1 | Each real time kernel port consists of three files that contain the core kernel 2 | components and are common to every port, and one or more files that are 3 | specific to a particular microcontroller and or compiler. 4 | 5 | + The FreeRTOS/Source directory contains the three files that are common to 6 | every port - list.c, queue.c and tasks.c. The kernel is contained within these 7 | three files. croutine.c implements the optional co-routine functionality - which 8 | is normally only used on very memory limited systems. 9 | 10 | + The FreeRTOS/Source/Portable directory contains the files that are specific to 11 | a particular microcontroller and or compiler. 12 | 13 | + The FreeRTOS/Source/include directory contains the real time kernel header 14 | files. 15 | 16 | See the readme file in the FreeRTOS/Source/Portable directory for more 17 | information. -------------------------------------------------------------------------------- /04_canSniffer_FW/board1_STM/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ***************************************************************************** 3 | ** 4 | ** File : syscalls.c 5 | ** 6 | ** Abstract : System Workbench Minimal System calls file 7 | ** 8 | ** For more information about which c-functions 9 | ** need which of these lowlevel functions 10 | ** please consult the Newlib libc-manual 11 | ** 12 | ** Environment : System Workbench for MCU 13 | ** 14 | ** Distribution: The file is distributed as is without any warranty 15 | ** of any kind. 16 | ** 17 | ***************************************************************************** 18 | ** 19 | **

© COPYRIGHT(c) 2014 Ac6

20 | ** 21 | ** Redistribution and use in source and binary forms, with or without modification, 22 | ** are permitted provided that the following conditions are met: 23 | ** 1. Redistributions of source code must retain the above copyright notice, 24 | ** this list of conditions and the following disclaimer. 25 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 26 | ** this list of conditions and the following disclaimer in the documentation 27 | ** and/or other materials provided with the distribution. 28 | ** 3. Neither the name of Ac6 nor the names of its contributors 29 | ** may be used to endorse or promote products derived from this software 30 | ** without specific prior written permission. 31 | ** 32 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 33 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 34 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 35 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 36 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 38 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 39 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 40 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 41 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 | ** 43 | ***************************************************************************** 44 | */ 45 | 46 | /* Includes */ 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | 56 | 57 | /* Variables */ 58 | //#undef errno 59 | extern int errno; 60 | extern int __io_putchar(int ch) __attribute__((weak)); 61 | extern int __io_getchar(void) __attribute__((weak)); 62 | 63 | register char * stack_ptr asm("sp"); 64 | 65 | char *__env[1] = { 0 }; 66 | char **environ = __env; 67 | 68 | 69 | /* Functions */ 70 | void initialise_monitor_handles() 71 | { 72 | } 73 | 74 | int _getpid(void) 75 | { 76 | return 1; 77 | } 78 | 79 | int _kill(int pid, int sig) 80 | { 81 | errno = EINVAL; 82 | return -1; 83 | } 84 | 85 | void _exit (int status) 86 | { 87 | _kill(status, -1); 88 | while (1) {} /* Make sure we hang here */ 89 | } 90 | 91 | int _read (int file, char *ptr, int len) 92 | { 93 | int DataIdx; 94 | 95 | for (DataIdx = 0; DataIdx < len; DataIdx++) 96 | { 97 | *ptr++ = __io_getchar(); 98 | } 99 | 100 | return len; 101 | } 102 | 103 | int _write(int file, char *ptr, int len) 104 | { 105 | int DataIdx; 106 | 107 | for (DataIdx = 0; DataIdx < len; DataIdx++) 108 | { 109 | __io_putchar(*ptr++); 110 | } 111 | return len; 112 | } 113 | 114 | caddr_t _sbrk(int incr) 115 | { 116 | extern char end asm("end"); 117 | static char *heap_end; 118 | char *prev_heap_end; 119 | 120 | if (heap_end == 0) 121 | heap_end = &end; 122 | 123 | prev_heap_end = heap_end; 124 | if (heap_end + incr > stack_ptr) 125 | { 126 | // write(1, "Heap and stack collision\n", 25); 127 | // abort(); 128 | errno = ENOMEM; 129 | return (caddr_t) -1; 130 | } 131 | 132 | heap_end += incr; 133 | 134 | return (caddr_t) prev_heap_end; 135 | } 136 | 137 | int _close(int file) 138 | { 139 | return -1; 140 | } 141 | 142 | 143 | int _fstat(int file, struct stat *st) 144 | { 145 | st->st_mode = S_IFCHR; 146 | return 0; 147 | } 148 | 149 | int _isatty(int file) 150 | { 151 | return 1; 152 | } 153 | 154 | int _lseek(int file, int ptr, int dir) 155 | { 156 | return 0; 157 | } 158 | 159 | int _open(char *path, int flags, ...) 160 | { 161 | /* Pretend like we always fail */ 162 | return -1; 163 | } 164 | 165 | int _wait(int *status) 166 | { 167 | errno = ECHILD; 168 | return -1; 169 | } 170 | 171 | int _unlink(char *name) 172 | { 173 | errno = ENOENT; 174 | return -1; 175 | } 176 | 177 | int _times(struct tms *buf) 178 | { 179 | return -1; 180 | } 181 | 182 | int _stat(char *file, struct stat *st) 183 | { 184 | st->st_mode = S_IFCHR; 185 | return 0; 186 | } 187 | 188 | int _link(char *old, char *new) 189 | { 190 | errno = EMLINK; 191 | return -1; 192 | } 193 | 194 | int _fork(void) 195 | { 196 | errno = EAGAIN; 197 | return -1; 198 | } 199 | 200 | int _execve(char *name, char **argv, char **env) 201 | { 202 | errno = ENOMEM; 203 | return -1; 204 | } 205 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Adam Varga 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 | # canDrive 2 | Tools for hacking your car. Please concider checking out the tutorials made about this project: 3 | https://www.youtube.com/playlist?list=PLNiFaO8hU1z0o_6DSxk-jcVAM3UCUR-pY 4 | 5 | I've created this google sheet, so everybody can freely add their decoded IDs and packets, so it's easier for the community to collaborate: 6 | https://docs.google.com/spreadsheets/d/1eBKiTwEE6aPnfw2EfSHItLeMz00fJq0Y0L99Ym7fKwU/edit?usp=sharing 7 | 8 | # Content 9 | - 01_canSniffer_Arduino: This code runs on your arduino sniffer device and creates an interface between the car and the GUI. 10 | - 02_canSniffer_GUI: Powerful and easy-to-use graphical sniffer application used for reverse engineering CAN packets. Written in Python. 11 | - 03_canSniffer_HW: Hardware projects for the custom OBD2 module. Made in Altium Designer. 12 | - 04_canSniffer_FW: Embedded code running on the custom OBD2 module. 13 | # Description 14 | ### 01_canSniffer_Arduino 15 | This code creates the interface between the car and the canSniffer_GUI application. If the RANDOM_CAN define is set to 1, this code is generating random CAN packets in order to test the higher level code. The received packets will be echoed back. If the RANDOM_CAN define is set to 0, the CAN_SPEED define has to match the speed of the desired CAN channel in order to receive and transfer from and to the CAN bus. 16 | Required arduino packages: 17 | - CAN by Sandeep Mistry (https:github.com/sandeepmistry/arduino-CAN) 18 | 19 | Required modifications: 20 | - MCP2515.h: 16e6 clock frequency reduced to 8e6 (depending on MCP2515 clock) 21 | - MCP2515.cpp: extend CNF_MAPPER with your desired CAN speeds 22 | 23 | ### 02_canSniffer_GUI 24 | Python 3 is required for this project, 3.8 is preferred. The GUI is based on pyQt. This project contains my decoded packets in save/decodedPackets.csv. The required python packages can be installed with: 25 | ```sh 26 | $ pip install -r requirements.txt 27 | ``` 28 | 29 | ### 03_canSniffer_HW 30 | Altium Designer projects for the hardware projects. Currently version 2. The module consists of 2 PCBs (board1 & board2). The libraries of the used components can be found under the common folder. Schematics can also be found as PDF files. 31 | 32 | ### 04_canSniffer_FW 33 | (BETA) Only board1 beta firmware is uploaded yet. It is a STM32CubeIDE project for the STM32F413. To be uploaded: nRF project for board2. 34 | 35 | # To be uploaded 36 | - Final version of the firmware. 37 | - (at some point) Source code for the mobile application that is compatible with the v2 hardware. 38 | - (potentially) New versions of the hardware module. 39 | --------------------------------------------------------------------------------