├── Oscilloscope-Docs ├── Csabiscope-Schema.pdf └── photos │ ├── csabiscope-head.jpg │ ├── csabiscope-prototype-pcb.jpg │ ├── csabiscope-setup-menu.jpg │ ├── csabiscope-trigger-menu.jpg │ └── csabiscope.jpg ├── Oscilloscope ├── .cproject ├── .gitignore ├── .project ├── .settings │ ├── language.settings.xml │ └── org.eclipse.cdt.codan.core.prefs ├── Oscilloscope Flash and Debug.launch ├── Oscilloscope Flash and Release.launch ├── commonlibs │ ├── include │ │ ├── adc.h │ │ ├── driver │ │ │ ├── AbstractDriver.h │ │ │ └── SPIDriver.h │ │ ├── fix_fft.h │ │ ├── graphics │ │ │ ├── Canvas.h │ │ │ ├── Fonts.h │ │ │ ├── ScenarioPlayerTask.h │ │ │ └── TaskCanvas.h │ │ ├── isqrt.h │ │ ├── lcd │ │ │ └── LCD_ST7735.h │ │ ├── pins.h │ │ ├── pwm.h │ │ ├── systick │ │ │ ├── SysTickHandler.h │ │ │ └── SysTime.h │ │ ├── task │ │ │ ├── AbstractTask.h │ │ │ ├── Resource.h │ │ │ └── TaskHandler.h │ │ └── xprintf.h │ ├── scripts │ │ ├── 10x20.bdf │ │ ├── 4x6.bdf │ │ ├── 5x7.bdf │ │ ├── 6x10.bdf │ │ ├── 7x13O.bdf │ │ ├── 7x14.bdf │ │ ├── 7x14B.bdf │ │ └── generate_fonts.pl │ └── src │ │ ├── adc.cpp │ │ ├── driver │ │ └── SPIDriver.cpp │ │ ├── fix_fft.c │ │ ├── graphics │ │ ├── Canvas.cpp │ │ ├── Fonts.cpp │ │ ├── ScenarioPlayerTask.cpp │ │ └── TaskCanvas.cpp │ │ ├── isqrt.cpp │ │ ├── lcd │ │ └── LCD_ST7735.cpp │ │ ├── pins.cpp │ │ ├── pwm.cpp │ │ ├── systick │ │ ├── SysTickHandler.cpp │ │ └── SysTime.cpp │ │ ├── task │ │ └── TaskHandler.cpp │ │ └── xprintf.c ├── include │ ├── AmplifierWidget.h │ ├── Colors.h │ ├── Config.h │ ├── GainSetterTask.h │ ├── InputDeviceHandler.h │ ├── MeasurementData.h │ ├── MeasurementValueWidget.h │ ├── OscilloscopeGrid.h │ ├── OscilloscopeScreen.h │ ├── Sampler.h │ ├── SetupMenu.h │ ├── TriggerHandler.h │ ├── TriggerWidget.h │ ├── USB │ │ ├── USBHandler.h │ │ ├── hw_config.h │ │ ├── platform_config.h │ │ ├── stm32_it.h │ │ ├── usb_conf.h │ │ ├── usb_desc.h │ │ ├── usb_istr.h │ │ ├── usb_prop.h │ │ └── usb_pwr.h │ └── stm32f10x_conf.h ├── ldscripts │ ├── libs.ld │ ├── mem.ld │ └── sections.ld ├── src │ ├── AmplifierWidget.cpp │ ├── Config.cpp │ ├── GainSetterTask.cpp │ ├── InputDeviceHandler.cpp │ ├── MeasurementData.cpp │ ├── MeasurementValueWidget.cpp │ ├── OscilloscopeGrid.cpp │ ├── OscilloscopeScreen.cpp │ ├── Sampler.cpp │ ├── SetupMenu.cpp │ ├── TriggerHandler.cpp │ ├── TriggerWidget.cpp │ ├── USB │ │ ├── USBHandler.cpp │ │ ├── hw_config.c │ │ ├── stm32_it.c │ │ ├── usb_desc.c │ │ ├── usb_endp.c │ │ ├── usb_istr.c │ │ ├── usb_prop.c │ │ └── usb_pwr.c │ ├── _write.c │ └── main.cpp ├── system │ ├── include │ │ ├── arm │ │ │ └── semihosting.h │ │ ├── cmsis │ │ │ ├── README_DEVICE.txt │ │ │ ├── arm_common_tables.h │ │ │ ├── arm_const_structs.h │ │ │ ├── arm_math.h │ │ │ ├── cmsis_armcc.h │ │ │ ├── cmsis_armcc_V6.h │ │ │ ├── cmsis_device.h │ │ │ ├── cmsis_gcc.h │ │ │ ├── core_cm0.h │ │ │ ├── core_cm0plus.h │ │ │ ├── core_cm3.h │ │ │ ├── core_cm4.h │ │ │ ├── core_cm7.h │ │ │ ├── core_cmFunc.h │ │ │ ├── core_cmInstr.h │ │ │ ├── core_cmSimd.h │ │ │ ├── core_sc000.h │ │ │ ├── core_sc300.h │ │ │ ├── stm32f10x.h │ │ │ └── system_stm32f10x.h │ │ ├── cortexm │ │ │ └── ExceptionHandlers.h │ │ ├── diag │ │ │ └── Trace.h │ │ └── stm32f1-stdperiph │ │ │ ├── README_STDPERIPH.txt │ │ │ ├── misc.h │ │ │ ├── stm32f10x_adc.h │ │ │ ├── stm32f10x_bkp.h │ │ │ ├── stm32f10x_can.h │ │ │ ├── stm32f10x_cec.h │ │ │ ├── stm32f10x_crc.h │ │ │ ├── stm32f10x_dac.h │ │ │ ├── stm32f10x_dbgmcu.h │ │ │ ├── stm32f10x_dma.h │ │ │ ├── stm32f10x_exti.h │ │ │ ├── stm32f10x_flash.h │ │ │ ├── stm32f10x_fsmc.h │ │ │ ├── stm32f10x_gpio.h │ │ │ ├── stm32f10x_i2c.h │ │ │ ├── stm32f10x_iwdg.h │ │ │ ├── stm32f10x_pwr.h │ │ │ ├── stm32f10x_rcc.h │ │ │ ├── stm32f10x_rtc.h │ │ │ ├── stm32f10x_sdio.h │ │ │ ├── stm32f10x_spi.h │ │ │ ├── stm32f10x_tim.h │ │ │ ├── stm32f10x_usart.h │ │ │ └── stm32f10x_wwdg.h │ └── src │ │ ├── cmsis │ │ ├── README_DEVICE.txt │ │ ├── system_stm32f10x.c │ │ └── vectors_stm32f10x.c │ │ ├── cortexm │ │ ├── _initialize_hardware.c │ │ ├── _reset_hardware.c │ │ └── exception_handlers.c │ │ ├── diag │ │ ├── Trace.c │ │ └── trace_impl.c │ │ ├── newlib │ │ ├── README.txt │ │ ├── _cxx.cpp │ │ ├── _exit.c │ │ ├── _sbrk.c │ │ ├── _startup.c │ │ ├── _syscalls.c │ │ └── assert.c │ │ └── stm32f1-stdperiph │ │ ├── README_STDPERIPH.txt │ │ ├── misc.c │ │ ├── stm32f10x_adc.c │ │ ├── stm32f10x_bkp.c │ │ ├── stm32f10x_can.c │ │ ├── stm32f10x_cec.c │ │ ├── stm32f10x_crc.c │ │ ├── stm32f10x_dac.c │ │ ├── stm32f10x_dbgmcu.c │ │ ├── stm32f10x_dma.c │ │ ├── stm32f10x_exti.c │ │ ├── stm32f10x_flash.c │ │ ├── stm32f10x_fsmc.c │ │ ├── stm32f10x_gpio.c │ │ ├── stm32f10x_i2c.c │ │ ├── stm32f10x_iwdg.c │ │ ├── stm32f10x_pwr.c │ │ ├── stm32f10x_rcc.c │ │ ├── stm32f10x_rtc.c │ │ ├── stm32f10x_sdio.c │ │ ├── stm32f10x_spi.c │ │ ├── stm32f10x_tim.c │ │ ├── stm32f10x_usart.c │ │ └── stm32f10x_wwdg.c └── usblibs │ ├── include │ ├── usb_core.h │ ├── usb_def.h │ ├── usb_init.h │ ├── usb_int.h │ ├── usb_lib.h │ ├── usb_mem.h │ ├── usb_regs.h │ ├── usb_sil.h │ └── usb_type.h │ ├── scripts │ ├── decode_usb.pl │ ├── serialread.pl │ └── usbtowav.pl │ └── src │ ├── usb_core.c │ ├── usb_init.c │ ├── usb_int.c │ ├── usb_mem.c │ ├── usb_regs.c │ └── usb_sil.c └── README.md /Oscilloscope-Docs/Csabiscope-Schema.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cskarai/csabiscope/fd1eff021840db4cf1b753eeb70804f43b8b955c/Oscilloscope-Docs/Csabiscope-Schema.pdf -------------------------------------------------------------------------------- /Oscilloscope-Docs/photos/csabiscope-head.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cskarai/csabiscope/fd1eff021840db4cf1b753eeb70804f43b8b955c/Oscilloscope-Docs/photos/csabiscope-head.jpg -------------------------------------------------------------------------------- /Oscilloscope-Docs/photos/csabiscope-prototype-pcb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cskarai/csabiscope/fd1eff021840db4cf1b753eeb70804f43b8b955c/Oscilloscope-Docs/photos/csabiscope-prototype-pcb.jpg -------------------------------------------------------------------------------- /Oscilloscope-Docs/photos/csabiscope-setup-menu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cskarai/csabiscope/fd1eff021840db4cf1b753eeb70804f43b8b955c/Oscilloscope-Docs/photos/csabiscope-setup-menu.jpg -------------------------------------------------------------------------------- /Oscilloscope-Docs/photos/csabiscope-trigger-menu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cskarai/csabiscope/fd1eff021840db4cf1b753eeb70804f43b8b955c/Oscilloscope-Docs/photos/csabiscope-trigger-menu.jpg -------------------------------------------------------------------------------- /Oscilloscope-Docs/photos/csabiscope.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cskarai/csabiscope/fd1eff021840db4cf1b753eeb70804f43b8b955c/Oscilloscope-Docs/photos/csabiscope.jpg -------------------------------------------------------------------------------- /Oscilloscope/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | -------------------------------------------------------------------------------- /Oscilloscope/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Oscilloscope 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /Oscilloscope/.settings/language.settings.xml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/adc.h: -------------------------------------------------------------------------------- 1 | #ifndef ADC_H_ 2 | #define ADC_H_ 3 | 4 | #include "stm32f10x.h" 5 | 6 | bool isCalibrated( ADC_TypeDef * ADC ); 7 | bool calibrateADC( ADC_TypeDef * ADC ); 8 | 9 | #endif /* ADC_H_ */ 10 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/driver/AbstractDriver.h: -------------------------------------------------------------------------------- 1 | #ifndef ABSTRACTDRIVER_H_ 2 | #define ABSTRACTDRIVER_H_ 3 | 4 | #include 5 | 6 | typedef enum 7 | { 8 | TT_COMMAND, 9 | TT_DATA_8_BIT, 10 | TT_DATA_16_BIT, 11 | TT_DATA_32_BIT, 12 | TT_FLOOD_8_BIT, 13 | TT_FLOOD_16_BIT, 14 | TT_FLOOD_32_BIT, 15 | } TransferType; 16 | 17 | typedef void (*TransferCompletedCb)(void * arg); 18 | 19 | class AbstractDriver; 20 | 21 | class AbstractDriverContext 22 | { 23 | public: 24 | virtual void start(TransferType type) = 0; 25 | virtual void done() = 0; 26 | 27 | virtual int getTransferSpeed() { return -1; } 28 | 29 | virtual AbstractDriver * getDriver() = 0; 30 | 31 | virtual ~AbstractDriverContext() {}; 32 | }; 33 | 34 | class AbstractDriver 35 | { 36 | public: 37 | virtual void startDataTransfer(AbstractDriverContext * ctx, unsigned len, volatile const uint8_t * buffer, TransferType tt, TransferCompletedCb cb, void * cbArg=0) = 0; 38 | virtual void checkTransferCompleted() = 0; 39 | virtual uint32_t requiredResources() = 0; 40 | virtual void loop() {}; 41 | 42 | protected: 43 | ~AbstractDriver() {} 44 | }; 45 | 46 | #endif /* ABSTRACTDRIVER_H_ */ 47 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/driver/SPIDriver.h: -------------------------------------------------------------------------------- 1 | #ifndef SPIDRIVER_H_ 2 | #define SPIDRIVER_H_ 3 | 4 | #include "driver/AbstractDriver.h" 5 | #include "pins.h" 6 | 7 | class SPIDriver : virtual public AbstractDriver 8 | { 9 | private: 10 | unsigned spiNum; 11 | SPI_TypeDef * spi; 12 | DMA_Channel_TypeDef * dma; 13 | 14 | AbstractDriverContext * ctx; 15 | TransferCompletedCb callback; 16 | void * callbackArg; 17 | 18 | void initRCC(); 19 | void initSPI(); 20 | void initNVIC(); 21 | void initDMA(); 22 | void configureDMA(TransferType tt); 23 | 24 | void transferDone(); 25 | 26 | public: 27 | SPIDriver(unsigned spiNum); 28 | 29 | AbstractDriverContext * createSPIContext(STM32Pin cs, int prescaler); 30 | AbstractDriverContext * createSPILCDContext(STM32Pin cs, STM32Pin a0, STM32Pin backlight, int prescaler); 31 | 32 | void init(); 33 | virtual void startDataTransfer(AbstractDriverContext * ctx, unsigned len, volatile const uint8_t * buffer, TransferType tt, TransferCompletedCb cb, void * cbArg=0); 34 | virtual void checkTransferCompleted(); 35 | virtual uint32_t requiredResources(); 36 | 37 | virtual ~SPIDriver() {} 38 | }; 39 | 40 | #endif /* SPIDRIVER_H_ */ 41 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/fix_fft.h: -------------------------------------------------------------------------------- 1 | #ifndef FFT_H_ 2 | #define FFT_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #ifndef fixed 9 | #define fixed short 10 | #endif 11 | 12 | int fix_fft(fixed fr[], fixed fi[], int m, int inverse); 13 | void window(fixed fr[], int n); 14 | void fix_loud(fixed loud[], fixed fr[], fixed fi[], int n, int scale_shift); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | 21 | #endif /* FFT_H_ */ 22 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/graphics/Canvas.h: -------------------------------------------------------------------------------- 1 | #ifndef CANVAS_H_ 2 | #define CANVAS_H_ 3 | 4 | #include 5 | 6 | typedef enum 7 | { 8 | ANGLE_0=0, 9 | ANGLE_90=1, 10 | ANGLE_180=2, 11 | ANGLE_270=3, 12 | } Angle; 13 | 14 | typedef struct 15 | { 16 | uint16_t x; 17 | uint16_t y; 18 | uint16_t h; 19 | uint16_t pos; 20 | } BitmapSegmenterData; 21 | 22 | typedef struct 23 | { 24 | unsigned w; 25 | unsigned size; 26 | const uint8_t * map; 27 | uint32_t color_fore; 28 | uint32_t color_bck; 29 | Angle angle; 30 | unsigned userData; 31 | unsigned segments; 32 | BitmapSegmenterData segmenterData[0]; 33 | } BitmapSegmenterDescriptor; 34 | 35 | typedef struct 36 | { 37 | uint16_t x; 38 | uint16_t y; 39 | uint16_t w; 40 | uint16_t h; 41 | const uint8_t * map; 42 | const char * text; 43 | const uint8_t * font; 44 | uint32_t color_fore; 45 | uint32_t color_bck; 46 | uint32_t color_frame; 47 | uint32_t color_sunken; 48 | } ButtonDescriptor; 49 | 50 | typedef struct 51 | { 52 | uint16_t x; 53 | uint16_t y; 54 | uint8_t ptr; 55 | uint8_t len; 56 | } TextSegmenterData; 57 | 58 | typedef struct 59 | { 60 | const uint8_t * font; 61 | const char * text; 62 | uint32_t color_fore; 63 | uint32_t color_bck; 64 | Angle angle; 65 | unsigned userData; 66 | unsigned segments; 67 | TextSegmenterData segmenterData[0]; 68 | } TextSegmenterDescriptor; 69 | 70 | 71 | typedef void (*ColorSetter)(uint8_t *, unsigned, uint32_t); 72 | typedef void (*ColorFiller)(uint8_t *, unsigned, unsigned, uint32_t); 73 | 74 | #define COLOR_BLACK 0x000000 75 | #define COLOR_WHITE 0xFFFFFF 76 | #define COLOR_RED 0xFF0000 77 | #define COLOR_GREEN 0x00FF00 78 | #define COLOR_BLUE 0x0000FF 79 | #define COLOR_YELLOW 0xFFFF00 80 | #define COLOR_CYAN 0x00FFFF 81 | #define COLOR_PURPLE 0xFF00FF 82 | #define COLOR_MAGENTA 0xFF00FF 83 | #define COLOR_ORANGE 0xFFA500 84 | #define COLOR_GRAY 0xBfBFBF 85 | 86 | typedef struct 87 | { 88 | union { 89 | uint8_t * data8; 90 | uint16_t * data16; 91 | uint32_t * data32; 92 | } buffer; 93 | 94 | unsigned x; 95 | unsigned y; 96 | unsigned w; 97 | unsigned h; 98 | Angle angle; 99 | void * deviceData; 100 | } ColorBuffer; 101 | 102 | class Canvas 103 | { 104 | private: 105 | const uint8_t * font; 106 | 107 | void drawButtonCommon(unsigned x, unsigned y, const uint8_t *map, const char * text, uint32_t color_fore, uint32_t color_bck, uint32_t color_frame, uint32_t color_sunken, int w, int h); 108 | 109 | public: 110 | virtual unsigned getWidth() = 0; 111 | virtual unsigned getHeight() = 0; 112 | virtual unsigned getColorSizeInBytes() = 0; 113 | 114 | virtual ColorBuffer * allocateColorBuffer(unsigned x, unsigned y, unsigned w, unsigned h, Angle angle = ANGLE_0); 115 | virtual void fillColors(ColorBuffer * buffer) = 0; 116 | 117 | virtual void floodColor(unsigned x, unsigned y, unsigned w, unsigned h, uint32_t color) = 0; 118 | 119 | virtual uint32_t rgb(uint32_t color) = 0; 120 | 121 | void drawTextSegment(TextSegmenterDescriptor * desc, TextSegmenterData * data); 122 | virtual void drawTextSegments(TextSegmenterDescriptor * desc); 123 | void drawBitmapSegment(BitmapSegmenterDescriptor * desc, BitmapSegmenterData * data); 124 | virtual void drawBitmapSegments(BitmapSegmenterDescriptor * desc); 125 | 126 | virtual void drawButton(ButtonDescriptor *); 127 | 128 | 129 | public: 130 | void clipCoordinates(unsigned &x, unsigned &y, unsigned &w, unsigned &h); 131 | uint8_t parseUTF8(const char ** text); 132 | unsigned textWidth(const char * text); 133 | 134 | void fillRect(unsigned x, unsigned y, unsigned w, unsigned h, uint32_t color); 135 | void fillScreen(uint32_t color); 136 | 137 | void drawHLine(unsigned x, unsigned y, unsigned w, uint32_t color); 138 | void drawVLine(unsigned x, unsigned y, unsigned h, uint32_t color); 139 | void drawRect(unsigned x, unsigned y, unsigned w, unsigned h, uint32_t color); 140 | void drawPixel(unsigned x, unsigned y, uint32_t color); 141 | 142 | void drawColors(unsigned x, unsigned y, unsigned h, unsigned w, void *colors); 143 | 144 | void setFont(const uint8_t * fontIn) { font = fontIn; } 145 | void drawText(unsigned x, unsigned y, const char * text, uint32_t color_fore, uint32_t color_bck = 0, Angle angle = ANGLE_0 ); 146 | void drawBitmap(unsigned x, unsigned y, unsigned w, unsigned h, const uint8_t *map, uint32_t color_fore, uint32_t color_bck = 0, Angle angle = ANGLE_0); 147 | void drawImage(unsigned x, unsigned y, const uint8_t *map, uint32_t color_fore, uint32_t color_bck = 0, Angle angle = ANGLE_0); 148 | 149 | void drawTextButton(unsigned x, unsigned y, const char *text, uint32_t color_fore, uint32_t color_bck, uint32_t color_frame = COLOR_WHITE, uint32_t color_sunken = COLOR_GRAY, int w=0, int h=0); 150 | void drawImageButton(unsigned x, unsigned y, const uint8_t *map, uint32_t color_fore, uint32_t color_bck, uint32_t color_frame = COLOR_WHITE, uint32_t color_sunken = COLOR_GRAY, int w=0, int h=0); 151 | 152 | ColorSetter getColorSetter(); 153 | ColorFiller getColorFiller(); 154 | 155 | protected: 156 | ~Canvas() {} 157 | }; 158 | 159 | #endif /* CANVAS_H_ */ 160 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/graphics/Fonts.h: -------------------------------------------------------------------------------- 1 | #ifndef FONTS_H 2 | #define FONTS_H 3 | 4 | #include 5 | 6 | extern const uint8_t font_7x13O []; 7 | extern const uint8_t font_7x14 []; 8 | extern const uint8_t font_4x6 []; 9 | extern const uint8_t font_10x20 []; 10 | extern const uint8_t font_5x7 []; 11 | extern const uint8_t font_6x10 []; 12 | extern const uint8_t font_7x14B []; 13 | 14 | #endif /* FONTS_H */ 15 | 16 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/graphics/ScenarioPlayerTask.h: -------------------------------------------------------------------------------- 1 | #ifndef SCENARIOPLAYERTASK_H_ 2 | #define SCENARIOPLAYERTASK_H_ 3 | 4 | #include "task/AbstractTask.h" 5 | #include "driver/AbstractDriver.h" 6 | 7 | typedef enum 8 | { 9 | SC_COMMAND = 0, 10 | SC_DELAY = 128, 11 | SC_FLOOD = 129, 12 | SC_SEND_BUFFER = 130, 13 | SC_DONE = 131, 14 | SC_PAD = 132, 15 | } Scene; 16 | 17 | class ScenarioPlayerTask : public virtual AbstractTask 18 | { 19 | private: 20 | AbstractDriverContext *driverContext; 21 | 22 | volatile const uint8_t *scenario = 0; 23 | volatile unsigned state; 24 | volatile uint32_t data = 0; 25 | unsigned colorSize; 26 | 27 | static void transferCompleteCb(void *arg); 28 | void transferCompleted(); 29 | 30 | ScenarioPlayerTask(unsigned colorSizeIn, AbstractDriverContext *driverContextIn, const uint8_t * scenarioIn); 31 | 32 | protected: 33 | void jumpToNextCommand(); 34 | void playCommand(); 35 | 36 | public: 37 | static ScenarioPlayerTask * createScenarioPlayer( unsigned colorSize, AbstractDriverContext *driverContextIn, const uint8_t * scenarioIn ); 38 | static ScenarioPlayerTask * createScenarioPlayer( unsigned colorSize, AbstractDriverContext *driverContextIn, unsigned len ); 39 | 40 | uint8_t * getScenario() { return (uint8_t *) scenario; } 41 | 42 | virtual uint32_t requiredResources() {return driverContext->getDriver()->requiredResources();} 43 | virtual void start(); 44 | virtual void loop(); 45 | }; 46 | 47 | #endif /* SCENARIOPLAYERTASK_H_ */ 48 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/graphics/TaskCanvas.h: -------------------------------------------------------------------------------- 1 | #ifndef TASKCANVAS_H_ 2 | #define TASKCANVAS_H_ 3 | 4 | #include "driver/AbstractDriver.h" 5 | #include "task/AbstractTask.h" 6 | #include "graphics/Canvas.h" 7 | #include "task/TaskHandler.h" 8 | 9 | class ScenarioPlayerTask; 10 | 11 | class TaskCanvas : public virtual Canvas 12 | { 13 | friend class ScenarioPlayerTask; 14 | 15 | private: 16 | static void processBitmapSegment(TaskCanvas * canvas, void * args); 17 | static void processTextSegment(TaskCanvas * canvas, void * args); 18 | static void processButton(TaskCanvas * canvas, void * args); 19 | 20 | public: 21 | virtual ColorBuffer * allocateColorBuffer(unsigned x, unsigned y, unsigned w, unsigned h, Angle angle = ANGLE_0) override; 22 | virtual void fillColors(ColorBuffer * buffer) override; 23 | virtual void floodColor(unsigned x, unsigned y, unsigned w, unsigned h, uint32_t color) override; 24 | virtual void drawBitmapSegments(BitmapSegmenterDescriptor * desc) override; 25 | virtual void drawTextSegments(TextSegmenterDescriptor * desc) override; 26 | virtual void drawButton(ButtonDescriptor *) override; 27 | 28 | virtual AbstractDriverContext * getDriverContext() = 0; 29 | void playScenario(ScenarioPlayerTask * scpTask); 30 | 31 | uint32_t requiredResources(); 32 | 33 | virtual unsigned addWindowAddrScenario(uint8_t * dest, unsigned x, unsigned y, unsigned w, unsigned h, Angle angle = ANGLE_0) = 0; 34 | 35 | protected: 36 | ~TaskCanvas() {} 37 | }; 38 | 39 | typedef void (*ActionCallback)(TaskCanvas *canvas, void *args); 40 | 41 | class ScheduledAction : public virtual AbstractTask 42 | { 43 | private: 44 | TaskCanvas * canvas; 45 | ActionCallback callback; 46 | void * args; 47 | 48 | public: 49 | ScheduledAction(TaskCanvas *canvasIn, ActionCallback callbackIn, void * argsIn = 0) : 50 | canvas(canvasIn), callback(callbackIn), args(argsIn) 51 | { 52 | TaskHandler::getInstance().scheduleTask(this); 53 | } 54 | 55 | virtual bool hasCachedData() { return true; } 56 | 57 | virtual uint32_t requiredResources() {return canvas->requiredResources();} 58 | 59 | virtual void buildCachedData() 60 | { 61 | if( callback != 0 ) 62 | callback(canvas, args); 63 | callback = 0; 64 | } 65 | 66 | virtual void start() 67 | { 68 | taskCompleted(); 69 | } 70 | }; 71 | 72 | template void scheduleWidget(TaskCanvas * canvas, W * widget) 73 | { 74 | new ScheduledAction(canvas, [] (TaskCanvas * canvas, void * arg) { 75 | ((W *)arg)->draw(canvas); 76 | delete (W*)arg; 77 | }, widget); 78 | } 79 | 80 | #include "graphics/ScenarioPlayerTask.h" 81 | 82 | #endif /* TASKCANVAS_H_ */ 83 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/isqrt.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDE_ISQRT_H_ 2 | #define INCLUDE_ISQRT_H_ 3 | 4 | #include 5 | 6 | uint32_t isqrt(uint32_t n); 7 | 8 | #endif /* INCLUDE_ISQRT_H_ */ 9 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/lcd/LCD_ST7735.h: -------------------------------------------------------------------------------- 1 | #ifndef LCD_ST7735_H_ 2 | #define LCD_ST7735_H_ 3 | 4 | #include "graphics/TaskCanvas.h" 5 | #include "task/TaskHandler.h" 6 | #include "driver/SPIDriver.h" 7 | 8 | class LCD_ST7735 : public virtual TaskCanvas 9 | { 10 | private: 11 | AbstractDriverContext * spiContext = 0; 12 | 13 | public: 14 | virtual void init(SPIDriver * driver, STM32Pin a0, STM32Pin cs, STM32Pin backlight); 15 | virtual unsigned getWidth(); 16 | virtual unsigned getHeight(); 17 | virtual unsigned getColorSizeInBytes(); 18 | 19 | virtual unsigned addWindowAddrScenario(uint8_t * dest, unsigned x, unsigned y, unsigned w, unsigned h, Angle angle = ANGLE_0); 20 | virtual AbstractDriverContext * getDriverContext() { return spiContext; } 21 | 22 | virtual uint32_t rgb(uint32_t color); 23 | 24 | virtual ~LCD_ST7735() {delete spiContext;} 25 | }; 26 | 27 | #endif /* LCD_ST7735_H_ */ 28 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/pins.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDE_PINS_H_ 2 | #define INCLUDE_PINS_H_ 3 | 4 | #include "stm32f10x.h" 5 | 6 | #define PORT_A 0 7 | #define PORT_B 16 8 | #define PORT_C 32 9 | 10 | typedef enum 11 | { 12 | PA0 = PORT_A + 0, 13 | PA1 = PORT_A + 1, 14 | PA2 = PORT_A + 2, 15 | PA3 = PORT_A + 3, 16 | PA4 = PORT_A + 4, 17 | PA5 = PORT_A + 5, 18 | PA6 = PORT_A + 6, 19 | PA7 = PORT_A + 7, 20 | PA8 = PORT_A + 8, 21 | PA9 = PORT_A + 9, 22 | PA10 = PORT_A + 10, 23 | PA11 = PORT_A + 11, 24 | PA12 = PORT_A + 12, 25 | PA13 = PORT_A + 13, 26 | PA14 = PORT_A + 14, 27 | PA15 = PORT_A + 15, 28 | PB0 = PORT_B + 0, 29 | PB1 = PORT_B + 1, 30 | PB2 = PORT_B + 2, 31 | PB3 = PORT_B + 3, 32 | PB4 = PORT_B + 4, 33 | PB5 = PORT_B + 5, 34 | PB6 = PORT_B + 6, 35 | PB7 = PORT_B + 7, 36 | PB8 = PORT_B + 8, 37 | PB9 = PORT_B + 9, 38 | PB10 = PORT_B + 10, 39 | PB11 = PORT_B + 11, 40 | PB12 = PORT_B + 12, 41 | PB13 = PORT_B + 13, 42 | PB14 = PORT_B + 14, 43 | PB15 = PORT_B + 15, 44 | PC13 = PORT_C + 13, 45 | PC14 = PORT_C + 14, 46 | PC15 = PORT_C + 15, 47 | } STM32Pin; 48 | 49 | #define GPIO_PIN_NUMBER(a) ( (a) & 0xF ) 50 | #define GPIO_PIN_MASK(a) ( 1 << ( a ) ) 51 | #define GPIO_PORT(a) ( (GPIO_TypeDef *)(GPIOA_BASE + (GPIOB_BASE-GPIOA_BASE)*((a) >> 4)) ) 52 | #define GPIO_RCC_MASK(a) ( RCC_APB2Periph_GPIOA << ((a) >> 4) ) 53 | 54 | void pinMode(STM32Pin pin, GPIOMode_TypeDef mode, GPIOSpeed_TypeDef speed = GPIO_Speed_2MHz); 55 | void writePin(STM32Pin pin, bool value); 56 | bool readPin(STM32Pin pin); 57 | 58 | void enableRCC(STM32Pin pin); 59 | int getADCChannel(STM32Pin pin); 60 | 61 | #endif /* INCLUDE_PINS_H_ */ 62 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/pwm.h: -------------------------------------------------------------------------------- 1 | #ifndef PWM_H_ 2 | #define PWM_H_ 3 | 4 | #include "pins.h" 5 | #include "stm32f10x.h" 6 | 7 | void pwmInit(STM32Pin pin); 8 | void pwmSetFrequency(STM32Pin pin, uint32_t frequency); 9 | void pwmSetDuty(STM32Pin pin, unsigned percent); 10 | void pwmSetEnabled(STM32Pin pin, bool enabled); 11 | 12 | void pwmTimerAndChannelForPin(STM32Pin pin, TIM_TypeDef ** tim, int * channel); 13 | 14 | #endif /* PWM_H_ */ 15 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/systick/SysTickHandler.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTICKHANDLER_H_ 2 | #define SYSTICKHANDLER_H_ 3 | 4 | #include 5 | 6 | typedef void (* SysTickCallback)(); 7 | 8 | class SysTickHandler 9 | { 10 | private: 11 | uint32_t clocksPerTick = 0; 12 | uint32_t clocksPerSecond = 0; 13 | uint32_t frequency = 0; 14 | static volatile uint64_t ticks; 15 | static SysTickCallback sysTickCallback; 16 | static SysTickHandler * instance; 17 | 18 | public: 19 | SysTickHandler(); 20 | 21 | void init(unsigned frequency, SysTickCallback cb = 0); 22 | void reinit(); 23 | 24 | void sleep(uint32_t millisToWait); 25 | uint64_t getTicks(); 26 | uint64_t getMillis(); 27 | 28 | inline static void tick() 29 | { 30 | ticks++; 31 | if( sysTickCallback ) 32 | sysTickCallback(); 33 | } 34 | 35 | inline static SysTickHandler * getInstance() { return instance; } 36 | }; 37 | 38 | #endif /* SYSTICKHANDLER_H_ */ 39 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/systick/SysTime.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTIME_H 2 | #define SYSTIME_H 3 | 4 | #include 5 | 6 | typedef uint64_t (*MillisGetter)(); 7 | 8 | class SysTime 9 | { 10 | protected: 11 | static MillisGetter mgetter; 12 | 13 | public: 14 | static void setMillisGetter(MillisGetter getter) { mgetter = getter; } 15 | static uint64_t getMillis() {return mgetter();}; 16 | }; 17 | 18 | #endif /* SYSTIME_H */ 19 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/task/AbstractTask.h: -------------------------------------------------------------------------------- 1 | #ifndef ABSTRACTTASK_H_ 2 | #define ABSTRACTTASK_H_ 3 | 4 | #define TASK_SINGLE_SHOT (-1) 5 | 6 | #include 7 | 8 | typedef enum 9 | { 10 | TS_WAITING, 11 | TS_STARTED, 12 | TS_DONE, 13 | TS_RESUBMITTED, 14 | } TaskState; 15 | 16 | class TaskHandler; 17 | 18 | class AbstractTask 19 | { 20 | friend class TaskHandler; 21 | 22 | private: 23 | uint32_t nextRun; 24 | int32_t repeatInterval = -1; 25 | TaskState state = TS_WAITING; 26 | bool autoDelete = true; 27 | bool cacheBuilt = false; 28 | 29 | public: 30 | virtual uint32_t requiredResources() {return 0;} 31 | virtual void start() = 0; 32 | virtual void loop() {}; 33 | 34 | virtual void buildCachedData() {}; 35 | virtual bool hasCachedData() { return false; } 36 | void invalidateCache() { cacheBuilt = false; } 37 | void buildCache() { if( hasCachedData() && !cacheBuilt ) { buildCachedData(); cacheBuilt = true;} }; 38 | 39 | int32_t getRepeatInterval() { return repeatInterval; } 40 | void setRepeatInterval(int32_t repeat) { repeatInterval = repeat; } 41 | bool isAutoDelete() { return autoDelete; } 42 | void setAutoDelete(bool del) { autoDelete = del; } 43 | TaskState getState() { return state; } 44 | void setState(TaskState st) {state = st;} 45 | void taskCompleted() { setState(TS_DONE); } 46 | void resubmitTask() { setState(TS_RESUBMITTED); } 47 | 48 | virtual ~AbstractTask() {} 49 | }; 50 | 51 | #endif /* ABSTRACTTASK_H_ */ 52 | 53 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/task/Resource.h: -------------------------------------------------------------------------------- 1 | #ifndef RESOURCE_H_ 2 | #define RESOURCE_H_ 3 | 4 | #define RESOURCE_ADC_1 (1 << 0) 5 | #define RESOURCE_ADC_2 (1 << 1) 6 | #define RESOURCE_ADC_3 (1 << 2) 7 | #define RESOURCE_SPI_1 (1 << 3) 8 | #define RESOURCE_SPI_2 (1 << 4) 9 | #define RESOURCE_DMA1_CH_1 (1 << 5) 10 | #define RESOURCE_DMA1_CH_3 (1 << 6) 11 | #define RESOURCE_DMA1_CH_5 (1 << 7) 12 | 13 | #define RESOURCE_DMA_SPI_1 ( RESOURCE_DMA1_CH_3 + RESOURCE_SPI_1 ) 14 | #define RESOURCE_DMA_SPI_2 ( RESOURCE_DMA1_CH_5 + RESOURCE_SPI_2 ) 15 | #define RESOURCE_DMA_ADC_1 ( RESOURCE_DMA1_CH_1 + RESOURCE_ADC_1 ) 16 | 17 | #endif /* RESOURCE_H_ */ 18 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/task/TaskHandler.h: -------------------------------------------------------------------------------- 1 | #ifndef TASK_TASKHANDLER_H_ 2 | #define TASK_TASKHANDLER_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | class TaskHandler 10 | { 11 | private: 12 | static TaskHandler * instance; 13 | uint32_t availableResources; 14 | std::list runningTaskList; 15 | std::list waitingTaskList; 16 | 17 | public: 18 | TaskHandler(); 19 | 20 | void scheduleTask(AbstractTask *task, int32_t shot = 0, int32_t repeat = -1); 21 | int getTasksToProcess(uint32_t resource); 22 | 23 | void loop(); 24 | 25 | static TaskHandler & getInstance() { return *instance; } 26 | }; 27 | 28 | #endif /* TASK_TASKHANDLER_H_ */ 29 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/include/xprintf.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /* Universal string handler for user console interface (C)ChaN, 2011 */ 3 | /*------------------------------------------------------------------------*/ 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #ifndef _STRFUNC 10 | #define _STRFUNC 11 | 12 | #define _USE_XFUNC_OUT 1 /* 1: Use output functions */ 13 | #define _CR_CRLF 1 /* 1: Convert \n ==> \r\n in the output char */ 14 | 15 | #define _USE_XFUNC_IN 1 /* 1: Use input function */ 16 | #define _LINE_ECHO 1 /* 1: Echo back input chars in xgets function */ 17 | 18 | 19 | #if _USE_XFUNC_OUT 20 | #include 21 | #define xdev_out(func) xfunc_out = (void(*)(unsigned char))(func) 22 | extern void (*xfunc_out)(unsigned char); 23 | void xputc (char c); 24 | void xputs (const char* str); 25 | void xfputs (void (*func)(unsigned char), const char* str); 26 | void xprintf (const char* fmt, ...); 27 | int xsprintf (char* buff, const char* fmt, ...); 28 | int xvsprintf (char* buff, const char* fmt, va_list arp); 29 | 30 | void xfprintf (void (*func)(unsigned char), const char* fmt, ...); 31 | void put_dump (const void* buff, unsigned long addr, int len, int width); 32 | #define DW_CHAR sizeof(char) 33 | #define DW_SHORT sizeof(short) 34 | #define DW_LONG sizeof(long) 35 | #endif 36 | 37 | #if _USE_XFUNC_IN 38 | #define xdev_in(func) xfunc_in = (unsigned char(*)(void))(func) 39 | extern unsigned char (*xfunc_in)(void); 40 | int xgets (char* buff, int len); 41 | int xfgets (unsigned char (*func)(void), char* buff, int len); 42 | int xatoi (char** str, long* res); 43 | #endif 44 | 45 | #endif 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/scripts/generate_fonts.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use Data::Dumper; 5 | use utf8; 6 | 7 | my @chars = 32 .. 126; 8 | my $hungarian = "ÁÉÍÓÖŐÚÜŰáéíóöőúüűµ"; 9 | 10 | my @intl = split //, $hungarian; 11 | push @chars, map {ord($_)} @intl; 12 | push @chars, 32 while @chars < 128; 13 | 14 | my @files = `find . -iname '*.bdf'`; 15 | $_ =~ s/^\s+|\s+$//gs for (@files); 16 | 17 | my @names; 18 | 19 | my $file = "#include \"graphics/Fonts.h\"\n"; 20 | 21 | for my $bdfFile (@files) 22 | { 23 | print "Processing: $bdfFile...\n"; 24 | my $name = $bdfFile; 25 | $name =~ s/^.*\///g; 26 | $name =~ s/\.BDF$//gi; 27 | 28 | my $name = "font_$name"; 29 | 30 | open FH, "<", $bdfFile or die "Can't open file for read: $!"; 31 | 32 | my @bdf = ; 33 | $_ =~ s/^\s+|\s+$//gs for (@bdf); 34 | 35 | my $state = 0; 36 | my %chrs; 37 | my $width; 38 | my $height; 39 | 40 | 41 | my $cwidth; 42 | my @filtered; 43 | my @def; 44 | 45 | for my $line (@bdf ) 46 | { 47 | if( $state == 0 ) 48 | { 49 | if( $line =~ /^STARTFONT/ ) 50 | { 51 | $state ++; 52 | } 53 | } 54 | if( $state == 1 ) 55 | { 56 | if( $line =~ /^FONTBOUNDINGBOX (\d+) (\d+)/ ) 57 | { 58 | $width = $1; 59 | $height = $2; 60 | $state++; 61 | } 62 | } 63 | if( $state == 2 ) 64 | { 65 | if( $line =~ /^STARTCHAR/ ) 66 | { 67 | $state++; 68 | } 69 | } 70 | if( $state == 3 ) 71 | { 72 | if( $line =~ /^ENCODING (\d+)/ ) 73 | { 74 | my $unicode = $1; 75 | 76 | my $i = 0; 77 | @filtered = grep { $_->[0] == $unicode } map { [ $_, $i++ ] } @chars; 78 | 79 | if( @filtered ) 80 | { 81 | $cwidth = $width; 82 | $state ++; 83 | } 84 | else 85 | { 86 | $state = 2; 87 | } 88 | } 89 | } 90 | if( $state == 4 ) 91 | { 92 | if( $line =~ /^BBX (\d+)/ ) 93 | { 94 | $cwidth = $1; 95 | } 96 | if( $line =~ /^ENDCHAR$/ ) 97 | { 98 | $state = 2; 99 | } 100 | if( $line =~ /^BITMAP/ ) 101 | { 102 | @def = (); 103 | $state++; 104 | } 105 | } 106 | if( $state == 5 ) 107 | { 108 | if( $line =~ /^([0-9a-fA-F]+)$/ ) 109 | { 110 | push @def, $1; 111 | } 112 | if( $line =~ /^ENDCHAR$/ ) 113 | { 114 | for my $desc ( @filtered ) 115 | { 116 | my $ndx = $desc->[1]; 117 | my @dfn = @def; 118 | $chrs{$ndx} = { width => $cwidth, def => \@dfn }; 119 | } 120 | $state = 2; 121 | } 122 | } 123 | } 124 | 125 | die "Not every font defined" if values %chrs != @chars; 126 | 127 | $file .= "const uint8_t $name [] = {\n"; 128 | $file .= " $width, $height,\n"; 129 | 130 | my $ndx = 0; 131 | for my $chr (@chars) 132 | { 133 | my $def = $chrs{$ndx++}; 134 | $file .= " " . $def->{width}; 135 | $file .= ", "; 136 | 137 | my $data = $def->{def}; 138 | my @hex; 139 | 140 | for my $line (@$data) 141 | { 142 | my @arr = ( $line =~ m/../g ); 143 | push @hex, @arr; 144 | } 145 | $_ = "0x$_" for (@hex); 146 | $file .= join(",", @hex); 147 | $file .= ", // "; 148 | if(chr($chr) eq '\\') 149 | { 150 | $file .= "back slash"; 151 | } 152 | else 153 | { 154 | $file .= chr($chr); 155 | } 156 | $file .= "\n"; 157 | } 158 | 159 | $file .= "};\n\n"; 160 | 161 | close FH; 162 | 163 | push @names, $name; 164 | } 165 | 166 | # generate the header files 167 | my $header = "#ifndef FONTS_H\n#define FONTS_H\n\n#include \n\n" . join("", map { "extern const uint8_t $_ [];\n" } @names) . "\n#endif /* FONTS_H */\n\n"; 168 | 169 | open HDR, ">", "../include/graphics/Fonts.h" or die "Can't open file for write: $!"; 170 | print HDR $header; 171 | close(HDR); 172 | 173 | open FCNT, ">", "../src/graphics/Fonts.cpp" or die "Can't open file for write: $!"; 174 | print FCNT $file; 175 | close(FCNT); 176 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/src/adc.cpp: -------------------------------------------------------------------------------- 1 | #include "adc.h" 2 | 3 | bool calibrated[3] = {false, false, false}; 4 | 5 | bool calibrateADC( ADC_TypeDef * ADC ) 6 | { 7 | int adc = 0; 8 | if( ADC == ADC1 ) 9 | adc = 0; 10 | else if( ADC == ADC2 ) 11 | adc = 1; 12 | if( ADC == ADC3 ) 13 | adc = 2; 14 | 15 | if(!calibrated[adc]) 16 | { 17 | //Enable ADC reset calibration register 18 | ADC_ResetCalibration(ADC); 19 | //Check the end of ADC reset calibration register 20 | while(ADC_GetResetCalibrationStatus(ADC)); 21 | //Start ADC calibration 22 | ADC_StartCalibration(ADC); 23 | //Check the end of ADC calibration 24 | while(ADC_GetCalibrationStatus(ADC)); 25 | 26 | calibrated[adc] = true; 27 | 28 | return true; 29 | } 30 | return false; 31 | } 32 | 33 | bool isCalibrated( ADC_TypeDef * ADC ) 34 | { 35 | int adc = 0; 36 | if( ADC == ADC1 ) 37 | adc = 0; 38 | else if( ADC == ADC2 ) 39 | adc = 1; 40 | if( ADC == ADC3 ) 41 | adc = 2; 42 | 43 | return calibrated[adc]; 44 | } 45 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/src/graphics/ScenarioPlayerTask.cpp: -------------------------------------------------------------------------------- 1 | #include "graphics/ScenarioPlayerTask.h" 2 | #include "systick/SysTime.h" 3 | #include 4 | #include 5 | 6 | typedef enum 7 | { 8 | SPST_DONE, 9 | SPST_WAIT_COMMAND_DONE, 10 | SPST_WAIT_DATA_DONE, 11 | SPST_WAIT_DELAY, 12 | } ScPlayerState; 13 | 14 | ScenarioPlayerTask::ScenarioPlayerTask(unsigned colorSizeIn, AbstractDriverContext *driverContextIn, const uint8_t * scenarioIn) : 15 | driverContext(driverContextIn), scenario(scenarioIn), state(SPST_DONE), colorSize(colorSizeIn) 16 | { 17 | } 18 | 19 | ScenarioPlayerTask * ScenarioPlayerTask::createScenarioPlayer( unsigned colorSize, AbstractDriverContext *driverContext, const uint8_t * scenarioIn ) 20 | { 21 | return new ScenarioPlayerTask( colorSize, driverContext, scenarioIn ); 22 | } 23 | 24 | ScenarioPlayerTask * ScenarioPlayerTask::createScenarioPlayer( unsigned colorSize, AbstractDriverContext *driverContext, unsigned len ) 25 | { 26 | uint8_t * alloc = new uint8_t [ sizeof(ScenarioPlayerTask) + len ]; 27 | ScenarioPlayerTask * task = new (alloc) ScenarioPlayerTask(colorSize, driverContext, (const uint8_t *)(alloc + sizeof(ScenarioPlayerTask))); 28 | return task; 29 | } 30 | 31 | void ScenarioPlayerTask::transferCompleteCb(void *arg) 32 | { 33 | ((ScenarioPlayerTask *)arg)->transferCompleted(); 34 | } 35 | 36 | void ScenarioPlayerTask::transferCompleted() 37 | { 38 | switch( state ) 39 | { 40 | case SPST_WAIT_DATA_DONE: 41 | jumpToNextCommand(); 42 | break; 43 | case SPST_WAIT_COMMAND_DONE: 44 | { 45 | uint8_t len = *scenario & 127; 46 | if( len == 0 ) 47 | jumpToNextCommand(); 48 | else 49 | { 50 | state = SPST_WAIT_DATA_DONE; 51 | driverContext->getDriver()->startDataTransfer(driverContext, len, scenario+2, TT_DATA_8_BIT, ScenarioPlayerTask::transferCompleteCb, this); 52 | } 53 | } 54 | break; 55 | } 56 | } 57 | 58 | void ScenarioPlayerTask::jumpToNextCommand() 59 | { 60 | state = SPST_DONE; 61 | 62 | if( *scenario < 0x80 ) // SC_COMMAND 63 | scenario += 2 + *scenario; 64 | else if (*scenario == SC_DELAY ) 65 | scenario += 2; 66 | else if (*scenario == SC_FLOOD ) 67 | scenario += 7; 68 | else if (*scenario == SC_DONE ) 69 | { 70 | /* do nothing */ 71 | } 72 | else if (*scenario == SC_SEND_BUFFER ) 73 | { 74 | unsigned cnt = (scenario[1] + (scenario[2] << 8)) * colorSize; 75 | scenario += 3 + cnt; 76 | } 77 | playCommand(); 78 | } 79 | 80 | void ScenarioPlayerTask::playCommand() 81 | { 82 | while( *scenario == SC_PAD ) // padding bytes for 4 byte alignment 83 | scenario++; 84 | 85 | switch( *scenario ) 86 | { 87 | case SC_DONE: 88 | taskCompleted(); 89 | state = SPST_DONE; 90 | return; 91 | case SC_DELAY: 92 | { 93 | unsigned time = scenario[1]; 94 | if( time == 255 ) 95 | time = 500; 96 | 97 | data = (uint32_t)(SysTime::getMillis() + time); 98 | state = SPST_WAIT_DELAY; 99 | break; 100 | } 101 | case SC_SEND_BUFFER: 102 | { 103 | unsigned len = scenario[1] + 256*scenario[2]; 104 | TransferType ttp; 105 | 106 | switch(colorSize) 107 | { 108 | case 2: 109 | ttp = TT_DATA_16_BIT; 110 | break; 111 | case 4: 112 | ttp = TT_DATA_32_BIT; 113 | break; 114 | case 1: 115 | default: 116 | ttp = TT_DATA_8_BIT; 117 | break; 118 | } 119 | 120 | state = SPST_WAIT_DATA_DONE; 121 | driverContext->getDriver()->startDataTransfer(driverContext, len, scenario+3, ttp, ScenarioPlayerTask::transferCompleteCb, this); 122 | break; 123 | } 124 | case SC_FLOOD: 125 | { 126 | unsigned len = scenario[1] + 256*scenario[2]; 127 | TransferType ttp; 128 | 129 | switch(colorSize) 130 | { 131 | case 2: 132 | ttp = TT_FLOOD_16_BIT; 133 | break; 134 | case 4: 135 | ttp = TT_FLOOD_32_BIT; 136 | break; 137 | case 1: 138 | default: 139 | ttp = TT_FLOOD_8_BIT; 140 | break; 141 | } 142 | 143 | state = SPST_WAIT_DATA_DONE; 144 | driverContext->getDriver()->startDataTransfer(driverContext, len, scenario+3, ttp, ScenarioPlayerTask::transferCompleteCb, this); 145 | break; 146 | } 147 | default: 148 | if( *scenario < 0x80 ) 149 | { 150 | state = SPST_WAIT_COMMAND_DONE; 151 | driverContext->getDriver()->startDataTransfer(driverContext, 1, scenario+1, TT_COMMAND, ScenarioPlayerTask::transferCompleteCb, this); 152 | break; 153 | } 154 | } 155 | } 156 | 157 | void ScenarioPlayerTask::start() 158 | { 159 | playCommand(); 160 | } 161 | 162 | void ScenarioPlayerTask::loop() 163 | { 164 | switch( state ) 165 | { 166 | case SPST_DONE: 167 | break; 168 | case SPST_WAIT_COMMAND_DONE: 169 | case SPST_WAIT_DATA_DONE: 170 | driverContext->getDriver()->checkTransferCompleted(); 171 | break; 172 | case SPST_WAIT_DELAY: 173 | { 174 | uint64_t ts = SysTime::getMillis(); 175 | uint64_t waitEnd = ( ts & 0xFFFFFFFF00000000 ) | data; 176 | if(( waitEnd > ts ) && ( waitEnd - ts > 0x7FFFFFFF ) ) 177 | waitEnd -= 0x100000000; 178 | if(( waitEnd < ts ) && ( ts - waitEnd > 0x7FFFFFFF ) ) 179 | waitEnd += 0x100000000; 180 | 181 | if( ts >= waitEnd ) 182 | jumpToNextCommand(); 183 | } 184 | break; 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/src/isqrt.cpp: -------------------------------------------------------------------------------- 1 | #include "isqrt.h" 2 | 3 | uint32_t isqrt(uint32_t n) 4 | { 5 | uint32_t root = 0, bit, trial; 6 | bit = (n >= 0x10000) ? (uint32_t)1<<30 : (uint32_t)1<<14; 7 | do 8 | { 9 | trial = root+bit; 10 | if (n >= trial) 11 | { 12 | n -= trial; 13 | root = trial+bit; 14 | } 15 | root >>= 1; 16 | bit >>= 2; 17 | } while (bit); 18 | return root; 19 | } 20 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/src/pins.cpp: -------------------------------------------------------------------------------- 1 | #include "pins.h" 2 | 3 | bool readPin(STM32Pin pin) 4 | { 5 | uint32_t mask = GPIO_Pin_0 << GPIO_PIN_NUMBER(pin); 6 | 7 | return GPIO_ReadInputData(GPIO_PORT(pin)) & mask; 8 | } 9 | 10 | void writePin(STM32Pin pin, bool value) 11 | { 12 | uint32_t mask = GPIO_Pin_0 << GPIO_PIN_NUMBER(pin); 13 | 14 | GPIO_WriteBit(GPIO_PORT(pin), mask, (BitAction)value); 15 | } 16 | 17 | void pinMode(STM32Pin pin, GPIOMode_TypeDef mode, GPIOSpeed_TypeDef speed) 18 | { 19 | GPIO_InitTypeDef GPIO_InitStructure; //Variable used to setup the GPIO pins 20 | GPIO_StructInit(&GPIO_InitStructure); // Reset init structure, if not it can cause issues... 21 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 << GPIO_PIN_NUMBER(pin); 22 | GPIO_InitStructure.GPIO_Mode = mode; 23 | GPIO_InitStructure.GPIO_Speed = speed; 24 | GPIO_Init(GPIO_PORT(pin), &GPIO_InitStructure); 25 | } 26 | 27 | void enableRCC(STM32Pin pin) 28 | { 29 | RCC_APB2PeriphClockCmd(GPIO_RCC_MASK(pin), ENABLE); 30 | } 31 | 32 | int getADCChannel(STM32Pin pin) 33 | { 34 | switch(pin) 35 | { 36 | case PA0: 37 | case PA1: 38 | case PA2: 39 | case PA3: 40 | case PA4: 41 | case PA5: 42 | case PA6: 43 | case PA7: 44 | return (pin & 7) + ADC_Channel_0; 45 | case PB0: 46 | case PB1: 47 | return (pin & 1) + ADC_Channel_8; 48 | default: 49 | return -1; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/src/pwm.cpp: -------------------------------------------------------------------------------- 1 | #include "pwm.h" 2 | 3 | void pwmInit(STM32Pin pin) 4 | { 5 | int channel = -1; 6 | TIM_TypeDef * timer = 0; 7 | 8 | pwmTimerAndChannelForPin(pin, &timer, &channel); 9 | if( timer != 0 ) 10 | { 11 | if( timer == TIM1 ) 12 | RCC_APB1PeriphClockCmd(RCC_APB2Periph_TIM1 , ENABLE); 13 | if( timer == TIM2 ) 14 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 , ENABLE); 15 | if( timer == TIM3 ) 16 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3 , ENABLE); 17 | if( timer == TIM4 ) 18 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4 , ENABLE); 19 | 20 | enableRCC(pin); 21 | pinMode(pin, GPIO_Mode_AF_PP, GPIO_Speed_50MHz); 22 | 23 | TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; 24 | TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); 25 | TIM_TimeBaseInit(timer, &TIM_TimeBaseStructure); 26 | 27 | TIM_Cmd(timer, ENABLE); 28 | } 29 | } 30 | 31 | void pwmSetEnabled(STM32Pin pin, bool enabled) 32 | { 33 | int channel = -1; 34 | TIM_TypeDef * timer = 0; 35 | 36 | pwmTimerAndChannelForPin(pin, &timer, &channel); 37 | 38 | if( timer != 0 ) 39 | TIM_Cmd(timer, enabled ? ENABLE : DISABLE); 40 | } 41 | 42 | void pwmSetFrequency(STM32Pin pin, uint32_t frequency) 43 | { 44 | int channel = -1; 45 | TIM_TypeDef * timer = 0; 46 | 47 | pwmTimerAndChannelForPin(pin, &timer, &channel); 48 | if( timer != 0 && frequency > 0 ) 49 | { 50 | uint32_t period = SystemCoreClock / frequency - 1; 51 | uint32_t prescaler = 0; 52 | 53 | while( period >= 0x10000 ) 54 | { 55 | period = (period+1) / 2; 56 | prescaler = prescaler*2 + 1; 57 | } 58 | 59 | TIM_PrescalerConfig(timer, prescaler, TIM_PSCReloadMode_Update); 60 | TIM_SetAutoreload(timer, period); 61 | } 62 | } 63 | 64 | void pwmSetDuty(STM32Pin pin, unsigned percent) 65 | { 66 | int channel = -1; 67 | TIM_TypeDef * timer = 0; 68 | 69 | pwmTimerAndChannelForPin(pin, &timer, &channel); 70 | if( timer != 0 ) 71 | { 72 | unsigned arr = timer->ARR; 73 | unsigned pulse = arr * percent / 100; 74 | 75 | TIM_OCInitTypeDef TIM_OCInitStructure; 76 | TIM_OCStructInit(&TIM_OCInitStructure); 77 | 78 | TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; 79 | TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; 80 | TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; 81 | TIM_OCInitStructure.TIM_Pulse = pulse; 82 | 83 | 84 | switch(channel) 85 | { 86 | case 1: 87 | TIM_OC1Init(timer, &TIM_OCInitStructure); 88 | TIM_OC1PreloadConfig(timer, TIM_OCPreload_Enable); 89 | break; 90 | case 2: 91 | TIM_OC2Init(timer, &TIM_OCInitStructure); 92 | TIM_OC2PreloadConfig(timer, TIM_OCPreload_Enable); 93 | break; 94 | case 3: 95 | TIM_OC3Init(timer, &TIM_OCInitStructure); 96 | TIM_OC3PreloadConfig(timer, TIM_OCPreload_Enable); 97 | break; 98 | case 4: 99 | TIM_OC4Init(timer, &TIM_OCInitStructure); 100 | TIM_OC4PreloadConfig(timer, TIM_OCPreload_Enable); 101 | break; 102 | } 103 | } 104 | } 105 | 106 | void pwmTimerAndChannelForPin(STM32Pin pin, TIM_TypeDef ** tim, int * channel) 107 | { 108 | switch( pin ) 109 | { 110 | case PA8: 111 | case PA9: 112 | case PA10: 113 | case PA11: 114 | *tim = TIM1; 115 | *channel = pin - PA8 + 1; 116 | break; 117 | case PB6: 118 | case PB7: 119 | case PB8: 120 | case PB9: 121 | *tim = TIM4; 122 | *channel = pin - PB6 + 1; 123 | break; 124 | case PA6: 125 | case PA7: 126 | *tim = TIM3; 127 | *channel = pin - PA6 + 1; 128 | break; 129 | case PB0: 130 | case PB1: 131 | *tim = TIM3; 132 | *channel = pin - PB0 + 3; 133 | break; 134 | case PA0: 135 | case PA1: 136 | case PA2: 137 | case PA3: 138 | *tim = TIM2; 139 | *channel = pin - PA0 + 1; 140 | break; 141 | default: 142 | *channel = -1; 143 | *tim = 0; 144 | break; 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/src/systick/SysTickHandler.cpp: -------------------------------------------------------------------------------- 1 | #include "systick/SysTickHandler.h" 2 | #include "systick/SysTime.h" 3 | 4 | #include 5 | 6 | volatile uint64_t SysTickHandler::ticks = 0; 7 | SysTickCallback SysTickHandler::sysTickCallback = 0; 8 | SysTickHandler * SysTickHandler::instance = 0; 9 | 10 | SysTickHandler::SysTickHandler() 11 | { 12 | instance = this; 13 | SysTime::setMillisGetter([]() { 14 | return SysTickHandler::getInstance()->getMillis(); 15 | }); 16 | } 17 | 18 | extern "C" void SysTick_Handler(void) 19 | { 20 | SysTickHandler::tick(); 21 | } 22 | 23 | void SysTickHandler::init(unsigned frequencyIn, SysTickCallback cb) 24 | { 25 | frequency = frequencyIn; 26 | sysTickCallback = cb; 27 | reinit(); 28 | } 29 | 30 | void SysTickHandler::reinit() 31 | { 32 | RCC_ClocksTypeDef RCC_Clocks; 33 | RCC_GetClocksFreq (&RCC_Clocks); 34 | clocksPerSecond = RCC_Clocks.HCLK_Frequency; 35 | SysTick_Config (clocksPerTick = clocksPerSecond / frequency); 36 | } 37 | 38 | void SysTickHandler::sleep(uint32_t millisToWait) 39 | { 40 | uint64_t end = getMillis() + millisToWait; 41 | 42 | while(getMillis() < end); 43 | } 44 | 45 | uint64_t SysTickHandler::getTicks() 46 | { 47 | uint64_t t1, t2; 48 | do 49 | { 50 | t1 = ticks; 51 | t2 = ticks; 52 | }while(t1 != t2); 53 | return t1; 54 | } 55 | 56 | uint64_t SysTickHandler::getMillis() 57 | { 58 | uint64_t millis = getTicks() * 1000 * clocksPerTick / clocksPerSecond; 59 | return millis; 60 | } 61 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/src/systick/SysTime.cpp: -------------------------------------------------------------------------------- 1 | #include "systick/SysTime.h" 2 | 3 | MillisGetter SysTime::mgetter = 0; 4 | -------------------------------------------------------------------------------- /Oscilloscope/commonlibs/src/task/TaskHandler.cpp: -------------------------------------------------------------------------------- 1 | #include "task/TaskHandler.h" 2 | #include "systick/SysTime.h" 3 | 4 | #define MAX_CACHE_EXTRACTED 1 5 | 6 | TaskHandler * TaskHandler::instance = 0; 7 | 8 | TaskHandler::TaskHandler(): availableResources(0xFFFFFFFF) 9 | { 10 | TaskHandler::instance = this; 11 | } 12 | 13 | void TaskHandler::scheduleTask(AbstractTask *task, int32_t nextShot, int32_t repeat) 14 | { 15 | task->state = TS_WAITING; 16 | task->nextRun = (uint32_t)(SysTime::getMillis() + nextShot); 17 | task->repeatInterval = repeat; 18 | waitingTaskList.push_back(task); 19 | } 20 | 21 | void TaskHandler::loop() 22 | { 23 | // loop over tasks 24 | std::list::iterator iterator; 25 | for (iterator = runningTaskList.begin(); iterator != runningTaskList.end();) { 26 | AbstractTask * task = *iterator; 27 | task->loop(); 28 | 29 | if( task->getState() == TS_DONE || task->getState() == TS_RESUBMITTED ) 30 | { 31 | iterator = runningTaskList.erase(iterator); 32 | availableResources |= task->requiredResources(); 33 | 34 | if( task->getState() == TS_RESUBMITTED ) 35 | scheduleTask(task, 0, task->repeatInterval); 36 | else if( task->getRepeatInterval() == TASK_SINGLE_SHOT ) 37 | { 38 | if( task->isAutoDelete() ) 39 | delete task; 40 | } 41 | else 42 | scheduleTask(task, task->repeatInterval, task->repeatInterval); 43 | 44 | continue; 45 | } 46 | 47 | iterator++; 48 | } 49 | 50 | int cacheExtracted = 0; 51 | uint64_t ts = SysTime::getMillis(); 52 | // start waiting tasks 53 | for (iterator = waitingTaskList.begin(); iterator != waitingTaskList.end();) { 54 | AbstractTask * task = *iterator; 55 | 56 | // build only one into cache 57 | if( task->hasCachedData() ) 58 | { 59 | if( cacheExtracted < MAX_CACHE_EXTRACTED ) 60 | { 61 | task->buildCache(); 62 | cacheExtracted++; 63 | } 64 | } 65 | 66 | if(( task->requiredResources() & availableResources ) == task->requiredResources() ) 67 | { 68 | uint64_t runTime = ( ts & 0xFFFFFFFF00000000 ) | task->nextRun; 69 | if(( runTime > ts ) && ( runTime - ts > 0x7FFFFFFF ) ) 70 | runTime -= 0x100000000; 71 | if(( runTime < ts ) && ( ts - runTime > 0x7FFFFFFF ) ) 72 | runTime += 0x100000000; 73 | 74 | if( runTime <= ts ) 75 | { 76 | // we have all the resources to execute the task 77 | availableResources &= ~task->requiredResources(); 78 | 79 | iterator = waitingTaskList.erase(iterator); 80 | runningTaskList.push_back(task); 81 | task->buildCache(); 82 | task->start(); 83 | continue; 84 | } 85 | } 86 | iterator++; 87 | } 88 | } 89 | 90 | int TaskHandler::getTasksToProcess(uint32_t resource) 91 | { 92 | int cnt = 0; 93 | 94 | for (AbstractTask * task : runningTaskList) { 95 | if(( task->requiredResources() & resource ) == resource) 96 | cnt++; 97 | } 98 | 99 | for (AbstractTask * task : waitingTaskList) { 100 | if(( task->requiredResources() & resource ) == resource) 101 | cnt++; 102 | } 103 | 104 | return cnt; 105 | } 106 | -------------------------------------------------------------------------------- /Oscilloscope/include/AmplifierWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef AMPLIFIERWIDGET_H_ 2 | #define AMPLIFIERWIDGET_H_ 3 | 4 | #include "graphics/TaskCanvas.h" 5 | #include "MeasurementData.h" 6 | 7 | class AmplifierWidget 8 | { 9 | public: 10 | void draw(TaskCanvas *canvas); 11 | }; 12 | 13 | #endif /* AMPLIFIERWIDGET_H_ */ 14 | -------------------------------------------------------------------------------- /Oscilloscope/include/Colors.h: -------------------------------------------------------------------------------- 1 | #ifndef COLORS_H_ 2 | #define COLORS_H_ 3 | 4 | #define OSCILLOSCOPE_COLOR_BACKGROUND 0x000000 5 | #define OSCILLOSCOPE_COLOR_GRID 0xA00000 6 | #define OSCILLOSCOPE_COLOR_ZERO 0xFF40FF 7 | #define OSCILLOSCOPE_COLOR_CHANNEL_1 0xF8F800 8 | #define OSCILLOSCOPE_COLOR_CHANNEL_2 0x00E8F8 9 | #define OSCILLOSCOPE_COLOR_CHANNEL_1_TEXT 0xFFFF00 10 | #define OSCILLOSCOPE_COLOR_CHANNEL_2_TEXT 0x00FFFF 11 | #define OSCILLOSCOPE_COLOR_UNITS 0xFFC000 12 | #define OSCILLOSCOPE_COLOR_LOGO 0x0000BF 13 | #define OSCILLOSCOPE_COLOR_LOGO_BACKGROUND 0xFFF0FF 14 | #define OSCILLOSCOPE_COLOR_FREQUENCY 0xFF0080 15 | #define OSCILLOSCOPE_COLOR_TRIGGER 0xBFBFBF 16 | 17 | #endif /* COLORS_H_ */ 18 | -------------------------------------------------------------------------------- /Oscilloscope/include/GainSetterTask.h: -------------------------------------------------------------------------------- 1 | #ifndef GAINSETTERTASK_H_ 2 | #define GAINSETTERTASK_H_ 3 | 4 | #include "task/AbstractTask.h" 5 | #include "graphics/TaskCanvas.h" 6 | #include "driver/AbstractDriver.h" 7 | #include "driver/SPIDriver.h" 8 | #include "pins.h" 9 | #include "Config.h" 10 | 11 | const char * getGainName(AmplifierGain name); 12 | int getGainValue(AmplifierGain name); 13 | AmplifierGain currentGain(); 14 | AmplifierGain previousGain(AmplifierGain gain); 15 | AmplifierGain nextGain(AmplifierGain gain); 16 | 17 | class GainSetterTask : public virtual AbstractTask 18 | { 19 | private: 20 | static AbstractDriverContext * driverContext; 21 | static TaskCanvas * taskCanvas; 22 | 23 | AmplifierGain gainToSet; 24 | uint8_t command[2]; 25 | bool completed = false; 26 | 27 | static void transferCompleteCb(void *arg); 28 | 29 | public: 30 | static void init(TaskCanvas * canvas, SPIDriver * driver, STM32Pin cspin); 31 | 32 | GainSetterTask(AmplifierGain gain) : gainToSet(gain) {} 33 | 34 | virtual void start(); 35 | virtual uint32_t requiredResources() {return driverContext->getDriver()->requiredResources(); } 36 | }; 37 | 38 | 39 | #endif /* GAINSETTERTASK_H_ */ 40 | -------------------------------------------------------------------------------- /Oscilloscope/include/InputDeviceHandler.h: -------------------------------------------------------------------------------- 1 | #ifndef INPUTDEVICEHANDLER_H_ 2 | #define INPUTDEVICEHANDLER_H_ 3 | 4 | #define PIN_JOY_FIRE PB6 5 | 6 | enum InputDeviceEvent 7 | { 8 | // simple states 9 | JOY_NONE=0, 10 | JOY_UP=1, 11 | JOY_RIGHT=2, 12 | JOY_DOWN=4, 13 | JOY_LEFT=8, 14 | JOY_FIRE=16, 15 | JOY_REPEAT=32, 16 | JOY_DOUBLE_FIRE=80, 17 | 18 | // composite states 19 | JOY_UPLEFT=JOY_UP+JOY_LEFT, 20 | JOY_UPRIGHT=JOY_UP+JOY_RIGHT, 21 | JOY_DOWNLEFT=JOY_DOWN+JOY_LEFT, 22 | JOY_DOWNRIGHT=JOY_DOWN+JOY_RIGHT, 23 | 24 | JOY_FIRE_UP=JOY_FIRE+JOY_UP, 25 | JOY_FIRE_UPLEFT=JOY_FIRE+JOY_UP+JOY_LEFT, 26 | JOY_FIRE_UPRIGHT=JOY_FIRE+JOY_UP+JOY_RIGHT, 27 | JOY_FIRE_DOWN=JOY_FIRE+JOY_DOWN, 28 | JOY_FIRE_DOWNLEFT=JOY_FIRE+JOY_DOWN+JOY_LEFT, 29 | JOY_FIRE_DOWNRIGHT=JOY_FIRE+JOY_DOWN+JOY_RIGHT, 30 | JOY_FIRE_LEFT=JOY_FIRE+JOY_LEFT, 31 | JOY_FIRE_RIGHT=JOY_FIRE+JOY_RIGHT, 32 | 33 | JOY_REPEAT_FIRE=JOY_REPEAT+JOY_FIRE, 34 | 35 | JOY_REPEAT_UP=JOY_REPEAT+JOY_UP, 36 | JOY_REPEAT_UPLEFT=JOY_REPEAT+JOY_UP+JOY_LEFT, 37 | JOY_REPEAT_UPRIGHT=JOY_REPEAT+JOY_UP+JOY_RIGHT, 38 | JOY_REPEAT_DOWN=JOY_REPEAT+JOY_DOWN, 39 | JOY_REPEAT_DOWNLEFT=JOY_REPEAT+JOY_DOWN+JOY_LEFT, 40 | JOY_REPEAT_DOWNRIGHT=JOY_REPEAT+JOY_DOWN+JOY_RIGHT, 41 | JOY_REPEAT_LEFT=JOY_REPEAT+JOY_LEFT, 42 | JOY_REPEAT_RIGHT=JOY_REPEAT+JOY_RIGHT, 43 | 44 | JOY_REPEAT_FIRE_UP=JOY_REPEAT+JOY_FIRE+JOY_UP, 45 | JOY_REPEAT_FIRE_UPLEFT=JOY_REPEAT+JOY_FIRE+JOY_UP+JOY_LEFT, 46 | JOY_REPEAT_FIRE_UPRIGHT=JOY_REPEAT+JOY_FIRE+JOY_UP+JOY_RIGHT, 47 | JOY_REPEAT_FIRE_DOWN=JOY_REPEAT+JOY_FIRE+JOY_DOWN, 48 | JOY_REPEAT_FIRE_DOWNLEFT=JOY_REPEAT+JOY_FIRE+JOY_DOWN+JOY_LEFT, 49 | JOY_REPEAT_FIRE_DOWNRIGHT=JOY_REPEAT+JOY_FIRE+JOY_DOWN+JOY_RIGHT, 50 | JOY_REPEAT_FIRE_LEFT=JOY_REPEAT+JOY_FIRE+JOY_LEFT, 51 | JOY_REPEAT_FIRE_RIGHT=JOY_REPEAT+JOY_FIRE+JOY_RIGHT, 52 | 53 | USB_COMMAND_NONE=0, 54 | USB_COMMAND_START_TRANSMISSION=0x1000, 55 | }; 56 | 57 | typedef void (*InputDeviceCallback)(InputDeviceEvent event); 58 | 59 | class InputDeviceHandler 60 | { 61 | private: 62 | InputDeviceCallback inputDeviceCallback = 0; 63 | unsigned lastJoyEventStamp = 0xF0000000; 64 | unsigned lastJoyReadStamp = 0; 65 | InputDeviceEvent lastEvent = JOY_NONE; 66 | unsigned doubleFireCounter = 0xFFFFFFFF; 67 | InputDeviceEvent usbEvent = USB_COMMAND_NONE; 68 | 69 | InputDeviceEvent readJoystickState(unsigned time); 70 | 71 | public: 72 | void init(InputDeviceCallback cb=0); 73 | void loop(); 74 | 75 | InputDeviceCallback getInputDeviceCallback() { return inputDeviceCallback; } 76 | void setInputDeviceCallback( InputDeviceCallback cb ) { inputDeviceCallback = cb; } 77 | 78 | void noJoystickData(); 79 | void setUSBCommand(InputDeviceEvent event) {usbEvent = event;} 80 | }; 81 | 82 | extern InputDeviceHandler inputDeviceHandler; 83 | 84 | #endif /* INPUTDEVICEHANDLER_H_ */ 85 | -------------------------------------------------------------------------------- /Oscilloscope/include/MeasurementData.h: -------------------------------------------------------------------------------- 1 | #ifndef MEASUREMENTDATA_H_ 2 | #define MEASUREMENTDATA_H_ 3 | 4 | #define SAMPLE_NUMBER 150 5 | #define MAX_VALUE 100 6 | #define MAX_CHANNELS 2 7 | 8 | #define INVALID_VALUE ((unsigned)(-1)) 9 | 10 | #include 11 | 12 | enum class ValueScale 13 | { 14 | NANO, 15 | MICRO, 16 | MILLI, 17 | NONE, 18 | KILO, 19 | MEGA, 20 | GIGA, 21 | }; 22 | 23 | enum class ValueUnit 24 | { 25 | VOLTAGE, 26 | TIME, 27 | NONE, 28 | FREQUENCY, 29 | PERCENT, 30 | BYTE, 31 | BYTE_PER_SEC, 32 | INVALID, 33 | }; 34 | 35 | typedef struct Value 36 | { 37 | int data : 24; 38 | ValueScale scale : 4; 39 | ValueUnit unit : 4; 40 | 41 | public: 42 | Value(int dataIn, ValueScale scaleIn, ValueUnit unitIn) : data(dataIn), scale(scaleIn), unit(unitIn) {} 43 | Value() : data(0), scale(ValueScale::NONE), unit(ValueUnit::INVALID) {} 44 | } Value; 45 | 46 | int digits(int value); 47 | int roundValue(int val, int digits); 48 | int roundValueUp(int val, int digits); 49 | 50 | const char * scaleToString(ValueScale unit); 51 | const char * unitToString(ValueUnit unit); 52 | const char * valueToString(Value v, bool preferInt=false); 53 | Value scaleValue(int value, ValueScale lowestScale, ValueUnit unit); 54 | Value scaleIntValue(int value, ValueScale lowestScale, ValueUnit unit); 55 | 56 | class MeasurementData 57 | { 58 | private: 59 | uint8_t channelData[MAX_CHANNELS][SAMPLE_NUMBER]; 60 | unsigned offset[MAX_CHANNELS]; 61 | unsigned zeroLine = 0xFFFFFFFF; 62 | unsigned counter = 0; 63 | unsigned average[MAX_CHANNELS]; 64 | unsigned min[MAX_CHANNELS]; 65 | unsigned max[MAX_CHANNELS]; 66 | uint64_t eff[MAX_CHANNELS]; 67 | Value channelError[MAX_CHANNELS]; 68 | Value frequency; 69 | unsigned samplingInterval = 0; 70 | Value scopeMin; 71 | Value scopeMax; 72 | Value scopeScale; 73 | int gainValue; 74 | 75 | unsigned internalReferenceValue; 76 | Value internalReferenceError; 77 | 78 | Value convertValue(unsigned val, int divisor, int channel); 79 | void determineFrequency(uint32_t * buffer, unsigned maxSamples); 80 | 81 | public: 82 | MeasurementData(); 83 | 84 | uint8_t * getChannelData(unsigned chan) {return channelData[chan];} 85 | unsigned getZeroLine() { return zeroLine; } 86 | void setZeroLine( unsigned val ) { zeroLine = val; } 87 | unsigned getSamplingInterval() { return samplingInterval; } 88 | void setSamplingInterval( unsigned val ) { samplingInterval = val; } 89 | 90 | unsigned getOffset(unsigned chan) {return offset[chan];} 91 | void setOffset(unsigned chan, unsigned val) {offset[chan] = val; } 92 | 93 | void reset(); 94 | void setCollectedData(uint32_t * buffer, unsigned maxSamples); 95 | void setSampleBuffer(uint32_t * buffer, unsigned maxSamples); 96 | void setFFTBuffer(uint32_t * buffer, unsigned maxSamples); 97 | void setVrefAndVccBuffer(uint32_t * buffer, unsigned maxSamples); 98 | 99 | Value getAverage(int channel) { return convertValue(average[channel], counter, channel); } 100 | Value getMin(int channel) { return convertValue(min[channel], 1, channel); } 101 | Value getMax(int channel) { return convertValue(max[channel], 1, channel); } 102 | Value getEff(int channel); 103 | Value adcToVoltage( unsigned adc, int channel); 104 | unsigned voltageToAdc( Value voltage, int channel); 105 | 106 | Value getMeasuredFrequency() { return frequency; } 107 | Value getChannelError(int channel) { return channelError[channel]; } 108 | 109 | Value getScopeMin() { return scopeMin; } 110 | Value getScopeMax() { return scopeMax; } 111 | Value getScopeScale() { return scopeScale; } 112 | 113 | unsigned getInternalReferenceValue() { return internalReferenceValue; } 114 | void setInternalReferenceValue(unsigned val) {internalReferenceValue = val; } 115 | Value getInternalReferenceError() { return internalReferenceError; } 116 | }; 117 | 118 | #endif /* MEASUREMENTDATA_H_ */ 119 | -------------------------------------------------------------------------------- /Oscilloscope/include/MeasurementValueWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef MEASUREMENTVALUEWIDGET_H_ 2 | #define MEASUREMENTVALUEWIDGET_H_ 3 | 4 | #include "graphics/TaskCanvas.h" 5 | #include "MeasurementData.h" 6 | 7 | class MeasurementValueWidget 8 | { 9 | private: 10 | MeasurementData * data; 11 | 12 | public: 13 | MeasurementValueWidget(MeasurementData *dataIn); 14 | 15 | void draw(TaskCanvas *canvas); 16 | void channel(char * buffer, int channel); 17 | }; 18 | 19 | #endif /* MEASUREMENTVALUEWIDGET_H_ */ 20 | -------------------------------------------------------------------------------- /Oscilloscope/include/OscilloscopeGrid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * OscilloscopeGrid.h 3 | * 4 | * Created on: 2016. dec. 31. 5 | * Author: ckarai 6 | */ 7 | 8 | #ifndef OSCILLOSCOPEGRID_H_ 9 | #define OSCILLOSCOPEGRID_H_ 10 | 11 | #define GRID_X 8 12 | #define GRID_Y 17 13 | 14 | #include "task/AbstractTask.h" 15 | #include "graphics/TaskCanvas.h" 16 | #include "MeasurementData.h" 17 | 18 | class OscilloscopeGrid : public virtual AbstractTask 19 | { 20 | private: 21 | TaskCanvas * canvas; 22 | MeasurementData * data; 23 | unsigned x; 24 | unsigned y; 25 | unsigned currentX; 26 | 27 | void renderScopeGrid(unsigned currentX); 28 | void renderChannel(unsigned channel, uint8_t * colors, unsigned currentX, unsigned segmSize); 29 | 30 | public: 31 | OscilloscopeGrid(TaskCanvas * canvasIn, MeasurementData *dataIn, unsigned xIn, unsigned yIn); 32 | 33 | virtual void start(); 34 | 35 | virtual bool hasCachedData() { return true; } 36 | virtual void buildCachedData(); 37 | 38 | virtual uint32_t requiredResources() {return canvas->requiredResources();} 39 | }; 40 | 41 | 42 | 43 | #endif /* OSCILLOSCOPEGRID_H_ */ 44 | -------------------------------------------------------------------------------- /Oscilloscope/include/OscilloscopeScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef OSCILLOSCOPESCREEN_H_ 2 | #define OSCILLOSCOPESCREEN_H_ 3 | 4 | #include "graphics/TaskCanvas.h" 5 | #include "MeasurementData.h" 6 | 7 | class OscilloscopeScreen 8 | { 9 | private: 10 | MeasurementData * data; 11 | 12 | public: 13 | OscilloscopeScreen(MeasurementData *data); 14 | 15 | void draw(TaskCanvas *canvas); 16 | }; 17 | 18 | #endif /* OSCILLOSCOPESCREEN_H_ */ 19 | -------------------------------------------------------------------------------- /Oscilloscope/include/Sampler.h: -------------------------------------------------------------------------------- 1 | #ifndef SAMPLER_H_ 2 | #define SAMPLER_H_ 3 | 4 | #include "MeasurementData.h" 5 | #include "pins.h" 6 | 7 | #define CIRCULAR_RESERVE 10 8 | #define SAMPLE_BUFFER_SIZE (2*(SAMPLE_NUMBER+CIRCULAR_RESERVE)) 9 | 10 | #define PIN_JOYY PA0 11 | #define PIN_JOYX PA1 12 | #define PIN_VREF PA2 13 | #define PIN_CHANNEL_1 PB0 14 | #define PIN_CHANNEL_2 PB1 15 | 16 | typedef enum 17 | { 18 | ST_NONE, 19 | ST_SAMPLE_VREF_AND_VCC, 20 | ST_COLLECT_DATA, 21 | ST_TRIGGER_WAIT, 22 | ST_SAMPLE_LINES, 23 | 24 | ST_DATA_TRANSMIT, 25 | 26 | ST_MAX, 27 | } SampleState; 28 | 29 | typedef enum 30 | { 31 | SM_TIMER, 32 | SM_CONTINUOUS, 33 | SM_FAST_INTERLEAVED, 34 | } SamplingMethod; 35 | 36 | typedef enum 37 | { 38 | REFRESH_OSCILLOSCOPE, 39 | REFRESH_TRIGGER, 40 | REFRESH_MEASUREMENT_VALUE, 41 | } RefreshType; 42 | 43 | typedef void (*RefreshCallback)(RefreshType joy); 44 | 45 | class TaskCanvas; 46 | 47 | class Sampler 48 | { 49 | private: 50 | unsigned lcdResources; 51 | MeasurementData & measurementData; 52 | uint32_t sampleBuffer[SAMPLE_BUFFER_SIZE]; 53 | volatile bool sampleDone = true; 54 | SampleState sampleState = ST_NONE; 55 | SamplingMethod samplingMethod = SM_TIMER; 56 | unsigned lastTimeStamp = 0xF0000000; 57 | bool timeExpired = false; 58 | bool lcdWait = false; 59 | bool singleShotTriggerEnable = true; 60 | bool lastSingleShotEnabled = false; 61 | 62 | RefreshCallback refreshCallback = 0; 63 | 64 | static Sampler * instance; 65 | 66 | void nextState(); 67 | void setupState(); 68 | void processResults(); 69 | 70 | static unsigned getSamplingRateIndex(unsigned rate); 71 | 72 | void setSamplerPriority(int prio, int subPrio); 73 | 74 | public: 75 | Sampler(unsigned lcdResources, MeasurementData & data); 76 | 77 | static void handleIrq(int isCompleted); 78 | 79 | void init(RefreshCallback rf=0); 80 | void loop(); 81 | 82 | void setSamplingTimeMicro(unsigned micro); 83 | 84 | static Sampler * getInstance() { return instance; } 85 | 86 | static unsigned getNextSamplingRate(unsigned rate); 87 | static unsigned getPreviousSamplingRate(unsigned rate); 88 | 89 | void increaseSamplingRate(); 90 | void decreaseSamplingRate(); 91 | 92 | void enableSingleShotTrigger() { singleShotTriggerEnable = true; } 93 | bool isSingleShotTriggerEnabled() { return singleShotTriggerEnable; } 94 | 95 | void restart(); 96 | 97 | RefreshCallback getRefreshCallback() { return refreshCallback; } 98 | void setRefreshCallback( RefreshCallback cb ) { refreshCallback = cb; } 99 | 100 | MeasurementData & getMeasurementData() { return measurementData;} 101 | 102 | void setSampleDone() { sampleDone = true; } 103 | 104 | void startTransmitter( void (*transmitter_cb)(int complete)); 105 | void setTransmitterPriority(int prio, int subPrio) {setSamplerPriority(prio, subPrio);} 106 | 107 | uint32_t * getSampleBuffer() { return sampleBuffer; } 108 | 109 | bool readJoy(unsigned * joyx, unsigned *joyy); 110 | }; 111 | 112 | #endif /* SAMPLER_H_ */ 113 | -------------------------------------------------------------------------------- /Oscilloscope/include/TriggerHandler.h: -------------------------------------------------------------------------------- 1 | #ifndef TRIGGERHANDLER_H_ 2 | #define TRIGGERHANDLER_H_ 3 | 4 | #include "Config.h" 5 | #include 6 | 7 | typedef void (*TriggerCallback)(int cycles_to_collect); 8 | 9 | class TriggerHandler 10 | { 11 | private: 12 | bool inited = false; 13 | 14 | void initializeTrigger(); 15 | void enableWatchDog(); 16 | 17 | public: 18 | void init(TriggerCallback callback); 19 | void loop(); 20 | 21 | void setupTrigger(); 22 | void destroyTrigger(); 23 | 24 | void reorderSampleBuffer(uint32_t * buffer, int size, int circularReserve); 25 | 26 | static void jumpToNextTrigger(); 27 | static void jumpToPreviousTrigger(); 28 | }; 29 | 30 | 31 | extern TriggerHandler triggerHandler; 32 | 33 | 34 | #endif /* TRIGGERHANDLER_H_ */ 35 | -------------------------------------------------------------------------------- /Oscilloscope/include/TriggerWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef TRIGGERWIDGET_H_ 2 | #define TRIGGERWIDGET_H_ 3 | 4 | #include "graphics/TaskCanvas.h" 5 | #include "MeasurementData.h" 6 | 7 | class TriggerWidget 8 | { 9 | private: 10 | MeasurementData * data; 11 | 12 | public: 13 | TriggerWidget(MeasurementData *dataIn); 14 | 15 | void draw(TaskCanvas *canvas); 16 | }; 17 | 18 | extern const uint8_t bmp_trigger_none []; 19 | extern const uint8_t bmp_trigger_rising_edge []; 20 | extern const uint8_t bmp_trigger_falling_edge []; 21 | extern const uint8_t bmp_trigger_changing_edge []; 22 | extern const uint8_t bmp_trigger_positive_peak []; 23 | extern const uint8_t bmp_trigger_negative_peak []; 24 | extern const uint8_t bmp_trigger_external []; 25 | extern const uint8_t bmp_trigger_none_fft []; 26 | 27 | #endif /* TRIGGERWIDGET_H_ */ 28 | -------------------------------------------------------------------------------- /Oscilloscope/include/USB/USBHandler.h: -------------------------------------------------------------------------------- 1 | #ifndef USB_USBHANDLER_H_ 2 | #define USB_USBHANDLER_H_ 3 | 4 | extern "C" 5 | { 6 | #include "usb_pwr.h" 7 | #include "hw_config.h" 8 | } 9 | 10 | typedef enum 11 | { 12 | // Good states 13 | STATE_NONE=0, 14 | STATE_TRANSMITTING, 15 | STATE_USER_ABORT, 16 | STATE_USB_ABORT, 17 | 18 | // Errors 19 | STATE_BUFFER_OVERFLOW=128, 20 | } USBState; 21 | 22 | typedef void (*LoopCallback)(); 23 | 24 | #define MAX_USB_TRANSMISSION_RATE 910000 25 | 26 | #define SEND_BUFFER_SIZE 4096 27 | #define MAX_TRANSMIT_SIZE 0x7FFFFFFF 28 | 29 | #define FRAME_CLOSING 0 30 | #define FRAME_DONE -1 31 | #define FRAME_WAITING -2 32 | 33 | class USBHandler 34 | { 35 | private: 36 | volatile unsigned transmittedBytes = 0; 37 | volatile bool sendHeader = false; 38 | volatile bool transmitting = false; 39 | volatile USBState usbState = STATE_NONE; 40 | 41 | uint8_t * usbBuffer = 0; 42 | 43 | int usbHead = 0; 44 | int usbTail = 0; 45 | 46 | int availableBytes = FRAME_DONE; 47 | 48 | public: 49 | void init(); 50 | void attach(); 51 | void detach(); 52 | 53 | DEVICE_STATE getState() { return (DEVICE_STATE)bDeviceState; } 54 | 55 | unsigned getTransmittedBytes() { return transmittedBytes; } 56 | 57 | void transmit( LoopCallback cb ); 58 | 59 | void fillUSBBuffer(int part); 60 | void sendUSBBuffer(); 61 | void newFrame(); 62 | 63 | bool isTransmitting() { return transmitting; } 64 | 65 | USBState getTransmissionState() { return usbState; } 66 | void resetTransmissionResult() { usbState = STATE_NONE; } 67 | 68 | void dataReceived(char * data, unsigned length); 69 | }; 70 | 71 | extern USBHandler usbHandler; 72 | 73 | #endif /* USB_USBHANDLER_H_ */ 74 | -------------------------------------------------------------------------------- /Oscilloscope/include/USB/hw_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file hw_config.h 4 | * @author MCD Application Team 5 | * @version V4.0.0 6 | * @date 21-January-2013 7 | * @brief Hardware Configuration & Setup 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __HW_CONFIG_H 31 | #define __HW_CONFIG_H 32 | 33 | /* Includes ------------------------------------------------------------------*/ 34 | #include "platform_config.h" 35 | #include "usb_type.h" 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* Exported macro ------------------------------------------------------------*/ 40 | /* Exported define -----------------------------------------------------------*/ 41 | #define MASS_MEMORY_START 0x04002000 42 | #define BULK_MAX_PACKET_SIZE 0x00000040 43 | #define LED_ON 0xF0 44 | #define LED_OFF 0xFF 45 | 46 | /* Exported functions ------------------------------------------------------- */ 47 | void Set_System(void); 48 | void Set_USBClock(void); 49 | void Enter_LowPowerMode(void); 50 | void Leave_LowPowerMode(void); 51 | void USB_Interrupts_Config(void); 52 | void USB_Interrupts_SetHighPriority(void); 53 | void USB_Interrupts_SetLowPriority(void); 54 | void USB_Cable_Config (FunctionalState NewState); 55 | void Get_SerialNum(void); 56 | void LCD_Control(void); 57 | uint32_t CDC_Send_DATA (uint8_t *ptrBuffer, uint8_t Send_length); 58 | uint32_t CDC_Receive_DATA(void); 59 | /* External variables --------------------------------------------------------*/ 60 | 61 | #endif /*__HW_CONFIG_H*/ 62 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 63 | -------------------------------------------------------------------------------- /Oscilloscope/include/USB/platform_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file platform_config.h 4 | * @author MCD Application Team 5 | * @version V4.0.0 6 | * @date 21-January-2013 7 | * @brief Evaluation board specific configuration file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __PLATFORM_CONFIG_H 31 | #define __PLATFORM_CONFIG_H 32 | 33 | #include "stm32f10x.h" 34 | 35 | #define USB_DISCONNECT GPIOB 36 | #define USB_DISCONNECT_PIN GPIO_Pin_14 37 | #define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOB 38 | 39 | #define ID1 (0x1FFFF7E8) 40 | #define ID2 (0x1FFFF7EC) 41 | #define ID3 (0x1FFFF7F0) 42 | 43 | 44 | #endif /* __PLATFORM_CONFIG_H */ 45 | 46 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 47 | -------------------------------------------------------------------------------- /Oscilloscope/include/USB/stm32_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32_it.h 4 | * @author MCD Application Team 5 | * @version V4.0.0 6 | * @date 21-January-2013 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32_IT_H 31 | #define __STM32_IT_H 32 | 33 | /* Includes ------------------------------------------------------------------*/ 34 | #include "platform_config.h" 35 | 36 | void USBWakeUp_IRQHandler(void); 37 | void USB_FS_WKUP_IRQHandler(void); 38 | 39 | #endif /* __STM32_IT_H */ 40 | 41 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 42 | -------------------------------------------------------------------------------- /Oscilloscope/include/USB/usb_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_conf.h 4 | * @author MCD Application Team 5 | * @version V4.0.0 6 | * @date 21-January-2013 7 | * @brief Virtual COM Port Demo configuration header 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __USB_CONF_H 31 | #define __USB_CONF_H 32 | 33 | void DATA_RECEIVED_Callback(char * buf, unsigned length); 34 | 35 | /* Includes ------------------------------------------------------------------*/ 36 | /* Exported types ------------------------------------------------------------*/ 37 | /* Exported constants --------------------------------------------------------*/ 38 | /* Exported macro ------------------------------------------------------------*/ 39 | /* Exported functions ------------------------------------------------------- */ 40 | /* External variables --------------------------------------------------------*/ 41 | 42 | /*-------------------------------------------------------------*/ 43 | /* EP_NUM */ 44 | /* defines how many endpoints are used by the device */ 45 | /*-------------------------------------------------------------*/ 46 | 47 | #define EP_NUM (4) 48 | 49 | /*-------------------------------------------------------------*/ 50 | /* -------------- Buffer Description Table -----------------*/ 51 | /*-------------------------------------------------------------*/ 52 | /* buffer table base address */ 53 | /* buffer table base address */ 54 | #define BTABLE_ADDRESS (0x00) 55 | 56 | /* EP0 */ 57 | /* rx/tx buffer base address */ 58 | #define ENDP0_RXADDR (0x40) 59 | #define ENDP0_TXADDR (0x80) 60 | 61 | /* EP1 */ 62 | /* tx buffer base address */ 63 | #define ENDP1_TXADDR (0xC0) 64 | #define ENDP2_TXADDR (0x100) 65 | #define ENDP3_RXADDR (0x110) 66 | 67 | 68 | /*-------------------------------------------------------------*/ 69 | /* ------------------- ISTR events -------------------------*/ 70 | /*-------------------------------------------------------------*/ 71 | /* IMR_MSK */ 72 | /* mask defining which events has to be handled */ 73 | /* by the device application software */ 74 | #define IMR_MSK (CNTR_CTRM | CNTR_SOFM | CNTR_RESETM ) 75 | 76 | /*#define CTR_CALLBACK*/ 77 | /*#define DOVR_CALLBACK*/ 78 | /*#define ERR_CALLBACK*/ 79 | /*#define WKUP_CALLBACK*/ 80 | /*#define SUSP_CALLBACK*/ 81 | /*#define RESET_CALLBACK*/ 82 | #define SOF_CALLBACK 83 | /*#define ESOF_CALLBACK*/ 84 | #define DATA_RECEIVED_CALLBACK 85 | /* CTR service routines */ 86 | /* associated to defined endpoints */ 87 | /*#define EP1_IN_Callback NOP_Process*/ 88 | #define EP2_IN_Callback NOP_Process 89 | #define EP3_IN_Callback NOP_Process 90 | #define EP4_IN_Callback NOP_Process 91 | #define EP5_IN_Callback NOP_Process 92 | #define EP6_IN_Callback NOP_Process 93 | #define EP7_IN_Callback NOP_Process 94 | 95 | #define EP1_OUT_Callback NOP_Process 96 | #define EP2_OUT_Callback NOP_Process 97 | /*#define EP3_OUT_Callback NOP_Process*/ 98 | #define EP4_OUT_Callback NOP_Process 99 | #define EP5_OUT_Callback NOP_Process 100 | #define EP6_OUT_Callback NOP_Process 101 | #define EP7_OUT_Callback NOP_Process 102 | 103 | #endif /* __USB_CONF_H */ 104 | 105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 106 | -------------------------------------------------------------------------------- /Oscilloscope/include/USB/usb_desc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_desc.h 4 | * @author MCD Application Team 5 | * @version V4.0.0 6 | * @date 21-January-2013 7 | * @brief Descriptor Header for Virtual COM Port Device 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __USB_DESC_H 31 | #define __USB_DESC_H 32 | 33 | /* Includes ------------------------------------------------------------------*/ 34 | /* Exported types ------------------------------------------------------------*/ 35 | /* Exported constants --------------------------------------------------------*/ 36 | /* Exported macro ------------------------------------------------------------*/ 37 | /* Exported define -----------------------------------------------------------*/ 38 | #define USB_DEVICE_DESCRIPTOR_TYPE 0x01 39 | #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02 40 | #define USB_STRING_DESCRIPTOR_TYPE 0x03 41 | #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04 42 | #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05 43 | 44 | #define VIRTUAL_COM_PORT_DATA_SIZE 64 45 | #define VIRTUAL_COM_PORT_INT_SIZE 8 46 | 47 | #define VIRTUAL_COM_PORT_SIZ_DEVICE_DESC 18 48 | #define VIRTUAL_COM_PORT_SIZ_CONFIG_DESC 62 49 | #define VIRTUAL_COM_PORT_SIZ_STRING_LANGID 4 50 | #define VIRTUAL_COM_PORT_SIZ_STRING_VENDOR 24 51 | #define VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT 22 52 | #define VIRTUAL_COM_PORT_SIZ_STRING_SERIAL 50 53 | 54 | #define STANDARD_ENDPOINT_DESC_SIZE 0x09 55 | 56 | /* Exported functions ------------------------------------------------------- */ 57 | extern const uint8_t Virtual_Com_Port_DeviceDescriptor[VIRTUAL_COM_PORT_SIZ_DEVICE_DESC]; 58 | extern const uint8_t Virtual_Com_Port_ConfigDescriptor[VIRTUAL_COM_PORT_SIZ_CONFIG_DESC]; 59 | 60 | extern const uint8_t Virtual_Com_Port_StringLangID[VIRTUAL_COM_PORT_SIZ_STRING_LANGID]; 61 | extern const uint8_t Virtual_Com_Port_StringVendor[VIRTUAL_COM_PORT_SIZ_STRING_VENDOR]; 62 | extern const uint8_t Virtual_Com_Port_StringProduct[VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT]; 63 | extern uint8_t Virtual_Com_Port_StringSerial[VIRTUAL_COM_PORT_SIZ_STRING_SERIAL]; 64 | 65 | #endif /* __USB_DESC_H */ 66 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 67 | -------------------------------------------------------------------------------- /Oscilloscope/include/USB/usb_istr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_istr.h 4 | * @author MCD Application Team 5 | * @version V4.0.0 6 | * @date 21-January-2013 7 | * @brief This file includes the peripherals header files in the user application. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __USB_ISTR_H 31 | #define __USB_ISTR_H 32 | 33 | /* Includes ------------------------------------------------------------------*/ 34 | #include "usb_conf.h" 35 | 36 | /* Exported types ------------------------------------------------------------*/ 37 | /* Exported constants --------------------------------------------------------*/ 38 | /* Exported macro ------------------------------------------------------------*/ 39 | /* Exported functions ------------------------------------------------------- */ 40 | 41 | void USB_Istr(void); 42 | 43 | /* function prototypes Automatically built defining related macros */ 44 | 45 | void EP1_IN_Callback(void); 46 | void EP2_IN_Callback(void); 47 | void EP3_IN_Callback(void); 48 | void EP4_IN_Callback(void); 49 | void EP5_IN_Callback(void); 50 | void EP6_IN_Callback(void); 51 | void EP7_IN_Callback(void); 52 | 53 | void EP1_OUT_Callback(void); 54 | void EP2_OUT_Callback(void); 55 | void EP3_OUT_Callback(void); 56 | void EP4_OUT_Callback(void); 57 | void EP5_OUT_Callback(void); 58 | void EP6_OUT_Callback(void); 59 | void EP7_OUT_Callback(void); 60 | 61 | #ifdef CTR_CALLBACK 62 | void CTR_Callback(void); 63 | #endif 64 | 65 | #ifdef DOVR_CALLBACK 66 | void DOVR_Callback(void); 67 | #endif 68 | 69 | #ifdef ERR_CALLBACK 70 | void ERR_Callback(void); 71 | #endif 72 | 73 | #ifdef WKUP_CALLBACK 74 | void WKUP_Callback(void); 75 | #endif 76 | 77 | #ifdef SUSP_CALLBACK 78 | void SUSP_Callback(void); 79 | #endif 80 | 81 | #ifdef RESET_CALLBACK 82 | void RESET_Callback(void); 83 | #endif 84 | 85 | #ifdef SOF_CALLBACK 86 | void SOF_Callback(void); 87 | #endif 88 | 89 | #ifdef ESOF_CALLBACK 90 | void ESOF_Callback(void); 91 | #endif 92 | #endif /*__USB_ISTR_H*/ 93 | 94 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 95 | -------------------------------------------------------------------------------- /Oscilloscope/include/USB/usb_prop.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_prop.h 4 | * @author MCD Application Team 5 | * @version V4.0.0 6 | * @date 21-January-2013 7 | * @brief All processing related to Virtual COM Port Demo (Endpoint 0) 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __usb_prop_H 31 | #define __usb_prop_H 32 | 33 | /* Includes ------------------------------------------------------------------*/ 34 | /* Exported types ------------------------------------------------------------*/ 35 | typedef struct 36 | { 37 | uint32_t bitrate; 38 | uint8_t format; 39 | uint8_t paritytype; 40 | uint8_t datatype; 41 | }LINE_CODING; 42 | 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* Exported macro ------------------------------------------------------------*/ 45 | /* Exported define -----------------------------------------------------------*/ 46 | 47 | #define Virtual_Com_Port_GetConfiguration NOP_Process 48 | //#define Virtual_Com_Port_SetConfiguration NOP_Process 49 | #define Virtual_Com_Port_GetInterface NOP_Process 50 | #define Virtual_Com_Port_SetInterface NOP_Process 51 | #define Virtual_Com_Port_GetStatus NOP_Process 52 | #define Virtual_Com_Port_ClearFeature NOP_Process 53 | #define Virtual_Com_Port_SetEndPointFeature NOP_Process 54 | #define Virtual_Com_Port_SetDeviceFeature NOP_Process 55 | //#define Virtual_Com_Port_SetDeviceAddress NOP_Process 56 | 57 | #define SEND_ENCAPSULATED_COMMAND 0x00 58 | #define GET_ENCAPSULATED_RESPONSE 0x01 59 | #define SET_COMM_FEATURE 0x02 60 | #define GET_COMM_FEATURE 0x03 61 | #define CLEAR_COMM_FEATURE 0x04 62 | #define SET_LINE_CODING 0x20 63 | #define GET_LINE_CODING 0x21 64 | #define SET_CONTROL_LINE_STATE 0x22 65 | #define SEND_BREAK 0x23 66 | 67 | /* Exported functions ------------------------------------------------------- */ 68 | void Virtual_Com_Port_init(void); 69 | void Virtual_Com_Port_Reset(void); 70 | void Virtual_Com_Port_SetConfiguration(void); 71 | void Virtual_Com_Port_SetDeviceAddress (void); 72 | void Virtual_Com_Port_Status_In (void); 73 | void Virtual_Com_Port_Status_Out (void); 74 | RESULT Virtual_Com_Port_Data_Setup(uint8_t); 75 | RESULT Virtual_Com_Port_NoData_Setup(uint8_t); 76 | RESULT Virtual_Com_Port_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting); 77 | uint8_t *Virtual_Com_Port_GetDeviceDescriptor(uint16_t ); 78 | uint8_t *Virtual_Com_Port_GetConfigDescriptor(uint16_t); 79 | uint8_t *Virtual_Com_Port_GetStringDescriptor(uint16_t); 80 | 81 | uint8_t *Virtual_Com_Port_GetLineCoding(uint16_t Length); 82 | uint8_t *Virtual_Com_Port_SetLineCoding(uint16_t Length); 83 | 84 | #endif /* __usb_prop_H */ 85 | 86 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 87 | 88 | -------------------------------------------------------------------------------- /Oscilloscope/include/USB/usb_pwr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_pwr.h 4 | * @author MCD Application Team 5 | * @version V4.0.0 6 | * @date 21-January-2013 7 | * @brief Connection/disconnection & power management header 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | #include "usb_lib.h" 29 | 30 | /* Define to prevent recursive inclusion -------------------------------------*/ 31 | #ifndef __USB_PWR_H 32 | #define __USB_PWR_H 33 | 34 | /* Includes ------------------------------------------------------------------*/ 35 | /* Exported types ------------------------------------------------------------*/ 36 | typedef enum _RESUME_STATE 37 | { 38 | RESUME_EXTERNAL, 39 | RESUME_INTERNAL, 40 | RESUME_LATER, 41 | RESUME_WAIT, 42 | RESUME_START, 43 | RESUME_ON, 44 | RESUME_OFF, 45 | RESUME_ESOF 46 | } RESUME_STATE; 47 | 48 | typedef enum _DEVICE_STATE 49 | { 50 | UNCONNECTED, 51 | ATTACHED, 52 | POWERED, 53 | SUSPENDED, 54 | ADDRESSED, 55 | CONFIGURED 56 | } DEVICE_STATE; 57 | 58 | /* Exported constants --------------------------------------------------------*/ 59 | /* Exported macro ------------------------------------------------------------*/ 60 | /* Exported functions ------------------------------------------------------- */ 61 | void Suspend(void); 62 | void Resume_Init(void); 63 | void Resume(RESUME_STATE eResumeSetVal); 64 | RESULT PowerOn(void); 65 | RESULT PowerOff(void); 66 | 67 | /* External variables --------------------------------------------------------*/ 68 | extern __IO uint32_t bDeviceState; /* USB device status */ 69 | extern __IO bool fSuspendEnabled; /* true when suspend is possible */ 70 | 71 | #endif /*__USB_PWR_H*/ 72 | 73 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 74 | -------------------------------------------------------------------------------- /Oscilloscope/include/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_CONF_H 24 | #define __STM32F10x_CONF_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | /* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */ 28 | #include "stm32f10x_adc.h" 29 | #include "stm32f10x_bkp.h" 30 | #include "stm32f10x_can.h" 31 | #include "stm32f10x_cec.h" 32 | #include "stm32f10x_crc.h" 33 | #include "stm32f10x_dac.h" 34 | #include "stm32f10x_dbgmcu.h" 35 | #include "stm32f10x_dma.h" 36 | #include "stm32f10x_exti.h" 37 | #include "stm32f10x_flash.h" 38 | #include "stm32f10x_fsmc.h" 39 | #include "stm32f10x_gpio.h" 40 | #include "stm32f10x_i2c.h" 41 | #include "stm32f10x_iwdg.h" 42 | #include "stm32f10x_pwr.h" 43 | #include "stm32f10x_rcc.h" 44 | #include "stm32f10x_rtc.h" 45 | #include "stm32f10x_sdio.h" 46 | #include "stm32f10x_spi.h" 47 | #include "stm32f10x_tim.h" 48 | #include "stm32f10x_usart.h" 49 | #include "stm32f10x_wwdg.h" 50 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 51 | 52 | /* Exported types ------------------------------------------------------------*/ 53 | /* Exported constants --------------------------------------------------------*/ 54 | /* Uncomment the line below to expanse the "assert_param" macro in the 55 | Standard Peripheral Library drivers code */ 56 | /* #define USE_FULL_ASSERT 1 */ 57 | 58 | /* Exported macro ------------------------------------------------------------*/ 59 | #ifdef USE_FULL_ASSERT 60 | 61 | /** 62 | * @brief The assert_param macro is used for function's parameters check. 63 | * @param expr: If expr is false, it calls assert_failed function which reports 64 | * the name of the source file and the source line number of the call 65 | * that failed. If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | //#define VECT_TAB_SRAM 76 | 77 | #endif /* __STM32F10x_CONF_H */ 78 | 79 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 80 | -------------------------------------------------------------------------------- /Oscilloscope/ldscripts/libs.ld: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Placeholder to list other libraries required by the application. 4 | 5 | GROUP( 6 | ) 7 | 8 | */ 9 | -------------------------------------------------------------------------------- /Oscilloscope/ldscripts/mem.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * Memory Spaces Definitions. 3 | * 4 | * Need modifying for a specific board. 5 | * FLASH.ORIGIN: starting address of flash 6 | * FLASH.LENGTH: length of flash 7 | * RAM.ORIGIN: starting address of RAM bank 0 8 | * RAM.LENGTH: length of RAM bank 0 9 | * 10 | * The values below can be addressed in further linker scripts 11 | * using functions like 'ORIGIN(RAM)' or 'LENGTH(RAM)'. 12 | */ 13 | 14 | MEMORY 15 | { 16 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K 17 | CCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 0 18 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K 19 | FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 20 | EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0 21 | EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0 22 | EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0 23 | EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0 24 | MEMORY_ARRAY (xrw) : ORIGIN = 0x00000000, LENGTH = 0 25 | } 26 | 27 | /* 28 | * For external ram use something like: 29 | 30 | RAM (xrw) : ORIGIN = 0x68000000, LENGTH = 20K 31 | 32 | */ 33 | -------------------------------------------------------------------------------- /Oscilloscope/src/AmplifierWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "AmplifierWidget.h" 2 | #include "graphics/Fonts.h" 3 | #include "GainSetterTask.h" 4 | #include 5 | 6 | #define AMPLIFIER_LOCATION_X 139 7 | #define AMPLIFIER_LOCATION_Y 25 8 | #define AMPLIFIER_SIZE_X 19 9 | #define AMPLIFIER_SIZE_Y 16 10 | 11 | void AmplifierWidget::draw(TaskCanvas * canvas) 12 | { 13 | canvas->setFont(font_5x7); 14 | canvas->fillRect(AMPLIFIER_LOCATION_X, AMPLIFIER_LOCATION_Y, AMPLIFIER_SIZE_X, AMPLIFIER_SIZE_Y, COLOR_BLUE); 15 | canvas->drawRect(AMPLIFIER_LOCATION_X, AMPLIFIER_LOCATION_Y, AMPLIFIER_SIZE_X, AMPLIFIER_SIZE_Y, COLOR_WHITE); 16 | 17 | const char * name = getGainName(currentGain()); 18 | int loc = AMPLIFIER_LOCATION_X + 3; 19 | if( strlen(name) < 3 ) 20 | loc += 2; 21 | canvas->drawText(loc, AMPLIFIER_LOCATION_Y+5, name, COLOR_WHITE, COLOR_BLUE); 22 | } 23 | -------------------------------------------------------------------------------- /Oscilloscope/src/Config.cpp: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #include 3 | #include 4 | #include 5 | 6 | #define CONFIG_ADDRESS 0x0801FC00 7 | #define PAGE_SIZE 0x400 8 | 9 | Config config; 10 | 11 | void Config::calculateCRC() 12 | { 13 | CRC_ResetDR(); 14 | crc = 0; 15 | 16 | CRC_CalcBlockCRC((uint32_t *)this, sizeof(Config)/sizeof(uint32_t)); 17 | crc = CRC_GetCRC(); 18 | } 19 | 20 | void Config::loadConfig(Config * loadConfig) 21 | { 22 | memcpy(loadConfig, (void *)CONFIG_ADDRESS, sizeof(Config)); 23 | uint32_t crc = loadConfig->crc; 24 | loadConfig->calculateCRC(); 25 | 26 | // the calculated CRC is invalid 27 | if( crc != loadConfig->crc ) 28 | { 29 | Config init; 30 | memcpy(loadConfig, &init, sizeof(Config)); 31 | } 32 | } 33 | 34 | void Config::saveConfig(Config * saveConfig) 35 | { 36 | uint8_t buf[PAGE_SIZE]; 37 | memset(buf, 0xFF, PAGE_SIZE); 38 | saveConfig->calculateCRC(); 39 | memcpy(buf, saveConfig, sizeof(Config)); 40 | 41 | FLASH_Unlock(); 42 | FLASH_ErasePage( CONFIG_ADDRESS ); 43 | 44 | for(unsigned i=0; i < sizeof(buf); i+=2) 45 | { 46 | uint16_t hword = buf[i]; 47 | hword |= (uint16_t)(buf[i+1]) << 8; 48 | 49 | FLASH_ProgramHalfWord(CONFIG_ADDRESS+i, hword); 50 | } 51 | 52 | FLASH_Lock(); 53 | 54 | } 55 | 56 | void Config::init() 57 | { 58 | RCC_AHBPeriphClockCmd(RCC_AHBENR_CRCEN, ENABLE); 59 | Config::loadConfig(&config); 60 | } 61 | -------------------------------------------------------------------------------- /Oscilloscope/src/GainSetterTask.cpp: -------------------------------------------------------------------------------- 1 | #include "GainSetterTask.h" 2 | #include "AmplifierWidget.h" 3 | 4 | const char * getGainName(AmplifierGain name) 5 | { 6 | switch(name) 7 | { 8 | case GAIN_1X: 9 | return "1X"; 10 | case GAIN_2X: 11 | return "2X"; 12 | case GAIN_4X: 13 | return "4X"; 14 | case GAIN_5X: 15 | return "5X"; 16 | case GAIN_8X: 17 | return "8X"; 18 | case GAIN_10X: 19 | return "10X"; 20 | case GAIN_16X: 21 | return "16X"; 22 | case GAIN_32X: 23 | return "32X"; 24 | default: 25 | return ""; 26 | } 27 | } 28 | 29 | int getGainValue(AmplifierGain name) 30 | { 31 | switch(name) 32 | { 33 | case GAIN_1X: 34 | return 1; 35 | case GAIN_2X: 36 | return 2; 37 | case GAIN_4X: 38 | return 4; 39 | case GAIN_5X: 40 | return 5; 41 | case GAIN_8X: 42 | return 8; 43 | case GAIN_10X: 44 | return 10; 45 | case GAIN_16X: 46 | return 16; 47 | case GAIN_32X: 48 | return 32; 49 | default: 50 | return 1; 51 | } 52 | } 53 | 54 | AmplifierGain currentGain() 55 | { 56 | return config.getCurrentGain(); 57 | } 58 | 59 | AmplifierGain previousGain(AmplifierGain gain) 60 | { 61 | if( gain==GAIN_1X ) 62 | return gain; 63 | return (AmplifierGain)((int)gain - 1); 64 | } 65 | 66 | AmplifierGain nextGain(AmplifierGain gain) 67 | { 68 | if( gain==GAIN_32X ) 69 | return gain; 70 | return (AmplifierGain)((int)gain + 1); 71 | } 72 | 73 | AbstractDriverContext * GainSetterTask::driverContext = 0; 74 | TaskCanvas * GainSetterTask::taskCanvas = 0; 75 | 76 | void GainSetterTask::init(TaskCanvas * canvas, SPIDriver * driver, STM32Pin cspin) 77 | { 78 | taskCanvas = canvas; 79 | driverContext = driver->createSPIContext(cspin, SPI_BaudRatePrescaler_16); 80 | } 81 | 82 | void GainSetterTask::transferCompleteCb(void *arg) 83 | { 84 | GainSetterTask * task = (GainSetterTask *)arg; 85 | task->taskCompleted(); 86 | config.setCurrentGain( task->gainToSet ); 87 | 88 | AmplifierWidget * amplifierWidget = new AmplifierWidget(); 89 | scheduleWidget(taskCanvas, amplifierWidget); 90 | } 91 | 92 | void GainSetterTask::start() 93 | { 94 | command[0] = 0x40; // gain to set 95 | command[1] = (uint8_t)gainToSet; 96 | 97 | driverContext->getDriver()->startDataTransfer(driverContext, 2, command, TT_DATA_8_BIT, GainSetterTask::transferCompleteCb, this); 98 | } 99 | -------------------------------------------------------------------------------- /Oscilloscope/src/InputDeviceHandler.cpp: -------------------------------------------------------------------------------- 1 | #include "InputDeviceHandler.h" 2 | #include "Sampler.h" 3 | #include "pins.h" 4 | #include "systick/SysTime.h" 5 | 6 | #define JOY_PRELL_TIME 30 7 | #define JOY_REPEAT_TIME 500 8 | #define JOY_POLL_MILLIS 10 9 | 10 | #define JOY_CENTER 2048 11 | #define JOY_ON_LIMIT 1024 12 | #define JOY_FIRE_ON_LIMIT 400 13 | #define JOY_HYSTERESIS 200 14 | 15 | #define DOUBLE_FIRE_TIME 500 16 | 17 | InputDeviceHandler inputDeviceHandler; 18 | 19 | void InputDeviceHandler::init(InputDeviceCallback cb) 20 | { 21 | inputDeviceCallback=cb; 22 | 23 | enableRCC(PIN_JOY_FIRE); 24 | pinMode(PIN_JOY_FIRE, GPIO_Mode_IPU); 25 | 26 | } 27 | 28 | InputDeviceEvent InputDeviceHandler::readJoystickState(unsigned time) 29 | { 30 | unsigned evnt = JOY_NONE; 31 | if( ! readPin(PIN_JOY_FIRE) ) 32 | evnt |= JOY_FIRE; 33 | 34 | // read joystick 35 | unsigned joyx, joyy; 36 | if(( time - lastJoyReadStamp > JOY_POLL_MILLIS ) && Sampler::getInstance()->readJoy(&joyx, &joyy) ) 37 | { 38 | unsigned joyOnLimit = ( evnt & JOY_FIRE ) ? JOY_FIRE_ON_LIMIT : JOY_ON_LIMIT; 39 | 40 | unsigned joyxMin = JOY_CENTER - joyOnLimit + ((lastEvent & JOY_LEFT) ? JOY_HYSTERESIS : -JOY_HYSTERESIS); 41 | unsigned joyxMax = JOY_CENTER + joyOnLimit + ((lastEvent & JOY_RIGHT) ? -JOY_HYSTERESIS : JOY_HYSTERESIS); 42 | 43 | if( joyx <= joyxMin ) 44 | evnt |= JOY_RIGHT; 45 | if( joyx >= joyxMax ) 46 | evnt |= JOY_LEFT; 47 | 48 | unsigned joyyMin = JOY_CENTER - joyOnLimit + ((lastEvent & JOY_DOWN) ? JOY_HYSTERESIS : -JOY_HYSTERESIS); 49 | unsigned joyyMax = JOY_CENTER + joyOnLimit + ((lastEvent & JOY_UP) ? -JOY_HYSTERESIS : JOY_HYSTERESIS); 50 | 51 | if( joyy <= joyyMin ) 52 | evnt |= JOY_UP; 53 | if( joyy >= joyyMax ) 54 | evnt |= JOY_DOWN; 55 | 56 | lastJoyReadStamp = time; 57 | } 58 | else 59 | evnt |= (lastEvent & (JOY_UP | JOY_DOWN | JOY_LEFT | JOY_RIGHT)); 60 | 61 | return (InputDeviceEvent)evnt; 62 | } 63 | 64 | void InputDeviceHandler::loop() 65 | { 66 | unsigned time = (unsigned)SysTime::getMillis(); 67 | InputDeviceEvent evnt = readJoystickState(time); 68 | if( evnt != lastEvent ) 69 | { 70 | if( time - lastJoyEventStamp < JOY_PRELL_TIME ) 71 | return; 72 | 73 | if( (evnt != JOY_NONE ) && (evnt != JOY_FIRE ) ) 74 | doubleFireCounter = 0xFFFFFFFF; 75 | 76 | lastEvent = evnt; 77 | lastJoyEventStamp = time; 78 | 79 | if( evnt == JOY_FIRE ) 80 | { 81 | if(( doubleFireCounter != 0xFFFFFFFF ) && ( time - doubleFireCounter < DOUBLE_FIRE_TIME )) 82 | { 83 | evnt = JOY_DOUBLE_FIRE; 84 | doubleFireCounter = 0xFFFFFFFF; 85 | } 86 | else 87 | doubleFireCounter = time; 88 | } 89 | 90 | 91 | 92 | if( inputDeviceCallback ) 93 | inputDeviceCallback(evnt); 94 | } 95 | else 96 | { 97 | if( inputDeviceCallback && ( lastEvent != JOY_NONE ) && 98 | ( time - lastJoyEventStamp >= JOY_REPEAT_TIME )) 99 | { 100 | lastJoyEventStamp = time; 101 | inputDeviceCallback((InputDeviceEvent)(evnt | JOY_REPEAT)); 102 | } 103 | } 104 | 105 | if( usbEvent != USB_COMMAND_NONE ) 106 | { 107 | InputDeviceEvent event = usbEvent; 108 | usbEvent = USB_COMMAND_NONE; 109 | inputDeviceCallback(event); 110 | } 111 | } 112 | 113 | void InputDeviceHandler::noJoystickData() 114 | { 115 | lastEvent = (InputDeviceEvent)(lastEvent & ~( JOY_UP | JOY_RIGHT | JOY_DOWN | JOY_LEFT )); 116 | } 117 | -------------------------------------------------------------------------------- /Oscilloscope/src/MeasurementValueWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "MeasurementValueWidget.h" 2 | #include "graphics/Fonts.h" 3 | #include "Colors.h" 4 | #include "xprintf.h" 5 | #include "Config.h" 6 | #include 7 | 8 | #define INTERNAL_REFERENCE_VOLTAGE 1.21 9 | 10 | MeasurementValueWidget::MeasurementValueWidget(MeasurementData *dataIn) : 11 | data(dataIn) 12 | { 13 | } 14 | 15 | void MeasurementValueWidget::channel(char * buffer, int channel) 16 | { 17 | Value average = data->getAverage(channel); 18 | Value min = data->getMin(channel); 19 | Value max = data->getMax(channel); 20 | Value cus; 21 | 22 | switch( config.getCustomMeter() ) 23 | { 24 | case PowerError: 25 | cus = data->getInternalReferenceError(); 26 | break; 27 | case ChannelError: 28 | cus = data->getChannelError(channel); 29 | break; 30 | case EffectiveValue: 31 | default: 32 | cus = data->getEff(channel); 33 | break; 34 | } 35 | 36 | min.unit = ValueUnit::NONE; 37 | max.unit = ValueUnit::NONE; 38 | cus.unit = ValueUnit::NONE; 39 | 40 | char avbuf[20]; 41 | strcpy( avbuf, valueToString(average) ); 42 | char minbuf[20]; 43 | strcpy( minbuf, valueToString(min) ); 44 | char maxbuf[20]; 45 | strcpy( maxbuf, valueToString(max) ); 46 | char cusbuf[20]; 47 | strcpy( cusbuf, valueToString(cus) ); 48 | 49 | xsprintf(buffer, "%7s [%s,%s]", avbuf, minbuf, maxbuf); 50 | 51 | while(strlen(buffer) < 23) 52 | strcat(buffer," "); 53 | 54 | switch( config.getCustomMeter() ) 55 | { 56 | case EffectiveValue: 57 | xsprintf(buffer+strlen(buffer), "E%5s", cusbuf); 58 | break; 59 | case ChannelError: 60 | xsprintf(buffer+strlen(buffer), " %4s%c", cusbuf, '%'); 61 | break; 62 | case PowerError: 63 | if( channel == 0 ) 64 | { 65 | unsigned refVal = data->getInternalReferenceValue(); 66 | Value refV(0xFFF00 * INTERNAL_REFERENCE_VOLTAGE / refVal, ValueScale::NONE, ValueUnit::VOLTAGE); 67 | strcpy( cusbuf, valueToString(refV) ); 68 | xsprintf(buffer+strlen(buffer), " %5s", cusbuf ); 69 | } 70 | else 71 | xsprintf(buffer+strlen(buffer), " %4s%c", cusbuf, '%'); 72 | break; 73 | default: 74 | break; 75 | } 76 | } 77 | 78 | void MeasurementValueWidget::draw(TaskCanvas * canvas) 79 | { 80 | char buf[40]; 81 | canvas->setFont(font_5x7); 82 | channel(buf, 0); 83 | canvas->drawText(15, 1, buf, OSCILLOSCOPE_COLOR_CHANNEL_1_TEXT, COLOR_BLACK); 84 | 85 | if( config.getNumberOfChannels() < 2 ) 86 | { 87 | memset(buf, ' ', 30); 88 | buf[29] = 0; 89 | } 90 | else 91 | channel(buf, 1); 92 | canvas->drawText(15, 9, buf, OSCILLOSCOPE_COLOR_CHANNEL_2_TEXT, COLOR_BLACK); 93 | } 94 | -------------------------------------------------------------------------------- /Oscilloscope/src/OscilloscopeScreen.cpp: -------------------------------------------------------------------------------- 1 | #include "OscilloscopeScreen.h" 2 | #include "OscilloscopeGrid.h" 3 | #include "graphics/Fonts.h" 4 | #include "task/TaskHandler.h" 5 | #include "MeasurementValueWidget.h" 6 | #include "AmplifierWidget.h" 7 | #include "TriggerWidget.h" 8 | #include "Colors.h" 9 | 10 | #define CHANNEL_HEIGHT 7 11 | #define CHANNEL_WIDTH 14 12 | #define CHANNEL_1_X 0 13 | #define CHANNEL_1_Y 0 14 | #define CHANNEL_2_X 0 15 | #define CHANNEL_2_Y 8 16 | 17 | #define LOGO_X 54 18 | #define LOGO_Y 120 19 | 20 | const uint8_t image_interval_x [] = { 21 | 12, 22 | 4, 23 | 0b01000000, 0b01000000, 24 | 0b11111111, 0b11100000, 25 | 0b01000100, 0b01000000, 26 | 0b00000100, 0b00000000, 27 | 0b00000111, 0b11111000, 28 | }; 29 | 30 | const uint8_t image_interval_y [] = { 31 | 5, 32 | 13, 33 | 0b10000000, 34 | 0b10000000, 35 | 0b10000000, 36 | 0b10010000, 37 | 0b10111000, 38 | 0b10010000, 39 | 0b10010000, 40 | 0b10010000, 41 | 0b11110000, 42 | 0b00010000, 43 | 0b00010000, 44 | 0b00010000, 45 | 0b00111000, 46 | 0b00010000, 47 | }; 48 | 49 | const uint8_t image_min_value [] = { 50 | 5, 51 | 4, 52 | 0b11111000, 53 | 0b00001000, 54 | 0b00001000, 55 | 0b00011100, 56 | 0b00001000, 57 | }; 58 | 59 | const uint8_t image_max_value [] = { 60 | 5, 61 | 4, 62 | 0b00001000, 63 | 0b00011100, 64 | 0b00001000, 65 | 0b00001000, 66 | 0b11111000, 67 | }; 68 | 69 | OscilloscopeScreen::OscilloscopeScreen(MeasurementData *dataIn) : data(dataIn) 70 | { 71 | } 72 | 73 | void OscilloscopeScreen::draw(TaskCanvas * canvas) 74 | { 75 | // clear the screen 76 | canvas->fillScreen(COLOR_BLACK); 77 | 78 | // draw the channels 79 | canvas->setFont(font_5x7); 80 | canvas->fillRect(CHANNEL_1_X, CHANNEL_1_Y, CHANNEL_WIDTH, CHANNEL_HEIGHT, OSCILLOSCOPE_COLOR_CHANNEL_1_TEXT); 81 | canvas->fillRect(CHANNEL_2_X, CHANNEL_2_Y, CHANNEL_WIDTH, CHANNEL_HEIGHT, OSCILLOSCOPE_COLOR_CHANNEL_2_TEXT); 82 | canvas->drawText(CHANNEL_1_X + 1, CHANNEL_1_Y + 1, "Cs1", COLOR_BLACK, OSCILLOSCOPE_COLOR_CHANNEL_1_TEXT); 83 | canvas->drawText(CHANNEL_2_X + 1, CHANNEL_2_Y + 1, "Cs2", COLOR_BLACK, OSCILLOSCOPE_COLOR_CHANNEL_2_TEXT); 84 | 85 | canvas->drawText(LOGO_X, LOGO_Y, " Csabiszkóp ", OSCILLOSCOPE_COLOR_LOGO, OSCILLOSCOPE_COLOR_LOGO_BACKGROUND); 86 | 87 | // draw arrows for oscilloscope grid 88 | canvas->drawImage(GRID_X, GRID_Y + 102, image_interval_x, COLOR_WHITE, COLOR_BLACK); 89 | canvas->drawImage(GRID_X-5, GRID_Y+87, image_interval_y, COLOR_WHITE, COLOR_BLACK); 90 | canvas->drawImage(GRID_X+121, GRID_Y, image_min_value, COLOR_WHITE, COLOR_BLACK); 91 | canvas->drawImage(GRID_X+121, GRID_Y+96, image_max_value, COLOR_WHITE, COLOR_BLACK); 92 | 93 | MeasurementValueWidget * measurementWidget = new MeasurementValueWidget(data); 94 | scheduleWidget(canvas, measurementWidget); 95 | 96 | AmplifierWidget * amplifierWidget = new AmplifierWidget(); 97 | scheduleWidget(canvas, amplifierWidget); 98 | 99 | TriggerWidget * triggerWidget = new TriggerWidget(data); 100 | scheduleWidget(canvas, triggerWidget); 101 | 102 | OscilloscopeGrid *osc = new OscilloscopeGrid(canvas, data, GRID_X, GRID_Y); 103 | TaskHandler::getInstance().scheduleTask(osc); 104 | } 105 | -------------------------------------------------------------------------------- /Oscilloscope/src/USB/stm32_it.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32_it.c 4 | * @author MCD Application Team 5 | * @version V4.0.0 6 | * @date 21-January-2013 7 | * @brief Main Interrupt Service Routines. 8 | * This file provides template for all exceptions handler and peripherals 9 | * interrupt service routine. 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | *

© COPYRIGHT 2013 STMicroelectronics

14 | * 15 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 16 | * You may not use this file except in compliance with the License. 17 | * You may obtain a copy of the License at: 18 | * 19 | * http://www.st.com/software_license_agreement_liberty_v2 20 | * 21 | * Unless required by applicable law or agreed to in writing, software 22 | * distributed under the License is distributed on an "AS IS" BASIS, 23 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24 | * See the License for the specific language governing permissions and 25 | * limitations under the License. 26 | * 27 | ****************************************************************************** 28 | */ 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "hw_config.h" 32 | #include "stm32_it.h" 33 | #include "usb_lib.h" 34 | #include "usb_istr.h" 35 | 36 | /******************************************************************************* 37 | * Function Name : USB_IRQHandler 38 | * Description : This function handles USB Low Priority interrupts 39 | * requests. 40 | * Input : None 41 | * Output : None 42 | * Return : None 43 | *******************************************************************************/ 44 | #if defined(STM32L1XX_MD) || defined(STM32L1XX_HD)|| defined(STM32L1XX_MD_PLUS)|| defined (STM32F37X) 45 | void USB_LP_IRQHandler(void) 46 | #else 47 | void USB_LP_CAN1_RX0_IRQHandler(void) 48 | #endif 49 | { 50 | USB_Istr(); 51 | } 52 | 53 | /******************************************************************************* 54 | * Function Name : USB_FS_WKUP_IRQHandler 55 | * Description : This function handles USB WakeUp interrupt request. 56 | * Input : None 57 | * Output : None 58 | * Return : None 59 | *******************************************************************************/ 60 | 61 | #if defined(STM32L1XX_MD) || defined(STM32L1XX_HD)|| defined(STM32L1XX_MD_PLUS) 62 | void USB_FS_WKUP_IRQHandler(void) 63 | #else 64 | void USBWakeUp_IRQHandler(void) 65 | #endif 66 | { 67 | EXTI_ClearITPendingBit(EXTI_Line18); 68 | } 69 | 70 | /******************************************************************************/ 71 | /* STM32 Peripherals Interrupt Handlers */ 72 | /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ 73 | /* available peripheral interrupt handler's name please refer to the startup */ 74 | /* file (startup_stm32xxx.s). */ 75 | /******************************************************************************/ 76 | 77 | /******************************************************************************* 78 | * Function Name : PPP_IRQHandler 79 | * Description : This function handles PPP interrupt request. 80 | * Input : None 81 | * Output : None 82 | * Return : None 83 | *******************************************************************************/ 84 | /*void PPP_IRQHandler(void) 85 | { 86 | }*/ 87 | 88 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 89 | 90 | -------------------------------------------------------------------------------- /Oscilloscope/src/USB/usb_endp.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_endp.c 4 | * @author MCD Application Team 5 | * @version V4.0.0 6 | * @date 21-January-2013 7 | * @brief Endpoint routines 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2013 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "usb_lib.h" 31 | #include "usb_desc.h" 32 | #include "usb_mem.h" 33 | #include "hw_config.h" 34 | #include "usb_istr.h" 35 | #include "usb_pwr.h" 36 | 37 | /* Private typedef -----------------------------------------------------------*/ 38 | /* Private define ------------------------------------------------------------*/ 39 | 40 | /* Private macro -------------------------------------------------------------*/ 41 | /* Private variables ---------------------------------------------------------*/ 42 | 43 | /******************************************************************************* 44 | * Function Name : EP1_IN_Callback 45 | * Description : 46 | * Input : None. 47 | * Output : None. 48 | * Return : None. 49 | *******************************************************************************/ 50 | 51 | /*void EP1_IN_Callback (void) 52 | { 53 | }*/ 54 | 55 | /******************************************************************************* 56 | * Function Name : EP3_OUT_Callback 57 | * Description : 58 | * Input : None. 59 | * Output : None. 60 | * Return : None. 61 | *******************************************************************************/ 62 | void EP3_OUT_Callback(void) 63 | { 64 | unsigned receive_length = GetEPRxCount(ENDP3); 65 | char buffer[VIRTUAL_COM_PORT_DATA_SIZE+1]; 66 | PMAToUserBufferCopy((unsigned char*)buffer, ENDP3_RXADDR, receive_length); 67 | 68 | #ifdef DATA_RECEIVED_CALLBACK 69 | DATA_RECEIVED_Callback(buffer, receive_length); 70 | #endif 71 | 72 | CDC_Receive_DATA(); 73 | } 74 | 75 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 76 | -------------------------------------------------------------------------------- /Oscilloscope/src/_write.c: -------------------------------------------------------------------------------- 1 | // 2 | // This file is part of the µOS++ III distribution. 3 | // Copyright (c) 2014 Liviu Ionescu. 4 | // 5 | 6 | // Do not include on semihosting and when freestanding 7 | #if !defined(OS_USE_SEMIHOSTING) && !(__STDC_HOSTED__ == 0) 8 | 9 | // ---------------------------------------------------------------------------- 10 | 11 | #include 12 | #include "diag/Trace.h" 13 | 14 | // ---------------------------------------------------------------------------- 15 | 16 | // When using retargetted configurations, the standard write() system call, 17 | // after a long way inside newlib, finally calls this implementation function. 18 | 19 | // Based on the file descriptor, it can send arrays of characters to 20 | // different physical devices. 21 | 22 | // Currently only the output and error file descriptors are tested, 23 | // and the characters are forwarded to the trace device, mainly 24 | // for demonstration purposes. Adjust it for your specific needs. 25 | 26 | // For freestanding applications this file is not used and can be safely 27 | // ignored. 28 | 29 | ssize_t 30 | _write (int fd, const char* buf, size_t nbyte); 31 | 32 | ssize_t 33 | _write (int fd __attribute__((unused)), const char* buf __attribute__((unused)), 34 | size_t nbyte __attribute__((unused))) 35 | { 36 | #if defined(TRACE) 37 | // STDOUT and STDERR are routed to the trace device 38 | if (fd == 1 || fd == 2) 39 | { 40 | return trace_write (buf, nbyte); 41 | } 42 | #endif // TRACE 43 | 44 | errno = ENOSYS; 45 | return -1; 46 | } 47 | 48 | // ---------------------------------------------------------------------------- 49 | 50 | #endif // !defined(OS_USE_SEMIHOSTING) && !(__STDC_HOSTED__ == 0) 51 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/arm/semihosting.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file is part of the µOS++ III distribution. 3 | // Copyright (c) 2014 Liviu Ionescu. 4 | // 5 | 6 | #ifndef ARM_SEMIHOSTING_H_ 7 | #define ARM_SEMIHOSTING_H_ 8 | 9 | // ---------------------------------------------------------------------------- 10 | 11 | // Semihosting operations. 12 | enum OperationNumber 13 | { 14 | // Regular operations 15 | SEMIHOSTING_EnterSVC = 0x17, 16 | SEMIHOSTING_ReportException = 0x18, 17 | SEMIHOSTING_SYS_CLOSE = 0x02, 18 | SEMIHOSTING_SYS_CLOCK = 0x10, 19 | SEMIHOSTING_SYS_ELAPSED = 0x30, 20 | SEMIHOSTING_SYS_ERRNO = 0x13, 21 | SEMIHOSTING_SYS_FLEN = 0x0C, 22 | SEMIHOSTING_SYS_GET_CMDLINE = 0x15, 23 | SEMIHOSTING_SYS_HEAPINFO = 0x16, 24 | SEMIHOSTING_SYS_ISERROR = 0x08, 25 | SEMIHOSTING_SYS_ISTTY = 0x09, 26 | SEMIHOSTING_SYS_OPEN = 0x01, 27 | SEMIHOSTING_SYS_READ = 0x06, 28 | SEMIHOSTING_SYS_READC = 0x07, 29 | SEMIHOSTING_SYS_REMOVE = 0x0E, 30 | SEMIHOSTING_SYS_RENAME = 0x0F, 31 | SEMIHOSTING_SYS_SEEK = 0x0A, 32 | SEMIHOSTING_SYS_SYSTEM = 0x12, 33 | SEMIHOSTING_SYS_TICKFREQ = 0x31, 34 | SEMIHOSTING_SYS_TIME = 0x11, 35 | SEMIHOSTING_SYS_TMPNAM = 0x0D, 36 | SEMIHOSTING_SYS_WRITE = 0x05, 37 | SEMIHOSTING_SYS_WRITEC = 0x03, 38 | SEMIHOSTING_SYS_WRITE0 = 0x04, 39 | 40 | // Codes returned by SEMIHOSTING_ReportException 41 | ADP_Stopped_ApplicationExit = ((2 << 16) + 38), 42 | ADP_Stopped_RunTimeError = ((2 << 16) + 35), 43 | 44 | }; 45 | 46 | // ---------------------------------------------------------------------------- 47 | 48 | // SWI numbers and reason codes for RDI (Angel) monitors. 49 | #define AngelSWI_ARM 0x123456 50 | #ifdef __thumb__ 51 | #define AngelSWI 0xAB 52 | #else 53 | #define AngelSWI AngelSWI_ARM 54 | #endif 55 | // For thumb only architectures use the BKPT instruction instead of SWI. 56 | #if defined(__ARM_ARCH_7M__) \ 57 | || defined(__ARM_ARCH_7EM__) \ 58 | || defined(__ARM_ARCH_6M__) 59 | #define AngelSWIInsn "bkpt" 60 | #define AngelSWIAsm bkpt 61 | #else 62 | #define AngelSWIInsn "swi" 63 | #define AngelSWIAsm swi 64 | #endif 65 | 66 | #if defined(OS_DEBUG_SEMIHOSTING_FAULTS) 67 | // Testing the local semihosting handler cannot use another BKPT, since this 68 | // configuration cannot trigger HaedFault exceptions while the debugger is 69 | // connected, so we use an illegal op code, that will trigger an 70 | // UsageFault exception. 71 | #define AngelSWITestFault "setend be" 72 | #define AngelSWITestFaultOpCode (0xB658) 73 | #endif 74 | 75 | static inline int 76 | __attribute__ ((always_inline)) 77 | call_host (int reason, void* arg) 78 | { 79 | int value; 80 | asm volatile ( 81 | 82 | " mov r0, %[rsn] \n" 83 | " mov r1, %[arg] \n" 84 | #if defined(OS_DEBUG_SEMIHOSTING_FAULTS) 85 | " " AngelSWITestFault " \n" 86 | #else 87 | " " AngelSWIInsn " %[swi] \n" 88 | #endif 89 | " mov %[val], r0" 90 | 91 | : [val] "=r" (value) /* Outputs */ 92 | : [rsn] "r" (reason), [arg] "r" (arg), [swi] "i" (AngelSWI) /* Inputs */ 93 | : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" 94 | // Clobbers r0 and r1, and lr if in supervisor mode 95 | ); 96 | 97 | // Accordingly to page 13-77 of ARM DUI 0040D other registers 98 | // can also be clobbered. Some memory positions may also be 99 | // changed by a system call, so they should not be kept in 100 | // registers. Note: we are assuming the manual is right and 101 | // Angel is respecting the APCS. 102 | return value; 103 | } 104 | 105 | // ---------------------------------------------------------------------------- 106 | 107 | // Function used in _exit() to return the status code as Angel exception. 108 | static inline void 109 | __attribute__ ((always_inline,noreturn)) 110 | report_exception (int reason) 111 | { 112 | call_host (SEMIHOSTING_ReportException, (void*) reason); 113 | 114 | for (;;) 115 | ; 116 | } 117 | 118 | // ---------------------------------------------------------------------------- 119 | 120 | #endif // ARM_SEMIHOSTING_H_ 121 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/cmsis/README_DEVICE.txt: -------------------------------------------------------------------------------- 1 | The stm32f10x.h and system_stm32f10x.h files are from stsw-stm32054.zip, 2 | the folder: 3 | 4 | STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x 5 | 6 | The cmsis_device.h is added for convenience. 7 | 8 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/cmsis/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 58 | 59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 68 | 69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/cmsis/cmsis_device.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file is part of the µOS++ III distribution. 3 | // Copyright (c) 2014 Liviu Ionescu. 4 | // 5 | 6 | #ifndef STM32F1_CMSIS_DEVICE_H_ 7 | #define STM32F1_CMSIS_DEVICE_H_ 8 | 9 | #include "stm32f10x.h" 10 | 11 | #endif // STM32F1_CMSIS_DEVICE_H_ 12 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/cmsis/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | 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 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/cmsis/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | 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 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/cmsis/core_cmSimd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmSimd.h 3 | * @brief CMSIS Cortex-M SIMD Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | 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 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMSIMD_H 42 | #define __CORE_CMSIMD_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | 49 | /* ################### Compiler specific Intrinsics ########################### */ 50 | /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics 51 | Access to dedicated SIMD instructions 52 | @{ 53 | */ 54 | 55 | /*------------------ RealView Compiler -----------------*/ 56 | #if defined ( __CC_ARM ) 57 | #include "cmsis_armcc.h" 58 | 59 | /*------------------ ARM Compiler V6 -------------------*/ 60 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 61 | #include "cmsis_armcc_V6.h" 62 | 63 | /*------------------ GNU Compiler ----------------------*/ 64 | #elif defined ( __GNUC__ ) 65 | #include "cmsis_gcc.h" 66 | 67 | /*------------------ ICC Compiler ----------------------*/ 68 | #elif defined ( __ICCARM__ ) 69 | #include 70 | 71 | /*------------------ TI CCS Compiler -------------------*/ 72 | #elif defined ( __TMS470__ ) 73 | #include 74 | 75 | /*------------------ TASKING Compiler ------------------*/ 76 | #elif defined ( __TASKING__ ) 77 | /* 78 | * The CMSIS functions have been implemented as intrinsics in the compiler. 79 | * Please use "carm -?i" to get an up to date list of all intrinsics, 80 | * Including the CMSIS ones. 81 | */ 82 | 83 | /*------------------ COSMIC Compiler -------------------*/ 84 | #elif defined ( __CSMC__ ) 85 | #include 86 | 87 | #endif 88 | 89 | /*@} end of group CMSIS_SIMD_intrinsics */ 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __CORE_CMSIMD_H */ 97 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/cmsis/system_stm32f10x.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f10x.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /** @addtogroup CMSIS 23 | * @{ 24 | */ 25 | 26 | /** @addtogroup stm32f10x_system 27 | * @{ 28 | */ 29 | 30 | /** 31 | * @brief Define to prevent recursive inclusion 32 | */ 33 | #ifndef __SYSTEM_STM32F10X_H 34 | #define __SYSTEM_STM32F10X_H 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** @addtogroup STM32F10x_System_Includes 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @addtogroup STM32F10x_System_Exported_types 50 | * @{ 51 | */ 52 | 53 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @addtogroup STM32F10x_System_Exported_Constants 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32F10x_System_Exported_Macros 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32F10x_System_Exported_Functions 76 | * @{ 77 | */ 78 | 79 | extern void SystemInit(void); 80 | extern void SystemCoreClockUpdate(void); 81 | /** 82 | * @} 83 | */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /*__SYSTEM_STM32F10X_H */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 99 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/cortexm/ExceptionHandlers.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file is part of the µOS++ III distribution. 3 | // Copyright (c) 2014 Liviu Ionescu. 4 | // 5 | 6 | #ifndef CORTEXM_EXCEPTION_HANDLERS_H_ 7 | #define CORTEXM_EXCEPTION_HANDLERS_H_ 8 | 9 | #include 10 | 11 | #if defined(DEBUG) 12 | #define __DEBUG_BKPT() asm volatile ("bkpt 0") 13 | #endif 14 | 15 | // ---------------------------------------------------------------------------- 16 | 17 | #if defined(__cplusplus) 18 | extern "C" 19 | { 20 | #endif 21 | 22 | // External references to cortexm_handlers.c 23 | 24 | extern void 25 | Reset_Handler (void); 26 | extern void 27 | NMI_Handler (void); 28 | extern void 29 | HardFault_Handler (void); 30 | 31 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) 32 | extern void 33 | MemManage_Handler (void); 34 | extern void 35 | BusFault_Handler (void); 36 | extern void 37 | UsageFault_Handler (void); 38 | extern void 39 | DebugMon_Handler (void); 40 | #endif 41 | 42 | extern void 43 | SVC_Handler (void); 44 | 45 | extern void 46 | PendSV_Handler (void); 47 | extern void 48 | SysTick_Handler (void); 49 | 50 | // Exception Stack Frame of the Cortex-M3 or Cortex-M4 processor. 51 | typedef struct 52 | { 53 | uint32_t r0; 54 | uint32_t r1; 55 | uint32_t r2; 56 | uint32_t r3; 57 | uint32_t r12; 58 | uint32_t lr; 59 | uint32_t pc; 60 | uint32_t psr; 61 | #if defined(__ARM_ARCH_7EM__) 62 | uint32_t s[16]; 63 | #endif 64 | } ExceptionStackFrame; 65 | 66 | #if defined(TRACE) 67 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) 68 | void 69 | dumpExceptionStack (ExceptionStackFrame* frame, uint32_t cfsr, uint32_t mmfar, 70 | uint32_t bfar, uint32_t lr); 71 | #endif // defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) 72 | #if defined(__ARM_ARCH_6M__) 73 | void 74 | dumpExceptionStack (ExceptionStackFrame* frame, uint32_t lr); 75 | #endif // defined(__ARM_ARCH_6M__) 76 | #endif // defined(TRACE) 77 | 78 | void 79 | HardFault_Handler_C (ExceptionStackFrame* frame, uint32_t lr); 80 | 81 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) 82 | void 83 | UsageFault_Handler_C (ExceptionStackFrame* frame, uint32_t lr); 84 | void 85 | BusFault_Handler_C (ExceptionStackFrame* frame, uint32_t lr); 86 | #endif // defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) 87 | 88 | #if defined(__cplusplus) 89 | } 90 | #endif 91 | 92 | // ---------------------------------------------------------------------------- 93 | 94 | #endif // CORTEXM_EXCEPTION_HANDLERS_H_ 95 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/diag/Trace.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file is part of the µOS++ III distribution. 3 | // Copyright (c) 2014 Liviu Ionescu. 4 | // 5 | 6 | #ifndef DIAG_TRACE_H_ 7 | #define DIAG_TRACE_H_ 8 | 9 | // ---------------------------------------------------------------------------- 10 | 11 | #include 12 | 13 | // ---------------------------------------------------------------------------- 14 | 15 | // The trace device is an independent output channel, intended for debug 16 | // purposes. 17 | // 18 | // The API is simple, and mimics the standard output calls: 19 | // - trace_printf() 20 | // - trace_puts() 21 | // - trace_putchar(); 22 | // 23 | // The implementation is done in 24 | // - trace_write() 25 | // 26 | // Trace support is enabled by adding the TRACE definition. 27 | // By default the trace messages are forwarded to the ITM output, 28 | // but can be rerouted via any device or completely suppressed by 29 | // changing the definitions required in system/src/diag/trace_impl.c 30 | // (currently OS_USE_TRACE_ITM, OS_USE_TRACE_SEMIHOSTING_DEBUG/_STDOUT). 31 | // 32 | // When TRACE is not defined, all functions are inlined to empty bodies. 33 | // This has the advantage that the trace call do not need to be conditionally 34 | // compiled with #ifdef TRACE/#endif 35 | 36 | 37 | #if defined(TRACE) 38 | 39 | #if defined(__cplusplus) 40 | extern "C" 41 | { 42 | #endif 43 | 44 | void 45 | trace_initialize(void); 46 | 47 | // Implementation dependent 48 | ssize_t 49 | trace_write(const char* buf, size_t nbyte); 50 | 51 | // ----- Portable ----- 52 | 53 | int 54 | trace_printf(const char* format, ...); 55 | 56 | int 57 | trace_puts(const char *s); 58 | 59 | int 60 | trace_putchar(int c); 61 | 62 | void 63 | trace_dump_args(int argc, char* argv[]); 64 | 65 | #if defined(__cplusplus) 66 | } 67 | #endif 68 | 69 | #else // !defined(TRACE) 70 | 71 | #if defined(__cplusplus) 72 | extern "C" 73 | { 74 | #endif 75 | 76 | inline void 77 | trace_initialize(void); 78 | 79 | // Implementation dependent 80 | inline ssize_t 81 | trace_write(const char* buf, size_t nbyte); 82 | 83 | inline int 84 | trace_printf(const char* format, ...); 85 | 86 | inline int 87 | trace_puts(const char *s); 88 | 89 | inline int 90 | trace_putchar(int c); 91 | 92 | inline void 93 | trace_dump_args(int argc, char* argv[]); 94 | 95 | #if defined(__cplusplus) 96 | } 97 | #endif 98 | 99 | inline void 100 | __attribute__((always_inline)) 101 | trace_initialize(void) 102 | { 103 | } 104 | 105 | // Empty definitions when trace is not defined 106 | inline ssize_t 107 | __attribute__((always_inline)) 108 | trace_write(const char* buf __attribute__((unused)), 109 | size_t nbyte __attribute__((unused))) 110 | { 111 | return 0; 112 | } 113 | 114 | inline int 115 | __attribute__((always_inline)) 116 | trace_printf(const char* format __attribute__((unused)), ...) 117 | { 118 | return 0; 119 | } 120 | 121 | inline int 122 | __attribute__((always_inline)) 123 | trace_puts(const char *s __attribute__((unused))) 124 | { 125 | return 0; 126 | } 127 | 128 | inline int 129 | __attribute__((always_inline)) 130 | trace_putchar(int c) 131 | { 132 | return c; 133 | } 134 | 135 | inline void 136 | __attribute__((always_inline)) 137 | trace_dump_args(int argc __attribute__((unused)), 138 | char* argv[] __attribute__((unused))) 139 | { 140 | } 141 | 142 | #endif // defined(TRACE) 143 | 144 | // ---------------------------------------------------------------------------- 145 | 146 | #endif // DIAG_TRACE_H_ 147 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/stm32f1-stdperiph/README_STDPERIPH.txt: -------------------------------------------------------------------------------- 1 | These files are from stsw-stm32054.zip, the folder: 2 | 3 | STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc 4 | 5 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/stm32f1-stdperiph/stm32f10x_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_crc.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_CRC_H 25 | #define __STM32F10x_CRC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup CRC 39 | * @{ 40 | */ 41 | 42 | /** @defgroup CRC_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup CRC_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /** @defgroup CRC_Exported_Macros 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup CRC_Exported_Functions 67 | * @{ 68 | */ 69 | 70 | void CRC_ResetDR(void); 71 | uint32_t CRC_CalcCRC(uint32_t Data); 72 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 73 | uint32_t CRC_GetCRC(void); 74 | void CRC_SetIDRegister(uint8_t IDValue); 75 | uint8_t CRC_GetIDRegister(void); 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* __STM32F10x_CRC_H */ 82 | /** 83 | * @} 84 | */ 85 | 86 | /** 87 | * @} 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 95 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/stm32f1-stdperiph/stm32f10x_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_dbgmcu.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the DBGMCU 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_DBGMCU_H 25 | #define __STM32F10x_DBGMCU_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup DBGMCU 39 | * @{ 40 | */ 41 | 42 | /** @defgroup DBGMCU_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup DBGMCU_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | #define DBGMCU_SLEEP ((uint32_t)0x00000001) 55 | #define DBGMCU_STOP ((uint32_t)0x00000002) 56 | #define DBGMCU_STANDBY ((uint32_t)0x00000004) 57 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00000100) 58 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000200) 59 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00000400) 60 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00000800) 61 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00001000) 62 | #define DBGMCU_TIM4_STOP ((uint32_t)0x00002000) 63 | #define DBGMCU_CAN1_STOP ((uint32_t)0x00004000) 64 | #define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00008000) 65 | #define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00010000) 66 | #define DBGMCU_TIM8_STOP ((uint32_t)0x00020000) 67 | #define DBGMCU_TIM5_STOP ((uint32_t)0x00040000) 68 | #define DBGMCU_TIM6_STOP ((uint32_t)0x00080000) 69 | #define DBGMCU_TIM7_STOP ((uint32_t)0x00100000) 70 | #define DBGMCU_CAN2_STOP ((uint32_t)0x00200000) 71 | #define DBGMCU_TIM15_STOP ((uint32_t)0x00400000) 72 | #define DBGMCU_TIM16_STOP ((uint32_t)0x00800000) 73 | #define DBGMCU_TIM17_STOP ((uint32_t)0x01000000) 74 | #define DBGMCU_TIM12_STOP ((uint32_t)0x02000000) 75 | #define DBGMCU_TIM13_STOP ((uint32_t)0x04000000) 76 | #define DBGMCU_TIM14_STOP ((uint32_t)0x08000000) 77 | #define DBGMCU_TIM9_STOP ((uint32_t)0x10000000) 78 | #define DBGMCU_TIM10_STOP ((uint32_t)0x20000000) 79 | #define DBGMCU_TIM11_STOP ((uint32_t)0x40000000) 80 | 81 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0x800000F8) == 0x00) && ((PERIPH) != 0x00)) 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup DBGMCU_Exported_Macros 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @defgroup DBGMCU_Exported_Functions 95 | * @{ 96 | */ 97 | 98 | uint32_t DBGMCU_GetREVID(void); 99 | uint32_t DBGMCU_GetDEVID(void); 100 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif /* __STM32F10x_DBGMCU_H */ 107 | /** 108 | * @} 109 | */ 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 120 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/stm32f1-stdperiph/stm32f10x_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_iwdg.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the IWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_IWDG_H 25 | #define __STM32F10x_IWDG_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup IWDG 39 | * @{ 40 | */ 41 | 42 | /** @defgroup IWDG_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup IWDG_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup IWDG_WriteAccess 55 | * @{ 56 | */ 57 | 58 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555) 59 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000) 60 | #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \ 61 | ((ACCESS) == IWDG_WriteAccess_Disable)) 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup IWDG_prescaler 67 | * @{ 68 | */ 69 | 70 | #define IWDG_Prescaler_4 ((uint8_t)0x00) 71 | #define IWDG_Prescaler_8 ((uint8_t)0x01) 72 | #define IWDG_Prescaler_16 ((uint8_t)0x02) 73 | #define IWDG_Prescaler_32 ((uint8_t)0x03) 74 | #define IWDG_Prescaler_64 ((uint8_t)0x04) 75 | #define IWDG_Prescaler_128 ((uint8_t)0x05) 76 | #define IWDG_Prescaler_256 ((uint8_t)0x06) 77 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \ 78 | ((PRESCALER) == IWDG_Prescaler_8) || \ 79 | ((PRESCALER) == IWDG_Prescaler_16) || \ 80 | ((PRESCALER) == IWDG_Prescaler_32) || \ 81 | ((PRESCALER) == IWDG_Prescaler_64) || \ 82 | ((PRESCALER) == IWDG_Prescaler_128)|| \ 83 | ((PRESCALER) == IWDG_Prescaler_256)) 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup IWDG_Flag 89 | * @{ 90 | */ 91 | 92 | #define IWDG_FLAG_PVU ((uint16_t)0x0001) 93 | #define IWDG_FLAG_RVU ((uint16_t)0x0002) 94 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU)) 95 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /** @defgroup IWDG_Exported_Macros 105 | * @{ 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** @defgroup IWDG_Exported_Functions 113 | * @{ 114 | */ 115 | 116 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess); 117 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler); 118 | void IWDG_SetReload(uint16_t Reload); 119 | void IWDG_ReloadCounter(void); 120 | void IWDG_Enable(void); 121 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG); 122 | 123 | #ifdef __cplusplus 124 | } 125 | #endif 126 | 127 | #endif /* __STM32F10x_IWDG_H */ 128 | /** 129 | * @} 130 | */ 131 | 132 | /** 133 | * @} 134 | */ 135 | 136 | /** 137 | * @} 138 | */ 139 | 140 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 141 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/stm32f1-stdperiph/stm32f10x_pwr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_pwr.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the PWR firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_PWR_H 25 | #define __STM32F10x_PWR_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup PWR 39 | * @{ 40 | */ 41 | 42 | /** @defgroup PWR_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup PWR_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup PVD_detection_level 55 | * @{ 56 | */ 57 | 58 | #define PWR_PVDLevel_2V2 ((uint32_t)0x00000000) 59 | #define PWR_PVDLevel_2V3 ((uint32_t)0x00000020) 60 | #define PWR_PVDLevel_2V4 ((uint32_t)0x00000040) 61 | #define PWR_PVDLevel_2V5 ((uint32_t)0x00000060) 62 | #define PWR_PVDLevel_2V6 ((uint32_t)0x00000080) 63 | #define PWR_PVDLevel_2V7 ((uint32_t)0x000000A0) 64 | #define PWR_PVDLevel_2V8 ((uint32_t)0x000000C0) 65 | #define PWR_PVDLevel_2V9 ((uint32_t)0x000000E0) 66 | #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_2V2) || ((LEVEL) == PWR_PVDLevel_2V3)|| \ 67 | ((LEVEL) == PWR_PVDLevel_2V4) || ((LEVEL) == PWR_PVDLevel_2V5)|| \ 68 | ((LEVEL) == PWR_PVDLevel_2V6) || ((LEVEL) == PWR_PVDLevel_2V7)|| \ 69 | ((LEVEL) == PWR_PVDLevel_2V8) || ((LEVEL) == PWR_PVDLevel_2V9)) 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup Regulator_state_is_STOP_mode 75 | * @{ 76 | */ 77 | 78 | #define PWR_Regulator_ON ((uint32_t)0x00000000) 79 | #define PWR_Regulator_LowPower ((uint32_t)0x00000001) 80 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \ 81 | ((REGULATOR) == PWR_Regulator_LowPower)) 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup STOP_mode_entry 87 | * @{ 88 | */ 89 | 90 | #define PWR_STOPEntry_WFI ((uint8_t)0x01) 91 | #define PWR_STOPEntry_WFE ((uint8_t)0x02) 92 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE)) 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /** @defgroup PWR_Flag 99 | * @{ 100 | */ 101 | 102 | #define PWR_FLAG_WU ((uint32_t)0x00000001) 103 | #define PWR_FLAG_SB ((uint32_t)0x00000002) 104 | #define PWR_FLAG_PVDO ((uint32_t)0x00000004) 105 | #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \ 106 | ((FLAG) == PWR_FLAG_PVDO)) 107 | 108 | #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB)) 109 | /** 110 | * @} 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** @defgroup PWR_Exported_Macros 118 | * @{ 119 | */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** @defgroup PWR_Exported_Functions 126 | * @{ 127 | */ 128 | 129 | void PWR_DeInit(void); 130 | void PWR_BackupAccessCmd(FunctionalState NewState); 131 | void PWR_PVDCmd(FunctionalState NewState); 132 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel); 133 | void PWR_WakeUpPinCmd(FunctionalState NewState); 134 | void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry); 135 | void PWR_EnterSTANDBYMode(void); 136 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG); 137 | void PWR_ClearFlag(uint32_t PWR_FLAG); 138 | 139 | #ifdef __cplusplus 140 | } 141 | #endif 142 | 143 | #endif /* __STM32F10x_PWR_H */ 144 | /** 145 | * @} 146 | */ 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /** 153 | * @} 154 | */ 155 | 156 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 157 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/stm32f1-stdperiph/stm32f10x_rtc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_rtc.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the RTC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_RTC_H 25 | #define __STM32F10x_RTC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup RTC 39 | * @{ 40 | */ 41 | 42 | /** @defgroup RTC_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup RTC_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup RTC_interrupts_define 55 | * @{ 56 | */ 57 | 58 | #define RTC_IT_OW ((uint16_t)0x0004) /*!< Overflow interrupt */ 59 | #define RTC_IT_ALR ((uint16_t)0x0002) /*!< Alarm interrupt */ 60 | #define RTC_IT_SEC ((uint16_t)0x0001) /*!< Second interrupt */ 61 | #define IS_RTC_IT(IT) ((((IT) & (uint16_t)0xFFF8) == 0x00) && ((IT) != 0x00)) 62 | #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_OW) || ((IT) == RTC_IT_ALR) || \ 63 | ((IT) == RTC_IT_SEC)) 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup RTC_interrupts_flags 69 | * @{ 70 | */ 71 | 72 | #define RTC_FLAG_RTOFF ((uint16_t)0x0020) /*!< RTC Operation OFF flag */ 73 | #define RTC_FLAG_RSF ((uint16_t)0x0008) /*!< Registers Synchronized flag */ 74 | #define RTC_FLAG_OW ((uint16_t)0x0004) /*!< Overflow flag */ 75 | #define RTC_FLAG_ALR ((uint16_t)0x0002) /*!< Alarm flag */ 76 | #define RTC_FLAG_SEC ((uint16_t)0x0001) /*!< Second flag */ 77 | #define IS_RTC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFFF0) == 0x00) && ((FLAG) != 0x00)) 78 | #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_RTOFF) || ((FLAG) == RTC_FLAG_RSF) || \ 79 | ((FLAG) == RTC_FLAG_OW) || ((FLAG) == RTC_FLAG_ALR) || \ 80 | ((FLAG) == RTC_FLAG_SEC)) 81 | #define IS_RTC_PRESCALER(PRESCALER) ((PRESCALER) <= 0xFFFFF) 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @defgroup RTC_Exported_Macros 92 | * @{ 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** @defgroup RTC_Exported_Functions 100 | * @{ 101 | */ 102 | 103 | void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState); 104 | void RTC_EnterConfigMode(void); 105 | void RTC_ExitConfigMode(void); 106 | uint32_t RTC_GetCounter(void); 107 | void RTC_SetCounter(uint32_t CounterValue); 108 | void RTC_SetPrescaler(uint32_t PrescalerValue); 109 | void RTC_SetAlarm(uint32_t AlarmValue); 110 | uint32_t RTC_GetDivider(void); 111 | void RTC_WaitForLastTask(void); 112 | void RTC_WaitForSynchro(void); 113 | FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG); 114 | void RTC_ClearFlag(uint16_t RTC_FLAG); 115 | ITStatus RTC_GetITStatus(uint16_t RTC_IT); 116 | void RTC_ClearITPendingBit(uint16_t RTC_IT); 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif /* __STM32F10x_RTC_H */ 123 | /** 124 | * @} 125 | */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 136 | -------------------------------------------------------------------------------- /Oscilloscope/system/include/stm32f1-stdperiph/stm32f10x_wwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_wwdg.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the WWDG firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_WWDG_H 25 | #define __STM32F10x_WWDG_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup WWDG 39 | * @{ 40 | */ 41 | 42 | /** @defgroup WWDG_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup WWDG_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup WWDG_Prescaler 55 | * @{ 56 | */ 57 | 58 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 59 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 60 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 61 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 62 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \ 63 | ((PRESCALER) == WWDG_Prescaler_2) || \ 64 | ((PRESCALER) == WWDG_Prescaler_4) || \ 65 | ((PRESCALER) == WWDG_Prescaler_8)) 66 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F) 67 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F)) 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /** @defgroup WWDG_Exported_Macros 78 | * @{ 79 | */ 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup WWDG_Exported_Functions 85 | * @{ 86 | */ 87 | 88 | void WWDG_DeInit(void); 89 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 90 | void WWDG_SetWindowValue(uint8_t WindowValue); 91 | void WWDG_EnableIT(void); 92 | void WWDG_SetCounter(uint8_t Counter); 93 | void WWDG_Enable(uint8_t Counter); 94 | FlagStatus WWDG_GetFlagStatus(void); 95 | void WWDG_ClearFlag(void); 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* __STM32F10x_WWDG_H */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 116 | -------------------------------------------------------------------------------- /Oscilloscope/system/src/cmsis/README_DEVICE.txt: -------------------------------------------------------------------------------- 1 | The system_stm32f10x.c file is from stsw-stm32054.zip, the folder: 2 | 3 | STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x 4 | 5 | The vectors_stm32f10x.c was created to conform to the startup_stm32f10x_xx*.s. -------------------------------------------------------------------------------- /Oscilloscope/system/src/cortexm/_initialize_hardware.c: -------------------------------------------------------------------------------- 1 | // 2 | // This file is part of the µOS++ III distribution. 3 | // Copyright (c) 2014 Liviu Ionescu. 4 | // 5 | 6 | // ---------------------------------------------------------------------------- 7 | 8 | #include "cmsis_device.h" 9 | 10 | // ---------------------------------------------------------------------------- 11 | 12 | extern unsigned int __vectors_start; 13 | 14 | // Forward declarations. 15 | 16 | void 17 | __initialize_hardware_early(void); 18 | 19 | void 20 | __initialize_hardware(void); 21 | 22 | // ---------------------------------------------------------------------------- 23 | 24 | // This is the early hardware initialisation routine, it can be 25 | // redefined in the application for more complex cases that 26 | // require early inits (before BSS init). 27 | // 28 | // Called early from _start(), right before data & bss init. 29 | // 30 | // After Reset the Cortex-M processor is in Thread mode, 31 | // priority is Privileged, and the Stack is set to Main. 32 | 33 | void 34 | __attribute__((weak)) 35 | __initialize_hardware_early(void) 36 | { 37 | // Call the CSMSIS system initialisation routine. 38 | SystemInit(); 39 | 40 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) 41 | // Set VTOR to the actual address, provided by the linker script. 42 | // Override the manual, possibly wrong, SystemInit() setting. 43 | SCB->VTOR = (uint32_t)(&__vectors_start); 44 | #endif 45 | 46 | // The current version of SystemInit() leaves the value of the clock 47 | // in a RAM variable (SystemCoreClock), which will be cleared shortly, 48 | // so it needs to be recomputed after the RAM initialisations 49 | // are completed. 50 | 51 | #if defined(OS_INCLUDE_STARTUP_INIT_FP) || (defined (__VFP_FP__) && !defined (__SOFTFP__)) 52 | 53 | // Normally FP init is done by SystemInit(). In case this is not done 54 | // there, it is possible to force its inclusion by defining 55 | // OS_INCLUDE_STARTUP_INIT_FP. 56 | 57 | // Enable the Cortex-M4 FPU only when -mfloat-abi=hard. 58 | // Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C) 59 | 60 | // Set bits 20-23 to enable CP10 and CP11 coprocessor 61 | SCB->CPACR |= (0xF << 20); 62 | 63 | #endif // (__VFP_FP__) && !(__SOFTFP__) 64 | 65 | #if defined(OS_DEBUG_SEMIHOSTING_FAULTS) 66 | SCB->SHCSR |= SCB_SHCSR_USGFAULTENA_Msk; 67 | #endif 68 | } 69 | 70 | // This is the second hardware initialisation routine, it can be 71 | // redefined in the application for more complex cases that 72 | // require custom inits (before constructors), otherwise these can 73 | // be done in main(). 74 | // 75 | // Called from _start(), right after data & bss init, before 76 | // constructors. 77 | 78 | void 79 | __attribute__((weak)) 80 | __initialize_hardware(void) 81 | { 82 | // Call the CSMSIS system clock routine to store the clock frequency 83 | // in the SystemCoreClock global RAM location. 84 | SystemCoreClockUpdate(); 85 | } 86 | 87 | // ---------------------------------------------------------------------------- 88 | -------------------------------------------------------------------------------- /Oscilloscope/system/src/cortexm/_reset_hardware.c: -------------------------------------------------------------------------------- 1 | // 2 | // This file is part of the µOS++ III distribution. 3 | // Copyright (c) 2014 Liviu Ionescu. 4 | // 5 | 6 | // ---------------------------------------------------------------------------- 7 | 8 | #include "cmsis_device.h" 9 | 10 | // ---------------------------------------------------------------------------- 11 | 12 | extern void 13 | __attribute__((noreturn)) 14 | NVIC_SystemReset(void); 15 | 16 | // ---------------------------------------------------------------------------- 17 | 18 | // Forward declarations 19 | 20 | void 21 | __reset_hardware(void); 22 | 23 | // ---------------------------------------------------------------------------- 24 | 25 | // This is the default hardware reset routine; it can be 26 | // redefined in the application for more complex applications. 27 | // 28 | // Called from _exit(). 29 | 30 | void 31 | __attribute__((weak,noreturn)) 32 | __reset_hardware() 33 | { 34 | NVIC_SystemReset(); 35 | } 36 | 37 | // ---------------------------------------------------------------------------- 38 | -------------------------------------------------------------------------------- /Oscilloscope/system/src/diag/Trace.c: -------------------------------------------------------------------------------- 1 | // 2 | // This file is part of the µOS++ III distribution. 3 | // Copyright (c) 2014 Liviu Ionescu. 4 | // 5 | 6 | // ---------------------------------------------------------------------------- 7 | 8 | #if defined(TRACE) 9 | 10 | #include 11 | #include 12 | #include "diag/Trace.h" 13 | #include "string.h" 14 | #include "xprintf.h" 15 | 16 | #ifndef OS_INTEGER_TRACE_PRINTF_TMP_ARRAY_SIZE 17 | #define OS_INTEGER_TRACE_PRINTF_TMP_ARRAY_SIZE (128) 18 | #endif 19 | 20 | // ---------------------------------------------------------------------------- 21 | 22 | int 23 | trace_printf(const char* format, ...) 24 | { 25 | int ret; 26 | va_list ap; 27 | 28 | va_start (ap, format); 29 | 30 | // TODO: rewrite it to no longer use newlib, it is way too heavy 31 | 32 | static char buf[OS_INTEGER_TRACE_PRINTF_TMP_ARRAY_SIZE]; 33 | 34 | // Print to the local buffer 35 | ret = xvsprintf (buf, format, ap); 36 | if (ret > 0) 37 | { 38 | // Transfer the buffer to the device 39 | ret = trace_write (buf, (size_t)ret); 40 | } 41 | 42 | va_end (ap); 43 | return ret; 44 | } 45 | 46 | int 47 | trace_puts(const char *s) 48 | { 49 | trace_write(s, strlen(s)); 50 | return trace_write("\n", 1); 51 | } 52 | 53 | int 54 | trace_putchar(int c) 55 | { 56 | trace_write((const char*)&c, 1); 57 | return c; 58 | } 59 | 60 | void 61 | trace_dump_args(int argc, char* argv[]) 62 | { 63 | trace_printf("main(argc=%d, argv=[", argc); 64 | for (int i = 0; i < argc; ++i) 65 | { 66 | if (i != 0) 67 | { 68 | trace_printf(", "); 69 | } 70 | trace_printf("\"%s\"", argv[i]); 71 | } 72 | trace_printf("]);\n"); 73 | } 74 | 75 | // ---------------------------------------------------------------------------- 76 | 77 | #endif // TRACE 78 | -------------------------------------------------------------------------------- /Oscilloscope/system/src/newlib/README.txt: -------------------------------------------------------------------------------- 1 | 2 | The following files extend or replace some of the the newlib functionality: 3 | 4 | _startup.c: a customised startup sequence, written in C 5 | 6 | _exit.c: a customised exit() implementation 7 | 8 | _syscalls.c: local versions of the libnosys/librdimon code 9 | 10 | _sbrk.c: a custom _sbrk() to match the actual linker scripts 11 | 12 | assert.c: implementation for the asserion macros 13 | 14 | _cxx.cpp: local versions of some C++ support, to avoid references to 15 | large functions. 16 | 17 | -------------------------------------------------------------------------------- /Oscilloscope/system/src/newlib/_cxx.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // This file is part of the µOS++ III distribution. 3 | // Copyright (c) 2014 Liviu Ionescu. 4 | // 5 | 6 | // ---------------------------------------------------------------------------- 7 | 8 | // These functions are redefined locally, to avoid references to some 9 | // heavy implementations in the standard C++ library. 10 | 11 | // ---------------------------------------------------------------------------- 12 | 13 | #include 14 | #include 15 | #include "diag/Trace.h" 16 | 17 | // ---------------------------------------------------------------------------- 18 | 19 | namespace __gnu_cxx 20 | { 21 | void 22 | __attribute__((noreturn)) 23 | __verbose_terminate_handler(); 24 | 25 | void 26 | __verbose_terminate_handler() 27 | { 28 | trace_puts(__func__); 29 | abort(); 30 | } 31 | } 32 | 33 | // ---------------------------------------------------------------------------- 34 | 35 | extern "C" 36 | { 37 | void 38 | __attribute__((noreturn)) 39 | __cxa_pure_virtual(); 40 | 41 | void 42 | __cxa_pure_virtual() 43 | { 44 | trace_puts(__func__); 45 | abort(); 46 | } 47 | } 48 | 49 | // ---------------------------------------------------------------------------- 50 | 51 | -------------------------------------------------------------------------------- /Oscilloscope/system/src/newlib/_exit.c: -------------------------------------------------------------------------------- 1 | // 2 | // This file is part of the µOS++ III distribution. 3 | // Copyright (c) 2014 Liviu Ionescu. 4 | // 5 | 6 | // ---------------------------------------------------------------------------- 7 | 8 | #include 9 | #include "diag/Trace.h" 10 | 11 | // ---------------------------------------------------------------------------- 12 | 13 | #if !defined(DEBUG) 14 | extern void 15 | __attribute__((noreturn)) 16 | __reset_hardware(void); 17 | #endif 18 | 19 | // ---------------------------------------------------------------------------- 20 | 21 | // Forward declaration 22 | 23 | void 24 | _exit(int code); 25 | 26 | // ---------------------------------------------------------------------------- 27 | 28 | // On Release, call the hardware reset procedure. 29 | // On Debug we just enter an infinite loop, to be used as landmark when halting 30 | // the debugger. 31 | // 32 | // It can be redefined in the application, if more functionality 33 | // is required. 34 | 35 | void 36 | __attribute__((weak)) 37 | _exit(int code __attribute__((unused))) 38 | { 39 | #if !defined(DEBUG) 40 | __reset_hardware(); 41 | #endif 42 | 43 | // TODO: write on trace 44 | while (1) 45 | ; 46 | } 47 | 48 | // ---------------------------------------------------------------------------- 49 | 50 | void 51 | __attribute__((weak,noreturn)) 52 | abort(void) 53 | { 54 | trace_puts("abort(), exiting..."); 55 | 56 | _exit(1); 57 | } 58 | 59 | // ---------------------------------------------------------------------------- 60 | -------------------------------------------------------------------------------- /Oscilloscope/system/src/newlib/_sbrk.c: -------------------------------------------------------------------------------- 1 | // 2 | // This file is part of the µOS++ III distribution. 3 | // Copyright (c) 2014 Liviu Ionescu. 4 | // 5 | 6 | // ---------------------------------------------------------------------------- 7 | 8 | #include 9 | #include 10 | 11 | // ---------------------------------------------------------------------------- 12 | 13 | caddr_t 14 | _sbrk(int incr); 15 | 16 | // ---------------------------------------------------------------------------- 17 | 18 | // The definitions used here should be kept in sync with the 19 | // stack definitions in the linker script. 20 | 21 | caddr_t 22 | _sbrk(int incr) 23 | { 24 | extern char _Heap_Begin; // Defined by the linker. 25 | extern char _Heap_Limit; // Defined by the linker. 26 | 27 | static char* current_heap_end; 28 | char* current_block_address; 29 | 30 | if (current_heap_end == 0) 31 | { 32 | current_heap_end = &_Heap_Begin; 33 | } 34 | 35 | current_block_address = current_heap_end; 36 | 37 | // Need to align heap to word boundary, else will get 38 | // hard faults on Cortex-M0. So we assume that heap starts on 39 | // word boundary, hence make sure we always add a multiple of 40 | // 4 to it. 41 | incr = (incr + 3) & (~3); // align value to 4 42 | if (current_heap_end + incr > &_Heap_Limit) 43 | { 44 | // Some of the libstdc++-v3 tests rely upon detecting 45 | // out of memory errors, so do not abort here. 46 | #if 0 47 | extern void abort (void); 48 | 49 | _write (1, "_sbrk: Heap and stack collision\n", 32); 50 | 51 | abort (); 52 | #else 53 | // Heap has overflowed 54 | errno = ENOMEM; 55 | return (caddr_t) - 1; 56 | #endif 57 | } 58 | 59 | current_heap_end += incr; 60 | 61 | return (caddr_t) current_block_address; 62 | } 63 | 64 | // ---------------------------------------------------------------------------- 65 | 66 | -------------------------------------------------------------------------------- /Oscilloscope/system/src/newlib/assert.c: -------------------------------------------------------------------------------- 1 | // 2 | // This file is part of the µOS++ III distribution. 3 | // Copyright (c) 2014 Liviu Ionescu. 4 | // 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "diag/Trace.h" 11 | 12 | // ---------------------------------------------------------------------------- 13 | 14 | void 15 | __attribute__((noreturn)) 16 | __assert_func (const char *file, int line, const char *func, 17 | const char *failedexpr) 18 | { 19 | trace_printf ("assertion \"%s\" failed: file \"%s\", line %d%s%s\n", 20 | failedexpr, file, line, func ? ", function: " : "", 21 | func ? func : ""); 22 | abort (); 23 | /* NOTREACHED */ 24 | } 25 | 26 | // ---------------------------------------------------------------------------- 27 | 28 | // This is STM32 specific, but can be used on other platforms too. 29 | // If you need it, add the following to your application header: 30 | 31 | //#ifdef USE_FULL_ASSERT 32 | //#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 33 | //void assert_failed(uint8_t* file, uint32_t line); 34 | //#else 35 | //#define assert_param(expr) ((void)0) 36 | //#endif // USE_FULL_ASSERT 37 | 38 | #if defined(USE_FULL_ASSERT) 39 | 40 | void 41 | assert_failed (uint8_t* file, uint32_t line); 42 | 43 | // Called from the assert_param() macro, usually defined in the stm32f*_conf.h 44 | void 45 | __attribute__((noreturn, weak)) 46 | assert_failed (uint8_t* file, uint32_t line) 47 | { 48 | trace_printf ("assert_param() failed: file \"%s\", line %d\n", file, line); 49 | abort (); 50 | /* NOTREACHED */ 51 | } 52 | 53 | #endif // defined(USE_FULL_ASSERT) 54 | 55 | // ---------------------------------------------------------------------------- 56 | -------------------------------------------------------------------------------- /Oscilloscope/system/src/stm32f1-stdperiph/README_STDPERIPH.txt: -------------------------------------------------------------------------------- 1 | These files are from stsw-stm32054.zip, the folder: 2 | 3 | STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/src 4 | 5 | -------------------------------------------------------------------------------- /Oscilloscope/system/src/stm32f1-stdperiph/stm32f10x_crc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_crc.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the CRC firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_crc.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup CRC 30 | * @brief CRC driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup CRC_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @} 40 | */ 41 | 42 | /** @defgroup CRC_Private_Defines 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup CRC_Private_Macros 51 | * @{ 52 | */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /** @defgroup CRC_Private_Variables 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup CRC_Private_FunctionPrototypes 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup CRC_Private_Functions 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @brief Resets the CRC Data register (DR). 80 | * @param None 81 | * @retval None 82 | */ 83 | void CRC_ResetDR(void) 84 | { 85 | /* Reset CRC generator */ 86 | CRC->CR = CRC_CR_RESET; 87 | } 88 | 89 | /** 90 | * @brief Computes the 32-bit CRC of a given data word(32-bit). 91 | * @param Data: data word(32-bit) to compute its CRC 92 | * @retval 32-bit CRC 93 | */ 94 | uint32_t CRC_CalcCRC(uint32_t Data) 95 | { 96 | CRC->DR = Data; 97 | 98 | return (CRC->DR); 99 | } 100 | 101 | /** 102 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit). 103 | * @param pBuffer: pointer to the buffer containing the data to be computed 104 | * @param BufferLength: length of the buffer to be computed 105 | * @retval 32-bit CRC 106 | */ 107 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength) 108 | { 109 | uint32_t index = 0; 110 | 111 | for(index = 0; index < BufferLength; index++) 112 | { 113 | CRC->DR = pBuffer[index]; 114 | } 115 | return (CRC->DR); 116 | } 117 | 118 | /** 119 | * @brief Returns the current CRC value. 120 | * @param None 121 | * @retval 32-bit CRC 122 | */ 123 | uint32_t CRC_GetCRC(void) 124 | { 125 | return (CRC->DR); 126 | } 127 | 128 | /** 129 | * @brief Stores a 8-bit data in the Independent Data(ID) register. 130 | * @param IDValue: 8-bit value to be stored in the ID register 131 | * @retval None 132 | */ 133 | void CRC_SetIDRegister(uint8_t IDValue) 134 | { 135 | CRC->IDR = IDValue; 136 | } 137 | 138 | /** 139 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register 140 | * @param None 141 | * @retval 8-bit value of the ID register 142 | */ 143 | uint8_t CRC_GetIDRegister(void) 144 | { 145 | return (CRC->IDR); 146 | } 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /** 153 | * @} 154 | */ 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 161 | -------------------------------------------------------------------------------- /Oscilloscope/usblibs/include/usb_def.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : usb_def.h 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : Definitions related to USB Core 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_DEF_H 18 | #define __USB_DEF_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | /* Exported types ------------------------------------------------------------*/ 22 | typedef enum _RECIPIENT_TYPE 23 | { 24 | DEVICE_RECIPIENT, /* Recipient device */ 25 | INTERFACE_RECIPIENT, /* Recipient interface */ 26 | ENDPOINT_RECIPIENT, /* Recipient endpoint */ 27 | OTHER_RECIPIENT 28 | } RECIPIENT_TYPE; 29 | 30 | 31 | typedef enum _STANDARD_REQUESTS 32 | { 33 | GET_STATUS = 0, 34 | CLEAR_FEATURE, 35 | RESERVED1, 36 | SET_FEATURE, 37 | RESERVED2, 38 | SET_ADDRESS, 39 | GET_DESCRIPTOR, 40 | SET_DESCRIPTOR, 41 | GET_CONFIGURATION, 42 | SET_CONFIGURATION, 43 | GET_INTERFACE, 44 | SET_INTERFACE, 45 | TOTAL_sREQUEST, /* Total number of Standard request */ 46 | SYNCH_FRAME = 12 47 | } STANDARD_REQUESTS; 48 | 49 | /* Definition of "USBwValue" */ 50 | typedef enum _DESCRIPTOR_TYPE 51 | { 52 | DEVICE_DESCRIPTOR = 1, 53 | CONFIG_DESCRIPTOR, 54 | STRING_DESCRIPTOR, 55 | INTERFACE_DESCRIPTOR, 56 | ENDPOINT_DESCRIPTOR 57 | } DESCRIPTOR_TYPE; 58 | 59 | /* Feature selector of a SET_FEATURE or CLEAR_FEATURE */ 60 | typedef enum _FEATURE_SELECTOR 61 | { 62 | ENDPOINT_STALL, 63 | DEVICE_REMOTE_WAKEUP 64 | } FEATURE_SELECTOR; 65 | 66 | /* Exported constants --------------------------------------------------------*/ 67 | /* Definition of "USBbmRequestType" */ 68 | #define REQUEST_TYPE 0x60 /* Mask to get request type */ 69 | #define STANDARD_REQUEST 0x00 /* Standard request */ 70 | #define CLASS_REQUEST 0x20 /* Class request */ 71 | #define VENDOR_REQUEST 0x40 /* Vendor request */ 72 | 73 | #define RECIPIENT 0x1F /* Mask to get recipient */ 74 | 75 | /* Exported macro ------------------------------------------------------------*/ 76 | /* Exported functions ------------------------------------------------------- */ 77 | 78 | #endif /* __USB_DEF_H */ 79 | 80 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 81 | -------------------------------------------------------------------------------- /Oscilloscope/usblibs/include/usb_init.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : usb_init.h 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : Initialization routines & global variables 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_INIT_H 18 | #define __USB_INIT_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | /* Exported types ------------------------------------------------------------*/ 22 | /* Exported constants --------------------------------------------------------*/ 23 | /* Exported macro ------------------------------------------------------------*/ 24 | /* Exported functions ------------------------------------------------------- */ 25 | void USB_Init(void); 26 | 27 | /* External variables --------------------------------------------------------*/ 28 | /* The number of current endpoint, it will be used to specify an endpoint */ 29 | extern uint8_t EPindex; 30 | /* The number of current device, it is an index to the Device_Table */ 31 | /*extern uint8_t Device_no; */ 32 | /* Points to the DEVICE_INFO structure of current device */ 33 | /* The purpose of this register is to speed up the execution */ 34 | extern DEVICE_INFO* pInformation; 35 | /* Points to the DEVICE_PROP structure of current device */ 36 | /* The purpose of this register is to speed up the execution */ 37 | extern DEVICE_PROP* pProperty; 38 | /* Temporary save the state of Rx & Tx status. */ 39 | /* Whenever the Rx or Tx state is changed, its value is saved */ 40 | /* in this variable first and will be set to the EPRB or EPRA */ 41 | /* at the end of interrupt process */ 42 | extern USER_STANDARD_REQUESTS *pUser_Standard_Requests; 43 | 44 | extern uint16_t SaveState ; 45 | extern uint16_t wInterrupt_Mask; 46 | 47 | #endif /* __USB_INIT_H */ 48 | 49 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 50 | -------------------------------------------------------------------------------- /Oscilloscope/usblibs/include/usb_int.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : usb_int.h 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : Endpoint CTR (Low and High) interrupt's service routines 7 | * prototypes 8 | ******************************************************************************** 9 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 10 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 11 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 12 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 13 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 14 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 15 | *******************************************************************************/ 16 | 17 | /* Define to prevent recursive inclusion -------------------------------------*/ 18 | #ifndef __USB_INT_H 19 | #define __USB_INT_H 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | /* Exported types ------------------------------------------------------------*/ 23 | /* Exported constants --------------------------------------------------------*/ 24 | /* Exported macro ------------------------------------------------------------*/ 25 | /* Exported functions ------------------------------------------------------- */ 26 | void CTR_LP(void); 27 | void CTR_HP(void); 28 | 29 | /* External variables --------------------------------------------------------*/ 30 | 31 | #endif /* __USB_INT_H */ 32 | 33 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 34 | -------------------------------------------------------------------------------- /Oscilloscope/usblibs/include/usb_lib.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : usb_lib.h 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : USB library include files 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_LIB_H 18 | #define __USB_LIB_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #ifdef STM32L1XX_MD 22 | #include "stm32l1xx.h" 23 | #else 24 | #include "stm32f10x.h" 25 | #endif /* STM32L1XX_MD */ 26 | 27 | #include "usb_type.h" 28 | #include "usb_regs.h" 29 | #include "usb_def.h" 30 | #include "usb_core.h" 31 | #include "usb_init.h" 32 | #ifndef STM32F10X_CL 33 | #include "usb_mem.h" 34 | #include "usb_int.h" 35 | #endif /* STM32F10X_CL */ 36 | 37 | #include "usb_sil.h" 38 | 39 | #ifdef STM32F10X_CL 40 | #include "otgd_fs_cal.h" 41 | #include "otgd_fs_pcd.h" 42 | #include "otgd_fs_dev.h" 43 | #include "otgd_fs_int.h" 44 | #endif /* STM32F10X_CL */ 45 | 46 | 47 | /* Exported types ------------------------------------------------------------*/ 48 | /* Exported constants --------------------------------------------------------*/ 49 | /* Exported macro ------------------------------------------------------------*/ 50 | /* Exported functions ------------------------------------------------------- */ 51 | /* External variables --------------------------------------------------------*/ 52 | 53 | #endif /* __USB_LIB_H */ 54 | 55 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 56 | -------------------------------------------------------------------------------- /Oscilloscope/usblibs/include/usb_mem.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : usb_mem.h 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : Utility prototypes functions for memory/PMA transfers 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_MEM_H 18 | #define __USB_MEM_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | /* Exported types ------------------------------------------------------------*/ 22 | /* Exported constants --------------------------------------------------------*/ 23 | /* Exported macro ------------------------------------------------------------*/ 24 | /* Exported functions ------------------------------------------------------- */ 25 | void UserToPMABufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes); 26 | void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes); 27 | 28 | /* External variables --------------------------------------------------------*/ 29 | 30 | #endif /*__USB_MEM_H*/ 31 | 32 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 33 | -------------------------------------------------------------------------------- /Oscilloscope/usblibs/include/usb_sil.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : usb_sil.h 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : Simplified Interface Layer function prototypes. 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_SIL_H 18 | #define __USB_SIL_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | /* Exported types ------------------------------------------------------------*/ 22 | /* Exported constants --------------------------------------------------------*/ 23 | /* Exported macro ------------------------------------------------------------*/ 24 | /* Exported functions ------------------------------------------------------- */ 25 | 26 | uint32_t USB_SIL_Init(void); 27 | uint32_t USB_SIL_Write(uint8_t bEpAddr, uint8_t* pBufferPointer, uint32_t wBufferSize); 28 | uint32_t USB_SIL_Read(uint8_t bEpAddr, uint8_t* pBufferPointer); 29 | 30 | /* External variables --------------------------------------------------------*/ 31 | 32 | #endif /* __USB_SIL_H */ 33 | 34 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 35 | -------------------------------------------------------------------------------- /Oscilloscope/usblibs/include/usb_type.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : usb_type.h 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : Type definitions used by the USB Library 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_TYPE_H 18 | #define __USB_TYPE_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "usb_conf.h" 22 | 23 | /* Exported types ------------------------------------------------------------*/ 24 | /* Exported constants --------------------------------------------------------*/ 25 | #ifndef NULL 26 | #define NULL ((void *)0) 27 | #endif 28 | 29 | #if !defined (__STM32F10x_H) && !defined(__STM32L1XX_H) 30 | 31 | typedef signed long s32; 32 | typedef signed short s16; 33 | typedef signed char s8; 34 | 35 | typedef volatile signed long vs32; 36 | typedef volatile signed short vs16; 37 | typedef volatile signed char vs8; 38 | 39 | typedef unsigned long u32; 40 | typedef unsigned short u16; 41 | typedef unsigned char u8; 42 | 43 | typedef unsigned long const uc32; /* Read Only */ 44 | typedef unsigned short const uc16; /* Read Only */ 45 | typedef unsigned char const uc8; /* Read Only */ 46 | 47 | typedef volatile unsigned long vu32; 48 | typedef volatile unsigned short vu16; 49 | typedef volatile unsigned char vu8; 50 | 51 | typedef volatile unsigned long const vuc32; /* Read Only */ 52 | typedef volatile unsigned short const vuc16; /* Read Only */ 53 | typedef volatile unsigned char const vuc8; /* Read Only */ 54 | 55 | typedef enum { RESET = 0, SET = !RESET } FlagStatus, ITStatus; 56 | 57 | typedef enum { DISABLE = 0, ENABLE = !DISABLE} FunctionalState; 58 | 59 | typedef enum { ERROR = 0, SUCCESS = !ERROR} ErrorStatus; 60 | #endif /* __STM32F10x_H && __STM32L15x_H */ 61 | 62 | #ifndef __cplusplus 63 | 64 | typedef enum 65 | { 66 | FALSE = 0, TRUE = !FALSE 67 | } 68 | bool; 69 | 70 | #endif 71 | 72 | /* Exported macro ------------------------------------------------------------*/ 73 | /* Exported functions ------------------------------------------------------- */ 74 | /* External variables --------------------------------------------------------*/ 75 | 76 | #endif /* __USB_TYPE_H */ 77 | 78 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 79 | -------------------------------------------------------------------------------- /Oscilloscope/usblibs/scripts/serialread.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use IO::Handle; 6 | use threads; 7 | use threads::shared; 8 | 9 | use Data::Dumper; 10 | 11 | my $device = shift @ARGV; 12 | my $file = shift @ARGV; 13 | 14 | if( ! defined $file || ! defined $device ) 15 | { 16 | print STDERR "Usage: serialread.pl /dev/ttyACM0 outfile.txt\n"; 17 | exit(0); 18 | } 19 | 20 | system("stty -F $device raw"); 21 | 22 | my @chunks : shared; 23 | my $threadRunning : shared = 1; 24 | 25 | open( DH, "<", $device ) or die "Can't open device for read: $!\n"; 26 | binmode DH; 27 | 28 | my $thread = threads->create( 29 | sub { 30 | my $printed = 0; 31 | 32 | open( FH, ">", $file ) or die "Can't open file for write: $!\n"; 33 | binmode FH; 34 | 35 | while($threadRunning) 36 | { 37 | my $data = shift @chunks; 38 | if( defined $data ) 39 | { 40 | print FH "$data"; 41 | $printed = 1; 42 | } 43 | elsif( $printed ) 44 | { 45 | FH->flush(); 46 | $printed = 0; 47 | } 48 | } 49 | 50 | close FH; 51 | } 52 | ); 53 | 54 | 55 | my $bufsize = 20_000_000; 56 | my $buffer; 57 | 58 | while ( my $read = sysread(DH , $buffer , $bufsize) ) 59 | { 60 | push @chunks, $buffer; 61 | } 62 | 63 | close DH; 64 | 65 | while( @chunks ) {} 66 | 67 | $threadRunning = 0; 68 | $thread->join(); 69 | -------------------------------------------------------------------------------- /Oscilloscope/usblibs/scripts/usbtowav.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Data::Dumper; 7 | 8 | my $infile = shift @ARGV; 9 | my $outfile = shift @ARGV; 10 | 11 | die "Usage: usbtowav.pl" if ! $infile || ! $outfile; 12 | 13 | my $filesize = -s $infile; 14 | 15 | open( FH, "<", $infile ) or die "Can't open file to read: $!"; 16 | 17 | my $line = ; 18 | die "Invalid file format!" if $line !~ /Bits: (\d+)/; 19 | my $bits = $1; 20 | 21 | $line = ; 22 | die "Invalid file format!" if $line !~ /Channels: (\d+)/; 23 | my $channels = $1; 24 | 25 | $line = ; 26 | die "Invalid file format!" if $line !~ /Period: (\d+)/; 27 | my $rate = $1; 28 | 29 | $line = ; 30 | die "Invalid file format!" if ! $line; 31 | 32 | my $pos = tell(FH); 33 | 34 | my $samples = $filesize - $pos; 35 | 36 | my $samplesize = 2; 37 | $samplesize = 3 if $bits == 12; 38 | $samplesize *= 2 if $channels == 2; 39 | 40 | $samples *= 2; 41 | $samples /= $samplesize; 42 | $samples = int($samples); 43 | 44 | binmode FH; 45 | 46 | open( WH, ">", $outfile ) or die "Can't open file to write: $!"; 47 | binmode WH; 48 | 49 | print WH "RIFF"; 50 | 51 | my $wavfilesize = $samples; 52 | $wavfilesize *= 2 if $bits == 12; 53 | $wavfilesize *= 2 if $channels == 2; 54 | 55 | print WH pack("V", $wavfilesize + 44 - 8); 56 | print WH "WAVEfmt "; 57 | print WH pack("V", 16); # chunk size 58 | print WH pack("v", 1); # PCM 59 | print WH pack("v", $channels); # number of channels 60 | 61 | my @validfreqlist = (384000, 352800, 192000, 176400, 96000, 88200, 48000, 44100, 22050, 16000, 11025, 8000); 62 | my $freq = 1000000000 / $rate; 63 | 64 | my @dist = map { [ $_, abs($_ - $freq) ] } @validfreqlist; 65 | @dist = sort { $a->[1] <=> $b->[1] } @dist; 66 | 67 | $freq = $dist[0][0]; 68 | 69 | print WH pack("V", $freq); # chunk size 70 | 71 | my $bytesPerSample = (($bits == 12) ? 2 : 1); 72 | my $byteRate = $freq * $channels * $bytesPerSample; 73 | 74 | print WH pack("V", $byteRate); # chunk size 75 | print WH pack("v", $bytesPerSample); # bytes for a sample 76 | print WH pack("v", 8 * $bytesPerSample); # bytes for a sample 77 | print WH 'data'; 78 | print WH pack("V", $wavfilesize); 79 | 80 | my $remaining = ''; 81 | my $buffer; 82 | while( sysread(FH , $buffer , 4096) ) 83 | { 84 | process_buffer( $buffer); 85 | } 86 | 87 | close FH; 88 | close WH; 89 | 90 | 91 | 92 | sub process_buffer 93 | { 94 | my ($buffer) = @_; 95 | 96 | $buffer = $remaining . $buffer; 97 | 98 | if( $bits == 12 ) 99 | { 100 | while( length($buffer) >= 3 ) 101 | { 102 | my $byte1 = ord( substr($buffer, 0, 1)); 103 | my $byte2 = ord( substr($buffer, 1, 1)); 104 | my $byte3 = ord( substr($buffer, 2, 1)); 105 | 106 | my $ch1 = 16 * (($byte1 << 4) + ($byte2 >> 4) - 0x800); 107 | my $ch2 = 16 * ((($byte2 & 15) << 8) + $byte3 - 0x800); 108 | print WH pack("v", $ch1); 109 | print WH pack("v", $ch2); 110 | substr($buffer, 0, 3) = ''; 111 | } 112 | } 113 | else 114 | { 115 | if( $channels == 1 ) 116 | { 117 | while( length($buffer) >= 1 ) 118 | { 119 | print WH substr($buffer, 0, 1); 120 | substr($buffer, 0, 1) = ''; 121 | } 122 | } 123 | else 124 | { 125 | while( length($buffer) >= 2 ) 126 | { 127 | print WH substr($buffer, 0, 2); 128 | substr($buffer, 0, 2) = ''; 129 | } 130 | } 131 | } 132 | 133 | $remaining = $buffer; 134 | } 135 | -------------------------------------------------------------------------------- /Oscilloscope/usblibs/src/usb_init.c: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : usb_init.c 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : Initialization routines & global variables 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Includes ------------------------------------------------------------------*/ 17 | #include "usb_lib.h" 18 | 19 | /* Private typedef -----------------------------------------------------------*/ 20 | /* Private define ------------------------------------------------------------*/ 21 | /* Private macro -------------------------------------------------------------*/ 22 | /* Private variables ---------------------------------------------------------*/ 23 | /* The number of current endpoint, it will be used to specify an endpoint */ 24 | uint8_t EPindex; 25 | /* The number of current device, it is an index to the Device_Table */ 26 | /* uint8_t Device_no; */ 27 | /* Points to the DEVICE_INFO structure of current device */ 28 | /* The purpose of this register is to speed up the execution */ 29 | DEVICE_INFO *pInformation; 30 | /* Points to the DEVICE_PROP structure of current device */ 31 | /* The purpose of this register is to speed up the execution */ 32 | DEVICE_PROP *pProperty; 33 | /* Temporary save the state of Rx & Tx status. */ 34 | /* Whenever the Rx or Tx state is changed, its value is saved */ 35 | /* in this variable first and will be set to the EPRB or EPRA */ 36 | /* at the end of interrupt process */ 37 | uint16_t SaveState ; 38 | uint16_t wInterrupt_Mask; 39 | DEVICE_INFO Device_Info; 40 | USER_STANDARD_REQUESTS *pUser_Standard_Requests; 41 | 42 | /* Extern variables ----------------------------------------------------------*/ 43 | /* Private function prototypes -----------------------------------------------*/ 44 | /* Private functions ---------------------------------------------------------*/ 45 | 46 | /******************************************************************************* 47 | * Function Name : USB_Init 48 | * Description : USB system initialization 49 | * Input : None. 50 | * Output : None. 51 | * Return : None. 52 | *******************************************************************************/ 53 | void USB_Init(void) 54 | { 55 | pInformation = &Device_Info; 56 | pInformation->ControlState = 2; 57 | pProperty = &Device_Property; 58 | pUser_Standard_Requests = &User_Standard_Requests; 59 | /* Initialize devices one by one */ 60 | pProperty->Init(); 61 | } 62 | 63 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 64 | -------------------------------------------------------------------------------- /Oscilloscope/usblibs/src/usb_mem.c: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : usb_mem.c 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : Utility functions for memory transfers to/from PMA 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | #ifndef STM32F10X_CL 16 | 17 | /* Includes ------------------------------------------------------------------*/ 18 | #include "usb_lib.h" 19 | 20 | /* Private typedef -----------------------------------------------------------*/ 21 | /* Private define ------------------------------------------------------------*/ 22 | /* Private macro -------------------------------------------------------------*/ 23 | /* Private variables ---------------------------------------------------------*/ 24 | /* Extern variables ----------------------------------------------------------*/ 25 | /* Private function prototypes -----------------------------------------------*/ 26 | /* Private functions ---------------------------------------------------------*/ 27 | /******************************************************************************* 28 | * Function Name : UserToPMABufferCopy 29 | * Description : Copy a buffer from user memory area to packet memory area (PMA) 30 | * Input : - pbUsrBuf: pointer to user memory area. 31 | * - wPMABufAddr: address into PMA. 32 | * - wNBytes: no. of bytes to be copied. 33 | * Output : None. 34 | * Return : None . 35 | *******************************************************************************/ 36 | void UserToPMABufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) 37 | { 38 | uint32_t n = (wNBytes + 1) >> 1; /* n = (wNBytes + 1) / 2 */ 39 | uint32_t i, temp1, temp2; 40 | uint16_t *pdwVal; 41 | pdwVal = (uint16_t *)(wPMABufAddr * 2 + PMAAddr); 42 | for (i = n; i != 0; i--) 43 | { 44 | temp1 = (uint16_t) * pbUsrBuf; 45 | pbUsrBuf++; 46 | temp2 = temp1 | (uint16_t) * pbUsrBuf << 8; 47 | *pdwVal++ = temp2; 48 | pdwVal++; 49 | pbUsrBuf++; 50 | } 51 | } 52 | /******************************************************************************* 53 | * Function Name : PMAToUserBufferCopy 54 | * Description : Copy a buffer from user memory area to packet memory area (PMA) 55 | * Input : - pbUsrBuf = pointer to user memory area. 56 | * - wPMABufAddr = address into PMA. 57 | * - wNBytes = no. of bytes to be copied. 58 | * Output : None. 59 | * Return : None. 60 | *******************************************************************************/ 61 | void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) 62 | { 63 | uint32_t n = (wNBytes + 1) >> 1;/* /2*/ 64 | uint32_t i; 65 | uint32_t *pdwVal; 66 | pdwVal = (uint32_t *)(wPMABufAddr * 2 + PMAAddr); 67 | for (i = n; i != 0; i--) 68 | { 69 | *(uint16_t*)pbUsrBuf++ = *pdwVal++; 70 | pbUsrBuf++; 71 | } 72 | } 73 | 74 | #endif /* STM32F10X_CL */ 75 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 76 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Csabiscope 2 | 3 | Csabiscope is an STM32 oscilloscope project, using STM32F103C8T6 IC. 4 | 5 | Supported features: 6 | - drawing oscilloscope screen 7 | - calculating min/max/effective values 8 | - calculating frequency 9 | - single or dual channel sampling upto 1.25 MHz 10 | - triggers (rising/falling edge, change, min peak, max peak, external) 11 | - optional sampling before trigger, configurable 12 | - hardware amplification ( 1x, 2x, 4x, 5x, 8x, 10x, 16x, 32x ) 13 | - AC decoupling switch 14 | - FFT 15 | - USB data transfer up to 833 kbyte/s 16 | - configurable test square signal (PWM degrades sampling quality) 17 | - saving configuration onto flash 18 | --------------------------------------------------------------------------------